@inventarch/runtime 0.0.0-stage → 1.1.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 (106) hide show
  1. package/LANGUAGE.md +56 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +4 -0
  4. package/README.md +11 -2
  5. package/SPEC.md +77 -0
  6. package/dist/authoring/index.d.ts +159 -0
  7. package/dist/authoring/index.d.ts.map +1 -0
  8. package/dist/authoring/index.js +416 -0
  9. package/dist/authoring/index.js.map +1 -0
  10. package/dist/authoring-execution/execution.d.ts +12 -0
  11. package/dist/authoring-execution/execution.d.ts.map +1 -0
  12. package/dist/authoring-execution/execution.js +73 -0
  13. package/dist/authoring-execution/execution.js.map +1 -0
  14. package/dist/authoring-execution/index.d.ts +6 -0
  15. package/dist/authoring-execution/index.d.ts.map +1 -0
  16. package/dist/authoring-execution/index.js +6 -0
  17. package/dist/authoring-execution/index.js.map +1 -0
  18. package/dist/authoring-execution/inventory.d.ts +5 -0
  19. package/dist/authoring-execution/inventory.d.ts.map +1 -0
  20. package/dist/authoring-execution/inventory.js +46 -0
  21. package/dist/authoring-execution/inventory.js.map +1 -0
  22. package/dist/authoring-execution/shared.d.ts +22 -0
  23. package/dist/authoring-execution/shared.d.ts.map +1 -0
  24. package/dist/authoring-execution/shared.js +101 -0
  25. package/dist/authoring-execution/shared.js.map +1 -0
  26. package/dist/authoring-execution/types.d.ts +43 -0
  27. package/dist/authoring-execution/types.d.ts.map +1 -0
  28. package/dist/authoring-execution/types.js +21 -0
  29. package/dist/authoring-execution/types.js.map +1 -0
  30. package/dist/candidate.d.ts +49 -0
  31. package/dist/candidate.d.ts.map +1 -0
  32. package/dist/candidate.js +158 -0
  33. package/dist/candidate.js.map +1 -0
  34. package/dist/classify.d.ts +12 -0
  35. package/dist/classify.d.ts.map +1 -0
  36. package/dist/classify.js +21 -0
  37. package/dist/classify.js.map +1 -0
  38. package/dist/collect.d.ts +16 -0
  39. package/dist/collect.d.ts.map +1 -0
  40. package/dist/collect.js +133 -0
  41. package/dist/collect.js.map +1 -0
  42. package/dist/context.d.ts +5 -0
  43. package/dist/context.d.ts.map +1 -0
  44. package/dist/context.js +124 -0
  45. package/dist/context.js.map +1 -0
  46. package/dist/coordinate.d.ts +21 -0
  47. package/dist/coordinate.d.ts.map +1 -0
  48. package/dist/coordinate.js +40 -0
  49. package/dist/coordinate.js.map +1 -0
  50. package/dist/door.d.ts +17 -0
  51. package/dist/door.d.ts.map +1 -0
  52. package/dist/door.js +217 -0
  53. package/dist/door.js.map +1 -0
  54. package/dist/editor/index.d.ts +5 -0
  55. package/dist/editor/index.d.ts.map +1 -0
  56. package/dist/editor/index.js +4 -0
  57. package/dist/editor/index.js.map +1 -0
  58. package/dist/editor/types.d.ts +226 -0
  59. package/dist/editor/types.d.ts.map +1 -0
  60. package/dist/editor/types.js +2 -0
  61. package/dist/editor/types.js.map +1 -0
  62. package/dist/editor/workspace.d.ts +46 -0
  63. package/dist/editor/workspace.d.ts.map +1 -0
  64. package/dist/editor/workspace.js +903 -0
  65. package/dist/editor/workspace.js.map +1 -0
  66. package/dist/entry.d.ts +9 -0
  67. package/dist/entry.d.ts.map +1 -0
  68. package/dist/entry.js +26 -0
  69. package/dist/entry.js.map +1 -0
  70. package/dist/errors.d.ts +8 -0
  71. package/dist/errors.d.ts.map +1 -0
  72. package/dist/errors.js +15 -0
  73. package/dist/errors.js.map +1 -0
  74. package/dist/index.d.ts +25 -0
  75. package/dist/index.d.ts.map +1 -0
  76. package/dist/index.js +14 -0
  77. package/dist/index.js.map +1 -0
  78. package/dist/machine-protocol.d.ts +33 -0
  79. package/dist/machine-protocol.d.ts.map +1 -0
  80. package/dist/machine-protocol.js +339 -0
  81. package/dist/machine-protocol.js.map +1 -0
  82. package/dist/mentions.d.ts +20 -0
  83. package/dist/mentions.d.ts.map +1 -0
  84. package/dist/mentions.js +79 -0
  85. package/dist/mentions.js.map +1 -0
  86. package/dist/publication.d.ts +22 -0
  87. package/dist/publication.d.ts.map +1 -0
  88. package/dist/publication.js +275 -0
  89. package/dist/publication.js.map +1 -0
  90. package/dist/render.d.ts +9 -0
  91. package/dist/render.d.ts.map +1 -0
  92. package/dist/render.js +78 -0
  93. package/dist/render.js.map +1 -0
  94. package/dist/select.d.ts +16 -0
  95. package/dist/select.d.ts.map +1 -0
  96. package/dist/select.js +55 -0
  97. package/dist/select.js.map +1 -0
  98. package/dist/steward.d.ts +22 -0
  99. package/dist/steward.d.ts.map +1 -0
  100. package/dist/steward.js +45 -0
  101. package/dist/steward.js.map +1 -0
  102. package/dist/types.d.ts +97 -0
  103. package/dist/types.d.ts.map +1 -0
  104. package/dist/types.js +10 -0
  105. package/dist/types.js.map +1 -0
  106. package/package.json +162 -3
