@inventarch/runtime 1.1.1 → 2.0.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.
Files changed (66) hide show
  1. package/LANGUAGE.md +2 -2
  2. package/README.md +17 -1
  3. package/SPEC.md +28 -4
  4. package/dist/context.d.ts +10 -1
  5. package/dist/context.d.ts.map +1 -1
  6. package/dist/context.js +14 -5
  7. package/dist/context.js.map +1 -1
  8. package/dist/coordinate.d.ts +9 -2
  9. package/dist/coordinate.d.ts.map +1 -1
  10. package/dist/coordinate.js +14 -0
  11. package/dist/coordinate.js.map +1 -1
  12. package/dist/door.d.ts +17 -0
  13. package/dist/door.d.ts.map +1 -1
  14. package/dist/door.js +111 -6
  15. package/dist/door.js.map +1 -1
  16. package/dist/editor/workspace.d.ts.map +1 -1
  17. package/dist/editor/workspace.js +6 -5
  18. package/dist/editor/workspace.js.map +1 -1
  19. package/dist/errors.d.ts +4 -2
  20. package/dist/errors.d.ts.map +1 -1
  21. package/dist/errors.js +13 -1
  22. package/dist/errors.js.map +1 -1
  23. package/dist/index.d.ts +14 -0
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +8 -0
  26. package/dist/index.js.map +1 -1
  27. package/dist/locator.d.ts +149 -0
  28. package/dist/locator.d.ts.map +1 -0
  29. package/dist/locator.js +572 -0
  30. package/dist/locator.js.map +1 -0
  31. package/dist/machine-protocol.d.ts +5 -0
  32. package/dist/machine-protocol.d.ts.map +1 -1
  33. package/dist/machine-protocol.js +141 -5
  34. package/dist/machine-protocol.js.map +1 -1
  35. package/dist/mandate-modes.d.ts +60 -0
  36. package/dist/mandate-modes.d.ts.map +1 -0
  37. package/dist/mandate-modes.js +112 -0
  38. package/dist/mandate-modes.js.map +1 -0
  39. package/dist/mentions.d.ts.map +1 -1
  40. package/dist/mentions.js +2 -3
  41. package/dist/mentions.js.map +1 -1
  42. package/dist/next.d.ts +151 -0
  43. package/dist/next.d.ts.map +1 -0
  44. package/dist/next.js +724 -0
  45. package/dist/next.js.map +1 -0
  46. package/dist/packet-host.d.ts +88 -0
  47. package/dist/packet-host.d.ts.map +1 -0
  48. package/dist/packet-host.js +239 -0
  49. package/dist/packet-host.js.map +1 -0
  50. package/dist/packet.d.ts +157 -0
  51. package/dist/packet.d.ts.map +1 -0
  52. package/dist/packet.js +207 -0
  53. package/dist/packet.js.map +1 -0
  54. package/dist/position.d.ts +275 -0
  55. package/dist/position.d.ts.map +1 -0
  56. package/dist/position.js +530 -0
  57. package/dist/position.js.map +1 -0
  58. package/dist/render.d.ts +12 -1
  59. package/dist/render.d.ts.map +1 -1
  60. package/dist/render.js +25 -0
  61. package/dist/render.js.map +1 -1
  62. package/dist/scope-key.d.ts +101 -0
  63. package/dist/scope-key.d.ts.map +1 -0
  64. package/dist/scope-key.js +175 -0
  65. package/dist/scope-key.js.map +1 -0
  66. package/package.json +32 -4
package/dist/index.d.ts CHANGED
@@ -4,6 +4,14 @@ export { classify, scoreShapes, defaultClassifier } from './classify.js';
4
4
  export type { Classifier, Shape } from './classify.js';
5
5
  export { prepareCoordinate, COORDINATE_DOMAINS } from './coordinate.js';
6
6
  export type { PreparedCoordinate, CoordinateOptions, AxisSource } from './coordinate.js';
7
+ export { K0, SCOPE_KEY_CAPS, normalizeScopeKey, resolveScopeKey, rootRelative } from './scope-key.js';
8
+ export type { ResolvedScopeKey, ResolvedSeat, ScopeKey } from './scope-key.js';
9
+ export { position, positionBody } from './position.js';
10
+ export type { AppliesByWord, Freshness, FrontierTally, HostNote, LoadedEntry, LoadedPlace, LoadedRecord, PointerTally, PositionBody, PositionCell, PositionCounts, PositionOutput, PositionPointer, PositionRecord, PositionUnknown, PositionVia, PositionWidening, SubjectMatch, } from './position.js';
11
+ export { entryCount, renderPacket } from './packet.js';
12
+ export type { PacketCatalogRow, PacketHostNote, PacketIntent, PacketMandate, PacketOutput, PacketParticipant, PacketPhase, PacketProvenance, PacketSeat, PacketSystem, PacketTally, PositionPacket, } from './packet.js';
13
+ export { PACKET_MARKER, renderHost } from './packet-host.js';
14
+ export type { HostFile, HostOutput, PacketHost, PacketReceipt, PacketTarget } from './packet-host.js';
7
15
  export { context, DEFAULT_TOKENIZER } from './context.js';
