harnery 0.38.0 → 0.40.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/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +32 -8
- package/dist/commands/artifacts.d.ts.map +1 -1
- package/dist/commands/artifacts.js +97 -6
- package/dist/commands/backup.d.ts +16 -0
- package/dist/commands/backup.d.ts.map +1 -1
- package/dist/commands/backup.js +239 -33
- package/dist/commands/browse.d.ts +8 -0
- package/dist/commands/browse.d.ts.map +1 -1
- package/dist/commands/browse.js +466 -231
- package/dist/commands/diagnostics.d.ts.map +1 -1
- package/dist/commands/diagnostics.js +6 -3
- package/dist/commands/ledger-v3.d.ts.map +1 -1
- package/dist/commands/ledger-v3.js +20 -4
- package/dist/commands/qa-run.d.ts.map +1 -1
- package/dist/commands/qa-run.js +26 -3
- package/dist/commands/qa-status.d.ts.map +1 -1
- package/dist/commands/qa-status.js +7 -2
- package/dist/commands/resources.d.ts.map +1 -1
- package/dist/commands/resources.js +23 -3
- package/dist/commands/review-pack.d.ts.map +1 -1
- package/dist/commands/review-pack.js +98 -23
- package/dist/commands/tunnel.d.ts.map +1 -1
- package/dist/commands/tunnel.js +2 -2
- package/dist/core/adapters/profiles.d.ts +1 -1
- package/dist/core/agents/canonical-emit.d.ts +3 -2
- package/dist/core/agents/canonical-emit.d.ts.map +1 -1
- package/dist/core/agents/canonical-emit.js +2 -0
- package/dist/core/agents/cli.js +13 -6
- package/dist/core/agents/live-authority-v3.d.ts.map +1 -1
- package/dist/core/agents/live-authority-v3.js +5 -3
- package/dist/core/agents/live-lifecycle-v3.d.ts +2 -2
- package/dist/core/agents/live-lifecycle-v3.d.ts.map +1 -1
- package/dist/core/agents/render/prompt-context.d.ts +7 -5
- package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
- package/dist/core/agents/render/prompt-context.js +63 -8
- package/dist/core/agents/session-finalizer-v3.d.ts +2 -2
- package/dist/core/agents/session-finalizer-v3.d.ts.map +1 -1
- package/dist/core/agents/state/live-coordination-view.d.ts +3 -3
- package/dist/core/agents/state/live-coordination-view.d.ts.map +1 -1
- package/dist/core/agents/state/live-coordination-view.js +2 -1
- package/dist/core/agents/state/names.d.ts +35 -2
- package/dist/core/agents/state/names.d.ts.map +1 -1
- package/dist/core/agents/state/names.js +80 -5
- package/dist/core/agents/state/stale-sweep.d.ts +2 -1
- package/dist/core/agents/state/stale-sweep.d.ts.map +1 -1
- package/dist/core/agents/state/stale-sweep.js +23 -6
- package/dist/core/agents/turn-elapsed.d.ts +51 -0
- package/dist/core/agents/turn-elapsed.d.ts.map +1 -0
- package/dist/core/agents/turn-elapsed.js +91 -0
- package/dist/core/artifacts/activity.d.ts +14 -0
- package/dist/core/artifacts/activity.d.ts.map +1 -0
- package/dist/core/artifacts/activity.js +52 -0
- package/dist/core/artifacts/delivery-card.d.ts +39 -0
- package/dist/core/artifacts/delivery-card.d.ts.map +1 -0
- package/dist/core/artifacts/delivery-card.js +282 -0
- package/dist/core/artifacts/index.d.ts +42 -7
- package/dist/core/artifacts/index.d.ts.map +1 -1
- package/dist/core/artifacts/index.js +288 -76
- package/dist/core/artifacts/mutation-lock.d.ts +2 -0
- package/dist/core/artifacts/mutation-lock.d.ts.map +1 -0
- package/dist/core/artifacts/mutation-lock.js +91 -0
- package/dist/core/backup/host-snapshot.d.ts +18 -0
- package/dist/core/backup/host-snapshot.d.ts.map +1 -0
- package/dist/core/backup/host-snapshot.js +64 -0
- package/dist/core/config.d.ts +20 -5
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +44 -10
- package/dist/core/diagnostics/advice.d.ts +38 -3
- package/dist/core/diagnostics/advice.d.ts.map +1 -1
- package/dist/core/diagnostics/advice.js +103 -99
- package/dist/core/diagnostics/bundle.d.ts.map +1 -1
- package/dist/core/diagnostics/bundle.js +111 -47
- package/dist/core/diagnostics/comparison.d.ts.map +1 -1
- package/dist/core/diagnostics/comparison.js +3 -2
- package/dist/core/diagnostics/contract.d.ts +15 -31
- package/dist/core/diagnostics/contract.d.ts.map +1 -1
- package/dist/core/diagnostics/contract.js +2 -5
- package/dist/core/diagnostics/index.d.ts +2 -0
- package/dist/core/diagnostics/index.d.ts.map +1 -1
- package/dist/core/diagnostics/index.js +2 -0
- package/dist/core/diagnostics/pressure-contract.d.ts +260 -0
- package/dist/core/diagnostics/pressure-contract.d.ts.map +1 -0
- package/dist/core/diagnostics/pressure-contract.js +70 -0
- package/dist/core/diagnostics/pressure.d.ts +25 -0
- package/dist/core/diagnostics/pressure.d.ts.map +1 -0
- package/dist/core/diagnostics/pressure.js +1138 -0
- package/dist/core/diagnostics/replay.d.ts.map +1 -1
- package/dist/core/diagnostics/replay.js +90 -10
- package/dist/core/events/v3/adapter-id.d.ts +6 -0
- package/dist/core/events/v3/adapter-id.d.ts.map +1 -0
- package/dist/core/events/v3/adapter-id.js +7 -0
- package/dist/core/events/v3/archive-retention.d.ts.map +1 -1
- package/dist/core/events/v3/archive-retention.js +3 -2
- package/dist/core/events/v3/bootstrap.d.ts +41 -4
- package/dist/core/events/v3/bootstrap.d.ts.map +1 -1
- package/dist/core/events/v3/bootstrap.js +120 -17
- package/dist/core/events/v3/capabilities.d.ts +16 -9
- package/dist/core/events/v3/capabilities.d.ts.map +1 -1
- package/dist/core/events/v3/capabilities.js +37 -2
- package/dist/core/events/v3/capability-drift.d.ts +2 -2
- package/dist/core/events/v3/capability-drift.d.ts.map +1 -1
- package/dist/core/events/v3/control-witness.d.ts +48 -5
- package/dist/core/events/v3/control-witness.d.ts.map +1 -1
- package/dist/core/events/v3/control-witness.js +91 -36
- package/dist/core/events/v3/control.d.ts.map +1 -1
- package/dist/core/events/v3/control.js +22 -2
- package/dist/core/events/v3/index.d.ts +2 -1
- package/dist/core/events/v3/index.d.ts.map +1 -1
- package/dist/core/events/v3/index.js +2 -1
- package/dist/core/events/v3/live-feed.d.ts +7 -1
- package/dist/core/events/v3/live-feed.d.ts.map +1 -1
- package/dist/core/events/v3/live-feed.js +21 -3
- package/dist/core/events/v3/live-routing.d.ts.map +1 -1
- package/dist/core/events/v3/live-routing.js +10 -2
- package/dist/core/events/v3/producers/command-recorder.d.ts +2 -2
- package/dist/core/events/v3/producers/command-recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/command-recorder.js +2 -1
- package/dist/core/events/v3/producers/coordination-recorder.d.ts +2 -2
- package/dist/core/events/v3/producers/coordination-recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/coordination-recorder.js +2 -1
- package/dist/core/events/v3/producers/hook-base.d.ts +2 -2
- package/dist/core/events/v3/producers/hook-base.d.ts.map +1 -1
- package/dist/core/events/v3/producers/hook-base.js +15 -5
- package/dist/core/events/v3/producers/hook.d.ts.map +1 -1
- package/dist/core/events/v3/producers/hook.js +17 -4
- package/dist/core/events/v3/producers/intake.d.ts +4 -4
- package/dist/core/events/v3/producers/intake.d.ts.map +1 -1
- package/dist/core/events/v3/producers/intake.js +3 -2
- package/dist/core/events/v3/producers/producer-state-observer.d.ts.map +1 -1
- package/dist/core/events/v3/producers/producer-state-observer.js +2 -1
- package/dist/core/events/v3/producers/recorder.d.ts +16 -5
- package/dist/core/events/v3/producers/recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/recorder.js +31 -9
- package/dist/core/events/v3/reader.d.ts.map +1 -1
- package/dist/core/events/v3/reader.js +10 -13
- package/dist/core/events/v3/runtime-build.d.ts.map +1 -1
- package/dist/core/events/v3/runtime-build.js +3 -2
- package/dist/core/events/v3/runtime-telemetry-capabilities.d.ts +2 -2
- package/dist/core/events/v3/runtime-telemetry-capabilities.d.ts.map +1 -1
- package/dist/core/events/v3/turn-telemetry.d.ts +2 -2
- package/dist/core/events/v3/turn-telemetry.d.ts.map +1 -1
- package/dist/core/hooks/adapter/output.d.ts +16 -14
- package/dist/core/hooks/adapter/output.d.ts.map +1 -1
- package/dist/core/hooks/adapter/output.js +36 -38
- package/dist/core/hooks/backup-schedule.d.ts +34 -0
- package/dist/core/hooks/backup-schedule.d.ts.map +1 -0
- package/dist/core/hooks/backup-schedule.js +114 -0
- package/dist/core/hooks/cli.js +61 -18
- package/dist/core/hooks/codex-wsl-bridge.d.ts +2 -0
- package/dist/core/hooks/codex-wsl-bridge.d.ts.map +1 -1
- package/dist/core/hooks/codex-wsl-bridge.js +18 -4
- package/dist/core/hooks/index.d.ts +1 -0
- package/dist/core/hooks/index.d.ts.map +1 -1
- package/dist/core/hooks/index.js +1 -0
- package/dist/core/hooks/prompt-context/contract.d.ts +61 -0
- package/dist/core/hooks/prompt-context/contract.d.ts.map +1 -0
- package/dist/core/hooks/prompt-context/contract.js +102 -0
- package/dist/core/hooks/prompt-context/index.d.ts +5 -0
- package/dist/core/hooks/prompt-context/index.d.ts.map +1 -0
- package/dist/core/hooks/prompt-context/index.js +2 -0
- package/dist/core/hooks/prompt-context/runner.d.ts +24 -0
- package/dist/core/hooks/prompt-context/runner.d.ts.map +1 -0
- package/dist/core/hooks/prompt-context/runner.js +249 -0
- package/dist/core/qa-artifacts.d.ts +3 -0
- package/dist/core/qa-artifacts.d.ts.map +1 -1
- package/dist/core/qa-artifacts.js +25 -3
- package/dist/core/resources/contract.d.ts +69 -3
- package/dist/core/resources/contract.d.ts.map +1 -1
- package/dist/core/resources/contract.js +1 -1
- package/dist/core/resources/index.d.ts +1 -0
- package/dist/core/resources/index.d.ts.map +1 -1
- package/dist/core/resources/index.js +1 -0
- package/dist/core/resources/native.d.ts +36 -0
- package/dist/core/resources/native.d.ts.map +1 -0
- package/dist/core/resources/native.js +418 -0
- package/dist/core/resources/sampler.d.ts +2 -0
- package/dist/core/resources/sampler.d.ts.map +1 -1
- package/dist/core/resources/sampler.js +31 -1
- package/dist/core/resources/status.d.ts +61 -0
- package/dist/core/resources/status.d.ts.map +1 -0
- package/dist/core/resources/status.js +536 -0
- package/dist/core/resources/system.d.ts +27 -0
- package/dist/core/resources/system.d.ts.map +1 -0
- package/dist/core/resources/system.js +439 -0
- package/dist/core/semantic/contract.d.ts +13 -13
- package/dist/core/semantic/service.d.ts +2 -0
- package/dist/core/semantic/service.d.ts.map +1 -1
- package/dist/core/semantic/service.js +27 -4
- package/dist/core/storage/builtins.js +41 -0
- package/dist/core/supervisor/contract.d.ts +41 -3
- package/dist/core/supervisor/contract.d.ts.map +1 -1
- package/dist/core/supervisor/contract.js +3 -2
- package/dist/core/supervisor/findings.d.ts +3 -0
- package/dist/core/supervisor/findings.d.ts.map +1 -1
- package/dist/core/supervisor/findings.js +88 -0
- package/dist/core/supervisor/history.d.ts.map +1 -1
- package/dist/core/supervisor/history.js +14 -0
- package/dist/core/supervisor/ledger-state.d.ts +55 -0
- package/dist/core/supervisor/ledger-state.d.ts.map +1 -0
- package/dist/core/supervisor/ledger-state.js +0 -0
- package/dist/core/supervisor/service.d.ts.map +1 -1
- package/dist/core/supervisor/service.js +120 -7
- package/dist/core/supervisor/storage.d.ts +3 -1
- package/dist/core/supervisor/storage.d.ts.map +1 -1
- package/dist/core/supervisor/storage.js +4 -0
- package/dist/core/workflow/admission.d.ts +3 -0
- package/dist/core/workflow/admission.d.ts.map +1 -1
- package/dist/core/workflow/admission.js +28 -16
- package/dist/core/workflow/engine.js +2 -2
- package/dist/core/workflow/live-session-v3.d.ts.map +1 -1
- package/dist/core/workflow/live-session-v3.js +6 -1
- package/dist/core/workflow/proof.d.ts.map +1 -1
- package/dist/core/workflow/proof.js +4 -3
- package/dist/lib/browser/capture-fidelity.d.ts +7 -0
- package/dist/lib/browser/capture-fidelity.d.ts.map +1 -1
- package/dist/lib/browser/capture-fidelity.js +17 -0
- package/dist/lib/browser/client.d.ts +9 -0
- package/dist/lib/browser/client.d.ts.map +1 -1
- package/dist/lib/browser/client.js +85 -37
- package/dist/lib/browser/index.d.ts +3 -1
- package/dist/lib/browser/index.d.ts.map +1 -1
- package/dist/lib/browser/index.js +2 -1
- package/dist/lib/browser/page-review-budget.d.ts +13 -0
- package/dist/lib/browser/page-review-budget.d.ts.map +1 -0
- package/dist/lib/browser/page-review-budget.js +251 -0
- package/dist/lib/browser/page-review-contracts.d.ts +127 -0
- package/dist/lib/browser/page-review-contracts.d.ts.map +1 -0
- package/dist/lib/browser/page-review-contracts.js +5 -0
- package/dist/lib/browser/page-review-evidence.d.ts +48 -0
- package/dist/lib/browser/page-review-evidence.d.ts.map +1 -0
- package/dist/lib/browser/page-review-evidence.js +340 -0
- package/dist/lib/browser/page-review-judge.d.ts +1 -1
- package/dist/lib/browser/page-review-judge.d.ts.map +1 -1
- package/dist/lib/browser/page-review-judge.js +46 -38
- package/dist/lib/browser/page-review-pack.d.ts +44 -22
- package/dist/lib/browser/page-review-pack.d.ts.map +1 -1
- package/dist/lib/browser/page-review-pack.js +116 -36
- package/dist/lib/browser/page-review-source.d.ts +12 -0
- package/dist/lib/browser/page-review-source.d.ts.map +1 -0
- package/dist/lib/browser/page-review-source.js +22 -0
- package/dist/lib/browser/qa-run-contracts.d.ts +35 -9
- package/dist/lib/browser/qa-run-contracts.d.ts.map +1 -1
- package/dist/lib/browser/qa-run-contracts.js +48 -14
- package/dist/lib/browser/qa-run.d.ts.map +1 -1
- package/dist/lib/browser/qa-run.js +215 -68
- package/dist/lib/browser/qa-snapshot.d.ts +6 -0
- package/dist/lib/browser/qa-snapshot.d.ts.map +1 -1
- package/dist/lib/browser/qa-snapshot.js +259 -48
- package/dist/lib/browser/review-capture-transaction.d.ts +13 -0
- package/dist/lib/browser/review-capture-transaction.d.ts.map +1 -0
- package/dist/lib/browser/review-capture-transaction.js +79 -0
- package/dist/lib/browser/standalone-html.d.ts.map +1 -1
- package/dist/lib/browser/standalone-html.js +4 -2
- package/dist/lib/browser/thumbnail-association.d.ts +34 -0
- package/dist/lib/browser/thumbnail-association.d.ts.map +1 -0
- package/dist/lib/browser/thumbnail-association.js +158 -0
- package/dist/lib/browser/tiling.d.ts +30 -0
- package/dist/lib/browser/tiling.d.ts.map +1 -1
- package/dist/lib/browser/tiling.js +38 -0
- package/dist/lib/docs-metadata-managed.d.ts.map +1 -1
- package/dist/lib/docs-metadata-managed.js +4 -1
- package/dist/lib/identities/assume.d.ts.map +1 -1
- package/dist/lib/identities/assume.js +7 -1
- package/dist/lib/instructions/templates.d.ts.map +1 -1
- package/dist/lib/instructions/templates.js +1 -0
- package/dist/lib/local-file-url.d.ts +12 -0
- package/dist/lib/local-file-url.d.ts.map +1 -1
- package/dist/lib/local-file-url.js +16 -2
- package/dist/lib/tunnel/state.d.ts +19 -4
- package/dist/lib/tunnel/state.d.ts.map +1 -1
- package/dist/lib/tunnel/state.js +53 -13
- package/package.json +7 -4
- package/schemas/config.schema.json +69 -2
- package/src/commands/agents.ts +42 -9
- package/src/commands/artifacts.ts +130 -6
- package/src/commands/backup.ts +287 -34
- package/src/commands/browse.ts +564 -267
- package/src/commands/diagnostics.ts +6 -3
- package/src/commands/ledger-v3.ts +20 -3
- package/src/commands/qa-run.ts +37 -3
- package/src/commands/qa-status.ts +11 -2
- package/src/commands/resources.ts +23 -3
- package/src/commands/review-pack.ts +165 -62
- package/src/commands/tunnel.ts +2 -1
- package/src/core/agents/canonical-emit.ts +4 -2
- package/src/core/agents/cli.ts +14 -6
- package/src/core/agents/live-authority-v3.ts +7 -3
- package/src/core/agents/live-lifecycle-v3.ts +2 -2
- package/src/core/agents/render/prompt-context.ts +68 -14
- package/src/core/agents/session-finalizer-v3.ts +2 -2
- package/src/core/agents/state/live-coordination-view.ts +4 -4
- package/src/core/agents/state/names.ts +92 -7
- package/src/core/agents/state/stale-sweep.ts +22 -8
- package/src/core/agents/turn-elapsed.ts +135 -0
- package/src/core/artifacts/activity.ts +71 -0
- package/src/core/artifacts/delivery-card.ts +375 -0
- package/src/core/artifacts/index.ts +385 -91
- package/src/core/artifacts/mutation-lock.ts +106 -0
- package/src/core/backup/host-snapshot.ts +76 -0
- package/src/core/config.ts +66 -13
- package/src/core/diagnostics/advice.ts +148 -120
- package/src/core/diagnostics/bundle.ts +138 -52
- package/src/core/diagnostics/comparison.ts +6 -2
- package/src/core/diagnostics/contract.ts +39 -42
- package/src/core/diagnostics/index.ts +2 -0
- package/src/core/diagnostics/pressure-contract.ts +294 -0
- package/src/core/diagnostics/pressure.ts +1361 -0
- package/src/core/diagnostics/replay.ts +116 -11
- package/src/core/events/v3/adapter-id.ts +12 -0
- package/src/core/events/v3/archive-retention.ts +3 -6
- package/src/core/events/v3/bootstrap.ts +163 -16
- package/src/core/events/v3/capabilities.ts +75 -25
- package/src/core/events/v3/capability-drift.ts +2 -2
- package/src/core/events/v3/control-witness.ts +172 -41
- package/src/core/events/v3/control.ts +34 -2
- package/src/core/events/v3/index.ts +3 -0
- package/src/core/events/v3/live-feed.ts +23 -5
- package/src/core/events/v3/live-routing.ts +14 -2
- package/src/core/events/v3/producers/command-recorder.ts +4 -4
- package/src/core/events/v3/producers/coordination-recorder.ts +4 -4
- package/src/core/events/v3/producers/hook-base.ts +21 -16
- package/src/core/events/v3/producers/hook.ts +21 -4
- package/src/core/events/v3/producers/intake.ts +6 -6
- package/src/core/events/v3/producers/producer-state-observer.ts +2 -1
- package/src/core/events/v3/producers/recorder.ts +50 -21
- package/src/core/events/v3/reader.ts +14 -13
- package/src/core/events/v3/runtime-build.ts +3 -2
- package/src/core/events/v3/runtime-telemetry-capabilities.ts +3 -3
- package/src/core/events/v3/turn-telemetry.ts +4 -4
- package/src/core/hooks/adapter/output.ts +50 -36
- package/src/core/hooks/backup-schedule.ts +147 -0
- package/src/core/hooks/cli.ts +65 -14
- package/src/core/hooks/codex-wsl-bridge.ts +21 -5
- package/src/core/hooks/index.ts +1 -0
- package/src/core/hooks/prompt-context/contract.ts +177 -0
- package/src/core/hooks/prompt-context/index.ts +22 -0
- package/src/core/hooks/prompt-context/runner.ts +303 -0
- package/src/core/qa-artifacts.ts +29 -3
- package/src/core/resources/contract.ts +76 -3
- package/src/core/resources/index.ts +1 -0
- package/src/core/resources/native.ts +481 -0
- package/src/core/resources/sampler.ts +46 -1
- package/src/core/resources/status.ts +717 -0
- package/src/core/resources/system.ts +530 -0
- package/src/core/semantic/service.ts +37 -3
- package/src/core/storage/builtins.ts +41 -0
- package/src/core/supervisor/contract.ts +45 -3
- package/src/core/supervisor/findings.ts +159 -0
- package/src/core/supervisor/history.ts +15 -0
- package/src/core/supervisor/ledger-state.ts +0 -0
- package/src/core/supervisor/service.ts +133 -5
- package/src/core/supervisor/storage.ts +7 -0
- package/src/core/workflow/admission.ts +33 -17
- package/src/core/workflow/engine.ts +2 -2
- package/src/core/workflow/live-session-v3.ts +6 -8
- package/src/core/workflow/proof.ts +4 -3
- package/src/lib/browser/capture-fidelity.ts +23 -0
- package/src/lib/browser/client.ts +96 -44
- package/src/lib/browser/index.ts +15 -1
- package/src/lib/browser/page-review-budget.ts +309 -0
- package/src/lib/browser/page-review-contracts.ts +129 -0
- package/src/lib/browser/page-review-evidence.ts +465 -0
- package/src/lib/browser/page-review-judge.ts +56 -40
- package/src/lib/browser/page-review-pack.ts +181 -43
- package/src/lib/browser/page-review-source.ts +30 -0
- package/src/lib/browser/qa-run-contracts.ts +62 -18
- package/src/lib/browser/qa-run.ts +259 -71
- package/src/lib/browser/qa-snapshot.ts +289 -48
- package/src/lib/browser/review-capture-transaction.ts +106 -0
- package/src/lib/browser/standalone-html.ts +4 -2
- package/src/lib/browser/thumbnail-association.ts +190 -0
- package/src/lib/browser/tiling.ts +63 -0
- package/src/lib/docs-metadata-managed.ts +4 -1
- package/src/lib/identities/assume.ts +12 -4
- package/src/lib/instructions/templates.ts +1 -0
- package/src/lib/local-file-url.ts +17 -2
- package/src/lib/tunnel/state.ts +70 -13
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pressure assessment: the one explained answer to "is this machine under
|
|
3
|
+
* contention, and what should an agent do about it?"
|
|
4
|
+
*
|
|
5
|
+
* Two rules are structural rather than advisory. State comes only from
|
|
6
|
+
* contention evidence the kernel reports (stall time, kills, reclaim rates,
|
|
7
|
+
* exhausted capacity); attribution findings name who is using a resource and
|
|
8
|
+
* are carried as contributors that can never raise or lower the state. And a
|
|
9
|
+
* dimension the platform does not expose is reported as unavailable, never
|
|
10
|
+
* silently read as healthy.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { ResourceSnapshot } from "../resources/contract.ts";
|
|
14
|
+
|
|
15
|
+
export const PRESSURE_ASSESSMENT_SCHEMA_VERSION = 1 as const;
|
|
16
|
+
|
|
17
|
+
export type PressureState = "normal" | "elevated" | "critical" | "unknown";
|
|
18
|
+
export type PressureScope = "guest" | "native" | "windows-host";
|
|
19
|
+
export type PressureLimitingResource = "memory" | "cpu" | "io" | "storage" | "none" | "unknown";
|
|
20
|
+
export type PressureTrend = "rising" | "steady" | "falling" | "unknown";
|
|
21
|
+
export type PressureRecommendedAction =
|
|
22
|
+
| "proceed"
|
|
23
|
+
| "limit-heavy-work"
|
|
24
|
+
| "avoid-new-heavy-work"
|
|
25
|
+
| "unknown";
|
|
26
|
+
|
|
27
|
+
/** What an agent is about to do, so guidance can differ by the resource it consumes. */
|
|
28
|
+
export type PressureWorkloadClass = "lightweight" | "cpu-heavy" | "memory-heavy" | "storage-heavy";
|
|
29
|
+
|
|
30
|
+
/** One measurable contention dimension. Each maps to exactly one snapshot field. */
|
|
31
|
+
export type PressureDimension =
|
|
32
|
+
| "memory_stall"
|
|
33
|
+
| "io_stall"
|
|
34
|
+
| "cpu_stall"
|
|
35
|
+
| "oom_kills"
|
|
36
|
+
| "swap_activity"
|
|
37
|
+
| "direct_reclaim"
|
|
38
|
+
| "memory_available"
|
|
39
|
+
| "disk_available"
|
|
40
|
+
| "host_memory";
|
|
41
|
+
|
|
42
|
+
export type PressureUnit =
|
|
43
|
+
| "percent"
|
|
44
|
+
| "bytes"
|
|
45
|
+
| "bytes-per-second"
|
|
46
|
+
| "pages-per-second"
|
|
47
|
+
| "count"
|
|
48
|
+
| "milliseconds";
|
|
49
|
+
|
|
50
|
+
export interface PressureEvidenceDimension {
|
|
51
|
+
dimension: PressureDimension;
|
|
52
|
+
state: "supported" | "unavailable";
|
|
53
|
+
observed_value: number | null;
|
|
54
|
+
unit: PressureUnit | null;
|
|
55
|
+
/** Consecutive samples this dimension has held its current side of a threshold. */
|
|
56
|
+
sample_count: number;
|
|
57
|
+
reason_code?: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type PressureReasonCode =
|
|
61
|
+
| "memory_full_stall_critical"
|
|
62
|
+
| "memory_full_stall_elevated"
|
|
63
|
+
| "io_full_stall_critical"
|
|
64
|
+
| "io_full_stall_elevated"
|
|
65
|
+
| "cpu_stall_elevated"
|
|
66
|
+
| "new_oom_kill"
|
|
67
|
+
| "swap_out_rate_critical"
|
|
68
|
+
| "swap_out_rate_elevated"
|
|
69
|
+
| "direct_reclaim_with_memory_signal"
|
|
70
|
+
| "direct_reclaim_elevated"
|
|
71
|
+
| "memory_and_swap_exhausted"
|
|
72
|
+
| "memory_available_low"
|
|
73
|
+
| "disk_space_critical"
|
|
74
|
+
| "disk_space_low"
|
|
75
|
+
| "host_memory_pressure"
|
|
76
|
+
| "recovering_within_dwell"
|
|
77
|
+
| "no_contention_evidence"
|
|
78
|
+
| "evidence_unavailable"
|
|
79
|
+
| "snapshot_stale";
|
|
80
|
+
|
|
81
|
+
export interface PressureReason {
|
|
82
|
+
code: PressureReasonCode;
|
|
83
|
+
dimension: PressureDimension | null;
|
|
84
|
+
summary: string;
|
|
85
|
+
observed_value: number | null;
|
|
86
|
+
threshold_value: number | null;
|
|
87
|
+
unit: PressureUnit | null;
|
|
88
|
+
sample_count: number;
|
|
89
|
+
contributes_to: PressureState;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* A finding that names who is consuming a resource. Present so an operator can
|
|
94
|
+
* see the likely owner; never an input to `state`.
|
|
95
|
+
*/
|
|
96
|
+
export interface PressureContributor {
|
|
97
|
+
finding_id: string;
|
|
98
|
+
finding_kind: string;
|
|
99
|
+
finding_class: "contention" | "attribution" | "diagnostic";
|
|
100
|
+
severity: "info" | "warning" | "critical";
|
|
101
|
+
summary: string;
|
|
102
|
+
scope_kind: string;
|
|
103
|
+
scope_id: string;
|
|
104
|
+
occurrence_count: number;
|
|
105
|
+
attribution_state: "attributed" | "unattributed" | "unknown";
|
|
106
|
+
/** `exact` is the only value that may be rendered as a named owner. */
|
|
107
|
+
attribution_confidence: "exact" | "none";
|
|
108
|
+
owner_kind?: "agent" | "service";
|
|
109
|
+
owner_id?: string;
|
|
110
|
+
workload_relationship?: "active-work" | "unexpected-idle-growth" | "unknown";
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface PressureWorkloadGuidance {
|
|
114
|
+
workload_class: PressureWorkloadClass;
|
|
115
|
+
recommendation: PressureRecommendedAction;
|
|
116
|
+
summary: string;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* The carried-forward inputs a later sample needs to reproduce a hysteresis
|
|
121
|
+
* transition. Frozen in advice v2 and in diagnostic bundles so a replay is
|
|
122
|
+
* deterministic without the observer's memory.
|
|
123
|
+
*/
|
|
124
|
+
export interface PressureHysteresisState {
|
|
125
|
+
state: PressureState;
|
|
126
|
+
state_since: string;
|
|
127
|
+
/** Consecutive samples clear of every elevated threshold. */
|
|
128
|
+
consecutive_clear_samples: number;
|
|
129
|
+
/** Per-dimension consecutive samples above the elevated threshold. */
|
|
130
|
+
dimension_streaks: Readonly<Partial<Record<PressureDimension, number>>>;
|
|
131
|
+
/** Baseline for the OOM counter, so historical kills never open a finding. */
|
|
132
|
+
oom_baseline_total_kills: number | null;
|
|
133
|
+
/** While set, a new OOM kill holds `critical` until this instant. */
|
|
134
|
+
oom_hold_until: string | null;
|
|
135
|
+
/**
|
|
136
|
+
* Identity of the observer run that produced this state. A change resets
|
|
137
|
+
* every streak, because counters and PSI averages restart with it.
|
|
138
|
+
*/
|
|
139
|
+
observer_generation: string | null;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface PressureAssessment {
|
|
143
|
+
schema_version: typeof PRESSURE_ASSESSMENT_SCHEMA_VERSION;
|
|
144
|
+
observer_only: true;
|
|
145
|
+
state: PressureState;
|
|
146
|
+
scope: PressureScope;
|
|
147
|
+
limiting_resource: PressureLimitingResource;
|
|
148
|
+
trend: PressureTrend;
|
|
149
|
+
observed_at: string;
|
|
150
|
+
sample_age_ms: number | null;
|
|
151
|
+
evidence_state: "complete" | "partial" | "unavailable";
|
|
152
|
+
evidence: readonly PressureEvidenceDimension[];
|
|
153
|
+
reasons: readonly PressureReason[];
|
|
154
|
+
contributors: readonly PressureContributor[];
|
|
155
|
+
omitted_contributor_count: number;
|
|
156
|
+
/** Share of machine memory held by processes with no validated owner. */
|
|
157
|
+
unattributed_memory_percent: number | null;
|
|
158
|
+
recommended_action: PressureRecommendedAction;
|
|
159
|
+
summary: string;
|
|
160
|
+
guidance: readonly PressureWorkloadGuidance[];
|
|
161
|
+
/** The state this sample carries forward; also the replay input of the next. */
|
|
162
|
+
hysteresis: PressureHysteresisState;
|
|
163
|
+
policy_version: typeof PRESSURE_POLICY.policy_version;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const MIB = 1_024 * 1_024;
|
|
167
|
+
const GIB = 1_024 * MIB;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Every numeric threshold the assessment uses. Included in the diagnostic
|
|
171
|
+
* bundle `threshold_digest`, so tuning any value invalidates a frozen replay
|
|
172
|
+
* instead of silently changing its expected result.
|
|
173
|
+
*/
|
|
174
|
+
export const PRESSURE_POLICY = {
|
|
175
|
+
policy_version: 2,
|
|
176
|
+
/** A snapshot older than this cannot support any state but `unknown`. */
|
|
177
|
+
sample_staleness_ms: 15_000,
|
|
178
|
+
/**
|
|
179
|
+
* A snapshot may carry a sample time slightly ahead of the assessment clock,
|
|
180
|
+
* because the observer samples and then assesses. Within this tolerance the
|
|
181
|
+
* age reads as zero; beyond it the clock is untrustworthy and the state is
|
|
182
|
+
* `unknown`. A negative age is never published.
|
|
183
|
+
*/
|
|
184
|
+
sample_future_tolerance_ms: 1_000,
|
|
185
|
+
/** Samples of recent history the assessment may consider. */
|
|
186
|
+
max_history_samples: 12,
|
|
187
|
+
memory_stall: { critical_avg10: 50, elevated_avg10: 20, elevated_samples: 2 },
|
|
188
|
+
/**
|
|
189
|
+
* Full I/O stalls are noisier than memory stalls on virtual disks, where a
|
|
190
|
+
* checkout or a bundler cache write alone can hold `avg10` in the twenties
|
|
191
|
+
* for several seconds. Elevated therefore needs a higher bar held across a
|
|
192
|
+
* longer streak than memory does.
|
|
193
|
+
*/
|
|
194
|
+
io_stall: { critical_avg10: 50, elevated_avg10: 30, elevated_samples: 5 },
|
|
195
|
+
cpu_stall: { elevated_some_avg60: 40, elevated_samples: 3 },
|
|
196
|
+
oom: { critical_hold_ms: 60_000 },
|
|
197
|
+
swap_activity: {
|
|
198
|
+
critical_out_bytes_per_second: 50 * MIB,
|
|
199
|
+
critical_samples: 3,
|
|
200
|
+
elevated_out_bytes_per_second: 5 * MIB,
|
|
201
|
+
elevated_samples: 3,
|
|
202
|
+
},
|
|
203
|
+
direct_reclaim: { elevated_pages_per_second: 100_000, elevated_samples: 3 },
|
|
204
|
+
memory_available: {
|
|
205
|
+
critical_available_percent: 5,
|
|
206
|
+
critical_swap_used_percent: 90,
|
|
207
|
+
elevated_available_percent: 10,
|
|
208
|
+
elevated_samples: 3,
|
|
209
|
+
},
|
|
210
|
+
disk: {
|
|
211
|
+
critical_available_bytes: 1 * GIB,
|
|
212
|
+
critical_used_percent: 97,
|
|
213
|
+
elevated_available_bytes: 5 * GIB,
|
|
214
|
+
elevated_used_percent: 90,
|
|
215
|
+
},
|
|
216
|
+
/**
|
|
217
|
+
* A state leaves only after this many consecutive samples in which no
|
|
218
|
+
* dimension sits at or above its entry threshold. The dwell is the whole of
|
|
219
|
+
* the exit hysteresis: there is no lower exit threshold, because one would
|
|
220
|
+
* hold a state open indefinitely on a reading the policy itself calls normal.
|
|
221
|
+
*/
|
|
222
|
+
recovery: { critical_exit_samples: 3, elevated_exit_samples: 5 },
|
|
223
|
+
limits: { max_reasons: 6, max_contributors: 8, max_evidence: 12 },
|
|
224
|
+
} as const;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Everything the assessment is allowed to read. Pure input: no clock, no
|
|
228
|
+
* filesystem, no findings store. `now_ms` and `observer_generation` are
|
|
229
|
+
* supplied by the caller so a fixture can drive a fake clock and a restart.
|
|
230
|
+
*/
|
|
231
|
+
export interface AssessPressureInput {
|
|
232
|
+
/** The latest snapshot, or null when it is missing, corrupt, or too large. */
|
|
233
|
+
snapshot: ResourceSnapshot | null;
|
|
234
|
+
/** Why the snapshot is absent, when it is. */
|
|
235
|
+
snapshot_reason?: string | null;
|
|
236
|
+
/**
|
|
237
|
+
* Recent samples, oldest first, bounded by `PRESSURE_POLICY.max_history_samples`.
|
|
238
|
+
* Used only for trend; consecutive-sample streaks come from `prior`.
|
|
239
|
+
*/
|
|
240
|
+
history: readonly PressureHistorySample[];
|
|
241
|
+
/** Active findings, for contributors only. */
|
|
242
|
+
findings: readonly PressureFindingInput[];
|
|
243
|
+
findings_capability: PressureCapabilityInput;
|
|
244
|
+
/** The state the previous sample carried forward, or null on a cold start. */
|
|
245
|
+
prior: PressureHysteresisState | null;
|
|
246
|
+
observer_generation: string;
|
|
247
|
+
now_ms: number;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* The finding fields a contributor is built from. Structurally satisfied by
|
|
252
|
+
* `SupervisorFinding`; declared here so this module stays a leaf and so the
|
|
253
|
+
* assessment cannot reach any finding field that could set state.
|
|
254
|
+
*/
|
|
255
|
+
export interface PressureFindingInput {
|
|
256
|
+
id: string;
|
|
257
|
+
finding_kind: string;
|
|
258
|
+
finding_class: "contention" | "attribution" | "diagnostic";
|
|
259
|
+
severity: "info" | "warning" | "critical";
|
|
260
|
+
state: "opened" | "resolved";
|
|
261
|
+
summary: string;
|
|
262
|
+
scope_kind: string;
|
|
263
|
+
scope_id: string;
|
|
264
|
+
observed_at: string;
|
|
265
|
+
occurrence_count: number;
|
|
266
|
+
attribution?: {
|
|
267
|
+
state: "attributed" | "unattributed";
|
|
268
|
+
owner_kind?: "agent" | "service";
|
|
269
|
+
owner_id?: string;
|
|
270
|
+
};
|
|
271
|
+
workload_context?: { relationship: "active-work" | "unexpected-idle-growth" | "unknown" };
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export interface PressureCapabilityInput {
|
|
275
|
+
source_kind: string;
|
|
276
|
+
state: string;
|
|
277
|
+
reason_code?: string;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** The subset of a past sample the trend calculation needs. */
|
|
281
|
+
export interface PressureHistorySample {
|
|
282
|
+
sampled_at: string;
|
|
283
|
+
memory_full_avg10: number | null;
|
|
284
|
+
io_full_avg10: number | null;
|
|
285
|
+
cpu_some_avg60: number | null;
|
|
286
|
+
memory_available_percent: number | null;
|
|
287
|
+
swap_out_bytes_per_second: number | null;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Compute one explained assessment. Deterministic in its input: the same input
|
|
292
|
+
* always yields the same output, which is what makes a frozen bundle replayable.
|
|
293
|
+
*/
|
|
294
|
+
export type AssessPressure = (input: AssessPressureInput) => PressureAssessment;
|