@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
@@ -0,0 +1,530 @@
1
+ import { PHASES, SEVERITIES, SHAPE_ROWS } from '@inventarch/language';
2
+ import { conditionHolds, digest, effectiveSeverity, laneOf, reaches } from '@inventarch/graph';
3
+ import { RuntimeError } from './errors.js';
4
+ import { fragmentText } from './locator.js';
5
+ import { statedText } from './render.js';
6
+ import { SCOPE_KEY_CAPS, normalizeScopeKey, resolveScopeKey } from './scope-key.js';
7
+ import { freeze } from './types.js';
8
+ /** p, the listed pointer lines before the tallies (design §1: a rendering constant, not a key part). */
9
+ const LISTED = 48;
10
+ /** c, the playbook cells a body delivers (design §1: a rendering constant, not a key part). */
11
+ const CELLS = 4;
12
+ /** The depth and budget of a re-seat key (design §7). */
13
+ const RESEAT = { depth: 1, budget: 16 };
14
+ /** The words whose subject fields apply them by word (design row 18, plan amendment A4). */
15
+ const SUBJECT_WORDS = ['law', 'convention', 'principle', 'playbook'];
16
+ const FIELD_MATCH = 'field match, not a row';
17
+ const PRIMING = SHAPE_ROWS.governance.priming;
18
+ /** The admission findings that make a loaded record's relations unknown: unresolved references and unconsented rows. */
19
+ const FINDINGS = new Set([
20
+ 'IA-GRAPH-TARGET-MISSING',
21
+ 'IA-GRAPH-TARGET-AMBIGUOUS',
22
+ 'IA-GRAPH-EDGE-UNCONSENTED',
23
+ 'IA-COMP-FIELD-REF-MISSING',
24
+ ]);
25
+ const order = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
26
+ /** The index of `value` in `list`, or the list's length for a value it does not hold: after every listed one. */
27
+ const rank = (list, value) => {
28
+ const at = value === undefined ? -1 : list.indexOf(value);
29
+ return at < 0 ? list.length : at;
30
+ };
31
+ /**
32
+ * R16: the position of the partial key `partial` through the scope token `within`: body(K) for the key normalizeScopeKey
33
+ * completes and resolveScopeKey resolves, its digest, and the host note. The key's parts are closed, so request text or
34
+ * a token in it is refused as an unknown part, and nothing text-driven runs; the body reads no capture, and the note
35
+ * reads the handle's capture pair, so writing a capture moves only the note. Refusals are those of the three steps.
36
+ */
37
+ export function position(handle, within, partial = {}) {
38
+ const key = normalizeScopeKey(partial), body = positionBody(handle, within, resolveScopeKey(handle, within, key));
39
+ const revision = handle.revision, captured = handle.capturedRevision, previous = handle.previousRevision;
40
+ return freeze({
41
+ body,
42
+ digest: digest(body),
43
+ hostNote: {
44
+ revision,
45
+ ...(captured === undefined ? {} : { capturedRevision: captured }),
46
+ ...(previous === undefined ? {} : { previousRevision: previous }),
47
+ freshness: captured === undefined ? 'no-capture' : captured === revision ? 'current' : 'stale',
48
+ key,
49
+ },
50
+ });
51
+ }
52
+ /**
53
+ * R15: body(K) for the key `resolved` that resolveScopeKey returned for the same scope token `within`. Every read goes
54
+ * through `within`, and admission findings are read only on a whole-workspace one (db PT5). A missing token, or a seat
55
+ * at runtime placement, is IA-RUNTIME-REQUEST-INVALID, and an unknown, stale or closed token keeps its database code.
56
+ * R17 adds the sections that apply by word, their cells and the mandates, and reserves blocking rules by word too.
57
+ */
58
+ export function positionBody(handle, within, resolved) {
59
+ if (typeof within !== 'string' || within.length === 0)
60
+ throw new RuntimeError('IA-RUNTIME-REQUEST-INVALID', 'Runtime reads require an explicit scope token');
61
+ // A record at runtime placement (band 0) is no part of a body: neither the seat's composition, a seed, a hop or
62
+ // waypoint, loaded, reserved, a pointer, tallied nor frontier, and no row or claim of one ranks or reaches another,
63
+ // nor is one the record a location is declared at.
64
+ const read = { within }, snapshot = handle.snapshot(read), records = snapshot.records.filter((node) => node.placement.kind !== 'runtime'), nodes = new Map(records.map((node) => [node.identity, node])), rootOf = new Map(snapshot.membership.map((row) => [row.identity, row.root])), roots = handle.roots(read);
65
+ const { key, seat, resolution, coordinate } = resolved, { kinds, lanes, predicates } = coordinate.focus, values = coordinate.values, seatId = seat.identity, word = key.word;
66
+ // Each seat refusal names the one command to run (design row 27), as a key refusal does (R14): the position without
67
+ // that seat, K0, unless the seat at runtime placement is the one K0 takes, the repository's own @workspace, whether
68
+ // the key names it or not, which K0 refuses alike; then the overview of what the workspace admits.
69
+ if (seatId !== undefined && !nodes.has(seatId)) {
70
+ const placed = snapshot.records.some((node) => node.identity === seatId);
71
+ throw new RuntimeError('IA-RUNTIME-REQUEST-INVALID', placed
72
+ ? `The seat '${seatId}' is at runtime placement (band 0), which no position body enters`
73
+ : `The seat '${seatId}' is not an admitted record in this scope`, placed && (seat.kind === 'workspace' || seatId === handle.resolveSeat('', read).seat)
74
+ ? 'ia inspect'
75
+ : 'ia position');
76
+ }
77
+ // A row with a condition is a row of the body only where its condition holds at the key's coordinate (decision
78
+ // conditional-relations-in-delivery), read as graph traversal reads it for the same coordinate: graph `conditionHolds`
79
+ // over the coordinate scopeCoordinate builds, the condition's subject being the record that states the row, the
80
+ // author graph G06 keeps as an edge's condition subject. A row that does not hold is never followed, primes nothing
81
+ // and names no pointer or frontier record, so nothing is reached through it. A conditional row stated by a record the
82
+ // body does not enter (a runtime-band @workspace's, read when one is the home) holds for nothing in it.
83
+ const live = (row) => {
84
+ if (row.kind === 'field-ref' || row.condition === undefined)
85
+ return true;
86
+ const subject = nodes.get(row.declaredOn);
87
+ return subject !== undefined && conditionHolds(row.condition, subject.dimensions, values);
88
+ };
89
+ const viewed = new Map();
90
+ const rowsOf = (identity) => {
91
+ let rows = viewed.get(identity);
92
+ if (rows === undefined)
93
+ viewed.set(identity, (rows = handle.directedView(identity, read).filter((row) => nodes.has(row.counterpart) && live(row))));
94
+ return rows;
95
+ };
96
+ /**
97
+ * The word filter (decision scope-key-caps: w restricts seeds and tallies): with w set, only records of w are
98
+ * composition, seeds, loaded, pointers, pointer tallies or frontier. The blocking rules reserved outside the budget,
99
+ * the applies-by-word section, its cells and the mandates are never filtered, so no rule that governs the loaded
100
+ * records is hidden by the word.
101
+ */
102
+ const wanted = (identity) => word === undefined || nodes.get(identity).discriminator === word;
103
+ /** The rows a hop may follow: edge rows, either direction, whose predicate is in the shape's focus. */
104
+ const inFocus = (row) => row.kind !== 'field-ref' && predicates.includes(row.predicate);
105
+ const viaRow = (from, row) => row.kind === 'field-ref'
106
+ ? { by: 'field', from, field: row.field, direction: row.direction }
107
+ : { by: 'row', from, predicate: row.predicate, spelling: row.spelling, declaredBy: row.declaredBy };
108
+ // A workspace's closure: the floor and adopted bands, and the members of its own declared roots, or, while it
109
+ // declares none (or no workspace holds the seat), every record no workspace declares a root for. A record of another
110
+ // workspace's root is never entered.
111
+ const declared = new Set(roots.map((r) => r.root));
112
+ const ownOf = (workspace) => new Set(roots.filter((r) => r.workspace === workspace).map((r) => r.root));
113
+ const holds = (own, identity) => {
114
+ const band = nodes.get(identity).band, root = rootOf.get(identity);
115
+ return band === 10 || band === 90 || (own.size > 0 ? own.has(root) : !declared.has(root));
116
+ };
117
+ // The seat's workspace: the seat itself when it is a @workspace; else, of the repository's own @workspace and the
118
+ // workspace whose declared root holds the seat record's membership root (a location's: the record it is declared at),
119
+ // the first whose closure holds that record. A floor or adopted record, an installed one included, is in every
120
+ // closure, so it is seated in the repository's workspace with the records the repository authors, even when the
121
+ // installed or adopted @workspace that ships it declares the root it sits in (plan T2's fallback: the floor, the
122
+ // adopted records and the repository's own roots). When neither closure holds the record, no workspace holds the
123
+ // seat: the seat is never outside its own closure (design §1).
124
+ const repository = () => {
125
+ const at = handle.resolveSeat('', read).seat;
126
+ return at !== undefined && nodes.get(at)?.discriminator === 'workspace' ? at : undefined;
127
+ };
128
+ const workspaceOf = (identity) => {
129
+ if (identity === undefined || !nodes.has(identity))
130
+ return repository();
131
+ if (nodes.get(identity).discriminator === 'workspace')
132
+ return identity;
133
+ const root = rootOf.get(identity);
134
+ if (root === undefined)
135
+ return repository();
136
+ const holder = roots.find((r) => reaches(r.root, root))?.workspace;
137
+ return [repository(), holder].find((at) => at !== undefined && holds(ownOf(at), identity));
138
+ };
139
+ const home = workspaceOf(seat.kind === 'location' ? resolution?.seat : seatId), own = ownOf(home);
140
+ const inside = (identity) => holds(own, identity);
141
+ // C0, at cost 0 and one level from the seat: its field references both ways; a workspace seat's capture members; a
142
+ // @system seat's word members; a location's declared-at record and claimants. The first class to reach one names it.
143
+ const composition = new Map();
144
+ const compose = (identity, via) => {
145
+ if (identity !== undefined && identity !== seatId && nodes.has(identity) && !composition.has(identity))
146
+ composition.set(identity, via);
147
+ };
148
+ if (seatId !== undefined) {
149
+ const node = nodes.get(seatId);
150
+ for (const row of rowsOf(seatId))
151
+ if (row.kind === 'field-ref')
152
+ compose(row.counterpart, viaRow(seatId, row));
153
+ if (node.discriminator === 'workspace')
154
+ for (const row of snapshot.membership)
155
+ if (own.has(row.root))
156
+ compose(row.identity, { by: 'membership', root: row.root });
157
+ if (node.discriminator === 'system')
158
+ for (const record of records)
159
+ if (record.system === node.name)
160
+ compose(record.identity, { by: 'word', system: node.name });
161
+ }
162
+ if (seat.kind === 'location' && resolution !== undefined) {
163
+ if (resolution.seat !== undefined)
164
+ compose(resolution.seat, { by: 'declared-at', rule: resolution.by });
165
+ for (const claimant of resolution.claimants)
166
+ compose(claimant.identity, { by: 'claim', matches: claimant.matches });
167
+ }
168
+ /**
169
+ * C0, Σ and the hops under one word filter `keep`. With w set the body walks twice: under the filter for what loads,
170
+ * the pointers, their tallies and the frontier, and without it for the candidates whose blocking rules are reserved.
171
+ */
172
+ const traverse = (keep) => {
173
+ const c0 = new Map(), boundary = new Map();
174
+ for (const [identity, via] of composition)
175
+ if (keep(identity)) {
176
+ if (inside(identity))
177
+ c0.set(identity, via);
178
+ else
179
+ boundary.set(identity, { hop: 0, via });
180
+ }
181
+ // Σ = {S} ∪ {r ∈ C0 : kind(r) ∈ kind focus ∨ lane(r) ∈ lane focus}.
182
+ const seeds = [...c0.keys()]
183
+ .filter((identity) => {
184
+ const node = nodes.get(identity);
185
+ return kinds.includes(node.kind) || lanes.includes(laneOf(node));
186
+ })
187
+ .sort(order);
188
+ // Hops 1..d from Σ over edge rows in predicate focus, either direction, never leaving the closure: a record outside
189
+ // it is a pointer, not entered; with w set, a record of another word is a waypoint, followed, never loaded or
190
+ // listed.
191
+ const reached = new Map(seeds.map((identity) => [identity, { hop: 0, via: c0.get(identity) }])), waypoints = new Set();
192
+ let level = [...(seatId === undefined ? [] : [seatId]), ...seeds];
193
+ for (let hop = 1; hop <= key.depth; hop++) {
194
+ const next = [];
195
+ for (const from of level)
196
+ for (const row of rowsOf(from)) {
197
+ const to = row.counterpart;
198
+ if (!inFocus(row) || to === seatId || reached.has(to) || boundary.has(to))
199
+ continue;
200
+ if (!inside(to)) {
201
+ if (keep(to))
202
+ boundary.set(to, { hop, via: viaRow(from, row) });
203
+ continue;
204
+ }
205
+ reached.set(to, { hop, via: viaRow(from, row) });
206
+ if (!keep(to))
207
+ waypoints.add(to);
208
+ next.push(to);
209
+ }
210
+ level = next.sort(order);
211
+ }
212
+ const hopReached = [...reached.keys()].filter((identity) => reached.get(identity).hop > 0 && !waypoints.has(identity));
213
+ return { c0, boundary, seeds, reached, hopReached };
214
+ };
215
+ const unfiltered = traverse(() => true), { c0, boundary, seeds, reached, hopReached } = word === undefined ? unfiltered : traverse(wanted);
216
+ /** How a record of the word's walk was first reached: the seat, a hop, else its composition class. */
217
+ const reachOf = (identity) => identity === seatId ? { hop: 0 } : (reached.get(identity) ?? { hop: 0, via: c0.get(identity) });
218
+ // The blocking rules reserved by word alone (R17), which no composition class or hop reaches.
219
+ const matched = new Map();
220
+ /** How a reserved rule was first reached, in the walk without the word, or by its field match. */
221
+ const ruleReach = (identity) => unfiltered.reached.get(identity) ?? matched.get(identity) ?? { hop: 0, via: unfiltered.c0.get(identity) };
222
+ // Applies by word (design row 18, plan amendment A4, R17): the @law, @convention, @principle and @playbook records of
223
+ // the closure whose `subject.subject-word` is the word, or `subject.subject-kind` the kind, of a record, of any word
224
+ // whatever w is. A field match, not a row: it costs no hop and claims no relation or consent.
225
+ const subjects = records.flatMap((node) => {
226
+ if (!SUBJECT_WORDS.includes(node.discriminator) || !inside(node.identity))
227
+ return [];
228
+ const word = statedText(node, 'subject.subject-word'), kind = statedText(node, 'subject.subject-kind');
229
+ return word === undefined && kind === undefined
230
+ ? []
231
+ : [{ identity: node.identity, ...(word === undefined ? {} : { word }), ...(kind === undefined ? {} : { kind }) }];
232
+ });
233
+ /** The subject fields of `subject` that the word or kind of a record of `against` answers, each with the first. */
234
+ const matchesOf = (subject, against) => {
235
+ const first = (value, of) => value === undefined ? undefined : against.find((identity) => of(nodes.get(identity)) === value);
236
+ const byWord = first(subject.word, (node) => node.discriminator), byKind = first(subject.kind, (node) => node.kind);
237
+ return [
238
+ ...(byWord === undefined
239
+ ? []
240
+ : [{ field: 'subject.subject-word', value: subject.word, record: byWord }]),
241
+ ...(byKind === undefined
242
+ ? []
243
+ : [{ field: 'subject.subject-kind', value: subject.kind, record: byKind }]),
244
+ ];
245
+ };
246
+ const blocking = (identity) => {
247
+ const node = nodes.get(identity);
248
+ return node.kind === 'governance' && effectiveSeverity(node.dimensions, values) === 'blocking';
249
+ };
250
+ // The order keys of design §6, total: governance (prime, band ↓, hop, sev, id), every other shape (band ↓, hop,
251
+ // lane, id). prime is the least priming index of a row incident to the record, sev its severity's rank.
252
+ const sorted = (identities, hopOf, governance) => [...identities]
253
+ .map((identity) => {
254
+ const node = nodes.get(identity);
255
+ return {
256
+ identity,
257
+ band: node.band,
258
+ hop: hopOf(identity),
259
+ prime: governance
260
+ ? Math.min(PRIMING.length, ...rowsOf(identity).flatMap((row) => (row.kind === 'field-ref' ? [] : [rank(PRIMING, row.predicate)])))
261
+ : 0,
262
+ sev: governance ? rank(SEVERITIES, effectiveSeverity(node.dimensions, values)) : 0,
263
+ lane: governance ? 0 : rank(lanes, laneOf(node)),
264
+ };
265
+ })
266
+ .sort((a, b) => a.prime - b.prime ||
267
+ b.band - a.band ||
268
+ a.hop - b.hop ||
269
+ a.sev - b.sev ||
270
+ a.lane - b.lane ||
271
+ order(a.identity, b.identity))
272
+ .map((entry) => entry.identity);
273
+ const governance = key.shape === 'governance', hopOfReach = (identity) => reachOf(identity).hop;
274
+ // K = {S} ∪ C0 ∪ Σ ∪ C before truncation, and before the word filter. R, its blocking governance, and the blocking
275
+ // rules that apply by word to a record of K, whichever records n truncates or w leaves out (R17), are reserved
276
+ // outside n, then L = {S} ∪ first n of sort(((Σ \ {S}) ∪ C) \ R), Σ and C under the word.
277
+ const candidates = new Set([...unfiltered.c0.keys(), ...unfiltered.hopReached]), among = [...(seatId === undefined ? [] : [seatId]), ...[...candidates].sort(order)];
278
+ for (const subject of subjects)
279
+ if (subject.identity !== seatId && !candidates.has(subject.identity) && blocking(subject.identity)) {
280
+ const matches = matchesOf(subject, among);
281
+ if (matches.length > 0)
282
+ matched.set(subject.identity, { hop: 0, via: { by: 'subject', label: FIELD_MATCH, matches } });
283
+ }
284
+ const rules = sorted([...[...candidates].filter(blocking), ...matched.keys()], (identity) => ruleReach(identity).hop, true);
285
+ const reserved = new Set(rules);
286
+ const pool = sorted(new Set([...seeds, ...hopReached].filter((identity) => !reserved.has(identity))), hopOfReach, governance);
287
+ const chosen = pool.slice(0, key.budget), entered = [...(seatId === undefined ? [] : [seatId]), ...chosen], inLoaded = new Set(entered);
288
+ // Pointers: (C0 ∪ C ∪ the out-of-focus rows and field references of L) \ (L ∪ R), and the records outside the
289
+ // closure that composition or a hop reached; each once, by the first that reaches it.
290
+ const pointed = new Map();
291
+ const point = (identity, reach) => {
292
+ if (identity === seatId || inLoaded.has(identity) || reserved.has(identity) || pointed.has(identity))
293
+ return;
294
+ if (wanted(identity))
295
+ pointed.set(identity, reach);
296
+ };
297
+ for (const identity of [...c0.keys(), ...hopReached])
298
+ point(identity, reachOf(identity));
299
+ for (const [identity, reach] of boundary)
300
+ point(identity, reach);
301
+ for (const from of entered)
302
+ for (const row of rowsOf(from))
303
+ if (!inFocus(row))
304
+ point(row.counterpart, { hop: reachOf(from).hop, via: viaRow(from, row) });
305
+ const pointers = sorted(pointed.keys(), (identity) => pointed.get(identity).hop, governance);
306
+ // The frontier: hop d + 1 from L, records nothing above lists or reached, never entered.
307
+ const frontier = new Set();
308
+ for (const from of entered)
309
+ if (reachOf(from).hop === key.depth)
310
+ for (const row of rowsOf(from)) {
311
+ const to = row.counterpart;
312
+ if (inFocus(row) &&
313
+ wanted(to) &&
314
+ to !== seatId &&
315
+ !inLoaded.has(to) &&
316
+ !reserved.has(to) &&
317
+ !pointed.has(to) &&
318
+ !reached.has(to) &&
319
+ !boundary.has(to))
320
+ frontier.add(to);
321
+ }
322
+ // The rules and playbooks outside `rules` that apply by word to a record of L or of R: R is delivered in full, as L
323
+ // is, so reserving a blocking candidate outside n keeps what applies to it. A rule `rules` holds by word alone is a
324
+ // field match itself, not a record of L or R, so matches never chain. Each is listed once, whichever of its fields
325
+ // match and however many records answer them, and with no row or hop to rank by, it ranks by band ↓ then identity,
326
+ // as claimants and cells do.
327
+ const delivered = [...entered, ...rules.filter((identity) => candidates.has(identity))];
328
+ const byBand = (a, b) => nodes.get(b).band - nodes.get(a).band || order(a, b);
329
+ const applies = subjects
330
+ .filter((subject) => !reserved.has(subject.identity))
331
+ .map((subject) => ({ identity: subject.identity, matches: matchesOf(subject, delivered) }))
332
+ .filter((entry) => entry.matches.length > 0)
333
+ .sort((a, b) => byBand(a.identity, b.identity));
334
+ // The cells at (P, primitive(H)) of the first c playbooks that apply by word (design row 19): the text `ia read`
335
+ // reads at the address, every cell there in source order, conditions unevaluated; else the nearest phase with a cell
336
+ // of that primitive, by distance in the cycle orient, plan, act, learn, a tie going to the phase that order lists
337
+ // first.
338
+ const primitive = SHAPE_ROWS[key.shape].primitive, phaseAt = PHASES.indexOf(key.phase);
339
+ const cellOf = (identity) => {
340
+ const node = nodes.get(identity), fragment = `${key.phase}/${primitive}`, text = fragmentText(node, fragment);
341
+ if (text !== undefined)
342
+ return { playbook: identity, address: `${identity}#${fragment}`, text };
343
+ const has = (phase) => node.cells.some((cell) => cell.phase === phase && cell.primitive === primitive);
344
+ const distance = (phase) => {
345
+ const apart = Math.abs(PHASES.indexOf(phase) - phaseAt);
346
+ return Math.min(apart, PHASES.length - apart);
347
+ };
348
+ const nearest = PHASES.filter(has).sort((a, b) => distance(a) - distance(b) || PHASES.indexOf(a) - PHASES.indexOf(b))[0];
349
+ return {
350
+ playbook: identity,
351
+ missing: `${identity}#${fragment}`,
352
+ ...(nearest === undefined ? {} : { nearest }),
353
+ message: nearest === undefined
354
+ ? `no cell; no phase has a cell at ${primitive}`
355
+ : `no cell; nearest phase with a cell: ${nearest}`,
356
+ };
357
+ };
358
+ const cells = applies
359
+ .filter((entry) => nodes.get(entry.identity).discriminator === 'playbook')
360
+ .slice(0, CELLS)
361
+ .map((entry) => cellOf(entry.identity));
362
+ // The mandates (plan amendment A8; a body matches no participant, which the position packet selects over body(K0)'s
363
+ // mandates, R19): those of the closure that claim a location seat or whose `authority.scope` names the seat's
364
+ // workspace, each once, a mandate that does both keeping its claim, all ranked by band ↓ then identity.
365
+ const governing = new Map();
366
+ const govern = (identity, via) => {
367
+ if (nodes.get(identity)?.discriminator === 'mandate' && inside(identity) && !governing.has(identity))
368
+ governing.set(identity, via);
369
+ };
370
+ if (seat.kind === 'location' && resolution !== undefined)
371
+ for (const claimant of resolution.claimants)
372
+ govern(claimant.identity, { by: 'claim', matches: claimant.matches });
373
+ if (home !== undefined)
374
+ for (const row of rowsOf(home))
375
+ if (row.kind === 'field-ref' && row.direction === 'in' && row.field === 'authority.scope')
376
+ govern(row.counterpart, viaRow(home, row));
377
+ const mandates = [...governing.keys()].sort(byBand);
378
+ /** The steward the @system `system` names in `head.steward`, when the scope admits that @system. */
379
+ const stewardOf = (system) => {
380
+ const identity = `floor/definition/system/${system}`;
381
+ return nodes.has(identity)
382
+ ? rowsOf(identity).find((row) => row.kind === 'field-ref' && row.field === 'head.steward' && row.direction === 'out')?.counterpart
383
+ : undefined;
384
+ };
385
+ const record = (identity, reach) => {
386
+ const node = nodes.get(identity), steward = stewardOf(node.system);
387
+ return {
388
+ identity,
389
+ word: node.discriminator,
390
+ kind: node.kind,
391
+ lane: laneOf(node),
392
+ system: node.system,
393
+ ...(steward === undefined ? {} : { steward }),
394
+ band: node.band,
395
+ hop: reach.hop,
396
+ ...(reach.via === undefined ? {} : { via: reach.via }),
397
+ };
398
+ };
399
+ const loadedRecord = (identity, reach) => ({
400
+ ...record(identity, reach),
401
+ digest: nodes.get(identity).digest,
402
+ });
403
+ const pointer = (identity) => {
404
+ const reach = pointed.get(identity), holder = inside(identity) ? undefined : roots.find((r) => r.root === rootOf.get(identity))?.workspace;
405
+ return { ...record(identity, reach), via: reach.via, ...(holder === undefined ? {} : { workspace: holder }) };
406
+ };
407
+ /** Per-group counts, the groups in key order. */
408
+ const tally = (identities, group) => {
409
+ const counts = new Map();
410
+ for (const identity of identities) {
411
+ const [system, value] = group(identity), at = JSON.stringify([system, value]);
412
+ const entry = counts.get(at) ?? { system, value, count: 0 };
413
+ entry.count++;
414
+ counts.set(at, entry);
415
+ }
416
+ return [...counts.values()].sort((a, b) => order(a.system, b.system) || order(a.value, b.value));
417
+ };
418
+ const withSteward = (system) => {
419
+ const steward = stewardOf(system);
420
+ return steward === undefined ? {} : { steward };
421
+ };
422
+ /** The entries past the listed ones, per (word, owner system). */
423
+ const wordTallies = (identities) => tally(identities, (identity) => [nodes.get(identity).system, nodes.get(identity).discriminator]).map(({ system, value, count }) => ({ system, word: value, ...withSteward(system), count }));
424
+ // Unknowns: the seat's, its workspace's sources, and on a whole-workspace scope the unresolved references and
425
+ // unconsented rows admission found on a loaded record.
426
+ const unknowns = [];
427
+ if (seat.kind === 'location') {
428
+ const path = seat.path, declaredAt = resolution?.seat !== undefined && nodes.has(resolution.seat);
429
+ // A narrowed scope prunes the claimants it does not admit (db D09), so it can say only that none in it claims.
430
+ if (!declaredAt && !resolution?.claimants.some((claimant) => nodes.has(claimant.identity)))
431
+ unknowns.push({
432
+ kind: 'seat',
433
+ subject: path,
434
+ message: handle.isCompleteScope(within)
435
+ ? `no record claims '${path}' and none is declared at it; widening key: the workspace`
436
+ : `no record in this scope claims '${path}' and none in it is declared at it; widening key: the workspace`,
437
+ });
438
+ else if (!declaredAt)
439
+ unknowns.push({
440
+ kind: 'seat',
441
+ subject: path,
442
+ message: `no admitted record in this scope is declared at '${path}'`,
443
+ });
444
+ }
445
+ else if (seat.unknown !== undefined)
446
+ unknowns.push({ kind: 'seat', message: 'no admitted @workspace in this scope is declared at the repository root' });
447
+ const fallback = 'its closure is the floor, the adopted records and every record no workspace declares a root for';
448
+ if (home !== undefined && own.size === 0)
449
+ unknowns.push({
450
+ kind: 'sources',
451
+ subject: home,
452
+ message: `workspace declares no sources: ${home} has no capture members, and ${fallback}`,
453
+ });
454
+ else if (home === undefined && seat.kind !== 'workspace')
455
+ unknowns.push({ kind: 'sources', message: `no @workspace holds the seat, and ${fallback}` });
456
+ if (handle.isCompleteScope(within)) {
457
+ const spans = entered.map((identity) => nodes.get(identity));
458
+ for (const finding of handle.report.findings) {
459
+ if (!FINDINGS.has(finding.code))
460
+ continue;
461
+ // The innermost loaded record whose source span holds the finding's line.
462
+ const subject = spans
463
+ .filter((node) => node.source.path === finding.path && node.source.line <= finding.line)
464
+ .filter((node) => finding.line <= node.source.endLine)
465
+ .sort((a, b) => b.source.line - a.source.line)[0];
466
+ if (subject !== undefined)
467
+ unknowns.push({
468
+ kind: 'finding',
469
+ subject: subject.identity,
470
+ code: finding.code,
471
+ path: finding.path,
472
+ line: finding.line,
473
+ message: finding.message,
474
+ });
475
+ }
476
+ }
477
+ else
478
+ unknowns.push({
479
+ kind: 'unread',
480
+ message: 'a narrowed scope reads no admission finding, so unresolved and unconsented rows are not named',
481
+ });
482
+ const listed = pointers.slice(0, LISTED), tallied = pointers.slice(LISTED), frontierIds = [...frontier];
483
+ const body = {
484
+ format: 'ia.position-body.v1',
485
+ revision: snapshot.revision,
486
+ key,
487
+ seat,
488
+ loaded: [
489
+ seatId === undefined ? { path: seat.path ?? '' } : loadedRecord(seatId, reachOf(seatId)),
490
+ ...chosen.map((identity) => loadedRecord(identity, reachOf(identity))),
491
+ ],
492
+ rules: rules.map((identity) => loadedRecord(identity, ruleReach(identity))),
493
+ pointers: listed.map(pointer),
494
+ pointerTallies: wordTallies(tallied),
495
+ appliesByWord: applies.slice(0, LISTED).map(({ identity, matches }) => {
496
+ const via = { by: 'subject', label: FIELD_MATCH, matches };
497
+ return {
498
+ ...record(identity, { hop: 0, via }),
499
+ via,
500
+ reseat: { seat: identity, shape: key.shape, phase: key.phase, ...RESEAT },
501
+ };
502
+ }),
503
+ appliesByWordTallies: wordTallies(applies.slice(LISTED).map((entry) => entry.identity)),
504
+ cells,
505
+ mandates: mandates.map((identity) => {
506
+ const via = governing.get(identity);
507
+ return { ...record(identity, { hop: 0, via }), via };
508
+ }),
509
+ frontier: tally(frontierIds, (identity) => [nodes.get(identity).system, nodes.get(identity).kind]).map(({ system, value, count }) => ({ system, kind: value, ...withSteward(system), count })),
510
+ unknowns,
511
+ counts: {
512
+ composition: c0.size,
513
+ seeds: seeds.length + 1,
514
+ loaded: 1 + chosen.length,
515
+ rules: rules.length,
516
+ pointers: pointers.length,
517
+ appliesByWord: applies.length,
518
+ frontier: frontier.size,
519
+ truncatedLoaded: pool.length - chosen.length,
520
+ truncatedPointers: tallied.length,
521
+ truncatedAppliesByWord: Math.max(0, applies.length - LISTED),
522
+ },
523
+ widening: {
524
+ ...(key.depth < SCOPE_KEY_CAPS.depth ? { deeper: { ...key, depth: key.depth + 1 } } : {}),
525
+ reseat: { shape: key.shape, phase: key.phase, ...RESEAT },
526
+ },
527
+ };
528
+ return freeze(body);
529
+ }
530
+ //# sourceMappingURL=position.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"position.js","sourceRoot":"","sources":["../src/position.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEtE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG/F,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEpF,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AA+OpC,wGAAwG;AACxG,MAAM,MAAM,GAAG,EAAE,CAAC;AAClB,+FAA+F;AAC/F,MAAM,KAAK,GAAG,CAAC,CAAC;AAChB,yDAAyD;AACzD,MAAM,MAAM,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAW,CAAC;AACjD,4FAA4F;AAC5F,MAAM,aAAa,GAAsB,CAAC,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;AACxF,MAAM,WAAW,GAAG,wBAAwB,CAAC;AAC7C,MAAM,OAAO,GAAsB,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC;AACjE,wHAAwH;AACxH,MAAM,QAAQ,GAAwB,IAAI,GAAG,CAAC;IAC5C,yBAAyB;IACzB,2BAA2B;IAC3B,2BAA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,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM;YACzB,KAAK,EAAE,KAAK,CAAC,MAAM;YACnB,QAAQ,EAAE,QAAQ,CAAC,MAAM;YACzB,aAAa,EAAE,OAAO,CAAC,MAAM;YAC7B,QAAQ,EAAE,QAAQ,CAAC,IAAI;YACvB,eAAe,EAAE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM;YAC5C,iBAAiB,EAAE,OAAO,CAAC,MAAM;YACjC,sBAAsB,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;SAC7D;QACD,QAAQ,EAAE;YACR,GAAG,CAAC,GAAG,CAAC,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACzF,MAAM,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,GAAG,MAAM,EAAE;SAC1D;KACF,CAAC;IACF,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;AACtB,CAAC"}
package/dist/render.d.ts CHANGED
@@ -1,9 +1,20 @@
1
- import type { CompiledValue, Variant } from '@inventarch/language';
1
+ import type { CompiledRecord, CompiledValue, Variant } from '@inventarch/language';
2
2
  import type { Coordinate, Node } from '@inventarch/graph';