@@ -0,0 +1,339 @@
1
+ /**
2
+ * The machine protocol's one description (docs/specs/command-discoverability/README.md §2). For each Door operation:
3
+ * its purpose, parameter schema, result, refusals with a next action, and an example that returns `ok: true` on
4
+ * packages/compliance/fixtures/loop. `ia <operation> --help`, the MCP door's tools/list and
5
+ * docs/reference/cli/machine-protocol.md are projections of this table. It describes the frozen wire format and changes none
6
+ * of it: the Door validates every request itself, and tests/select-door.test.ts and apps/cli/tests/cli.test.ts hold this
7
+ * table to what the Door admits and refuses.
8
+ */
9
+ import { COORDINATE_DOMAINS } from './coordinate.js';
10
+ import { freeze } from './types.js';
11
+ const text = (description) => ({ type: 'string', description });
12
+ const strings = (description) => ({ type: 'array', items: { type: 'string' }, description });
13
+ const object = (properties, required = [], description) => ({
14
+ type: 'object',
15
+ ...(description === undefined ? {} : { description }),
16
+ properties,
17
+ required,
18
+ additionalProperties: false,
19
+ });
20
+ const axes = Object.fromEntries(Object.entries(COORDINATE_DOMAINS).map(([axis, values]) => [axis, { type: 'string', enum: values }]));
21
+ const coordinate = (description, required) => ({
22
+ type: 'object',
23
+ description,
24
+ properties: axes,
25
+ ...(required === undefined ? {} : { required }),
26
+ additionalProperties: false,
27
+ });
28
+ /**
29
+ * On a read the Door always passes a scope token, the initial one when `within` is omitted, so root, phase and revision
30
+ * assert that scope's own values rather than narrow the read (packages/db/SPEC.md D08).
31
+ */
32
+ const read = {
33
+ within: text('Scope token issued earlier in the same process: one CLI invocation, or the MCP server process. Omitted, the call reads the initial boundary.'),
34
+ root: text('Asserts the scope\'s root ("" for the initial scope); a path to any other location refuses with IA-DB-SCOPE-MISMATCH. It does not narrow the read: issue a scope and pass its token as within. Not the workspace path, which is --root on the CLI and the configured root on MCP.'),
35
+ phase: {
36
+ anyOf: [{ type: 'string', enum: COORDINATE_DOMAINS.phase }, { type: 'null' }],
37
+ description: "Asserts the scope's phase (null for a scope without one); a different one refuses with IA-DB-SCOPE-MISMATCH, and a value outside the phase set with IA-GRAPH-COORDINATE-VALUE-UNKNOWN. It does not narrow the read.",
38
+ },
39
+ revision: text("Asserts the scope's revision; any other value refuses with IA-DB-SCOPE-MISMATCH."),
40
+ };
41
+ /** On scope the same keys bind the new scope, which stays inside its parent (packages/db/SPEC.md D07). */
42
+ const narrowing = {
43
+ within: text('Parent scope token issued earlier in the same process; omitted, the parent is the initial boundary.'),
44
+ root: text("Workspace-relative location the new scope resolves from: the parent's root or a directory below it. A source is admitted where its declared reach covers this location, and the default empty reach covers every location, so this is not a path filter."),
45
+ phase: {
46
+ anyOf: [{ type: 'string', enum: COORDINATE_DOMAINS.phase }, { type: 'null' }],
47
+ description: "Phase to bind the new scope to; omitted keeps the parent's phase, and null binds none.",
48
+ },
49
+ revision: text("Asserts the parent scope's revision; any other value refuses with IA-DB-SCOPE-MISMATCH."),
50
+ };
51
+ const reference = {
52
+ description: 'A typed reference: {kind: "identity", identity} or {kind: "ref", discriminator, name}, each with an optional fragment.',
53
+ oneOf: [
54
+ object({
55
+ kind: { const: 'identity' },
56
+ identity: text('Admitted identity.'),
57
+ fragment: text('Fragment inside the record.'),
58
+ }, ['kind', 'identity']),
59
+ object({
60
+ kind: { const: 'ref' },
61
+ discriminator: text('Record discriminator, such as playbook.'),
62
+ name: text('Record name.'),
63
+ fragment: text('Fragment inside the record.'),
64
+ }, ['kind', 'discriminator', 'name']),
65
+ ],
66
+ };
67
+ const request = {
68
+ within: read.within,
69
+ text: text('The request in plain words; may be empty.'),
70
+ coordinate: coordinate('Where the work stands. phase and primitive are required; each further axis narrows what applies.', ['phase', 'primitive']),
71
+ subject: {
72
+ anyOf: [{ type: 'string' }, reference],
73
+ description: 'The record the request is about: an identity or a typed reference.',
74
+ },
75
+ follow: strings('Relationship verbs to follow from the delivered records.'),
76
+ revision: read.revision,
77
+ };
78
+ const REQUEST_INVALID = {
79
+ code: 'IA-RUNTIME-REQUEST-INVALID',
80
+ when: 'A parameter is unknown, missing or of the wrong type.',
81
+ next: "Match the parameters to this operation's schema; the message names what was expected.",
82
+ };
83
+ const SCOPE_UNAVAILABLE = {
84
+ code: 'IA-DB-SCOPE-UNAVAILABLE',
85
+ when: 'within is a token this process did not issue.',
86
+ next: 'Omit within, or pass a token issued earlier in the same process; a CLI token ends with its invocation.',
87
+ };
88
+ const SCOPE_MISMATCH = {
89
+ code: 'IA-DB-SCOPE-MISMATCH',
90
+ when: "root, phase or revision differs from the scope's own value.",
91
+ next: "Drop the binding or pass the scope's own value. To read a narrower scope, issue one with scope and pass its token as within in the same process; a CLI invocation performs one operation, so its reads cover the initial boundary.",
92
+ };
93
+ const PARENT_MISMATCH = {
94
+ code: 'IA-DB-SCOPE-MISMATCH',
95
+ when: "revision differs from the parent scope's, or root lies outside the parent's root.",
96
+ next: "Omit revision or pass the parent's, and choose a root at or below the parent's.",
97
+ };
98
+ const REVISION_MISMATCH = {
99
+ code: 'IA-DB-SCOPE-MISMATCH',
100
+ when: "revision differs from the scope's own.",
101
+ next: "Drop revision or pass the scope's own.",
102
+ };
103
+ const VALUE_UNKNOWN = {
104
+ code: 'IA-GRAPH-COORDINATE-VALUE-UNKNOWN',
105
+ when: 'A phase or coordinate value is outside its closed set, or coordinate names an unknown axis.',
106
+ next: 'Use one of the values or axes the message lists.',
107
+ };
108
+ const COORDINATE_INCOMPLETE = {
109
+ code: 'coordinate-incomplete',
110
+ when: 'coordinate lacks an axis this operation needs; missing names each one.',
111
+ next: 'Declare every axis in missing on coordinate.',
112
+ };
113
+ const VERB_UNKNOWN = {
114
+ code: 'IA-GRAPH-VERB-UNKNOWN',
115
+ when: 'follow names a verb the language does not define.',
116
+ next: 'Use the verbs the message lists.',
117
+ };
118
+ /** The refusals every read through the four bindings shares. */
119
+ const BOUND = [REQUEST_INVALID, SCOPE_UNAVAILABLE, SCOPE_MISMATCH, VALUE_UNKNOWN];
120
+ /** context and select: phase is a coordinate axis there, not a binding, and revision is the only scope assertion. */
121
+ const REQUESTED = [REQUEST_INVALID, SCOPE_UNAVAILABLE, REVISION_MISMATCH, COORDINATE_INCOMPLETE, VALUE_UNKNOWN];
122
+ const EXAMPLE_IDENTITY = 'governance-system/definition/procedure/sample-procedure';
123
+ /** Frozen deeply, so a projection that shares its schema objects (the MCP tools) cannot change it. */
124
+ export const MACHINE_PROTOCOL = freeze({
125
+ version: 1,
126
+ flow: [
127
+ 'scope issues a token that bounds later reads by phase or identities, and by root only where sources declare a reach. It is optional: without within, a call reads the initial boundary.',
128
+ 'context delivers the cited procedure cells and governance that apply to a coordinate; select chooses exactly one binding among candidates, or refuses.',
129
+ 'get, records, resolve, search and traverse read admitted records inside the scope; pass within to stay inside a narrowed one.',
130
+ 'A token lives as long as the process that issued it: one CLI invocation, or the MCP server process. A CLI invocation performs one operation, so its reads always cover the initial boundary; narrowing takes scope, then within, in one MCP session.',
131
+ "report is privileged inspection of the whole workspace's admission, served by the CLI only.",
132
+ ],
133
+ operations: [
134
+ {
135
+ name: 'scope',
136
+ summary: 'Issue a read-only scope, or narrow one by phase or identities.',
137
+ description: 'Issue a read-only scope or narrow an existing scope by phase or identity set; its root narrows only where sources declare a reach. Pass its token as within to later calls in the same process.',
138
+ params: object({
139
+ ...narrowing,
140
+ identities: strings("Identities the new scope admits; it stays inside the parent's boundary."),
141
+ }),
142
+ result: 'The scope: {token, root, revision}, plus phase when one is bound.',
143
+ refusals: [REQUEST_INVALID, SCOPE_UNAVAILABLE, PARENT_MISMATCH, VALUE_UNKNOWN],
144
+ example: { identities: [EXAMPLE_IDENTITY] },
145
+ mcp: 'ia_scope',
146
+ },
147
+ {
148
+ name: 'context',
149
+ summary: 'Deliver the cited procedure cells and governance that apply to a coordinate.',
150
+ description: 'Deliver cited IA procedure cells and applicable governance for a declared phase and primitive. Budget.tokens counts delivered text and purpose, not the whole JSON response. Blocking obligations cannot be silently budgeted away. Narrow topical context with the search and scope operations.',
151
+ params: object({
152
+ ...request,
153
+ ranking: {
154
+ enum: ['native', 'topical'],
155
+ description: 'Default native preserves procedure-first ordering. Topical prioritizes scoped search relevance after reserving all blocking governance; it does not affect execution selection.',
156
+ },
157
+ budget: object({ tokens: { type: 'integer', minimum: 0 }, records: { type: 'integer', minimum: 0 } }, ['tokens', 'records'], 'Delivery limits; default {tokens: 4000, records: 50}.'),
158
+ }, ['text', 'coordinate']),
159
+ result: 'A cited packet: {revision, scope, coordinate, included, omitted, followed, gated, dangling, limits}. included holds the delivered cells with their citations; omitted names what the budget, a disqualifying condition or an unresolved reference left out.',
160
+ refusals: [
161
+ ...REQUESTED,
162
+ VERB_UNKNOWN,
163
+ {
164
+ code: 'IA-RUNTIME-BUDGET-INVALID',
165
+ when: 'budget.tokens or budget.records is negative or not a safe integer.',
166
+ next: 'Pass nonnegative integers, or omit budget for the default.',
167
+ },
168
+ {
169
+ code: 'IA-GRAPH-BUDGET-BLOCKING-OVERFLOW',
170
+ when: 'The budget cannot hold every applicable blocking obligation; required gives the minimum.',
171
+ next: 'Raise budget to at least required, or narrow the scope.',
172
+ },
173
+ ],
174
+ example: { text: 'author a record', coordinate: { phase: 'orient', primitive: 'Decision' } },
175
+ mcp: 'ia_context',
176
+ },
177
+ {
178
+ name: 'select',
179
+ summary: 'Choose exactly one binding among candidate identities, or refuse.',
180
+ description: 'Choose exclusively among supplied identities; ties or missing required coordinates refuse. This grants no execution permission.',
181
+ params: object({
182
+ ...request,
183
+ follow: strings('Accepted for symmetry with context; select ignores it.'),
184
+ candidates: strings('Identities to choose among.'),
185
+ requiredAxes: {
186
+ type: 'array',
187
+ items: { type: 'string', enum: Object.keys(COORDINATE_DOMAINS) },
188
+ description: 'Further coordinate axes the request must declare; a missing one refuses with coordinate-incomplete.',
189
+ },
190
+ }, ['text', 'coordinate', 'candidates']),
191
+ result: 'The chosen binding: {revision, scope, entry}.',
192
+ refusals: [
193
+ ...REQUESTED,
194
+ {
195
+ code: 'no-candidate',
196
+ when: 'No candidate is admitted in this scope and applies to the coordinate.',
197
+ next: 'Pass candidates that apply; context lists the procedures that do.',
198
+ },
199
+ {
200
+ code: 'deny-wins-tie',
201
+ when: 'Candidates tie on step, score and band.',
202
+ next: 'Declare more coordinate axes so one applies more specifically, or pass fewer candidates.',
203
+ },
204
+ ],
205
+ example: {
206
+ text: '',
207
+ coordinate: { phase: 'act', primitive: 'Decision', category: 'process' },
208
+ candidates: [EXAMPLE_IDENTITY],
209
+ },
210
+ mcp: 'ia_select',
211
+ },
212
+ {
213
+ name: 'get',
214
+ summary: 'Read one admitted record inside the scope.',
215
+ description: 'Read one admitted IA record inside the scope.',
216
+ params: object({ ...read, identity: text('Admitted identity to read.') }, ['identity']),
217
+ result: 'The admitted record: {identity, system, kind, discriminator, name, source, sections, edges, cells, ...}.',
218
+ refusals: [
219
+ ...BOUND,
220
+ {
221
+ code: 'IA-DB-OUT-OF-SCOPE',
222
+ when: 'The identity is outside the scope.',
223
+ next: 'Pick an identity that records or search returns in this scope, or widen the scope.',
224
+ },
225
+ ],
226
+ example: { identity: EXAMPLE_IDENTITY },
227
+ mcp: 'ia_get',
228
+ },
229
+ {
230
+ name: 'records',
231
+ summary: 'Read the whole admitted snapshot inside the scope.',
232
+ description: 'Read the admitted immutable record snapshot inside the scope. It can be large; search, get and traverse read less.',
233
+ params: object(read),
234
+ result: 'The snapshot: {revision, root, records, systems}, plus phase when the scope binds one.',
235
+ refusals: BOUND,
236
+ example: {},
237
+ mcp: 'ia_records',
238
+ },
239
+ {
240
+ name: 'resolve',
241
+ summary: 'Resolve a typed reference or identity to exactly one record.',
242
+ description: 'Resolve a typed reference or identity with exact-cardinality refusal. An unresolved reference is still a successful response; its result says why.',
243
+ params: object({ ...read, reference }, ['reference']),
244
+ result: '{ok: true, identity} when exactly one record matches; otherwise {ok: false, code, ...}, for example IA-GRAPH-TARGET-MISSING.',
245
+ refusals: BOUND,
246
+ example: { reference: { kind: 'ref', discriminator: 'playbook', name: 'sample-procedure' } },
247
+ mcp: 'ia_resolve',
248
+ },
249
+ {
250
+ name: 'search',
251
+ summary: 'Search decoded record text inside the scope.',
252
+ description: 'Search decoded IA text with statistics restricted to the scope.',
253
+ params: object({ ...read, text: text('Words to find.') }, ['text']),
254
+ result: 'An array of hits inside the scope, each naming an identity.',
255
+ refusals: BOUND,
256
+ example: { text: 'authoring' },
257
+ mcp: 'ia_search',
258
+ },
259
+ {
260
+ name: 'traverse',
261
+ summary: 'Follow typed relationships from start identities.',
262
+ description: 'Follow scoped IA relationships with typed filters and optional conditional gating.',
263
+ params: object({
264
+ ...read,
265
+ start: strings('Identities to start from.'),
266
+ follow: strings('Relationship verbs to follow.'),
267
+ direction: { enum: ['out', 'in', 'both'], description: 'Edge direction.' },
268
+ depth: { type: 'integer', minimum: 0, maximum: 8, description: 'Hops from start.' },
269
+ filter: object({
270
+ kind: { enum: COORDINATE_DOMAINS.kind },
271
+ discriminator: text('Record discriminator.'),
272
+ system: text('Owning system.'),
273
+ }, [], 'Keep only records of this kind, discriminator or system.'),
274
+ coordinate: coordinate('Coordinate that conditional relationships are gated by.'),
275
+ }, ['start']),
276
+ result: 'The walk: {nodes, via, edges, gated, dangling}; each node carries its depth.',
277
+ refusals: [
278
+ ...BOUND,
279
+ VERB_UNKNOWN,
280
+ {
281
+ code: 'IA-GRAPH-TRAVERSAL-INVALID',
282
+ when: 'depth is not an integer from 0 to 8.',
283
+ next: 'Pass an integer depth from 0 to 8.',
284
+ },
285
+ ],
286
+ example: { start: [EXAMPLE_IDENTITY], depth: 1 },
287
+ mcp: 'ia_traverse',
288
+ },
289
+ {
290
+ name: 'report',
291
+ summary: 'Report admission verdicts and findings for the whole workspace (CLI only).',
292
+ description: 'Report admission verdicts and findings for the whole workspace. Privileged local inspection: the CLI enables it and the MCP door does not serve it.',
293
+ params: object({}),
294
+ result: 'The report: {revision, outcome, verdicts, findings, shadows}. On the CLI an outcome of fail exits 1 although the response is ok.',
295
+ refusals: [
296
+ {
297
+ code: 'IA-RUNTIME-REQUEST-INVALID',
298
+ when: 'A parameter was supplied (report takes none), or the host has not enabled report.',
299
+ next: 'Pass {} or omit --params; only the CLI enables report.',
300
+ },
301
+ ],
302
+ example: {},
303
+ mcp: null,
304
+ },
305
+ ],
306
+ differences: [
307
+ {
308
+ topic: 'report',
309
+ cli: 'ia report prints the privileged admission report.',
310
+ mcp: 'Not served: the door runs with report disabled.',
311
+ },
312
+ {
313
+ topic: 'vocabulary',
314
+ cli: 'The consumer verb ia vocabulary, with its own options and --json envelope.',
315
+ mcp: 'The tool ia_vocabulary; it is not a Door operation.',
316
+ },
317
+ {
318
+ topic: 'Token lifetime',
319
+ cli: 'One invocation: a token printed by one run cannot be passed to the next, so every CLI read covers the initial boundary.',
320
+ mcp: 'The server process: a token stays valid across calls until the server exits.',
321
+ },
322
+ {
323
+ topic: 'Workspace',
324
+ cli: '--root <path>, default the current directory, with no search upward.',
325
+ mcp: 'The root the host configured when it started the server.',
326
+ },
327
+ {
328
+ topic: 'Context format',
329
+ cli: 'No format parameter; the full packet.',
330
+ mcp: 'ia_context also takes format=full|compact; compact summarizes omissions.',
331
+ },
332
+ {
333
+ topic: 'Refusals',
334
+ cli: 'The refusal object on stdout; exit 2 for IA-RUNTIME-REQUEST-INVALID, otherwise 1. IA-CLI-USAGE (exit 2) for an argument error and IA-DB-ROOT-INVALID (exit 1) for a missing --root belong to the route.',
335
+ mcp: 'The same object as structuredContent and text, with isError true; protocol faults are JSON-RPC errors.',
336
+ },
337
+ ],
338
+ });
339
+ //# sourceMappingURL=machine-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"machine-protocol.js","sourceRoot":"","sources":["../src/machine-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAiCpC,MAAM,IAAI,GAAG,CAAC,WAAmB,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,CAAC;AACxE,MAAM,OAAO,GAAG,CAAC,WAAmB,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;AACrG,MAAM,MAAM,GAAG,CAAC,UAAmC,EAAE,WAA8B,EAAE,EAAE,WAAoB,EAAE,EAAE,CAAC,CAAC;IAC/G,IAAI,EAAE,QAAQ;IACd,GAAG,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;IACrD,UAAU;IACV,QAAQ;IACR,oBAAoB,EAAE,KAAK;CAC5B,CAAC,CAAC;AACH,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,CAC7B,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CACrG,CAAC;AACF,MAAM,UAAU,GAAG,CAAC,WAAmB,EAAE,QAA4B,EAAE,EAAE,CAAC,CAAC;IACzE,IAAI,EAAE,QAAQ;IACd,WAAW;IACX,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GAAG,EAAE,sEAAsE;YAC3E,GAAG,EAAE,0DAA0D;SAChE;QACD;YACE,KAAK,EAAE,gBAAgB;YACvB,GAAG,EAAE,uCAAuC;YAC5C,GAAG,EAAE,0EAA0E;SAChF;QACD;YACE,KAAK,EAAE,UAAU;YACjB,GAAG,EAAE,yMAAyM;YAC9M,GAAG,EAAE,wGAAwG;SAC9G;KACF;CACF,CAAC,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { EdgeReference } from '@inventarch/language';
2
+ import type { Node } from '@inventarch/graph';
3
+ import type { ReadHandle } from '@inventarch/db';
4
+ interface Mention {
5
+ readonly address: string;
6
+ readonly reference?: EdgeReference;
7
+ readonly kind?: string;
8
+ readonly name?: string;
9
+ readonly fragment?: string;
10
+ }
11
+ export declare function subjectMention(subject: string | EdgeReference): Mention;
12
+ export declare function mentions(text: string): readonly Mention[];
13
+ export declare function resolveMention(handle: ReadHandle, within: string, nodes: readonly Node[], mention: Mention): {
14
+ readonly node: Node;
15
+ readonly fragment?: string;
16
+ } | {
17
+ readonly detail: string;
18
+ };
19
+ export {};
20
+ //# sourceMappingURL=mentions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mentions.d.ts","sourceRoot":"","sources":["../src/mentions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,UAAU,OAAO;IACf,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC;IACnC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,GAAG,OAAO,CAqCvE;AACD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,OAAO,EAAE,CAezD;AACD,wBAAgB,cAAc,CAC5B,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,OAAO,EAAE,OAAO,GACf;IAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CA0BnF"}
@@ -0,0 +1,79 @@
1
+ import { KINDS } from '@inventarch/language';
2
+ const SIGIL = /^@([a-z][a-z0-9-]*)\s+("(?:\\.|[^"\\])*"|[^\s#]+)(?:#([^\s]+))?$/i;
3
+ export function subjectMention(subject) {
4
+ if (typeof subject !== 'string')
5
+ return {
6
+ address: subject.kind === 'identity' ? subject.identity : `@${subject.discriminator} ${subject.name}`,
7
+ reference: subject,
8
+ };
9
+ const sigil = SIGIL.exec(subject);
10
+ if (sigil !== null) {
11
+ let name = sigil[2];
12
+ if (name.startsWith('"'))
13
+ try {
14
+ name = JSON.parse(name);
15
+ }
16
+ catch {
17
+ return { address: subject };
18
+ }
19
+ return {
20
+ address: subject,
21
+ reference: {
22
+ kind: 'ref',
23
+ discriminator: sigil[1].toLowerCase(),
24
+ name,
25
+ ...(sigil[3] === undefined ? {} : { fragment: sigil[3] }),
26
+ },
27
+ };
28
+ }
29
+ const [base = '', fragment] = subject.split('#'), pieces = base.split('/');
30
+ if (pieces.length === 4)
31
+ return {
32
+ address: subject,
33
+ reference: { kind: 'identity', identity: base, ...(fragment === undefined ? {} : { fragment }) },
34
+ };
35
+ return {
36
+ address: subject,
37
+ ...(pieces.length === 2 ? { kind: pieces[0], name: pieces[1] } : { name: base }),
38
+ ...(fragment === undefined ? {} : { fragment }),
39
+ };
40
+ }
41
+ export function mentions(text) {
42
+ const found = [];
43
+ const patterns = [
44
+ /@[a-z][a-z0-9-]*\s+(?:"(?:\\.|[^"\\])*"|[a-z0-9][a-z0-9_-]*)(?:#[a-z0-9/-]+)?/gi,
45
+ new RegExp(`\\b[a-z0-9-]+/(?:${KINDS.join('|')})/[a-z0-9-]+/[a-z0-9-]+(?:#[a-z0-9/-]+)?`, 'gi'),
46
+ new RegExp(`(?<![a-z0-9/-])(?:${KINDS.join('|')})/[a-z0-9-]+(?:#[a-z0-9/-]+)?(?![a-z0-9/-])`, 'gi'),
47
+ ];
48
+ for (const pattern of patterns)
49
+ for (const match of text.matchAll(pattern)) {
50
+ const start = match.index, end = start + match[0].length;
51
+ if (!found.some((item) => start < item.end && end > item.start))
52
+ found.push({ start, end, mention: subjectMention(match[0]) });
53
+ }
54
+ return found.sort((a, b) => a.start - b.start).map((item) => item.mention);
55
+ }
56
+ export function resolveMention(handle, within, nodes, mention) {
57
+ let identity, fragment = mention.fragment;
58
+ if (mention.reference !== undefined) {
59
+ const result = handle.resolve(mention.reference, { within });
60
+ if (!result.ok)
61
+ return { detail: result.code };
62
+ identity = result.identity;
63
+ fragment = result.fragment;
64
+ }
65
+ else {
66
+ const matches = nodes.filter((n) => (n.name === mention.name?.toLowerCase() || n.displayName.toLowerCase() === mention.name?.toLowerCase()) &&
67
+ (mention.kind === undefined || n.kind === mention.kind));
68
+ if (matches.length !== 1)
69
+ return { detail: matches.length === 0 ? 'IA-GRAPH-TARGET-MISSING' : 'IA-GRAPH-TARGET-AMBIGUOUS' };
70
+ identity = matches[0].identity;
71
+ }
72
+ const node = nodes.find((n) => n.identity === identity);
73
+ if (fragment !== undefined &&
74
+ !node.cells.some((c) => `${c.phase}/${c.primitive}` === fragment) &&
75
+ !node.requirements.some((r) => r.id === fragment))
76
+ return { detail: `No cell or requirement fragment '${fragment}'` };
77
+ return { node, ...(fragment === undefined ? {} : { fragment }) };
78
+ }
79
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UBLICATION-UNAVAILABLE"];
2
+ export declare class PublicationError extends Error {
3
+ readonly code: (typeof PUBLICATION_CODES)[number];
4
+ constructor(code: (typeof PUBLICATION_CODES)[number], message: string);
5
+ }
6
+ export interface PublicationFile {
7
+ readonly path: string;
8
+ readonly text: string;
9
+ }
10
+ export interface PreparedPublication {
11
+ publish(): string;
12
+ close(): void;
13
+ }
14
+ export type PublicationStatus = 'absent' | 'applied' | 'partial' | 'unknown';
15
+ export declare function portableDraftPath(value: unknown): string;
16
+ /** Read-only host qualification of the canonical root and supported filesystem. */
17
+ export declare function qualifyPublicationRoot(root: string): string;
18
+ /** Trusted host primitive. Hold this object through the last authority check and always close it. */
19
+ export declare function preparePublication(root: string, destination: string, files: readonly PublicationFile[], metadata: string): PreparedPublication;
20
+ /** Acquiring the destination lock proves no cooperating earlier publisher can still apply. */
21
+ export declare function inspectPublication(root: string, destination: string, files: readonly PublicationFile[], metadata: string, assertCurrent: () => Promise<void>): Promise<PublicationStatus>;
22
+ //# sourceMappingURL=publication.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publication.d.ts","sourceRoot":"","sources":["../src/publication.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,iBAAiB,mJAMpB,CAAC;AACX,qBAAa,gBAAiB,SAAQ,KAAK;IAEvC,QAAQ,CAAC,IAAI,EAAE,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC;gBAAxC,IAAI,EAAE,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,EACjD,OAAO,EAAE,MAAM;CAKlB;AACD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AACD,MAAM,WAAW,mBAAmB;IAClC,OAAO,IAAI,MAAM,CAAC;IAClB,KAAK,IAAI,IAAI,CAAC;CACf;AACD,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAQ7E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAkBxD;AAiBD,mFAAmF;AACnF,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAkC3D;AAgFD,qGAAqG;AACrG,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,SAAS,eAAe,EAAE,EACjC,QAAQ,EAAE,MAAM,GACf,mBAAmB,CA4DrB;AAED,8FAA8F;AAC9F,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,SAAS,eAAe,EAAE,EACjC,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GACjC,OAAO,CAAC,iBAAiB,CAAC,CA2C5B"}