@eir-labs/coltrane 0.8.0 → 0.9.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 (80) hide show
  1. package/agents/change-verifier.json +40 -0
  2. package/agents/code-implementer.json +42 -0
  3. package/agents/contract-definer.json +31 -0
  4. package/agents/defect-investigator.json +60 -0
  5. package/agents/grounder.json +38 -0
  6. package/agents/pr-publisher.json +48 -0
  7. package/agents/red-spec-drafter.json +46 -0
  8. package/agents/spec-publisher.json +48 -0
  9. package/agents/spec-reviewer.json +32 -0
  10. package/dist/src/bifrost_invoker.js +53 -52
  11. package/dist/src/bifrost_invoker.js.map +1 -1
  12. package/dist/src/change_set_branch.d.ts +131 -0
  13. package/dist/src/change_set_branch.js +179 -0
  14. package/dist/src/change_set_branch.js.map +1 -0
  15. package/dist/src/claude_invoker.d.ts +79 -2
  16. package/dist/src/claude_invoker.js +377 -36
  17. package/dist/src/claude_invoker.js.map +1 -1
  18. package/dist/src/cli.d.ts +1 -1
  19. package/dist/src/cli.js +26 -3
  20. package/dist/src/cli.js.map +1 -1
  21. package/dist/src/committed_work.d.ts +206 -0
  22. package/dist/src/committed_work.js +0 -0
  23. package/dist/src/committed_work.js.map +1 -0
  24. package/dist/src/composition.d.ts +11 -0
  25. package/dist/src/composition.js +3 -1
  26. package/dist/src/composition.js.map +1 -1
  27. package/dist/src/genome_schema.d.ts +803 -10
  28. package/dist/src/genome_schema.js +413 -7
  29. package/dist/src/genome_schema.js.map +1 -1
  30. package/dist/src/genome_store.d.ts +16 -1
  31. package/dist/src/genome_store.js +68 -0
  32. package/dist/src/genome_store.js.map +1 -1
  33. package/dist/src/gig_tracker.js +4 -0
  34. package/dist/src/gig_tracker.js.map +1 -1
  35. package/dist/src/hosted_tools.js +19 -0
  36. package/dist/src/hosted_tools.js.map +1 -1
  37. package/dist/src/institution_enforcement.d.ts +77 -0
  38. package/dist/src/institution_enforcement.js +442 -0
  39. package/dist/src/institution_enforcement.js.map +1 -0
  40. package/dist/src/institution_loader.d.ts +63 -0
  41. package/dist/src/institution_loader.js +239 -0
  42. package/dist/src/institution_loader.js.map +1 -0
  43. package/dist/src/loader.d.ts +4 -1
  44. package/dist/src/loader.js +19 -1
  45. package/dist/src/loader.js.map +1 -1
  46. package/dist/src/mcp.js +8 -1
  47. package/dist/src/mcp.js.map +1 -1
  48. package/dist/src/runtime.d.ts +66 -0
  49. package/dist/src/runtime.js +202 -2
  50. package/dist/src/runtime.js.map +1 -1
  51. package/dist/src/server.d.ts +7 -0
  52. package/dist/src/server.js +90 -1
  53. package/dist/src/server.js.map +1 -1
  54. package/dist/src/venue_realize.d.ts +90 -0
  55. package/dist/src/venue_realize.js +129 -0
  56. package/dist/src/venue_realize.js.map +1 -0
  57. package/dist/src/version.d.ts +1 -1
  58. package/dist/src/version.js +1 -1
  59. package/dist/src/worker.d.ts +45 -3
  60. package/dist/src/worker.js +67 -2
  61. package/dist/src/worker.js.map +1 -1
  62. package/domain_types/change-request.json +2 -1
  63. package/domain_types/class-sweep.json +34 -0
  64. package/domain_types/defect-class.json +25 -0
  65. package/domain_types/defect-location.json +28 -0
  66. package/domain_types/defect-report.json +28 -0
  67. package/domain_types/fix-spec.json +28 -0
  68. package/domain_types/fix-verification.json +28 -0
  69. package/domain_types/grounding-dossier.json +95 -0
  70. package/domain_types/pull-request.json +43 -0
  71. package/domain_types/red-spec.json +76 -0
  72. package/domain_types/reproduction.json +28 -0
  73. package/domain_types/root-cause.json +28 -0
  74. package/domain_types/subsystem-contract.json +106 -0
  75. package/institutions/coltrane.json +166 -0
  76. package/institutions/quartet.json +143 -26
  77. package/package.json +2 -1
  78. package/standards/defect-investigation-v1.json +156 -0
  79. package/standards/software-change-pr-v1.json +151 -0
  80. package/standards/spec-drafting-v1.json +125 -0
