harnery 0.33.0 → 0.34.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +1237 -590
- 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 +306 -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 +161 -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 +1530 -593
- 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 +352 -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 +171 -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,23 @@
|
|
|
1
|
+
import { type FingerprintContextV3 } from "./canonical.js";
|
|
2
|
+
import type { EventPayloadV3 } from "./contract.js";
|
|
3
|
+
export type TargetDescriptorV3 = EventPayloadV3<"tool.requested">["targets"][number];
|
|
4
|
+
export interface ExtractTargetsV3Input {
|
|
5
|
+
coordRoot: string;
|
|
6
|
+
toolNamespace: string;
|
|
7
|
+
toolName: string;
|
|
8
|
+
toolInput: unknown;
|
|
9
|
+
fingerprintContext: FingerprintContextV3;
|
|
10
|
+
}
|
|
11
|
+
export interface DescribePathTargetV3Input {
|
|
12
|
+
coordRoot: string;
|
|
13
|
+
value: string;
|
|
14
|
+
access: TargetDescriptorV3["access"];
|
|
15
|
+
fingerprintContext: FingerprintContextV3;
|
|
16
|
+
extractorVersion: string;
|
|
17
|
+
}
|
|
18
|
+
/** Describe one known path without exposing values outside the coordination root. */
|
|
19
|
+
export declare function describePathTargetV3(input: DescribePathTargetV3Input): TargetDescriptorV3;
|
|
20
|
+
/** Versioned, tool-specific target extraction. Unknown tools deliberately emit no guessed target. */
|
|
21
|
+
export declare function extractTargetsV3(input: ExtractTargetsV3Input): TargetDescriptorV3[];
|
|
22
|
+
export declare function exactToolInputFingerprintV3(context: FingerprintContextV3, toolNamespace: string, toolName: string, toolInput: unknown): import("./canonical.js").FingerprintV3;
|
|
23
|
+
//# sourceMappingURL=targets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"targets.d.ts","sourceRoot":"","sources":["../../../../src/core/events/v3/targets.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,oBAAoB,EAAiB,MAAM,gBAAgB,CAAC;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,MAAM,MAAM,kBAAkB,GAAG,cAAc,CAAC,gBAAgB,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAErF,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,kBAAkB,EAAE,oBAAoB,CAAC;CAC1C;AAED,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IACrC,kBAAkB,EAAE,oBAAoB,CAAC;IACzC,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,qFAAqF;AACrF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,kBAAkB,CAUzF;AAED,qGAAqG;AACrG,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,kBAAkB,EAAE,CA0DnF;AAED,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,oBAAoB,EAC7B,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,OAAO,0CAOnB"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { isAbsolute, relative, resolve, sep } from "node:path";
|
|
2
|
+
import { fingerprintV3 } from "./canonical.js";
|
|
3
|
+
/** Describe one known path without exposing values outside the coordination root. */
|
|
4
|
+
export function describePathTargetV3(input) {
|
|
5
|
+
return pathTarget({
|
|
6
|
+
coordRoot: input.coordRoot,
|
|
7
|
+
fingerprintContext: input.fingerprintContext,
|
|
8
|
+
}, input.value, input.access, input.extractorVersion);
|
|
9
|
+
}
|
|
10
|
+
/** Versioned, tool-specific target extraction. Unknown tools deliberately emit no guessed target. */
|
|
11
|
+
export function extractTargetsV3(input) {
|
|
12
|
+
const record = plainRecord(input.toolInput);
|
|
13
|
+
if (!record)
|
|
14
|
+
return [];
|
|
15
|
+
const name = input.toolName.toLowerCase();
|
|
16
|
+
const descriptors = [];
|
|
17
|
+
const addPath = (value, access, version) => {
|
|
18
|
+
if (typeof value !== "string" || value.length === 0)
|
|
19
|
+
return;
|
|
20
|
+
descriptors.push(pathTarget(input, value, access, version));
|
|
21
|
+
};
|
|
22
|
+
const addOpaque = (kind, value, access, version) => {
|
|
23
|
+
if (typeof value !== "string" || value.length === 0)
|
|
24
|
+
return;
|
|
25
|
+
descriptors.push({
|
|
26
|
+
kind,
|
|
27
|
+
access,
|
|
28
|
+
fingerprint: fingerprintV3(input.fingerprintContext, `semantic-target.${kind}`, value, "root"),
|
|
29
|
+
extractor_version: version,
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
if (["read", "write", "edit", "multiedit", "notebookedit", "notebook_edit"].includes(name)) {
|
|
33
|
+
const access = name === "read" ? "read" : "write";
|
|
34
|
+
for (const field of ["file_path", "path", "notebook_path"]) {
|
|
35
|
+
addPath(record[field], access, "file-tool-v1");
|
|
36
|
+
}
|
|
37
|
+
if (Array.isArray(record.paths)) {
|
|
38
|
+
for (const path of record.paths)
|
|
39
|
+
addPath(path, access, "file-tool-v1");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else if (["grep", "search", "rg"].includes(name)) {
|
|
43
|
+
addPath(record.path, "read", "search-tool-v1");
|
|
44
|
+
addOpaque("pattern", record.pattern ?? record.query, "read", "search-tool-v1");
|
|
45
|
+
}
|
|
46
|
+
else if (["glob", "find"].includes(name)) {
|
|
47
|
+
addPath(record.path, "read", "glob-tool-v1");
|
|
48
|
+
addOpaque("pattern", record.pattern ?? record.glob, "read", "glob-tool-v1");
|
|
49
|
+
}
|
|
50
|
+
else if (["webfetch", "web_fetch", "fetch", "open"].includes(name)) {
|
|
51
|
+
addOpaque("url", record.url ?? record.ref_id, "read", "web-tool-v1");
|
|
52
|
+
}
|
|
53
|
+
else if (["websearch", "web_search", "search_query"].includes(name)) {
|
|
54
|
+
addOpaque("query", record.query ?? record.q, "read", "web-search-v1");
|
|
55
|
+
}
|
|
56
|
+
else if (["bash", "shell", "exec_command"].includes(name)) {
|
|
57
|
+
addPath(record.workdir ?? record.cwd, "execute", "command-tool-v1");
|
|
58
|
+
}
|
|
59
|
+
else if (["artifact", "view_image", "image"].includes(name)) {
|
|
60
|
+
addPath(record.path ?? record.file_path, "read", "artifact-tool-v1");
|
|
61
|
+
addOpaque("artifact", record.artifact_id, "read", "artifact-tool-v1");
|
|
62
|
+
}
|
|
63
|
+
else if (["apply_patch", "patch"].includes(name)) {
|
|
64
|
+
if (typeof record.patch === "string") {
|
|
65
|
+
for (const path of extractPatchPaths(record.patch))
|
|
66
|
+
addPath(path, "write", "patch-tool-v1");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return deduplicateTargets(descriptors);
|
|
70
|
+
}
|
|
71
|
+
export function exactToolInputFingerprintV3(context, toolNamespace, toolName, toolInput) {
|
|
72
|
+
return fingerprintV3(context, "exact-input", {
|
|
73
|
+
tool_namespace: toolNamespace,
|
|
74
|
+
tool_name: toolName,
|
|
75
|
+
input: toolInput,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function pathTarget(input, value, access, version) {
|
|
79
|
+
const root = resolve(input.coordRoot);
|
|
80
|
+
const valueUsesWindowsRoot = /^(?:[a-zA-Z]:[\\/]|\\\\)/.test(value);
|
|
81
|
+
const coordRootUsesWindowsRoot = /^(?:[a-zA-Z]:[\\/]|\\\\)/.test(input.coordRoot);
|
|
82
|
+
const valueUsesPosixRoot = value.startsWith("/");
|
|
83
|
+
const foreignAbsolute = (valueUsesWindowsRoot && !coordRootUsesWindowsRoot) ||
|
|
84
|
+
(valueUsesPosixRoot && coordRootUsesWindowsRoot);
|
|
85
|
+
const resolved = resolve(root, value);
|
|
86
|
+
const relativePath = relative(root, resolved);
|
|
87
|
+
const contained = !foreignAbsolute &&
|
|
88
|
+
relativePath !== ".." &&
|
|
89
|
+
!relativePath.startsWith(`..${sep}`) &&
|
|
90
|
+
!isAbsolute(relativePath);
|
|
91
|
+
if (contained) {
|
|
92
|
+
const portable = relativePath.length === 0 ? "." : relativePath.split(sep).join("/");
|
|
93
|
+
return {
|
|
94
|
+
kind: "workspace_path",
|
|
95
|
+
access,
|
|
96
|
+
display: portable,
|
|
97
|
+
fingerprint: fingerprintV3(input.fingerprintContext, "semantic-target.workspace-path", portable, "root"),
|
|
98
|
+
extractor_version: version,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
kind: "external_path",
|
|
103
|
+
access,
|
|
104
|
+
fingerprint: fingerprintV3(input.fingerprintContext, "semantic-target.external-path", value.normalize("NFC").replaceAll("\\", "/"), "root"),
|
|
105
|
+
extractor_version: version,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function extractPatchPaths(patch) {
|
|
109
|
+
const paths = [];
|
|
110
|
+
for (const line of patch.split("\n")) {
|
|
111
|
+
const match = line.match(/^\*\*\* (?:Add|Update|Delete) File: (.+)$/);
|
|
112
|
+
if (match?.[1])
|
|
113
|
+
paths.push(match[1]);
|
|
114
|
+
}
|
|
115
|
+
return paths;
|
|
116
|
+
}
|
|
117
|
+
function deduplicateTargets(targets) {
|
|
118
|
+
const seen = new Set();
|
|
119
|
+
return targets.filter((target) => {
|
|
120
|
+
const key = `${target.kind}\0${target.access}\0${target.fingerprint.digest}`;
|
|
121
|
+
if (seen.has(key))
|
|
122
|
+
return false;
|
|
123
|
+
seen.add(key);
|
|
124
|
+
return true;
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
function plainRecord(value) {
|
|
128
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
129
|
+
return undefined;
|
|
130
|
+
const prototype = Object.getPrototypeOf(value);
|
|
131
|
+
if (prototype !== Object.prototype && prototype !== null)
|
|
132
|
+
return undefined;
|
|
133
|
+
return value;
|
|
134
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Adapter } from "../../adapter.js";
|
|
2
|
+
import { type AdapterSignalV3, type CapabilitySupportV3 } from "./capabilities.js";
|
|
3
|
+
import type { TurnHarnessV3, TurnInferenceV3, TurnUsageV3 } from "./contract.js";
|
|
4
|
+
export type TelemetryObservationV3<T> = {
|
|
5
|
+
state: "observed";
|
|
6
|
+
value: T;
|
|
7
|
+
attestation: "native" | "derived";
|
|
8
|
+
confidence: "exact" | "high";
|
|
9
|
+
} | {
|
|
10
|
+
state: "unsupported";
|
|
11
|
+
capability: string;
|
|
12
|
+
} | {
|
|
13
|
+
state: "expected_but_missing";
|
|
14
|
+
capability: string;
|
|
15
|
+
reason: string;
|
|
16
|
+
};
|
|
17
|
+
export interface ContextMeasurementV3 {
|
|
18
|
+
used_tokens: number;
|
|
19
|
+
limit_tokens: number;
|
|
20
|
+
remaining_tokens?: number;
|
|
21
|
+
measured_at: string;
|
|
22
|
+
method: string;
|
|
23
|
+
}
|
|
24
|
+
export interface TurnTelemetryV3 {
|
|
25
|
+
usage: TelemetryObservationV3<TurnUsageV3>;
|
|
26
|
+
inference: TelemetryObservationV3<TurnInferenceV3>;
|
|
27
|
+
context: TelemetryObservationV3<ContextMeasurementV3>;
|
|
28
|
+
}
|
|
29
|
+
export type TurnTelemetryCapabilitySupportV3 = Partial<Pick<Record<AdapterSignalV3, CapabilitySupportV3>, "model_usage" | "inference_timing" | "context_usage">>;
|
|
30
|
+
export interface HarnessTimingAccumulatorV3 {
|
|
31
|
+
hook_time_ms: number;
|
|
32
|
+
hook_count: number;
|
|
33
|
+
slowest_hook?: string;
|
|
34
|
+
slowest_hook_ms: number;
|
|
35
|
+
}
|
|
36
|
+
/** Extract only telemetry explicitly reported by a hook/status payload. */
|
|
37
|
+
export declare function extractTurnTelemetryV3(adapter: Adapter, payload: Record<string, unknown>, observedAt?: string, support?: TurnTelemetryCapabilitySupportV3): TurnTelemetryV3;
|
|
38
|
+
export declare function emptyHarnessTimingV3(): HarnessTimingAccumulatorV3;
|
|
39
|
+
export declare function recordHarnessTimingV3(accumulator: HarnessTimingAccumulatorV3, hook: string, durationMs: number): HarnessTimingAccumulatorV3;
|
|
40
|
+
export declare function harnessObservationV3(accumulator: HarnessTimingAccumulatorV3): TelemetryObservationV3<TurnHarnessV3>;
|
|
41
|
+
//# sourceMappingURL=turn-telemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turn-telemetry.d.ts","sourceRoot":"","sources":["../../../../src/core/events/v3/turn-telemetry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,mBAAmB,EACzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjF,MAAM,MAAM,sBAAsB,CAAC,CAAC,IAChC;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,CAAC,CAAC;IAAC,WAAW,EAAE,QAAQ,GAAG,SAAS,CAAC;IAAC,UAAU,EAAE,OAAO,GAAG,MAAM,CAAA;CAAE,GAChG;IAAE,KAAK,EAAE,aAAa,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAC5C;IAAE,KAAK,EAAE,sBAAsB,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1E,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,sBAAsB,CAAC,WAAW,CAAC,CAAC;IAC3C,SAAS,EAAE,sBAAsB,CAAC,eAAe,CAAC,CAAC;IACnD,OAAO,EAAE,sBAAsB,CAAC,oBAAoB,CAAC,CAAC;CACvD;AAED,MAAM,MAAM,gCAAgC,GAAG,OAAO,CACpD,IAAI,CACF,MAAM,CAAC,eAAe,EAAE,mBAAmB,CAAC,EAC5C,aAAa,GAAG,kBAAkB,GAAG,eAAe,CACrD,CACF,CAAC;AAEF,MAAM,WAAW,0BAA0B;IACzC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,2EAA2E;AAC3E,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,UAAU,SAA2B,EACrC,OAAO,GAAE,gCAAqC,GAC7C,eAAe,CAgFjB;AAwCD,wBAAgB,oBAAoB,IAAI,0BAA0B,CAEjE;AAED,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,0BAA0B,EACvC,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,GACjB,0BAA0B,CAU5B;AAED,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,0BAA0B,GACtC,sBAAsB,CAAC,aAAa,CAAC,CAsBvC"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { adapterSignalSupportV3, } from "./capabilities.js";
|
|
2
|
+
/** Extract only telemetry explicitly reported by a hook/status payload. */
|
|
3
|
+
export function extractTurnTelemetryV3(adapter, payload, observedAt = new Date().toISOString(), support = {}) {
|
|
4
|
+
const context = record(payload.context_window) ??
|
|
5
|
+
record(payload.model_context_window) ??
|
|
6
|
+
record(payload.context_usage);
|
|
7
|
+
const usage = record(payload.usage) ??
|
|
8
|
+
record(payload.token_usage) ??
|
|
9
|
+
record(context?.current_usage) ??
|
|
10
|
+
undefined;
|
|
11
|
+
const input = number(usage?.input_tokens);
|
|
12
|
+
const output = number(usage?.output_tokens);
|
|
13
|
+
const cacheRead = number(usage?.cache_read_tokens) ?? number(usage?.cache_read_input_tokens);
|
|
14
|
+
const cacheWrite = number(usage?.cache_write_tokens) ?? number(usage?.cache_creation_input_tokens);
|
|
15
|
+
const usageObservation = input !== undefined && output !== undefined
|
|
16
|
+
? {
|
|
17
|
+
state: "observed",
|
|
18
|
+
value: {
|
|
19
|
+
input_tokens: input,
|
|
20
|
+
output_tokens: output,
|
|
21
|
+
...(cacheRead !== undefined ? { cache_read_tokens: cacheRead } : {}),
|
|
22
|
+
...(cacheWrite !== undefined ? { cache_write_tokens: cacheWrite } : {}),
|
|
23
|
+
method: `${adapter.replaceAll("-", "_")}_hook`,
|
|
24
|
+
},
|
|
25
|
+
attestation: "native",
|
|
26
|
+
confidence: "exact",
|
|
27
|
+
}
|
|
28
|
+
: missing(adapter, "model_usage", support.model_usage);
|
|
29
|
+
const inferenceMs = number(payload.api_time_ms) ??
|
|
30
|
+
number(payload.inference_time_ms) ??
|
|
31
|
+
number(record(payload.timing)?.api_time_ms) ??
|
|
32
|
+
number(usage?.api_time_ms);
|
|
33
|
+
const requestCount = number(payload.request_count) ?? number(record(payload.timing)?.request_count) ?? 1;
|
|
34
|
+
const inferenceObservation = inferenceMs !== undefined
|
|
35
|
+
? {
|
|
36
|
+
state: "observed",
|
|
37
|
+
value: { api_time_ms: inferenceMs, request_count: requestCount },
|
|
38
|
+
attestation: "native",
|
|
39
|
+
confidence: "exact",
|
|
40
|
+
}
|
|
41
|
+
: missing(adapter, "inference_timing", support.inference_timing);
|
|
42
|
+
const usedTokens = number(context?.used_tokens) ??
|
|
43
|
+
number(context?.input_tokens) ??
|
|
44
|
+
number(context?.total_tokens) ??
|
|
45
|
+
number(payload.used_tokens) ??
|
|
46
|
+
number(payload.total_input_tokens) ??
|
|
47
|
+
number(usage?.total_tokens) ??
|
|
48
|
+
number(usage?.prompt_tokens) ??
|
|
49
|
+
(usage
|
|
50
|
+
? sumDefined([
|
|
51
|
+
number(usage.input_tokens),
|
|
52
|
+
number(usage.cache_read_input_tokens),
|
|
53
|
+
number(usage.cache_creation_input_tokens),
|
|
54
|
+
])
|
|
55
|
+
: undefined);
|
|
56
|
+
const limitTokens = number(context?.context_window_size) ??
|
|
57
|
+
number(context?.window_tokens) ??
|
|
58
|
+
number(context?.context_window_tokens) ??
|
|
59
|
+
number(context?.max_tokens) ??
|
|
60
|
+
number(payload.context_window_size) ??
|
|
61
|
+
number(payload.context_window_tokens) ??
|
|
62
|
+
(typeof payload.context_window === "number" ? number(payload.context_window) : undefined);
|
|
63
|
+
const contextMeasurement = contextObservation(adapter, usedTokens, limitTokens, observedAt, support.context_usage);
|
|
64
|
+
return { usage: usageObservation, inference: inferenceObservation, context: contextMeasurement };
|
|
65
|
+
}
|
|
66
|
+
function contextObservation(adapter, usedTokens, limitTokens, observedAt, override) {
|
|
67
|
+
if (usedTokens !== undefined && limitTokens !== undefined && limitTokens > 0) {
|
|
68
|
+
return {
|
|
69
|
+
state: "observed",
|
|
70
|
+
value: {
|
|
71
|
+
used_tokens: usedTokens,
|
|
72
|
+
limit_tokens: limitTokens,
|
|
73
|
+
remaining_tokens: Math.max(0, limitTokens - usedTokens),
|
|
74
|
+
measured_at: observedAt,
|
|
75
|
+
method: `${adapter.replaceAll("-", "_")}_hook`,
|
|
76
|
+
},
|
|
77
|
+
attestation: "native",
|
|
78
|
+
confidence: "exact",
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
if (usedTokens !== undefined || limitTokens !== undefined) {
|
|
82
|
+
return {
|
|
83
|
+
state: "expected_but_missing",
|
|
84
|
+
capability: "context_usage",
|
|
85
|
+
reason: usedTokens === undefined
|
|
86
|
+
? "context_used_tokens_not_reported"
|
|
87
|
+
: limitTokens === undefined
|
|
88
|
+
? "context_limit_tokens_not_reported"
|
|
89
|
+
: "context_limit_tokens_invalid",
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
return missing(adapter, "context_usage", override);
|
|
93
|
+
}
|
|
94
|
+
export function emptyHarnessTimingV3() {
|
|
95
|
+
return { hook_time_ms: 0, hook_count: 0, slowest_hook_ms: 0 };
|
|
96
|
+
}
|
|
97
|
+
export function recordHarnessTimingV3(accumulator, hook, durationMs) {
|
|
98
|
+
const duration = safeInteger(durationMs);
|
|
99
|
+
if (duration === undefined)
|
|
100
|
+
return accumulator;
|
|
101
|
+
const name = safeToken(hook, "unknown_hook");
|
|
102
|
+
return {
|
|
103
|
+
hook_time_ms: accumulator.hook_time_ms + duration,
|
|
104
|
+
hook_count: accumulator.hook_count + 1,
|
|
105
|
+
slowest_hook: duration >= accumulator.slowest_hook_ms ? name : accumulator.slowest_hook,
|
|
106
|
+
slowest_hook_ms: Math.max(duration, accumulator.slowest_hook_ms),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
export function harnessObservationV3(accumulator) {
|
|
110
|
+
return accumulator.hook_count > 0
|
|
111
|
+
? {
|
|
112
|
+
state: "observed",
|
|
113
|
+
value: {
|
|
114
|
+
hook_time_ms: accumulator.hook_time_ms,
|
|
115
|
+
hook_count: accumulator.hook_count,
|
|
116
|
+
...(accumulator.slowest_hook
|
|
117
|
+
? {
|
|
118
|
+
slowest_hook: accumulator.slowest_hook,
|
|
119
|
+
slowest_hook_ms: accumulator.slowest_hook_ms,
|
|
120
|
+
}
|
|
121
|
+
: {}),
|
|
122
|
+
},
|
|
123
|
+
attestation: "derived",
|
|
124
|
+
confidence: "high",
|
|
125
|
+
}
|
|
126
|
+
: {
|
|
127
|
+
state: "expected_but_missing",
|
|
128
|
+
capability: "harness_timing",
|
|
129
|
+
reason: "no_hook_timing_samples",
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function missing(adapter, signal, override) {
|
|
133
|
+
const declared = override ?? adapterSignalSupportV3(adapter, signal);
|
|
134
|
+
if (declared === "unsupported")
|
|
135
|
+
return { state: "unsupported", capability: signal };
|
|
136
|
+
return {
|
|
137
|
+
state: "expected_but_missing",
|
|
138
|
+
capability: signal,
|
|
139
|
+
reason: signal === "model_usage"
|
|
140
|
+
? "not_reported"
|
|
141
|
+
: declared === "conditional"
|
|
142
|
+
? "conditional_signal_not_reported"
|
|
143
|
+
: "promised_signal_not_reported",
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function record(value) {
|
|
147
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
148
|
+
? value
|
|
149
|
+
: undefined;
|
|
150
|
+
}
|
|
151
|
+
function number(value) {
|
|
152
|
+
return typeof value === "number" ? safeInteger(value) : undefined;
|
|
153
|
+
}
|
|
154
|
+
function safeInteger(value) {
|
|
155
|
+
return Number.isFinite(value) && value >= 0 ? Math.floor(value) : undefined;
|
|
156
|
+
}
|
|
157
|
+
function sumDefined(values) {
|
|
158
|
+
return values.some((value) => value !== undefined)
|
|
159
|
+
? values.reduce((total, value) => total + (value ?? 0), 0)
|
|
160
|
+
: undefined;
|
|
161
|
+
}
|
|
162
|
+
function safeToken(value, fallback) {
|
|
163
|
+
const normalized = value
|
|
164
|
+
.normalize("NFC")
|
|
165
|
+
.replace(/[^a-zA-Z0-9._:/+-]/g, "_")
|
|
166
|
+
.slice(0, 128);
|
|
167
|
+
return /^[a-zA-Z0-9]/.test(normalized) ? normalized : fallback;
|
|
168
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type EventV3 } from "./contract.js";
|
|
2
|
+
export interface EventV3ValidationResult {
|
|
3
|
+
ok: boolean;
|
|
4
|
+
event?: EventV3;
|
|
5
|
+
issues: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare function validateEventV3(value: unknown): EventV3ValidationResult;
|
|
8
|
+
export declare function assertEventV3(value: unknown): asserts value is EventV3;
|
|
9
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../../src/core/events/v3/validate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAiB,MAAM,eAAe,CAAC;AAE5D,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAuCD,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,uBAAuB,CAkBvE;AAkSD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,CAKtE"}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { Value } from "@sinclair/typebox/value";
|
|
2
|
+
import { canonicalJsonV3 } from "./canonical.js";
|
|
3
|
+
import { EventV3Schema } from "./contract.js";
|
|
4
|
+
export function validateEventV3(value) {
|
|
5
|
+
if (!Value.Check(EventV3Schema, value)) {
|
|
6
|
+
return {
|
|
7
|
+
ok: false,
|
|
8
|
+
issues: [...Value.Errors(EventV3Schema, value)]
|
|
9
|
+
.slice(0, 12)
|
|
10
|
+
.map((error) => `${error.path || "/"}:${error.type}`),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
const event = value;
|
|
14
|
+
const issues = [
|
|
15
|
+
...validateBaseSemantics(event),
|
|
16
|
+
...validateSpanSemantics(event),
|
|
17
|
+
...validateRecoverySemantics(event),
|
|
18
|
+
];
|
|
19
|
+
return issues.length === 0
|
|
20
|
+
? { ok: true, event: value, issues: [] }
|
|
21
|
+
: { ok: false, issues };
|
|
22
|
+
}
|
|
23
|
+
function validateBaseSemantics(event) {
|
|
24
|
+
const issues = [];
|
|
25
|
+
const targets = event.event_type === "tool.requested"
|
|
26
|
+
? arrayOfRecords(event.payload.targets)
|
|
27
|
+
: event.event_type === "coord.claim_changed"
|
|
28
|
+
? [record(event.payload.target)]
|
|
29
|
+
: [];
|
|
30
|
+
for (const [index, target] of targets.entries()) {
|
|
31
|
+
if (target.display === undefined)
|
|
32
|
+
continue;
|
|
33
|
+
const prefix = event.event_type === "tool.requested" ? `/payload/targets/${index}` : "/payload/target";
|
|
34
|
+
if (target.kind !== "workspace_path") {
|
|
35
|
+
issues.push(`${prefix}/display:forbidden_for_target_kind`);
|
|
36
|
+
}
|
|
37
|
+
else if (typeof target.display !== "string" || !safeWorkspaceDisplay(target.display)) {
|
|
38
|
+
issues.push(`${prefix}/display:workspace_path_invalid`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (event.producer.bridge === "codex-wsl" && event.producer.platform !== "linux") {
|
|
42
|
+
issues.push("/producer/platform:codex-wsl_requires_linux_writer");
|
|
43
|
+
}
|
|
44
|
+
if (event.provenance.attribution.state === "verified" &&
|
|
45
|
+
event.provenance.attribution.method === "unattributed") {
|
|
46
|
+
issues.push("/provenance/attribution:verified_unattributed");
|
|
47
|
+
}
|
|
48
|
+
if (event.event_type === "session.started") {
|
|
49
|
+
validateAttestationDeclaration(event, issues);
|
|
50
|
+
}
|
|
51
|
+
if (event.event_type === "session.attestation_changed") {
|
|
52
|
+
const declaration = validateAttestationDeclaration(event, issues);
|
|
53
|
+
if (event.payload.prior_attestation_id === declaration.attestation_id) {
|
|
54
|
+
issues.push("/payload/prior_attestation_id:must_change");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (event.event_type === "turn.completed") {
|
|
58
|
+
const harnessObservation = record(event.payload.harness);
|
|
59
|
+
if (harnessObservation.state === "observed") {
|
|
60
|
+
const harness = record(harnessObservation.value);
|
|
61
|
+
const slowestHookMs = harness.slowest_hook_ms;
|
|
62
|
+
if (slowestHookMs !== undefined && typeof harness.slowest_hook !== "string") {
|
|
63
|
+
issues.push("/payload/harness/value/slowest_hook:required_with_duration");
|
|
64
|
+
}
|
|
65
|
+
if (typeof slowestHookMs === "number" &&
|
|
66
|
+
typeof harness.hook_time_ms === "number" &&
|
|
67
|
+
slowestHookMs > harness.hook_time_ms) {
|
|
68
|
+
issues.push("/payload/harness/value/slowest_hook_ms:must_not_exceed_hook_time");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (event.links.caused_by.includes(event.event_id)) {
|
|
73
|
+
issues.push("/links/caused_by:self_reference");
|
|
74
|
+
}
|
|
75
|
+
if (event.links.span_id !== undefined && event.links.span_id === event.links.parent_span_id) {
|
|
76
|
+
issues.push("/links/parent_span_id:self_reference");
|
|
77
|
+
}
|
|
78
|
+
if (event.event_type === "session.termination_observed" &&
|
|
79
|
+
event.payload.observer_instance_id === event.payload.subject_instance_id) {
|
|
80
|
+
issues.push("/payload/observer_instance_id:observer_must_differ_from_subject");
|
|
81
|
+
}
|
|
82
|
+
if (event.event_type === "progress.observed") {
|
|
83
|
+
const evidenceIds = Array.isArray(event.payload.evidence_event_ids)
|
|
84
|
+
? event.payload.evidence_event_ids
|
|
85
|
+
: [];
|
|
86
|
+
if (evidenceIds.includes(event.event_id)) {
|
|
87
|
+
issues.push("/payload/evidence_event_ids:self_reference");
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if ((event.event_type === "coord.task_changed" ||
|
|
91
|
+
event.event_type === "coord.lifecycle_changed" ||
|
|
92
|
+
event.event_type === "coord.identity_attested") &&
|
|
93
|
+
!record(event.payload.authority).transaction_id) {
|
|
94
|
+
issues.push("/payload/authority/transaction_id:required_for_authority_transition");
|
|
95
|
+
}
|
|
96
|
+
if (event.event_type === "decision.state_changed") {
|
|
97
|
+
const authority = record(event.payload.authority);
|
|
98
|
+
if (!authority.transaction_id && !authority.record_id) {
|
|
99
|
+
issues.push("/payload/authority:durable_reference_required");
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (event.event_type === "coord.claim_changed" &&
|
|
103
|
+
event.payload.operation !== "denied" &&
|
|
104
|
+
!record(event.payload.authority).transaction_id) {
|
|
105
|
+
issues.push("/payload/authority/transaction_id:required_for_authority_transition");
|
|
106
|
+
}
|
|
107
|
+
if (event.event_type === "coord.claim_changed" &&
|
|
108
|
+
record(event.payload.target).access !== event.payload.access) {
|
|
109
|
+
issues.push("/payload/target/access:must_match_claim_access");
|
|
110
|
+
}
|
|
111
|
+
if (event.event_type === "ledger.activated" &&
|
|
112
|
+
event.payload.eligible_after_event_id !== event.event_id) {
|
|
113
|
+
issues.push("/payload/eligible_after_event_id:must_reference_activation_event");
|
|
114
|
+
}
|
|
115
|
+
return issues;
|
|
116
|
+
}
|
|
117
|
+
function validateAttestationDeclaration(event, issues) {
|
|
118
|
+
const declaration = record(event.payload.runtime_attestation);
|
|
119
|
+
if (declaration.attestation_id !== event.attestation_id) {
|
|
120
|
+
issues.push("/payload/runtime_attestation/attestation_id:mismatch");
|
|
121
|
+
}
|
|
122
|
+
if (declaration.generation_id !== event.scope.generation_id) {
|
|
123
|
+
issues.push("/payload/runtime_attestation/generation_id:mismatch");
|
|
124
|
+
}
|
|
125
|
+
if (declaration.declared_by_event_id !== event.event_id) {
|
|
126
|
+
issues.push("/payload/runtime_attestation/declared_by_event_id:mismatch");
|
|
127
|
+
}
|
|
128
|
+
return declaration;
|
|
129
|
+
}
|
|
130
|
+
function validateSpanSemantics(event) {
|
|
131
|
+
const span = spanFrom(event.payload.span);
|
|
132
|
+
if (!span)
|
|
133
|
+
return [];
|
|
134
|
+
const issues = [];
|
|
135
|
+
if (span.span_id === span.parent_span_id) {
|
|
136
|
+
issues.push("/payload/span/parent_span_id:self_reference");
|
|
137
|
+
}
|
|
138
|
+
if (span.open_event_id === event.event_id) {
|
|
139
|
+
issues.push("/payload/span/open_event_id:self_reference");
|
|
140
|
+
}
|
|
141
|
+
if (event.links.span_id !== undefined && event.links.span_id !== span.span_id) {
|
|
142
|
+
issues.push("/payload/span/span_id:must_match_links");
|
|
143
|
+
}
|
|
144
|
+
if (event.links.parent_span_id !== undefined &&
|
|
145
|
+
event.links.parent_span_id !== span.parent_span_id) {
|
|
146
|
+
issues.push("/payload/span/parent_span_id:must_match_links");
|
|
147
|
+
}
|
|
148
|
+
if (span.open_event_id !== undefined && !event.links.caused_by.includes(span.open_event_id)) {
|
|
149
|
+
issues.push("/payload/span/open_event_id:must_be_causal_parent");
|
|
150
|
+
}
|
|
151
|
+
const duration = observationFrom(event.payload.duration_ms);
|
|
152
|
+
if (duration && canonicalJsonV3(duration) !== canonicalJsonV3(span.duration_ms)) {
|
|
153
|
+
issues.push("/payload/duration_ms:must_match_span_duration");
|
|
154
|
+
}
|
|
155
|
+
const openedAt = Date.parse(span.opened_at);
|
|
156
|
+
const completedAt = Date.parse(event.time.observed_at);
|
|
157
|
+
if (openedAt > completedAt &&
|
|
158
|
+
(span.duration_ms.state !== "expected_but_missing" ||
|
|
159
|
+
span.duration_ms.reason !== "clock_regressed")) {
|
|
160
|
+
issues.push("/payload/span/duration_ms:clock_regression_must_be_missing");
|
|
161
|
+
}
|
|
162
|
+
return issues;
|
|
163
|
+
}
|
|
164
|
+
function validateRecoverySemantics(event) {
|
|
165
|
+
if (event.event_type !== "tool.requested" &&
|
|
166
|
+
event.event_type !== "tool.completed" &&
|
|
167
|
+
event.event_type !== "command.completed") {
|
|
168
|
+
return [];
|
|
169
|
+
}
|
|
170
|
+
const issues = [];
|
|
171
|
+
const recovery = recoveryFrom(event.payload.recovery);
|
|
172
|
+
if (!recovery) {
|
|
173
|
+
if (event.event_type !== "command.completed" && event.provenance.attestation === "derived") {
|
|
174
|
+
issues.push("/payload/recovery:required_for_derived_tool_event");
|
|
175
|
+
}
|
|
176
|
+
return issues;
|
|
177
|
+
}
|
|
178
|
+
if (event.provenance.attestation !== "derived") {
|
|
179
|
+
issues.push("/payload/recovery:requires_derived_attestation");
|
|
180
|
+
}
|
|
181
|
+
if (recovery.requested_event_id === event.event_id) {
|
|
182
|
+
issues.push("/payload/recovery/requested_event_id:self_reference");
|
|
183
|
+
}
|
|
184
|
+
if (event.event_type === "tool.requested") {
|
|
185
|
+
if (recovery.reason !== "request_not_observed") {
|
|
186
|
+
issues.push("/payload/recovery/reason:invalid_for_tool_requested");
|
|
187
|
+
}
|
|
188
|
+
if (recovery.requested_event_id !== undefined) {
|
|
189
|
+
issues.push("/payload/recovery/requested_event_id:forbidden_on_derived_request");
|
|
190
|
+
}
|
|
191
|
+
if (recovery.elapsed_upper_bound_ms !== undefined) {
|
|
192
|
+
issues.push("/payload/recovery/elapsed_upper_bound_ms:forbidden_on_tool_requested");
|
|
193
|
+
}
|
|
194
|
+
return issues;
|
|
195
|
+
}
|
|
196
|
+
if (event.payload.outcome !== "unknown") {
|
|
197
|
+
issues.push("/payload/outcome:recovery_requires_unknown_outcome");
|
|
198
|
+
}
|
|
199
|
+
const span = spanFrom(event.payload.span);
|
|
200
|
+
const duration = observationFrom(event.payload.duration_ms);
|
|
201
|
+
for (const [path, candidate] of [
|
|
202
|
+
["/payload/span/duration_ms", span?.duration_ms],
|
|
203
|
+
["/payload/duration_ms", duration],
|
|
204
|
+
]) {
|
|
205
|
+
if (!candidate)
|
|
206
|
+
continue;
|
|
207
|
+
if (candidate.state !== "unknown") {
|
|
208
|
+
issues.push(`${path}:recovery_requires_unknown_duration`);
|
|
209
|
+
}
|
|
210
|
+
else if (candidate.reason !== recovery.reason) {
|
|
211
|
+
issues.push(`${path}:recovery_reason_mismatch`);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
const upperBound = recovery.elapsed_upper_bound_ms;
|
|
215
|
+
if (upperBound?.state === "observed") {
|
|
216
|
+
if (upperBound.attestation !== "derived" || upperBound.confidence !== "exact") {
|
|
217
|
+
issues.push("/payload/recovery/elapsed_upper_bound_ms:requires_exact_derived_monotonic_time");
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
else if (upperBound &&
|
|
221
|
+
(upperBound.state !== "unknown" ||
|
|
222
|
+
(upperBound.reason !== "recovery_clock_mismatch" &&
|
|
223
|
+
upperBound.reason !== "recovery_monotonic_clock_unavailable" &&
|
|
224
|
+
upperBound.reason !== "recovery_monotonic_clock_regressed"))) {
|
|
225
|
+
issues.push("/payload/recovery/elapsed_upper_bound_ms:invalid_clock_proof");
|
|
226
|
+
}
|
|
227
|
+
if (event.event_type === "command.completed") {
|
|
228
|
+
if (recovery.reason !== "command_completion_not_observed") {
|
|
229
|
+
issues.push("/payload/recovery/reason:invalid_for_command_completed");
|
|
230
|
+
}
|
|
231
|
+
if (event.payload.exit_code !== undefined) {
|
|
232
|
+
issues.push("/payload/exit_code:forbidden_on_recovered_command");
|
|
233
|
+
}
|
|
234
|
+
if (recovery.elapsed_upper_bound_ms !== undefined) {
|
|
235
|
+
issues.push("/payload/recovery/elapsed_upper_bound_ms:forbidden_on_command_completed");
|
|
236
|
+
}
|
|
237
|
+
return issues;
|
|
238
|
+
}
|
|
239
|
+
if (recovery.reason === "request_not_observed" ||
|
|
240
|
+
recovery.reason === "command_completion_not_observed") {
|
|
241
|
+
issues.push("/payload/recovery/reason:invalid_for_tool_completed");
|
|
242
|
+
}
|
|
243
|
+
return issues;
|
|
244
|
+
}
|
|
245
|
+
function safeWorkspaceDisplay(value) {
|
|
246
|
+
return (value === "." ||
|
|
247
|
+
(!value.startsWith("/") &&
|
|
248
|
+
!/^[a-zA-Z]:/.test(value) &&
|
|
249
|
+
!value.includes("\\") &&
|
|
250
|
+
!value.split("/").includes("..")));
|
|
251
|
+
}
|
|
252
|
+
function record(value) {
|
|
253
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
254
|
+
? value
|
|
255
|
+
: {};
|
|
256
|
+
}
|
|
257
|
+
function arrayOfRecords(value) {
|
|
258
|
+
return Array.isArray(value) ? value.map(record) : [];
|
|
259
|
+
}
|
|
260
|
+
function observationFrom(value) {
|
|
261
|
+
const candidate = record(value);
|
|
262
|
+
return typeof candidate.state === "string"
|
|
263
|
+
? candidate
|
|
264
|
+
: undefined;
|
|
265
|
+
}
|
|
266
|
+
function spanFrom(value) {
|
|
267
|
+
const candidate = record(value);
|
|
268
|
+
return typeof candidate.span_id === "string" && observationFrom(candidate.duration_ms)
|
|
269
|
+
? candidate
|
|
270
|
+
: undefined;
|
|
271
|
+
}
|
|
272
|
+
function recoveryFrom(value) {
|
|
273
|
+
const candidate = record(value);
|
|
274
|
+
return typeof candidate.reason === "string" ? candidate : undefined;
|
|
275
|
+
}
|
|
276
|
+
export function assertEventV3(value) {
|
|
277
|
+
const result = validateEventV3(value);
|
|
278
|
+
if (!result.ok) {
|
|
279
|
+
throw new Error(`event failed V3 contract validation (${result.issues.join(", ")})`);
|
|
280
|
+
}
|
|
281
|
+
}
|