@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.
- package/LICENSE +201 -0
- package/README.md +85 -0
- package/agents/anticipation-mapper.json +34 -0
- package/agents/claim-amender.json +34 -0
- package/agents/claim-architect.json +34 -0
- package/agents/claim-rewriter.json +32 -0
- package/agents/delivery-finalizer.json +40 -0
- package/agents/diamond-cutter.json +33 -0
- package/agents/disclosure-analyst.json +26 -0
- package/agents/domain-explorer.json +37 -0
- package/agents/e2e-runner.json +34 -0
- package/agents/e2e-suite-judge.json +26 -0
- package/agents/event-clusterer.json +29 -0
- package/agents/novelty-searcher.json +40 -0
- package/agents/patent-browser-scout.json +49 -0
- package/agents/patent-examiner.json +36 -0
- package/agents/phase_agents/claim-rewriter.md +44 -0
- package/agents/phase_agents/delivery-finalizer.md +30 -0
- package/agents/phase_agents/diamond-cutter.md +47 -0
- package/agents/phase_agents/domain-explorer.md +27 -0
- package/agents/phase_agents/novelty-searcher.md +50 -0
- package/agents/phase_agents/problem-definer.md +32 -0
- package/agents/phase_agents/solution-developer.md +26 -0
- package/agents/phase_agents/verdict-judger.md +70 -0
- package/agents/players/audience-modeler.md +40 -0
- package/agents/players/chain-audit-keeper.md +41 -0
- package/agents/players/illumination-reviewer.md +42 -0
- package/agents/players/methodology-cadence-keeper.md +42 -0
- package/agents/players/substrate-edge-keeper.md +45 -0
- package/agents/prior-art-scout.json +45 -0
- package/agents/problem-definer.json +35 -0
- package/agents/seeds/steve_seed_a.json +12 -0
- package/agents/seeds/steve_seed_b.json +12 -0
- package/agents/seeds/steve_seed_c.json +12 -0
- package/agents/seeds/steve_seed_d.json +12 -0
- package/agents/sensor.json +22 -0
- package/agents/solution-developer.json +35 -0
- package/agents/source-walker.json +38 -0
- package/agents/spec-drafter.json +31 -0
- package/agents/sub_thread_soft_judge.json +26 -0
- package/agents/sub_thread_trace_sensor.json +22 -0
- package/agents/summarizer.json +25 -0
- package/agents/synthesis-writer.json +29 -0
- package/agents/triage-judge.json +39 -0
- package/agents/user_flow_judge.json +26 -0
- package/agents/user_flow_sensor.json +22 -0
- package/agents/verdict-judger.json +39 -0
- package/core_types/artifact.json +17 -0
- package/core_types/interpretation.json +16 -0
- package/core_types/judgment.json +16 -0
- package/core_types/plan.json +16 -0
- package/core_types/signal.json +16 -0
- package/core_types/verdict.json +27 -0
- package/dist/src/access_grant.d.ts +46 -0
- package/dist/src/access_grant.js +76 -0
- package/dist/src/access_grant.js.map +1 -0
- package/dist/src/acoustics.d.ts +9 -0
- package/dist/src/acoustics.js +65 -0
- package/dist/src/acoustics.js.map +1 -0
- package/dist/src/agent_profile.d.ts +36 -0
- package/dist/src/agent_profile.js +57 -0
- package/dist/src/agent_profile.js.map +1 -0
- package/dist/src/bifrost_invoker.d.ts +33 -0
- package/dist/src/bifrost_invoker.js +85 -0
- package/dist/src/bifrost_invoker.js.map +1 -0
- package/dist/src/canonical_core_types.d.ts +2 -0
- package/dist/src/canonical_core_types.js +111 -0
- package/dist/src/canonical_core_types.js.map +1 -0
- package/dist/src/canonical_form.d.ts +55 -0
- package/dist/src/canonical_form.js +93 -0
- package/dist/src/canonical_form.js.map +1 -0
- package/dist/src/charter.d.ts +37 -0
- package/dist/src/charter.js +86 -0
- package/dist/src/charter.js.map +1 -0
- package/dist/src/circle_of_fifths.d.ts +27 -0
- package/dist/src/circle_of_fifths.js +78 -0
- package/dist/src/circle_of_fifths.js.map +1 -0
- package/dist/src/claude_invoker.d.ts +102 -0
- package/dist/src/claude_invoker.js +760 -0
- package/dist/src/claude_invoker.js.map +1 -0
- package/dist/src/coltrane_profile.d.ts +87 -0
- package/dist/src/coltrane_profile.js +132 -0
- package/dist/src/coltrane_profile.js.map +1 -0
- package/dist/src/composition.d.ts +57 -0
- package/dist/src/composition.js +447 -0
- package/dist/src/composition.js.map +1 -0
- package/dist/src/core_types.d.ts +6 -0
- package/dist/src/core_types.js +25 -0
- package/dist/src/core_types.js.map +1 -0
- package/dist/src/document_factory.d.ts +89 -0
- package/dist/src/document_factory.js +176 -0
- package/dist/src/document_factory.js.map +1 -0
- package/dist/src/genome_schema.d.ts +512 -0
- package/dist/src/genome_schema.js +168 -0
- package/dist/src/genome_schema.js.map +1 -0
- package/dist/src/genome_writer.d.ts +67 -0
- package/dist/src/genome_writer.js +179 -0
- package/dist/src/genome_writer.js.map +1 -0
- package/dist/src/gig_song.d.ts +29 -0
- package/dist/src/gig_song.js +56 -0
- package/dist/src/gig_song.js.map +1 -0
- package/dist/src/gig_tracker.d.ts +54 -0
- package/dist/src/gig_tracker.js +109 -0
- package/dist/src/gig_tracker.js.map +1 -0
- package/dist/src/harmonic_validation.d.ts +11 -0
- package/dist/src/harmonic_validation.js +35 -0
- package/dist/src/harmonic_validation.js.map +1 -0
- package/dist/src/hooks.d.ts +27 -0
- package/dist/src/hooks.js +2 -0
- package/dist/src/hooks.js.map +1 -0
- package/dist/src/index.d.ts +36 -0
- package/dist/src/index.js +37 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/jsong.d.ts +47 -0
- package/dist/src/jsong.js +130 -0
- package/dist/src/jsong.js.map +1 -0
- package/dist/src/judges/user_flow_judge.d.ts +89 -0
- package/dist/src/judges/user_flow_judge.js +200 -0
- package/dist/src/judges/user_flow_judge.js.map +1 -0
- package/dist/src/learner.d.ts +37 -0
- package/dist/src/learner.js +30 -0
- package/dist/src/learner.js.map +1 -0
- package/dist/src/ledger.d.ts +225 -0
- package/dist/src/ledger.js +306 -0
- package/dist/src/ledger.js.map +1 -0
- package/dist/src/loader.d.ts +87 -0
- package/dist/src/loader.js +504 -0
- package/dist/src/loader.js.map +1 -0
- package/dist/src/mcp.d.ts +23 -0
- package/dist/src/mcp.js +125 -0
- package/dist/src/mcp.js.map +1 -0
- package/dist/src/modulation_path.d.ts +42 -0
- package/dist/src/modulation_path.js +60 -0
- package/dist/src/modulation_path.js.map +1 -0
- package/dist/src/output_validation.d.ts +19 -0
- package/dist/src/output_validation.js +51 -0
- package/dist/src/output_validation.js.map +1 -0
- package/dist/src/outputs.d.ts +125 -0
- package/dist/src/outputs.js +452 -0
- package/dist/src/outputs.js.map +1 -0
- package/dist/src/overtones.d.ts +42 -0
- package/dist/src/overtones.js +98 -0
- package/dist/src/overtones.js.map +1 -0
- package/dist/src/player_to_claude_code.d.ts +17 -0
- package/dist/src/player_to_claude_code.js +141 -0
- package/dist/src/player_to_claude_code.js.map +1 -0
- package/dist/src/playwright_cage.d.ts +28 -0
- package/dist/src/playwright_cage.js +47 -0
- package/dist/src/playwright_cage.js.map +1 -0
- package/dist/src/polyphony.d.ts +46 -0
- package/dist/src/polyphony.js +91 -0
- package/dist/src/polyphony.js.map +1 -0
- package/dist/src/portfolio.d.ts +52 -0
- package/dist/src/portfolio.js +186 -0
- package/dist/src/portfolio.js.map +1 -0
- package/dist/src/pricing.d.ts +23 -0
- package/dist/src/pricing.js +16 -0
- package/dist/src/pricing.js.map +1 -0
- package/dist/src/registry.d.ts +46 -0
- package/dist/src/registry.js +199 -0
- package/dist/src/registry.js.map +1 -0
- package/dist/src/runtime.d.ts +304 -0
- package/dist/src/runtime.js +1099 -0
- package/dist/src/runtime.js.map +1 -0
- package/dist/src/server.d.ts +88 -0
- package/dist/src/server.js +1692 -0
- package/dist/src/server.js.map +1 -0
- package/dist/src/server_entry.d.ts +2 -0
- package/dist/src/server_entry.js +40 -0
- package/dist/src/server_entry.js.map +1 -0
- package/dist/src/server_relay.d.ts +82 -0
- package/dist/src/server_relay.js +341 -0
- package/dist/src/server_relay.js.map +1 -0
- package/dist/src/simulate.d.ts +60 -0
- package/dist/src/simulate.js +72 -0
- package/dist/src/simulate.js.map +1 -0
- package/dist/src/skill_runner.mjs +34 -0
- package/dist/src/skill_subprocess.d.ts +65 -0
- package/dist/src/skill_subprocess.js +132 -0
- package/dist/src/skill_subprocess.js.map +1 -0
- package/dist/src/skills.d.ts +85 -0
- package/dist/src/skills.js +258 -0
- package/dist/src/skills.js.map +1 -0
- package/dist/src/subthread_recorder.d.ts +68 -0
- package/dist/src/subthread_recorder.js +166 -0
- package/dist/src/subthread_recorder.js.map +1 -0
- package/dist/src/tensor_read.d.ts +38 -0
- package/dist/src/tensor_read.js +60 -0
- package/dist/src/tensor_read.js.map +1 -0
- package/dist/src/test_honest_broker.d.ts +34 -0
- package/dist/src/test_honest_broker.js +155 -0
- package/dist/src/test_honest_broker.js.map +1 -0
- package/dist/src/test_topology.d.ts +22 -0
- package/dist/src/test_topology.js +137 -0
- package/dist/src/test_topology.js.map +1 -0
- package/dist/src/tones.d.ts +20 -0
- package/dist/src/tones.js +81 -0
- package/dist/src/tones.js.map +1 -0
- package/dist/src/tool_providers.d.ts +45 -0
- package/dist/src/tool_providers.js +104 -0
- package/dist/src/tool_providers.js.map +1 -0
- package/dist/src/type_versioning.d.ts +23 -0
- package/dist/src/type_versioning.js +31 -0
- package/dist/src/type_versioning.js.map +1 -0
- package/dist/src/version.d.ts +28 -0
- package/dist/src/version.js +86 -0
- package/dist/src/version.js.map +1 -0
- package/domain_types/claim-draft.json +34 -0
- package/domain_types/coverage-report.json +31 -0
- package/domain_types/draft-agent-profile.json +31 -0
- package/domain_types/draft-domain-type.json +28 -0
- package/domain_types/draft-standard.json +46 -0
- package/domain_types/e2e-observation.json +32 -0
- package/domain_types/e2e-report.json +30 -0
- package/domain_types/e2e-target.json +26 -0
- package/domain_types/e2e-verdict.json +26 -0
- package/domain_types/examine-round-record.json +40 -0
- package/domain_types/examiner-rejection.json +28 -0
- package/domain_types/failure-modes.json +31 -0
- package/domain_types/invention-analysis.json +34 -0
- package/domain_types/invention-spec.json +34 -0
- package/domain_types/novelty-analysis.json +28 -0
- package/domain_types/novelty-verdict.json +35 -0
- package/domain_types/parsed-conversation-trace.json +38 -0
- package/domain_types/pattern-extraction.json +62 -0
- package/domain_types/prior-art-hit.json +50 -0
- package/domain_types/project-charter.json +71 -0
- package/domain_types/provisional-draft.json +34 -0
- package/domain_types/raw-note.json +19 -0
- package/domain_types/repo-survey.json +28 -0
- package/domain_types/seeding-verdict.json +70 -0
- package/domain_types/soft-verdict.json +55 -0
- package/domain_types/summary.json +19 -0
- package/domain_types/triage-verdict.json +59 -0
- package/domain_types/user-flow-transcript.json +43 -0
- package/domain_types/user-flow-verdict.json +60 -0
- package/domain_types/verdict-record.json +39 -0
- package/package.json +82 -0
- package/skills/citation-verify/fixtures/basic.json +14 -0
- package/skills/citation-verify/meta.json +10 -0
- package/skills/citation-verify/skill.mjs +26 -0
- package/skills/claim-element-decompose/fixtures/basic.json +11 -0
- package/skills/claim-element-decompose/meta.json +10 -0
- package/skills/claim-element-decompose/skill.mjs +14 -0
- package/skills/diamond-cutting-discipline/fixtures/basic.json +13 -0
- package/skills/diamond-cutting-discipline/meta.json +19 -0
- package/skills/diamond-cutting-discipline/skill.md +46 -0
- package/skills/element-mapping-matrix/fixtures/basic.json +13 -0
- package/skills/element-mapping-matrix/meta.json +10 -0
- package/skills/element-mapping-matrix/skill.mjs +20 -0
- package/skills/number-adder/fixtures/basic.json +9 -0
- package/skills/number-adder/meta.json +10 -0
- package/skills/number-adder/skill.mjs +12 -0
- package/skills/patent-fetch/fixtures/parse.json +18 -0
- package/skills/patent-fetch/meta.json +11 -0
- package/skills/patent-fetch/skill.mjs +34 -0
- package/skills/query-expand/fixtures/basic.json +14 -0
- package/skills/query-expand/meta.json +10 -0
- package/skills/query-expand/skill.mjs +29 -0
- package/skills/run-vitest-band/fixtures/basic.json +9 -0
- package/skills/run-vitest-band/meta.json +18 -0
- package/skills/run-vitest-band/skill.mjs +22 -0
- package/skills/statutory-checklist/fixtures/basic.json +16 -0
- package/skills/statutory-checklist/meta.json +10 -0
- package/skills/statutory-checklist/skill.mjs +25 -0
- package/skills/summarize-tight/fixtures/basic.json +13 -0
- package/skills/summarize-tight/meta.json +20 -0
- package/skills/summarize-tight/skill.md +1 -0
- package/skills/verdict-gate/fixtures/basic.json +9 -0
- package/skills/verdict-gate/meta.json +10 -0
- package/skills/verdict-gate/skill.mjs +82 -0
- package/standards/e2e-suite-v0.json +44 -0
- package/standards/patent-triage-v0.json +98 -0
- package/standards/patent-triage-v1.json +84 -0
- package/standards/seed-from-local-repos-v0.json +115 -0
- package/standards/sub_thread_invocation.json +50 -0
- package/standards/summarize.json +40 -0
- package/standards/synthesis-walk-v0.json +108 -0
- package/standards/user_flow_correctness.json +57 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server_relay.js","sourceRoot":"","sources":["../../src/server_relay.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,EAAE;AACF,6EAA6E;AAC7E,0EAA0E;AAC1E,+EAA+E;AAC/E,4EAA4E;AAC5E,4EAA4E;AAC5E,gBAAgB;AAChB,EAAE;AACF,2EAA2E;AAC3E,4EAA4E;AAC5E,yEAAyE;AACzE,+CAA+C;AAC/C,EAAE;AACF,cAAc;AACd,qEAAqE;AACrE,qCAAqC;AACrC,2EAA2E;AAC3E,8EAA8E;AAC9E,qCAAqC;AACrC,yEAAyE;AACzE,2DAA2D;AAC3D,EAAE;AACF,6EAA6E;AAC7E,0EAA0E;AAC1E,mDAAmD;AAEnD,OAAO,EAAE,KAAK,EAA4B,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAKhD,MAAM,mBAAmB,GAAG;IAC1B,IAAI,EAAE,gBAAgB;IACtB,WAAW,EACT,+KAA+K;IACjL,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,EAAE;QACd,oBAAoB,EAAE,KAAK;KAC5B;CACF,CAAC;AAWF;;;;GAIG;AACH,SAAS,UAAU,CAAC,SAAiB;IACnC,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,SAAS,CAAC,EAAE;QAC1C,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC;QAClC,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,sBAAsB,EAAE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AM,CAAC;YACP,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAC3B,OAAO;QACT,CAAC;QACD,IAAI,GAAG,EAAE,CAAC;YACR,mFAAmF;YACnF,IAAI,GAAG,CAAC,MAAM,KAAK,YAAY;gBAAE,UAAU,GAAG,IAAI,CAAC;iBAC9C,IAAI,GAAG,CAAC,MAAM,KAAK,2BAA2B;gBAAE,iBAAiB,GAAG,IAAI,CAAC;YAE9E,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;YAC1C,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;gBAC5B,kFAAkF;gBAClF,mFAAmF;gBACnF,oFAAoF;gBACpF,KAAK,YAAY,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;oBACnC,MAAM,KAAK,GAAG,OAAO,CAAC,EAAE;wBACtB,CAAC,CAAC,oBAAoB,CAAC,SAAS,CAAC;wBACjC,CAAC,CAAC,iBAAiB,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;oBACjD,IAAI,CAAC,OAAO,CAAC,EAAE;wBAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,oCAAoC,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;oBAC9F,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;gBACrD,CAAC,CAAC,CAAC;gBACH,OAAO;YACT,CAAC;QACH,CAAC;QACD,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,gDAAgD;IAChD,MAAM,IAAI,OAAO,CAAO,GAAG,EAAE;QAC3B,4CAA4C;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Depth, ModelTier } from "./pricing.js";
|
|
2
|
+
/** The structural facts a simulation needs about the standard it is simulating. A projection,
|
|
3
|
+
* not the Standard itself, so this module stays free of the composition layer. */
|
|
4
|
+
export interface SimulatedStandardShape {
|
|
5
|
+
slug: string;
|
|
6
|
+
phases: readonly {
|
|
7
|
+
name: string;
|
|
8
|
+
chairs: number;
|
|
9
|
+
}[];
|
|
10
|
+
}
|
|
11
|
+
export interface SimulateQuery {
|
|
12
|
+
standard_slug: string;
|
|
13
|
+
mock_input: Record<string, unknown>;
|
|
14
|
+
depth: Depth;
|
|
15
|
+
model_tier?: ModelTier;
|
|
16
|
+
agent_count?: number;
|
|
17
|
+
base_cost_usd?: number;
|
|
18
|
+
base_duration_ms?: number;
|
|
19
|
+
/**
|
|
20
|
+
* #239 — the standard being simulated. Without it `standardSimulate` received only a SLUG,
|
|
21
|
+
* so it could not read the thing it was estimating: the 6-phase submission-convergence came
|
|
22
|
+
* back as three invented phases named sense/process/deliver. The caller reads it out of the
|
|
23
|
+
* genome and passes it here.
|
|
24
|
+
*/
|
|
25
|
+
standard?: SimulatedStandardShape | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Settled per-run costs (USD) previously observed for this standard, from the ledger's gig
|
|
28
|
+
* rows (#195). When present these ARE the estimate — a measured mean beats any formula.
|
|
29
|
+
*/
|
|
30
|
+
observed_costs_usd?: readonly number[] | undefined;
|
|
31
|
+
}
|
|
32
|
+
export interface SimulatedPhase {
|
|
33
|
+
name: string;
|
|
34
|
+
/** How many chairs this phase dispatches. 0 when the standard could not be read. */
|
|
35
|
+
chairs: number;
|
|
36
|
+
estimated_cost: number;
|
|
37
|
+
estimated_duration_ms: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Where the number came from. The pre-spend check CLAUDE.md tells operators to run before
|
|
41
|
+
* dispatching has to say which of these it is, or a guess reads like a reading:
|
|
42
|
+
* observed — mean of real settled runs of this standard, depth-adjusted
|
|
43
|
+
* structural — derived from this standard's real phases + chair count
|
|
44
|
+
* fallback — no standard resolvable; a per-slug default, i.e. a guess
|
|
45
|
+
*/
|
|
46
|
+
export type SimulationBasis = "observed" | "structural" | "fallback";
|
|
47
|
+
export interface SimulationResult {
|
|
48
|
+
phases: readonly SimulatedPhase[];
|
|
49
|
+
estimated_cost: number;
|
|
50
|
+
estimated_duration_ms: number;
|
|
51
|
+
basis: SimulationBasis;
|
|
52
|
+
/** How many real runs the `observed` estimate averaged. 0 for the other bases. */
|
|
53
|
+
sample_size: number;
|
|
54
|
+
}
|
|
55
|
+
/** Structural per-chair cost, USD, at depth=standard/tier=standard. A documented constant,
|
|
56
|
+
* not a measurement — which is why a structural estimate is labelled `structural`. */
|
|
57
|
+
export declare const PER_CHAIR_BASE_COST_USD = 0.6;
|
|
58
|
+
/** Structural per-chair wall clock, ms, at depth=standard. Same caveat. */
|
|
59
|
+
export declare const PER_CHAIR_BASE_DURATION_MS = 30000;
|
|
60
|
+
export declare function standardSimulate(q: SimulateQuery): SimulationResult;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { DEPTH_MULTIPLIER, MODEL_MULTIPLIER } from "./pricing.js";
|
|
2
|
+
// Retained ONLY as the no-standard fallback (see SimulationBasis.fallback). These are the
|
|
3
|
+
// original hardcoded lookups; they are no longer the primary path, and a result computed from
|
|
4
|
+
// them is labelled `fallback` so no caller mistakes one for a reading of their pipeline.
|
|
5
|
+
const KNOWN_BASE_COST = {
|
|
6
|
+
"readiness-scan": 0.95,
|
|
7
|
+
"bug-fix": 1.0,
|
|
8
|
+
"feature-build": 12.0,
|
|
9
|
+
};
|
|
10
|
+
const KNOWN_PHASES = {
|
|
11
|
+
"readiness-scan": ["sense", "interpret", "report"],
|
|
12
|
+
};
|
|
13
|
+
/** Structural per-chair cost, USD, at depth=standard/tier=standard. A documented constant,
|
|
14
|
+
* not a measurement — which is why a structural estimate is labelled `structural`. */
|
|
15
|
+
export const PER_CHAIR_BASE_COST_USD = 0.6;
|
|
16
|
+
/** Structural per-chair wall clock, ms, at depth=standard. Same caveat. */
|
|
17
|
+
export const PER_CHAIR_BASE_DURATION_MS = 30_000;
|
|
18
|
+
export function standardSimulate(q) {
|
|
19
|
+
const tier = q.model_tier ?? "standard";
|
|
20
|
+
const depthMult = DEPTH_MULTIPLIER[q.depth];
|
|
21
|
+
const tierMult = MODEL_MULTIPLIER[tier];
|
|
22
|
+
// Phase shape: the standard's own phases when we can read it, the per-slug fallback otherwise.
|
|
23
|
+
const phaseShapes = q.standard
|
|
24
|
+
? q.standard.phases.map((p) => ({ name: p.name, chairs: p.chairs }))
|
|
25
|
+
: (KNOWN_PHASES[q.standard_slug] ?? ["sense", "process", "deliver"]).map((name) => ({ name, chairs: 0 }));
|
|
26
|
+
const chairTotal = phaseShapes.reduce((s, p) => s + p.chairs, 0);
|
|
27
|
+
// Cost. Observed history wins; then the standard's real size; then the per-slug default.
|
|
28
|
+
const observed = (q.observed_costs_usd ?? []).filter((n) => Number.isFinite(n) && n > 0);
|
|
29
|
+
let basis;
|
|
30
|
+
let baseCost;
|
|
31
|
+
if (q.base_cost_usd !== undefined) {
|
|
32
|
+
// An explicit caller-supplied base is honoured, and honestly labelled by what it describes.
|
|
33
|
+
basis = q.standard ? "structural" : "fallback";
|
|
34
|
+
baseCost = q.base_cost_usd;
|
|
35
|
+
}
|
|
36
|
+
else if (observed.length > 0) {
|
|
37
|
+
basis = "observed";
|
|
38
|
+
// Observed runs are already depth-and-tier-inclusive of whatever depth they RAN at; we have
|
|
39
|
+
// no per-run depth on the ledger, so normalise to depth=standard and let the multipliers
|
|
40
|
+
// re-apply. Honest about being an approximation — it is still a measurement of this pipeline.
|
|
41
|
+
baseCost = observed.reduce((s, n) => s + n, 0) / observed.length;
|
|
42
|
+
}
|
|
43
|
+
else if (q.standard) {
|
|
44
|
+
basis = "structural";
|
|
45
|
+
baseCost = Math.max(chairTotal, 1) * PER_CHAIR_BASE_COST_USD;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
basis = "fallback";
|
|
49
|
+
baseCost = KNOWN_BASE_COST[q.standard_slug] ?? 1.0;
|
|
50
|
+
}
|
|
51
|
+
const baseDuration = q.base_duration_ms
|
|
52
|
+
?? (q.standard ? Math.max(phaseShapes.length, 1) * PER_CHAIR_BASE_DURATION_MS : 30_000);
|
|
53
|
+
const totalCost = baseCost * depthMult * tierMult;
|
|
54
|
+
const totalDuration = baseDuration * depthMult;
|
|
55
|
+
const n = Math.max(phaseShapes.length, 1);
|
|
56
|
+
// Spread cost by chair count when we know it (a 3-chair phase costs more than a 1-chair one);
|
|
57
|
+
// evenly when we don't.
|
|
58
|
+
const phases = phaseShapes.map((p) => ({
|
|
59
|
+
name: p.name,
|
|
60
|
+
chairs: p.chairs,
|
|
61
|
+
estimated_cost: chairTotal > 0 ? (totalCost * p.chairs) / chairTotal : totalCost / n,
|
|
62
|
+
estimated_duration_ms: totalDuration / n,
|
|
63
|
+
}));
|
|
64
|
+
return {
|
|
65
|
+
phases,
|
|
66
|
+
estimated_cost: totalCost,
|
|
67
|
+
estimated_duration_ms: totalDuration,
|
|
68
|
+
basis,
|
|
69
|
+
sample_size: basis === "observed" ? observed.length : 0,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=simulate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simulate.js","sourceRoot":"","sources":["../../src/simulate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAyDlE,0FAA0F;AAC1F,8FAA8F;AAC9F,yFAAyF;AACzF,MAAM,eAAe,GAA2B;IAC9C,gBAAgB,EAAE,IAAI;IACtB,SAAS,EAAE,GAAG;IACd,eAAe,EAAE,IAAI;CACtB,CAAC;AAEF,MAAM,YAAY,GAA6B;IAC7C,gBAAgB,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,CAAC;CACnD,CAAC;AAEF;uFACuF;AACvF,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,2EAA2E;A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G,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACvD,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,cAAc,EAAE,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC;QACpF,qBAAqB,EAAE,aAAa,GAAG,CAAC;KACzC,CAAC,CAAC,CAAC;IAEJ,OAAO;QACL,MAAM;QACN,cAAc,EAAE,SAAS;QACzB,qBAAqB,EAAE,aAAa;QACpC,KAAK;QACL,WAAW,EAAE,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;KACxD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Skill runner — the child harness executed under Node's --permission sandbox.
|
|
2
|
+
//
|
|
3
|
+
// The parent (skill_subprocess.ts) spawns:
|
|
4
|
+
// node --permission --allow-fs-read=* [tier flags] skill_runner.mjs <skill-dir>
|
|
5
|
+
// and pipes the input as JSON on stdin. This harness imports the skill's execution
|
|
6
|
+
// half, calls run(input), and writes {ok, output} (or {ok:false, error}) to stdout.
|
|
7
|
+
//
|
|
8
|
+
// stdin/stdout are not gated by the permission model; fs/child/net are — so a tier-0
|
|
9
|
+
// skill can read its own code + inputs but cannot write, spawn, or reach the network.
|
|
10
|
+
import { argv, stdin, stdout, exit } from "node:process";
|
|
11
|
+
import { pathToFileURL } from "node:url";
|
|
12
|
+
import { join, isAbsolute, resolve } from "node:path";
|
|
13
|
+
|
|
14
|
+
const skillDir = argv[2];
|
|
15
|
+
|
|
16
|
+
async function main() {
|
|
17
|
+
let raw = "";
|
|
18
|
+
for await (const chunk of stdin) raw += chunk;
|
|
19
|
+
const input = raw.trim() ? JSON.parse(raw) : {};
|
|
20
|
+
|
|
21
|
+
const dir = isAbsolute(skillDir) ? skillDir : resolve(skillDir);
|
|
22
|
+
const mod = await import(pathToFileURL(join(dir, "skill.mjs")).href);
|
|
23
|
+
const run = mod.default ?? mod.run;
|
|
24
|
+
if (typeof run !== "function") {
|
|
25
|
+
throw new Error(`skill at ${skillDir} exports no default run() function`);
|
|
26
|
+
}
|
|
27
|
+
const output = await run(input);
|
|
28
|
+
stdout.write(JSON.stringify({ ok: true, output }));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
main().catch((e) => {
|
|
32
|
+
stdout.write(JSON.stringify({ ok: false, error: String(e?.message ?? e) }));
|
|
33
|
+
exit(1);
|
|
34
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export interface SkillMeta {
|
|
2
|
+
slug: string;
|
|
3
|
+
version: number;
|
|
4
|
+
skill_type?: string;
|
|
5
|
+
input_type?: string;
|
|
6
|
+
output_type?: string;
|
|
7
|
+
determinism_ratio?: number;
|
|
8
|
+
permission?: {
|
|
9
|
+
tier?: number;
|
|
10
|
+
};
|
|
11
|
+
/** Per-skill execution ceiling. Caps the caller-supplied timeout (whichever is smaller). */
|
|
12
|
+
timeout_ms?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface SkillFixture {
|
|
15
|
+
id: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
input: unknown;
|
|
18
|
+
expected_output?: unknown;
|
|
19
|
+
assertions?: {
|
|
20
|
+
path: string;
|
|
21
|
+
op: string;
|
|
22
|
+
value?: unknown;
|
|
23
|
+
}[];
|
|
24
|
+
}
|
|
25
|
+
export interface ExecuteResult {
|
|
26
|
+
ok: boolean;
|
|
27
|
+
output?: unknown;
|
|
28
|
+
error?: string;
|
|
29
|
+
duration_ms: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Permission tier → Node --permission flags. Tier 0 is read-only with no side effects
|
|
33
|
+
* (can load its own code + read inputs, but cannot write, spawn, or reach the network).
|
|
34
|
+
* Higher tiers add write, then child_process (needed by skills that shell out, e.g.
|
|
35
|
+
* run-vitest-band). The grant IS the enforcement — a skill can do only what its tier allows.
|
|
36
|
+
*/
|
|
37
|
+
export declare function tierFlags(tier: number): string[];
|
|
38
|
+
export declare function readSkillMeta(skillDir: string): SkillMeta;
|
|
39
|
+
export declare function loadFixtures(skillDir: string): SkillFixture[];
|
|
40
|
+
/** Run a skill's execution half in a permission-scoped subprocess. `tierOverride` runs the
|
|
41
|
+
* skill at a tier other than its declared one — used by the cage matrix to exercise one
|
|
42
|
+
* capability probe across every tier. */
|
|
43
|
+
export declare function executeSkill(skillDir: string, input: unknown, timeoutMs?: number, tierOverride?: number): ExecuteResult;
|
|
44
|
+
export interface FixtureResult {
|
|
45
|
+
id: string;
|
|
46
|
+
passed: boolean;
|
|
47
|
+
stable: boolean;
|
|
48
|
+
error?: string;
|
|
49
|
+
}
|
|
50
|
+
export interface FixtureReport {
|
|
51
|
+
skill: string;
|
|
52
|
+
total: number;
|
|
53
|
+
passed: number;
|
|
54
|
+
pass_rate: number;
|
|
55
|
+
deterministic: boolean;
|
|
56
|
+
determinism_runs: number;
|
|
57
|
+
results: FixtureResult[];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Run every fixture for a skill. Each fixture is executed DETERMINISM_RUNS times: the first
|
|
61
|
+
* run is checked against expected_output + assertions (the test suite + evolution gate); all
|
|
62
|
+
* runs must produce identical output (the determinism meter). A pure skill is green +
|
|
63
|
+
* deterministic; a candidate skill.mjs that regresses a fixture fails here — the gate.
|
|
64
|
+
*/
|
|
65
|
+
export declare function runSkillFixtures(skillDir: string): FixtureReport;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// Skill execution + the fixture/determinism runner (skills as first-class, Phase 1 —
|
|
2
|
+
// docs/skills-as-first-class.md). A skill package is a directory:
|
|
3
|
+
// skills/<slug>/ { meta.json, skill.mjs, fixtures/*.json }
|
|
4
|
+
// The execution half runs in a Node --permission subprocess scoped by the skill's
|
|
5
|
+
// permission tier (the Node analog of the old Deno --allow cage). Fixtures are the
|
|
6
|
+
// load-bearing instrument: they are the skill's test suite, the determinism meter
|
|
7
|
+
// (stable across repeated runs), AND the evolution gate (an improved skill.mjs is
|
|
8
|
+
// accepted only if every fixture still passes).
|
|
9
|
+
import { spawnSync } from "node:child_process";
|
|
10
|
+
import { readFileSync, readdirSync, existsSync } from "node:fs";
|
|
11
|
+
import { join, extname } from "node:path";
|
|
12
|
+
import { fileURLToPath } from "node:url";
|
|
13
|
+
const RUNNER = fileURLToPath(new URL("./skill_runner.mjs", import.meta.url));
|
|
14
|
+
/**
|
|
15
|
+
* Permission tier → Node --permission flags. Tier 0 is read-only with no side effects
|
|
16
|
+
* (can load its own code + read inputs, but cannot write, spawn, or reach the network).
|
|
17
|
+
* Higher tiers add write, then child_process (needed by skills that shell out, e.g.
|
|
18
|
+
* run-vitest-band). The grant IS the enforcement — a skill can do only what its tier allows.
|
|
19
|
+
*/
|
|
20
|
+
export function tierFlags(tier) {
|
|
21
|
+
const flags = ["--permission", "--allow-fs-read=*"];
|
|
22
|
+
if (tier >= 1)
|
|
23
|
+
flags.push("--allow-fs-write=*");
|
|
24
|
+
if (tier >= 2)
|
|
25
|
+
flags.push("--allow-child-process");
|
|
26
|
+
return flags;
|
|
27
|
+
}
|
|
28
|
+
export function readSkillMeta(skillDir) {
|
|
29
|
+
return JSON.parse(readFileSync(join(skillDir, "meta.json"), "utf-8"));
|
|
30
|
+
}
|
|
31
|
+
export function loadFixtures(skillDir) {
|
|
32
|
+
const dir = join(skillDir, "fixtures");
|
|
33
|
+
if (!existsSync(dir))
|
|
34
|
+
return [];
|
|
35
|
+
return readdirSync(dir)
|
|
36
|
+
.filter((f) => extname(f) === ".json")
|
|
37
|
+
.sort()
|
|
38
|
+
.map((f) => JSON.parse(readFileSync(join(dir, f), "utf-8")));
|
|
39
|
+
}
|
|
40
|
+
/** Run a skill's execution half in a permission-scoped subprocess. `tierOverride` runs the
|
|
41
|
+
* skill at a tier other than its declared one — used by the cage matrix to exercise one
|
|
42
|
+
* capability probe across every tier. */
|
|
43
|
+
export function executeSkill(skillDir, input, timeoutMs = 120_000, tierOverride) {
|
|
44
|
+
const meta = readSkillMeta(skillDir);
|
|
45
|
+
const tier = tierOverride ?? (meta.permission?.tier ?? 0);
|
|
46
|
+
// the skill's own meta.timeout_ms caps the caller's timeout — a runaway code half can't
|
|
47
|
+
// outlive its declared budget. SIGKILL (not the default SIGTERM) is the kill signal so a
|
|
48
|
+
// SIGTERM-trapping child can't survive the timeout.
|
|
49
|
+
const timeout = typeof meta.timeout_ms === "number" ? Math.min(timeoutMs, meta.timeout_ms) : timeoutMs;
|
|
50
|
+
const started = Date.now();
|
|
51
|
+
const res = spawnSync("node", [...tierFlags(tier), RUNNER, skillDir], {
|
|
52
|
+
input: JSON.stringify(input),
|
|
53
|
+
encoding: "utf-8",
|
|
54
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
55
|
+
timeout,
|
|
56
|
+
killSignal: "SIGKILL",
|
|
57
|
+
});
|
|
58
|
+
const duration_ms = Date.now() - started;
|
|
59
|
+
if (res.error)
|
|
60
|
+
return { ok: false, error: String(res.error.message), duration_ms };
|
|
61
|
+
try {
|
|
62
|
+
const parsed = JSON.parse(res.stdout);
|
|
63
|
+
return { ...parsed, duration_ms };
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return { ok: false, error: `unparseable skill output: ${(res.stdout || res.stderr || "").slice(0, 300)}`, duration_ms };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function getPath(obj, path) {
|
|
70
|
+
return path.split(".").reduce((acc, k) => (acc != null ? acc[k] : undefined), obj);
|
|
71
|
+
}
|
|
72
|
+
function checkAssertion(output, a) {
|
|
73
|
+
const v = getPath(output, a.path);
|
|
74
|
+
switch (a.op) {
|
|
75
|
+
case "exists": return v !== undefined && v !== null;
|
|
76
|
+
case "is_number": return typeof v === "number";
|
|
77
|
+
case "is_string": return typeof v === "string";
|
|
78
|
+
case "is_boolean": return typeof v === "boolean";
|
|
79
|
+
case "equals": return JSON.stringify(v) === JSON.stringify(a.value);
|
|
80
|
+
default: return false;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function deepEqual(a, b) {
|
|
84
|
+
return JSON.stringify(canon(a)) === JSON.stringify(canon(b));
|
|
85
|
+
}
|
|
86
|
+
function canon(v) {
|
|
87
|
+
if (Array.isArray(v))
|
|
88
|
+
return v.map(canon);
|
|
89
|
+
if (v && typeof v === "object") {
|
|
90
|
+
return Object.fromEntries(Object.keys(v).sort().map((k) => [k, canon(v[k])]));
|
|
91
|
+
}
|
|
92
|
+
return v;
|
|
93
|
+
}
|
|
94
|
+
// How many times each fixture runs to read determinism. >=3 so a coincidentally-stable pair
|
|
95
|
+
// can't pass as deterministic — a flaky skill that happens to agree twice gets caught.
|
|
96
|
+
const DETERMINISM_RUNS = 3;
|
|
97
|
+
/**
|
|
98
|
+
* Run every fixture for a skill. Each fixture is executed DETERMINISM_RUNS times: the first
|
|
99
|
+
* run is checked against expected_output + assertions (the test suite + evolution gate); all
|
|
100
|
+
* runs must produce identical output (the determinism meter). A pure skill is green +
|
|
101
|
+
* deterministic; a candidate skill.mjs that regresses a fixture fails here — the gate.
|
|
102
|
+
*/
|
|
103
|
+
export function runSkillFixtures(skillDir) {
|
|
104
|
+
const slug = readSkillMeta(skillDir).slug;
|
|
105
|
+
const fixtures = loadFixtures(skillDir);
|
|
106
|
+
const results = [];
|
|
107
|
+
let passed = 0;
|
|
108
|
+
let deterministic = true;
|
|
109
|
+
for (const fx of fixtures) {
|
|
110
|
+
const runs = Array.from({ length: DETERMINISM_RUNS }, () => executeSkill(skillDir, fx.input));
|
|
111
|
+
const r1 = runs[0];
|
|
112
|
+
const stable = runs.every((r) => r.ok) && runs.every((r) => deepEqual(r.output, r1.output));
|
|
113
|
+
const matchesExpected = fx.expected_output === undefined || deepEqual(r1.output, fx.expected_output);
|
|
114
|
+
const assertionsHold = (fx.assertions ?? []).every((a) => checkAssertion(r1.output, a));
|
|
115
|
+
const ok = r1.ok && matchesExpected && assertionsHold;
|
|
116
|
+
if (ok)
|
|
117
|
+
passed++;
|
|
118
|
+
if (!stable)
|
|
119
|
+
deterministic = false;
|
|
120
|
+
results.push({ id: fx.id, passed: ok, stable, ...(r1.ok ? {} : { error: r1.error }) });
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
skill: slug,
|
|
124
|
+
total: fixtures.length,
|
|
125
|
+
passed,
|
|
126
|
+
pass_rate: fixtures.length ? passed / fixtures.length : 0,
|
|
127
|
+
deterministic,
|
|
128
|
+
determinism_runs: DETERMINISM_RUNS,
|
|
129
|
+
results,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=skill_subprocess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill_subprocess.js","sourceRoot":"","sources":["../../src/skill_subprocess.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,kEAAkE;AAClE,6DAA6D;AAC7D,kFAAkF;AAClF,mFAAmF;AACnF,kFAAkF;AAClF,kFAAkF;AAClF,gDAAgD;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,oBAAoB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AA6B7E;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,MAAM,KAAK,GAAG,CAAC,cAAc,EAAE,mBAAmB,CAAC,CAAC;IACpD,IAAI,IAAI,IAAI,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,oBAAo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cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;QACxF,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,eAAe,IAAI,cAAc,CAAC;QACtD,IAAI,EAAE;YAAE,MAAM,EAAE,CAAC;QACjB,IAAI,CAAC,MAAM;YAAE,aAAa,GAAG,KAAK,CAAC;QACnC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;IACzF,CAAC;IAED,OAAO;QACL,KAAK,EAAE,IAAI;QACX,KAAK,EAAE,QAAQ,CAAC,MAAM;QACtB,MAAM;QACN,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACzD,aAAa;QACb,gBAAgB,EAAE,gBAAgB;QAClC,OAAO;KACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { type SkillMeta, type SkillFixture, type ExecuteResult } from "./skill_subprocess.js";
|
|
2
|
+
export { executeSkill, runSkillFixtures, loadFixtures, readSkillMeta, tierFlags, type SkillMeta, type SkillFixture, type ExecuteResult, type FixtureReport, type FixtureResult, } from "./skill_subprocess.js";
|
|
3
|
+
export declare class SkillLoadError extends Error {
|
|
4
|
+
}
|
|
5
|
+
export declare class SkillCompositionCycleError extends Error {
|
|
6
|
+
}
|
|
7
|
+
export declare const CODE_HASH_ALGO = "sha256";
|
|
8
|
+
export declare function hashSkillCode(codePath: string): string;
|
|
9
|
+
export interface SkillPackage {
|
|
10
|
+
dir: string;
|
|
11
|
+
meta: SkillMeta & {
|
|
12
|
+
code_hash?: string;
|
|
13
|
+
composable_with?: readonly string[];
|
|
14
|
+
input_schema?: Record<string, unknown>;
|
|
15
|
+
output_schema?: Record<string, unknown>;
|
|
16
|
+
};
|
|
17
|
+
codeHash: string | null;
|
|
18
|
+
fixtures: SkillFixture[];
|
|
19
|
+
mdPath: string | null;
|
|
20
|
+
}
|
|
21
|
+
/** Load a skill package: meta + code (content-hashed) + fixtures + the reasoning half.
|
|
22
|
+
* A malformed package (unreadable/sluggless meta, bad fixture shape) raises SkillLoadError;
|
|
23
|
+
* an ABSENT code half is allowed (codeHash null) — that degrades to pure reasoning at run. */
|
|
24
|
+
export declare function loadSkillPackage(dir: string): SkillPackage;
|
|
25
|
+
export type FieldOrigin = "code" | "model";
|
|
26
|
+
export interface ResolutionResult {
|
|
27
|
+
output: Record<string, unknown>;
|
|
28
|
+
resolved: Record<string, unknown>;
|
|
29
|
+
residual: string[];
|
|
30
|
+
field_origins: Record<string, FieldOrigin>;
|
|
31
|
+
degraded?: {
|
|
32
|
+
reason: string;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export type ResidualInvoker = (ctx: {
|
|
36
|
+
unresolved: readonly string[];
|
|
37
|
+
resolved: Record<string, unknown>;
|
|
38
|
+
md: string;
|
|
39
|
+
}) => Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
40
|
+
/** Options for resolution + chain recording. `chainDir` isolates the durable chain so
|
|
41
|
+
* tests (and consumers) can point it at a scratch location instead of ambient state. */
|
|
42
|
+
export interface SkillChainOpts {
|
|
43
|
+
chainDir?: string;
|
|
44
|
+
}
|
|
45
|
+
/** Run code first, compute the residual, let the model fill only the gap, tag origins.
|
|
46
|
+
* When `opts.chainDir` is set, append a SkillChainEvent recording this resolution. */
|
|
47
|
+
export declare function resolveSkill(dir: string, input: unknown, invoke: ResidualInvoker, opts?: SkillChainOpts): Promise<ResolutionResult>;
|
|
48
|
+
export interface SkillChainEvent {
|
|
49
|
+
slug: string;
|
|
50
|
+
version: number;
|
|
51
|
+
code_hash: string;
|
|
52
|
+
tier: number;
|
|
53
|
+
duration_ms: number;
|
|
54
|
+
permission_violations: string[];
|
|
55
|
+
field_origins: Record<string, FieldOrigin>;
|
|
56
|
+
degraded_reason?: string;
|
|
57
|
+
}
|
|
58
|
+
/** Read the recorded resolution events for a skill+version — the log determinism reads from. */
|
|
59
|
+
export declare function skillChainEvents(slug: string, version?: number, opts?: SkillChainOpts): SkillChainEvent[];
|
|
60
|
+
export interface DeterminismReport {
|
|
61
|
+
slug: string;
|
|
62
|
+
version: number;
|
|
63
|
+
ratio: number;
|
|
64
|
+
window: number;
|
|
65
|
+
samples: number;
|
|
66
|
+
}
|
|
67
|
+
export declare function computeDeterminismRatio(slug: string, version: number, opts?: SkillChainOpts & {
|
|
68
|
+
window?: number;
|
|
69
|
+
}): DeterminismReport;
|
|
70
|
+
export interface EvolutionVerdict {
|
|
71
|
+
accepted: boolean;
|
|
72
|
+
failing_fixtures: string[];
|
|
73
|
+
}
|
|
74
|
+
/** Run a candidate skill.mjs against the package's fixtures; accept iff none regress. The
|
|
75
|
+
* fixtures are the evolution gate: an "improvement" that breaks any committed contract is
|
|
76
|
+
* rejected, and the broken fixtures are named. */
|
|
77
|
+
export declare function evolveSkill(dir: string, candidateCodePath: string): EvolutionVerdict;
|
|
78
|
+
export interface CompositionResult {
|
|
79
|
+
order: string[];
|
|
80
|
+
merged_residual: string[];
|
|
81
|
+
}
|
|
82
|
+
/** Compose multiple skills for one chair: validate composable_with, order by deps,
|
|
83
|
+
* detect cycles (SkillCompositionCycleError), merge the residual. */
|
|
84
|
+
export declare function composeSkills(dirs: readonly string[]): CompositionResult;
|
|
85
|
+
export type { ExecuteResult as _ExecuteResult };
|