@ouro.bot/cli 0.1.0-alpha.1469 → 0.1.0-alpha.1470
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/README.md +1 -1
- package/changelog.json +6 -2
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/desk.lock.json +8 -0
- package/dist/heart/identity.js +27 -1
- package/dist/mind/desk-section.js +33 -43
- package/dist/repertoire/desk-mcp.js +140 -0
- package/dist/repertoire/mcp-manager.js +22 -0
- package/dist/repertoire/mcp-tools.js +11 -7
- package/npm-shrinkwrap.json +2 -2
- package/package.json +4 -1
- package/vendor/desk/.claude-plugin/plugin.json +35 -0
- package/vendor/desk/.mcp.claude-codex.json +28 -0
- package/vendor/desk/.mcp.copilot.json +16 -0
- package/vendor/desk/.ouro-desk.json +6 -0
- package/vendor/desk/CHANGELOG.md +7004 -0
- package/vendor/desk/README.md +195 -0
- package/vendor/desk/activation/README.md +98 -0
- package/vendor/desk/activation/copilot-root.flattened-bundle.json +38 -0
- package/vendor/desk/activation/desk.activation.json +251 -0
- package/vendor/desk/activation/host-capability-evidence.md +46 -0
- package/vendor/desk/activation/support-matrix.json +84 -0
- package/vendor/desk/agency.json +20 -0
- package/vendor/desk/agents/observer.agent.md +26 -0
- package/vendor/desk/agents/observer.md +29 -0
- package/vendor/desk/agents/worker.agent.md +32 -0
- package/vendor/desk/agents/worker.md +40 -0
- package/vendor/desk/artifacts/tombstones/tombstone.schema.json +53 -0
- package/vendor/desk/artifacts/tombstones/tombstones.jsonl +1 -0
- package/vendor/desk/changelog.d/README.md +12 -0
- package/vendor/desk/docs/agent-files.md +104 -0
- package/vendor/desk/docs/agentic-engineering-v2-rfc.md +206 -0
- package/vendor/desk/docs/agentic-engineering-v3-rfc.md +109 -0
- package/vendor/desk/docs/browser-remote-desktops.md +69 -0
- package/vendor/desk/docs/dependency-activation-stories-and-criteria.md +500 -0
- package/vendor/desk/docs/evaluation-packet.md +363 -0
- package/vendor/desk/docs/factory-local-capture.md +651 -0
- package/vendor/desk/docs/factory-store-playbook.md +927 -0
- package/vendor/desk/docs/images/factory-site.png +0 -0
- package/vendor/desk/docs/issue-drains.md +79 -0
- package/vendor/desk/docs/lfs-inspection.md +55 -0
- package/vendor/desk/docs/preview-diagnostics.md +11 -0
- package/vendor/desk/docs/relays.md +88 -0
- package/vendor/desk/docs/schedules.md +69 -0
- package/vendor/desk/docs/search-recovery.md +22 -0
- package/vendor/desk/docs/session-labels.md +157 -0
- package/vendor/desk/docs/session-retention.md +125 -0
- package/vendor/desk/docs/sessions.md +17 -0
- package/vendor/desk/docs/stalled-nudges.md +54 -0
- package/vendor/desk/docs/webhooks.md +80 -0
- package/vendor/desk/docs/workspace-tidy.md +74 -0
- package/vendor/desk/hooks/boot-checks.cjs +7 -0
- package/vendor/desk/hooks/claude-session-start.cjs +123 -0
- package/vendor/desk/hooks/compatible-node.cjs +97 -0
- package/vendor/desk/hooks/copilot-boot-prompt.cjs +69 -0
- package/vendor/desk/hooks/copilot-durable-files.cjs +8 -0
- package/vendor/desk/hooks/copilot-hooks.json +61 -0
- package/vendor/desk/hooks/copilot-intake-context.cjs +5 -0
- package/vendor/desk/hooks/copilot-lane-model.cjs +8 -0
- package/vendor/desk/hooks/copilot-session-start.cjs +264 -0
- package/vendor/desk/hooks/copilot-skill-current.cjs +28 -0
- package/vendor/desk/hooks/factory-end.cjs +5 -0
- package/vendor/desk/hooks/factory-start.cjs +27 -0
- package/vendor/desk/hooks/hooks.json +40 -0
- package/vendor/desk/hooks/lib/boot-checks.cjs +643 -0
- package/vendor/desk/hooks/lib/child-agent.cjs +14 -0
- package/vendor/desk/hooks/lib/copilot-intake-context.cjs +73 -0
- package/vendor/desk/hooks/lib/current-release.cjs +162 -0
- package/vendor/desk/hooks/lib/delivery-stop.cjs +326 -0
- package/vendor/desk/hooks/lib/detach-worker.cjs +43 -0
- package/vendor/desk/hooks/lib/durable-files.cjs +102 -0
- package/vendor/desk/hooks/lib/factory-end.cjs +327 -0
- package/vendor/desk/hooks/lib/lane-model.cjs +82 -0
- package/vendor/desk/hooks/lib/node-required.cjs +56 -0
- package/vendor/desk/hooks/lib/orca-session-title.cjs +60 -0
- package/vendor/desk/hooks/lib/session-end.cjs +30 -0
- package/vendor/desk/hooks/lib/sync-end.cjs +89 -0
- package/vendor/desk/hooks/loop-start.cjs +105 -0
- package/vendor/desk/hooks/node-missing.sh +78 -0
- package/vendor/desk/hooks/orca-session-title.cjs +8 -0
- package/vendor/desk/hooks/session-end.cjs +8 -0
- package/vendor/desk/mcp/README.md +269 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/support-matrix.json +72 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/README.md +25 -0
- package/vendor/desk/mcp/bootstrap.cjs +761 -0
- package/vendor/desk/mcp/docs/private-feedback.md +13 -0
- package/vendor/desk/mcp/idle-proxy.cjs +423 -0
- package/vendor/desk/mcp/index.js +813 -0
- package/vendor/desk/mcp/package-lock.json +3717 -0
- package/vendor/desk/mcp/package.json +44 -0
- package/vendor/desk/mcp/scripts/agency-desk-channel.js +7 -0
- package/vendor/desk/mcp/scripts/build-runtime-deps-pack.js +5 -0
- package/vendor/desk/mcp/scripts/crew.js +89 -0
- package/vendor/desk/mcp/scripts/drains-launcher.mjs +329 -0
- package/vendor/desk/mcp/scripts/drains.js +5 -0
- package/vendor/desk/mcp/scripts/factory.js +657 -0
- package/vendor/desk/mcp/scripts/file-desk-problem.js +9 -0
- package/vendor/desk/mcp/scripts/finish-commit.js +7 -0
- package/vendor/desk/mcp/scripts/lfs.js +37 -0
- package/vendor/desk/mcp/scripts/local-recovery.js +363 -0
- package/vendor/desk/mcp/scripts/migrations.js +11 -0
- package/vendor/desk/mcp/scripts/private-view.js +177 -0
- package/vendor/desk/mcp/scripts/resolve-desk-root.js +106 -0
- package/vendor/desk/mcp/scripts/session-boot.js +22 -0
- package/vendor/desk/mcp/scripts/session-retention.js +5 -0
- package/vendor/desk/mcp/scripts/session-sync.js +10 -0
- package/vendor/desk/mcp/scripts/sessions.js +5 -0
- package/vendor/desk/mcp/scripts/sync-push.js +13 -0
- package/vendor/desk/mcp/scripts/tidy-status.js +8 -0
- package/vendor/desk/mcp/scripts/verify-runtime-deps-pack.js +5 -0
- package/vendor/desk/mcp/src/actions/desk-read.actions.mts +73 -0
- package/vendor/desk/mcp/src/actions/desk-session.actions.mts +42 -0
- package/vendor/desk/mcp/src/actions/desk-web.actions.mts +52 -0
- package/vendor/desk/mcp/src/actions/desk.actions.mts +5 -0
- package/vendor/desk/mcp/src/actions/generated/desk/OuroActions.swift +649 -0
- package/vendor/desk/mcp/src/actions/generated/desk/OuroActionsReins.swift +61 -0
- package/vendor/desk/mcp/src/actions/generated/desk/actions.json +280 -0
- package/vendor/desk/mcp/src/actions/generated/desk/commands.json +145 -0
- package/vendor/desk/mcp/src/actions/generated/desk/mcp.json +256 -0
- package/vendor/desk/mcp/src/actions/generated/desk/web.ts +59 -0
- package/vendor/desk/mcp/src/actions/generated/desk/webmcp.json +250 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/OuroActions.swift +241 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/OuroActionsReins.swift +25 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/actions.json +73 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/commands.json +53 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/mcp.json +83 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/web.ts +47 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/webmcp.json +81 -0
- package/vendor/desk/mcp/src/actions/served.js +5 -0
- package/vendor/desk/mcp/src/activation/admit.js +77 -0
- package/vendor/desk/mcp/src/activation/failures.js +65 -0
- package/vendor/desk/mcp/src/activation/readiness-policy.js +102 -0
- package/vendor/desk/mcp/src/activation/schema.js +17 -0
- package/vendor/desk/mcp/src/activation/superpowers-context.js +265 -0
- package/vendor/desk/mcp/src/activation/validate.js +540 -0
- package/vendor/desk/mcp/src/artifacts/tombstones.js +61 -0
- package/vendor/desk/mcp/src/crew/initiative.js +287 -0
- package/vendor/desk/mcp/src/crew/workspace.js +1259 -0
- package/vendor/desk/mcp/src/db/init.js +75 -0
- package/vendor/desk/mcp/src/db/schema.sql +83 -0
- package/vendor/desk/mcp/src/desk/active-tasks.js +408 -0
- package/vendor/desk/mcp/src/desk/card-commit-guard.js +281 -0
- package/vendor/desk/mcp/src/desk/cleanup-index.js +53 -0
- package/vendor/desk/mcp/src/desk/content-home.js +246 -0
- package/vendor/desk/mcp/src/desk/crew-config.js +102 -0
- package/vendor/desk/mcp/src/desk/crew-member.js +196 -0
- package/vendor/desk/mcp/src/desk/crew-roster.js +151 -0
- package/vendor/desk/mcp/src/desk/frontmatter-lite.js +228 -0
- package/vendor/desk/mcp/src/desk/gh-logins.js +109 -0
- package/vendor/desk/mcp/src/desk/handles.js +123 -0
- package/vendor/desk/mcp/src/desk/handoff-reference.js +35 -0
- package/vendor/desk/mcp/src/desk/improvement-authority.js +3 -0
- package/vendor/desk/mcp/src/desk/improvement-cards.js +704 -0
- package/vendor/desk/mcp/src/desk/improvement-person.js +51 -0
- package/vendor/desk/mcp/src/desk/lifecycle.js +16 -0
- package/vendor/desk/mcp/src/desk/machine-desks.js +119 -0
- package/vendor/desk/mcp/src/desk/naming.js +333 -0
- package/vendor/desk/mcp/src/desk/organization.js +592 -0
- package/vendor/desk/mcp/src/desk/resources.js +274 -0
- package/vendor/desk/mcp/src/desk/runtime-resolver.js +30 -0
- package/vendor/desk/mcp/src/desk/scratch-paths.js +44 -0
- package/vendor/desk/mcp/src/desk/step-delivery.js +140 -0
- package/vendor/desk/mcp/src/desk/steps.js +263 -0
- package/vendor/desk/mcp/src/desk/tidy.js +930 -0
- package/vendor/desk/mcp/src/desk/unsigned-deliveries.js +359 -0
- package/vendor/desk/mcp/src/factory/agent-types.js +45 -0
- package/vendor/desk/mcp/src/factory/andon-watch.js +109 -0
- package/vendor/desk/mcp/src/factory/binding.js +612 -0
- package/vendor/desk/mcp/src/factory/boot-check.js +645 -0
- package/vendor/desk/mcp/src/factory/capture-classify.js +158 -0
- package/vendor/desk/mcp/src/factory/capture-count.js +183 -0
- package/vendor/desk/mcp/src/factory/capture-flush.js +268 -0
- package/vendor/desk/mcp/src/factory/capture-publish.js +141 -0
- package/vendor/desk/mcp/src/factory/capture-schema.js +193 -0
- package/vendor/desk/mcp/src/factory/capture-sweep.js +239 -0
- package/vendor/desk/mcp/src/factory/catch-point.js +60 -0
- package/vendor/desk/mcp/src/factory/commit-resolve.js +94 -0
- package/vendor/desk/mcp/src/factory/consent-answer.js +37 -0
- package/vendor/desk/mcp/src/factory/context-capability.js +15 -0
- package/vendor/desk/mcp/src/factory/context-outbox.js +885 -0
- package/vendor/desk/mcp/src/factory/context-run.js +386 -0
- package/vendor/desk/mcp/src/factory/context-schema.js +249 -0
- package/vendor/desk/mcp/src/factory/copilot-turn-index.js +93 -0
- package/vendor/desk/mcp/src/factory/copilot-usage.js +148 -0
- package/vendor/desk/mcp/src/factory/credential.js +45 -0
- package/vendor/desk/mcp/src/factory/derive-claude.js +960 -0
- package/vendor/desk/mcp/src/factory/derive-codex.js +734 -0
- package/vendor/desk/mcp/src/factory/derive-common.js +279 -0
- package/vendor/desk/mcp/src/factory/derive-copilot.js +1057 -0
- package/vendor/desk/mcp/src/factory/derive-run.js +807 -0
- package/vendor/desk/mcp/src/factory/desk-problem-file.js +310 -0
- package/vendor/desk/mcp/src/factory/desk-problem-fingerprint.js +70 -0
- package/vendor/desk/mcp/src/factory/desk-problem-known.js +246 -0
- package/vendor/desk/mcp/src/factory/desk-problem-template.js +107 -0
- package/vendor/desk/mcp/src/factory/desk-repo.js +1223 -0
- package/vendor/desk/mcp/src/factory/desk-task-line.js +28 -0
- package/vendor/desk/mcp/src/factory/desk-visibility.js +48 -0
- package/vendor/desk/mcp/src/factory/end-hook.js +14 -0
- package/vendor/desk/mcp/src/factory/evaluate-kick.js +164 -0
- package/vendor/desk/mcp/src/factory/evaluate-run.js +678 -0
- package/vendor/desk/mcp/src/factory/evaluator-step.js +484 -0
- package/vendor/desk/mcp/src/factory/filer-launch.js +79 -0
- package/vendor/desk/mcp/src/factory/flush-health.js +26 -0
- package/vendor/desk/mcp/src/factory/flush.js +1758 -0
- package/vendor/desk/mcp/src/factory/focus.js +326 -0
- package/vendor/desk/mcp/src/factory/headless-flag.cjs +32 -0
- package/vendor/desk/mcp/src/factory/headless-flag.js +25 -0
- package/vendor/desk/mcp/src/factory/headless-ledger.js +743 -0
- package/vendor/desk/mcp/src/factory/headless.js +567 -0
- package/vendor/desk/mcp/src/factory/held-route.js +93 -0
- package/vendor/desk/mcp/src/factory/host-flags.js +36 -0
- package/vendor/desk/mcp/src/factory/improvement-verify.js +429 -0
- package/vendor/desk/mcp/src/factory/kaizen-file.js +231 -0
- package/vendor/desk/mcp/src/factory/label-binding.js +90 -0
- package/vendor/desk/mcp/src/factory/label-schema.js +426 -0
- package/vendor/desk/mcp/src/factory/local-status.js +368 -0
- package/vendor/desk/mcp/src/factory/loop-conditions.js +121 -0
- package/vendor/desk/mcp/src/factory/loop-health.js +500 -0
- package/vendor/desk/mcp/src/factory/loop-slot.js +90 -0
- package/vendor/desk/mcp/src/factory/loop-status.js +100 -0
- package/vendor/desk/mcp/src/factory/loop-switch.cjs +14 -0
- package/vendor/desk/mcp/src/factory/loop-worker-state.js +96 -0
- package/vendor/desk/mcp/src/factory/loop-worker.js +290 -0
- package/vendor/desk/mcp/src/factory/marker.js +61 -0
- package/vendor/desk/mcp/src/factory/mirror-step.js +145 -0
- package/vendor/desk/mcp/src/factory/os-protect.js +243 -0
- package/vendor/desk/mcp/src/factory/outbox.js +2231 -0
- package/vendor/desk/mcp/src/factory/outcome.js +431 -0
- package/vendor/desk/mcp/src/factory/pipeline/andon.js +319 -0
- package/vendor/desk/mcp/src/factory/pipeline/attention-rollup.js +158 -0
- package/vendor/desk/mcp/src/factory/pipeline/attention.js +146 -0
- package/vendor/desk/mcp/src/factory/pipeline/build.js +299 -0
- package/vendor/desk/mcp/src/factory/pipeline/compare.js +148 -0
- package/vendor/desk/mcp/src/factory/pipeline/formulas.js +652 -0
- package/vendor/desk/mcp/src/factory/pipeline/kaizen.js +387 -0
- package/vendor/desk/mcp/src/factory/pipeline/lifecycle-clocks.js +345 -0
- package/vendor/desk/mcp/src/factory/pipeline/normalize.js +73 -0
- package/vendor/desk/mcp/src/factory/pipeline/number-states.js +154 -0
- package/vendor/desk/mcp/src/factory/pipeline/outcomes.js +268 -0
- package/vendor/desk/mcp/src/factory/pipeline/report.js +737 -0
- package/vendor/desk/mcp/src/factory/pipeline/rollups.js +883 -0
- package/vendor/desk/mcp/src/factory/pipeline/stretches.js +523 -0
- package/vendor/desk/mcp/src/factory/pipeline/timeline.js +199 -0
- package/vendor/desk/mcp/src/factory/pipeline/validate-pr.js +238 -0
- package/vendor/desk/mcp/src/factory/pipeline/versions.js +42 -0
- package/vendor/desk/mcp/src/factory/pipeline/walk.js +1177 -0
- package/vendor/desk/mcp/src/factory/plugin-registry.js +72 -0
- package/vendor/desk/mcp/src/factory/plugin-sources.cjs +249 -0
- package/vendor/desk/mcp/src/factory/pr-green.js +77 -0
- package/vendor/desk/mcp/src/factory/process-lock.js +142 -0
- package/vendor/desk/mcp/src/factory/proof-session.js +75 -0
- package/vendor/desk/mcp/src/factory/publish.js +637 -0
- package/vendor/desk/mcp/src/factory/published-schema.js +648 -0
- package/vendor/desk/mcp/src/factory/reconcile-reasons.js +22 -0
- package/vendor/desk/mcp/src/factory/reconcile-step.js +251 -0
- package/vendor/desk/mcp/src/factory/reconcile.js +808 -0
- package/vendor/desk/mcp/src/factory/release-version.js +134 -0
- package/vendor/desk/mcp/src/factory/repo-name.js +13 -0
- package/vendor/desk/mcp/src/factory/retention.js +60 -0
- package/vendor/desk/mcp/src/factory/route-desk.js +40 -0
- package/vendor/desk/mcp/src/factory/route-issues.js +251 -0
- package/vendor/desk/mcp/src/factory/route-local.js +264 -0
- package/vendor/desk/mcp/src/factory/schema.js +957 -0
- package/vendor/desk/mcp/src/factory/session-kind.js +16 -0
- package/vendor/desk/mcp/src/factory/session-lifetime.js +56 -0
- package/vendor/desk/mcp/src/factory/session-route.js +183 -0
- package/vendor/desk/mcp/src/factory/shell-git.js +500 -0
- package/vendor/desk/mcp/src/factory/store-issues.js +143 -0
- package/vendor/desk/mcp/src/factory/store-route.js +208 -0
- package/vendor/desk/mcp/src/factory/test-state-guard.js +103 -0
- package/vendor/desk/mcp/src/factory/time.js +36 -0
- package/vendor/desk/mcp/src/factory/tool-issue-file.js +84 -0
- package/vendor/desk/mcp/src/factory/tool-kinds.js +87 -0
- package/vendor/desk/mcp/src/factory/triage-schema.js +233 -0
- package/vendor/desk/mcp/src/factory/windows-acl.js +679 -0
- package/vendor/desk/mcp/src/indexer/chunk.js +232 -0
- package/vendor/desk/mcp/src/indexer/discover.js +434 -0
- package/vendor/desk/mcp/src/indexer/exclusions.js +247 -0
- package/vendor/desk/mcp/src/indexer/index.js +167 -0
- package/vendor/desk/mcp/src/indexer/refs.js +0 -0
- package/vendor/desk/mcp/src/indexer/text-hash.js +18 -0
- package/vendor/desk/mcp/src/lib/ouro-actions/actions.claims.json +75 -0
- package/vendor/desk/mcp/src/lib/ouro-actions/dist-manifest.json +70 -0
- package/vendor/desk/mcp/src/lib/ouro-actions/ouro-actions.mts +1416 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/LICENSE +21 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/ax-claims.ts +190 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/ax-command.ts +1020 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/checks.ts +343 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/cli.ts +240 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/component.ts +430 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/dev-commands.ts +204 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/doctor.ts +126 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/effects.ts +68 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/exit-codes.ts +75 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/help.ts +220 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/mcp.ts +268 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/outcome.ts +265 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/output.ts +67 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/precise-copy.ts +235 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/problem.ts +124 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/surfaces.kit.mts +8 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/surfaces.ts +568 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/terminal.ts +245 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/voice.ts +136 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/wait.ts +226 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/work-event.ts +181 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/xray.kit.mts +18 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/xray.ts +2072 -0
- package/vendor/desk/mcp/src/package-metadata.js +20 -0
- package/vendor/desk/mcp/src/protected/legacy-ledger.js +55 -0
- package/vendor/desk/mcp/src/readiness/leftovers.js +75 -0
- package/vendor/desk/mcp/src/readiness/process-start.js +149 -0
- package/vendor/desk/mcp/src/runtime/admission-worker.js +194 -0
- package/vendor/desk/mcp/src/runtime/admission.js +177 -0
- package/vendor/desk/mcp/src/runtime/agency-desk-channel.js +342 -0
- package/vendor/desk/mcp/src/runtime/agents-md.js +62 -0
- package/vendor/desk/mcp/src/runtime/append-lane.js +68 -0
- package/vendor/desk/mcp/src/runtime/argv-safe-reason.js +55 -0
- package/vendor/desk/mcp/src/runtime/boot-dependencies.js +75 -0
- package/vendor/desk/mcp/src/runtime/boot-text.js +504 -0
- package/vendor/desk/mcp/src/runtime/boot.js +1677 -0
- package/vendor/desk/mcp/src/runtime/bootstrap.js +1455 -0
- package/vendor/desk/mcp/src/runtime/chunked-import.js +102 -0
- package/vendor/desk/mcp/src/runtime/copilot-commit-trailer.js +133 -0
- package/vendor/desk/mcp/src/runtime/copilot-session.js +155 -0
- package/vendor/desk/mcp/src/runtime/deliver.js +469 -0
- package/vendor/desk/mcp/src/runtime/desk-channel.js +86 -0
- package/vendor/desk/mcp/src/runtime/desk-failure.js +26 -0
- package/vendor/desk/mcp/src/runtime/desk-health.js +168 -0
- package/vendor/desk/mcp/src/runtime/desk-session.js +1451 -0
- package/vendor/desk/mcp/src/runtime/diagnostic-server.js +72 -0
- package/vendor/desk/mcp/src/runtime/diagnostics.js +241 -0
- package/vendor/desk/mcp/src/runtime/drains-cli.js +187 -0
- package/vendor/desk/mcp/src/runtime/drains.js +781 -0
- package/vendor/desk/mcp/src/runtime/elsewhere-note.js +9 -0
- package/vendor/desk/mcp/src/runtime/failure-evidence.js +21 -0
- package/vendor/desk/mcp/src/runtime/fast-refs.js +209 -0
- package/vendor/desk/mcp/src/runtime/filer-throttle.js +66 -0
- package/vendor/desk/mcp/src/runtime/focused-card.js +147 -0
- package/vendor/desk/mcp/src/runtime/front-door.js +204 -0
- package/vendor/desk/mcp/src/runtime/gate-wait.js +2 -0
- package/vendor/desk/mcp/src/runtime/git-inspection.js +201 -0
- package/vendor/desk/mcp/src/runtime/git-read-worker.js +157 -0
- package/vendor/desk/mcp/src/runtime/health.js +50 -0
- package/vendor/desk/mcp/src/runtime/hooks.js +353 -0
- package/vendor/desk/mcp/src/runtime/hosted.js +163 -0
- package/vendor/desk/mcp/src/runtime/inbox.js +102 -0
- package/vendor/desk/mcp/src/runtime/index-drift.js +118 -0
- package/vendor/desk/mcp/src/runtime/last-start.js +133 -0
- package/vendor/desk/mcp/src/runtime/lesson-section.js +92 -0
- package/vendor/desk/mcp/src/runtime/lessons-shelf.js +100 -0
- package/vendor/desk/mcp/src/runtime/lfs.js +319 -0
- package/vendor/desk/mcp/src/runtime/native-path.js +12 -0
- package/vendor/desk/mcp/src/runtime/newest-release.js +197 -0
- package/vendor/desk/mcp/src/runtime/node-selection.js +233 -0
- package/vendor/desk/mcp/src/runtime/orca-session-title.js +225 -0
- package/vendor/desk/mcp/src/runtime/other-sessions.js +183 -0
- package/vendor/desk/mcp/src/runtime/pending-migrations.js +653 -0
- package/vendor/desk/mcp/src/runtime/plugin-update.js +215 -0
- package/vendor/desk/mcp/src/runtime/pluginless-runtimes.js +34 -0
- package/vendor/desk/mcp/src/runtime/pr-publication.js +226 -0
- package/vendor/desk/mcp/src/runtime/preview-snapshot.js +23 -0
- package/vendor/desk/mcp/src/runtime/publication-mode.js +19 -0
- package/vendor/desk/mcp/src/runtime/relays.js +974 -0
- package/vendor/desk/mcp/src/runtime/release-alert.js +148 -0
- package/vendor/desk/mcp/src/runtime/remote-identity.js +140 -0
- package/vendor/desk/mcp/src/runtime/resolve-here.js +4 -0
- package/vendor/desk/mcp/src/runtime/runtime-deps-cli.js +65 -0
- package/vendor/desk/mcp/src/runtime/runtime-deps.js +1109 -0
- package/vendor/desk/mcp/src/runtime/runtime-identity.js +22 -0
- package/vendor/desk/mcp/src/runtime/runtime-swap.js +101 -0
- package/vendor/desk/mcp/src/runtime/schedules.js +235 -0
- package/vendor/desk/mcp/src/runtime/session-activity.js +190 -0
- package/vendor/desk/mcp/src/runtime/session-label.js +30 -0
- package/vendor/desk/mcp/src/runtime/session-retention.js +662 -0
- package/vendor/desk/mcp/src/runtime/session-sync.js +333 -0
- package/vendor/desk/mcp/src/runtime/session-trailer.js +126 -0
- package/vendor/desk/mcp/src/runtime/sessions-cli.js +301 -0
- package/vendor/desk/mcp/src/runtime/signoff-listed.js +81 -0
- package/vendor/desk/mcp/src/runtime/skills.js +76 -0
- package/vendor/desk/mcp/src/runtime/stale-card-lead.js +52 -0
- package/vendor/desk/mcp/src/runtime/stale-desk-refresh.js +198 -0
- package/vendor/desk/mcp/src/runtime/stale-desk.js +219 -0
- package/vendor/desk/mcp/src/runtime/stalled.js +255 -0
- package/vendor/desk/mcp/src/runtime/standing-authority.js +79 -0
- package/vendor/desk/mcp/src/runtime/startup-boot.js +341 -0
- package/vendor/desk/mcp/src/runtime/startup-resolve.js +140 -0
- package/vendor/desk/mcp/src/runtime/state-branch.js +203 -0
- package/vendor/desk/mcp/src/runtime/status-compact.js +165 -0
- package/vendor/desk/mcp/src/runtime/status-inspection-child.js +26 -0
- package/vendor/desk/mcp/src/runtime/status-inspection.js +147 -0
- package/vendor/desk/mcp/src/runtime/status-root.js +39 -0
- package/vendor/desk/mcp/src/runtime/sync-worker.js +911 -0
- package/vendor/desk/mcp/src/runtime/test-state-guard.js +107 -0
- package/vendor/desk/mcp/src/runtime/unmerged-saves.js +247 -0
- package/vendor/desk/mcp/src/runtime/workspace-claim.js +53 -0
- package/vendor/desk/mcp/src/runtime/workspace-evidence.js +96 -0
- package/vendor/desk/mcp/src/runtime/workspace-tidy.js +509 -0
- package/vendor/desk/mcp/src/search/direct-lexical.js +54 -0
- package/vendor/desk/mcp/src/search/embedder.js +108 -0
- package/vendor/desk/mcp/src/search/engine.js +406 -0
- package/vendor/desk/mcp/src/search/files-router.js +22 -0
- package/vendor/desk/mcp/src/search/old-index.js +46 -0
- package/vendor/desk/mcp/src/search/vectors.js +60 -0
- package/vendor/desk/mcp/src/server.js +389 -0
- package/vendor/desk/mcp/src/tool-names.js +73 -0
- package/vendor/desk/mcp/src/tool-refusal.cjs +35 -0
- package/vendor/desk/mcp/src/tool-schema-parts.js +12 -0
- package/vendor/desk/mcp/src/tool-schemas.js +325 -0
- package/vendor/desk/mcp/src/tools/_card-commit.js +148 -0
- package/vendor/desk/mcp/src/tools/archive-links.js +185 -0
- package/vendor/desk/mcp/src/tools/archive-move.js +18 -0
- package/vendor/desk/mcp/src/tools/archive-native-session.js +728 -0
- package/vendor/desk/mcp/src/tools/archive-state.js +513 -0
- package/vendor/desk/mcp/src/tools/delivery-gate.js +251 -0
- package/vendor/desk/mcp/src/tools/desk-save.js +444 -0
- package/vendor/desk/mcp/src/tools/doctor.js +122 -0
- package/vendor/desk/mcp/src/tools/done-evidence.js +260 -0
- package/vendor/desk/mcp/src/tools/factory-context.js +204 -0
- package/vendor/desk/mcp/src/tools/friction.js +332 -0
- package/vendor/desk/mcp/src/tools/improvement.js +156 -0
- package/vendor/desk/mcp/src/tools/lesson-lines.js +22 -0
- package/vendor/desk/mcp/src/tools/lesson-owners.js +137 -0
- package/vendor/desk/mcp/src/tools/lesson-team.js +169 -0
- package/vendor/desk/mcp/src/tools/lesson.js +254 -0
- package/vendor/desk/mcp/src/tools/local-only.js +151 -0
- package/vendor/desk/mcp/src/tools/move.js +794 -0
- package/vendor/desk/mcp/src/tools/native-stage-context.js +32 -0
- package/vendor/desk/mcp/src/tools/note.js +267 -0
- package/vendor/desk/mcp/src/tools/search.js +634 -0
- package/vendor/desk/mcp/src/tools/shared-write.js +196 -0
- package/vendor/desk/mcp/src/tools/sibling-desk.js +37 -0
- package/vendor/desk/mcp/src/tools/status.js +233 -0
- package/vendor/desk/mcp/src/tools/task-archive-due.js +9 -0
- package/vendor/desk/mcp/src/tools/task-archived-resource.js +53 -0
- package/vendor/desk/mcp/src/tools/task-body.js +141 -0
- package/vendor/desk/mcp/src/tools/task-focus.js +164 -0
- package/vendor/desk/mcp/src/tools/task-log.js +76 -0
- package/vendor/desk/mcp/src/tools/task-signoff.js +155 -0
- package/vendor/desk/mcp/src/tools/task.js +1768 -0
- package/vendor/desk/mcp/src/tools/track-row.js +89 -0
- package/vendor/desk/mcp/src/tools/track.js +240 -0
- package/vendor/desk/mcp/src/util/agency-session.cjs +29 -0
- package/vendor/desk/mcp/src/util/archive-links.js +105 -0
- package/vendor/desk/mcp/src/util/bash.js +36 -0
- package/vendor/desk/mcp/src/util/capture-record.js +73 -0
- package/vendor/desk/mcp/src/util/cas-commit.js +252 -0
- package/vendor/desk/mcp/src/util/created-dirs.js +71 -0
- package/vendor/desk/mcp/src/util/deferred-tools.js +51 -0
- package/vendor/desk/mcp/src/util/desk-owner.js +99 -0
- package/vendor/desk/mcp/src/util/env-value.js +13 -0
- package/vendor/desk/mcp/src/util/file-identity.js +40 -0
- package/vendor/desk/mcp/src/util/finish-commit.js +145 -0
- package/vendor/desk/mcp/src/util/fm.js +410 -0
- package/vendor/desk/mcp/src/util/git-config-file.js +85 -0
- package/vendor/desk/mcp/src/util/git-stage.js +440 -0
- package/vendor/desk/mcp/src/util/main-publish.js +240 -0
- package/vendor/desk/mcp/src/util/markdown-links.cjs +555 -0
- package/vendor/desk/mcp/src/util/object-input.js +59 -0
- package/vendor/desk/mcp/src/util/paths.js +647 -0
- package/vendor/desk/mcp/src/util/rank.js +189 -0
- package/vendor/desk/mcp/src/util/redact.js +92 -0
- package/vendor/desk/mcp/src/util/remove-retry.js +35 -0
- package/vendor/desk/mcp/src/util/rename-retry.js +73 -0
- package/vendor/desk/mcp/src/util/route-around.js +265 -0
- package/vendor/desk/mcp/src/util/shell-quote.js +18 -0
- package/vendor/desk/mcp/src/util/startup-direction.js +124 -0
- package/vendor/desk/mcp/src/util/state-ignore.js +33 -0
- package/vendor/desk/mcp/src/util/tool-commits.js +64 -0
- package/vendor/desk/mcp/src/util/unicode-16/LICENSE-MIT.txt +7 -0
- package/vendor/desk/mcp/src/util/unicode-16/README.md +9 -0
- package/vendor/desk/mcp/src/util/unicode-16/letter.cjs +1 -0
- package/vendor/desk/mcp/src/util/unicode-16/mark.cjs +1 -0
- package/vendor/desk/mcp/src/util/unicode-16/number.cjs +1 -0
- package/vendor/desk/mcp/web-auth.cjs +1897 -0
- package/vendor/desk/mcp/web-browser-discovery.cjs +53 -0
- package/vendor/desk/mcp/web-catalog.json +34 -0
- package/vendor/desk/mcp/web-launch.cjs +101 -0
- package/vendor/desk/mcp/web.cjs +1239 -0
- package/vendor/desk/migrations/01-move-to-ourostack-desk.md +188 -0
- package/vendor/desk/migrations/02-tidy-desk.md +87 -0
- package/vendor/desk/migrations/03-desk-release-channel.md +38 -0
- package/vendor/desk/optional/session-label/consumer.mjs +237 -0
- package/vendor/desk/optional/session-label/extension.mjs +32 -0
- package/vendor/desk/plugin.json +54 -0
- package/vendor/desk/settings.json +3 -0
- package/vendor/desk/skills/add-workspace-mcp/SKILL.md +180 -0
- package/vendor/desk/skills/adopt-inflight-work/SKILL.md +212 -0
- package/vendor/desk/skills/archive-workflow/SKILL.md +132 -0
- package/vendor/desk/skills/content-routing/SKILL.md +95 -0
- package/vendor/desk/skills/core-meeting-capture/SKILL.md +47 -0
- package/vendor/desk/skills/core-meeting-capture/references/capture-contract.md +175 -0
- package/vendor/desk/skills/curator/SKILL.md +103 -0
- package/vendor/desk/skills/delightful-decks/SKILL.md +67 -0
- package/vendor/desk/skills/desk-problem/SKILL.md +87 -0
- package/vendor/desk/skills/directory-structure/SKILL.md +169 -0
- package/vendor/desk/skills/doc-review-rigor/SKILL.md +63 -0
- package/vendor/desk/skills/draining-issues/SKILL.md +62 -0
- package/vendor/desk/skills/evaluate-release/SKILL.md +96 -0
- package/vendor/desk/skills/evidence-discipline/SKILL.md +150 -0
- package/vendor/desk/skills/factory-evaluator/SKILL.md +122 -0
- package/vendor/desk/skills/factory-task-context/SKILL.md +116 -0
- package/vendor/desk/skills/factory-work/SKILL.md +16 -0
- package/vendor/desk/skills/fast-honest-ci/SKILL.md +70 -0
- package/vendor/desk/skills/fast-honest-ci/examples.md +49 -0
- package/vendor/desk/skills/first-run-bootstrap/SKILL.md +95 -0
- package/vendor/desk/skills/friction-management/SKILL.md +98 -0
- package/vendor/desk/skills/git-hygiene/SKILL.md +253 -0
- package/vendor/desk/skills/independent-review/SKILL.md +34 -0
- package/vendor/desk/skills/interaction-style/SKILL.md +239 -0
- package/vendor/desk/skills/lesson-capture/SKILL.md +85 -0
- package/vendor/desk/skills/lesson-capture/agents-md-budget.mjs +61 -0
- package/vendor/desk/skills/online-evaluation/SKILL.md +81 -0
- package/vendor/desk/skills/operator-voice-comments/LICENSE-humanize +21 -0
- package/vendor/desk/skills/operator-voice-comments/SKILL.md +90 -0
- package/vendor/desk/skills/operator-voice-comments/human-voice.md +43 -0
- package/vendor/desk/skills/peer-pr-review/SKILL.md +104 -0
- package/vendor/desk/skills/pr-feedback-on-own-pr/SKILL.md +145 -0
- package/vendor/desk/skills/pr-review-interrogation/SKILL.md +121 -0
- package/vendor/desk/skills/pr-reviewer-audit/SKILL.md +68 -0
- package/vendor/desk/skills/pr-reviewer-audit/helpers/audit.py +335 -0
- package/vendor/desk/skills/pr-reviewer-audit/helpers/test_audit.py +486 -0
- package/vendor/desk/skills/pr-self-review/SKILL.md +86 -0
- package/vendor/desk/skills/pr-surface-hygiene/SKILL.md +105 -0
- package/vendor/desk/skills/pr-surface-hygiene/check-visual-proof.cjs +99 -0
- package/vendor/desk/skills/pr-surface-hygiene/repository-setup.md +19 -0
- package/vendor/desk/skills/pr-surface-hygiene/resources/pr-visual-proof.yml +29 -0
- package/vendor/desk/skills/pr-surface-hygiene/resources/pull-request-template.md +5 -0
- package/vendor/desk/skills/preflight-actions/SKILL.md +60 -0
- package/vendor/desk/skills/preview-feedback/SKILL.md +70 -0
- package/vendor/desk/skills/repo-handling/SKILL.md +67 -0
- package/vendor/desk/skills/rnd-lab/SKILL.md +52 -0
- package/vendor/desk/skills/runtime-symptom-investigation/SKILL.md +106 -0
- package/vendor/desk/skills/session-resumption/SKILL.md +126 -0
- package/vendor/desk/skills/session-start/SKILL.md +54 -0
- package/vendor/desk/skills/session-start/details.md +150 -0
- package/vendor/desk/skills/session-start-migrations/README.md +71 -0
- package/vendor/desk/skills/session-start-migrations/SKILL.md +108 -0
- package/vendor/desk/skills/start-task/SKILL.md +88 -0
- package/vendor/desk/skills/task-card-format/SKILL.md +198 -0
- package/vendor/desk/skills/task-lifecycle/SKILL.md +217 -0
- package/vendor/desk/skills/track-card-format/SKILL.md +90 -0
- package/vendor/desk/skills/using-desk/SKILL.md +58 -0
- package/vendor/desk/skills/using-superpowers-with-desk/SKILL.md +156 -0
- package/vendor/desk/skills/work-orchestration/SKILL.md +162 -0
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
// The loop's health record and its own alarms: the `measure` step.
|
|
2
|
+
//
|
|
3
|
+
// `buildLoopHealth` reads the improvement cards and the numbers the other steps left in `status.json` and builds
|
|
4
|
+
// the `desk.factory.loop/1` record, kept on this machine (`loop-slot.js` flattens it to the capture record's `loop_slot_v1`): counts, ages, the last result of each step
|
|
5
|
+
// and the headless evaluator's state. Every number is a Count in the number-states shape every published factory number
|
|
6
|
+
// uses, `{ state: "measured", value, reasons: [] }` or `{ state: "unavailable", value: null, reasons: [reason] }`, so a
|
|
7
|
+
// number that could not be read never shows as 0. The record holds codes,
|
|
8
|
+
// counts and two kinds of timestamp only: no path, card title, job id or store name, and nothing is copied from
|
|
9
|
+
// `status.loop` wholesale (it holds per-job attempt records and condition keys), only field by field.
|
|
10
|
+
//
|
|
11
|
+
// `runMeasureStep` writes the record to `status.json` under `loop.health`, opens one `loop_alarm:<name>` card for
|
|
12
|
+
// every alarm that holds (the card library builds the fixed title; a card already open is not written again), and
|
|
13
|
+
// then states the complete list of alarms that hold to the conditions record so the verify step can close an alarm
|
|
14
|
+
// card when its condition has cleared. An alarm whose input could not be read is kept in that list if it is
|
|
15
|
+
// recorded as present: a failed look never reads as "cleared". The ages never count `loop_alarm` cards, so an
|
|
16
|
+
// alarm never raises the very age that opened it.
|
|
17
|
+
|
|
18
|
+
import { createRequire } from "node:module"
|
|
19
|
+
import { validWorker } from "./loop-worker-state.js"
|
|
20
|
+
import * as path from "node:path"
|
|
21
|
+
|
|
22
|
+
import { MAX_CARD_FILES, SOURCES, cardKey, isClaimLive, openImprovement, readCards as readCardsDefault } from "../desk/improvement-cards.js"
|
|
23
|
+
import { cardCommitMessage, writeCardCommitted as writeCardCommittedDefault } from "../tools/_card-commit.js"
|
|
24
|
+
import { deskVersion } from "../package-metadata.js"
|
|
25
|
+
import { isHeadlessFactorySession } from "./headless-flag.js"
|
|
26
|
+
import { MAX_HEADLESS_JOBS_PER_DAY } from "./headless.js"
|
|
27
|
+
import { conditionOf, observeConditions } from "./loop-conditions.js"
|
|
28
|
+
import { MIN_GAP_HOURS, STEPS, recordStep, staleSteps } from "./loop-status.js"
|
|
29
|
+
import { readStatus, updateStatus } from "./outbox.js"
|
|
30
|
+
import { RECONCILE_REASONS } from "./reconcile-reasons.js"
|
|
31
|
+
import { slotValid } from "./loop-slot.js"
|
|
32
|
+
import { PATTERNS } from "./schema.js"
|
|
33
|
+
|
|
34
|
+
export const AGE_ALARM_DAYS = 7
|
|
35
|
+
/** The label lag target: a finished job is labeled within this many minutes of its finish, else `loop_alarm:label_lag` opens. */
|
|
36
|
+
export const LABEL_LAG_ALARM_MINUTES = 60
|
|
37
|
+
export const STUCK_ALARM_DAYS = 21
|
|
38
|
+
export const STALE_AFTER_HOURS = 72
|
|
39
|
+
/** A stored time this far ahead of the clock is clock skew, not a fresh reading. */
|
|
40
|
+
const FUTURE_ALLOWANCE_MINUTES = 5
|
|
41
|
+
const RECORD_SCHEMA = "desk.factory.loop/1"
|
|
42
|
+
|
|
43
|
+
/** Every state code the evaluator step writes; a stored state outside the list reads `unavailable` in the record. */
|
|
44
|
+
export const HEADLESS_STATES = Object.freeze(["idle", "ran", "no_agent_cli", "no_credentials", "disabled_would_bill", "sign_in_unknown", "budget_exhausted", "disabled", "unsupported_host", "no_time_for_a_run"])
|
|
45
|
+
/** The states an agent can fix; only these open `loop_alarm:headless_blocked` (a spent cap, a switch and per-token billing are shown, never carded). */
|
|
46
|
+
export const BLOCKING_STATES = Object.freeze(["no_agent_cli", "no_credentials", "unsupported_host", "sign_in_unknown"])
|
|
47
|
+
const BLOCKED_DAYS_FOR_ALARM = 2
|
|
48
|
+
// The evaluator states in which no run can start until the person or the machine changes something: `label_lag` stays down in them.
|
|
49
|
+
const LAG_SILENT_STATES = Object.freeze(["no_agent_cli", "no_credentials", "disabled_would_bill", "sign_in_unknown", "disabled"])
|
|
50
|
+
|
|
51
|
+
const HOUR_MS = 3600 * 1000
|
|
52
|
+
const DAY_MS = 24 * HOUR_MS
|
|
53
|
+
const WINDOW_DAYS = 30
|
|
54
|
+
const RECONCILE_WINDOW_DAYS = 7
|
|
55
|
+
const REASON = /^[a-z][a-z_]{0,39}$/u
|
|
56
|
+
const RESULT_CODE = /^[a-z0-9][a-z0-9_:-]{0,63}$/u
|
|
57
|
+
const VERSION = /^[0-9A-Za-z][0-9A-Za-z.+-]{0,39}$/u
|
|
58
|
+
const UTC_DAY = /^\d{4}-\d{2}-\d{2}$/u
|
|
59
|
+
|
|
60
|
+
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value)
|
|
61
|
+
const isInteger = (value) => Number.isSafeInteger(value) && value >= 0
|
|
62
|
+
const timeOf = (value) => (typeof value === "string" && PATTERNS.timestamp.test(value) ? Date.parse(value) : Number.NaN)
|
|
63
|
+
const isoOrNull = (value) => (Number.isNaN(timeOf(value)) ? null : value)
|
|
64
|
+
|
|
65
|
+
/** `count(value, reason = "not_recorded") -> Count`: a non-negative integer is measured; anything else is unavailable with `reason`. */
|
|
66
|
+
export function count(value, reason = "not_recorded") {
|
|
67
|
+
return isInteger(value) ? measured(value) : unavailable(reason)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const measured = (value) => ({ state: "measured", value, reasons: [] })
|
|
71
|
+
const unavailable = (reason) => ({ state: "unavailable", value: null, reasons: [reason] })
|
|
72
|
+
|
|
73
|
+
/** A stored Count (as the sign-off scan writes it: `{ state, value }`, `{ state: "partial", value, reason }` or `{ state: "unavailable", reason }`, or in the contract shape) read back as a Count, or null when it is not one. */
|
|
74
|
+
function storedCount(value) {
|
|
75
|
+
if (!isObject(value)) return null
|
|
76
|
+
const keys = Object.keys(value).length
|
|
77
|
+
const contract = Array.isArray(value.reasons)
|
|
78
|
+
if (value.state === "measured") return isInteger(value.value) && (keys === 2 || (keys === 3 && contract && value.reasons.length === 0)) ? measured(value.value) : null
|
|
79
|
+
// A partial count is a lower bound: it keeps its value and names why it is partial.
|
|
80
|
+
if (value.state === "partial") {
|
|
81
|
+
const reason = keys === 3 ? (contract ? value.reasons[0] : value.reason) : undefined
|
|
82
|
+
return isInteger(value.value) && typeof reason === "string" && REASON.test(reason) ? { state: "partial", value: value.value, reasons: [reason] } : null
|
|
83
|
+
}
|
|
84
|
+
if (value.state !== "unavailable") return null
|
|
85
|
+
// The two-key spelling `{ state, reason }` and the contract's `{ state, value: null, reasons: [reason] }` both read back.
|
|
86
|
+
const reason = keys === 2 ? value.reason : keys === 3 && value.value === null && contract && value.reasons.length === 1 ? value.reasons[0] : undefined
|
|
87
|
+
return typeof reason === "string" && REASON.test(reason) ? unavailable(reason) : null
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const pluginVersion = (env) => deskVersion(env) ?? "unknown"
|
|
91
|
+
|
|
92
|
+
// ---------------------------------------------------------------------------
|
|
93
|
+
// Improvement cards
|
|
94
|
+
|
|
95
|
+
const SOURCE_COUNTS = Object.fromEntries(SOURCES.map((source) => [source, 0]))
|
|
96
|
+
|
|
97
|
+
function cardSection(read, nowMs) {
|
|
98
|
+
let reason = null
|
|
99
|
+
if (!isObject(read) || read.unreadable === true || !Array.isArray(read.cards)) reason = "unreadable"
|
|
100
|
+
else if (read.truncated === true) reason = "too_many_cards"
|
|
101
|
+
if (reason !== null) {
|
|
102
|
+
return {
|
|
103
|
+
cards: null,
|
|
104
|
+
improvement: {
|
|
105
|
+
open: unavailable(reason), claimed: unavailable(reason), claim_expired: unavailable(reason), shipped: unavailable(reason), verifying: unavailable(reason),
|
|
106
|
+
oldest_open_age_days: unavailable(reason), oldest_in_verification_age_days: unavailable(reason),
|
|
107
|
+
closed_confirmed_30d: unavailable(reason), closed_unverified_30d: unavailable(reason), reopened_30d: unavailable(reason), reopened_from_verification: unavailable(reason),
|
|
108
|
+
by_source: Object.fromEntries(SOURCES.map((source) => [source, unavailable(reason)])),
|
|
109
|
+
},
|
|
110
|
+
loopAlarmsOpen: unavailable(reason),
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const cards = read.cards
|
|
114
|
+
const inState = (...states) => cards.filter((card) => states.includes(card.state))
|
|
115
|
+
// Loop alarm cards are the loop's own and are counted in `loop_alarms_open`, so the four card counts leave them out, as the ages do.
|
|
116
|
+
const own = (state) => inState(state).filter((card) => card.source !== "loop_alarm")
|
|
117
|
+
const live = (card) => isClaimLive(card, nowMs)
|
|
118
|
+
const since = nowMs - WINDOW_DAYS * DAY_MS
|
|
119
|
+
const closedWithin = (state) => cards.filter((card) => card.state === state && Date.parse(card.closed_at) >= since).length
|
|
120
|
+
const oldest = (list, none) => {
|
|
121
|
+
const times = list.filter((card) => card.source !== "loop_alarm").map((card) => Date.parse(card.last_opened_at))
|
|
122
|
+
return times.length === 0 ? unavailable(none) : measured(Math.max(0, Math.floor((nowMs - Math.min(...times)) / DAY_MS)))
|
|
123
|
+
}
|
|
124
|
+
const bySource = { ...SOURCE_COUNTS }
|
|
125
|
+
for (const card of inState("open")) bySource[card.source] += 1
|
|
126
|
+
return {
|
|
127
|
+
cards,
|
|
128
|
+
improvement: {
|
|
129
|
+
open: count(own("open").length),
|
|
130
|
+
claimed: count(own("claimed").filter(live).length),
|
|
131
|
+
claim_expired: count(inState("claimed").filter((card) => !live(card)).length),
|
|
132
|
+
shipped: count(own("shipped").length),
|
|
133
|
+
verifying: count(own("verifying").length),
|
|
134
|
+
oldest_open_age_days: oldest(inState("open", "claimed"), "none_open"),
|
|
135
|
+
oldest_in_verification_age_days: oldest(inState("shipped", "verifying"), "none_in_verification"),
|
|
136
|
+
closed_confirmed_30d: count(closedWithin("closed_confirmed")),
|
|
137
|
+
closed_unverified_30d: count(closedWithin("closed_unverified")),
|
|
138
|
+
// Two numbers, neither claiming to be the other. `reopened_30d` counts only what can be dated: a finding that came back after its card closed
|
|
139
|
+
// (`openImprovement` moves `last_opened_at`). A move from shipped or verifying back to open is counted on the card but carries no date, so
|
|
140
|
+
// `reopened_from_verification` is the sum of those counts over the cards still not closed. Neither counts `loop_alarm` cards (flapping alarms).
|
|
141
|
+
reopened_30d: count(cards.filter((card) => card.source !== "loop_alarm" && card.recurrences > 0 && Date.parse(card.last_opened_at) >= since).length),
|
|
142
|
+
reopened_from_verification: count(cards.filter((card) => card.source !== "loop_alarm" && !card.state.startsWith("closed_")).reduce((sum, card) => sum + card.reopened, 0)),
|
|
143
|
+
by_source: Object.fromEntries(Object.entries(bySource).map(([source, n]) => [source, count(n)])),
|
|
144
|
+
},
|
|
145
|
+
loopAlarmsOpen: count(cards.filter((card) => card.source === "loop_alarm" && !card.state.startsWith("closed_")).length),
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// ---------------------------------------------------------------------------
|
|
150
|
+
// The other inputs
|
|
151
|
+
|
|
152
|
+
/** A value recorded at `at` is usable when `at` reads as a time at most `STALE_AFTER_HOURS` old (a time more than `FUTURE_ALLOWANCE_MINUTES` ahead of the clock is stale too). */
|
|
153
|
+
function freshness(holder, nowMs) {
|
|
154
|
+
if (!isObject(holder) || holder.at === undefined) return "not_recorded"
|
|
155
|
+
const at = timeOf(holder.at)
|
|
156
|
+
return Number.isNaN(at) || nowMs - at > STALE_AFTER_HOURS * HOUR_MS || at - nowMs > FUTURE_ALLOWANCE_MINUTES * 60 * 1000 ? "stale" : "fresh"
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function recordedCount(holder, field, nowMs) {
|
|
160
|
+
const fresh = freshness(holder, nowMs)
|
|
161
|
+
if (fresh !== "fresh") return unavailable(fresh)
|
|
162
|
+
return count(holder[field])
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function unsignedSection(signoff, nowMs) {
|
|
166
|
+
// The scan records `checked_at` each time boot runs it; an old scan says nothing about now.
|
|
167
|
+
const fresh = isObject(signoff) ? freshness({ at: signoff.checked_at }, nowMs) : "not_recorded"
|
|
168
|
+
const read = (name) => (fresh !== "fresh" ? unavailable(fresh) : storedCount(signoff[name]) ?? unavailable("not_recorded"))
|
|
169
|
+
return { count: read("unsigned"), oldest_age_days: read("oldest_unsigned_age_days") }
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* The label lag from the evaluator step's record (`status.evaluator.lag`): `label_lag_minutes`, the age in whole minutes of the oldest finished
|
|
174
|
+
* job this machine can label and is still trying to (a measured 0 when there is none), `unlabeled_finished`, how many such jobs there
|
|
175
|
+
* are, and `unlabeled_unsupported`, how many finished jobs wait with a session on a host the runner does not support (named on the
|
|
176
|
+
* session-start line; the record holds no job id). A record older than the stale window, dated in the future or damaged says nothing
|
|
177
|
+
* about now: all three are `unavailable`.
|
|
178
|
+
*/
|
|
179
|
+
function lagSection(stored, nowMs) {
|
|
180
|
+
const lag = isObject(stored) && isObject(stored.lag) ? stored.lag : null
|
|
181
|
+
const fresh = freshness(lag, nowMs)
|
|
182
|
+
const none = (reason) => ({ label_lag_minutes: unavailable(reason), unlabeled_finished: unavailable(reason), unlabeled_unsupported: unavailable(reason) })
|
|
183
|
+
if (fresh !== "fresh") return none(fresh)
|
|
184
|
+
const jobs = count(lag.unlabeled_jobs)
|
|
185
|
+
const oldest = timeOf(lag.oldest_finished_at)
|
|
186
|
+
if (jobs.state !== "measured" || (jobs.value === 0) !== (lag.oldest_finished_at === null) || (jobs.value > 0 && Number.isNaN(oldest))) return none("not_recorded")
|
|
187
|
+
const unsupported = Array.isArray(lag.unsupported_jobs) ? measured(lag.unsupported_jobs.length) : unavailable("not_recorded")
|
|
188
|
+
return { label_lag_minutes: measured(jobs.value === 0 ? 0 : Math.max(0, Math.floor((nowMs - oldest) / 60000))), unlabeled_finished: jobs, unlabeled_unsupported: unsupported }
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function headlessSection(stored, today) {
|
|
192
|
+
const hl = isObject(stored) && isObject(stored.headless) ? stored.headless : null
|
|
193
|
+
// A stored day earlier than today means no run today: a measured 0. A day that is today's keeps its numbers; an unreadable or future day says nothing.
|
|
194
|
+
const day = hl !== null && typeof hl.day === "string" && UTC_DAY.test(hl.day) ? hl.day : null
|
|
195
|
+
const phase = day === null ? "unknown" : day === today ? "today" : day < today ? "earlier" : "unknown"
|
|
196
|
+
// Only a state recorded on today's day is today's state; yesterday's `ran` or `no_agent_cli` is not.
|
|
197
|
+
const state = phase === "today" && HEADLESS_STATES.includes(hl.state) ? hl.state : "unavailable"
|
|
198
|
+
const todays = (field) => (phase === "earlier" ? count(0) : phase === "today" ? count(hl[field]) : unavailable("not_recorded"))
|
|
199
|
+
let cost = unavailable("not_recorded")
|
|
200
|
+
if (phase === "earlier") cost = measured(0)
|
|
201
|
+
else if (phase === "today" && hl.cost_unreported_runs === 0) {
|
|
202
|
+
if (typeof hl.cost_usd === "number" && Number.isFinite(hl.cost_usd) && hl.cost_usd >= 0) cost = measured(hl.cost_usd)
|
|
203
|
+
else if (hl.cost_usd === null && hl.jobs === 0) cost = measured(0)
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
state,
|
|
207
|
+
jobs_today: todays("jobs"),
|
|
208
|
+
cap_per_day: count(MAX_HEADLESS_JOBS_PER_DAY),
|
|
209
|
+
accepted_today: todays("accepted"),
|
|
210
|
+
rejected_today: todays("rejected"),
|
|
211
|
+
cost_usd_today: cost,
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** The two reconcile reasons that need the store's own facts. The loop does not clone the store in v0, so it never compares and never reports a count for them. */
|
|
216
|
+
export const STORE_SIDE_REASONS = Object.freeze(["status_unobserved", "store_only"])
|
|
217
|
+
|
|
218
|
+
// Cards that record why they have no factory report link, as the reconcile step summed them: Counts, each `unavailable` when the
|
|
219
|
+
// summary holds none, so a desk whose cards were never counted never reads as zero cards waiting.
|
|
220
|
+
function linkSection(links) {
|
|
221
|
+
const known = isObject(links) && isObject(links.by_reason)
|
|
222
|
+
const byReason = {}
|
|
223
|
+
if (known) for (const [reason, n] of Object.entries(links.by_reason)) if (/^[a-z_]{1,40}$/u.test(reason)) byReason[reason] = count(n)
|
|
224
|
+
return { cards: count(known ? links.cards : undefined), archived: count(known ? links.archived : undefined), by_reason: byReason }
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function reconcileSection(summary) {
|
|
228
|
+
const last = isObject(summary) ? isoOrNull(summary.at) : null
|
|
229
|
+
const mismatches = {}
|
|
230
|
+
if (last !== null && isObject(summary.runs)) {
|
|
231
|
+
for (const reason of [...RECONCILE_REASONS, "unknown_reason"]) {
|
|
232
|
+
if (STORE_SIDE_REASONS.includes(reason)) continue
|
|
233
|
+
const entry = summary.runs[reason]
|
|
234
|
+
if (isObject(entry) && isInteger(entry.count) && entry.count > 0) mismatches[reason] = count(entry.count)
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
// A reason the loop never checks is `unavailable`, never absent: an absent reason reads as "none found".
|
|
238
|
+
const storeSide = Object.fromEntries(STORE_SIDE_REASONS.map((reason) => [reason, unavailable("store_not_compared")]))
|
|
239
|
+
return { last_ran_at: last, window_days: count(RECONCILE_WINDOW_DAYS), desks: last === null ? unavailable("not_recorded") : !isObject(summary.runs) ? unavailable("runs_damaged") : count(summary.desks), mismatches, store_side: storeSide, report_link_unavailable: linkSection(last === null ? null : summary.report_link_unavailable) }
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** How often each step is expected to run: its minimum gap, and daily for the steps that run whenever the worker does. */
|
|
243
|
+
const expectedInterval = (name) => (MIN_GAP_HOURS[name] > 0 ? MIN_GAP_HOURS[name] : 24)
|
|
244
|
+
|
|
245
|
+
function stepsSection(status, nowMs) {
|
|
246
|
+
const stored = isObject(status.loop) && isObject(status.loop.steps) ? status.loop.steps : {}
|
|
247
|
+
const recorded = STEPS.filter((name) => isObject(stored[name]))
|
|
248
|
+
const stale = new Set(staleSteps(status, nowMs, recorded))
|
|
249
|
+
return Object.fromEntries(STEPS.map((name) => {
|
|
250
|
+
const record = isObject(stored[name]) ? stored[name] : null
|
|
251
|
+
return [name, {
|
|
252
|
+
last_ran_at: record === null ? null : isoOrNull(record.last_ran_at),
|
|
253
|
+
last_ok_at: record === null ? null : isoOrNull(record.last_ok_at),
|
|
254
|
+
last_result: record === null ? "never_ran" : typeof record.last_result === "string" && RESULT_CODE.test(record.last_result) ? record.last_result : "unknown",
|
|
255
|
+
// A step with no record has run 0 times; a record whose counter is damaged says nothing.
|
|
256
|
+
runs: record === null ? count(0) : count(record.runs),
|
|
257
|
+
failures: record === null ? count(0) : count(record.failures),
|
|
258
|
+
expected_interval_hours: count(expectedInterval(name)),
|
|
259
|
+
stale: stale.has(name),
|
|
260
|
+
}]
|
|
261
|
+
}))
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// The loop worker's last outcome: a code and a time, nothing else (`loop-worker-state.js`).
|
|
265
|
+
function workerSection(stored) {
|
|
266
|
+
const worker = validWorker(stored)
|
|
267
|
+
return { last_result: worker === null ? "never_ran" : worker.result, last_ran_at: worker === null ? null : worker.at }
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const { isLoopEnabled } = createRequire(import.meta.url)("./loop-switch.cjs")
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* `withLoopSwitch(record, env) -> record`: the stored health record as this machine's reader should show it. With the loop switched off in `env`
|
|
274
|
+
* (`DESK_FACTORY_LOOP`, the shared rule in `loop-switch.cjs`), `worker.last_result` is `disabled` whatever the stored record holds, because a loop that is
|
|
275
|
+
* off never runs the measure step and so never rewrites the record. Everything else is unchanged; a missing record stays missing. Every place that shows
|
|
276
|
+
* or sends the stored record applies it where the record is read, not where it is built.
|
|
277
|
+
*/
|
|
278
|
+
export function withLoopSwitch(record, env) {
|
|
279
|
+
if (!isObject(record) || isLoopEnabled(env)) return record
|
|
280
|
+
return { ...record, worker: { last_ran_at: null, ...(isObject(record.worker) ? record.worker : {}), last_result: "disabled" } }
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// ---------------------------------------------------------------------------
|
|
284
|
+
// Assembly
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* `assembleLoop({ status, read, nowMs, version }) -> { loop, signals }`: the pure part. `signals` holds what the alarms need and the record
|
|
288
|
+
* does not carry: `blocked_days` (consecutive blocked days, or null), `cards_invalid` (count of set-aside and unreadable card files, or null),
|
|
289
|
+
* `facts_quarantine_not_settling` (the coverage pass was recorded although a facts quarantine did not settle, `status.coverage_kept`).
|
|
290
|
+
*/
|
|
291
|
+
export function assembleLoop({ status, read, nowMs, version }) {
|
|
292
|
+
const cards = cardSection(read, nowMs)
|
|
293
|
+
const stored = status
|
|
294
|
+
const loopStatus = isObject(stored.loop) ? stored.loop : {}
|
|
295
|
+
const evaluator = isObject(stored.evaluator) ? stored.evaluator : null
|
|
296
|
+
const today = new Date(nowMs).toISOString().slice(0, 10)
|
|
297
|
+
const field = (name) => (evaluator === null ? unavailable("not_recorded") : count(evaluator[name]))
|
|
298
|
+
const routeIssues = loopStatus.route_issues
|
|
299
|
+
const invalid = cards.cards === null || !isInteger(read.set_aside_total) || !isInteger(read.unreadable_files) ? null : read.set_aside_total + read.unreadable_files
|
|
300
|
+
const loop = {
|
|
301
|
+
schema: RECORD_SCHEMA,
|
|
302
|
+
written_at: new Date(nowMs).toISOString(),
|
|
303
|
+
desk_version: version,
|
|
304
|
+
improvement: { ...cards.improvement, age_alarm_days: count(AGE_ALARM_DAYS), stuck_alarm_days: count(STUCK_ALARM_DAYS) },
|
|
305
|
+
unsigned_deliveries: unsignedSection(stored.signoff, nowMs),
|
|
306
|
+
alarms: {
|
|
307
|
+
andon_open: recordedCount(routeIssues, "andon_open", nowMs),
|
|
308
|
+
store_build_failing: recordedCount(routeIssues, "store_build_failing", nowMs),
|
|
309
|
+
desk_problems_open: recordedCount(routeIssues, "desk_problems_open", nowMs),
|
|
310
|
+
loop_alarms_open: cards.loopAlarmsOpen,
|
|
311
|
+
},
|
|
312
|
+
evaluator: {
|
|
313
|
+
waiting: field("waiting"),
|
|
314
|
+
oldest_wait_days: unavailable("not_recorded"),
|
|
315
|
+
expired_total: field("expired_total"),
|
|
316
|
+
labels_quarantined: recordedCount(loopStatus.labels_quarantined, "count", nowMs),
|
|
317
|
+
gave_up: field("gave_up"),
|
|
318
|
+
...lagSection(evaluator, nowMs),
|
|
319
|
+
label_lag_alarm_minutes: count(LABEL_LAG_ALARM_MINUTES),
|
|
320
|
+
headless: headlessSection(evaluator, today),
|
|
321
|
+
},
|
|
322
|
+
reconcile: reconcileSection(stored.reconcile),
|
|
323
|
+
steps: stepsSection(stored, nowMs),
|
|
324
|
+
worker: workerSection(loopStatus.worker),
|
|
325
|
+
}
|
|
326
|
+
const blocked = evaluator !== null && isObject(evaluator.headless) && isInteger(evaluator.headless.blocked_days) ? evaluator.headless.blocked_days : null
|
|
327
|
+
// A facts quarantine that has not settled within the keep limit (`capture-sweep.js`): its hosts go to the store as not counted, which no store alarm reads.
|
|
328
|
+
const notSettling = isObject(stored.coverage_kept) && stored.coverage_kept.code === "quarantine_not_settling"
|
|
329
|
+
return { loop, signals: { blocked_days: blocked, cards_invalid: invalid, slot_invalid: !slotValid(loop), facts_quarantine_not_settling: notSettling, held_sessions: agedHolds(stored.held_sessions, nowMs) }, cards: cards.cards }
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
const HELD_ALARM_MS = 24 * 60 * 60 * 1000
|
|
333
|
+
/** The held-session groups whose oldest hold is older than a day, from the sweep's record (`derive-run.js` `heldSessions`), or null when there is no record. */
|
|
334
|
+
function agedHolds(record, nowMs) {
|
|
335
|
+
if (!isObject(record) || !Array.isArray(record.groups)) return null
|
|
336
|
+
return record.groups.filter((group) => isObject(group) && typeof group.route === "string" && typeof group.reason === "string" && isInteger(group.sessions) && group.sessions > 0 && nowMs - Date.parse(group.oldest_at) >= HELD_ALARM_MS)
|
|
337
|
+
.map(({ route, reason, sessions, oldest_at: oldest }) => ({ route, reason, sessions, oldest_at: oldest }))
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function toMillis(now) {
|
|
341
|
+
const time = now === null ? Number.NaN : new Date(now).getTime()
|
|
342
|
+
if (Number.isNaN(time)) throw Object.assign(new TypeError("Pass now as a valid time"), { code: "loop_health_pass_now_as_a_valid" })
|
|
343
|
+
return time
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
async function gather({ env, deskRoot, personPrefix = "", now = new Date(), readStatusImpl = readStatus, readCardsImpl = readCardsDefault, pluginVersion: given }) {
|
|
347
|
+
const nowMs = toMillis(now)
|
|
348
|
+
let status = null
|
|
349
|
+
try {
|
|
350
|
+
status = await readStatusImpl(env)
|
|
351
|
+
} catch {
|
|
352
|
+
status = null
|
|
353
|
+
}
|
|
354
|
+
let read = null
|
|
355
|
+
try {
|
|
356
|
+
read = await readCardsImpl({ deskRoot, personPrefix, limit: MAX_CARD_FILES })
|
|
357
|
+
} catch {
|
|
358
|
+
read = null
|
|
359
|
+
}
|
|
360
|
+
const version = given === undefined ? pluginVersion(env) : typeof given === "string" && VERSION.test(given) ? given : "unknown"
|
|
361
|
+
return { ...assembleLoop({ status: isObject(status) ? status : {}, read, nowMs, version }), status }
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/** `buildLoopHealth({ env, deskRoot, personPrefix, now, readStatusImpl?, readCardsImpl?, pluginVersion? }) -> Loop`: the record (see the header). An unreadable input makes its numbers unavailable, never 0. */
|
|
365
|
+
export async function buildLoopHealth(input) {
|
|
366
|
+
return (await gather(input)).loop
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// ---------------------------------------------------------------------------
|
|
370
|
+
// Alarms
|
|
371
|
+
|
|
372
|
+
// A partial count is a lower bound, so a partial value above the threshold is above it.
|
|
373
|
+
const measuredAbove = (value, threshold) => (value.state === "measured" || value.state === "partial") && value.value > threshold
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* `loopAlarms(loop, { attempted?, blocked_days?, cards_invalid?, facts_quarantine_not_settling? }) -> [{ name, evidence }]`: the alarms that hold now, in a fixed order. `evidence`
|
|
377
|
+
* is a small object of counts for the caller's logs; a card carries no evidence pointer. `attempted` names the steps the worker ran this
|
|
378
|
+
* run: a step that was not attempted never raises `step_stale`.
|
|
379
|
+
*/
|
|
380
|
+
export function loopAlarms(loop, signals = {}) {
|
|
381
|
+
const alarms = []
|
|
382
|
+
const { improvement, unsigned_deliveries: unsigned, evaluator, steps } = loop
|
|
383
|
+
if (measuredAbove(improvement.oldest_open_age_days, AGE_ALARM_DAYS)) alarms.push({ name: "improvement_age", evidence: { age_days: improvement.oldest_open_age_days.value } })
|
|
384
|
+
if (measuredAbove(improvement.oldest_in_verification_age_days, STUCK_ALARM_DAYS)) alarms.push({ name: "improvement_stuck", evidence: { age_days: improvement.oldest_in_verification_age_days.value } })
|
|
385
|
+
if (measuredAbove(unsigned.oldest_age_days, AGE_ALARM_DAYS)) alarms.push({ name: "unsigned_age", evidence: { age_days: unsigned.oldest_age_days.value } })
|
|
386
|
+
if (BLOCKING_STATES.includes(evaluator.headless.state) && isInteger(signals.blocked_days) && signals.blocked_days >= BLOCKED_DAYS_FOR_ALARM) alarms.push({ name: "headless_blocked", evidence: { blocked_days: signals.blocked_days } })
|
|
387
|
+
if (isInteger(signals.cards_invalid) && signals.cards_invalid > 0) alarms.push({ name: "cards_invalid", evidence: { files: signals.cards_invalid } })
|
|
388
|
+
if (measuredAbove(evaluator.labels_quarantined, 0)) alarms.push({ name: "labels_quarantined", evidence: { count: evaluator.labels_quarantined.value } })
|
|
389
|
+
// A machine whose evaluator cannot run (a sign-in, a CLI, billing or the switch) has its own state and alarm; the lag says nothing more there.
|
|
390
|
+
if (!LAG_SILENT_STATES.includes(evaluator.headless.state) && measuredAbove(evaluator.label_lag_minutes, LABEL_LAG_ALARM_MINUTES)) alarms.push({ name: "label_lag", evidence: { minutes: evaluator.label_lag_minutes.value, jobs: evaluator.unlabeled_finished.value } })
|
|
391
|
+
if (signals.facts_quarantine_not_settling === true) alarms.push({ name: "facts_quarantine_not_settling", evidence: {} })
|
|
392
|
+
// The record's own slot fails the store's rule, so the capture record goes without it: said once as an alarm, never silence.
|
|
393
|
+
if (Array.isArray(signals.held_sessions) && signals.held_sessions.length > 0) alarms.push({ name: "held_sessions", evidence: { sessions: signals.held_sessions.reduce((sum, group) => sum + group.sessions, 0), groups: signals.held_sessions } })
|
|
394
|
+
if (signals.slot_invalid === true) alarms.push({ name: "capture_loop_slot", evidence: {} })
|
|
395
|
+
for (const step of signals.attempted ?? []) if (STEPS.includes(step) && steps[step].stale) alarms.push({ name: `step_stale:${step}`, evidence: { failures: steps[step].failures.value } })
|
|
396
|
+
return alarms
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/** `unreadAlarms(loop, signals) -> [name]`: the alarms whose input could not be read this run. They are neither raised nor cleared by it. */
|
|
400
|
+
export function unreadAlarms(loop, signals = {}) {
|
|
401
|
+
const unread = []
|
|
402
|
+
const { improvement, unsigned_deliveries: unsigned, evaluator } = loop
|
|
403
|
+
const blind = (value, none) => value.state === "unavailable" && value.reasons[0] !== none
|
|
404
|
+
if (blind(improvement.oldest_open_age_days, "none_open")) unread.push("improvement_age")
|
|
405
|
+
if (blind(improvement.oldest_in_verification_age_days, "none_in_verification")) unread.push("improvement_stuck")
|
|
406
|
+
// A measured 0 unsigned reads clear whatever the age says; a count that is above 0 with no age, or no count, cannot be read.
|
|
407
|
+
if (unsigned.count.state === "unavailable" || (unsigned.count.value > 0 && unsigned.oldest_age_days.state === "unavailable")) unread.push("unsigned_age")
|
|
408
|
+
if (evaluator.headless.state === "unavailable" || !isInteger(signals.blocked_days)) unread.push("headless_blocked")
|
|
409
|
+
if (!isInteger(signals.cards_invalid)) unread.push("cards_invalid")
|
|
410
|
+
if (evaluator.labels_quarantined.state === "unavailable") unread.push("labels_quarantined")
|
|
411
|
+
if (evaluator.label_lag_minutes.state === "unavailable") unread.push("label_lag")
|
|
412
|
+
if (typeof signals.facts_quarantine_not_settling !== "boolean") unread.push("facts_quarantine_not_settling")
|
|
413
|
+
if (!Array.isArray(signals.held_sessions)) unread.push("held_sessions")
|
|
414
|
+
const attempted = signals.attempted ?? []
|
|
415
|
+
for (const step of STEPS) if (!attempted.includes(step)) unread.push(`step_stale:${step}`)
|
|
416
|
+
return unread
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// ---------------------------------------------------------------------------
|
|
420
|
+
// The step
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* `runMeasureStep(env, { deskRoot, personPrefix = "", now, attempted = [], ...seams }) -> { ok, result, counts }`. `attempted` names the steps the
|
|
424
|
+
* worker ran in this run. Results: `measured` (ok); `headless_session` (nothing written, nothing recorded); `status_unavailable` and `status_write_failed` (nothing
|
|
425
|
+
* recorded); `alarm_write_failed`, `observe_failed` and `step_not_recorded` (not ok; the record was written). Seams, for tests: `writeCardCommitted`,
|
|
426
|
+
* `observe`, `readStatusImpl`, `updateStatusImpl`, `readCardsImpl`, `recordStepImpl`, `pluginVersion`. It throws only for an invalid `deskRoot` or `now`.
|
|
427
|
+
*/
|
|
428
|
+
export async function runMeasureStep(env, {
|
|
429
|
+
deskRoot, personPrefix = "", now, attempted = [],
|
|
430
|
+
writeCardCommitted = writeCardCommittedDefault, observe = observeConditions, readStatusImpl = readStatus, updateStatusImpl = updateStatus,
|
|
431
|
+
readCardsImpl = readCardsDefault, recordStepImpl = recordStep, pluginVersion: version,
|
|
432
|
+
}) {
|
|
433
|
+
if (typeof deskRoot !== "string" || !path.isAbsolute(deskRoot)) throw Object.assign(new TypeError("Pass deskRoot as an absolute path"), { code: "loop_health_pass_deskroot_as_an_absolute" })
|
|
434
|
+
const nowMs = toMillis(now)
|
|
435
|
+
const counts = {}
|
|
436
|
+
const tally = (code) => { counts[code] = (counts[code] ?? 0) + 1 }
|
|
437
|
+
if (isHeadlessFactorySession(env)) return { ok: false, result: "headless_session", counts }
|
|
438
|
+
const date = new Date(nowMs)
|
|
439
|
+
|
|
440
|
+
let status
|
|
441
|
+
try {
|
|
442
|
+
status = await readStatusImpl(env)
|
|
443
|
+
} catch {
|
|
444
|
+
status = null
|
|
445
|
+
}
|
|
446
|
+
if (!isObject(status)) return { ok: false, result: "status_unavailable", counts }
|
|
447
|
+
|
|
448
|
+
const built = await gather({ env, deskRoot, personPrefix, now: date, readStatusImpl: async () => status, readCardsImpl, pluginVersion: version })
|
|
449
|
+
try {
|
|
450
|
+
await updateStatusImpl(env, (current) => ({ ...current, loop: { ...(isObject(current.loop) ? current.loop : {}), health: built.loop } }))
|
|
451
|
+
} catch {
|
|
452
|
+
return { ok: false, result: "status_write_failed", counts }
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
const signals = { ...built.signals, attempted: attempted.filter((name) => STEPS.includes(name)) }
|
|
456
|
+
const holding = loopAlarms(built.loop, signals)
|
|
457
|
+
const open = new Set((built.cards ?? []).filter((card) => card.source === "loop_alarm" && !card.state.startsWith("closed_")).map((card) => card.key))
|
|
458
|
+
let writeFailed = false
|
|
459
|
+
for (const { name } of holding) {
|
|
460
|
+
const key = cardKey("loop_alarm", name)
|
|
461
|
+
if (open.has(key)) continue
|
|
462
|
+
try {
|
|
463
|
+
const { result, commit } = await writeCardCommitted({
|
|
464
|
+
deskRoot, personPrefix,
|
|
465
|
+
write: () => openImprovement({ deskRoot, personPrefix, key, source: "loop_alarm", evidence: [], plugin: "desk", signal: null, now: date }),
|
|
466
|
+
message: (written) => cardCommitMessage("measure", written.file_name ?? "set_aside"),
|
|
467
|
+
})
|
|
468
|
+
if (result.result === "opened" || result.result === "reopened") tally(result.result)
|
|
469
|
+
else if (result.result === "duplicate") tally("duplicate")
|
|
470
|
+
else { writeFailed = true; tally("card_write_failed") }
|
|
471
|
+
if (commit !== "committed" && commit !== "no_change" && commit !== "no_files") tally(commit)
|
|
472
|
+
} catch {
|
|
473
|
+
writeFailed = true
|
|
474
|
+
tally("card_write_failed")
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
// The complete list of alarms that hold. An alarm whose input could not be read stays in it when it is recorded present.
|
|
479
|
+
const present = new Set(holding.map((alarm) => alarm.name))
|
|
480
|
+
for (const name of unreadAlarms(built.loop, signals)) {
|
|
481
|
+
if (!present.has(name) && conditionOf(status, `loop_alarm:${name}`).present === true) present.add(name)
|
|
482
|
+
}
|
|
483
|
+
let observeFailed = false
|
|
484
|
+
try {
|
|
485
|
+
const seen = await observe(env, { source: "loop_alarm", present: [...present], now: date })
|
|
486
|
+
if (!seen?.ok) observeFailed = true
|
|
487
|
+
} catch {
|
|
488
|
+
observeFailed = true
|
|
489
|
+
}
|
|
490
|
+
if (observeFailed) tally("observe_failed")
|
|
491
|
+
|
|
492
|
+
const result = writeFailed ? "alarm_write_failed" : observeFailed ? "observe_failed" : "measured"
|
|
493
|
+
const ok = result === "measured"
|
|
494
|
+
try {
|
|
495
|
+
await recordStepImpl(env, "measure", { ok, result, now: date })
|
|
496
|
+
} catch {
|
|
497
|
+
return { ok: false, result: "step_not_recorded", counts }
|
|
498
|
+
}
|
|
499
|
+
return { ok, result, counts }
|
|
500
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// The loop health record flattened to the capture record's loop slot (`loop_slot_v1` of the store; the rule is `validateLoopSlot` in `capture-schema.js`).
|
|
2
|
+
//
|
|
3
|
+
// The base slot is counts only. Each key is read from one field of the stored `desk.factory.loop/1` record (`loop-health.js`), and only a measured Count
|
|
4
|
+
// becomes a number: an unavailable, partial (a lower bound, not the number), damaged or missing field is `null`, the contract's "not measured",
|
|
5
|
+
// never 0. `headless` is the evaluator's state code, `null` when it is not recorded for today. Nothing else is read, so no name, path, title,
|
|
6
|
+
// card text or date can reach the slot, and nothing in it is per person. A compatible store may additionally receive a fixed refresh-state code.
|
|
7
|
+
//
|
|
8
|
+
// A record older than `SLOT_MAX_AGE_HOURS` (or dated in the future) says nothing about now, so it gives no slot. The age of the oldest open card is
|
|
9
|
+
// aged by the record's own age in whole days, because the slot has no date and the store counts from the capture commit. A key whose value fails
|
|
10
|
+
// the store's rule is sent as `null` and the rest of the slot goes; `slotValid` is false for it, so the measure step raises
|
|
11
|
+
// `loop_alarm:capture_loop_slot`.
|
|
12
|
+
|
|
13
|
+
import { LOOP_SLOT_VERSION, TRIAGE_REFRESH_CODES, validateLoopSlot } from "./capture-schema.js"
|
|
14
|
+
|
|
15
|
+
export const SLOT_MAX_AGE_HOURS = 72
|
|
16
|
+
const HOUR_MS = 3600 * 1000
|
|
17
|
+
const DAY_MS = 24 * HOUR_MS
|
|
18
|
+
const FUTURE_ALLOWANCE_MS = 5 * 60 * 1000
|
|
19
|
+
|
|
20
|
+
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value)
|
|
21
|
+
|
|
22
|
+
/** A stored Count's value when it is measured and a non-negative whole number, else null. A value over the store's ceiling is kept, so the slot fails its rule and says so. */
|
|
23
|
+
function measuredValue(count) {
|
|
24
|
+
return isObject(count) && count.state === "measured" && Number.isSafeInteger(count.value) && count.value >= 0 ? count.value : null
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function staleStepCount(steps) {
|
|
28
|
+
const records = isObject(steps) ? Object.values(steps).filter(isObject) : []
|
|
29
|
+
// No step ever ran: nothing is known to be stale, and nothing is known to be fresh either.
|
|
30
|
+
if (!records.some((record) => typeof record.last_ran_at === "string")) return null
|
|
31
|
+
return records.filter((record) => record.stale === true).length
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** `slotFields(record) -> object`: the slot's keys and values from the stored loop record, `v` first. Not yet validated. */
|
|
35
|
+
export function slotFields(record) {
|
|
36
|
+
const improvement = isObject(record.improvement) ? record.improvement : {}
|
|
37
|
+
const alarms = isObject(record.alarms) ? record.alarms : {}
|
|
38
|
+
const headless = isObject(record.evaluator) && isObject(record.evaluator.headless) ? record.evaluator.headless.state : null
|
|
39
|
+
return {
|
|
40
|
+
v: LOOP_SLOT_VERSION,
|
|
41
|
+
improvement_open: measuredValue(improvement.open),
|
|
42
|
+
improvement_claimed: measuredValue(improvement.claimed),
|
|
43
|
+
improvement_shipped: measuredValue(improvement.shipped),
|
|
44
|
+
improvement_verifying: measuredValue(improvement.verifying),
|
|
45
|
+
oldest_open_age_days: measuredValue(improvement.oldest_open_age_days),
|
|
46
|
+
closed_confirmed_month: measuredValue(improvement.closed_confirmed_30d),
|
|
47
|
+
closed_unverified_month: measuredValue(improvement.closed_unverified_30d),
|
|
48
|
+
loop_alarms_open: measuredValue(alarms.loop_alarms_open),
|
|
49
|
+
steps_stale: staleStepCount(record.steps),
|
|
50
|
+
headless: typeof headless === "string" && headless !== "unavailable" ? headless : null,
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** `slotValid(record) -> boolean`: whether the slot built from `record` passes the store's rule. False for a value that is not a loop record. */
|
|
55
|
+
export function slotValid(record) {
|
|
56
|
+
return isObject(record) && validateLoopSlot(slotFields(record), "", [])
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** `sound(key, value) -> boolean`: whether `value` alone passes the store's rule for `key`. */
|
|
60
|
+
const sound = (key, value) => validateLoopSlot({ v: LOOP_SLOT_VERSION, [key]: value }, "", [])
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* `loopSlotFrom(record, nowMs) -> slot | null`: the slot for the capture record, or null when there is no current record. The record must be
|
|
64
|
+
* a `desk.factory.loop/1` record written at most `SLOT_MAX_AGE_HOURS` ago. A key that fails the store's rule is `null`; the other keys are kept.
|
|
65
|
+
*/
|
|
66
|
+
export function loopSlotFrom(record, nowMs, { triageRefresh } = {}) {
|
|
67
|
+
if (!isObject(record) || record.schema !== "desk.factory.loop/1") return null
|
|
68
|
+
const at = typeof record.written_at === "string" ? Date.parse(record.written_at) : Number.NaN
|
|
69
|
+
if (!Number.isFinite(at) || nowMs - at > SLOT_MAX_AGE_HOURS * HOUR_MS || at - nowMs > FUTURE_ALLOWANCE_MS) return null
|
|
70
|
+
const fields = slotFields(record)
|
|
71
|
+
if (triageRefresh === null || TRIAGE_REFRESH_CODES.includes(triageRefresh)) fields.triage_refresh = triageRefresh
|
|
72
|
+
if (fields.oldest_open_age_days !== null) fields.oldest_open_age_days += Math.max(0, Math.floor((nowMs - at) / DAY_MS))
|
|
73
|
+
return Object.fromEntries(Object.entries(fields).map(([key, value]) => [key, key === "v" || sound(key, value) ? value : null]))
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** A current, store-matched refresh operation, never a diagnosis inferred from step age. */
|
|
77
|
+
export function triageRefreshFrom(status, { store, nowMs }) {
|
|
78
|
+
const triage = status?.triage
|
|
79
|
+
const step = status?.loop?.health?.steps?.triage
|
|
80
|
+
const at = typeof triage?.at === "string" ? Date.parse(triage.at) : NaN
|
|
81
|
+
if (typeof triage?.store !== "string" || triage.store.toLowerCase() !== store.toLowerCase() ||
|
|
82
|
+
step?.last_ran_at !== triage.at || !Number.isFinite(at) ||
|
|
83
|
+
nowMs - at > SLOT_MAX_AGE_HOURS * HOUR_MS || at - nowMs > FUTURE_ALLOWANCE_MS) return null
|
|
84
|
+
const refresh = triage.refresh
|
|
85
|
+
if (!isObject(refresh) || !["complete", "truncated"].includes(refresh.scan) ||
|
|
86
|
+
!["changes", "written", "held", "foreign", "unknown", "deferred"].every((key) => Number.isSafeInteger(refresh[key]) && refresh[key] >= 0)) return null
|
|
87
|
+
if (refresh.alarm === "triage_resource_unrecoverable" && refresh.held > 0) return "resource_unrecoverable"
|
|
88
|
+
if (refresh.alarm !== null) return null
|
|
89
|
+
return refresh.scan === "complete" && refresh.held === 0 && refresh.unknown === 0 && refresh.deferred === 0 ? "current" : "incomplete"
|
|
90
|
+
}
|