@@ -0,0 +1,442 @@
1
+ // Institutional-law ENFORCEMENT — the seam that makes Coltrane's own laws machine-checkable
2
+ // at the moment of action, rather than prose that sounds binding.
3
+ //
4
+ // Coltrane's public position is that an institutional law is decidable when an action is
5
+ // attempted. Today institutions/coltrane.json ships three ADICO laws whose `check.predicate`
6
+ // is a real s-expression that NOTHING evaluates, and composeStandard verifies chair caps at
7
+ // dispatch while verifying no chair obligation at all. This module is the repair: a
8
+ // zero-dependency in-house s-expression evaluator with a fixed verdict codomain, and an
9
+ // admissibility check that refuses an institution document claiming more enforcement than it
10
+ // has.
11
+ //
12
+ // GREEN STATUS. The signatures below and the `Verdict` codomain are the fixed seam authored by
13
+ // the red spec; this change fills the bodies WITHOUT touching either. The evaluator is a total
14
+ // four-plus-valued reducer over a supplied fact record; admissibility is a separate, explicitly
15
+ // invoked pure function. Neither is wired into loadGenome — a universal gate would refuse
16
+ // quartet.json (unmarked obligations, non-fact-decidable operators) and break "loads unchanged".
17
+ // See docs/specs/coltrane-enforces-its-laws.md.
18
+ /** The five closed verdict values as data — for codomain-closure and exhaustiveness assertions. */
19
+ export const VERDICTS = [
20
+ "PERMIT",
21
+ "DENY",
22
+ "NOT_APPLICABLE",
23
+ "UNDECIDED",
24
+ "DEAD_NAME",
25
+ ];
26
+ // ── An in-house, zero-dependency s-expression reader ──────────────────────────────────────────
27
+ // SMT-LIB2 is itself s-expression many-sorted first-order logic, so a Z3 backend later sits behind
28
+ // the SAME `evaluate()` signature; this reader is the fact-only front half. It is TOTAL over
29
+ // well-formed input and throws only ParseError on malformed input — which `evaluate` catches
30
+ // (runtime never throws) and which admissibility surfaces as a static refusal.
31
+ class ParseError extends Error {
32
+ }
33
+ function isDelimiter(c) {
34
+ return c === "(" || c === ")" || c === '"' || c === " " || c === "\t" || c === "\n" || c === "\r";
35
+ }
36
+ function tokenize(src) {
37
+ const out = [];
38
+ const n = src.length;
39
+ let i = 0;
40
+ while (i < n) {
41
+ const c = src[i];
42
+ if (c === " " || c === "\t" || c === "\n" || c === "\r") {
43
+ i++;
44
+ continue;
45
+ }
46
+ if (c === "(") {
47
+ out.push({ t: "(" });
48
+ i++;
49
+ continue;
50
+ }
51
+ if (c === ")") {
52
+ out.push({ t: ")" });
53
+ i++;
54
+ continue;
55
+ }
56
+ if (c === '"') {
57
+ let j = i + 1;
58
+ let s = "";
59
+ while (j < n && src[j] !== '"') {
60
+ if (src[j] === "\\" && j + 1 < n) {
61
+ s += src[j + 1];
62
+ j += 2;
63
+ continue;
64
+ }
65
+ s += src[j];
66
+ j++;
67
+ }
68
+ if (j >= n)
69
+ throw new ParseError("unterminated string literal");
70
+ out.push({ t: "str", v: s });
71
+ i = j + 1;
72
+ continue;
73
+ }
74
+ let j = i;
75
+ while (j < n && !isDelimiter(src[j]))
76
+ j++;
77
+ out.push({ t: "sym", v: src.slice(i, j) });
78
+ i = j;
79
+ }
80
+ return out;
81
+ }
82
+ function parse(src) {
83
+ const toks = tokenize(src);
84
+ let pos = 0;
85
+ function readExpr() {
86
+ if (pos >= toks.length)
87
+ throw new ParseError("unexpected end of input");
88
+ const tok = toks[pos];
89
+ if (tok.t === "(") {
90
+ pos++;
91
+ const items = [];
92
+ while (pos < toks.length && toks[pos].t !== ")")
93
+ items.push(readExpr());
94
+ if (pos >= toks.length)
95
+ throw new ParseError("unbalanced parenthesis");
96
+ pos++; // consume the ")"
97
+ return { kind: "list", items };
98
+ }
99
+ if (tok.t === ")")
100
+ throw new ParseError("unexpected )");
101
+ pos++;
102
+ return tok.t === "str" ? { kind: "str", value: tok.v } : { kind: "sym", name: tok.v };
103
+ }
104
+ const expr = readExpr();
105
+ if (pos !== toks.length)
106
+ throw new ParseError("trailing tokens after expression");
107
+ return expr;
108
+ }
109
+ // ── The operator table — the UNION across both shipped institutions ───────────────────────────
110
+ // coltrane's fact-decidable core plus quartet's collection/temporal operators. An operator in this
111
+ // set is IMPLEMENTED (it does not trip the admissibility "unimplemented operator" refusal); one
112
+ // outside it is an unimplemented operator — an admissibility refusal statically, and UNDECIDED at
113
+ // runtime. Some KNOWN operators (subseteq/forall/resolvable/…) still cannot be reduced from facts
114
+ // alone, so they too return UNDECIDED at runtime — that is an honest non-decision, not an unknown.
115
+ const KNOWN_OPERATORS = new Set([
116
+ "=>",
117
+ "and",
118
+ "or",
119
+ "not",
120
+ "=",
121
+ "is-agent",
122
+ "human-governor",
123
+ "require",
124
+ "allow",
125
+ "deny",
126
+ "subseteq",
127
+ "forall",
128
+ "resolvable",
129
+ "nonempty",
130
+ "declared_before",
131
+ "has",
132
+ "backed_by_contract",
133
+ ]);
134
+ /** `allow` / `deny` are verdict ATOMS, not variables — excluded when collecting free variables. */
135
+ const VERDICT_ATOMS = new Set(["allow", "deny"]);
136
+ function resolveOperand(node, facts) {
137
+ if (node.kind === "str")
138
+ return { ok: true, value: node.value };
139
+ if (node.kind === "sym")
140
+ return { ok: true, value: facts[node.name] };
141
+ return { ok: false };
142
+ }
143
+ function asBool(node, facts) {
144
+ if (node.kind !== "list" || node.items.length === 0)
145
+ return "U";
146
+ const head = node.items[0];
147
+ if (head.kind !== "sym")
148
+ return "U";
149
+ const args = node.items.slice(1);
150
+ switch (head.name) {
151
+ case "and": {
152
+ let seenUndecided = false;
153
+ for (const a of args) {
154
+ const b = asBool(a, facts);
155
+ if (b === false)
156
+ return false;
157
+ if (b === "U")
158
+ seenUndecided = true;
159
+ }
160
+ return seenUndecided ? "U" : true;
161
+ }
162
+ case "or": {
163
+ let seenUndecided = false;
164
+ for (const a of args) {
165
+ const b = asBool(a, facts);
166
+ if (b === true)
167
+ return true;
168
+ if (b === "U")
169
+ seenUndecided = true;
170
+ }
171
+ return seenUndecided ? "U" : false;
172
+ }
173
+ case "not": {
174
+ if (args.length !== 1)
175
+ return "U";
176
+ const b = asBool(args[0], facts);
177
+ return b === "U" ? "U" : !b;
178
+ }
179
+ case "=": {
180
+ if (args.length !== 2)
181
+ return "U";
182
+ const l = resolveOperand(args[0], facts);
183
+ const r = resolveOperand(args[1], facts);
184
+ if (!l.ok || !r.ok)
185
+ return "U";
186
+ return l.value === r.value;
187
+ }
188
+ case "is-agent": {
189
+ if (args.length !== 1)
190
+ return "U";
191
+ const v = resolveOperand(args[0], facts).value;
192
+ return !!v && typeof v === "object" && v.is_agent === true;
193
+ }
194
+ case "human-governor": {
195
+ if (args.length !== 1)
196
+ return "U";
197
+ const v = resolveOperand(args[0], facts).value;
198
+ return !!v && typeof v === "object" && v.human_governor === true;
199
+ }
200
+ default:
201
+ // A KNOWN-but-not-fact-decidable operator (subseteq/forall/resolvable/nonempty/…) or one this
202
+ // evaluator does not implement: it cannot be reduced from the supplied facts. UNDECIDED, never
203
+ // a silent true/false.
204
+ return "U";
205
+ }
206
+ }
207
+ function asVerdict(node, facts) {
208
+ if (node.kind === "sym") {
209
+ if (node.name === "allow")
210
+ return "PERMIT";
211
+ if (node.name === "deny")
212
+ return "DENY";
213
+ return "UNDECIDED";
214
+ }
215
+ if (node.kind === "str")
216
+ return "UNDECIDED";
217
+ if (node.items.length === 0)
218
+ return "UNDECIDED";
219
+ const head = node.items[0];
220
+ if (head.kind !== "sym")
221
+ return "UNDECIDED";
222
+ const args = node.items.slice(1);
223
+ switch (head.name) {
224
+ case "=>": {
225
+ // The guard/consequent form: P false → the law does not govern this action (NOT_APPLICABLE);
226
+ // P true → reduce the consequent; P undecidable → UNDECIDED (never a decision).
227
+ if (args.length !== 2)
228
+ return "UNDECIDED";
229
+ const p = asBool(args[0], facts);
230
+ if (p === "U")
231
+ return "UNDECIDED";
232
+ if (p === false)
233
+ return "NOT_APPLICABLE";
234
+ return asVerdict(args[1], facts);
235
+ }
236
+ case "require": {
237
+ // An obligation's check: R holds → the obligation is met (PERMIT); R fails → the or_else fires
238
+ // (DENY); R undecidable → UNDECIDED.
239
+ if (args.length !== 1)
240
+ return "UNDECIDED";
241
+ const r = asBool(args[0], facts);
242
+ if (r === "U")
243
+ return "UNDECIDED";
244
+ return r ? "PERMIT" : "DENY";
245
+ }
246
+ case "allow":
247
+ return "PERMIT";
248
+ case "deny":
249
+ return "DENY";
250
+ default:
251
+ // A boolean/collection operator in verdict position, or an unimplemented one: the fact-only
252
+ // evaluator cannot reduce it to a decision.
253
+ return "UNDECIDED";
254
+ }
255
+ }
256
+ /**
257
+ * Evaluate a law's `check` against a supplied fact record and return exactly one Verdict.
258
+ *
259
+ * The interface is the fixed seam: an SMT/solver backend (SMT-LIB2 is itself s-expression
260
+ * many-sorted first-order logic) is reachable later behind this identical signature without
261
+ * changing any caller — solve-vs-evaluate stays inside the box, provided the in-house evaluator
262
+ * keeps "cannot decide" explicit (UNDECIDED) rather than defaulting.
263
+ *
264
+ * Total: it never throws. A declared input the fact record does not supply is DEAD_NAME (fail
265
+ * closed); an unparseable or irreducible predicate is UNDECIDED; neither is ever a PERMIT or DENY.
266
+ */
267
+ export function evaluate(check, facts) {
268
+ // Fail closed on a dead name FIRST: a name the law declares in `check.inputs` but the fact record
269
+ // does not supply. The exact analogue of resolveAgentGrants().unknown — a promised name with no
270
+ // backing. Checked before reduction so a missing input never masquerades as a decision.
271
+ const inputs = check.inputs;
272
+ for (const name of Object.keys(inputs)) {
273
+ if (!Object.prototype.hasOwnProperty.call(facts, name))
274
+ return "DEAD_NAME";
275
+ }
276
+ let ast;
277
+ try {
278
+ ast = parse(check.predicate);
279
+ }
280
+ catch {
281
+ // A predicate that does not parse cannot be reduced from facts. Runtime never throws and never
282
+ // decides; an unparseable predicate is REFUSED statically by checkInstitutionAdmissibility.
283
+ return "UNDECIDED";
284
+ }
285
+ return asVerdict(ast, facts);
286
+ }
287
+ function asRecord(v) {
288
+ return v !== null && typeof v === "object" ? v : {};
289
+ }
290
+ /** Walk a parsed predicate, partitioning symbols into operators (head position) and free variables
291
+ * (operand position, excluding the verdict atoms allow/deny and string literals). */
292
+ /** Operators that BIND their first argument: `(forall x collection body)` introduces `x` for the
293
+ * body's extent. Without this the binder reads as a free variable, and a well-formed law is
294
+ * refused for referencing an input it was never supposed to declare — which is how the first real
295
+ * run of the admissibility check reported two correct quartet laws as broken. Knowing `forall` as
296
+ * an operator is not the same as knowing it as a binder. */
297
+ const BINDING_OPERATORS = new Set(["forall", "exists"]);
298
+ function collectSymbols(node, vars, ops, isHead, bound = new Set()) {
299
+ if (node.kind === "list") {
300
+ if (node.items.length === 0)
301
+ return;
302
+ const head = node.items[0];
303
+ // A binding form: item[1] is the variable it introduces, in scope for everything after it. The
304
+ // binder itself is never a free variable and never an input the law must declare.
305
+ if (head?.kind === "sym" && BINDING_OPERATORS.has(head.name) && node.items[1]?.kind === "sym") {
306
+ const inner = new Set(bound);
307
+ inner.add(node.items[1].name);
308
+ ops.add(head.name);
309
+ // Skip items[0] (the operator, already recorded) and items[1] (the binder, not a reference).
310
+ for (let i = 2; i < node.items.length; i++)
311
+ collectSymbols(node.items[i], vars, ops, false, inner);
312
+ return;
313
+ }
314
+ for (let i = 0; i < node.items.length; i++)
315
+ collectSymbols(node.items[i], vars, ops, i === 0, bound);
316
+ return;
317
+ }
318
+ if (node.kind === "sym") {
319
+ if (isHead)
320
+ ops.add(node.name);
321
+ // A symbol bound by an enclosing quantifier is a reference to that binding, not a free
322
+ // variable. Everything else still is — the fix must narrow the false positive, not grant
323
+ // amnesty to genuinely undeclared names appearing inside a quantifier body.
324
+ else if (!VERDICT_ATOMS.has(node.name) && !bound.has(node.name))
325
+ vars.add(node.name);
326
+ }
327
+ // string literals are values, not names
328
+ }
329
+ function checkLaw(law, offenders) {
330
+ const l = asRecord(law);
331
+ const ref = typeof l.aim === "string" && l.aim.length > 0 ? l.aim : "(law)";
332
+ const push = (reason) => {
333
+ offenders.push({ kind: "law", ref, reason });
334
+ };
335
+ const check = asRecord(l.check);
336
+ const predicate = check.predicate;
337
+ const inputs = asRecord(check.inputs);
338
+ if (typeof predicate !== "string") {
339
+ push("law has no check.predicate to evaluate");
340
+ return;
341
+ }
342
+ let ast;
343
+ try {
344
+ ast = parse(predicate);
345
+ }
346
+ catch (e) {
347
+ push(`predicate does not parse: ${e instanceof Error ? e.message : String(e)}`);
348
+ return;
349
+ }
350
+ const vars = new Set();
351
+ const ops = new Set();
352
+ collectSymbols(ast, vars, ops, false);
353
+ const declared = new Set(Object.keys(inputs));
354
+ // Var-declaration closure, both directions: every free variable is declared, AND every declared
355
+ // input is referenced (an unused declaration is a typo-mask that overclaims the law's surface).
356
+ for (const v of vars) {
357
+ if (!declared.has(v))
358
+ push(`predicate references undeclared variable "${v}"`);
359
+ }
360
+ for (const d of declared) {
361
+ if (!vars.has(d))
362
+ push(`declared input "${d}" is never referenced by the predicate`);
363
+ }
364
+ // Every operator the predicate names must be implemented; an unknown operator must not pass.
365
+ for (const op of ops) {
366
+ if (!KNOWN_OPERATORS.has(op))
367
+ push(`predicate uses an unimplemented operator "${op}"`);
368
+ }
369
+ // or_else is the ADICO slot that separates a RULE from a norm; the schema's z.string() lets ''
370
+ // through, so admissibility is where an empty consequence-on-breach is caught.
371
+ if (typeof l.or_else !== "string" || l.or_else.trim() === "") {
372
+ push("or_else is empty — a rule needs a stated consequence on breach");
373
+ }
374
+ }
375
+ function checkChair(chair, offenders) {
376
+ const c = asRecord(chair);
377
+ const role = typeof c.role === "string" ? c.role : "(chair)";
378
+ const obligations = Array.isArray(c.obligations) ? c.obligations : [];
379
+ for (const raw of obligations) {
380
+ const ob = asRecord(raw);
381
+ const aim = typeof ob.aim === "string" ? ob.aim : "(obligation)";
382
+ // Verified OR explicitly marked declared-tier. There is no verifier surface in this genome, so
383
+ // an obligation states its tier: "enforced" claims a verifier backs it, "declared" states it is
384
+ // a norm with no runtime check. An UNMARKED obligation is refused — silence must not pass a norm
385
+ // off as a rule.
386
+ if (ob.tier !== "declared" && ob.tier !== "enforced") {
387
+ offenders.push({
388
+ kind: "obligation",
389
+ ref: `${role} :: ${aim}`,
390
+ reason: "obligation is neither verified nor explicitly marked declared-tier",
391
+ });
392
+ }
393
+ }
394
+ }
395
+ /**
396
+ * Refuse an institution document that claims more enforcement than it has. Per law: the predicate
397
+ * parses; every free variable is declared in `check.inputs` and every declared input is referenced;
398
+ * every operator is implemented; `or_else` is non-empty. Per chair obligation: it is verified OR
399
+ * explicitly marked declared-tier — an unmarked unverified obligation is refused, so silence cannot
400
+ * pass a norm off as a rule. Collects every offender and refuses once (collect-all / refuse-once,
401
+ * mirroring runtime.ts's PreflightDispatchError sweep).
402
+ *
403
+ * This is an explicitly-invoked pure function; it is deliberately NOT wired into loadGenome, so
404
+ * quartet.json (unmarked obligations, non-fact-decidable operators) still loads unchanged.
405
+ */
406
+ export function checkInstitutionAdmissibility(doc) {
407
+ const offenders = [];
408
+ const institution = asRecord(doc.institution);
409
+ const laws = Array.isArray(institution.laws) ? institution.laws : [];
410
+ for (const law of laws)
411
+ checkLaw(law, offenders);
412
+ const chairs = Array.isArray(doc.chairs) ? doc.chairs : [];
413
+ for (const chair of chairs)
414
+ checkChair(chair, offenders);
415
+ return { admitted: offenders.length === 0, offenders };
416
+ }
417
+ /**
418
+ * The STATIC half of evaluability, reused by the committed-work layer so acceptance and law share
419
+ * one grammar rather than minting a second: a LawCheck is evaluable when its predicate parses and
420
+ * every free variable it references is declared in `inputs`. This is exactly the undeclared-variable
421
+ * refusal checkLaw applies — a predicate naming a variable it never declares can never reduce to a
422
+ * decision, so an UNMARKED commitment carrying one must be refused (silence must not pass a stated
423
+ * intention off as a checkable commitment). Total: returns false on a predicate that does not parse.
424
+ */
425
+ export function lawCheckIsEvaluable(check) {
426
+ let ast;
427
+ try {
428
+ ast = parse(check.predicate);
429
+ }
430
+ catch {
431
+ return false;
432
+ }
433
+ const vars = new Set();
434
+ const ops = new Set();
435
+ collectSymbols(ast, vars, ops, false);
436
+ for (const v of vars) {
437
+ if (!Object.prototype.hasOwnProperty.call(check.inputs, v))
438
+ return false;
439
+ }
440
+ return true;
441
+ }
442
+ //# sourceMappingURL=institution_enforcement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"institution_enforcement.js","sourceRoot":"","sources":["../../src/institution_enforcement.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,kEAAkE;AAClE,EAAE;AACF,yFAAyF;AACzF,6FAA6F;AAC7F,4FAA4F;AAC5F,oFAAoF;AACpF,wFAAwF;AACxF,6FAA6F;AAC7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CAAC,EAAE,CAAC;IAC3D,KAAK,MAAM,KAAK,IAAI,MAAM;QAAE,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACzD,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC;AACzD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAe;IACjD,IAAI,GAAU,CAAC;IACf,IAAI,CAAC;QACH,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IACtC,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;IAC3E,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,63 @@
1
+ import type { LoadError } from "./loader.js";
2
+ import type { InstitutionOutput, OrganizationOutput, AgentRecordOutput, InstitutionalChairOutput, ChairAssignmentOutput, ForebearOutput, LineageEdgeOutput, NorthstarOutput, TourOutput, ResourceOutput } from "./genome_schema.js";
3
+ /** The multi-section institution document as it lives on disk (shape per institutions/quartet.json).
4
+ * Each present section is validated LOSS-FREE against its already-authored per-section schema in
5
+ * src/genome_schema.ts; an absent optional section is treated as empty, not as an error. This IS
6
+ * the `definition` a store row carries (see docs spec ITEM 4) — file and store backings share it so
7
+ * they cannot drift. */
8
+ export interface InstitutionDocumentSections {
9
+ institution: InstitutionOutput;
10
+ organizations?: readonly OrganizationOutput[];
11
+ agent_records?: readonly AgentRecordOutput[];
12
+ org_members?: readonly {
13
+ org_slug: string;
14
+ agent_slug: string;
15
+ }[];
16
+ chairs?: readonly InstitutionalChairOutput[];
17
+ assignments?: readonly ChairAssignmentOutput[];
18
+ forebears?: readonly ForebearOutput[];
19
+ lineage_edges?: readonly LineageEdgeOutput[];
20
+ northstars?: readonly NorthstarOutput[];
21
+ }
22
+ /** A validated, ADMITTED institution carried in the loaded genome, keyed by institution slug.
23
+ * Only documents that (a) parse, (b) validate section-by-section, and (c) pass
24
+ * checkInstitutionAdmissibility appear here — an inadmissible one fails closed into a load_error. */
25
+ export interface LoadedInstitution {
26
+ slug: string;
27
+ document: InstitutionDocumentSections;
28
+ }
29
+ /**
30
+ * SEAM (RED — body throws). Read every institutions/*.json under `root`, validate each present
31
+ * section against its per-section schema, invoke checkInstitutionAdmissibility on the schema-valid
32
+ * document, and return the admitted institutions keyed by slug PLUS one load_error of kind
33
+ * "institution" per file that is malformed, schema-invalid, inadmissible, or a duplicate slug.
34
+ *
35
+ * TOTAL by contract: the GREEN body must never throw for an institution reason — a bad document is
36
+ * a per-file load_error and drops out; the rest of the genome loads. Deliberately NOT wired into
37
+ * loadGenome yet: wiring it (after the agent/standard/org maps exist) is the GREEN change these red
38
+ * tests demand. Until then this throws, so the tree compiles and red is honest.
39
+ */
40
+ export declare function loadInstitutions(root: string): {
41
+ institutions: Map<string, LoadedInstitution>;
42
+ load_errors: LoadError[];
43
+ };
44
+ /** A tour document as it lives on disk: the tour plus the resources its draws name. */
45
+ export interface LoadedTour {
46
+ slug: string;
47
+ document: {
48
+ tour: TourOutput;
49
+ resources: ResourceOutput[];
50
+ };
51
+ }
52
+ /**
53
+ * Read every tours/*.json under `root`, validate the tour + resources against their schemas, resolve
54
+ * each tour against its institution from the ALREADY-LOADED institutions map (its chairs, so an
55
+ * accountable office / responsible chair is checked against real chairs), and invoke
56
+ * checkTourAdmissibility fail-closed. An admitted tour is carried keyed by slug; a malformed,
57
+ * schema-invalid, inadmissible, unresolved-institution, or duplicate-slug document drops out as one
58
+ * "tour" load_error. TOTAL — it never throws for a tour reason.
59
+ */
60
+ export declare function loadTours(root: string, institutions: ReadonlyMap<string, LoadedInstitution>): {
61
+ tours: Map<string, LoadedTour>;
62
+ load_errors: LoadError[];
63
+ };