@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 @@
1
+ {"version":3,"file":"genome_schema.js","sourceRoot":"","sources":["../../src/genome_schema.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,gGAAgG;AAChG,oGAAoG;AACpG,kGAAkG;AAClG,iGAAiG;AACjG,kGAAkG;AAClG,uDAAuD;AACvD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,qFAAqF;AACrF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,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5F,8FAA8F;IAC9F,+FAA+F;IAC/F,iGAAiG;IACjG,mGAAmG;IACnG,kGAAkG;IAClG,kGAAkG;IAClG,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,MAAM,GAAG,GAAI,CAAoE,CAAC,IAAI,CAAC;QACvF,MAAM,KAAK,GAAG,GAAG,EAAE,SAAS,IAAI,GAAG,EAAE,MAAM,CAAC;QAC5C,IAAI,KAAK,IAAI,KAAK,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC;YAAC,CAAC,GAAG,KAAK,CAAC;YAAC,SAAS;QAAC,CAAC;QACjE,MAAM;IACR,CAAC;IACD,IAAI,CAAC,YAAY,CAAC,CAAC,SAAS,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO;QAAE,OAAO,QAAQ,CAAC;IACxE,IAAI,CAAC,YAAY,CAAC,CAAC,SAAS;QAAE,OAAO,QAAQ,CAAC;IAC9C,IAAI,CAAC,YAAY,CAAC,CAAC,UAAU;QAAE,OAAO,SAAS,CAAC;IAChD,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ;QAAE,OAAO,OAAO,CAAC;IACvE,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,aAAa,CAAC,MAAkC;IAC9D,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9G,CAAC"}
@@ -0,0 +1,67 @@
1
+ import { type Agent, type AgentDef } from "./composition.js";
2
+ import { type Ledger } from "./ledger.js";
3
+ /**
4
+ * Write a genome file, preserving any prior version's BYTES before a destructive
5
+ * overwrite. The ledger already keeps the content-hash *identity* of every seal;
6
+ * this keeps the actual prior *content*, so a re-compose / re-define / evolve over
7
+ * an existing slug is recoverable, not just provably-changed.
8
+ *
9
+ * When <subdir>/<slug>.json already exists with DIFFERENT bytes, the old bytes are
10
+ * snapshotted to .coltrane/history/<subdir>/<slug>/<oldContentHash>.json (gitignored,
11
+ * local) before the overwrite. Identical bytes → no snapshot (idempotent no-op).
12
+ * Returns the prior content hash when an overwrite displaced real content.
13
+ */
14
+ export declare function writeGenomeFileVersioned(genome_dir: string, subdir: string, slug: string, jsonText: string): {
15
+ overwritten: boolean;
16
+ prior_content_hash?: string;
17
+ };
18
+ export interface SealResult {
19
+ agent: Agent;
20
+ content_hash: string;
21
+ dependency_hash: string;
22
+ effective_hash: string;
23
+ }
24
+ /** Generic substrate seal for ANY genome definition (agent / standard / type / skill).
25
+ * Computes the canonical identity, and when a genome_dir is given, writes the
26
+ * content-addressed file under <subdir>/<slug>.json AND appends the ledger seal keyed
27
+ * standard_slug=<kind>, genome_hash=effective_hash. The single blessed write path. */
28
+ export declare function sealDefinition(kind: string, slug: string, def: unknown, ledger: Ledger, genome_dir: string | undefined, subdir: string): {
29
+ content_hash: string;
30
+ dependency_hash: string;
31
+ effective_hash: string;
32
+ };
33
+ /** Ledger-only identity seal — for version-producing mutations (type_extend, agent_evolve)
34
+ * whose new-version FILE materialization needs version-aware loader support (the one named
35
+ * boundary). The identity is still sealed in the append-only ledger, so the mutation is
36
+ * never a contract lie: its effective_hash is recorded even before the file lands. */
37
+ export declare function recordIdentity(kind: string, slug: string, def: unknown, ledger: Ledger): {
38
+ content_hash: string;
39
+ dependency_hash: string;
40
+ effective_hash: string;
41
+ };
42
+ /** The canonical identity of an agent definition. PURE + deterministic from the def, so
43
+ * the same input always yields the same effective_hash (cross-machine interoperable). */
44
+ export declare function agentIdentity(def: AgentDef): {
45
+ content_hash: string;
46
+ dependency_hash: string;
47
+ effective_hash: string;
48
+ };
49
+ /** Validate, hash, and (when a genome_dir is provided) PERSIST + LEDGER-SEAL. Without a
50
+ * genome_dir the identity is still computed + returned (validation path); with one, the
51
+ * agent is written to agents/<slug>.json and the effective_hash is recorded in the
52
+ * append-only ledger — the only way an agent enters the substrate of truth. */
53
+ export declare function sealAgentDefinition(def: AgentDef, ledger: Ledger, genome_dir?: string): SealResult;
54
+ /** Persist a skill as the LOADABLE PACKAGE the loader reads — skills/<slug>/{meta.json, skill.mjs?,
55
+ * skill.md?, fixtures/*.json} — not a flat skills/<slug>.json the loader skips. The content fields
56
+ * (`code` → skill.mjs, `md` → skill.md) and each fixture become their own files; meta.json holds the
57
+ * remaining declared fields. Identity is hashed over the full canonical def, so the content_hash is
58
+ * stable regardless of the on-disk split. Closes the skill_define → reload roundtrip (audit E).
59
+ * The caller MUST pre-validate completeness (≥1 fixture + a code/reasoning half) — the loader
60
+ * hard-fails an incomplete package, so an incomplete write would crash the next genome load. */
61
+ export declare function sealSkillPackage(def: Record<string, unknown> & {
62
+ slug: string;
63
+ }, ledger: Ledger, genome_dir?: string): {
64
+ content_hash: string;
65
+ dependency_hash: string;
66
+ effective_hash: string;
67
+ };
@@ -0,0 +1,179 @@
1
+ // MCP-sole-writer + canonical identity sealing (the substrate-of-truth loop, O26).
2
+ // A definition's identity is its canonical hash chain (content → dependency → effective),
3
+ // NOT its bytes. sealAgentDefinition is the blessed write path: validate → hash → (when a
4
+ // genome_dir is given) write the content-addressed file AND append a ledger entry keyed
5
+ // standard_slug="agent_define", genome_hash=effective_hash. A hand-edited file with no
6
+ // such ledger entry is an orphan — no identity, outside the substrate.
7
+ import { writeFileSync, mkdirSync, existsSync, readFileSync } from "node:fs";
8
+ import { join } from "node:path";
9
+ import { randomUUID } from "node:crypto";
10
+ import { defineAgent } from "./composition.js";
11
+ import { canonJson, sha256Hex, effectiveHash, EMPTY_DEPENDENCY_HASH } from "./canonical_form.js";
12
+ import { LEDGER_SCHEMA_VERSION } from "./ledger.js";
13
+ /**
14
+ * Write a genome file, preserving any prior version's BYTES before a destructive
15
+ * overwrite. The ledger already keeps the content-hash *identity* of every seal;
16
+ * this keeps the actual prior *content*, so a re-compose / re-define / evolve over
17
+ * an existing slug is recoverable, not just provably-changed.
18
+ *
19
+ * When <subdir>/<slug>.json already exists with DIFFERENT bytes, the old bytes are
20
+ * snapshotted to .coltrane/history/<subdir>/<slug>/<oldContentHash>.json (gitignored,
21
+ * local) before the overwrite. Identical bytes → no snapshot (idempotent no-op).
22
+ * Returns the prior content hash when an overwrite displaced real content.
23
+ */
24
+ export function writeGenomeFileVersioned(genome_dir, subdir, slug, jsonText) {
25
+ const dir = join(genome_dir, subdir);
26
+ mkdirSync(dir, { recursive: true });
27
+ const path = join(dir, `${slug}.json`);
28
+ let result = { overwritten: false };
29
+ if (existsSync(path)) {
30
+ const oldBytes = readFileSync(path, "utf-8");
31
+ if (oldBytes !== jsonText) {
32
+ const prior = sha256Hex(oldBytes);
33
+ const histDir = join(genome_dir, ".coltrane", "history", subdir, slug);
34
+ mkdirSync(histDir, { recursive: true });
35
+ writeFileSync(join(histDir, `${prior}.json`), oldBytes);
36
+ result = { overwritten: true, prior_content_hash: prior };
37
+ }
38
+ }
39
+ writeFileSync(path, jsonText);
40
+ return result;
41
+ }
42
+ /** Generic substrate seal for ANY genome definition (agent / standard / type / skill).
43
+ * Computes the canonical identity, and when a genome_dir is given, writes the
44
+ * content-addressed file under <subdir>/<slug>.json AND appends the ledger seal keyed
45
+ * standard_slug=<kind>, genome_hash=effective_hash. The single blessed write path. */
46
+ export function sealDefinition(kind, slug, def, ledger, genome_dir, subdir) {
47
+ const content_hash = sha256Hex(canonJson(def));
48
+ const dependency_hash = EMPTY_DEPENDENCY_HASH;
49
+ const effective_hash = effectiveHash(content_hash, dependency_hash);
50
+ if (genome_dir) {
51
+ // #218 — SEAL BEFORE WRITE. The reverse order manufactures the exact orphan this module's
52
+ // header calls "outside the substrate": if the append throws (ENOSPC/EACCES — the
53
+ // LedgerError path at src/ledger.ts), the definition is already on disk and loadable with
54
+ // no identity, while dispatchTool tells the caller nothing happened. Recording an identity
55
+ // whose file failed to materialise is the safe direction: the next write retries, and the
56
+ // ledger never claims less than reality.
57
+ const now = new Date().toISOString();
58
+ ledger.append({
59
+ kind: "genome_mutation",
60
+ schema_version: LEDGER_SCHEMA_VERSION,
61
+ entry_id: `${kind}:${slug}:${randomUUID()}`,
62
+ event: kind,
63
+ subject_slug: slug,
64
+ content_hash,
65
+ dependency_hash,
66
+ effective_hash,
67
+ output_hashes: [content_hash],
68
+ started_at: now,
69
+ finished_at: now,
70
+ });
71
+ writeGenomeFileVersioned(genome_dir, subdir, slug, JSON.stringify(def, null, 2) + "\n");
72
+ }
73
+ return { content_hash, dependency_hash, effective_hash };
74
+ }
75
+ /** Ledger-only identity seal — for version-producing mutations (type_extend, agent_evolve)
76
+ * whose new-version FILE materialization needs version-aware loader support (the one named
77
+ * boundary). The identity is still sealed in the append-only ledger, so the mutation is
78
+ * never a contract lie: its effective_hash is recorded even before the file lands. */
79
+ export function recordIdentity(kind, slug, def, ledger) {
80
+ const content_hash = sha256Hex(canonJson(def));
81
+ const dependency_hash = EMPTY_DEPENDENCY_HASH;
82
+ const effective_hash = effectiveHash(content_hash, dependency_hash);
83
+ const now = new Date().toISOString();
84
+ ledger.append({
85
+ kind: "genome_mutation",
86
+ schema_version: LEDGER_SCHEMA_VERSION,
87
+ entry_id: `${kind}:${slug}:${randomUUID()}`,
88
+ event: kind,
89
+ subject_slug: slug,
90
+ content_hash,
91
+ dependency_hash,
92
+ effective_hash,
93
+ output_hashes: [content_hash],
94
+ started_at: now,
95
+ finished_at: now,
96
+ });
97
+ return { content_hash, dependency_hash, effective_hash };
98
+ }
99
+ /** The canonical identity of an agent definition. PURE + deterministic from the def, so
100
+ * the same input always yields the same effective_hash (cross-machine interoperable). */
101
+ export function agentIdentity(def) {
102
+ const content_hash = sha256Hex(canonJson(def)); // canonical JSON → stable across formatting
103
+ const dependency_hash = EMPTY_DEPENDENCY_HASH; // v0: dependency closure (referenced types) is the next layer
104
+ const effective_hash = effectiveHash(content_hash, dependency_hash);
105
+ return { content_hash, dependency_hash, effective_hash };
106
+ }
107
+ /** Validate, hash, and (when a genome_dir is provided) PERSIST + LEDGER-SEAL. Without a
108
+ * genome_dir the identity is still computed + returned (validation path); with one, the
109
+ * agent is written to agents/<slug>.json and the effective_hash is recorded in the
110
+ * append-only ledger — the only way an agent enters the substrate of truth. */
111
+ export function sealAgentDefinition(def, ledger, genome_dir) {
112
+ const agent = defineAgent(def); // composition-rule validation (throws on illegal pipeline)
113
+ const { content_hash, dependency_hash, effective_hash } = agentIdentity(def);
114
+ if (genome_dir) {
115
+ // #218 — seal before write (see sealDefinition).
116
+ const now = new Date().toISOString();
117
+ ledger.append({
118
+ kind: "genome_mutation",
119
+ schema_version: LEDGER_SCHEMA_VERSION,
120
+ entry_id: `agent_define:${def.slug}:${randomUUID()}`,
121
+ event: "agent_define",
122
+ subject_slug: def.slug,
123
+ content_hash,
124
+ dependency_hash,
125
+ effective_hash, // the agent's identity claim
126
+ output_hashes: [content_hash],
127
+ started_at: now,
128
+ finished_at: now,
129
+ });
130
+ writeGenomeFileVersioned(genome_dir, "agents", def.slug, JSON.stringify(def, null, 2) + "\n");
131
+ }
132
+ return { agent, content_hash, dependency_hash, effective_hash };
133
+ }
134
+ /** Persist a skill as the LOADABLE PACKAGE the loader reads — skills/<slug>/{meta.json, skill.mjs?,
135
+ * skill.md?, fixtures/*.json} — not a flat skills/<slug>.json the loader skips. The content fields
136
+ * (`code` → skill.mjs, `md` → skill.md) and each fixture become their own files; meta.json holds the
137
+ * remaining declared fields. Identity is hashed over the full canonical def, so the content_hash is
138
+ * stable regardless of the on-disk split. Closes the skill_define → reload roundtrip (audit E).
139
+ * The caller MUST pre-validate completeness (≥1 fixture + a code/reasoning half) — the loader
140
+ * hard-fails an incomplete package, so an incomplete write would crash the next genome load. */
141
+ export function sealSkillPackage(def, ledger, genome_dir) {
142
+ const content_hash = sha256Hex(canonJson(def));
143
+ const dependency_hash = EMPTY_DEPENDENCY_HASH;
144
+ const effective_hash = effectiveHash(content_hash, dependency_hash);
145
+ if (genome_dir) {
146
+ // #218 — seal before write. This helper is the worst offender in the reverse order: it
147
+ // materialises meta.json, skill.mjs, skill.md and every fixture before appending, so a
148
+ // failed append left a PARTIAL package plus no identity.
149
+ const sealedAt = new Date().toISOString();
150
+ ledger.append({
151
+ kind: "genome_mutation",
152
+ schema_version: LEDGER_SCHEMA_VERSION,
153
+ entry_id: `skill_define:${def.slug}:${randomUUID()}`,
154
+ event: "skill_define",
155
+ subject_slug: def.slug,
156
+ content_hash,
157
+ dependency_hash,
158
+ effective_hash,
159
+ output_hashes: [content_hash],
160
+ started_at: sealedAt,
161
+ finished_at: sealedAt,
162
+ });
163
+ const pkgDir = join(genome_dir, "skills", def.slug);
164
+ mkdirSync(pkgDir, { recursive: true });
165
+ const { fixtures, code, md, ...meta } = def;
166
+ writeFileSync(join(pkgDir, "meta.json"), JSON.stringify(meta, null, 2) + "\n");
167
+ if (typeof code === "string")
168
+ writeFileSync(join(pkgDir, "skill.mjs"), code);
169
+ if (typeof md === "string")
170
+ writeFileSync(join(pkgDir, "skill.md"), md);
171
+ if (Array.isArray(fixtures)) {
172
+ const fxDir = join(pkgDir, "fixtures");
173
+ mkdirSync(fxDir, { recursive: true });
174
+ fixtures.forEach((fx, i) => writeFileSync(join(fxDir, `fixture-${String(i + 1).padStart(3, "0")}.json`), JSON.stringify(fx, null, 2) + "\n"));
175
+ }
176
+ }
177
+ return { content_hash, dependency_hash, effective_hash };
178
+ }
179
+ //# sourceMappingURL=genome_writer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"genome_writer.js","sourceRoot":"","sources":["../../src/genome_writer.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,0FAA0F;AAC1F,0FAA0F;AAC1F,wFAAwF;AACxF,uFAAuF;AACvF,uEAAuE;AACvE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,YAA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AAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CACjH,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC;AAC3D,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { type Tone, type Chord, type Resolution, type Arity } from "./tones.js";
2
+ export type ToneMap = Readonly<Record<string, Tone>>;
3
+ export declare const DEFAULT_TONE_MAP: ToneMap;
4
+ export interface SongStep {
5
+ agent_slug: string;
6
+ primitives: readonly string[];
7
+ phase?: string | undefined;
8
+ }
9
+ export interface AgentChord {
10
+ agent_slug: string;
11
+ chord: Chord;
12
+ arity: Arity;
13
+ consonance: number;
14
+ }
15
+ export interface GigSong {
16
+ steps: AgentChord[];
17
+ progression: Chord[];
18
+ resolution: Resolution;
19
+ }
20
+ /** Sound one agent: its primitives → a chord (unknown primitives are dropped). */
21
+ export declare function stepToChord(step: SongStep, toneOf?: ToneMap): Chord;
22
+ /** Encode an ordered gig trajectory into a song (progression + resolution). */
23
+ export declare function gigToSong(steps: readonly SongStep[], toneOf?: ToneMap): GigSong;
24
+ /** Render a gig-song to a JSONG observation tick-log — one tick per agent-chord.
25
+ * Minimal v0 state packing: index 4 (the C/coherence slot) carries the chord's
26
+ * consonance; score = consonance; slug = agent. The full 59-dim fingerprint
27
+ * packing is the research-lane concern, deferred — this stays honest about what
28
+ * it fills. */
29
+ export declare function songToJsong(song: GigSong, gigId?: Uint8Array): Uint8Array;
@@ -0,0 +1,56 @@
1
+ // gig_song — "the sim plays the gig." Encodes a gig's trajectory (its ordered
2
+ // agents, each composed of cognitive primitives) into a chord PROGRESSION, then
3
+ // renders that to a JSONG observation tick-log. This is the generative bridge:
4
+ // engine (gigs/agents/primitives/outputs) → song-substrate (tones/chords) → jsong.
5
+ //
6
+ // The primitive→tone map is a PARAMETER, not a baked-in truth — the song is one
7
+ // read of three, and which tone a primitive sounds as is a spec decision, passed
8
+ // in (DEFAULT_TONE_MAP is a sensible diatonic default, overridable). Output is
9
+ // STRUCTURE (progression + resolution + per-step chords), never a scalar verdict.
10
+ import { chordConsonance, chordArity, resolve } from "./tones.js";
11
+ import { writeAll, emptyState, ROLE_OBSERVATION, FLAG_MUSICAL } from "./jsong.js";
12
+ export const DEFAULT_TONE_MAP = {
13
+ SENSE: 0, INTERPRET: 2, JUDGE: 4, PLAN: 5, CREATE: 7, VERIFY: 9,
14
+ };
15
+ /** Sound one agent: its primitives → a chord (unknown primitives are dropped). */
16
+ export function stepToChord(step, toneOf = DEFAULT_TONE_MAP) {
17
+ const tones = [];
18
+ for (const p of step.primitives) {
19
+ const t = toneOf[p];
20
+ if (typeof t === "number")
21
+ tones.push(t);
22
+ }
23
+ return tones;
24
+ }
25
+ /** Encode an ordered gig trajectory into a song (progression + resolution). */
26
+ export function gigToSong(steps, toneOf = DEFAULT_TONE_MAP) {
27
+ const stepsOut = steps.map((s) => {
28
+ const chord = stepToChord(s, toneOf);
29
+ return { agent_slug: s.agent_slug, chord, arity: chordArity(chord), consonance: chordConsonance(chord) };
30
+ });
31
+ const progression = stepsOut.map((s) => s.chord);
32
+ return { steps: stepsOut, progression, resolution: resolve(progression) };
33
+ }
34
+ /** Render a gig-song to a JSONG observation tick-log — one tick per agent-chord.
35
+ * Minimal v0 state packing: index 4 (the C/coherence slot) carries the chord's
36
+ * consonance; score = consonance; slug = agent. The full 59-dim fingerprint
37
+ * packing is the research-lane concern, deferred — this stays honest about what
38
+ * it fills. */
39
+ export function songToJsong(song, gigId = new Uint8Array(16)) {
40
+ const header = { version: 0, gig_id: gigId, agent_id: new Uint8Array(16), start_us: 0n };
41
+ const ticks = song.steps.map((s, i) => {
42
+ const state = emptyState();
43
+ state[4] = s.consonance; // state_59[4] = C (coherence) per the JSONG canonical order
44
+ return {
45
+ tick_idx: i,
46
+ delta_us: 0,
47
+ role: ROLE_OBSERVATION,
48
+ flags: FLAG_MUSICAL,
49
+ state_59: state,
50
+ score: s.consonance,
51
+ slug: s.agent_slug,
52
+ };
53
+ });
54
+ return writeAll(header, ticks);
55
+ }
56
+ //# sourceMappingURL=gig_song.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gig_song.js","sourceRoot":"","sources":["../../src/gig_song.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,gFAAgF;AAChF,+EAA+E;AAC/E,mFAAmF;AACnF,EAAE;AACF,gFAAgF;AAChF,iFAAiF;AACjF,+EAA+E;AAC/E,kFAAkF;AAElF,OAAO,EAAyB,eAAe,EAAE,UAAU,EAAE,OAAO,EAA+B,MAAM,YAAY,CAAC;AACtH,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAoC,gBAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAKpH,MAAM,CAAC,MAAM,gBAAgB,GAAY;IACvC,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;CAChE,CAAC;AAwBF,kFAAkF;AAClF,MAAM,UAAU,WAAW,CAAC,IAAc,EAAE,SAAkB,gBAAgB;IAC5E,MAAM,KAAK,GAAW,EAAE,CAAC;IACzB,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;QAChC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,OAAO,CAAC,KAAK,QAAQ;YAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,SAAS,CAAC,KAA0B,EAAE,SAAkB,gBAAgB;IACtF,MAAM,QAAQ,GAAiB,K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C;IACH,OAAO,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,54 @@
1
+ import type { GigProgressEvent, BudgetState } from "./runtime.js";
2
+ import type { GigUsage } from "./ledger.js";
3
+ export interface GigChairState {
4
+ role: string;
5
+ phase: string;
6
+ status: "running" | "complete" | "failed";
7
+ producer?: string;
8
+ output_types?: string[];
9
+ duration_ms?: number;
10
+ tool_calls: string[];
11
+ error?: string;
12
+ }
13
+ /** The outcomes a tracked gig can reach. `aborted` is first-class (#251): without it a
14
+ * cancelled run could only surface as `failed` carrying a kill-shaped error string —
15
+ * indistinguishable from a genuine crash, which is the opposite of what an operator who
16
+ * just cancelled it needs to see. */
17
+ export type GigStatus = "running" | "complete" | "failed" | "aborted";
18
+ export interface GigRunState {
19
+ gig_id: string;
20
+ standard_slug: string;
21
+ status: GigStatus;
22
+ started_at: string;
23
+ finished_at?: string;
24
+ phases_total: number;
25
+ current_phase?: string;
26
+ phases_seen: string[];
27
+ chairs: Record<string, GigChairState>;
28
+ outputs_count: number;
29
+ run_fingerprint?: string;
30
+ genome_hash?: string;
31
+ error?: string;
32
+ usage?: GigUsage;
33
+ budget_state?: BudgetState;
34
+ controller?: AbortController | undefined;
35
+ /** An operator asked for this run to stop (set even when no controller could be reached). */
36
+ abort_requested?: boolean;
37
+ /** Why. Surfaced by gig_monitor so `aborted` reads as a decision, not a mystery. */
38
+ abort_reason?: string;
39
+ }
40
+ export declare function newGigRun(gig_id: string, standard_slug: string, phases_total: number, now: string): GigRunState;
41
+ export declare function applyGigProgress(state: GigRunState, ev: GigProgressEvent): void;
42
+ /**
43
+ * Retention bound for the live-run map (#253). `gig_runs` had three call sites and no
44
+ * `delete` — every dispatch added an entry retained for the server's lifetime, including
45
+ * per-chair `tool_calls` arrays that grow per call.
46
+ *
47
+ * Only SETTLED runs are eligible: a running gig's entry holds the AbortController, so
48
+ * pruning one would silently make that gig uncancellable — trading a memory leak for the
49
+ * very bug #249 is about. Oldest-settled-first, so the runs an operator is most likely to
50
+ * ask about survive. Returns how many were dropped.
51
+ */
52
+ export declare const DEFAULT_GIG_RUN_RETENTION = 200;
53
+ export declare function pruneGigRuns(runs: Map<string, GigRunState>, max?: number): number;
54
+ export declare function gigEventLogLine(gig_id: string, ev: GigProgressEvent): string | null;
@@ -0,0 +1,109 @@
1
+ // Live gig state — the coltrane-layer observability the async dispatcher exposes.
2
+ //
3
+ // gig_dispatch (async) starts a gig in the background and returns its id immediately; the
4
+ // runtime fires GigProgressEvents as it walks the phase graph; this module folds those into
5
+ // a GigRunState that gig_monitor reads. State is in-memory (per server lifetime): a restart
6
+ // drops in-flight tracking — acceptable for v0, and a restart mid-gig is its own problem.
7
+ export function newGigRun(gig_id, standard_slug, phases_total, now) {
8
+ return {
9
+ gig_id, standard_slug, status: "running", started_at: now,
10
+ phases_total, phases_seen: [], chairs: {}, outputs_count: 0,
11
+ };
12
+ }
13
+ // Fold one progress event into the state (mutating). Pure w.r.t. side effects — file/stderr
14
+ // teeing is the caller's job; this only updates the queryable snapshot.
15
+ export function applyGigProgress(state, ev) {
16
+ switch (ev.type) {
17
+ case "phase_start":
18
+ state.current_phase = ev.phase;
19
+ if (!state.phases_seen.includes(ev.phase))
20
+ state.phases_seen.push(ev.phase);
21
+ for (const role of ev.roles) {
22
+ if (!state.chairs[role])
23
+ state.chairs[role] = { role, phase: ev.phase, status: "running", tool_calls: [] };
24
+ }
25
+ break;
26
+ case "chair_start":
27
+ state.chairs[ev.role] = { role: ev.role, phase: ev.phase, status: "running", producer: ev.producer, tool_calls: [] };
28
+ break;
29
+ case "agent_event": {
30
+ const c = state.chairs[ev.role];
31
+ if (c && ev.event.type === "tool_use" && ev.event.tool)
32
+ c.tool_calls.push(ev.event.tool);
33
+ break;
34
+ }
35
+ case "chair_complete": {
36
+ const c = state.chairs[ev.role] ?? (state.chairs[ev.role] = { role: ev.role, phase: ev.phase, status: "running", tool_calls: [] });
37
+ c.status = "complete";
38
+ c.producer = ev.producer;
39
+ c.output_types = ev.output_types;
40
+ c.duration_ms = ev.duration_ms;
41
+ state.outputs_count += ev.output_types.length;
42
+ break;
43
+ }
44
+ case "chair_failed": {
45
+ const c = state.chairs[ev.role] ?? (state.chairs[ev.role] = { role: ev.role, phase: ev.phase, status: "running", tool_calls: [] });
46
+ c.status = "failed";
47
+ c.error = ev.error;
48
+ break;
49
+ }
50
+ case "gig_complete":
51
+ state.outputs_count = ev.outputs;
52
+ break;
53
+ case "gig_failed":
54
+ state.error = ev.error;
55
+ break;
56
+ case "gig_aborted":
57
+ // A cancelled run is not a crashed run. Recording it as its own terminal status is what
58
+ // lets gig_monitor answer "did my abort land?" instead of showing a kill-shaped error.
59
+ state.status = "aborted";
60
+ state.abort_reason = ev.reason;
61
+ state.finished_at ??= new Date().toISOString();
62
+ break;
63
+ }
64
+ }
65
+ /**
66
+ * Retention bound for the live-run map (#253). `gig_runs` had three call sites and no
67
+ * `delete` — every dispatch added an entry retained for the server's lifetime, including
68
+ * per-chair `tool_calls` arrays that grow per call.
69
+ *
70
+ * Only SETTLED runs are eligible: a running gig's entry holds the AbortController, so
71
+ * pruning one would silently make that gig uncancellable — trading a memory leak for the
72
+ * very bug #249 is about. Oldest-settled-first, so the runs an operator is most likely to
73
+ * ask about survive. Returns how many were dropped.
74
+ */
75
+ export const DEFAULT_GIG_RUN_RETENTION = 200;
76
+ export function pruneGigRuns(runs, max = DEFAULT_GIG_RUN_RETENTION) {
77
+ const settled = [...runs.values()].filter((s) => s.status !== "running");
78
+ if (settled.length <= max)
79
+ return 0;
80
+ const at = (s) => s.finished_at ?? s.started_at;
81
+ settled.sort((a, b) => (at(a) < at(b) ? -1 : at(a) > at(b) ? 1 : 0));
82
+ const drop = settled.slice(0, settled.length - max);
83
+ for (const s of drop)
84
+ runs.delete(s.gig_id);
85
+ return drop.length;
86
+ }
87
+ // A compact one-line summary of an event for the stderr/MCP log (skips per-token noise).
88
+ export function gigEventLogLine(gig_id, ev) {
89
+ const base = { t: new Date().toISOString(), gig: gig_id };
90
+ switch (ev.type) {
91
+ case "phase_start": return JSON.stringify({ ...base, ev: "phase_start", phase: ev.phase, chairs: ev.roles });
92
+ case "chair_start": return JSON.stringify({ ...base, ev: "chair_start", phase: ev.phase, role: ev.role, producer: ev.producer });
93
+ case "chair_complete": return JSON.stringify({ ...base, ev: "chair_complete", role: ev.role, sealed: ev.output_types, ms: ev.duration_ms });
94
+ case "chair_failed": return JSON.stringify({ ...base, ev: "chair_failed", role: ev.role, error: ev.error });
95
+ // #241 — a dangling (non-required) skill binding. Surfaced live because an unskilled run
96
+ // is otherwise indistinguishable from a skilled one: same genome_hash, run_fingerprint,
97
+ // content_sha. This log line is the only place the difference shows up while it happens.
98
+ case "skills_unresolved": return JSON.stringify({ ...base, ev: "skills_unresolved", phase: ev.phase, role: ev.role, agent: ev.agent, missing: ev.missing });
99
+ case "gig_complete": return JSON.stringify({ ...base, ev: "gig_complete", outputs: ev.outputs });
100
+ case "gig_failed": return JSON.stringify({ ...base, ev: "gig_failed", error: ev.error });
101
+ case "gig_aborted": return JSON.stringify({ ...base, ev: "gig_aborted", reason: ev.reason });
102
+ case "agent_event":
103
+ // only surface tool calls live, not every assistant token
104
+ return ev.event.type === "tool_use"
105
+ ? JSON.stringify({ ...base, ev: "tool_use", role: ev.role, tool: ev.event.tool })
106
+ : null;
107
+ }
108
+ }
109
+ //# sourceMappingURL=gig_tracker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gig_tracker.js","sourceRoot":"","sources":["../../src/gig_tracker.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,EAAE;AACF,0FAA0F;AAC1F,4FAA4F;AAC5F,4FAA4F;AAC5F,0FAA0F;AA0D1F,MAAM,UAAU,SAAS,CAAC,MAAc,EAAE,aAAqB,EAAE,YAAoB,EAAE,GAAW;IAChG,OAAO;QACL,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG;QACzD,YAAY,EAAE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AmB,CAAC,CAAC,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,mBAAmB,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5J,KAAK,cAAc,CAAC,CAAC,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,cAAc,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QACjG,KAAK,YAAY,CAAC,CAAC,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC;QACzF,KAAK,aAAa,CAAC,CAAC,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;QAC7F,KAAK,aAAa;YAChB,0DAA0D;YAC1D,OAAO,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,UAAU;gBACjC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;gBACjF,CAAC,CAAC,IAAI,CAAC;IACb,CAAC;AACH,CAAC"}
@@ -0,0 +1,11 @@
1
+ export interface SongReading {
2
+ resolution: number;
3
+ tonic: number;
4
+ density: number;
5
+ }
6
+ export declare function songChannel(r: SongReading): number[];
7
+ export declare function coupling(a: number[], b: number[]): number;
8
+ export declare function channelCoupling(channels: Record<string, number[]>): Array<{
9
+ pair: [string, string];
10
+ coupling: number;
11
+ }>;
@@ -0,0 +1,35 @@
1
+ // The song channel — ONE of three reads (score / output / song). It is a TENSOR, never a
2
+ // verdict: validation does not collapse to a scalar "truth." The signal is cross-channel
3
+ // COUPLING — real = the channels stay coupled (move together); illusion = they decouple
4
+ // (each looks internally fine, but they diverge from one another). This module produces the
5
+ // song channel's reading as a vector + the coupling structure. It does NOT judge, and never
6
+ // reduces the channels to one answer.
7
+ // the song channel as a vector — its slice of the validation tensor. never a verdict.
8
+ export function songChannel(r) {
9
+ return [r.resolution, r.tonic, r.density];
10
+ }
11
+ // pairwise coupling between two channel vectors (cosine: 1 = fully coupled, 0 = decoupled).
12
+ // a primitive — the SIGNAL is the full set of pairwise couplings preserved as structure,
13
+ // never reduced to one number.
14
+ export function coupling(a, b) {
15
+ const dot = a.reduce((s, x, i) => s + x * (b[i] ?? 0), 0);
16
+ const na = Math.sqrt(a.reduce((s, x) => s + x * x, 0));
17
+ const nb = Math.sqrt(b.reduce((s, x) => s + x * x, 0));
18
+ return na === 0 || nb === 0 ? 0 : dot / (na * nb);
19
+ }
20
+ // the coupling STRUCTURE across channels — every pair, preserved. an illusion shows as a
21
+ // pair that DECOUPLES while each channel stays internally fine; a real result keeps every
22
+ // pair coupled. returns the structure, never a collapsed verdict.
23
+ export function channelCoupling(channels) {
24
+ const names = Object.keys(channels);
25
+ const out = [];
26
+ for (let i = 0; i < names.length; i++) {
27
+ for (let j = i + 1; j < names.length; j++) {
28
+ const a = names[i];
29
+ const b = names[j];
30
+ out.push({ pair: [a, b], coupling: coupling(channels[a], channels[b]) });
31
+ }
32
+ }
33
+ return out;
34
+ }
35
+ //# sourceMappingURL=harmonic_validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"harmonic_validation.js","sourceRoot":"","sources":["../../src/harmonic_validation.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,yFAAyF;AACzF,wFAAwF;AACxF,4FAA4F;AAC5F,4FAA4F;AAC5F,sC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CAAC,EAAE,EAAE,CAAC;QACtC,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC1C,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;YACpB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;YACpB,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAE,EAAE,QAAQ,CAAC,CAAC,CAAE,CAAC,EAAE,CAAC,CAAC;QAC7E,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { ServerDeps, ToolResult } from "./server.js";
2
+ /** What a hook sees about the call it's wrapping. `args` is the CURRENT args — i.e. whatever a prior
3
+ * before-hook rewrote them to — so a later hook (and the impl) act on the threaded value. */
4
+ export interface ToolCallContext {
5
+ readonly slug: string;
6
+ readonly args: Record<string, unknown>;
7
+ readonly deps: ServerDeps;
8
+ /** the engine's own computed approval flag, for the hook to consult — NOT enforced by the engine. */
9
+ readonly requires_approval: boolean;
10
+ }
11
+ /** A before-hook either lets the call proceed (optionally rewriting args) or halts it with a result.
12
+ * `halt` means "the call never ran": the impl, the remaining before-hooks, and ALL after-hooks are
13
+ * skipped, and `result` is returned verbatim. */
14
+ export type PreOutcome = {
15
+ action: "continue";
16
+ args?: Record<string, unknown>;
17
+ } | {
18
+ action: "halt";
19
+ result: ToolResult;
20
+ };
21
+ /** A pre/post interceptor on dispatchTool. `name` is for diagnostics/telemetry only. A hook that
22
+ * throws fails the call CLOSED (a gate that errors must never let the call through). */
23
+ export interface ToolHook {
24
+ readonly name: string;
25
+ before?(ctx: ToolCallContext): Promise<PreOutcome> | PreOutcome;
26
+ after?(ctx: ToolCallContext, result: ToolResult): Promise<ToolResult> | ToolResult;
27
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/hooks.ts"],"names":[],"mappings":""}