@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,100 @@
|
|
|
1
|
+
// Step bookkeeping for the factory loop. Each automatic step records when it last ran, when it last
|
|
2
|
+
// succeeded and a stable result code in `status.json` under `loop.steps.<name>`. A step that never ran has
|
|
3
|
+
// no record, and a step that ran and failed keeps `last_ok_at` as it was (null if it never succeeded), so a
|
|
4
|
+
// step that did not run never looks like one that ran and found nothing. No free text enters the record.
|
|
5
|
+
|
|
6
|
+
import { updateStatus } from "./outbox.js"
|
|
7
|
+
|
|
8
|
+
export const STEPS = Object.freeze(["evaluate", "route", "mirror", "reconcile", "verify", "measure", "deliver"])
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The shortest time between two runs of a step, in hours; 0 means the step runs every time it is asked.
|
|
12
|
+
*/
|
|
13
|
+
export const MIN_GAP_HOURS = Object.freeze({ evaluate: 1, route: 6, mirror: 6, reconcile: 24, verify: 24, measure: 0, deliver: 0 })
|
|
14
|
+
|
|
15
|
+
const STALE_AFTER_HOURS = 72
|
|
16
|
+
const STALE_FAILURES_IN_A_ROW = 3
|
|
17
|
+
const HOUR_MS = 3600 * 1000
|
|
18
|
+
const RESULT_CODE = /^[a-z0-9][a-z0-9_:-]{0,63}$/
|
|
19
|
+
|
|
20
|
+
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value)
|
|
21
|
+
|
|
22
|
+
function requireStep(name) {
|
|
23
|
+
if (!STEPS.includes(name)) throw Object.assign(new TypeError("step: Pass a known step"), { code: "step_pass_a_known_step" })
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function toTime(value) {
|
|
27
|
+
if (value === null) throw Object.assign(new TypeError("Pass now as a valid time"), { code: "loop_status_pass_now_as_a_valid_2" })
|
|
28
|
+
const time = new Date(value).getTime()
|
|
29
|
+
if (Number.isNaN(time)) throw Object.assign(new TypeError("Pass now as a valid time"), { code: "loop_status_pass_now_as_a_valid" })
|
|
30
|
+
return time
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function timeOrNull(value) {
|
|
34
|
+
const time = typeof value === "string" ? Date.parse(value) : Number.NaN
|
|
35
|
+
return Number.isNaN(time) ? null : time
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** A stored counter that is not a non-negative safe integer is damaged and counts as 0. */
|
|
39
|
+
const counter = (value) => (Number.isSafeInteger(value) && value >= 0 ? value : 0)
|
|
40
|
+
|
|
41
|
+
function stepsOf(status) {
|
|
42
|
+
return isObject(status?.loop) && isObject(status.loop.steps) ? status.loop.steps : {}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* `recordStep(env, name, { ok, result, now }) -> step record`: counts one run of `name` in `status.loop.steps.<name>`. `result` is a
|
|
47
|
+
* lowercase code of at most 64 characters.
|
|
48
|
+
*/
|
|
49
|
+
export async function recordStep(env, name, { ok, result, now = new Date() } = {}) {
|
|
50
|
+
requireStep(name)
|
|
51
|
+
if (typeof ok !== "boolean") throw Object.assign(new TypeError("Pass ok as a boolean"), { code: "loop_status_pass_ok_as_a_boolean" })
|
|
52
|
+
if (typeof result !== "string" || !RESULT_CODE.test(result)) throw Object.assign(new TypeError("Pass result as a lowercase code of at most 64 characters"), { code: "loop_status_pass_result_as_a_lowercase" })
|
|
53
|
+
const at = new Date(toTime(now)).toISOString()
|
|
54
|
+
let record
|
|
55
|
+
await updateStatus(env, (current) => {
|
|
56
|
+
const loop = isObject(current.loop) ? current.loop : {}
|
|
57
|
+
const steps = isObject(loop.steps) ? loop.steps : {}
|
|
58
|
+
const before = isObject(steps[name]) ? steps[name] : {}
|
|
59
|
+
record = {
|
|
60
|
+
last_ran_at: at,
|
|
61
|
+
last_ok_at: ok ? at : (before.last_ok_at ?? null),
|
|
62
|
+
last_result: result,
|
|
63
|
+
runs: counter(before.runs) + 1,
|
|
64
|
+
failures: counter(before.failures) + (ok ? 0 : 1),
|
|
65
|
+
failures_in_a_row: ok ? 0 : counter(before.failures_in_a_row) + 1,
|
|
66
|
+
}
|
|
67
|
+
return { ...current, loop: { ...loop, steps: { ...steps, [name]: record } } }
|
|
68
|
+
})
|
|
69
|
+
return record
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* `dueStep(status, name, now, { newWorkAt }) -> boolean`: true for a step that never ran, or whose last run is at least `MIN_GAP_HOURS[name]`
|
|
74
|
+
* old, or that last ran before `newWorkAt` (milliseconds, or null): work that arrived after the step last ran makes it due at once, whatever
|
|
75
|
+
* the gap. The evaluator step passes its newest evaluation request, so a finished job never waits out the gap.
|
|
76
|
+
*/
|
|
77
|
+
export function dueStep(status, name, now, { newWorkAt = null } = {}) {
|
|
78
|
+
requireStep(name)
|
|
79
|
+
const nowMs = toTime(now)
|
|
80
|
+
const ranAt = timeOrNull(stepsOf(status)[name]?.last_ran_at)
|
|
81
|
+
if (ranAt === null) return true
|
|
82
|
+
if (Number.isFinite(newWorkAt) && newWorkAt > ranAt) return true
|
|
83
|
+
const elapsed = nowMs - ranAt
|
|
84
|
+
return elapsed < 0 || elapsed >= MIN_GAP_HOURS[name] * HOUR_MS
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** `staleSteps(status, now, attemptedNames) -> string[]`: the steps attempted in this run whose last success is over 72 hours old (or over 72 hours ahead of the clock), or that failed 3 times in a row. An unreadable non-null `last_ok_at` counts as stale; a null one has no age. A step not attempted is never reported. */
|
|
88
|
+
export function staleSteps(status, now, attemptedNames) {
|
|
89
|
+
const steps = stepsOf(status)
|
|
90
|
+
const nowMs = toTime(now)
|
|
91
|
+
return attemptedNames.filter((name) => {
|
|
92
|
+
const record = steps[name]
|
|
93
|
+
if (!STEPS.includes(name) || !isObject(record)) return false
|
|
94
|
+
if (counter(record.failures_in_a_row) >= STALE_FAILURES_IN_A_ROW) return true
|
|
95
|
+
if (record.last_ok_at === null || record.last_ok_at === undefined) return false
|
|
96
|
+
const okAt = timeOrNull(record.last_ok_at)
|
|
97
|
+
// A success dated more than the stale window ahead of the clock (a clock that moved back) has no knowable age, so it reads stale rather than fresh for days.
|
|
98
|
+
return okAt === null || Math.abs(nowMs - okAt) > STALE_AFTER_HOURS * HOUR_MS
|
|
99
|
+
})
|
|
100
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// The one off switch for the whole improvement loop: `DESK_FACTORY_LOOP` set to anything but 1, true, on or yes
|
|
4
|
+
// (padded or in capitals) turns it off, the same rule as the evaluator's `DESK_FACTORY_HEADLESS_EVALUATOR`.
|
|
5
|
+
// Unset means on. The loop worker (loop-worker.js) and the launcher hook (hooks/loop-start.cjs) both read it here.
|
|
6
|
+
|
|
7
|
+
const ON = new Set(["1", "true", "on", "yes"]);
|
|
8
|
+
|
|
9
|
+
function isLoopEnabled(env) {
|
|
10
|
+
const value = env?.DESK_FACTORY_LOOP;
|
|
11
|
+
return value === undefined || ON.has(String(value).trim().toLowerCase());
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = { isLoopEnabled };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// What the loop worker leaves behind about itself, and the mark a reset status file leaves.
|
|
2
|
+
//
|
|
3
|
+
// The worker's own outcome of every run is `status.json.loop.worker = { at, result, since }` (`since` is when the current result
|
|
4
|
+
// started, so a lock held for hours shows its age). When the status file cannot be written, the same three fields go to
|
|
5
|
+
// `locks/loop-worker.state.json`. Both hold a code and two times, nothing else. The session-start line and the health record read them here.
|
|
6
|
+
//
|
|
7
|
+
// A damaged `status.json` is moved aside by the reader as `status.json.corrupt-json-<n>` and read as empty, which would reset the
|
|
8
|
+
// evaluator's daily cap. The moved-aside file is the durable mark: a UTC day on which one was set aside is a spent day for the evaluator.
|
|
9
|
+
// `ctime` is the time of the rename, which is when the status was reset; the later of it and `mtime` is used.
|
|
10
|
+
|
|
11
|
+
import { readdirSync, statSync, readFileSync } from "node:fs"
|
|
12
|
+
import { promises as fsp } from "node:fs"
|
|
13
|
+
import { randomBytes } from "node:crypto"
|
|
14
|
+
import * as path from "node:path"
|
|
15
|
+
|
|
16
|
+
export const WORKER_STATE_FILE = "loop-worker.state.json"
|
|
17
|
+
const ASIDE_NAME = /^status\.json\.corrupt-json-[0-9]+$/u
|
|
18
|
+
const RESULT_CODE = /^[a-z0-9][a-z0-9_:-]{0,63}$/u
|
|
19
|
+
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value)
|
|
20
|
+
const isTime = (value) => typeof value === "string" && !Number.isNaN(Date.parse(value))
|
|
21
|
+
|
|
22
|
+
/** The names of the status files that were moved aside, or `[]` when the folder cannot be listed. */
|
|
23
|
+
export function listStatusAside(root) {
|
|
24
|
+
try {
|
|
25
|
+
return readdirSync(root).filter((name) => ASIDE_NAME.test(name))
|
|
26
|
+
} catch {
|
|
27
|
+
return []
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** The latest UTC day (`YYYY-MM-DD`) on which a status file was set aside, or `null`. */
|
|
32
|
+
export function statusResetDay(root) {
|
|
33
|
+
let latest = null
|
|
34
|
+
for (const name of listStatusAside(root)) {
|
|
35
|
+
try {
|
|
36
|
+
const info = statSync(path.join(root, name))
|
|
37
|
+
const ms = Math.max(info.mtimeMs, info.ctimeMs)
|
|
38
|
+
latest = Math.max(latest ?? ms, ms)
|
|
39
|
+
} catch {
|
|
40
|
+
// Gone since the listing.
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return latest === null ? null : new Date(latest).toISOString().slice(0, 10)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** A stored `{ at, result, since }` that is well formed, or `null`. */
|
|
47
|
+
export function validWorker(value) {
|
|
48
|
+
return isObject(value) && isTime(value.at) && isTime(value.since) && typeof value.result === "string" && RESULT_CODE.test(value.result)
|
|
49
|
+
? { at: value.at, result: value.result, since: value.since }
|
|
50
|
+
: null
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The record for a run that ended with `result` at `at` (ISO): `since` stays while the result stays the same. */
|
|
54
|
+
function nextWorker(previous, result, at) {
|
|
55
|
+
const before = validWorker(previous)
|
|
56
|
+
return { at, result, since: before !== null && before.result === result && Date.parse(before.since) <= Date.parse(at) ? before.since : at }
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function readFallback(root) {
|
|
60
|
+
try {
|
|
61
|
+
return validWorker(JSON.parse(readFileSync(path.join(root, "locks", WORKER_STATE_FILE), "utf8")))
|
|
62
|
+
} catch {
|
|
63
|
+
return null
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** The newer of the status file's record and the fallback file's (`status` may be `null`), or `null` when neither is well formed. */
|
|
68
|
+
export function readWorker(status, root) {
|
|
69
|
+
const stored = validWorker(isObject(status?.loop) ? status.loop.worker : undefined)
|
|
70
|
+
const fallback = readFallback(root)
|
|
71
|
+
if (stored === null) return fallback
|
|
72
|
+
return fallback !== null && Date.parse(fallback.at) > Date.parse(stored.at) ? fallback : stored
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Writes the worker's outcome: into the status through `updateStatusImpl`, else into the small file beside the lock. Never throws. */
|
|
76
|
+
export async function recordWorker(env, root, result, at, updateStatusImpl) {
|
|
77
|
+
try {
|
|
78
|
+
await updateStatusImpl(env, (current) => {
|
|
79
|
+
const loop = isObject(current.loop) ? current.loop : {}
|
|
80
|
+
return { ...current, loop: { ...loop, worker: nextWorker(loop.worker, result, at) } }
|
|
81
|
+
})
|
|
82
|
+
return
|
|
83
|
+
} catch {
|
|
84
|
+
// Fall through to the file beside the lock.
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
const dir = path.join(root, "locks")
|
|
88
|
+
await fsp.mkdir(dir, { recursive: true, mode: 0o700 })
|
|
89
|
+
const file = path.join(dir, WORKER_STATE_FILE)
|
|
90
|
+
const temporary = `${file}.${randomBytes(4).toString("hex")}.tmp`
|
|
91
|
+
await fsp.writeFile(temporary, JSON.stringify(nextWorker(readFallback(root), result, at)), { mode: 0o600 })
|
|
92
|
+
await fsp.rename(temporary, file)
|
|
93
|
+
} catch {
|
|
94
|
+
// Nowhere to write: the printed line is all there is.
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
// The loop worker: one detached run of the improvement cycle, started by the session-start hook (hooks/loop-start.cjs)
|
|
2
|
+
// through `factory.js loop`. It runs the steps in order (the list `STEPS` below is data, so a step added later is
|
|
3
|
+
// one more entry), one at a time and each inside its own try, so one failing step never stops the next. A step that
|
|
4
|
+
// is not due (`dueStep`, inside its minimum gap with no newer work for it) is skipped and leaves no record. Besides the
|
|
5
|
+
// session-start hook, the end of a turn and a finalize run start the worker when the evaluator step is due (`evaluate-kick.js`),
|
|
6
|
+
// and a worker whose evaluator step labeled a job starts the next one as it ends, so the queue drains back to back.
|
|
7
|
+
//
|
|
8
|
+
// The order is route, evaluate, mirror, reconcile, verify, measure. Findings are routed first, so the later steps read current cards.
|
|
9
|
+
// The evaluator step starts at most one run (`maxRuns: 1`). An evaluation continuation an earlier Desk's triage step left in the status
|
|
10
|
+
// (`status.loop.evaluation_continuation`) is consumed under the lock before the evaluator step is asked whether it is due
|
|
11
|
+
// (`consumeEvaluationContinuation`): a consumed token makes the evaluator due; a refused one changes nothing.
|
|
12
|
+
//
|
|
13
|
+
// Safe and detached:
|
|
14
|
+
// - One worker at a time per machine, under one lock file in the factory state folder (`process-lock.js`: the
|
|
15
|
+
// worker's process id, start time, a random token and the child ids it started, which `onChild` and
|
|
16
|
+
// `onChildExit` of the evaluator step keep). A second worker answers `busy`. A lock is taken over only when
|
|
17
|
+
// its recorded process is not alive or it is older than 6 hours. Nothing is ever matched by name or signalled.
|
|
18
|
+
// - A fixed time budget: no step starts after `LOOP_BUDGET_MS` (20 minutes); the evaluator step gets a deadline
|
|
19
|
+
// that leaves `LATER_STEPS_RESERVE_MS` for the later steps; and the process ends itself at the budget plus
|
|
20
|
+
// `CEILING_GRACE_MS` if a step hangs. The evaluator's facts scan is left out of that budget: the step asks
|
|
21
|
+
// `extendDeadline(scanMs)` once its scan ends, and the worker grants the scan's time (at most
|
|
22
|
+
// `MAX_SCAN_ALLOWANCE_MS` in all), moves the budget, and with it the later steps' reserve, and the ceiling by
|
|
23
|
+
// the grant, tells its launcher (`hooks/loop-start.cjs`, over the message channel it opened, only while it is
|
|
24
|
+
// open) so the hard stop moves too, and rewrites its lock so the end-of-turn kick still reads it as running.
|
|
25
|
+
// A scan that ends before the first ceiling (21 minutes after the start) therefore never leaves less than one
|
|
26
|
+
// run's time; a longer scan is still ended by that ceiling or the launcher's 22-minute hard stop, as before.
|
|
27
|
+
// - A headless factory session (`DESK_FACTORY_HEADLESS`) starts nothing and writes nothing. `DESK_FACTORY_LOOP`
|
|
28
|
+
// set to anything but 1, true, on or yes turns the loop off (`disabled`). No state folder, no consenting store
|
|
29
|
+
// and no desk root each start nothing. Every outcome but a headless session or a missing state folder is recorded
|
|
30
|
+
// (`loop-worker-state.js`) so the session-start line and the health record can say what the loop last did.
|
|
31
|
+
//
|
|
32
|
+
// The result holds codes and integers only: `{ result, ran, skipped, failed, steps: { <step>: <code> } }`, where
|
|
33
|
+
// `result` is `completed`, `budget_spent`, `status_unavailable`, `status_reset` (the status file was damaged and moved aside during this run: nothing more runs, and that UTC day is a spent day for the evaluator), `busy`, `headless_session`, `disabled`,
|
|
34
|
+
// `no_factory_state`, `no_consenting_store`, `no_desk` or `stale_release` (the Desk that started this worker is older than the newest release on this machine, as in a session that outlived its Desk: it claims nothing, the code is recorded as the skip reason, and the newest release's own hooks run the loop), and a step's code is its own result code, `skipped`
|
|
35
|
+
// (not due), `not_started` (the budget was spent, or the status unreadable or reset), `step_error` (it threw) or
|
|
36
|
+
// `invalid_result`. The `route` step is the two route collectors as one: `routed`, `issues_failed`, `local_failed`
|
|
37
|
+
// or `both_failed`. `route` and `measure` answer `not_own_desk` (not run and not recorded) in a desk that is not the person's own (`route-desk.js`).
|
|
38
|
+
// Every other step records itself; the worker records `route`, and records `step_error` for a step that threw. The measure step runs last and is told which steps ran.
|
|
39
|
+
|
|
40
|
+
import { createRequire } from "node:module"
|
|
41
|
+
import { existsSync, readdirSync } from "node:fs"
|
|
42
|
+
import * as os from "node:os"
|
|
43
|
+
import * as path from "node:path"
|
|
44
|
+
|
|
45
|
+
import { checkPersonPrefix } from "./binding.js"
|
|
46
|
+
import { hasContributingStore } from "./boot-check.js"
|
|
47
|
+
import { isHeadlessFactorySession } from "./headless-flag.js"
|
|
48
|
+
import { runMeasureStep } from "./loop-health.js"
|
|
49
|
+
import { dueStep, recordStep } from "./loop-status.js"
|
|
50
|
+
import { runMirrorStep } from "./mirror-step.js"
|
|
51
|
+
import { listStatusAside, recordWorker } from "./loop-worker-state.js"
|
|
52
|
+
import { factoryStateRoot, readStatus, updateStatus } from "./outbox.js"
|
|
53
|
+
import { processAlive, releaseLock, takeLock, touchLock, trackChild } from "./process-lock.js"
|
|
54
|
+
import { runReconcileStep } from "./reconcile-step.js"
|
|
55
|
+
import { runRouteIssuesStep } from "./route-issues.js"
|
|
56
|
+
import { runRouteLocalStep } from "./route-local.js"
|
|
57
|
+
import { isOwnDesk } from "./route-desk.js"
|
|
58
|
+
import { runEvaluatorStep } from "./evaluator-step.js"
|
|
59
|
+
import { contextEvaluationDue } from "./context-run.js"
|
|
60
|
+
import { LOOP_LOCK_NAME, evaluateDue, kickLoop, newestRequestAt } from "./evaluate-kick.js"
|
|
61
|
+
import { consumeEvaluationContinuation } from "./headless-ledger.js"
|
|
62
|
+
import { runVerifyStep } from "./improvement-verify.js"
|
|
63
|
+
import { compareVersions, isVersion } from "./pipeline/versions.js"
|
|
64
|
+
|
|
65
|
+
const { isLoopEnabled } = createRequire(import.meta.url)("./loop-switch.cjs")
|
|
66
|
+
|
|
67
|
+
export const LOOP_BUDGET_MS = 20 * 60 * 1000
|
|
68
|
+
// What the evaluator step leaves for the steps after it: it starts no run that could end later than this before the budget.
|
|
69
|
+
export const LATER_STEPS_RESERVE_MS = 3 * 60 * 1000
|
|
70
|
+
// The process ends itself this long after the budget if a step is still running.
|
|
71
|
+
const CEILING_GRACE_MS = 60 * 1000
|
|
72
|
+
// The most facts-scan time the worker leaves out of its budget, in all. With the budget and the grace it keeps a worker well inside the
|
|
73
|
+
// lock's 6-hour outer age (`LOCK_OUTER_AGE_MS`), so no second worker ever takes over a live one. `hooks/loop-start.cjs` holds the same number.
|
|
74
|
+
export const MAX_SCAN_ALLOWANCE_MS = 5 * 60 * 60 * 1000
|
|
75
|
+
const LOCK_NAME = LOOP_LOCK_NAME
|
|
76
|
+
const CODE = /^[a-z0-9][a-z0-9_:-]{0,63}$/u
|
|
77
|
+
|
|
78
|
+
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value)
|
|
79
|
+
/** The newest complete Desk release copy on this machine (`runtime/newest-release.js` keeps them), or null. */
|
|
80
|
+
function newestInstalledRelease(env) {
|
|
81
|
+
const cacheHome = typeof env.XDG_CACHE_HOME === "string" && env.XDG_CACHE_HOME.trim() !== "" ? env.XDG_CACHE_HOME : path.join(env.HOME || os.homedir(), ".cache")
|
|
82
|
+
const copies = path.join(cacheHome, "ouroboros-skills", "desk", "release-copies")
|
|
83
|
+
try {
|
|
84
|
+
return readdirSync(copies).filter((name) => isVersion(name) && existsSync(path.join(copies, name, ".complete.json"))).sort(compareVersions).at(-1) ?? null
|
|
85
|
+
} catch {
|
|
86
|
+
return null
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const answer = (result, extra = {}) => ({ result, ran: 0, skipped: 0, failed: 0, steps: {}, ...extra })
|
|
91
|
+
|
|
92
|
+
// A step's answer, or null when it is not `{ ok: boolean, result: <code> }`.
|
|
93
|
+
const readAnswer = (value) => (isObject(value) && typeof value.ok === "boolean" && typeof value.result === "string" && CODE.test(value.result) ? { ok: value.ok, result: value.result } : null)
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The default notice to the launcher: a message on the channel it opened, only while that channel is open. The callback takes any error
|
|
97
|
+
* (a launcher that ended between the check and the write), which Node would otherwise raise as an `error` event and end this worker with.
|
|
98
|
+
*/
|
|
99
|
+
export function notifyLauncher(message) {
|
|
100
|
+
if (typeof process.send === "function" && process.connected) process.send(message, () => {})
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const swallow = async (fn) => {
|
|
104
|
+
try {
|
|
105
|
+
return await fn()
|
|
106
|
+
} catch {
|
|
107
|
+
return undefined
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const NOT_OWN_DESK = Object.freeze({ ok: true, result: "not_own_desk" })
|
|
112
|
+
|
|
113
|
+
// The two route collectors count as one step, recorded once by the worker. They write this machine's findings, so they run only in the
|
|
114
|
+
// person's own desk (`route-desk.js`); in any other desk the step is not recorded, so the own desk's next run is not held by the step's gap.
|
|
115
|
+
async function routeStep(env, ctx, impls) {
|
|
116
|
+
if (!ctx.ownDesk) return NOT_OWN_DESK
|
|
117
|
+
const half = async (fn) => readAnswer(await swallow(() => fn(env, { deskRoot: ctx.deskRoot, personPrefix: ctx.personPrefix, now: ctx.now }))) ?? { ok: false, result: "step_error" }
|
|
118
|
+
const issues = await half(impls.routeIssues)
|
|
119
|
+
const local = await half(impls.routeLocal)
|
|
120
|
+
if (issues.result === "headless_session" || local.result === "headless_session") return { ok: false, result: "headless_session" }
|
|
121
|
+
const result = issues.ok && local.ok ? "routed" : !issues.ok && !local.ok ? "both_failed" : !issues.ok ? "issues_failed" : "local_failed"
|
|
122
|
+
const outcome = { ok: result === "routed", result }
|
|
123
|
+
await swallow(() => recordStep(env, "route", { ...outcome, now: ctx.now }))
|
|
124
|
+
return outcome
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// The pending evaluation continuation an earlier Desk's triage step left (`status.loop.evaluation_continuation`), or null.
|
|
128
|
+
const pendingContinuation = (status) => (isObject(status?.loop) && isObject(status.loop.evaluation_continuation) ? status.loop.evaluation_continuation : null)
|
|
129
|
+
|
|
130
|
+
// Consumes a pending continuation under this worker's lock and removes it from the status, whatever the ledger answers: a token is
|
|
131
|
+
// offered once. Answers whether it was consumed.
|
|
132
|
+
async function consumeContinuation(env, ctx, status, impls) {
|
|
133
|
+
const token = pendingContinuation(status)
|
|
134
|
+
if (token === null) return false
|
|
135
|
+
const consumed = await swallow(() => impls.consumeContinuation(env, { token, now: ctx.now, status }))
|
|
136
|
+
await swallow(() => ctx.updateStatus(env, (current) => {
|
|
137
|
+
// Another token, or none: it is not this worker's to remove.
|
|
138
|
+
if (JSON.stringify(pendingContinuation(current)) !== JSON.stringify(token)) return current
|
|
139
|
+
const { evaluation_continuation: _gone, ...rest } = current.loop
|
|
140
|
+
return { ...current, loop: rest }
|
|
141
|
+
}))
|
|
142
|
+
return consumed?.state === "consumed"
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// The ordered steps. Each `run(env, ctx, impls)` answers `{ ok, result }`; a step that records itself needs nothing more. A step with
|
|
146
|
+
// `newWorkAt(env)` is due as soon as work newer than its last run arrives: an evaluation request makes the evaluator step due at once, and so
|
|
147
|
+
// does a queue still draining (`evaluateDue`).
|
|
148
|
+
const STEPS = Object.freeze([
|
|
149
|
+
{ name: "route", run: routeStep },
|
|
150
|
+
{
|
|
151
|
+
name: "evaluate", newWorkAt: newestRequestAt,
|
|
152
|
+
due: async (status, now, newWorkAt, env, ctx, impls) => {
|
|
153
|
+
const consumed = await consumeContinuation(env, ctx, status, impls)
|
|
154
|
+
return consumed || evaluateDue(status, now, { newWorkAt }) || await contextEvaluationDue(env, status, now)
|
|
155
|
+
},
|
|
156
|
+
run: (env, ctx, impls) => impls.evaluate(env, { pluginVersion: ctx.pluginVersion, now: ctx.now, deadline: ctx.agentDeadline(), deskRoot: ctx.deskRoot, maxRuns: 1, onChild: ctx.onChild, onChildExit: ctx.onChildExit, extendDeadline: ctx.extendDeadline }),
|
|
157
|
+
},
|
|
158
|
+
{ name: "mirror", run: (env, ctx, impls) => impls.mirror(env, { deskRoot: ctx.deskRoot, personPrefix: ctx.personPrefix, now: ctx.now }) },
|
|
159
|
+
{ name: "reconcile", run: (env, ctx, impls) => impls.reconcile(env, { now: ctx.now, desks: [ctx.deskRoot], personPrefix: ctx.personPrefix }) },
|
|
160
|
+
{ name: "verify", run: (env, ctx, impls) => impls.verify(env, { deskRoot: ctx.deskRoot, personPrefix: ctx.personPrefix, now: ctx.now }) },
|
|
161
|
+
// The machine's health record and its loop alarms describe the person's own desk: measured anywhere else, they would report that desk's
|
|
162
|
+
// cards as the machine's and its missing alarms as cleared, and the verify step would close the person's alarm cards.
|
|
163
|
+
{ name: "measure", run: (env, ctx, impls) => (ctx.ownDesk ? impls.measure(env, { deskRoot: ctx.deskRoot, personPrefix: ctx.personPrefix, now: ctx.now, attempted: [...ctx.attempted] }) : NOT_OWN_DESK) },
|
|
164
|
+
])
|
|
165
|
+
|
|
166
|
+
export const LOOP_STEP_NAMES = Object.freeze(STEPS.map(({ name }) => name))
|
|
167
|
+
|
|
168
|
+
const DEFAULT_IMPLS = { evaluate: runEvaluatorStep, consumeContinuation: consumeEvaluationContinuation, routeIssues: runRouteIssuesStep, routeLocal: runRouteLocalStep, mirror: runMirrorStep, reconcile: runReconcileStep, verify: runVerifyStep, measure: runMeasureStep, kick: kickLoop }
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* `runLoopWorker(env, { deskRoot, personPrefix, pluginVersion, clock, alive, budgetMs, ceilingMs, exit, notify, readStatusImpl, impls }) -> result`
|
|
172
|
+
* (see the header). `clock` (milliseconds), `alive`, `exit`, `notify` (the notice to the launcher), `readStatusImpl` and `impls` (the step functions) are seams for tests.
|
|
173
|
+
* Throws a `TypeError` for a `deskRoot` that is neither null nor absolute or a `personPrefix` that is not `""` or `desks/<alias>`.
|
|
174
|
+
*/
|
|
175
|
+
export async function runLoopWorker(env, {
|
|
176
|
+
deskRoot, personPrefix = "", pluginVersion, clock = Date.now, alive = processAlive, budgetMs = LOOP_BUDGET_MS,
|
|
177
|
+
ceilingMs = budgetMs + CEILING_GRACE_MS, exit = process.exit, notify = notifyLauncher, readStatusImpl = readStatus, updateStatusImpl = updateStatus, impls = {},
|
|
178
|
+
ownDesk = isOwnDesk, newestRelease = newestInstalledRelease,
|
|
179
|
+
}) {
|
|
180
|
+
if (deskRoot !== null && !path.isAbsolute(deskRoot)) throw Object.assign(new TypeError("Pass deskRoot as an absolute path"), { code: "loop_worker_pass_deskroot_as_an_absolute" })
|
|
181
|
+
checkPersonPrefix(personPrefix, "runLoopWorker")
|
|
182
|
+
if (isHeadlessFactorySession(env)) return answer("headless_session")
|
|
183
|
+
const root = await factoryStateRoot(env, { create: false })
|
|
184
|
+
// Every run's outcome is recorded where the health record and the session-start line can read it; nothing when there is no state folder.
|
|
185
|
+
const ended = async (outcome) => {
|
|
186
|
+
if (root !== null) await recordWorker(env, root, outcome.result, new Date(clock()).toISOString(), updateStatusImpl)
|
|
187
|
+
return outcome
|
|
188
|
+
}
|
|
189
|
+
if (!isLoopEnabled(env)) return ended(answer("disabled"))
|
|
190
|
+
if (deskRoot === null) return ended(answer("no_desk"))
|
|
191
|
+
// A worker the old turn-end hook of a long-running session started must not claim work that belongs to the current release.
|
|
192
|
+
const newest = newestRelease(env)
|
|
193
|
+
if (isVersion(pluginVersion) && isVersion(newest) && compareVersions(newest, pluginVersion) > 0) return ended(answer("stale_release", { running: pluginVersion, newest }))
|
|
194
|
+
if (root === null) return answer("no_factory_state")
|
|
195
|
+
// A desk that has not opted in stays silent: nothing is recorded, so no health line or card follows from it.
|
|
196
|
+
if (!hasContributingStore(env)) return answer("no_consenting_store")
|
|
197
|
+
const lock = await takeLock(root, { name: LOCK_NAME, alive, clock, record: { children: [] } })
|
|
198
|
+
if (lock === null) return ended(answer("busy"))
|
|
199
|
+
|
|
200
|
+
const started = clock()
|
|
201
|
+
let ceiling = setTimeout(() => exit(0), ceilingMs)
|
|
202
|
+
ceiling.unref()
|
|
203
|
+
const functions = { ...DEFAULT_IMPLS, ...impls }
|
|
204
|
+
// The facts-scan time granted so far: the budget, the evaluator's limit and the ceiling all move by it.
|
|
205
|
+
let extension = 0
|
|
206
|
+
// Child ids go into the lock file one write at a time, in the order they were reported.
|
|
207
|
+
let pending = Promise.resolve()
|
|
208
|
+
const track = (pid, on) => { pending = pending.then(() => trackChild(lock, pid, on)) }
|
|
209
|
+
const extendDeadline = async (scanMs) => {
|
|
210
|
+
const asked = typeof scanMs === "number" && !Number.isNaN(scanMs) ? Math.floor(scanMs) : 0
|
|
211
|
+
const granted = Math.min(Math.max(0, asked), MAX_SCAN_ALLOWANCE_MS - extension)
|
|
212
|
+
if (granted === 0) return 0
|
|
213
|
+
extension += granted
|
|
214
|
+
clearTimeout(ceiling)
|
|
215
|
+
ceiling = setTimeout(() => exit(0), Math.max(0, started + ceilingMs + extension - clock()))
|
|
216
|
+
ceiling.unref()
|
|
217
|
+
notify({ desk_loop_extend_ms: extension })
|
|
218
|
+
// The kick reads a lock younger than its 22 minutes as a live worker (`KICK_LOCK_AGE_MS`); what is left of this worker after the scan
|
|
219
|
+
// is shorter than that, so a lock rewritten now keeps the kick from starting a second worker that would only record `busy`.
|
|
220
|
+
pending = pending.then(() => touchLock(lock))
|
|
221
|
+
await pending
|
|
222
|
+
return granted
|
|
223
|
+
}
|
|
224
|
+
const ctx = {
|
|
225
|
+
deskRoot, personPrefix, pluginVersion, attempted: [], updateStatus: updateStatusImpl,
|
|
226
|
+
ownDesk: ownDesk(env, deskRoot),
|
|
227
|
+
// The agent steps' deadline: the budget, moved by any facts-scan time granted so far, less the later steps' reserve.
|
|
228
|
+
agentDeadline: () => new Date(started + budgetMs + extension - LATER_STEPS_RESERVE_MS),
|
|
229
|
+
onChild: (pid) => track(pid, true),
|
|
230
|
+
onChildExit: (pid) => track(pid, false),
|
|
231
|
+
extendDeadline,
|
|
232
|
+
}
|
|
233
|
+
const outcome = answer("completed")
|
|
234
|
+
// A status file that the reader moves aside and reads as empty must not look like a machine that never ran: it would restart the evaluator's daily cap.
|
|
235
|
+
const known = new Set(listStatusAside(root))
|
|
236
|
+
try {
|
|
237
|
+
let stopped = null
|
|
238
|
+
for (const step of STEPS) {
|
|
239
|
+
if (stopped === null && clock() >= started + budgetMs + extension) stopped = "budget_spent"
|
|
240
|
+
let status
|
|
241
|
+
if (stopped === null) {
|
|
242
|
+
try {
|
|
243
|
+
status = await readStatusImpl(env)
|
|
244
|
+
if (listStatusAside(root).some((name) => !known.has(name))) stopped = "status_reset"
|
|
245
|
+
} catch {
|
|
246
|
+
stopped = "status_unavailable"
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
// New work that cannot be read makes nothing due early; the gap still applies.
|
|
250
|
+
const newWorkAt = stopped === null && step.newWorkAt !== undefined ? ((await swallow(() => step.newWorkAt(env))) ?? null) : null
|
|
251
|
+
const due = step.due ?? ((stored, now, work) => dueStep(stored, step.name, now, { newWorkAt: work }))
|
|
252
|
+
if (stopped === null && !(await due(status, new Date(clock()), newWorkAt, env, { ...ctx, now: new Date(clock()) }, functions))) {
|
|
253
|
+
outcome.steps[step.name] = "skipped"
|
|
254
|
+
outcome.skipped += 1
|
|
255
|
+
continue
|
|
256
|
+
}
|
|
257
|
+
if (stopped !== null) {
|
|
258
|
+
outcome.steps[step.name] = "not_started"
|
|
259
|
+
continue
|
|
260
|
+
}
|
|
261
|
+
ctx.now = new Date(clock())
|
|
262
|
+
let result
|
|
263
|
+
try {
|
|
264
|
+
result = await step.run(env, ctx, functions)
|
|
265
|
+
} catch {
|
|
266
|
+
result = { ok: false, result: "step_error" }
|
|
267
|
+
await swallow(() => recordStep(env, step.name, { ok: false, result: "step_error", now: ctx.now }))
|
|
268
|
+
}
|
|
269
|
+
const read = readAnswer(result) ?? { ok: false, result: "invalid_result" }
|
|
270
|
+
ctx.attempted.push(step.name)
|
|
271
|
+
outcome.ran += 1
|
|
272
|
+
if (!read.ok) outcome.failed += 1
|
|
273
|
+
outcome.steps[step.name] = read.result
|
|
274
|
+
}
|
|
275
|
+
if (stopped !== null) outcome.result = stopped
|
|
276
|
+
await ended(outcome)
|
|
277
|
+
} finally {
|
|
278
|
+
clearTimeout(ceiling)
|
|
279
|
+
await pending
|
|
280
|
+
await releaseLock(lock)
|
|
281
|
+
}
|
|
282
|
+
// A worker whose evaluator step accepted a job's labels (`evaluator.accepted_last_step`) starts the next one once its lock is free, so the queue drains back to back. The kick starts
|
|
283
|
+
// one only while a job the runner can run today is left within the day's ceiling (`evaluateDue`); a kick that fails changes nothing here.
|
|
284
|
+
if (outcome.steps.evaluate === "ran" && (await swallow(async () => (await readStatusImpl(env))?.evaluator?.accepted_last_step > 0)) === true) await swallow(() => functions.kick(env, { scope: { deskRoot, personPrefix } }))
|
|
285
|
+
else if (outcome.steps.evaluate === "context_ran" && (await swallow(async () => {
|
|
286
|
+
const context = (await readStatusImpl(env))?.context_evaluation
|
|
287
|
+
return context?.accepted > 0 && context.refused === 0
|
|
288
|
+
})) === true) await swallow(() => functions.kick(env, { scope: { deskRoot, personPrefix } }))
|
|
289
|
+
return outcome
|
|
290
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import fs from "node:fs"
|
|
2
|
+
import * as path from "node:path"
|
|
3
|
+
import { EXACT, sameFile } from "../util/file-identity.js"
|
|
4
|
+
import { ENUMS, LIMITS, PATTERNS, isPlainObject, validPluginSource } from "./schema.js"
|
|
5
|
+
|
|
6
|
+
export const MAX_MARKER_BYTES = 64 * 1024
|
|
7
|
+
const REQUIRED = ["schema_version", "host", "session_id", "log_path", "cwd", "desk_root", "end_reason", "ended_at", "plugins", "updated_at"]
|
|
8
|
+
const OPTIONAL = ["entrypoint", "person_prefix", "routing", "proof"]
|
|
9
|
+
const time = (value) => typeof value === "string" && PATTERNS.timestamp.test(value) && Number.isFinite(Date.parse(value))
|
|
10
|
+
const unchangedFile = (left, right) => ["dev", "ino", "size", "mtimeNs", "ctimeNs"].every((key) => left[key] === right[key])
|
|
11
|
+
export const absolutePath = (value) => typeof value === "string" && value.length <= 4096 && !/[\x00-\x1f\x7f]/u.test(value) && path.isAbsolute(value)
|
|
12
|
+
|
|
13
|
+
export function validRouting(value) {
|
|
14
|
+
return isPlainObject(value) && Object.keys(value).sort().join(",") === "source,store,warnings"
|
|
15
|
+
&& ["desk", "overlay", "default", "invalid_declaration"].includes(value.source)
|
|
16
|
+
&& (value.source === "invalid_declaration" ? value.store === null : typeof value.store === "string" && PATTERNS.prRepo.test(value.store))
|
|
17
|
+
&& Array.isArray(value.warnings) && value.warnings.length <= 192
|
|
18
|
+
&& value.warnings.every((warning) => isPlainObject(warning) && Object.keys(warning).sort().join(",") === "code,manifest"
|
|
19
|
+
&& ["manifest_unreadable", "manifest_unparseable"].includes(warning.code) && absolutePath(warning.manifest))
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function validMarker(marker) {
|
|
23
|
+
if (!isPlainObject(marker) || REQUIRED.some((key) => !Object.hasOwn(marker, key))
|
|
24
|
+
|| Object.keys(marker).some((key) => !REQUIRED.includes(key) && !OPTIONAL.includes(key))) return false
|
|
25
|
+
return marker.schema_version === 1 && ENUMS.host.includes(marker.host)
|
|
26
|
+
&& typeof marker.session_id === "string" && PATTERNS.sessionId.test(marker.session_id)
|
|
27
|
+
&& absolutePath(marker.log_path) && absolutePath(marker.cwd)
|
|
28
|
+
&& (marker.desk_root === null || absolutePath(marker.desk_root))
|
|
29
|
+
&& (marker.end_reason === null || ENUMS.endReason.includes(marker.end_reason))
|
|
30
|
+
&& (marker.ended_at === null || time(marker.ended_at)) && time(marker.updated_at)
|
|
31
|
+
&& Array.isArray(marker.plugins) && marker.plugins.length <= LIMITS.plugins
|
|
32
|
+
&& marker.plugins.every((plugin) => isPlainObject(plugin) && ["name,version", "name,source,version"].includes(Object.keys(plugin).sort().join(","))
|
|
33
|
+
&& typeof plugin.name === "string" && PATTERNS.pluginName.test(plugin.name)
|
|
34
|
+
&& typeof plugin.version === "string" && PATTERNS.semver.test(plugin.version)
|
|
35
|
+
&& validPluginSource(plugin))
|
|
36
|
+
&& (!Object.hasOwn(marker, "entrypoint") || ENUMS.entrypoint.includes(marker.entrypoint))
|
|
37
|
+
&& (!Object.hasOwn(marker, "person_prefix") || (typeof marker.person_prefix === "string" && /^(?:desks\/[A-Za-z0-9][A-Za-z0-9_-]{0,63})?$/u.test(marker.person_prefix)))
|
|
38
|
+
&& (!Object.hasOwn(marker, "routing") || validRouting(marker.routing))
|
|
39
|
+
// `proof: true` is written only for a controlled proof session (`DESK_FACTORY_PROOF`, issue #578); any other value makes the marker invalid.
|
|
40
|
+
&& (!Object.hasOwn(marker, "proof") || marker.proof === true)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Metadata only: never block on a pipe or read an unbounded manifest.
|
|
44
|
+
export function readSmallText(file, limit = MAX_MARKER_BYTES) {
|
|
45
|
+
const before = fs.lstatSync(file, EXACT)
|
|
46
|
+
if (!before.isFile() || before.nlink !== 1n || before.size > limit) throw new Error("metadata_unreadable")
|
|
47
|
+
const fd = fs.openSync(file, fs.constants.O_RDONLY | fs.constants.O_NONBLOCK | fs.constants.O_NOFOLLOW)
|
|
48
|
+
try {
|
|
49
|
+
const stat = fs.fstatSync(fd, EXACT)
|
|
50
|
+
if (!stat.isFile() || stat.nlink !== 1n || stat.size > limit || !sameFile(stat, before)) throw new Error("metadata_unreadable")
|
|
51
|
+
const bytes = Buffer.alloc(limit + 1)
|
|
52
|
+
const size = fs.readSync(fd, bytes, 0, bytes.length, 0)
|
|
53
|
+
if (size > limit) throw new Error("metadata_unreadable")
|
|
54
|
+
const after = fs.fstatSync(fd, EXACT)
|
|
55
|
+
const atPath = fs.lstatSync(file, EXACT)
|
|
56
|
+
if (!atPath.isFile() || atPath.nlink !== 1n || !unchangedFile(stat, after) || !unchangedFile(after, atPath)) throw new Error("metadata_unreadable")
|
|
57
|
+
return bytes.toString("utf8", 0, size)
|
|
58
|
+
} finally {
|
|
59
|
+
fs.closeSync(fd)
|
|
60
|
+
}
|
|
61
|
+
}
|