@eir-labs/coltrane 0.4.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 (279) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +85 -0
  3. package/agents/anticipation-mapper.json +34 -0
  4. package/agents/claim-amender.json +34 -0
  5. package/agents/claim-architect.json +34 -0
  6. package/agents/claim-rewriter.json +32 -0
  7. package/agents/delivery-finalizer.json +40 -0
  8. package/agents/diamond-cutter.json +33 -0
  9. package/agents/disclosure-analyst.json +26 -0
  10. package/agents/domain-explorer.json +37 -0
  11. package/agents/e2e-runner.json +34 -0
  12. package/agents/e2e-suite-judge.json +26 -0
  13. package/agents/event-clusterer.json +29 -0
  14. package/agents/novelty-searcher.json +40 -0
  15. package/agents/patent-browser-scout.json +49 -0
  16. package/agents/patent-examiner.json +36 -0
  17. package/agents/phase_agents/claim-rewriter.md +44 -0
  18. package/agents/phase_agents/delivery-finalizer.md +30 -0
  19. package/agents/phase_agents/diamond-cutter.md +47 -0
  20. package/agents/phase_agents/domain-explorer.md +27 -0
  21. package/agents/phase_agents/novelty-searcher.md +50 -0
  22. package/agents/phase_agents/problem-definer.md +32 -0
  23. package/agents/phase_agents/solution-developer.md +26 -0
  24. package/agents/phase_agents/verdict-judger.md +70 -0
  25. package/agents/players/audience-modeler.md +40 -0
  26. package/agents/players/chain-audit-keeper.md +41 -0
  27. package/agents/players/illumination-reviewer.md +42 -0
  28. package/agents/players/methodology-cadence-keeper.md +42 -0
  29. package/agents/players/substrate-edge-keeper.md +45 -0
  30. package/agents/prior-art-scout.json +45 -0
  31. package/agents/problem-definer.json +35 -0
  32. package/agents/seeds/steve_seed_a.json +12 -0
  33. package/agents/seeds/steve_seed_b.json +12 -0
  34. package/agents/seeds/steve_seed_c.json +12 -0
  35. package/agents/seeds/steve_seed_d.json +12 -0
  36. package/agents/sensor.json +22 -0
  37. package/agents/solution-developer.json +35 -0
  38. package/agents/source-walker.json +38 -0
  39. package/agents/spec-drafter.json +31 -0
  40. package/agents/sub_thread_soft_judge.json +26 -0
  41. package/agents/sub_thread_trace_sensor.json +22 -0
  42. package/agents/summarizer.json +25 -0
  43. package/agents/synthesis-writer.json +29 -0
  44. package/agents/triage-judge.json +39 -0
  45. package/agents/user_flow_judge.json +26 -0
  46. package/agents/user_flow_sensor.json +22 -0
  47. package/agents/verdict-judger.json +39 -0
  48. package/core_types/artifact.json +17 -0
  49. package/core_types/interpretation.json +16 -0
  50. package/core_types/judgment.json +16 -0
  51. package/core_types/plan.json +16 -0
  52. package/core_types/signal.json +16 -0
  53. package/core_types/verdict.json +27 -0
  54. package/dist/src/access_grant.d.ts +46 -0
  55. package/dist/src/access_grant.js +76 -0
  56. package/dist/src/access_grant.js.map +1 -0
  57. package/dist/src/acoustics.d.ts +9 -0
  58. package/dist/src/acoustics.js +65 -0
  59. package/dist/src/acoustics.js.map +1 -0
  60. package/dist/src/agent_profile.d.ts +36 -0
  61. package/dist/src/agent_profile.js +57 -0
  62. package/dist/src/agent_profile.js.map +1 -0
  63. package/dist/src/bifrost_invoker.d.ts +33 -0
  64. package/dist/src/bifrost_invoker.js +85 -0
  65. package/dist/src/bifrost_invoker.js.map +1 -0
  66. package/dist/src/canonical_core_types.d.ts +2 -0
  67. package/dist/src/canonical_core_types.js +111 -0
  68. package/dist/src/canonical_core_types.js.map +1 -0
  69. package/dist/src/canonical_form.d.ts +55 -0
  70. package/dist/src/canonical_form.js +93 -0
  71. package/dist/src/canonical_form.js.map +1 -0
  72. package/dist/src/charter.d.ts +37 -0
  73. package/dist/src/charter.js +86 -0
  74. package/dist/src/charter.js.map +1 -0
  75. package/dist/src/circle_of_fifths.d.ts +27 -0
  76. package/dist/src/circle_of_fifths.js +78 -0
  77. package/dist/src/circle_of_fifths.js.map +1 -0
  78. package/dist/src/claude_invoker.d.ts +102 -0
  79. package/dist/src/claude_invoker.js +760 -0
  80. package/dist/src/claude_invoker.js.map +1 -0
  81. package/dist/src/coltrane_profile.d.ts +87 -0
  82. package/dist/src/coltrane_profile.js +132 -0
  83. package/dist/src/coltrane_profile.js.map +1 -0
  84. package/dist/src/composition.d.ts +57 -0
  85. package/dist/src/composition.js +447 -0
  86. package/dist/src/composition.js.map +1 -0
  87. package/dist/src/core_types.d.ts +6 -0
  88. package/dist/src/core_types.js +25 -0
  89. package/dist/src/core_types.js.map +1 -0
  90. package/dist/src/document_factory.d.ts +89 -0
  91. package/dist/src/document_factory.js +176 -0
  92. package/dist/src/document_factory.js.map +1 -0
  93. package/dist/src/genome_schema.d.ts +512 -0
  94. package/dist/src/genome_schema.js +168 -0
  95. package/dist/src/genome_schema.js.map +1 -0
  96. package/dist/src/genome_writer.d.ts +67 -0
  97. package/dist/src/genome_writer.js +179 -0
  98. package/dist/src/genome_writer.js.map +1 -0
  99. package/dist/src/gig_song.d.ts +29 -0
  100. package/dist/src/gig_song.js +56 -0
  101. package/dist/src/gig_song.js.map +1 -0
  102. package/dist/src/gig_tracker.d.ts +54 -0
  103. package/dist/src/gig_tracker.js +109 -0
  104. package/dist/src/gig_tracker.js.map +1 -0
  105. package/dist/src/harmonic_validation.d.ts +11 -0
  106. package/dist/src/harmonic_validation.js +35 -0
  107. package/dist/src/harmonic_validation.js.map +1 -0
  108. package/dist/src/hooks.d.ts +27 -0
  109. package/dist/src/hooks.js +2 -0
  110. package/dist/src/hooks.js.map +1 -0
  111. package/dist/src/index.d.ts +36 -0
  112. package/dist/src/index.js +37 -0
  113. package/dist/src/index.js.map +1 -0
  114. package/dist/src/jsong.d.ts +47 -0
  115. package/dist/src/jsong.js +130 -0
  116. package/dist/src/jsong.js.map +1 -0
  117. package/dist/src/judges/user_flow_judge.d.ts +89 -0
  118. package/dist/src/judges/user_flow_judge.js +200 -0
  119. package/dist/src/judges/user_flow_judge.js.map +1 -0
  120. package/dist/src/learner.d.ts +37 -0
  121. package/dist/src/learner.js +30 -0
  122. package/dist/src/learner.js.map +1 -0
  123. package/dist/src/ledger.d.ts +225 -0
  124. package/dist/src/ledger.js +306 -0
  125. package/dist/src/ledger.js.map +1 -0
  126. package/dist/src/loader.d.ts +87 -0
  127. package/dist/src/loader.js +504 -0
  128. package/dist/src/loader.js.map +1 -0
  129. package/dist/src/mcp.d.ts +23 -0
  130. package/dist/src/mcp.js +125 -0
  131. package/dist/src/mcp.js.map +1 -0
  132. package/dist/src/modulation_path.d.ts +42 -0
  133. package/dist/src/modulation_path.js +60 -0
  134. package/dist/src/modulation_path.js.map +1 -0
  135. package/dist/src/output_validation.d.ts +19 -0
  136. package/dist/src/output_validation.js +51 -0
  137. package/dist/src/output_validation.js.map +1 -0
  138. package/dist/src/outputs.d.ts +125 -0
  139. package/dist/src/outputs.js +452 -0
  140. package/dist/src/outputs.js.map +1 -0
  141. package/dist/src/overtones.d.ts +42 -0
  142. package/dist/src/overtones.js +98 -0
  143. package/dist/src/overtones.js.map +1 -0
  144. package/dist/src/player_to_claude_code.d.ts +17 -0
  145. package/dist/src/player_to_claude_code.js +141 -0
  146. package/dist/src/player_to_claude_code.js.map +1 -0
  147. package/dist/src/playwright_cage.d.ts +28 -0
  148. package/dist/src/playwright_cage.js +47 -0
  149. package/dist/src/playwright_cage.js.map +1 -0
  150. package/dist/src/polyphony.d.ts +46 -0
  151. package/dist/src/polyphony.js +91 -0
  152. package/dist/src/polyphony.js.map +1 -0
  153. package/dist/src/portfolio.d.ts +52 -0
  154. package/dist/src/portfolio.js +186 -0
  155. package/dist/src/portfolio.js.map +1 -0
  156. package/dist/src/pricing.d.ts +23 -0
  157. package/dist/src/pricing.js +16 -0
  158. package/dist/src/pricing.js.map +1 -0
  159. package/dist/src/registry.d.ts +46 -0
  160. package/dist/src/registry.js +199 -0
  161. package/dist/src/registry.js.map +1 -0
  162. package/dist/src/runtime.d.ts +304 -0
  163. package/dist/src/runtime.js +1099 -0
  164. package/dist/src/runtime.js.map +1 -0
  165. package/dist/src/server.d.ts +88 -0
  166. package/dist/src/server.js +1692 -0
  167. package/dist/src/server.js.map +1 -0
  168. package/dist/src/server_entry.d.ts +2 -0
  169. package/dist/src/server_entry.js +40 -0
  170. package/dist/src/server_entry.js.map +1 -0
  171. package/dist/src/server_relay.d.ts +82 -0
  172. package/dist/src/server_relay.js +341 -0
  173. package/dist/src/server_relay.js.map +1 -0
  174. package/dist/src/simulate.d.ts +60 -0
  175. package/dist/src/simulate.js +72 -0
  176. package/dist/src/simulate.js.map +1 -0
  177. package/dist/src/skill_runner.mjs +34 -0
  178. package/dist/src/skill_subprocess.d.ts +65 -0
  179. package/dist/src/skill_subprocess.js +132 -0
  180. package/dist/src/skill_subprocess.js.map +1 -0
  181. package/dist/src/skills.d.ts +85 -0
  182. package/dist/src/skills.js +258 -0
  183. package/dist/src/skills.js.map +1 -0
  184. package/dist/src/subthread_recorder.d.ts +68 -0
  185. package/dist/src/subthread_recorder.js +166 -0
  186. package/dist/src/subthread_recorder.js.map +1 -0
  187. package/dist/src/tensor_read.d.ts +38 -0
  188. package/dist/src/tensor_read.js +60 -0
  189. package/dist/src/tensor_read.js.map +1 -0
  190. package/dist/src/test_honest_broker.d.ts +34 -0
  191. package/dist/src/test_honest_broker.js +155 -0
  192. package/dist/src/test_honest_broker.js.map +1 -0
  193. package/dist/src/test_topology.d.ts +22 -0
  194. package/dist/src/test_topology.js +137 -0
  195. package/dist/src/test_topology.js.map +1 -0
  196. package/dist/src/tones.d.ts +20 -0
  197. package/dist/src/tones.js +81 -0
  198. package/dist/src/tones.js.map +1 -0
  199. package/dist/src/tool_providers.d.ts +45 -0
  200. package/dist/src/tool_providers.js +104 -0
  201. package/dist/src/tool_providers.js.map +1 -0
  202. package/dist/src/type_versioning.d.ts +23 -0
  203. package/dist/src/type_versioning.js +31 -0
  204. package/dist/src/type_versioning.js.map +1 -0
  205. package/dist/src/version.d.ts +28 -0
  206. package/dist/src/version.js +86 -0
  207. package/dist/src/version.js.map +1 -0
  208. package/domain_types/claim-draft.json +34 -0
  209. package/domain_types/coverage-report.json +31 -0
  210. package/domain_types/draft-agent-profile.json +31 -0
  211. package/domain_types/draft-domain-type.json +28 -0
  212. package/domain_types/draft-standard.json +46 -0
  213. package/domain_types/e2e-observation.json +32 -0
  214. package/domain_types/e2e-report.json +30 -0
  215. package/domain_types/e2e-target.json +26 -0
  216. package/domain_types/e2e-verdict.json +26 -0
  217. package/domain_types/examine-round-record.json +40 -0
  218. package/domain_types/examiner-rejection.json +28 -0
  219. package/domain_types/failure-modes.json +31 -0
  220. package/domain_types/invention-analysis.json +34 -0
  221. package/domain_types/invention-spec.json +34 -0
  222. package/domain_types/novelty-analysis.json +28 -0
  223. package/domain_types/novelty-verdict.json +35 -0
  224. package/domain_types/parsed-conversation-trace.json +38 -0
  225. package/domain_types/pattern-extraction.json +62 -0
  226. package/domain_types/prior-art-hit.json +50 -0
  227. package/domain_types/project-charter.json +71 -0
  228. package/domain_types/provisional-draft.json +34 -0
  229. package/domain_types/raw-note.json +19 -0
  230. package/domain_types/repo-survey.json +28 -0
  231. package/domain_types/seeding-verdict.json +70 -0
  232. package/domain_types/soft-verdict.json +55 -0
  233. package/domain_types/summary.json +19 -0
  234. package/domain_types/triage-verdict.json +59 -0
  235. package/domain_types/user-flow-transcript.json +43 -0
  236. package/domain_types/user-flow-verdict.json +60 -0
  237. package/domain_types/verdict-record.json +39 -0
  238. package/package.json +82 -0
  239. package/skills/citation-verify/fixtures/basic.json +14 -0
  240. package/skills/citation-verify/meta.json +10 -0
  241. package/skills/citation-verify/skill.mjs +26 -0
  242. package/skills/claim-element-decompose/fixtures/basic.json +11 -0
  243. package/skills/claim-element-decompose/meta.json +10 -0
  244. package/skills/claim-element-decompose/skill.mjs +14 -0
  245. package/skills/diamond-cutting-discipline/fixtures/basic.json +13 -0
  246. package/skills/diamond-cutting-discipline/meta.json +19 -0
  247. package/skills/diamond-cutting-discipline/skill.md +46 -0
  248. package/skills/element-mapping-matrix/fixtures/basic.json +13 -0
  249. package/skills/element-mapping-matrix/meta.json +10 -0
  250. package/skills/element-mapping-matrix/skill.mjs +20 -0
  251. package/skills/number-adder/fixtures/basic.json +9 -0
  252. package/skills/number-adder/meta.json +10 -0
  253. package/skills/number-adder/skill.mjs +12 -0
  254. package/skills/patent-fetch/fixtures/parse.json +18 -0
  255. package/skills/patent-fetch/meta.json +11 -0
  256. package/skills/patent-fetch/skill.mjs +34 -0
  257. package/skills/query-expand/fixtures/basic.json +14 -0
  258. package/skills/query-expand/meta.json +10 -0
  259. package/skills/query-expand/skill.mjs +29 -0
  260. package/skills/run-vitest-band/fixtures/basic.json +9 -0
  261. package/skills/run-vitest-band/meta.json +18 -0
  262. package/skills/run-vitest-band/skill.mjs +22 -0
  263. package/skills/statutory-checklist/fixtures/basic.json +16 -0
  264. package/skills/statutory-checklist/meta.json +10 -0
  265. package/skills/statutory-checklist/skill.mjs +25 -0
  266. package/skills/summarize-tight/fixtures/basic.json +13 -0
  267. package/skills/summarize-tight/meta.json +20 -0
  268. package/skills/summarize-tight/skill.md +1 -0
  269. package/skills/verdict-gate/fixtures/basic.json +9 -0
  270. package/skills/verdict-gate/meta.json +10 -0
  271. package/skills/verdict-gate/skill.mjs +82 -0
  272. package/standards/e2e-suite-v0.json +44 -0
  273. package/standards/patent-triage-v0.json +98 -0
  274. package/standards/patent-triage-v1.json +84 -0
  275. package/standards/seed-from-local-repos-v0.json +115 -0
  276. package/standards/sub_thread_invocation.json +50 -0
  277. package/standards/summarize.json +40 -0
  278. package/standards/synthesis-walk-v0.json +108 -0
  279. package/standards/user_flow_correctness.json +57 -0
