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,555 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import {
|
|
3
|
+
closeSync,
|
|
4
|
+
existsSync,
|
|
5
|
+
constants as fsConstants,
|
|
6
|
+
lstatSync,
|
|
7
|
+
openSync,
|
|
8
|
+
readdirSync,
|
|
9
|
+
readFileSync,
|
|
10
|
+
realpathSync,
|
|
11
|
+
unlinkSync,
|
|
12
|
+
} from "node:fs";
|
|
13
|
+
import { basename, dirname, isAbsolute, join, relative } from "node:path";
|
|
14
|
+
import {
|
|
15
|
+
HARNERY_STRUCTURED_LOG_PROVIDER_ID,
|
|
16
|
+
type HarneryRegisteredStorageFamily,
|
|
17
|
+
} from "./contract.ts";
|
|
18
|
+
import type {
|
|
19
|
+
HarneryMaintenanceAction,
|
|
20
|
+
HarneryMaintenanceProvider,
|
|
21
|
+
HarneryMaintenanceProviderPlan,
|
|
22
|
+
} from "./maintenance.ts";
|
|
23
|
+
import {
|
|
24
|
+
familyLogDirectory,
|
|
25
|
+
logManifestFingerprint,
|
|
26
|
+
pruneSealedLogSegment,
|
|
27
|
+
readSegmentManifest,
|
|
28
|
+
withFamilyLease,
|
|
29
|
+
} from "./segments.ts";
|
|
30
|
+
|
|
31
|
+
export const STRUCTURED_LOG_RETENTION_SCOPE = "structured-log-retention" as const;
|
|
32
|
+
|
|
33
|
+
export interface StructuredLogRetentionSegment {
|
|
34
|
+
sequence: number;
|
|
35
|
+
file: string;
|
|
36
|
+
actual_bytes: number;
|
|
37
|
+
content_sha256: string;
|
|
38
|
+
sealed_at: string;
|
|
39
|
+
age_expired: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface StructuredLogRetentionSnapshot {
|
|
43
|
+
file: string;
|
|
44
|
+
actual_bytes: number;
|
|
45
|
+
recovery_breadcrumb: boolean;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface StructuredLogRetentionInspection {
|
|
49
|
+
family_id: string;
|
|
50
|
+
effective_policy: {
|
|
51
|
+
max_bytes: number;
|
|
52
|
+
max_age_ms: number;
|
|
53
|
+
fingerprint: string;
|
|
54
|
+
sources: { max_bytes: string; max_age_ms: string };
|
|
55
|
+
} | null;
|
|
56
|
+
usage: {
|
|
57
|
+
managed_bytes: number;
|
|
58
|
+
unmanaged_bytes: number;
|
|
59
|
+
total_bytes: number;
|
|
60
|
+
managed_files: number;
|
|
61
|
+
unmanaged_files: number;
|
|
62
|
+
};
|
|
63
|
+
pressure: {
|
|
64
|
+
state: "within_budget" | "over_budget" | "unknown";
|
|
65
|
+
ratio: number | null;
|
|
66
|
+
bytes_over: number | null;
|
|
67
|
+
reason_codes: string[];
|
|
68
|
+
};
|
|
69
|
+
retention: {
|
|
70
|
+
state: "active" | "blocked" | "unmanaged";
|
|
71
|
+
enforcement: "manual" | "none";
|
|
72
|
+
reason_codes: string[];
|
|
73
|
+
};
|
|
74
|
+
sealed_segments: StructuredLogRetentionSegment[];
|
|
75
|
+
obsolete_snapshots: StructuredLogRetentionSnapshot[];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
interface MutableUsage {
|
|
79
|
+
managed_bytes: number;
|
|
80
|
+
unmanaged_bytes: number;
|
|
81
|
+
managed_files: number;
|
|
82
|
+
unmanaged_files: number;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Read-only, non-creating inspection for command and maintenance callers. */
|
|
86
|
+
export function inspectStructuredLogRetention(
|
|
87
|
+
family: HarneryRegisteredStorageFamily,
|
|
88
|
+
now = new Date(),
|
|
89
|
+
): StructuredLogRetentionInspection {
|
|
90
|
+
const usage: MutableUsage = {
|
|
91
|
+
managed_bytes: 0,
|
|
92
|
+
unmanaged_bytes: 0,
|
|
93
|
+
managed_files: 0,
|
|
94
|
+
unmanaged_files: 0,
|
|
95
|
+
};
|
|
96
|
+
const reasons = new Set<string>();
|
|
97
|
+
const effective = family.effective_log_retention;
|
|
98
|
+
const policy =
|
|
99
|
+
effective?.state === "valid"
|
|
100
|
+
? {
|
|
101
|
+
max_bytes: effective.max_bytes,
|
|
102
|
+
max_age_ms: effective.max_age_ms,
|
|
103
|
+
fingerprint: effective.effective_policy_fingerprint,
|
|
104
|
+
sources: {
|
|
105
|
+
max_bytes: effective.provenance.max_bytes.source,
|
|
106
|
+
max_age_ms: effective.provenance.max_age_days.source,
|
|
107
|
+
},
|
|
108
|
+
}
|
|
109
|
+
: null;
|
|
110
|
+
if (!structuredSegmentCapable(family)) {
|
|
111
|
+
return result(family.id, policy, usage, "unmanaged", "none", ["unsupported_log_family"]);
|
|
112
|
+
}
|
|
113
|
+
if (!policy) {
|
|
114
|
+
return result(family.id, null, usage, "blocked", "none", ["effective_policy_invalid"]);
|
|
115
|
+
}
|
|
116
|
+
const directory = familyLogDirectory(family);
|
|
117
|
+
if (!existsSync(directory)) {
|
|
118
|
+
return result(family.id, policy, usage, "active", "manual", ["root_dormant"]);
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
const root = lstatSync(directory);
|
|
122
|
+
if (!root.isDirectory() || root.isSymbolicLink()) {
|
|
123
|
+
return result(family.id, policy, usage, "blocked", "none", ["unsafe_family_root"]);
|
|
124
|
+
}
|
|
125
|
+
const manifest = readSegmentManifest(directory, family);
|
|
126
|
+
const knownRootFiles = new Set(["active.jsonl", "manifest.json", "metrics.json"]);
|
|
127
|
+
for (const name of knownRootFiles) accountKnownFile(join(directory, name), usage, reasons);
|
|
128
|
+
|
|
129
|
+
const listed = new Set(manifest.segments.map(({ file }) => file));
|
|
130
|
+
const segments: StructuredLogRetentionSegment[] = [];
|
|
131
|
+
for (const segment of manifest.segments) {
|
|
132
|
+
const path = join(directory, ...segment.file.split("/"));
|
|
133
|
+
const observed = safeRegularFile(path);
|
|
134
|
+
if (!observed.safe) {
|
|
135
|
+
reasons.add(observed.reason ?? "missing_manifest_segment");
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
usage.managed_bytes += observed.bytes;
|
|
139
|
+
usage.managed_files += 1;
|
|
140
|
+
segments.push({
|
|
141
|
+
sequence: segment.sequence,
|
|
142
|
+
file: segment.file,
|
|
143
|
+
actual_bytes: observed.bytes,
|
|
144
|
+
content_sha256: segment.sha256,
|
|
145
|
+
sealed_at: segment.sealed_at,
|
|
146
|
+
age_expired: now.getTime() - Date.parse(segment.sealed_at) >= policy.max_age_ms,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
accountUnknownSegmentFiles(directory, listed, usage, reasons);
|
|
150
|
+
const snapshots = accountManifestSnapshots(directory, manifest.next_sequence, usage, reasons);
|
|
151
|
+
accountUnknownRootFiles(directory, knownRootFiles, usage);
|
|
152
|
+
accountLeaseFiles(directory, usage, reasons);
|
|
153
|
+
const blocker = [...reasons].some((reason) =>
|
|
154
|
+
[
|
|
155
|
+
"unsafe_family_root",
|
|
156
|
+
"unsafe_managed_path",
|
|
157
|
+
"hard_link_ambiguous",
|
|
158
|
+
"missing_manifest_segment",
|
|
159
|
+
"manifest_invalid",
|
|
160
|
+
"recovery_breadcrumb_present",
|
|
161
|
+
].includes(reason),
|
|
162
|
+
);
|
|
163
|
+
const ageExpired = segments.some(({ age_expired }) => age_expired);
|
|
164
|
+
const bytesOver = Math.max(0, usage.managed_bytes - policy.max_bytes);
|
|
165
|
+
if (usage.unmanaged_bytes > 0) reasons.add("unmanaged_bytes_present");
|
|
166
|
+
if (bytesOver > 0) reasons.add("managed_bytes_exceed_budget");
|
|
167
|
+
if (ageExpired) reasons.add("age_expired");
|
|
168
|
+
return {
|
|
169
|
+
family_id: family.id,
|
|
170
|
+
effective_policy: policy,
|
|
171
|
+
usage: { ...usage, total_bytes: usage.managed_bytes + usage.unmanaged_bytes },
|
|
172
|
+
pressure: {
|
|
173
|
+
state: blocker ? "unknown" : bytesOver > 0 || ageExpired ? "over_budget" : "within_budget",
|
|
174
|
+
ratio: blocker ? null : usage.managed_bytes / policy.max_bytes,
|
|
175
|
+
bytes_over: blocker ? null : bytesOver,
|
|
176
|
+
reason_codes: [...reasons].sort(),
|
|
177
|
+
},
|
|
178
|
+
retention: {
|
|
179
|
+
state: blocker ? "blocked" : "active",
|
|
180
|
+
enforcement: blocker ? "none" : "manual",
|
|
181
|
+
reason_codes: [...reasons].sort(),
|
|
182
|
+
},
|
|
183
|
+
sealed_segments: segments,
|
|
184
|
+
obsolete_snapshots: snapshots.filter(({ recovery_breadcrumb }) => !recovery_breadcrumb),
|
|
185
|
+
};
|
|
186
|
+
} catch {
|
|
187
|
+
return result(family.id, policy, usage, "blocked", "none", ["manifest_invalid"]);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export function createStructuredLogRetentionProvider(
|
|
192
|
+
family: HarneryRegisteredStorageFamily,
|
|
193
|
+
): HarneryMaintenanceProvider {
|
|
194
|
+
if (!structuredSegmentCapable(family)) {
|
|
195
|
+
throw new Error(`family ${family.id} is not manifest-backed structured log storage`);
|
|
196
|
+
}
|
|
197
|
+
return {
|
|
198
|
+
family_id: family.id,
|
|
199
|
+
destructive_scope: STRUCTURED_LOG_RETENTION_SCOPE,
|
|
200
|
+
plan: ({ budget, now }): HarneryMaintenanceProviderPlan => {
|
|
201
|
+
const inspection = inspectStructuredLogRetention(family, now);
|
|
202
|
+
if (
|
|
203
|
+
inspection.retention.state !== "active" ||
|
|
204
|
+
!inspection.effective_policy ||
|
|
205
|
+
inspection.pressure.state === "unknown"
|
|
206
|
+
) {
|
|
207
|
+
return { actions: [] };
|
|
208
|
+
}
|
|
209
|
+
const actions: HarneryMaintenanceAction[] = [];
|
|
210
|
+
let files = 0;
|
|
211
|
+
let bytes = 0;
|
|
212
|
+
const add = (action: HarneryMaintenanceAction): boolean => {
|
|
213
|
+
if (files + action.files > budget.max_files || bytes + action.bytes > budget.max_bytes) {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
actions.push(action);
|
|
217
|
+
files += action.files;
|
|
218
|
+
bytes += action.bytes;
|
|
219
|
+
return true;
|
|
220
|
+
};
|
|
221
|
+
for (const snapshot of inspection.obsolete_snapshots) {
|
|
222
|
+
const path = join(familyLogDirectory(family), ...snapshot.file.split("/"));
|
|
223
|
+
if (
|
|
224
|
+
!add(
|
|
225
|
+
retentionAction(family, inspection.effective_policy.fingerprint, {
|
|
226
|
+
action_id: `snapshot-${basename(snapshot.file, ".json")}`,
|
|
227
|
+
kind: "prune-log-manifest-snapshot",
|
|
228
|
+
target_ref: snapshot.file,
|
|
229
|
+
files: 1,
|
|
230
|
+
bytes: snapshot.actual_bytes,
|
|
231
|
+
expected_sha256: sha256File(path),
|
|
232
|
+
}),
|
|
233
|
+
)
|
|
234
|
+
) {
|
|
235
|
+
return { actions };
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
let projected = inspection.usage.managed_bytes - actions.reduce((sum, x) => sum + x.bytes, 0);
|
|
239
|
+
let predictedManifest = readSegmentManifest(familyLogDirectory(family), family);
|
|
240
|
+
for (const segment of inspection.sealed_segments) {
|
|
241
|
+
if (!segment.age_expired && projected <= inspection.effective_policy.max_bytes) break;
|
|
242
|
+
const path = join(familyLogDirectory(family), ...segment.file.split("/"));
|
|
243
|
+
const expectedManifestFingerprint = logManifestFingerprint(predictedManifest);
|
|
244
|
+
const nextManifest = {
|
|
245
|
+
...predictedManifest,
|
|
246
|
+
pruned_through_sequence: segment.sequence,
|
|
247
|
+
segments: predictedManifest.segments.slice(1),
|
|
248
|
+
};
|
|
249
|
+
const action = retentionAction(family, inspection.effective_policy.fingerprint, {
|
|
250
|
+
action_id: `segment-${String(segment.sequence).padStart(8, "0")}`,
|
|
251
|
+
kind: "prune-log-segment",
|
|
252
|
+
target_ref: segment.file,
|
|
253
|
+
files: 1,
|
|
254
|
+
bytes: segment.actual_bytes,
|
|
255
|
+
expected_sha256: sha256File(path),
|
|
256
|
+
metadata: {
|
|
257
|
+
sequence: segment.sequence,
|
|
258
|
+
content_sha256: segment.content_sha256,
|
|
259
|
+
expected_manifest_fingerprint: expectedManifestFingerprint,
|
|
260
|
+
result_manifest_fingerprint: logManifestFingerprint(nextManifest),
|
|
261
|
+
},
|
|
262
|
+
});
|
|
263
|
+
if (!add(action)) break;
|
|
264
|
+
predictedManifest = nextManifest;
|
|
265
|
+
projected -= segment.actual_bytes;
|
|
266
|
+
}
|
|
267
|
+
return { actions };
|
|
268
|
+
},
|
|
269
|
+
apply: async ({ action }) => {
|
|
270
|
+
const current = family.effective_log_retention;
|
|
271
|
+
if (
|
|
272
|
+
current?.state !== "valid" ||
|
|
273
|
+
action.authorization_scope !== STRUCTURED_LOG_RETENTION_SCOPE ||
|
|
274
|
+
action.effective_policy_fingerprint !== current.effective_policy_fingerprint
|
|
275
|
+
) {
|
|
276
|
+
return { outcome: "refused", detail: "effective log retention policy changed" };
|
|
277
|
+
}
|
|
278
|
+
if (action.kind === "prune-log-segment") {
|
|
279
|
+
const sequence = Number(action.metadata?.sequence);
|
|
280
|
+
const contentSha256 = String(action.metadata?.content_sha256 ?? "");
|
|
281
|
+
const expectedManifestFingerprint = String(
|
|
282
|
+
action.metadata?.expected_manifest_fingerprint ?? "",
|
|
283
|
+
);
|
|
284
|
+
const resultManifestFingerprint = String(
|
|
285
|
+
action.metadata?.result_manifest_fingerprint ?? "",
|
|
286
|
+
);
|
|
287
|
+
const outcome = await pruneSealedLogSegment({
|
|
288
|
+
directory: familyLogDirectory(family),
|
|
289
|
+
family,
|
|
290
|
+
sequence,
|
|
291
|
+
file: action.target_ref,
|
|
292
|
+
expected_bytes: action.bytes,
|
|
293
|
+
expected_file_sha256: action.expected_sha256 ?? "",
|
|
294
|
+
expected_content_sha256: contentSha256,
|
|
295
|
+
expected_manifest_fingerprint: expectedManifestFingerprint,
|
|
296
|
+
result_manifest_fingerprint: resultManifestFingerprint,
|
|
297
|
+
});
|
|
298
|
+
return { outcome };
|
|
299
|
+
}
|
|
300
|
+
if (action.kind === "prune-log-manifest-snapshot") {
|
|
301
|
+
return {
|
|
302
|
+
outcome: await pruneObsoleteSnapshot(
|
|
303
|
+
family,
|
|
304
|
+
action.target_ref,
|
|
305
|
+
action.bytes,
|
|
306
|
+
action.expected_sha256 ?? "",
|
|
307
|
+
),
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
return { outcome: "refused", detail: "unsupported structured-log retention action" };
|
|
311
|
+
},
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function structuredSegmentCapable(family: HarneryRegisteredStorageFamily): boolean {
|
|
316
|
+
return (
|
|
317
|
+
family.provider.provider_id === HARNERY_STRUCTURED_LOG_PROVIDER_ID &&
|
|
318
|
+
(family.storage_class === "operational-log" || family.storage_class === "debug-log") &&
|
|
319
|
+
family.format === "jsonl" &&
|
|
320
|
+
family.resolved_roots.some(
|
|
321
|
+
(root) => root.match === "provider-partition" && root.ownership !== "external",
|
|
322
|
+
)
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function retentionAction(
|
|
327
|
+
family: HarneryRegisteredStorageFamily,
|
|
328
|
+
fingerprint: string,
|
|
329
|
+
action: Omit<
|
|
330
|
+
HarneryMaintenanceAction,
|
|
331
|
+
"family_id" | "destructive" | "authorization_scope" | "effective_policy_fingerprint"
|
|
332
|
+
>,
|
|
333
|
+
): HarneryMaintenanceAction {
|
|
334
|
+
return {
|
|
335
|
+
...action,
|
|
336
|
+
family_id: family.id,
|
|
337
|
+
destructive: true,
|
|
338
|
+
authorization_scope: STRUCTURED_LOG_RETENTION_SCOPE,
|
|
339
|
+
effective_policy_fingerprint: fingerprint,
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
async function pruneObsoleteSnapshot(
|
|
344
|
+
family: HarneryRegisteredStorageFamily,
|
|
345
|
+
relativePath: string,
|
|
346
|
+
expectedBytes: number,
|
|
347
|
+
expectedSha256: string,
|
|
348
|
+
): Promise<"applied" | "already_applied"> {
|
|
349
|
+
if (!/^manifests\/[0-9]{8}\.json$/.test(relativePath)) {
|
|
350
|
+
throw new Error("invalid log manifest snapshot target");
|
|
351
|
+
}
|
|
352
|
+
const directory = familyLogDirectory(family);
|
|
353
|
+
return withFamilyLease(
|
|
354
|
+
directory,
|
|
355
|
+
{
|
|
356
|
+
lease_timeout_ms: family.lease_policy?.acquisition_timeout_ms ?? 2_000,
|
|
357
|
+
lease_retry_ms: family.lease_policy?.retry_backoff_ms ?? 10,
|
|
358
|
+
lease_stale_ms: family.lease_policy?.stale_owner_ms ?? 30_000,
|
|
359
|
+
},
|
|
360
|
+
() => {
|
|
361
|
+
const manifest = readSegmentManifest(directory, family);
|
|
362
|
+
const sequence = Number(basename(relativePath, ".json"));
|
|
363
|
+
if (sequence >= manifest.next_sequence) {
|
|
364
|
+
throw new Error("log retention preserves an uncommitted recovery breadcrumb");
|
|
365
|
+
}
|
|
366
|
+
const path = join(directory, ...relativePath.split("/"));
|
|
367
|
+
if (!existsSync(path)) return "already_applied";
|
|
368
|
+
assertExactFile(path, expectedBytes, expectedSha256);
|
|
369
|
+
unlinkSync(path);
|
|
370
|
+
return "applied";
|
|
371
|
+
},
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
function result(
|
|
376
|
+
familyId: string,
|
|
377
|
+
policy: StructuredLogRetentionInspection["effective_policy"],
|
|
378
|
+
usage: MutableUsage,
|
|
379
|
+
state: StructuredLogRetentionInspection["retention"]["state"],
|
|
380
|
+
enforcement: StructuredLogRetentionInspection["retention"]["enforcement"],
|
|
381
|
+
reasons: string[],
|
|
382
|
+
): StructuredLogRetentionInspection {
|
|
383
|
+
return {
|
|
384
|
+
family_id: familyId,
|
|
385
|
+
effective_policy: policy,
|
|
386
|
+
usage: { ...usage, total_bytes: usage.managed_bytes + usage.unmanaged_bytes },
|
|
387
|
+
pressure: {
|
|
388
|
+
state: state === "active" ? "within_budget" : "unknown",
|
|
389
|
+
ratio: state === "active" && policy ? 0 : null,
|
|
390
|
+
bytes_over: state === "active" && policy ? 0 : null,
|
|
391
|
+
reason_codes: [...new Set(reasons)].sort(),
|
|
392
|
+
},
|
|
393
|
+
retention: {
|
|
394
|
+
state,
|
|
395
|
+
enforcement,
|
|
396
|
+
reason_codes: [...new Set(reasons)].sort(),
|
|
397
|
+
},
|
|
398
|
+
sealed_segments: [],
|
|
399
|
+
obsolete_snapshots: [],
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function accountKnownFile(path: string, usage: MutableUsage, reasons: Set<string>): void {
|
|
404
|
+
if (!existsSync(path)) return;
|
|
405
|
+
const observed = safeRegularFile(path);
|
|
406
|
+
if (!observed.safe) {
|
|
407
|
+
reasons.add(observed.reason ?? "unsafe_managed_path");
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
usage.managed_bytes += observed.bytes;
|
|
411
|
+
usage.managed_files += 1;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
function accountUnknownSegmentFiles(
|
|
415
|
+
directory: string,
|
|
416
|
+
listed: ReadonlySet<string>,
|
|
417
|
+
usage: MutableUsage,
|
|
418
|
+
reasons: Set<string>,
|
|
419
|
+
): void {
|
|
420
|
+
const root = join(directory, "segments");
|
|
421
|
+
if (!existsSync(root)) return;
|
|
422
|
+
const stat = lstatSync(root);
|
|
423
|
+
if (stat.isSymbolicLink() || !stat.isDirectory()) {
|
|
424
|
+
reasons.add("unsafe_managed_path");
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
for (const entry of readdirSync(root, { withFileTypes: true })) {
|
|
428
|
+
const relativePath = `segments/${entry.name}`;
|
|
429
|
+
if (listed.has(relativePath)) continue;
|
|
430
|
+
accountUnmanaged(join(root, entry.name), usage);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
function accountManifestSnapshots(
|
|
435
|
+
directory: string,
|
|
436
|
+
nextSequence: number,
|
|
437
|
+
usage: MutableUsage,
|
|
438
|
+
reasons: Set<string>,
|
|
439
|
+
): StructuredLogRetentionSnapshot[] {
|
|
440
|
+
const root = join(directory, "manifests");
|
|
441
|
+
if (!existsSync(root)) return [];
|
|
442
|
+
const rootStat = lstatSync(root);
|
|
443
|
+
if (rootStat.isSymbolicLink() || !rootStat.isDirectory()) {
|
|
444
|
+
reasons.add("unsafe_managed_path");
|
|
445
|
+
return [];
|
|
446
|
+
}
|
|
447
|
+
const entries = readdirSync(root, { withFileTypes: true });
|
|
448
|
+
for (const entry of entries) {
|
|
449
|
+
if (!entry.isFile() || !/^[0-9]{8}\.json$/.test(entry.name)) {
|
|
450
|
+
accountUnmanaged(join(root, entry.name), usage);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
const names = entries
|
|
454
|
+
.filter((entry) => entry.isFile() && /^[0-9]{8}\.json$/.test(entry.name))
|
|
455
|
+
.map((entry) => `manifests/${entry.name}`)
|
|
456
|
+
.sort();
|
|
457
|
+
return names.flatMap((relativePath) => {
|
|
458
|
+
const observed = safeRegularFile(join(directory, ...relativePath.split("/")));
|
|
459
|
+
if (!observed.safe) {
|
|
460
|
+
reasons.add(observed.reason ?? "unsafe_managed_path");
|
|
461
|
+
return [];
|
|
462
|
+
}
|
|
463
|
+
usage.managed_bytes += observed.bytes;
|
|
464
|
+
usage.managed_files += 1;
|
|
465
|
+
const recoveryBreadcrumb = Number(basename(relativePath, ".json")) >= nextSequence;
|
|
466
|
+
if (recoveryBreadcrumb) reasons.add("recovery_breadcrumb_present");
|
|
467
|
+
return [
|
|
468
|
+
{
|
|
469
|
+
file: relativePath,
|
|
470
|
+
actual_bytes: observed.bytes,
|
|
471
|
+
recovery_breadcrumb: recoveryBreadcrumb,
|
|
472
|
+
},
|
|
473
|
+
];
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
function accountUnknownRootFiles(
|
|
478
|
+
directory: string,
|
|
479
|
+
known: ReadonlySet<string>,
|
|
480
|
+
usage: MutableUsage,
|
|
481
|
+
): void {
|
|
482
|
+
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
483
|
+
if (known.has(entry.name) || ["segments", "manifests", ".append-lease"].includes(entry.name)) {
|
|
484
|
+
continue;
|
|
485
|
+
}
|
|
486
|
+
accountUnmanaged(join(directory, entry.name), usage);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
function accountLeaseFiles(directory: string, usage: MutableUsage, reasons: Set<string>): void {
|
|
491
|
+
const lease = join(directory, ".append-lease");
|
|
492
|
+
if (!existsSync(lease)) return;
|
|
493
|
+
try {
|
|
494
|
+
const stat = lstatSync(lease);
|
|
495
|
+
if (!stat.isDirectory() || stat.isSymbolicLink()) {
|
|
496
|
+
reasons.add("unsafe_managed_path");
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
for (const entry of readdirSync(lease, { withFileTypes: true })) {
|
|
500
|
+
accountKnownFile(join(lease, entry.name), usage, reasons);
|
|
501
|
+
}
|
|
502
|
+
} catch {
|
|
503
|
+
// A writer may release the lease during this read-only observation.
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
function accountUnmanaged(path: string, usage: MutableUsage): void {
|
|
508
|
+
try {
|
|
509
|
+
const stat = lstatSync(path);
|
|
510
|
+
if (stat.isFile() && !stat.isSymbolicLink()) usage.unmanaged_bytes += stat.size;
|
|
511
|
+
usage.unmanaged_files += 1;
|
|
512
|
+
} catch {
|
|
513
|
+
// Concurrent disappearance contributes no retained bytes.
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
function safeRegularFile(path: string): { safe: boolean; bytes: number; reason?: string } {
|
|
518
|
+
try {
|
|
519
|
+
const stat = lstatSync(path);
|
|
520
|
+
if (stat.isSymbolicLink() || !stat.isFile()) {
|
|
521
|
+
return { safe: false, bytes: 0, reason: "unsafe_managed_path" };
|
|
522
|
+
}
|
|
523
|
+
if (stat.nlink !== 1) return { safe: false, bytes: 0, reason: "hard_link_ambiguous" };
|
|
524
|
+
return { safe: true, bytes: stat.size };
|
|
525
|
+
} catch (error) {
|
|
526
|
+
return {
|
|
527
|
+
safe: false,
|
|
528
|
+
bytes: 0,
|
|
529
|
+
reason:
|
|
530
|
+
(error as NodeJS.ErrnoException).code === "ENOENT"
|
|
531
|
+
? "missing_manifest_segment"
|
|
532
|
+
: "unsafe_managed_path",
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
function assertExactFile(path: string, expectedBytes: number, expectedSha256: string): void {
|
|
538
|
+
const observed = safeRegularFile(path);
|
|
539
|
+
if (!observed.safe) throw new Error(observed.reason ?? "unsafe log retention source");
|
|
540
|
+
if (observed.bytes !== expectedBytes) throw new Error("log retention source size changed");
|
|
541
|
+
if (sha256File(path) !== expectedSha256) throw new Error("log retention source digest changed");
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
function sha256File(path: string): string {
|
|
545
|
+
const parent = realpathSync(dirname(path));
|
|
546
|
+
const fd = openSync(path, fsConstants.O_RDONLY | (fsConstants.O_NOFOLLOW ?? 0));
|
|
547
|
+
try {
|
|
548
|
+
const actual = realpathSync(path);
|
|
549
|
+
const rel = relative(parent, actual);
|
|
550
|
+
if (rel.startsWith("..") || isAbsolute(rel)) throw new Error("log retention path escaped");
|
|
551
|
+
return createHash("sha256").update(readFileSync(fd)).digest("hex");
|
|
552
|
+
} finally {
|
|
553
|
+
closeSync(fd);
|
|
554
|
+
}
|
|
555
|
+
}
|