@inventarch/runtime 3.4.1 → 3.5.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/SPEC.md +7 -1
- package/dist/method/bindings.d.ts +51 -0
- package/dist/method/bindings.d.ts.map +1 -0
- package/dist/method/bindings.js +166 -0
- package/dist/method/bindings.js.map +1 -0
- package/dist/method/catalogue.d.ts +39 -0
- package/dist/method/catalogue.d.ts.map +1 -0
- package/dist/method/catalogue.js +126 -0
- package/dist/method/catalogue.js.map +1 -0
- package/dist/method/errors.d.ts +28 -0
- package/dist/method/errors.d.ts.map +1 -0
- package/dist/method/errors.js +39 -0
- package/dist/method/errors.js.map +1 -0
- package/dist/method/index.d.ts +30 -0
- package/dist/method/index.d.ts.map +1 -0
- package/dist/method/index.js +16 -0
- package/dist/method/index.js.map +1 -0
- package/dist/method/installed-kits.d.ts +49 -0
- package/dist/method/installed-kits.d.ts.map +1 -0
- package/dist/method/installed-kits.js +194 -0
- package/dist/method/installed-kits.js.map +1 -0
- package/dist/method/kit-root.d.ts +31 -0
- package/dist/method/kit-root.d.ts.map +1 -0
- package/dist/method/kit-root.js +120 -0
- package/dist/method/kit-root.js.map +1 -0
- package/dist/method/kits.d.ts +130 -0
- package/dist/method/kits.d.ts.map +1 -0
- package/dist/method/kits.js +381 -0
- package/dist/method/kits.js.map +1 -0
- package/dist/method/packet.d.ts +51 -0
- package/dist/method/packet.d.ts.map +1 -0
- package/dist/method/packet.js +62 -0
- package/dist/method/packet.js.map +1 -0
- package/dist/method/pin.d.ts +71 -0
- package/dist/method/pin.d.ts.map +1 -0
- package/dist/method/pin.js +164 -0
- package/dist/method/pin.js.map +1 -0
- package/dist/method/reader.d.ts +38 -0
- package/dist/method/reader.d.ts.map +1 -0
- package/dist/method/reader.js +97 -0
- package/dist/method/reader.js.map +1 -0
- package/dist/method/registry.d.ts +39 -0
- package/dist/method/registry.d.ts.map +1 -0
- package/dist/method/registry.js +129 -0
- package/dist/method/registry.js.map +1 -0
- package/dist/method/releases.d.ts +47 -0
- package/dist/method/releases.d.ts.map +1 -0
- package/dist/method/releases.js +104 -0
- package/dist/method/releases.js.map +1 -0
- package/dist/method/resolve.d.ts +44 -0
- package/dist/method/resolve.d.ts.map +1 -0
- package/dist/method/resolve.js +448 -0
- package/dist/method/resolve.js.map +1 -0
- package/dist/method/retained.d.ts +8 -0
- package/dist/method/retained.d.ts.map +1 -0
- package/dist/method/retained.js +182 -0
- package/dist/method/retained.js.map +1 -0
- package/dist/method/root.d.ts +12 -0
- package/dist/method/root.d.ts.map +1 -0
- package/dist/method/root.js +43 -0
- package/dist/method/root.js.map +1 -0
- package/dist/method/session.d.ts +64 -0
- package/dist/method/session.d.ts.map +1 -0
- package/dist/method/session.js +109 -0
- package/dist/method/session.js.map +1 -0
- package/dist/packet-host.d.ts +1 -1
- package/dist/packet-host.d.ts.map +1 -1
- package/dist/packet.d.ts +1 -1
- package/dist/packet.d.ts.map +1 -1
- package/dist/packet.js +3 -2
- package/dist/packet.js.map +1 -1
- package/package.json +8 -4
package/SPEC.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
`inertCommandRoot(root)` identifies roots whose letters, numbers, spaces and `._-/:` punctuation can be repeated in a shell command, with spaces double-quoted. Windows path separators are accepted on Windows except a UNC backslash prefix, whose JSON quoting does not preserve its path meaning across native shells. Other characters require a caller to omit the root and explicitly request execution from the workspace directory. This helper supplies no authority and changes no mandate decision. `admissionReport` retains its stricter unquoted-root contract.
|
|
4
4
|
|
|
5
|
+
## Method kits and packets
|
|
6
|
+
|
|
7
|
+
`@inventarch/runtime/method` is the shared method resolver the MCP door reads kits through, in process. It reads kit folders (`.ia/release.json`, `.ia/src`, the lock, `releases.json` in format 1 or format 2 with `releases/<version>.json`, and the `checks.json`, `delivery.json`, `bindings.json` and `onwrite.json` sidecars) from a bundled folder and then `<IA home>/kits/<folder>/<version>/`; selects a repository's binding from `.ia/bindings.json` (exact, wildcard, default, then precedence); keeps task pins (format 3, format 1 read as format 3) under `<IA home>/work-v1/<project>/<task>/`; retains exact method bytes under the closure store; restores kit read roots under `<IA home>/kit-roots-v1/` unless the caller names a cache; and assembles the packet with the digest over its sorted-key canonical form, the envelope and binding excluded. `resolveMethod` follows the `ia` plugin's `resolve.mjs` step for step, reading position bodies, records, inbound rows and cell bodies through db and this package instead of the CLI. Its caller supplies the native restore that installs a kit's language base into the kit's read root, so this package gains no distribution dependency. `laneCatalogue`, `openSession`, `readRegistry`, `registerWorkspace` and `checkRoot` serve the door's catalogue, session log, workspace registry (format `ia-workspace-locations-2`, reading `personal-workspace-locations-1` and Studio's format 1, writing format 2 only) and per-root mandate check. Lanes, keys, words and phases are closed tokens; a subject is carried as the caller gives it and never reaches a position.
|
|
8
|
+
|
|
9
|
+
Installed kits (2026-10-31, contract C7b, ia-kb `dec-133` and `dec-117`): a workspace lock's `package` entries (`lockedPackageKits`) name kit releases the engine installs as ordinary releases in `.ia/distributions/store/<archive>/`; npm is transport only, and no kit is read from an npm package folder. `installedPackageKits` reads each from the store: its `distribution.json` must hash to the manifest digest the lock pins and name that release, and its pinned files are copied, each checked against its SHA-256, into `<IA home>/installed-kits-v1/<archive>/` with a format 1 `releases.json` of its one release and a `.ia/distributions.lock.json` that pins its dependencies exactly as the workspace lock does, so retention, read roots and the door's restore treat it as any kit folder (origin `installed`). `workspaceKits` lists a workspace's kits: the bundled ones, each installed kit, then the home's; a kit an entry names is taken from no other source, so `resolveMethod` refuses a binding to one the store lacks `IA-CORE-KIT-RESTORE-REQUIRED` ("run ia restore"; a pinned task may still read its retained bytes), and a kit no source provides still refuses `IA-CORE-KIT-UNKNOWN`. `installedKit` counts an entry kit as installed, so its packet's laws are the repository's position's and `envelope.kitInstalled` is true. `openSession` takes the kits the store lacks and adds `restore: {kits, message}` and a "Kits not restored" briefing line. `checkRoot` keeps the installation's refusal reason (`restore-required`, `lock-drift`) on its error. A lock without entries changes none of this.
|
|
10
|
+
|
|
5
11
|
## Optional topical context assembly
|
|
6
12
|
|
|
7
13
|
`context` accepts `ContextOptions.ranking` and the Door accepts `params.ranking`: `native` (default) preserves the existing procedure-first order; `topical` reserves all applicable blocking governance first, then orders other admitted candidates by the existing scoped text-search score, using native entry order for ties. Packets identify this opt-in mode with `ranking: "topical"`. It changes neither candidate eligibility, scope, coordinate validation, blocker overflow refusal nor exclusive execution selection. It is a retrieval option, not a semantic accuracy guarantee.
|
|
@@ -106,7 +112,7 @@ Body reader (2026-10-07): `src/locator.ts` reads the body behind a locator for `
|
|
|
106
112
|
|
|
107
113
|
R18. Delivery view (2026-10-08): `src/next.ts`, exported from the package root and the `./internal/next` subpath, publishes `deliveryView(handle, within, seat?)` and `NEXT_CODES` with the `CycleRow`, `DeliveryMilestone`, `DeliveryResult`, `DeliveryTask`, `DeliveryView`, `ExitEvidence`, `NextCode`, `NextRefusal`, `Prerequisite`, `ReviewItem`, `StateDimension` and `StateLine` types. It is a pure function of the admitted records the scope token `within` reads: every read (the snapshot, directed views, one traversal, readiness) carries that token, so a narrowed scope lists only what it admits and prunes rows to it (db D09), and only a whole-workspace token (db `isCompleteScope`, PT5) also reads the admission findings it alone may disclose, `refused` and the report's COMP-PARSE findings; the view is computed per call, never stored, and nothing is written, the capture pair that `readiness` reads included; an unknown, stale or closed token keeps its database error. It returns `{ok: true, view}` or one refusal `{ok: false, code, message, next, plans?, cycle?}` whose `next` is exactly one command, as `readBody` returns its refusals as values. The plan is the seat's when a seat is given: a `@plan`, the plan a `@milestone`'s `work.plan` names, or that of a `@task`'s `work.milestone`; without one, the only admitted `@plan` at band 100. IA-RUNTIME-NEXT-SEAT refuses a seat the scope does not admit (next the view without a seat that runs: `ia next` while the scope admits one `@plan` at band 100, `ia next --seat <the first of them>` while it admits several, which `ia next` alone refuses, and `ia next --help` while it admits none) or that is not a `@plan`, `@milestone` or `@task` (next `ia position --seat <seat>`); IA-RUNTIME-NEXT-NO-PLAN a seat that belongs to no admitted plan, or no seat and no plan at band 100 (next `ia next --help`); IA-RUNTIME-NEXT-AMBIGUOUS no seat and several plans at band 100, listed in the message and in `plans` (next `ia next --seat <the first of them>`); IA-RUNTIME-NEXT-CYCLE `require` rows that form a cycle among the plan's tasks, milestones or both, listed in `cycle` as declared rows `{from, to, declaredOn, path, line}`, each `from` requiring its `to` (next `ia position --seat <the cycle's first task, else its first milestone> --shape sequence`). The runtime's own `next` keeps the commands above, which the Door and MCP callers receive; the consumer `ia next` builds its own next action (it names `ia preview plan` for a workspace that registers `@plan` and authors none, when the acting participant's mandate profile allows Verification and the word, and otherwise a command that profile allows). The plan's milestones are the `@milestone` records whose `work.plan` names it, and its tasks the `@task` records whose `work.milestone` names one of them (the reverse field index). Order: one topological sort, Kahn's algorithm, over the tasks and two vertices per milestone, its start (its prerequisites met) and its end (satisfied). A milestone's tasks follow its start and precede its end, its start precedes its end, and each declared `require` row between two records of the plan, in either spelling, makes the requiring record (a task, or a milestone's start) follow the required one (a task, or a milestone's end). Ready milestone vertices are emitted first and ready tasks by (milestone identity, task identity), so tasks come prerequisites first with ties by milestone then task: the order Kahn's algorithm gives over the task-level expansion (a task follows each task it requires, each task of a milestone it requires, and each prerequisite task of its milestone, required directly or through a required milestone's tasks), and a required milestone with no task still passes on its own prerequisites, so a cycle through it is refused too. Requirements outside the plan order nothing and remain basis lines. A relation row that carries a condition (2026-10-08), such as `requires @task guide when phase is act` or `grounds @task guide when phase is act`, counts only where its condition holds at the coordinate the scope binds, decided as graph traversal decides it: the coordinate is the phase db `resolveScope` binds the token to, or none (a scope binds no other condition axis), and graph `conditionHolds` decides each term, the condition's subject being the record that states the row (its `declaredOn`, the author graph G06 keeps as the edge's condition subject). A condition is decided where every coordinate the bound one may still be completed to (each axis it binds no value for absent, or set to each of its values) reads it alike, and undecided where two of them differ: `conditionHolds` reads provenance and artifact set from the subject alone, so the subject decides those terms; it reads severity as graph `effectiveSeverity`, the stronger of the subject's and the coordinate's (G08), so a severity term is decided only where the subject's own severity decides it at every coordinate (`when severity is blocking` on a blocking record holds everywhere, `when severity is advisory` on one fails everywhere) and is undecided otherwise, as on a record that states no severity, such as a `@task`; and a term on any other axis the scope binds no value for, such as the phase on a whole-workspace scope, is undecided. A row whose condition fails is no row: it orders nothing, is no requirement, grounding or supersession, and its declared line is not read as unanswered either. A row the scope does not decide, as one conditional on a phase on the whole-workspace scope `ia next` reads, or on a severity on any scope, is conditional with an unknown basis and is never satisfied: a conditional requirement orders nothing and is an unsatisfied prerequisite whatever its target's state, its basis `<word> <target>: conditional on <terms>, which the scope binds no <axes> to decide (unknown)`, the axes being those the bound coordinate leaves open, and one no admitted record answers reads `no admitted record answers it, conditional on …`. Intent is read at the bound coordinate with each undecided row read as no row; when that reading reads an undecided row that could change it (a grounding of the task, or of a supersedor, a supersession between two decisions grounding either, or a supersession of the task by a record that is or may be accepted), it is read again at each completion of the bound coordinate on the axes those rows leave open, where every row is decided, a record that a row holding at the bound coordinate names read before one only a conditional row names. The line that reads the same, value and basis, at every completion is the intent, since no binding the scope could take changes it and the conditional row is never read as satisfied: a decision with no choice that grounds the task only at act, beside one that grounds it with no condition and is accepted, leaves it `accepted`, and a supersession that holds, by a record one decision accepts at every completion, leaves it `superseded`. Else intent is `unknown`, its basis the first such row, `<record> grounds it conditional on …` or `<record> supersedes it conditional on …`, as it stays when the axes those rows leave open have more than 256 completions. Review items read rows that hold only. Of two rows to one counterpart the one that holds is read before a conditional one, and of two lines for one target a decided one before a conditional one. Field references carry no condition, so exit evidence, milestones, plans and owner-agents are read as before. Admission refuses a record that states a conditional `supersede` of a work record (each work-system word's supersede rule has cardinality one, which a condition would leave undecided: IA-COMP-EDGE-UNRESOLVED), so such a row is rare; one that reaches the view is read as above. A task's effective prerequisites are its own `require` targets, then its milestone's, each target once, an inherited one marked `via` that milestone. work-system consents `require` to a `@task`, `@milestone` or `@decision` target only (a `@task` that requires a `@spec` is refused at admission, IA-GRAPH-EDGE-UNCONSENTED), so no required-spec line arises; a requirement no admitted record answers, an admission warning with no row, is read from the traversal's dangling rows and is never satisfied; and a `require` the task or its milestone itself declares that gives neither a row nor a dangling edge in the scope, as when its answer is outside it (D09 prunes the row, and the traversal never crosses the scope), is never satisfied either, its state unknown. A requirement declared only on a record outside the scope is not read. A record's exit evidence is the first `@observation`, by identity, that its `work.exit-evidence` names or whose `evidence.subject` names it, whose `evidence.verdict` is success and whose `evidence.subject-revision` reads `current` under `readiness` (db D08) for that record; its evaluator is `evidence.evaluator`, and its `attribution` is `self` when that equals the identity the task's `work.owner-agent` names, `unknown` when the task states an owner-agent that no admitted `@agent` in the scope answers or the observation records no evaluator for a task that names one, else `other`. Basis lines: `decision <d>: choice made` or `no choice` (`decision.choice` stated or not); `task <t>: exit evidence <o>` or `no exit evidence`; `milestone <m>: exit evidence <o>` (its own), `every task has exit evidence`, `exit evidence missing for <n> of <k> tasks`, `no task and no exit evidence`, or `every task the view reads has exit evidence; records outside this scope are unknown` (a narrowed scope) or `…; records admission refused are unknown` (a whole-workspace scope while admission refuses a `@task`, whose `work.milestone` the view cannot read, or a file a language error refuses whole, db D03), neither of which satisfies it; `<reference>: no admitted record answers it`; `<reference>: no record in this scope answers it (unknown)`; each with ` (via <milestone>)` when inherited. The verdict `line` is `exit evidence recorded (<o>, evaluator <e>[, self-attributed | , self-attribution unknown])`, else `no declared blocker` when every effective prerequisite is satisfied, else `blocked (<each unsatisfied basis>; …)`; a record's `work.status` is printed as `status <value> (self-declared)` and is never a basis. The five state lines of each task: intent `superseded` when a record that supersedes the task is grounded by a live `@decision` stating `decision.choice` and `decision.effective-revision`, `accepted` when the task itself is, else `unknown`, naming the first live grounding decision's missing choice or effective revision, or that none grounds it (in this scope, on a narrowed one), the live decisions grounding a record being those no other of them supersedes, unless the two supersede each other through a cycle, which removes neither (revisions are compared by equality only, never ordered); definition `admitted` at the record's per-record digest, as every listed task is an admitted winner, so the plan's `rejected` cannot arise on a listed task: a `@task` admission refused has no record to list, and a whole-workspace view names it as an `admission` review item instead; realizable and realized `not applicable` (a task binds nothing and no effect owner realizes one); worked `observed success` or `observed refusal` for an observation at the current digest, `stale` for one whose subject-revision is the previous snapshot's digest, `unknown` for one at neither (or with no subject-revision, or another verdict), and `unobserved` when no observation names the task, `unknown` on a narrowed scope. Review items, each naming as owner the `head.steward` of the `@system` of the record it is about when the scope admits that system: `grounding`, two or more live `@decision` records grounding the plan or one of its milestones or tasks, the message naming those that supersede one another in a cycle; `currency`, two `@spec` records whose `work.status` is accepted, one superseding the other with no `work.replaced-scope` (a partial supersession keeps both live, and a draft or superseded spec is not current); and, on a whole-workspace scope only, `admission`, each `@plan`, `@milestone` or `@task` record admission refused that no admitted occurrence answers, with its path, line and reason, and each file a COMP-PARSE error refuses whole, without an owner, both naming `ia validate`. `next` is `ia position --seat <task> --shape sequence` for the first task in order whose verdict is `no declared blocker`, so tasks with exit evidence are skipped; it is null when every task has exit evidence or every other task is blocked, and `summary` says which, its every-task line reading `every task the view reads has exit evidence (<n> of <n>); <why>` while a task may go unread as above or admission refuses a `@milestone`, whose tasks the view then cannot list. The view is `{format: 'ia.delivery-view.v1', revision, plan, milestones, tasks, review, next, summary}`, milestones in the order their starts are emitted. `tests/next.test.ts` pins every refusal (from a `@task` seat with no admitted milestone too), the order (a cross-milestone requirement no milestone states, and a task a satisfied milestone releases ranked against tasks already ready), each verdict, refusal and inconclusive observations that are never exit evidence, stale evidence and each attribution, the later milestone's task blocked through its milestone and never recommended, an inherited requirement no admitted record answers and a target the task and its milestone both require listed once, a milestone-level cycle, skipped evidenced tasks, the all-evidenced, all-blocked and empty-plan summaries, review items (a supersede cycle, a superseded decision as no basis of intent, draft and superseded specs), a refused `@task` and a file a language error refuses, the band-100 rule, narrowed scopes (an out-of-scope requirement, task, observation, decision and owner-agent read as unknown, never met; plans and seats outside the scope neither counted nor read) that a view writes nothing, exit evidence at runtime placement (band 0) counted as authored evidence is, a conditional grounding and requirement read at orient, at act and with no phase bound, against graph traversal for the same scope and coordinate; a severity term on a record that states no severity read as traversal reads it, conditional and blocking at every phase, and provenance terms the stating record decides; a row that holds read before a conditional one, and a conditional supersession refused at admission; an intent a conditional grounding cannot change read as it reads at every phase (accepted beside the conditional grounding of a decision with no choice, or of an accepted decision earlier by identity, and superseded through a supersedor whose acceptance a conditional grounding cannot change), and one it changes read as unknown; a conditional requirement no admitted record answers, and one whose answer a narrowed scope leaves out, read only where it holds; a milestone's unconditional requirement of a target read before the task's conditional one, and satisfied once the target is evidenced; and the Door through a token `scope` binds to a phase, over `tests/fixtures/delivery/` laid over the conformance corpus, which carries no work records; tools/compliance runs one boundary fixture per code, once through `deliveryView` and once through the Door. The Door's `next` operation serves the view and its refusals unchanged (R12 version 2 refinement, next), the MCP door as `ia_next`, and the CLI as the consumer verb `ia next` (apps/cli/SPEC.md); `ia position`, which `next` and two refusals name, is a CLI verb too.
|
|
108
114
|
|
|
109
|
-
R19. Position packet (2026-10-08): `src/packet.ts`, exported from the package root and the `./internal/packet` subpath, publishes `renderPacket(handle, within, catalog)` and `entryCount(packet)` with the `PositionPacket`, `PacketCatalogRow`, `PacketSeat`, `PacketParticipant`, `PacketMandate`, `PacketSystem`, `PacketTally`, `PacketIntent`, `PacketPhase`, `PacketProvenance`, `PacketHostNote` and `PacketOutput` types; the root's `Packet` stays R03's context packet, so the position packet's type is `PositionPacket`. The packet is the one host-neutral thing a host adapter renders (an adapter may change file names, file count and markup, never content, ordering or numbers). `renderPacket` calls `position(handle, within)` (R16) once, at K0, and reads everything else through the same scope token: the snapshot and its D02a membership rows, directed views (db D09), the declared roots (db D02c) and the registered words (db D09a). A missing token is IA-RUNTIME-REQUEST-INVALID, an unknown, stale or closed one keeps its database code, and every other refusal is position's: the packet renders the records admission admitted and gates none of them, so an admitted mandate that `mandateAuthorityOf` would refuse, one with a child under an authority field or naming its participant or a scope with a fragment reference, renders as authored, and a mandate admission refuses, one declaring `moves []` among them since 2026-10-12 (compliance C05), renders as no mandate, never as a refusal. It returns the frozen `{packet, digest, hostNote}`, never merged: `digest` is graph's codec `digest` of the packet, and the host note is position's note `{revision, capturedRevision?, previousRevision?, freshness, key}` with `installed: 'unknown (no join checked here)'`, which carries no digest. The packet is `{format: 'ia.position-packet.v1', revision, body, seat, participants, mandates, systems, tallies, intents, phases, commands, lines, provenance}`. `revision` is the K0 body's and `body` position(K0)'s digest. `seat` is K0's seat, the repository's own `@workspace`: `{identity?, sources, systems, steward?, participants?}`, `identity` absent when no admitted `@workspace` is declared at the repository root (R14), `sources` its `composition.sources` entries as authored, `systems` N, `steward` its `composition.steward` reference, and `participants` the text `none (no authored @mandate names an @agent)` exactly when no participant is rendered. A reference the packet prints is the identity of the admitted record its typed field reference resolves to, or, when none does, the reference as authored (`@<word> <name>`). `mandates` are the entries of body(K0)'s `mandates` (R17) at band 100 whose `authority.participant` resolves to an admitted `@agent` at band 100, by identity, each `{identity, participant, moves?, scope, excludedWords?, covers?}`: `moves`, `excludedWords` and `covers` are its unconditional `authority.moves`, `authority.excluded-words` and `authority.covers` as authored, each present exactly when the record states the key (a declared `moves []` would be `moves: []`, but admission refuses it since 2026-10-12; `moves` absent restricts no move), and `scope` its `authority.scope` references. `participants` are those agents, each once, by identity, as `{identity, says?}` with its `meaning.says`; `composition.steward` names no participant, and P = 0 is a packet, not a refusal. `systems` holds one pointer line per `composition.systems` reference of the seat, by identity: for an admitted record `{identity, words, band, steward?, reach}`, `words` the words its `discriminators` rows (`<word> lowers to <kind>`) register, sorted, `steward` its `head.steward` when that resolves, and `reach` `ia position --seat <identity>` (a `@system` carries no source locator, so `ia read` gives only its head `describes`, not its words or steward); for a reference no admitted record answers `{identity: <the reference as authored>, words: 'unresolved', steward: 'unresolved'}`. `tallies` are `{word, count}` by word: the band-100 records whose capture membership root is one of the seat's own declared roots, R15's capture members of a workspace seat. A seat that declares no root has no tally, as body(K0)'s `sources` unknown says: its fallback closure is what a position may enter, not what the workspace captures. A fresh init's tallies so count what it authors under `.ia/src @authored` (workspace, agent and mandate, the installed base being band 90), and the conformance corpus, which declares no root, has none. `intents` are the five SHAPE_ROWS shapes in table order, `{shape, category, primitive, phase, kinds, lanes, predicates, priming, words}`: `phase` is the primitive's PRIMITIVE_ANCHORS phase, and `words` the registered words whose lowering has its kind in the shape's kinds or, over the kind and each of its facets, a graph `laneOf` lane in its lanes, as R15 seeds a record. The lowerings are read from the floor's two registrations and the admitted `@system` records' `discriminators` rows, the first by identity should two lower one word. `phases` are the four phases in cycle order, `{phase, primitives, changes}`: `primitives` are those PRIMITIVE_ANCHORS anchors at the phase, and `changes` the fixed line `--phase selects the playbook cell delivered and decides which conditional relation rows apply` (R15 and R18). `commands` are the `catalog` rows the caller passes, in its order, each copied as its five fields `{command, mode, move, refuses, next}`. The CLI's catalog is the COMMANDS rows it tags, which `packetCatalog` in apps/cli builds for its caller to pass, since this package may not import that app: apps/cli's `renderProjectionFor` passes it for `ia host`, `ia project`, `ia doctor` and the install, update and remove refresh, and `tools/projections/generate.ts` for this repository. LEGACY_OPERATIONS are no catalog rows. `lines` are the three SPEC-owned lines with `ia scope` read as `ia position`, without markup and without their `source: <CLI SPEC>@<version>` suffix, which would put a CLI version in the packet. `provenance` is `{revision, slug?}`, `slug` the seat's name: identities stay as they are, and the repository slug is carried only here. The packet names no absolute path, scope token, time, capture state or CLI version, and no record at runtime placement is part of it (R15). Two roots so give byte-equal packets and digests, and a capture moves only the host note. `entryCount(packet)` is P participants + M mandates + 1 seat + N system lines + T tallies + 5 intent rows + 4 phase rows + C catalog rows + 1 provenance +
|
|
115
|
+
R19. Position packet (2026-10-08): `src/packet.ts`, exported from the package root and the `./internal/packet` subpath, publishes `renderPacket(handle, within, catalog)` and `entryCount(packet)` with the `PositionPacket`, `PacketCatalogRow`, `PacketSeat`, `PacketParticipant`, `PacketMandate`, `PacketSystem`, `PacketTally`, `PacketIntent`, `PacketPhase`, `PacketProvenance`, `PacketHostNote` and `PacketOutput` types; the root's `Packet` stays R03's context packet, so the position packet's type is `PositionPacket`. The packet is the one host-neutral thing a host adapter renders (an adapter may change file names, file count and markup, never content, ordering or numbers). `renderPacket` calls `position(handle, within)` (R16) once, at K0, and reads everything else through the same scope token: the snapshot and its D02a membership rows, directed views (db D09), the declared roots (db D02c) and the registered words (db D09a). A missing token is IA-RUNTIME-REQUEST-INVALID, an unknown, stale or closed one keeps its database code, and every other refusal is position's: the packet renders the records admission admitted and gates none of them, so an admitted mandate that `mandateAuthorityOf` would refuse, one with a child under an authority field or naming its participant or a scope with a fragment reference, renders as authored, and a mandate admission refuses, one declaring `moves []` among them since 2026-10-12 (compliance C05), renders as no mandate, never as a refusal. It returns the frozen `{packet, digest, hostNote}`, never merged: `digest` is graph's codec `digest` of the packet, and the host note is position's note `{revision, capturedRevision?, previousRevision?, freshness, key}` with `installed: 'unknown (no join checked here)'`, which carries no digest. The packet is `{format: 'ia.position-packet.v1', revision, body, seat, participants, mandates, systems, tallies, intents, phases, commands, lines, provenance}`. `revision` is the K0 body's and `body` position(K0)'s digest. `seat` is K0's seat, the repository's own `@workspace`: `{identity?, sources, systems, steward?, participants?}`, `identity` absent when no admitted `@workspace` is declared at the repository root (R14), `sources` its `composition.sources` entries as authored, `systems` N, `steward` its `composition.steward` reference, and `participants` the text `none (no authored @mandate names an @agent)` exactly when no participant is rendered. A reference the packet prints is the identity of the admitted record its typed field reference resolves to, or, when none does, the reference as authored (`@<word> <name>`). `mandates` are the entries of body(K0)'s `mandates` (R17) at band 100 whose `authority.participant` resolves to an admitted `@agent` at band 100, by identity, each `{identity, participant, moves?, scope, excludedWords?, covers?}`: `moves`, `excludedWords` and `covers` are its unconditional `authority.moves`, `authority.excluded-words` and `authority.covers` as authored, each present exactly when the record states the key (a declared `moves []` would be `moves: []`, but admission refuses it since 2026-10-12; `moves` absent restricts no move), and `scope` its `authority.scope` references. `participants` are those agents, each once, by identity, as `{identity, says?}` with its `meaning.says`; `composition.steward` names no participant, and P = 0 is a packet, not a refusal. `systems` holds one pointer line per `composition.systems` reference of the seat, by identity: for an admitted record `{identity, words, band, steward?, reach}`, `words` the words its `discriminators` rows (`<word> lowers to <kind>`) register, sorted, `steward` its `head.steward` when that resolves, and `reach` `ia position --seat <identity>` (a `@system` carries no source locator, so `ia read` gives only its head `describes`, not its words or steward); for a reference no admitted record answers `{identity: <the reference as authored>, words: 'unresolved', steward: 'unresolved'}`. `tallies` are `{word, count}` by word: the band-100 records whose capture membership root is one of the seat's own declared roots, R15's capture members of a workspace seat. A seat that declares no root has no tally, as body(K0)'s `sources` unknown says: its fallback closure is what a position may enter, not what the workspace captures. A fresh init's tallies so count what it authors under `.ia/src @authored` (workspace, agent and mandate, the installed base being band 90), and the conformance corpus, which declares no root, has none. `intents` are the five SHAPE_ROWS shapes in table order, `{shape, category, primitive, phase, kinds, lanes, predicates, priming, words}`: `phase` is the primitive's PRIMITIVE_ANCHORS phase, and `words` the registered words whose lowering has its kind in the shape's kinds or, over the kind and each of its facets, a graph `laneOf` lane in its lanes, as R15 seeds a record. The lowerings are read from the floor's two registrations and the admitted `@system` records' `discriminators` rows, the first by identity should two lower one word. `phases` are the four phases in cycle order, `{phase, primitives, changes}`: `primitives` are those PRIMITIVE_ANCHORS anchors at the phase, and `changes` the fixed line `--phase selects the playbook cell delivered and decides which conditional relation rows apply` (R15 and R18). `commands` are the `catalog` rows the caller passes, in its order, each copied as its five fields `{command, mode, move, refuses, next}`. The CLI's catalog is the COMMANDS rows it tags, which `packetCatalog` in apps/cli builds for its caller to pass, since this package may not import that app: apps/cli's `renderProjectionFor` passes it for `ia host`, `ia project`, `ia doctor` and the install, update and remove refresh, and `tools/projections/generate.ts` for this repository. LEGACY_OPERATIONS are no catalog rows. `lines` are the three SPEC-owned lines with `ia scope` read as `ia position`, without markup and without their `source: <CLI SPEC>@<version>` suffix, which would put a CLI version in the packet, then the session line naming the door's `ia_session`, the three lanes, `ia_catalogue` and `ia_method` (kit foundation, 2026-10-30). `provenance` is `{revision, slug?}`, `slug` the seat's name: identities stay as they are, and the repository slug is carried only here. The packet names no absolute path, scope token, time, capture state or CLI version, and no record at runtime placement is part of it (R15). Two roots so give byte-equal packets and digests, and a capture moves only the host note. `entryCount(packet)` is P participants + M mandates + 1 seat + N system lines + T tallies + 5 intent rows + 4 phase rows + C catalog rows + 1 provenance + 4 SPEC lines, the host note no entry. A fresh init (P = M = 1, T = 3) has 20 + C + N entries: 29 + N with the CLI's nine catalog rows. `tests/packet.test.ts` pins a golden packet in `tests/golden/` (revision and body digest masked and asserted apart; only `node packages/runtime/tests/golden/write.mjs` regenerates it) for the three records a fresh `ia init` authors (`tests/fixtures/packet/workspace.ia`) over the conformance corpus adopted at band 90, with 40 entries under a nine-row catalog fixture. It also pins the formula on that fixture, on the conformance corpus and on this repository's own records, its terms counted from the admitted records (N from the seat's `composition.systems`, T from the words of the band-100 membership rows under the seat's own declared roots, P and M from the band-100 mandates scoped to the seat whose participant is a band-100 agent) rather than from the packet, and pins these counts under the nine-row fixture: 29 on the conformance corpus and 54 on this repository after separating neutral examples from its live corpus, which its committed `CLAUDE.md` renders too; no participant and no refusal on the conformance corpus and for a mandate whose participant is adopted; two participants named by three mandates, each agent once and both by identity, with a mandate's excluded words and covers; a mandate declaring `moves []` refused by admission and rendered as no mandate, with position still running, and an admitted one with fragment references rendered with no refusal; an adopted mandate scoped to the seat left out; the tallies of a declared root narrower than the corpus, and none for a seat that declares no root; a narrowed scope token, which leaves out an @agent and a @system it does not admit (the system line `unresolved`, no participant or mandate, the steward as authored, no tally of the left-out word); a `@system` at runtime placement read as unresolved; a repository root no admitted `@workspace` is declared at, with no seat identity, system line, tally or slug; the frozen output, its intent rows copies of the kernel's; byte-equal packets and digests at two roots, naming neither root nor token; `body` equal to position(K0)'s digest; a capture moving the host note and neither the packet nor its digest; an unresolved `composition.systems` reference and system lines authored out of identity order; and the intent and phase tables, a word with an authority facet seeded under governance by its lane. apps/cli pins its catalog rows, each command's mode and move, a one-line refusal and one next command of COMMANDS.
|
|
110
116
|
|
|
111
117
|
R20. Host adapters (2026-10-09): `src/packet-host.ts`, exported from the package root and the `./internal/packet-host` subpath, publishes `renderHost(host, packet, digest, hostNote, target)` and `PACKET_MARKER` with the `PacketHost` (`claude` or `codex`), `PacketTarget` (`repository` or `consumer`), `HostFile`, `PacketReceipt` and `HostOutput` types. It renders one R19 packet, with the digest and host note `renderPacket` returned beside it, as the host's files and returns the frozen `HostOutput` `{files, receipt}`, each file `{path, text}` with a workspace-relative path. It is a pure function of its arguments and the package's own version, which it reads from its manifest: it reads no workspace and writes, deletes and plans no file, which the caller that applies does: apps/cli's `applyHostProjection` for a consumer workspace and `tools/projections/generate.ts` for this repository. An unknown host or target, or a `digest` that is not graph's codec digest of `packet`, is IA-RUNTIME-REQUEST-INVALID. No host is rendered an agent file (the system stewards are pointer lines, never agent definitions). The files by host and target: claude `consumer` `.claude/rules/ia-workspace.md` and `.claude/skills/ia-authoring/SKILL.md`; claude `repository` `CLAUDE.md`, `.claude/skills/ia-authoring/SKILL.md` and `.agents/skills/ia-authoring/SKILL.md`, the files this repository commits, which hold no steward agent; codex `AGENTS.md` and `.agents/skills/ia-authoring/SKILL.md` in either target, the `repository` entry file without the host note. Every file carries `PACKET_MARKER`, `<!-- Generated by ia project; edit the cited native records. -->`: first in the entry file, and in each `SKILL.md` after its YAML frontmatter and a blank line. The one generic `ia-authoring` skill per host stays (no skill is rendered per system or playbook), its text chosen by target, not host, byte for byte as compliance's 1.x renderers wrote it but for the marker line: the `repository` skill is renderHostArtifacts' and the `consumer` skill renderWorkspaceProjection's, its `Source revision` the packet's revision (both renderers are retired, compliance SPEC C22–C24). The entry file is the marker; then the packet's sections under the title `# IA position packet: <provenance slug>` (`# IA position packet` when the packet has no slug), in the packet's field order: the seat line, the participants, the mandates, the system pointer lines, the captured-record tallies, the intent table, the phase table, the command catalog and the SPEC lines, each an `## ` heading over its entries, one entry per list item or table body row, a section with no entry left out with its heading; then one provenance line `ia-generated <revision> <packet digest> <adapter>`, `<adapter>` being `ia-claude` or `ia-codex`, followed by `@<the package version>` in the `consumer` target only, so this repository's committed `CLAUDE.md` does not move when a release bumps the version; then, in the `consumer` target only, the section `## Host note (not part of the packet)` with the note's freshness, installed state and key, the key as `ia position` prints it (a location seat `''` as `.`). The entry file so renders exactly `entryCount(packet)` entries, the provenance line among them and the host note none. The rendering is markup only (an adapter changes file names, file count and markup, never content, ordering or numbers): every section value is printed in the packet's field order, except that the title prints the provenance slug, and `format`, `revision` and `body` are not printed apart, since the provenance line's revision and packet digest cover them and the receipt carries `body` as `bodyDigest`; identities, references, sources, covers paths and commands are code spans, each fenced past the backticks it holds; each bare IA word token in free text (an `@` and a word as the language spells one, `[a-z][a-z0-9-]*`, with no letter, digit, `_`, `.`, `-`, `/`, `@` or backtick before it and no word character, `-`, `/`, `@` or backtick after it, so neither an address, a scoped package such as `@inventarch/db` nor a token touching a backtick, which no fence could wrap without joining that run, and outside every authored code span, found as CommonMark finds one: a whole backtick run, its text and the next run of the same length) is a code span too, its fence one backtick or, when the value holds a backtick run no span closes, longer than every such run, and the authored span is kept as written whatever tokens it holds, so neither the committed `CLAUDE.md` nor a consumer file renders `@workspace` or `@plan` as a GitHub mention unless the author wrote it touching a backtick, the packet's values and entries unchanged; a line break in a value is printed as one space, so an entry stays one line; line folding scans in linear time even when long space/tab runs have no following line break, retaining all other bytes and the existing whitespace boundaries; a pipe in a table cell is escaped; an empty list prints `none`; and a seat without an identity prints `workspace undeclared`. The sections are byte-identical for both hosts and both targets: in one target the claude and codex entry files differ only in the adapter the provenance line names. The receipt is `{format: 'ia.packet-receipt.v1', host, cli, adapter, revision, slug, packetDigest, bodyDigest, entries, files, removed, foreign, guard, hostNote, participants, mandates, writtenAt}`: `adapter` the adapter id with the package version in either target, `revision` the packet's, `slug` the packet's provenance slug or null when it has none (the repository slug is kept in provenance and receipts, never in identities), `packetDigest` the digest passed, `bodyDigest` the packet's `body`, `entries` entryCount(packet), `files` each rendered file as `{path, sha256}` in render order with the SHA-256 of its UTF-8 text, `hostNote` a copy of the note, and `participants` and `mandates` the packet's identities. renderHost leaves `removed` and `foreign` empty, `guard` `none`, and `cli` and `writtenAt` null: the caller that applies the files sets them to the owned legacy files it deleted (each `{path, sha256}`), the files it left in place as foreign, `retired` when it retired a steward-guard registration first, its own id@version (only the applying CLI knows it) and the time it wrote, and writes the receipt beside the projection state (apps/cli `applyHostProjection`). The receipt carries no source digests and no consumer id@version per command invoked. `tests/packet-host.test.ts` pins both hosts and both targets on R19's fresh-init fixture packet and on this repository's own records: the file paths, none under `.claude/agents`; the title naming the slug; the marker first in each entry file and after each skill's frontmatter and a blank line; `entryCount(packet)` rendered entries with the sections in the packet's field order; byte-equal sections across hosts and targets; and each receipt's file digests. It also pins the repository skills equal to this repository's committed files, which `pnpm projections:generate` renders with this adapter and runtime:test hashes as inputs (tools/testing's `host-adapters` input profile); this repository's one participant and one mandate entry; on a fresh init, the consumer skill's text, the adapter version and the host note in the consumer target alone, and the receipt's adapter version in both; a hand-built packet rendered to exact text, with an unresolved system line, a multi-line non-ASCII `says`, a backtick in a path and a pipe in a catalog row, and one with no participant, seat identity, system line, tally or command; the host note's key with an identity seat and a word and with two location seats, the root printed `.`, and a code span a backtick starts or ends padded inside its fence; frozen output, byte-equal at two fresh-init roots and naming neither, the caller's note left unfrozen; each bare IA word token in a participant's `says`, a catalog row's refusal and a SPEC line rendered as a code span in every host and target, an address, a scoped package and a token already in an authored code span, opening it, after a space or a `[` inside it or beside another token in a double-backtick span, left as they are with the span, a token after a backtick no run closes fenced past it, and one touching such a backtick left as authored, no bare token left in the seat line of a packet without a participant or in this repository's packet, the entry count and the packet unchanged, and the receipt's slug null for a packet without one; and the three refusals.
|
|
112
118
|
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bindings: which kit and capability answer an entry point's activity in a repository, read from the interim sidecar
|
|
3
|
+
* `<repo>/.ia/bindings.json`:
|
|
4
|
+
* `{ format: 1, bindings: { "<entry>.<activity>": binding | [binding, ...] }, precedence?: [kit id, ...], defaults?: { <entry>: binding } }`,
|
|
5
|
+
* where a binding is `{ kit, capability, profile? }`. `<entry>.*` answers every activity of the entry without an exact
|
|
6
|
+
* key, and `defaults.<entry>` answers when neither does. Several candidates for one key conflict unless `precedence`
|
|
7
|
+
* orders them. The entry points are Work, Delivery and Knowledge; Delivery took Development's place.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ENTRIES: readonly ["work", "delivery", "knowledge"];
|
|
10
|
+
export type Entry = (typeof ENTRIES)[number];
|
|
11
|
+
export declare const RENAMED: Readonly<Record<string, string>>;
|
|
12
|
+
export declare const renamedMessage: (entry: string) => string;
|
|
13
|
+
export interface Binding {
|
|
14
|
+
readonly kit: string;
|
|
15
|
+
readonly capability: string;
|
|
16
|
+
readonly profile?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface Bindings {
|
|
19
|
+
readonly format: 1;
|
|
20
|
+
readonly path: string;
|
|
21
|
+
readonly bindings: Readonly<Record<string, readonly Binding[]>>;
|
|
22
|
+
readonly precedence: readonly string[];
|
|
23
|
+
readonly defaults: Readonly<Record<string, Binding>>;
|
|
24
|
+
}
|
|
25
|
+
export interface SelectedBinding extends Binding {
|
|
26
|
+
readonly key: string;
|
|
27
|
+
readonly via: string;
|
|
28
|
+
}
|
|
29
|
+
export declare const bindingsPath: (root: string) => string;
|
|
30
|
+
/** The parsed sidecar, or null when the repository has none. */
|
|
31
|
+
export declare function readBindings(root: string): Bindings | null;
|
|
32
|
+
/** The one binding for `<entry>.<activity>`, with how it was chosen: exact, wildcard or default, then precedence. */
|
|
33
|
+
export declare function selectBinding(data: Bindings | null, entry: string, activity: string): SelectedBinding;
|
|
34
|
+
/** The nearest folder at or above `from` that holds `.ia/src`, or null. */
|
|
35
|
+
export declare function findWorkspace(from: string): string | null;
|
|
36
|
+
/**
|
|
37
|
+
* The scope key each entry point's activity states to the position: a shape (the intent) and a phase (the moment). An
|
|
38
|
+
* activity the table does not name takes its entry's default; an explicit shape or phase overrides either.
|
|
39
|
+
*/
|
|
40
|
+
export declare const SCOPE_KEYS: Readonly<Record<Entry, Readonly<Record<string, readonly [string, string]>>>>;
|
|
41
|
+
export declare const SHAPES: readonly ["context", "governance", "execution", "sequence", "learning"];
|
|
42
|
+
export declare const PHASES: readonly ["orient", "plan", "act", "learn"];
|
|
43
|
+
export declare function scopeKey(entry: string, activity: string, overrides?: {
|
|
44
|
+
readonly shape?: string | undefined;
|
|
45
|
+
readonly phase?: string | undefined;
|
|
46
|
+
}): {
|
|
47
|
+
readonly shape: string;
|
|
48
|
+
readonly phase: string;
|
|
49
|
+
readonly mapped: boolean;
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=bindings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindings.d.ts","sourceRoot":"","sources":["../../src/method/bindings.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,4CAA6C,CAAC;AAClE,MAAM,MAAM,KAAK,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAC7C,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAA+B,CAAC;AACrF,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,KAAG,MAC0D,CAAC;AAE1G,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AACD,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC,CAAC,CAAC;IAChE,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAA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ync, realpathSync } from 'node:fs';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { MethodError } from './errors.js';
|
|
4
|
+
/**
|
|
5
|
+
* Bindings: which kit and capability answer an entry point's activity in a repository, read from the interim sidecar
|
|
6
|
+
* `<repo>/.ia/bindings.json`:
|
|
7
|
+
* `{ format: 1, bindings: { "<entry>.<activity>": binding | [binding, ...] }, precedence?: [kit id, ...], defaults?: { <entry>: binding } }`,
|
|
8
|
+
* where a binding is `{ kit, capability, profile? }`. `<entry>.*` answers every activity of the entry without an exact
|
|
9
|
+
* key, and `defaults.<entry>` answers when neither does. Several candidates for one key conflict unless `precedence`
|
|
10
|
+
* orders them. The entry points are Work, Delivery and Knowledge; Delivery took Development's place.
|
|
11
|
+
*/
|
|
12
|
+
export const ENTRIES = ['work', 'delivery', 'knowledge'];
|
|
13
|
+
export const RENAMED = { development: 'delivery' };
|
|
14
|
+
export const renamedMessage = (entry) => `the ${entry} entry point is now ${RENAMED[entry]}: write ${RENAMED[entry]} where ${entry} was written`;
|
|
15
|
+
export const bindingsPath = (root) => join(root, '.ia', 'bindings.json');
|
|
16
|
+
function checkBinding(value, where) {
|
|
17
|
+
const row = value;
|
|
18
|
+
if (typeof row !== 'object' ||
|
|
19
|
+
row === null ||
|
|
20
|
+
typeof row['kit'] !== 'string' ||
|
|
21
|
+
typeof row['capability'] !== 'string')
|
|
22
|
+
throw new MethodError(`${where} needs { kit, capability }`, 'IA-CORE-BINDINGS-MALFORMED');
|
|
23
|
+
return {
|
|
24
|
+
kit: row['kit'],
|
|
25
|
+
capability: row['capability'],
|
|
26
|
+
...(row['profile'] ? { profile: row['profile'] } : {}),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** The parsed sidecar, or null when the repository has none. */
|
|
30
|
+
export function readBindings(root) {
|
|
31
|
+
const path = bindingsPath(root);
|
|
32
|
+
if (!existsSync(path))
|
|
33
|
+
return null;
|
|
34
|
+
let parsed;
|
|
35
|
+
try {
|
|
36
|
+
parsed = JSON.parse(readFileSync(path, 'utf8'));
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
throw new MethodError(`${path} is not JSON: ${error.message}`, 'IA-CORE-BINDINGS-MALFORMED');
|
|
40
|
+
}
|
|
41
|
+
const declared = parsed['bindings'];
|
|
42
|
+
if (parsed['format'] !== 1 || typeof declared !== 'object' || declared === null)
|
|
43
|
+
throw new MethodError(`${path} needs format 1 and a bindings object`, 'IA-CORE-BINDINGS-MALFORMED');
|
|
44
|
+
const bindings = {};
|
|
45
|
+
for (const [key, value] of Object.entries(declared)) {
|
|
46
|
+
if (!/^[a-z]+\.(?:[a-z][a-z0-9-]*|\*)$/.test(key))
|
|
47
|
+
throw new MethodError(`${path}: key ${key} is not <entry>.<activity>`, 'IA-CORE-BINDINGS-MALFORMED');
|
|
48
|
+
const entry = key.slice(0, key.indexOf('.'));
|
|
49
|
+
if (RENAMED[entry])
|
|
50
|
+
throw new MethodError(`${path}: key ${key}: ${renamedMessage(entry)}, so ${RENAMED[entry]}${key.slice(entry.length)}`, 'IA-CORE-BINDINGS-MALFORMED', { key });
|
|
51
|
+
bindings[key] = (Array.isArray(value) ? value : [value]).map((v, i) => checkBinding(v, `${path}: ${key}[${i}]`));
|
|
52
|
+
}
|
|
53
|
+
const precedence = parsed['precedence'] ?? [];
|
|
54
|
+
if (!Array.isArray(precedence) || !precedence.every((p) => typeof p === 'string'))
|
|
55
|
+
throw new MethodError(`${path}: precedence must be a list of kit ids`, 'IA-CORE-BINDINGS-MALFORMED');
|
|
56
|
+
const defaults = {};
|
|
57
|
+
for (const [entry, value] of Object.entries((parsed['defaults'] ?? {}))) {
|
|
58
|
+
if (RENAMED[entry])
|
|
59
|
+
throw new MethodError(`${path}: defaults.${entry}: ${renamedMessage(entry)}, so defaults.${RENAMED[entry]}`, 'IA-CORE-BINDINGS-MALFORMED');
|
|
60
|
+
defaults[entry] = checkBinding(value, `${path}: defaults.${entry}`);
|
|
61
|
+
}
|
|
62
|
+
return { format: 1, path, bindings, precedence: precedence, defaults };
|
|
63
|
+
}
|
|
64
|
+
/** The one binding for `<entry>.<activity>`, with how it was chosen: exact, wildcard or default, then precedence. */
|
|
65
|
+
export function selectBinding(data, entry, activity) {
|
|
66
|
+
if (RENAMED[entry])
|
|
67
|
+
throw new MethodError(renamedMessage(entry), 'IA-CORE-USAGE');
|
|
68
|
+
if (!ENTRIES.includes(entry))
|
|
69
|
+
throw new MethodError(`unknown entry point ${entry}; the entry points are ${ENTRIES.join(', ')}`, 'IA-CORE-USAGE');
|
|
70
|
+
const key = `${entry}.${activity}`;
|
|
71
|
+
const none = () => new MethodError(`no method is bound for ${key} in this repository: .ia/bindings.json names no ${key}, no ${entry}.*, and no defaults.${entry}. List the kits with kit.mjs list and bind one with bind.mjs set ${key} <kit> <capability>`, 'IA-CORE-NO-METHOD', { key });
|
|
72
|
+
if (!data)
|
|
73
|
+
throw none();
|
|
74
|
+
let candidates, via;
|
|
75
|
+
const exact = data.bindings[key], wildcard = data.bindings[`${entry}.*`], fallback = data.defaults[entry];
|
|
76
|
+
if (exact?.length) {
|
|
77
|
+
candidates = exact;
|
|
78
|
+
via = 'exact';
|
|
79
|
+
}
|
|
80
|
+
else if (wildcard?.length) {
|
|
81
|
+
candidates = wildcard;
|
|
82
|
+
via = 'wildcard';
|
|
83
|
+
}
|
|
84
|
+
else if (fallback) {
|
|
85
|
+
candidates = [fallback];
|
|
86
|
+
via = 'default';
|
|
87
|
+
}
|
|
88
|
+
else
|
|
89
|
+
throw none();
|
|
90
|
+
if (candidates.length === 1)
|
|
91
|
+
return { ...candidates[0], key, via };
|
|
92
|
+
const ranked = candidates
|
|
93
|
+
.map((c) => ({ c, rank: data.precedence.indexOf(c.kit) }))
|
|
94
|
+
.filter((r) => r.rank >= 0)
|
|
95
|
+
.sort((a, b) => a.rank - b.rank);
|
|
96
|
+
if (ranked.length === 0 || (ranked.length > 1 && ranked[0].rank === ranked[1].rank))
|
|
97
|
+
throw new MethodError(`${key} is bound to ${candidates.length} methods and precedence does not order them: ${candidates.map((c) => `${c.kit}#${c.capability}`).join(', ')}. Run bind.mjs precedence <kit...> to rank the kits, or bind.mjs set ${key} <kit> <capability> to keep one`, 'IA-CORE-CONFLICT', { key, candidates: candidates.map((c) => ({ kit: c.kit, capability: c.capability })) });
|
|
98
|
+
return { ...ranked[0].c, key, via: `${via}+precedence` };
|
|
99
|
+
}
|
|
100
|
+
/** The nearest folder at or above `from` that holds `.ia/src`, or null. */
|
|
101
|
+
export function findWorkspace(from) {
|
|
102
|
+
let dir = resolve(from);
|
|
103
|
+
try {
|
|
104
|
+
dir = realpathSync.native(dir);
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
dir = resolve(from);
|
|
108
|
+
}
|
|
109
|
+
for (let i = 0; i < 64; i++) {
|
|
110
|
+
if (existsSync(join(dir, '.ia', 'src')))
|
|
111
|
+
return dir;
|
|
112
|
+
const parent = dirname(dir);
|
|
113
|
+
if (parent === dir)
|
|
114
|
+
return null;
|
|
115
|
+
dir = parent;
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* The scope key each entry point's activity states to the position: a shape (the intent) and a phase (the moment). An
|
|
121
|
+
* activity the table does not name takes its entry's default; an explicit shape or phase overrides either.
|
|
122
|
+
*/
|
|
123
|
+
export const SCOPE_KEYS = {
|
|
124
|
+
work: {
|
|
125
|
+
default: ['governance', 'plan'],
|
|
126
|
+
task: ['governance', 'plan'],
|
|
127
|
+
decision: ['governance', 'plan'],
|
|
128
|
+
dependencies: ['sequence', 'plan'],
|
|
129
|
+
delegation: ['execution', 'act'],
|
|
130
|
+
progress: ['context', 'orient'],
|
|
131
|
+
completion: ['learning', 'learn'],
|
|
132
|
+
},
|
|
133
|
+
delivery: {
|
|
134
|
+
default: ['execution', 'act'],
|
|
135
|
+
understand: ['context', 'orient'],
|
|
136
|
+
design: ['governance', 'plan'],
|
|
137
|
+
change: ['execution', 'act'],
|
|
138
|
+
diagnose: ['context', 'orient'],
|
|
139
|
+
review: ['learning', 'learn'],
|
|
140
|
+
deliver: ['learning', 'learn'],
|
|
141
|
+
},
|
|
142
|
+
knowledge: {
|
|
143
|
+
default: ['context', 'orient'],
|
|
144
|
+
find: ['context', 'orient'],
|
|
145
|
+
explain: ['context', 'orient'],
|
|
146
|
+
packet: ['context', 'orient'],
|
|
147
|
+
place: ['governance', 'plan'],
|
|
148
|
+
reconcile: ['learning', 'learn'],
|
|
149
|
+
maintain: ['execution', 'act'],
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
export const SHAPES = ['context', 'governance', 'execution', 'sequence', 'learning'];
|
|
153
|
+
export const PHASES = ['orient', 'plan', 'act', 'learn'];
|
|
154
|
+
export function scopeKey(entry, activity, overrides = {}) {
|
|
155
|
+
const table = Object.hasOwn(SCOPE_KEYS, entry) ? SCOPE_KEYS[entry] : null;
|
|
156
|
+
if (!table)
|
|
157
|
+
throw new MethodError(`unknown entry point ${entry}; the entry points are ${Object.keys(SCOPE_KEYS).join(', ')}`, 'IA-CORE-USAGE');
|
|
158
|
+
const mapped = Object.hasOwn(table, activity);
|
|
159
|
+
const [shape, phase] = (mapped ? table[activity] : table['default']);
|
|
160
|
+
if (overrides.shape && !SHAPES.includes(overrides.shape))
|
|
161
|
+
throw new MethodError(`--shape must be one of ${SHAPES.join(', ')}`, 'IA-CORE-USAGE');
|
|
162
|
+
if (overrides.phase && !PHASES.includes(overrides.phase))
|
|
163
|
+
throw new MethodError(`--phase must be one of ${PHASES.join(', ')}`, 'IA-CORE-USAGE');
|
|
164
|
+
return { shape: overrides.shape ?? shape, phase: overrides.phase ?? phase, mapped };
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=bindings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindings.js","sourceRoot":"","sources":["../../src/method/bindings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YA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AW,CACnB,uBAAuB,KAAK,0BAA0B,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAC1F,eAAe,CAChB,CAAC;IACJ,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC9C,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAE,CAAC;IACtE,IAAI,SAAS,CAAC,KAAK,IAAI,CAAE,MAA4B,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC;QAC7E,MAAM,IAAI,WAAW,CAAC,0BAA0B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,eAAe,CAAC,CAAC;IACxF,IAAI,SAAS,CAAC,KAAK,IAAI,CAAE,MAA4B,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC;QAC7E,MAAM,IAAI,WAAW,CAAC,0BAA0B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,eAAe,CAAC,CAAC;IACxF,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,IAAI,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,IAAI,KAAK,EAAE,MAAM,EAAE,CAAC;AACtF,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Entry } from './bindings.js';
|
|
2
|
+
import type { Kit } from './kits.js';
|
|
3
|
+
/**
|
|
4
|
+
* A lane's catalogue: the activities a model can map a request to, each a key it then hands to `resolveMethod`. Its
|
|
5
|
+
* sources are each kit's `bindings.json` recommendations for the lane, the workspace's `.ia/bindings.json`, and each
|
|
6
|
+
* lane kit's `delivery.json` whole capabilities no key yet names. An item is `bound` when the workspace binds its key,
|
|
7
|
+
* else `installed`; `entitled` is an account connector's and never this catalogue's. No free text is read: the lane,
|
|
8
|
+
* word and phase are closed tokens.
|
|
9
|
+
*/
|
|
10
|
+
export type CatalogueState = 'bound' | 'installed' | 'entitled';
|
|
11
|
+
export interface CatalogueItem {
|
|
12
|
+
readonly key: string;
|
|
13
|
+
readonly display: string;
|
|
14
|
+
readonly kit: string;
|
|
15
|
+
readonly version: string | null;
|
|
16
|
+
readonly capability?: string;
|
|
17
|
+
readonly profile?: string;
|
|
18
|
+
readonly description: string;
|
|
19
|
+
readonly state: CatalogueState;
|
|
20
|
+
}
|
|
21
|
+
export interface Catalogue {
|
|
22
|
+
readonly lane: Entry;
|
|
23
|
+
readonly items: readonly CatalogueItem[];
|
|
24
|
+
}
|
|
25
|
+
export declare const DESCRIPTION_LIMIT = 200;
|
|
26
|
+
/** `ia-<lane>:<activity>`, and `ia-<lane>` for the lane's own `<lane>.*` key. */
|
|
27
|
+
export declare const displayName: (key: string) => string;
|
|
28
|
+
/** Each `@capability` record's `meaning.says` in a kit's sources, by name, read as text without opening the kit. */
|
|
29
|
+
export declare function capabilityDescriptions(kitDir: string): ReadonlyMap<string, string>;
|
|
30
|
+
/** The catalogue of one lane, for a workspace root (or none) and the kits a resolve can read. */
|
|
31
|
+
export declare function laneCatalogue(request: {
|
|
32
|
+
readonly lane: string;
|
|
33
|
+
readonly word?: string;
|
|
34
|
+
readonly phase?: string;
|
|
35
|
+
}, context: {
|
|
36
|
+
readonly root: string | null;
|
|
37
|
+
readonly kits: readonly Kit[];
|
|
38
|
+
}): Catalogue;
|
|
39
|
+
//# sourceMappingURL=catalogue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalogue.d.ts","sourceRoot":"","sources":["../../src/method/catalogue.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAG3C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAErC;;;;;;GAMG;AACH,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FileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { ENTRIES, SCOPE_KEYS, readBindings } from './bindings.js';
|
|
4
|
+
import { MethodError } from './errors.js';
|
|
5
|
+
import { kitBindings, kitDelivery } from './kits.js';
|
|
6
|
+
export const DESCRIPTION_LIMIT = 200;
|
|
7
|
+
/** `ia-<lane>:<activity>`, and `ia-<lane>` for the lane's own `<lane>.*` key. */
|
|
8
|
+
export const displayName = (key) => {
|
|
9
|
+
const [lane, activity] = key.split('.');
|
|
10
|
+
return activity === '*' ? `ia-${lane}` : `ia-${lane}:${activity}`;
|
|
11
|
+
};
|
|
12
|
+
const oneLine = (text) => {
|
|
13
|
+
const flat = text.replace(/\s+/g, ' ').trim();
|
|
14
|
+
if (flat.length <= DESCRIPTION_LIMIT)
|
|
15
|
+
return flat;
|
|
16
|
+
const sentence = flat.slice(0, DESCRIPTION_LIMIT).match(/^.*?[.!?](?=\s|$)/)?.[0];
|
|
17
|
+
return sentence && sentence.length >= 40 ? sentence : `${flat.slice(0, DESCRIPTION_LIMIT - 1).trimEnd()}…`;
|
|
18
|
+
};
|
|
19
|
+
/** Each `@capability` record's `meaning.says` in a kit's sources, by name, read as text without opening the kit. */
|
|
20
|
+
export function capabilityDescriptions(kitDir) {
|
|
21
|
+
const found = new Map();
|
|
22
|
+
const systems = join(kitDir, '.ia', 'src', 'systems');
|
|
23
|
+
if (!existsSync(systems))
|
|
24
|
+
return found;
|
|
25
|
+
for (const system of readdirSync(systems).sort()) {
|
|
26
|
+
const records = join(systems, system, 'records');
|
|
27
|
+
const files = [
|
|
28
|
+
join(systems, system, 'system.ia'),
|
|
29
|
+
...(existsSync(records) ? readdirSync(records).map((file) => join(records, file)) : []),
|
|
30
|
+
].filter((file) => file.endsWith('.ia') && existsSync(file));
|
|
31
|
+
for (const file of files) {
|
|
32
|
+
const text = readFileSync(file, 'utf8').replace(/\r\n/g, '\n');
|
|
33
|
+
for (const block of text.split(/^(?=@)/m)) {
|
|
34
|
+
const head = /^@capability ([a-z0-9][a-z0-9-]*)/.exec(block);
|
|
35
|
+
const says = /^\s+says "((?:[^"\\]|\\.)*)"/m.exec(block);
|
|
36
|
+
if (head && says && !found.has(head[1]))
|
|
37
|
+
found.set(head[1], says[1].replace(/\\(.)/g, '$1'));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return found;
|
|
42
|
+
}
|
|
43
|
+
/** The phase an activity states to the position (`SCOPE_KEYS`), its lane's default when the table names none. */
|
|
44
|
+
const phaseOf = (lane, activity) => (SCOPE_KEYS[lane][activity] ?? SCOPE_KEYS[lane]['default'])[1];
|
|
45
|
+
/** The catalogue of one lane, for a workspace root (or none) and the kits a resolve can read. */
|
|
46
|
+
export function laneCatalogue(request, context) {
|
|
47
|
+
if (!ENTRIES.includes(request.lane))
|
|
48
|
+
throw new MethodError(`lane must be one of ${ENTRIES.join(', ')}`, 'IA-CORE-USAGE');
|
|
49
|
+
const lane = request.lane;
|
|
50
|
+
const byId = new Map(context.kits.map((kit) => [kit.id, kit]));
|
|
51
|
+
const descriptions = new Map();
|
|
52
|
+
const describe = (kitId, capability) => {
|
|
53
|
+
const kit = byId.get(kitId);
|
|
54
|
+
if (kit === undefined)
|
|
55
|
+
return '';
|
|
56
|
+
if (!descriptions.has(kitId))
|
|
57
|
+
descriptions.set(kitId, capabilityDescriptions(kit.dir));
|
|
58
|
+
return oneLine(descriptions.get(kitId).get(capability) ?? '');
|
|
59
|
+
};
|
|
60
|
+
const versionOf = (kitId) => {
|
|
61
|
+
const kit = byId.get(kitId);
|
|
62
|
+
return kit === undefined ? null : (kit.latest?.version ?? kit.version ?? null);
|
|
63
|
+
};
|
|
64
|
+
const items = new Map();
|
|
65
|
+
const add = (key, row, state) => {
|
|
66
|
+
items.set(key, {
|
|
67
|
+
key,
|
|
68
|
+
display: displayName(key),
|
|
69
|
+
kit: row.kit,
|
|
70
|
+
version: versionOf(row.kit),
|
|
71
|
+
capability: row.capability,
|
|
72
|
+
...(row.profile === undefined ? {} : { profile: row.profile }),
|
|
73
|
+
description: describe(row.kit, row.capability),
|
|
74
|
+
state,
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
for (const kit of context.kits) {
|
|
78
|
+
let recommend;
|
|
79
|
+
try {
|
|
80
|
+
({ recommend } = kitBindings(kit));
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
const own = Object.entries(recommend).filter(([key]) => key.startsWith(`${lane}.`));
|
|
86
|
+
for (const [key, row] of own)
|
|
87
|
+
if (!items.has(key))
|
|
88
|
+
add(key, row, 'installed');
|
|
89
|
+
if (own.length === 0)
|
|
90
|
+
continue;
|
|
91
|
+
let whole = [];
|
|
92
|
+
try {
|
|
93
|
+
whole = kitDelivery(kit).whole;
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
whole = [];
|
|
97
|
+
}
|
|
98
|
+
const named = new Set(own.map(([, row]) => row.capability));
|
|
99
|
+
for (const capability of whole) {
|
|
100
|
+
const key = `${lane}.${capability}`;
|
|
101
|
+
if (!named.has(capability) && !items.has(key))
|
|
102
|
+
add(key, { kit: kit.id, capability }, 'installed');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const bound = context.root === null ? null : readBindings(context.root);
|
|
106
|
+
if (bound !== null)
|
|
107
|
+
for (const [key, rows] of Object.entries(bound.bindings)) {
|
|
108
|
+
if (!key.startsWith(`${lane}.`))
|
|
109
|
+
continue;
|
|
110
|
+
const ranked = rows.length === 1 ? rows[0] : (rows.find((row) => bound.precedence.includes(row.kit)) ?? rows[0]);
|
|
111
|
+
if (ranked !== undefined)
|
|
112
|
+
add(key, ranked, 'bound');
|
|
113
|
+
}
|
|
114
|
+
const listed = [...items.values()]
|
|
115
|
+
.filter((item) => {
|
|
116
|
+
const activity = item.key.slice(lane.length + 1);
|
|
117
|
+
if (request.word !== undefined && activity !== request.word)
|
|
118
|
+
return false;
|
|
119
|
+
if (request.phase !== undefined && activity !== '*' && phaseOf(lane, activity) !== request.phase)
|
|
120
|
+
return false;
|
|
121
|
+
return true;
|
|
122
|
+
})
|
|
123
|
+
.sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0));
|
|
124
|
+
return { lane, items: listed };
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=catalogue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalogue.js","sourceRoot":"","sources":["../../src/method/catalogue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAyBrD,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAErC,iFAAiF;AACjF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAW,EAAU,EAAE;IACjD,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAqB,CAAC;IAC5D,OAAO,QAAQ,KAAK,GAAG,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;AACpE,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG,CAAC,IAAY,EAAU,EAAE;IACvC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IAC9C,IAAI,IAAI,CAAC,MAAM,IAAI,iBAAiB;QAAE,OAAO,IAAI,CAAC;IAClD,M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GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACjD,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,IAAI,QAAQ,KAAK,OAAO,CAAC,IAAI;YAAE,OAAO,KAAK,CAAC;QAC1E,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,IAAI,QAAQ,KAAK,GAAG,IAAI,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,KAAK,OAAO,CAAC,KAAK;YAAE,OAAO,KAAK,CAAC;QAC/G,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;SACD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAChE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A method refusal: the `{ error: { code, message, candidates?, key? } }` payload the `ia` plugin's resolver prints, so a
|
|
3
|
+
* host that reads one reads the other.
|
|
4
|
+
*/
|
|
5
|
+
export declare class MethodError extends Error {
|
|
6
|
+
readonly code: string;
|
|
7
|
+
readonly candidates?: readonly unknown[];
|
|
8
|
+
readonly key?: string;
|
|
9
|
+
readonly pinnedRoot?: string;
|
|
10
|
+
constructor(message: string, code: string, extra?: {
|
|
11
|
+
readonly candidates?: readonly unknown[];
|
|
12
|
+
readonly key?: string;
|
|
13
|
+
readonly pinnedRoot?: string;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
export interface MethodRefusal {
|
|
17
|
+
readonly error: {
|
|
18
|
+
readonly code: string;
|
|
19
|
+
readonly message: string;
|
|
20
|
+
readonly candidates?: readonly unknown[];
|
|
21
|
+
readonly key?: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** The refusal payload for any thrown value; a value without a code is `IA-CORE-ERROR`. */
|
|
25
|
+
export declare function methodRefusal(error: unknown): MethodRefusal;
|
|
26
|
+
/** A JSON object member as a plain record, or undefined. */
|
|
27
|
+
export declare const objectAt: (value: unknown) => Record<string, unknown> | undefined;
|
|
28
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/method/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;IACzC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;gBAE3B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,KAAK,GAAE;QAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;QAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAO;CAQhH;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE;QACd,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;QACzC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAED,2FAA2F;AAC3F,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,CAe3D;AAED,4DAA4D;AAC5D,eAAO,MAAM,QAAQ,GAAI,OAAO,OAAO,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SACmD,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A method refusal: the `{ error: { code, message, candidates?, key? } }` payload the `ia` plugin's resolver prints, so a
|
|
3
|
+
* host that reads one reads the other.
|
|
4
|
+
*/
|
|
5
|
+
export class MethodError extends Error {
|
|
6
|
+
code;
|
|
7
|
+
candidates;
|
|
8
|
+
key;
|
|
9
|
+
pinnedRoot;
|
|
10
|
+
constructor(message, code, extra = {}) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.code = code;
|
|
13
|
+
if (extra.candidates !== undefined)
|
|
14
|
+
this.candidates = extra.candidates;
|
|
15
|
+
if (extra.key !== undefined)
|
|
16
|
+
this.key = extra.key;
|
|
17
|
+
if (extra.pinnedRoot !== undefined)
|
|
18
|
+
this.pinnedRoot = extra.pinnedRoot;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** The refusal payload for any thrown value; a value without a code is `IA-CORE-ERROR`. */
|
|
22
|
+
export function methodRefusal(error) {
|
|
23
|
+
const code = error !== null && typeof error === 'object' && 'code' in error && typeof error.code === 'string'
|
|
24
|
+
? error.code
|
|
25
|
+
: 'IA-CORE-ERROR';
|
|
26
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
27
|
+
const extra = error instanceof MethodError ? error : undefined;
|
|
28
|
+
return {
|
|
29
|
+
error: {
|
|
30
|
+
code,
|
|
31
|
+
message,
|
|
32
|
+
...(extra?.candidates === undefined ? {} : { candidates: extra.candidates }),
|
|
33
|
+
...(extra?.key === undefined ? {} : { key: extra.key }),
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** A JSON object member as a plain record, or undefined. */
|
|
38
|
+
export const objectAt = (value) => value !== null && typeof value === 'object' && !Array.isArray(value) ? value : undefined;
|
|
39
|
+
//# sourceMappingURL=errors.js.map
|