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
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import {
|
|
3
|
+
chmodSync,
|
|
4
|
+
closeSync,
|
|
5
|
+
existsSync,
|
|
6
|
+
fsyncSync,
|
|
7
|
+
openSync,
|
|
8
|
+
readFileSync,
|
|
9
|
+
renameSync,
|
|
10
|
+
unlinkSync,
|
|
11
|
+
writeFileSync,
|
|
12
|
+
} from "node:fs";
|
|
13
|
+
import { fsyncParentDirectory } from "../../workflow/durable-record.ts";
|
|
14
|
+
import { canonicalJsonV3, type FingerprintV3, fingerprintV3, sha256V3 } from "./canonical.ts";
|
|
15
|
+
import type { ActivationManifestV3, CandidateGenesisManifestV3 } from "./control.ts";
|
|
16
|
+
import { fingerprintContextV3 } from "./fingerprint-keys.ts";
|
|
17
|
+
import {
|
|
18
|
+
advanceEventV3AppendValidationCheckpointV3,
|
|
19
|
+
EVENT_V3_CONTROL_CHECKPOINT_RELATIVE_PATH,
|
|
20
|
+
EVENT_V3_CONTROL_WITNESS_RELATIVE_PATH,
|
|
21
|
+
type EventV3AppendValidationCheckpointV3,
|
|
22
|
+
type EventV3AuthorityStorageVersionV3,
|
|
23
|
+
eventV3AuthorityStorageVersionV3,
|
|
24
|
+
eventV3ControlCheckpointPathV3,
|
|
25
|
+
eventV3ControlWitnessPathV3,
|
|
26
|
+
parseEventV3AppendValidationCheckpointV3,
|
|
27
|
+
} from "./reader.ts";
|
|
28
|
+
|
|
29
|
+
export { EVENT_V3_CONTROL_CHECKPOINT_RELATIVE_PATH, EVENT_V3_CONTROL_WITNESS_RELATIVE_PATH };
|
|
30
|
+
|
|
31
|
+
interface EventV3ControlWitnessPayload {
|
|
32
|
+
format: "harnery-event-v3-control-witness";
|
|
33
|
+
format_version: 1;
|
|
34
|
+
genesis_id: `gex_${string}`;
|
|
35
|
+
activation_id: `act_${string}`;
|
|
36
|
+
genesis_event_id: `evt_${string}`;
|
|
37
|
+
activation_event_id: `evt_${string}`;
|
|
38
|
+
genesis_manifest_digest: `sha256:${string}`;
|
|
39
|
+
activation_manifest_digest: `sha256:${string}`;
|
|
40
|
+
candidate_manifest_digest: `sha256:${string}`;
|
|
41
|
+
privacy_key_epoch: `pep_${string}`;
|
|
42
|
+
root_id: `root_${string}`;
|
|
43
|
+
storage: EventV3AuthorityStorageVersionV3;
|
|
44
|
+
checkpoint_digest: `sha256:${string}`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface EventV3ControlWitness {
|
|
48
|
+
payload: EventV3ControlWitnessPayload;
|
|
49
|
+
authentication: FingerprintV3;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface ActiveControlWitnessBindingV3 {
|
|
53
|
+
genesis: CandidateGenesisManifestV3;
|
|
54
|
+
activation: ActivationManifestV3;
|
|
55
|
+
candidate_manifest_digest: `sha256:${string}`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** True only when one authenticated witness names this exact active control pair and storage. */
|
|
59
|
+
export function activeControlWitnessMatchesV3(
|
|
60
|
+
coordRoot: string,
|
|
61
|
+
binding: ActiveControlWitnessBindingV3,
|
|
62
|
+
): boolean {
|
|
63
|
+
try {
|
|
64
|
+
const before = eventV3AuthorityStorageVersionV3(coordRoot);
|
|
65
|
+
const witness = readAuthenticatedWitnessV3(coordRoot);
|
|
66
|
+
if (!witness) return false;
|
|
67
|
+
const expected = witnessPayloadV3(binding, before, witness.payload.checkpoint_digest);
|
|
68
|
+
if (canonicalJsonV3(witness.payload) !== canonicalJsonV3(expected)) return false;
|
|
69
|
+
const after = eventV3AuthorityStorageVersionV3(coordRoot);
|
|
70
|
+
return sameStorageVersion(before, after);
|
|
71
|
+
} catch {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Publish a witness only when the storage validated by the caller is still current.
|
|
78
|
+
* Failure is intentionally silent: the next read retains the canonical full-scan fallback.
|
|
79
|
+
*/
|
|
80
|
+
export function publishActiveControlWitnessV3(
|
|
81
|
+
coordRoot: string,
|
|
82
|
+
binding: ActiveControlWitnessBindingV3,
|
|
83
|
+
validatedStorage: EventV3AuthorityStorageVersionV3,
|
|
84
|
+
checkpoint: EventV3AppendValidationCheckpointV3,
|
|
85
|
+
): boolean {
|
|
86
|
+
try {
|
|
87
|
+
const current = eventV3AuthorityStorageVersionV3(coordRoot);
|
|
88
|
+
if (!sameStorageVersion(validatedStorage, current)) return false;
|
|
89
|
+
return publishWitnessV3(
|
|
90
|
+
coordRoot,
|
|
91
|
+
witnessPayloadV3(binding, current, checkpointDigestV3(checkpoint)),
|
|
92
|
+
checkpoint,
|
|
93
|
+
);
|
|
94
|
+
} catch {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Capture a previously authenticated witness before the append lease mutates storage.
|
|
101
|
+
* The returned payload is safe to advance only while the caller continues to hold that lease.
|
|
102
|
+
*/
|
|
103
|
+
export function readAdvanceableControlWitnessV3(coordRoot: string):
|
|
104
|
+
| {
|
|
105
|
+
payload: EventV3ControlWitnessPayload;
|
|
106
|
+
checkpoint: EventV3AppendValidationCheckpointV3;
|
|
107
|
+
}
|
|
108
|
+
| undefined {
|
|
109
|
+
try {
|
|
110
|
+
const storage = eventV3AuthorityStorageVersionV3(coordRoot);
|
|
111
|
+
const witness = readAuthenticatedWitnessV3(coordRoot);
|
|
112
|
+
if (!witness || !sameStorageVersion(witness.payload.storage, storage)) return undefined;
|
|
113
|
+
const checkpoint = readAuthenticatedCheckpointV3(coordRoot, witness.payload.checkpoint_digest);
|
|
114
|
+
return checkpoint && checkpoint.validated_active_bytes === storage.active_bytes
|
|
115
|
+
? { payload: witness.payload, checkpoint }
|
|
116
|
+
: undefined;
|
|
117
|
+
} catch {
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Advance a lease-held witness after durable appends without changing writer success semantics. */
|
|
123
|
+
export function advanceControlWitnessV3(
|
|
124
|
+
coordRoot: string,
|
|
125
|
+
prior: {
|
|
126
|
+
payload: EventV3ControlWitnessPayload;
|
|
127
|
+
checkpoint: EventV3AppendValidationCheckpointV3;
|
|
128
|
+
},
|
|
129
|
+
currentGenesisId: string | undefined,
|
|
130
|
+
): boolean {
|
|
131
|
+
try {
|
|
132
|
+
if (currentGenesisId !== prior.payload.genesis_id) return false;
|
|
133
|
+
const storageBeforeValidation = eventV3AuthorityStorageVersionV3(coordRoot);
|
|
134
|
+
const checkpoint = advanceEventV3AppendValidationCheckpointV3(coordRoot, prior.checkpoint);
|
|
135
|
+
if (!checkpoint) return false;
|
|
136
|
+
const storage = eventV3AuthorityStorageVersionV3(coordRoot);
|
|
137
|
+
if (
|
|
138
|
+
storageBeforeValidation.fingerprint !== storage.fingerprint ||
|
|
139
|
+
prior.payload.storage.stable_fingerprint !== storage.stable_fingerprint ||
|
|
140
|
+
checkpoint.validated_active_bytes !== storage.active_bytes
|
|
141
|
+
) {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
return publishWitnessV3(
|
|
145
|
+
coordRoot,
|
|
146
|
+
{
|
|
147
|
+
...prior.payload,
|
|
148
|
+
storage,
|
|
149
|
+
checkpoint_digest: checkpointDigestV3(checkpoint),
|
|
150
|
+
},
|
|
151
|
+
checkpoint,
|
|
152
|
+
);
|
|
153
|
+
} catch {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function witnessPayloadV3(
|
|
159
|
+
binding: ActiveControlWitnessBindingV3,
|
|
160
|
+
storage: EventV3AuthorityStorageVersionV3,
|
|
161
|
+
checkpointDigest: `sha256:${string}`,
|
|
162
|
+
): EventV3ControlWitnessPayload {
|
|
163
|
+
const scope = binding.genesis.event.scope as { root_id: `root_${string}` };
|
|
164
|
+
return {
|
|
165
|
+
format: "harnery-event-v3-control-witness",
|
|
166
|
+
format_version: 1,
|
|
167
|
+
genesis_id: binding.genesis.event.payload.genesis_id as `gex_${string}`,
|
|
168
|
+
activation_id: binding.activation.activation_id,
|
|
169
|
+
genesis_event_id: binding.genesis.event.event_id as `evt_${string}`,
|
|
170
|
+
activation_event_id: binding.activation.event.event_id as `evt_${string}`,
|
|
171
|
+
genesis_manifest_digest: sha256V3(canonicalJsonV3(binding.genesis)),
|
|
172
|
+
activation_manifest_digest: sha256V3(canonicalJsonV3(binding.activation)),
|
|
173
|
+
candidate_manifest_digest: binding.candidate_manifest_digest,
|
|
174
|
+
privacy_key_epoch: binding.genesis.profile.privacy_key_epoch,
|
|
175
|
+
root_id: scope.root_id,
|
|
176
|
+
storage,
|
|
177
|
+
checkpoint_digest: checkpointDigest,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function readAuthenticatedWitnessV3(coordRoot: string): EventV3ControlWitness | undefined {
|
|
182
|
+
const path = eventV3ControlWitnessPathV3(coordRoot);
|
|
183
|
+
if (!existsSync(path)) return undefined;
|
|
184
|
+
const raw = readFileSync(path, "utf8");
|
|
185
|
+
const value: unknown = JSON.parse(raw);
|
|
186
|
+
const witness = parseWitnessV3(value);
|
|
187
|
+
if (`${canonicalJsonV3(witness)}\n` !== raw) return undefined;
|
|
188
|
+
const expected = authenticatePayloadV3(coordRoot, witness.payload);
|
|
189
|
+
return canonicalJsonV3(witness.authentication) === canonicalJsonV3(expected)
|
|
190
|
+
? witness
|
|
191
|
+
: undefined;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function publishWitnessV3(
|
|
195
|
+
coordRoot: string,
|
|
196
|
+
payload: EventV3ControlWitnessPayload,
|
|
197
|
+
checkpoint: EventV3AppendValidationCheckpointV3,
|
|
198
|
+
): boolean {
|
|
199
|
+
if (!publishCanonicalFileV3(eventV3ControlCheckpointPathV3(coordRoot), checkpoint)) return false;
|
|
200
|
+
const witness: EventV3ControlWitness = {
|
|
201
|
+
payload,
|
|
202
|
+
authentication: authenticatePayloadV3(coordRoot, payload),
|
|
203
|
+
};
|
|
204
|
+
return publishCanonicalFileV3(eventV3ControlWitnessPathV3(coordRoot), witness);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function publishCanonicalFileV3(path: string, value: unknown): boolean {
|
|
208
|
+
const temporary = `${path}.tmp-${process.pid}-${randomUUID()}`;
|
|
209
|
+
let fd: number | undefined;
|
|
210
|
+
try {
|
|
211
|
+
fd = openSync(temporary, "wx", 0o600);
|
|
212
|
+
writeFileSync(fd, `${canonicalJsonV3(value)}\n`, "utf8");
|
|
213
|
+
fsyncSync(fd);
|
|
214
|
+
closeSync(fd);
|
|
215
|
+
fd = undefined;
|
|
216
|
+
chmodSync(temporary, 0o600);
|
|
217
|
+
renameSync(temporary, path);
|
|
218
|
+
fsyncParentDirectory(path);
|
|
219
|
+
return true;
|
|
220
|
+
} finally {
|
|
221
|
+
if (fd !== undefined) closeSync(fd);
|
|
222
|
+
if (existsSync(temporary)) unlinkSync(temporary);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function readAuthenticatedCheckpointV3(
|
|
227
|
+
coordRoot: string,
|
|
228
|
+
expectedDigest: `sha256:${string}`,
|
|
229
|
+
): EventV3AppendValidationCheckpointV3 | undefined {
|
|
230
|
+
try {
|
|
231
|
+
const raw = readFileSync(eventV3ControlCheckpointPathV3(coordRoot), "utf8");
|
|
232
|
+
const value: unknown = JSON.parse(raw);
|
|
233
|
+
if (
|
|
234
|
+
`${canonicalJsonV3(value)}\n` !== raw ||
|
|
235
|
+
sha256V3(canonicalJsonV3(value)) !== expectedDigest
|
|
236
|
+
) {
|
|
237
|
+
return undefined;
|
|
238
|
+
}
|
|
239
|
+
return parseEventV3AppendValidationCheckpointV3(value);
|
|
240
|
+
} catch {
|
|
241
|
+
return undefined;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function checkpointDigestV3(checkpoint: EventV3AppendValidationCheckpointV3): `sha256:${string}` {
|
|
246
|
+
return sha256V3(canonicalJsonV3(checkpoint));
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function authenticatePayloadV3(
|
|
250
|
+
coordRoot: string,
|
|
251
|
+
payload: EventV3ControlWitnessPayload,
|
|
252
|
+
): FingerprintV3 {
|
|
253
|
+
const context = fingerprintContextV3(
|
|
254
|
+
coordRoot,
|
|
255
|
+
payload.root_id,
|
|
256
|
+
undefined,
|
|
257
|
+
payload.privacy_key_epoch,
|
|
258
|
+
);
|
|
259
|
+
return fingerprintV3(context, "control-state-witness", payload, "root");
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function parseWitnessV3(value: unknown): EventV3ControlWitness {
|
|
263
|
+
const envelope = object(value);
|
|
264
|
+
if (Object.keys(envelope).sort().join("\0") !== "authentication\0payload") {
|
|
265
|
+
throw new Error("control witness envelope is invalid");
|
|
266
|
+
}
|
|
267
|
+
const payload = object(envelope.payload);
|
|
268
|
+
const expectedPayloadKeys = [
|
|
269
|
+
"activation_event_id",
|
|
270
|
+
"activation_id",
|
|
271
|
+
"activation_manifest_digest",
|
|
272
|
+
"candidate_manifest_digest",
|
|
273
|
+
"checkpoint_digest",
|
|
274
|
+
"format",
|
|
275
|
+
"format_version",
|
|
276
|
+
"genesis_event_id",
|
|
277
|
+
"genesis_id",
|
|
278
|
+
"genesis_manifest_digest",
|
|
279
|
+
"privacy_key_epoch",
|
|
280
|
+
"root_id",
|
|
281
|
+
"storage",
|
|
282
|
+
];
|
|
283
|
+
if (Object.keys(payload).sort().join("\0") !== expectedPayloadKeys.sort().join("\0")) {
|
|
284
|
+
throw new Error("control witness payload shape is invalid");
|
|
285
|
+
}
|
|
286
|
+
const storage = object(payload.storage);
|
|
287
|
+
if (Object.keys(storage).sort().join("\0") !== "active_bytes\0fingerprint\0stable_fingerprint") {
|
|
288
|
+
throw new Error("control witness storage shape is invalid");
|
|
289
|
+
}
|
|
290
|
+
if (
|
|
291
|
+
payload.format !== "harnery-event-v3-control-witness" ||
|
|
292
|
+
payload.format_version !== 1 ||
|
|
293
|
+
!token(payload.genesis_id, "gex_") ||
|
|
294
|
+
!token(payload.activation_id, "act_") ||
|
|
295
|
+
!token(payload.genesis_event_id, "evt_") ||
|
|
296
|
+
!token(payload.activation_event_id, "evt_") ||
|
|
297
|
+
!digest(payload.genesis_manifest_digest) ||
|
|
298
|
+
!digest(payload.activation_manifest_digest) ||
|
|
299
|
+
!digest(payload.candidate_manifest_digest) ||
|
|
300
|
+
!digest(payload.checkpoint_digest) ||
|
|
301
|
+
!token(payload.privacy_key_epoch, "pep_") ||
|
|
302
|
+
!token(payload.root_id, "root_") ||
|
|
303
|
+
!digest(storage.fingerprint) ||
|
|
304
|
+
!digest(storage.stable_fingerprint) ||
|
|
305
|
+
!Number.isSafeInteger(storage.active_bytes) ||
|
|
306
|
+
(storage.active_bytes as number) < 0
|
|
307
|
+
) {
|
|
308
|
+
throw new Error("control witness payload is invalid");
|
|
309
|
+
}
|
|
310
|
+
const authentication = object(envelope.authentication);
|
|
311
|
+
return {
|
|
312
|
+
payload: payload as unknown as EventV3ControlWitnessPayload,
|
|
313
|
+
authentication: authentication as unknown as FingerprintV3,
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function object(value: unknown): Record<string, unknown> {
|
|
318
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
319
|
+
throw new Error("control witness value is not an object");
|
|
320
|
+
}
|
|
321
|
+
return value as Record<string, unknown>;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function token(value: unknown, prefix: string): value is string {
|
|
325
|
+
return (
|
|
326
|
+
typeof value === "string" && value.startsWith(prefix) && /^[a-zA-Z0-9._-]{1,160}$/.test(value)
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function digest(value: unknown): value is `sha256:${string}` {
|
|
331
|
+
return typeof value === "string" && /^sha256:[a-f0-9]{64}$/.test(value);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function sameStorageVersion(
|
|
335
|
+
left: EventV3AuthorityStorageVersionV3,
|
|
336
|
+
right: EventV3AuthorityStorageVersionV3,
|
|
337
|
+
): boolean {
|
|
338
|
+
return left.fingerprint === right.fingerprint && left.active_bytes === right.active_bytes;
|
|
339
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type EventV3ControlState, readEventV3ControlState } from "./control.ts";
|
|
2
|
+
import { writeEventV3 } from "./writer.ts";
|
|
3
|
+
|
|
4
|
+
/** Repair only a manifest-first crash by appending the exact pre-minted event. */
|
|
5
|
+
export function repairEventV3ControlPair(coordRoot: string): EventV3ControlState {
|
|
6
|
+
const control = readEventV3ControlState(coordRoot);
|
|
7
|
+
if (control.state !== "repairable") return control;
|
|
8
|
+
const event =
|
|
9
|
+
control.reason === "genesis_event_missing" ? control.genesis.event : control.activation?.event;
|
|
10
|
+
if (!event) return { state: "invalid", reason: "repair_event_unavailable" };
|
|
11
|
+
const result = writeEventV3(coordRoot, event);
|
|
12
|
+
if (result.state !== "committed") {
|
|
13
|
+
return { state: "invalid", reason: "control_event_repair_not_committed" };
|
|
14
|
+
}
|
|
15
|
+
return readEventV3ControlState(coordRoot);
|
|
16
|
+
}
|
|
@@ -3,11 +3,16 @@ import { join } from "node:path";
|
|
|
3
3
|
import { buildEventV3 } from "./builder.ts";
|
|
4
4
|
import { canonicalJsonV3, sha256V3 } from "./canonical.ts";
|
|
5
5
|
import type { EventV3 } from "./contract.ts";
|
|
6
|
+
import { activeControlWitnessMatchesV3, publishActiveControlWitnessV3 } from "./control-witness.ts";
|
|
6
7
|
import { EVENT_V3_SCHEMA_DIGEST } from "./generated.ts";
|
|
7
8
|
import { activationIdV3, eventIdV3, genesisIdV3 } from "./ids.ts";
|
|
8
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
eventV3AuthorityStorageVersionV3,
|
|
11
|
+
type ReadLedgerV3Result,
|
|
12
|
+
readEventV3AppendValidationCheckpointV3,
|
|
13
|
+
readLedgerV3,
|
|
14
|
+
} from "./reader.ts";
|
|
9
15
|
import { validateEventV3 } from "./validate.ts";
|
|
10
|
-
import { writeEventV3 } from "./writer.ts";
|
|
11
16
|
|
|
12
17
|
export const EVENT_V3_GENESIS_MANIFEST = ".harnery/ledgers/v3/genesis.json" as const;
|
|
13
18
|
export const EVENT_V3_ACTIVATION_MANIFEST = ".harnery/ledgers/v3/activation.json" as const;
|
|
@@ -210,6 +215,26 @@ export function validateActivationManifestV3(
|
|
|
210
215
|
* Resolve the session/evidence gate from exact control-file and ledger-event pairs.
|
|
211
216
|
* This function never repairs or creates state. Any ambiguity keeps the gate closed.
|
|
212
217
|
*/
|
|
218
|
+
/**
|
|
219
|
+
* The live epoch's genesis id from the immutable manifest, or undefined when
|
|
220
|
+
* no valid genesis is published. This is the cheap epoch-identity read the
|
|
221
|
+
* writer fence uses: one small canonical file, never the event history.
|
|
222
|
+
*/
|
|
223
|
+
export function liveGenesisIdV3(coordRoot: string): `gex_${string}` | undefined {
|
|
224
|
+
return genesisIdFromManifestV3(join(coordRoot, EVENT_V3_GENESIS_MANIFEST));
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** Same read for a caller that already holds the manifest path (the writer's drain). */
|
|
228
|
+
export function genesisIdFromManifestV3(genesisPath: string): `gex_${string}` | undefined {
|
|
229
|
+
if (!existsSync(genesisPath)) return undefined;
|
|
230
|
+
const genesis = readGenesisManifest(genesisPath);
|
|
231
|
+
if (!genesis.ok) return undefined;
|
|
232
|
+
const genesisId = genesis.value.event.payload.genesis_id;
|
|
233
|
+
return typeof genesisId === "string" && genesisId.startsWith("gex_")
|
|
234
|
+
? (genesisId as `gex_${string}`)
|
|
235
|
+
: undefined;
|
|
236
|
+
}
|
|
237
|
+
|
|
213
238
|
export function readEventV3ControlState(coordRoot: string): EventV3ControlState {
|
|
214
239
|
const genesisPath = join(coordRoot, EVENT_V3_GENESIS_MANIFEST);
|
|
215
240
|
const activationPath = join(coordRoot, EVENT_V3_ACTIVATION_MANIFEST);
|
|
@@ -232,6 +257,25 @@ export function readEventV3ControlState(coordRoot: string): EventV3ControlState
|
|
|
232
257
|
if (!genesisResult.ok) return { state: "invalid", reason: genesisResult.reason };
|
|
233
258
|
const genesis = genesisResult.value;
|
|
234
259
|
const candidateDigest = candidateManifestDigestV3(genesis);
|
|
260
|
+
const activationForWitness = hasActivation
|
|
261
|
+
? readActivationManifest(activationPath, genesis, candidateDigest)
|
|
262
|
+
: undefined;
|
|
263
|
+
if (
|
|
264
|
+
activationForWitness?.ok &&
|
|
265
|
+
activeControlWitnessMatchesV3(coordRoot, {
|
|
266
|
+
genesis,
|
|
267
|
+
activation: activationForWitness.value,
|
|
268
|
+
candidate_manifest_digest: candidateDigest,
|
|
269
|
+
})
|
|
270
|
+
) {
|
|
271
|
+
return {
|
|
272
|
+
state: "active",
|
|
273
|
+
genesis,
|
|
274
|
+
activation: activationForWitness.value,
|
|
275
|
+
candidate_manifest_digest: candidateDigest,
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
const storageBeforeValidation = eventV3AuthorityStorageVersionV3(coordRoot);
|
|
235
279
|
const ledger = readControlLedger(coordRoot);
|
|
236
280
|
if (!ledger.complete) {
|
|
237
281
|
return { state: "invalid", reason: "ledger_integrity_failure" };
|
|
@@ -253,7 +297,8 @@ export function readEventV3ControlState(coordRoot: string): EventV3ControlState
|
|
|
253
297
|
return { state: "candidate", genesis, candidate_manifest_digest: candidateDigest };
|
|
254
298
|
}
|
|
255
299
|
|
|
256
|
-
const activationResult =
|
|
300
|
+
const activationResult =
|
|
301
|
+
activationForWitness ?? readActivationManifest(activationPath, genesis, candidateDigest);
|
|
257
302
|
if (!activationResult.ok) return { state: "invalid", reason: activationResult.reason };
|
|
258
303
|
const activation = activationResult.value;
|
|
259
304
|
const activationPair = exactEventPair(
|
|
@@ -271,12 +316,17 @@ export function readEventV3ControlState(coordRoot: string): EventV3ControlState
|
|
|
271
316
|
activation,
|
|
272
317
|
};
|
|
273
318
|
}
|
|
274
|
-
|
|
319
|
+
const active: Extract<EventV3ControlState, { state: "active" }> = {
|
|
275
320
|
state: "active",
|
|
276
321
|
genesis,
|
|
277
322
|
activation,
|
|
278
323
|
candidate_manifest_digest: candidateDigest,
|
|
279
324
|
};
|
|
325
|
+
const checkpoint = readEventV3AppendValidationCheckpointV3(coordRoot);
|
|
326
|
+
if (checkpoint) {
|
|
327
|
+
publishActiveControlWitnessV3(coordRoot, active, storageBeforeValidation, checkpoint);
|
|
328
|
+
}
|
|
329
|
+
return active;
|
|
280
330
|
}
|
|
281
331
|
|
|
282
332
|
export function eventV3WriteGateOpen(coordRoot: string, mode: EventV3WriteMode): boolean {
|
|
@@ -284,20 +334,6 @@ export function eventV3WriteGateOpen(coordRoot: string, mode: EventV3WriteMode):
|
|
|
284
334
|
return mode === "candidate" ? control.state === "candidate" : control.state === "active";
|
|
285
335
|
}
|
|
286
336
|
|
|
287
|
-
/** Repair only a manifest-first crash by appending the exact pre-minted event. */
|
|
288
|
-
export function repairEventV3ControlPair(coordRoot: string): EventV3ControlState {
|
|
289
|
-
const control = readEventV3ControlState(coordRoot);
|
|
290
|
-
if (control.state !== "repairable") return control;
|
|
291
|
-
const event =
|
|
292
|
-
control.reason === "genesis_event_missing" ? control.genesis.event : control.activation?.event;
|
|
293
|
-
if (!event) return { state: "invalid", reason: "repair_event_unavailable" };
|
|
294
|
-
const result = writeEventV3(coordRoot, event);
|
|
295
|
-
if (result.state !== "committed") {
|
|
296
|
-
return { state: "invalid", reason: "control_event_repair_not_committed" };
|
|
297
|
-
}
|
|
298
|
-
return readEventV3ControlState(coordRoot);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
337
|
export function candidateProfileDigestV3(profile: CandidateProfileV3): `sha256:${string}` {
|
|
302
338
|
return sha256V3(canonicalJsonV3(profile));
|
|
303
339
|
}
|