@inventarch/db 3.5.1 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -36,7 +36,7 @@ try {
36
36
  }
37
37
  ```
38
38
 
39
- `open` admits the workspace once. `resolveScope` issues an opaque token, and every read that passes it as `within` stays inside that scope. Band 100 marks a record the workspace authors. `cache: false` makes the open fully read-only. Without it, the handle keeps a disposable graph cache at `.ia/.iadb/graph.json`; a handle opened with `checks: 'structural'` or `evidence: true` never reads or writes that cache. The `.ia/.gitignore` that `ia init` writes does not list `.iadb/`, so add it to your ignore file.
39
+ `open` admits the workspace once. `resolveScope` issues an opaque token, and every read that passes it as `within` stays inside that scope. A handle holds the 4,096 ordinary scopes most recently issued or read, so a token left unread past that refuses with `IA-DB-STALE`, as one does once its sources change: issue a new scope. A scope issued with `pinned: true` sits outside that bound and stays until the sources change or the handle closes. Only a host holding the handle can pin, and nothing limits how many it does, so pin only what you can count. Band 100 marks a record the workspace authors. `cache: false` makes the open fully read-only. Without it, the handle keeps a disposable graph cache at `.ia/.iadb/graph.json`; a handle opened with `checks: 'structural'` or `evidence: true` never reads or writes that cache. The `.ia/.gitignore` that `ia init` writes does not list `.iadb/`, so add it to your ignore file.
40
40
 
41
41
  ## 🧭 What it does
42
42
 
package/SPEC.md CHANGED
@@ -30,7 +30,7 @@ The public `@inventarch/db/descriptors` entrypoint owns the pure, bounded, versi
30
30
 
31
31
  ## Distribution implementation packet
32
32
 
33
- The public `@inventarch/db/distribution` entrypoint owns strict version-1 transport decoders and canonical bytes for release descriptors/manifests, portable locks, generation membership and activation pointers. JSON rejects duplicate decoded keys and unknown fields; object input must be bounded plain data without accessors or aliases. Native parsing stays in language. Package IDs are provider-qualified lowercase `provider/name`; versions and ranges use pinned SemVer. No absolute path or credential enters a portable lock. Metadata limits are 4 MiB, 128 selected bundles and 10,000 files, beside separate archive/file ceilings. Decoding copies and freezes output. A release descriptor's `distribution` is its one optional key (2026-10-09): a workspace that releases nothing, as one a default `ia init` creates, omits it, and the decoded `ReleaseDescriptor` then has no `distribution` property; present, it must still be a native distribution identity, never null. A bundle manifest always carries one, and its decoded keys keep their order, so canonical bytes are unchanged.
33
+ The public `@inventarch/db/distribution` entrypoint owns strict version-1 transport decoders and canonical bytes for release descriptors/manifests, portable locks, generation membership and activation pointers. JSON rejects duplicate decoded keys and unknown fields; object input must be bounded plain data without accessors or aliases. Native parsing stays in language. Package IDs are provider-qualified lowercase `provider/name`; versions and ranges use pinned SemVer. `commonRange(a, b)` returns a range accepting exactly what both ranges accept, or null when it cannot write one: the narrower of two nested ranges as spelled when it admits no prerelease, otherwise the sorted conjunction of their comparators, and null for a prerelease in a conjunction or a result past the 256-character range limit. No absolute path or credential enters a portable lock. Metadata limits are 4 MiB, 128 selected bundles and 10,000 files, beside separate archive/file ceilings. Decoding copies and freezes output. A release descriptor's `distribution` is its one optional key (2026-10-09): a workspace that releases nothing, as one a default `ia init` creates, omits it, and the decoded `ReleaseDescriptor` then has no `distribution` property; present, it must still be a native distribution identity, never null. A bundle manifest always carries one, and its decoded keys keep their order, so canonical bytes are unchanged.
34
34
 
35
35
  The same entrypoint shapes the installed-implementation catalog a host payload carries: `checkInstalledImplementations(value)` admits exactly `format` `ia.installed-implementations.v1`, an `evaluators` section with an `ia-evaluator-catalog/1.x` format and at most 1,024 entries, and at most 1,024 `operations` sorted by id and unique, each `available` (id, version, operation identity, handler, input and output validator ids, a portable `runtime/node_modules/...` handler module inside one of its sorted `packages`, and the module's SHA-256), `unavailable` or `revoked` with a single-line reason, and returns the value or the first reason it is not one; it reads, loads and executes nothing. `@inventarch/distribution` verifies a catalog against its payload with it and `@inventarch/workspace-runtime` binds records against its rows (`InstalledOperation`).
36
36
 
@@ -54,7 +54,7 @@ D02. Default authored sources use band100, empty reach and workspace provenance.
54
54
 
55
55
  D02a. Capture membership. `Snapshot.membership` holds one frozen row `{identity, root, band, digest}` per record in `records`, in the same identity order: `band` is the record's placement band and `digest` its graph G13 per-record digest. The capture declares roots once, from the `@workspace` records the root view (location '', no phase) admits: each `composition.sources` entry spelled `<root> @<placement>` declares that root at that placement, read relative to the tree holding the declaring record (the directory above its `.ia/src`, which the exported `sourceTree(path)` names: '' for the workspace's own tree, a package's or an installed store's directory, and an adopted mount's `.ia/adopted/<id>/<revision>` label), so an adopted or installed `@workspace` speaks only for its own mount. An entry that does not parse, names an unknown placement, or is absolute or escapes that tree declares nothing (`inertDeclarations` names it, D02b), and so does a `@workspace` the root view does not admit (one whose reach excludes the root). A record's `root` is the longest declared root at the record's own placement that contains its source path; the record is then a member of every `@workspace` declaring that root. That is composition, not an edge row or a field index. Any other record keeps its system seat: the `systemMember` system folder of its path, whether local, package, adopted (`.ia/adopted/<id>/<revision>/…`) or installed (`.ia/distributions/store/<archive>/…`). A record under `.ia/src/floor/` is rooted at `.ia/src/floor`, and any other record outside every system folder (the generated installation workspace) at its source directory, so floor records read `.ia/src/floor` at band 10 unless a workspace declares a root containing them at `@floor`. Each view's rows come from its admitted winners: shadowed, tied, blocked, refused and inactive (out-of-reach or out-of-phase) occurrences, and records admission removed, are not admitted records and have no row. A row depends only on its occurrence and the capture's declared roots, so every view admitting an occurrence gives it the same row: a scope narrowed by identities, root or phase prunes rows and never re-roots one, although a narrower root or phase can admit another occurrence of an identity, whose row is its own. The input model cannot express two cases: an adopted closure named by locator (`<distribution-id>@<digest>`) is not a path, so such a `sources` entry declares no root and adopted and installed records keep their system seats; and nothing seats a record by anything but its path and placement. Membership and per-record digests are not revision inputs, so workspace revisions are unchanged. The runtime Door's MACHINE_PROTOCOL version 1 `records` operation omits `membership`.
56
56
 
57
- D02b. Location seat. `resolveSeat(path, options)` on every reader returns a frozen `SeatResolution` `{path, seat?, by?, claimants, unknown?}`. `path` is canonicalized as a scope root with `\` read as `/`; an absolute path, or one escaping the workspace, comes back as supplied with `unknown: 'outside'` and no claimants. Otherwise the seat is the first that applies, and `by` names which: `system`, the admitted `@system` of the system folder that holds the path or is the path, as `systemMember` reads local, package, adopted and installed folders, and the floor's `@system` for `.ia/src/floor`; `root`, the `@workspace` declaring the longest D02a root that contains the path, at any placement, ties by workspace identity; `repository`, for a path with no `.ia` segment, the repository's own `@workspace`. The capture decides that workspace once, from the root view. The sole admitted `@workspace` at the init entry point `.ia/src/workspace.ia` is the repository's own, whether or not it declares sources; several workspaces at that entry point decide none. When no workspace is admitted at that exact path, preserve the existing fallback: the one admitted `@workspace` in the repository's `.ia/src` tree that declares a root, else the only `@workspace` there; none or several decide none. An adopted or package-local `workspace.ia` is not this entry point. This preference identifies the repository without granting any source membership or mandate authority: other workspaces still declare their own roots, and scope pruning never substitutes a different repository workspace. With no seat, `unknown` is `undeclared`. `claimants` are graph G06c's claimants of the path, whatever the seat: each record whose `authority.covers`, `subject.covers`, `work.covers`, `hook.paths` or `check.covers` selection selects it (a `@check`'s textual `check.scope` claims nothing), with every matching field and selection, band descending then identity ascending; the graph indexes the selections once per load, so claimants are read from that index, never from the records, and the seat from the graph's name and discriminator indexes and the capture's declared roots. `options` bind as `get` binds them (CLOSED, STALE, SCOPE-UNAVAILABLE, SCOPE-MISMATCH), and a scope prunes as search and resolution do (D09): a seat or claimant outside it is absent, so the path takes the next seat that applies. `inertDeclarations(options)` on every reader names, as frozen `{identity, field, value, path, line, reason}` values ordered by path, line and identity and pruned to the scope, each declaration the capture reads that declares nothing: a `composition.sources` entry of an admitted `@workspace` that names no root (D02a), and a claimant selection the dialect reads as none (graph `isSelection`), which selects no path, so a host can say so where it is authored; neither is a report finding, so admission, snapshots and the Door are unchanged. The resolution reads the view's graph and the capture's declared roots only; it adds no snapshot field, no cache payload beyond the graph's G06c index and no revision input, and the frozen Door routes and `ia scope` do not call it. `tests/seat.test.ts` pins the exit evidence (`.ia/src/systems/work-system/records/work.ia` seats at work-system with the fixture `@mandate` that covers it), each seat rule and the root tie-break, how the repository's own `@workspace` is chosen, outside paths, claimant order across bands and fields, scope binding and a scope pruning each seat rule, and the editor reader's unsaved overlays.
57
+ D02b. Location seat. `resolveSeat(path, options)` on every reader returns a frozen `SeatResolution` `{path, seat?, by?, declarers?, claimants, unknown?}`. `path` is canonicalized as a scope root with `\` read as `/`; an absolute path, or one escaping the workspace, comes back as supplied with `unknown: 'outside'` and no claimants. Otherwise the seat is the first that applies, and `by` names which: `system`, the admitted `@system` of the system folder that holds the path or is the path, as `systemMember` reads local, package, adopted and installed folders, and the floor's `@system` for `.ia/src/floor`; `root`, the `@workspace` declaring the longest D02a root that contains the path, at any placement; `shared`, when several `@workspace` records in the read's scope declare that same longest root (amended 2026-11-04, inventarch/ia#194; it was an identity tie-break): the path is seated at none of them, since D02a makes a record under the root a member of every declarer, and `declarers` lists each declaring identity once, in identity order, with no `seat`; `repository`, for a path with no `.ia` segment, the repository's own `@workspace`. The capture decides that workspace once, from the root view. The sole admitted `@workspace` at the init entry point `.ia/src/workspace.ia` is the repository's own, whether or not it declares sources; several workspaces at that entry point decide none. When no workspace is admitted at that exact path, preserve the existing fallback: the one admitted `@workspace` in the repository's `.ia/src` tree that declares a root, else the only `@workspace` there; none or several decide none. An adopted or package-local `workspace.ia` is not this entry point. This preference identifies the repository without granting any source membership or mandate authority: other workspaces still declare their own roots, and scope pruning never substitutes a different repository workspace. With neither a seat nor declarers, `unknown` is `undeclared`. `claimants` are graph G06c's claimants of the path, whatever the seat: each record whose `authority.covers`, `subject.covers`, `work.covers`, `hook.paths` or `check.covers` selection selects it (a `@check`'s textual `check.scope` claims nothing), with every matching field and selection, band descending then identity ascending; the graph indexes the selections once per load, so claimants are read from that index, never from the records, and the seat from the graph's name and discriminator indexes and the capture's declared roots. `options` bind as `get` binds them (CLOSED, STALE, SCOPE-UNAVAILABLE, SCOPE-MISMATCH), and a scope prunes as search and resolution do (D09): a seat or claimant outside it is absent, so the path takes the next seat that applies, and a shared root whose declarers the scope prunes to one seats at that one by `root`. `repositoryWorkspace(options)` on every reader gives the repository's own `@workspace` the capture decided (amended 2026-11-04, inventarch/ia#226), whatever the seat of `''`, so a root it shares with other workspaces keeps it; bound as `get` binds, and absent when the scope does not admit it, a scope never substituting another. `inertDeclarations(options)` on every reader names, as frozen `{identity, field, value, path, line, reason}` values ordered by path, line and identity and pruned to the scope, each declaration the capture reads that declares nothing: a `composition.sources` entry of an admitted `@workspace` that names no root (D02a), and a claimant selection the dialect reads as none (graph `isSelection`), which selects no path, so a host can say so where it is authored; neither is a report finding, so admission, snapshots and the Door are unchanged. The resolution reads the view's graph and the capture's declared roots only; it adds no snapshot field, no cache payload beyond the graph's G06c index and no revision input, and the frozen Door routes and `ia scope` do not call it. `tests/seat.test.ts` pins the exit evidence (`.ia/src/systems/work-system/records/work.ia` seats at work-system with the fixture `@mandate` that covers it), each seat rule, a root two and three workspaces share (a scope pruning its declarers to two keeping it shared, to one seating it by `root`), how the repository's own `@workspace` is chosen and read at a shared root, outside paths, claimant order across bands and fields, scope binding and a scope pruning each seat rule, and the editor reader's unsaved overlays.
58
58
 
59
59
  D02c. Declared roots (runtime R15). `roots(options)` on every reader returns the roots the capture declares (D02a) as frozen `DeclaredRoot` copies `{root, placement, workspace}`, in the capture's order: longest root first, then by declaring `@workspace` identity. An entry that declares nothing (`inertDeclarations`) is no root. `options` bind as `get` binds them (CLOSED, STALE, SCOPE-UNAVAILABLE, SCOPE-MISMATCH), and a root whose declaring `@workspace` the read does not admit is pruned, as the seat rule prunes it (D02b, D09); membership rows keep the roots they were captured under whatever the scope, so pruning a root never re-roots a row. It is how a runtime reader computes a workspace's capture members and closure without the private view: it adds no snapshot field, cache payload or revision input, never reads the D08a capture pair, and the frozen Door routes do not call it. `DeclaredRoot` is exported as a type. `tests/membership.test.ts` pins the order, the inert entry left out, frozen copies, and a scope that does not admit the declaring workspace pruning its roots while its rows keep theirs; `tests/scope.test.ts` and `tests/retention.test.ts` pin the token checks and that no capture file is read.
60
60
 
@@ -70,7 +70,7 @@ D06. The derived .ia/.iadb/graph.json stores a format tag, revision and determin
70
70
 
71
71
  D07. resolveScope issues an opaque unguessable token bound privately to its issuing handle, canonical root, optional phase (wildcard when omitted), view revision and source generation. The initial occurrence boundary includes every reachable candidate occurrence before phase selection; an optional identity allowlist only intersects it. A child root is the same or a segment-boundary descendant. Its occurrence boundary intersects the parent's and its admitted identities include only winners whose actual occurrence is in that boundary. A new winner with the same identity cannot widen it. A child may change phase but never add occurrences. Omitted child bindings inherit; explicit phase:null requests a wildcard. Refuse narrowing with SCOPE-MISMATCH if the effective registry differs from the parent: a read token cannot authorize new vocabulary/schema interpretation. A privileged host may issue an independent root token for that view. Explicit requested revision must agree with the inherited token when narrowing.
72
72
 
73
- D08. Every read carrying a token validates issuer, open state, generation and explicit root/phase/revision assertions. Omitted bindings inherit. Unknown/forged/other-handle tokens are SCOPE-UNAVAILABLE; incompatible bindings or a wider child root SCOPE-MISMATCH; changed generation STALE (a token never revives after refresh to different inputs and back); closed handle CLOSED. Stale tokens never read current bytes under an old stamp. Scope grants reading only. Tokens are not transferable between processes without the later owning transport retaining their issuing handle.
73
+ D08. Every read carrying a token validates issuer, open state, generation and explicit root/phase/revision assertions. Omitted bindings inherit. Unknown/forged/other-handle tokens are SCOPE-UNAVAILABLE; incompatible bindings or a wider child root SCOPE-MISMATCH; changed generation STALE (a token never revives after refresh to different inputs and back), as is a token whose scope was evicted (D08c); closed handle CLOSED. Stale tokens never read current bytes under an old stamp. Scope grants reading only. Tokens are not transferable between processes without the later owning transport retaining their issuing handle.
74
74
 
75
75
  D08 retention, apart from scope validation: a handle retains two admitted root snapshots, seeded from the capture pair of D08a (location '', no phase), each as its revision, its authored revision (D05a) and its D02a membership rows: the current one, and `previous`, the most recent admitted root snapshot whose authored revision differs from the current one. Only an authored revision change rotates (2026-10-09: a change to runtime-band sources alone, such as evidence an `ia validate` writes, moves the revision but must not spend the comparison staleness and readiness depend on). A refresh, or a new handle, that finds the authored revision last retained as current keeps the existing previous, so a plain open or refresh at an unchanged authored revision never wipes that comparison; an authored revision change, even one that alters no record text, rotates that current into previous; a failed refresh rotates nothing. `previousRevision` and `previousAuthoredRevision` name the previous snapshot's revision and authored revision, undefined while none is retained. `staleness(identity, options)` and `readiness(identity, digest, options)` bind `options` exactly as `get` does (CLOSED, STALE, SCOPE-UNAVAILABLE, SCOPE-MISMATCH, and OUT-OF-SCOPE for an identity outside the scope's allowed identities) and take the current digest from the view `get` reads, so their current side is the record `get` returns. Only root snapshots are retained, so the previous side is the identity's digest in the previous root snapshot, and it applies only while the selected view's digest is the identity's current root digest, as it always is for a root read. `staleness` answers `unchanged` when the two sides are equal, `changed` when not, `new` when only the current side has a digest (so every current identity reads `new` while no previous snapshot is retained), `removed` when only the previous side does, undefined when neither does. `readiness` answers `current` when `digest` equals the current side, else `previous` when it equals the previous side, else `unknown`: digest equality, never an order. When a narrower root or phase selects a digest other than the current root one, including a record only one of the two views holds (for example a phase-shadowed or tied occurrence, or one only a narrower root reaches), the retained root snapshots describe a different occurrence: `staleness` is undefined and `readiness` answers `current` for the selected record's own digest, else `unknown`. A scope admits only identities its view holds, so a read through a scope token never reports `removed`. The previous snapshot persists between processes as the capture pair of D08a, the one retained pair, which only `ia capture` writes: every disk handle, whatever its cache setting, seeds its pair from it, and no handle writes it. A handle reads the pair the first time it is asked for `previousRevision`, `previousAuthoredRevision`, `capturedRevision`, `capturedAuthoredRevision`, `staleness` or `readiness`, never on open or refresh, so a read that never asks (every frozen Door route) opens no capture file. The seed is the capture at `current.json` and, when it is a capture at another authored revision, the one at `previous.json`; with no readable `current.json`, a capture at `previous.json` alone. The handle rotates that seed against its own root snapshot: at the captured authored revision `previous` is the capture at `previous.json`, at another authored revision it is the capture at `current.json`. A capture is trusted by its authored revision and the membership rows of its records not at runtime placement (band other than 0), each by its identity, band and digest: a `current.json` that names the fresh authored revision with other such rows is not this workspace's capture at that revision, so the pair seeds nothing, while one that differs from the fresh snapshot only in its runtime-band rows, and so in its revision, or in the roots of its rows, which a runtime-band `@workspace` can declare (D02a) and no retained read takes, is this workspace's. Admission still reads every placement, so a runtime-band record that changes which records not at runtime placement are admitted (one repeating an authored requirement id refuses both) leaves a capture at that authored revision untrusted until the next capture; a capture at another authored revision cannot be rebuilt from the fresh inputs, so it is trusted as written. A link or junction on the way, an entry that is not a regular file, and a file that is no capture (not JSON, another format, a malformed revision, authored revision or membership row) are ignored, never followed, and leave every read usable. `capturedRevision` and `capturedAuthoredRevision` name the revision and the authored revision of the capture at `current.json`, undefined when there is none or it is not trusted; a capture at another authored revision than `authoredRevision` is stale, and one that differs only in runtime-band sources is not. A refresh rotates the pair its handle holds in memory without reading the capture pair: at a changed authored revision the root snapshot it held becomes `previous`, and at an unchanged one it keeps the previous side it held, still unread until asked, so however often a handle refreshes it holds one pair. `capturedRevision` and `capturedAuthoredRevision` are read again the next time they are asked after a refresh, as `ia capture` may have run, so a handle that lived through an edit reports the edit as changed whether or not it was captured. The cache-free editor reader retains nothing: `previousRevision`, `previousAuthoredRevision`, `capturedRevision` and `capturedAuthoredRevision` are undefined, every current identity reads `new`, and `readiness` never answers `previous`. Retention is not a revision input and adds no snapshot field (the `authoredRevision` a snapshot carries is its view's, D05a), so workspace revisions, snapshots and the Door's MACHINE_PROTOCOL version 1 output are unchanged by it.
76
76
 
@@ -78,6 +78,8 @@ D08a. The capture pair (the CLI's `capture`). `writeCapture(root, text)` writes
78
78
 
79
79
  D08b. The capture plan (`ia capture --preview`). `planCapture(root, text)` makes every check and read `writeCapture(root, text)` makes before its first write, with the same TypeError for a `text` that is no `ia-snapshot-1` document and the same PATH-UNSAFE refusals, and returns the frozen `CapturePlan`: the result that write would return, so its counts, `prior`, `ignored`, `previous` and `rotated` are the write's, plus `identities` `{changed, added, removed}`, the identities those three counts count, each list sorted by code unit (with no readable prior capture, `added` lists every row). It creates no directory and stages, renames, removes or writes no file, so the capture pair keeps its bytes and modification times. `writeCapture` makes its checks and reads through the same planner, then writes; its result and its writes are unchanged. `CapturePlan` is exported as a type. `tests/retention.test.ts` pins the plan of a workspace never captured (no `.ia/work` is created), one edit named as the one changed identity with the pair left as it was, an added and a removed identity, the plan agreeing with the write's result at each step, a check that refuses the plan, and each list sorted by code unit whatever order either document holds its rows in.
80
80
 
81
+ D08c. Held scopes and views (2026-10-30). What a reader holds, pinned scopes aside, is bounded however many scopes it issues and however many locations it is asked for, so a long-lived door stays flat. A reader holds the 4,096 ordinary scopes (`HELD_SCOPES`) most recently issued or read, and issuing one past that evicts the least recently used. The number is chosen so ordinary use never meets it: an operation issues at most one scope, so a heavy session of about 1,400 calls stays under it three times over and not even a token used once and left idle is evicted; and at the default 4,000 text tokens a context, 4,096 of them is some 16 million tokens delivered, more than any client keeps a token in view through. Reading a token keeps it, however old. The cap costs little: a scope that keeps its whole view holds about 330 bytes, about 1.3 MB for the full table. An evicted token refuses as a stale one does: every read through it, `resolveScope`, `isCompleteScope`, `staleness` and `readiness` among them, is IA-DB-STALE, whenever it comes, and is never served from another scope or the whole view; the token does not revive. This shortens what a token promised: it used to last as long as its handle, and can now expire within it. A client recovers by issuing a new scope, with the same narrowing. A refresh to changed inputs releases every scope (D05), so a stale token and an evicted one take one path, whose message names both, its opening words those the stale refusal always had, and says to issue a new scope. A refresh to identical inputs releases none, and each token then reads the new state's view, not the one it was issued against. A token stays a UUID, its first 74 random bits as `randomUUID` gives them and its last twelve digits their HMAC-SHA-256 tag, under a key each reader draws when it is built and never shows, so a reader knows every token it ever issued without keeping any of them: `isIssuedScope(token)` is true of a token it evicted or a refresh retired and false of a forged token, an altered one or another reader's, which reads go on refusing as SCOPE-UNAVAILABLE, and it is CLOSED on a closed reader. The tag only tells those two refusals apart. It grants nothing: a read needs a scope still held, found by the whole token. `ScopeRequest.pinned` holds a scope outside that bound, in a table of its own, for a host that keeps a scope for the life of its handle whether or not a read names it, as the runtime Door keeps its initial scope. A pinned scope is neither counted nor evicted, so it takes no ordinary place: 4,096 ordinary scopes always fit beside any number of pins, and no scope comes back already evicted. Pins themselves are not bounded. Each stays until a refresh to changed inputs or close, and nothing limits how many a caller makes, so only a host that holds the reader may create them, and it pins what it can count. No client can: the Door's `scope` operation admits no such parameter. A child is not pinned by its parent. A scope holds no view and no serialized registry. It finds its view again by its binding, whose revision `view` asserts, so a view no scope pins can leave; and D07's registry comparison reads a SHA-256 digest of the stable serialization, computed once per view, equal exactly when the serializations are. Only a scope that narrows its view holds sets of its own, its occurrence boundary and allowed identities; one that keeps the whole view reads the view's, computed once and released with the view, so its meaning is unchanged and it holds neither. A narrowed scope holds about 58 bytes per identity it keeps, which is what remains proportional to the corpus: at worst, every held scope naming nearly every identity, about 42 MB on the conformance corpus's 186 records. Views and compilation are kept per declared reach, not per location. The reaches above a location nest, so the deepest selects every source any of them does, and a view built at a location differs from one built at that reach only in the location it names. So every location below one reach reads that reach's view, whatever `root` a client names: naming another root builds and holds nothing. A read still names its own root, in `Snapshot.root` and a scope's binding; only `graph.location` on what `EditorSnapshot.inspect` returns is the reach's, which nothing reads. A state holds the 16 views (`HELD_VIEWS`) most recently read, by declared reach and phase, the root view among them and never evicted: three reaches, each read whole and at all four phases, where a workspace that declares none needs five. A view evicted is built again when next read, in about 40 ms on that corpus, from the same captured inputs, so it reads the same revision and records and refuses nothing: its cost is that build and never a token. None of this changes what a read returns, a revision, the cache, the capture pair or a token's wire shape. `tests/scope.test.ts` pins eviction at exactly the cap, the least recently used leaving and a token read just before kept, every read of an evicted token refused and its survivors' boundaries intact, an evicted token told from altered, spliced, foreign and forged ones long after it left, the token's UUID shape, a pinned scope kept unread, retired by changed inputs and not revived when they come back, and a child not pinned, twice the cap in pins leaving a fresh scope readable and all 4,096 ordinary scopes held, what a refresh replaced collected while the tokens issued before it read the same records, and every scope collected on close (`tests/release-child.ts`, a bounded child process under `--expose-gc`), whole and narrowed scopes reading and bounding children the same after their views left, the view bound through `EditorSnapshot.inspect`, and one view for every location below a reach, each read naming its own root; `tests/view.test.ts` pins that view byte for byte, but for the location it names, at locations below a reach, whole and at a phase, and one compile per declared reach however many locations are read.
82
+
81
83
  D09. get, records, referencedBy, directedView, resolveSeat, words, roots, resolve, search and traverse honor the supplied token and view. get, referencedBy and directedView, like D08 staleness and readiness, yield OUT-OF-SCOPE outside their allowed identities; referencedBy returns graph G06a typed field references naming the identity, pruned to holders in scope; directedView returns the identity's graph G06b directed view (its declared edge rows, the derived inverses of its counterparts' declarations and its typed field references both ways, each row with `declaredOn`, its spelling or field path and `derived`), pruned the same way to rows whose counterpart is in scope (the declaring record is the identity or that counterpart, so a pruned scope never shows a row declared outside it). The view is a snapshot derivation: graph computes it on read from the view's admitted graph, so it is per revision and deterministic but is not stored in the cache payload or the D08a capture and is not a revision input. It is the same pure function of one revision wherever it is read, so a capture document need not carry it. Dangling, ambiguous and consent-refused assertions stay admission findings (graph diagnostics in the report) with no row in it; lists/search/resolution, D02b seat resolution included, prune and traversal cannot cross an excluded intermediary. Scope and typed traversal filters apply before emitting gated edges. A scoped snapshot exposes only allowed immutable nodes, their D02a membership rows, its root/phase/view revision and admitted system order; it does not expose the private full graph/registry/indexes or unscoped diagnostics. All query products delegate to graph; db creates no second adjacency or text index. Unscoped reads are privileged host inspection, and runtime must always supply a token.
82
84
 
83
85
  D09a. Registered words. `words(options)` on every reader returns the frozen, sorted keywords the read view's registry registers for its admitted systems, the floor's `system` and `schema` included; a keyword two systems register at the winning band is blocked and absent, and so is every word of a system admission blocked. It is the closed set a runtime scope key's `word` is checked against (runtime R14). `options` bind as `get` binds them; a scope narrows records, never the registry (a child scope that would change it refuses, D07), so every scope of a view reads the same words. Only the keywords are exposed: the registry, its registrations and its consent ledgers stay private. It adds no snapshot field, cache payload or revision input, it never reads the D08a capture pair, and the frozen Door routes do not call it.
@@ -0,0 +1,52 @@
1
+ import type { Assessment, Finding } from '@inventarch/compliance';
2
+ import type { Graph, Node } from '@inventarch/graph';
3
+ /**
4
+ * A path as the rules compare it: `/`-separated, case preserved. An absolute path is made relative to the root when
5
+ * both are absolute (a drive letter is dropped from the two together, never from one), else it is kept as given.
6
+ */
7
+ export declare function relativeTo(root: string, path: string): string;
8
+ /** The Markdown files under `<root>/.ia/src`, as root-relative paths. */
9
+ export declare function teachingFiles(root: string): readonly string[];
10
+ /**
11
+ * C12 over documents already read: a relative link must stay under `.ia/src/`, exist and be in the installed closure
12
+ * (`nativePaths` and the documents themselves). A root-relative `/x` link leaves `.ia/src/` and is reported; absolute
13
+ * URLs and `#` anchors are skipped. Paths are `/` paths.
14
+ */
15
+ export declare function teachingLinkFindings(files: readonly {
16
+ readonly path: string;
17
+ readonly text: string;
18
+ }[], nativePaths: ReadonlySet<string>, exists: (path: string) => boolean): readonly Finding[];
19
+ /**
20
+ * C12: the teaching documents `files` (root-relative or absolute under `root`) read from disk, their links checked
21
+ * against the files under `<root>/.ia/src` (plus `nativePaths`) as the installed closure.
22
+ */
23
+ export declare function canonTeachingLinks(root: string, files: readonly string[], nativePaths: ReadonlySet<string>): readonly Finding[];
24
+ /**
25
+ * A6: a `.ia/src` below `root` other than `<root>/.ia/src` is reported unless its `.ia/` holds a `release.json` that
26
+ * decodes or a `distributions.lock.json` that decodes with an entry. Active in a kit or a knowledge repository
27
+ * (`scope`), else nothing.
28
+ */
29
+ export declare function canonSourceRoots(root: string, scope: 'kit' | 'knowledge' | null): readonly Finding[];
30
+ /**
31
+ * C6: a kit ships no scripts. A shipped file (`shippedFiles`: anything under `.ia/` but runtime state, plus the declared
32
+ * assets) with a script extension is reported unless it sits under `.ia/src/systems/<allowed>/` (the folders of the
33
+ * executing systems, dec-040 A). Nothing outside a kit.
34
+ */
35
+ export declare function canonKitScripts(root: string, isKit: boolean, allowedSystems?: readonly string[]): readonly Finding[];
36
+ export interface CanonFileOptions {
37
+ /** The Markdown documents C12 reads (default: every `.md` under `<root>/.ia/src`). */
38
+ readonly files?: readonly string[];
39
+ /** The graph whose resolved `enforce` edges decide which laws are enforced. */
40
+ readonly graph?: Graph;
41
+ /** The packages the lock installs, as the db reader returns them; one with the knowledge kit's id sets scope 'knowledge'. */
42
+ readonly installed?: readonly {
43
+ readonly id: string;
44
+ }[];
45
+ }
46
+ /** A6's scope: a kit, else a knowledge repository (the lock installs the knowledge kit), else none. */
47
+ export declare function sourceRootScope(nodes: readonly Node[], installed?: readonly {
48
+ readonly id: string;
49
+ }[]): 'kit' | 'knowledge' | null;
50
+ /** The file-based canon rules C12, A6 and C6 as assessments, each active only when a law enforces a check that runs it. */
51
+ export declare function canonFileAssessments(root: string, nodes: readonly Node[], options?: CanonFileOptions): readonly Assessment[];
52
+ //# sourceMappingURL=files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/canon/files.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAsBrD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAM7D;AAmCD,yEAAyE;AACzE,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAE7D;AAQD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,EAClE,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAChC,SAAS,OAAO,EAAE,CAgCpB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,GAC/B,SAAS,OAAO,EAAE,CAYpB;AA2DD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,WAAW,GAAG,IAAI,GAAG,SAAS,OAAO,EAAE,CAWpG;AA4CD;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,cAAc,GAAE,SAAS,MAAM,EAAO,GACrC,SAAS,OAAO,EAAE,CAcpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,sFAAsF;IACtF,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,+EAA+E;IAC/E,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IACvB,6HAA6H;IAC7H,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACzD;AAED,uGAAuG;AACvG,wBAAgB,eAAe,CAC7B,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,SAAS,GAAE,SAAS;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,EAAO,GACjD,KAAK,GAAG,WAAW,GAAG,IAAI,CAE5B;AAED,2HAA2H;AAC3H,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,OAAO,GAAE,gBAAqB,GAC7B,SAAS,UAAU,EAAE,CAsBvB"}
@@ -0,0 +1,281 @@
1
+ import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
2
+ import { posix, resolve } from 'node:path';
3
+ import { canonAssessment, executingKitSystems, isKitWorkspace } from '@inventarch/compliance';
4
+ import { decodeDistributionLock, decodeReleaseDescriptor } from '../distribution/contracts.js';
5
+ import { localTarget, scanMarkdown } from './links.js';
6
+ /** The directories no canon file walk enters. */
7
+ const SKIPPED = new Set(['node_modules', 'dist', '.git']);
8
+ /** Runtime state under any `.ia/` (the root's, or a nested workspace's): never a source root, never shipped. */
9
+ const RUNTIME_STATE = /(?:^|\/)\.ia\/(?:distributions|work)$/;
10
+ const isRuntimeState = (path) => RUNTIME_STATE.test(path);
11
+ const SOURCE = '.ia/src';
12
+ const KB_KIT = 'inventarch/ia-kb-kit';
13
+ /** `\` is a separator in every path these rules compare. */
14
+ const slashed = (path) => path.split(String.fromCharCode(92)).join('/');
15
+ const DRIVE = /^[A-Za-z]:(?=\/|$)/;
16
+ const isAbsolutePath = (path) => path.startsWith('/') || DRIVE.test(path);
17
+ /** `path` without its trailing `/`s, by a backwards scan: a regex here is quadratic on a crafted run of `/`. */
18
+ function withoutTrailingSlashes(path) {
19
+ let end = path.length;
20
+ while (end > 0 && path[end - 1] === '/')
21
+ end--;
22
+ return path.slice(0, end);
23
+ }
24
+ /**
25
+ * A path as the rules compare it: `/`-separated, case preserved. An absolute path is made relative to the root when
26
+ * both are absolute (a drive letter is dropped from the two together, never from one), else it is kept as given.
27
+ */
28
+ export function relativeTo(root, path) {
29
+ const spelled = posix.normalize(slashed(path)), base = withoutTrailingSlashes(slashed(root));
30
+ if (!isAbsolutePath(spelled) || !isAbsolutePath(base))
31
+ return spelled.replace(/^\.\//, '');
32
+ const [from, to] = [base.replace(DRIVE, ''), spelled.replace(DRIVE, '')];
33
+ return to === from ? '' : to.startsWith(from + '/') ? to.slice(from.length + 1) : spelled;
34
+ }
35
+ function entries(directory) {
36
+ try {
37
+ return readdirSync(directory, { withFileTypes: true }).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
38
+ }
39
+ catch {
40
+ return [];
41
+ }
42
+ }
43
+ /** A `.git` entry (directory, or the file a worktree has) is the boundary of a separate checkout. */
44
+ const isSeparateCheckout = (root, path) => entries(resolve(root, path)).some((child) => child.name === '.git');
45
+ /**
46
+ * Every file under `directory` as a root-relative `/` path, in order; links are not followed. `node_modules`, `dist`,
47
+ * `.git` and runtime state at any depth are skipped; `bounded` also stops at separate checkouts.
48
+ */
49
+ function walkFiles(root, directory, bounded = false) {
50
+ const found = [];
51
+ const visit = (relative) => {
52
+ for (const entry of entries(resolve(root, relative))) {
53
+ if (SKIPPED.has(entry.name))
54
+ continue;
55
+ const path = relative === '' ? entry.name : `${relative}/${entry.name}`;
56
+ if (entry.isDirectory() && (isRuntimeState(path) || (bounded && isSeparateCheckout(root, path))))
57
+ continue;
58
+ if (entry.isDirectory())
59
+ visit(path);
60
+ else if (entry.isFile())
61
+ found.push(path);
62
+ }
63
+ };
64
+ visit(directory);
65
+ return found;
66
+ }
67
+ /** The Markdown files under `<root>/.ia/src`, as root-relative paths. */
68
+ export function teachingFiles(root) {
69
+ return walkFiles(root, SOURCE).filter((path) => path.endsWith('.md'));
70
+ }
71
+ const closed = (available, target) => available.has(target) || [...available].some((file) => file.startsWith(`${target}/`));
72
+ /** Absolute URLs (a scheme, or a `//` network path) and in-page anchors are not local teaching targets. */
73
+ const NOT_LOCAL = /^[a-z][a-z0-9+.-]*:|^#|^\/\//i;
74
+ /**
75
+ * C12 over documents already read: a relative link must stay under `.ia/src/`, exist and be in the installed closure
76
+ * (`nativePaths` and the documents themselves). A root-relative `/x` link leaves `.ia/src/` and is reported; absolute
77
+ * URLs and `#` anchors are skipped. Paths are `/` paths.
78
+ */
79
+ export function teachingLinkFindings(files, nativePaths, exists) {
80
+ const available = new Set([...nativePaths, ...files.map((file) => file.path)]), parsed = new Map(files.map((file) => [file.path, scanMarkdown(file.text)])), found = [];
81
+ const report = (path, line, message) => {
82
+ found.push({ code: 'IA-COMP-CANON-TEACHING-LINKS', path, line, severity: 'error', message: `${path}: ${message}` });
83
+ };
84
+ for (const file of files) {
85
+ for (const link of parsed.get(file.path).links) {
86
+ if (link.kind === 'html' || NOT_LOCAL.test(link.href))
87
+ continue;
88
+ if (link.href.startsWith('/')) {
89
+ report(file.path, link.line, `target outside installed teaching closure: ${link.href}`);
90
+ continue;
91
+ }
92
+ let pathname, fragment;
93
+ try {
94
+ const local = localTarget(link.href);
95
+ pathname = slashed(local?.pathname ?? '');
96
+ fragment = local?.fragment ?? '';
97
+ }
98
+ catch {
99
+ report(file.path, link.line, `invalid teaching link ${link.href}`);
100
+ continue;
101
+ }
102
+ if (pathname === '')
103
+ continue;
104
+ const target = posix.normalize(posix.join(posix.dirname(file.path), pathname));
105
+ if (!target.startsWith(SOURCE + '/') || !exists(target) || !closed(available, target))
106
+ report(file.path, link.line, `target outside installed teaching closure: ${link.href}`);
107
+ else if (fragment !== '' && parsed.has(target) && !parsed.get(target).ids.has(fragment))
108
+ report(file.path, link.line, `section missing from its installed teaching target: ${link.href}`);
109
+ }
110
+ }
111
+ return found.sort((a, b) => (a.message < b.message ? -1 : a.message > b.message ? 1 : 0));
112
+ }
113
+ /**
114
+ * C12: the teaching documents `files` (root-relative or absolute under `root`) read from disk, their links checked
115
+ * against the files under `<root>/.ia/src` (plus `nativePaths`) as the installed closure.
116
+ */
117
+ export function canonTeachingLinks(root, files, nativePaths) {
118
+ const documents = [];
119
+ for (const file of files) {
120
+ const path = relativeTo(root, file);
121
+ try {
122
+ documents.push({ path, text: readFileSync(resolve(root, path), 'utf8') });
123
+ }
124
+ catch {
125
+ // A listed file that cannot be read has no links to check.
126
+ }
127
+ }
128
+ const installed = new Set([...walkFiles(root, SOURCE), ...[...nativePaths].map((path) => relativeTo(root, path))]);
129
+ return teachingLinkFindings(documents, installed, (path) => existsSync(resolve(root, path)));
130
+ }
131
+ /**
132
+ * A nested `.ia/` is released when its `release.json` decodes as a release descriptor, or adopted when its
133
+ * `distributions.lock.json` decodes as a lock installing at least one package or entry. An empty or malformed file
134
+ * exempts nothing.
135
+ */
136
+ function releasedOrAdopted(root, ia) {
137
+ const read = (name) => {
138
+ try {
139
+ return readFileSync(resolve(root, ia, name), 'utf8');
140
+ }
141
+ catch {
142
+ return null;
143
+ }
144
+ };
145
+ const descriptor = read('release.json'), lock = read('distributions.lock.json');
146
+ if (descriptor !== null)
147
+ try {
148
+ decodeReleaseDescriptor(descriptor);
149
+ return true;
150
+ }
151
+ catch {
152
+ // Not a release descriptor; the lock may still adopt the root.
153
+ }
154
+ if (lock !== null)
155
+ try {
156
+ const decoded = decodeDistributionLock(lock);
157
+ return decoded.packages.length + (decoded.entries?.length ?? 0) > 0;
158
+ }
159
+ catch {
160
+ // Not a lock.
161
+ }
162
+ return false;
163
+ }
164
+ /** Every `.ia/src` directory below `root` other than `<root>/.ia/src`, as a root-relative path. */
165
+ function nestedSources(root) {
166
+ const found = [];
167
+ const visit = (relative) => {
168
+ const here = relative === '' ? '' : `${relative}/`;
169
+ for (const entry of entries(resolve(root, relative))) {
170
+ if (!entry.isDirectory() || SKIPPED.has(entry.name))
171
+ continue;
172
+ const path = `${here}${entry.name}`;
173
+ if (isRuntimeState(path) || isSeparateCheckout(root, path))
174
+ continue;
175
+ const children = entries(resolve(root, path));
176
+ if (entry.name === '.ia') {
177
+ if (path !== '.ia' &&
178
+ children.some((child) => child.isDirectory() && child.name === 'src') &&
179
+ !releasedOrAdopted(root, path))
180
+ found.push(`${path}/src`);
181
+ }
182
+ visit(path);
183
+ }
184
+ };
185
+ visit('');
186
+ return found;
187
+ }
188
+ /**
189
+ * A6: a `.ia/src` below `root` other than `<root>/.ia/src` is reported unless its `.ia/` holds a `release.json` that
190
+ * decodes or a `distributions.lock.json` that decodes with an entry. Active in a kit or a knowledge repository
191
+ * (`scope`), else nothing.
192
+ */
193
+ export function canonSourceRoots(root, scope) {
194
+ if (scope === null)
195
+ return [];
196
+ return nestedSources(root).map((path) => ({
197
+ code: 'IA-COMP-CANON-SOURCE-ROOTS',
198
+ path,
199
+ line: 1,
200
+ severity: 'error',
201
+ message: `${path}: A ${scope === 'kit' ? 'kit' : 'knowledge repository'} authors one .ia/src; this nested root is neither released nor adopted.`,
202
+ }));
203
+ }
204
+ /** A script extension, matched case-insensitively. */
205
+ const SCRIPT = /\.(?:mjs|cjs|js|ts|mts|cts|tsx|jsx|py|rb|sh|bash|zsh|ps1|psm1|cmd|bat)$/i;
206
+ /**
207
+ * The files `<root>/.ia/release.json` declares under `assets`, as the marketplace kit loader reads them
208
+ * (`plugins/ia/scripts/lib/kit.mjs` `declaredAssets`): each `assets[].path`, resolved against the root. An asset that is
209
+ * absolute, leaves the root or names no regular file is not shipped and so not listed; a descriptor that does not
210
+ * parse declares none. C6 is not the descriptor's validator.
211
+ */
212
+ function declaredAssets(root) {
213
+ let assets;
214
+ try {
215
+ assets = JSON.parse(readFileSync(resolve(root, '.ia/release.json'), 'utf8')).assets;
216
+ }
217
+ catch {
218
+ return [];
219
+ }
220
+ if (!Array.isArray(assets))
221
+ return [];
222
+ const found = new Set();
223
+ for (const asset of assets) {
224
+ const path = asset?.path;
225
+ if (typeof path !== 'string' || path === '' || isAbsolutePath(slashed(path)))
226
+ continue;
227
+ const spelled = posix.normalize(slashed(path));
228
+ if (spelled === '.' || spelled === '..' || spelled.startsWith('../'))
229
+ continue;
230
+ try {
231
+ if (statSync(resolve(root, spelled)).isFile())
232
+ found.add(spelled);
233
+ }
234
+ catch {
235
+ // A declared asset that is missing is not shipped.
236
+ }
237
+ }
238
+ return [...found].sort();
239
+ }
240
+ /**
241
+ * The files a kit ships, as marketplace `lib/kit.mjs` packs and digests them: everything under `<root>/.ia/` (the walk
242
+ * skips `node_modules`, `dist`, `.git`, runtime state such as `.ia/distributions` and `.ia/work` at any depth, and
243
+ * separate checkouts) plus the assets `.ia/release.json` declares. Tests, fixtures and scripts the descriptor does not
244
+ * declare stay home.
245
+ */
246
+ function shippedFiles(root) {
247
+ return [...new Set([...walkFiles(root, '.ia', true), ...declaredAssets(root)])].sort();
248
+ }
249
+ /**
250
+ * C6: a kit ships no scripts. A shipped file (`shippedFiles`: anything under `.ia/` but runtime state, plus the declared
251
+ * assets) with a script extension is reported unless it sits under `.ia/src/systems/<allowed>/` (the folders of the
252
+ * executing systems, dec-040 A). Nothing outside a kit.
253
+ */
254
+ export function canonKitScripts(root, isKit, allowedSystems = []) {
255
+ if (!isKit)
256
+ return [];
257
+ const folders = allowedSystems.map((name) => `${SOURCE}/systems/${name}/`);
258
+ return shippedFiles(root)
259
+ .filter((path) => SCRIPT.test(path) && !folders.some((folder) => path.startsWith(folder)))
260
+ .map((path) => ({
261
+ code: 'IA-COMP-CANON-KIT-SCRIPTS',
262
+ path,
263
+ line: 1,
264
+ severity: 'error',
265
+ message: `${path}: A kit holds no scripts; move this file into the folder of an executing system or remove it.`,
266
+ }));
267
+ }
268
+ /** A6's scope: a kit, else a knowledge repository (the lock installs the knowledge kit), else none. */
269
+ export function sourceRootScope(nodes, installed = []) {
270
+ return isKitWorkspace(nodes) ? 'kit' : installed.some((p) => p.id === KB_KIT) ? 'knowledge' : null;
271
+ }
272
+ /** The file-based canon rules C12, A6 and C6 as assessments, each active only when a law enforces a check that runs it. */
273
+ export function canonFileAssessments(root, nodes, options = {}) {
274
+ const { files, graph, installed } = options;
275
+ return [
276
+ canonAssessment(nodes, 'CANON-TEACHING-LINKS', () => canonTeachingLinks(root, files ?? teachingFiles(root), new Set()), graph),
277
+ canonAssessment(nodes, 'CANON-SOURCE-ROOTS', () => canonSourceRoots(root, sourceRootScope(nodes, installed)), graph),
278
+ canonAssessment(nodes, 'CANON-KIT-SCRIPTS', () => canonKitScripts(root, isKitWorkspace(nodes), executingKitSystems(nodes)), graph),
279
+ ].flatMap((assessment) => assessment ?? []);
280
+ }
281
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/canon/files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE1E,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAG9F,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEvD,iDAAiD;AACjD,MAAM,OAAO,GAAwB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AAE,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC5C,OAAO;QACL,eAAe,CACb,KAAK,EACL,sBAAsB,EACtB,GAAG,EAAE,CAAC,kBAAkB,CAAC,IAAI,EAAE,KAAK,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,EAAE,CAAC,EACvE,KAAK,CACN;QACD,eAAe,CACb,KAAK,EACL,oBAAoB,EACpB,GAAG,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,eAAe,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,EAC/D,KAAK,CACN;QACD,eAAe,CACb,KAAK,EACL,mBAAmB,EACnB,GAAG,EAAE,CAAC,eAAe,CAAC,IAAI,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE,mBAAmB,CAAC,KAAK,CAAC,CAAC,EAC9E,KAAK,CACN;KACF,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,23 @@
1
+ /** One link a Markdown document makes: the href as written, and the line it starts on. */
2
+ export interface MarkdownLink {
3
+ readonly href: string;
4
+ readonly kind: 'link' | 'image' | 'definition' | 'html';
5
+ readonly line: number;
6
+ }
7
+ export interface ScannedMarkdown {
8
+ readonly links: readonly MarkdownLink[];
9
+ readonly ids: ReadonlySet<string>;
10
+ }
11
+ /**
12
+ * A GitHub-style slugger: lower-case, punctuation other than `-` and `_` removed, spaces to `-`; a repeat gets `-1`,
13
+ * `-2`, and so on.
14
+ */
15
+ export declare function createSlugger(): (text: string) => string;
16
+ /** Links (Markdown and raw HTML attributes) and section ids of a GFM document, without a parser; fenced code is skipped. */
17
+ export declare function scanMarkdown(text: string): ScannedMarkdown;
18
+ /** Split URI components before percent-decoding: an encoded # or ? is part of the filename. Null for a non-local href. */
19
+ export declare function localTarget(href: string): {
20
+ pathname: string;
21
+ fragment: string;
22
+ } | null;
23
+ //# sourceMappingURL=links.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../../src/canon/links.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,YAAY,GAAG,MAAM,CAAC;IACxD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AACD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IACxC,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACnC;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAgBxD;AA2QD,4HAA4H;AAC5H,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAqC1D;AAED,0HAA0H;AAC1H,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CASvF"}