@@ -0,0 +1,447 @@
1
+ import { PRIMITIVE_OUTPUT_TYPE } from "./core_types.js";
2
+ import { AgentSchema } from "./genome_schema.js";
3
+ export class CompositionError extends Error {
4
+ }
5
+ // A definition that is structurally parseable but INCOMPLETE against the current schema —
6
+ // e.g. an agent missing its now-required behavioral representation. Distinct from
7
+ // CompositionError (a malformed/illegal definition): an incomplete genome must be UPGRADED
8
+ // (fill in the missing features), so the loader HARD-fails on this rather than soft-skipping
9
+ // the file. Underdeveloped is not the same as broken.
10
+ export class GenomeIncompleteError extends Error {
11
+ }
12
+ const ROOT_PRIMITIVES = new Set(["SENSE"]);
13
+ const NEEDS_UPSTREAM_REASONING = new Set(["CREATE"]);
14
+ const NEEDS_TARGET = new Set(["VERIFY"]);
15
+ const REASONING = new Set(["INTERPRET", "PLAN", "SENSE"]);
16
+ export function defineAgent(def) {
17
+ const prims = def.primitives;
18
+ // A string passes `.length === 0`, so a wrong-type `primitives` (e.g. "SENSE")
19
+ // would otherwise load a broken agent silently. Reject non-arrays by field name.
20
+ if (!Array.isArray(prims)) {
21
+ throw new CompositionError(`agent ${def.slug}: "primitives" must be an array, got ${typeof prims}`);
22
+ }
23
+ if (prims.length === 0) {
24
+ throw new CompositionError(`agent ${def.slug} has no primitives`);
25
+ }
26
+ // Per-agent sanity: when multiple primitives are bundled in a single agent
27
+ // (e.g. [PLAN, CREATE]), an inner CREATE position needs an inner PLAN or
28
+ // INTERPRET upstream of it. Standalone CREATE/[CREATE] is admitted at this
29
+ // layer; the cross-phase §3 gate enforces "upstream reasoning" across phases
30
+ // in composeStandard. This split lets a CREATE-only agent compose into a
31
+ // standard where the upstream phase supplies the reasoning.
32
+ for (let i = 1; i < prims.length; i++) {
33
+ const p = prims[i];
34
+ if (NEEDS_UPSTREAM_REASONING.has(p)) {
35
+ const upstream = prims.slice(0, i);
36
+ const hasReasoning = upstream.some((u) => u === "INTERPRET" || u === "PLAN");
37
+ if (!hasReasoning) {
38
+ throw new CompositionError(`agent ${def.slug}: CREATE at position ${i} has no upstream INTERPRET or PLAN`);
39
+ }
40
+ }
41
+ if (NEEDS_TARGET.has(p)) {
42
+ const upstream = prims.slice(0, i);
43
+ if (upstream.length === 0) {
44
+ throw new CompositionError(`agent ${def.slug}: VERIFY has no upstream target`);
45
+ }
46
+ }
47
+ }
48
+ // Behavioral representation is mandatory — checked AFTER the structural (primitive)
49
+ // validation so a malformed agent reports its structural defect first. Missing behavioral
50
+ // representation is INCOMPLETE (a schema-migration gap, distinct from malformed): like any
51
+ // invalid agent it HARD-fails the load — a genome must load cleanly to run, never hollow.
52
+ if (typeof def.identity !== "string" || def.identity.trim() === "") {
53
+ throw new GenomeIncompleteError(`agent ${def.slug}: identity is required (who the agent is) — fill it in to upgrade the genome`);
54
+ }
55
+ if (typeof def.method !== "string" || def.method.trim() === "") {
56
+ throw new GenomeIncompleteError(`agent ${def.slug}: method is required (how the agent works) — fill it in to upgrade the genome`);
57
+ }
58
+ // Widen past the compile-time 2-tuple: the JSON-authored path reaches here as `any`, so the
59
+ // disposition's arity is only really known at runtime — these guards protect that path.
60
+ const bp = def.behavioral_primitives;
61
+ if (!Array.isArray(bp) || bp.length === 0) {
62
+ throw new GenomeIncompleteError(`agent ${def.slug}: behavioral_primitives (disposition) is required — fill it in to upgrade the genome`);
63
+ }
64
+ // The disposition is a PAIRING: exactly two roles in tension. One role is a single voice;
65
+ // three+ dilute the tension. A genome carrying a non-pair is malformed against the contract,
66
+ // so it hard-fails the load rather than rendering a confused Disposition layer.
67
+ if (bp.length !== 2) {
68
+ throw new GenomeIncompleteError(`agent ${def.slug}: behavioral_primitives must be exactly two roles in tension, got ${bp.length} — a disposition is a pairing`);
69
+ }
70
+ if (!Array.isArray(def.constraints)) {
71
+ throw new GenomeIncompleteError(`agent ${def.slug}: constraints is required (use [] for none) — fill it in to upgrade the genome`);
72
+ }
73
+ // LOSS-FREE projection via the single-source schema (genome_schema.ts AgentSchema): parse
74
+ // PRESERVES every field the schema declares (browser_grant, the cage grants, …) and applies
75
+ // defaults — no hand-enumerated literal to silently drop a sealed field (the bug this whole change
76
+ // closes). The structural + behavioral checks above already threw the precise error types; if the
77
+ // schema rejects a shape those missed, surface it as a load-hard GenomeIncompleteError.
78
+ let parsed;
79
+ try {
80
+ parsed = AgentSchema.parse(def);
81
+ }
82
+ catch (e) {
83
+ throw new GenomeIncompleteError(`agent ${def.slug}: ${e instanceof Error ? e.message : String(e)}`);
84
+ }
85
+ // output_types derives from the last primitive's output type when not declared (stays here, not
86
+ // in the schema, because the default depends on another field). The cage arrays fill to [] to
87
+ // match the prior runtime shape (deny-by-default = an empty grant, never undefined).
88
+ const output_types = parsed.output_types.length > 0
89
+ ? parsed.output_types
90
+ : prims.map((p) => PRIMITIVE_OUTPUT_TYPE[p]).slice(-1);
91
+ return {
92
+ ...parsed,
93
+ output_types,
94
+ allowed_tools: parsed.allowed_tools ?? [],
95
+ disallowed_tools: parsed.disallowed_tools ?? [],
96
+ skill_slugs: parsed.skill_slugs ?? [],
97
+ };
98
+ }
99
+ export function composeStandard(def) {
100
+ const agentBySlug = new Map(def.agents.map((a) => [a.slug, a]));
101
+ // Reject legacy {name, agent} phase shape at the boundary. Chairs is the only
102
+ // supported shape; the legacy field never reaches the runtime.
103
+ for (const p of def.phases) {
104
+ const legacy = p;
105
+ if (legacy.agent !== undefined) {
106
+ throw new CompositionError(`standard ${def.slug}: phase ${legacy.name} uses legacy phase.agent — not supported; declare chairs[] instead`);
107
+ }
108
+ if (legacy.chairs === undefined) {
109
+ throw new CompositionError(`standard ${def.slug}: phase ${legacy.name} missing chairs[] (chairs required on every phase)`);
110
+ }
111
+ }
112
+ // #187 — optional chair array fields default to [] (the loader already tolerates omitted
113
+ // fields; composeStandard must not be stricter than the loader it feeds). A chair that omits
114
+ // required_skills / depends_on / input_contract / output_contract is treated as empty, not a
115
+ // raw "ch.<field> is not iterable" TypeError.
116
+ const phases = def.phases.map((p) => ({
117
+ name: p.name,
118
+ chairs: p.chairs.map((ch) => ({
119
+ ...ch,
120
+ role: ch.role ?? "",
121
+ agent_slug: ch.agent_slug ?? "",
122
+ depends_on: ch.depends_on ?? [],
123
+ input_contract: ch.input_contract ?? [],
124
+ output_contract: ch.output_contract ?? [],
125
+ required_skills: ch.required_skills ?? [],
126
+ })),
127
+ }));
128
+ // ── Chair-level validation ─────────────────────────────────────────────────
129
+ // (a) every phase has at least one chair
130
+ // (b) role uniqueness — within phase + across phases of this standard
131
+ // (c) every chair's agent_slug resolves to an agent in this standard
132
+ // (d) every chair's required_skills are declared on its bound agent
133
+ // (e) every chair's output_contract is non-empty
134
+ const seenRoles = new Map(); // role → phase name
135
+ for (const ph of phases) {
136
+ if (ph.chairs.length === 0) {
137
+ throw new CompositionError(`standard ${def.slug}: phase ${ph.name} has empty chairs array (every phase needs ≥1 chair)`);
138
+ }
139
+ const phaseRoles = new Set();
140
+ for (const ch of ph.chairs) {
141
+ if (phaseRoles.has(ch.role)) {
142
+ throw new CompositionError(`standard ${def.slug}: duplicate role "${ch.role}" within phase ${ph.name}`);
143
+ }
144
+ phaseRoles.add(ch.role);
145
+ if (seenRoles.has(ch.role)) {
146
+ throw new CompositionError(`standard ${def.slug}: duplicate role "${ch.role}" across phases (also in ${seenRoles.get(ch.role)})`);
147
+ }
148
+ seenRoles.set(ch.role, ph.name);
149
+ // A skill-backed chair (skill_slug set, no agent_slug) runs the skill's deterministic
150
+ // code half instead of an agent — skip the agent/required-skills checks for it. The
151
+ // type-flow (input/output_contract) below still applies.
152
+ const isSkillChair = !!ch.skill_slug && (ch.agent_slug ?? "") === "";
153
+ if (!isSkillChair) {
154
+ const ag = agentBySlug.get(ch.agent_slug);
155
+ if (!ag) {
156
+ throw new CompositionError(`standard ${def.slug}: chair "${ch.role}" references unknown agent "${ch.agent_slug}" (not in standard's agents list)`);
157
+ }
158
+ const declared = new Set(ag.skill_slugs ?? []);
159
+ for (const sk of ch.required_skills) {
160
+ if (!declared.has(sk)) {
161
+ throw new CompositionError(`standard ${def.slug}: chair "${ch.role}" requires skill "${sk}" which agent "${ag.slug}" does not declare`);
162
+ }
163
+ }
164
+ }
165
+ if (ch.output_contract.length === 0) {
166
+ throw new CompositionError(`standard ${def.slug}: chair "${ch.role}" has empty output_contract (every chair must declare ≥1 output type)`);
167
+ }
168
+ // #243 — an optional_outputs entry naming nothing in the contract silently WIDENS the
169
+ // floor it was meant to narrow: the typo'd name excuses nothing, and the type the author
170
+ // meant to mark optional stays required while they believe otherwise. That is the exact
171
+ // class of bug the floor exists to close, so it is caught where the genome is authored
172
+ // rather than mid-run.
173
+ for (const opt of ch.optional_outputs ?? []) {
174
+ if (!ch.output_contract.includes(opt)) {
175
+ throw new CompositionError(`standard ${def.slug}: chair "${ch.role}" marks "${opt}" optional but does not promise it — ` +
176
+ `optional_outputs must be a subset of output_contract [${ch.output_contract.join(", ")}]`);
177
+ }
178
+ }
179
+ // #243 — a skill-backed chair seals exactly ONE output: its deterministic code half
180
+ // returns a single blob, and `prepareChair` takes `output_contract[0]` and discards the
181
+ // rest. So a multi-entry contract on a skill chair is a promise the runtime structurally
182
+ // cannot keep — and, worse, cannot even REPORT breaking, because the floor is computed
183
+ // over the one spec that was built. Silent since the skill path was added. Reject it
184
+ // here, where the author can see it, rather than letting entries 2..N evaporate.
185
+ if (ch.skill_slug && (ch.agent_slug ?? "") === "" && ch.output_contract.length > 1) {
186
+ throw new CompositionError(`standard ${def.slug}: skill-backed chair "${ch.role}" promises ${ch.output_contract.length} output types ` +
187
+ `[${ch.output_contract.join(", ")}] but a skill seals exactly one. Only "${ch.output_contract[0]}" would ` +
188
+ `ever be produced and the rest would be silently dropped — split the work across chairs, or back this ` +
189
+ `chair with an agent.`);
190
+ }
191
+ }
192
+ }
193
+ // ── depends_on validation: walk roles in phase-then-chair order ────────────
194
+ // (f) self-reference is a cycle
195
+ // (g) forward reference (depends_on a role declared in a later phase) is rejected
196
+ // (h) unknown role in depends_on is rejected
197
+ // (i) cycle detection across the full role graph
198
+ const rolePhaseIndex = new Map(); // role → phase index
199
+ for (let i = 0; i < phases.length; i++) {
200
+ for (const ch of phases[i].chairs) {
201
+ rolePhaseIndex.set(ch.role, i);
202
+ }
203
+ }
204
+ for (let i = 0; i < phases.length; i++) {
205
+ for (const ch of phases[i].chairs) {
206
+ for (const dep of ch.depends_on) {
207
+ if (dep === ch.role) {
208
+ throw new CompositionError(`standard ${def.slug}: chair "${ch.role}" depends_on itself (self-cycle)`);
209
+ }
210
+ const depPhase = rolePhaseIndex.get(dep);
211
+ if (depPhase === undefined) {
212
+ throw new CompositionError(`standard ${def.slug}: chair "${ch.role}" depends_on unknown role "${dep}" (undeclared in this standard)`);
213
+ }
214
+ if (depPhase > i) {
215
+ throw new CompositionError(`standard ${def.slug}: chair "${ch.role}" (phase ${phases[i].name}) has forward reference to "${dep}" (phase ${phases[depPhase].name}); depends_on must point to an earlier or same-phase role`);
216
+ }
217
+ }
218
+ }
219
+ }
220
+ // Cycle detection across the full role graph (DFS with grey/black coloring).
221
+ // Self-cycles are already caught above; this finds longer cycles like A→B→A.
222
+ const adj = new Map();
223
+ for (const ph of phases) {
224
+ for (const ch of ph.chairs) {
225
+ adj.set(ch.role, ch.depends_on);
226
+ }
227
+ }
228
+ const WHITE = 0, GREY = 1, BLACK = 2;
229
+ const color = new Map();
230
+ for (const role of adj.keys())
231
+ color.set(role, WHITE);
232
+ function dfs(role) {
233
+ color.set(role, GREY);
234
+ for (const dep of adj.get(role) ?? []) {
235
+ const c = color.get(dep);
236
+ if (c === GREY) {
237
+ throw new CompositionError(`standard ${def.slug}: cycle in depends_on graph involving role "${role}" → "${dep}"`);
238
+ }
239
+ if (c === WHITE)
240
+ dfs(dep);
241
+ }
242
+ color.set(role, BLACK);
243
+ }
244
+ for (const role of adj.keys()) {
245
+ if (color.get(role) === WHITE)
246
+ dfs(role);
247
+ }
248
+ // ── input_contract satisfaction ───────────────────────────────────────────
249
+ // Each chair's declared input_contract must be covered by the union of its
250
+ // depends_on chairs' output_contracts — OR by the standard's declared gig inputs
251
+ // (#156: an ENTRY chair, depends_on [], reads its typed input_contract from gigInput;
252
+ // that contract IS the typed gig seed, validated against gigInput at start-of-run by runGig).
253
+ const gigInputs = new Set(def.input_types ?? []);
254
+ const chairByRole = new Map();
255
+ for (const ph of phases) {
256
+ for (const ch of ph.chairs)
257
+ chairByRole.set(ch.role, ch);
258
+ }
259
+ for (const ph of phases) {
260
+ for (const ch of ph.chairs) {
261
+ if (ch.input_contract.length === 0)
262
+ continue;
263
+ const produced = new Set(gigInputs); // gig inputs are available to any chair
264
+ for (const dep of ch.depends_on) {
265
+ const upstream = chairByRole.get(dep);
266
+ if (!upstream)
267
+ continue; // already reported above
268
+ for (const t of upstream.output_contract)
269
+ produced.add(t);
270
+ }
271
+ for (const need of ch.input_contract) {
272
+ if (!produced.has(need)) {
273
+ throw new CompositionError(`standard ${def.slug}: chair "${ch.role}" input_contract requires "${need}" not produced by any upstream chair (depends_on=[${ch.depends_on.join(",")}])`);
274
+ }
275
+ }
276
+ }
277
+ }
278
+ // ── Legacy primitive-graph + domain checks (operate on normalized phases) ──
279
+ // These predate chairs; they enforce SENSE/CREATE/VERIFY positional rules
280
+ // across the agents bound by each phase's chairs. For multi-chair phases we
281
+ // treat the chair set as the phase's agents (order: declaration order).
282
+ for (const ph of phases) {
283
+ for (const ch of ph.chairs) {
284
+ if (ch.skill_slug && !ch.agent_slug)
285
+ continue; // skill-backed chair: no agent to domain-check
286
+ const ag = agentBySlug.get(ch.agent_slug); // existence verified above
287
+ // Rob #134: agents with no explicit domain (null OR undefined) are
288
+ // domain-agnostic — compatible with any standard. Only reject when the
289
+ // agent declares an explicit domain that conflicts with the standard's.
290
+ if (ag.domain != null && ag.domain !== def.domain) {
291
+ throw new CompositionError(`standard ${def.slug}: agent ${ag.slug}.domain=${ag.domain} ≠ standard.domain=${def.domain}`);
292
+ }
293
+ }
294
+ }
295
+ // The gig contract (#177): types entering from outside the standard count as available
296
+ // upstream for the agent-level gates — a faithful agent consuming a cross-standard/gig input
297
+ // is not "input from nowhere", and such an input can be a standalone-CREATE's reasoner.
298
+ const standardInputs = new Set(def.input_types ?? []);
299
+ const upstreamOutputs = new Set(standardInputs);
300
+ const upstreamPhasePrimitives = new Set();
301
+ for (let i = 0; i < phases.length; i++) {
302
+ const ph = phases[i];
303
+ // For the legacy primitive-graph check we consider each chair in turn,
304
+ // treating prior chairs (same phase or earlier) as the upstream bag.
305
+ for (const ch of ph.chairs) {
306
+ if (ch.skill_slug && !ch.agent_slug)
307
+ continue; // skill-backed chair: not in the primitive graph
308
+ const ag = agentBySlug.get(ch.agent_slug);
309
+ if (i > 0) {
310
+ // #188: check what THIS PLACEMENT actually consumes, not the agent's GLOBAL input_types
311
+ // (its capability envelope across all roles) — so an agent reused across chairs isn't
312
+ // blocked at an early, lean placement by a type only a later chair needs. Mirror the
313
+ // runtime's own input resolution (prepareChair): a chair that declares an input_contract
314
+ // (or a depends_on) is in the faithful path — check its input_contract; a chair that
315
+ // declares neither falls back to the agent's input_types (the legacy all-prior-outputs
316
+ // filter the runtime uses for it). Checked against upstream-produced ∪ standard.input_types.
317
+ const consumed = ch.input_contract.length > 0
318
+ ? ch.input_contract
319
+ : ch.depends_on.length === 0 ? ag.input_types : [];
320
+ for (const it of consumed) {
321
+ if (it && !upstreamOutputs.has(it)) {
322
+ throw new CompositionError(`standard ${def.slug}: phase ${ph.name} input ${it} not produced upstream`);
323
+ }
324
+ }
325
+ }
326
+ const firstPrim = ag.primitives[0];
327
+ if (firstPrim && NEEDS_UPSTREAM_REASONING.has(firstPrim)) {
328
+ const agentSelfHasReasoning = ag.primitives.slice(1).some((u) => u === "INTERPRET" || u === "PLAN");
329
+ const phaseUpstreamHasReasoning = upstreamPhasePrimitives.has("INTERPRET") || upstreamPhasePrimitives.has("PLAN");
330
+ // #177: a standalone CREATE whose input arrives as a gig/cross-standard input has its
331
+ // reasoner supplied from outside the standard — the in-standard upstream isn't the only
332
+ // valid source of reasoning.
333
+ const gigSuppliesReasoning = ag.input_types.some((it) => standardInputs.has(it));
334
+ if (!agentSelfHasReasoning && !phaseUpstreamHasReasoning && !gigSuppliesReasoning) {
335
+ throw new CompositionError(`standard ${def.slug}: phase ${ph.name} (${ag.slug}) starts with CREATE but no upstream phase supplies INTERPRET or PLAN`);
336
+ }
337
+ }
338
+ if (firstPrim && NEEDS_TARGET.has(firstPrim)) {
339
+ if (upstreamPhasePrimitives.size === 0 && ag.primitives.length === 1) {
340
+ throw new CompositionError(`standard ${def.slug}: phase ${ph.name} (${ag.slug}) starts with VERIFY but no upstream phase target`);
341
+ }
342
+ }
343
+ }
344
+ // After processing all chairs in this phase, fold their primitives + outputs
345
+ // into the upstream bag for subsequent phases.
346
+ for (const ch of ph.chairs) {
347
+ if (ch.skill_slug && !ch.agent_slug) {
348
+ // a skill-backed chair produces its declared output_contract types — fold those into
349
+ // the upstream bag so a downstream agent chair can consume them.
350
+ for (const ot of ch.output_contract)
351
+ upstreamOutputs.add(ot);
352
+ continue;
353
+ }
354
+ const ag = agentBySlug.get(ch.agent_slug);
355
+ for (const p of ag.primitives)
356
+ upstreamPhasePrimitives.add(p);
357
+ for (const ot of ag.output_types)
358
+ upstreamOutputs.add(ot);
359
+ }
360
+ }
361
+ // #181 — the legacy agent-to-agent producer/consumer cycle check below reasons over
362
+ // agent-GLOBAL input_types/output_types. That collapses a multi-chair agent (one chair
363
+ // producing T, a later one consuming T via depends_on) into a single node and false-flags it as
364
+ // a self-cycle. The authoritative dataflow is the chair depends_on graph — already validated
365
+ // acyclic above (`dfs`). So defer to it: a type T that is produced AND consumed in-standard is a
366
+ // legal PIPELINE (not a cycle) when every chair consuming T transitively depends on a chair
367
+ // producing T. Only when that ordering is absent (the legacy no-depends_on shape, or a genuine
368
+ // loop the role DAG didn't already reject) does the coarser agent-global check still apply.
369
+ const transitiveDeps = new Map();
370
+ function depsOf(role) {
371
+ const cached = transitiveDeps.get(role);
372
+ if (cached)
373
+ return cached;
374
+ const acc = new Set();
375
+ transitiveDeps.set(role, acc); // set before recursion; the graph is already proven acyclic
376
+ for (const d of adj.get(role) ?? []) {
377
+ acc.add(d);
378
+ for (const x of depsOf(d))
379
+ acc.add(x);
380
+ }
381
+ return acc;
382
+ }
383
+ const producerRoles = new Map();
384
+ const consumerRoles = new Map();
385
+ for (const ph of phases) {
386
+ for (const ch of ph.chairs) {
387
+ for (const t of ch.output_contract)
388
+ producerRoles.set(t, [...(producerRoles.get(t) ?? []), ch.role]);
389
+ for (const t of ch.input_contract)
390
+ consumerRoles.set(t, [...(consumerRoles.get(t) ?? []), ch.role]);
391
+ }
392
+ }
393
+ // T is a clean in-standard pipeline iff a chair produces it AND every chair consuming it
394
+ // transitively depends_on a chair that produces it (producer precedes consumer, role-scoped).
395
+ const pipelineOrdered = (t) => {
396
+ const producers = producerRoles.get(t) ?? [];
397
+ if (producers.length === 0)
398
+ return false;
399
+ const consumers = consumerRoles.get(t) ?? [];
400
+ return consumers.every((c) => producers.some((p) => depsOf(c).has(p)));
401
+ };
402
+ const produces = new Map();
403
+ for (const ag of def.agents) {
404
+ for (const ot of ag.output_types) {
405
+ if (produces.has(ot))
406
+ continue;
407
+ produces.set(ot, ag.slug);
408
+ }
409
+ }
410
+ for (const ag of def.agents) {
411
+ for (const it of ag.input_types) {
412
+ if (produces.has(it)) {
413
+ // #183: the TRIGGER must be chair-scoped too, not just the #181 exoneration. `produces`
414
+ // and the loop above read agent-GLOBAL output_types/input_types — a capability envelope.
415
+ // A type the agent can globally read+write but which no chair in THIS standard realizes is
416
+ // not this standard's dataflow and cannot form a cycle here. Only a type a chair both
417
+ // produces AND consumes in-standard is a candidate; everything else is "not my problem".
418
+ const chairProduces = (producerRoles.get(it)?.length ?? 0) > 0;
419
+ const chairConsumes = (consumerRoles.get(it)?.length ?? 0) > 0;
420
+ if (!chairProduces || !chairConsumes)
421
+ continue;
422
+ // #181: the chair graph orders this type's producer before its consumer → legal pipeline.
423
+ if (pipelineOrdered(it))
424
+ continue;
425
+ const producer = produces.get(it);
426
+ const producerAgent = agentBySlug.get(producer);
427
+ if (producerAgent) {
428
+ for (const pIn of producerAgent.input_types) {
429
+ for (const myOut of ag.output_types) {
430
+ if (pIn === myOut) {
431
+ throw new CompositionError(`standard ${def.slug}: cycle detected between ${ag.slug} and ${producer}`);
432
+ }
433
+ }
434
+ }
435
+ }
436
+ }
437
+ }
438
+ }
439
+ // LOSS-FREE: spread the whole def, then override the two transform outputs — `phases` (the
440
+ // validated PhaseDef) and `input_types` (the deduped standard-input set). Every other declared
441
+ // field (eval_slugs / output_types / max_examine_rounds / description + anything added later to
442
+ // StandardSchema) rides through automatically, so composition can't silently drop a sealed field —
443
+ // the bug this whole change closes. The engine doesn't yet ENFORCE max_examine_rounds (separate task).
444
+ const std = { ...def, phases, input_types: [...standardInputs] };
445
+ return std;
446
+ }
447
+ //# sourceMappingURL=composition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composition.js","sourceRoot":"","sources":["../../src/composition.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,EAAE,WAAW,EAA8E,MAAM,oBAAoB,CAAC;AAiF7H,MAAM,OAAO,gBAAiB,SAAQ,KAAK;CAAG;AAE9C,0FAA0F;AAC1F,kFAAkF;AAClF,2FAA2F;AAC3F,6FAA6F;AAC7F,sDAAsD;AACtD,MAAM,OAAO,qBAAsB,SAAQ,KAAK;CAAG;AAEnD,MAAM,eAAe,GAAG,IAAI,GAAG,CAAY,CAAC,OAAO,CAAC,CAAC,CAAC;AACtD,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;AAChE,MAAM,YAAY,GAAG,IAAI,GAAG,CAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;AACpD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAY,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAErE,MAAM,UAAU,WAAW,CAAC,GAAa;IACvC,MAAM,KAAK,GAAG,GAAG,CAAC,UAAU,CAAC;IAC7B,+EAA+E;IAC/E,iFAAiF;IACjF,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,gBAAgB,CACxB,SAAS,GAAG,CAAC,IAAI,wCAAwC,OAAO,KAAK,EAAE,CACxE,CAAC;IACJ,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,gBAAgB,CAAC,SAAS,GAAG,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E,CAAC,IAAI,QAAQ,QAAQ,EAAE,CAC1E,CAAC;4BACJ,CAAC;wBACH,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,2FAA2F;IAC3F,+FAA+F;IAC/F,gGAAgG;IAChG,mGAAmG;IACnG,uGAAuG;IACvG,MAAM,GAAG,GAAa,EAAE,GAAG,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,GAAG,cAAc,CAAC,EAAE,CAAC;IAC3E,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,6 @@
1
+ export type CoreType = "Signal" | "Interpretation" | "Judgment" | "Plan" | "Artifact" | "Verdict";
2
+ export type Primitive = "SENSE" | "INTERPRET" | "JUDGE" | "PLAN" | "CREATE" | "VERIFY";
3
+ export type ReferenceType = "derived_from" | "validates" | "challenges" | "refines" | "triggers" | "contains";
4
+ export declare const CORE_TYPES: readonly CoreType[];
5
+ export declare const REFERENCE_TYPES: readonly ReferenceType[];
6
+ export declare const PRIMITIVE_OUTPUT_TYPE: Readonly<Record<Primitive, CoreType>>;
@@ -0,0 +1,25 @@
1
+ export const CORE_TYPES = [
2
+ "Signal",
3
+ "Interpretation",
4
+ "Judgment",
5
+ "Plan",
6
+ "Artifact",
7
+ "Verdict",
8
+ ];
9
+ export const REFERENCE_TYPES = [
10
+ "derived_from",
11
+ "validates",
12
+ "challenges",
13
+ "refines",
14
+ "triggers",
15
+ "contains",
16
+ ];
17
+ export const PRIMITIVE_OUTPUT_TYPE = {
18
+ SENSE: "Signal",
19
+ INTERPRET: "Interpretation",
20
+ JUDGE: "Judgment",
21
+ PLAN: "Plan",
22
+ CREATE: "Artifact",
23
+ VERIFY: "Verdict",
24
+ };
25
+ //# sourceMappingURL=core_types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core_types.js","sourceRoot":"","sources":["../../src/core_types.ts"],"names":[],"mappings":"AAwBA,MAAM,CAAC,MAAM,UAAU,GAAwB;IAC7C,QAAQ;IACR,gBAAgB;IAChB,UAAU;IACV,MAAM;IACN,UAAU;IACV,SAAS;CACV,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAA6B;IACvD,cAAc;IACd,WAAW;IACX,YAAY;IACZ,SAAS;IACT,UAAU;IACV,UAAU;CACX,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAA0C;IAC1E,KAAK,EAAE,QAAQ;IACf,SAAS,EAAE,gBAAgB;IAC3B,KAAK,EAAE,UAAU;IACjB,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE,SAAS;CAClB,CAAC"}
@@ -0,0 +1,89 @@
1
+ export interface InferenceRequest {
2
+ dataset: Record<string, unknown>;
3
+ instruction: string;
4
+ response_type: ResponseShape;
5
+ constraints: readonly string[];
6
+ }
7
+ export interface ResponseShape {
8
+ fields: Record<string, "string" | "number" | "boolean">;
9
+ maxLength?: Record<string, number>;
10
+ }
11
+ export type InferenceResponse = Record<string, unknown>;
12
+ export type Inferer = (req: InferenceRequest) => InferenceResponse;
13
+ export declare class FactoryError extends Error {
14
+ }
15
+ /** Validate a response against its shape. Returns null if ok, else the reason. */
16
+ export declare function checkShape(resp: InferenceResponse, shape: ResponseShape): string | null;
17
+ /** Run one inference call under the contract: validate the typed return; on a miss,
18
+ * retry ONCE with the error fed back into constraints; then fail loud. Never
19
+ * silently passes a non-conforming response (the T3 discipline). */
20
+ export declare function runInference(req: InferenceRequest, infer: Inferer): InferenceResponse;
21
+ /** Build the prompt for one inference call. PURE — same request, same prompt.
22
+ * The dataset is the ONLY material; constraints are hard prohibitions; the
23
+ * response shape is stated as the exact JSON contract the model must return. */
24
+ export declare function buildInfererPrompt(req: InferenceRequest): string;
25
+ export interface ClaudeInfererOptions {
26
+ bin?: string | undefined;
27
+ model?: string | undefined;
28
+ /**
29
+ * #225 — wall-clock bound on the inference spawn. This call is SYNCHRONOUS, so an
30
+ * unbounded child wedges the whole process; a tool-granted child has no inherent
31
+ * terminus. Defaults to the same bound the chair invoker uses.
32
+ */
33
+ timeout_ms?: number | undefined;
34
+ run?: ((bin: string, args: string[]) => string) | undefined;
35
+ }
36
+ /** The production Inferer. Spawns `claude -p <prompt>` and parses the JSON it
37
+ * returns (reusing extractJson — tolerant of fences/prose). The CLI spawn is the
38
+ * one non-deterministic seam; inject `run` to test the prompt-build + parse path. */
39
+ export declare function makeClaudeInferer(opts?: ClaudeInfererOptions): Inferer;
40
+ export type Fact = string;
41
+ export interface IntentProfile {
42
+ doc_type: string;
43
+ classification: string;
44
+ supplied_context: Record<string, Fact[]>;
45
+ }
46
+ export interface Skeleton {
47
+ sections: string[];
48
+ density_targets: Record<string, number>;
49
+ }
50
+ export interface Slot {
51
+ id: string;
52
+ facts: Fact[];
53
+ constraints: readonly string[];
54
+ response_type: ResponseShape;
55
+ target_length: number;
56
+ }
57
+ export interface Phrasing {
58
+ slot_id: string;
59
+ text: string;
60
+ }
61
+ export interface CoherentDraft {
62
+ audience: string;
63
+ doc_type: string;
64
+ body: string;
65
+ }
66
+ export declare const GOVERNING_RULES: readonly string[];
67
+ export interface DocSchema {
68
+ sections: string[];
69
+ density_targets?: Record<string, number>;
70
+ }
71
+ export type SchemaPack = Record<string, DocSchema>;
72
+ export declare const SCHEMA_PACK: SchemaPack;
73
+ /** Load a schema-pack from a genome JSON file (eir_document_schemas.json). Validates
74
+ * each entry has a non-empty sections[] and a "default" exists — fails loud, so a
75
+ * malformed genome can never silently degrade to the bootstrap pack. */
76
+ export declare function loadSchemaPack(path: string): SchemaPack;
77
+ export declare function selectSkeleton(intent: IntentProfile, pack?: SchemaPack): Skeleton;
78
+ export declare function bindSlots(skeleton: Skeleton, intent: IntentProfile): Slot[];
79
+ export declare function composePhrasings(slots: readonly Slot[], infer: Inferer): Phrasing[];
80
+ export declare function smoothCoherence(phrasings: readonly Phrasing[], intent: IntentProfile, infer: Inferer): CoherentDraft;
81
+ export declare function render(draft: CoherentDraft): string;
82
+ export interface FactoryResult {
83
+ skeleton: Skeleton;
84
+ slots: Slot[];
85
+ dropped: string[];
86
+ phrasings: Phrasing[];
87
+ artifact: string;
88
+ }
89
+ export declare function runFactory(intent: IntentProfile, infer: Inferer, pack?: SchemaPack): FactoryResult;