harnery 0.30.0 → 0.31.1
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/README.md +4 -4
- package/dist/commander.d.ts +8 -0
- package/dist/commander.d.ts.map +1 -1
- package/dist/commander.js +14 -13
- package/dist/commands/adapter.d.ts +12 -0
- package/dist/commands/adapter.d.ts.map +1 -0
- package/dist/commands/{harness.js → adapter.js} +35 -35
- package/dist/commands/agents.d.ts +3 -2
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +185 -74
- package/dist/commands/artifacts.d.ts +4 -0
- package/dist/commands/artifacts.d.ts.map +1 -0
- package/dist/commands/artifacts.js +143 -0
- package/dist/commands/backup.d.ts +1 -1
- package/dist/commands/backup.d.ts.map +1 -1
- package/dist/commands/backup.js +5 -2
- package/dist/commands/browse.d.ts.map +1 -1
- package/dist/commands/browse.js +310 -7
- package/dist/commands/checkpoint.d.ts +12 -0
- package/dist/commands/checkpoint.d.ts.map +1 -0
- package/dist/commands/checkpoint.js +162 -0
- package/dist/commands/context.d.ts +2 -2
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js +3 -151
- package/dist/commands/decision.d.ts.map +1 -1
- package/dist/commands/decision.js +31 -7
- package/dist/commands/deinit.d.ts +2 -2
- package/dist/commands/deinit.js +15 -15
- package/dist/commands/doctor.js +23 -23
- package/dist/commands/governor.d.ts +4 -0
- package/dist/commands/governor.d.ts.map +1 -0
- package/dist/commands/{supervisor.js → governor.js} +133 -108
- package/dist/commands/grep.d.ts +1 -1
- package/dist/commands/grep.d.ts.map +1 -1
- package/dist/commands/grep.js +19 -2
- package/dist/commands/init.d.ts +12 -12
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +44 -30
- package/dist/commands/{session.d.ts → journal.d.ts} +2 -2
- package/dist/commands/journal.d.ts.map +1 -0
- package/dist/commands/{scratch.js → journal.js} +47 -47
- package/dist/commands/policy.js +1 -1
- package/dist/commands/presence.js +2 -2
- package/dist/commands/sync.d.ts +1 -1
- package/dist/commands/sync.js +3 -3
- package/dist/commands/tunnel.d.ts +16 -0
- package/dist/commands/tunnel.d.ts.map +1 -1
- package/dist/commands/tunnel.js +213 -27
- package/dist/commands/web-fetch.js +1 -1
- package/dist/commands/web.d.ts +19 -0
- package/dist/commands/web.d.ts.map +1 -1
- package/dist/commands/web.js +51 -0
- package/dist/commands/work.d.ts.map +1 -1
- package/dist/commands/work.js +38 -22
- package/dist/commands/workflow.d.ts.map +1 -1
- package/dist/commands/workflow.js +35 -28
- package/dist/core/{harnesses → adapters}/attest-projection.d.ts +2 -2
- package/dist/core/adapters/attest-projection.d.ts.map +1 -0
- package/dist/core/{harnesses → adapters}/attest.d.ts +16 -16
- package/dist/core/adapters/attest.d.ts.map +1 -0
- package/dist/core/{harnesses → adapters}/attest.js +9 -9
- package/dist/core/{harnesses → adapters}/attestation.d.ts +16 -16
- package/dist/core/adapters/attestation.d.ts.map +1 -0
- package/dist/core/{harnesses → adapters}/attestation.js +20 -20
- package/dist/core/{harnesses → adapters}/bench.d.ts +12 -12
- package/dist/core/adapters/bench.d.ts.map +1 -0
- package/dist/core/{harnesses → adapters}/bench.js +12 -12
- package/dist/core/adapters/index.d.ts +13 -0
- package/dist/core/adapters/index.d.ts.map +1 -0
- package/dist/core/adapters/index.js +6 -0
- package/dist/core/{harnesses → adapters}/profiles.d.ts +11 -11
- package/dist/core/adapters/profiles.d.ts.map +1 -0
- package/dist/core/{harnesses → adapters}/profiles.js +11 -11
- package/dist/core/adapters/registry.d.ts +15 -0
- package/dist/core/adapters/registry.d.ts.map +1 -0
- package/dist/core/{harnesses → adapters}/registry.js +11 -11
- package/dist/core/{harnesses → adapters}/types.d.ts +23 -23
- package/dist/core/adapters/types.d.ts.map +1 -0
- package/dist/core/{harnesses → adapters}/types.js +1 -1
- package/dist/core/agents/canonical-emit.d.ts +9 -14
- package/dist/core/agents/canonical-emit.d.ts.map +1 -1
- package/dist/core/agents/canonical-emit.js +15 -44
- package/dist/core/agents/cli-emit.js +1 -1
- package/dist/core/agents/cli.js +30 -26
- package/dist/core/agents/codex-replay.d.ts +1 -1
- package/dist/core/agents/codex-replay.js +6 -6
- package/dist/core/agents/coord-bin.d.ts +33 -0
- package/dist/core/agents/coord-bin.d.ts.map +1 -0
- package/dist/core/agents/coord-bin.js +89 -0
- package/dist/core/agents/coord-client.d.ts +78 -8
- package/dist/core/agents/coord-client.d.ts.map +1 -1
- package/dist/core/agents/coord-client.js +303 -75
- package/dist/core/agents/events/consume.d.ts +1 -1
- package/dist/core/agents/events/emit.d.ts +5 -6
- package/dist/core/agents/events/emit.d.ts.map +1 -1
- package/dist/core/agents/events/emit.js +2 -2
- package/dist/core/agents/paths.d.ts +5 -2
- package/dist/core/agents/paths.d.ts.map +1 -1
- package/dist/core/agents/paths.js +7 -13
- package/dist/core/agents/render/prompt-context.d.ts +21 -9
- package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
- package/dist/core/agents/render/prompt-context.js +82 -30
- package/dist/core/agents/render/session-context.d.ts +1 -1
- package/dist/core/agents/render/session-context.js +5 -5
- package/dist/core/agents/rules/claim-conflict.d.ts +2 -6
- package/dist/core/agents/rules/claim-conflict.d.ts.map +1 -1
- package/dist/core/agents/rules/claim-conflict.js +1 -1
- package/dist/core/agents/rules/commit-conflict.js +98 -22
- package/dist/core/agents/rules/stop-hook.d.ts +9 -9
- package/dist/core/agents/rules/stop-hook.d.ts.map +1 -1
- package/dist/core/agents/rules/stop-hook.js +23 -5
- package/dist/core/agents/rules/verdict.d.ts +14 -0
- package/dist/core/agents/rules/verdict.d.ts.map +1 -0
- package/dist/core/agents/rules/verdict.js +1 -0
- package/dist/core/agents/session-events.js +3 -3
- package/dist/core/agents/state/council.d.ts +1 -1
- package/dist/core/agents/state/council.js +1 -1
- package/dist/core/agents/state/heartbeat-projector.d.ts +3 -2
- package/dist/core/agents/state/heartbeat-projector.d.ts.map +1 -1
- package/dist/core/agents/state/heartbeat-projector.js +14 -10
- package/dist/core/agents/state/heartbeat-writer.d.ts +1 -1
- package/dist/core/agents/state/heartbeat-writer.js +12 -12
- package/dist/core/agents/state/{scratch.d.ts → journal.d.ts} +7 -7
- package/dist/core/agents/state/{scratch.d.ts.map → journal.d.ts.map} +1 -1
- package/dist/core/agents/state/{scratch.js → journal.js} +12 -12
- package/dist/core/agents/state/pidmap.d.ts +28 -4
- package/dist/core/agents/state/pidmap.d.ts.map +1 -1
- package/dist/core/agents/state/pidmap.js +130 -15
- package/dist/core/agents/state/proc-start.d.ts +95 -0
- package/dist/core/agents/state/proc-start.d.ts.map +1 -0
- package/dist/core/agents/state/proc-start.js +199 -0
- package/dist/core/agents/state/shell-mutation.d.ts +1 -1
- package/dist/core/agents/state/shell-mutation.js +1 -1
- package/dist/core/agents/state/stale-sweep.js +7 -7
- package/dist/core/artifacts/index.d.ts +86 -0
- package/dist/core/artifacts/index.d.ts.map +1 -0
- package/dist/core/artifacts/index.js +421 -0
- package/dist/core/config.d.ts +9 -2
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +26 -2
- package/dist/core/context/index.d.ts +12 -12
- package/dist/core/context/index.js +10 -10
- package/dist/core/governor/adapter-spread.d.ts +52 -0
- package/dist/core/governor/adapter-spread.d.ts.map +1 -0
- package/dist/core/governor/adapter-spread.js +52 -0
- package/dist/core/governor/index.d.ts +7 -0
- package/dist/core/governor/index.d.ts.map +1 -0
- package/dist/core/governor/index.js +6 -0
- package/dist/core/governor/plan-api.d.ts +38 -0
- package/dist/core/governor/plan-api.d.ts.map +1 -0
- package/dist/core/governor/plan-api.js +83 -0
- package/dist/core/governor/plan-read.d.ts +5 -0
- package/dist/core/governor/plan-read.d.ts.map +1 -0
- package/dist/core/{supervisor → governor}/plan-read.js +66 -52
- package/dist/core/{supervisor → governor}/plan-types.d.ts +57 -56
- package/dist/core/governor/plan-types.d.ts.map +1 -0
- package/dist/core/{supervisor → governor}/plan-types.js +4 -4
- package/dist/core/governor/planning.d.ts +48 -0
- package/dist/core/governor/planning.d.ts.map +1 -0
- package/dist/core/{supervisor → governor}/planning.js +125 -94
- package/dist/core/governor/read.d.ts +6 -0
- package/dist/core/governor/read.d.ts.map +1 -0
- package/dist/core/governor/read.js +4 -0
- package/dist/core/governor/runner.d.ts +37 -0
- package/dist/core/governor/runner.d.ts.map +1 -0
- package/dist/core/{supervisor → governor}/runner.js +15 -15
- package/dist/core/governor/service-read.d.ts +6 -0
- package/dist/core/governor/service-read.d.ts.map +1 -0
- package/dist/core/{supervisor → governor}/service-read.js +12 -12
- package/dist/core/governor/service.d.ts +114 -0
- package/dist/core/governor/service.d.ts.map +1 -0
- package/dist/core/{supervisor → governor}/service.js +57 -57
- package/dist/core/governor/state.d.ts +116 -0
- package/dist/core/governor/state.d.ts.map +1 -0
- package/dist/core/{supervisor → governor}/state.js +228 -108
- package/dist/core/hooks/adapter/detect.d.ts +9 -0
- package/dist/core/hooks/{harness → adapter}/detect.d.ts.map +1 -1
- package/dist/core/hooks/{harness → adapter}/detect.js +8 -8
- package/dist/core/hooks/{harness → adapter}/events.d.ts +15 -14
- package/dist/core/hooks/adapter/events.d.ts.map +1 -0
- package/dist/core/hooks/{harness → adapter}/events.js +5 -5
- package/dist/core/hooks/{harness → adapter}/output.d.ts +20 -14
- package/dist/core/hooks/adapter/output.d.ts.map +1 -0
- package/dist/core/hooks/{harness → adapter}/output.js +30 -22
- package/dist/core/hooks/{harness → adapter}/parse.d.ts +5 -5
- package/dist/core/hooks/{harness → adapter}/parse.d.ts.map +1 -1
- package/dist/core/hooks/{harness → adapter}/parse.js +4 -4
- package/dist/core/hooks/{harness → adapter}/wiring.d.ts +15 -15
- package/dist/core/hooks/{harness → adapter}/wiring.d.ts.map +1 -1
- package/dist/core/hooks/{harness → adapter}/wiring.js +13 -13
- package/dist/core/hooks/cli.d.ts +3 -3
- package/dist/core/hooks/cli.js +187 -162
- package/dist/core/hooks/effects/image-capture.d.ts +5 -5
- package/dist/core/hooks/effects/image-capture.d.ts.map +1 -1
- package/dist/core/hooks/effects/image-capture.js +3 -3
- package/dist/core/hooks/effects/index.d.ts +12 -12
- package/dist/core/hooks/effects/index.d.ts.map +1 -1
- package/dist/core/hooks/effects/index.js +19 -19
- package/dist/core/hooks/events/emit.d.ts +2 -2
- package/dist/core/hooks/events/emit.d.ts.map +1 -1
- package/dist/core/hooks/events/emit.js +1 -1
- package/dist/core/hooks/events/rotate.js +1 -1
- package/dist/core/hooks/events/schema.d.ts +13 -5
- package/dist/core/hooks/events/schema.d.ts.map +1 -1
- package/dist/core/hooks/guard-path.d.ts +2 -2
- package/dist/core/hooks/guard-path.js +2 -2
- package/dist/core/hooks/index.d.ts +1 -1
- package/dist/core/hooks/index.d.ts.map +1 -1
- package/dist/core/hooks/resolve/anchor.d.ts +14 -5
- package/dist/core/hooks/resolve/anchor.d.ts.map +1 -1
- package/dist/core/hooks/resolve/anchor.js +64 -7
- package/dist/core/hooks/resolve/coord-root.d.ts +16 -11
- package/dist/core/hooks/resolve/coord-root.d.ts.map +1 -1
- package/dist/core/hooks/resolve/coord-root.js +18 -43
- package/dist/core/hooks/resolve/intent.js +1 -1
- package/dist/core/hooks/resolve/owner.d.ts +1 -1
- package/dist/core/hooks/resolve/owner.d.ts.map +1 -1
- package/dist/core/hooks/resolve/owner.js +11 -5
- package/dist/core/{scratch → journal}/index.d.ts +25 -25
- package/dist/core/{scratch → journal}/index.d.ts.map +1 -1
- package/dist/core/{scratch → journal}/index.js +38 -38
- package/dist/core/policy/evaluate.d.ts +1 -1
- package/dist/core/policy/evaluate.d.ts.map +1 -1
- package/dist/core/policy/evaluate.js +7 -7
- package/dist/core/policy/types.d.ts +3 -3
- package/dist/core/policy/types.d.ts.map +1 -1
- package/dist/core/work/state.d.ts +12 -4
- package/dist/core/work/state.d.ts.map +1 -1
- package/dist/core/work/state.js +50 -17
- package/dist/core/workflow/adapters.d.ts +17 -0
- package/dist/core/workflow/adapters.d.ts.map +1 -0
- package/dist/core/workflow/adapters.js +21 -0
- package/dist/core/workflow/approvals.js +6 -6
- package/dist/core/workflow/billing.d.ts +9 -9
- package/dist/core/workflow/billing.js +9 -9
- package/dist/core/workflow/child-env.d.ts +10 -2
- package/dist/core/workflow/child-env.d.ts.map +1 -1
- package/dist/core/workflow/child-env.js +12 -4
- package/dist/core/workflow/engine.d.ts +15 -5
- package/dist/core/workflow/engine.d.ts.map +1 -1
- package/dist/core/workflow/engine.js +138 -83
- package/dist/core/workflow/evidence-preflight.d.ts +24 -0
- package/dist/core/workflow/evidence-preflight.d.ts.map +1 -0
- package/dist/core/workflow/evidence-preflight.js +134 -0
- package/dist/core/workflow/index.d.ts +1 -1
- package/dist/core/workflow/index.d.ts.map +1 -1
- package/dist/core/workflow/proof.d.ts +11 -5
- package/dist/core/workflow/proof.d.ts.map +1 -1
- package/dist/core/workflow/proof.js +45 -36
- package/dist/core/workflow/run-state.d.ts +1 -1
- package/dist/core/workflow/run-state.js +7 -7
- package/dist/core/workflow/sandbox-projection.d.ts +6 -6
- package/dist/core/workflow/sandbox-projection.d.ts.map +1 -1
- package/dist/core/workflow/sandbox-projection.js +11 -11
- package/dist/core/workflow/spawn-claude.d.ts +3 -3
- package/dist/core/workflow/spawn-claude.d.ts.map +1 -1
- package/dist/core/workflow/spawn-claude.js +9 -6
- package/dist/core/workflow/spawn-codex.d.ts +4 -4
- package/dist/core/workflow/spawn-codex.d.ts.map +1 -1
- package/dist/core/workflow/spawn-codex.js +9 -6
- package/dist/core/workflow/spawn-cursor.d.ts +4 -4
- package/dist/core/workflow/spawn-cursor.d.ts.map +1 -1
- package/dist/core/workflow/spawn-cursor.js +9 -6
- package/dist/core/workflow/spawn-failure.d.ts +1 -1
- package/dist/core/workflow/spawn-failure.js +1 -1
- package/dist/core/workflow/specialists.js +2 -2
- package/dist/core/workflow/{journal.d.ts → transcript.d.ts} +8 -8
- package/dist/core/workflow/transcript.d.ts.map +1 -0
- package/dist/core/workflow/{journal.js → transcript.js} +14 -14
- package/dist/core/workflow/types.d.ts +98 -51
- package/dist/core/workflow/types.d.ts.map +1 -1
- package/dist/core/workflow/types.js +11 -1
- package/dist/core/workflow/validate.d.ts +1 -1
- package/dist/core/workflow/validate.js +1 -1
- package/dist/core/workflow/workspaces/cancellation.js +2 -2
- package/dist/core/workflow/workspaces/cleanup.js +2 -2
- package/dist/core/workflow/workspaces/execution.js +6 -6
- package/dist/core/workflow/workspaces/inspect.js +9 -9
- package/dist/core/workflow/workspaces/integration.js +14 -14
- package/dist/core/workflow/workspaces/lifecycle.d.ts +1 -1
- package/dist/core/workflow/workspaces/lifecycle.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/lifecycle.js +9 -9
- package/dist/core/workflow/workspaces/local-git.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/local-git.js +39 -5
- package/dist/core/workflow/workspaces/recovery.js +3 -3
- package/dist/core/workflow/workspaces/state.d.ts +1 -1
- package/dist/core/workflow/workspaces/state.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/state.js +3 -3
- package/dist/core/workflow/workspaces/types.d.ts +1 -1
- package/dist/core/workflow/workspaces/types.d.ts.map +1 -1
- package/dist/lib/browser/asserts.d.ts +28 -0
- package/dist/lib/browser/asserts.d.ts.map +1 -0
- package/dist/lib/browser/asserts.js +152 -0
- package/dist/lib/browser/client.d.ts +49 -0
- package/dist/lib/browser/client.d.ts.map +1 -1
- package/dist/lib/browser/client.js +155 -14
- package/dist/lib/browser/content-checks.d.ts +108 -0
- package/dist/lib/browser/content-checks.d.ts.map +1 -0
- package/dist/lib/browser/content-checks.js +474 -0
- package/dist/lib/browser/critique.d.ts +91 -0
- package/dist/lib/browser/critique.d.ts.map +1 -0
- package/dist/lib/browser/critique.js +167 -0
- package/dist/lib/browser/geometry.d.ts +32 -0
- package/dist/lib/browser/geometry.d.ts.map +1 -1
- package/dist/lib/browser/geometry.js +244 -1
- package/dist/lib/browser/index.d.ts +4 -1
- package/dist/lib/browser/index.d.ts.map +1 -1
- package/dist/lib/browser/index.js +2 -0
- package/dist/lib/claude-desktop.d.ts.map +1 -1
- package/dist/lib/claude-desktop.js +4 -1
- package/dist/lib/context/index.js +9 -2
- package/dist/lib/council/index.d.ts +6 -6
- package/dist/lib/council/index.d.ts.map +1 -1
- package/dist/lib/council/index.js +8 -8
- package/dist/lib/identities/assume.d.ts +2 -2
- package/dist/lib/identities/assume.js +7 -7
- package/dist/lib/instructions/apply.d.ts +3 -3
- package/dist/lib/instructions/apply.d.ts.map +1 -1
- package/dist/lib/instructions/apply.js +75 -27
- package/dist/lib/instructions/host-addendum.d.ts +54 -0
- package/dist/lib/instructions/host-addendum.d.ts.map +1 -0
- package/dist/lib/instructions/host-addendum.js +107 -0
- package/dist/lib/instructions/templates.d.ts +10 -3
- package/dist/lib/instructions/templates.d.ts.map +1 -1
- package/dist/lib/instructions/templates.js +41 -12
- package/dist/lib/machine.d.ts +2 -2
- package/dist/lib/machine.js +2 -2
- package/package.json +26 -21
- package/schemas/config.schema.json +26 -1
- package/src/commander.ts +22 -13
- package/src/commands/{harness.ts → adapter.ts} +46 -46
- package/src/commands/agents.ts +200 -78
- package/src/commands/artifacts.ts +168 -0
- package/src/commands/backup.ts +47 -33
- package/src/commands/browse.ts +438 -2
- package/src/commands/checkpoint.ts +196 -0
- package/src/commands/context.ts +3 -176
- package/src/commands/decision.ts +41 -7
- package/src/commands/deinit.ts +16 -16
- package/src/commands/doctor.ts +28 -28
- package/src/commands/{supervisor.ts → governor.ts} +184 -154
- package/src/commands/grep.ts +19 -2
- package/src/commands/init.ts +50 -34
- package/src/commands/{scratch.ts → journal.ts} +60 -60
- package/src/commands/policy.ts +1 -1
- package/src/commands/presence.ts +2 -2
- package/src/commands/sync.ts +3 -3
- package/src/commands/tunnel.ts +256 -38
- package/src/commands/web-fetch.ts +1 -1
- package/src/commands/web.ts +56 -1
- package/src/commands/work.ts +50 -35
- package/src/commands/workflow.ts +43 -34
- package/src/core/{harnesses → adapters}/attest-projection.ts +2 -2
- package/src/core/{harnesses → adapters}/attest.ts +27 -27
- package/src/core/{harnesses → adapters}/attestation.ts +41 -41
- package/src/core/{harnesses → adapters}/bench.ts +34 -43
- package/src/core/adapters/index.ts +56 -0
- package/src/core/{harnesses → adapters}/profiles.ts +16 -16
- package/src/core/{harnesses → adapters}/registry.ts +23 -23
- package/src/core/{harnesses → adapters}/types.ts +23 -23
- package/src/core/agents/canonical-emit.ts +16 -43
- package/src/core/agents/cli-emit.ts +1 -1
- package/src/core/agents/cli.ts +30 -28
- package/src/core/agents/codex-replay.ts +6 -6
- package/src/core/agents/coord-bin.ts +92 -0
- package/src/core/agents/coord-client.ts +302 -78
- package/src/core/agents/events/consume.ts +1 -1
- package/src/core/agents/events/emit.ts +7 -6
- package/src/core/agents/paths.ts +7 -11
- package/src/core/agents/render/prompt-context.ts +107 -31
- package/src/core/agents/render/session-context.ts +6 -6
- package/src/core/agents/rules/claim-conflict.ts +4 -7
- package/src/core/agents/rules/commit-conflict.ts +103 -22
- package/src/core/agents/rules/stop-hook.ts +33 -17
- package/src/core/agents/rules/verdict.ts +13 -0
- package/src/core/agents/session-events.ts +4 -4
- package/src/core/agents/state/council.ts +1 -1
- package/src/core/agents/state/heartbeat-projector.ts +16 -12
- package/src/core/agents/state/heartbeat-writer.ts +12 -12
- package/src/core/agents/state/{scratch.ts → journal.ts} +12 -12
- package/src/core/agents/state/pidmap.ts +130 -15
- package/src/core/agents/state/proc-start.ts +208 -0
- package/src/core/agents/state/shell-mutation.ts +1 -1
- package/src/core/agents/state/stale-sweep.ts +7 -7
- package/src/core/artifacts/index.ts +557 -0
- package/src/core/config.ts +30 -2
- package/src/core/context/index.ts +15 -15
- package/src/core/governor/adapter-spread.ts +82 -0
- package/src/core/governor/index.ts +91 -0
- package/src/core/governor/plan-api.ts +115 -0
- package/src/core/{supervisor → governor}/plan-read.ts +112 -97
- package/src/core/{supervisor → governor}/plan-types.ts +59 -56
- package/src/core/{supervisor → governor}/planning.ts +223 -192
- package/src/core/governor/read.ts +59 -0
- package/src/core/{supervisor → governor}/runner.ts +39 -39
- package/src/core/{supervisor → governor}/service-read.ts +22 -22
- package/src/core/{supervisor → governor}/service.ts +117 -119
- package/src/core/{supervisor → governor}/state.ts +325 -167
- package/src/core/hooks/adapter/detect.ts +30 -0
- package/src/core/hooks/{harness → adapter}/events.ts +16 -14
- package/src/core/hooks/{harness → adapter}/output.ts +31 -23
- package/src/core/hooks/{harness → adapter}/parse.ts +5 -5
- package/src/core/hooks/{harness → adapter}/wiring.ts +21 -21
- package/src/core/hooks/cli.ts +197 -173
- package/src/core/hooks/effects/image-capture.ts +6 -6
- package/src/core/hooks/effects/index.ts +19 -19
- package/src/core/hooks/events/emit.ts +3 -3
- package/src/core/hooks/events/rotate.ts +1 -1
- package/src/core/hooks/events/schema.ts +15 -7
- package/src/core/hooks/guard-path.ts +2 -2
- package/src/core/hooks/index.ts +1 -1
- package/src/core/hooks/resolve/anchor.ts +63 -8
- package/src/core/hooks/resolve/coord-root.ts +18 -40
- package/src/core/hooks/resolve/intent.ts +1 -1
- package/src/core/hooks/resolve/owner.ts +11 -5
- package/src/core/{scratch → journal}/index.ts +53 -53
- package/src/core/policy/evaluate.ts +8 -8
- package/src/core/policy/types.ts +3 -3
- package/src/core/work/state.ts +65 -23
- package/src/core/workflow/adapters.ts +33 -0
- package/src/core/workflow/approvals.ts +7 -7
- package/src/core/workflow/billing.ts +12 -12
- package/src/core/workflow/child-env.ts +13 -4
- package/src/core/workflow/engine.ts +155 -90
- package/src/core/workflow/evidence-preflight.ts +165 -0
- package/src/core/workflow/index.ts +3 -3
- package/src/core/workflow/proof.ts +60 -50
- package/src/core/workflow/run-state.ts +7 -7
- package/src/core/workflow/sandbox-projection.ts +16 -16
- package/src/core/workflow/spawn-claude.ts +13 -10
- package/src/core/workflow/spawn-codex.ts +13 -10
- package/src/core/workflow/spawn-cursor.ts +13 -10
- package/src/core/workflow/spawn-failure.ts +1 -1
- package/src/core/workflow/specialists.ts +2 -2
- package/src/core/workflow/{journal.ts → transcript.ts} +16 -16
- package/src/core/workflow/types.ts +108 -51
- package/src/core/workflow/validate.ts +1 -1
- package/src/core/workflow/workspaces/cancellation.ts +2 -2
- package/src/core/workflow/workspaces/cleanup.ts +2 -2
- package/src/core/workflow/workspaces/execution.ts +6 -6
- package/src/core/workflow/workspaces/inspect.ts +14 -11
- package/src/core/workflow/workspaces/integration.ts +18 -14
- package/src/core/workflow/workspaces/lifecycle.ts +10 -10
- package/src/core/workflow/workspaces/local-git.ts +47 -5
- package/src/core/workflow/workspaces/recovery.ts +3 -3
- package/src/core/workflow/workspaces/state.ts +4 -3
- package/src/core/workflow/workspaces/types.ts +1 -1
- package/src/lib/browser/asserts.ts +177 -0
- package/src/lib/browser/client.ts +189 -14
- package/src/lib/browser/content-checks.ts +571 -0
- package/src/lib/browser/critique.ts +231 -0
- package/src/lib/browser/geometry.ts +297 -1
- package/src/lib/browser/index.ts +34 -0
- package/src/lib/claude-desktop.ts +4 -1
- package/src/lib/context/index.ts +11 -1
- package/src/lib/council/index.ts +9 -9
- package/src/lib/identities/assume.ts +7 -7
- package/src/lib/instructions/apply.ts +87 -25
- package/src/lib/instructions/host-addendum.ts +126 -0
- package/src/lib/instructions/templates.ts +44 -15
- package/src/lib/machine.ts +2 -2
- package/dist/commands/harness.d.ts +0 -12
- package/dist/commands/harness.d.ts.map +0 -1
- package/dist/commands/scratch.d.ts +0 -4
- package/dist/commands/scratch.d.ts.map +0 -1
- package/dist/commands/session.d.ts.map +0 -1
- package/dist/commands/session.js +0 -162
- package/dist/commands/supervisor.d.ts +0 -4
- package/dist/commands/supervisor.d.ts.map +0 -1
- package/dist/core/harnesses/attest-projection.d.ts.map +0 -1
- package/dist/core/harnesses/attest.d.ts.map +0 -1
- package/dist/core/harnesses/attestation.d.ts.map +0 -1
- package/dist/core/harnesses/bench.d.ts.map +0 -1
- package/dist/core/harnesses/index.d.ts +0 -13
- package/dist/core/harnesses/index.d.ts.map +0 -1
- package/dist/core/harnesses/index.js +0 -6
- package/dist/core/harnesses/profiles.d.ts.map +0 -1
- package/dist/core/harnesses/registry.d.ts +0 -15
- package/dist/core/harnesses/registry.d.ts.map +0 -1
- package/dist/core/harnesses/types.d.ts.map +0 -1
- package/dist/core/hooks/harness/detect.d.ts +0 -9
- package/dist/core/hooks/harness/events.d.ts.map +0 -1
- package/dist/core/hooks/harness/output.d.ts.map +0 -1
- package/dist/core/supervisor/index.d.ts +0 -7
- package/dist/core/supervisor/index.d.ts.map +0 -1
- package/dist/core/supervisor/index.js +0 -6
- package/dist/core/supervisor/plan-api.d.ts +0 -23
- package/dist/core/supervisor/plan-api.d.ts.map +0 -1
- package/dist/core/supervisor/plan-api.js +0 -50
- package/dist/core/supervisor/plan-read.d.ts +0 -5
- package/dist/core/supervisor/plan-read.d.ts.map +0 -1
- package/dist/core/supervisor/plan-types.d.ts.map +0 -1
- package/dist/core/supervisor/planning.d.ts +0 -33
- package/dist/core/supervisor/planning.d.ts.map +0 -1
- package/dist/core/supervisor/read.d.ts +0 -6
- package/dist/core/supervisor/read.d.ts.map +0 -1
- package/dist/core/supervisor/read.js +0 -4
- package/dist/core/supervisor/runner.d.ts +0 -37
- package/dist/core/supervisor/runner.d.ts.map +0 -1
- package/dist/core/supervisor/service-read.d.ts +0 -6
- package/dist/core/supervisor/service-read.d.ts.map +0 -1
- package/dist/core/supervisor/service.d.ts +0 -114
- package/dist/core/supervisor/service.d.ts.map +0 -1
- package/dist/core/supervisor/state.d.ts +0 -95
- package/dist/core/supervisor/state.d.ts.map +0 -1
- package/dist/core/workflow/harnesses.d.ts +0 -17
- package/dist/core/workflow/harnesses.d.ts.map +0 -1
- package/dist/core/workflow/harnesses.js +0 -21
- package/dist/core/workflow/journal.d.ts.map +0 -1
- package/src/commands/session.ts +0 -187
- package/src/core/harnesses/index.ts +0 -56
- package/src/core/hooks/harness/detect.ts +0 -30
- package/src/core/supervisor/index.ts +0 -89
- package/src/core/supervisor/plan-api.ts +0 -73
- package/src/core/supervisor/read.ts +0 -59
- package/src/core/workflow/harnesses.ts +0 -33
- /package/dist/core/{harnesses → adapters}/attest-projection.js +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Context continuity: durable, structured state around native
|
|
3
|
-
* compaction. Harnery does not decide when a
|
|
4
|
-
* context telemetry when the
|
|
2
|
+
* Context continuity: durable, structured state around native adapter
|
|
3
|
+
* compaction. Harnery does not decide when a adapter compacts. It records
|
|
4
|
+
* context telemetry when the adapter exposes it, checkpoints external work
|
|
5
5
|
* state before compaction, and renders a verified recovery briefing after it.
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -9,7 +9,7 @@ import { spawnSync } from "node:child_process";
|
|
|
9
9
|
import { createHash, randomUUID } from "node:crypto";
|
|
10
10
|
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
11
11
|
import { dirname, join } from "node:path";
|
|
12
|
-
import type {
|
|
12
|
+
import type { Adapter } from "../hooks/events/schema.ts";
|
|
13
13
|
|
|
14
14
|
export const CONTEXT_SCHEMA_VERSION = 1 as const;
|
|
15
15
|
export const MAX_CAPSULE_BYTES = 32 * 1024;
|
|
@@ -23,7 +23,7 @@ export type CheckpointReason = "manual" | "pressure" | "pre_compact" | "session_
|
|
|
23
23
|
|
|
24
24
|
export interface ContextSample {
|
|
25
25
|
session_id: string;
|
|
26
|
-
|
|
26
|
+
adapter: Adapter;
|
|
27
27
|
model?: string;
|
|
28
28
|
used_tokens?: number;
|
|
29
29
|
window_tokens?: number;
|
|
@@ -65,7 +65,7 @@ export interface ContinuityCapsule {
|
|
|
65
65
|
session: {
|
|
66
66
|
session_id: string;
|
|
67
67
|
instance_id: string;
|
|
68
|
-
|
|
68
|
+
adapter: Adapter;
|
|
69
69
|
model?: string;
|
|
70
70
|
};
|
|
71
71
|
context?: ContextSample;
|
|
@@ -83,7 +83,7 @@ export interface ContinuityCapsule {
|
|
|
83
83
|
|
|
84
84
|
export interface ExtractContextSampleOptions {
|
|
85
85
|
sessionId: string;
|
|
86
|
-
|
|
86
|
+
adapter: Adapter;
|
|
87
87
|
model?: string;
|
|
88
88
|
source?: ContextSampleSource;
|
|
89
89
|
confidence?: ContextSampleConfidence;
|
|
@@ -93,7 +93,7 @@ export interface ExtractContextSampleOptions {
|
|
|
93
93
|
export interface CheckpointContextInput {
|
|
94
94
|
sessionId: string;
|
|
95
95
|
instanceId: string;
|
|
96
|
-
|
|
96
|
+
adapter: Adapter;
|
|
97
97
|
cwd: string;
|
|
98
98
|
reason: CheckpointReason;
|
|
99
99
|
model?: string;
|
|
@@ -129,7 +129,7 @@ interface HeartbeatSnapshot {
|
|
|
129
129
|
last_tool_target?: string;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
/** Parse the context-window shapes exposed by current
|
|
132
|
+
/** Parse the context-window shapes exposed by current adapter hook/status data. */
|
|
133
133
|
export function extractContextSample(
|
|
134
134
|
payload: Record<string, unknown>,
|
|
135
135
|
options: ExtractContextSampleOptions,
|
|
@@ -177,7 +177,7 @@ export function extractContextSample(
|
|
|
177
177
|
|
|
178
178
|
return {
|
|
179
179
|
session_id: options.sessionId,
|
|
180
|
-
|
|
180
|
+
adapter: options.adapter,
|
|
181
181
|
model,
|
|
182
182
|
used_tokens: usedTokens,
|
|
183
183
|
window_tokens: windowTokens,
|
|
@@ -245,7 +245,7 @@ export function checkpointContext(
|
|
|
245
245
|
session: {
|
|
246
246
|
session_id: input.sessionId,
|
|
247
247
|
instance_id: input.instanceId,
|
|
248
|
-
|
|
248
|
+
adapter: input.adapter,
|
|
249
249
|
model: input.model ?? current.latest_context?.model ?? heartbeat?.model,
|
|
250
250
|
},
|
|
251
251
|
context: current.latest_context,
|
|
@@ -271,7 +271,7 @@ export function checkpointContext(
|
|
|
271
271
|
return { capsule, path: absolutePath, state: next, reused: false };
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
-
/** Prepare a briefing without claiming that a
|
|
274
|
+
/** Prepare a briefing without claiming that a adapter has accepted it yet. */
|
|
275
275
|
export function prepareContextRecovery(
|
|
276
276
|
coordRoot: string,
|
|
277
277
|
input: { sessionId: string; instanceId: string; cwd: string },
|
|
@@ -298,7 +298,7 @@ export function prepareContextRecovery(
|
|
|
298
298
|
return { state: current, capsule, briefing };
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
-
/** Advance continuity only after the
|
|
301
|
+
/** Advance continuity only after the adapter context channel accepted the briefing. */
|
|
302
302
|
export function completeContextRecovery(
|
|
303
303
|
coordRoot: string,
|
|
304
304
|
input: { sessionId: string; instanceId: string },
|
|
@@ -319,7 +319,7 @@ export function completeContextRecovery(
|
|
|
319
319
|
return recovered;
|
|
320
320
|
}
|
|
321
321
|
|
|
322
|
-
/** Record that the
|
|
322
|
+
/** Record that the adapter, rather than Harnery, reported compaction complete. */
|
|
323
323
|
export function markContextCompactionCompleted(
|
|
324
324
|
coordRoot: string,
|
|
325
325
|
input: { sessionId: string; instanceId: string; observedAt?: string },
|
|
@@ -532,7 +532,7 @@ function git(cwd: string, args: string[]): string | undefined {
|
|
|
532
532
|
function sameMeasurement(a: ContextSample | undefined, b: ContextSample): boolean {
|
|
533
533
|
if (!a) return false;
|
|
534
534
|
return (
|
|
535
|
-
a.
|
|
535
|
+
a.adapter === b.adapter &&
|
|
536
536
|
a.model === b.model &&
|
|
537
537
|
a.used_tokens === b.used_tokens &&
|
|
538
538
|
a.window_tokens === b.window_tokens &&
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Preflight: would every specialist on this team land on the same adapter?
|
|
3
|
+
*
|
|
4
|
+
* Harnery does not auto-spread. A specialist without an `adapter` pin inherits
|
|
5
|
+
* the run's default, so a team whose profiles all omit the pin puts every child
|
|
6
|
+
* on one adapter. That is legal and sometimes intended. It is a problem when the
|
|
7
|
+
* host is also `subscriptionOnly`, because then the concentration lands on one
|
|
8
|
+
* seat's session meter rather than on metered per-token billing: the seat hits
|
|
9
|
+
* its limit, and every specialist stops at once rather than the team degrading.
|
|
10
|
+
*
|
|
11
|
+
* The check is deliberately narrow, because a false refusal here is worse than
|
|
12
|
+
* the miss it prevents. It fires only when all four hold:
|
|
13
|
+
*
|
|
14
|
+
* 1. more than one specialist (a solo team cannot spread),
|
|
15
|
+
* 2. every specialist resolves to the same adapter,
|
|
16
|
+
* 3. `subscriptionOnly` is on (otherwise concentration is a cost curve, not a
|
|
17
|
+
* cliff), and
|
|
18
|
+
* 4. more than one adapter is ATTESTED REACHABLE.
|
|
19
|
+
*
|
|
20
|
+
* Condition 4 is the one worth insisting on. Counting *declared* adapters would
|
|
21
|
+
* suggest spreading onto a seat that cannot run — a dead adapter passes a
|
|
22
|
+
* declaration check and then fails every child it is handed. Only an
|
|
23
|
+
* attestation records that the adapter actually completed a turn on this
|
|
24
|
+
* machine, so only an attestation is grounds for telling someone to use it.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
export interface AdapterSpreadInput {
|
|
28
|
+
/** Specialist id → its optional adapter pin. */
|
|
29
|
+
specialists: Readonly<Record<string, { adapter?: string }>>;
|
|
30
|
+
/** The adapter an unpinned specialist inherits. */
|
|
31
|
+
defaultAdapter: string;
|
|
32
|
+
/** Adapters with a live attestation on this machine — proven to run, not
|
|
33
|
+
* merely registered. */
|
|
34
|
+
reachable: readonly string[];
|
|
35
|
+
/** Whether children are confined to subscription (logged-in) auth. */
|
|
36
|
+
subscriptionOnly: boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface AdapterSpreadVerdict {
|
|
40
|
+
/** True when the team would put every child on one adapter AND that is worth
|
|
41
|
+
* refusing over. False both when the team spreads and when concentrating is
|
|
42
|
+
* unremarkable (single specialist, one reachable adapter, metered billing). */
|
|
43
|
+
concentrated: boolean;
|
|
44
|
+
/** The adapter everything would land on, when concentrated. */
|
|
45
|
+
adapter?: string;
|
|
46
|
+
/** Operator-facing explanation, present exactly when concentrated. */
|
|
47
|
+
reason?: string;
|
|
48
|
+
/** Attested-reachable adapters this team is not using. */
|
|
49
|
+
unused: string[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function inspectAdapterSpread(input: AdapterSpreadInput): AdapterSpreadVerdict {
|
|
53
|
+
const ids = Object.keys(input.specialists);
|
|
54
|
+
const resolved = ids.map((id) => input.specialists[id]?.adapter ?? input.defaultAdapter);
|
|
55
|
+
const distinct = [...new Set(resolved)];
|
|
56
|
+
const unused = input.reachable.filter((a) => !distinct.includes(a));
|
|
57
|
+
|
|
58
|
+
if (ids.length < 2 || distinct.length !== 1 || !input.subscriptionOnly || unused.length === 0) {
|
|
59
|
+
return { concentrated: false, unused };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const adapter = distinct[0] as string;
|
|
63
|
+
const pinned = ids.filter((id) => input.specialists[id]?.adapter).length;
|
|
64
|
+
// Say which of the two shapes this is. "You wrote no pins" and "you pinned
|
|
65
|
+
// them all to one" need different corrections, and a single generic message
|
|
66
|
+
// would send half the readers looking in the wrong place.
|
|
67
|
+
const how =
|
|
68
|
+
pinned === 0
|
|
69
|
+
? `no specialist pins an adapter, so all ${ids.length} inherit the default (${adapter})`
|
|
70
|
+
: `all ${ids.length} specialists resolve to ${adapter}`;
|
|
71
|
+
return {
|
|
72
|
+
concentrated: true,
|
|
73
|
+
adapter,
|
|
74
|
+
unused,
|
|
75
|
+
reason:
|
|
76
|
+
`${how}, and children are confined to subscription auth — so one seat carries the whole ` +
|
|
77
|
+
`team and every specialist stops together when it hits its limit. ` +
|
|
78
|
+
`${unused.length === 1 ? "This adapter is" : "These adapters are"} attested and idle: ` +
|
|
79
|
+
`${unused.join(", ")}. Pin some specialists onto ${unused.length === 1 ? "it" : "them"}, ` +
|
|
80
|
+
`or pass --allow-single-adapter if one seat is what you want.`,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export {
|
|
2
|
+
approveGovernorPlan,
|
|
3
|
+
findCompletedMissionGoverning,
|
|
4
|
+
rejectGovernorPlan,
|
|
5
|
+
reopenGovernorMission,
|
|
6
|
+
retryGovernorPlan,
|
|
7
|
+
} from "./plan-api.ts";
|
|
8
|
+
export {
|
|
9
|
+
readGovernorPlan,
|
|
10
|
+
readGovernorPlanReviewReceipt,
|
|
11
|
+
readGovernorPlans,
|
|
12
|
+
} from "./plan-read.ts";
|
|
13
|
+
export {
|
|
14
|
+
type CreateGovernorPlanTemplateInput,
|
|
15
|
+
type CreateGovernorReplanningInput,
|
|
16
|
+
GOVERNOR_PLAN_SCHEMA_VERSION,
|
|
17
|
+
type GovernorPlanEvent,
|
|
18
|
+
type GovernorPlanEventType,
|
|
19
|
+
type GovernorPlanHistory,
|
|
20
|
+
type GovernorPlanMilestone,
|
|
21
|
+
type GovernorPlanOutcome,
|
|
22
|
+
type GovernorPlanProposal,
|
|
23
|
+
type GovernorPlanRecord,
|
|
24
|
+
type GovernorPlanRequest,
|
|
25
|
+
type GovernorPlanReviewFinding,
|
|
26
|
+
type GovernorPlanReviewReceipt,
|
|
27
|
+
type GovernorPlanReviewReviewer,
|
|
28
|
+
type GovernorPlanReviewRound,
|
|
29
|
+
type GovernorPlanReviewStatus,
|
|
30
|
+
type GovernorPlanReviewSummary,
|
|
31
|
+
type GovernorPlanReviewVerdict,
|
|
32
|
+
type GovernorPlanStatus,
|
|
33
|
+
type GovernorPlanTemplate,
|
|
34
|
+
type GovernorPlanWorkSpec,
|
|
35
|
+
type GovernorReplanningPolicy,
|
|
36
|
+
MAX_GOVERNOR_PLAN_REVIEWERS,
|
|
37
|
+
MAX_GOVERNOR_PLAN_REVISION_ROUNDS,
|
|
38
|
+
} from "./plan-types.ts";
|
|
39
|
+
export {
|
|
40
|
+
type GovernorDispatchOutcome,
|
|
41
|
+
type GovernorRunReport,
|
|
42
|
+
type GovernorStopReason,
|
|
43
|
+
type RunGovernorInput,
|
|
44
|
+
runGovernor,
|
|
45
|
+
} from "./runner.ts";
|
|
46
|
+
export {
|
|
47
|
+
type ConfigureGovernorServiceInput,
|
|
48
|
+
configureGovernorService,
|
|
49
|
+
GOVERNOR_SERVICE_CONFIG_SCHEMA_VERSION,
|
|
50
|
+
GOVERNOR_SERVICE_RUNTIME_SCHEMA_VERSION,
|
|
51
|
+
GOVERNOR_SERVICE_STATUS_SCHEMA_VERSION,
|
|
52
|
+
type GovernorServiceConfig,
|
|
53
|
+
type GovernorServiceEngineConfig,
|
|
54
|
+
type GovernorServiceGoalRuntime,
|
|
55
|
+
type GovernorServiceGoalState,
|
|
56
|
+
type GovernorServiceProcessState,
|
|
57
|
+
type GovernorServiceRuntime,
|
|
58
|
+
type GovernorServiceStatus,
|
|
59
|
+
type GovernorServiceStatusRecord,
|
|
60
|
+
type GovernorServiceSweepOutcome,
|
|
61
|
+
type GovernorServiceSweepReport,
|
|
62
|
+
governorServiceLogPath,
|
|
63
|
+
type RunGovernorServiceDaemonInput,
|
|
64
|
+
type RunGovernorServiceSweepInput,
|
|
65
|
+
readGovernorServiceConfig,
|
|
66
|
+
readGovernorServiceRuntime,
|
|
67
|
+
readGovernorServiceStatus,
|
|
68
|
+
requestGovernorServiceStop,
|
|
69
|
+
runGovernorServiceDaemon,
|
|
70
|
+
runGovernorServiceSweep,
|
|
71
|
+
spawnGovernorService,
|
|
72
|
+
} from "./service.ts";
|
|
73
|
+
export {
|
|
74
|
+
assertGovernorId,
|
|
75
|
+
type CreateGovernorInput,
|
|
76
|
+
type CreateGovernorMissionInput,
|
|
77
|
+
collectGovernorWork,
|
|
78
|
+
createGovernor,
|
|
79
|
+
GOVERNOR_INTENT_SCHEMA_VERSION,
|
|
80
|
+
type GovernorAutomationPolicy,
|
|
81
|
+
type GovernorIntent,
|
|
82
|
+
type GovernorLimits,
|
|
83
|
+
type GovernorMission,
|
|
84
|
+
type GovernorNextAction,
|
|
85
|
+
type GovernorProjection,
|
|
86
|
+
type GovernorRecord,
|
|
87
|
+
type GovernorState,
|
|
88
|
+
listGovernors,
|
|
89
|
+
newGovernorId,
|
|
90
|
+
readGovernor,
|
|
91
|
+
} from "./state.ts";
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { GovernorPlanOutcome } from "./plan-types.ts";
|
|
2
|
+
import {
|
|
3
|
+
applyGovernorPlanProposal,
|
|
4
|
+
rejectGovernorPlanProposal,
|
|
5
|
+
reopenGovernorMissionPlan,
|
|
6
|
+
retryGovernorPlanProposal,
|
|
7
|
+
} from "./planning.ts";
|
|
8
|
+
import { acquireGovernorLease, listGovernors, readGovernorIgnoringLease } from "./state.ts";
|
|
9
|
+
|
|
10
|
+
export function approveGovernorPlan(input: {
|
|
11
|
+
coordRoot: string;
|
|
12
|
+
goalId: string;
|
|
13
|
+
planId: string;
|
|
14
|
+
actor?: string;
|
|
15
|
+
reason?: string;
|
|
16
|
+
}): GovernorPlanOutcome {
|
|
17
|
+
const actor = input.actor?.trim() || `governor:${input.goalId}`;
|
|
18
|
+
const release = acquireGovernorLease(input.coordRoot, input.goalId);
|
|
19
|
+
try {
|
|
20
|
+
return applyGovernorPlanProposal({
|
|
21
|
+
coordRoot: input.coordRoot,
|
|
22
|
+
record: readGovernorIgnoringLease(input.coordRoot, input.goalId),
|
|
23
|
+
planId: input.planId,
|
|
24
|
+
actor,
|
|
25
|
+
reason: input.reason,
|
|
26
|
+
});
|
|
27
|
+
} finally {
|
|
28
|
+
release();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function rejectGovernorPlan(input: {
|
|
33
|
+
coordRoot: string;
|
|
34
|
+
goalId: string;
|
|
35
|
+
planId: string;
|
|
36
|
+
actor?: string;
|
|
37
|
+
reason: string;
|
|
38
|
+
}): GovernorPlanOutcome {
|
|
39
|
+
const actor = input.actor?.trim() || `governor:${input.goalId}`;
|
|
40
|
+
const release = acquireGovernorLease(input.coordRoot, input.goalId);
|
|
41
|
+
try {
|
|
42
|
+
return rejectGovernorPlanProposal({
|
|
43
|
+
coordRoot: input.coordRoot,
|
|
44
|
+
goalId: input.goalId,
|
|
45
|
+
planId: input.planId,
|
|
46
|
+
actor,
|
|
47
|
+
reason: input.reason,
|
|
48
|
+
});
|
|
49
|
+
} finally {
|
|
50
|
+
release();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The goal of a succeeded mission that governs this work item, if there is one.
|
|
55
|
+
*
|
|
56
|
+
* A work item holds no back-reference to its goal, so this is a scan. It exists so
|
|
57
|
+
* `work reopen` can tell the difference between an item nothing is watching and one
|
|
58
|
+
* whose mission has already been declared complete — the case where reopening the
|
|
59
|
+
* item alone leaves it in `ready_work` that the governor will never dispatch. */
|
|
60
|
+
export function findCompletedMissionGoverning(
|
|
61
|
+
coordRoot: string,
|
|
62
|
+
workId: string,
|
|
63
|
+
): string | undefined {
|
|
64
|
+
for (const record of listGovernors(coordRoot)) {
|
|
65
|
+
if (record.projection.state !== "succeeded" || !record.intent.mission) continue;
|
|
66
|
+
if (record.projection.root_work_id === workId || record.projection.work_ids.includes(workId)) {
|
|
67
|
+
return record.intent.id;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** ADR 0050: reopen an accepted mission completion by appending to the plan log.
|
|
74
|
+
* Held under the goal lease so it cannot race a foreground governor run. */
|
|
75
|
+
export function reopenGovernorMission(input: {
|
|
76
|
+
coordRoot: string;
|
|
77
|
+
goalId: string;
|
|
78
|
+
actor?: string;
|
|
79
|
+
reason: string;
|
|
80
|
+
}): GovernorPlanOutcome {
|
|
81
|
+
const actor = input.actor?.trim() || `governor:${input.goalId}`;
|
|
82
|
+
const release = acquireGovernorLease(input.coordRoot, input.goalId);
|
|
83
|
+
try {
|
|
84
|
+
return reopenGovernorMissionPlan({
|
|
85
|
+
coordRoot: input.coordRoot,
|
|
86
|
+
record: readGovernorIgnoringLease(input.coordRoot, input.goalId),
|
|
87
|
+
actor,
|
|
88
|
+
reason: input.reason,
|
|
89
|
+
});
|
|
90
|
+
} finally {
|
|
91
|
+
release();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function retryGovernorPlan(input: {
|
|
96
|
+
coordRoot: string;
|
|
97
|
+
goalId: string;
|
|
98
|
+
planId: string;
|
|
99
|
+
actor?: string;
|
|
100
|
+
reason: string;
|
|
101
|
+
}): GovernorPlanOutcome {
|
|
102
|
+
const actor = input.actor?.trim() || `governor:${input.goalId}`;
|
|
103
|
+
const release = acquireGovernorLease(input.coordRoot, input.goalId);
|
|
104
|
+
try {
|
|
105
|
+
return retryGovernorPlanProposal({
|
|
106
|
+
coordRoot: input.coordRoot,
|
|
107
|
+
record: readGovernorIgnoringLease(input.coordRoot, input.goalId),
|
|
108
|
+
planId: input.planId,
|
|
109
|
+
actor,
|
|
110
|
+
reason: input.reason,
|
|
111
|
+
});
|
|
112
|
+
} finally {
|
|
113
|
+
release();
|
|
114
|
+
}
|
|
115
|
+
}
|