harnery 0.33.0 → 0.34.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/dist/commander.d.ts.map +1 -1
- package/dist/commander.js +4 -0
- package/dist/commands/adapter.js +2 -2
- package/dist/commands/agents.d.ts +144 -1
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +1220 -588
- package/dist/commands/artifacts.d.ts.map +1 -1
- package/dist/commands/artifacts.js +7 -6
- package/dist/commands/backup.d.ts +1 -1
- package/dist/commands/backup.d.ts.map +1 -1
- package/dist/commands/backup.js +29 -16
- package/dist/commands/browse.d.ts.map +1 -1
- package/dist/commands/browse.js +234 -12
- package/dist/commands/checkpoint.d.ts.map +1 -1
- package/dist/commands/checkpoint.js +3 -2
- package/dist/commands/claude-desktop.d.ts +1 -1
- package/dist/commands/claude-desktop.d.ts.map +1 -1
- package/dist/commands/claude-desktop.js +3 -74
- package/dist/commands/context.js +1 -6
- package/dist/commands/decision.d.ts.map +1 -1
- package/dist/commands/decision.js +22 -38
- package/dist/commands/docs.d.ts.map +1 -1
- package/dist/commands/docs.js +91 -28
- package/dist/commands/doctor.js +10 -1
- package/dist/commands/events.d.ts +5 -0
- package/dist/commands/events.d.ts.map +1 -0
- package/dist/commands/events.js +189 -0
- package/dist/commands/governor.d.ts.map +1 -1
- package/dist/commands/governor.js +13 -4
- package/dist/commands/init.d.ts +9 -2
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +223 -51
- package/dist/commands/journal.d.ts.map +1 -1
- package/dist/commands/journal.js +4 -13
- package/dist/commands/ledger-v3.d.ts +5 -0
- package/dist/commands/ledger-v3.d.ts.map +1 -0
- package/dist/commands/ledger-v3.js +91 -0
- package/dist/commands/presence.d.ts.map +1 -1
- package/dist/commands/presence.js +11 -5
- package/dist/commands/sync.d.ts +1 -1
- package/dist/commands/sync.js +1 -1
- package/dist/commands/web.d.ts +6 -0
- package/dist/commands/web.d.ts.map +1 -1
- package/dist/commands/web.js +67 -7
- package/dist/commands/work.d.ts.map +1 -1
- package/dist/commands/work.js +22 -5
- package/dist/core/adapter.d.ts +5 -0
- package/dist/core/adapter.d.ts.map +1 -0
- package/dist/core/adapter.js +1 -0
- package/dist/core/adapters/attest.d.ts +5 -2
- package/dist/core/adapters/attest.d.ts.map +1 -1
- package/dist/core/adapters/attest.js +8 -3
- package/dist/core/adapters/profiles.d.ts +6 -6
- package/dist/core/adapters/profiles.d.ts.map +1 -1
- package/dist/core/adapters/profiles.js +4 -4
- package/dist/core/agents/canonical-emit.d.ts +17 -15
- package/dist/core/agents/canonical-emit.d.ts.map +1 -1
- package/dist/core/agents/canonical-emit.js +22 -22
- package/dist/core/agents/cli.js +207 -234
- package/dist/core/agents/codex-archive-v3.d.ts +14 -0
- package/dist/core/agents/codex-archive-v3.d.ts.map +1 -0
- package/dist/core/agents/codex-archive-v3.js +110 -0
- package/dist/core/agents/coord-client.d.ts +19 -81
- package/dist/core/agents/coord-client.d.ts.map +1 -1
- package/dist/core/agents/coord-client.js +65 -155
- package/dist/core/agents/finalization.d.ts +4 -1
- package/dist/core/agents/finalization.d.ts.map +1 -1
- package/dist/core/agents/finalization.js +89 -32
- package/dist/core/agents/index.d.ts +4 -5
- package/dist/core/agents/index.d.ts.map +1 -1
- package/dist/core/agents/index.js +4 -5
- package/dist/core/agents/live-authority-v3.d.ts +59 -0
- package/dist/core/agents/live-authority-v3.d.ts.map +1 -0
- package/dist/core/agents/live-authority-v3.js +233 -0
- package/dist/core/agents/live-lifecycle-v3.d.ts +20 -0
- package/dist/core/agents/live-lifecycle-v3.d.ts.map +1 -0
- package/dist/core/agents/live-lifecycle-v3.js +91 -0
- package/dist/core/agents/live-observation-v3.d.ts +25 -0
- package/dist/core/agents/live-observation-v3.d.ts.map +1 -0
- package/dist/core/agents/live-observation-v3.js +157 -0
- package/dist/core/agents/render/prompt-context.d.ts +4 -4
- package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
- package/dist/core/agents/render/prompt-context.js +23 -58
- package/dist/core/agents/render/session-context.d.ts +1 -1
- package/dist/core/agents/render/session-context.d.ts.map +1 -1
- package/dist/core/agents/render/session-context.js +8 -32
- package/dist/core/agents/rules/claim-conflict.d.ts +3 -3
- package/dist/core/agents/rules/claim-conflict.d.ts.map +1 -1
- package/dist/core/agents/rules/claim-conflict.js +79 -127
- package/dist/core/agents/rules/commit-conflict.d.ts.map +1 -1
- package/dist/core/agents/rules/commit-conflict.js +3 -18
- package/dist/core/agents/rules/stop-hook.d.ts +9 -50
- package/dist/core/agents/rules/stop-hook.d.ts.map +1 -1
- package/dist/core/agents/rules/stop-hook.js +193 -236
- package/dist/core/agents/session-events.d.ts +5 -7
- package/dist/core/agents/session-events.d.ts.map +1 -1
- package/dist/core/agents/session-events.js +127 -95
- package/dist/core/agents/session-finalization-state-v3.d.ts +30 -0
- package/dist/core/agents/session-finalization-state-v3.d.ts.map +1 -0
- package/dist/core/agents/session-finalization-state-v3.js +40 -0
- package/dist/core/agents/session-finalizer-v3.d.ts +107 -0
- package/dist/core/agents/session-finalizer-v3.d.ts.map +1 -0
- package/dist/core/agents/session-finalizer-v3.js +734 -0
- package/dist/core/agents/session-name-display.d.ts +40 -0
- package/dist/core/agents/session-name-display.d.ts.map +1 -0
- package/dist/core/agents/session-name-display.js +119 -0
- package/dist/core/agents/state/activity-log.d.ts +3 -3
- package/dist/core/agents/state/activity-log.d.ts.map +1 -1
- package/dist/core/agents/state/activity-log.js +7 -16
- package/dist/core/agents/state/heartbeat-writer.d.ts +23 -55
- package/dist/core/agents/state/heartbeat-writer.d.ts.map +1 -1
- package/dist/core/agents/state/heartbeat-writer.js +56 -228
- package/dist/core/agents/state/live-coordination-view.d.ts +31 -0
- package/dist/core/agents/state/live-coordination-view.d.ts.map +1 -0
- package/dist/core/agents/state/live-coordination-view.js +209 -0
- package/dist/core/agents/state/session-state.d.ts +4 -3
- package/dist/core/agents/state/session-state.d.ts.map +1 -1
- package/dist/core/agents/state/session-state.js +18 -9
- package/dist/core/agents/state/stale-sweep.d.ts +1 -1
- package/dist/core/agents/state/stale-sweep.d.ts.map +1 -1
- package/dist/core/agents/state/stale-sweep.js +26 -15
- package/dist/core/artifacts/index.d.ts.map +1 -1
- package/dist/core/artifacts/index.js +5 -7
- package/dist/core/config.d.ts +33 -2
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +98 -2
- package/dist/core/context/index.d.ts +1 -4
- package/dist/core/context/index.d.ts.map +1 -1
- package/dist/core/context/index.js +9 -9
- package/dist/core/events/span-parent.d.ts +15 -0
- package/dist/core/events/span-parent.d.ts.map +1 -0
- package/dist/core/events/span-parent.js +34 -0
- package/dist/core/events/v3/advance.d.ts +14 -0
- package/dist/core/events/v3/advance.d.ts.map +1 -0
- package/dist/core/events/v3/advance.js +134 -0
- package/dist/core/events/v3/authority-outbox.d.ts +78 -0
- package/dist/core/events/v3/authority-outbox.d.ts.map +1 -0
- package/dist/core/events/v3/authority-outbox.js +399 -0
- package/dist/core/events/v3/base-builder.d.ts +20 -0
- package/dist/core/events/v3/base-builder.d.ts.map +1 -0
- package/dist/core/events/v3/base-builder.js +29 -0
- package/dist/core/events/v3/base-contract.d.ts +7576 -0
- package/dist/core/events/v3/base-contract.d.ts.map +1 -0
- package/dist/core/events/v3/base-contract.js +647 -0
- package/dist/core/events/v3/bootstrap.d.ts +34 -0
- package/dist/core/events/v3/bootstrap.d.ts.map +1 -0
- package/dist/core/events/v3/bootstrap.js +175 -0
- package/dist/core/events/v3/builder.d.ts +20 -0
- package/dist/core/events/v3/builder.d.ts.map +1 -0
- package/dist/core/events/v3/builder.js +28 -0
- package/dist/core/events/v3/canonical.d.ts +31 -0
- package/dist/core/events/v3/canonical.d.ts.map +1 -0
- package/dist/core/events/v3/canonical.js +100 -0
- package/dist/core/events/v3/capabilities.d.ts +31 -0
- package/dist/core/events/v3/capabilities.d.ts.map +1 -0
- package/dist/core/events/v3/capabilities.js +107 -0
- package/dist/core/events/v3/capability-drift.d.ts +22 -0
- package/dist/core/events/v3/capability-drift.d.ts.map +1 -0
- package/dist/core/events/v3/capability-drift.js +134 -0
- package/dist/core/events/v3/catalog.d.ts +38 -0
- package/dist/core/events/v3/catalog.d.ts.map +1 -0
- package/dist/core/events/v3/catalog.js +135 -0
- package/dist/core/events/v3/clock-order.d.ts +34 -0
- package/dist/core/events/v3/clock-order.d.ts.map +1 -0
- package/dist/core/events/v3/clock-order.js +35 -0
- package/dist/core/events/v3/contract.d.ts +171 -0
- package/dist/core/events/v3/contract.d.ts.map +1 -0
- package/dist/core/events/v3/contract.js +180 -0
- package/dist/core/events/v3/control.d.ts +111 -0
- package/dist/core/events/v3/control.d.ts.map +1 -0
- package/dist/core/events/v3/control.js +419 -0
- package/dist/core/events/v3/coordination-view.d.ts +69 -0
- package/dist/core/events/v3/coordination-view.d.ts.map +1 -0
- package/dist/core/events/v3/coordination-view.js +119 -0
- package/dist/core/events/v3/economics.d.ts +77 -0
- package/dist/core/events/v3/economics.d.ts.map +1 -0
- package/dist/core/events/v3/economics.js +274 -0
- package/dist/core/events/v3/finalization-view.d.ts +26 -0
- package/dist/core/events/v3/finalization-view.d.ts.map +1 -0
- package/dist/core/events/v3/finalization-view.js +37 -0
- package/dist/core/events/v3/fingerprint-keys.d.ts +25 -0
- package/dist/core/events/v3/fingerprint-keys.d.ts.map +1 -0
- package/dist/core/events/v3/fingerprint-keys.js +217 -0
- package/dist/core/events/v3/generated.d.ts +4 -0
- package/dist/core/events/v3/generated.d.ts.map +1 -0
- package/dist/core/events/v3/generated.js +47 -0
- package/dist/core/events/v3/ids.d.ts +9 -0
- package/dist/core/events/v3/ids.d.ts.map +1 -0
- package/dist/core/events/v3/ids.js +25 -0
- package/dist/core/events/v3/index.d.ts +35 -0
- package/dist/core/events/v3/index.d.ts.map +1 -0
- package/dist/core/events/v3/index.js +33 -0
- package/dist/core/events/v3/latency.d.ts +63 -0
- package/dist/core/events/v3/latency.d.ts.map +1 -0
- package/dist/core/events/v3/latency.js +412 -0
- package/dist/core/events/v3/live-feed.d.ts +45 -0
- package/dist/core/events/v3/live-feed.d.ts.map +1 -0
- package/dist/core/events/v3/live-feed.js +246 -0
- package/dist/core/events/v3/live-observation.d.ts +35 -0
- package/dist/core/events/v3/live-observation.d.ts.map +1 -0
- package/dist/core/events/v3/live-observation.js +1 -0
- package/dist/core/events/v3/live-routing.d.ts +57 -0
- package/dist/core/events/v3/live-routing.d.ts.map +1 -0
- package/dist/core/events/v3/live-routing.js +107 -0
- package/dist/core/events/v3/producers/command-recorder.d.ts +67 -0
- package/dist/core/events/v3/producers/command-recorder.d.ts.map +1 -0
- package/dist/core/events/v3/producers/command-recorder.js +477 -0
- package/dist/core/events/v3/producers/command.d.ts +50 -0
- package/dist/core/events/v3/producers/command.d.ts.map +1 -0
- package/dist/core/events/v3/producers/command.js +135 -0
- package/dist/core/events/v3/producers/coordination-recorder.d.ts +53 -0
- package/dist/core/events/v3/producers/coordination-recorder.d.ts.map +1 -0
- package/dist/core/events/v3/producers/coordination-recorder.js +376 -0
- package/dist/core/events/v3/producers/coordination.d.ts +90 -0
- package/dist/core/events/v3/producers/coordination.d.ts.map +1 -0
- package/dist/core/events/v3/producers/coordination.js +229 -0
- package/dist/core/events/v3/producers/hook-base.d.ts +54 -0
- package/dist/core/events/v3/producers/hook-base.d.ts.map +1 -0
- package/dist/core/events/v3/producers/hook-base.js +424 -0
- package/dist/core/events/v3/producers/hook.d.ts +29 -0
- package/dist/core/events/v3/producers/hook.d.ts.map +1 -0
- package/dist/core/events/v3/producers/hook.js +71 -0
- package/dist/core/events/v3/producers/intake.d.ts +65 -0
- package/dist/core/events/v3/producers/intake.d.ts.map +1 -0
- package/dist/core/events/v3/producers/intake.js +244 -0
- package/dist/core/events/v3/producers/recorder.d.ts +240 -0
- package/dist/core/events/v3/producers/recorder.d.ts.map +1 -0
- package/dist/core/events/v3/producers/recorder.js +2176 -0
- package/dist/core/events/v3/projection.d.ts +101 -0
- package/dist/core/events/v3/projection.d.ts.map +1 -0
- package/dist/core/events/v3/projection.js +479 -0
- package/dist/core/events/v3/reader.d.ts +75 -0
- package/dist/core/events/v3/reader.d.ts.map +1 -0
- package/dist/core/events/v3/reader.js +778 -0
- package/dist/core/events/v3/recovery-record.d.ts +47 -0
- package/dist/core/events/v3/recovery-record.d.ts.map +1 -0
- package/dist/core/events/v3/recovery-record.js +167 -0
- package/dist/core/events/v3/recovery.d.ts +22 -0
- package/dist/core/events/v3/recovery.d.ts.map +1 -0
- package/dist/core/events/v3/recovery.js +227 -0
- package/dist/core/events/v3/span-state.d.ts +52 -0
- package/dist/core/events/v3/span-state.d.ts.map +1 -0
- package/dist/core/events/v3/span-state.js +142 -0
- package/dist/core/events/v3/targets.d.ts +23 -0
- package/dist/core/events/v3/targets.d.ts.map +1 -0
- package/dist/core/events/v3/targets.js +134 -0
- package/dist/core/events/v3/turn-telemetry.d.ts +41 -0
- package/dist/core/events/v3/turn-telemetry.d.ts.map +1 -0
- package/dist/core/events/v3/turn-telemetry.js +168 -0
- package/dist/core/events/v3/validate.d.ts +9 -0
- package/dist/core/events/v3/validate.d.ts.map +1 -0
- package/dist/core/events/v3/validate.js +281 -0
- package/dist/core/events/v3/writer.d.ts +56 -0
- package/dist/core/events/v3/writer.d.ts.map +1 -0
- package/dist/core/events/v3/writer.js +335 -0
- package/dist/core/governor/index.d.ts +1 -1
- package/dist/core/governor/index.d.ts.map +1 -1
- package/dist/core/governor/index.js +1 -1
- package/dist/core/governor/plan-api.d.ts +2 -1
- package/dist/core/governor/plan-api.d.ts.map +1 -1
- package/dist/core/governor/plan-api.js +6 -3
- package/dist/core/governor/read.d.ts +1 -1
- package/dist/core/governor/read.d.ts.map +1 -1
- package/dist/core/governor/read.js +1 -1
- package/dist/core/governor/state.d.ts +9 -0
- package/dist/core/governor/state.d.ts.map +1 -1
- package/dist/core/governor/state.js +40 -3
- package/dist/core/guard/config.d.ts +5 -0
- package/dist/core/guard/config.d.ts.map +1 -0
- package/dist/core/guard/config.js +157 -0
- package/dist/core/guard/coordinator.d.ts +14 -0
- package/dist/core/guard/coordinator.d.ts.map +1 -0
- package/dist/core/guard/coordinator.js +173 -0
- package/dist/core/guard/evaluator.d.ts +4 -0
- package/dist/core/guard/evaluator.d.ts.map +1 -0
- package/dist/core/guard/evaluator.js +242 -0
- package/dist/core/guard/evidence-v3.d.ts +15 -0
- package/dist/core/guard/evidence-v3.d.ts.map +1 -0
- package/dist/core/guard/evidence-v3.js +171 -0
- package/dist/core/guard/index.d.ts +10 -0
- package/dist/core/guard/index.d.ts.map +1 -0
- package/dist/core/guard/index.js +6 -0
- package/dist/core/guard/live-source-v3.d.ts +40 -0
- package/dist/core/guard/live-source-v3.d.ts.map +1 -0
- package/dist/core/guard/live-source-v3.js +128 -0
- package/dist/core/guard/storage.d.ts +27 -0
- package/dist/core/guard/storage.d.ts.map +1 -0
- package/dist/core/guard/storage.js +140 -0
- package/dist/core/guard/types.d.ts +119 -0
- package/dist/core/guard/types.d.ts.map +1 -0
- package/dist/core/guard/types.js +1 -0
- package/dist/core/hooks/adapter/detect.d.ts +18 -1
- package/dist/core/hooks/adapter/detect.d.ts.map +1 -1
- package/dist/core/hooks/adapter/detect.js +29 -0
- package/dist/core/hooks/adapter/events.d.ts +7 -4
- package/dist/core/hooks/adapter/events.d.ts.map +1 -1
- package/dist/core/hooks/adapter/events.js +12 -4
- package/dist/core/hooks/adapter/output.d.ts +2 -2
- package/dist/core/hooks/adapter/output.d.ts.map +1 -1
- package/dist/core/hooks/adapter/parse.d.ts +7 -4
- package/dist/core/hooks/adapter/parse.d.ts.map +1 -1
- package/dist/core/hooks/adapter/parse.js +63 -25
- package/dist/core/hooks/adapter/wiring.d.ts +30 -4
- package/dist/core/hooks/adapter/wiring.d.ts.map +1 -1
- package/dist/core/hooks/adapter/wiring.js +89 -11
- package/dist/core/hooks/cli.d.ts +1 -1
- package/dist/core/hooks/cli.js +305 -444
- package/dist/core/hooks/effects/image-capture.d.ts +20 -34
- package/dist/core/hooks/effects/image-capture.d.ts.map +1 -1
- package/dist/core/hooks/effects/image-capture.js +212 -221
- package/dist/core/hooks/effects/index.d.ts +1 -9
- package/dist/core/hooks/effects/index.d.ts.map +1 -1
- package/dist/core/hooks/effects/index.js +1 -24
- package/dist/core/hooks/events/input-hash.d.ts +7 -0
- package/dist/core/hooks/events/input-hash.d.ts.map +1 -0
- package/dist/core/hooks/events/input-hash.js +43 -0
- package/dist/core/hooks/index.d.ts +4 -3
- package/dist/core/hooks/index.d.ts.map +1 -1
- package/dist/core/hooks/index.js +2 -3
- package/dist/core/hooks/resolve/coord-root.d.ts +1 -1
- package/dist/core/hooks/resolve/coord-root.js +1 -1
- package/dist/core/hooks/resolve/owner.d.ts +16 -15
- package/dist/core/hooks/resolve/owner.d.ts.map +1 -1
- package/dist/core/hooks/resolve/owner.js +51 -42
- package/dist/core/hooks/resolve/transcript.d.ts +33 -3
- package/dist/core/hooks/resolve/transcript.d.ts.map +1 -1
- package/dist/core/hooks/resolve/transcript.js +155 -14
- package/dist/core/hooks/session-name-presence.d.ts +9 -10
- package/dist/core/hooks/session-name-presence.d.ts.map +1 -1
- package/dist/core/hooks/session-name-presence.js +15 -15
- package/dist/core/hooks/unsafe-cross-shell.d.ts +1 -1
- package/dist/core/hooks/unsafe-cross-shell.d.ts.map +1 -1
- package/dist/core/journal/index.d.ts +2 -2
- package/dist/core/journal/index.d.ts.map +1 -1
- package/dist/core/journal/index.js +9 -22
- package/dist/core/presence/blob.d.ts +4 -3
- package/dist/core/presence/blob.d.ts.map +1 -1
- package/dist/core/presence/blob.js +45 -44
- package/dist/core/presence/codec-digest.d.ts +29 -0
- package/dist/core/presence/codec-digest.d.ts.map +1 -0
- package/dist/core/presence/codec-digest.js +170 -0
- package/dist/core/presence/relay-client.d.ts +1 -1
- package/dist/core/presence/relay-client.d.ts.map +1 -1
- package/dist/core/presence/relay-client.js +5 -5
- package/dist/core/work/index.d.ts +1 -1
- package/dist/core/work/index.d.ts.map +1 -1
- package/dist/core/work/index.js +1 -1
- package/dist/core/work/read.d.ts +1 -1
- package/dist/core/work/read.d.ts.map +1 -1
- package/dist/core/work/read.js +1 -1
- package/dist/core/work/runner.d.ts.map +1 -1
- package/dist/core/work/runner.js +6 -0
- package/dist/core/work/state.d.ts +9 -0
- package/dist/core/work/state.d.ts.map +1 -1
- package/dist/core/work/state.js +17 -3
- package/dist/core/workflow/engine.js +24 -25
- package/dist/core/workflow/live-session-v3.d.ts +19 -0
- package/dist/core/workflow/live-session-v3.d.ts.map +1 -0
- package/dist/core/workflow/live-session-v3.js +86 -0
- package/dist/core/workflow/scope-id.d.ts +3 -0
- package/dist/core/workflow/scope-id.d.ts.map +1 -0
- package/dist/core/workflow/scope-id.js +5 -0
- package/dist/core/workflow/workspaces/leases.d.ts +4 -0
- package/dist/core/workflow/workspaces/leases.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/leases.js +53 -19
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/browser/client.d.ts +41 -0
- package/dist/lib/browser/client.d.ts.map +1 -1
- package/dist/lib/browser/client.js +203 -0
- package/dist/lib/browser/critique.d.ts +28 -2
- package/dist/lib/browser/critique.d.ts.map +1 -1
- package/dist/lib/browser/critique.js +74 -18
- package/dist/lib/browser/geometry.d.ts +1 -1
- package/dist/lib/browser/geometry.d.ts.map +1 -1
- package/dist/lib/browser/geometry.js +130 -6
- package/dist/lib/browser/index.d.ts +3 -0
- package/dist/lib/browser/index.d.ts.map +1 -1
- package/dist/lib/browser/index.js +3 -0
- package/dist/lib/browser/qa-plan.d.ts +174 -0
- package/dist/lib/browser/qa-plan.d.ts.map +1 -0
- package/dist/lib/browser/qa-plan.js +321 -0
- package/dist/lib/browser/qa-reuse.d.ts +99 -0
- package/dist/lib/browser/qa-reuse.d.ts.map +1 -0
- package/dist/lib/browser/qa-reuse.js +222 -0
- package/dist/lib/browser/qa-snapshot.d.ts +64 -0
- package/dist/lib/browser/qa-snapshot.d.ts.map +1 -0
- package/dist/lib/browser/qa-snapshot.js +171 -0
- package/dist/lib/browser/runts.d.ts.map +1 -1
- package/dist/lib/browser/runts.js +22 -1
- package/dist/lib/browser/tiling.d.ts +71 -0
- package/dist/lib/browser/tiling.d.ts.map +1 -0
- package/dist/lib/browser/tiling.js +118 -0
- package/dist/lib/claude-desktop.d.ts +0 -47
- package/dist/lib/claude-desktop.d.ts.map +1 -1
- package/dist/lib/claude-desktop.js +1 -169
- package/dist/lib/context/index.d.ts +0 -3
- package/dist/lib/context/index.d.ts.map +1 -1
- package/dist/lib/context/index.js +20 -42
- package/dist/lib/council/index.d.ts +2 -2
- package/dist/lib/council/index.d.ts.map +1 -1
- package/dist/lib/council/index.js +9 -20
- package/dist/lib/docs-frontmatter.d.ts +1 -6
- package/dist/lib/docs-frontmatter.d.ts.map +1 -1
- package/dist/lib/docs-frontmatter.js +12 -78
- package/dist/lib/docs-index.d.ts +9 -0
- package/dist/lib/docs-index.d.ts.map +1 -1
- package/dist/lib/docs-index.js +32 -3
- package/dist/lib/docs-lint.d.ts.map +1 -1
- package/dist/lib/docs-lint.js +14 -30
- package/dist/lib/docs-metadata-audit.d.ts +19 -0
- package/dist/lib/docs-metadata-audit.d.ts.map +1 -0
- package/dist/lib/docs-metadata-audit.js +132 -0
- package/dist/lib/docs-metadata-managed.d.ts +23 -0
- package/dist/lib/docs-metadata-managed.d.ts.map +1 -0
- package/dist/lib/docs-metadata-managed.js +78 -0
- package/dist/lib/docs-metadata-sync.d.ts +20 -0
- package/dist/lib/docs-metadata-sync.d.ts.map +1 -0
- package/dist/lib/docs-metadata-sync.js +222 -0
- package/dist/lib/docs-metadata-v2-schema.d.ts +273 -0
- package/dist/lib/docs-metadata-v2-schema.d.ts.map +1 -0
- package/dist/lib/docs-metadata-v2-schema.js +134 -0
- package/dist/lib/docs-metadata-v2.d.ts +21 -0
- package/dist/lib/docs-metadata-v2.d.ts.map +1 -0
- package/dist/lib/docs-metadata-v2.js +424 -0
- package/dist/lib/docs-new.d.ts +11 -0
- package/dist/lib/docs-new.d.ts.map +1 -0
- package/dist/lib/docs-new.js +52 -0
- package/dist/lib/docs-sweep.d.ts.map +1 -1
- package/dist/lib/docs-sweep.js +45 -29
- package/dist/lib/headless/index.d.ts +98 -0
- package/dist/lib/headless/index.d.ts.map +1 -0
- package/dist/lib/headless/index.js +211 -0
- package/dist/lib/identities/assume.d.ts +4 -4
- package/dist/lib/identities/assume.d.ts.map +1 -1
- package/dist/lib/identities/assume.js +52 -68
- package/dist/lib/instructions/apply.d.ts +5 -4
- package/dist/lib/instructions/apply.d.ts.map +1 -1
- package/dist/lib/instructions/apply.js +32 -20
- package/dist/lib/instructions/bundle.d.ts +1 -1
- package/dist/lib/instructions/bundle.d.ts.map +1 -1
- package/dist/lib/instructions/bundle.js +1 -1
- package/dist/lib/instructions/splice.d.ts +0 -1
- package/dist/lib/instructions/splice.d.ts.map +1 -1
- package/dist/lib/instructions/splice.js +22 -6
- package/dist/lib/instructions/templates.d.ts +7 -5
- package/dist/lib/instructions/templates.d.ts.map +1 -1
- package/dist/lib/instructions/templates.js +79 -9
- package/package.json +26 -5
- package/schemas/config.schema.json +120 -2
- package/schemas/docs-metadata-v2.schema.json +441 -0
- package/schemas/event-v3.schema.json +24472 -0
- package/src/commander.ts +4 -0
- package/src/commands/adapter.ts +2 -2
- package/src/commands/agents.ts +1512 -592
- package/src/commands/artifacts.ts +7 -6
- package/src/commands/backup.ts +29 -21
- package/src/commands/browse.ts +349 -8
- package/src/commands/checkpoint.ts +4 -3
- package/src/commands/claude-desktop.ts +2 -101
- package/src/commands/context.ts +1 -6
- package/src/commands/decision.ts +27 -44
- package/src/commands/docs.ts +100 -33
- package/src/commands/doctor.ts +14 -1
- package/src/commands/events.ts +256 -0
- package/src/commands/governor.ts +18 -4
- package/src/commands/init.ts +253 -57
- package/src/commands/instructions.ts +1 -1
- package/src/commands/journal.ts +4 -13
- package/src/commands/ledger-v3.ts +111 -0
- package/src/commands/presence.ts +11 -10
- package/src/commands/sync.ts +1 -1
- package/src/commands/web.ts +67 -8
- package/src/commands/work.ts +28 -5
- package/src/core/adapter.ts +5 -0
- package/src/core/adapters/attest.ts +8 -3
- package/src/core/adapters/profiles.ts +4 -6
- package/src/core/agents/canonical-emit.ts +34 -25
- package/src/core/agents/cli.ts +236 -262
- package/src/core/agents/codex-archive-v3.ts +138 -0
- package/src/core/agents/coord-client.ts +75 -188
- package/src/core/agents/finalization.ts +120 -38
- package/src/core/agents/index.ts +4 -5
- package/src/core/agents/live-authority-v3.ts +375 -0
- package/src/core/agents/live-lifecycle-v3.ts +140 -0
- package/src/core/agents/live-observation-v3.ts +216 -0
- package/src/core/agents/render/prompt-context.ts +29 -60
- package/src/core/agents/render/session-context.ts +10 -31
- package/src/core/agents/rules/claim-conflict.ts +85 -126
- package/src/core/agents/rules/commit-conflict.ts +3 -14
- package/src/core/agents/rules/stop-hook.ts +239 -293
- package/src/core/agents/session-events.ts +137 -104
- package/src/core/agents/session-finalization-state-v3.ts +90 -0
- package/src/core/agents/session-finalizer-v3.ts +953 -0
- package/src/core/agents/session-name-display.ts +149 -0
- package/src/core/agents/state/activity-log.ts +6 -14
- package/src/core/agents/state/heartbeat-writer.ts +82 -277
- package/src/core/agents/state/live-coordination-view.ts +290 -0
- package/src/core/agents/state/session-state.ts +24 -12
- package/src/core/agents/state/stale-sweep.ts +40 -17
- package/src/core/artifacts/index.ts +4 -5
- package/src/core/config.ts +148 -3
- package/src/core/context/index.ts +9 -17
- package/src/core/events/span-parent.ts +46 -0
- package/src/core/events/v3/advance.ts +168 -0
- package/src/core/events/v3/authority-outbox.ts +548 -0
- package/src/core/events/v3/base-builder.ts +60 -0
- package/src/core/events/v3/base-contract.ts +882 -0
- package/src/core/events/v3/bootstrap.ts +226 -0
- package/src/core/events/v3/builder.ts +59 -0
- package/src/core/events/v3/canonical.ts +153 -0
- package/src/core/events/v3/capabilities.ts +171 -0
- package/src/core/events/v3/capability-drift.ts +177 -0
- package/src/core/events/v3/catalog.ts +202 -0
- package/src/core/events/v3/clock-order.ts +41 -0
- package/src/core/events/v3/contract.ts +365 -0
- package/src/core/events/v3/control.ts +576 -0
- package/src/core/events/v3/coordination-view.ts +193 -0
- package/src/core/events/v3/economics.ts +384 -0
- package/src/core/events/v3/finalization-view.ts +67 -0
- package/src/core/events/v3/fingerprint-keys.ts +260 -0
- package/src/core/events/v3/generated.ts +48 -0
- package/src/core/events/v3/ids.ts +33 -0
- package/src/core/events/v3/index.ts +322 -0
- package/src/core/events/v3/latency.ts +551 -0
- package/src/core/events/v3/live-feed.ts +319 -0
- package/src/core/events/v3/live-observation.ts +39 -0
- package/src/core/events/v3/live-routing.ts +135 -0
- package/src/core/events/v3/producers/command-recorder.ts +631 -0
- package/src/core/events/v3/producers/command.ts +201 -0
- package/src/core/events/v3/producers/coordination-recorder.ts +538 -0
- package/src/core/events/v3/producers/coordination.ts +355 -0
- package/src/core/events/v3/producers/hook-base.ts +578 -0
- package/src/core/events/v3/producers/hook.ts +119 -0
- package/src/core/events/v3/producers/intake.ts +319 -0
- package/src/core/events/v3/producers/recorder.ts +2805 -0
- package/src/core/events/v3/projection.ts +653 -0
- package/src/core/events/v3/reader.ts +1127 -0
- package/src/core/events/v3/recovery-record.ts +244 -0
- package/src/core/events/v3/recovery.ts +271 -0
- package/src/core/events/v3/span-state.ts +187 -0
- package/src/core/events/v3/targets.ts +182 -0
- package/src/core/events/v3/turn-telemetry.ts +259 -0
- package/src/core/events/v3/validate.ts +361 -0
- package/src/core/events/v3/writer.ts +419 -0
- package/src/core/governor/index.ts +3 -0
- package/src/core/governor/plan-api.ts +10 -2
- package/src/core/governor/read.ts +3 -0
- package/src/core/governor/state.ts +52 -5
- package/src/core/guard/config.ts +206 -0
- package/src/core/guard/coordinator.ts +227 -0
- package/src/core/guard/evaluator.ts +343 -0
- package/src/core/guard/evidence-v3.ts +227 -0
- package/src/core/guard/index.ts +35 -0
- package/src/core/guard/live-source-v3.ts +204 -0
- package/src/core/guard/storage.ts +188 -0
- package/src/core/guard/types.ts +152 -0
- package/src/core/hooks/adapter/detect.ts +28 -1
- package/src/core/hooks/adapter/events.ts +14 -6
- package/src/core/hooks/adapter/output.ts +7 -2
- package/src/core/hooks/adapter/parse.ts +80 -38
- package/src/core/hooks/adapter/wiring.ts +119 -13
- package/src/core/hooks/cli.ts +351 -466
- package/src/core/hooks/effects/image-capture.ts +228 -238
- package/src/core/hooks/effects/index.ts +1 -36
- package/src/core/hooks/events/input-hash.ts +47 -0
- package/src/core/hooks/index.ts +4 -11
- package/src/core/hooks/resolve/coord-root.ts +1 -1
- package/src/core/hooks/resolve/owner.ts +52 -45
- package/src/core/hooks/resolve/transcript.ts +165 -14
- package/src/core/hooks/session-name-presence.ts +14 -15
- package/src/core/hooks/unsafe-cross-shell.ts +1 -1
- package/src/core/journal/index.ts +15 -22
- package/src/core/presence/blob.ts +48 -41
- package/src/core/presence/codec-digest.ts +215 -0
- package/src/core/presence/relay-client.ts +5 -5
- package/src/core/work/index.ts +3 -0
- package/src/core/work/read.ts +3 -0
- package/src/core/work/runner.ts +6 -0
- package/src/core/work/state.ts +27 -3
- package/src/core/workflow/engine.ts +24 -24
- package/src/core/workflow/live-session-v3.ts +126 -0
- package/src/core/workflow/scope-id.ts +6 -0
- package/src/core/workflow/workspaces/leases.ts +56 -19
- package/src/index.ts +1 -1
- package/src/lib/browser/client.ts +230 -0
- package/src/lib/browser/critique.ts +104 -27
- package/src/lib/browser/geometry.ts +143 -14
- package/src/lib/browser/index.ts +34 -0
- package/src/lib/browser/qa-plan.ts +501 -0
- package/src/lib/browser/qa-reuse.ts +306 -0
- package/src/lib/browser/qa-snapshot.ts +223 -0
- package/src/lib/browser/runts.ts +27 -2
- package/src/lib/browser/tiling.ts +164 -0
- package/src/lib/claude-desktop.ts +1 -232
- package/src/lib/context/index.ts +22 -46
- package/src/lib/council/index.ts +9 -21
- package/src/lib/docs-frontmatter.ts +8 -79
- package/src/lib/docs-index.ts +33 -3
- package/src/lib/docs-lint.ts +15 -29
- package/src/lib/docs-metadata-audit.ts +166 -0
- package/src/lib/docs-metadata-managed.ts +83 -0
- package/src/lib/docs-metadata-sync.ts +262 -0
- package/src/lib/docs-metadata-v2-schema.ts +138 -0
- package/src/lib/docs-metadata-v2.ts +646 -0
- package/src/lib/docs-new.ts +63 -0
- package/src/lib/docs-sweep.ts +42 -28
- package/src/lib/headless/index.ts +287 -0
- package/src/lib/identities/assume.ts +67 -86
- package/src/lib/instructions/apply.ts +33 -20
- package/src/lib/instructions/bundle.ts +2 -2
- package/src/lib/instructions/splice.ts +21 -7
- package/src/lib/instructions/templates.ts +85 -13
- package/dist/core/agents/cli-emit.d.ts +0 -27
- package/dist/core/agents/cli-emit.d.ts.map +0 -1
- package/dist/core/agents/cli-emit.js +0 -57
- package/dist/core/agents/codex-replay.d.ts +0 -29
- package/dist/core/agents/codex-replay.d.ts.map +0 -1
- package/dist/core/agents/codex-replay.js +0 -138
- package/dist/core/agents/events/consume.d.ts +0 -82
- package/dist/core/agents/events/consume.d.ts.map +0 -1
- package/dist/core/agents/events/consume.js +0 -195
- package/dist/core/agents/events/emit.d.ts +0 -42
- package/dist/core/agents/events/emit.d.ts.map +0 -1
- package/dist/core/agents/events/emit.js +0 -75
- package/dist/core/agents/events/ulid.d.ts +0 -11
- package/dist/core/agents/events/ulid.d.ts.map +0 -1
- package/dist/core/agents/events/ulid.js +0 -47
- package/dist/core/agents/state/heartbeat-projector.d.ts +0 -76
- package/dist/core/agents/state/heartbeat-projector.d.ts.map +0 -1
- package/dist/core/agents/state/heartbeat-projector.js +0 -581
- package/dist/core/hooks/events/emit.d.ts +0 -31
- package/dist/core/hooks/events/emit.d.ts.map +0 -1
- package/dist/core/hooks/events/emit.js +0 -93
- package/dist/core/hooks/events/rotate.d.ts +0 -43
- package/dist/core/hooks/events/rotate.d.ts.map +0 -1
- package/dist/core/hooks/events/rotate.js +0 -142
- package/dist/core/hooks/events/schema.d.ts +0 -341
- package/dist/core/hooks/events/schema.d.ts.map +0 -1
- package/dist/core/hooks/events/schema.js +0 -12
- package/dist/core/hooks/events/ulid.d.ts +0 -10
- package/dist/core/hooks/events/ulid.d.ts.map +0 -1
- package/dist/core/hooks/events/ulid.js +0 -47
- package/dist/lib/docs-frontmatter-migrate.d.ts +0 -33
- package/dist/lib/docs-frontmatter-migrate.d.ts.map +0 -1
- package/dist/lib/docs-frontmatter-migrate.js +0 -364
- package/src/core/agents/cli-emit.ts +0 -64
- package/src/core/agents/codex-replay.ts +0 -163
- package/src/core/agents/events/consume.ts +0 -254
- package/src/core/agents/events/emit.ts +0 -115
- package/src/core/agents/events/ulid.ts +0 -51
- package/src/core/agents/state/heartbeat-projector.ts +0 -645
- package/src/core/hooks/events/emit.ts +0 -125
- package/src/core/hooks/events/rotate.ts +0 -151
- package/src/core/hooks/events/schema.ts +0 -582
- package/src/core/hooks/events/ulid.ts +0 -51
- package/src/lib/docs-frontmatter-migrate.ts +0 -427
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
EvaluateRunQualityInput,
|
|
3
|
+
RunQualityEvaluatorState,
|
|
4
|
+
RunQualityEvidenceEvent,
|
|
5
|
+
RunQualitySignal,
|
|
6
|
+
RunQualitySnapshot,
|
|
7
|
+
RunQualityStatus,
|
|
8
|
+
} from "./types.ts";
|
|
9
|
+
import { RUN_QUALITY_SCHEMA_VERSION } from "./types.ts";
|
|
10
|
+
|
|
11
|
+
const LEVELS: RunQualityStatus[] = ["unknown", "healthy", "attention", "critical"];
|
|
12
|
+
|
|
13
|
+
/** Pure report-only transition. It has no filesystem, process, or verdict dependencies. */
|
|
14
|
+
export function evaluateRunQuality(input: EvaluateRunQualityInput): RunQualitySnapshot {
|
|
15
|
+
const configChanged = !!input.previous && input.previous.config_digest !== input.config_digest;
|
|
16
|
+
const sameGeneration =
|
|
17
|
+
!input.previous || input.previous.session_generation === input.session_generation;
|
|
18
|
+
const priorState = !configChanged && sameGeneration ? input.previous?.state : undefined;
|
|
19
|
+
const state = cloneState(priorState);
|
|
20
|
+
const events = [...input.events].sort(compareEvidence);
|
|
21
|
+
let progressSeen = false;
|
|
22
|
+
let newEvidence = false;
|
|
23
|
+
|
|
24
|
+
for (const event of events) {
|
|
25
|
+
if (input.previous?.evidence.last_event_id === event.event_id) continue;
|
|
26
|
+
newEvidence = true;
|
|
27
|
+
progressSeen = applyEvidence(state, event, input) || progressSeen;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const legitimateWait = input.role_wait.fresh && input.role_wait.wait_kind !== "none";
|
|
31
|
+
const deadlineEpoch = !newEvidence && input.live && !legitimateWait;
|
|
32
|
+
const epoch = newEvidence ? "evidence" : deadlineEpoch ? "deadline" : "read";
|
|
33
|
+
|
|
34
|
+
const inGrace = graceActive(state, input.now);
|
|
35
|
+
const signals = buildSignals(state, input, inGrace);
|
|
36
|
+
const precursorFamilies = new Set(
|
|
37
|
+
signals
|
|
38
|
+
.filter(
|
|
39
|
+
(signal) =>
|
|
40
|
+
signal.state === "active" &&
|
|
41
|
+
signal.id !== "no_progress" &&
|
|
42
|
+
signal.id !== "compaction_grace",
|
|
43
|
+
)
|
|
44
|
+
.map((signal) =>
|
|
45
|
+
signal.id === "repeated_tool_calls" || signal.id === "target_stagnation"
|
|
46
|
+
? "tool_behavior"
|
|
47
|
+
: signal.id,
|
|
48
|
+
),
|
|
49
|
+
).size;
|
|
50
|
+
|
|
51
|
+
if (progressSeen) {
|
|
52
|
+
state.no_progress_epochs = 0;
|
|
53
|
+
state.no_progress_deadline_epochs = 0;
|
|
54
|
+
} else if (precursorFamilies >= 2 && (newEvidence || deadlineEpoch)) {
|
|
55
|
+
state.no_progress_epochs++;
|
|
56
|
+
if (deadlineEpoch) state.no_progress_deadline_epochs++;
|
|
57
|
+
}
|
|
58
|
+
replaceSignal(signals, noProgressSignal(state, input, inGrace, legitimateWait));
|
|
59
|
+
|
|
60
|
+
let desired = desiredStatus(signals, input.sufficient_history, input.evidence.truncated);
|
|
61
|
+
if (progressSeen && desired === "critical") desired = "attention";
|
|
62
|
+
const previousStatus = input.previous?.status ?? "unknown";
|
|
63
|
+
const transitionBase = configChanged || !sameGeneration ? "unknown" : previousStatus;
|
|
64
|
+
const status = stepOneLevel(transitionBase, desired);
|
|
65
|
+
const evaluatedAt = input.now;
|
|
66
|
+
const nextEligibleAt = addSeconds(evaluatedAt, input.config.evaluation_interval_seconds);
|
|
67
|
+
const expiresAt = addSeconds(evaluatedAt, input.config.snapshot_ttl_seconds);
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
schema_version: RUN_QUALITY_SCHEMA_VERSION,
|
|
71
|
+
instance_id: input.instance_id,
|
|
72
|
+
session_id: input.session_id,
|
|
73
|
+
session_generation: input.session_generation,
|
|
74
|
+
adapter: input.adapter,
|
|
75
|
+
config_digest: input.config_digest,
|
|
76
|
+
mode: input.config.mode === "report" ? "report" : "shadow",
|
|
77
|
+
status,
|
|
78
|
+
previous_status: previousStatus,
|
|
79
|
+
evaluated_at: evaluatedAt,
|
|
80
|
+
next_eligible_at: nextEligibleAt,
|
|
81
|
+
expires_at: expiresAt,
|
|
82
|
+
evidence: input.evidence,
|
|
83
|
+
signals,
|
|
84
|
+
role_wait: input.role_wait,
|
|
85
|
+
state,
|
|
86
|
+
epoch,
|
|
87
|
+
reason: configChanged
|
|
88
|
+
? "config_changed"
|
|
89
|
+
: !input.sufficient_history || input.evidence.truncated
|
|
90
|
+
? "insufficient_evidence"
|
|
91
|
+
: deadlineEpoch
|
|
92
|
+
? "deadline"
|
|
93
|
+
: "evidence",
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function applyEvidence(
|
|
98
|
+
state: RunQualityEvaluatorState,
|
|
99
|
+
event: RunQualityEvidenceEvent,
|
|
100
|
+
input: EvaluateRunQualityInput,
|
|
101
|
+
): boolean {
|
|
102
|
+
switch (event.kind) {
|
|
103
|
+
case "tool_call":
|
|
104
|
+
state.work_since_progress++;
|
|
105
|
+
if (event.target_hash) {
|
|
106
|
+
state.target_hash_seen = true;
|
|
107
|
+
if (state.target_hash === event.target_hash) state.target_streak++;
|
|
108
|
+
else {
|
|
109
|
+
state.target_hash = event.target_hash;
|
|
110
|
+
state.target_streak = 1;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (!event.input_hash) {
|
|
114
|
+
state.missing_hash_seen = true;
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
state.exact_hash_seen = true;
|
|
118
|
+
if (state.repeated_hash === event.input_hash) state.repeated_count++;
|
|
119
|
+
else {
|
|
120
|
+
state.repeated_hash = event.input_hash;
|
|
121
|
+
state.repeated_count = 1;
|
|
122
|
+
}
|
|
123
|
+
return false;
|
|
124
|
+
case "tool_success":
|
|
125
|
+
state.failure_streak = 0;
|
|
126
|
+
return false;
|
|
127
|
+
case "tool_failure":
|
|
128
|
+
state.failure_streak++;
|
|
129
|
+
return false;
|
|
130
|
+
case "progress":
|
|
131
|
+
state.work_since_progress = 0;
|
|
132
|
+
state.target_streak = 0;
|
|
133
|
+
return true;
|
|
134
|
+
case "context_sample":
|
|
135
|
+
applyContextSample(state, event, input.adapter);
|
|
136
|
+
return false;
|
|
137
|
+
case "compaction_started":
|
|
138
|
+
state.compaction_grace_until = addSeconds(
|
|
139
|
+
event.ts,
|
|
140
|
+
input.config.thresholds.compaction_grace_seconds,
|
|
141
|
+
);
|
|
142
|
+
return false;
|
|
143
|
+
case "compaction_completed":
|
|
144
|
+
state.compaction_grace_until = addSeconds(
|
|
145
|
+
event.ts,
|
|
146
|
+
input.config.thresholds.compaction_grace_seconds,
|
|
147
|
+
);
|
|
148
|
+
return true;
|
|
149
|
+
case "tool_pairing_incomplete":
|
|
150
|
+
case "command_pairing_incomplete":
|
|
151
|
+
case "recovered_terminal":
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function applyContextSample(
|
|
157
|
+
state: RunQualityEvaluatorState,
|
|
158
|
+
event: RunQualityEvidenceEvent,
|
|
159
|
+
adapter: string,
|
|
160
|
+
): void {
|
|
161
|
+
if (
|
|
162
|
+
event.used_tokens === undefined ||
|
|
163
|
+
!Number.isFinite(event.used_tokens) ||
|
|
164
|
+
!attestedContextSource(adapter, event.telemetry_source, event.confidence)
|
|
165
|
+
) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const previous = state.last_context;
|
|
169
|
+
if (previous) {
|
|
170
|
+
const minutes = (Date.parse(event.ts) - Date.parse(previous.ts)) / 60_000;
|
|
171
|
+
if (Number.isFinite(minutes) && minutes > 0) {
|
|
172
|
+
state.context_growth_per_minute = (event.used_tokens - previous.used_tokens) / minutes;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
state.last_context = { used_tokens: event.used_tokens, ts: event.ts };
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function attestedContextSource(
|
|
179
|
+
adapter: string,
|
|
180
|
+
source: string | undefined,
|
|
181
|
+
confidence: RunQualityEvidenceEvent["confidence"],
|
|
182
|
+
): boolean {
|
|
183
|
+
if (confidence !== "exact" && confidence !== "reported") return false;
|
|
184
|
+
const allowed: Record<string, readonly string[]> = {
|
|
185
|
+
"claude-code": ["hook", "native_event", "result"],
|
|
186
|
+
codex: ["native_event", "result", "transcript"],
|
|
187
|
+
cursor: ["native_event"],
|
|
188
|
+
};
|
|
189
|
+
return !!source && (allowed[adapter] ?? []).includes(source);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function buildSignals(
|
|
193
|
+
state: RunQualityEvaluatorState,
|
|
194
|
+
input: EvaluateRunQualityInput,
|
|
195
|
+
inGrace: boolean,
|
|
196
|
+
): RunQualitySignal[] {
|
|
197
|
+
const t = input.config.thresholds;
|
|
198
|
+
return [
|
|
199
|
+
thresholdSignal(
|
|
200
|
+
"repeated_tool_calls",
|
|
201
|
+
state.repeated_count,
|
|
202
|
+
t.repeated_tool_calls,
|
|
203
|
+
state.exact_hash_seen ? "exact_input_hash" : "exact_input_hash_unavailable",
|
|
204
|
+
!state.exact_hash_seen && state.missing_hash_seen,
|
|
205
|
+
),
|
|
206
|
+
thresholdSignal(
|
|
207
|
+
"consecutive_failures",
|
|
208
|
+
state.failure_streak,
|
|
209
|
+
t.consecutive_failures,
|
|
210
|
+
"consecutive_outcomes",
|
|
211
|
+
false,
|
|
212
|
+
),
|
|
213
|
+
inGrace
|
|
214
|
+
? signal("context_growth", "suppressed", "none", 0, "compaction_grace")
|
|
215
|
+
: state.context_growth_per_minute === undefined
|
|
216
|
+
? signal("context_growth", "unknown", "none", 0, "attested_samples_unavailable")
|
|
217
|
+
: thresholdSignal(
|
|
218
|
+
"context_growth",
|
|
219
|
+
Math.max(0, Math.round(state.context_growth_per_minute)),
|
|
220
|
+
t.context_growth_per_minute,
|
|
221
|
+
"attested_context_velocity",
|
|
222
|
+
false,
|
|
223
|
+
),
|
|
224
|
+
thresholdSignal(
|
|
225
|
+
"target_stagnation",
|
|
226
|
+
state.target_streak,
|
|
227
|
+
t.repeated_tool_calls,
|
|
228
|
+
"same_target_without_progress_event",
|
|
229
|
+
!state.target_hash_seen,
|
|
230
|
+
),
|
|
231
|
+
signal("no_progress", "inactive", "none", state.no_progress_epochs, "not_corroborated"),
|
|
232
|
+
inGrace
|
|
233
|
+
? signal("compaction_grace", "active", "none", 1, "within_grace_deadline")
|
|
234
|
+
: signal("compaction_grace", "inactive", "none", 0, "outside_grace_deadline"),
|
|
235
|
+
];
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function noProgressSignal(
|
|
239
|
+
state: RunQualityEvaluatorState,
|
|
240
|
+
input: EvaluateRunQualityInput,
|
|
241
|
+
inGrace: boolean,
|
|
242
|
+
legitimateWait: boolean,
|
|
243
|
+
): RunQualitySignal {
|
|
244
|
+
if (inGrace) return signal("no_progress", "suppressed", "none", 0, "compaction_grace");
|
|
245
|
+
if (legitimateWait) return signal("no_progress", "suppressed", "none", 0, "legitimate_wait");
|
|
246
|
+
if (state.no_progress_deadline_epochs < 1) {
|
|
247
|
+
return signal(
|
|
248
|
+
"no_progress",
|
|
249
|
+
"inactive",
|
|
250
|
+
"none",
|
|
251
|
+
state.no_progress_epochs,
|
|
252
|
+
"deadline_epoch_required",
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
return thresholdSignal(
|
|
256
|
+
"no_progress",
|
|
257
|
+
state.no_progress_epochs,
|
|
258
|
+
input.config.thresholds.no_progress_evaluations,
|
|
259
|
+
"corroborated_epochs",
|
|
260
|
+
false,
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function thresholdSignal(
|
|
265
|
+
id: RunQualitySignal["id"],
|
|
266
|
+
count: number,
|
|
267
|
+
threshold: number,
|
|
268
|
+
reason: string,
|
|
269
|
+
unknown: boolean,
|
|
270
|
+
): RunQualitySignal {
|
|
271
|
+
if (unknown) return signal(id, "unknown", "none", count, reason);
|
|
272
|
+
if (count >= threshold * 2) return signal(id, "active", "critical", count, reason);
|
|
273
|
+
if (count >= threshold) return signal(id, "active", "attention", count, reason);
|
|
274
|
+
return signal(id, "inactive", "none", count, reason);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function signal(
|
|
278
|
+
id: RunQualitySignal["id"],
|
|
279
|
+
state: RunQualitySignal["state"],
|
|
280
|
+
severity: RunQualitySignal["severity"],
|
|
281
|
+
count: number,
|
|
282
|
+
reason_code: string,
|
|
283
|
+
): RunQualitySignal {
|
|
284
|
+
return { id, state, severity, count, reason_code };
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function replaceSignal(signals: RunQualitySignal[], next: RunQualitySignal): void {
|
|
288
|
+
const index = signals.findIndex((signal) => signal.id === next.id);
|
|
289
|
+
if (index >= 0) signals[index] = next;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function desiredStatus(
|
|
293
|
+
signals: RunQualitySignal[],
|
|
294
|
+
sufficientHistory: boolean,
|
|
295
|
+
truncated: boolean,
|
|
296
|
+
): RunQualityStatus {
|
|
297
|
+
if (!sufficientHistory || truncated) return "unknown";
|
|
298
|
+
if (signals.some((signal) => signal.state === "active" && signal.severity === "critical")) {
|
|
299
|
+
return "critical";
|
|
300
|
+
}
|
|
301
|
+
if (signals.some((signal) => signal.state === "active" && signal.severity === "attention")) {
|
|
302
|
+
return "attention";
|
|
303
|
+
}
|
|
304
|
+
return "healthy";
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function stepOneLevel(previous: RunQualityStatus, desired: RunQualityStatus): RunQualityStatus {
|
|
308
|
+
if (previous === desired) return previous;
|
|
309
|
+
if (previous === "unknown") return desired === "critical" ? "attention" : desired;
|
|
310
|
+
if (desired === "unknown") return "unknown";
|
|
311
|
+
const from = LEVELS.indexOf(previous);
|
|
312
|
+
const to = LEVELS.indexOf(desired);
|
|
313
|
+
return LEVELS[from + Math.sign(to - from)] ?? desired;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function graceActive(state: RunQualityEvaluatorState, now: string): boolean {
|
|
317
|
+
if (!state.compaction_grace_until) return false;
|
|
318
|
+
return Date.parse(now) < Date.parse(state.compaction_grace_until);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function cloneState(previous?: RunQualityEvaluatorState): RunQualityEvaluatorState {
|
|
322
|
+
return previous
|
|
323
|
+
? structuredClone(previous)
|
|
324
|
+
: {
|
|
325
|
+
repeated_count: 0,
|
|
326
|
+
exact_hash_seen: false,
|
|
327
|
+
missing_hash_seen: false,
|
|
328
|
+
target_streak: 0,
|
|
329
|
+
target_hash_seen: false,
|
|
330
|
+
failure_streak: 0,
|
|
331
|
+
work_since_progress: 0,
|
|
332
|
+
no_progress_epochs: 0,
|
|
333
|
+
no_progress_deadline_epochs: 0,
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function compareEvidence(a: RunQualityEvidenceEvent, b: RunQualityEvidenceEvent): number {
|
|
338
|
+
return a.event_id.localeCompare(b.event_id) || a.ts.localeCompare(b.ts);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function addSeconds(iso: string, seconds: number): string {
|
|
342
|
+
return new Date(Date.parse(iso) + seconds * 1000).toISOString();
|
|
343
|
+
}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { canonicalJsonV3, type EventV3 } from "../events/v3/index.ts";
|
|
3
|
+
import type { RunQualityCorpusCategoryV3, RunQualityEvidenceEvent } from "./types.ts";
|
|
4
|
+
|
|
5
|
+
interface GenerationScope {
|
|
6
|
+
root_id: string;
|
|
7
|
+
instance_id: string;
|
|
8
|
+
session_id: string;
|
|
9
|
+
generation_id: string;
|
|
10
|
+
workflow_id?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface GenerationLinks {
|
|
14
|
+
caused_by: string[];
|
|
15
|
+
parent_generation_id?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Convert one validated V3 row into the evaluator's privacy-safe evidence.
|
|
20
|
+
* Both the live guard and offline corpus use this exact adapter.
|
|
21
|
+
*/
|
|
22
|
+
export function normalizeRunQualityEventV3(
|
|
23
|
+
event: EventV3,
|
|
24
|
+
priorEvents: ReadonlyMap<string, EventV3> = new Map(),
|
|
25
|
+
): RunQualityEvidenceEvent[] {
|
|
26
|
+
const base = { event_id: event.event_id, ts: event.time.observed_at };
|
|
27
|
+
const recovery = recoveryCategory(event, base);
|
|
28
|
+
switch (event.event_type) {
|
|
29
|
+
case "tool.requested":
|
|
30
|
+
return [
|
|
31
|
+
{
|
|
32
|
+
...base,
|
|
33
|
+
kind: "tool_call",
|
|
34
|
+
input_hash: bareDigest(event.payload.exact_input.digest),
|
|
35
|
+
target_hash: combinedTargetHash(
|
|
36
|
+
event.payload.targets.map(({ fingerprint }) => fingerprint.digest),
|
|
37
|
+
),
|
|
38
|
+
},
|
|
39
|
+
...recovery,
|
|
40
|
+
];
|
|
41
|
+
case "tool.completed":
|
|
42
|
+
return [
|
|
43
|
+
{
|
|
44
|
+
...base,
|
|
45
|
+
kind: event.payload.outcome === "succeeded" ? "tool_success" : "tool_failure",
|
|
46
|
+
},
|
|
47
|
+
...recovery,
|
|
48
|
+
];
|
|
49
|
+
case "command.completed":
|
|
50
|
+
return recovery;
|
|
51
|
+
case "turn.started":
|
|
52
|
+
return [{ ...base, kind: "progress" }];
|
|
53
|
+
case "progress.observed":
|
|
54
|
+
return trustedProgress(event, priorEvents) ? [{ ...base, kind: "progress" }] : [];
|
|
55
|
+
case "context.observed": {
|
|
56
|
+
const measurement = event.payload.measurement;
|
|
57
|
+
if (measurement.state !== "observed") return [];
|
|
58
|
+
return [
|
|
59
|
+
{
|
|
60
|
+
...base,
|
|
61
|
+
kind: "context_sample",
|
|
62
|
+
used_tokens: measurement.value.used_tokens,
|
|
63
|
+
confidence: evidenceConfidence(measurement.attestation, measurement.confidence),
|
|
64
|
+
telemetry_source: telemetrySource(measurement.value.method),
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
case "context.compaction_started":
|
|
69
|
+
return [{ ...base, kind: "compaction_started" }];
|
|
70
|
+
case "context.compaction_completed":
|
|
71
|
+
return [{ ...base, kind: "compaction_completed" }];
|
|
72
|
+
default:
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Derive generation-level pairing markers from validated events. The markers
|
|
79
|
+
* are audit metadata, not behavioral guard evidence: callers keep them in a
|
|
80
|
+
* separate corpus-category dimension.
|
|
81
|
+
*/
|
|
82
|
+
export function normalizeRunQualityPairingV3(
|
|
83
|
+
events: readonly EventV3[],
|
|
84
|
+
): RunQualityEvidenceEvent[] {
|
|
85
|
+
const spans = new Map<
|
|
86
|
+
string,
|
|
87
|
+
{
|
|
88
|
+
tool_requested: EventV3[];
|
|
89
|
+
tool_completed: EventV3[];
|
|
90
|
+
started_commands: EventV3[];
|
|
91
|
+
completed_commands: EventV3[];
|
|
92
|
+
}
|
|
93
|
+
>();
|
|
94
|
+
for (const event of events) {
|
|
95
|
+
if (
|
|
96
|
+
event.event_type !== "tool.requested" &&
|
|
97
|
+
event.event_type !== "tool.completed" &&
|
|
98
|
+
event.event_type !== "command.started" &&
|
|
99
|
+
event.event_type !== "command.completed"
|
|
100
|
+
) {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
const spanId = (event.links as { span_id?: string }).span_id;
|
|
104
|
+
if (!spanId) continue;
|
|
105
|
+
const span = spans.get(spanId) ?? {
|
|
106
|
+
tool_requested: [],
|
|
107
|
+
tool_completed: [],
|
|
108
|
+
started_commands: [],
|
|
109
|
+
completed_commands: [],
|
|
110
|
+
};
|
|
111
|
+
if (event.event_type === "tool.requested") span.tool_requested.push(event);
|
|
112
|
+
else if (event.event_type === "tool.completed") span.tool_completed.push(event);
|
|
113
|
+
else if (event.event_type === "command.started") span.started_commands.push(event);
|
|
114
|
+
else span.completed_commands.push(event);
|
|
115
|
+
spans.set(spanId, span);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const markers: RunQualityEvidenceEvent[] = [];
|
|
119
|
+
for (const span of spans.values()) {
|
|
120
|
+
if (
|
|
121
|
+
(span.tool_requested.length > 0 || span.tool_completed.length > 0) &&
|
|
122
|
+
(span.tool_requested.length !== 1 || span.tool_completed.length !== 1)
|
|
123
|
+
) {
|
|
124
|
+
markers.push(
|
|
125
|
+
pairingMarker("tool_pairing_incomplete", span.tool_requested, span.tool_completed),
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
if (
|
|
129
|
+
(span.started_commands.length > 0 || span.completed_commands.length > 0) &&
|
|
130
|
+
(span.started_commands.length !== 1 || span.completed_commands.length !== 1)
|
|
131
|
+
) {
|
|
132
|
+
markers.push(
|
|
133
|
+
pairingMarker("command_pairing_incomplete", span.started_commands, span.completed_commands),
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return markers;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function isRunQualityCorpusCategoryV3(
|
|
141
|
+
kind: RunQualityEvidenceEvent["kind"],
|
|
142
|
+
): kind is RunQualityCorpusCategoryV3 {
|
|
143
|
+
return (
|
|
144
|
+
kind === "tool_pairing_incomplete" ||
|
|
145
|
+
kind === "command_pairing_incomplete" ||
|
|
146
|
+
kind === "recovered_terminal"
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function recoveryCategory(
|
|
151
|
+
event: EventV3,
|
|
152
|
+
base: Pick<RunQualityEvidenceEvent, "event_id" | "ts">,
|
|
153
|
+
): RunQualityEvidenceEvent[] {
|
|
154
|
+
if (!("recovery" in event.payload) || event.payload.recovery === undefined) return [];
|
|
155
|
+
return [{ ...base, kind: "recovered_terminal" }];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function pairingMarker(
|
|
159
|
+
kind: Extract<
|
|
160
|
+
RunQualityCorpusCategoryV3,
|
|
161
|
+
"tool_pairing_incomplete" | "command_pairing_incomplete"
|
|
162
|
+
>,
|
|
163
|
+
left: EventV3[],
|
|
164
|
+
right: EventV3[],
|
|
165
|
+
): RunQualityEvidenceEvent {
|
|
166
|
+
const witness = [...left, ...right].sort(
|
|
167
|
+
(a, b) =>
|
|
168
|
+
a.time.observed_at.localeCompare(b.time.observed_at) || a.event_id.localeCompare(b.event_id),
|
|
169
|
+
)[0]!;
|
|
170
|
+
return { event_id: witness.event_id, ts: witness.time.observed_at, kind };
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function trustedProgress(
|
|
174
|
+
event: Extract<EventV3, { event_type: "progress.observed" }>,
|
|
175
|
+
priorEvents: ReadonlyMap<string, EventV3>,
|
|
176
|
+
): boolean {
|
|
177
|
+
const links = event.links as GenerationLinks;
|
|
178
|
+
const scope = event.scope as GenerationScope;
|
|
179
|
+
if (!event.payload.evidence_event_ids.every((eventId) => links.caused_by.includes(eventId))) {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
return event.payload.evidence_event_ids.every((eventId) => {
|
|
183
|
+
const evidence = priorEvents.get(eventId);
|
|
184
|
+
if (!evidence || !("generation_id" in evidence.scope)) return false;
|
|
185
|
+
if (evidence.scope.generation_id !== scope.generation_id) return false;
|
|
186
|
+
switch (evidence.event_type) {
|
|
187
|
+
case "tool.completed":
|
|
188
|
+
case "turn.completed":
|
|
189
|
+
case "run.completed":
|
|
190
|
+
case "command.completed":
|
|
191
|
+
case "agent.completed":
|
|
192
|
+
return evidence.payload.outcome === "succeeded";
|
|
193
|
+
case "artifact.observed":
|
|
194
|
+
return evidence.payload.operation !== "viewed";
|
|
195
|
+
default:
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function combinedTargetHash(digests: string[]): string | undefined {
|
|
202
|
+
const unique = [...new Set(digests.map(bareDigest))].sort();
|
|
203
|
+
if (unique.length === 0) return undefined;
|
|
204
|
+
if (unique.length === 1) return unique[0];
|
|
205
|
+
return createHash("sha256").update(canonicalJsonV3(unique)).digest("hex");
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function bareDigest(digest: string): string {
|
|
209
|
+
return digest.slice("sha256:".length);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function evidenceConfidence(
|
|
213
|
+
attestation: "native" | "derived" | "inferred",
|
|
214
|
+
confidence: "exact" | "high" | "medium" | "low",
|
|
215
|
+
): NonNullable<RunQualityEvidenceEvent["confidence"]> {
|
|
216
|
+
if (attestation === "native" && confidence === "exact") return "exact";
|
|
217
|
+
if (attestation === "inferred") return "estimated";
|
|
218
|
+
return "reported";
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function telemetrySource(method: string): string {
|
|
222
|
+
if (method.endsWith("_hook")) return "hook";
|
|
223
|
+
if (method.includes("transcript")) return "transcript";
|
|
224
|
+
if (method.includes("result")) return "result";
|
|
225
|
+
if (method.includes("estimate")) return "estimate";
|
|
226
|
+
return "native_event";
|
|
227
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export { DEFAULT_RUN_QUALITY_CONFIG, readRunQualityConfig } from "./config.ts";
|
|
2
|
+
export type { RunQualityEvaluationResult } from "./coordinator.ts";
|
|
3
|
+
export { evaluateRunQualityIfDue } from "./coordinator.ts";
|
|
4
|
+
export { evaluateRunQuality } from "./evaluator.ts";
|
|
5
|
+
export {
|
|
6
|
+
isRunQualityCorpusCategoryV3,
|
|
7
|
+
normalizeRunQualityEventV3,
|
|
8
|
+
normalizeRunQualityPairingV3,
|
|
9
|
+
} from "./evidence-v3.ts";
|
|
10
|
+
export type {
|
|
11
|
+
RunQualityLiveGenerationV3,
|
|
12
|
+
RunQualityLiveSourceV3,
|
|
13
|
+
} from "./live-source-v3.ts";
|
|
14
|
+
export {
|
|
15
|
+
projectRunQualityLiveSourceV3,
|
|
16
|
+
RunQualityLiveSourceV3Error,
|
|
17
|
+
readRunQualityLiveSourceV3,
|
|
18
|
+
} from "./live-source-v3.ts";
|
|
19
|
+
export {
|
|
20
|
+
readFreshRunQualitySnapshot,
|
|
21
|
+
readRunQualitySnapshot,
|
|
22
|
+
} from "./storage.ts";
|
|
23
|
+
export type {
|
|
24
|
+
EvaluateRunQualityInput,
|
|
25
|
+
RunQualityConfig,
|
|
26
|
+
RunQualityConfigResult,
|
|
27
|
+
RunQualityCorpusCategoryV3,
|
|
28
|
+
RunQualityEvidenceEvent,
|
|
29
|
+
RunQualityMode,
|
|
30
|
+
RunQualityRoleWait,
|
|
31
|
+
RunQualitySignal,
|
|
32
|
+
RunQualitySnapshot,
|
|
33
|
+
RunQualityStatus,
|
|
34
|
+
RunQualityWaitKind,
|
|
35
|
+
} from "./types.ts";
|