@eir-labs/coltrane 0.10.0 → 0.12.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 (144) hide show
  1. package/agents/bandleader.json +54 -0
  2. package/agents/bill.json +4 -2
  3. package/agents/change-verifier.json +2 -1
  4. package/agents/code-implementer.json +7 -4
  5. package/agents/john.json +5 -3
  6. package/agents/lineage-scout-external.json +19 -6
  7. package/agents/lineage-scribe.json +20 -9
  8. package/agents/lineage-weaver.json +26 -11
  9. package/agents/miles.json +2 -1
  10. package/agents/players/bandleader.md +70 -0
  11. package/agents/pr-publisher.json +4 -2
  12. package/agents/red-spec-drafter.json +12 -6
  13. package/agents/room-prober.json +29 -0
  14. package/agents/source-walker.json +1 -1
  15. package/charts/room-probe-chart-v1.json +14 -0
  16. package/charts/worker-contract-docker-v2.json +135 -0
  17. package/charts/worker-contract-v3.json +206 -0
  18. package/dist/src/boundary_check.d.ts +18 -0
  19. package/dist/src/boundary_check.js +70 -0
  20. package/dist/src/boundary_check.js.map +1 -0
  21. package/dist/src/boundary_scan.d.ts +62 -0
  22. package/dist/src/boundary_scan.js +93 -0
  23. package/dist/src/boundary_scan.js.map +1 -0
  24. package/dist/src/chart.js +34 -1
  25. package/dist/src/chart.js.map +1 -1
  26. package/dist/src/claude_invoker.d.ts +2 -13
  27. package/dist/src/claude_invoker.js +242 -18
  28. package/dist/src/claude_invoker.js.map +1 -1
  29. package/dist/src/cli.d.ts +1 -1
  30. package/dist/src/cli.js +115 -27
  31. package/dist/src/cli.js.map +1 -1
  32. package/dist/src/drain_preflight.d.ts +33 -0
  33. package/dist/src/drain_preflight.js +97 -0
  34. package/dist/src/drain_preflight.js.map +1 -0
  35. package/dist/src/genome_schema.d.ts +390 -9
  36. package/dist/src/genome_schema.js +163 -8
  37. package/dist/src/genome_schema.js.map +1 -1
  38. package/dist/src/genome_store.js +9 -0
  39. package/dist/src/genome_store.js.map +1 -1
  40. package/dist/src/genome_writer.d.ts +1 -1
  41. package/dist/src/genome_writer.js +10 -2
  42. package/dist/src/genome_writer.js.map +1 -1
  43. package/dist/src/gig_conformance.d.ts +66 -0
  44. package/dist/src/gig_conformance.js +153 -0
  45. package/dist/src/gig_conformance.js.map +1 -0
  46. package/dist/src/gig_tracker.js +8 -0
  47. package/dist/src/gig_tracker.js.map +1 -1
  48. package/dist/src/grounding.d.ts +44 -0
  49. package/dist/src/grounding.js +127 -0
  50. package/dist/src/grounding.js.map +1 -0
  51. package/dist/src/index.d.ts +3 -0
  52. package/dist/src/index.js +9 -0
  53. package/dist/src/index.js.map +1 -1
  54. package/dist/src/institution_loader.d.ts +29 -5
  55. package/dist/src/institution_loader.js +67 -6
  56. package/dist/src/institution_loader.js.map +1 -1
  57. package/dist/src/lineage_adoption.d.ts +82 -0
  58. package/dist/src/lineage_adoption.js +82 -0
  59. package/dist/src/lineage_adoption.js.map +1 -0
  60. package/dist/src/lineage_persist.d.ts +34 -0
  61. package/dist/src/lineage_persist.js +60 -0
  62. package/dist/src/lineage_persist.js.map +1 -0
  63. package/dist/src/loader.d.ts +13 -0
  64. package/dist/src/loader.js +43 -2
  65. package/dist/src/loader.js.map +1 -1
  66. package/dist/src/local_queue.d.ts +105 -0
  67. package/dist/src/local_queue.js +380 -0
  68. package/dist/src/local_queue.js.map +1 -0
  69. package/dist/src/mcp.js +37 -4
  70. package/dist/src/mcp.js.map +1 -1
  71. package/dist/src/org_hire.d.ts +23 -0
  72. package/dist/src/org_hire.js +42 -0
  73. package/dist/src/org_hire.js.map +1 -0
  74. package/dist/src/outputs.d.ts +17 -0
  75. package/dist/src/outputs.js +86 -1
  76. package/dist/src/outputs.js.map +1 -1
  77. package/dist/src/player_to_claude_code.js +26 -2
  78. package/dist/src/player_to_claude_code.js.map +1 -1
  79. package/dist/src/registry.d.ts +3 -1
  80. package/dist/src/registry.js +43 -3
  81. package/dist/src/registry.js.map +1 -1
  82. package/dist/src/repo_index.d.ts +58 -0
  83. package/dist/src/repo_index.js +232 -0
  84. package/dist/src/repo_index.js.map +1 -0
  85. package/dist/src/residency.d.ts +149 -0
  86. package/dist/src/residency.js +283 -0
  87. package/dist/src/residency.js.map +1 -0
  88. package/dist/src/reuse.d.ts +44 -4
  89. package/dist/src/reuse.js +0 -0
  90. package/dist/src/reuse.js.map +1 -1
  91. package/dist/src/runtime.d.ts +82 -0
  92. package/dist/src/runtime.js +254 -25
  93. package/dist/src/runtime.js.map +1 -1
  94. package/dist/src/server.d.ts +37 -0
  95. package/dist/src/server.js +422 -11
  96. package/dist/src/server.js.map +1 -1
  97. package/dist/src/server_relay.d.ts +40 -2
  98. package/dist/src/server_relay.js +186 -19
  99. package/dist/src/server_relay.js.map +1 -1
  100. package/dist/src/tool_providers.d.ts +27 -0
  101. package/dist/src/tool_providers.js +48 -0
  102. package/dist/src/tool_providers.js.map +1 -1
  103. package/dist/src/venue_credential.d.ts +41 -0
  104. package/dist/src/venue_credential.js +57 -0
  105. package/dist/src/venue_credential.js.map +1 -0
  106. package/dist/src/venue_realize.d.ts +23 -0
  107. package/dist/src/venue_realize.js +43 -3
  108. package/dist/src/venue_realize.js.map +1 -1
  109. package/dist/src/venue_realizer.d.ts +224 -0
  110. package/dist/src/venue_realizer.js +889 -0
  111. package/dist/src/venue_realizer.js.map +1 -0
  112. package/dist/src/version.d.ts +1 -1
  113. package/dist/src/version.js +1 -1
  114. package/dist/src/worker.d.ts +57 -0
  115. package/dist/src/worker.js +155 -24
  116. package/dist/src/worker.js.map +1 -1
  117. package/dist/src/worker_env.d.ts +79 -0
  118. package/dist/src/worker_env.js +322 -0
  119. package/dist/src/worker_env.js.map +1 -0
  120. package/dist/src/workspace.d.ts +12 -1
  121. package/dist/src/workspace.js +10 -3
  122. package/dist/src/workspace.js.map +1 -1
  123. package/domain_types/change-context.json +59 -13
  124. package/domain_types/lineage-adoption-target.json +22 -0
  125. package/domain_types/lineage-map.json +7 -2
  126. package/domain_types/lineage-record.json +55 -5
  127. package/domain_types/prior-art-hit.json +16 -1
  128. package/domain_types/red-spec.json +5 -3
  129. package/domain_types/woodshed-record.json +149 -0
  130. package/evals/gist-present.json +7 -0
  131. package/institutions/coltrane.json +178 -6
  132. package/package.json +6 -3
  133. package/skills/non-vacuity-probe/fixtures/fixture-001.json +17 -0
  134. package/skills/non-vacuity-probe/meta.json +12 -0
  135. package/skills/non-vacuity-probe/skill.md +27 -0
  136. package/skills/non-vacuity-probe/skill.mjs +81 -0
  137. package/standards/lineage-adopt-v0.json +37 -0
  138. package/standards/room-probe-v1.json +28 -0
  139. package/standards/software-change-pr-v1.json +15 -15
  140. package/standards/software-change-red-first-v0.json +183 -0
  141. package/standards/spec-review-and-sequence-v0.json +112 -0
  142. package/standards/studio-session-v0.json +101 -0
  143. package/tours/coltrane.json +72 -0
  144. package/venues/engine-room-v1.json +32 -0
