harnery 0.32.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/README.md +2 -0
- package/dist/commander.d.ts.map +1 -1
- package/dist/commander.js +7 -1
- 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 +1408 -565
- 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 +2 -2
- package/dist/commands/claude-desktop.d.ts.map +1 -1
- package/dist/commands/claude-desktop.js +2 -2
- 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.d.ts +4 -2
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +55 -7
- 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 +10 -2
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +233 -51
- package/dist/commands/instructions.d.ts +4 -0
- package/dist/commands/instructions.d.ts.map +1 -0
- package/dist/commands/instructions.js +100 -0
- 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 +15 -6
- 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 +27 -25
- package/dist/core/agents/cli.js +212 -235
- 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 -70
- 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 +5 -5
- package/dist/core/agents/index.d.ts.map +1 -1
- package/dist/core/agents/index.js +5 -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 +10 -4
- package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
- package/dist/core/agents/render/prompt-context.js +61 -55
- 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 +15 -33
- 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 +29 -46
- package/dist/core/agents/state/heartbeat-writer.d.ts.map +1 -1
- package/dist/core/agents/state/heartbeat-writer.js +59 -199
- 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 +45 -0
- package/dist/core/agents/state/session-state.d.ts.map +1 -0
- package/dist/core/agents/state/session-state.js +90 -0
- 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 +13 -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 +64 -24
- 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 +345 -400
- package/dist/core/hooks/codex-authorization.d.ts +30 -0
- package/dist/core/hooks/codex-authorization.d.ts.map +1 -0
- package/dist/core/hooks/codex-authorization.js +199 -0
- 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 +8 -3
- package/dist/core/presence/blob.d.ts.map +1 -1
- package/dist/core/presence/blob.js +54 -41
- 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/index.js +15 -1
- 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/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 +33 -0
- package/dist/lib/instructions/bundle.d.ts.map +1 -0
- package/dist/lib/instructions/bundle.js +149 -0
- 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 +27 -6
- 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 +7 -1
- package/src/commands/adapter.ts +2 -2
- package/src/commands/agents.ts +1737 -570
- 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 +7 -5
- 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 +73 -8
- package/src/commands/events.ts +256 -0
- package/src/commands/governor.ts +18 -4
- package/src/commands/init.ts +264 -57
- package/src/commands/instructions.ts +129 -0
- package/src/commands/journal.ts +4 -13
- package/src/commands/ledger-v3.ts +111 -0
- package/src/commands/presence.ts +18 -11
- 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 +39 -28
- package/src/core/agents/cli.ts +242 -263
- package/src/core/agents/codex-archive-v3.ts +138 -0
- package/src/core/agents/coord-client.ts +75 -177
- package/src/core/agents/finalization.ts +120 -38
- package/src/core/agents/index.ts +5 -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 +89 -55
- package/src/core/agents/render/session-context.ts +23 -32
- 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 +98 -242
- package/src/core/agents/state/live-coordination-view.ts +290 -0
- package/src/core/agents/state/session-state.ts +143 -0
- 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 +15 -6
- package/src/core/hooks/adapter/output.ts +7 -2
- package/src/core/hooks/adapter/parse.ts +81 -36
- package/src/core/hooks/adapter/wiring.ts +119 -13
- package/src/core/hooks/cli.ts +398 -422
- package/src/core/hooks/codex-authorization.ts +253 -0
- 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 +63 -38
- package/src/core/presence/codec-digest.ts +215 -0
- package/src/core/presence/index.ts +18 -1
- 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/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 +199 -0
- 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 -65
- package/dist/core/agents/state/heartbeat-projector.d.ts.map +0 -1
- package/dist/core/agents/state/heartbeat-projector.js +0 -527
- 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 -312
- 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 -582
- 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 -538
- package/src/core/hooks/events/ulid.ts +0 -51
- package/src/lib/docs-frontmatter-migrate.ts +0 -427
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
import type { ReadLedgerV3Result } from "./reader.ts";
|
|
2
|
+
|
|
3
|
+
export const EVENT_V3_LATENCY_PROJECTION_VERSION = "event-v3-latency-v1" as const;
|
|
4
|
+
|
|
5
|
+
export type LatencyMetricV3 =
|
|
6
|
+
| { state: "observed"; value_ms: number }
|
|
7
|
+
| { state: "unknown"; known_ms: number; upper_bound_ms?: number; reasons: string[] };
|
|
8
|
+
|
|
9
|
+
export interface ToolLatencyV3 {
|
|
10
|
+
namespace: string;
|
|
11
|
+
name: string;
|
|
12
|
+
count: number;
|
|
13
|
+
duration_ms: LatencyMetricV3;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type ContextCoverageStateV3 =
|
|
17
|
+
| "observed"
|
|
18
|
+
| "partial"
|
|
19
|
+
| "unsupported"
|
|
20
|
+
| "expected_but_missing";
|
|
21
|
+
|
|
22
|
+
export interface ContextCoverageV3 {
|
|
23
|
+
state: ContextCoverageStateV3;
|
|
24
|
+
event_id: string | null;
|
|
25
|
+
reason: string | null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface TurnLatencyV3 {
|
|
29
|
+
generation_id: string;
|
|
30
|
+
turn_id: string;
|
|
31
|
+
terminal_event_id: string;
|
|
32
|
+
outcome: string;
|
|
33
|
+
wall_ms: LatencyMetricV3;
|
|
34
|
+
tool_ms: LatencyMetricV3;
|
|
35
|
+
tool_bound_coverage_percent: number | null;
|
|
36
|
+
tool_ranking_eligible: boolean;
|
|
37
|
+
command_ms: LatencyMetricV3;
|
|
38
|
+
command_exclusive_ms: LatencyMetricV3;
|
|
39
|
+
wait_ms: LatencyMetricV3;
|
|
40
|
+
occupied_ms: LatencyMetricV3;
|
|
41
|
+
inference_ms: LatencyMetricV3;
|
|
42
|
+
harness_ms: LatencyMetricV3;
|
|
43
|
+
slowest_hook: string | null;
|
|
44
|
+
slowest_hook_ms: number | null;
|
|
45
|
+
residual_ms: LatencyMetricV3;
|
|
46
|
+
over_attributed_ms: number;
|
|
47
|
+
context_percent: number | null;
|
|
48
|
+
context_coverage: ContextCoverageV3;
|
|
49
|
+
span_counts: { tool: number; command: number; wait: number };
|
|
50
|
+
tool_breakdown: ToolLatencyV3[];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type LatencyProjectionDiagnosticCodeV3 =
|
|
54
|
+
| "duplicate_turn_terminal"
|
|
55
|
+
| "tool_channel_unattested"
|
|
56
|
+
| "span_outside_turn"
|
|
57
|
+
| "recovery_bound_exceeds_turn_wall"
|
|
58
|
+
| "over_attributed";
|
|
59
|
+
|
|
60
|
+
export interface LatencyProjectionDiagnosticV3 {
|
|
61
|
+
code: LatencyProjectionDiagnosticCodeV3;
|
|
62
|
+
event_id: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface LatencyProjectionV3 {
|
|
66
|
+
projection_version: typeof EVENT_V3_LATENCY_PROJECTION_VERSION;
|
|
67
|
+
turns: TurnLatencyV3[];
|
|
68
|
+
diagnostics: LatencyProjectionDiagnosticV3[];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
interface EventShape {
|
|
72
|
+
event_id: string;
|
|
73
|
+
event_type: string;
|
|
74
|
+
scope: { generation_id?: string; turn_id?: string };
|
|
75
|
+
payload: Record<string, unknown>;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
interface Interval {
|
|
79
|
+
start: number;
|
|
80
|
+
end: number;
|
|
81
|
+
event_id: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface IntervalSet {
|
|
85
|
+
intervals: Interval[];
|
|
86
|
+
upperBounds: Interval[];
|
|
87
|
+
reasons: string[];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function projectLatencyV3(read: ReadLedgerV3Result): LatencyProjectionV3 {
|
|
91
|
+
if (!read.complete) throw new Error("latency projection requires a complete V3 ledger read");
|
|
92
|
+
const events = read.events.map(({ event }) => event as unknown as EventShape);
|
|
93
|
+
const diagnostics: LatencyProjectionDiagnosticV3[] = [];
|
|
94
|
+
const terminalByTurn = new Map<string, EventShape>();
|
|
95
|
+
|
|
96
|
+
for (const event of events) {
|
|
97
|
+
if (event.event_type !== "turn.completed") continue;
|
|
98
|
+
const key = turnKey(event);
|
|
99
|
+
const prior = terminalByTurn.get(key);
|
|
100
|
+
if (prior) diagnostics.push({ code: "duplicate_turn_terminal", event_id: event.event_id });
|
|
101
|
+
else terminalByTurn.set(key, event);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const turns = [...terminalByTurn.values()].map((terminal) => {
|
|
105
|
+
const key = turnKey(terminal);
|
|
106
|
+
const turnEvents = events.filter((event) => turnKey(event) === key);
|
|
107
|
+
return projectTurn(terminal, turnEvents, diagnostics);
|
|
108
|
+
});
|
|
109
|
+
turns.sort(
|
|
110
|
+
(left, right) =>
|
|
111
|
+
left.generation_id.localeCompare(right.generation_id) ||
|
|
112
|
+
left.turn_id.localeCompare(right.turn_id),
|
|
113
|
+
);
|
|
114
|
+
return { projection_version: EVENT_V3_LATENCY_PROJECTION_VERSION, turns, diagnostics };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function projectTurn(
|
|
118
|
+
terminal: EventShape,
|
|
119
|
+
events: EventShape[],
|
|
120
|
+
diagnostics: LatencyProjectionDiagnosticV3[],
|
|
121
|
+
): TurnLatencyV3 {
|
|
122
|
+
const span = record(terminal.payload.span);
|
|
123
|
+
const wall = metricFromObservation(span.duration_ms, "turn_duration_unknown");
|
|
124
|
+
const wallInterval = intervalFromSpan(terminal);
|
|
125
|
+
const toolEvents = events.filter(({ event_type }) => event_type === "tool.completed");
|
|
126
|
+
const commandEvents = events.filter(({ event_type }) => event_type === "command.completed");
|
|
127
|
+
const waitStartEvents = events.filter(({ event_type }) => event_type === "wait.started");
|
|
128
|
+
const waitEvents = events.filter(({ event_type }) => event_type === "wait.ended");
|
|
129
|
+
const tools = intervalSet(toolEvents, wallInterval, diagnostics);
|
|
130
|
+
const commands = intervalSet(commandEvents, wallInterval, diagnostics);
|
|
131
|
+
const waits = intervalSet(waitEvents, wallInterval, diagnostics);
|
|
132
|
+
const endedWaitIds = new Set(waitEvents.map(({ payload }) => string(record(payload).wait_id)));
|
|
133
|
+
|
|
134
|
+
const toolCount = record(terminal.payload.tool_call_count);
|
|
135
|
+
const expectedToolCount = observedNumber(toolCount);
|
|
136
|
+
if (toolCount.state === "unsupported") tools.reasons.push("tool_call_count_unsupported");
|
|
137
|
+
else if (expectedToolCount === undefined) {
|
|
138
|
+
const reason = string(toolCount.reason);
|
|
139
|
+
tools.reasons.push(reason === "tool_channel_unattested" ? reason : "tool_call_count_unknown");
|
|
140
|
+
if (reason === "tool_channel_unattested") {
|
|
141
|
+
diagnostics.push({ code: "tool_channel_unattested", event_id: terminal.event_id });
|
|
142
|
+
}
|
|
143
|
+
} else if (expectedToolCount !== toolEvents.length)
|
|
144
|
+
tools.reasons.push("tool_terminal_count_mismatch");
|
|
145
|
+
|
|
146
|
+
const waitCount = record(terminal.payload.wait_count);
|
|
147
|
+
const expectedWaitCount = observedNumber(waitCount);
|
|
148
|
+
if (waitCount.state === "unsupported") waits.reasons.push("wait_count_unsupported");
|
|
149
|
+
else if (expectedWaitCount === undefined) {
|
|
150
|
+
waits.reasons.push(
|
|
151
|
+
Object.keys(waitCount).length === 0 ? "wait_count_unattested" : "wait_count_unknown",
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
if (
|
|
155
|
+
waitStartEvents.some(({ payload }) => !endedWaitIds.has(string(record(payload).wait_id))) ||
|
|
156
|
+
(expectedWaitCount !== undefined && expectedWaitCount !== endedWaitIds.size)
|
|
157
|
+
) {
|
|
158
|
+
waits.reasons.push("wait_terminal_count_mismatch");
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const tool = metricFromIntervals(tools);
|
|
162
|
+
const command = metricFromIntervals(commands);
|
|
163
|
+
const wait = metricFromIntervals(waits);
|
|
164
|
+
const commandExclusive = metricFromIntervals({
|
|
165
|
+
intervals: subtractIntervals(commands.intervals, tools.intervals),
|
|
166
|
+
upperBounds: [...commands.upperBounds, ...tools.upperBounds],
|
|
167
|
+
reasons: [...commands.reasons, ...tools.reasons],
|
|
168
|
+
});
|
|
169
|
+
const occupied = metricFromIntervals({
|
|
170
|
+
intervals: [...tools.intervals, ...commands.intervals, ...waits.intervals],
|
|
171
|
+
upperBounds: [...tools.upperBounds, ...commands.upperBounds, ...waits.upperBounds],
|
|
172
|
+
reasons: [...tools.reasons, ...commands.reasons, ...waits.reasons],
|
|
173
|
+
});
|
|
174
|
+
const inference = metricFromNestedObservation(
|
|
175
|
+
terminal.payload.inference,
|
|
176
|
+
"api_time_ms",
|
|
177
|
+
"inference_timing_unknown",
|
|
178
|
+
);
|
|
179
|
+
const harness = metricFromNestedObservation(
|
|
180
|
+
terminal.payload.harness,
|
|
181
|
+
"hook_time_ms",
|
|
182
|
+
"harness_timing_unknown",
|
|
183
|
+
);
|
|
184
|
+
const slowestHook = slowestHookFromObservation(terminal.payload.harness);
|
|
185
|
+
const residual = residualMetric(wall, occupied, inference, harness);
|
|
186
|
+
const overAttributed = residual.over_attributed_ms;
|
|
187
|
+
if (overAttributed > 0)
|
|
188
|
+
diagnostics.push({ code: "over_attributed", event_id: terminal.event_id });
|
|
189
|
+
|
|
190
|
+
const scope = terminal.scope;
|
|
191
|
+
const context = latestContext(events);
|
|
192
|
+
const toolBreakdown = [...groupByTool(toolEvents).entries()]
|
|
193
|
+
.map(([key, groupedEvents]) => {
|
|
194
|
+
const [namespace, name] = key.split("\0");
|
|
195
|
+
return {
|
|
196
|
+
namespace: namespace ?? "",
|
|
197
|
+
name: name ?? "",
|
|
198
|
+
count: groupedEvents.length,
|
|
199
|
+
duration_ms: metricFromIntervals(intervalSet(groupedEvents, wallInterval, diagnostics)),
|
|
200
|
+
};
|
|
201
|
+
})
|
|
202
|
+
.sort(
|
|
203
|
+
(left, right) =>
|
|
204
|
+
left.namespace.localeCompare(right.namespace) || left.name.localeCompare(right.name),
|
|
205
|
+
);
|
|
206
|
+
return {
|
|
207
|
+
generation_id: scope.generation_id ?? "",
|
|
208
|
+
turn_id: scope.turn_id ?? "",
|
|
209
|
+
terminal_event_id: terminal.event_id,
|
|
210
|
+
outcome: string(terminal.payload.outcome),
|
|
211
|
+
wall_ms: wall,
|
|
212
|
+
tool_ms: tool,
|
|
213
|
+
tool_bound_coverage_percent: boundCoveragePercent(tool, wall),
|
|
214
|
+
tool_ranking_eligible: tool.state === "observed",
|
|
215
|
+
command_ms: command,
|
|
216
|
+
command_exclusive_ms: commandExclusive,
|
|
217
|
+
wait_ms: wait,
|
|
218
|
+
occupied_ms: occupied,
|
|
219
|
+
inference_ms: inference,
|
|
220
|
+
harness_ms: harness,
|
|
221
|
+
slowest_hook: slowestHook.name,
|
|
222
|
+
slowest_hook_ms: slowestHook.duration_ms,
|
|
223
|
+
residual_ms: residual.metric,
|
|
224
|
+
over_attributed_ms: overAttributed,
|
|
225
|
+
context_percent: context.percent,
|
|
226
|
+
context_coverage: context.coverage,
|
|
227
|
+
span_counts: {
|
|
228
|
+
tool: toolEvents.length,
|
|
229
|
+
command: commandEvents.length,
|
|
230
|
+
wait: waitEvents.length,
|
|
231
|
+
},
|
|
232
|
+
tool_breakdown: toolBreakdown,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function groupByTool(events: EventShape[]): Map<string, EventShape[]> {
|
|
237
|
+
const groups = new Map<string, EventShape[]>();
|
|
238
|
+
for (const event of events) {
|
|
239
|
+
const tool = record(event.payload.tool);
|
|
240
|
+
const key = `${string(tool.namespace)}\0${string(tool.name)}`;
|
|
241
|
+
const group = groups.get(key) ?? [];
|
|
242
|
+
group.push(event);
|
|
243
|
+
groups.set(key, group);
|
|
244
|
+
}
|
|
245
|
+
return groups;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function intervalSet(
|
|
249
|
+
events: EventShape[],
|
|
250
|
+
wall: Interval | undefined,
|
|
251
|
+
diagnostics: LatencyProjectionDiagnosticV3[],
|
|
252
|
+
): IntervalSet {
|
|
253
|
+
const intervals: Interval[] = [];
|
|
254
|
+
const upperBounds: Interval[] = [];
|
|
255
|
+
const reasons: string[] = [];
|
|
256
|
+
for (const event of events) {
|
|
257
|
+
const interval = intervalFromSpan(event);
|
|
258
|
+
if (!interval) {
|
|
259
|
+
reasons.push(observationReason(record(event.payload.span).duration_ms));
|
|
260
|
+
const upperBound = upperBoundInterval(event);
|
|
261
|
+
if (upperBound) {
|
|
262
|
+
if (wall && (upperBound.start < wall.start || upperBound.end > wall.end)) {
|
|
263
|
+
diagnostics.push({
|
|
264
|
+
code: "recovery_bound_exceeds_turn_wall",
|
|
265
|
+
event_id: event.event_id,
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
const clipped = wall
|
|
269
|
+
? {
|
|
270
|
+
...upperBound,
|
|
271
|
+
start: Math.max(upperBound.start, wall.start),
|
|
272
|
+
end: Math.min(upperBound.end, wall.end),
|
|
273
|
+
}
|
|
274
|
+
: upperBound;
|
|
275
|
+
if (clipped.end > clipped.start) upperBounds.push(clipped);
|
|
276
|
+
}
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
if (!wall) {
|
|
280
|
+
intervals.push(interval);
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
if (interval.start < wall.start || interval.end > wall.end) {
|
|
284
|
+
diagnostics.push({ code: "span_outside_turn", event_id: event.event_id });
|
|
285
|
+
}
|
|
286
|
+
const clipped = {
|
|
287
|
+
...interval,
|
|
288
|
+
start: Math.max(interval.start, wall.start),
|
|
289
|
+
end: Math.min(interval.end, wall.end),
|
|
290
|
+
};
|
|
291
|
+
if (clipped.end > clipped.start) intervals.push(clipped);
|
|
292
|
+
}
|
|
293
|
+
return { intervals, upperBounds, reasons: unique(reasons) };
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function intervalFromSpan(event: EventShape): Interval | undefined {
|
|
297
|
+
const span = record(event.payload.span);
|
|
298
|
+
const duration = observedNumber(span.duration_ms);
|
|
299
|
+
const start = Date.parse(string(span.opened_at));
|
|
300
|
+
if (duration === undefined || !Number.isFinite(start)) return undefined;
|
|
301
|
+
return { start, end: start + duration, event_id: event.event_id };
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function upperBoundInterval(event: EventShape): Interval | undefined {
|
|
305
|
+
const span = record(event.payload.span);
|
|
306
|
+
const recovery = record(event.payload.recovery);
|
|
307
|
+
const upperBound = observedNumber(recovery.elapsed_upper_bound_ms);
|
|
308
|
+
const start = Date.parse(string(span.opened_at));
|
|
309
|
+
if (upperBound === undefined || !Number.isFinite(start)) return undefined;
|
|
310
|
+
return { start, end: start + upperBound, event_id: event.event_id };
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function metricFromIntervals(set: IntervalSet): LatencyMetricV3 {
|
|
314
|
+
const known = unionLength(set.intervals);
|
|
315
|
+
const upperBound = unionLength([...set.intervals, ...set.upperBounds]);
|
|
316
|
+
return set.reasons.length === 0
|
|
317
|
+
? { state: "observed", value_ms: known }
|
|
318
|
+
: {
|
|
319
|
+
state: "unknown",
|
|
320
|
+
known_ms: known,
|
|
321
|
+
...(set.upperBounds.length > 0 ? { upper_bound_ms: upperBound } : {}),
|
|
322
|
+
reasons: unique(set.reasons),
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function boundCoveragePercent(metric: LatencyMetricV3, wall: LatencyMetricV3): number | null {
|
|
327
|
+
if (metric.state !== "unknown" || metric.upper_bound_ms === undefined) return null;
|
|
328
|
+
if (wall.state !== "observed" || wall.value_ms <= 0) return null;
|
|
329
|
+
return Math.round((metric.upper_bound_ms / wall.value_ms) * 1_000) / 10;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function metricFromObservation(value: unknown, fallback: string): LatencyMetricV3 {
|
|
333
|
+
const observed = observedNumber(value);
|
|
334
|
+
return observed === undefined
|
|
335
|
+
? { state: "unknown", known_ms: 0, reasons: [observationReason(value) || fallback] }
|
|
336
|
+
: { state: "observed", value_ms: observed };
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function metricFromNestedObservation(
|
|
340
|
+
value: unknown,
|
|
341
|
+
field: string,
|
|
342
|
+
fallback: string,
|
|
343
|
+
): LatencyMetricV3 {
|
|
344
|
+
const observation = record(value);
|
|
345
|
+
if (observation.state === "observed") {
|
|
346
|
+
const numberValue = record(observation.value)[field];
|
|
347
|
+
if (typeof numberValue === "number" && numberValue >= 0) {
|
|
348
|
+
return { state: "observed", value_ms: numberValue };
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return {
|
|
352
|
+
state: "unknown",
|
|
353
|
+
known_ms: 0,
|
|
354
|
+
reasons: [observationReason(value) || fallback],
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function residualMetric(
|
|
359
|
+
wall: LatencyMetricV3,
|
|
360
|
+
occupied: LatencyMetricV3,
|
|
361
|
+
inference: LatencyMetricV3,
|
|
362
|
+
harness: LatencyMetricV3,
|
|
363
|
+
): { metric: LatencyMetricV3; over_attributed_ms: number } {
|
|
364
|
+
const components = { wall, occupied, inference, harness };
|
|
365
|
+
const unknown = Object.entries(components)
|
|
366
|
+
.filter(([, metric]) => metric.state === "unknown")
|
|
367
|
+
.map(([name]) => `${name}_unknown`);
|
|
368
|
+
if (unknown.length > 0) {
|
|
369
|
+
return { metric: { state: "unknown", known_ms: 0, reasons: unknown }, over_attributed_ms: 0 };
|
|
370
|
+
}
|
|
371
|
+
const attributed = value(occupied) + value(inference) + value(harness);
|
|
372
|
+
const raw = value(wall) - attributed;
|
|
373
|
+
return {
|
|
374
|
+
metric: { state: "observed", value_ms: Math.max(0, raw) },
|
|
375
|
+
over_attributed_ms: Math.max(0, -raw),
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function latestContext(events: EventShape[]): {
|
|
380
|
+
percent: number | null;
|
|
381
|
+
coverage: ContextCoverageV3;
|
|
382
|
+
} {
|
|
383
|
+
const observed = events.filter(({ event_type }) => event_type === "context.observed").at(-1);
|
|
384
|
+
if (!observed) {
|
|
385
|
+
return {
|
|
386
|
+
percent: null,
|
|
387
|
+
coverage: {
|
|
388
|
+
state: "expected_but_missing",
|
|
389
|
+
event_id: null,
|
|
390
|
+
reason: "context_observation_missing",
|
|
391
|
+
},
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
const measurement = record(observed.payload.measurement);
|
|
395
|
+
if (measurement.state === "unsupported") {
|
|
396
|
+
return {
|
|
397
|
+
percent: null,
|
|
398
|
+
coverage: {
|
|
399
|
+
state: "unsupported",
|
|
400
|
+
event_id: observed.event_id,
|
|
401
|
+
reason: "context_usage_unsupported",
|
|
402
|
+
},
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
if (measurement.state === "expected_but_missing") {
|
|
406
|
+
const reason = string(measurement.reason) || "context_measurement_missing";
|
|
407
|
+
return {
|
|
408
|
+
percent: null,
|
|
409
|
+
coverage: {
|
|
410
|
+
state: reason.startsWith("context_") ? "partial" : "expected_but_missing",
|
|
411
|
+
event_id: observed.event_id,
|
|
412
|
+
reason,
|
|
413
|
+
},
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
if (measurement.state !== "observed") {
|
|
417
|
+
return {
|
|
418
|
+
percent: null,
|
|
419
|
+
coverage: {
|
|
420
|
+
state: "expected_but_missing",
|
|
421
|
+
event_id: observed.event_id,
|
|
422
|
+
reason: "context_measurement_invalid",
|
|
423
|
+
},
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
const value = record(measurement.value);
|
|
427
|
+
const used = value.used_tokens;
|
|
428
|
+
const limit = value.limit_tokens;
|
|
429
|
+
if (typeof used !== "number" || typeof limit !== "number" || limit <= 0) {
|
|
430
|
+
return {
|
|
431
|
+
percent: null,
|
|
432
|
+
coverage: {
|
|
433
|
+
state: "expected_but_missing",
|
|
434
|
+
event_id: observed.event_id,
|
|
435
|
+
reason: "context_measurement_invalid",
|
|
436
|
+
},
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
return {
|
|
440
|
+
percent: (used / limit) * 100,
|
|
441
|
+
coverage: { state: "observed", event_id: observed.event_id, reason: null },
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
function observedNumber(value: unknown): number | undefined {
|
|
446
|
+
const observation = record(value);
|
|
447
|
+
return observation.state === "observed" &&
|
|
448
|
+
typeof observation.value === "number" &&
|
|
449
|
+
observation.value >= 0
|
|
450
|
+
? observation.value
|
|
451
|
+
: undefined;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
function slowestHookFromObservation(value: unknown): {
|
|
455
|
+
name: string | null;
|
|
456
|
+
duration_ms: number | null;
|
|
457
|
+
} {
|
|
458
|
+
const observation = record(value);
|
|
459
|
+
if (observation.state !== "observed") return { name: null, duration_ms: null };
|
|
460
|
+
const harness = record(observation.value);
|
|
461
|
+
const name = string(harness.slowest_hook);
|
|
462
|
+
const duration = harness.slowest_hook_ms;
|
|
463
|
+
return name && typeof duration === "number" && Number.isSafeInteger(duration) && duration >= 0
|
|
464
|
+
? { name, duration_ms: duration }
|
|
465
|
+
: { name: null, duration_ms: null };
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
function observationReason(value: unknown): string {
|
|
469
|
+
const observation = record(value);
|
|
470
|
+
const state = string(observation.state) || "unknown";
|
|
471
|
+
const reason = string(observation.reason);
|
|
472
|
+
return reason ? `${state}:${reason}` : state;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
function unionLength(intervals: Interval[]): number {
|
|
476
|
+
const sorted = intervals
|
|
477
|
+
.filter(({ end, start }) => end > start)
|
|
478
|
+
.sort((left, right) => left.start - right.start || left.end - right.end);
|
|
479
|
+
let total = 0;
|
|
480
|
+
let start: number | undefined;
|
|
481
|
+
let end: number | undefined;
|
|
482
|
+
for (const interval of sorted) {
|
|
483
|
+
if (start === undefined || end === undefined) {
|
|
484
|
+
start = interval.start;
|
|
485
|
+
end = interval.end;
|
|
486
|
+
} else if (interval.start <= end) {
|
|
487
|
+
end = Math.max(end, interval.end);
|
|
488
|
+
} else {
|
|
489
|
+
total += end - start;
|
|
490
|
+
start = interval.start;
|
|
491
|
+
end = interval.end;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
return total + (start !== undefined && end !== undefined ? end - start : 0);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
function subtractIntervals(source: Interval[], covered: Interval[]): Interval[] {
|
|
498
|
+
const cover = mergeIntervals(covered);
|
|
499
|
+
const output: Interval[] = [];
|
|
500
|
+
for (const interval of mergeIntervals(source)) {
|
|
501
|
+
let pieces = [interval];
|
|
502
|
+
for (const blocker of cover) {
|
|
503
|
+
pieces = pieces.flatMap((piece) => subtractOne(piece, blocker));
|
|
504
|
+
}
|
|
505
|
+
output.push(...pieces);
|
|
506
|
+
}
|
|
507
|
+
return output;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
function subtractOne(source: Interval, blocker: Interval): Interval[] {
|
|
511
|
+
if (blocker.end <= source.start || blocker.start >= source.end) return [source];
|
|
512
|
+
const output: Interval[] = [];
|
|
513
|
+
if (blocker.start > source.start) output.push({ ...source, end: blocker.start });
|
|
514
|
+
if (blocker.end < source.end) output.push({ ...source, start: blocker.end });
|
|
515
|
+
return output;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
function mergeIntervals(intervals: Interval[]): Interval[] {
|
|
519
|
+
const sorted = [...intervals].sort(
|
|
520
|
+
(left, right) => left.start - right.start || left.end - right.end,
|
|
521
|
+
);
|
|
522
|
+
const output: Interval[] = [];
|
|
523
|
+
for (const interval of sorted) {
|
|
524
|
+
const prior = output.at(-1);
|
|
525
|
+
if (prior && interval.start <= prior.end) prior.end = Math.max(prior.end, interval.end);
|
|
526
|
+
else output.push({ ...interval });
|
|
527
|
+
}
|
|
528
|
+
return output;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
function turnKey(event: EventShape): string {
|
|
532
|
+
return `${event.scope.generation_id ?? ""}\0${event.scope.turn_id ?? ""}`;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
function value(metric: LatencyMetricV3): number {
|
|
536
|
+
return metric.state === "observed" ? metric.value_ms : metric.known_ms;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
function unique(values: string[]): string[] {
|
|
540
|
+
return [...new Set(values)].sort();
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
function record(value: unknown): Record<string, unknown> {
|
|
544
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
545
|
+
? (value as Record<string, unknown>)
|
|
546
|
+
: {};
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
function string(value: unknown): string {
|
|
550
|
+
return typeof value === "string" ? value : "";
|
|
551
|
+
}
|