8
16
  export type { ContextRequest, ContextResult, ContextOptions, Budget, Tokenizer, Packet, Entry, Clause, Citation, Omission, Refusal, } from './types.js';
9
17
  export { select } from './select.js';
@@ -22,4 +30,10 @@ export type { CandidateEnvelope, CandidateScope, CandidateValidation } from './c
22
30
  export { PUBLICATION_CODES, PublicationError, portableDraftPath, qualifyPublicationRoot, preparePublication, inspectPublication, } from './publication.js';
23
31
  export type { PublicationFile, PreparedPublication, PublicationStatus } from './publication.js';
24
32
  export { isEntry } from './entry.js';
33
+ export { MANDATE_CODES, MODES, MODE_MOVES, MOVES, isMode, mandateAuthorityOf, mandateRefusal, } from './mandate-modes.js';
34
+ export type { MandateAuthority, MandateCode, MandateRefusal, Mode, Move } from './mandate-modes.js';
35
+ export { READ_CODES, SOURCE_LOCATORS, parseLocator, readBody } from './locator.js';
36
+ export type { Locator, ReadBody, ReadBodyOptions, ReadCode, ReadRefusal, ReadResult } from './locator.js';
37
+ export { NEXT_CODES, deliveryView } from './next.js';
38
+ export type { CycleRow, DeliveryMilestone, DeliveryResult, DeliveryTask, DeliveryView, ExitEvidence, NextCode, NextRefusal, Prerequisite, ReviewItem, StateDimension, StateLine, } from './next.js';
25
39
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC/E,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACzE,YAAY,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;A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ANGED
@@ -1,6 +1,10 @@
1
1
  export { RUNTIME_CODES, RUNTIME_ESCALATIONS, RuntimeError } from './errors.js';
2
2
  export { classify, scoreShapes, defaultClassifier } from './classify.js';
3
3
  export { prepareCoordinate, COORDINATE_DOMAINS } from './coordinate.js';
4
+ export { K0, SCOPE_KEY_CAPS, normalizeScopeKey, resolveScopeKey, rootRelative } from './scope-key.js';
5
+ export { position, positionBody } from './position.js';
6
+ export { entryCount, renderPacket } from './packet.js';
7
+ export { PACKET_MARKER, renderHost } from './packet-host.js';
4
8
  export { context, DEFAULT_TOKENIZER } from './context.js';
5
9
  export { select } from './select.js';
6
10
  export { open as openDatabase } from '@inventarch/db';
@@ -11,4 +15,8 @@ export { HOOK_CODES, evaluateSteward } from './steward.js';
11
15
  export { validateCandidate } from './candidate.js';
12
16
  export { PUBLICATION_CODES, PublicationError, portableDraftPath, qualifyPublicationRoot, preparePublication, inspectPublication, } from './publication.js';
13
17
  export { isEntry } from './entry.js';
