Documentation
¶
Overview ¶
Package artifact defines how the engine NAMES a stored artifact: a design, a board export, a datasheet, a checklist, anything the injected Loader resolves to bytes.
One string, 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 what it resolves to is the deployment's business. A per-store scheme would put the storage kind in the client's hands, which the Loader and ProjectStore ports exist to prevent.
Why a URI rather than a path ¶
The mount is the containment boundary and `..` cannot escape it. Relative resolution between related files (a KiCad schematic naming its sub-sheets, a symbol library referenced from inside a file) becomes one specified operation, and a URI path is always slash-separated, so the platform-separator split `formats.Loader` warns about 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, 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, as a directory listing of a whole mount asks for.
Path string
}
URI is a parsed artifact URI: the mount it lives in, and the mount-relative path within it.
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. It exists so code holding the two halves (an adapter reading a config flag, a test) cannot assemble a string that Parse would then reject.
func Parse ¶
Parse reads an artifact URI.
A bare path, an absolute path, a different scheme, or a path escaping its mount are all errors rather than best-effort readings, because this is the containment boundary and 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, which is how an absent optional field reads.
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.