harnery 0.35.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commander.d.ts +30 -5
- package/dist/commander.d.ts.map +1 -1
- package/dist/commander.js +128 -96
- package/dist/commands/agents.d.ts +23 -3
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +464 -242
- package/dist/commands/artifacts.d.ts.map +1 -1
- package/dist/commands/artifacts.js +26 -1
- package/dist/commands/backup.d.ts.map +1 -1
- package/dist/commands/backup.js +10 -10
- package/dist/commands/browse-session.d.ts.map +1 -1
- package/dist/commands/browse-session.js +12 -0
- package/dist/commands/browse.d.ts +1 -1
- package/dist/commands/browse.d.ts.map +1 -1
- package/dist/commands/browse.js +16 -4
- package/dist/commands/conversations.d.ts +10 -0
- package/dist/commands/conversations.d.ts.map +1 -0
- package/dist/commands/conversations.js +201 -0
- package/dist/commands/deinit.d.ts.map +1 -1
- package/dist/commands/deinit.js +5 -0
- package/dist/commands/diagnostics.d.ts +4 -0
- package/dist/commands/diagnostics.d.ts.map +1 -0
- package/dist/commands/diagnostics.js +229 -0
- package/dist/commands/docs.d.ts.map +1 -1
- package/dist/commands/docs.js +13 -2
- package/dist/commands/doctor.d.ts +5 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +51 -7
- package/dist/commands/fetch.js +6 -5
- package/dist/commands/files.d.ts +34 -0
- package/dist/commands/files.d.ts.map +1 -0
- package/dist/commands/files.js +166 -0
- package/dist/commands/governor.d.ts.map +1 -1
- package/dist/commands/governor.js +18 -12
- package/dist/commands/inbox.d.ts +5 -0
- package/dist/commands/inbox.d.ts.map +1 -0
- package/dist/commands/inbox.js +57 -0
- package/dist/commands/init.d.ts +4 -5
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +63 -13
- package/dist/commands/ledger-v3.d.ts.map +1 -1
- package/dist/commands/ledger-v3.js +417 -2
- package/dist/commands/logs.d.ts +4 -0
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/logs.js +169 -0
- package/dist/commands/messages.d.ts +5 -0
- package/dist/commands/messages.d.ts.map +1 -0
- package/dist/commands/messages.js +45 -0
- package/dist/commands/outline.d.ts +1 -1
- package/dist/commands/outline.d.ts.map +1 -1
- package/dist/commands/outline.js +2 -2
- package/dist/commands/qa-run.d.ts +4 -0
- package/dist/commands/qa-run.d.ts.map +1 -0
- package/dist/commands/qa-run.js +141 -0
- package/dist/commands/read.d.ts +1 -1
- package/dist/commands/read.d.ts.map +1 -1
- package/dist/commands/read.js +2 -2
- package/dist/commands/resources.d.ts +4 -0
- package/dist/commands/resources.d.ts.map +1 -0
- package/dist/commands/resources.js +29 -0
- package/dist/commands/semantic.d.ts.map +1 -1
- package/dist/commands/semantic.js +54 -2
- package/dist/commands/storage.d.ts +4 -0
- package/dist/commands/storage.d.ts.map +1 -0
- package/dist/commands/storage.js +238 -0
- package/dist/commands/supervisor.d.ts +4 -0
- package/dist/commands/supervisor.d.ts.map +1 -0
- package/dist/commands/supervisor.js +101 -0
- package/dist/commands/tunnel.d.ts +5 -1
- package/dist/commands/tunnel.d.ts.map +1 -1
- package/dist/commands/tunnel.js +44 -31
- package/dist/commands/web.d.ts +3 -0
- package/dist/commands/web.d.ts.map +1 -1
- package/dist/commands/web.js +84 -7
- package/dist/commands/work.js +3 -3
- package/dist/commands/workflow.d.ts.map +1 -1
- package/dist/commands/workflow.js +17 -13
- package/dist/core/adapters/profiles.d.ts +1 -1
- package/dist/core/agents/cli.js +215 -41
- package/dist/core/agents/health.d.ts +17 -0
- package/dist/core/agents/health.d.ts.map +1 -0
- package/dist/core/agents/health.js +109 -0
- package/dist/core/agents/live-authority-v3.d.ts +47 -1
- package/dist/core/agents/live-authority-v3.d.ts.map +1 -1
- package/dist/core/agents/live-authority-v3.js +244 -10
- package/dist/core/agents/live-lifecycle-v3.js +6 -1
- package/dist/core/agents/live-observation-v3.d.ts.map +1 -1
- package/dist/core/agents/live-observation-v3.js +6 -1
- package/dist/core/agents/mailbox.d.ts +92 -0
- package/dist/core/agents/mailbox.d.ts.map +1 -0
- package/dist/core/agents/mailbox.js +325 -0
- package/dist/core/agents/reconcile-coordination-v3.d.ts +44 -0
- package/dist/core/agents/reconcile-coordination-v3.d.ts.map +1 -0
- package/dist/core/agents/reconcile-coordination-v3.js +58 -0
- package/dist/core/agents/render/prompt-context.d.ts +14 -3
- package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
- package/dist/core/agents/render/prompt-context.js +54 -16
- package/dist/core/agents/render/session-context.d.ts +8 -0
- package/dist/core/agents/render/session-context.d.ts.map +1 -1
- package/dist/core/agents/render/session-context.js +34 -3
- package/dist/core/agents/rules/commit-conflict.d.ts.map +1 -1
- package/dist/core/agents/rules/commit-conflict.js +50 -1
- package/dist/core/agents/rules/stop-hook.d.ts +2 -0
- package/dist/core/agents/rules/stop-hook.d.ts.map +1 -1
- package/dist/core/agents/rules/stop-hook.js +93 -16
- package/dist/core/agents/rules/verdict.d.ts +1 -0
- package/dist/core/agents/rules/verdict.d.ts.map +1 -1
- package/dist/core/agents/session-events.d.ts.map +1 -1
- package/dist/core/agents/session-events.js +4 -0
- package/dist/core/agents/session-finalization-state-v3.js +1 -1
- package/dist/core/agents/session-finalizer-v3.js +9 -2
- package/dist/core/agents/state/activity-log.d.ts +3 -0
- package/dist/core/agents/state/activity-log.d.ts.map +1 -1
- package/dist/core/agents/state/activity-log.js +6 -3
- package/dist/core/agents/state/heartbeat-writer.d.ts +6 -0
- package/dist/core/agents/state/heartbeat-writer.d.ts.map +1 -1
- package/dist/core/agents/state/heartbeat-writer.js +18 -0
- package/dist/core/agents/state/live-coordination-view.d.ts +5 -7
- package/dist/core/agents/state/live-coordination-view.d.ts.map +1 -1
- package/dist/core/agents/state/live-coordination-view.js +15 -90
- package/dist/core/agents/state/live-coordination-writer.d.ts +12 -0
- package/dist/core/agents/state/live-coordination-writer.d.ts.map +1 -0
- package/dist/core/agents/state/live-coordination-writer.js +92 -0
- package/dist/core/artifacts/index.d.ts +47 -1
- package/dist/core/artifacts/index.d.ts.map +1 -1
- package/dist/core/artifacts/index.js +191 -6
- package/dist/core/config.d.ts +74 -4
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +141 -4
- package/dist/core/conversations/archive.d.ts +49 -0
- package/dist/core/conversations/archive.d.ts.map +1 -0
- package/dist/core/conversations/archive.js +136 -0
- package/dist/core/conversations/catalog.d.ts +10 -0
- package/dist/core/conversations/catalog.d.ts.map +1 -0
- package/dist/core/conversations/catalog.js +72 -0
- package/dist/core/conversations/context-pack.d.ts +6 -0
- package/dist/core/conversations/context-pack.d.ts.map +1 -0
- package/dist/core/conversations/context-pack.js +60 -0
- package/dist/core/conversations/contract.d.ts +155 -0
- package/dist/core/conversations/contract.d.ts.map +1 -0
- package/dist/core/conversations/contract.js +1 -0
- package/dist/core/conversations/evaluation.d.ts +16 -0
- package/dist/core/conversations/evaluation.d.ts.map +1 -0
- package/dist/core/conversations/evaluation.js +9 -0
- package/dist/core/conversations/index.d.ts +10 -0
- package/dist/core/conversations/index.d.ts.map +1 -0
- package/dist/core/conversations/index.js +9 -0
- package/dist/core/conversations/lifecycle.d.ts +28 -0
- package/dist/core/conversations/lifecycle.d.ts.map +1 -0
- package/dist/core/conversations/lifecycle.js +29 -0
- package/dist/core/conversations/normalize.d.ts +14 -0
- package/dist/core/conversations/normalize.d.ts.map +1 -0
- package/dist/core/conversations/normalize.js +82 -0
- package/dist/core/conversations/query.d.ts +8 -0
- package/dist/core/conversations/query.d.ts.map +1 -0
- package/dist/core/conversations/query.js +280 -0
- package/dist/core/conversations/search-index.d.ts +9 -0
- package/dist/core/conversations/search-index.d.ts.map +1 -0
- package/dist/core/conversations/search-index.js +29 -0
- package/dist/core/diagnostics/advice.d.ts +9 -0
- package/dist/core/diagnostics/advice.d.ts.map +1 -0
- package/dist/core/diagnostics/advice.js +112 -0
- package/dist/core/diagnostics/bundle.d.ts +35 -0
- package/dist/core/diagnostics/bundle.d.ts.map +1 -0
- package/dist/core/diagnostics/bundle.js +874 -0
- package/dist/core/diagnostics/comparison.d.ts +5 -0
- package/dist/core/diagnostics/comparison.d.ts.map +1 -0
- package/dist/core/diagnostics/comparison.js +444 -0
- package/dist/core/diagnostics/contract.d.ts +245 -0
- package/dist/core/diagnostics/contract.d.ts.map +1 -0
- package/dist/core/diagnostics/contract.js +18 -0
- package/dist/core/diagnostics/identity.d.ts +3 -0
- package/dist/core/diagnostics/identity.d.ts.map +1 -0
- package/dist/core/diagnostics/identity.js +10 -0
- package/dist/core/diagnostics/index.d.ts +8 -0
- package/dist/core/diagnostics/index.d.ts.map +1 -0
- package/dist/core/diagnostics/index.js +7 -0
- package/dist/core/diagnostics/replay.d.ts +8 -0
- package/dist/core/diagnostics/replay.d.ts.map +1 -0
- package/dist/core/diagnostics/replay.js +213 -0
- package/dist/core/diagnostics/sanitize.d.ts +9 -0
- package/dist/core/diagnostics/sanitize.d.ts.map +1 -0
- package/dist/core/diagnostics/sanitize.js +84 -0
- package/dist/core/events/legacy-storage/canary.d.ts +18 -0
- package/dist/core/events/legacy-storage/canary.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/canary.js +150 -0
- package/dist/core/events/legacy-storage/compression.d.ts +13 -0
- package/dist/core/events/legacy-storage/compression.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/compression.js +107 -0
- package/dist/core/events/legacy-storage/fence.d.ts +15 -0
- package/dist/core/events/legacy-storage/fence.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/fence.js +115 -0
- package/dist/core/events/legacy-storage/index.d.ts +7 -0
- package/dist/core/events/legacy-storage/index.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/index.js +6 -0
- package/dist/core/events/legacy-storage/inventory.d.ts +10 -0
- package/dist/core/events/legacy-storage/inventory.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/inventory.js +40 -0
- package/dist/core/events/legacy-storage/manifest.d.ts +23 -0
- package/dist/core/events/legacy-storage/manifest.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/manifest.js +108 -0
- package/dist/core/events/legacy-storage/reader.d.ts +15 -0
- package/dist/core/events/legacy-storage/reader.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/reader.js +154 -0
- package/dist/core/events/v3/archive-retention.d.ts +33 -0
- package/dist/core/events/v3/archive-retention.d.ts.map +1 -0
- package/dist/core/events/v3/archive-retention.js +195 -0
- package/dist/core/events/v3/authority-outbox.d.ts +7 -2
- package/dist/core/events/v3/authority-outbox.d.ts.map +1 -1
- package/dist/core/events/v3/authority-outbox.js +16 -3
- package/dist/core/events/v3/base-contract.d.ts +81 -41
- package/dist/core/events/v3/base-contract.d.ts.map +1 -1
- package/dist/core/events/v3/base-contract.js +17 -7
- package/dist/core/events/v3/bootstrap.d.ts +39 -0
- package/dist/core/events/v3/bootstrap.d.ts.map +1 -1
- package/dist/core/events/v3/bootstrap.js +167 -3
- package/dist/core/events/v3/capabilities.d.ts +1 -1
- package/dist/core/events/v3/capabilities.d.ts.map +1 -1
- package/dist/core/events/v3/capabilities.js +4 -3
- package/dist/core/events/v3/control-witness.d.ts +44 -0
- package/dist/core/events/v3/control-witness.d.ts.map +1 -0
- package/dist/core/events/v3/control-witness.js +233 -0
- package/dist/core/events/v3/control-writer.d.ts +4 -0
- package/dist/core/events/v3/control-writer.d.ts.map +1 -0
- package/dist/core/events/v3/control-writer.js +16 -0
- package/dist/core/events/v3/control.d.ts +8 -2
- package/dist/core/events/v3/control.d.ts.map +1 -1
- package/dist/core/events/v3/control.js +46 -18
- package/dist/core/events/v3/coordination-transaction-recovery.d.ts +42 -0
- package/dist/core/events/v3/coordination-transaction-recovery.d.ts.map +1 -0
- package/dist/core/events/v3/coordination-transaction-recovery.js +342 -0
- package/dist/core/events/v3/coordination-view.d.ts.map +1 -1
- package/dist/core/events/v3/coordination-view.js +16 -1
- package/dist/core/events/v3/generated.d.ts +1 -1
- package/dist/core/events/v3/generated.js +1 -1
- package/dist/core/events/v3/index.d.ts +5 -2
- package/dist/core/events/v3/index.d.ts.map +1 -1
- package/dist/core/events/v3/index.js +4 -1
- package/dist/core/events/v3/live-route-observer.d.ts +31 -0
- package/dist/core/events/v3/live-route-observer.d.ts.map +1 -0
- package/dist/core/events/v3/live-route-observer.js +58 -0
- package/dist/core/events/v3/live-routing.d.ts +13 -21
- package/dist/core/events/v3/live-routing.d.ts.map +1 -1
- package/dist/core/events/v3/live-routing.js +46 -41
- package/dist/core/events/v3/producers/coordination-recorder.d.ts +11 -1
- package/dist/core/events/v3/producers/coordination-recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/coordination-recorder.js +76 -10
- package/dist/core/events/v3/producers/diagnostic-summaries.d.ts +129 -0
- package/dist/core/events/v3/producers/diagnostic-summaries.d.ts.map +1 -0
- package/dist/core/events/v3/producers/diagnostic-summaries.js +499 -0
- package/dist/core/events/v3/producers/hook-base.d.ts +1 -1
- package/dist/core/events/v3/producers/hook-base.d.ts.map +1 -1
- package/dist/core/events/v3/producers/hook-base.js +14 -3
- package/dist/core/events/v3/producers/intake.d.ts +7 -0
- package/dist/core/events/v3/producers/intake.d.ts.map +1 -1
- package/dist/core/events/v3/producers/intake.js +26 -2
- package/dist/core/events/v3/producers/producer-state-observer.d.ts +8 -0
- package/dist/core/events/v3/producers/producer-state-observer.d.ts.map +1 -0
- package/dist/core/events/v3/producers/producer-state-observer.js +45 -0
- package/dist/core/events/v3/producers/recorder.d.ts +71 -1
- package/dist/core/events/v3/producers/recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/recorder.js +441 -25
- package/dist/core/events/v3/reader.d.ts +51 -0
- package/dist/core/events/v3/reader.d.ts.map +1 -1
- package/dist/core/events/v3/reader.js +181 -1
- package/dist/core/events/v3/rotation-config.d.ts +9 -0
- package/dist/core/events/v3/rotation-config.d.ts.map +1 -0
- package/dist/core/events/v3/rotation-config.js +91 -0
- package/dist/core/events/v3/runtime-build.d.ts +11 -0
- package/dist/core/events/v3/runtime-build.d.ts.map +1 -0
- package/dist/core/events/v3/runtime-build.js +39 -0
- package/dist/core/events/v3/runtime-identity.d.ts +5 -0
- package/dist/core/events/v3/runtime-identity.d.ts.map +1 -0
- package/dist/core/events/v3/runtime-identity.js +18 -0
- package/dist/core/events/v3/runtime-telemetry-capabilities.d.ts +6 -5
- package/dist/core/events/v3/runtime-telemetry-capabilities.d.ts.map +1 -1
- package/dist/core/events/v3/runtime-telemetry-capabilities.js +1 -1
- package/dist/core/events/v3/support-storage/classify.d.ts +46 -0
- package/dist/core/events/v3/support-storage/classify.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/classify.js +149 -0
- package/dist/core/events/v3/support-storage/eligibility.d.ts +29 -0
- package/dist/core/events/v3/support-storage/eligibility.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/eligibility.js +35 -0
- package/dist/core/events/v3/support-storage/index.d.ts +10 -0
- package/dist/core/events/v3/support-storage/index.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/index.js +9 -0
- package/dist/core/events/v3/support-storage/inventory.d.ts +30 -0
- package/dist/core/events/v3/support-storage/inventory.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/inventory.js +94 -0
- package/dist/core/events/v3/support-storage/logical-authority.d.ts +14 -0
- package/dist/core/events/v3/support-storage/logical-authority.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/logical-authority.js +104 -0
- package/dist/core/events/v3/support-storage/maintenance.d.ts +98 -0
- package/dist/core/events/v3/support-storage/maintenance.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/maintenance.js +352 -0
- package/dist/core/events/v3/support-storage/pack-contract.d.ts +59 -0
- package/dist/core/events/v3/support-storage/pack-contract.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/pack-contract.js +249 -0
- package/dist/core/events/v3/support-storage/pack-reader.d.ts +34 -0
- package/dist/core/events/v3/support-storage/pack-reader.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/pack-reader.js +258 -0
- package/dist/core/events/v3/support-storage/pack-writer.d.ts +30 -0
- package/dist/core/events/v3/support-storage/pack-writer.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/pack-writer.js +268 -0
- package/dist/core/events/v3/support-storage/recovery.d.ts +15 -0
- package/dist/core/events/v3/support-storage/recovery.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/recovery.js +22 -0
- package/dist/core/events/v3/turn-telemetry.d.ts +14 -8
- package/dist/core/events/v3/turn-telemetry.d.ts.map +1 -1
- package/dist/core/events/v3/turn-telemetry.js +32 -2
- package/dist/core/events/v3/writer.d.ts +13 -1
- package/dist/core/events/v3/writer.d.ts.map +1 -1
- package/dist/core/events/v3/writer.js +126 -12
- package/dist/core/governor/plan-read.d.ts.map +1 -1
- package/dist/core/governor/plan-read.js +5 -21
- package/dist/core/governor/planning.js +6 -8
- package/dist/core/governor/service-read.d.ts +12 -0
- package/dist/core/governor/service-read.d.ts.map +1 -1
- package/dist/core/governor/service-read.js +266 -2
- package/dist/core/governor/service.d.ts +1 -0
- package/dist/core/governor/service.d.ts.map +1 -1
- package/dist/core/governor/service.js +53 -18
- package/dist/core/guard/evidence-v3.d.ts.map +1 -1
- package/dist/core/guard/evidence-v3.js +2 -0
- package/dist/core/hooks/adapter/events.d.ts.map +1 -1
- package/dist/core/hooks/adapter/events.js +1 -0
- package/dist/core/hooks/adapter/output.d.ts +12 -2
- package/dist/core/hooks/adapter/output.d.ts.map +1 -1
- package/dist/core/hooks/adapter/output.js +23 -5
- package/dist/core/hooks/adapter/runtime-telemetry.d.ts +27 -4
- package/dist/core/hooks/adapter/runtime-telemetry.d.ts.map +1 -1
- package/dist/core/hooks/adapter/runtime-telemetry.js +307 -6
- package/dist/core/hooks/cli.js +380 -207
- package/dist/core/hooks/effects/image-capture.d.ts +1 -1
- package/dist/core/hooks/effects/image-capture.d.ts.map +1 -1
- package/dist/core/hooks/effects/image-capture.js +4 -2
- package/dist/core/hooks/health.d.ts +59 -0
- package/dist/core/hooks/health.d.ts.map +1 -0
- package/dist/core/hooks/health.js +84 -0
- package/dist/core/hooks/remediation-cap.d.ts +8 -3
- package/dist/core/hooks/remediation-cap.d.ts.map +1 -1
- package/dist/core/hooks/remediation-cap.js +3 -11
- package/dist/core/hooks/resolve/coord-root.d.ts +22 -9
- package/dist/core/hooks/resolve/coord-root.d.ts.map +1 -1
- package/dist/core/hooks/resolve/coord-root.js +92 -11
- package/dist/core/hooks/resolve/owner.d.ts.map +1 -1
- package/dist/core/hooks/resolve/owner.js +5 -0
- package/dist/core/hooks/resolve/transcript.d.ts +8 -0
- package/dist/core/hooks/resolve/transcript.d.ts.map +1 -1
- package/dist/core/hooks/resolve/transcript.js +11 -0
- package/dist/core/inbox/contract.d.ts +64 -0
- package/dist/core/inbox/contract.d.ts.map +1 -0
- package/dist/core/inbox/contract.js +13 -0
- package/dist/core/inbox/index.d.ts +5 -0
- package/dist/core/inbox/index.d.ts.map +1 -0
- package/dist/core/inbox/index.js +4 -0
- package/dist/core/inbox/lifecycle.d.ts +22 -0
- package/dist/core/inbox/lifecycle.d.ts.map +1 -0
- package/dist/core/inbox/lifecycle.js +41 -0
- package/dist/core/inbox/service.d.ts +36 -0
- package/dist/core/inbox/service.d.ts.map +1 -0
- package/dist/core/inbox/service.js +210 -0
- package/dist/core/inbox/watcher.d.ts +7 -0
- package/dist/core/inbox/watcher.d.ts.map +1 -0
- package/dist/core/inbox/watcher.js +26 -0
- package/dist/core/presence/codec-digest.d.ts.map +1 -1
- package/dist/core/presence/codec-digest.js +14 -3
- package/dist/core/presence/relay-client.d.ts +1 -0
- package/dist/core/presence/relay-client.d.ts.map +1 -1
- package/dist/core/presence/relay-client.js +52 -8
- package/dist/core/resources/contract.d.ts +90 -0
- package/dist/core/resources/contract.d.ts.map +1 -0
- package/dist/core/resources/contract.js +2 -0
- package/dist/core/resources/index.d.ts +6 -0
- package/dist/core/resources/index.d.ts.map +1 -0
- package/dist/core/resources/index.js +5 -0
- package/dist/core/resources/sampler.d.ts +27 -0
- package/dist/core/resources/sampler.d.ts.map +1 -0
- package/dist/core/resources/sampler.js +357 -0
- package/dist/core/resources/service-status.d.ts +3 -0
- package/dist/core/resources/service-status.d.ts.map +1 -0
- package/dist/core/resources/service-status.js +48 -0
- package/dist/core/resources/service.d.ts +26 -0
- package/dist/core/resources/service.d.ts.map +1 -0
- package/dist/core/resources/service.js +292 -0
- package/dist/core/resources/storage.d.ts +13 -0
- package/dist/core/resources/storage.d.ts.map +1 -0
- package/dist/core/resources/storage.js +30 -0
- package/dist/core/semantic/adapters.d.ts +11 -8
- package/dist/core/semantic/adapters.d.ts.map +1 -1
- package/dist/core/semantic/adapters.js +169 -31
- package/dist/core/semantic/contract.d.ts +532 -48
- package/dist/core/semantic/contract.d.ts.map +1 -1
- package/dist/core/semantic/contract.js +104 -3
- package/dist/core/semantic/index.d.ts +7 -3
- package/dist/core/semantic/index.d.ts.map +1 -1
- package/dist/core/semantic/index.js +7 -3
- package/dist/core/semantic/once.d.ts +6 -1
- package/dist/core/semantic/once.d.ts.map +1 -1
- package/dist/core/semantic/once.js +80 -9
- package/dist/core/semantic/prompt.d.ts.map +1 -1
- package/dist/core/semantic/prompt.js +14 -1
- package/dist/core/semantic/review.d.ts +144 -0
- package/dist/core/semantic/review.d.ts.map +1 -0
- package/dist/core/semantic/review.js +544 -0
- package/dist/core/semantic/routes.d.ts +10 -0
- package/dist/core/semantic/routes.d.ts.map +1 -0
- package/dist/core/semantic/routes.js +21 -0
- package/dist/core/semantic/scheduler.d.ts +14 -3
- package/dist/core/semantic/scheduler.d.ts.map +1 -1
- package/dist/core/semantic/scheduler.js +30 -6
- package/dist/core/semantic/service-status.d.ts +20 -0
- package/dist/core/semantic/service-status.d.ts.map +1 -1
- package/dist/core/semantic/service-status.js +60 -4
- package/dist/core/semantic/service.d.ts +1 -0
- package/dist/core/semantic/service.d.ts.map +1 -1
- package/dist/core/semantic/service.js +104 -15
- package/dist/core/semantic/soak.d.ts +75 -0
- package/dist/core/semantic/soak.d.ts.map +1 -0
- package/dist/core/semantic/soak.js +476 -0
- package/dist/core/semantic/storage.d.ts +11 -1
- package/dist/core/semantic/storage.d.ts.map +1 -1
- package/dist/core/semantic/storage.js +4 -3
- package/dist/core/semantic/usage.d.ts +43 -0
- package/dist/core/semantic/usage.d.ts.map +1 -0
- package/dist/core/semantic/usage.js +193 -0
- package/dist/core/semantic/validate.d.ts +3 -1
- package/dist/core/semantic/validate.d.ts.map +1 -1
- package/dist/core/semantic/validate.js +34 -1
- package/dist/core/storage/atomic-json.d.ts +3 -0
- package/dist/core/storage/atomic-json.d.ts.map +1 -0
- package/dist/core/storage/atomic-json.js +15 -0
- package/dist/core/storage/buffer.d.ts +28 -0
- package/dist/core/storage/buffer.d.ts.map +1 -0
- package/dist/core/storage/buffer.js +101 -0
- package/dist/core/storage/builtins.d.ts +3 -0
- package/dist/core/storage/builtins.d.ts.map +1 -0
- package/dist/core/storage/builtins.js +722 -0
- package/dist/core/storage/catalog.d.ts +19 -0
- package/dist/core/storage/catalog.d.ts.map +1 -0
- package/dist/core/storage/catalog.js +365 -0
- package/dist/core/storage/config.d.ts +16 -0
- package/dist/core/storage/config.d.ts.map +1 -0
- package/dist/core/storage/config.js +311 -0
- package/dist/core/storage/contract.d.ts +275 -0
- package/dist/core/storage/contract.d.ts.map +1 -0
- package/dist/core/storage/contract.js +3 -0
- package/dist/core/storage/durable-history.d.ts +36 -0
- package/dist/core/storage/durable-history.d.ts.map +1 -0
- package/dist/core/storage/durable-history.js +606 -0
- package/dist/core/storage/health.d.ts +4 -0
- package/dist/core/storage/health.d.ts.map +1 -0
- package/dist/core/storage/health.js +65 -0
- package/dist/core/storage/index.d.ts +16 -0
- package/dist/core/storage/index.d.ts.map +1 -0
- package/dist/core/storage/index.js +15 -0
- package/dist/core/storage/inventory.d.ts +25 -0
- package/dist/core/storage/inventory.d.ts.map +1 -0
- package/dist/core/storage/inventory.js +666 -0
- package/dist/core/storage/jsonl.d.ts +52 -0
- package/dist/core/storage/jsonl.d.ts.map +1 -0
- package/dist/core/storage/jsonl.js +156 -0
- package/dist/core/storage/log-retention.d.ts +52 -0
- package/dist/core/storage/log-retention.d.ts.map +1 -0
- package/dist/core/storage/log-retention.js +419 -0
- package/dist/core/storage/logger.d.ts +84 -0
- package/dist/core/storage/logger.d.ts.map +1 -0
- package/dist/core/storage/logger.js +413 -0
- package/dist/core/storage/maintenance-providers.d.ts +26 -0
- package/dist/core/storage/maintenance-providers.d.ts.map +1 -0
- package/dist/core/storage/maintenance-providers.js +141 -0
- package/dist/core/storage/maintenance.d.ts +125 -0
- package/dist/core/storage/maintenance.d.ts.map +1 -0
- package/dist/core/storage/maintenance.js +609 -0
- package/dist/core/storage/metrics.d.ts +60 -0
- package/dist/core/storage/metrics.d.ts.map +1 -0
- package/dist/core/storage/metrics.js +134 -0
- package/dist/core/storage/policy.d.ts +7 -0
- package/dist/core/storage/policy.d.ts.map +1 -0
- package/dist/core/storage/policy.js +110 -0
- package/dist/core/storage/process-log.d.ts +38 -0
- package/dist/core/storage/process-log.d.ts.map +1 -0
- package/dist/core/storage/process-log.js +165 -0
- package/dist/core/storage/query.d.ts +48 -0
- package/dist/core/storage/query.d.ts.map +1 -0
- package/dist/core/storage/query.js +346 -0
- package/dist/core/storage/receipts.d.ts +23 -0
- package/dist/core/storage/receipts.d.ts.map +1 -0
- package/dist/core/storage/receipts.js +117 -0
- package/dist/core/storage/segments.d.ts +84 -0
- package/dist/core/storage/segments.d.ts.map +1 -0
- package/dist/core/storage/segments.js +542 -0
- package/dist/core/storage/sink-graph.d.ts +65 -0
- package/dist/core/storage/sink-graph.d.ts.map +1 -0
- package/dist/core/storage/sink-graph.js +213 -0
- package/dist/core/storage/storm-control.d.ts +23 -0
- package/dist/core/storage/storm-control.d.ts.map +1 -0
- package/dist/core/storage/storm-control.js +59 -0
- package/dist/core/supervisor/activity.d.ts +4 -0
- package/dist/core/supervisor/activity.d.ts.map +1 -0
- package/dist/core/supervisor/activity.js +141 -0
- package/dist/core/supervisor/contract.d.ts +268 -0
- package/dist/core/supervisor/contract.d.ts.map +1 -0
- package/dist/core/supervisor/contract.js +35 -0
- package/dist/core/supervisor/explanations.d.ts +4 -0
- package/dist/core/supervisor/explanations.d.ts.map +1 -0
- package/dist/core/supervisor/explanations.js +71 -0
- package/dist/core/supervisor/findings.d.ts +20 -0
- package/dist/core/supervisor/findings.d.ts.map +1 -0
- package/dist/core/supervisor/findings.js +399 -0
- package/dist/core/supervisor/history.d.ts +9 -0
- package/dist/core/supervisor/history.d.ts.map +1 -0
- package/dist/core/supervisor/history.js +46 -0
- package/dist/core/supervisor/hook-health-alerts.d.ts +14 -0
- package/dist/core/supervisor/hook-health-alerts.d.ts.map +1 -0
- package/dist/core/supervisor/hook-health-alerts.js +70 -0
- package/dist/core/supervisor/hook-health-storage.d.ts +5 -0
- package/dist/core/supervisor/hook-health-storage.d.ts.map +1 -0
- package/dist/core/supervisor/hook-health-storage.js +24 -0
- package/dist/core/supervisor/hook-health.d.ts +72 -0
- package/dist/core/supervisor/hook-health.d.ts.map +1 -0
- package/dist/core/supervisor/hook-health.js +203 -0
- package/dist/core/supervisor/hooks.d.ts +10 -0
- package/dist/core/supervisor/hooks.d.ts.map +1 -0
- package/dist/core/supervisor/hooks.js +28 -0
- package/dist/core/supervisor/index.d.ts +15 -0
- package/dist/core/supervisor/index.d.ts.map +1 -0
- package/dist/core/supervisor/index.js +14 -0
- package/dist/core/supervisor/log-feed.d.ts +9 -0
- package/dist/core/supervisor/log-feed.d.ts.map +1 -0
- package/dist/core/supervisor/log-feed.js +103 -0
- package/dist/core/supervisor/service.d.ts +29 -0
- package/dist/core/supervisor/service.d.ts.map +1 -0
- package/dist/core/supervisor/service.js +450 -0
- package/dist/core/supervisor/services.d.ts +11 -0
- package/dist/core/supervisor/services.d.ts.map +1 -0
- package/dist/core/supervisor/services.js +155 -0
- package/dist/core/supervisor/status.d.ts +3 -0
- package/dist/core/supervisor/status.d.ts.map +1 -0
- package/dist/core/supervisor/status.js +48 -0
- package/dist/core/supervisor/storage.d.ts +30 -0
- package/dist/core/supervisor/storage.d.ts.map +1 -0
- package/dist/core/supervisor/storage.js +73 -0
- package/dist/core/supervisor/timeline.d.ts +3 -0
- package/dist/core/supervisor/timeline.d.ts.map +1 -0
- package/dist/core/supervisor/timeline.js +87 -0
- package/dist/core/work/state.d.ts.map +1 -1
- package/dist/core/work/state.js +10 -14
- package/dist/core/workflow/admission.d.ts +23 -0
- package/dist/core/workflow/admission.d.ts.map +1 -0
- package/dist/core/workflow/admission.js +136 -0
- package/dist/core/workflow/engine.d.ts.map +1 -1
- package/dist/core/workflow/engine.js +77 -2
- package/dist/core/workflow/index.d.ts +3 -2
- package/dist/core/workflow/index.d.ts.map +1 -1
- package/dist/core/workflow/index.js +2 -1
- package/dist/core/workflow/live-session-v3.d.ts.map +1 -1
- package/dist/core/workflow/live-session-v3.js +2 -1
- package/dist/core/workflow/proof.d.ts +2 -1
- package/dist/core/workflow/proof.d.ts.map +1 -1
- package/dist/core/workflow/proof.js +39 -1
- package/dist/core/workflow/run-state.d.ts +3 -2
- package/dist/core/workflow/run-state.d.ts.map +1 -1
- package/dist/core/workflow/run-state.js +8 -1
- package/dist/core/workflow/types.d.ts +33 -1
- package/dist/core/workflow/types.d.ts.map +1 -1
- package/dist/core/workflow/types.js +2 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/lazy-commands.d.ts +26 -0
- package/dist/lazy-commands.d.ts.map +1 -0
- package/dist/lazy-commands.js +210 -0
- package/dist/lib/browser/client.d.ts +5 -0
- package/dist/lib/browser/client.d.ts.map +1 -1
- package/dist/lib/browser/client.js +1 -0
- package/dist/lib/browser/index.d.ts +2 -0
- package/dist/lib/browser/index.d.ts.map +1 -1
- package/dist/lib/browser/index.js +2 -0
- package/dist/lib/browser/qa-run-contracts.d.ts +173 -0
- package/dist/lib/browser/qa-run-contracts.d.ts.map +1 -0
- package/dist/lib/browser/qa-run-contracts.js +226 -0
- package/dist/lib/browser/qa-run.d.ts +51 -0
- package/dist/lib/browser/qa-run.d.ts.map +1 -0
- package/dist/lib/browser/qa-run.js +684 -0
- package/dist/lib/coord-root-id.d.ts +9 -0
- package/dist/lib/coord-root-id.d.ts.map +1 -0
- package/dist/lib/coord-root-id.js +17 -0
- package/dist/lib/docs-lint.d.ts +2 -0
- package/dist/lib/docs-lint.d.ts.map +1 -1
- package/dist/lib/docs-lint.js +45 -80
- package/dist/lib/docs-metadata-audit.d.ts +3 -0
- package/dist/lib/docs-metadata-audit.d.ts.map +1 -1
- package/dist/lib/docs-metadata-audit.js +13 -23
- package/dist/lib/docs-metadata-sync.d.ts +1 -0
- package/dist/lib/docs-metadata-sync.d.ts.map +1 -1
- package/dist/lib/docs-metadata-sync.js +28 -10
- package/dist/lib/docs-repository-view.d.ts +22 -0
- package/dist/lib/docs-repository-view.d.ts.map +1 -0
- package/dist/lib/docs-repository-view.js +185 -0
- package/dist/lib/http/client.d.ts +11 -5
- package/dist/lib/http/client.d.ts.map +1 -1
- package/dist/lib/http/client.js +22 -4
- package/dist/lib/http/index.d.ts +1 -1
- package/dist/lib/http/index.d.ts.map +1 -1
- package/dist/lib/http/index.js +1 -1
- package/dist/lib/indexer-exclusions.d.ts +27 -0
- package/dist/lib/indexer-exclusions.d.ts.map +1 -0
- package/dist/lib/indexer-exclusions.js +176 -0
- package/dist/lib/instructions/apply.d.ts +3 -1
- package/dist/lib/instructions/apply.d.ts.map +1 -1
- package/dist/lib/instructions/apply.js +74 -3
- package/dist/lib/instructions/templates.d.ts.map +1 -1
- package/dist/lib/instructions/templates.js +11 -0
- package/dist/lib/local-file-url.d.ts +9 -0
- package/dist/lib/local-file-url.d.ts.map +1 -0
- package/dist/lib/local-file-url.js +20 -0
- package/dist/lib/web-performance.d.ts +118 -0
- package/dist/lib/web-performance.d.ts.map +1 -0
- package/dist/lib/web-performance.js +192 -0
- package/package.json +40 -2
- package/schemas/config.schema.json +58 -0
- package/schemas/event-v3.schema.json +324 -112
- package/src/commander.ts +488 -95
- package/src/commands/agents.ts +617 -237
- package/src/commands/artifacts.ts +40 -2
- package/src/commands/backup.ts +18 -14
- package/src/commands/browse-session.ts +12 -0
- package/src/commands/browse.ts +21 -7
- package/src/commands/conversations.ts +279 -0
- package/src/commands/deinit.ts +6 -0
- package/src/commands/diagnostics.ts +271 -0
- package/src/commands/docs.ts +25 -6
- package/src/commands/doctor.ts +75 -9
- package/src/commands/fetch.ts +7 -6
- package/src/commands/files.ts +243 -0
- package/src/commands/governor.ts +21 -12
- package/src/commands/inbox.ts +61 -0
- package/src/commands/init.ts +78 -16
- package/src/commands/ledger-v3.ts +503 -1
- package/src/commands/logs.ts +224 -0
- package/src/commands/messages.ts +61 -0
- package/src/commands/outline.ts +6 -2
- package/src/commands/qa-run.ts +184 -0
- package/src/commands/read.ts +6 -2
- package/src/commands/resources.ts +38 -0
- package/src/commands/semantic.ts +66 -1
- package/src/commands/storage.ts +310 -0
- package/src/commands/supervisor.ts +141 -0
- package/src/commands/tunnel.ts +66 -52
- package/src/commands/web.ts +96 -7
- package/src/commands/work.ts +3 -3
- package/src/commands/workflow.ts +21 -13
- package/src/core/agents/cli.ts +265 -55
- package/src/core/agents/health.ts +142 -0
- package/src/core/agents/live-authority-v3.ts +341 -10
- package/src/core/agents/live-lifecycle-v3.ts +6 -1
- package/src/core/agents/live-observation-v3.ts +6 -1
- package/src/core/agents/mailbox.ts +373 -0
- package/src/core/agents/reconcile-coordination-v3.ts +77 -0
- package/src/core/agents/render/prompt-context.ts +66 -15
- package/src/core/agents/render/session-context.ts +37 -3
- package/src/core/agents/rules/commit-conflict.ts +58 -1
- package/src/core/agents/rules/stop-hook.ts +105 -20
- package/src/core/agents/rules/verdict.ts +1 -0
- package/src/core/agents/session-events.ts +4 -0
- package/src/core/agents/session-finalization-state-v3.ts +1 -1
- package/src/core/agents/session-finalizer-v3.ts +8 -2
- package/src/core/agents/state/activity-log.ts +7 -2
- package/src/core/agents/state/heartbeat-writer.ts +27 -0
- package/src/core/agents/state/live-coordination-view.ts +16 -105
- package/src/core/agents/state/live-coordination-writer.ts +141 -0
- package/src/core/artifacts/index.ts +260 -11
- package/src/core/config.ts +235 -5
- package/src/core/conversations/archive.ts +237 -0
- package/src/core/conversations/catalog.ts +79 -0
- package/src/core/conversations/context-pack.ts +72 -0
- package/src/core/conversations/contract.ts +178 -0
- package/src/core/conversations/evaluation.ts +30 -0
- package/src/core/conversations/index.ts +9 -0
- package/src/core/conversations/lifecycle.ts +63 -0
- package/src/core/conversations/normalize.ts +105 -0
- package/src/core/conversations/query.ts +318 -0
- package/src/core/conversations/search-index.ts +48 -0
- package/src/core/diagnostics/advice.ts +147 -0
- package/src/core/diagnostics/bundle.ts +1142 -0
- package/src/core/diagnostics/comparison.ts +565 -0
- package/src/core/diagnostics/contract.ts +311 -0
- package/src/core/diagnostics/identity.ts +11 -0
- package/src/core/diagnostics/index.ts +7 -0
- package/src/core/diagnostics/replay.ts +314 -0
- package/src/core/diagnostics/sanitize.ts +97 -0
- package/src/core/events/legacy-storage/canary.ts +177 -0
- package/src/core/events/legacy-storage/compression.ts +130 -0
- package/src/core/events/legacy-storage/fence.ts +129 -0
- package/src/core/events/legacy-storage/index.ts +6 -0
- package/src/core/events/legacy-storage/inventory.ts +51 -0
- package/src/core/events/legacy-storage/manifest.ts +136 -0
- package/src/core/events/legacy-storage/reader.ts +178 -0
- package/src/core/events/v3/archive-retention.ts +251 -0
- package/src/core/events/v3/authority-outbox.ts +22 -1
- package/src/core/events/v3/base-contract.ts +17 -7
- package/src/core/events/v3/bootstrap.ts +195 -2
- package/src/core/events/v3/capabilities.ts +5 -3
- package/src/core/events/v3/control-witness.ts +339 -0
- package/src/core/events/v3/control-writer.ts +16 -0
- package/src/core/events/v3/control.ts +54 -18
- package/src/core/events/v3/coordination-transaction-recovery.ts +477 -0
- package/src/core/events/v3/coordination-view.ts +17 -1
- package/src/core/events/v3/generated.ts +1 -1
- package/src/core/events/v3/index.ts +14 -2
- package/src/core/events/v3/live-route-observer.ts +80 -0
- package/src/core/events/v3/live-routing.ts +65 -46
- package/src/core/events/v3/producers/coordination-recorder.ts +95 -10
- package/src/core/events/v3/producers/diagnostic-summaries.ts +593 -0
- package/src/core/events/v3/producers/hook-base.ts +15 -3
- package/src/core/events/v3/producers/intake.ts +31 -2
- package/src/core/events/v3/producers/producer-state-observer.ts +52 -0
- package/src/core/events/v3/producers/recorder.ts +681 -34
- package/src/core/events/v3/reader.ts +243 -2
- package/src/core/events/v3/rotation-config.ts +98 -0
- package/src/core/events/v3/runtime-build.ts +41 -0
- package/src/core/events/v3/runtime-identity.ts +16 -0
- package/src/core/events/v3/runtime-telemetry-capabilities.ts +14 -8
- package/src/core/events/v3/support-storage/classify.ts +209 -0
- package/src/core/events/v3/support-storage/eligibility.ts +58 -0
- package/src/core/events/v3/support-storage/index.ts +9 -0
- package/src/core/events/v3/support-storage/inventory.ts +135 -0
- package/src/core/events/v3/support-storage/logical-authority.ts +117 -0
- package/src/core/events/v3/support-storage/maintenance.ts +501 -0
- package/src/core/events/v3/support-storage/pack-contract.ts +337 -0
- package/src/core/events/v3/support-storage/pack-reader.ts +346 -0
- package/src/core/events/v3/support-storage/pack-writer.ts +352 -0
- package/src/core/events/v3/support-storage/recovery.ts +43 -0
- package/src/core/events/v3/turn-telemetry.ts +58 -7
- package/src/core/events/v3/writer.ts +168 -16
- package/src/core/governor/plan-read.ts +5 -18
- package/src/core/governor/planning.ts +5 -8
- package/src/core/governor/service-read.ts +320 -2
- package/src/core/governor/service.ts +49 -22
- package/src/core/guard/evidence-v3.ts +1 -0
- package/src/core/hooks/adapter/events.ts +1 -0
- package/src/core/hooks/adapter/output.ts +23 -5
- package/src/core/hooks/adapter/runtime-telemetry.ts +408 -13
- package/src/core/hooks/cli.ts +404 -233
- package/src/core/hooks/effects/image-capture.ts +4 -1
- package/src/core/hooks/health.ts +146 -0
- package/src/core/hooks/remediation-cap.ts +12 -6
- package/src/core/hooks/resolve/coord-root.ts +91 -11
- package/src/core/hooks/resolve/owner.ts +4 -0
- package/src/core/hooks/resolve/transcript.ts +18 -0
- package/src/core/inbox/contract.ts +81 -0
- package/src/core/inbox/index.ts +4 -0
- package/src/core/inbox/lifecycle.ts +104 -0
- package/src/core/inbox/service.ts +305 -0
- package/src/core/inbox/watcher.ts +36 -0
- package/src/core/presence/codec-digest.ts +15 -9
- package/src/core/presence/relay-client.ts +55 -7
- package/src/core/resources/contract.ts +98 -0
- package/src/core/resources/index.ts +5 -0
- package/src/core/resources/sampler.ts +458 -0
- package/src/core/resources/service-status.ts +62 -0
- package/src/core/resources/service.ts +337 -0
- package/src/core/resources/storage.ts +44 -0
- package/src/core/semantic/adapters.ts +200 -41
- package/src/core/semantic/contract.ts +135 -3
- package/src/core/semantic/index.ts +76 -2
- package/src/core/semantic/once.ts +93 -7
- package/src/core/semantic/prompt.ts +13 -1
- package/src/core/semantic/review.ts +803 -0
- package/src/core/semantic/routes.ts +30 -0
- package/src/core/semantic/scheduler.ts +49 -5
- package/src/core/semantic/service-status.ts +99 -5
- package/src/core/semantic/service.ts +116 -15
- package/src/core/semantic/soak.ts +638 -0
- package/src/core/semantic/storage.ts +20 -6
- package/src/core/semantic/usage.ts +272 -0
- package/src/core/semantic/validate.ts +31 -0
- package/src/core/storage/atomic-json.ts +15 -0
- package/src/core/storage/buffer.ts +124 -0
- package/src/core/storage/builtins.ts +972 -0
- package/src/core/storage/catalog.ts +467 -0
- package/src/core/storage/config.ts +423 -0
- package/src/core/storage/contract.ts +342 -0
- package/src/core/storage/durable-history.ts +738 -0
- package/src/core/storage/health.ts +76 -0
- package/src/core/storage/index.ts +15 -0
- package/src/core/storage/inventory.ts +859 -0
- package/src/core/storage/jsonl.ts +213 -0
- package/src/core/storage/log-retention.ts +555 -0
- package/src/core/storage/logger.ts +548 -0
- package/src/core/storage/maintenance-providers.ts +200 -0
- package/src/core/storage/maintenance.ts +929 -0
- package/src/core/storage/metrics.ts +199 -0
- package/src/core/storage/policy.ts +141 -0
- package/src/core/storage/process-log.ts +203 -0
- package/src/core/storage/query.ts +418 -0
- package/src/core/storage/receipts.ts +162 -0
- package/src/core/storage/segments.ts +721 -0
- package/src/core/storage/sink-graph.ts +343 -0
- package/src/core/storage/storm-control.ts +91 -0
- package/src/core/supervisor/activity.ts +193 -0
- package/src/core/supervisor/contract.ts +312 -0
- package/src/core/supervisor/explanations.ts +104 -0
- package/src/core/supervisor/findings.ts +788 -0
- package/src/core/supervisor/history.ts +61 -0
- package/src/core/supervisor/hook-health-alerts.ts +108 -0
- package/src/core/supervisor/hook-health-storage.ts +25 -0
- package/src/core/supervisor/hook-health.ts +301 -0
- package/src/core/supervisor/hooks.ts +35 -0
- package/src/core/supervisor/index.ts +14 -0
- package/src/core/supervisor/log-feed.ts +131 -0
- package/src/core/supervisor/service.ts +511 -0
- package/src/core/supervisor/services.ts +203 -0
- package/src/core/supervisor/status.ts +59 -0
- package/src/core/supervisor/storage.ts +126 -0
- package/src/core/supervisor/timeline.ts +133 -0
- package/src/core/work/state.ts +12 -21
- package/src/core/workflow/admission.ts +215 -0
- package/src/core/workflow/engine.ts +93 -1
- package/src/core/workflow/index.ts +10 -0
- package/src/core/workflow/live-session-v3.ts +2 -4
- package/src/core/workflow/proof.ts +54 -1
- package/src/core/workflow/run-state.ts +13 -1
- package/src/core/workflow/types.ts +39 -1
- package/src/index.ts +2 -0
- package/src/lazy-commands.ts +294 -0
- package/src/lib/browser/client.ts +6 -0
- package/src/lib/browser/index.ts +29 -0
- package/src/lib/browser/qa-run-contracts.ts +380 -0
- package/src/lib/browser/qa-run.ts +784 -0
- package/src/lib/coord-root-id.ts +23 -0
- package/src/lib/docs-lint.ts +58 -77
- package/src/lib/docs-metadata-audit.ts +26 -21
- package/src/lib/docs-metadata-sync.ts +32 -9
- package/src/lib/docs-repository-view.ts +220 -0
- package/src/lib/http/client.ts +44 -8
- package/src/lib/http/index.ts +6 -1
- package/src/lib/indexer-exclusions.ts +173 -0
- package/src/lib/instructions/apply.ts +81 -2
- package/src/lib/instructions/templates.ts +11 -0
- package/src/lib/local-file-url.ts +31 -0
- package/src/lib/web-performance.ts +335 -0
|
@@ -97,6 +97,10 @@ const CLOSED_TURN_MEMORY_CAP = 16;
|
|
|
97
97
|
const SPAN_SOFT_WATERMARK = 128;
|
|
98
98
|
const PENDING_RUNTIME_CONTEXT_CAP = 4;
|
|
99
99
|
const RUNTIME_CONTEXT_RETRY_LIMIT = 2;
|
|
100
|
+
/** Active turns pay for at most one bounded adapter telemetry read per interval. */
|
|
101
|
+
const ACTIVE_RUNTIME_CONTEXT_PROBE_INTERVAL_MS = 15_000;
|
|
102
|
+
/** Codex can flush the terminal row just after Stop; keep this grace bounded and off other hooks. */
|
|
103
|
+
const STOP_RUNTIME_CONTEXT_RETRY_DELAYS_MS = [75, 175] as const;
|
|
100
104
|
/** Finalization is off the interactive hook path; briefly cover Codex's delayed transcript flush. */
|
|
101
105
|
const APPROVED_END_RUNTIME_CONTEXT_RETRY_DELAYS_MS = [0, 250, 250] as const;
|
|
102
106
|
/**
|
|
@@ -137,6 +141,14 @@ interface TurnHarnessTimingV3 {
|
|
|
137
141
|
slowest_hook_ms: number;
|
|
138
142
|
}
|
|
139
143
|
|
|
144
|
+
interface CursorResponseRitualV3 {
|
|
145
|
+
turn_id: `tid_${string}`;
|
|
146
|
+
native_turn_id?: string;
|
|
147
|
+
observed_at: string;
|
|
148
|
+
status_box_present: boolean;
|
|
149
|
+
status_box_present_strict: boolean;
|
|
150
|
+
}
|
|
151
|
+
|
|
140
152
|
interface PendingEventV3 {
|
|
141
153
|
source_id?: `hid_${string}`;
|
|
142
154
|
event: EventV3;
|
|
@@ -159,6 +171,12 @@ interface PendingRuntimeContextV3 extends TurnContextTargetV3 {
|
|
|
159
171
|
attempts: number;
|
|
160
172
|
}
|
|
161
173
|
|
|
174
|
+
interface ActiveRuntimeContextProbeV3 {
|
|
175
|
+
turn_id: `tid_${string}`;
|
|
176
|
+
attempted_at: string;
|
|
177
|
+
boundary?: "tool_completed";
|
|
178
|
+
}
|
|
179
|
+
|
|
162
180
|
interface DelegationStateV3 extends OpenSpanStateV3 {
|
|
163
181
|
source_id: `hid_${string}`;
|
|
164
182
|
delegation_id: `del_${string}`;
|
|
@@ -177,18 +195,33 @@ export interface HookProducerStateV3 {
|
|
|
177
195
|
capability_profile: `cap_${string}`;
|
|
178
196
|
cursor_mode?: CursorExecutionModeV3;
|
|
179
197
|
privacy_epoch_id: `pep_${string}`;
|
|
198
|
+
/**
|
|
199
|
+
* Genesis id of the ledger epoch this producer's boot chain lives in. The
|
|
200
|
+
* fingerprint key epoch survives ledger rotation, so this is the field that
|
|
201
|
+
* keeps a state file from being adopted across an epoch boundary (its
|
|
202
|
+
* sequences and causal links only validate inside their own epoch). A state
|
|
203
|
+
* without it predates the field and is never adopted.
|
|
204
|
+
*/
|
|
205
|
+
epoch_genesis_id?: `gex_${string}`;
|
|
180
206
|
boot_id: `boot_${string}`;
|
|
181
207
|
clock_id: `clk_${string}`;
|
|
182
208
|
next_sequence: number;
|
|
183
209
|
current_turn_id?: `tid_${string}`;
|
|
184
210
|
/** Native turn identity retained owner-only for transcript attribution. */
|
|
185
211
|
current_native_turn_id?: string;
|
|
212
|
+
/** Latest completed assistant response for Cursor's open turn. The response
|
|
213
|
+
* body is discarded by agent-hook; only these booleans survive until Stop
|
|
214
|
+
* copies them into the authoritative turn.completed ritual observation. */
|
|
215
|
+
cursor_response_ritual?: CursorResponseRitualV3;
|
|
186
216
|
tool_call_count: number;
|
|
187
217
|
tool_call_count_turn_id?: `tid_${string}`;
|
|
188
218
|
last_event_id?: `evt_${string}`;
|
|
189
219
|
last_monotonic_ns?: string;
|
|
190
220
|
last_observed_at?: string;
|
|
191
221
|
started_event_id?: `evt_${string}`;
|
|
222
|
+
/** A derived lifecycle reopen is allowed to exist before the adapter's next
|
|
223
|
+
* native prompt. Retained owner-only until that prompt starts a real turn. */
|
|
224
|
+
session_start_derivation?: "approved_lifecycle_reopen" | "validated_current_session_heal";
|
|
192
225
|
session_span: OpenSpanStateV3;
|
|
193
226
|
current_turn_span?: OpenSpanStateV3;
|
|
194
227
|
terminal: boolean;
|
|
@@ -201,6 +234,10 @@ export interface HookProducerStateV3 {
|
|
|
201
234
|
turn_ordinal: number;
|
|
202
235
|
pending?: PendingEventV3;
|
|
203
236
|
pending_runtime_contexts?: PendingRuntimeContextV3[];
|
|
237
|
+
/** Last bounded active-turn probe; owner-only and used only for cadence. */
|
|
238
|
+
active_runtime_context_probe?: ActiveRuntimeContextProbeV3;
|
|
239
|
+
/** Last emitted runtime source witness; owner-only measurement deduplication. */
|
|
240
|
+
last_context_source_witness?: string;
|
|
204
241
|
/** Verified adapter-native transcript path retained only in owner-only state. */
|
|
205
242
|
runtime_transcript_path?: string;
|
|
206
243
|
/** Tuning carried by the current attestation; {} means attested-none.
|
|
@@ -243,7 +280,7 @@ export interface RecordHookSignalV3Input {
|
|
|
243
280
|
hook_duration_ms?: number;
|
|
244
281
|
stop_remediation?: boolean;
|
|
245
282
|
turn_ritual?: TurnRitualEvidenceV3;
|
|
246
|
-
session_start_derivation?: "approved_lifecycle_reopen";
|
|
283
|
+
session_start_derivation?: "approved_lifecycle_reopen" | "validated_current_session_heal";
|
|
247
284
|
delegated_child?: {
|
|
248
285
|
generation_id: `gen_${string}`;
|
|
249
286
|
parent_generation_id: `gen_${string}`;
|
|
@@ -263,6 +300,12 @@ export type RecordHookSignalV3Result =
|
|
|
263
300
|
/** A late signal for a span already closed in memory; preserved in diagnostics, never re-opened. */
|
|
264
301
|
| { state: "suppressed"; reason: "closed_span" }
|
|
265
302
|
| { state: "ignored" }
|
|
303
|
+
| {
|
|
304
|
+
state: "observed";
|
|
305
|
+
generation_id: `gen_${string}`;
|
|
306
|
+
turn_id: `tid_${string}`;
|
|
307
|
+
observed_at: string;
|
|
308
|
+
}
|
|
266
309
|
/** Durably queued in the intake spool; a lease holder or drain hook records it. */
|
|
267
310
|
| { state: "spooled" }
|
|
268
311
|
| { state: "recorded"; event: EventV3; durability: WriteEventV3Result; recovered: boolean };
|
|
@@ -607,8 +650,23 @@ function processHookSignalLocked(
|
|
|
607
650
|
: control.activation.event.event_id;
|
|
608
651
|
const rootFingerprintContext = fingerprintContextV3(input.coordRoot, rootId, undefined, epochId);
|
|
609
652
|
const sessionId = `sid_${sessionHash.slice(4)}` as `sid_${string}`;
|
|
653
|
+
const genesisId = control.genesis.event.payload.genesis_id as `gex_${string}`;
|
|
654
|
+
// Every write below carries the epoch fence: an event produced for this
|
|
655
|
+
// epoch is refused (or quarantined from the spool) once the epoch has been
|
|
656
|
+
// replaced, instead of poisoning the successor's authority.
|
|
657
|
+
input = {
|
|
658
|
+
...input,
|
|
659
|
+
writerOptions: { ...input.writerOptions, expectedGenesisId: genesisId },
|
|
660
|
+
};
|
|
610
661
|
try {
|
|
611
662
|
let state = existsSync(path) ? readProducerState(path) : undefined;
|
|
663
|
+
if (state && state.epoch_genesis_id !== genesisId) {
|
|
664
|
+
// A producer state from a replaced epoch (or one that predates the
|
|
665
|
+
// field) is never adopted: its boot sequences and causal links only
|
|
666
|
+
// validate inside the epoch that recorded them. The session re-onboards
|
|
667
|
+
// below exactly as it does after an automatic epoch refresh.
|
|
668
|
+
state = undefined;
|
|
669
|
+
}
|
|
612
670
|
if (
|
|
613
671
|
state &&
|
|
614
672
|
(state.adapter !== input.adapter ||
|
|
@@ -634,7 +692,7 @@ function processHookSignalLocked(
|
|
|
634
692
|
const pendingSource = state.pending.source_id;
|
|
635
693
|
const incomingSource = sourceIdForSignal(input, rootFingerprintContext);
|
|
636
694
|
const pendingEvent = state.pending.event;
|
|
637
|
-
const durability = writeEventV3(input.coordRoot, pendingEvent);
|
|
695
|
+
const durability = writeEventV3(input.coordRoot, pendingEvent, input.writerOptions);
|
|
638
696
|
applyCommittedEvent(state, pendingEvent);
|
|
639
697
|
state.pending = undefined;
|
|
640
698
|
publishProducerState(path, state);
|
|
@@ -648,10 +706,19 @@ function processHookSignalLocked(
|
|
|
648
706
|
if (state && !state.terminal && state.started_event_id) {
|
|
649
707
|
return { state: "already_started", event_id: state.started_event_id };
|
|
650
708
|
}
|
|
651
|
-
if (
|
|
709
|
+
if (
|
|
710
|
+
(input.session_start_derivation === "approved_lifecycle_reopen" && !state?.terminal) ||
|
|
711
|
+
(input.session_start_derivation === "validated_current_session_heal" && state?.terminal)
|
|
712
|
+
) {
|
|
652
713
|
return { state: "missing_session_start" };
|
|
653
714
|
}
|
|
654
|
-
state = newProducerState(
|
|
715
|
+
state = newProducerState(
|
|
716
|
+
input,
|
|
717
|
+
sessionId,
|
|
718
|
+
epochId,
|
|
719
|
+
boundaryEventId as `evt_${string}`,
|
|
720
|
+
genesisId,
|
|
721
|
+
);
|
|
655
722
|
} else if (!state || state.terminal) {
|
|
656
723
|
// Mid-flight onboarding (ADR 0078): a live session with no producer
|
|
657
724
|
// state in this epoch (fresh epoch, lost session-start hook) opens a
|
|
@@ -678,7 +745,13 @@ function processHookSignalLocked(
|
|
|
678
745
|
});
|
|
679
746
|
return { state: "missing_session_start" };
|
|
680
747
|
}
|
|
681
|
-
state = newProducerState(
|
|
748
|
+
state = newProducerState(
|
|
749
|
+
input,
|
|
750
|
+
sessionId,
|
|
751
|
+
epochId,
|
|
752
|
+
boundaryEventId as `evt_${string}`,
|
|
753
|
+
genesisId,
|
|
754
|
+
);
|
|
682
755
|
const cursorPromptBootstrap = isCursorPromptBootstrap(input);
|
|
683
756
|
const onboarding = buildMidFlightSessionStart(input, state, rootId, cursorPromptBootstrap);
|
|
684
757
|
commitEventLocked(input, state, path, onboarding);
|
|
@@ -688,6 +761,7 @@ function processHookSignalLocked(
|
|
|
688
761
|
instance_id: input.instance_id,
|
|
689
762
|
signal: input.signal,
|
|
690
763
|
session_hash: sessionHash,
|
|
764
|
+
...(input.adapter === "codex" ? codexMidFlightDiagnosticContext(input.payload) : {}),
|
|
691
765
|
});
|
|
692
766
|
}
|
|
693
767
|
}
|
|
@@ -815,6 +889,51 @@ function processHookSignalLocked(
|
|
|
815
889
|
// Sample once for the native event and every span it opens or closes so
|
|
816
890
|
// their self-contained timing cannot drift by a millisecond.
|
|
817
891
|
const eventClock = signalClock(input);
|
|
892
|
+
if (input.signal === "after-agent-response") {
|
|
893
|
+
if (
|
|
894
|
+
input.adapter !== "cursor" ||
|
|
895
|
+
!state.current_turn_id ||
|
|
896
|
+
!state.current_turn_span ||
|
|
897
|
+
!input.turn_ritual
|
|
898
|
+
) {
|
|
899
|
+
writeProducerDiagnosticV3(input.coordRoot, "cursor_response_ritual_unbound", {
|
|
900
|
+
adapter: input.adapter,
|
|
901
|
+
instance_id: input.instance_id,
|
|
902
|
+
generation_id: state.generation_id,
|
|
903
|
+
signal: input.signal,
|
|
904
|
+
reason: !state.current_turn_id
|
|
905
|
+
? "no_open_turn"
|
|
906
|
+
: !state.current_turn_span
|
|
907
|
+
? "no_open_turn_span"
|
|
908
|
+
: "ritual_observation_missing",
|
|
909
|
+
});
|
|
910
|
+
publishProducerState(path, state);
|
|
911
|
+
return { state: "ignored" };
|
|
912
|
+
}
|
|
913
|
+
const observation: CursorResponseRitualV3 = {
|
|
914
|
+
turn_id: state.current_turn_id,
|
|
915
|
+
...(input.payload.turn_id ? { native_turn_id: input.payload.turn_id } : {}),
|
|
916
|
+
observed_at: eventClock.observed_at,
|
|
917
|
+
status_box_present: input.turn_ritual.status_box_present,
|
|
918
|
+
status_box_present_strict: input.turn_ritual.status_box_present_strict,
|
|
919
|
+
};
|
|
920
|
+
state.cursor_response_ritual = observation;
|
|
921
|
+
publishProducerState(path, state);
|
|
922
|
+
writeProducerDiagnosticV3(input.coordRoot, "cursor_response_ritual_observed", {
|
|
923
|
+
instance_id: state.instance_id,
|
|
924
|
+
generation_id: state.generation_id,
|
|
925
|
+
turn_id: observation.turn_id,
|
|
926
|
+
...(observation.native_turn_id ? { native_turn_id: observation.native_turn_id } : {}),
|
|
927
|
+
response_observed_at: observation.observed_at,
|
|
928
|
+
status_box_present_strict: observation.status_box_present_strict,
|
|
929
|
+
});
|
|
930
|
+
return {
|
|
931
|
+
state: "observed",
|
|
932
|
+
generation_id: state.generation_id,
|
|
933
|
+
turn_id: observation.turn_id,
|
|
934
|
+
observed_at: observation.observed_at,
|
|
935
|
+
};
|
|
936
|
+
}
|
|
818
937
|
if (input.signal === "user-prompt-submit" && !state.current_turn_span) {
|
|
819
938
|
state.current_turn_span = openSpanStateV3({
|
|
820
939
|
span_id: spanIdV3(),
|
|
@@ -1040,6 +1159,38 @@ function processHookSignalLocked(
|
|
|
1040
1159
|
// Before the signal's own event: the tool call or turn that carries the
|
|
1041
1160
|
// new effort already ran under it, so it must ride the new attestation.
|
|
1042
1161
|
maybeAttestTuningChange(input, state, path, rootId);
|
|
1162
|
+
const cursorResponseRitual =
|
|
1163
|
+
input.adapter === "cursor" &&
|
|
1164
|
+
(input.signal === "stop" || input.signal === "stop-failure") &&
|
|
1165
|
+
state.current_turn_id &&
|
|
1166
|
+
state.cursor_response_ritual?.turn_id === state.current_turn_id
|
|
1167
|
+
? state.cursor_response_ritual
|
|
1168
|
+
: undefined;
|
|
1169
|
+
const terminalTurnRitual =
|
|
1170
|
+
input.adapter === "cursor" && (input.signal === "stop" || input.signal === "stop-failure")
|
|
1171
|
+
? cursorResponseRitual
|
|
1172
|
+
? {
|
|
1173
|
+
status_box_present: cursorResponseRitual.status_box_present,
|
|
1174
|
+
status_box_present_strict: cursorResponseRitual.status_box_present_strict,
|
|
1175
|
+
session_name_required: false,
|
|
1176
|
+
session_name_present: false,
|
|
1177
|
+
}
|
|
1178
|
+
: undefined
|
|
1179
|
+
: input.turn_ritual;
|
|
1180
|
+
if (cursorResponseRitual) {
|
|
1181
|
+
writeProducerDiagnosticV3(input.coordRoot, "cursor_response_ritual_consumed", {
|
|
1182
|
+
instance_id: state.instance_id,
|
|
1183
|
+
generation_id: state.generation_id,
|
|
1184
|
+
turn_id: cursorResponseRitual.turn_id,
|
|
1185
|
+
...(cursorResponseRitual.native_turn_id
|
|
1186
|
+
? { response_native_turn_id: cursorResponseRitual.native_turn_id }
|
|
1187
|
+
: {}),
|
|
1188
|
+
...(input.payload.turn_id ? { stop_native_turn_id: input.payload.turn_id } : {}),
|
|
1189
|
+
response_observed_at: cursorResponseRitual.observed_at,
|
|
1190
|
+
stop_observed_at: eventClock.observed_at,
|
|
1191
|
+
status_box_present_strict: cursorResponseRitual.status_box_present_strict,
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1043
1194
|
const event = normalizeHookEventV3(input.signal, eventInput.payload, {
|
|
1044
1195
|
coordRoot: input.coordRoot,
|
|
1045
1196
|
adapter: input.adapter,
|
|
@@ -1098,7 +1249,7 @@ function processHookSignalLocked(
|
|
|
1098
1249
|
child_generation_id: delegation?.child_generation_id,
|
|
1099
1250
|
agent_role: delegation?.role,
|
|
1100
1251
|
stop_remediation: input.stop_remediation,
|
|
1101
|
-
turn_ritual:
|
|
1252
|
+
turn_ritual: terminalTurnRitual,
|
|
1102
1253
|
});
|
|
1103
1254
|
if (!event) return { state: "ignored" };
|
|
1104
1255
|
if (
|
|
@@ -1145,12 +1296,16 @@ function processHookSignalLocked(
|
|
|
1145
1296
|
}
|
|
1146
1297
|
if (
|
|
1147
1298
|
input.signal === "session-start" &&
|
|
1148
|
-
input.session_start_derivation
|
|
1299
|
+
input.session_start_derivation &&
|
|
1149
1300
|
event.event_type === "session.started"
|
|
1150
1301
|
) {
|
|
1302
|
+
const lifecycleReopen = input.session_start_derivation === "approved_lifecycle_reopen";
|
|
1303
|
+
const reason = lifecycleReopen
|
|
1304
|
+
? "approved_lifecycle_reopen"
|
|
1305
|
+
: "validated_current_session_heal";
|
|
1151
1306
|
event.provenance = {
|
|
1152
1307
|
...event.provenance,
|
|
1153
|
-
source_event: `${input.adapter}.
|
|
1308
|
+
source_event: `${input.adapter}.${reason.replaceAll("_", "-")}`,
|
|
1154
1309
|
attestation: "derived",
|
|
1155
1310
|
confidence: "high",
|
|
1156
1311
|
attribution: {
|
|
@@ -1161,7 +1316,7 @@ function processHookSignalLocked(
|
|
|
1161
1316
|
};
|
|
1162
1317
|
event.payload.resume = {
|
|
1163
1318
|
state: "unknown",
|
|
1164
|
-
reason
|
|
1319
|
+
reason,
|
|
1165
1320
|
};
|
|
1166
1321
|
assertEventV3(event);
|
|
1167
1322
|
}
|
|
@@ -1170,7 +1325,20 @@ function processHookSignalLocked(
|
|
|
1170
1325
|
span.open_event_id = event.event_id as `evt_${string}`;
|
|
1171
1326
|
stampSpanTurn(span, event, eventInput, state);
|
|
1172
1327
|
}
|
|
1328
|
+
// A turn terminal clears current_native_turn_id when it commits. Retain the
|
|
1329
|
+
// native identity long enough to seed a delayed context retry afterward.
|
|
1330
|
+
const nativeTurnIdForContext = input.payload.turn_id ?? state.current_native_turn_id;
|
|
1173
1331
|
const durability = commitEventLocked(input, state, path, event, sourceId);
|
|
1332
|
+
if (event.event_type === "context.compaction_started" && input.signal === "pre-compact") {
|
|
1333
|
+
maybeCommitNativeHookContextObservation(
|
|
1334
|
+
input,
|
|
1335
|
+
state,
|
|
1336
|
+
path,
|
|
1337
|
+
rootId,
|
|
1338
|
+
fingerprintContext,
|
|
1339
|
+
event,
|
|
1340
|
+
);
|
|
1341
|
+
}
|
|
1174
1342
|
if (event.event_type === "tool.requested" && sourceId) {
|
|
1175
1343
|
const explicitWait = explicitNativeWait(input);
|
|
1176
1344
|
if (explicitWait) {
|
|
@@ -1183,9 +1351,25 @@ function processHookSignalLocked(
|
|
|
1183
1351
|
if (progressKind) {
|
|
1184
1352
|
commitProgressObservation(input, state, path, rootId, event, progressKind);
|
|
1185
1353
|
}
|
|
1354
|
+
if (event.event_type === "tool.completed" && input.signal === "post-tool-use") {
|
|
1355
|
+
maybeCommitActiveRuntimeContextObservation(
|
|
1356
|
+
input,
|
|
1357
|
+
state,
|
|
1358
|
+
path,
|
|
1359
|
+
rootId,
|
|
1360
|
+
fingerprintContext,
|
|
1361
|
+
event,
|
|
1362
|
+
);
|
|
1363
|
+
}
|
|
1186
1364
|
if (turnTelemetry) {
|
|
1187
1365
|
const contextTarget = turnContextTarget(event);
|
|
1188
|
-
queuePendingRuntimeContext(
|
|
1366
|
+
queuePendingRuntimeContext(
|
|
1367
|
+
input,
|
|
1368
|
+
state,
|
|
1369
|
+
contextTarget,
|
|
1370
|
+
turnTelemetry.context,
|
|
1371
|
+
nativeTurnIdForContext,
|
|
1372
|
+
);
|
|
1189
1373
|
commitTurnContextObservation(
|
|
1190
1374
|
input,
|
|
1191
1375
|
state,
|
|
@@ -1652,6 +1836,53 @@ function commitTurnContextObservation(
|
|
|
1652
1836
|
observedAt?: string,
|
|
1653
1837
|
): void {
|
|
1654
1838
|
if (!target) return;
|
|
1839
|
+
commitContextObservation(
|
|
1840
|
+
input,
|
|
1841
|
+
state,
|
|
1842
|
+
path,
|
|
1843
|
+
rootId,
|
|
1844
|
+
fingerprintContext,
|
|
1845
|
+
{
|
|
1846
|
+
caused_by_event_id: target.terminal_event_id,
|
|
1847
|
+
observed_at: observedAt ?? target.terminal_observed_at,
|
|
1848
|
+
turn_id: target.turn_id,
|
|
1849
|
+
...(target.run_id ? { run_id: target.run_id } : {}),
|
|
1850
|
+
...(target.workflow_id ? { workflow_id: target.workflow_id } : {}),
|
|
1851
|
+
...(target.workflow_agent_id ? { workflow_agent_id: target.workflow_agent_id } : {}),
|
|
1852
|
+
},
|
|
1853
|
+
measurement,
|
|
1854
|
+
contextProvenance,
|
|
1855
|
+
);
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1858
|
+
function commitContextObservation(
|
|
1859
|
+
input: RecordHookSignalV3Input,
|
|
1860
|
+
state: HookProducerStateV3,
|
|
1861
|
+
path: string,
|
|
1862
|
+
rootId: `root_${string}`,
|
|
1863
|
+
fingerprintContext: ReturnType<typeof fingerprintContextV3>,
|
|
1864
|
+
target: {
|
|
1865
|
+
caused_by_event_id: `evt_${string}`;
|
|
1866
|
+
observed_at: string;
|
|
1867
|
+
turn_id: `tid_${string}`;
|
|
1868
|
+
run_id?: `run_${string}`;
|
|
1869
|
+
workflow_id?: `wf_${string}`;
|
|
1870
|
+
workflow_agent_id?: string;
|
|
1871
|
+
},
|
|
1872
|
+
measurement: TelemetryObservationV3<ContextMeasurementV3>,
|
|
1873
|
+
contextProvenance?: ContextTelemetryProvenanceV3,
|
|
1874
|
+
): void {
|
|
1875
|
+
if (
|
|
1876
|
+
measurement.state === "observed" &&
|
|
1877
|
+
contextProvenance?.source_witness &&
|
|
1878
|
+
state.last_context_source_witness === contextProvenance.source_witness
|
|
1879
|
+
) {
|
|
1880
|
+
publishProducerState(path, state);
|
|
1881
|
+
return;
|
|
1882
|
+
}
|
|
1883
|
+
if (measurement.state === "observed" && contextProvenance?.source_witness) {
|
|
1884
|
+
state.last_context_source_witness = contextProvenance.source_witness;
|
|
1885
|
+
}
|
|
1655
1886
|
const event = buildEventV3("context.observed", {
|
|
1656
1887
|
producer: {
|
|
1657
1888
|
producer_id: input.producer_id,
|
|
@@ -1673,7 +1904,7 @@ function commitTurnContextObservation(
|
|
|
1673
1904
|
...(target.workflow_agent_id ? { workflow_agent_id: target.workflow_agent_id } : {}),
|
|
1674
1905
|
},
|
|
1675
1906
|
attestation_id: state.attestation_id,
|
|
1676
|
-
links: { caused_by: [target.
|
|
1907
|
+
links: { caused_by: [target.caused_by_event_id] },
|
|
1677
1908
|
provenance: {
|
|
1678
1909
|
source_event: safeRole(
|
|
1679
1910
|
[
|
|
@@ -1700,10 +1931,10 @@ function commitTurnContextObservation(
|
|
|
1700
1931
|
subject_instance_id: state.instance_id,
|
|
1701
1932
|
},
|
|
1702
1933
|
},
|
|
1703
|
-
// The source sample may precede
|
|
1704
|
-
//
|
|
1705
|
-
//
|
|
1706
|
-
observed_at:
|
|
1934
|
+
// The source sample may precede the hook boundary that admits it.
|
|
1935
|
+
// measurement.measured_at preserves the sample clock without creating a
|
|
1936
|
+
// causal wall-clock regression in the producer event chain.
|
|
1937
|
+
observed_at: target.observed_at,
|
|
1707
1938
|
monotonic_ns: orderedEventMonotonic(state, input.monotonic_ns),
|
|
1708
1939
|
clock_id: state.clock_id,
|
|
1709
1940
|
payload: {
|
|
@@ -1714,6 +1945,198 @@ function commitTurnContextObservation(
|
|
|
1714
1945
|
maybeAttestContextCapabilityChange(input, state, path, rootId, measurement, contextProvenance);
|
|
1715
1946
|
}
|
|
1716
1947
|
|
|
1948
|
+
/**
|
|
1949
|
+
* Admit fresh adapter-native or bounded runtime context while a turn is open.
|
|
1950
|
+
* Tool completions are safe sampling boundaries. Persistent owner-only cadence
|
|
1951
|
+
* state prevents short-lived hook processes from reading on every request,
|
|
1952
|
+
* and the source witness prevents duplicate public events.
|
|
1953
|
+
*/
|
|
1954
|
+
function maybeCommitActiveRuntimeContextObservation(
|
|
1955
|
+
input: RecordHookSignalV3Input,
|
|
1956
|
+
state: HookProducerStateV3,
|
|
1957
|
+
path: string,
|
|
1958
|
+
rootId: `root_${string}`,
|
|
1959
|
+
fingerprintContext: ReturnType<typeof fingerprintContextV3>,
|
|
1960
|
+
sourceEvent: EventV3,
|
|
1961
|
+
): void {
|
|
1962
|
+
if (input.signal !== "post-tool-use" || state.terminal || !state.current_turn_id) {
|
|
1963
|
+
return;
|
|
1964
|
+
}
|
|
1965
|
+
const nativeSessionId = input.payload.session_id ?? input.payload.conversation_id;
|
|
1966
|
+
const nativeTurnId = input.payload.turn_id ?? state.current_native_turn_id;
|
|
1967
|
+
if (!nativeSessionId || (!nativeTurnId && input.adapter !== "cursor")) return;
|
|
1968
|
+
|
|
1969
|
+
const now = Date.now();
|
|
1970
|
+
const configuredInterval = input.runtimeTelemetryOptions?.activeContextProbeIntervalMs;
|
|
1971
|
+
const intervalMs =
|
|
1972
|
+
configuredInterval !== undefined && Number.isFinite(configuredInterval)
|
|
1973
|
+
? Math.max(0, Math.floor(configuredInterval))
|
|
1974
|
+
: ACTIVE_RUNTIME_CONTEXT_PROBE_INTERVAL_MS;
|
|
1975
|
+
const prior = state.active_runtime_context_probe;
|
|
1976
|
+
const priorAttempt = prior ? Date.parse(prior.attempted_at) : Number.NaN;
|
|
1977
|
+
if (
|
|
1978
|
+
prior?.turn_id === state.current_turn_id &&
|
|
1979
|
+
prior.boundary === "tool_completed" &&
|
|
1980
|
+
Number.isFinite(priorAttempt) &&
|
|
1981
|
+
now - priorAttempt >= 0 &&
|
|
1982
|
+
now - priorAttempt < intervalMs
|
|
1983
|
+
) {
|
|
1984
|
+
return;
|
|
1985
|
+
}
|
|
1986
|
+
state.active_runtime_context_probe = {
|
|
1987
|
+
turn_id: state.current_turn_id,
|
|
1988
|
+
attempted_at: new Date(now).toISOString(),
|
|
1989
|
+
boundary: "tool_completed",
|
|
1990
|
+
};
|
|
1991
|
+
|
|
1992
|
+
const native = extractTurnTelemetryV3(
|
|
1993
|
+
input.adapter,
|
|
1994
|
+
input.payload.raw,
|
|
1995
|
+
sourceEvent.time.observed_at,
|
|
1996
|
+
).context;
|
|
1997
|
+
if (native.state === "observed") {
|
|
1998
|
+
commitActiveContextObservation(
|
|
1999
|
+
input,
|
|
2000
|
+
state,
|
|
2001
|
+
path,
|
|
2002
|
+
rootId,
|
|
2003
|
+
fingerprintContext,
|
|
2004
|
+
sourceEvent,
|
|
2005
|
+
native,
|
|
2006
|
+
nativeContextProvenance(input, state, native),
|
|
2007
|
+
);
|
|
2008
|
+
return;
|
|
2009
|
+
}
|
|
2010
|
+
if (input.adapter === "cursor" && state.cursor_mode === "cloud") {
|
|
2011
|
+
publishProducerState(path, state);
|
|
2012
|
+
return;
|
|
2013
|
+
}
|
|
2014
|
+
|
|
2015
|
+
const transcriptPath = runtimeTranscriptPath(input, state);
|
|
2016
|
+
if (!transcriptPath && input.adapter !== "cursor") {
|
|
2017
|
+
publishProducerState(path, state);
|
|
2018
|
+
return;
|
|
2019
|
+
}
|
|
2020
|
+
const runtime = readRuntimeContextTelemetry(
|
|
2021
|
+
{
|
|
2022
|
+
adapter: input.adapter,
|
|
2023
|
+
session_id: nativeSessionId,
|
|
2024
|
+
...(nativeTurnId ? { turn_id: nativeTurnId } : {}),
|
|
2025
|
+
...(state.current_turn_span?.opened_at
|
|
2026
|
+
? { turn_started_at: state.current_turn_span.opened_at }
|
|
2027
|
+
: {}),
|
|
2028
|
+
transcript_path: transcriptPath,
|
|
2029
|
+
observed_at: sourceEvent.time.observed_at,
|
|
2030
|
+
mode: "active_turn",
|
|
2031
|
+
},
|
|
2032
|
+
input.runtimeTelemetryOptions,
|
|
2033
|
+
);
|
|
2034
|
+
if (runtime.bytes_read > 0) recordRuntimeTelemetryTiming(state, runtime.io_duration_ms);
|
|
2035
|
+
if (runtime.state !== "observed") {
|
|
2036
|
+
publishProducerState(path, state);
|
|
2037
|
+
return;
|
|
2038
|
+
}
|
|
2039
|
+
|
|
2040
|
+
commitActiveContextObservation(
|
|
2041
|
+
input,
|
|
2042
|
+
state,
|
|
2043
|
+
path,
|
|
2044
|
+
rootId,
|
|
2045
|
+
fingerprintContext,
|
|
2046
|
+
sourceEvent,
|
|
2047
|
+
runtimeContextObservation(runtime),
|
|
2048
|
+
{
|
|
2049
|
+
source_event: runtime.source_event,
|
|
2050
|
+
source_witness: runtime.source_witness,
|
|
2051
|
+
...(input.adapterVersion ? { runtime_version: input.adapterVersion } : {}),
|
|
2052
|
+
attestation: runtime.attestation,
|
|
2053
|
+
confidence: runtime.confidence,
|
|
2054
|
+
},
|
|
2055
|
+
);
|
|
2056
|
+
}
|
|
2057
|
+
|
|
2058
|
+
function commitActiveContextObservation(
|
|
2059
|
+
input: RecordHookSignalV3Input,
|
|
2060
|
+
state: HookProducerStateV3,
|
|
2061
|
+
path: string,
|
|
2062
|
+
rootId: `root_${string}`,
|
|
2063
|
+
fingerprintContext: ReturnType<typeof fingerprintContextV3>,
|
|
2064
|
+
sourceEvent: EventV3,
|
|
2065
|
+
measurement: TelemetryObservationV3<ContextMeasurementV3>,
|
|
2066
|
+
provenance: ContextTelemetryProvenanceV3,
|
|
2067
|
+
): void {
|
|
2068
|
+
if (!state.current_turn_id) return;
|
|
2069
|
+
const scope = sourceEvent.scope as {
|
|
2070
|
+
run_id?: `run_${string}`;
|
|
2071
|
+
workflow_id?: `wf_${string}`;
|
|
2072
|
+
workflow_agent_id?: string;
|
|
2073
|
+
};
|
|
2074
|
+
commitContextObservation(
|
|
2075
|
+
input,
|
|
2076
|
+
state,
|
|
2077
|
+
path,
|
|
2078
|
+
rootId,
|
|
2079
|
+
fingerprintContext,
|
|
2080
|
+
{
|
|
2081
|
+
caused_by_event_id: sourceEvent.event_id as `evt_${string}`,
|
|
2082
|
+
observed_at: sourceEvent.time.observed_at,
|
|
2083
|
+
turn_id: state.current_turn_id,
|
|
2084
|
+
...(scope.run_id ? { run_id: scope.run_id } : {}),
|
|
2085
|
+
...(scope.workflow_id ? { workflow_id: scope.workflow_id } : {}),
|
|
2086
|
+
...(scope.workflow_agent_id ? { workflow_agent_id: scope.workflow_agent_id } : {}),
|
|
2087
|
+
},
|
|
2088
|
+
measurement,
|
|
2089
|
+
provenance,
|
|
2090
|
+
);
|
|
2091
|
+
}
|
|
2092
|
+
|
|
2093
|
+
function nativeContextProvenance(
|
|
2094
|
+
input: RecordHookSignalV3Input,
|
|
2095
|
+
state: HookProducerStateV3,
|
|
2096
|
+
measurement: Extract<TelemetryObservationV3<ContextMeasurementV3>, { state: "observed" }>,
|
|
2097
|
+
): ContextTelemetryProvenanceV3 {
|
|
2098
|
+
const { measured_at: _measuredAt, ...stableValue } = measurement.value;
|
|
2099
|
+
const witness = canonicalJsonV3({
|
|
2100
|
+
adapter: input.adapter,
|
|
2101
|
+
session_id: state.session_id,
|
|
2102
|
+
turn_id: state.current_turn_id,
|
|
2103
|
+
value: stableValue,
|
|
2104
|
+
});
|
|
2105
|
+
return {
|
|
2106
|
+
source_event: `${input.adapter}.native_context`,
|
|
2107
|
+
source_witness: createHash("sha256").update(witness).digest("hex"),
|
|
2108
|
+
...(input.adapterVersion ? { runtime_version: input.adapterVersion } : {}),
|
|
2109
|
+
attestation: measurement.attestation,
|
|
2110
|
+
confidence: measurement.confidence,
|
|
2111
|
+
};
|
|
2112
|
+
}
|
|
2113
|
+
|
|
2114
|
+
function maybeCommitNativeHookContextObservation(
|
|
2115
|
+
input: RecordHookSignalV3Input,
|
|
2116
|
+
state: HookProducerStateV3,
|
|
2117
|
+
path: string,
|
|
2118
|
+
rootId: `root_${string}`,
|
|
2119
|
+
fingerprintContext: ReturnType<typeof fingerprintContextV3>,
|
|
2120
|
+
sourceEvent: EventV3,
|
|
2121
|
+
): void {
|
|
2122
|
+
const measurement = extractTurnTelemetryV3(
|
|
2123
|
+
input.adapter,
|
|
2124
|
+
input.payload.raw,
|
|
2125
|
+
sourceEvent.time.observed_at,
|
|
2126
|
+
).context;
|
|
2127
|
+
if (measurement.state !== "observed") return;
|
|
2128
|
+
commitActiveContextObservation(
|
|
2129
|
+
input,
|
|
2130
|
+
state,
|
|
2131
|
+
path,
|
|
2132
|
+
rootId,
|
|
2133
|
+
fingerprintContext,
|
|
2134
|
+
sourceEvent,
|
|
2135
|
+
measurement,
|
|
2136
|
+
nativeContextProvenance(input, state, measurement),
|
|
2137
|
+
);
|
|
2138
|
+
}
|
|
2139
|
+
|
|
1717
2140
|
function maybeAttestContextCapabilityChange(
|
|
1718
2141
|
input: RecordHookSignalV3Input,
|
|
1719
2142
|
state: HookProducerStateV3,
|
|
@@ -1729,6 +2152,12 @@ function maybeAttestContextCapabilityChange(
|
|
|
1729
2152
|
source: provenance?.source_event ?? `${input.adapter}.turn_context`,
|
|
1730
2153
|
attestation: provenance?.attestation ?? measurement.attestation,
|
|
1731
2154
|
confidence: provenance?.confidence ?? measurement.confidence,
|
|
2155
|
+
completeness:
|
|
2156
|
+
"used_percent" in measurement.value
|
|
2157
|
+
? ("percentage_only" as const)
|
|
2158
|
+
: (provenance?.attestation ?? measurement.attestation) === "inferred"
|
|
2159
|
+
? ("inferred" as const)
|
|
2160
|
+
: ("exact" as const),
|
|
1732
2161
|
}
|
|
1733
2162
|
: measurement.state === "expected_but_missing"
|
|
1734
2163
|
? { state: "partial" as const, reason: measurement.reason }
|
|
@@ -1777,6 +2206,7 @@ function queuePendingRuntimeContext(
|
|
|
1777
2206
|
state: HookProducerStateV3,
|
|
1778
2207
|
target: TurnContextTargetV3 | undefined,
|
|
1779
2208
|
measurement: TelemetryObservationV3<ContextMeasurementV3>,
|
|
2209
|
+
nativeTurnId: string | undefined,
|
|
1780
2210
|
): void {
|
|
1781
2211
|
if (
|
|
1782
2212
|
input.adapter !== "codex" ||
|
|
@@ -1787,7 +2217,6 @@ function queuePendingRuntimeContext(
|
|
|
1787
2217
|
return;
|
|
1788
2218
|
}
|
|
1789
2219
|
const nativeSessionId = input.payload.session_id ?? input.payload.conversation_id;
|
|
1790
|
-
const nativeTurnId = input.payload.turn_id;
|
|
1791
2220
|
if (!nativeSessionId || !nativeTurnId) return;
|
|
1792
2221
|
const pending: PendingRuntimeContextV3 = {
|
|
1793
2222
|
...target,
|
|
@@ -1925,19 +2354,36 @@ function turnTelemetryForTerminal(
|
|
|
1925
2354
|
observedAt: string,
|
|
1926
2355
|
): TurnTelemetryV3 {
|
|
1927
2356
|
const native = extractTurnTelemetryV3(input.adapter, input.payload.raw, observedAt);
|
|
1928
|
-
if (native.context.state === "observed"
|
|
2357
|
+
if (native.context.state === "observed") return native;
|
|
2358
|
+
if (input.adapter === "cursor" && state.cursor_mode === "cloud") {
|
|
2359
|
+
return {
|
|
2360
|
+
...native,
|
|
2361
|
+
context: { state: "unsupported", capability: "context_usage" },
|
|
2362
|
+
};
|
|
2363
|
+
}
|
|
1929
2364
|
|
|
1930
|
-
const
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
);
|
|
2365
|
+
const request = {
|
|
2366
|
+
adapter: input.adapter,
|
|
2367
|
+
session_id: input.payload.session_id ?? input.payload.conversation_id,
|
|
2368
|
+
turn_id: input.payload.turn_id ?? state.current_native_turn_id,
|
|
2369
|
+
transcript_path: runtimeTranscriptPath(input, state),
|
|
2370
|
+
observed_at: observedAt,
|
|
2371
|
+
mode: "turn" as const,
|
|
2372
|
+
};
|
|
2373
|
+
let runtime = readRuntimeContextTelemetry(request, input.runtimeTelemetryOptions);
|
|
1940
2374
|
if (runtime.bytes_read > 0) recordRuntimeTelemetryTiming(state, runtime.io_duration_ms);
|
|
2375
|
+
if (
|
|
2376
|
+
input.adapter === "codex" &&
|
|
2377
|
+
runtime.state === "partial" &&
|
|
2378
|
+
retryableRuntimeContextReason(runtime.reason)
|
|
2379
|
+
) {
|
|
2380
|
+
for (const delayMs of STOP_RUNTIME_CONTEXT_RETRY_DELAYS_MS) {
|
|
2381
|
+
sleepSync(delayMs);
|
|
2382
|
+
runtime = readRuntimeContextTelemetry(request, input.runtimeTelemetryOptions);
|
|
2383
|
+
if (runtime.bytes_read > 0) recordRuntimeTelemetryTiming(state, runtime.io_duration_ms);
|
|
2384
|
+
if (runtime.state !== "partial" || !retryableRuntimeContextReason(runtime.reason)) break;
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
1941
2387
|
if (runtime.state === "unsupported") return native;
|
|
1942
2388
|
return {
|
|
1943
2389
|
...native,
|
|
@@ -1947,8 +2393,8 @@ function turnTelemetryForTerminal(
|
|
|
1947
2393
|
runtime.state === "observed" ? runtime.source_event : `${input.adapter}.runtime_context`,
|
|
1948
2394
|
...(runtime.state === "observed" ? { source_witness: runtime.source_witness } : {}),
|
|
1949
2395
|
...(input.adapterVersion ? { runtime_version: input.adapterVersion } : {}),
|
|
1950
|
-
attestation: "derived",
|
|
1951
|
-
confidence: runtime.state === "observed" ?
|
|
2396
|
+
attestation: runtime.state === "observed" ? runtime.attestation : "derived",
|
|
2397
|
+
confidence: runtime.state === "observed" ? runtime.confidence : "high",
|
|
1952
2398
|
},
|
|
1953
2399
|
};
|
|
1954
2400
|
}
|
|
@@ -2001,6 +2447,19 @@ function runtimeContextObservation(
|
|
|
2001
2447
|
runtime: RuntimeContextTelemetry,
|
|
2002
2448
|
): TelemetryObservationV3<ContextMeasurementV3> {
|
|
2003
2449
|
if (runtime.state === "observed") {
|
|
2450
|
+
if ("used_percent" in runtime) {
|
|
2451
|
+
return {
|
|
2452
|
+
state: "observed",
|
|
2453
|
+
value: {
|
|
2454
|
+
used_percent: runtime.used_percent,
|
|
2455
|
+
remaining_percent: Math.max(0, 100 - runtime.used_percent),
|
|
2456
|
+
measured_at: runtime.measured_at,
|
|
2457
|
+
method: runtime.method,
|
|
2458
|
+
},
|
|
2459
|
+
attestation: runtime.attestation,
|
|
2460
|
+
confidence: runtime.confidence,
|
|
2461
|
+
};
|
|
2462
|
+
}
|
|
2004
2463
|
return {
|
|
2005
2464
|
state: "observed",
|
|
2006
2465
|
value: {
|
|
@@ -2010,8 +2469,8 @@ function runtimeContextObservation(
|
|
|
2010
2469
|
measured_at: runtime.measured_at,
|
|
2011
2470
|
method: runtime.method,
|
|
2012
2471
|
},
|
|
2013
|
-
attestation:
|
|
2014
|
-
confidence:
|
|
2472
|
+
attestation: runtime.attestation,
|
|
2473
|
+
confidence: runtime.confidence,
|
|
2015
2474
|
};
|
|
2016
2475
|
}
|
|
2017
2476
|
return {
|
|
@@ -2176,8 +2635,8 @@ interface RuntimeAttestationChangeV3 {
|
|
|
2176
2635
|
telemetry: RuntimeTelemetryCapabilitiesV3;
|
|
2177
2636
|
reason: string;
|
|
2178
2637
|
source_event: string;
|
|
2179
|
-
attestation: "native" | "derived";
|
|
2180
|
-
confidence: "exact" | "high";
|
|
2638
|
+
attestation: "native" | "derived" | "inferred";
|
|
2639
|
+
confidence: "exact" | "high" | "medium" | "low";
|
|
2181
2640
|
}
|
|
2182
2641
|
|
|
2183
2642
|
function commitRuntimeAttestationChange(
|
|
@@ -2527,6 +2986,40 @@ function isCursorPromptBootstrap(input: RecordHookSignalV3Input): boolean {
|
|
|
2527
2986
|
);
|
|
2528
2987
|
}
|
|
2529
2988
|
|
|
2989
|
+
/** Privacy-safe environment and recovery provenance for Codex mid-flight
|
|
2990
|
+
* onboarding. WSLENV values are never recorded, only normalized variable
|
|
2991
|
+
* names, and the native session identifier itself remains fingerprinted. */
|
|
2992
|
+
export function codexMidFlightDiagnosticContext(
|
|
2993
|
+
payload: ParsedPayload,
|
|
2994
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
2995
|
+
): Record<string, string | boolean> {
|
|
2996
|
+
const wslenv = env.WSLENV?.trim() ?? "";
|
|
2997
|
+
const wslenvNames = [
|
|
2998
|
+
...new Set(
|
|
2999
|
+
wslenv
|
|
3000
|
+
.split(":")
|
|
3001
|
+
.map((entry) => entry.split("/", 1)[0]?.trim() ?? "")
|
|
3002
|
+
.filter((name) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(name)),
|
|
3003
|
+
),
|
|
3004
|
+
]
|
|
3005
|
+
.sort()
|
|
3006
|
+
.join(":")
|
|
3007
|
+
.slice(0, 512);
|
|
3008
|
+
const identityRecoverySource = payload.session_id
|
|
3009
|
+
? "native_session_id"
|
|
3010
|
+
: payload.conversation_id
|
|
3011
|
+
? "native_conversation_id"
|
|
3012
|
+
: payload.agent_id
|
|
3013
|
+
? "native_agent_id"
|
|
3014
|
+
: "unavailable";
|
|
3015
|
+
return {
|
|
3016
|
+
thread_id_present: Boolean(env.CODEX_THREAD_ID?.trim()),
|
|
3017
|
+
wslenv_present: wslenv.length > 0,
|
|
3018
|
+
wslenv_names: wslenvNames,
|
|
3019
|
+
identity_recovery_source: identityRecoverySource,
|
|
3020
|
+
};
|
|
3021
|
+
}
|
|
3022
|
+
|
|
2530
3023
|
function suppressClosedSpanSignal(
|
|
2531
3024
|
input: RecordHookSignalV3Input,
|
|
2532
3025
|
sessionHash: `hid_${string}`,
|
|
@@ -2555,6 +3048,13 @@ export function recordApprovedSessionEndV3(
|
|
|
2555
3048
|
if (control.state !== input.mode) {
|
|
2556
3049
|
return { state: "gate_closed", reason: control.state };
|
|
2557
3050
|
}
|
|
3051
|
+
input = {
|
|
3052
|
+
...input,
|
|
3053
|
+
writerOptions: {
|
|
3054
|
+
...input.writerOptions,
|
|
3055
|
+
expectedGenesisId: control.genesis.event.payload.genesis_id as `gex_${string}`,
|
|
3056
|
+
},
|
|
3057
|
+
};
|
|
2558
3058
|
const matches = listHookProducerStateRecordsV3(input.coordRoot, { includeTerminal: true }).filter(
|
|
2559
3059
|
({ state }) =>
|
|
2560
3060
|
state.instance_id === input.instance_id && state.generation_id === input.generation_id,
|
|
@@ -2716,6 +3216,13 @@ export function salvageOpenSpansV3(input: SalvageOpenSpansV3Input): SalvageOpenS
|
|
|
2716
3216
|
if (control.state !== input.mode) {
|
|
2717
3217
|
return { state: "gate_closed", reason: control.state };
|
|
2718
3218
|
}
|
|
3219
|
+
input = {
|
|
3220
|
+
...input,
|
|
3221
|
+
writerOptions: {
|
|
3222
|
+
...input.writerOptions,
|
|
3223
|
+
expectedGenesisId: control.genesis.event.payload.genesis_id as `gex_${string}`,
|
|
3224
|
+
},
|
|
3225
|
+
};
|
|
2719
3226
|
const matches = listHookProducerStateRecordsV3(input.coordRoot).filter(
|
|
2720
3227
|
({ state }) =>
|
|
2721
3228
|
state.instance_id === input.instance_id && state.generation_id === input.generation_id,
|
|
@@ -2824,6 +3331,9 @@ export function listHookProducerStateRecordsV3(
|
|
|
2824
3331
|
)) {
|
|
2825
3332
|
const path = join(directory, name);
|
|
2826
3333
|
const state = readProducerState(path);
|
|
3334
|
+
// Skip authorities left behind by a replaced epoch: their sequences and
|
|
3335
|
+
// causal links belong to the archived ledger, not this one.
|
|
3336
|
+
if (state.epoch_genesis_id !== control.genesis.event.payload.genesis_id) continue;
|
|
2827
3337
|
if (!options.includeTerminal && state.terminal) continue;
|
|
2828
3338
|
records.push({ path, modified_at_ms: lstatSync(path).mtimeMs, state });
|
|
2829
3339
|
}
|
|
@@ -2843,6 +3353,8 @@ function hookSignalCapability(signal: HookSignalV3): AdapterSignalV3 {
|
|
|
2843
3353
|
return "session_end";
|
|
2844
3354
|
case "user-prompt-submit":
|
|
2845
3355
|
return "prompt";
|
|
3356
|
+
case "after-agent-response":
|
|
3357
|
+
return "assistant_reply_text";
|
|
2846
3358
|
case "stop":
|
|
2847
3359
|
case "stop-failure":
|
|
2848
3360
|
return "turn_completion";
|
|
@@ -2880,7 +3392,101 @@ export function readHookProducerStateV3(
|
|
|
2880
3392
|
);
|
|
2881
3393
|
const sessionHash = normalizeNativeIdV3(context, `${adapter}.session`, nativeSessionId);
|
|
2882
3394
|
const path = producerStatePath(coordRoot, adapter, sessionHash);
|
|
2883
|
-
|
|
3395
|
+
if (!existsSync(path)) return undefined;
|
|
3396
|
+
const state = readProducerState(path);
|
|
3397
|
+
// A state left behind by a replaced epoch is not this epoch's authority.
|
|
3398
|
+
return state.epoch_genesis_id === control.genesis.event.payload.genesis_id ? state : undefined;
|
|
3399
|
+
}
|
|
3400
|
+
|
|
3401
|
+
export interface ReconcilePendingRuntimeContextV3Input {
|
|
3402
|
+
coordRoot: string;
|
|
3403
|
+
mode: EventV3WriteMode;
|
|
3404
|
+
nativeSessionId: string;
|
|
3405
|
+
producer_id: `prd_${string}`;
|
|
3406
|
+
build_id: `build_${string}`;
|
|
3407
|
+
platform: "linux" | "windows" | "macos" | "unknown";
|
|
3408
|
+
finalAttempt?: boolean;
|
|
3409
|
+
runtimeTelemetryOptions?: RuntimeTelemetryOptions;
|
|
3410
|
+
writerOptions?: WriteEventV3Options;
|
|
3411
|
+
}
|
|
3412
|
+
|
|
3413
|
+
export type ReconcilePendingRuntimeContextV3Result =
|
|
3414
|
+
| { state: "gate_closed" }
|
|
3415
|
+
| { state: "missing" }
|
|
3416
|
+
| { state: "busy" }
|
|
3417
|
+
| { state: "not_pending" }
|
|
3418
|
+
| { state: "pending" }
|
|
3419
|
+
| { state: "settled" };
|
|
3420
|
+
|
|
3421
|
+
/**
|
|
3422
|
+
* Retry one Codex session's owner-only context join without replaying its Stop
|
|
3423
|
+
* signal. Codex appends `task_complete` only after the synchronous Stop hook
|
|
3424
|
+
* exits, so this is invoked by a bounded detached worker after that exit.
|
|
3425
|
+
*/
|
|
3426
|
+
export function reconcilePendingRuntimeContextV3(
|
|
3427
|
+
input: ReconcilePendingRuntimeContextV3Input,
|
|
3428
|
+
): ReconcilePendingRuntimeContextV3Result {
|
|
3429
|
+
const control = readEventV3ControlState(input.coordRoot);
|
|
3430
|
+
if (control.state !== input.mode) return { state: "gate_closed" };
|
|
3431
|
+
if (control.state !== "candidate" && control.state !== "active") {
|
|
3432
|
+
return { state: "gate_closed" };
|
|
3433
|
+
}
|
|
3434
|
+
const rootId = control.genesis.event.scope.root_id as `root_${string}`;
|
|
3435
|
+
const rootContext = fingerprintContextV3(
|
|
3436
|
+
input.coordRoot,
|
|
3437
|
+
rootId,
|
|
3438
|
+
undefined,
|
|
3439
|
+
control.genesis.profile.privacy_key_epoch,
|
|
3440
|
+
);
|
|
3441
|
+
const sessionHash = normalizeNativeIdV3(rootContext, "codex.session", input.nativeSessionId);
|
|
3442
|
+
const path = producerStatePath(input.coordRoot, "codex", sessionHash);
|
|
3443
|
+
if (!existsSync(path)) return { state: "missing" };
|
|
3444
|
+
const lease = acquireStateLeaseWithRetry(input.coordRoot, path, STATE_LEASE_RETRY_ATTEMPTS);
|
|
3445
|
+
if (!lease) return { state: "busy" };
|
|
3446
|
+
try {
|
|
3447
|
+
const state = readProducerState(path);
|
|
3448
|
+
if (state.epoch_genesis_id !== control.genesis.event.payload.genesis_id) {
|
|
3449
|
+
// The pending contexts belong to a replaced epoch; its archive already
|
|
3450
|
+
// holds everything this producer durably recorded.
|
|
3451
|
+
return { state: "missing" };
|
|
3452
|
+
}
|
|
3453
|
+
if (state.adapter !== "codex" || !state.pending_runtime_contexts?.length) {
|
|
3454
|
+
return { state: "not_pending" };
|
|
3455
|
+
}
|
|
3456
|
+
const context = fingerprintContextV3(
|
|
3457
|
+
input.coordRoot,
|
|
3458
|
+
rootId,
|
|
3459
|
+
state.generation_id,
|
|
3460
|
+
state.privacy_epoch_id,
|
|
3461
|
+
);
|
|
3462
|
+
reconcilePendingRuntimeContexts(
|
|
3463
|
+
{
|
|
3464
|
+
coordRoot: input.coordRoot,
|
|
3465
|
+
mode: input.mode,
|
|
3466
|
+
signal: "stop",
|
|
3467
|
+
payload: { raw: {}, session_id: input.nativeSessionId },
|
|
3468
|
+
adapter: "codex",
|
|
3469
|
+
instance_id: state.instance_id,
|
|
3470
|
+
producer_id: input.producer_id,
|
|
3471
|
+
build_id: input.build_id,
|
|
3472
|
+
platform: input.platform,
|
|
3473
|
+
observed_at: new Date().toISOString(),
|
|
3474
|
+
runtimeTelemetryOptions: input.runtimeTelemetryOptions,
|
|
3475
|
+
writerOptions: {
|
|
3476
|
+
...input.writerOptions,
|
|
3477
|
+
expectedGenesisId: control.genesis.event.payload.genesis_id as `gex_${string}`,
|
|
3478
|
+
},
|
|
3479
|
+
},
|
|
3480
|
+
state,
|
|
3481
|
+
path,
|
|
3482
|
+
rootId,
|
|
3483
|
+
context,
|
|
3484
|
+
{ deferRetryLimit: true, finalAttempt: input.finalAttempt },
|
|
3485
|
+
);
|
|
3486
|
+
return state.pending_runtime_contexts?.length ? { state: "pending" } : { state: "settled" };
|
|
3487
|
+
} finally {
|
|
3488
|
+
lease.release();
|
|
3489
|
+
}
|
|
2884
3490
|
}
|
|
2885
3491
|
|
|
2886
3492
|
/** Resolve one terminal producer only when native session and instance identity agree. */
|
|
@@ -2918,6 +3524,7 @@ export function readHookProducerStateByInstanceV3(
|
|
|
2918
3524
|
/^hid_[a-f0-9]{64}\.json$/.test(entry),
|
|
2919
3525
|
)) {
|
|
2920
3526
|
const state = readProducerState(join(directory, name));
|
|
3527
|
+
if (state.epoch_genesis_id !== control.genesis.event.payload.genesis_id) continue;
|
|
2921
3528
|
if (state.instance_id === instanceId && !state.terminal) matches.push(state);
|
|
2922
3529
|
}
|
|
2923
3530
|
}
|
|
@@ -2949,6 +3556,7 @@ function newProducerState(
|
|
|
2949
3556
|
sessionId: `sid_${string}`,
|
|
2950
3557
|
epochId: `pep_${string}`,
|
|
2951
3558
|
boundaryEventId: `evt_${string}`,
|
|
3559
|
+
genesisId: `gex_${string}`,
|
|
2952
3560
|
): HookProducerStateV3 {
|
|
2953
3561
|
const bootId = `boot_${randomUUID()}` as const;
|
|
2954
3562
|
return {
|
|
@@ -2962,6 +3570,7 @@ function newProducerState(
|
|
|
2962
3570
|
capability_profile: adapterCapabilityProfileDigestV3(input.adapter),
|
|
2963
3571
|
cursor_mode: input.adapter === "cursor" ? (input.payload.cursor_mode ?? "unknown") : undefined,
|
|
2964
3572
|
privacy_epoch_id: epochId,
|
|
3573
|
+
epoch_genesis_id: genesisId,
|
|
2965
3574
|
boot_id: bootId,
|
|
2966
3575
|
clock_id: clockIdV3(),
|
|
2967
3576
|
next_sequence: 1,
|
|
@@ -2972,6 +3581,7 @@ function newProducerState(
|
|
|
2972
3581
|
boot_id: bootId,
|
|
2973
3582
|
clock: signalClock(input),
|
|
2974
3583
|
}),
|
|
3584
|
+
session_start_derivation: input.session_start_derivation,
|
|
2975
3585
|
terminal: false,
|
|
2976
3586
|
spans: [],
|
|
2977
3587
|
delegations: [],
|
|
@@ -3002,6 +3612,8 @@ function applyCommittedEvent(state: HookProducerStateV3, event: EventV3): void {
|
|
|
3002
3612
|
if (event.event_type === "turn.started") {
|
|
3003
3613
|
const nextTurnId = (event.scope as { turn_id: `tid_${string}` }).turn_id;
|
|
3004
3614
|
state.current_turn_id = nextTurnId;
|
|
3615
|
+
state.cursor_response_ritual = undefined;
|
|
3616
|
+
state.session_start_derivation = undefined;
|
|
3005
3617
|
if (state.tool_call_count_turn_id !== nextTurnId) {
|
|
3006
3618
|
state.tool_call_count = 0;
|
|
3007
3619
|
state.tool_call_count_turn_id = nextTurnId;
|
|
@@ -3086,6 +3698,7 @@ function applyCommittedEvent(state: HookProducerStateV3, event: EventV3): void {
|
|
|
3086
3698
|
}
|
|
3087
3699
|
state.current_turn_id = undefined;
|
|
3088
3700
|
state.current_native_turn_id = undefined;
|
|
3701
|
+
state.cursor_response_ritual = undefined;
|
|
3089
3702
|
state.current_turn_span = undefined;
|
|
3090
3703
|
state.tool_call_count = 0;
|
|
3091
3704
|
state.tool_call_count_turn_id = undefined;
|
|
@@ -3378,6 +3991,7 @@ function readProducerState(path: string): HookProducerStateV3 {
|
|
|
3378
3991
|
}
|
|
3379
3992
|
if (state.adapter === "cursor") state.cursor_mode ??= "unknown";
|
|
3380
3993
|
const allowedKeys = new Set([
|
|
3994
|
+
"active_runtime_context_probe",
|
|
3381
3995
|
"adapter",
|
|
3382
3996
|
"attestation_id",
|
|
3383
3997
|
"boot_id",
|
|
@@ -3389,7 +4003,9 @@ function readProducerState(path: string): HookProducerStateV3 {
|
|
|
3389
4003
|
"current_native_turn_id",
|
|
3390
4004
|
"current_turn_span",
|
|
3391
4005
|
"cursor_mode",
|
|
4006
|
+
"cursor_response_ritual",
|
|
3392
4007
|
"delegations",
|
|
4008
|
+
"epoch_genesis_id",
|
|
3393
4009
|
"format",
|
|
3394
4010
|
"format_version",
|
|
3395
4011
|
"generation_id",
|
|
@@ -3399,6 +4015,7 @@ function readProducerState(path: string): HookProducerStateV3 {
|
|
|
3399
4015
|
"last_attested_telemetry",
|
|
3400
4016
|
"last_attested_tuning",
|
|
3401
4017
|
"last_attested_tuning_observation",
|
|
4018
|
+
"last_context_source_witness",
|
|
3402
4019
|
"tuning_probe_turn_id",
|
|
3403
4020
|
"last_event_id",
|
|
3404
4021
|
"last_monotonic_ns",
|
|
@@ -3409,6 +4026,7 @@ function readProducerState(path: string): HookProducerStateV3 {
|
|
|
3409
4026
|
"runtime_transcript_path",
|
|
3410
4027
|
"privacy_epoch_id",
|
|
3411
4028
|
"session_id",
|
|
4029
|
+
"session_start_derivation",
|
|
3412
4030
|
"session_span",
|
|
3413
4031
|
"spans",
|
|
3414
4032
|
"started_event_id",
|
|
@@ -3432,6 +4050,7 @@ function readProducerState(path: string): HookProducerStateV3 {
|
|
|
3432
4050
|
!/^att_[0-9a-f-]{36}$/.test(state.attestation_id) ||
|
|
3433
4051
|
!/^cap_[a-f0-9]{64}$/.test(state.capability_profile) ||
|
|
3434
4052
|
!/^pep_[a-zA-Z0-9._-]+$/.test(state.privacy_epoch_id) ||
|
|
4053
|
+
(state.epoch_genesis_id !== undefined && !/^gex_[0-9a-f-]{36}$/.test(state.epoch_genesis_id)) ||
|
|
3435
4054
|
!/^boot_[a-zA-Z0-9._-]+$/.test(state.boot_id) ||
|
|
3436
4055
|
!/^clk_[0-9a-f-]{36}$/.test(state.clock_id) ||
|
|
3437
4056
|
!Number.isSafeInteger(state.next_sequence) ||
|
|
@@ -3502,16 +4121,32 @@ function readProducerState(path: string): HookProducerStateV3 {
|
|
|
3502
4121
|
(typeof state.current_native_turn_id !== "string" ||
|
|
3503
4122
|
state.current_native_turn_id.length === 0 ||
|
|
3504
4123
|
state.current_native_turn_id.length > 512)) ||
|
|
4124
|
+
(state.cursor_response_ritual !== undefined &&
|
|
4125
|
+
(!/^tid_[a-f0-9]{64}$/.test(state.cursor_response_ritual.turn_id) ||
|
|
4126
|
+
(state.cursor_response_ritual.native_turn_id !== undefined &&
|
|
4127
|
+
(typeof state.cursor_response_ritual.native_turn_id !== "string" ||
|
|
4128
|
+
state.cursor_response_ritual.native_turn_id.length === 0 ||
|
|
4129
|
+
state.cursor_response_ritual.native_turn_id.length > 512)) ||
|
|
4130
|
+
!Number.isFinite(Date.parse(state.cursor_response_ritual.observed_at)) ||
|
|
4131
|
+
typeof state.cursor_response_ritual.status_box_present !== "boolean" ||
|
|
4132
|
+
typeof state.cursor_response_ritual.status_box_present_strict !== "boolean")) ||
|
|
3505
4133
|
(state.last_event_id !== undefined && !/^evt_[0-9a-f-]{36}$/.test(state.last_event_id)) ||
|
|
3506
4134
|
(state.last_monotonic_ns !== undefined && !/^\d+$/.test(state.last_monotonic_ns)) ||
|
|
3507
4135
|
(state.last_observed_at !== undefined &&
|
|
3508
4136
|
!Number.isFinite(Date.parse(state.last_observed_at))) ||
|
|
3509
4137
|
(state.started_event_id !== undefined && !/^evt_[0-9a-f-]{36}$/.test(state.started_event_id)) ||
|
|
4138
|
+
(state.session_start_derivation !== undefined &&
|
|
4139
|
+
state.session_start_derivation !== "approved_lifecycle_reopen" &&
|
|
4140
|
+
state.session_start_derivation !== "validated_current_session_heal") ||
|
|
3510
4141
|
(state.pending_runtime_contexts !== undefined &&
|
|
3511
4142
|
(!Array.isArray(state.pending_runtime_contexts) ||
|
|
3512
4143
|
state.pending_runtime_contexts.length === 0 ||
|
|
3513
4144
|
state.pending_runtime_contexts.length > PENDING_RUNTIME_CONTEXT_CAP ||
|
|
3514
4145
|
state.pending_runtime_contexts.some((pending) => !validPendingRuntimeContext(pending)))) ||
|
|
4146
|
+
(state.active_runtime_context_probe !== undefined &&
|
|
4147
|
+
!validActiveRuntimeContextProbe(state.active_runtime_context_probe)) ||
|
|
4148
|
+
(state.last_context_source_witness !== undefined &&
|
|
4149
|
+
!/^[a-f0-9]{64}$/.test(state.last_context_source_witness)) ||
|
|
3515
4150
|
(state.runtime_transcript_path !== undefined &&
|
|
3516
4151
|
(typeof state.runtime_transcript_path !== "string" ||
|
|
3517
4152
|
state.runtime_transcript_path.length === 0 ||
|
|
@@ -3629,6 +4264,18 @@ function validPendingRuntimeContext(value: unknown): value is PendingRuntimeCont
|
|
|
3629
4264
|
);
|
|
3630
4265
|
}
|
|
3631
4266
|
|
|
4267
|
+
function validActiveRuntimeContextProbe(value: unknown): value is ActiveRuntimeContextProbeV3 {
|
|
4268
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
4269
|
+
const probe = value as ActiveRuntimeContextProbeV3;
|
|
4270
|
+
return (
|
|
4271
|
+
typeof probe.turn_id === "string" &&
|
|
4272
|
+
/^tid_[a-f0-9]{64}$/.test(probe.turn_id) &&
|
|
4273
|
+
typeof probe.attempted_at === "string" &&
|
|
4274
|
+
Number.isFinite(Date.parse(probe.attempted_at)) &&
|
|
4275
|
+
(probe.boundary === undefined || probe.boundary === "tool_completed")
|
|
4276
|
+
);
|
|
4277
|
+
}
|
|
4278
|
+
|
|
3632
4279
|
function pidIsAlive(pid: number): boolean {
|
|
3633
4280
|
if (!Number.isSafeInteger(pid) || pid < 1) return false;
|
|
3634
4281
|
try {
|