18
+ export { MANDATE_CODES, MODES, MODE_MOVES, MOVES, isMode, mandateAuthorityOf, mandateRefusal, } from './mandate-modes.js';
19
+ // The markdown and fragment helpers stay on the ./internal/locator subpath; the root names the reader and its terms.
20
+ export { READ_CODES, SOURCE_LOCATORS, parseLocator, readBody } from './locator.js';
21
+ export { NEXT_CODES, deliveryView } from './next.js';
14
22
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE/E,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAExE,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;A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1D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAQzD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EACL,aAAa,EACb,KAAK,EACL,UAAU,EACV,KAAK,EACL,MAAM,EACN,kBAAkB,EAClB,cAAc,GACf,MAAM,oBAAoB,CAAC;AAE5B,qHAAqH;AACrH,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEnF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,149 @@
1
+ import type { Node } from '@inventarch/graph';
2
+ import type { ReadHandle } from '@inventarch/db';
3
+ import type { RuntimeCode } from './errors.js';
4
+ /**
5
+ * Locators and the body reader: position-and-projection §5's `ia read` and design row 23.
6
+ *
7
+ * A locator names one admitted record, or one part of it, in one of four forms:
8
+ * - `<identity>`: the record, by its canonical `system/kind/facet/name` identity;
9
+ * - `<identity>#<phase>/<Primitive>`: the text of the record's cells at that address, a playbook's step;
10
+ * - `<identity>#<REQ-ID>`: the text of one of the record's requirements;
11
+ * - `<path>:<line>`: the innermost admitted record whose source span holds that line of a workspace source.
12
+ *
13
+ * The body behind a record is the document its source locator names, when its word carries one (SOURCE_LOCATORS) and the
14
+ * record states it; otherwise the record's own body (`bodyOf`). A fragment reads the record, never its document: the
15
+ * text of its cells or of its requirement at the fragment. A body is text and the SHA-256 of its UTF-8 bytes, never a
16
+ * certification: the reader neither admits the document nor judges what it says (IM-43). Structure (sections, fields,
17
+ * relationships) is the inspector's and never a body.
18
+ */
19
+ /**
20
+ * The field whose text names each word's document body, as its schema declares it: `work.source` on every work word
21
+ * that states one, @spec, @plan, @milestone, @task and @decision (position-and-projection rows 2d and 23, widened by
22
+ * decision work-source-locator: all five schemas declare the one field, and a plan's records name their sections of
23
+ * its document with it), `reference.document` on @authoring-guide (row 2h) and `template.resource`, a @template's
24
+ * input. A record that states none reads its own body.
25
+ */
26
+ export declare const SOURCE_LOCATORS: Readonly<Record<string, string>>;
27
+ export type Locator = {
28
+ readonly form: 'identity';
29
+ readonly identity: string;
30
+ } | {
31
+ readonly form: 'cell' | 'requirement';
32
+ readonly identity: string;
33
+ readonly fragment: string;
34
+ } | {
35
+ readonly form: 'line';
36
+ readonly path: string;
37
+ readonly line: number;
38
+ };
39
+ export type ReadCode = Extract<RuntimeCode, `IA-RUNTIME-READ-${string}`>;
40
+ /** The refusal codes a read can return; each is registered in RUNTIME_CODES. */
41
+ export declare const READ_CODES: readonly ReadCode[];
42
+ export interface ReadBodyOptions {
43
+ /**
44
+ * The host's reader of one workspace file, given its canonical workspace-relative path. The host holds the root
45
+ * boundary (R10): it returns the file's bytes, and throws for a path it does not admit (a link, a missing or irregular
46
+ * file), which the read reports as an unreachable locator.
47
+ */
48
+ readonly read: (path: string) => Uint8Array;
49
+ /**
50
+ * The workspace directory each adopted mount is bound to, by the `.ia/adopted/<id>/<revision>` tree label its sources
51
+ * carry (db `adoptedBindings`). A label is no directory, so the document of a record in an adopted mount is read from
52
+ * the directory bound here, and refused as unreachable when none is.
53
+ */
54
+ readonly mounts?: ReadonlyMap<string, string>;
55
+ /** Read a record at runtime placement (band 0), which is refused otherwise. */
56
+ readonly includeRuntime?: boolean;
57
+ /**
58
+ * The scope token every lookup reads through, `get` and `records` alike, so the scope bounds the read by identity. In
59
+ * a scope narrower than the whole workspace, a locator no admitted record in it answers gets one plain
60
+ * IA-RUNTIME-READ-UNADMITTED, `The locator is not in this scope`, which names no path, line, identity or refused
61
+ * record, as what lies outside a scope is not disclosed. A whole-workspace token (db `isCompleteScope`, PT5) reads
62
+ * what the root view reads, so a miss there is refused as there, naming a record admission refused with its reason,
63
+ * as deliveryView names one. Without it the read is in the handle's root view and says what the workspace's sources
64
+ * hold.
65
+ */
66
+ readonly within?: string;
67
+ }
68
+ export interface ReadBody {
69
+ /** The locator as given. */
70
+ readonly locator: string;
71
+ readonly identity: string;
72
+ /** `record` for the record's own body or one of its fragments, `document` for the file its source locator names. */
73
+ readonly kind: 'record' | 'document';
74
+ /** A document's canonical workspace-relative path. */
75
+ readonly path?: string;
76
+ /** The SHA-256 of the body's UTF-8 bytes, in hex. */
77
+ readonly digest: string;
78
+ readonly body: string;
79
+ /** A read returns bytes and a digest, never a certification. */
80
+ readonly certified: false;
81
+ }
82
+ export interface ReadRefusal {
83
+ readonly ok: false;
84
+ readonly code: ReadCode;
85
+ readonly message: string;
86
+ /** The record the locator reached, once it reached one. */
87
+ readonly identity?: string;
88
+ /**
89
+ * The workspace path the refusal concerns: a line locator's source, the source of a record whose fragment is missing
90
+ * or whose placement is refused (with its line), or the file a source locator names.
91
+ */
92
+ readonly path?: string;
93
+ readonly line?: number;
94
+ /**
95
+ * For a line no admitted record spans, what the workspace's sources hold in its file: `refused` when admission
96
+ * refused records there, else `admitted` when admitted records there span other lines. Absent when no record of the
97
+ * workspace's sources is in that file. For an identity, `refused` when a source holds it and admission refused it.
98
+ */
99
+ readonly file?: 'admitted' | 'refused';
100
+ /** For an identity a source holds whose record admission refused, the reason admission gives (db `refused`). */
101
+ readonly reason?: string;
102
+ }
103
+ export type ReadResult = {
104
+ readonly ok: true;
105
+ readonly body: ReadBody;
106
+ } | ReadRefusal;
107
+ /** The locator `text` spells, or undefined when it spells none of the four forms. */
108
+ export declare function parseLocator(text: string): Locator | undefined;
109
+ /**
110
+ * The text at `fragment` of `node`: its cells at a `phase/Primitive` address in source order, else its requirement with
111
+ * that id. Undefined when the record has neither, which is also what a request mention's fragment is checked against.
112
+ */
113
+ export declare function fragmentText(node: Node, fragment: string): string | undefined;
114
+ /**
115
+ * The anchor of one plain-text ATX heading, as GitHub's slugger gives it: an inline link keeps its text, letters are
116
+ * lowercased, every character other than a letter, mark, decimal or letter number, connector punctuation, `-` or space
117
+ * is dropped, and each space becomes `-`. Code spans and `*` emphasis come out as GitHub's, because their delimiters
118
+ * are dropped. The heading is not rendered first, so underscore emphasis, entity and character references, inline HTML
119
+ * and reference links keep their markup here, and such a heading may have another anchor on GitHub.
120
+ */
121
+ export declare function headingAnchor(heading: string): string;
122
+ /**
123
+ * The section of markdown `text` under the ATX heading whose `headingAnchor` is `anchor`: from that heading to the next
124
+ * heading of the same or a higher level, headings in fenced code ignored. A repeated anchor takes GitHub's `-1`, `-2`,
125
+ * ... in document order. A leading byte order mark is not part of the first line's heading, as GitHub skips it, and
126
+ * stays in the section. Setext headings and headings inside list items or block quotes are not read. Undefined when no
127
+ * heading has the anchor.
128
+ *
129
+ * A document may be 4 MiB and is read on the long-lived MCP door, so the read takes time linear in the document, up to
130
+ * a logarithmic factor in how deeply its containers nest, whatever it holds before the anchor: each line is scanned
131
+ * once from its end, each list or quote marker it opens or continues is read in time linear in its own width, and a
132
+ * line left blank after its container prefixes continues every open list item up to the first quote or empty item
133
+ * (the only containers a blank line ends), found by a binary search over the open quotes, never by walking the items.
134
+ */
135
+ export declare function markdownSection(text: string, anchor: string): string | undefined;
136
+ /**
137
+ * The body behind `locator` in the root view of `handle`, or in the scope `within` names, or one refusal:
138
+ * IA-RUNTIME-READ-UNADMITTED when no admitted record answers it (in a scope narrower than the whole workspace, the
139
+ * plain `SCOPED_MISS`; in the root view or a whole-workspace scope, what the workspace's sources hold there),
140
+ * IA-RUNTIME-READ-PLACEMENT for a record at runtime placement unless `includeRuntime` is set,
141
+ * IA-RUNTIME-READ-FRAGMENT when the record has no cell or requirement at the fragment, and IA-RUNTIME-READ-UNREACHABLE
142
+ * when its source locator names a file outside the workspace (or the record's tree), a record of an adopted mount
143
+ * `mounts` binds to no directory, a file the host's reader does not return, bytes that are not UTF-8, or an anchor that
144
+ * no markdown heading of the file has. A locator that spells none of the four forms is IA-RUNTIME-REQUEST-INVALID.
145
+ * A document path is read relative to the record's tree (db `sourceTree`): the workspace root for its own `.ia/src`,
146
+ * a package or installed store directory as it is, and for an adopted mount the directory `mounts` binds its label to.
147
+ */
148
+ export declare function readBody(handle: ReadHandle, locator: string, options: ReadBodyOptions): ReadResult;
149
+ //# sourceMappingURL=locator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locator.d.ts","sourceRoot":"","sources":["../src/locator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C;;;;;;;;;;;;;;GAcG;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQ3D,CAAC;AAEH,MAAM,MAAM,OAAO,GACf;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACxD;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC/F;IAAE,QAAQ,CAAC,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