@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,504 @@
1
+ import { readdirSync, readFileSync, existsSync, statSync } from "node:fs";
2
+ import { join, extname, resolve, isAbsolute, dirname } from "node:path";
3
+ import { createRequire } from "node:module";
4
+ import { defineAgent, composeStandard, CompositionError, GenomeIncompleteError } from "./composition.js";
5
+ import { loadSkillPackage, SkillLoadError } from "./skills.js";
6
+ import { SkillSchema, EvalSchema, DomainTypeSchema } from "./genome_schema.js";
7
+ import { CANONICAL_CORE_TYPES } from "./canonical_core_types.js";
8
+ export class GenomeLoadError extends Error {
9
+ }
10
+ /**
11
+ * Read every *.json file in `dir`. Files that fail to read or parse are
12
+ * accumulated into `parse_failures` instead of throwing — the caller (per
13
+ * Rob #129) decides whether the failure is hard (core types) or soft
14
+ * (definitions). Filesystem-level errors (readFileSync) still throw because
15
+ * they indicate the directory itself is unreadable.
16
+ */
17
+ function readJsonDir(dir) {
18
+ if (!existsSync(dir))
19
+ return { files: [], parse_failures: [] };
20
+ const files = [];
21
+ const parse_failures = [];
22
+ for (const name of readdirSync(dir)) {
23
+ if (extname(name) !== ".json")
24
+ continue;
25
+ const path = join(dir, name);
26
+ if (!statSync(path).isFile())
27
+ continue;
28
+ let raw;
29
+ try {
30
+ raw = readFileSync(path, "utf-8");
31
+ }
32
+ catch (e) {
33
+ const msg = e instanceof Error ? e.message : String(e);
34
+ throw new GenomeLoadError(`failed to read ${path}: ${msg}`);
35
+ }
36
+ try {
37
+ files.push({ path, data: JSON.parse(raw) });
38
+ }
39
+ catch (e) {
40
+ const msg = e instanceof Error ? e.message : String(e);
41
+ parse_failures.push({ path, error: `malformed JSON at ${path}: ${msg}` });
42
+ }
43
+ }
44
+ return { files, parse_failures };
45
+ }
46
+ const REQUIRED_CORE_SLUGS = new Set([
47
+ "Signal",
48
+ "Interpretation",
49
+ "Judgment",
50
+ "Plan",
51
+ "Artifact",
52
+ "Verdict",
53
+ ]);
54
+ /**
55
+ * #241 — an `agent.skill_slugs` entry that resolves to NO skill package is a dangling
56
+ * reference. `loadGenome` never cross-referenced the two maps, so `load_errors` stayed `[]`
57
+ * — the pass signal operators are explicitly instructed to trust — while the agent ran
58
+ * without the discipline it claims to hold.
59
+ *
60
+ * SOFT by design: the agent still loads. A non-required dangling binding degrades the prompt,
61
+ * it does not invalidate the definition; the RUNTIME decides whether it kills a chair, via
62
+ * `Chair.required_skills`. This only has to break the silence.
63
+ *
64
+ * Runs as a POST-PASS, after BOTH maps exist — and again in `loadLayeredGenome` after the
65
+ * fold, because a base-layer agent may legitimately bind a skill a higher layer supplies.
66
+ */
67
+ function danglingSkillBindingErrors(agents, skills, pathOf) {
68
+ const out = [];
69
+ for (const [slug, agent] of agents) {
70
+ const missing = (agent.skill_slugs ?? []).filter((s) => !skills.has(s));
71
+ if (missing.length === 0)
72
+ continue;
73
+ out.push({
74
+ kind: "agent",
75
+ path: pathOf(slug),
76
+ slug,
77
+ error: `dangling skill binding: skill_slugs [${missing.join(", ")}] resolve to no skill package ` +
78
+ `(define the package under skills/<slug>/ or drop the binding — a bound skill with no package ` +
79
+ `contributes nothing to the prompt and is invisible in the sealed output)`,
80
+ });
81
+ }
82
+ return out;
83
+ }
84
+ export function loadGenome(root, opts) {
85
+ const load_errors = [];
86
+ // core_types/ stays STRICTLY hard-fail: the system can't function without
87
+ // the six core slugs, so soft-fail would just delay the inevitable crash
88
+ // somewhere downstream. Parse failures here throw too — same logic.
89
+ const coreRead = readJsonDir(join(root, "core_types"));
90
+ const firstCoreFailure = coreRead.parse_failures[0];
91
+ if (firstCoreFailure) {
92
+ throw new GenomeLoadError(firstCoreFailure.error);
93
+ }
94
+ // Genome extension Phase 1 (docs/genome-extension.md): when a genome root has NO
95
+ // core_types/ of its own, seed the canonical, immutable 6 the engine owns — so a
96
+ // downstream consumer boots without hand-copying core substrate. A PARTIAL
97
+ // core_types/ (some-but-not-all 6) still hard-fails the strict gate below; that's
98
+ // a corrupt genome, not a fresh one.
99
+ const coreList = coreRead.files.length > 0
100
+ ? coreRead.files
101
+ : CANONICAL_CORE_TYPES.map((data) => ({ path: "<engine-canonical>", data }));
102
+ const core_types = new Map();
103
+ const core_type_paths = new Map();
104
+ for (const { path, data: c } of coreList) {
105
+ if (core_types.has(c.slug)) {
106
+ throw new GenomeLoadError(`duplicate core type slug "${c.slug}" in ${path} (first seen in ${core_type_paths.get(c.slug)})`);
107
+ }
108
+ core_types.set(c.slug, c);
109
+ core_type_paths.set(c.slug, path);
110
+ }
111
+ const missing = [...REQUIRED_CORE_SLUGS].filter((s) => !core_types.has(s));
112
+ if (missing.length > 0) {
113
+ throw new GenomeLoadError(`core_types/ missing required slugs: ${missing.join(", ")}`);
114
+ }
115
+ if (core_types.size !== REQUIRED_CORE_SLUGS.size) {
116
+ const extra = [...core_types.keys()].filter((s) => !REQUIRED_CORE_SLUGS.has(s));
117
+ throw new GenomeLoadError(`core_types/ contains non-spec slugs: ${extra.join(", ")} (core set is immutable; v2 spec §2)`);
118
+ }
119
+ // domain_types/ — past the core gate, soft-fail. One broken type no longer
120
+ // kills the genome. Each parse-failure becomes a typed LoadError.
121
+ const domainRead = readJsonDir(join(root, "domain_types"));
122
+ for (const f of domainRead.parse_failures) {
123
+ load_errors.push({ kind: "domain_type", path: f.path, slug: null, error: f.error });
124
+ }
125
+ const domain_types = new Map();
126
+ const domain_type_paths = new Map();
127
+ for (const { path, data: d } of domainRead.files) {
128
+ try {
129
+ const key = `${d.slug}@${d.version}`;
130
+ if (domain_types.has(key)) {
131
+ throw new Error(`duplicate domain type "${key}" in ${path} (first seen in ${domain_type_paths.get(key)})`);
132
+ }
133
+ if (!core_types.has(d.extends)) {
134
+ throw new Error(`field "extends" references "${d.extends}" which is not a core type`);
135
+ }
136
+ // Validate the file shape against the single Zod source (genome_schema.ts). Soft-fail per
137
+ // the domain_types stance above — a malformed type file is a typed LoadError, not a genome kill.
138
+ const typeCheck = DomainTypeSchema.safeParse(d);
139
+ if (!typeCheck.success) {
140
+ const why = typeCheck.error.issues.map((i) => `${i.path.join(".") || "(root)"}: ${i.message}`).join("; ");
141
+ throw new Error(`type schema validation failed — ${why}`);
142
+ }
143
+ domain_types.set(key, d);
144
+ domain_type_paths.set(key, path);
145
+ }
146
+ catch (e) {
147
+ load_errors.push({
148
+ kind: "domain_type",
149
+ path,
150
+ slug: typeof d?.slug === "string" ? d.slug : null,
151
+ error: e instanceof Error ? e.message : String(e),
152
+ });
153
+ }
154
+ }
155
+ // agents/ — each file is an AgentDef; validated through defineAgent. Soft-fail
156
+ // per file: a broken agent does not block other agents from loading.
157
+ const agentRead = readJsonDir(join(root, "agents"));
158
+ for (const f of agentRead.parse_failures) {
159
+ load_errors.push({ kind: "agent", path: f.path, slug: null, error: f.error });
160
+ }
161
+ const agents = new Map();
162
+ const agent_paths = new Map();
163
+ for (const { path, data: def } of agentRead.files) {
164
+ const slug = typeof def?.slug === "string" ? def.slug : null;
165
+ try {
166
+ if (!def.slug || typeof def.slug !== "string") {
167
+ throw new Error(`missing required "slug" field`);
168
+ }
169
+ if (agents.has(def.slug)) {
170
+ throw new Error(`duplicate agent slug "${def.slug}" (first seen in ${agent_paths.get(def.slug)})`);
171
+ }
172
+ agents.set(def.slug, defineAgent(def));
173
+ agent_paths.set(def.slug, path);
174
+ }
175
+ catch (e) {
176
+ // An agent that fails to VALIDATE — malformed (bad primitives / illegal progression,
177
+ // CompositionError) OR incomplete against the schema (missing behavioral, the
178
+ // GenomeIncompleteError) — HARD-fails the whole load. A genome must load cleanly to
179
+ // run; a standard with a quietly-missing chair would produce silently-wrong outputs.
180
+ // (Non-validation issues like a duplicate-slug collision still soft-fail below.)
181
+ if (e instanceof CompositionError || e instanceof GenomeIncompleteError)
182
+ throw e;
183
+ load_errors.push({
184
+ kind: "agent",
185
+ path,
186
+ slug,
187
+ error: e instanceof Error ? e.message : String(e),
188
+ });
189
+ }
190
+ }
191
+ // standards/ — resolve agent_slugs against loaded agents, then composeStandard.
192
+ // Soft-fail per file. A standard that references a missing-or-broken agent
193
+ // gets skipped + recorded; other standards still load.
194
+ const standardRead = readJsonDir(join(root, "standards"));
195
+ for (const f of standardRead.parse_failures) {
196
+ load_errors.push({ kind: "standard", path: f.path, slug: null, error: f.error });
197
+ }
198
+ const standards = new Map();
199
+ const standard_paths = new Map();
200
+ for (const { path, data: def } of standardRead.files) {
201
+ const slug = typeof def?.slug === "string" ? def.slug : null;
202
+ try {
203
+ if (!def.slug || typeof def.slug !== "string") {
204
+ throw new Error(`missing required "slug" field`);
205
+ }
206
+ if (standards.has(def.slug)) {
207
+ throw new Error(`duplicate standard slug "${def.slug}" (first seen in ${standard_paths.get(def.slug)})`);
208
+ }
209
+ const resolved = [];
210
+ for (const aslug of def.agent_slugs ?? []) {
211
+ // Resolve against this layer's own agents first, then agents inherited from
212
+ // lower layers (genome extension) — so a consumer standard can compose base
213
+ // players it didn't define itself.
214
+ const a = agents.get(aslug) ?? opts?.inheritedAgents?.get(aslug);
215
+ if (!a) {
216
+ throw new Error(`field "agent_slugs" references unknown agent "${aslug}"`);
217
+ }
218
+ resolved.push(a);
219
+ }
220
+ // Pass eval_slugs through to composeStandard when present (added in #128).
221
+ standards.set(def.slug, composeStandard({
222
+ slug: def.slug,
223
+ domain: def.domain,
224
+ agents: resolved,
225
+ phases: def.phases,
226
+ ...(def.eval_slugs ? { eval_slugs: def.eval_slugs } : {}),
227
+ // #177: the gig contract — types entering from outside the standard (gig / cross-standard).
228
+ ...(def.input_types ? { input_types: def.input_types } : {}),
229
+ // #genome-schema: fields the file declares must reach the runtime Standard, not be dropped.
230
+ ...(def.output_types ? { output_types: def.output_types } : {}),
231
+ ...(def.max_examine_rounds !== undefined ? { max_examine_rounds: def.max_examine_rounds } : {}),
232
+ ...(def.description ? { description: def.description } : {}),
233
+ }));
234
+ standard_paths.set(def.slug, path);
235
+ }
236
+ catch (e) {
237
+ load_errors.push({
238
+ kind: "standard",
239
+ path,
240
+ slug,
241
+ error: e instanceof CompositionError || e instanceof Error ? e.message : String(e),
242
+ });
243
+ }
244
+ }
245
+ // skills/<slug>/ PACKAGE directories are the ONLY skill format (the flat {slug, md} JSON
246
+ // is retired — no backwards-compat). A genome skill must be a COMPLETE package: meta +
247
+ // >=1 fixture (its pre-registered contract) + >=1 half (code and/or reasoning). Malformed
248
+ // (SkillLoadError) OR incomplete HARD-fails the load — a genome must load cleanly to run,
249
+ // mirroring the agent behavioral gate. Only a duplicate-slug collision soft-fails.
250
+ const skills = new Map();
251
+ const skill_paths = new Map();
252
+ const skillsDir = join(root, "skills");
253
+ if (existsSync(skillsDir)) {
254
+ for (const entry of readdirSync(skillsDir, { withFileTypes: true })) {
255
+ if (!entry.isDirectory())
256
+ continue;
257
+ const pkgDir = join(skillsDir, entry.name);
258
+ if (!existsSync(join(pkgDir, "meta.json")))
259
+ continue;
260
+ const pkg = loadSkillPackage(pkgDir); // SkillLoadError (malformed) propagates → hard-fail
261
+ if (pkg.fixtures.length === 0) {
262
+ throw new SkillLoadError(`skill ${pkg.meta.slug}: no fixtures — a skill must ship its pre-registered contract (fixtures capture intent at creation; deferring them loses it)`);
263
+ }
264
+ if (pkg.codeHash === null && pkg.mdPath === null) {
265
+ throw new SkillLoadError(`skill ${pkg.meta.slug}: empty — needs a code half (skill.mjs) and/or a reasoning half (skill.md)`);
266
+ }
267
+ // Validate the meta against the single Zod source — a malformed declared field (e.g. a
268
+ // non-numeric determinism_ratio, a malformed permission/network grant) hard-fails the load,
269
+ // mirroring the package-completeness gate above. Shape only: this does NOT re-impose any
270
+ // fixtures-pass-to-promote ceremony — promotion strictness is a separate, tunable policy.
271
+ const metaCheck = SkillSchema.safeParse(pkg.meta);
272
+ if (!metaCheck.success) {
273
+ const why = metaCheck.error.issues.map((i) => `${i.path.join(".") || "(root)"}: ${i.message}`).join("; ");
274
+ throw new SkillLoadError(`skill ${pkg.meta.slug}: meta failed schema validation — ${why}`);
275
+ }
276
+ if (skills.has(pkg.meta.slug)) {
277
+ load_errors.push({ kind: "skill", path: pkgDir, slug: pkg.meta.slug, error: `duplicate skill slug "${pkg.meta.slug}" (first seen in ${skill_paths.get(pkg.meta.slug)})` });
278
+ continue;
279
+ }
280
+ // resolve the reasoning half into the record so the prompt's Skills layer renders it
281
+ const md = pkg.mdPath ? readFileSync(pkg.mdPath, "utf-8") : undefined;
282
+ skills.set(pkg.meta.slug, { ...pkg.meta, slug: pkg.meta.slug, package_dir: pkgDir, code_hash: pkg.codeHash, ...(md !== undefined ? { md } : {}) });
283
+ skill_paths.set(pkg.meta.slug, pkgDir);
284
+ }
285
+ }
286
+ const evalRead = readJsonDir(join(root, "evals"));
287
+ for (const f of evalRead.parse_failures) {
288
+ load_errors.push({ kind: "eval", path: f.path, slug: null, error: f.error });
289
+ }
290
+ const evals = new Map();
291
+ const eval_paths = new Map();
292
+ for (const { path, data: e } of evalRead.files) {
293
+ const slug = typeof e?.slug === "string" ? e.slug : null;
294
+ try {
295
+ if (!e.slug)
296
+ throw new Error(`required field "slug" is missing`);
297
+ if (evals.has(e.slug)) {
298
+ throw new Error(`duplicate eval slug "${e.slug}" (first seen in ${eval_paths.get(e.slug)})`);
299
+ }
300
+ // Validate against the single Zod source — the {slug;[k]:unknown} bag is retired, so a
301
+ // malformed eval (e.g. a non-array non_empty_fields) is caught at load, not at score time.
302
+ const parsed = EvalSchema.safeParse(e);
303
+ if (!parsed.success) {
304
+ const why = parsed.error.issues.map((i) => `${i.path.join(".") || "(root)"}: ${i.message}`).join("; ");
305
+ throw new Error(`eval schema validation failed — ${why}`);
306
+ }
307
+ evals.set(e.slug, parsed.data);
308
+ eval_paths.set(e.slug, path);
309
+ }
310
+ catch (err) {
311
+ load_errors.push({ kind: "eval", path, slug, error: err instanceof Error ? err.message : String(err) });
312
+ }
313
+ }
314
+ // #241 — post-pass, now that BOTH the agents and skills maps exist.
315
+ if (!opts?.deferSkillBindingCheck) {
316
+ load_errors.push(...danglingSkillBindingErrors(agents, skills, (slug) => agent_paths.get(slug) ?? join(root, "agents")));
317
+ }
318
+ return { core_types, domain_types, agents, standards, skills, evals, load_errors };
319
+ }
320
+ /**
321
+ * Resolve a LAYERED genome from a stack of roots, lowest → highest (genome extension
322
+ * Phase 2 — docs/genome-extension.md). Each root is loaded as a normal genome, then
323
+ * folded so a higher layer's definitions OVERRIDE a lower layer's by slug, per class.
324
+ * A consumer extends a base by passing [baseRoot, consumerRoot]: it inherits the base,
325
+ * adds its own, and overrides where it specializes. `provenance` records which layer
326
+ * supplied each effective definition. core_types are the immutable 6 (every layer
327
+ * provides them, seeded or on-disk); the top layer's are used.
328
+ */
329
+ export function loadLayeredGenome(roots) {
330
+ if (roots.length === 0) {
331
+ throw new GenomeLoadError("loadLayeredGenome requires at least one root");
332
+ }
333
+ const domain_types = new Map();
334
+ const agents = new Map();
335
+ const standards = new Map();
336
+ const skills = new Map();
337
+ const evals = new Map();
338
+ const load_errors = [];
339
+ const provenance = new Map();
340
+ let core_types = new Map();
341
+ const fold = (into, from, root, kind) => {
342
+ for (const [slug, val] of from) {
343
+ into.set(slug, val); // higher layer overrides
344
+ provenance.set(`${kind}:${slug}`, root);
345
+ }
346
+ };
347
+ for (const root of roots) {
348
+ // Each layer loaded normally (core types seeded), with the agents accumulated
349
+ // from lower layers passed in — so this layer's standards can compose them.
350
+ // #241 — the skill-binding check is deferred to the post-fold pass below: a BASE agent
351
+ // may legitimately bind a skill a HIGHER layer supplies, so per-layer it would report a
352
+ // dangle that the resolved genome does not have.
353
+ const layer = loadGenome(root, { inheritedAgents: agents, deferSkillBindingCheck: true });
354
+ core_types = layer.core_types; // immutable 6 — top layer's (all identical)
355
+ fold(domain_types, layer.domain_types, root, "domain_type");
356
+ fold(agents, layer.agents, root, "agent");
357
+ fold(standards, layer.standards, root, "standard");
358
+ fold(skills, layer.skills, root, "skill");
359
+ fold(evals, layer.evals, root, "eval");
360
+ for (const e of layer.load_errors)
361
+ load_errors.push(e);
362
+ }
363
+ // #241 — the post-fold pass. Reported once, against the resolved genome, not once per layer.
364
+ load_errors.push(...danglingSkillBindingErrors(agents, skills, (slug) => {
365
+ const layerRoot = provenance.get(`agent:${slug}`);
366
+ return layerRoot ? join(layerRoot, "agents") : "";
367
+ }));
368
+ return { core_types, domain_types, agents, standards, skills, evals, load_errors, provenance };
369
+ }
370
+ /**
371
+ * Manifest-aware genome load (genome extension Phase 2 — opt-in). A genome root may
372
+ * declare the base(s) it extends in a `genome.json` manifest: `{ "extends": [<path>] }`
373
+ * (absolute, or relative to that root). resolveGenome walks the extends chain, flattens
374
+ * it to a layer stack (bases first, this root last, deduped + cycle-guarded), and resolves
375
+ * it via loadLayeredGenome. No manifest → a plain single-root load. This is what the
376
+ * running server (bootstrapServerDeps) calls, so a downstream consumer's declared base
377
+ * is honored automatically.
378
+ */
379
+ export function resolveGenome(root) {
380
+ const { roots, pinErrors } = resolveExtendsChain(root);
381
+ const genome = roots.length === 1 ? loadGenome(root) : loadLayeredGenome(roots);
382
+ if (pinErrors.length === 0)
383
+ return genome;
384
+ return { ...genome, load_errors: [...genome.load_errors, ...pinErrors] };
385
+ }
386
+ export function genomeCascadeCheck(consumerRoot, fromBase, toBase) {
387
+ const consumerReal = resolve(consumerRoot);
388
+ const consumerLayerErrors = (base) => loadLayeredGenome([base, consumerRoot]).load_errors.filter((e) => resolve(e.path).startsWith(consumerReal));
389
+ const key = (e) => `${e.kind}:${e.slug ?? ""}:${e.error}`;
390
+ const fromErrs = consumerLayerErrors(fromBase);
391
+ const toErrs = consumerLayerErrors(toBase);
392
+ const fromKeys = new Set(fromErrs.map(key));
393
+ const toKeys = new Set(toErrs.map(key));
394
+ return {
395
+ broken: toErrs.filter((e) => !fromKeys.has(key(e))),
396
+ healed: fromErrs.filter((e) => !toKeys.has(key(e))),
397
+ };
398
+ }
399
+ function readGenomeManifest(root, manifestErrors) {
400
+ const p = join(root, "genome.json");
401
+ if (!existsSync(p))
402
+ return [];
403
+ let raw;
404
+ try {
405
+ raw = readFileSync(p, "utf-8");
406
+ }
407
+ catch (e) {
408
+ manifestErrors.push({
409
+ kind: "manifest", path: p, slug: null,
410
+ error: `cannot read genome manifest: ${e instanceof Error ? e.message : String(e)} (the declared base(s) are NOT loaded)`,
411
+ });
412
+ return [];
413
+ }
414
+ try {
415
+ const data = JSON.parse(raw);
416
+ return Array.isArray(data.extends) ? data.extends.filter((e) => typeof e === "string") : [];
417
+ }
418
+ catch (e) {
419
+ // #247 — this used to `return []` silently, which UN-EXTENDS the genome: every inherited
420
+ // agent, standard, skill and type vanishes. The operator then gets a cascade of
421
+ // `references unknown agent "…"` errors pointing at files that are perfectly correct —
422
+ // the root cause destroyed and the symptom relocated. The manifest LoadError channel for
423
+ // exactly this class already existed (resolveExtendsEntry uses it for pin errors); this
424
+ // branch simply didn't use it. Still SOFT — one bad manifest is not a crash.
425
+ manifestErrors.push({
426
+ kind: "manifest", path: p, slug: null,
427
+ error: `malformed genome manifest — ${e instanceof Error ? e.message : String(e)} ` +
428
+ `(the declared base(s) are NOT loaded; every inherited definition is missing until this file parses, ` +
429
+ `so treat any "references unknown …" errors below as downstream of this one)`,
430
+ });
431
+ return [];
432
+ }
433
+ }
434
+ function resolveExtendsChain(root) {
435
+ const ordered = [];
436
+ const pinErrors = [];
437
+ const done = new Set();
438
+ const onStack = new Set();
439
+ const visit = (r) => {
440
+ const real = resolve(r);
441
+ if (done.has(real))
442
+ return;
443
+ if (onStack.has(real))
444
+ throw new GenomeLoadError(`genome extends cycle detected at ${real}`);
445
+ onStack.add(real);
446
+ for (const spec of readGenomeManifest(real, pinErrors)) {
447
+ const resolved = resolveExtendsEntry(spec, real, pinErrors);
448
+ if (resolved)
449
+ visit(resolved);
450
+ }
451
+ onStack.delete(real);
452
+ done.add(real);
453
+ ordered.push(real); // post-order: bases land before the root that extends them
454
+ };
455
+ visit(root);
456
+ return { roots: ordered, pinErrors };
457
+ }
458
+ // Split a package spec into name + optional version pin. Handles scoped names:
459
+ // "@scope/pkg@1.2.3" → { name: "@scope/pkg", version: "1.2.3" }
460
+ // "@scope/pkg" → { name: "@scope/pkg" }
461
+ // "pkg@1.2.3" → { name: "pkg", version: "1.2.3" }
462
+ function parsePackageSpec(spec) {
463
+ const slash = spec.startsWith("@") ? spec.indexOf("/") : 0;
464
+ const at = spec.indexOf("@", slash + 1);
465
+ return at > 0 ? { name: spec.slice(0, at), version: spec.slice(at + 1) } : { name: spec };
466
+ }
467
+ // Resolve one `extends` entry to a genome root. A path (./ , / , absolute) resolves
468
+ // relative to the declaring root. Anything else is an npm package spec
469
+ // (`@scope/pkg[@version]`): resolve the installed package's dir from the declaring
470
+ // root's node_modules; if a version was pinned, warn (manifest load_error) when the
471
+ // installed version differs — the pin records "validated against vX", so a mismatch
472
+ // means re-run the cascade and re-pin. Returns null (with a recorded error) if the
473
+ // package can't be resolved.
474
+ function resolveExtendsEntry(spec, fromRoot, pinErrors) {
475
+ if (spec.startsWith(".") || isAbsolute(spec) || spec.startsWith("/")) {
476
+ return isAbsolute(spec) ? spec : join(fromRoot, spec);
477
+ }
478
+ const { name, version } = parsePackageSpec(spec);
479
+ const manifestPath = join(fromRoot, "genome.json");
480
+ try {
481
+ const req = createRequire(join(fromRoot, "package.json"));
482
+ const pkgJsonPath = req.resolve(`${name}/package.json`);
483
+ const installed = JSON.parse(readFileSync(pkgJsonPath, "utf-8"));
484
+ if (version && installed.version && version !== installed.version) {
485
+ pinErrors.push({
486
+ kind: "manifest",
487
+ path: manifestPath,
488
+ slug: name,
489
+ error: `extends: base "${name}" pinned to ${version} but ${installed.version} is installed — re-run cascade + re-pin`,
490
+ });
491
+ }
492
+ return dirname(pkgJsonPath);
493
+ }
494
+ catch {
495
+ pinErrors.push({
496
+ kind: "manifest",
497
+ path: manifestPath,
498
+ slug: name,
499
+ error: `extends: cannot resolve base package "${name}" from ${fromRoot} (is it installed?)`,
500
+ });
501
+ return null;
502
+ }
503
+ }
504
+ //# sourceMappingURL=loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAA4B,MAAM,SAAS,CAAC;AACpG,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,gBAAgB,EAAE,qBAAqB,EAA2D,MAAM,kBAAkB,CAAC;AAClK,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC/D,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gBAChB,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE,IAAI;gBACV,KAAK,EAAE,kBAAkB,IAAI,eAAe,OAAO,QAAQ,SAAS,CAAC,OAAO,yCAAyC;aACtH,CAAC,CAAC;QACL,CAAC;QACD,OAAO,OAAO,CAAC,WAAW,CAAC,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACP,SAAS,CAAC,IAAI,CAAC;YACb,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,YAAY;YAClB,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,yCAAyC,IAAI,UAAU,QAAQ,qBAAqB;SAC5F,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { ChangeClass } from "./type_versioning.js";
2
+ export type MCPCategory = "understand" | "build" | "run" | "improve" | "manage_context";
3
+ export interface MCPToolDef {
4
+ slug: string;
5
+ category: MCPCategory;
6
+ input_schema: object;
7
+ output_schema: object;
8
+ }
9
+ export declare const MCP_TOOLS: readonly MCPToolDef[];
10
+ export declare const AGENT_STATUS_ORDER: readonly string[];
11
+ export declare const STANDARD_STATUS_ORDER: readonly string[];
12
+ export declare const SKILL_STATUS_ORDER: readonly string[];
13
+ export declare class PromotionError extends Error {
14
+ }
15
+ /** Validate a forward-only transition through the given status chain. Throws on
16
+ * unknown current/target or any backward/sideways move. Idempotent (current = target). */
17
+ export declare function checkPromotion(current: string, target: string, order: readonly string[]): void;
18
+ export interface ApprovalQuery {
19
+ slug: string;
20
+ change_class: ChangeClass | null;
21
+ target_kind: string | null;
22
+ }
23
+ export declare function requiresApproval(q: ApprovalQuery): boolean;