harnery 0.35.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commander.d.ts +30 -5
- package/dist/commander.d.ts.map +1 -1
- package/dist/commander.js +128 -96
- package/dist/commands/agents.d.ts +23 -3
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +464 -242
- package/dist/commands/artifacts.d.ts.map +1 -1
- package/dist/commands/artifacts.js +26 -1
- package/dist/commands/backup.d.ts.map +1 -1
- package/dist/commands/backup.js +10 -10
- package/dist/commands/browse-session.d.ts.map +1 -1
- package/dist/commands/browse-session.js +12 -0
- package/dist/commands/browse.d.ts +1 -1
- package/dist/commands/browse.d.ts.map +1 -1
- package/dist/commands/browse.js +16 -4
- package/dist/commands/conversations.d.ts +10 -0
- package/dist/commands/conversations.d.ts.map +1 -0
- package/dist/commands/conversations.js +201 -0
- package/dist/commands/deinit.d.ts.map +1 -1
- package/dist/commands/deinit.js +5 -0
- package/dist/commands/diagnostics.d.ts +4 -0
- package/dist/commands/diagnostics.d.ts.map +1 -0
- package/dist/commands/diagnostics.js +229 -0
- package/dist/commands/docs.d.ts.map +1 -1
- package/dist/commands/docs.js +13 -2
- package/dist/commands/doctor.d.ts +5 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +51 -7
- package/dist/commands/fetch.js +6 -5
- package/dist/commands/files.d.ts +34 -0
- package/dist/commands/files.d.ts.map +1 -0
- package/dist/commands/files.js +166 -0
- package/dist/commands/governor.d.ts.map +1 -1
- package/dist/commands/governor.js +18 -12
- package/dist/commands/inbox.d.ts +5 -0
- package/dist/commands/inbox.d.ts.map +1 -0
- package/dist/commands/inbox.js +57 -0
- package/dist/commands/init.d.ts +4 -5
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +63 -13
- package/dist/commands/ledger-v3.d.ts.map +1 -1
- package/dist/commands/ledger-v3.js +417 -2
- package/dist/commands/logs.d.ts +4 -0
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/logs.js +169 -0
- package/dist/commands/messages.d.ts +5 -0
- package/dist/commands/messages.d.ts.map +1 -0
- package/dist/commands/messages.js +45 -0
- package/dist/commands/outline.d.ts +1 -1
- package/dist/commands/outline.d.ts.map +1 -1
- package/dist/commands/outline.js +2 -2
- package/dist/commands/qa-run.d.ts +4 -0
- package/dist/commands/qa-run.d.ts.map +1 -0
- package/dist/commands/qa-run.js +141 -0
- package/dist/commands/read.d.ts +1 -1
- package/dist/commands/read.d.ts.map +1 -1
- package/dist/commands/read.js +2 -2
- package/dist/commands/resources.d.ts +4 -0
- package/dist/commands/resources.d.ts.map +1 -0
- package/dist/commands/resources.js +29 -0
- package/dist/commands/semantic.d.ts.map +1 -1
- package/dist/commands/semantic.js +54 -2
- package/dist/commands/storage.d.ts +4 -0
- package/dist/commands/storage.d.ts.map +1 -0
- package/dist/commands/storage.js +238 -0
- package/dist/commands/supervisor.d.ts +4 -0
- package/dist/commands/supervisor.d.ts.map +1 -0
- package/dist/commands/supervisor.js +101 -0
- package/dist/commands/tunnel.d.ts +5 -1
- package/dist/commands/tunnel.d.ts.map +1 -1
- package/dist/commands/tunnel.js +44 -31
- package/dist/commands/web.d.ts +3 -0
- package/dist/commands/web.d.ts.map +1 -1
- package/dist/commands/web.js +84 -7
- package/dist/commands/work.js +3 -3
- package/dist/commands/workflow.d.ts.map +1 -1
- package/dist/commands/workflow.js +17 -13
- package/dist/core/adapters/profiles.d.ts +1 -1
- package/dist/core/agents/cli.js +215 -41
- package/dist/core/agents/health.d.ts +17 -0
- package/dist/core/agents/health.d.ts.map +1 -0
- package/dist/core/agents/health.js +109 -0
- package/dist/core/agents/live-authority-v3.d.ts +47 -1
- package/dist/core/agents/live-authority-v3.d.ts.map +1 -1
- package/dist/core/agents/live-authority-v3.js +244 -10
- package/dist/core/agents/live-lifecycle-v3.js +6 -1
- package/dist/core/agents/live-observation-v3.d.ts.map +1 -1
- package/dist/core/agents/live-observation-v3.js +6 -1
- package/dist/core/agents/mailbox.d.ts +92 -0
- package/dist/core/agents/mailbox.d.ts.map +1 -0
- package/dist/core/agents/mailbox.js +325 -0
- package/dist/core/agents/reconcile-coordination-v3.d.ts +44 -0
- package/dist/core/agents/reconcile-coordination-v3.d.ts.map +1 -0
- package/dist/core/agents/reconcile-coordination-v3.js +58 -0
- package/dist/core/agents/render/prompt-context.d.ts +14 -3
- package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
- package/dist/core/agents/render/prompt-context.js +54 -16
- package/dist/core/agents/render/session-context.d.ts +8 -0
- package/dist/core/agents/render/session-context.d.ts.map +1 -1
- package/dist/core/agents/render/session-context.js +34 -3
- package/dist/core/agents/rules/commit-conflict.d.ts.map +1 -1
- package/dist/core/agents/rules/commit-conflict.js +50 -1
- package/dist/core/agents/rules/stop-hook.d.ts +2 -0
- package/dist/core/agents/rules/stop-hook.d.ts.map +1 -1
- package/dist/core/agents/rules/stop-hook.js +93 -16
- package/dist/core/agents/rules/verdict.d.ts +1 -0
- package/dist/core/agents/rules/verdict.d.ts.map +1 -1
- package/dist/core/agents/session-events.d.ts.map +1 -1
- package/dist/core/agents/session-events.js +4 -0
- package/dist/core/agents/session-finalization-state-v3.js +1 -1
- package/dist/core/agents/session-finalizer-v3.js +9 -2
- package/dist/core/agents/state/activity-log.d.ts +3 -0
- package/dist/core/agents/state/activity-log.d.ts.map +1 -1
- package/dist/core/agents/state/activity-log.js +6 -3
- package/dist/core/agents/state/heartbeat-writer.d.ts +6 -0
- package/dist/core/agents/state/heartbeat-writer.d.ts.map +1 -1
- package/dist/core/agents/state/heartbeat-writer.js +18 -0
- package/dist/core/agents/state/live-coordination-view.d.ts +5 -7
- package/dist/core/agents/state/live-coordination-view.d.ts.map +1 -1
- package/dist/core/agents/state/live-coordination-view.js +15 -90
- package/dist/core/agents/state/live-coordination-writer.d.ts +12 -0
- package/dist/core/agents/state/live-coordination-writer.d.ts.map +1 -0
- package/dist/core/agents/state/live-coordination-writer.js +92 -0
- package/dist/core/artifacts/index.d.ts +47 -1
- package/dist/core/artifacts/index.d.ts.map +1 -1
- package/dist/core/artifacts/index.js +191 -6
- package/dist/core/config.d.ts +74 -4
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +141 -4
- package/dist/core/conversations/archive.d.ts +49 -0
- package/dist/core/conversations/archive.d.ts.map +1 -0
- package/dist/core/conversations/archive.js +136 -0
- package/dist/core/conversations/catalog.d.ts +10 -0
- package/dist/core/conversations/catalog.d.ts.map +1 -0
- package/dist/core/conversations/catalog.js +72 -0
- package/dist/core/conversations/context-pack.d.ts +6 -0
- package/dist/core/conversations/context-pack.d.ts.map +1 -0
- package/dist/core/conversations/context-pack.js +60 -0
- package/dist/core/conversations/contract.d.ts +155 -0
- package/dist/core/conversations/contract.d.ts.map +1 -0
- package/dist/core/conversations/contract.js +1 -0
- package/dist/core/conversations/evaluation.d.ts +16 -0
- package/dist/core/conversations/evaluation.d.ts.map +1 -0
- package/dist/core/conversations/evaluation.js +9 -0
- package/dist/core/conversations/index.d.ts +10 -0
- package/dist/core/conversations/index.d.ts.map +1 -0
- package/dist/core/conversations/index.js +9 -0
- package/dist/core/conversations/lifecycle.d.ts +28 -0
- package/dist/core/conversations/lifecycle.d.ts.map +1 -0
- package/dist/core/conversations/lifecycle.js +29 -0
- package/dist/core/conversations/normalize.d.ts +14 -0
- package/dist/core/conversations/normalize.d.ts.map +1 -0
- package/dist/core/conversations/normalize.js +82 -0
- package/dist/core/conversations/query.d.ts +8 -0
- package/dist/core/conversations/query.d.ts.map +1 -0
- package/dist/core/conversations/query.js +280 -0
- package/dist/core/conversations/search-index.d.ts +9 -0
- package/dist/core/conversations/search-index.d.ts.map +1 -0
- package/dist/core/conversations/search-index.js +29 -0
- package/dist/core/diagnostics/advice.d.ts +9 -0
- package/dist/core/diagnostics/advice.d.ts.map +1 -0
- package/dist/core/diagnostics/advice.js +112 -0
- package/dist/core/diagnostics/bundle.d.ts +35 -0
- package/dist/core/diagnostics/bundle.d.ts.map +1 -0
- package/dist/core/diagnostics/bundle.js +874 -0
- package/dist/core/diagnostics/comparison.d.ts +5 -0
- package/dist/core/diagnostics/comparison.d.ts.map +1 -0
- package/dist/core/diagnostics/comparison.js +444 -0
- package/dist/core/diagnostics/contract.d.ts +245 -0
- package/dist/core/diagnostics/contract.d.ts.map +1 -0
- package/dist/core/diagnostics/contract.js +18 -0
- package/dist/core/diagnostics/identity.d.ts +3 -0
- package/dist/core/diagnostics/identity.d.ts.map +1 -0
- package/dist/core/diagnostics/identity.js +10 -0
- package/dist/core/diagnostics/index.d.ts +8 -0
- package/dist/core/diagnostics/index.d.ts.map +1 -0
- package/dist/core/diagnostics/index.js +7 -0
- package/dist/core/diagnostics/replay.d.ts +8 -0
- package/dist/core/diagnostics/replay.d.ts.map +1 -0
- package/dist/core/diagnostics/replay.js +213 -0
- package/dist/core/diagnostics/sanitize.d.ts +9 -0
- package/dist/core/diagnostics/sanitize.d.ts.map +1 -0
- package/dist/core/diagnostics/sanitize.js +84 -0
- package/dist/core/events/legacy-storage/canary.d.ts +18 -0
- package/dist/core/events/legacy-storage/canary.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/canary.js +150 -0
- package/dist/core/events/legacy-storage/compression.d.ts +13 -0
- package/dist/core/events/legacy-storage/compression.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/compression.js +107 -0
- package/dist/core/events/legacy-storage/fence.d.ts +15 -0
- package/dist/core/events/legacy-storage/fence.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/fence.js +115 -0
- package/dist/core/events/legacy-storage/index.d.ts +7 -0
- package/dist/core/events/legacy-storage/index.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/index.js +6 -0
- package/dist/core/events/legacy-storage/inventory.d.ts +10 -0
- package/dist/core/events/legacy-storage/inventory.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/inventory.js +40 -0
- package/dist/core/events/legacy-storage/manifest.d.ts +23 -0
- package/dist/core/events/legacy-storage/manifest.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/manifest.js +108 -0
- package/dist/core/events/legacy-storage/reader.d.ts +15 -0
- package/dist/core/events/legacy-storage/reader.d.ts.map +1 -0
- package/dist/core/events/legacy-storage/reader.js +154 -0
- package/dist/core/events/v3/archive-retention.d.ts +33 -0
- package/dist/core/events/v3/archive-retention.d.ts.map +1 -0
- package/dist/core/events/v3/archive-retention.js +195 -0
- package/dist/core/events/v3/authority-outbox.d.ts +7 -2
- package/dist/core/events/v3/authority-outbox.d.ts.map +1 -1
- package/dist/core/events/v3/authority-outbox.js +16 -3
- package/dist/core/events/v3/base-contract.d.ts +81 -41
- package/dist/core/events/v3/base-contract.d.ts.map +1 -1
- package/dist/core/events/v3/base-contract.js +17 -7
- package/dist/core/events/v3/bootstrap.d.ts +39 -0
- package/dist/core/events/v3/bootstrap.d.ts.map +1 -1
- package/dist/core/events/v3/bootstrap.js +167 -3
- package/dist/core/events/v3/capabilities.d.ts +1 -1
- package/dist/core/events/v3/capabilities.d.ts.map +1 -1
- package/dist/core/events/v3/capabilities.js +4 -3
- package/dist/core/events/v3/control-witness.d.ts +44 -0
- package/dist/core/events/v3/control-witness.d.ts.map +1 -0
- package/dist/core/events/v3/control-witness.js +233 -0
- package/dist/core/events/v3/control-writer.d.ts +4 -0
- package/dist/core/events/v3/control-writer.d.ts.map +1 -0
- package/dist/core/events/v3/control-writer.js +16 -0
- package/dist/core/events/v3/control.d.ts +8 -2
- package/dist/core/events/v3/control.d.ts.map +1 -1
- package/dist/core/events/v3/control.js +46 -18
- package/dist/core/events/v3/coordination-transaction-recovery.d.ts +42 -0
- package/dist/core/events/v3/coordination-transaction-recovery.d.ts.map +1 -0
- package/dist/core/events/v3/coordination-transaction-recovery.js +342 -0
- package/dist/core/events/v3/coordination-view.d.ts.map +1 -1
- package/dist/core/events/v3/coordination-view.js +16 -1
- package/dist/core/events/v3/generated.d.ts +1 -1
- package/dist/core/events/v3/generated.js +1 -1
- package/dist/core/events/v3/index.d.ts +5 -2
- package/dist/core/events/v3/index.d.ts.map +1 -1
- package/dist/core/events/v3/index.js +4 -1
- package/dist/core/events/v3/live-route-observer.d.ts +31 -0
- package/dist/core/events/v3/live-route-observer.d.ts.map +1 -0
- package/dist/core/events/v3/live-route-observer.js +58 -0
- package/dist/core/events/v3/live-routing.d.ts +13 -21
- package/dist/core/events/v3/live-routing.d.ts.map +1 -1
- package/dist/core/events/v3/live-routing.js +46 -41
- package/dist/core/events/v3/producers/coordination-recorder.d.ts +11 -1
- package/dist/core/events/v3/producers/coordination-recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/coordination-recorder.js +76 -10
- package/dist/core/events/v3/producers/diagnostic-summaries.d.ts +129 -0
- package/dist/core/events/v3/producers/diagnostic-summaries.d.ts.map +1 -0
- package/dist/core/events/v3/producers/diagnostic-summaries.js +499 -0
- package/dist/core/events/v3/producers/hook-base.d.ts +1 -1
- package/dist/core/events/v3/producers/hook-base.d.ts.map +1 -1
- package/dist/core/events/v3/producers/hook-base.js +14 -3
- package/dist/core/events/v3/producers/intake.d.ts +7 -0
- package/dist/core/events/v3/producers/intake.d.ts.map +1 -1
- package/dist/core/events/v3/producers/intake.js +26 -2
- package/dist/core/events/v3/producers/producer-state-observer.d.ts +8 -0
- package/dist/core/events/v3/producers/producer-state-observer.d.ts.map +1 -0
- package/dist/core/events/v3/producers/producer-state-observer.js +45 -0
- package/dist/core/events/v3/producers/recorder.d.ts +71 -1
- package/dist/core/events/v3/producers/recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/recorder.js +441 -25
- package/dist/core/events/v3/reader.d.ts +51 -0
- package/dist/core/events/v3/reader.d.ts.map +1 -1
- package/dist/core/events/v3/reader.js +181 -1
- package/dist/core/events/v3/rotation-config.d.ts +9 -0
- package/dist/core/events/v3/rotation-config.d.ts.map +1 -0
- package/dist/core/events/v3/rotation-config.js +91 -0
- package/dist/core/events/v3/runtime-build.d.ts +11 -0
- package/dist/core/events/v3/runtime-build.d.ts.map +1 -0
- package/dist/core/events/v3/runtime-build.js +39 -0
- package/dist/core/events/v3/runtime-identity.d.ts +5 -0
- package/dist/core/events/v3/runtime-identity.d.ts.map +1 -0
- package/dist/core/events/v3/runtime-identity.js +18 -0
- package/dist/core/events/v3/runtime-telemetry-capabilities.d.ts +6 -5
- package/dist/core/events/v3/runtime-telemetry-capabilities.d.ts.map +1 -1
- package/dist/core/events/v3/runtime-telemetry-capabilities.js +1 -1
- package/dist/core/events/v3/support-storage/classify.d.ts +46 -0
- package/dist/core/events/v3/support-storage/classify.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/classify.js +149 -0
- package/dist/core/events/v3/support-storage/eligibility.d.ts +29 -0
- package/dist/core/events/v3/support-storage/eligibility.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/eligibility.js +35 -0
- package/dist/core/events/v3/support-storage/index.d.ts +10 -0
- package/dist/core/events/v3/support-storage/index.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/index.js +9 -0
- package/dist/core/events/v3/support-storage/inventory.d.ts +30 -0
- package/dist/core/events/v3/support-storage/inventory.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/inventory.js +94 -0
- package/dist/core/events/v3/support-storage/logical-authority.d.ts +14 -0
- package/dist/core/events/v3/support-storage/logical-authority.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/logical-authority.js +104 -0
- package/dist/core/events/v3/support-storage/maintenance.d.ts +98 -0
- package/dist/core/events/v3/support-storage/maintenance.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/maintenance.js +352 -0
- package/dist/core/events/v3/support-storage/pack-contract.d.ts +59 -0
- package/dist/core/events/v3/support-storage/pack-contract.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/pack-contract.js +249 -0
- package/dist/core/events/v3/support-storage/pack-reader.d.ts +34 -0
- package/dist/core/events/v3/support-storage/pack-reader.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/pack-reader.js +258 -0
- package/dist/core/events/v3/support-storage/pack-writer.d.ts +30 -0
- package/dist/core/events/v3/support-storage/pack-writer.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/pack-writer.js +268 -0
- package/dist/core/events/v3/support-storage/recovery.d.ts +15 -0
- package/dist/core/events/v3/support-storage/recovery.d.ts.map +1 -0
- package/dist/core/events/v3/support-storage/recovery.js +22 -0
- package/dist/core/events/v3/turn-telemetry.d.ts +14 -8
- package/dist/core/events/v3/turn-telemetry.d.ts.map +1 -1
- package/dist/core/events/v3/turn-telemetry.js +32 -2
- package/dist/core/events/v3/writer.d.ts +13 -1
- package/dist/core/events/v3/writer.d.ts.map +1 -1
- package/dist/core/events/v3/writer.js +126 -12
- package/dist/core/governor/plan-read.d.ts.map +1 -1
- package/dist/core/governor/plan-read.js +5 -21
- package/dist/core/governor/planning.js +6 -8
- package/dist/core/governor/service-read.d.ts +12 -0
- package/dist/core/governor/service-read.d.ts.map +1 -1
- package/dist/core/governor/service-read.js +266 -2
- package/dist/core/governor/service.d.ts +1 -0
- package/dist/core/governor/service.d.ts.map +1 -1
- package/dist/core/governor/service.js +53 -18
- package/dist/core/guard/evidence-v3.d.ts.map +1 -1
- package/dist/core/guard/evidence-v3.js +2 -0
- package/dist/core/hooks/adapter/events.d.ts.map +1 -1
- package/dist/core/hooks/adapter/events.js +1 -0
- package/dist/core/hooks/adapter/output.d.ts +12 -2
- package/dist/core/hooks/adapter/output.d.ts.map +1 -1
- package/dist/core/hooks/adapter/output.js +23 -5
- package/dist/core/hooks/adapter/runtime-telemetry.d.ts +27 -4
- package/dist/core/hooks/adapter/runtime-telemetry.d.ts.map +1 -1
- package/dist/core/hooks/adapter/runtime-telemetry.js +307 -6
- package/dist/core/hooks/cli.js +380 -207
- package/dist/core/hooks/effects/image-capture.d.ts +1 -1
- package/dist/core/hooks/effects/image-capture.d.ts.map +1 -1
- package/dist/core/hooks/effects/image-capture.js +4 -2
- package/dist/core/hooks/health.d.ts +59 -0
- package/dist/core/hooks/health.d.ts.map +1 -0
- package/dist/core/hooks/health.js +84 -0
- package/dist/core/hooks/remediation-cap.d.ts +8 -3
- package/dist/core/hooks/remediation-cap.d.ts.map +1 -1
- package/dist/core/hooks/remediation-cap.js +3 -11
- package/dist/core/hooks/resolve/coord-root.d.ts +22 -9
- package/dist/core/hooks/resolve/coord-root.d.ts.map +1 -1
- package/dist/core/hooks/resolve/coord-root.js +92 -11
- package/dist/core/hooks/resolve/owner.d.ts.map +1 -1
- package/dist/core/hooks/resolve/owner.js +5 -0
- package/dist/core/hooks/resolve/transcript.d.ts +8 -0
- package/dist/core/hooks/resolve/transcript.d.ts.map +1 -1
- package/dist/core/hooks/resolve/transcript.js +11 -0
- package/dist/core/inbox/contract.d.ts +64 -0
- package/dist/core/inbox/contract.d.ts.map +1 -0
- package/dist/core/inbox/contract.js +13 -0
- package/dist/core/inbox/index.d.ts +5 -0
- package/dist/core/inbox/index.d.ts.map +1 -0
- package/dist/core/inbox/index.js +4 -0
- package/dist/core/inbox/lifecycle.d.ts +22 -0
- package/dist/core/inbox/lifecycle.d.ts.map +1 -0
- package/dist/core/inbox/lifecycle.js +41 -0
- package/dist/core/inbox/service.d.ts +36 -0
- package/dist/core/inbox/service.d.ts.map +1 -0
- package/dist/core/inbox/service.js +210 -0
- package/dist/core/inbox/watcher.d.ts +7 -0
- package/dist/core/inbox/watcher.d.ts.map +1 -0
- package/dist/core/inbox/watcher.js +26 -0
- package/dist/core/presence/codec-digest.d.ts.map +1 -1
- package/dist/core/presence/codec-digest.js +14 -3
- package/dist/core/presence/relay-client.d.ts +1 -0
- package/dist/core/presence/relay-client.d.ts.map +1 -1
- package/dist/core/presence/relay-client.js +52 -8
- package/dist/core/resources/contract.d.ts +90 -0
- package/dist/core/resources/contract.d.ts.map +1 -0
- package/dist/core/resources/contract.js +2 -0
- package/dist/core/resources/index.d.ts +6 -0
- package/dist/core/resources/index.d.ts.map +1 -0
- package/dist/core/resources/index.js +5 -0
- package/dist/core/resources/sampler.d.ts +27 -0
- package/dist/core/resources/sampler.d.ts.map +1 -0
- package/dist/core/resources/sampler.js +357 -0
- package/dist/core/resources/service-status.d.ts +3 -0
- package/dist/core/resources/service-status.d.ts.map +1 -0
- package/dist/core/resources/service-status.js +48 -0
- package/dist/core/resources/service.d.ts +26 -0
- package/dist/core/resources/service.d.ts.map +1 -0
- package/dist/core/resources/service.js +292 -0
- package/dist/core/resources/storage.d.ts +13 -0
- package/dist/core/resources/storage.d.ts.map +1 -0
- package/dist/core/resources/storage.js +30 -0
- package/dist/core/semantic/adapters.d.ts +11 -8
- package/dist/core/semantic/adapters.d.ts.map +1 -1
- package/dist/core/semantic/adapters.js +169 -31
- package/dist/core/semantic/contract.d.ts +532 -48
- package/dist/core/semantic/contract.d.ts.map +1 -1
- package/dist/core/semantic/contract.js +104 -3
- package/dist/core/semantic/index.d.ts +7 -3
- package/dist/core/semantic/index.d.ts.map +1 -1
- package/dist/core/semantic/index.js +7 -3
- package/dist/core/semantic/once.d.ts +6 -1
- package/dist/core/semantic/once.d.ts.map +1 -1
- package/dist/core/semantic/once.js +80 -9
- package/dist/core/semantic/prompt.d.ts.map +1 -1
- package/dist/core/semantic/prompt.js +14 -1
- package/dist/core/semantic/review.d.ts +144 -0
- package/dist/core/semantic/review.d.ts.map +1 -0
- package/dist/core/semantic/review.js +544 -0
- package/dist/core/semantic/routes.d.ts +10 -0
- package/dist/core/semantic/routes.d.ts.map +1 -0
- package/dist/core/semantic/routes.js +21 -0
- package/dist/core/semantic/scheduler.d.ts +14 -3
- package/dist/core/semantic/scheduler.d.ts.map +1 -1
- package/dist/core/semantic/scheduler.js +30 -6
- package/dist/core/semantic/service-status.d.ts +20 -0
- package/dist/core/semantic/service-status.d.ts.map +1 -1
- package/dist/core/semantic/service-status.js +60 -4
- package/dist/core/semantic/service.d.ts +1 -0
- package/dist/core/semantic/service.d.ts.map +1 -1
- package/dist/core/semantic/service.js +104 -15
- package/dist/core/semantic/soak.d.ts +75 -0
- package/dist/core/semantic/soak.d.ts.map +1 -0
- package/dist/core/semantic/soak.js +476 -0
- package/dist/core/semantic/storage.d.ts +11 -1
- package/dist/core/semantic/storage.d.ts.map +1 -1
- package/dist/core/semantic/storage.js +4 -3
- package/dist/core/semantic/usage.d.ts +43 -0
- package/dist/core/semantic/usage.d.ts.map +1 -0
- package/dist/core/semantic/usage.js +193 -0
- package/dist/core/semantic/validate.d.ts +3 -1
- package/dist/core/semantic/validate.d.ts.map +1 -1
- package/dist/core/semantic/validate.js +34 -1
- package/dist/core/storage/atomic-json.d.ts +3 -0
- package/dist/core/storage/atomic-json.d.ts.map +1 -0
- package/dist/core/storage/atomic-json.js +15 -0
- package/dist/core/storage/buffer.d.ts +28 -0
- package/dist/core/storage/buffer.d.ts.map +1 -0
- package/dist/core/storage/buffer.js +101 -0
- package/dist/core/storage/builtins.d.ts +3 -0
- package/dist/core/storage/builtins.d.ts.map +1 -0
- package/dist/core/storage/builtins.js +722 -0
- package/dist/core/storage/catalog.d.ts +19 -0
- package/dist/core/storage/catalog.d.ts.map +1 -0
- package/dist/core/storage/catalog.js +365 -0
- package/dist/core/storage/config.d.ts +16 -0
- package/dist/core/storage/config.d.ts.map +1 -0
- package/dist/core/storage/config.js +311 -0
- package/dist/core/storage/contract.d.ts +275 -0
- package/dist/core/storage/contract.d.ts.map +1 -0
- package/dist/core/storage/contract.js +3 -0
- package/dist/core/storage/durable-history.d.ts +36 -0
- package/dist/core/storage/durable-history.d.ts.map +1 -0
- package/dist/core/storage/durable-history.js +606 -0
- package/dist/core/storage/health.d.ts +4 -0
- package/dist/core/storage/health.d.ts.map +1 -0
- package/dist/core/storage/health.js +65 -0
- package/dist/core/storage/index.d.ts +16 -0
- package/dist/core/storage/index.d.ts.map +1 -0
- package/dist/core/storage/index.js +15 -0
- package/dist/core/storage/inventory.d.ts +25 -0
- package/dist/core/storage/inventory.d.ts.map +1 -0
- package/dist/core/storage/inventory.js +666 -0
- package/dist/core/storage/jsonl.d.ts +52 -0
- package/dist/core/storage/jsonl.d.ts.map +1 -0
- package/dist/core/storage/jsonl.js +156 -0
- package/dist/core/storage/log-retention.d.ts +52 -0
- package/dist/core/storage/log-retention.d.ts.map +1 -0
- package/dist/core/storage/log-retention.js +419 -0
- package/dist/core/storage/logger.d.ts +84 -0
- package/dist/core/storage/logger.d.ts.map +1 -0
- package/dist/core/storage/logger.js +413 -0
- package/dist/core/storage/maintenance-providers.d.ts +26 -0
- package/dist/core/storage/maintenance-providers.d.ts.map +1 -0
- package/dist/core/storage/maintenance-providers.js +141 -0
- package/dist/core/storage/maintenance.d.ts +125 -0
- package/dist/core/storage/maintenance.d.ts.map +1 -0
- package/dist/core/storage/maintenance.js +609 -0
- package/dist/core/storage/metrics.d.ts +60 -0
- package/dist/core/storage/metrics.d.ts.map +1 -0
- package/dist/core/storage/metrics.js +134 -0
- package/dist/core/storage/policy.d.ts +7 -0
- package/dist/core/storage/policy.d.ts.map +1 -0
- package/dist/core/storage/policy.js +110 -0
- package/dist/core/storage/process-log.d.ts +38 -0
- package/dist/core/storage/process-log.d.ts.map +1 -0
- package/dist/core/storage/process-log.js +165 -0
- package/dist/core/storage/query.d.ts +48 -0
- package/dist/core/storage/query.d.ts.map +1 -0
- package/dist/core/storage/query.js +346 -0
- package/dist/core/storage/receipts.d.ts +23 -0
- package/dist/core/storage/receipts.d.ts.map +1 -0
- package/dist/core/storage/receipts.js +117 -0
- package/dist/core/storage/segments.d.ts +84 -0
- package/dist/core/storage/segments.d.ts.map +1 -0
- package/dist/core/storage/segments.js +542 -0
- package/dist/core/storage/sink-graph.d.ts +65 -0
- package/dist/core/storage/sink-graph.d.ts.map +1 -0
- package/dist/core/storage/sink-graph.js +213 -0
- package/dist/core/storage/storm-control.d.ts +23 -0
- package/dist/core/storage/storm-control.d.ts.map +1 -0
- package/dist/core/storage/storm-control.js +59 -0
- package/dist/core/supervisor/activity.d.ts +4 -0
- package/dist/core/supervisor/activity.d.ts.map +1 -0
- package/dist/core/supervisor/activity.js +141 -0
- package/dist/core/supervisor/contract.d.ts +268 -0
- package/dist/core/supervisor/contract.d.ts.map +1 -0
- package/dist/core/supervisor/contract.js +35 -0
- package/dist/core/supervisor/explanations.d.ts +4 -0
- package/dist/core/supervisor/explanations.d.ts.map +1 -0
- package/dist/core/supervisor/explanations.js +71 -0
- package/dist/core/supervisor/findings.d.ts +20 -0
- package/dist/core/supervisor/findings.d.ts.map +1 -0
- package/dist/core/supervisor/findings.js +399 -0
- package/dist/core/supervisor/history.d.ts +9 -0
- package/dist/core/supervisor/history.d.ts.map +1 -0
- package/dist/core/supervisor/history.js +46 -0
- package/dist/core/supervisor/hook-health-alerts.d.ts +14 -0
- package/dist/core/supervisor/hook-health-alerts.d.ts.map +1 -0
- package/dist/core/supervisor/hook-health-alerts.js +70 -0
- package/dist/core/supervisor/hook-health-storage.d.ts +5 -0
- package/dist/core/supervisor/hook-health-storage.d.ts.map +1 -0
- package/dist/core/supervisor/hook-health-storage.js +24 -0
- package/dist/core/supervisor/hook-health.d.ts +72 -0
- package/dist/core/supervisor/hook-health.d.ts.map +1 -0
- package/dist/core/supervisor/hook-health.js +203 -0
- package/dist/core/supervisor/hooks.d.ts +10 -0
- package/dist/core/supervisor/hooks.d.ts.map +1 -0
- package/dist/core/supervisor/hooks.js +28 -0
- package/dist/core/supervisor/index.d.ts +15 -0
- package/dist/core/supervisor/index.d.ts.map +1 -0
- package/dist/core/supervisor/index.js +14 -0
- package/dist/core/supervisor/log-feed.d.ts +9 -0
- package/dist/core/supervisor/log-feed.d.ts.map +1 -0
- package/dist/core/supervisor/log-feed.js +103 -0
- package/dist/core/supervisor/service.d.ts +29 -0
- package/dist/core/supervisor/service.d.ts.map +1 -0
- package/dist/core/supervisor/service.js +450 -0
- package/dist/core/supervisor/services.d.ts +11 -0
- package/dist/core/supervisor/services.d.ts.map +1 -0
- package/dist/core/supervisor/services.js +155 -0
- package/dist/core/supervisor/status.d.ts +3 -0
- package/dist/core/supervisor/status.d.ts.map +1 -0
- package/dist/core/supervisor/status.js +48 -0
- package/dist/core/supervisor/storage.d.ts +30 -0
- package/dist/core/supervisor/storage.d.ts.map +1 -0
- package/dist/core/supervisor/storage.js +73 -0
- package/dist/core/supervisor/timeline.d.ts +3 -0
- package/dist/core/supervisor/timeline.d.ts.map +1 -0
- package/dist/core/supervisor/timeline.js +87 -0
- package/dist/core/work/state.d.ts.map +1 -1
- package/dist/core/work/state.js +10 -14
- package/dist/core/workflow/admission.d.ts +23 -0
- package/dist/core/workflow/admission.d.ts.map +1 -0
- package/dist/core/workflow/admission.js +136 -0
- package/dist/core/workflow/engine.d.ts.map +1 -1
- package/dist/core/workflow/engine.js +77 -2
- package/dist/core/workflow/index.d.ts +3 -2
- package/dist/core/workflow/index.d.ts.map +1 -1
- package/dist/core/workflow/index.js +2 -1
- package/dist/core/workflow/live-session-v3.d.ts.map +1 -1
- package/dist/core/workflow/live-session-v3.js +2 -1
- package/dist/core/workflow/proof.d.ts +2 -1
- package/dist/core/workflow/proof.d.ts.map +1 -1
- package/dist/core/workflow/proof.js +39 -1
- package/dist/core/workflow/run-state.d.ts +3 -2
- package/dist/core/workflow/run-state.d.ts.map +1 -1
- package/dist/core/workflow/run-state.js +8 -1
- package/dist/core/workflow/types.d.ts +33 -1
- package/dist/core/workflow/types.d.ts.map +1 -1
- package/dist/core/workflow/types.js +2 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/lazy-commands.d.ts +26 -0
- package/dist/lazy-commands.d.ts.map +1 -0
- package/dist/lazy-commands.js +210 -0
- package/dist/lib/browser/client.d.ts +5 -0
- package/dist/lib/browser/client.d.ts.map +1 -1
- package/dist/lib/browser/client.js +1 -0
- package/dist/lib/browser/index.d.ts +2 -0
- package/dist/lib/browser/index.d.ts.map +1 -1
- package/dist/lib/browser/index.js +2 -0
- package/dist/lib/browser/qa-run-contracts.d.ts +173 -0
- package/dist/lib/browser/qa-run-contracts.d.ts.map +1 -0
- package/dist/lib/browser/qa-run-contracts.js +226 -0
- package/dist/lib/browser/qa-run.d.ts +51 -0
- package/dist/lib/browser/qa-run.d.ts.map +1 -0
- package/dist/lib/browser/qa-run.js +684 -0
- package/dist/lib/coord-root-id.d.ts +9 -0
- package/dist/lib/coord-root-id.d.ts.map +1 -0
- package/dist/lib/coord-root-id.js +17 -0
- package/dist/lib/docs-lint.d.ts +2 -0
- package/dist/lib/docs-lint.d.ts.map +1 -1
- package/dist/lib/docs-lint.js +45 -80
- package/dist/lib/docs-metadata-audit.d.ts +3 -0
- package/dist/lib/docs-metadata-audit.d.ts.map +1 -1
- package/dist/lib/docs-metadata-audit.js +13 -23
- package/dist/lib/docs-metadata-sync.d.ts +1 -0
- package/dist/lib/docs-metadata-sync.d.ts.map +1 -1
- package/dist/lib/docs-metadata-sync.js +28 -10
- package/dist/lib/docs-repository-view.d.ts +22 -0
- package/dist/lib/docs-repository-view.d.ts.map +1 -0
- package/dist/lib/docs-repository-view.js +185 -0
- package/dist/lib/http/client.d.ts +11 -5
- package/dist/lib/http/client.d.ts.map +1 -1
- package/dist/lib/http/client.js +22 -4
- package/dist/lib/http/index.d.ts +1 -1
- package/dist/lib/http/index.d.ts.map +1 -1
- package/dist/lib/http/index.js +1 -1
- package/dist/lib/indexer-exclusions.d.ts +27 -0
- package/dist/lib/indexer-exclusions.d.ts.map +1 -0
- package/dist/lib/indexer-exclusions.js +176 -0
- package/dist/lib/instructions/apply.d.ts +3 -1
- package/dist/lib/instructions/apply.d.ts.map +1 -1
- package/dist/lib/instructions/apply.js +74 -3
- package/dist/lib/instructions/templates.d.ts.map +1 -1
- package/dist/lib/instructions/templates.js +11 -0
- package/dist/lib/local-file-url.d.ts +9 -0
- package/dist/lib/local-file-url.d.ts.map +1 -0
- package/dist/lib/local-file-url.js +20 -0
- package/dist/lib/web-performance.d.ts +118 -0
- package/dist/lib/web-performance.d.ts.map +1 -0
- package/dist/lib/web-performance.js +192 -0
- package/package.json +40 -2
- package/schemas/config.schema.json +58 -0
- package/schemas/event-v3.schema.json +324 -112
- package/src/commander.ts +488 -95
- package/src/commands/agents.ts +617 -237
- package/src/commands/artifacts.ts +40 -2
- package/src/commands/backup.ts +18 -14
- package/src/commands/browse-session.ts +12 -0
- package/src/commands/browse.ts +21 -7
- package/src/commands/conversations.ts +279 -0
- package/src/commands/deinit.ts +6 -0
- package/src/commands/diagnostics.ts +271 -0
- package/src/commands/docs.ts +25 -6
- package/src/commands/doctor.ts +75 -9
- package/src/commands/fetch.ts +7 -6
- package/src/commands/files.ts +243 -0
- package/src/commands/governor.ts +21 -12
- package/src/commands/inbox.ts +61 -0
- package/src/commands/init.ts +78 -16
- package/src/commands/ledger-v3.ts +503 -1
- package/src/commands/logs.ts +224 -0
- package/src/commands/messages.ts +61 -0
- package/src/commands/outline.ts +6 -2
- package/src/commands/qa-run.ts +184 -0
- package/src/commands/read.ts +6 -2
- package/src/commands/resources.ts +38 -0
- package/src/commands/semantic.ts +66 -1
- package/src/commands/storage.ts +310 -0
- package/src/commands/supervisor.ts +141 -0
- package/src/commands/tunnel.ts +66 -52
- package/src/commands/web.ts +96 -7
- package/src/commands/work.ts +3 -3
- package/src/commands/workflow.ts +21 -13
- package/src/core/agents/cli.ts +265 -55
- package/src/core/agents/health.ts +142 -0
- package/src/core/agents/live-authority-v3.ts +341 -10
- package/src/core/agents/live-lifecycle-v3.ts +6 -1
- package/src/core/agents/live-observation-v3.ts +6 -1
- package/src/core/agents/mailbox.ts +373 -0
- package/src/core/agents/reconcile-coordination-v3.ts +77 -0
- package/src/core/agents/render/prompt-context.ts +66 -15
- package/src/core/agents/render/session-context.ts +37 -3
- package/src/core/agents/rules/commit-conflict.ts +58 -1
- package/src/core/agents/rules/stop-hook.ts +105 -20
- package/src/core/agents/rules/verdict.ts +1 -0
- package/src/core/agents/session-events.ts +4 -0
- package/src/core/agents/session-finalization-state-v3.ts +1 -1
- package/src/core/agents/session-finalizer-v3.ts +8 -2
- package/src/core/agents/state/activity-log.ts +7 -2
- package/src/core/agents/state/heartbeat-writer.ts +27 -0
- package/src/core/agents/state/live-coordination-view.ts +16 -105
- package/src/core/agents/state/live-coordination-writer.ts +141 -0
- package/src/core/artifacts/index.ts +260 -11
- package/src/core/config.ts +235 -5
- package/src/core/conversations/archive.ts +237 -0
- package/src/core/conversations/catalog.ts +79 -0
- package/src/core/conversations/context-pack.ts +72 -0
- package/src/core/conversations/contract.ts +178 -0
- package/src/core/conversations/evaluation.ts +30 -0
- package/src/core/conversations/index.ts +9 -0
- package/src/core/conversations/lifecycle.ts +63 -0
- package/src/core/conversations/normalize.ts +105 -0
- package/src/core/conversations/query.ts +318 -0
- package/src/core/conversations/search-index.ts +48 -0
- package/src/core/diagnostics/advice.ts +147 -0
- package/src/core/diagnostics/bundle.ts +1142 -0
- package/src/core/diagnostics/comparison.ts +565 -0
- package/src/core/diagnostics/contract.ts +311 -0
- package/src/core/diagnostics/identity.ts +11 -0
- package/src/core/diagnostics/index.ts +7 -0
- package/src/core/diagnostics/replay.ts +314 -0
- package/src/core/diagnostics/sanitize.ts +97 -0
- package/src/core/events/legacy-storage/canary.ts +177 -0
- package/src/core/events/legacy-storage/compression.ts +130 -0
- package/src/core/events/legacy-storage/fence.ts +129 -0
- package/src/core/events/legacy-storage/index.ts +6 -0
- package/src/core/events/legacy-storage/inventory.ts +51 -0
- package/src/core/events/legacy-storage/manifest.ts +136 -0
- package/src/core/events/legacy-storage/reader.ts +178 -0
- package/src/core/events/v3/archive-retention.ts +251 -0
- package/src/core/events/v3/authority-outbox.ts +22 -1
- package/src/core/events/v3/base-contract.ts +17 -7
- package/src/core/events/v3/bootstrap.ts +195 -2
- package/src/core/events/v3/capabilities.ts +5 -3
- package/src/core/events/v3/control-witness.ts +339 -0
- package/src/core/events/v3/control-writer.ts +16 -0
- package/src/core/events/v3/control.ts +54 -18
- package/src/core/events/v3/coordination-transaction-recovery.ts +477 -0
- package/src/core/events/v3/coordination-view.ts +17 -1
- package/src/core/events/v3/generated.ts +1 -1
- package/src/core/events/v3/index.ts +14 -2
- package/src/core/events/v3/live-route-observer.ts +80 -0
- package/src/core/events/v3/live-routing.ts +65 -46
- package/src/core/events/v3/producers/coordination-recorder.ts +95 -10
- package/src/core/events/v3/producers/diagnostic-summaries.ts +593 -0
- package/src/core/events/v3/producers/hook-base.ts +15 -3
- package/src/core/events/v3/producers/intake.ts +31 -2
- package/src/core/events/v3/producers/producer-state-observer.ts +52 -0
- package/src/core/events/v3/producers/recorder.ts +681 -34
- package/src/core/events/v3/reader.ts +243 -2
- package/src/core/events/v3/rotation-config.ts +98 -0
- package/src/core/events/v3/runtime-build.ts +41 -0
- package/src/core/events/v3/runtime-identity.ts +16 -0
- package/src/core/events/v3/runtime-telemetry-capabilities.ts +14 -8
- package/src/core/events/v3/support-storage/classify.ts +209 -0
- package/src/core/events/v3/support-storage/eligibility.ts +58 -0
- package/src/core/events/v3/support-storage/index.ts +9 -0
- package/src/core/events/v3/support-storage/inventory.ts +135 -0
- package/src/core/events/v3/support-storage/logical-authority.ts +117 -0
- package/src/core/events/v3/support-storage/maintenance.ts +501 -0
- package/src/core/events/v3/support-storage/pack-contract.ts +337 -0
- package/src/core/events/v3/support-storage/pack-reader.ts +346 -0
- package/src/core/events/v3/support-storage/pack-writer.ts +352 -0
- package/src/core/events/v3/support-storage/recovery.ts +43 -0
- package/src/core/events/v3/turn-telemetry.ts +58 -7
- package/src/core/events/v3/writer.ts +168 -16
- package/src/core/governor/plan-read.ts +5 -18
- package/src/core/governor/planning.ts +5 -8
- package/src/core/governor/service-read.ts +320 -2
- package/src/core/governor/service.ts +49 -22
- package/src/core/guard/evidence-v3.ts +1 -0
- package/src/core/hooks/adapter/events.ts +1 -0
- package/src/core/hooks/adapter/output.ts +23 -5
- package/src/core/hooks/adapter/runtime-telemetry.ts +408 -13
- package/src/core/hooks/cli.ts +404 -233
- package/src/core/hooks/effects/image-capture.ts +4 -1
- package/src/core/hooks/health.ts +146 -0
- package/src/core/hooks/remediation-cap.ts +12 -6
- package/src/core/hooks/resolve/coord-root.ts +91 -11
- package/src/core/hooks/resolve/owner.ts +4 -0
- package/src/core/hooks/resolve/transcript.ts +18 -0
- package/src/core/inbox/contract.ts +81 -0
- package/src/core/inbox/index.ts +4 -0
- package/src/core/inbox/lifecycle.ts +104 -0
- package/src/core/inbox/service.ts +305 -0
- package/src/core/inbox/watcher.ts +36 -0
- package/src/core/presence/codec-digest.ts +15 -9
- package/src/core/presence/relay-client.ts +55 -7
- package/src/core/resources/contract.ts +98 -0
- package/src/core/resources/index.ts +5 -0
- package/src/core/resources/sampler.ts +458 -0
- package/src/core/resources/service-status.ts +62 -0
- package/src/core/resources/service.ts +337 -0
- package/src/core/resources/storage.ts +44 -0
- package/src/core/semantic/adapters.ts +200 -41
- package/src/core/semantic/contract.ts +135 -3
- package/src/core/semantic/index.ts +76 -2
- package/src/core/semantic/once.ts +93 -7
- package/src/core/semantic/prompt.ts +13 -1
- package/src/core/semantic/review.ts +803 -0
- package/src/core/semantic/routes.ts +30 -0
- package/src/core/semantic/scheduler.ts +49 -5
- package/src/core/semantic/service-status.ts +99 -5
- package/src/core/semantic/service.ts +116 -15
- package/src/core/semantic/soak.ts +638 -0
- package/src/core/semantic/storage.ts +20 -6
- package/src/core/semantic/usage.ts +272 -0
- package/src/core/semantic/validate.ts +31 -0
- package/src/core/storage/atomic-json.ts +15 -0
- package/src/core/storage/buffer.ts +124 -0
- package/src/core/storage/builtins.ts +972 -0
- package/src/core/storage/catalog.ts +467 -0
- package/src/core/storage/config.ts +423 -0
- package/src/core/storage/contract.ts +342 -0
- package/src/core/storage/durable-history.ts +738 -0
- package/src/core/storage/health.ts +76 -0
- package/src/core/storage/index.ts +15 -0
- package/src/core/storage/inventory.ts +859 -0
- package/src/core/storage/jsonl.ts +213 -0
- package/src/core/storage/log-retention.ts +555 -0
- package/src/core/storage/logger.ts +548 -0
- package/src/core/storage/maintenance-providers.ts +200 -0
- package/src/core/storage/maintenance.ts +929 -0
- package/src/core/storage/metrics.ts +199 -0
- package/src/core/storage/policy.ts +141 -0
- package/src/core/storage/process-log.ts +203 -0
- package/src/core/storage/query.ts +418 -0
- package/src/core/storage/receipts.ts +162 -0
- package/src/core/storage/segments.ts +721 -0
- package/src/core/storage/sink-graph.ts +343 -0
- package/src/core/storage/storm-control.ts +91 -0
- package/src/core/supervisor/activity.ts +193 -0
- package/src/core/supervisor/contract.ts +312 -0
- package/src/core/supervisor/explanations.ts +104 -0
- package/src/core/supervisor/findings.ts +788 -0
- package/src/core/supervisor/history.ts +61 -0
- package/src/core/supervisor/hook-health-alerts.ts +108 -0
- package/src/core/supervisor/hook-health-storage.ts +25 -0
- package/src/core/supervisor/hook-health.ts +301 -0
- package/src/core/supervisor/hooks.ts +35 -0
- package/src/core/supervisor/index.ts +14 -0
- package/src/core/supervisor/log-feed.ts +131 -0
- package/src/core/supervisor/service.ts +511 -0
- package/src/core/supervisor/services.ts +203 -0
- package/src/core/supervisor/status.ts +59 -0
- package/src/core/supervisor/storage.ts +126 -0
- package/src/core/supervisor/timeline.ts +133 -0
- package/src/core/work/state.ts +12 -21
- package/src/core/workflow/admission.ts +215 -0
- package/src/core/workflow/engine.ts +93 -1
- package/src/core/workflow/index.ts +10 -0
- package/src/core/workflow/live-session-v3.ts +2 -4
- package/src/core/workflow/proof.ts +54 -1
- package/src/core/workflow/run-state.ts +13 -1
- package/src/core/workflow/types.ts +39 -1
- package/src/index.ts +2 -0
- package/src/lazy-commands.ts +294 -0
- package/src/lib/browser/client.ts +6 -0
- package/src/lib/browser/index.ts +29 -0
- package/src/lib/browser/qa-run-contracts.ts +380 -0
- package/src/lib/browser/qa-run.ts +784 -0
- package/src/lib/coord-root-id.ts +23 -0
- package/src/lib/docs-lint.ts +58 -77
- package/src/lib/docs-metadata-audit.ts +26 -21
- package/src/lib/docs-metadata-sync.ts +32 -9
- package/src/lib/docs-repository-view.ts +220 -0
- package/src/lib/http/client.ts +44 -8
- package/src/lib/http/index.ts +6 -1
- package/src/lib/indexer-exclusions.ts +173 -0
- package/src/lib/instructions/apply.ts +81 -2
- package/src/lib/instructions/templates.ts +11 -0
- package/src/lib/local-file-url.ts +31 -0
- package/src/lib/web-performance.ts +335 -0
|
@@ -0,0 +1,874 @@
|
|
|
1
|
+
import { chmodSync, existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, realpathSync, } from "node:fs";
|
|
2
|
+
import { dirname, join, resolve, sep } from "node:path";
|
|
3
|
+
import { ARTIFACT_MANIFEST, artifactsRoot, configuredArtifactRetentionDays, createArtifact, inventoryArtifacts, releaseArtifact, resolveArtifactRef, showArtifact, } from "../artifacts/index.js";
|
|
4
|
+
import { currentHarneryRuntimeBuild } from "../events/v3/runtime-build.js";
|
|
5
|
+
import { writePrivateJsonAtomic } from "../storage/atomic-json.js";
|
|
6
|
+
import { SUPERVISOR_DIAGNOSTIC_LIMITS, SUPERVISOR_EXPLANATION_SCHEMA_VERSION, SUPERVISOR_FINDING_POLICY, SUPERVISOR_FINDING_SCHEMA_VERSION, SUPERVISOR_RESOURCE_BUDGET, SUPERVISOR_TIMELINE_SCHEMA_VERSION, } from "../supervisor/contract.js";
|
|
7
|
+
import { readWorkflowProof } from "../workflow/proof.js";
|
|
8
|
+
import { DIAGNOSTIC_ADVICE_LIMITS, DIAGNOSTIC_ADVICE_SCHEMA_VERSION, DIAGNOSTIC_BUNDLE_FILES, DIAGNOSTIC_BUNDLE_SCHEMA_VERSION, DIAGNOSTIC_COMMAND_SCHEMA_VERSION, DIAGNOSTIC_EXPECTED_SCHEMA_VERSION, DIAGNOSTIC_INPUT_SCHEMA_VERSION, DIAGNOSTIC_SUMMARY_SCHEMA_VERSION, } from "./contract.js";
|
|
9
|
+
import { pseudonymousMachineId } from "./identity.js";
|
|
10
|
+
import { canonicalJson, deriveCapturedExpected, replayDiagnosticInputs, sha256 } from "./replay.js";
|
|
11
|
+
import { sanitizeDiagnosticValue } from "./sanitize.js";
|
|
12
|
+
const SOURCE_FILE_LIMIT_BYTES = 1_500_000;
|
|
13
|
+
const DEFAULT_WINDOW_MS = 15 * 60 * 1_000;
|
|
14
|
+
const SHADOW_ADMISSION_CAPTURE_LIMIT = 20;
|
|
15
|
+
const PAYLOAD_FILES = DIAGNOSTIC_BUNDLE_FILES.filter((path) => path !== "diagnostic-manifest.json");
|
|
16
|
+
const SOURCE_SPECS = [
|
|
17
|
+
["supervisor.snapshot", ".harnery/supervisor/snapshot.json"],
|
|
18
|
+
["supervisor.history", ".harnery/supervisor/history.json"],
|
|
19
|
+
["supervisor.findings", ".harnery/supervisor/findings.json"],
|
|
20
|
+
["supervisor.activity", ".harnery/supervisor/activity.json"],
|
|
21
|
+
["supervisor.timelines", ".harnery/supervisor/timelines"],
|
|
22
|
+
["supervisor.explanations", ".harnery/supervisor/explanations"],
|
|
23
|
+
["supervisor.log-feed", ".harnery/supervisor/log-feed.json"],
|
|
24
|
+
["supervisor.hook-health", ".harnery/supervisor/hook-health.json"],
|
|
25
|
+
["resources.snapshot", ".harnery/resources/snapshot.json"],
|
|
26
|
+
["coordination.health", ".harnery/supervisor/coordination-health.json"],
|
|
27
|
+
];
|
|
28
|
+
export function captureDiagnosticBundle(repoRootRaw, input = {}) {
|
|
29
|
+
const repoRoot = resolve(repoRootRaw);
|
|
30
|
+
const now = input.now ?? new Date();
|
|
31
|
+
assertValidDate(now, "now");
|
|
32
|
+
const capturedAt = now.toISOString();
|
|
33
|
+
const aggregateStats = { sanitized_value_count: 0, omitted_value_count: 0 };
|
|
34
|
+
const sources = [
|
|
35
|
+
...SOURCE_SPECS.map(([sourceKind, relativePath]) => readCapturedSource(repoRoot, sourceKind, relativePath, aggregateStats)),
|
|
36
|
+
readShadowAdmissionSource(repoRoot, capturedAt, aggregateStats),
|
|
37
|
+
];
|
|
38
|
+
const selection = diagnosticSelection(input, sources, now);
|
|
39
|
+
const observations = {
|
|
40
|
+
schema_version: DIAGNOSTIC_INPUT_SCHEMA_VERSION,
|
|
41
|
+
captured_at: capturedAt,
|
|
42
|
+
selection,
|
|
43
|
+
sources,
|
|
44
|
+
};
|
|
45
|
+
const thresholds = {
|
|
46
|
+
schema_version: DIAGNOSTIC_INPUT_SCHEMA_VERSION,
|
|
47
|
+
values: {
|
|
48
|
+
diagnostic_limits: SUPERVISOR_DIAGNOSTIC_LIMITS,
|
|
49
|
+
finding_policy: SUPERVISOR_FINDING_POLICY,
|
|
50
|
+
resource_budget: SUPERVISOR_RESOURCE_BUDGET,
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
const expected = deriveCapturedExpected(observations, thresholds);
|
|
54
|
+
if (input.findingId && !expected.findings.some((finding) => finding.id === input.findingId)) {
|
|
55
|
+
throw new Error(`finding "${input.findingId}" is not present in the captured findings projection`);
|
|
56
|
+
}
|
|
57
|
+
const created = createArtifact(repoRoot, {
|
|
58
|
+
slug: "diagnostic-bundle",
|
|
59
|
+
purpose: input.findingId
|
|
60
|
+
? `Frozen diagnostics for finding ${input.findingId}`
|
|
61
|
+
: `Frozen diagnostics from ${selection.start_at} to ${selection.end_at}`,
|
|
62
|
+
retentionDays: input.retentionDays ?? configuredArtifactRetentionDays(repoRoot),
|
|
63
|
+
actor: input.actor,
|
|
64
|
+
now,
|
|
65
|
+
});
|
|
66
|
+
const inputsPath = join(created.path, "inputs");
|
|
67
|
+
mkdirSync(inputsPath, { recursive: true, mode: 0o700 });
|
|
68
|
+
tryChmod(inputsPath, 0o700);
|
|
69
|
+
const payloads = {
|
|
70
|
+
"inputs/observations.json": observations,
|
|
71
|
+
"inputs/thresholds.json": thresholds,
|
|
72
|
+
"expected.json": expected,
|
|
73
|
+
"summary.json": {},
|
|
74
|
+
};
|
|
75
|
+
const summaryBase = {
|
|
76
|
+
schema_version: DIAGNOSTIC_SUMMARY_SCHEMA_VERSION,
|
|
77
|
+
artifact_id: created.manifest.artifact_id,
|
|
78
|
+
captured_at: capturedAt,
|
|
79
|
+
machine_id: pseudonymousMachineId(input.machineLabel),
|
|
80
|
+
machine_id_kind: "pseudonymous",
|
|
81
|
+
selection,
|
|
82
|
+
source_count: sources.length,
|
|
83
|
+
supported_source_count: sources.filter((source) => source.capability === "supported").length,
|
|
84
|
+
sanitized_value_count: aggregateStats.sanitized_value_count,
|
|
85
|
+
omitted_value_count: aggregateStats.omitted_value_count,
|
|
86
|
+
};
|
|
87
|
+
const summary = stableSummary(summaryBase, payloads);
|
|
88
|
+
payloads["summary.json"] = summary;
|
|
89
|
+
for (const path of PAYLOAD_FILES)
|
|
90
|
+
writePrivateJsonAtomic(join(created.path, path), payloads[path]);
|
|
91
|
+
const files = PAYLOAD_FILES.map((path) => describeFile(created.path, path));
|
|
92
|
+
const capabilities = sources.map(sourceCapability);
|
|
93
|
+
const manifest = {
|
|
94
|
+
schema_version: DIAGNOSTIC_BUNDLE_SCHEMA_VERSION,
|
|
95
|
+
artifact_id: created.manifest.artifact_id,
|
|
96
|
+
captured_at: capturedAt,
|
|
97
|
+
machine_id: summary.machine_id,
|
|
98
|
+
finding_id: input.findingId,
|
|
99
|
+
time_range: { start_at: selection.start_at, end_at: selection.end_at },
|
|
100
|
+
engine_version: input.engineVersion ?? currentHarneryRuntimeBuild(),
|
|
101
|
+
threshold_digest: expected.threshold_digest,
|
|
102
|
+
sources: sources.map((source) => ({
|
|
103
|
+
source_kind: source.source_kind,
|
|
104
|
+
schema_version: source.schema_version,
|
|
105
|
+
capability: source.capability,
|
|
106
|
+
entry_count: countEntries(source.value),
|
|
107
|
+
omitted_count: source.value === undefined ? 1 : 0,
|
|
108
|
+
file: "inputs/observations.json",
|
|
109
|
+
})),
|
|
110
|
+
capabilities,
|
|
111
|
+
files,
|
|
112
|
+
replay: {
|
|
113
|
+
input_file: "inputs/observations.json",
|
|
114
|
+
thresholds_file: "inputs/thresholds.json",
|
|
115
|
+
expected_file: "expected.json",
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
writePrivateJsonAtomic(join(created.path, "diagnostic-manifest.json"), manifest);
|
|
119
|
+
validateDiagnosticBundle(repoRoot, created.manifest.artifact_id);
|
|
120
|
+
releaseArtifact(repoRoot, created.manifest.artifact_id, { actor: input.actor, now });
|
|
121
|
+
return { path: created.path, manifest, summary };
|
|
122
|
+
}
|
|
123
|
+
export function validateDiagnosticBundle(repoRootRaw, ref) {
|
|
124
|
+
const repoRoot = resolve(repoRootRaw);
|
|
125
|
+
const artifactPath = resolveArtifactRef(repoRoot, ref);
|
|
126
|
+
const managedRoot = realpathSync(artifactsRoot(repoRoot));
|
|
127
|
+
const resolvedArtifact = realpathSync(artifactPath);
|
|
128
|
+
if (dirname(resolvedArtifact) !== managedRoot ||
|
|
129
|
+
!resolvedArtifact.startsWith(`${managedRoot}${sep}`)) {
|
|
130
|
+
throw new Error("diagnostic bundle is outside the managed artifact root");
|
|
131
|
+
}
|
|
132
|
+
assertBundleTree(artifactPath);
|
|
133
|
+
const shown = showArtifact(repoRoot, artifactPath);
|
|
134
|
+
if (!["managed-active", "managed-current", "managed-expired", "managed-tracked"].includes(shown.entry.classification)) {
|
|
135
|
+
throw new Error(`diagnostic bundle has invalid managed classification ${shown.entry.classification}`);
|
|
136
|
+
}
|
|
137
|
+
if (shown.manifest.slug !== "diagnostic-bundle") {
|
|
138
|
+
throw new Error("artifact is not a diagnostic bundle");
|
|
139
|
+
}
|
|
140
|
+
const manifest = readJson(artifactPath, "diagnostic-manifest.json");
|
|
141
|
+
validateManifest(manifest, shown.manifest.artifact_id);
|
|
142
|
+
let totalBytes = 0;
|
|
143
|
+
for (const file of manifest.files) {
|
|
144
|
+
const bytes = readValidatedFile(artifactPath, file.path);
|
|
145
|
+
totalBytes += bytes.byteLength;
|
|
146
|
+
if (bytes.byteLength !== file.bytes)
|
|
147
|
+
throw new Error(`byte length mismatch for ${file.path}`);
|
|
148
|
+
if (sha256(bytes) !== file.sha256)
|
|
149
|
+
throw new Error(`digest mismatch for ${file.path}`);
|
|
150
|
+
}
|
|
151
|
+
if (totalBytes > SUPERVISOR_DIAGNOSTIC_LIMITS.max_bundle_bytes) {
|
|
152
|
+
throw new Error("diagnostic bundle exceeds the maximum byte limit");
|
|
153
|
+
}
|
|
154
|
+
const observations = readJson(artifactPath, manifest.replay.input_file);
|
|
155
|
+
const thresholds = readJson(artifactPath, manifest.replay.thresholds_file);
|
|
156
|
+
const expected = readJson(artifactPath, manifest.replay.expected_file);
|
|
157
|
+
const summary = readJson(artifactPath, "summary.json");
|
|
158
|
+
validatePayloads(manifest, observations, thresholds, expected, summary);
|
|
159
|
+
return { path: artifactPath, manifest, observations, thresholds, expected, summary };
|
|
160
|
+
}
|
|
161
|
+
/** Frozen web readers accept an opaque artifact id, never a filesystem path. */
|
|
162
|
+
export function readFrozenDiagnosticBundle(repoRoot, artifactId) {
|
|
163
|
+
if (!/^[A-Za-z0-9_-]{1,160}$/.test(artifactId)) {
|
|
164
|
+
throw new Error("diagnostic bundle id must be an opaque artifact id");
|
|
165
|
+
}
|
|
166
|
+
return validateDiagnosticBundle(repoRoot, artifactId);
|
|
167
|
+
}
|
|
168
|
+
export function showDiagnosticBundle(repoRoot, ref) {
|
|
169
|
+
return validateDiagnosticBundle(repoRoot, ref);
|
|
170
|
+
}
|
|
171
|
+
export function listDiagnosticBundles(repoRoot) {
|
|
172
|
+
return inventoryArtifacts(repoRoot)
|
|
173
|
+
.filter((entry) => entry.slug === "diagnostic-bundle" && entry.artifact_id)
|
|
174
|
+
.map((entry) => {
|
|
175
|
+
try {
|
|
176
|
+
const bundle = validateDiagnosticBundle(repoRoot, entry.artifact_id);
|
|
177
|
+
return {
|
|
178
|
+
artifact_id: entry.artifact_id,
|
|
179
|
+
created_at: entry.created_at ?? bundle.manifest.captured_at,
|
|
180
|
+
expires_at: entry.expires_at,
|
|
181
|
+
classification: entry.classification,
|
|
182
|
+
valid: true,
|
|
183
|
+
captured_at: bundle.manifest.captured_at,
|
|
184
|
+
finding_id: bundle.manifest.finding_id,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
return {
|
|
189
|
+
artifact_id: entry.artifact_id,
|
|
190
|
+
created_at: entry.created_at ?? "",
|
|
191
|
+
expires_at: entry.expires_at,
|
|
192
|
+
classification: entry.classification,
|
|
193
|
+
valid: false,
|
|
194
|
+
error: error instanceof Error ? error.message : String(error),
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
export function replayDiagnosticBundle(repoRoot, ref, now = new Date()) {
|
|
200
|
+
assertValidDate(now, "now");
|
|
201
|
+
const bundle = validateDiagnosticBundle(repoRoot, ref);
|
|
202
|
+
const actual = replayDiagnosticInputs(bundle.observations, bundle.thresholds);
|
|
203
|
+
const expectedDigest = sha256(canonicalJson(bundle.expected));
|
|
204
|
+
const actualDigest = sha256(canonicalJson(actual));
|
|
205
|
+
return {
|
|
206
|
+
schema_version: DIAGNOSTIC_COMMAND_SCHEMA_VERSION,
|
|
207
|
+
artifact_id: bundle.manifest.artifact_id,
|
|
208
|
+
replayed_at: now.toISOString(),
|
|
209
|
+
matched: expectedDigest === actualDigest,
|
|
210
|
+
threshold_digest: actual.threshold_digest,
|
|
211
|
+
expected_digest: expectedDigest,
|
|
212
|
+
actual_digest: actualDigest,
|
|
213
|
+
finding_count: actual.findings.length,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
function readCapturedSource(repoRoot, sourceKind, relativePath, aggregateStats) {
|
|
217
|
+
const path = join(repoRoot, relativePath);
|
|
218
|
+
if (!existsSync(path)) {
|
|
219
|
+
return { source_kind: sourceKind, capability: "unsupported", reason_code: "source_missing" };
|
|
220
|
+
}
|
|
221
|
+
try {
|
|
222
|
+
const stat = lstatSync(path);
|
|
223
|
+
if (stat.isSymbolicLink())
|
|
224
|
+
throw new Error("source_is_symlink");
|
|
225
|
+
const parsed = stat.isDirectory()
|
|
226
|
+
? readJsonDirectory(path)
|
|
227
|
+
: stat.isFile()
|
|
228
|
+
? readBoundedJsonFile(path)
|
|
229
|
+
: (() => {
|
|
230
|
+
throw new Error("source_is_not_regular_file");
|
|
231
|
+
})();
|
|
232
|
+
const sanitized = sanitizeDiagnosticValue(parsed);
|
|
233
|
+
aggregateStats.sanitized_value_count += sanitized.stats.sanitized_value_count;
|
|
234
|
+
aggregateStats.omitted_value_count += sanitized.stats.omitted_value_count;
|
|
235
|
+
const value = sanitized.value;
|
|
236
|
+
const record = object(value);
|
|
237
|
+
return {
|
|
238
|
+
source_kind: sourceKind,
|
|
239
|
+
capability: "supported",
|
|
240
|
+
schema_version: numeric(record?.schema_version),
|
|
241
|
+
observed_at: timestamp(record),
|
|
242
|
+
value,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
catch (error) {
|
|
246
|
+
return {
|
|
247
|
+
source_kind: sourceKind,
|
|
248
|
+
capability: "error",
|
|
249
|
+
reason_code: error instanceof Error ? error.message : String(error),
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
function readShadowAdmissionSource(repoRoot, capturedAt, aggregateStats) {
|
|
254
|
+
const sourceKind = "workflow.diagnostic-admission";
|
|
255
|
+
const workflowsRoot = join(repoRoot, ".harnery", "workflows");
|
|
256
|
+
if (!existsSync(workflowsRoot)) {
|
|
257
|
+
return { source_kind: sourceKind, capability: "unsupported", reason_code: "source_missing" };
|
|
258
|
+
}
|
|
259
|
+
try {
|
|
260
|
+
const rootStat = lstatSync(workflowsRoot);
|
|
261
|
+
if (rootStat.isSymbolicLink() || !rootStat.isDirectory()) {
|
|
262
|
+
throw new Error("workflow_root_is_not_regular_directory");
|
|
263
|
+
}
|
|
264
|
+
const candidates = readdirSync(workflowsRoot, { withFileTypes: true })
|
|
265
|
+
.filter((entry) => entry.isDirectory() && /^[A-Za-z0-9][A-Za-z0-9._-]{0,199}$/.test(entry.name))
|
|
266
|
+
.map((entry) => entry.name)
|
|
267
|
+
.sort((left, right) => right.localeCompare(left));
|
|
268
|
+
const records = [];
|
|
269
|
+
let invalidCount = 0;
|
|
270
|
+
const scanLimit = SHADOW_ADMISSION_CAPTURE_LIMIT * 2;
|
|
271
|
+
for (const runId of candidates.slice(0, scanLimit)) {
|
|
272
|
+
try {
|
|
273
|
+
const proof = readWorkflowProof(repoRoot, runId);
|
|
274
|
+
const admission = proof.diagnostic_admission;
|
|
275
|
+
if (!admission)
|
|
276
|
+
continue;
|
|
277
|
+
records.push({
|
|
278
|
+
run_id: proof.run.id,
|
|
279
|
+
ended_at: proof.run.ended_at,
|
|
280
|
+
state: admission.state,
|
|
281
|
+
action: admission.action,
|
|
282
|
+
...(admission.reason_code ? { reason_code: admission.reason_code } : {}),
|
|
283
|
+
...(admission.observation
|
|
284
|
+
? {
|
|
285
|
+
pressure: admission.observation.advice.pressure,
|
|
286
|
+
fan_out_recommendation: admission.observation.advice.fan_out_recommendation,
|
|
287
|
+
freshness: admission.observation.freshness,
|
|
288
|
+
service_state: admission.observation.service_state,
|
|
289
|
+
wait_ms: admission.observation.wait_ms,
|
|
290
|
+
}
|
|
291
|
+
: {}),
|
|
292
|
+
});
|
|
293
|
+
if (records.length >= SHADOW_ADMISSION_CAPTURE_LIMIT)
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
catch {
|
|
297
|
+
invalidCount += 1;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
const omittedCount = Math.max(0, candidates.length - Math.min(candidates.length, scanLimit));
|
|
301
|
+
const projection = {
|
|
302
|
+
schema_version: 1,
|
|
303
|
+
captured_at: capturedAt,
|
|
304
|
+
max_records: SHADOW_ADMISSION_CAPTURE_LIMIT,
|
|
305
|
+
examined_run_count: Math.min(candidates.length, scanLimit),
|
|
306
|
+
omitted_run_count: omittedCount,
|
|
307
|
+
invalid_run_count: invalidCount,
|
|
308
|
+
records,
|
|
309
|
+
};
|
|
310
|
+
const sanitized = sanitizeDiagnosticValue(projection);
|
|
311
|
+
aggregateStats.sanitized_value_count += sanitized.stats.sanitized_value_count;
|
|
312
|
+
aggregateStats.omitted_value_count += sanitized.stats.omitted_value_count;
|
|
313
|
+
return {
|
|
314
|
+
source_kind: sourceKind,
|
|
315
|
+
capability: omittedCount > 0 || invalidCount > 0 ? "partial" : "supported",
|
|
316
|
+
schema_version: 1,
|
|
317
|
+
observed_at: records[0]?.ended_at,
|
|
318
|
+
value: sanitized.value,
|
|
319
|
+
...(omittedCount > 0
|
|
320
|
+
? { reason_code: "bounded_workflow_window_truncated" }
|
|
321
|
+
: invalidCount > 0
|
|
322
|
+
? { reason_code: "invalid_workflow_proofs_ignored" }
|
|
323
|
+
: {}),
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
catch (error) {
|
|
327
|
+
return {
|
|
328
|
+
source_kind: sourceKind,
|
|
329
|
+
capability: "error",
|
|
330
|
+
reason_code: error instanceof Error ? error.message : String(error),
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
function readBoundedJsonFile(path) {
|
|
335
|
+
const stat = lstatSync(path);
|
|
336
|
+
if (stat.isSymbolicLink() || !stat.isFile())
|
|
337
|
+
throw new Error("source_is_not_regular_file");
|
|
338
|
+
if (stat.size > SOURCE_FILE_LIMIT_BYTES)
|
|
339
|
+
throw new Error("source_exceeds_byte_limit");
|
|
340
|
+
return JSON.parse(readFileSync(path, "utf8"));
|
|
341
|
+
}
|
|
342
|
+
function readJsonDirectory(path) {
|
|
343
|
+
const values = [];
|
|
344
|
+
let totalBytes = 0;
|
|
345
|
+
const names = readdirSync(path).sort();
|
|
346
|
+
if (names.length > SUPERVISOR_DIAGNOSTIC_LIMITS.max_findings) {
|
|
347
|
+
throw new Error("source_directory_exceeds_entry_limit");
|
|
348
|
+
}
|
|
349
|
+
for (const name of names) {
|
|
350
|
+
if (!/^[A-Za-z0-9_.-]+\.json$/.test(name)) {
|
|
351
|
+
throw new Error("source_directory_contains_unexpected_entry");
|
|
352
|
+
}
|
|
353
|
+
const file = join(path, name);
|
|
354
|
+
const stat = lstatSync(file);
|
|
355
|
+
if (stat.isSymbolicLink() || !stat.isFile()) {
|
|
356
|
+
throw new Error("source_directory_contains_nonregular_file");
|
|
357
|
+
}
|
|
358
|
+
totalBytes += stat.size;
|
|
359
|
+
if (totalBytes > SOURCE_FILE_LIMIT_BYTES)
|
|
360
|
+
throw new Error("source_exceeds_byte_limit");
|
|
361
|
+
values.push(readBoundedJsonFile(file));
|
|
362
|
+
}
|
|
363
|
+
return values;
|
|
364
|
+
}
|
|
365
|
+
function diagnosticSelection(input, sources, now) {
|
|
366
|
+
if ((input.startAt === undefined) !== (input.endAt === undefined)) {
|
|
367
|
+
throw new Error("--from and --to must be supplied together");
|
|
368
|
+
}
|
|
369
|
+
if (input.findingId && input.startAt) {
|
|
370
|
+
throw new Error("--finding cannot be combined with --from and --to");
|
|
371
|
+
}
|
|
372
|
+
if (input.findingId) {
|
|
373
|
+
if (!/^[A-Za-z0-9_.:-]{1,240}$/.test(input.findingId))
|
|
374
|
+
throw new Error("invalid finding id");
|
|
375
|
+
const finding = allFindings(sources).find((candidate) => candidate.id === input.findingId);
|
|
376
|
+
if (!finding) {
|
|
377
|
+
return {
|
|
378
|
+
finding_id: input.findingId,
|
|
379
|
+
start_at: now.toISOString(),
|
|
380
|
+
end_at: now.toISOString(),
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
return {
|
|
384
|
+
finding_id: input.findingId,
|
|
385
|
+
start_at: finding.opened_at,
|
|
386
|
+
end_at: finding.resolved_at ?? finding.observed_at,
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
const start = input.startAt
|
|
390
|
+
? parseIso(input.startAt, "--from")
|
|
391
|
+
: new Date(now.getTime() - DEFAULT_WINDOW_MS);
|
|
392
|
+
const end = input.endAt ? parseIso(input.endAt, "--to") : now;
|
|
393
|
+
if (start.getTime() > end.getTime())
|
|
394
|
+
throw new Error("--from must not follow --to");
|
|
395
|
+
return { start_at: start.toISOString(), end_at: end.toISOString() };
|
|
396
|
+
}
|
|
397
|
+
function allFindings(sources) {
|
|
398
|
+
const value = sources.find((source) => source.source_kind === "supervisor.findings")?.value;
|
|
399
|
+
const record = object(value);
|
|
400
|
+
return [
|
|
401
|
+
...arrayObjects(record?.active),
|
|
402
|
+
...arrayObjects(record?.transitions),
|
|
403
|
+
];
|
|
404
|
+
}
|
|
405
|
+
function sourceCapability(source) {
|
|
406
|
+
return {
|
|
407
|
+
source_kind: source.source_kind,
|
|
408
|
+
state: source.capability,
|
|
409
|
+
reason_code: source.reason_code,
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
function stableSummary(base, payloads) {
|
|
413
|
+
let summary = { ...base, total_bytes: 0 };
|
|
414
|
+
for (let attempt = 0; attempt < 8; attempt += 1) {
|
|
415
|
+
const total = PAYLOAD_FILES.reduce((sum, path) => {
|
|
416
|
+
const value = path === "summary.json" ? summary : payloads[path];
|
|
417
|
+
return sum + Buffer.byteLength(`${JSON.stringify(value)}\n`);
|
|
418
|
+
}, 0);
|
|
419
|
+
if (total === summary.total_bytes)
|
|
420
|
+
return summary;
|
|
421
|
+
summary = { ...base, total_bytes: total };
|
|
422
|
+
}
|
|
423
|
+
return summary;
|
|
424
|
+
}
|
|
425
|
+
function describeFile(root, path) {
|
|
426
|
+
const bytes = readValidatedFile(root, path);
|
|
427
|
+
return { path, media_type: "application/json", bytes: bytes.byteLength, sha256: sha256(bytes) };
|
|
428
|
+
}
|
|
429
|
+
function assertBundleTree(root) {
|
|
430
|
+
const rootStat = lstatSync(root);
|
|
431
|
+
if (rootStat.isSymbolicLink() || !rootStat.isDirectory()) {
|
|
432
|
+
throw new Error("diagnostic bundle root must be a regular directory");
|
|
433
|
+
}
|
|
434
|
+
const top = readdirSync(root).sort();
|
|
435
|
+
const expectedTop = [
|
|
436
|
+
ARTIFACT_MANIFEST,
|
|
437
|
+
"diagnostic-manifest.json",
|
|
438
|
+
"expected.json",
|
|
439
|
+
"inputs",
|
|
440
|
+
"summary.json",
|
|
441
|
+
].sort();
|
|
442
|
+
if (top.join("\0") !== expectedTop.join("\0"))
|
|
443
|
+
throw new Error("diagnostic bundle file set is not exact");
|
|
444
|
+
const inputs = join(root, "inputs");
|
|
445
|
+
const inputsStat = lstatSync(inputs);
|
|
446
|
+
if (inputsStat.isSymbolicLink() || !inputsStat.isDirectory()) {
|
|
447
|
+
throw new Error("diagnostic bundle inputs must be a regular directory");
|
|
448
|
+
}
|
|
449
|
+
const inputFiles = readdirSync(inputs).sort();
|
|
450
|
+
if (inputFiles.join("\0") !== ["observations.json", "thresholds.json"].join("\0")) {
|
|
451
|
+
throw new Error("diagnostic bundle input file set is not exact");
|
|
452
|
+
}
|
|
453
|
+
for (const path of [...PAYLOAD_FILES, "diagnostic-manifest.json"]) {
|
|
454
|
+
readValidatedFile(root, path);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
function readValidatedFile(rootRaw, relativePath) {
|
|
458
|
+
if (!PAYLOAD_FILES.includes(relativePath) &&
|
|
459
|
+
relativePath !== "diagnostic-manifest.json") {
|
|
460
|
+
throw new Error(`unexpected diagnostic bundle path ${relativePath}`);
|
|
461
|
+
}
|
|
462
|
+
const root = realpathSync(resolve(rootRaw));
|
|
463
|
+
const path = resolve(root, relativePath);
|
|
464
|
+
if (!path.startsWith(`${root}${sep}`))
|
|
465
|
+
throw new Error(`path escapes diagnostic bundle: ${relativePath}`);
|
|
466
|
+
const stat = lstatSync(path);
|
|
467
|
+
if (stat.isSymbolicLink() || !stat.isFile())
|
|
468
|
+
throw new Error(`${relativePath} is not a regular file`);
|
|
469
|
+
const real = realpathSync(path);
|
|
470
|
+
if (!real.startsWith(`${root}${sep}`))
|
|
471
|
+
throw new Error(`path escapes diagnostic bundle: ${relativePath}`);
|
|
472
|
+
if (stat.size > SUPERVISOR_DIAGNOSTIC_LIMITS.max_bundle_bytes) {
|
|
473
|
+
throw new Error(`${relativePath} exceeds the maximum byte limit`);
|
|
474
|
+
}
|
|
475
|
+
return readFileSync(real);
|
|
476
|
+
}
|
|
477
|
+
function readJson(root, relativePath) {
|
|
478
|
+
const bytes = readValidatedFile(root, relativePath);
|
|
479
|
+
try {
|
|
480
|
+
const value = JSON.parse(bytes.toString("utf8"));
|
|
481
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
482
|
+
throw new Error("root must be an object");
|
|
483
|
+
}
|
|
484
|
+
return value;
|
|
485
|
+
}
|
|
486
|
+
catch (error) {
|
|
487
|
+
throw new Error(`${relativePath} is invalid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
function validateManifest(manifest, artifactId) {
|
|
491
|
+
assertKeys(manifest, [
|
|
492
|
+
"schema_version",
|
|
493
|
+
"artifact_id",
|
|
494
|
+
"captured_at",
|
|
495
|
+
"machine_id",
|
|
496
|
+
"time_range",
|
|
497
|
+
"engine_version",
|
|
498
|
+
"threshold_digest",
|
|
499
|
+
"sources",
|
|
500
|
+
"capabilities",
|
|
501
|
+
"files",
|
|
502
|
+
"replay",
|
|
503
|
+
], ["finding_id"], "diagnostic manifest");
|
|
504
|
+
if (manifest.schema_version !== DIAGNOSTIC_BUNDLE_SCHEMA_VERSION)
|
|
505
|
+
throw new Error("unsupported diagnostic manifest schema");
|
|
506
|
+
if (manifest.artifact_id !== artifactId)
|
|
507
|
+
throw new Error("diagnostic artifact id does not match managed artifact id");
|
|
508
|
+
if (!validIso(manifest.captured_at) ||
|
|
509
|
+
!validIso(manifest.time_range?.start_at) ||
|
|
510
|
+
!validIso(manifest.time_range?.end_at)) {
|
|
511
|
+
throw new Error("diagnostic manifest has an invalid timestamp");
|
|
512
|
+
}
|
|
513
|
+
if (!/^machine_[0-9a-f]{64}$/.test(manifest.machine_id))
|
|
514
|
+
throw new Error("diagnostic machine id is not pseudonymous");
|
|
515
|
+
if (!/^[0-9a-f]{64}$/.test(manifest.threshold_digest))
|
|
516
|
+
throw new Error("invalid threshold digest");
|
|
517
|
+
if (typeof manifest.engine_version !== "string" ||
|
|
518
|
+
!/^[0-9A-Za-z._+-]{1,100}$/.test(manifest.engine_version)) {
|
|
519
|
+
throw new Error("invalid diagnostic engine version");
|
|
520
|
+
}
|
|
521
|
+
assertSelection(manifest.time_range, "diagnostic manifest time range", false);
|
|
522
|
+
if (!Array.isArray(manifest.sources) ||
|
|
523
|
+
manifest.sources.length > SUPERVISOR_DIAGNOSTIC_LIMITS.max_capabilities) {
|
|
524
|
+
throw new Error("diagnostic manifest sources exceed the limit");
|
|
525
|
+
}
|
|
526
|
+
for (const source of manifest.sources) {
|
|
527
|
+
assertKeys(source, ["source_kind", "capability", "entry_count", "omitted_count", "file"], ["schema_version"], "diagnostic manifest source");
|
|
528
|
+
if (!validSourceKind(source.source_kind) || !validCapabilityState(source.capability))
|
|
529
|
+
throw new Error("invalid diagnostic manifest source");
|
|
530
|
+
if (source.schema_version !== undefined &&
|
|
531
|
+
(!Number.isInteger(source.schema_version) || source.schema_version < 0))
|
|
532
|
+
throw new Error("invalid diagnostic source schema version");
|
|
533
|
+
if (!boundedInteger(source.entry_count, 0, 50_000) ||
|
|
534
|
+
!boundedInteger(source.omitted_count, 0, 50_000) ||
|
|
535
|
+
source.file !== "inputs/observations.json")
|
|
536
|
+
throw new Error("invalid diagnostic manifest source counts");
|
|
537
|
+
}
|
|
538
|
+
validateCapabilities(manifest.capabilities, "diagnostic manifest capabilities");
|
|
539
|
+
if (!Array.isArray(manifest.files) || manifest.files.length !== PAYLOAD_FILES.length)
|
|
540
|
+
throw new Error("diagnostic manifest file list is incomplete");
|
|
541
|
+
const listed = manifest.files.map((file) => file.path).sort();
|
|
542
|
+
if (listed.join("\0") !== [...PAYLOAD_FILES].sort().join("\0"))
|
|
543
|
+
throw new Error("diagnostic manifest file list is not exact");
|
|
544
|
+
for (const file of manifest.files) {
|
|
545
|
+
assertKeys(file, ["path", "media_type", "bytes", "sha256"], [], "diagnostic file descriptor");
|
|
546
|
+
if (file.media_type !== "application/json" ||
|
|
547
|
+
!Number.isInteger(file.bytes) ||
|
|
548
|
+
file.bytes < 1 ||
|
|
549
|
+
!/^[0-9a-f]{64}$/.test(file.sha256)) {
|
|
550
|
+
throw new Error(`invalid diagnostic file descriptor for ${String(file.path)}`);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
assertKeys(manifest.replay, ["input_file", "thresholds_file", "expected_file"], [], "diagnostic replay contract");
|
|
554
|
+
if (manifest.replay?.input_file !== "inputs/observations.json" ||
|
|
555
|
+
manifest.replay?.thresholds_file !== "inputs/thresholds.json" ||
|
|
556
|
+
manifest.replay?.expected_file !== "expected.json") {
|
|
557
|
+
throw new Error("diagnostic replay file contract is invalid");
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
function validatePayloads(manifest, observations, thresholds, expected, summary) {
|
|
561
|
+
assertKeys(observations, ["schema_version", "captured_at", "selection", "sources"], [], "diagnostic observations");
|
|
562
|
+
assertKeys(thresholds, ["schema_version", "values"], [], "diagnostic thresholds");
|
|
563
|
+
assertKeys(expected, [
|
|
564
|
+
"schema_version",
|
|
565
|
+
"threshold_digest",
|
|
566
|
+
"selection",
|
|
567
|
+
"findings",
|
|
568
|
+
"timelines",
|
|
569
|
+
"explanations",
|
|
570
|
+
"advice",
|
|
571
|
+
], [], "diagnostic expected output");
|
|
572
|
+
assertKeys(summary, [
|
|
573
|
+
"schema_version",
|
|
574
|
+
"artifact_id",
|
|
575
|
+
"captured_at",
|
|
576
|
+
"machine_id",
|
|
577
|
+
"machine_id_kind",
|
|
578
|
+
"selection",
|
|
579
|
+
"source_count",
|
|
580
|
+
"supported_source_count",
|
|
581
|
+
"sanitized_value_count",
|
|
582
|
+
"omitted_value_count",
|
|
583
|
+
"total_bytes",
|
|
584
|
+
], [], "diagnostic summary");
|
|
585
|
+
if (observations.schema_version !== DIAGNOSTIC_INPUT_SCHEMA_VERSION ||
|
|
586
|
+
thresholds.schema_version !== DIAGNOSTIC_INPUT_SCHEMA_VERSION) {
|
|
587
|
+
throw new Error("unsupported diagnostic input schema");
|
|
588
|
+
}
|
|
589
|
+
if (!Array.isArray(observations.sources) || !validIso(observations.captured_at))
|
|
590
|
+
throw new Error("invalid diagnostic observations");
|
|
591
|
+
if (observations.sources.length > SUPERVISOR_DIAGNOSTIC_LIMITS.max_capabilities)
|
|
592
|
+
throw new Error("diagnostic observations exceed the source limit");
|
|
593
|
+
assertSelection(observations.selection, "diagnostic observation selection", true);
|
|
594
|
+
for (const source of observations.sources) {
|
|
595
|
+
assertKeys(source, ["source_kind", "capability"], ["schema_version", "observed_at", "value", "reason_code"], "diagnostic captured source");
|
|
596
|
+
if (!validSourceKind(source.source_kind) || !validCapabilityState(source.capability))
|
|
597
|
+
throw new Error("invalid diagnostic captured source");
|
|
598
|
+
if (source.schema_version !== undefined &&
|
|
599
|
+
(!Number.isInteger(source.schema_version) || source.schema_version < 0))
|
|
600
|
+
throw new Error("invalid captured source schema version");
|
|
601
|
+
if (source.observed_at !== undefined && !validIso(source.observed_at))
|
|
602
|
+
throw new Error("invalid captured source timestamp");
|
|
603
|
+
if (source.reason_code !== undefined &&
|
|
604
|
+
(typeof source.reason_code !== "string" || source.reason_code.length > 240))
|
|
605
|
+
throw new Error("invalid captured source reason code");
|
|
606
|
+
}
|
|
607
|
+
if (!thresholds.values ||
|
|
608
|
+
typeof thresholds.values !== "object" ||
|
|
609
|
+
Array.isArray(thresholds.values))
|
|
610
|
+
throw new Error("invalid diagnostic threshold values");
|
|
611
|
+
if (expected.schema_version !== DIAGNOSTIC_EXPECTED_SCHEMA_VERSION)
|
|
612
|
+
throw new Error("unsupported diagnostic expected schema");
|
|
613
|
+
assertSelection(expected.selection, "diagnostic expected selection", true);
|
|
614
|
+
if (canonicalJson(expected.selection) !== canonicalJson(observations.selection))
|
|
615
|
+
throw new Error("diagnostic expected selection does not match inputs");
|
|
616
|
+
validateExpectedRecords(expected);
|
|
617
|
+
if (expected.threshold_digest !== sha256(canonicalJson(thresholds)) ||
|
|
618
|
+
expected.threshold_digest !== manifest.threshold_digest) {
|
|
619
|
+
throw new Error("captured threshold digest does not match manifest");
|
|
620
|
+
}
|
|
621
|
+
if (summary.schema_version !== DIAGNOSTIC_SUMMARY_SCHEMA_VERSION ||
|
|
622
|
+
summary.artifact_id !== manifest.artifact_id ||
|
|
623
|
+
summary.machine_id !== manifest.machine_id ||
|
|
624
|
+
summary.machine_id_kind !== "pseudonymous") {
|
|
625
|
+
throw new Error("invalid diagnostic summary");
|
|
626
|
+
}
|
|
627
|
+
assertSelection(summary.selection, "diagnostic summary selection", true);
|
|
628
|
+
for (const count of [
|
|
629
|
+
summary.source_count,
|
|
630
|
+
summary.supported_source_count,
|
|
631
|
+
summary.sanitized_value_count,
|
|
632
|
+
summary.omitted_value_count,
|
|
633
|
+
summary.total_bytes,
|
|
634
|
+
]) {
|
|
635
|
+
if (!boundedInteger(count, 0, SUPERVISOR_DIAGNOSTIC_LIMITS.max_bundle_bytes))
|
|
636
|
+
throw new Error("invalid diagnostic summary count");
|
|
637
|
+
}
|
|
638
|
+
if (summary.source_count !== observations.sources.length ||
|
|
639
|
+
summary.supported_source_count > summary.source_count)
|
|
640
|
+
throw new Error("diagnostic summary source counts do not match inputs");
|
|
641
|
+
}
|
|
642
|
+
function validateExpectedRecords(expected) {
|
|
643
|
+
if (!Array.isArray(expected.findings) ||
|
|
644
|
+
expected.findings.length > SUPERVISOR_DIAGNOSTIC_LIMITS.max_findings)
|
|
645
|
+
throw new Error("diagnostic expected findings exceed the limit");
|
|
646
|
+
if (!Array.isArray(expected.timelines) ||
|
|
647
|
+
expected.timelines.length > SUPERVISOR_DIAGNOSTIC_LIMITS.max_findings)
|
|
648
|
+
throw new Error("diagnostic expected timelines exceed the limit");
|
|
649
|
+
if (!Array.isArray(expected.explanations) ||
|
|
650
|
+
expected.explanations.length > SUPERVISOR_DIAGNOSTIC_LIMITS.max_findings)
|
|
651
|
+
throw new Error("diagnostic expected explanations exceed the limit");
|
|
652
|
+
for (const finding of expected.findings) {
|
|
653
|
+
if (!finding ||
|
|
654
|
+
typeof finding !== "object" ||
|
|
655
|
+
finding.schema_version !== SUPERVISOR_FINDING_SCHEMA_VERSION)
|
|
656
|
+
throw new Error("invalid diagnostic expected finding schema");
|
|
657
|
+
if (!Array.isArray(finding.evidence) ||
|
|
658
|
+
finding.evidence.length > SUPERVISOR_DIAGNOSTIC_LIMITS.max_evidence_per_finding)
|
|
659
|
+
throw new Error("diagnostic finding evidence exceeds the limit");
|
|
660
|
+
validateCapabilities(finding.capabilities, "diagnostic finding capabilities");
|
|
661
|
+
}
|
|
662
|
+
for (const timeline of expected.timelines) {
|
|
663
|
+
if (!timeline ||
|
|
664
|
+
typeof timeline !== "object" ||
|
|
665
|
+
timeline.schema_version !== SUPERVISOR_TIMELINE_SCHEMA_VERSION)
|
|
666
|
+
throw new Error("invalid diagnostic timeline schema");
|
|
667
|
+
if (!Array.isArray(timeline.entries) ||
|
|
668
|
+
timeline.entries.length > SUPERVISOR_DIAGNOSTIC_LIMITS.max_timeline_entries)
|
|
669
|
+
throw new Error("diagnostic timeline entries exceed the limit");
|
|
670
|
+
validateCapabilities(timeline.capabilities, "diagnostic timeline capabilities");
|
|
671
|
+
if (!boundedInteger(timeline.compacted_entries, 0, 50_000))
|
|
672
|
+
throw new Error("invalid diagnostic timeline compaction count");
|
|
673
|
+
for (const entry of timeline.entries) {
|
|
674
|
+
if (!entry ||
|
|
675
|
+
!validIso(entry.first_occurred_at) ||
|
|
676
|
+
!validIso(entry.last_occurred_at) ||
|
|
677
|
+
!boundedInteger(entry.occurrence_count, 1, 50_000) ||
|
|
678
|
+
Date.parse(entry.first_occurred_at) > Date.parse(entry.last_occurred_at)) {
|
|
679
|
+
throw new Error("invalid diagnostic timeline entry cluster");
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
for (const explanation of expected.explanations) {
|
|
684
|
+
if (!explanation ||
|
|
685
|
+
typeof explanation !== "object" ||
|
|
686
|
+
explanation.schema_version !== SUPERVISOR_EXPLANATION_SCHEMA_VERSION)
|
|
687
|
+
throw new Error("invalid diagnostic explanation schema");
|
|
688
|
+
for (const rows of [
|
|
689
|
+
explanation.observed,
|
|
690
|
+
explanation.related,
|
|
691
|
+
explanation.possible,
|
|
692
|
+
explanation.missing_capabilities,
|
|
693
|
+
]) {
|
|
694
|
+
if (!Array.isArray(rows) || rows.length > SUPERVISOR_DIAGNOSTIC_LIMITS.max_explanation_items)
|
|
695
|
+
throw new Error("diagnostic explanation entries exceed the limit");
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
validateAdvice(expected.advice);
|
|
699
|
+
}
|
|
700
|
+
function validateAdvice(advice) {
|
|
701
|
+
assertKeys(advice, [
|
|
702
|
+
"schema_version",
|
|
703
|
+
"evaluated_at",
|
|
704
|
+
"pressure",
|
|
705
|
+
"fan_out_recommendation",
|
|
706
|
+
"observer_only",
|
|
707
|
+
"summary",
|
|
708
|
+
"source_capability",
|
|
709
|
+
"active_finding_count",
|
|
710
|
+
"contributing_finding_count",
|
|
711
|
+
"omitted_contributing_finding_count",
|
|
712
|
+
"contributing_findings",
|
|
713
|
+
"reasons",
|
|
714
|
+
], [], "diagnostic advice");
|
|
715
|
+
if (advice.schema_version !== DIAGNOSTIC_ADVICE_SCHEMA_VERSION ||
|
|
716
|
+
!validIso(advice.evaluated_at) ||
|
|
717
|
+
!["normal", "elevated", "critical", "unknown"].includes(advice.pressure) ||
|
|
718
|
+
!["proceed", "use-caution", "avoid-new-fan-out", "unknown"].includes(advice.fan_out_recommendation) ||
|
|
719
|
+
advice.observer_only !== true ||
|
|
720
|
+
typeof advice.summary !== "string" ||
|
|
721
|
+
advice.summary.length > SUPERVISOR_DIAGNOSTIC_LIMITS.max_summary_chars) {
|
|
722
|
+
throw new Error("invalid diagnostic advice contract");
|
|
723
|
+
}
|
|
724
|
+
validateCapabilities([advice.source_capability], "diagnostic advice capability");
|
|
725
|
+
for (const count of [
|
|
726
|
+
advice.active_finding_count,
|
|
727
|
+
advice.contributing_finding_count,
|
|
728
|
+
advice.omitted_contributing_finding_count,
|
|
729
|
+
]) {
|
|
730
|
+
if (!boundedInteger(count, 0, SUPERVISOR_DIAGNOSTIC_LIMITS.max_findings))
|
|
731
|
+
throw new Error("invalid diagnostic advice count");
|
|
732
|
+
}
|
|
733
|
+
if (!Array.isArray(advice.contributing_findings) ||
|
|
734
|
+
advice.contributing_findings.length > DIAGNOSTIC_ADVICE_LIMITS.max_contributing_findings ||
|
|
735
|
+
!Array.isArray(advice.reasons) ||
|
|
736
|
+
advice.reasons.length > DIAGNOSTIC_ADVICE_LIMITS.max_reasons) {
|
|
737
|
+
throw new Error("diagnostic advice entries exceed the limit");
|
|
738
|
+
}
|
|
739
|
+
for (const finding of advice.contributing_findings) {
|
|
740
|
+
assertKeys(finding, [
|
|
741
|
+
"finding_id",
|
|
742
|
+
"finding_kind",
|
|
743
|
+
"severity",
|
|
744
|
+
"summary",
|
|
745
|
+
"scope_kind",
|
|
746
|
+
"scope_id",
|
|
747
|
+
"occurrence_count",
|
|
748
|
+
], ["owner_kind", "owner_id", "workload_relationship"], "diagnostic advice finding");
|
|
749
|
+
if (!["warning", "critical"].includes(finding.severity) ||
|
|
750
|
+
typeof finding.finding_id !== "string" ||
|
|
751
|
+
typeof finding.summary !== "string" ||
|
|
752
|
+
!boundedInteger(finding.occurrence_count, 1, 50_000)) {
|
|
753
|
+
throw new Error("invalid diagnostic advice finding");
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
for (const reason of advice.reasons) {
|
|
757
|
+
assertKeys(reason, ["code", "summary", "finding_ids"], [], "diagnostic advice reason");
|
|
758
|
+
if (![
|
|
759
|
+
"critical_findings_active",
|
|
760
|
+
"warning_findings_active",
|
|
761
|
+
"findings_source_unavailable",
|
|
762
|
+
"no_active_pressure_findings",
|
|
763
|
+
].includes(reason.code) ||
|
|
764
|
+
typeof reason.summary !== "string" ||
|
|
765
|
+
!Array.isArray(reason.finding_ids) ||
|
|
766
|
+
reason.finding_ids.length > DIAGNOSTIC_ADVICE_LIMITS.max_contributing_findings ||
|
|
767
|
+
reason.finding_ids.some((id) => typeof id !== "string")) {
|
|
768
|
+
throw new Error("invalid diagnostic advice reason");
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
function validateCapabilities(value, label) {
|
|
773
|
+
if (!Array.isArray(value) || value.length > SUPERVISOR_DIAGNOSTIC_LIMITS.max_capabilities)
|
|
774
|
+
throw new Error(`${label} exceed the limit`);
|
|
775
|
+
for (const capability of value) {
|
|
776
|
+
if (!capability || typeof capability !== "object" || Array.isArray(capability))
|
|
777
|
+
throw new Error(`invalid ${label}`);
|
|
778
|
+
assertKeys(capability, ["source_kind", "state"], ["reason_code", "detail"], label);
|
|
779
|
+
const record = capability;
|
|
780
|
+
if (!validSourceKind(record.source_kind) || !validCapabilityState(record.state))
|
|
781
|
+
throw new Error(`invalid ${label}`);
|
|
782
|
+
if (record.reason_code !== undefined &&
|
|
783
|
+
(typeof record.reason_code !== "string" || record.reason_code.length > 240))
|
|
784
|
+
throw new Error(`invalid ${label}`);
|
|
785
|
+
if (record.detail !== undefined &&
|
|
786
|
+
(typeof record.detail !== "string" || record.detail.length > 2_000))
|
|
787
|
+
throw new Error(`invalid ${label}`);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
function assertSelection(value, label, findingAllowed) {
|
|
791
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
792
|
+
throw new Error(`invalid ${label}`);
|
|
793
|
+
const record = value;
|
|
794
|
+
assertKeys(record, ["start_at", "end_at"], findingAllowed ? ["finding_id"] : [], label);
|
|
795
|
+
if (!validIso(record.start_at) ||
|
|
796
|
+
!validIso(record.end_at) ||
|
|
797
|
+
Date.parse(record.start_at) > Date.parse(record.end_at))
|
|
798
|
+
throw new Error(`invalid ${label}`);
|
|
799
|
+
if (record.finding_id !== undefined &&
|
|
800
|
+
(typeof record.finding_id !== "string" || !/^[A-Za-z0-9_.:-]{1,240}$/.test(record.finding_id)))
|
|
801
|
+
throw new Error(`invalid ${label}`);
|
|
802
|
+
}
|
|
803
|
+
function assertKeys(value, required, optional, label) {
|
|
804
|
+
const keys = Object.keys(value);
|
|
805
|
+
const allowed = new Set([...required, ...optional]);
|
|
806
|
+
const missing = required.filter((key) => !keys.includes(key));
|
|
807
|
+
const unknown = keys.filter((key) => !allowed.has(key));
|
|
808
|
+
if (missing.length > 0 || unknown.length > 0) {
|
|
809
|
+
throw new Error(`${label} keys are invalid`);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
function validCapabilityState(value) {
|
|
813
|
+
return ["supported", "partial", "unsupported", "error"].includes(String(value));
|
|
814
|
+
}
|
|
815
|
+
function validSourceKind(value) {
|
|
816
|
+
return typeof value === "string" && /^[a-z][a-z0-9_.:-]{0,119}$/.test(value);
|
|
817
|
+
}
|
|
818
|
+
function boundedInteger(value, minimum, maximum) {
|
|
819
|
+
return (typeof value === "number" && Number.isInteger(value) && value >= minimum && value <= maximum);
|
|
820
|
+
}
|
|
821
|
+
function countEntries(value) {
|
|
822
|
+
if (Array.isArray(value))
|
|
823
|
+
return value.length;
|
|
824
|
+
const record = object(value);
|
|
825
|
+
if (!record)
|
|
826
|
+
return value === undefined ? 0 : 1;
|
|
827
|
+
for (const key of ["active", "transitions", "points", "lanes", "rows"]) {
|
|
828
|
+
if (Array.isArray(record[key]))
|
|
829
|
+
return record[key].length;
|
|
830
|
+
}
|
|
831
|
+
return 1;
|
|
832
|
+
}
|
|
833
|
+
function timestamp(record) {
|
|
834
|
+
if (!record)
|
|
835
|
+
return undefined;
|
|
836
|
+
for (const key of ["captured_at", "sampled_at", "generated_at", "heartbeat_at"]) {
|
|
837
|
+
if (validIso(record[key]))
|
|
838
|
+
return record[key];
|
|
839
|
+
}
|
|
840
|
+
return undefined;
|
|
841
|
+
}
|
|
842
|
+
function numeric(value) {
|
|
843
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0 ? value : undefined;
|
|
844
|
+
}
|
|
845
|
+
function arrayObjects(value) {
|
|
846
|
+
return Array.isArray(value)
|
|
847
|
+
? value.filter((item) => !!item && typeof item === "object" && !Array.isArray(item))
|
|
848
|
+
: [];
|
|
849
|
+
}
|
|
850
|
+
function object(value) {
|
|
851
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
852
|
+
? value
|
|
853
|
+
: undefined;
|
|
854
|
+
}
|
|
855
|
+
function parseIso(value, label) {
|
|
856
|
+
const date = new Date(value);
|
|
857
|
+
assertValidDate(date, label);
|
|
858
|
+
return date;
|
|
859
|
+
}
|
|
860
|
+
function validIso(value) {
|
|
861
|
+
return typeof value === "string" && Number.isFinite(Date.parse(value));
|
|
862
|
+
}
|
|
863
|
+
function assertValidDate(value, label) {
|
|
864
|
+
if (!Number.isFinite(value.getTime()))
|
|
865
|
+
throw new Error(`${label} must be a valid timestamp`);
|
|
866
|
+
}
|
|
867
|
+
function tryChmod(path, mode) {
|
|
868
|
+
try {
|
|
869
|
+
chmodSync(path, mode);
|
|
870
|
+
}
|
|
871
|
+
catch {
|
|
872
|
+
// Windows does not expose POSIX modes. The private atomic writer still applies.
|
|
873
|
+
}
|
|
874
|
+
}
|