@@ -0,0 +1,58 @@
1
+ /** One import edge: `from` imports `symbol`, which is a real export of `to`. */
2
+ export interface ImporterEdge {
3
+ from: string;
4
+ to: string;
5
+ symbol: string;
6
+ }
7
+ /** One module-to-test link: `test` references `module`. */
8
+ export interface ModuleTest {
9
+ module: string;
10
+ test: string;
11
+ }
12
+ /** One entry point: `symbol` is an export of `module` that no other module imports. */
13
+ export interface EntryPoint {
14
+ module: string;
15
+ symbol: string;
16
+ }
17
+ /**
18
+ * The compiled index -- MECHANICAL structure only. There is deliberately no `claims` / `unknowns`
19
+ * / `frame` field: judgment is not the compiler's to produce (I12). The absence is a compile-time
20
+ * property of this type, not a runtime filter -- nothing can put a judgment field here.
21
+ */
22
+ export interface RepositoryIndex {
23
+ source_revision: string;
24
+ files_to_exports: Record<string, string[]>;
25
+ file_importers: ImporterEdge[];
26
+ module_tests: ModuleTest[];
27
+ entry_points: EntryPoint[];
28
+ conventions_observed: string[];
29
+ boundary: string[];
30
+ }
31
+ /** A file in the input set: its repo-relative path and its raw source text. */
32
+ export type RepoFile = {
33
+ path: string;
34
+ content: string;
35
+ };
36
+ /**
37
+ * The compiler refuses rather than emitting a partial index. Thrown when a relative import
38
+ * specifier resolves to no file in the input set -- a dangling edge is not representable, so the
39
+ * whole index is withheld (I18, fail-closed).
40
+ */
41
+ export declare class RepoIndexError extends Error {
42
+ constructor(message?: string);
43
+ }
44
+ /**
45
+ * Compile a repository index from source. Deterministic: the returned index is byte-identical
46
+ * under any permutation of `files`. Fails closed: a relative import that resolves to no file in
47
+ * the set throws RepoIndexError rather than yielding a partial, dangling index.
48
+ */
49
+ export declare function compileRepositoryIndex(files: RepoFile[], opts: {
50
+ source_revision: string;
51
+ }): RepositoryIndex;
52
+ /**
53
+ * Reconcile a compiled index against a model's claimed reading of the SAME mechanical fields. The
54
+ * compiler is authoritative: on any divergence the compiled value wins, so a model-hallucinated
55
+ * edge is dropped (I15). The model reading is offered for comparison only -- it never adds to the
56
+ * mechanical structure.
57
+ */
58
+ export declare function reconcileMechanical(compiled: RepositoryIndex, _modelReading: Pick<RepositoryIndex, "file_importers">): RepositoryIndex;
@@ -0,0 +1,232 @@
1
+ // The deterministic producer for a change-context's MECHANICAL fields.
2
+ //
3
+ // The reading seat (agent john, software-change-pr-v1) spends most of a 24 tool-call cap
4
+ // RE-DERIVING repository structure every run -- the import graph, the module-to-tests index, the
5
+ // exported symbols and their entry points. This module COMPILES those facts from source, so the
6
+ // mechanical half of a reading is a build artifact rather than a thing a model re-establishes by
7
+ // hand (and mis-establishes: three hand-rolled structural sweeps this week each needed correction,
8
+ // and a guessed invocation surface once survived into sealed tests).
9
+ //
10
+ // The prohibition that gives it its shape (#424 I12/I13): this compiler emits STRUCTURE ONLY. It
11
+ // never populates `claims`, `unknowns` or `frame` -- noticing is the reader's office, not the
12
+ // index's. The absence is enforced structurally: `RepositoryIndex` has no field for any of the
13
+ // three, so a compiled index carrying one would not type-check. A fast index that notices nothing
14
+ // is the POINT: it buys the reader's turns back for the judgment half a model is actually needed
15
+ // for.
16
+ //
17
+ // Everything here is pure and deterministic: the same file set in any order compiles to a
18
+ // byte-identical index (every field is canonicalised -- keys and arrays sorted -- before return).
19
+ // The compiler fails CLOSED: an import that resolves to no file in the input set refuses with a
20
+ // RepoIndexError rather than emitting a partial, dangling index.
21
+ /**
22
+ * The compiler refuses rather than emitting a partial index. Thrown when a relative import
23
+ * specifier resolves to no file in the input set -- a dangling edge is not representable, so the
24
+ * whole index is withheld (I18, fail-closed).
25
+ */
26
+ export class RepoIndexError extends Error {
27
+ constructor(message) {
28
+ super(message);
29
+ this.name = "RepoIndexError";
30
+ // Restore the prototype chain under ES5-target transpilation so `instanceof` holds.
31
+ Object.setPrototypeOf(this, RepoIndexError.prototype);
32
+ }
33
+ }
34
+ // -- source classification -----------------------------------------------------------------------
35
+ const TEST_FILE = /\.test\.[cm]?[jt]sx?$/;
36
+ const isTestFile = (path) => TEST_FILE.test(path);
37
+ // -- a small POSIX path resolver (the tree is described in POSIX paths, no fs access) ------------
38
+ /** Resolve a relative specifier against the importing file's directory, POSIX-style. */
39
+ function resolveRelative(fromPath, spec) {
40
+ const slash = fromPath.lastIndexOf("/");
41
+ const fromDir = slash >= 0 ? fromPath.slice(0, slash) : "";
42
+ const parts = (fromDir ? fromDir.split("/") : []).concat(spec.split("/"));
43
+ const stack = [];
44
+ for (const p of parts) {
45
+ if (p === "" || p === ".")
46
+ continue;
47
+ if (p === "..") {
48
+ stack.pop();
49
+ continue;
50
+ }
51
+ stack.push(p);
52
+ }
53
+ return stack.join("/");
54
+ }
55
+ /**
56
+ * Map a resolved `.js`-style specifier target to the real source file in the set (the ESM/bundler
57
+ * convention: source is `.ts`, the specifier names the emitted `.js`). Returns the matched path,
58
+ * or undefined when nothing in the set answers it.
59
+ */
60
+ function resolveModule(resolvedTarget, fileSet) {
61
+ const base = resolvedTarget.replace(/\.[cm]?jsx?$/, "");
62
+ const candidates = [
63
+ base + ".ts",
64
+ base + ".tsx",
65
+ base + ".mts",
66
+ base + ".cts",
67
+ resolvedTarget,
68
+ base + "/index.ts",
69
+ base + "/index.tsx",
70
+ ];
71
+ for (const c of candidates) {
72
+ if (fileSet.has(c))
73
+ return c;
74
+ }
75
+ return undefined;
76
+ }
77
+ /**
78
+ * Extract the named-import bindings and their module specifier from a source text. Only named
79
+ * imports carry the symbols an importer edge names; `import Default from` and `import * as ns`
80
+ * bring in no named export and are recorded with an empty symbol list (so resolution/fail-closed
81
+ * still runs on their specifier). Bare (non-relative) specifiers are left to the caller to skip.
82
+ */
83
+ function parseImports(content) {
84
+ const out = [];
85
+ // `import [type] [ ... ] from "spec"` -- the binding clause is optional (side-effect imports).
86
+ const re = /import\s+(?:type\s+)?([^;'"]*?\s+from\s+)?["']([^"']+)["']/g;
87
+ let m;
88
+ while ((m = re.exec(content)) !== null) {
89
+ const clause = m[1] ?? "";
90
+ const spec = m[2];
91
+ const braces = /\{([^}]*)\}/.exec(clause);
92
+ const symbols = [];
93
+ if (braces) {
94
+ for (const raw of braces[1].split(",")) {
95
+ const name = raw.trim().split(/\s+as\s+/)[0]?.trim();
96
+ // The edge names the target's EXPORTED symbol -- the left side of `orig as local`.
97
+ if (name && /^[A-Za-z_$][\w$]*$/.test(name))
98
+ symbols.push(name);
99
+ }
100
+ }
101
+ out.push({ spec, symbols });
102
+ }
103
+ return out;
104
+ }
105
+ /** Extract the exported symbol names declared in a source text. */
106
+ function parseExports(content) {
107
+ const names = new Set();
108
+ const push = (re) => {
109
+ let m;
110
+ const g = new RegExp(re.source, "g");
111
+ while ((m = g.exec(content)) !== null)
112
+ if (m[1])
113
+ names.add(m[1]);
114
+ };
115
+ // export [async] function NAME / export [abstract] class NAME / export const|let|var NAME /
116
+ // export type|interface|enum NAME
117
+ push(/export\s+(?:async\s+)?function\s*\*?\s*([A-Za-z_$][\w$]*)/);
118
+ push(/export\s+(?:abstract\s+)?class\s+([A-Za-z_$][\w$]*)/);
119
+ push(/export\s+(?:const|let|var)\s+([A-Za-z_$][\w$]*)/);
120
+ push(/export\s+(?:type|interface|enum)\s+([A-Za-z_$][\w$]*)/);
121
+ // export { a, b as c } -- the exported name is the right side of `as`, else the bare name.
122
+ let mm;
123
+ const named = /export\s*(?:type\s*)?\{([^}]*)\}(?!\s*from)/g;
124
+ while ((mm = named.exec(content)) !== null) {
125
+ for (const raw of mm[1].split(",")) {
126
+ const parts = raw.trim().split(/\s+as\s+/);
127
+ const name = (parts[1] ?? parts[0])?.trim();
128
+ if (name && /^[A-Za-z_$][\w$]*$/.test(name))
129
+ names.add(name);
130
+ }
131
+ }
132
+ return [...names];
133
+ }
134
+ const isRelative = (spec) => spec.startsWith("./") || spec.startsWith("../");
135
+ const edgeKey = (e) => `${e.from} ${e.to} ${e.symbol}`;
136
+ const mtKey = (m) => `${m.module} ${m.test}`;
137
+ const epKey = (e) => `${e.module} ${e.symbol}`;
138
+ /**
139
+ * Compile a repository index from source. Deterministic: the returned index is byte-identical
140
+ * under any permutation of `files`. Fails closed: a relative import that resolves to no file in
141
+ * the set throws RepoIndexError rather than yielding a partial, dangling index.
142
+ */
143
+ export function compileRepositoryIndex(files, opts) {
144
+ const fileSet = new Set(files.map((f) => f.path));
145
+ // Resolve a relative specifier or FAIL CLOSED -- every endpoint of every edge must be a real file.
146
+ const resolveOrThrow = (fromPath, spec) => {
147
+ const target = resolveModule(resolveRelative(fromPath, spec), fileSet);
148
+ if (target === undefined) {
149
+ throw new RepoIndexError(`unresolvable import in ${fromPath}: "${spec}" resolves to no file in the input set -- refusing a partial, dangling index`);
150
+ }
151
+ return target;
152
+ };
153
+ const filesToExports = {};
154
+ const edges = new Map();
155
+ const moduleTests = new Map();
156
+ const jsExtImport = { seen: false };
157
+ const colocatedTests = { seen: false };
158
+ for (const f of files) {
159
+ const imports = parseImports(f.content);
160
+ for (const imp of imports) {
161
+ if (!isRelative(imp.spec))
162
+ continue; // external/bare specifier -- not an in-tree edge
163
+ if (/\.[cm]?jsx?$/.test(imp.spec))
164
+ jsExtImport.seen = true;
165
+ const target = resolveOrThrow(f.path, imp.spec);
166
+ if (isTestFile(f.path)) {
167
+ // A test file's imports feed the module-to-tests index, never the importer graph.
168
+ if (!isTestFile(target)) {
169
+ const mt = { module: target, test: f.path };
170
+ moduleTests.set(mtKey(mt), mt);
171
+ colocatedTests.seen = true;
172
+ }
173
+ }
174
+ else {
175
+ // A source file's named imports are importer edges -- one per named symbol.
176
+ for (const symbol of imp.symbols) {
177
+ const e = { from: f.path, to: target, symbol };
178
+ edges.set(edgeKey(e), e);
179
+ }
180
+ }
181
+ }
182
+ if (!isTestFile(f.path)) {
183
+ filesToExports[f.path] = parseExports(f.content);
184
+ }
185
+ }
186
+ // entry_points = exported symbols no OTHER module imports (roots of symbol consumption). A
187
+ // symbol reached only from a test file still counts as an entry point -- tests are not consumers
188
+ // in the import graph.
189
+ const importedSymbols = new Set();
190
+ for (const e of edges.values())
191
+ importedSymbols.add(`${e.to} ${e.symbol}`);
192
+ const entryPoints = [];
193
+ for (const [module, exports] of Object.entries(filesToExports)) {
194
+ for (const symbol of exports) {
195
+ if (!importedSymbols.has(`${module} ${symbol}`))
196
+ entryPoints.push({ module, symbol });
197
+ }
198
+ }
199
+ const conventions = [];
200
+ if (jsExtImport.seen)
201
+ conventions.push("esm-js-extension-import-specifiers");
202
+ if (colocatedTests.seen)
203
+ conventions.push("tests-reference-source-by-relative-import");
204
+ // -- canonicalise every field: sorted keys, sorted arrays -- so JSON.stringify is order-stable --
205
+ const canonExports = {};
206
+ for (const path of Object.keys(filesToExports).sort()) {
207
+ canonExports[path] = [...filesToExports[path]].sort();
208
+ }
209
+ return {
210
+ source_revision: opts.source_revision,
211
+ files_to_exports: canonExports,
212
+ file_importers: [...edges.values()].sort((a, b) => edgeKey(a).localeCompare(edgeKey(b))),
213
+ module_tests: [...moduleTests.values()].sort((a, b) => mtKey(a).localeCompare(mtKey(b))),
214
+ entry_points: entryPoints.sort((a, b) => epKey(a).localeCompare(epKey(b))),
215
+ conventions_observed: conventions.sort(),
216
+ boundary: [...fileSet].sort(),
217
+ };
218
+ }
219
+ /**
220
+ * Reconcile a compiled index against a model's claimed reading of the SAME mechanical fields. The
221
+ * compiler is authoritative: on any divergence the compiled value wins, so a model-hallucinated
222
+ * edge is dropped (I15). The model reading is offered for comparison only -- it never adds to the
223
+ * mechanical structure.
224
+ */
225
+ export function reconcileMechanical(compiled, _modelReading) {
226
+ void _modelReading; // authoritative-compiler contract: the model's mechanical claims do not win
227
+ return {
228
+ ...compiled,
229
+ file_importers: [...compiled.file_importers],
230
+ };
231
+ }
232
+ //# sourceMappingURL=repo_index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repo_index.js","sourceRoot":"","sources":["../../src/repo_index.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,EAAE;AACF,yFAAyF;AACzF,iGAAiG;AACjG,gGAAgG;AAChG,iGAAiG;AACjG,mGAAmG;AACnG,qEAAqE;AACrE,EAAE;AACF,iGAAiG;AACjG,8FAA8F;AAC9F,+FAA+F;AAC/F,kGAAkG;AAClG,iGAAiG;AACjG,OAAO;AACP,EAAE;AACF,0FAA0F;AAC1F,kGAAkG;AAClG,gGAAgG;AAChG,iEAAiE;AAuCjE;;;;GAIG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,oFAAoF;QACpF,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;IACxD,CAAC;CACF;AAED,mGAAmG;AACnG,MAAM,SAAS,GAAG,uBAAuB,CAAC;AAC1C,MAAM,UAAU,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEnE,mGAAmG;AACnG,wFAAwF;AACxF,SAAS,eAAe,CAAC,QAAgB,EAAE,IAAY;IACrD,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CA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AC,CAAC,CAAC;QACxF,YAAY,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACxF,YAAY,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1E,oBAAoB,EAAE,WAAW,CAAC,IAAI,EAAE;QACxC,QAAQ,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,EAAE;KAC9B,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,QAAyB,EACzB,aAAsD;IAEtD,KAAK,aAAa,CAAC,CAAC,4EAA4E;IAChG,OAAO;QACL,GAAG,QAAQ;QACX,cAAc,EAAE,CAAC,GAAG,QAAQ,CAAC,cAAc,CAAC;KAC7C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,149 @@
1
+ export { workOnce as residencyGigPath } from "./worker.js";
2
+ export type ResidencyState = "seated" | "listening" | "playing" | "hibernated" | "drained" | "unseated";
3
+ export declare const RESIDENCY_STATES: readonly ResidencyState[];
4
+ export declare const LIVE_STATES: ReadonlySet<ResidencyState>;
5
+ export type ResidencyOpKind = "claim" | "listen" | "play" | "wake_seal" | "ack" | "heartbeat" | "hibernate" | "thaw" | "drain" | "unseat" | "reap";
6
+ export declare const RESIDENCY_OPS: readonly ResidencyOpKind[];
7
+ export type ResidencyActor = "holder" | "reaper" | "operator";
8
+ export interface LegalTransition {
9
+ from: ResidencyState;
10
+ op: ResidencyOpKind;
11
+ to: ResidencyState;
12
+ }
13
+ export declare const LEGAL_TRANSITIONS: readonly LegalTransition[];
14
+ export declare const RESIDENCY_ROW_FIELDS: readonly string[];
15
+ export declare const REFLEX_BUDGET_TICKS = 8;
16
+ export interface ResidencyRecord {
17
+ agent_slug: string;
18
+ org: string;
19
+ venue_slug: string;
20
+ channel_id: string;
21
+ soul_output_id: string | null;
22
+ status: ResidencyState;
23
+ session_id: string | null;
24
+ cursor: number;
25
+ host: string | null;
26
+ lease_until: number;
27
+ heartbeat_at: number;
28
+ fence: number;
29
+ last_sealed_sha: string | null;
30
+ private_memory?: unknown;
31
+ }
32
+ export interface ResidencyOp {
33
+ kind: ResidencyOpKind;
34
+ by?: ResidencyActor;
35
+ fence?: number;
36
+ now?: number;
37
+ host?: string;
38
+ session_id?: string;
39
+ message_index?: number;
40
+ sealed_output_sha?: string | null;
41
+ cortex_alive?: boolean;
42
+ agent_slug?: string;
43
+ org?: string;
44
+ channel_id?: string;
45
+ }
46
+ export type ResidencyRefusal = "illegal_transition" | "wrong_party" | "stale_fence" | "dead_cortex" | "immutable_identity" | "cursor_without_seal" | "double_activation";
47
+ export type ResidencyTransition = {
48
+ ok: true;
49
+ next: ResidencyRecord;
50
+ } | {
51
+ ok: false;
52
+ reason: ResidencyRefusal;
53
+ };
54
+ export interface InboundMessage {
55
+ id: string;
56
+ text: string;
57
+ at: number;
58
+ }
59
+ export interface SimClock {
60
+ now(): number;
61
+ tick(n?: number): void;
62
+ }
63
+ export interface ReflexDeps {
64
+ invoke: (...a: unknown[]) => unknown;
65
+ clock: SimClock;
66
+ }
67
+ export interface ReflexResult {
68
+ acked: true;
69
+ elapsed_ticks: number;
70
+ }
71
+ export interface ResidencySpec {
72
+ agent_slug: string;
73
+ org: string;
74
+ venue_slug: string;
75
+ channel_id: string;
76
+ }
77
+ export interface BootDeps {
78
+ resolveAgent: (slug: string) => unknown | null;
79
+ resolveVenue: (slug: string) => unknown | null;
80
+ cortexPresent: () => boolean;
81
+ seatRow: (rec: ResidencyRecord) => void;
82
+ }
83
+ export type BootRefusal = "no_such_agent" | "no_such_venue" | "no_cortex";
84
+ export type BootResult = {
85
+ ok: true;
86
+ rec: ResidencyRecord;
87
+ } | {
88
+ ok: false;
89
+ refusal: BootRefusal;
90
+ };
91
+ export interface VenueLike {
92
+ credential_surface: readonly string[];
93
+ }
94
+ export type CredentialAdmission = {
95
+ ok: true;
96
+ } | {
97
+ ok: false;
98
+ reason: "credential_breach";
99
+ };
100
+ /**
101
+ * Apply one residency op under its party constraint. TOTAL: for any (state, op) pair in the closed
102
+ * domain it never throws — a refusal is a decision, always a discriminated {ok:false,reason}. Every
103
+ * pair outside LEGAL_TRANSITIONS is refused AND leaves state unchanged (the caller keeps `rec`).
104
+ */
105
+ export declare function applyResidencyOp(rec: ResidencyRecord, op: ResidencyOp): ResidencyTransition;
106
+ /**
107
+ * Ack an inbound message in reflex: dumb by design. Invokes the model-invoker EXACTLY zero times
108
+ * (even when one is present) and completes within REFLEX_BUDGET_TICKS SIMULATED ticks on the
109
+ * injected clock — never a wall-clock read, so the budget holds identically on any machine.
110
+ */
111
+ export declare function reflexAck(_msg: InboundMessage, deps: ReflexDeps): ReflexResult;
112
+ /**
113
+ * The named reader for a dead-hibernated residency: a hibernated seat whose lease has lapsed is
114
+ * forced to `unseated`. It reaps the DEAD and not the living — a hibernated seat still inside its
115
+ * lease, or any non-hibernated record, is left untouched (a refusal, so "nothing reaped" is
116
+ * unambiguous). `hibernated` is a valid state, so without this reader a dead hibernated residency
117
+ * would read as healthy because nothing queries it.
118
+ */
119
+ export declare function reapResidency(rec: ResidencyRecord, now: number): ResidencyTransition;
120
+ /**
121
+ * A presence cannot read its OWN impressions as content: sealing an impression as evidence would let
122
+ * it witness itself. The self-read is scoped out — no impression content is ever returned.
123
+ */
124
+ export declare function readOwnImpressions(_rec: ResidencyRecord): {
125
+ content: null;
126
+ scoped_out: true;
127
+ } | {
128
+ content: unknown;
129
+ };
130
+ /**
131
+ * Admit a credential class only if the venue explicitly declares it in its credential_surface. The
132
+ * venue is the SOLE hands contract; a class it does not declare — including a channel token, which
133
+ * belongs to the distinct voice axis — is a breach.
134
+ */
135
+ export declare function admitVenueCredential(venue: VenueLike, credentialClass: string): CredentialAdmission;
136
+ /**
137
+ * Seat a residency, fail-closed. Three preflight checks run IN ORDER before seatRow ever runs, so a
138
+ * refused boot writes no row: an unresolvable agent → no_such_agent, an unresolvable venue →
139
+ * no_such_venue, an absent cortex → no_cortex. Cortex liveness is not a one-shot boot assertion — it
140
+ * also surfaces on every subsequent heartbeat (applyResidencyOp's dead_cortex path).
141
+ */
142
+ export declare function bootResidency(spec: ResidencySpec, deps: BootDeps): BootResult;
143
+ /**
144
+ * The `reside` verb REUSES work's gig path — it does not fork the drain's five-variable env contract.
145
+ * Missing COLTRANE_STORE_URL / COLTRANE_STORE_ANON is a usage refusal (exit 2), the same door work
146
+ * uses (src/cli.ts:241-248). The gig itself is workOnce, re-exported above as residencyGigPath; the
147
+ * store/channel wiring is a deployment seam the laws inject rather than assert here.
148
+ */
149
+ export declare function runReside(_argv: readonly string[], io: unknown): Promise<number>;