3
3
  import type { Clause } from './types.js';
4
4
  export declare function valueText(value: CompiledValue): string;
5
+ /**
6
+ * The text the record states unconditionally at `field`, a `section.key` path: a text, string or scalar value. Undefined
7
+ * when the record does not state it, states it only under a condition, or states a value that is not text.
8
+ */
9
+ export declare function statedText(node: CompiledRecord, field: string): string | undefined;
5
10
  /** The record's `says` and `answers`, rendered as recordText renders its meaning, or undefined when it has neither. */
6
11
  export declare function purposeOf(node: Node): string | undefined;
12
+ /**
13
+ * The record's own body (`ia read`, position-and-projection row 23): the part of what recordText renders that the record
14
+ * states rather than structures, its `meaning.says`. A `@system`, which has no meaning section, states its head
15
+ * `describes`; a record that states neither (a `@schema`) has an empty body.
16
+ */
17
+ export declare function bodyOf(node: Node): string;
7
18
  export declare function clausesOf(node: Node, selected: ReadonlyMap<string, Variant>): readonly Clause[];
8
19
  export declare function recordText(node: Node, coordinate: Coordinate, clauses: readonly Clause[]): string;
9
20
  //# sourceMappingURL=render.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAiB,aAAa,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAElF,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,wBAAgB,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CActD;AAYD,uHAAuH;AACvH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAMxD;AACD,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,MAAM,EAAE,CAmB/F;AACD,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAmBjG"}
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAgC,cAAc,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEjH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO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