Documentation
¶
Overview ¶
Package artifact defines how the engine NAMES a stored artifact. An artifact is a design, a board export, a datasheet, a checklist, or anything else the injected Loader resolves to bytes.
A name is one string, in one field.
mount://boards/designs/gateway/gateway.edn
It replaces a `(mount, path)` pair that 24 request messages carried as two fields (#179).
Why the authority is always `mount` ¶
Not `s3://` or `db://`. The authority is the mount NAME, a key in a server-defined namespace, and the deployment decides what it resolves to. A per-store scheme would put the storage kind in the client's hands. The Loader and ProjectStore ports exist to prevent that.
Why a URI rather than a path ¶
The mount is the containment boundary and `..` cannot escape it. Related files resolve against each other through one specified operation, such as a KiCad schematic naming its sub-sheets or a symbol library referenced from inside a file. A URI path is always slash-separated. `formats.Loader` warns about a platform-separator split, and that split cannot break a sibling lookup on Windows.
Grouping is NOT expressed here. A design's relationship to its board companion is DECLARED in a `design.yaml`, not encoded in a path or inferred from a stem.
Index ¶
Constants ¶
const Scheme = "mount"
Scheme is the only scheme an artifact URI uses. See the package doc for why it is fixed.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type URI ¶
type URI struct {
// Mount is the authority, a key in a server-defined namespace and never a host path.
Mount string
// Path is the mount-relative path, cleaned, slash-separated, with no leading slash. The mount
// ROOT is the empty string. A directory listing of a whole mount asks for that path.
Path string
}
URI is a parsed artifact URI. It holds its mount and the mount-relative path within that mount.
A parsed URI is a CONTAINED one. Parse rejects anything that escapes its mount, so callers can pass a value of this type around without re-checking containment.
func New ¶
New builds a URI from a mount and a mount-relative path, applying the same containment rules as Parse. Code holding the two halves calls it, such as an adapter reading a config flag or a test. That code then cannot assemble a string that Parse would reject.
func Parse ¶
Parse reads an artifact URI.
Parse refuses a bare path, an absolute path, a different scheme, and a path escaping its mount. Each is an error rather than a best-effort reading, because this is the containment boundary. A permissive parse here is a path traversal everywhere above it. The error names the broken rule, since these arrive from a wire and a client needs to fix its own call.
func (URI) Base ¶
Base returns the final path element, the way path.Base does, and "" for a mount root.
func (URI) Dir ¶
Dir returns the URI of the directory containing this one, or the mount root for a top-level entry.
func (URI) IsZero ¶
IsZero reports whether the URI names nothing. An absent optional field reads as a zero URI.
func (URI) Resolve ¶
Resolve returns the URI naming `rel` interpreted RELATIVE to this one, the way a browser resolves a relative href against the page it is on.
A reader calls this when a schematic names its sub-sheets or a symbol library. A reference is resolved against this URI's DIRECTORY, so resolving "sub/sheet1.kicad_sch" against ".../designs/gateway/gateway.kicad_sch" yields ".../designs/gateway/sub/sheet1.kicad_sch".
A result outside the mount is an error, so a file naming "../../etc/passwd" cannot leave the mount it was read from.