harnery 0.35.0 → 0.36.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 +124 -96
- package/dist/commands/agents.d.ts +23 -3
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +379 -198
- 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 +5 -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/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 +22 -0
- package/dist/commands/files.d.ts.map +1 -0
- package/dist/commands/files.js +113 -0
- package/dist/commands/governor.js +14 -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 +347 -1
- 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/read.d.ts +1 -1
- package/dist/commands/read.d.ts.map +1 -1
- package/dist/commands/read.js +2 -2
- 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/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 +67 -7
- package/dist/commands/work.js +3 -3
- package/dist/commands/workflow.js +13 -13
- package/dist/core/adapters/profiles.d.ts +1 -1
- package/dist/core/agents/cli.js +209 -39
- 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/render/prompt-context.d.ts +9 -3
- package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
- package/dist/core/agents/render/prompt-context.js +24 -7
- 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 +94 -13
- 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 +5 -1
- 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 +21 -0
- package/dist/core/artifacts/index.d.ts.map +1 -1
- package/dist/core/artifacts/index.js +46 -1
- package/dist/core/config.d.ts +62 -4
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +98 -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/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/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 +6 -0
- package/dist/core/events/legacy-storage/index.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/index.js +5 -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/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.js +3 -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 +4 -2
- package/dist/core/events/v3/index.d.ts.map +1 -1
- package/dist/core/events/v3/index.js +3 -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 +45 -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.js +1 -1
- 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 +25 -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 +55 -1
- package/dist/core/events/v3/producers/recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/recorder.js +353 -24
- 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 +4 -2
- package/dist/core/hooks/adapter/output.d.ts.map +1 -1
- package/dist/core/hooks/adapter/output.js +13 -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 +212 -30
- 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/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/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/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 +683 -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 +82 -0
- package/dist/core/storage/logger.d.ts.map +1 -0
- package/dist/core/storage/logger.js +411 -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 +34 -0
- package/dist/core/storage/query.d.ts.map +1 -0
- package/dist/core/storage/query.js +295 -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/work/state.d.ts.map +1 -1
- package/dist/core/work/state.js +10 -14
- package/dist/core/workflow/live-session-v3.d.ts.map +1 -1
- package/dist/core/workflow/live-session-v3.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/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/templates.d.ts.map +1 -1
- package/dist/lib/instructions/templates.js +5 -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 +29 -2
- package/schemas/config.schema.json +58 -0
- package/schemas/event-v3.schema.json +324 -112
- package/src/commander.ts +462 -95
- package/src/commands/agents.ts +517 -190
- package/src/commands/backup.ts +18 -14
- package/src/commands/browse-session.ts +12 -0
- package/src/commands/browse.ts +6 -7
- package/src/commands/conversations.ts +279 -0
- package/src/commands/deinit.ts +6 -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 +143 -0
- package/src/commands/governor.ts +13 -12
- package/src/commands/inbox.ts +61 -0
- package/src/commands/init.ts +78 -16
- package/src/commands/ledger-v3.ts +421 -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/read.ts +6 -2
- package/src/commands/semantic.ts +66 -1
- package/src/commands/storage.ts +310 -0
- package/src/commands/tunnel.ts +66 -52
- package/src/commands/web.ts +77 -7
- package/src/commands/work.ts +3 -3
- package/src/commands/workflow.ts +13 -13
- package/src/core/agents/cli.ts +259 -53
- 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/render/prompt-context.ts +27 -6
- package/src/core/agents/rules/stop-hook.ts +107 -16
- 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 +4 -1
- 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 +64 -1
- package/src/core/config.ts +126 -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/events/legacy-storage/canary.ts +177 -0
- package/src/core/events/legacy-storage/fence.ts +129 -0
- package/src/core/events/legacy-storage/index.ts +5 -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/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 +3 -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 +5 -2
- package/src/core/events/v3/live-route-observer.ts +80 -0
- package/src/core/events/v3/live-routing.ts +64 -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 +1 -1
- package/src/core/events/v3/producers/intake.ts +30 -2
- package/src/core/events/v3/producers/producer-state-observer.ts +52 -0
- package/src/core/events/v3/producers/recorder.ts +571 -33
- 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 +12 -5
- package/src/core/hooks/adapter/runtime-telemetry.ts +408 -13
- package/src/core/hooks/cli.ts +226 -32
- package/src/core/hooks/effects/image-capture.ts +4 -1
- 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/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/buffer.ts +124 -0
- package/src/core/storage/builtins.ts +916 -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 +546 -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 +360 -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/work/state.ts +12 -21
- package/src/core/workflow/live-session-v3.ts +2 -4
- package/src/index.ts +2 -0
- package/src/lazy-commands.ts +294 -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/templates.ts +5 -0
- package/src/lib/local-file-url.ts +31 -0
- package/src/lib/web-performance.ts +335 -0
|
@@ -31,6 +31,10 @@ const CLOSED_TURN_MEMORY_CAP = 16;
|
|
|
31
31
|
const SPAN_SOFT_WATERMARK = 128;
|
|
32
32
|
const PENDING_RUNTIME_CONTEXT_CAP = 4;
|
|
33
33
|
const RUNTIME_CONTEXT_RETRY_LIMIT = 2;
|
|
34
|
+
/** Active turns pay for at most one bounded adapter telemetry read per interval. */
|
|
35
|
+
const ACTIVE_RUNTIME_CONTEXT_PROBE_INTERVAL_MS = 15_000;
|
|
36
|
+
/** Codex can flush the terminal row just after Stop; keep this grace bounded and off other hooks. */
|
|
37
|
+
const STOP_RUNTIME_CONTEXT_RETRY_DELAYS_MS = [75, 175];
|
|
34
38
|
/** Finalization is off the interactive hook path; briefly cover Codex's delayed transcript flush. */
|
|
35
39
|
const APPROVED_END_RUNTIME_CONTEXT_RETRY_DELAYS_MS = [0, 250, 250];
|
|
36
40
|
/**
|
|
@@ -283,8 +287,23 @@ function processHookSignalLocked(control, input, sessionHash, path) {
|
|
|
283
287
|
: control.activation.event.event_id;
|
|
284
288
|
const rootFingerprintContext = fingerprintContextV3(input.coordRoot, rootId, undefined, epochId);
|
|
285
289
|
const sessionId = `sid_${sessionHash.slice(4)}`;
|
|
290
|
+
const genesisId = control.genesis.event.payload.genesis_id;
|
|
291
|
+
// Every write below carries the epoch fence: an event produced for this
|
|
292
|
+
// epoch is refused (or quarantined from the spool) once the epoch has been
|
|
293
|
+
// replaced, instead of poisoning the successor's authority.
|
|
294
|
+
input = {
|
|
295
|
+
...input,
|
|
296
|
+
writerOptions: { ...input.writerOptions, expectedGenesisId: genesisId },
|
|
297
|
+
};
|
|
286
298
|
try {
|
|
287
299
|
let state = existsSync(path) ? readProducerState(path) : undefined;
|
|
300
|
+
if (state && state.epoch_genesis_id !== genesisId) {
|
|
301
|
+
// A producer state from a replaced epoch (or one that predates the
|
|
302
|
+
// field) is never adopted: its boot sequences and causal links only
|
|
303
|
+
// validate inside the epoch that recorded them. The session re-onboards
|
|
304
|
+
// below exactly as it does after an automatic epoch refresh.
|
|
305
|
+
state = undefined;
|
|
306
|
+
}
|
|
288
307
|
if (state &&
|
|
289
308
|
(state.adapter !== input.adapter ||
|
|
290
309
|
state.session_id !== sessionId ||
|
|
@@ -307,7 +326,7 @@ function processHookSignalLocked(control, input, sessionHash, path) {
|
|
|
307
326
|
const pendingSource = state.pending.source_id;
|
|
308
327
|
const incomingSource = sourceIdForSignal(input, rootFingerprintContext);
|
|
309
328
|
const pendingEvent = state.pending.event;
|
|
310
|
-
const durability = writeEventV3(input.coordRoot, pendingEvent);
|
|
329
|
+
const durability = writeEventV3(input.coordRoot, pendingEvent, input.writerOptions);
|
|
311
330
|
applyCommittedEvent(state, pendingEvent);
|
|
312
331
|
state.pending = undefined;
|
|
313
332
|
publishProducerState(path, state);
|
|
@@ -321,10 +340,11 @@ function processHookSignalLocked(control, input, sessionHash, path) {
|
|
|
321
340
|
if (state && !state.terminal && state.started_event_id) {
|
|
322
341
|
return { state: "already_started", event_id: state.started_event_id };
|
|
323
342
|
}
|
|
324
|
-
if (input.session_start_derivation && !state?.terminal)
|
|
343
|
+
if ((input.session_start_derivation === "approved_lifecycle_reopen" && !state?.terminal) ||
|
|
344
|
+
(input.session_start_derivation === "validated_current_session_heal" && state?.terminal)) {
|
|
325
345
|
return { state: "missing_session_start" };
|
|
326
346
|
}
|
|
327
|
-
state = newProducerState(input, sessionId, epochId, boundaryEventId);
|
|
347
|
+
state = newProducerState(input, sessionId, epochId, boundaryEventId, genesisId);
|
|
328
348
|
}
|
|
329
349
|
else if (!state || state.terminal) {
|
|
330
350
|
// Mid-flight onboarding (ADR 0078): a live session with no producer
|
|
@@ -350,7 +370,7 @@ function processHookSignalLocked(control, input, sessionHash, path) {
|
|
|
350
370
|
});
|
|
351
371
|
return { state: "missing_session_start" };
|
|
352
372
|
}
|
|
353
|
-
state = newProducerState(input, sessionId, epochId, boundaryEventId);
|
|
373
|
+
state = newProducerState(input, sessionId, epochId, boundaryEventId, genesisId);
|
|
354
374
|
const cursorPromptBootstrap = isCursorPromptBootstrap(input);
|
|
355
375
|
const onboarding = buildMidFlightSessionStart(input, state, rootId, cursorPromptBootstrap);
|
|
356
376
|
commitEventLocked(input, state, path, onboarding);
|
|
@@ -360,6 +380,7 @@ function processHookSignalLocked(control, input, sessionHash, path) {
|
|
|
360
380
|
instance_id: input.instance_id,
|
|
361
381
|
signal: input.signal,
|
|
362
382
|
session_hash: sessionHash,
|
|
383
|
+
...(input.adapter === "codex" ? codexMidFlightDiagnosticContext(input.payload) : {}),
|
|
363
384
|
});
|
|
364
385
|
}
|
|
365
386
|
}
|
|
@@ -764,11 +785,15 @@ function processHookSignalLocked(control, input, sessionHash, path) {
|
|
|
764
785
|
assertEventV3(event);
|
|
765
786
|
}
|
|
766
787
|
if (input.signal === "session-start" &&
|
|
767
|
-
input.session_start_derivation
|
|
788
|
+
input.session_start_derivation &&
|
|
768
789
|
event.event_type === "session.started") {
|
|
790
|
+
const lifecycleReopen = input.session_start_derivation === "approved_lifecycle_reopen";
|
|
791
|
+
const reason = lifecycleReopen
|
|
792
|
+
? "approved_lifecycle_reopen"
|
|
793
|
+
: "validated_current_session_heal";
|
|
769
794
|
event.provenance = {
|
|
770
795
|
...event.provenance,
|
|
771
|
-
source_event: `${input.adapter}.
|
|
796
|
+
source_event: `${input.adapter}.${reason.replaceAll("_", "-")}`,
|
|
772
797
|
attestation: "derived",
|
|
773
798
|
confidence: "high",
|
|
774
799
|
attribution: {
|
|
@@ -779,7 +804,7 @@ function processHookSignalLocked(control, input, sessionHash, path) {
|
|
|
779
804
|
};
|
|
780
805
|
event.payload.resume = {
|
|
781
806
|
state: "unknown",
|
|
782
|
-
reason
|
|
807
|
+
reason,
|
|
783
808
|
};
|
|
784
809
|
assertEventV3(event);
|
|
785
810
|
}
|
|
@@ -788,7 +813,13 @@ function processHookSignalLocked(control, input, sessionHash, path) {
|
|
|
788
813
|
span.open_event_id = event.event_id;
|
|
789
814
|
stampSpanTurn(span, event, eventInput, state);
|
|
790
815
|
}
|
|
816
|
+
// A turn terminal clears current_native_turn_id when it commits. Retain the
|
|
817
|
+
// native identity long enough to seed a delayed context retry afterward.
|
|
818
|
+
const nativeTurnIdForContext = input.payload.turn_id ?? state.current_native_turn_id;
|
|
791
819
|
const durability = commitEventLocked(input, state, path, event, sourceId);
|
|
820
|
+
if (event.event_type === "context.compaction_started" && input.signal === "pre-compact") {
|
|
821
|
+
maybeCommitNativeHookContextObservation(input, state, path, rootId, fingerprintContext, event);
|
|
822
|
+
}
|
|
792
823
|
if (event.event_type === "tool.requested" && sourceId) {
|
|
793
824
|
const explicitWait = explicitNativeWait(input);
|
|
794
825
|
if (explicitWait) {
|
|
@@ -802,9 +833,12 @@ function processHookSignalLocked(control, input, sessionHash, path) {
|
|
|
802
833
|
if (progressKind) {
|
|
803
834
|
commitProgressObservation(input, state, path, rootId, event, progressKind);
|
|
804
835
|
}
|
|
836
|
+
if (event.event_type === "tool.completed" && input.signal === "post-tool-use") {
|
|
837
|
+
maybeCommitActiveRuntimeContextObservation(input, state, path, rootId, fingerprintContext, event);
|
|
838
|
+
}
|
|
805
839
|
if (turnTelemetry) {
|
|
806
840
|
const contextTarget = turnContextTarget(event);
|
|
807
|
-
queuePendingRuntimeContext(input, state, contextTarget, turnTelemetry.context);
|
|
841
|
+
queuePendingRuntimeContext(input, state, contextTarget, turnTelemetry.context, nativeTurnIdForContext);
|
|
808
842
|
commitTurnContextObservation(input, state, path, rootId, fingerprintContext, contextTarget, turnTelemetry.context, turnTelemetry.context_provenance);
|
|
809
843
|
}
|
|
810
844
|
if (event.event_type === "session.ended") {
|
|
@@ -1167,6 +1201,25 @@ function commitEventLocked(input, state, path, event, sourceId) {
|
|
|
1167
1201
|
function commitTurnContextObservation(input, state, path, rootId, fingerprintContext, target, measurement, contextProvenance, observedAt) {
|
|
1168
1202
|
if (!target)
|
|
1169
1203
|
return;
|
|
1204
|
+
commitContextObservation(input, state, path, rootId, fingerprintContext, {
|
|
1205
|
+
caused_by_event_id: target.terminal_event_id,
|
|
1206
|
+
observed_at: observedAt ?? target.terminal_observed_at,
|
|
1207
|
+
turn_id: target.turn_id,
|
|
1208
|
+
...(target.run_id ? { run_id: target.run_id } : {}),
|
|
1209
|
+
...(target.workflow_id ? { workflow_id: target.workflow_id } : {}),
|
|
1210
|
+
...(target.workflow_agent_id ? { workflow_agent_id: target.workflow_agent_id } : {}),
|
|
1211
|
+
}, measurement, contextProvenance);
|
|
1212
|
+
}
|
|
1213
|
+
function commitContextObservation(input, state, path, rootId, fingerprintContext, target, measurement, contextProvenance) {
|
|
1214
|
+
if (measurement.state === "observed" &&
|
|
1215
|
+
contextProvenance?.source_witness &&
|
|
1216
|
+
state.last_context_source_witness === contextProvenance.source_witness) {
|
|
1217
|
+
publishProducerState(path, state);
|
|
1218
|
+
return;
|
|
1219
|
+
}
|
|
1220
|
+
if (measurement.state === "observed" && contextProvenance?.source_witness) {
|
|
1221
|
+
state.last_context_source_witness = contextProvenance.source_witness;
|
|
1222
|
+
}
|
|
1170
1223
|
const event = buildEventV3("context.observed", {
|
|
1171
1224
|
producer: {
|
|
1172
1225
|
producer_id: input.producer_id,
|
|
@@ -1188,7 +1241,7 @@ function commitTurnContextObservation(input, state, path, rootId, fingerprintCon
|
|
|
1188
1241
|
...(target.workflow_agent_id ? { workflow_agent_id: target.workflow_agent_id } : {}),
|
|
1189
1242
|
},
|
|
1190
1243
|
attestation_id: state.attestation_id,
|
|
1191
|
-
links: { caused_by: [target.
|
|
1244
|
+
links: { caused_by: [target.caused_by_event_id] },
|
|
1192
1245
|
provenance: {
|
|
1193
1246
|
source_event: safeRole([
|
|
1194
1247
|
contextProvenance?.source_event ?? `${input.adapter}.turn-context`,
|
|
@@ -1209,10 +1262,10 @@ function commitTurnContextObservation(input, state, path, rootId, fingerprintCon
|
|
|
1209
1262
|
subject_instance_id: state.instance_id,
|
|
1210
1263
|
},
|
|
1211
1264
|
},
|
|
1212
|
-
// The source sample may precede
|
|
1213
|
-
//
|
|
1214
|
-
//
|
|
1215
|
-
observed_at:
|
|
1265
|
+
// The source sample may precede the hook boundary that admits it.
|
|
1266
|
+
// measurement.measured_at preserves the sample clock without creating a
|
|
1267
|
+
// causal wall-clock regression in the producer event chain.
|
|
1268
|
+
observed_at: target.observed_at,
|
|
1216
1269
|
monotonic_ns: orderedEventMonotonic(state, input.monotonic_ns),
|
|
1217
1270
|
clock_id: state.clock_id,
|
|
1218
1271
|
payload: {
|
|
@@ -1222,6 +1275,113 @@ function commitTurnContextObservation(input, state, path, rootId, fingerprintCon
|
|
|
1222
1275
|
commitEventLocked(input, state, path, event);
|
|
1223
1276
|
maybeAttestContextCapabilityChange(input, state, path, rootId, measurement, contextProvenance);
|
|
1224
1277
|
}
|
|
1278
|
+
/**
|
|
1279
|
+
* Admit fresh adapter-native or bounded runtime context while a turn is open.
|
|
1280
|
+
* Tool completions are safe sampling boundaries. Persistent owner-only cadence
|
|
1281
|
+
* state prevents short-lived hook processes from reading on every request,
|
|
1282
|
+
* and the source witness prevents duplicate public events.
|
|
1283
|
+
*/
|
|
1284
|
+
function maybeCommitActiveRuntimeContextObservation(input, state, path, rootId, fingerprintContext, sourceEvent) {
|
|
1285
|
+
if (input.signal !== "post-tool-use" || state.terminal || !state.current_turn_id) {
|
|
1286
|
+
return;
|
|
1287
|
+
}
|
|
1288
|
+
const nativeSessionId = input.payload.session_id ?? input.payload.conversation_id;
|
|
1289
|
+
const nativeTurnId = input.payload.turn_id ?? state.current_native_turn_id;
|
|
1290
|
+
if (!nativeSessionId || (!nativeTurnId && input.adapter !== "cursor"))
|
|
1291
|
+
return;
|
|
1292
|
+
const now = Date.now();
|
|
1293
|
+
const configuredInterval = input.runtimeTelemetryOptions?.activeContextProbeIntervalMs;
|
|
1294
|
+
const intervalMs = configuredInterval !== undefined && Number.isFinite(configuredInterval)
|
|
1295
|
+
? Math.max(0, Math.floor(configuredInterval))
|
|
1296
|
+
: ACTIVE_RUNTIME_CONTEXT_PROBE_INTERVAL_MS;
|
|
1297
|
+
const prior = state.active_runtime_context_probe;
|
|
1298
|
+
const priorAttempt = prior ? Date.parse(prior.attempted_at) : Number.NaN;
|
|
1299
|
+
if (prior?.turn_id === state.current_turn_id &&
|
|
1300
|
+
prior.boundary === "tool_completed" &&
|
|
1301
|
+
Number.isFinite(priorAttempt) &&
|
|
1302
|
+
now - priorAttempt >= 0 &&
|
|
1303
|
+
now - priorAttempt < intervalMs) {
|
|
1304
|
+
return;
|
|
1305
|
+
}
|
|
1306
|
+
state.active_runtime_context_probe = {
|
|
1307
|
+
turn_id: state.current_turn_id,
|
|
1308
|
+
attempted_at: new Date(now).toISOString(),
|
|
1309
|
+
boundary: "tool_completed",
|
|
1310
|
+
};
|
|
1311
|
+
const native = extractTurnTelemetryV3(input.adapter, input.payload.raw, sourceEvent.time.observed_at).context;
|
|
1312
|
+
if (native.state === "observed") {
|
|
1313
|
+
commitActiveContextObservation(input, state, path, rootId, fingerprintContext, sourceEvent, native, nativeContextProvenance(input, state, native));
|
|
1314
|
+
return;
|
|
1315
|
+
}
|
|
1316
|
+
if (input.adapter === "cursor" && state.cursor_mode === "cloud") {
|
|
1317
|
+
publishProducerState(path, state);
|
|
1318
|
+
return;
|
|
1319
|
+
}
|
|
1320
|
+
const transcriptPath = runtimeTranscriptPath(input, state);
|
|
1321
|
+
if (!transcriptPath && input.adapter !== "cursor") {
|
|
1322
|
+
publishProducerState(path, state);
|
|
1323
|
+
return;
|
|
1324
|
+
}
|
|
1325
|
+
const runtime = readRuntimeContextTelemetry({
|
|
1326
|
+
adapter: input.adapter,
|
|
1327
|
+
session_id: nativeSessionId,
|
|
1328
|
+
...(nativeTurnId ? { turn_id: nativeTurnId } : {}),
|
|
1329
|
+
...(state.current_turn_span?.opened_at
|
|
1330
|
+
? { turn_started_at: state.current_turn_span.opened_at }
|
|
1331
|
+
: {}),
|
|
1332
|
+
transcript_path: transcriptPath,
|
|
1333
|
+
observed_at: sourceEvent.time.observed_at,
|
|
1334
|
+
mode: "active_turn",
|
|
1335
|
+
}, input.runtimeTelemetryOptions);
|
|
1336
|
+
if (runtime.bytes_read > 0)
|
|
1337
|
+
recordRuntimeTelemetryTiming(state, runtime.io_duration_ms);
|
|
1338
|
+
if (runtime.state !== "observed") {
|
|
1339
|
+
publishProducerState(path, state);
|
|
1340
|
+
return;
|
|
1341
|
+
}
|
|
1342
|
+
commitActiveContextObservation(input, state, path, rootId, fingerprintContext, sourceEvent, runtimeContextObservation(runtime), {
|
|
1343
|
+
source_event: runtime.source_event,
|
|
1344
|
+
source_witness: runtime.source_witness,
|
|
1345
|
+
...(input.adapterVersion ? { runtime_version: input.adapterVersion } : {}),
|
|
1346
|
+
attestation: runtime.attestation,
|
|
1347
|
+
confidence: runtime.confidence,
|
|
1348
|
+
});
|
|
1349
|
+
}
|
|
1350
|
+
function commitActiveContextObservation(input, state, path, rootId, fingerprintContext, sourceEvent, measurement, provenance) {
|
|
1351
|
+
if (!state.current_turn_id)
|
|
1352
|
+
return;
|
|
1353
|
+
const scope = sourceEvent.scope;
|
|
1354
|
+
commitContextObservation(input, state, path, rootId, fingerprintContext, {
|
|
1355
|
+
caused_by_event_id: sourceEvent.event_id,
|
|
1356
|
+
observed_at: sourceEvent.time.observed_at,
|
|
1357
|
+
turn_id: state.current_turn_id,
|
|
1358
|
+
...(scope.run_id ? { run_id: scope.run_id } : {}),
|
|
1359
|
+
...(scope.workflow_id ? { workflow_id: scope.workflow_id } : {}),
|
|
1360
|
+
...(scope.workflow_agent_id ? { workflow_agent_id: scope.workflow_agent_id } : {}),
|
|
1361
|
+
}, measurement, provenance);
|
|
1362
|
+
}
|
|
1363
|
+
function nativeContextProvenance(input, state, measurement) {
|
|
1364
|
+
const { measured_at: _measuredAt, ...stableValue } = measurement.value;
|
|
1365
|
+
const witness = canonicalJsonV3({
|
|
1366
|
+
adapter: input.adapter,
|
|
1367
|
+
session_id: state.session_id,
|
|
1368
|
+
turn_id: state.current_turn_id,
|
|
1369
|
+
value: stableValue,
|
|
1370
|
+
});
|
|
1371
|
+
return {
|
|
1372
|
+
source_event: `${input.adapter}.native_context`,
|
|
1373
|
+
source_witness: createHash("sha256").update(witness).digest("hex"),
|
|
1374
|
+
...(input.adapterVersion ? { runtime_version: input.adapterVersion } : {}),
|
|
1375
|
+
attestation: measurement.attestation,
|
|
1376
|
+
confidence: measurement.confidence,
|
|
1377
|
+
};
|
|
1378
|
+
}
|
|
1379
|
+
function maybeCommitNativeHookContextObservation(input, state, path, rootId, fingerprintContext, sourceEvent) {
|
|
1380
|
+
const measurement = extractTurnTelemetryV3(input.adapter, input.payload.raw, sourceEvent.time.observed_at).context;
|
|
1381
|
+
if (measurement.state !== "observed")
|
|
1382
|
+
return;
|
|
1383
|
+
commitActiveContextObservation(input, state, path, rootId, fingerprintContext, sourceEvent, measurement, nativeContextProvenance(input, state, measurement));
|
|
1384
|
+
}
|
|
1225
1385
|
function maybeAttestContextCapabilityChange(input, state, path, rootId, measurement, provenance) {
|
|
1226
1386
|
const context = measurement.state === "observed"
|
|
1227
1387
|
? {
|
|
@@ -1229,6 +1389,11 @@ function maybeAttestContextCapabilityChange(input, state, path, rootId, measurem
|
|
|
1229
1389
|
source: provenance?.source_event ?? `${input.adapter}.turn_context`,
|
|
1230
1390
|
attestation: provenance?.attestation ?? measurement.attestation,
|
|
1231
1391
|
confidence: provenance?.confidence ?? measurement.confidence,
|
|
1392
|
+
completeness: "used_percent" in measurement.value
|
|
1393
|
+
? "percentage_only"
|
|
1394
|
+
: (provenance?.attestation ?? measurement.attestation) === "inferred"
|
|
1395
|
+
? "inferred"
|
|
1396
|
+
: "exact",
|
|
1232
1397
|
}
|
|
1233
1398
|
: measurement.state === "expected_but_missing"
|
|
1234
1399
|
? { state: "partial", reason: measurement.reason }
|
|
@@ -1268,7 +1433,7 @@ function turnContextTarget(turnTerminal) {
|
|
|
1268
1433
|
...(scope.workflow_agent_id ? { workflow_agent_id: scope.workflow_agent_id } : {}),
|
|
1269
1434
|
};
|
|
1270
1435
|
}
|
|
1271
|
-
function queuePendingRuntimeContext(input, state, target, measurement) {
|
|
1436
|
+
function queuePendingRuntimeContext(input, state, target, measurement, nativeTurnId) {
|
|
1272
1437
|
if (input.adapter !== "codex" ||
|
|
1273
1438
|
!target ||
|
|
1274
1439
|
measurement.state !== "expected_but_missing" ||
|
|
@@ -1276,7 +1441,6 @@ function queuePendingRuntimeContext(input, state, target, measurement) {
|
|
|
1276
1441
|
return;
|
|
1277
1442
|
}
|
|
1278
1443
|
const nativeSessionId = input.payload.session_id ?? input.payload.conversation_id;
|
|
1279
|
-
const nativeTurnId = input.payload.turn_id;
|
|
1280
1444
|
if (!nativeSessionId || !nativeTurnId)
|
|
1281
1445
|
return;
|
|
1282
1446
|
const pending = {
|
|
@@ -1376,17 +1540,37 @@ function retryableRuntimeContextReason(reason) {
|
|
|
1376
1540
|
}
|
|
1377
1541
|
function turnTelemetryForTerminal(input, state, observedAt) {
|
|
1378
1542
|
const native = extractTurnTelemetryV3(input.adapter, input.payload.raw, observedAt);
|
|
1379
|
-
if (native.context.state === "observed"
|
|
1543
|
+
if (native.context.state === "observed")
|
|
1380
1544
|
return native;
|
|
1381
|
-
|
|
1545
|
+
if (input.adapter === "cursor" && state.cursor_mode === "cloud") {
|
|
1546
|
+
return {
|
|
1547
|
+
...native,
|
|
1548
|
+
context: { state: "unsupported", capability: "context_usage" },
|
|
1549
|
+
};
|
|
1550
|
+
}
|
|
1551
|
+
const request = {
|
|
1382
1552
|
adapter: input.adapter,
|
|
1383
1553
|
session_id: input.payload.session_id ?? input.payload.conversation_id,
|
|
1384
1554
|
turn_id: input.payload.turn_id ?? state.current_native_turn_id,
|
|
1385
1555
|
transcript_path: runtimeTranscriptPath(input, state),
|
|
1556
|
+
observed_at: observedAt,
|
|
1386
1557
|
mode: "turn",
|
|
1387
|
-
}
|
|
1558
|
+
};
|
|
1559
|
+
let runtime = readRuntimeContextTelemetry(request, input.runtimeTelemetryOptions);
|
|
1388
1560
|
if (runtime.bytes_read > 0)
|
|
1389
1561
|
recordRuntimeTelemetryTiming(state, runtime.io_duration_ms);
|
|
1562
|
+
if (input.adapter === "codex" &&
|
|
1563
|
+
runtime.state === "partial" &&
|
|
1564
|
+
retryableRuntimeContextReason(runtime.reason)) {
|
|
1565
|
+
for (const delayMs of STOP_RUNTIME_CONTEXT_RETRY_DELAYS_MS) {
|
|
1566
|
+
sleepSync(delayMs);
|
|
1567
|
+
runtime = readRuntimeContextTelemetry(request, input.runtimeTelemetryOptions);
|
|
1568
|
+
if (runtime.bytes_read > 0)
|
|
1569
|
+
recordRuntimeTelemetryTiming(state, runtime.io_duration_ms);
|
|
1570
|
+
if (runtime.state !== "partial" || !retryableRuntimeContextReason(runtime.reason))
|
|
1571
|
+
break;
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1390
1574
|
if (runtime.state === "unsupported")
|
|
1391
1575
|
return native;
|
|
1392
1576
|
return {
|
|
@@ -1396,8 +1580,8 @@ function turnTelemetryForTerminal(input, state, observedAt) {
|
|
|
1396
1580
|
source_event: runtime.state === "observed" ? runtime.source_event : `${input.adapter}.runtime_context`,
|
|
1397
1581
|
...(runtime.state === "observed" ? { source_witness: runtime.source_witness } : {}),
|
|
1398
1582
|
...(input.adapterVersion ? { runtime_version: input.adapterVersion } : {}),
|
|
1399
|
-
attestation: "derived",
|
|
1400
|
-
confidence: runtime.state === "observed" ?
|
|
1583
|
+
attestation: runtime.state === "observed" ? runtime.attestation : "derived",
|
|
1584
|
+
confidence: runtime.state === "observed" ? runtime.confidence : "high",
|
|
1401
1585
|
},
|
|
1402
1586
|
};
|
|
1403
1587
|
}
|
|
@@ -1433,6 +1617,19 @@ function runtimeTranscriptPath(input, state) {
|
|
|
1433
1617
|
}
|
|
1434
1618
|
function runtimeContextObservation(runtime) {
|
|
1435
1619
|
if (runtime.state === "observed") {
|
|
1620
|
+
if ("used_percent" in runtime) {
|
|
1621
|
+
return {
|
|
1622
|
+
state: "observed",
|
|
1623
|
+
value: {
|
|
1624
|
+
used_percent: runtime.used_percent,
|
|
1625
|
+
remaining_percent: Math.max(0, 100 - runtime.used_percent),
|
|
1626
|
+
measured_at: runtime.measured_at,
|
|
1627
|
+
method: runtime.method,
|
|
1628
|
+
},
|
|
1629
|
+
attestation: runtime.attestation,
|
|
1630
|
+
confidence: runtime.confidence,
|
|
1631
|
+
};
|
|
1632
|
+
}
|
|
1436
1633
|
return {
|
|
1437
1634
|
state: "observed",
|
|
1438
1635
|
value: {
|
|
@@ -1442,8 +1639,8 @@ function runtimeContextObservation(runtime) {
|
|
|
1442
1639
|
measured_at: runtime.measured_at,
|
|
1443
1640
|
method: runtime.method,
|
|
1444
1641
|
},
|
|
1445
|
-
attestation:
|
|
1446
|
-
confidence:
|
|
1642
|
+
attestation: runtime.attestation,
|
|
1643
|
+
confidence: runtime.confidence,
|
|
1447
1644
|
};
|
|
1448
1645
|
}
|
|
1449
1646
|
return {
|
|
@@ -1888,6 +2085,34 @@ function isCursorPromptBootstrap(input) {
|
|
|
1888
2085
|
(input.payload.conversation_id !== undefined || input.payload.session_id !== undefined) &&
|
|
1889
2086
|
input.payload.turn_id !== undefined);
|
|
1890
2087
|
}
|
|
2088
|
+
/** Privacy-safe environment and recovery provenance for Codex mid-flight
|
|
2089
|
+
* onboarding. WSLENV values are never recorded, only normalized variable
|
|
2090
|
+
* names, and the native session identifier itself remains fingerprinted. */
|
|
2091
|
+
export function codexMidFlightDiagnosticContext(payload, env = process.env) {
|
|
2092
|
+
const wslenv = env.WSLENV?.trim() ?? "";
|
|
2093
|
+
const wslenvNames = [
|
|
2094
|
+
...new Set(wslenv
|
|
2095
|
+
.split(":")
|
|
2096
|
+
.map((entry) => entry.split("/", 1)[0]?.trim() ?? "")
|
|
2097
|
+
.filter((name) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(name))),
|
|
2098
|
+
]
|
|
2099
|
+
.sort()
|
|
2100
|
+
.join(":")
|
|
2101
|
+
.slice(0, 512);
|
|
2102
|
+
const identityRecoverySource = payload.session_id
|
|
2103
|
+
? "native_session_id"
|
|
2104
|
+
: payload.conversation_id
|
|
2105
|
+
? "native_conversation_id"
|
|
2106
|
+
: payload.agent_id
|
|
2107
|
+
? "native_agent_id"
|
|
2108
|
+
: "unavailable";
|
|
2109
|
+
return {
|
|
2110
|
+
thread_id_present: Boolean(env.CODEX_THREAD_ID?.trim()),
|
|
2111
|
+
wslenv_present: wslenv.length > 0,
|
|
2112
|
+
wslenv_names: wslenvNames,
|
|
2113
|
+
identity_recovery_source: identityRecoverySource,
|
|
2114
|
+
};
|
|
2115
|
+
}
|
|
1891
2116
|
function suppressClosedSpanSignal(input, sessionHash, category) {
|
|
1892
2117
|
writeProducerDiagnosticV3(input.coordRoot, category, {
|
|
1893
2118
|
adapter: input.adapter,
|
|
@@ -1909,6 +2134,13 @@ export function recordApprovedSessionEndV3(input) {
|
|
|
1909
2134
|
if (control.state !== input.mode) {
|
|
1910
2135
|
return { state: "gate_closed", reason: control.state };
|
|
1911
2136
|
}
|
|
2137
|
+
input = {
|
|
2138
|
+
...input,
|
|
2139
|
+
writerOptions: {
|
|
2140
|
+
...input.writerOptions,
|
|
2141
|
+
expectedGenesisId: control.genesis.event.payload.genesis_id,
|
|
2142
|
+
},
|
|
2143
|
+
};
|
|
1912
2144
|
const matches = listHookProducerStateRecordsV3(input.coordRoot, { includeTerminal: true }).filter(({ state }) => state.instance_id === input.instance_id && state.generation_id === input.generation_id);
|
|
1913
2145
|
if (matches.length !== 1) {
|
|
1914
2146
|
return {
|
|
@@ -2035,6 +2267,13 @@ export function salvageOpenSpansV3(input) {
|
|
|
2035
2267
|
if (control.state !== input.mode) {
|
|
2036
2268
|
return { state: "gate_closed", reason: control.state };
|
|
2037
2269
|
}
|
|
2270
|
+
input = {
|
|
2271
|
+
...input,
|
|
2272
|
+
writerOptions: {
|
|
2273
|
+
...input.writerOptions,
|
|
2274
|
+
expectedGenesisId: control.genesis.event.payload.genesis_id,
|
|
2275
|
+
},
|
|
2276
|
+
};
|
|
2038
2277
|
const matches = listHookProducerStateRecordsV3(input.coordRoot).filter(({ state }) => state.instance_id === input.instance_id && state.generation_id === input.generation_id);
|
|
2039
2278
|
if (matches.length !== 1) {
|
|
2040
2279
|
return {
|
|
@@ -2121,6 +2360,10 @@ export function listHookProducerStateRecordsV3(coordRoot, options = {}) {
|
|
|
2121
2360
|
for (const name of readdirSync(directory).filter((entry) => /^hid_[a-f0-9]{64}\.json$/.test(entry))) {
|
|
2122
2361
|
const path = join(directory, name);
|
|
2123
2362
|
const state = readProducerState(path);
|
|
2363
|
+
// Skip authorities left behind by a replaced epoch: their sequences and
|
|
2364
|
+
// causal links belong to the archived ledger, not this one.
|
|
2365
|
+
if (state.epoch_genesis_id !== control.genesis.event.payload.genesis_id)
|
|
2366
|
+
continue;
|
|
2124
2367
|
if (!options.includeTerminal && state.terminal)
|
|
2125
2368
|
continue;
|
|
2126
2369
|
records.push({ path, modified_at_ms: lstatSync(path).mtimeMs, state });
|
|
@@ -2165,7 +2408,66 @@ export function readHookProducerStateV3(coordRoot, adapter, nativeSessionId) {
|
|
|
2165
2408
|
const context = fingerprintContextV3(coordRoot, rootId, undefined, control.genesis.profile.privacy_key_epoch);
|
|
2166
2409
|
const sessionHash = normalizeNativeIdV3(context, `${adapter}.session`, nativeSessionId);
|
|
2167
2410
|
const path = producerStatePath(coordRoot, adapter, sessionHash);
|
|
2168
|
-
|
|
2411
|
+
if (!existsSync(path))
|
|
2412
|
+
return undefined;
|
|
2413
|
+
const state = readProducerState(path);
|
|
2414
|
+
// A state left behind by a replaced epoch is not this epoch's authority.
|
|
2415
|
+
return state.epoch_genesis_id === control.genesis.event.payload.genesis_id ? state : undefined;
|
|
2416
|
+
}
|
|
2417
|
+
/**
|
|
2418
|
+
* Retry one Codex session's owner-only context join without replaying its Stop
|
|
2419
|
+
* signal. Codex appends `task_complete` only after the synchronous Stop hook
|
|
2420
|
+
* exits, so this is invoked by a bounded detached worker after that exit.
|
|
2421
|
+
*/
|
|
2422
|
+
export function reconcilePendingRuntimeContextV3(input) {
|
|
2423
|
+
const control = readEventV3ControlState(input.coordRoot);
|
|
2424
|
+
if (control.state !== input.mode)
|
|
2425
|
+
return { state: "gate_closed" };
|
|
2426
|
+
if (control.state !== "candidate" && control.state !== "active") {
|
|
2427
|
+
return { state: "gate_closed" };
|
|
2428
|
+
}
|
|
2429
|
+
const rootId = control.genesis.event.scope.root_id;
|
|
2430
|
+
const rootContext = fingerprintContextV3(input.coordRoot, rootId, undefined, control.genesis.profile.privacy_key_epoch);
|
|
2431
|
+
const sessionHash = normalizeNativeIdV3(rootContext, "codex.session", input.nativeSessionId);
|
|
2432
|
+
const path = producerStatePath(input.coordRoot, "codex", sessionHash);
|
|
2433
|
+
if (!existsSync(path))
|
|
2434
|
+
return { state: "missing" };
|
|
2435
|
+
const lease = acquireStateLeaseWithRetry(input.coordRoot, path, STATE_LEASE_RETRY_ATTEMPTS);
|
|
2436
|
+
if (!lease)
|
|
2437
|
+
return { state: "busy" };
|
|
2438
|
+
try {
|
|
2439
|
+
const state = readProducerState(path);
|
|
2440
|
+
if (state.epoch_genesis_id !== control.genesis.event.payload.genesis_id) {
|
|
2441
|
+
// The pending contexts belong to a replaced epoch; its archive already
|
|
2442
|
+
// holds everything this producer durably recorded.
|
|
2443
|
+
return { state: "missing" };
|
|
2444
|
+
}
|
|
2445
|
+
if (state.adapter !== "codex" || !state.pending_runtime_contexts?.length) {
|
|
2446
|
+
return { state: "not_pending" };
|
|
2447
|
+
}
|
|
2448
|
+
const context = fingerprintContextV3(input.coordRoot, rootId, state.generation_id, state.privacy_epoch_id);
|
|
2449
|
+
reconcilePendingRuntimeContexts({
|
|
2450
|
+
coordRoot: input.coordRoot,
|
|
2451
|
+
mode: input.mode,
|
|
2452
|
+
signal: "stop",
|
|
2453
|
+
payload: { raw: {}, session_id: input.nativeSessionId },
|
|
2454
|
+
adapter: "codex",
|
|
2455
|
+
instance_id: state.instance_id,
|
|
2456
|
+
producer_id: input.producer_id,
|
|
2457
|
+
build_id: input.build_id,
|
|
2458
|
+
platform: input.platform,
|
|
2459
|
+
observed_at: new Date().toISOString(),
|
|
2460
|
+
runtimeTelemetryOptions: input.runtimeTelemetryOptions,
|
|
2461
|
+
writerOptions: {
|
|
2462
|
+
...input.writerOptions,
|
|
2463
|
+
expectedGenesisId: control.genesis.event.payload.genesis_id,
|
|
2464
|
+
},
|
|
2465
|
+
}, state, path, rootId, context, { deferRetryLimit: true, finalAttempt: input.finalAttempt });
|
|
2466
|
+
return state.pending_runtime_contexts?.length ? { state: "pending" } : { state: "settled" };
|
|
2467
|
+
}
|
|
2468
|
+
finally {
|
|
2469
|
+
lease.release();
|
|
2470
|
+
}
|
|
2169
2471
|
}
|
|
2170
2472
|
/** Resolve one terminal producer only when native session and instance identity agree. */
|
|
2171
2473
|
export function readTerminalHookProducerStateV3(coordRoot, nativeSessionId, instanceId) {
|
|
@@ -2192,6 +2494,8 @@ export function readHookProducerStateByInstanceV3(coordRoot, instanceId) {
|
|
|
2192
2494
|
}
|
|
2193
2495
|
for (const name of readdirSync(directory).filter((entry) => /^hid_[a-f0-9]{64}\.json$/.test(entry))) {
|
|
2194
2496
|
const state = readProducerState(join(directory, name));
|
|
2497
|
+
if (state.epoch_genesis_id !== control.genesis.event.payload.genesis_id)
|
|
2498
|
+
continue;
|
|
2195
2499
|
if (state.instance_id === instanceId && !state.terminal)
|
|
2196
2500
|
matches.push(state);
|
|
2197
2501
|
}
|
|
@@ -2213,7 +2517,7 @@ export function readJoinableHookProducerStateV3(coordRoot, adapter, nativeSessio
|
|
|
2213
2517
|
const byInstance = readHookProducerStateByInstanceV3(coordRoot, instanceId);
|
|
2214
2518
|
return byInstance?.adapter === adapter && !byInstance.terminal ? byInstance : undefined;
|
|
2215
2519
|
}
|
|
2216
|
-
function newProducerState(input, sessionId, epochId, boundaryEventId) {
|
|
2520
|
+
function newProducerState(input, sessionId, epochId, boundaryEventId, genesisId) {
|
|
2217
2521
|
const bootId = `boot_${randomUUID()}`;
|
|
2218
2522
|
return {
|
|
2219
2523
|
format: STATE_FORMAT,
|
|
@@ -2226,6 +2530,7 @@ function newProducerState(input, sessionId, epochId, boundaryEventId) {
|
|
|
2226
2530
|
capability_profile: adapterCapabilityProfileDigestV3(input.adapter),
|
|
2227
2531
|
cursor_mode: input.adapter === "cursor" ? (input.payload.cursor_mode ?? "unknown") : undefined,
|
|
2228
2532
|
privacy_epoch_id: epochId,
|
|
2533
|
+
epoch_genesis_id: genesisId,
|
|
2229
2534
|
boot_id: bootId,
|
|
2230
2535
|
clock_id: clockIdV3(),
|
|
2231
2536
|
next_sequence: 1,
|
|
@@ -2236,6 +2541,7 @@ function newProducerState(input, sessionId, epochId, boundaryEventId) {
|
|
|
2236
2541
|
boot_id: bootId,
|
|
2237
2542
|
clock: signalClock(input),
|
|
2238
2543
|
}),
|
|
2544
|
+
session_start_derivation: input.session_start_derivation,
|
|
2239
2545
|
terminal: false,
|
|
2240
2546
|
spans: [],
|
|
2241
2547
|
delegations: [],
|
|
@@ -2267,6 +2573,7 @@ function applyCommittedEvent(state, event) {
|
|
|
2267
2573
|
if (event.event_type === "turn.started") {
|
|
2268
2574
|
const nextTurnId = event.scope.turn_id;
|
|
2269
2575
|
state.current_turn_id = nextTurnId;
|
|
2576
|
+
state.session_start_derivation = undefined;
|
|
2270
2577
|
if (state.tool_call_count_turn_id !== nextTurnId) {
|
|
2271
2578
|
state.tool_call_count = 0;
|
|
2272
2579
|
state.tool_call_count_turn_id = nextTurnId;
|
|
@@ -2581,6 +2888,7 @@ function readProducerState(path) {
|
|
|
2581
2888
|
if (state.adapter === "cursor")
|
|
2582
2889
|
state.cursor_mode ??= "unknown";
|
|
2583
2890
|
const allowedKeys = new Set([
|
|
2891
|
+
"active_runtime_context_probe",
|
|
2584
2892
|
"adapter",
|
|
2585
2893
|
"attestation_id",
|
|
2586
2894
|
"boot_id",
|
|
@@ -2593,6 +2901,7 @@ function readProducerState(path) {
|
|
|
2593
2901
|
"current_turn_span",
|
|
2594
2902
|
"cursor_mode",
|
|
2595
2903
|
"delegations",
|
|
2904
|
+
"epoch_genesis_id",
|
|
2596
2905
|
"format",
|
|
2597
2906
|
"format_version",
|
|
2598
2907
|
"generation_id",
|
|
@@ -2602,6 +2911,7 @@ function readProducerState(path) {
|
|
|
2602
2911
|
"last_attested_telemetry",
|
|
2603
2912
|
"last_attested_tuning",
|
|
2604
2913
|
"last_attested_tuning_observation",
|
|
2914
|
+
"last_context_source_witness",
|
|
2605
2915
|
"tuning_probe_turn_id",
|
|
2606
2916
|
"last_event_id",
|
|
2607
2917
|
"last_monotonic_ns",
|
|
@@ -2612,6 +2922,7 @@ function readProducerState(path) {
|
|
|
2612
2922
|
"runtime_transcript_path",
|
|
2613
2923
|
"privacy_epoch_id",
|
|
2614
2924
|
"session_id",
|
|
2925
|
+
"session_start_derivation",
|
|
2615
2926
|
"session_span",
|
|
2616
2927
|
"spans",
|
|
2617
2928
|
"started_event_id",
|
|
@@ -2634,6 +2945,7 @@ function readProducerState(path) {
|
|
|
2634
2945
|
!/^att_[0-9a-f-]{36}$/.test(state.attestation_id) ||
|
|
2635
2946
|
!/^cap_[a-f0-9]{64}$/.test(state.capability_profile) ||
|
|
2636
2947
|
!/^pep_[a-zA-Z0-9._-]+$/.test(state.privacy_epoch_id) ||
|
|
2948
|
+
(state.epoch_genesis_id !== undefined && !/^gex_[0-9a-f-]{36}$/.test(state.epoch_genesis_id)) ||
|
|
2637
2949
|
!/^boot_[a-zA-Z0-9._-]+$/.test(state.boot_id) ||
|
|
2638
2950
|
!/^clk_[0-9a-f-]{36}$/.test(state.clock_id) ||
|
|
2639
2951
|
!Number.isSafeInteger(state.next_sequence) ||
|
|
@@ -2697,11 +3009,18 @@ function readProducerState(path) {
|
|
|
2697
3009
|
(state.last_observed_at !== undefined &&
|
|
2698
3010
|
!Number.isFinite(Date.parse(state.last_observed_at))) ||
|
|
2699
3011
|
(state.started_event_id !== undefined && !/^evt_[0-9a-f-]{36}$/.test(state.started_event_id)) ||
|
|
3012
|
+
(state.session_start_derivation !== undefined &&
|
|
3013
|
+
state.session_start_derivation !== "approved_lifecycle_reopen" &&
|
|
3014
|
+
state.session_start_derivation !== "validated_current_session_heal") ||
|
|
2700
3015
|
(state.pending_runtime_contexts !== undefined &&
|
|
2701
3016
|
(!Array.isArray(state.pending_runtime_contexts) ||
|
|
2702
3017
|
state.pending_runtime_contexts.length === 0 ||
|
|
2703
3018
|
state.pending_runtime_contexts.length > PENDING_RUNTIME_CONTEXT_CAP ||
|
|
2704
3019
|
state.pending_runtime_contexts.some((pending) => !validPendingRuntimeContext(pending)))) ||
|
|
3020
|
+
(state.active_runtime_context_probe !== undefined &&
|
|
3021
|
+
!validActiveRuntimeContextProbe(state.active_runtime_context_probe)) ||
|
|
3022
|
+
(state.last_context_source_witness !== undefined &&
|
|
3023
|
+
!/^[a-f0-9]{64}$/.test(state.last_context_source_witness)) ||
|
|
2705
3024
|
(state.runtime_transcript_path !== undefined &&
|
|
2706
3025
|
(typeof state.runtime_transcript_path !== "string" ||
|
|
2707
3026
|
state.runtime_transcript_path.length === 0 ||
|
|
@@ -2799,6 +3118,16 @@ function validPendingRuntimeContext(value) {
|
|
|
2799
3118
|
pending.attempts >= 0 &&
|
|
2800
3119
|
pending.attempts < RUNTIME_CONTEXT_RETRY_LIMIT);
|
|
2801
3120
|
}
|
|
3121
|
+
function validActiveRuntimeContextProbe(value) {
|
|
3122
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
3123
|
+
return false;
|
|
3124
|
+
const probe = value;
|
|
3125
|
+
return (typeof probe.turn_id === "string" &&
|
|
3126
|
+
/^tid_[a-f0-9]{64}$/.test(probe.turn_id) &&
|
|
3127
|
+
typeof probe.attempted_at === "string" &&
|
|
3128
|
+
Number.isFinite(Date.parse(probe.attempted_at)) &&
|
|
3129
|
+
(probe.boundary === undefined || probe.boundary === "tool_completed"));
|
|
3130
|
+
}
|
|
2802
3131
|
function pidIsAlive(pid) {
|
|
2803
3132
|
if (!Number.isSafeInteger(pid) || pid < 1)
|
|
2804
3133
|
return false;
|