@openrig/cli 0.7.23 → 0.7.24
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 +7 -7
- package/daemon/assets/claude-hook-bridge.cjs +575 -6
- package/daemon/assets/claude-hook-bridge.d.cts +5 -0
- package/daemon/assets/claude-permission-policies.cjs +4 -3
- package/daemon/assets/guidance/openrig-context-entry.md +1 -0
- package/daemon/assets/plugins/openrig/.claude-plugin/plugin.json +4 -3
- package/daemon/assets/plugins/openrig/.codex-plugin/plugin.json +3 -2
- package/daemon/assets/plugins/openrig/.cursor-plugin/plugin.json +1 -1
- package/daemon/assets/plugins/openrig/README.md +64 -9
- package/daemon/assets/plugins/openrig/hooks/claude.json +39 -0
- package/daemon/assets/plugins/openrig/hooks/codex.json +27 -0
- package/daemon/assets/plugins/openrig/hooks/scripts/claude-hook-bridge.cjs +715 -0
- package/daemon/assets/plugins/openrig/plugin.json +1 -1
- package/daemon/assets/plugins/openrig/scripts/run-rig.cjs +30 -0
- package/daemon/assets/plugins/openrig/skills/working-with-an-openrig-team/SKILL.md +71 -9
- package/daemon/assets/plugins/openrig-codex/.agents/plugins/marketplace.json +15 -0
- package/daemon/assets/plugins/openrig-codex/.codex-plugin/plugin.json +42 -0
- package/daemon/assets/plugins/openrig-codex/LICENSE +200 -0
- package/daemon/assets/plugins/openrig-codex/assets/logo.svg +1 -0
- package/daemon/assets/plugins/openrig-codex/hooks/codex.json +27 -0
- package/daemon/assets/plugins/openrig-codex/hooks/scripts/claude-hook-bridge.cjs +715 -0
- package/daemon/assets/plugins/openrig-codex/skills/working-with-an-openrig-team/SKILL.md +175 -0
- package/daemon/assets/plugins/openrig-core/.claude-plugin/plugin.json +1 -1
- package/daemon/assets/plugins/openrig-core/.codex-plugin/plugin.json +1 -1
- package/daemon/assets/plugins/openrig-core/README.md +10 -2
- package/daemon/assets/plugins/openrig-core/hooks/claude.json +9 -0
- package/daemon/assets/plugins/openrig-core/hooks/scripts/activity-relay.cjs +37 -0
- package/daemon/assets/plugins/openrig-core/hooks/scripts/compaction-restore-bridge.cjs +3 -1
- package/daemon/assets/plugins/openrig-core/hooks/scripts/permission-answer.cjs +270 -0
- package/daemon/assets/plugins/openrig-core/hooks/scripts/refocus.cjs +24 -6
- package/daemon/assets/plugins/openrig-core/skills/claude-compaction-restore/scripts/precompact-hook.mjs +7 -8
- package/daemon/assets/plugins/openrig-core/skills/claude-compaction-restore/scripts/restore-from-jsonl.mjs +45 -5
- package/daemon/assets/plugins/openrig-core/skills/openrig-user/SKILL.md +4 -2
- package/daemon/assets/plugins/openrig-core/skills/refocusing/scripts/trace-to-root.py +163 -23
- package/daemon/assets/skills/rigs/SKILL.md +122 -21
- package/daemon/context-packs/help/manifest.yaml +1 -1
- package/daemon/context-packs/onboarding-width/manifest.yaml +1 -1
- package/daemon/context-packs/onboarding-width/public-what-you-can-do.md +113 -12
- package/daemon/context-packs/reference/acp-agents.md +9 -2
- package/daemon/context-packs/reference/getting-started.md +31 -7
- package/daemon/context-packs/reference/manifest.yaml +1 -1
- package/daemon/context-packs/reference/rig-spec.md +8 -0
- package/daemon/context-packs/reference/tmux-servers.md +16 -0
- package/daemon/context-packs/reference/whats-new.md +106 -12
- package/daemon/context-packs/skills/agent-operated-software/manifest.yaml +1 -1
- package/daemon/context-packs/skills/agent-operated-workflows/manifest.yaml +1 -1
- package/daemon/context-packs/skills/applying-a-permission-policy/manifest.yaml +1 -1
- package/daemon/context-packs/skills/claude-compaction-restore/manifest.yaml +1 -1
- package/daemon/context-packs/skills/claude-compaction-restore/scripts/precompact-hook.mjs +7 -8
- package/daemon/context-packs/skills/claude-compaction-restore/scripts/restore-from-jsonl.mjs +45 -5
- package/daemon/context-packs/skills/core/agent-starters/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/agent-startup-and-context-ingestion/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/cross-host-rig-commands/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/human-in-the-loop/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/messaging-the-human/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/openrig-architect/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/openrig-cmux/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/openrig-herdr/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/openrig-skills/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/openrig-software-factory/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/openrig-upgrade/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/rig-bundles-and-shareable-artifacts/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/rig-lifecycle/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/session-source-fork/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/specification-system/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/topology-mutation-and-seat-management/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/watchdog/manifest.yaml +1 -1
- package/daemon/context-packs/skills/core/working-with-an-openrig-team/SKILL.md +71 -9
- package/daemon/context-packs/skills/core/working-with-an-openrig-team/manifest.yaml +1 -1
- package/daemon/context-packs/skills/delegating-work/manifest.yaml +1 -1
- package/daemon/context-packs/skills/forming-an-openrig-mental-model/manifest.yaml +1 -1
- package/daemon/context-packs/skills/loading-addressable-markdown/manifest.yaml +1 -1
- package/daemon/context-packs/skills/mission-slice-sop/manifest.yaml +1 -1
- package/daemon/context-packs/skills/openrig-operating-model/manifest.yaml +1 -1
- package/daemon/context-packs/skills/openrig-user/SKILL.md +4 -2
- package/daemon/context-packs/skills/openrig-user/manifest.yaml +1 -1
- package/daemon/context-packs/skills/orienting-to-an-inherited-seat/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/backlog-capture/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/context-builder/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/exec-summary/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/office-hours/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/plan-review/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/requirements-writer/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pm/ui-mockup/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pods/development-team/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pods/orchestration-team/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pods/oversight-team/manifest.yaml +1 -1
- package/daemon/context-packs/skills/pods/review-team/manifest.yaml +1 -1
- package/daemon/context-packs/skills/process/agent-browser/manifest.yaml +1 -1
- package/daemon/context-packs/skills/process/context-engineering/manifest.yaml +1 -1
- package/daemon/context-packs/skills/process/dogfood/manifest.yaml +1 -1
- package/daemon/context-packs/skills/process/frontend-design/manifest.yaml +1 -1
- package/daemon/context-packs/skills/process/systematic-debugging/manifest.yaml +1 -1
- package/daemon/context-packs/skills/process/test-driven-development/manifest.yaml +1 -1
- package/daemon/context-packs/skills/process/verification-before-completion/manifest.yaml +1 -1
- package/daemon/context-packs/skills/queue-handoff/manifest.yaml +1 -1
- package/daemon/context-packs/skills/refocusing/manifest.yaml +1 -1
- package/daemon/context-packs/skills/refocusing/scripts/trace-to-root.py +163 -23
- package/daemon/context-packs/skills/retiring-and-inheriting-a-seat/manifest.yaml +1 -1
- package/daemon/context-packs/skills/seat-continuity-and-handover/manifest.yaml +1 -1
- package/daemon/context-packs/skills/session-compaction-and-restore/manifest.yaml +1 -1
- package/daemon/context-packs/skills/software-for-agents/manifest.yaml +1 -1
- package/daemon/context-packs/world-example/manifest.yaml +1 -1
- package/daemon/context-packs/world-public/manifest.yaml +1 -1
- package/daemon/dist/adapters/claude-code-adapter.d.ts +10 -1
- package/daemon/dist/adapters/claude-code-adapter.d.ts.map +1 -1
- package/daemon/dist/adapters/claude-code-adapter.js +231 -33
- package/daemon/dist/adapters/claude-code-adapter.js.map +1 -1
- package/daemon/dist/adapters/claude-resume-launch.d.ts +3 -0
- package/daemon/dist/adapters/claude-resume-launch.d.ts.map +1 -1
- package/daemon/dist/adapters/claude-resume-launch.js +5 -0
- package/daemon/dist/adapters/claude-resume-launch.js.map +1 -1
- package/daemon/dist/adapters/claude-resume.d.ts.map +1 -1
- package/daemon/dist/adapters/claude-resume.js +59 -21
- package/daemon/dist/adapters/claude-resume.js.map +1 -1
- package/daemon/dist/adapters/community-harness-runtime-adapter.d.ts +22 -0
- package/daemon/dist/adapters/community-harness-runtime-adapter.d.ts.map +1 -1
- package/daemon/dist/adapters/community-harness-runtime-adapter.js +53 -16
- package/daemon/dist/adapters/community-harness-runtime-adapter.js.map +1 -1
- package/daemon/dist/adapters/pi-community-runtime-adapter.d.ts +9 -0
- package/daemon/dist/adapters/pi-community-runtime-adapter.d.ts.map +1 -1
- package/daemon/dist/adapters/pi-community-runtime-adapter.js +6 -0
- package/daemon/dist/adapters/pi-community-runtime-adapter.js.map +1 -1
- package/daemon/dist/adapters/pi-runtime-adapter.d.ts +3 -0
- package/daemon/dist/adapters/pi-runtime-adapter.d.ts.map +1 -1
- package/daemon/dist/adapters/pi-runtime-adapter.js +9 -3
- package/daemon/dist/adapters/pi-runtime-adapter.js.map +1 -1
- package/daemon/dist/adapters/tmux.d.ts +52 -9
- package/daemon/dist/adapters/tmux.d.ts.map +1 -1
- package/daemon/dist/adapters/tmux.js +102 -19
- package/daemon/dist/adapters/tmux.js.map +1 -1
- package/daemon/dist/build-info.js +3 -3
- package/daemon/dist/conversation-key-surface.d.ts +2 -0
- package/daemon/dist/conversation-key-surface.d.ts.map +1 -0
- package/daemon/dist/conversation-key-surface.js +5 -0
- package/daemon/dist/conversation-key-surface.js.map +1 -0
- package/daemon/dist/daemon-shutdown.d.ts +3 -0
- package/daemon/dist/daemon-shutdown.d.ts.map +1 -1
- package/daemon/dist/daemon-shutdown.js +5 -0
- package/daemon/dist/daemon-shutdown.js.map +1 -1
- package/daemon/dist/db/all-migrations.d.ts.map +1 -1
- package/daemon/dist/db/all-migrations.js +8 -0
- package/daemon/dist/db/all-migrations.js.map +1 -1
- package/daemon/dist/db/migrations/179_community_harness_runtime_switches.d.ts +14 -0
- package/daemon/dist/db/migrations/179_community_harness_runtime_switches.d.ts.map +1 -0
- package/daemon/dist/db/migrations/179_community_harness_runtime_switches.js +54 -0
- package/daemon/dist/db/migrations/179_community_harness_runtime_switches.js.map +1 -0
- package/daemon/dist/db/migrations/195_workflow_start_operations.d.ts +4 -0
- package/daemon/dist/db/migrations/195_workflow_start_operations.d.ts.map +1 -0
- package/daemon/dist/db/migrations/195_workflow_start_operations.js +13 -0
- package/daemon/dist/db/migrations/195_workflow_start_operations.js.map +1 -0
- package/daemon/dist/db/migrations/196_queue_item_evidence_ref_roots.d.ts +5 -0
- package/daemon/dist/db/migrations/196_queue_item_evidence_ref_roots.d.ts.map +1 -0
- package/daemon/dist/db/migrations/196_queue_item_evidence_ref_roots.js +7 -0
- package/daemon/dist/db/migrations/196_queue_item_evidence_ref_roots.js.map +1 -0
- package/daemon/dist/db/migrations/199_queue_items_native_permission_index.d.ts +9 -0
- package/daemon/dist/db/migrations/199_queue_items_native_permission_index.d.ts.map +1 -0
- package/daemon/dist/db/migrations/199_queue_items_native_permission_index.js +14 -0
- package/daemon/dist/db/migrations/199_queue_items_native_permission_index.js.map +1 -0
- package/daemon/dist/domain/agent-manifest.d.ts.map +1 -1
- package/daemon/dist/domain/agent-manifest.js +8 -0
- package/daemon/dist/domain/agent-manifest.js.map +1 -1
- package/daemon/dist/domain/background-process-evidence.d.ts +23 -0
- package/daemon/dist/domain/background-process-evidence.d.ts.map +1 -0
- package/daemon/dist/domain/background-process-evidence.js +81 -0
- package/daemon/dist/domain/background-process-evidence.js.map +1 -0
- package/daemon/dist/domain/chat-repository.d.ts +1 -1
- package/daemon/dist/domain/chat-repository.d.ts.map +1 -1
- package/daemon/dist/domain/chat-repository.js +2 -2
- package/daemon/dist/domain/chat-repository.js.map +1 -1
- package/daemon/dist/domain/claude-compaction-enforcer.d.ts +16 -6
- package/daemon/dist/domain/claude-compaction-enforcer.d.ts.map +1 -1
- package/daemon/dist/domain/claude-compaction-enforcer.js +13 -8
- package/daemon/dist/domain/claude-compaction-enforcer.js.map +1 -1
- package/daemon/dist/domain/codex-member-permissions.d.ts +35 -0
- package/daemon/dist/domain/codex-member-permissions.d.ts.map +1 -1
- package/daemon/dist/domain/codex-member-permissions.js +106 -1
- package/daemon/dist/domain/codex-member-permissions.js.map +1 -1
- package/daemon/dist/domain/community-harness-presets.d.ts +9 -0
- package/daemon/dist/domain/community-harness-presets.d.ts.map +1 -1
- package/daemon/dist/domain/community-harness-presets.js +25 -1
- package/daemon/dist/domain/community-harness-presets.js.map +1 -1
- package/daemon/dist/domain/current-work.d.ts +31 -4
- package/daemon/dist/domain/current-work.d.ts.map +1 -1
- package/daemon/dist/domain/current-work.js +48 -3
- package/daemon/dist/domain/current-work.js.map +1 -1
- package/daemon/dist/domain/feed/attention-aggregator.d.ts +5 -5
- package/daemon/dist/domain/feed/attention-aggregator.d.ts.map +1 -1
- package/daemon/dist/domain/feed/attention-aggregator.js +10 -4
- package/daemon/dist/domain/feed/attention-aggregator.js.map +1 -1
- package/daemon/dist/domain/files/path-safety.d.ts +7 -0
- package/daemon/dist/domain/files/path-safety.d.ts.map +1 -1
- package/daemon/dist/domain/files/path-safety.js +23 -0
- package/daemon/dist/domain/files/path-safety.js.map +1 -1
- package/daemon/dist/domain/frontmatter.d.ts.map +1 -1
- package/daemon/dist/domain/frontmatter.js +4 -2
- package/daemon/dist/domain/frontmatter.js.map +1 -1
- package/daemon/dist/domain/gateway/destination-resolver.d.ts +3 -0
- package/daemon/dist/domain/gateway/destination-resolver.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/destination-resolver.js +9 -0
- package/daemon/dist/domain/gateway/destination-resolver.js.map +1 -1
- package/daemon/dist/domain/gateway/human-quiet-windows.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/human-quiet-windows.js +2 -1
- package/daemon/dist/domain/gateway/human-quiet-windows.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/inbound.d.ts +6 -1
- package/daemon/dist/domain/gateway/slack/inbound.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/inbound.js +4 -1
- package/daemon/dist/domain/gateway/slack/inbound.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/message.d.ts +3 -0
- package/daemon/dist/domain/gateway/slack/message.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/message.js +3 -2
- package/daemon/dist/domain/gateway/slack/message.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/outbound-driver.d.ts +4 -0
- package/daemon/dist/domain/gateway/slack/outbound-driver.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/outbound-driver.js +1 -0
- package/daemon/dist/domain/gateway/slack/outbound-driver.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/queue-access.d.ts +2 -0
- package/daemon/dist/domain/gateway/slack/queue-access.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/queue-access.js +1 -0
- package/daemon/dist/domain/gateway/slack/queue-access.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/slack-delivery.d.ts +10 -2
- package/daemon/dist/domain/gateway/slack/slack-delivery.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/slack-delivery.js +60 -6
- package/daemon/dist/domain/gateway/slack/slack-delivery.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/slack-subsystem.d.ts +3 -13
- package/daemon/dist/domain/gateway/slack/slack-subsystem.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/slack-subsystem.js +70 -22
- package/daemon/dist/domain/gateway/slack/slack-subsystem.js.map +1 -1
- package/daemon/dist/domain/health-detectors.d.ts +4 -0
- package/daemon/dist/domain/health-detectors.d.ts.map +1 -1
- package/daemon/dist/domain/health-detectors.js +4 -1
- package/daemon/dist/domain/health-detectors.js.map +1 -1
- package/daemon/dist/domain/health-diagnosis.d.ts.map +1 -1
- package/daemon/dist/domain/health-diagnosis.js +14 -9
- package/daemon/dist/domain/health-diagnosis.js.map +1 -1
- package/daemon/dist/domain/health-passive-ceremony.d.ts +2 -0
- package/daemon/dist/domain/health-passive-ceremony.d.ts.map +1 -1
- package/daemon/dist/domain/health-passive-ceremony.js +71 -13
- package/daemon/dist/domain/health-passive-ceremony.js.map +1 -1
- package/daemon/dist/domain/history-query.d.ts +1 -1
- package/daemon/dist/domain/history-query.d.ts.map +1 -1
- package/daemon/dist/domain/history-query.js +1 -2
- package/daemon/dist/domain/history-query.js.map +1 -1
- package/daemon/dist/domain/hosts/read-through.d.ts.map +1 -1
- package/daemon/dist/domain/hosts/read-through.js +6 -0
- package/daemon/dist/domain/hosts/read-through.js.map +1 -1
- package/daemon/dist/domain/managed-restore-read-access.d.ts +18 -0
- package/daemon/dist/domain/managed-restore-read-access.d.ts.map +1 -1
- package/daemon/dist/domain/managed-restore-read-access.js +41 -1
- package/daemon/dist/domain/managed-restore-read-access.js.map +1 -1
- package/daemon/dist/domain/mission-control/audit-browse.d.ts +1 -1
- package/daemon/dist/domain/mission-control/audit-browse.d.ts.map +1 -1
- package/daemon/dist/domain/mission-control/audit-browse.js +3 -6
- package/daemon/dist/domain/mission-control/audit-browse.js.map +1 -1
- package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts.map +1 -1
- package/daemon/dist/domain/mission-control/mission-control-write-contract.js +21 -4
- package/daemon/dist/domain/mission-control/mission-control-write-contract.js.map +1 -1
- package/daemon/dist/domain/native-resume-probe.d.ts +22 -0
- package/daemon/dist/domain/native-resume-probe.d.ts.map +1 -1
- package/daemon/dist/domain/native-resume-probe.js +30 -0
- package/daemon/dist/domain/native-resume-probe.js.map +1 -1
- package/daemon/dist/domain/network/network-requests.d.ts +3 -2
- package/daemon/dist/domain/network/network-requests.d.ts.map +1 -1
- package/daemon/dist/domain/network/network-requests.js +34 -8
- package/daemon/dist/domain/network/network-requests.js.map +1 -1
- package/daemon/dist/domain/node-launcher.d.ts +2 -2
- package/daemon/dist/domain/node-launcher.d.ts.map +1 -1
- package/daemon/dist/domain/node-launcher.js +9 -7
- package/daemon/dist/domain/node-launcher.js.map +1 -1
- package/daemon/dist/domain/pane-cutover.d.ts +36 -9
- package/daemon/dist/domain/pane-cutover.d.ts.map +1 -1
- package/daemon/dist/domain/pane-cutover.js +82 -13
- package/daemon/dist/domain/pane-cutover.js.map +1 -1
- package/daemon/dist/domain/projection-planner.d.ts +17 -3
- package/daemon/dist/domain/projection-planner.d.ts.map +1 -1
- package/daemon/dist/domain/projection-planner.js +9 -1
- package/daemon/dist/domain/projection-planner.js.map +1 -1
- package/daemon/dist/domain/queue-destination-check.d.ts +8 -0
- package/daemon/dist/domain/queue-destination-check.d.ts.map +1 -1
- package/daemon/dist/domain/queue-destination-check.js +17 -4
- package/daemon/dist/domain/queue-destination-check.js.map +1 -1
- package/daemon/dist/domain/queue-erasure.js +1 -1
- package/daemon/dist/domain/queue-repository.d.ts +20 -1
- package/daemon/dist/domain/queue-repository.d.ts.map +1 -1
- package/daemon/dist/domain/queue-repository.js +93 -14
- package/daemon/dist/domain/queue-repository.js.map +1 -1
- package/daemon/dist/domain/queue-stuck-sweep.d.ts +23 -3
- package/daemon/dist/domain/queue-stuck-sweep.d.ts.map +1 -1
- package/daemon/dist/domain/queue-stuck-sweep.js +618 -13
- package/daemon/dist/domain/queue-stuck-sweep.js.map +1 -1
- package/daemon/dist/domain/queue-transfer-export.d.ts +1 -1
- package/daemon/dist/domain/queue-transfer-export.d.ts.map +1 -1
- package/daemon/dist/domain/queue-transfer-export.js +3 -1
- package/daemon/dist/domain/queue-transfer-export.js.map +1 -1
- package/daemon/dist/domain/queue-transition-log.d.ts +6 -0
- package/daemon/dist/domain/queue-transition-log.d.ts.map +1 -1
- package/daemon/dist/domain/queue-transition-log.js +1 -1
- package/daemon/dist/domain/queue-transition-log.js.map +1 -1
- package/daemon/dist/domain/queue-waiting.d.ts.map +1 -1
- package/daemon/dist/domain/queue-waiting.js +7 -0
- package/daemon/dist/domain/queue-waiting.js.map +1 -1
- package/daemon/dist/domain/queue-wake-ladder.d.ts.map +1 -1
- package/daemon/dist/domain/queue-wake-ladder.js +20 -4
- package/daemon/dist/domain/queue-wake-ladder.js.map +1 -1
- package/daemon/dist/domain/rehydrate-eligibility.d.ts +8 -0
- package/daemon/dist/domain/rehydrate-eligibility.d.ts.map +1 -1
- package/daemon/dist/domain/rehydrate-eligibility.js +61 -9
- package/daemon/dist/domain/rehydrate-eligibility.js.map +1 -1
- package/daemon/dist/domain/restore-check-service.d.ts.map +1 -1
- package/daemon/dist/domain/restore-check-service.js +5 -2
- package/daemon/dist/domain/restore-check-service.js.map +1 -1
- package/daemon/dist/domain/restore-orchestrator.d.ts +3 -0
- package/daemon/dist/domain/restore-orchestrator.d.ts.map +1 -1
- package/daemon/dist/domain/restore-orchestrator.js +42 -0
- package/daemon/dist/domain/restore-orchestrator.js.map +1 -1
- package/daemon/dist/domain/return-route.d.ts +13 -2
- package/daemon/dist/domain/return-route.d.ts.map +1 -1
- package/daemon/dist/domain/return-route.js +30 -1
- package/daemon/dist/domain/return-route.js.map +1 -1
- package/daemon/dist/domain/rig-lifecycle-service.d.ts +1 -0
- package/daemon/dist/domain/rig-lifecycle-service.d.ts.map +1 -1
- package/daemon/dist/domain/rig-lifecycle-service.js +23 -2
- package/daemon/dist/domain/rig-lifecycle-service.js.map +1 -1
- package/daemon/dist/domain/rig-mode/operating-posture.d.ts.map +1 -1
- package/daemon/dist/domain/rig-mode/operating-posture.js +23 -4
- package/daemon/dist/domain/rig-mode/operating-posture.js.map +1 -1
- package/daemon/dist/domain/rig-teardown.d.ts +30 -2
- package/daemon/dist/domain/rig-teardown.d.ts.map +1 -1
- package/daemon/dist/domain/rig-teardown.js +76 -8
- package/daemon/dist/domain/rig-teardown.js.map +1 -1
- package/daemon/dist/domain/rigspec-instantiator.d.ts +11 -9
- package/daemon/dist/domain/rigspec-instantiator.d.ts.map +1 -1
- package/daemon/dist/domain/rigspec-instantiator.js +100 -43
- package/daemon/dist/domain/rigspec-instantiator.js.map +1 -1
- package/daemon/dist/domain/rigspec-preflight.d.ts.map +1 -1
- package/daemon/dist/domain/rigspec-preflight.js +26 -3
- package/daemon/dist/domain/rigspec-preflight.js.map +1 -1
- package/daemon/dist/domain/roster-ready-notice.d.ts +11 -0
- package/daemon/dist/domain/roster-ready-notice.d.ts.map +1 -0
- package/daemon/dist/domain/roster-ready-notice.js +35 -0
- package/daemon/dist/domain/roster-ready-notice.js.map +1 -0
- package/daemon/dist/domain/runner-permissions.d.ts +140 -5
- package/daemon/dist/domain/runner-permissions.d.ts.map +1 -1
- package/daemon/dist/domain/runner-permissions.js +593 -16
- package/daemon/dist/domain/runner-permissions.js.map +1 -1
- package/daemon/dist/domain/runtime-adapter.d.ts +3 -1
- package/daemon/dist/domain/runtime-adapter.d.ts.map +1 -1
- package/daemon/dist/domain/runtime-exit.d.ts +79 -0
- package/daemon/dist/domain/runtime-exit.d.ts.map +1 -0
- package/daemon/dist/domain/runtime-exit.js +301 -0
- package/daemon/dist/domain/runtime-exit.js.map +1 -0
- package/daemon/dist/domain/runtime-switch-materials.d.ts +4 -1
- package/daemon/dist/domain/runtime-switch-materials.d.ts.map +1 -1
- package/daemon/dist/domain/runtime-switch-materials.js +66 -13
- package/daemon/dist/domain/runtime-switch-materials.js.map +1 -1
- package/daemon/dist/domain/scope/attestation-lineage.generated.js +2 -2
- package/daemon/dist/domain/scope/attestation-lineage.generated.js.map +1 -1
- package/daemon/dist/domain/scope/logical-checkbox.d.ts.map +1 -1
- package/daemon/dist/domain/scope/logical-checkbox.js +18 -0
- package/daemon/dist/domain/scope/logical-checkbox.js.map +1 -1
- package/daemon/dist/domain/scope/scaffold-placeholder.js +2 -2
- package/daemon/dist/domain/scope/scaffold-placeholder.js.map +1 -1
- package/daemon/dist/domain/seat-attention-reconciler.d.ts.map +1 -1
- package/daemon/dist/domain/seat-attention-reconciler.js +5 -2
- package/daemon/dist/domain/seat-attention-reconciler.js.map +1 -1
- package/daemon/dist/domain/seat-handover-service.d.ts +5 -2
- package/daemon/dist/domain/seat-handover-service.d.ts.map +1 -1
- package/daemon/dist/domain/seat-handover-service.js +30 -6
- package/daemon/dist/domain/seat-handover-service.js.map +1 -1
- package/daemon/dist/domain/seat-identity-reconciler.d.ts +18 -0
- package/daemon/dist/domain/seat-identity-reconciler.d.ts.map +1 -1
- package/daemon/dist/domain/seat-identity-reconciler.js +155 -6
- package/daemon/dist/domain/seat-identity-reconciler.js.map +1 -1
- package/daemon/dist/domain/seat-launch-environment.d.ts +6 -0
- package/daemon/dist/domain/seat-launch-environment.d.ts.map +1 -1
- package/daemon/dist/domain/seat-launch-environment.js +28 -4
- package/daemon/dist/domain/seat-launch-environment.js.map +1 -1
- package/daemon/dist/domain/seat-lifecycle-service.d.ts +37 -1
- package/daemon/dist/domain/seat-lifecycle-service.d.ts.map +1 -1
- package/daemon/dist/domain/seat-lifecycle-service.js +44 -8
- package/daemon/dist/domain/seat-lifecycle-service.js.map +1 -1
- package/daemon/dist/domain/seat-pool-executor.d.ts +61 -3
- package/daemon/dist/domain/seat-pool-executor.d.ts.map +1 -1
- package/daemon/dist/domain/seat-pool-executor.js +735 -59
- package/daemon/dist/domain/seat-pool-executor.js.map +1 -1
- package/daemon/dist/domain/seat-pool-slots.d.ts +24 -0
- package/daemon/dist/domain/seat-pool-slots.d.ts.map +1 -1
- package/daemon/dist/domain/seat-pool-slots.js +50 -0
- package/daemon/dist/domain/seat-pool-slots.js.map +1 -1
- package/daemon/dist/domain/seat-runtime-switch-service.d.ts +2 -1
- package/daemon/dist/domain/seat-runtime-switch-service.d.ts.map +1 -1
- package/daemon/dist/domain/seat-runtime-switch-service.js +68 -20
- package/daemon/dist/domain/seat-runtime-switch-service.js.map +1 -1
- package/daemon/dist/domain/session-transport.d.ts.map +1 -1
- package/daemon/dist/domain/session-transport.js +9 -2
- package/daemon/dist/domain/session-transport.js.map +1 -1
- package/daemon/dist/domain/skill-catalog.d.ts.map +1 -1
- package/daemon/dist/domain/skill-catalog.js +24 -10
- package/daemon/dist/domain/skill-catalog.js.map +1 -1
- package/daemon/dist/domain/startup-orchestrator.d.ts +5 -1
- package/daemon/dist/domain/startup-orchestrator.d.ts.map +1 -1
- package/daemon/dist/domain/startup-orchestrator.js +43 -7
- package/daemon/dist/domain/startup-orchestrator.js.map +1 -1
- package/daemon/dist/domain/startup-submission-evidence.d.ts +1 -0
- package/daemon/dist/domain/startup-submission-evidence.d.ts.map +1 -1
- package/daemon/dist/domain/startup-submission-evidence.js +5 -0
- package/daemon/dist/domain/startup-submission-evidence.js.map +1 -1
- package/daemon/dist/domain/stream-reader-actions.d.ts +23 -0
- package/daemon/dist/domain/stream-reader-actions.d.ts.map +1 -1
- package/daemon/dist/domain/stream-reader-actions.js +43 -0
- package/daemon/dist/domain/stream-reader-actions.js.map +1 -1
- package/daemon/dist/domain/successor-session-launcher.d.ts +24 -3
- package/daemon/dist/domain/successor-session-launcher.d.ts.map +1 -1
- package/daemon/dist/domain/successor-session-launcher.js +54 -23
- package/daemon/dist/domain/successor-session-launcher.js.map +1 -1
- package/daemon/dist/domain/terminal/earlier-tile-attach-0723.d.ts +2 -0
- package/daemon/dist/domain/terminal/earlier-tile-attach-0723.d.ts.map +1 -0
- package/daemon/dist/domain/terminal/earlier-tile-attach-0723.js +48 -0
- package/daemon/dist/domain/terminal/earlier-tile-attach-0723.js.map +1 -0
- package/daemon/dist/domain/terminal/rex-agent-status.d.ts.map +1 -1
- package/daemon/dist/domain/terminal/rex-agent-status.js +5 -2
- package/daemon/dist/domain/terminal/rex-agent-status.js.map +1 -1
- package/daemon/dist/domain/terminal/tile-attach.d.ts +11 -5
- package/daemon/dist/domain/terminal/tile-attach.d.ts.map +1 -1
- package/daemon/dist/domain/terminal/tile-attach.js +32 -12
- package/daemon/dist/domain/terminal/tile-attach.js.map +1 -1
- package/daemon/dist/domain/transcript-redaction.d.ts +10 -8
- package/daemon/dist/domain/transcript-redaction.d.ts.map +1 -1
- package/daemon/dist/domain/transcript-redaction.js +51 -22
- package/daemon/dist/domain/transcript-redaction.js.map +1 -1
- package/daemon/dist/domain/types.d.ts +7 -1
- package/daemon/dist/domain/types.d.ts.map +1 -1
- package/daemon/dist/domain/types.js +3 -0
- package/daemon/dist/domain/types.js.map +1 -1
- package/daemon/dist/domain/whoami-service.d.ts +11 -0
- package/daemon/dist/domain/whoami-service.d.ts.map +1 -1
- package/daemon/dist/domain/whoami-service.js +13 -0
- package/daemon/dist/domain/whoami-service.js.map +1 -1
- package/daemon/dist/domain/workflow-reconciliation.d.ts.map +1 -1
- package/daemon/dist/domain/workflow-reconciliation.js +9 -0
- package/daemon/dist/domain/workflow-reconciliation.js.map +1 -1
- package/daemon/dist/domain/workflow-runtime.d.ts +2 -0
- package/daemon/dist/domain/workflow-runtime.d.ts.map +1 -1
- package/daemon/dist/domain/workflow-runtime.js +45 -2
- package/daemon/dist/domain/workflow-runtime.js.map +1 -1
- package/daemon/dist/routes/activity.d.ts.map +1 -1
- package/daemon/dist/routes/activity.js +59 -2
- package/daemon/dist/routes/activity.js.map +1 -1
- package/daemon/dist/routes/compaction.d.ts.map +1 -1
- package/daemon/dist/routes/compaction.js +26 -9
- package/daemon/dist/routes/compaction.js.map +1 -1
- package/daemon/dist/routes/queue.d.ts.map +1 -1
- package/daemon/dist/routes/queue.js +64 -25
- package/daemon/dist/routes/queue.js.map +1 -1
- package/daemon/dist/routes/require-sender-identity.d.ts +15 -0
- package/daemon/dist/routes/require-sender-identity.d.ts.map +1 -1
- package/daemon/dist/routes/require-sender-identity.js +51 -5
- package/daemon/dist/routes/require-sender-identity.js.map +1 -1
- package/daemon/dist/routes/seat.js +6 -0
- package/daemon/dist/routes/seat.js.map +1 -1
- package/daemon/dist/routes/stream.d.ts.map +1 -1
- package/daemon/dist/routes/stream.js +28 -1
- package/daemon/dist/routes/stream.js.map +1 -1
- package/daemon/dist/routes/workflow.d.ts.map +1 -1
- package/daemon/dist/routes/workflow.js +48 -41
- package/daemon/dist/routes/workflow.js.map +1 -1
- package/daemon/dist/server.d.ts.map +1 -1
- package/daemon/dist/server.js +17 -1
- package/daemon/dist/server.js.map +1 -1
- package/daemon/dist/startup.d.ts.map +1 -1
- package/daemon/dist/startup.js +34 -6
- package/daemon/dist/startup.js.map +1 -1
- package/daemon/dist/transcript-redaction-surface.d.ts +2 -0
- package/daemon/dist/transcript-redaction-surface.d.ts.map +1 -0
- package/daemon/dist/transcript-redaction-surface.js +2 -0
- package/daemon/dist/transcript-redaction-surface.js.map +1 -0
- package/daemon/docs/reference/acp-agents.md +9 -2
- package/daemon/docs/reference/agent-spec.md +22 -1
- package/daemon/docs/reference/agent-startup-guide.md +10 -0
- package/daemon/docs/reference/community-harness-examples/cursor/cursor.yaml +3 -1
- package/daemon/docs/reference/community-harness-presets.md +27 -2
- package/daemon/docs/reference/daemon-http-clients.md +57 -0
- package/daemon/docs/reference/developing.md +3 -2
- package/daemon/docs/reference/getting-started.md +31 -7
- package/daemon/docs/reference/harness-runner-contract.md +72 -0
- package/daemon/docs/reference/hosted-members.md +21 -2
- package/daemon/docs/reference/network-connector.md +32 -3
- package/daemon/docs/reference/quickstart.md +4 -4
- package/daemon/docs/reference/refocus-channel.md +48 -0
- package/daemon/docs/reference/rig-bundle.md +11 -1
- package/daemon/docs/reference/rig-spec.md +8 -0
- package/daemon/docs/reference/seat-node-targeting.md +10 -0
- package/daemon/docs/reference/seat-pools.md +76 -10
- package/daemon/docs/reference/slack-app-setup.md +15 -0
- package/daemon/docs/reference/terminal-sessions.md +71 -3
- package/daemon/docs/reference/tmux-servers.md +16 -0
- package/daemon/docs/reference/whats-new.md +106 -12
- package/daemon/specs/agents/shared/skills/core/working-with-an-openrig-team/SKILL.md +71 -9
- package/daemon/specs/rigs/launch/factory/guidance/lead-first-move.md +4 -1
- package/daemon/specs/rigs/launch/kernel/agents/operator/agent/guidance/role.md +2 -1
- package/daemon/specs/rigs/launch/starter/guidance/lead-first-move.md +4 -1
- package/dist/bin-wrapper.d.ts.map +1 -1
- package/dist/bin-wrapper.js +24 -5
- package/dist/bin-wrapper.js.map +1 -1
- package/dist/build-info.js +3 -3
- package/dist/client.d.ts +4 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +7 -1
- package/dist/client.js.map +1 -1
- package/dist/commands/add.js +1 -1
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/agent.js +1 -1
- package/dist/commands/agent.js.map +1 -1
- package/dist/commands/bundle.d.ts.map +1 -1
- package/dist/commands/bundle.js +18 -4
- package/dist/commands/bundle.js.map +1 -1
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +6 -2
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/down.d.ts.map +1 -1
- package/dist/commands/down.js +12 -1
- package/dist/commands/down.js.map +1 -1
- package/dist/commands/expand.js +1 -1
- package/dist/commands/expand.js.map +1 -1
- package/dist/commands/fork.js +1 -1
- package/dist/commands/fork.js.map +1 -1
- package/dist/commands/grow.d.ts.map +1 -1
- package/dist/commands/grow.js +9 -4
- package/dist/commands/grow.js.map +1 -1
- package/dist/commands/import.js +1 -1
- package/dist/commands/import.js.map +1 -1
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +57 -22
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/network.d.ts +2 -3
- package/dist/commands/network.d.ts.map +1 -1
- package/dist/commands/network.js +54 -9
- package/dist/commands/network.js.map +1 -1
- package/dist/commands/ps.d.ts +1 -0
- package/dist/commands/ps.d.ts.map +1 -1
- package/dist/commands/ps.js +22 -19
- package/dist/commands/ps.js.map +1 -1
- package/dist/commands/queue.d.ts +2 -0
- package/dist/commands/queue.d.ts.map +1 -1
- package/dist/commands/queue.js +29 -6
- package/dist/commands/queue.js.map +1 -1
- package/dist/commands/reconcile-session.js +1 -1
- package/dist/commands/reconcile-session.js.map +1 -1
- package/dist/commands/restore.js +1 -1
- package/dist/commands/restore.js.map +1 -1
- package/dist/commands/rig.js +2 -2
- package/dist/commands/rig.js.map +1 -1
- package/dist/commands/seat.d.ts.map +1 -1
- package/dist/commands/seat.js +55 -16
- package/dist/commands/seat.js.map +1 -1
- package/dist/commands/skill.js +1 -1
- package/dist/commands/skill.js.map +1 -1
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +3 -2
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/terminal.d.ts.map +1 -1
- package/dist/commands/terminal.js +20 -4
- package/dist/commands/terminal.js.map +1 -1
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +2 -1
- package/dist/commands/up.js.map +1 -1
- package/dist/commands/whoami.d.ts.map +1 -1
- package/dist/commands/whoami.js +6 -0
- package/dist/commands/whoami.js.map +1 -1
- package/dist/commands/workflow-follow.d.ts.map +1 -1
- package/dist/commands/workflow-follow.js +37 -34
- package/dist/commands/workflow-follow.js.map +1 -1
- package/dist/commands/workflow-render.d.ts +1 -1
- package/dist/commands/workflow-render.d.ts.map +1 -1
- package/dist/commands/workflow-render.js +2 -7
- package/dist/commands/workflow-render.js.map +1 -1
- package/dist/commands/workflow.d.ts.map +1 -1
- package/dist/commands/workflow.js +22 -2
- package/dist/commands/workflow.js.map +1 -1
- package/dist/daemon-lifecycle.d.ts +24 -0
- package/dist/daemon-lifecycle.d.ts.map +1 -1
- package/dist/daemon-lifecycle.js +45 -8
- package/dist/daemon-lifecycle.js.map +1 -1
- package/dist/lib/bundle-source.d.ts +4 -0
- package/dist/lib/bundle-source.d.ts.map +1 -1
- package/dist/lib/bundle-source.js +14 -2
- package/dist/lib/bundle-source.js.map +1 -1
- package/dist/lib/context-git.js +2 -2
- package/dist/lib/context-git.js.map +1 -1
- package/dist/lib/frontmatter.d.ts.map +1 -1
- package/dist/lib/frontmatter.js +4 -2
- package/dist/lib/frontmatter.js.map +1 -1
- package/dist/lib/scope/attestation-lineage.js +2 -2
- package/dist/lib/scope/attestation-lineage.js.map +1 -1
- package/dist/lib/scope/logical-checkbox.d.ts.map +1 -1
- package/dist/lib/scope/logical-checkbox.js +18 -0
- package/dist/lib/scope/logical-checkbox.js.map +1 -1
- package/dist/lib/scope/progress-edit.js +1 -1
- package/dist/lib/scope/progress-edit.js.map +1 -1
- package/dist/lib/scope/scaffold-placeholder.js +2 -2
- package/dist/lib/scope/scaffold-placeholder.js.map +1 -1
- package/dist/lib/terminal-cell.d.ts +5 -0
- package/dist/lib/terminal-cell.d.ts.map +1 -0
- package/dist/lib/terminal-cell.js +22 -0
- package/dist/lib/terminal-cell.js.map +1 -0
- package/dist/mcp-http.d.ts +1 -1
- package/dist/mcp-http.d.ts.map +1 -1
- package/dist/mcp-http.js +6 -3
- package/dist/mcp-http.js.map +1 -1
- package/dist/mcp-server.d.ts +5 -1
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/mcp-server.js +111 -13
- package/dist/mcp-server.js.map +1 -1
- package/dist/release-surface/extract-surface.d.ts.map +1 -1
- package/dist/release-surface/extract-surface.js +38 -20
- package/dist/release-surface/extract-surface.js.map +1 -1
- package/dist/release-surface/generate.d.ts.map +1 -1
- package/dist/release-surface/generate.js +3 -0
- package/dist/release-surface/generate.js.map +1 -1
- package/dist/release-surface/surface-diff.d.ts +1 -0
- package/dist/release-surface/surface-diff.d.ts.map +1 -1
- package/dist/release-surface/surface-diff.js +19 -18
- package/dist/release-surface/surface-diff.js.map +1 -1
- package/dist/restore-packet/redaction.d.ts +4 -26
- package/dist/restore-packet/redaction.d.ts.map +1 -1
- package/dist/restore-packet/redaction.js +19 -63
- package/dist/restore-packet/redaction.js.map +1 -1
- package/dist/terminal-orca.d.ts +7 -0
- package/dist/terminal-orca.d.ts.map +1 -0
- package/dist/terminal-orca.js +239 -0
- package/dist/terminal-orca.js.map +1 -0
- package/package.json +1 -1
- package/tui/dist/connected-assistants.d.ts +1 -1
- package/tui/dist/connected-assistants.d.ts.map +1 -1
- package/tui/dist/connected-assistants.js +3 -1
- package/tui/dist/connected-assistants.js.map +1 -1
- package/tui/dist/daemon-client.d.ts +4 -0
- package/tui/dist/daemon-client.d.ts.map +1 -1
- package/tui/dist/daemon-client.js +12 -8
- package/tui/dist/daemon-client.js.map +1 -1
- package/tui/dist/health/health-model.d.ts.map +1 -1
- package/tui/dist/health/health-model.js +2 -0
- package/tui/dist/health/health-model.js.map +1 -1
- package/tui/dist/hydrate.d.ts +3 -1
- package/tui/dist/hydrate.d.ts.map +1 -1
- package/tui/dist/hydrate.js +40 -25
- package/tui/dist/hydrate.js.map +1 -1
- package/tui/dist/live.d.ts +5 -1
- package/tui/dist/live.d.ts.map +1 -1
- package/tui/dist/live.js +20 -2
- package/tui/dist/live.js.map +1 -1
- package/tui/dist/main.js +5 -2
- package/tui/dist/main.js.map +1 -1
- package/tui/dist/pulse/pulse-model.d.ts.map +1 -1
- package/tui/dist/pulse/pulse-model.js +3 -2
- package/tui/dist/pulse/pulse-model.js.map +1 -1
- package/tui/dist/render.d.ts.map +1 -1
- package/tui/dist/render.js +6 -5
- package/tui/dist/render.js.map +1 -1
- package/tui/dist/types.d.ts +10 -4
- package/tui/dist/types.d.ts.map +1 -1
- package/ui/dist/assets/index-Chh-NS8Z.css +32 -0
- package/ui/dist/assets/index-DG_7XFcL.js +628 -0
- package/ui/dist/index.html +2 -2
- package/ui/dist/assets/index-B-sMy02c.js +0 -623
- package/ui/dist/assets/index-DiN7RwWg.css +0 -32
|
@@ -4,8 +4,24 @@ import { reserveOperation } from "./operation-correlation.js";
|
|
|
4
4
|
import { planSeatPool, seatPoolCanReceive, } from "./policies/seat-pool.js";
|
|
5
5
|
import { DeliveryGuardError } from "./seat-delivery-guard.js";
|
|
6
6
|
import { seatPoolModelOfJob } from "./seat-pool-registration.js";
|
|
7
|
+
import { readAttemptOutcome } from "./seat-pool-slots.js";
|
|
8
|
+
import { parsePoolBlock } from "./seat-pool-spec.js";
|
|
7
9
|
import { deriveCanonicalSessionName } from "./session-name.js";
|
|
8
10
|
import { seatLaunchAdditionPathsForNode } from "./seat-launch-additions.js";
|
|
11
|
+
/** The report of a stop from what the checked stop returned. */
|
|
12
|
+
export function seatPoolStopReport(stop) {
|
|
13
|
+
// A keep_alive seat whose session was already gone is recorded as stopped, but nothing was stopped: an absence.
|
|
14
|
+
if (stop.ok && stop.alreadyDown)
|
|
15
|
+
return { cause: "drain", result: "absent", code: "already_down", ...(stop.message ? { message: stop.message } : {}) };
|
|
16
|
+
if (stop.ok)
|
|
17
|
+
return { cause: "drain", result: "stopped" };
|
|
18
|
+
if (stop.code === "session_not_live")
|
|
19
|
+
return { cause: "drain", result: "absent", code: stop.code, message: stop.message };
|
|
20
|
+
if (stop.code === "selection_changed" && stop.partialEffect !== true) {
|
|
21
|
+
return { cause: "drain", result: "changed_owner", code: stop.code, message: stop.message };
|
|
22
|
+
}
|
|
23
|
+
return { cause: "drain", result: "unconfirmed", code: stop.code, message: stop.message };
|
|
24
|
+
}
|
|
9
25
|
/** The queue's reroute actor and note, as the queue records a reroute (the queue's own rule for "was rerouted"). */
|
|
10
26
|
const QUEUE_FALLBACK_ACTOR = "system:queue-fallback";
|
|
11
27
|
const FALLBACK_NOTE = "fallback-routed: ";
|
|
@@ -165,15 +181,34 @@ function unreadableAdvisory(error) {
|
|
|
165
181
|
function inFlight(attemptId) {
|
|
166
182
|
return { id: attemptId, status: "in_flight", message: `in flight (attempt ${attemptId})` };
|
|
167
183
|
}
|
|
184
|
+
const CANCELLED_NOT_ISSUED = "cancelled: not issued";
|
|
185
|
+
const INTERRUPTED_BEFORE_CREATE = "not launched (interrupted before create)";
|
|
186
|
+
/** A slot's attempt as its row records it: an issued attempt with an `unknown` outcome is reported so, and a settled one
|
|
187
|
+
* by the status its outcome kept (a settled add with no such status settled running). */
|
|
188
|
+
function attemptView(slot) {
|
|
189
|
+
if (slot.attemptId === null || slot.attemptState === null)
|
|
190
|
+
return undefined;
|
|
191
|
+
const outcome = readAttemptOutcome(slot.attemptOutcome);
|
|
192
|
+
const text = (key) => (typeof outcome[key] === "string" ? { [key]: outcome[key] } : {});
|
|
193
|
+
if (slot.attemptState === "settled") {
|
|
194
|
+
if (outcome["status"] !== "not_running")
|
|
195
|
+
return { id: slot.attemptId, status: "running" };
|
|
196
|
+
return {
|
|
197
|
+
id: slot.attemptId, status: "not_running",
|
|
198
|
+
...(outcome["observed"] === "exited" || outcome["observed"] === "probe_absent" ? { observed: outcome["observed"] } : {}),
|
|
199
|
+
...text("code"), ...text("message"),
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
if (slot.attemptState === "issued" && outcome["status"] === "unknown") {
|
|
203
|
+
return { id: slot.attemptId, status: "unknown", ...text("code"), ...text("message") };
|
|
204
|
+
}
|
|
205
|
+
return inFlight(slot.attemptId);
|
|
206
|
+
}
|
|
168
207
|
function slotsView(slots) {
|
|
169
|
-
return slots.map((slot) =>
|
|
170
|
-
|
|
171
|
-
nodeId: slot.nodeId,
|
|
172
|
-
|
|
173
|
-
...(slot.attemptId === null || slot.attemptState === null
|
|
174
|
-
? {}
|
|
175
|
-
: { attempt: slot.attemptState === "settled" ? { id: slot.attemptId, status: "running" } : inFlight(slot.attemptId) }),
|
|
176
|
-
}));
|
|
208
|
+
return slots.map((slot) => {
|
|
209
|
+
const attempt = attemptView(slot);
|
|
210
|
+
return { slotNumber: slot.slotNumber, nodeId: slot.nodeId, phase: slot.phase, ...(attempt ? { attempt } : {}) };
|
|
211
|
+
});
|
|
177
212
|
}
|
|
178
213
|
/** The interim rule until drained slots come back: no new number while one is `drained`. Reported for the add only. */
|
|
179
214
|
const DRAINED_SLOT_GUARD = "held: drained slot awaiting comeback";
|
|
@@ -189,6 +224,58 @@ function addCallOutcome(outcome) {
|
|
|
189
224
|
...(node.error ? { error: node.error } : {}), ...(node.sessionName ? { sessionName: node.sessionName } : {}),
|
|
190
225
|
};
|
|
191
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* The one rule an add with a node settles by, in the cycle that ran it and in a later cycle (or process) that reads it
|
|
229
|
+
* again. Exited, or the node's executor confirmed stopped: not running, never retried. Running or idle with startup
|
|
230
|
+
* `ready`: running, unless the call is known to have returned anything but a launch (a failed launch whose session
|
|
231
|
+
* still runs is not settled here). Anything else (startup not ready, no session, another status): unknown.
|
|
232
|
+
*/
|
|
233
|
+
function classifyAdd(call, latest, confirmedStopped) {
|
|
234
|
+
const failure = call === null ? {}
|
|
235
|
+
: call.ok ? (call.error ? { message: call.error } : {})
|
|
236
|
+
: { code: call.code, message: call.message };
|
|
237
|
+
if (latest?.status === "exited")
|
|
238
|
+
return { status: "not_running", observed: "exited", ...failure };
|
|
239
|
+
if (confirmedStopped)
|
|
240
|
+
return { status: "not_running", observed: "probe_absent", ...failure };
|
|
241
|
+
if (latest === null)
|
|
242
|
+
return { status: "unknown", code: "no_session", message: "unknown: the node has no session yet" };
|
|
243
|
+
const evidence = `latest session ${latest.status}, startup ${latest.startupStatus ?? "unknown"}`;
|
|
244
|
+
if (latest.status === "running" || latest.status === "idle") {
|
|
245
|
+
if (call !== null && !(call.ok && call.status === "launched")) {
|
|
246
|
+
return { status: "unknown", code: call.ok ? `node_${call.status}` : call.code, message: `unknown: the add returned ${call.ok ? call.status : call.code}; ${evidence}` };
|
|
247
|
+
}
|
|
248
|
+
if (latest.startupStatus === "ready")
|
|
249
|
+
return { status: "running", sessionId: latest.id };
|
|
250
|
+
}
|
|
251
|
+
return { status: "unknown", code: "not_settled", message: `unknown: ${evidence}` };
|
|
252
|
+
}
|
|
253
|
+
/** The add call's outcome an `unknown` attempt kept on its row, or null when the call never returned. */
|
|
254
|
+
function keptCall(slot) {
|
|
255
|
+
const call = readAttemptOutcome(slot.attemptOutcome)["call"];
|
|
256
|
+
if (call === null || typeof call !== "object" || Array.isArray(call))
|
|
257
|
+
return null;
|
|
258
|
+
const c = call;
|
|
259
|
+
if (c["ok"] === true && typeof c["status"] === "string" && typeof c["nodeId"] === "string")
|
|
260
|
+
return c;
|
|
261
|
+
if (c["ok"] === false && typeof c["code"] === "string" && typeof c["message"] === "string")
|
|
262
|
+
return c;
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
/** What an add was issued on (`attempt_basis`), or null when the row's basis can't be read. */
|
|
266
|
+
function issuedBasis(text) {
|
|
267
|
+
if (text === null)
|
|
268
|
+
return null;
|
|
269
|
+
try {
|
|
270
|
+
const parsed = JSON.parse(text);
|
|
271
|
+
return Array.isArray(parsed.targets) && parsed.targets.every((t) => typeof t === "string") && typeof parsed.body === "string"
|
|
272
|
+
? { targets: parsed.targets, body: parsed.body }
|
|
273
|
+
: null;
|
|
274
|
+
}
|
|
275
|
+
catch {
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
192
279
|
function errorMessage(error) {
|
|
193
280
|
return error instanceof Error ? error.message : String(error);
|
|
194
281
|
}
|
|
@@ -200,11 +287,121 @@ class AddNotIssued extends Error {
|
|
|
200
287
|
this.code = code;
|
|
201
288
|
}
|
|
202
289
|
}
|
|
290
|
+
/** A node's latest session, in the order the reader uses. Null: none. */
|
|
291
|
+
function latestSession(db, nodeId) {
|
|
292
|
+
return db.prepare("SELECT id, status FROM sessions WHERE node_id = ? ORDER BY created_at DESC, id DESC LIMIT 1").get(nodeId) ?? null;
|
|
293
|
+
}
|
|
294
|
+
/** The spec the job was last ensured with (`context.pool`); null when it has none that reads. */
|
|
295
|
+
function lastEnsuredSpec(context) {
|
|
296
|
+
const read = parsePoolBlock(context["pool"]);
|
|
297
|
+
return read.ok ? read.spec : null;
|
|
298
|
+
}
|
|
299
|
+
/** The time of the latest drain step on record: the newest phase change of a `draining` or `drained` slot. */
|
|
300
|
+
function lastDrainStep(slots) {
|
|
301
|
+
let latest = null;
|
|
302
|
+
for (const slot of slots) {
|
|
303
|
+
if ((slot.phase !== "draining" && slot.phase !== "drained") || !validIso(slot.phaseChangedAt))
|
|
304
|
+
continue;
|
|
305
|
+
if (latest === null || Date.parse(slot.phaseChangedAt) > Date.parse(latest))
|
|
306
|
+
latest = slot.phaseChangedAt;
|
|
307
|
+
}
|
|
308
|
+
return latest;
|
|
309
|
+
}
|
|
310
|
+
/** Free to drain: its latest session runs, idle at its prompt, with no open row and no held message. */
|
|
311
|
+
function freeToDrain(agent) {
|
|
312
|
+
return agent.running && agent.idleAtPrompt && agent.openRows === 0 && agent.heldCount === 0;
|
|
313
|
+
}
|
|
203
314
|
export function makeSeatPoolExecutor(deps) {
|
|
315
|
+
/** Woken since the plan: the agent's recorded idle time can be read and is not the one the plan read. */
|
|
316
|
+
const woken = (nodeId, idleSince) => {
|
|
317
|
+
const changedAt = deps.seatState(nodeId)?.changedAt;
|
|
318
|
+
return validIso(changedAt) && changedAt !== idleSince;
|
|
319
|
+
};
|
|
320
|
+
const at = () => deps.now().toISOString();
|
|
204
321
|
/** The adds started and not settled yet. */
|
|
205
322
|
const pending = new Set();
|
|
323
|
+
/** The attempt ids this process issued and whose call has not settled yet. An `issued` row that is not here is no
|
|
324
|
+
* process's any more: an add cut off by a daemon restart, or one whose result was unknown when its call returned. */
|
|
325
|
+
const inFlightAttempts = new Set();
|
|
206
326
|
/** model node id → what settled since that model's last report. */
|
|
207
327
|
const settled = new Map();
|
|
328
|
+
const reportSettled = (modelNodeId, entry) => settled.set(modelNodeId, [...(settled.get(modelNodeId) ?? []), entry]);
|
|
329
|
+
/** An add with a node, settled by its latest session (classifyAdd). Running: `live`. Not running: `drained`, with a
|
|
330
|
+
* reuse hold. Unknown: it stays issued, with what was read kept on its row. What settled is returned for the report;
|
|
331
|
+
* nothing while unknown, or when the row no longer holds the attempt. */
|
|
332
|
+
const settleWithNode = (add, call, latest) => {
|
|
333
|
+
const settlement = classifyAdd(call, latest, deps.confirmedStopped(add.nodeId));
|
|
334
|
+
const entry = (attempt) => ({ slotNumber: add.slotNumber, logicalId: add.logicalId, nodeId: add.nodeId, attempt });
|
|
335
|
+
if (settlement.status === "running") {
|
|
336
|
+
return deps.slots.settleAdd(add.slotId, add.attemptId, {
|
|
337
|
+
outcome: JSON.stringify(call ?? { replayed: true }),
|
|
338
|
+
result: JSON.stringify({ nodeId: add.nodeId, sessionId: settlement.sessionId }), at: at(),
|
|
339
|
+
}) ? entry({ id: add.attemptId, status: "running" }) : null;
|
|
340
|
+
}
|
|
341
|
+
if (settlement.status === "not_running") {
|
|
342
|
+
const seen = {
|
|
343
|
+
observed: settlement.observed,
|
|
344
|
+
...(settlement.code !== undefined ? { code: settlement.code } : {}),
|
|
345
|
+
...(settlement.message !== undefined ? { message: settlement.message } : {}),
|
|
346
|
+
};
|
|
347
|
+
// The reuse hold: the launch's status or code (`not_running` when the call never returned), what was observed, and
|
|
348
|
+
// the launch's error when there is one.
|
|
349
|
+
const error = call === null ? undefined : call.ok ? call.error : call.message;
|
|
350
|
+
const hold = {
|
|
351
|
+
code: call === null ? "not_running" : call.ok ? call.status : call.code,
|
|
352
|
+
observed: settlement.observed,
|
|
353
|
+
...(error !== undefined ? { error } : {}),
|
|
354
|
+
};
|
|
355
|
+
return deps.slots.settleAddNotRunning(add.slotId, add.attemptId, {
|
|
356
|
+
outcome: JSON.stringify({ status: "not_running", ...seen, call }), hold: JSON.stringify(hold), at: at(),
|
|
357
|
+
}) ? entry({ id: add.attemptId, status: "not_running", ...seen }) : null;
|
|
358
|
+
}
|
|
359
|
+
deps.slots.recordAttemptOutcome(add.slotId, add.attemptId, JSON.stringify({ status: "unknown", code: settlement.code, message: settlement.message, call }));
|
|
360
|
+
return null;
|
|
361
|
+
};
|
|
362
|
+
/** The model's logical id, for the `<model>-s<n>` of a slot read back from its row. */
|
|
363
|
+
const logicalIdOf = (modelNodeId, slotNumber) => {
|
|
364
|
+
const row = deps.db.prepare("SELECT logical_id FROM nodes WHERE id = ?").get(modelNodeId);
|
|
365
|
+
return `${row?.logical_id ?? modelNodeId}-s${slotNumber}`;
|
|
366
|
+
};
|
|
367
|
+
/**
|
|
368
|
+
* An add attempt no process is running any more, settled from its row, under the custody lease. Reserved: cancelled.
|
|
369
|
+
* Issued: read again by replaying `reserveOperation` with what it was issued on, which never runs the add again; with
|
|
370
|
+
* no node recorded the row goes, otherwise the node settles it by the same rule as the call that ran it. An operation
|
|
371
|
+
* id with no row is not replayed (that would reserve it anew): unknown, as is any replay that is not one.
|
|
372
|
+
*/
|
|
373
|
+
const settleLeftover = (modelNodeId, slot) => {
|
|
374
|
+
const attemptId = slot.attemptId;
|
|
375
|
+
const logicalId = logicalIdOf(modelNodeId, slot.slotNumber);
|
|
376
|
+
if (slot.attemptState === "reserved") {
|
|
377
|
+
return deps.slots.cancelReservedAdd(slot.slotId, attemptId)
|
|
378
|
+
? { slotNumber: slot.slotNumber, logicalId, attempt: { id: attemptId, status: "cancelled", message: CANCELLED_NOT_ISSUED, code: "interrupted_before_issue" } }
|
|
379
|
+
: null;
|
|
380
|
+
}
|
|
381
|
+
const unknown = (code, message) => {
|
|
382
|
+
deps.slots.recordAttemptOutcome(slot.slotId, attemptId, JSON.stringify({ status: "unknown", code, message, call: keptCall(slot) }));
|
|
383
|
+
return null;
|
|
384
|
+
};
|
|
385
|
+
const basis = issuedBasis(slot.attemptBasis);
|
|
386
|
+
if (basis === null)
|
|
387
|
+
return unknown("basis_unreadable", "unknown: what the add was issued on can't be read");
|
|
388
|
+
if (!deps.db.prepare("SELECT 1 FROM operation_correlations WHERE operation_id = ?").get(attemptId)) {
|
|
389
|
+
return unknown("operation_missing", "unknown: the add's operation id has no record");
|
|
390
|
+
}
|
|
391
|
+
const replayed = reserveOperation(deps.db, attemptId, "member.add", basis.targets, basis.body);
|
|
392
|
+
if (replayed.state !== "replay")
|
|
393
|
+
return unknown(`operation_${replayed.state}`, `unknown: replaying the add's operation id gave ${replayed.state}`);
|
|
394
|
+
const operation = replayed.operation;
|
|
395
|
+
if (slot.nodeId === null) {
|
|
396
|
+
if (operation.nodeIds.length > 0)
|
|
397
|
+
return unknown("node_not_recorded", "unknown: the operation recorded a node the slot does not have");
|
|
398
|
+
return deps.slots.removeAddWithoutNode(slot.slotId, attemptId)
|
|
399
|
+
? { slotNumber: slot.slotNumber, logicalId, attempt: { id: attemptId, status: "no_node", code: "interrupted_before_create", message: INTERRUPTED_BEFORE_CREATE } }
|
|
400
|
+
: null;
|
|
401
|
+
}
|
|
402
|
+
const latest = operation.current.nodes.find((node) => node.id === slot.nodeId)?.latestSession ?? null;
|
|
403
|
+
return settleWithNode({ slotId: slot.slotId, slotNumber: slot.slotNumber, logicalId, attemptId, nodeId: slot.nodeId }, keptCall(slot), latest);
|
|
404
|
+
};
|
|
208
405
|
/** Why the model member gives no agent, read from the model node itself (the export leaves these out silently), or null. */
|
|
209
406
|
const addRefusal = (rigId, modelNodeId) => {
|
|
210
407
|
let node;
|
|
@@ -231,9 +428,9 @@ export function makeSeatPoolExecutor(deps) {
|
|
|
231
428
|
};
|
|
232
429
|
/** The add's call, after the lease, and its settlement on the slot row. Never rejects. */
|
|
233
430
|
const runAdd = async (modelNodeId, add) => {
|
|
234
|
-
const report = (entry) =>
|
|
431
|
+
const report = (entry) => reportSettled(modelNodeId, entry);
|
|
432
|
+
let outcome;
|
|
235
433
|
try {
|
|
236
|
-
let outcome;
|
|
237
434
|
if (add.folder !== null) {
|
|
238
435
|
try {
|
|
239
436
|
deps.add.makeFolder(add.folder);
|
|
@@ -267,7 +464,6 @@ export function makeSeatPoolExecutor(deps) {
|
|
|
267
464
|
const slot = deps.slots.get(add.slotId);
|
|
268
465
|
if (!slot || slot.attemptId !== add.attemptId)
|
|
269
466
|
return; // its row went with a node deleted by hand
|
|
270
|
-
const stored = JSON.stringify(outcome);
|
|
271
467
|
if (slot.nodeId === null) {
|
|
272
468
|
deps.slots.removeAddWithoutNode(add.slotId, add.attemptId);
|
|
273
469
|
const code = outcome.ok ? "node_not_recorded" : outcome.code;
|
|
@@ -278,20 +474,22 @@ export function makeSeatPoolExecutor(deps) {
|
|
|
278
474
|
return;
|
|
279
475
|
}
|
|
280
476
|
const latest = add.operation.read().current.nodes.find((node) => node.id === slot.nodeId)?.latestSession ?? null;
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
if (
|
|
284
|
-
|
|
285
|
-
})) {
|
|
286
|
-
report({ slotNumber: add.slotNumber, logicalId: add.logicalId, nodeId: slot.nodeId, attempt: { id: add.attemptId, status: "running" } });
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
|
-
// A node that does not run (or not yet) is not settled here: the attempt stays issued, with its outcome kept.
|
|
290
|
-
deps.slots.recordAttemptOutcome(add.slotId, add.attemptId, stored);
|
|
477
|
+
// An unknown result stays issued; once this call is over, a later cycle reads it again.
|
|
478
|
+
const entry = settleWithNode({ ...add, nodeId: slot.nodeId }, outcome, latest);
|
|
479
|
+
if (entry)
|
|
480
|
+
report(entry);
|
|
291
481
|
}
|
|
292
482
|
catch (error) {
|
|
483
|
+
// The call's outcome stays on the row, so the cycle that reads this attempt again settles it with the call.
|
|
484
|
+
try {
|
|
485
|
+
deps.slots.recordAttemptOutcome(add.slotId, add.attemptId, JSON.stringify({ status: "unknown", code: "settle_failed", message: errorMessage(error), call: outcome ?? null }));
|
|
486
|
+
}
|
|
487
|
+
catch { /* the settle's own error is the one reported */ }
|
|
293
488
|
report({ slotNumber: add.slotNumber, logicalId: add.logicalId, attempt: { ...inFlight(add.attemptId), code: "settle_failed", message: errorMessage(error) } });
|
|
294
489
|
}
|
|
490
|
+
finally {
|
|
491
|
+
inFlightAttempts.delete(add.attemptId);
|
|
492
|
+
}
|
|
295
493
|
};
|
|
296
494
|
/** One add after another, each after the lease is released; the cycle does not wait for them. */
|
|
297
495
|
const startAdds = (modelNodeId, adds) => {
|
|
@@ -337,28 +535,61 @@ export function makeSeatPoolExecutor(deps) {
|
|
|
337
535
|
const base = () => ({ modelNodeId, ...block, slots: slotsView(deps.slots.forModel(modelNodeId)) });
|
|
338
536
|
if (!active())
|
|
339
537
|
return report({ ...base(), held: JOB_STOPPED });
|
|
340
|
-
if (block.block === "none")
|
|
341
|
-
return report(base());
|
|
342
538
|
if (block.block === "unusable")
|
|
343
539
|
return report({ ...base(), held: BLOCK_UNREADABLE, advisory: unreadableAdvisory(block.error) });
|
|
344
|
-
//
|
|
345
|
-
//
|
|
346
|
-
const
|
|
347
|
-
const
|
|
540
|
+
// After `pool: {}` the model has no block: the job drains with the spec last stored on its row (`drain` set), and
|
|
541
|
+
// ends once every agent is drained. A job with no readable spec of its own does nothing.
|
|
542
|
+
const removed = block.block === "none";
|
|
543
|
+
const lastSpec = removed ? lastEnsuredSpec(job.context) : null;
|
|
544
|
+
if (block.block === "none" && lastSpec === null)
|
|
545
|
+
return report(base());
|
|
546
|
+
const spec = block.block === "stored" ? block.spec : { ...lastSpec, drain: true };
|
|
547
|
+
const removal = removed ? { removal: "the pool block was removed; draining with the spec last stored on the job" } : {};
|
|
548
|
+
// The plan is read outside the lease; the custody is for the hold check, the moves, the drain decisions and the
|
|
549
|
+
// add's reservation and issue. The add's call goes out after it.
|
|
550
|
+
const read = { ...readSeatPoolState(deps, model, slots), lastStepAt: lastDrainStep(slots) };
|
|
348
551
|
const plan = planSeatPool(spec, read, deps.now().getTime());
|
|
349
552
|
const dispatches = plan.intents.filter((i) => i.kind === "dispatch");
|
|
553
|
+
const drainIntents = plan.intents.filter((i) => i.kind === "drain");
|
|
350
554
|
const addIntent = plan.intents.find((i) => i.kind === "add");
|
|
351
555
|
const plannedTo = (slotNumber) => read.agents.find((a) => a.slotNumber === slotNumber)?.sessionName ?? `slot ${slotNumber}`;
|
|
556
|
+
// The session each agent ran when the plan read it: a drain stops only that session.
|
|
557
|
+
const planSession = new Map(read.agents.map((a) => [a.slotNumber, a.nodeId === null ? null : latestSession(deps.db, a.nodeId)?.id ?? null]));
|
|
352
558
|
let held;
|
|
353
559
|
let advisory;
|
|
354
560
|
let hold;
|
|
355
561
|
let custody;
|
|
562
|
+
let blockChanged = false;
|
|
356
563
|
const moved = [];
|
|
357
564
|
const skipped = [];
|
|
358
565
|
const failed = [];
|
|
566
|
+
const drains = [];
|
|
567
|
+
const toDrain = [];
|
|
568
|
+
const restops = [];
|
|
569
|
+
const gone = [];
|
|
570
|
+
/** The block again: a re-apply since the plan (cleared, broken, or with any other value; after `pool: {}`, a block
|
|
571
|
+
* stored again) ends this cycle's effects, since the plan may no longer hold. The next evaluation plans against the
|
|
572
|
+
* block as it is then. */
|
|
573
|
+
const blockChangedNow = () => {
|
|
574
|
+
const storedNow = deps.rigRepo.getNodePool(modelNodeId);
|
|
575
|
+
const same = removed
|
|
576
|
+
? storedNow === undefined
|
|
577
|
+
: storedNow !== undefined && "spec" in storedNow && sameSpec(storedNow.spec, spec);
|
|
578
|
+
if (same)
|
|
579
|
+
return false;
|
|
580
|
+
blockChanged = true;
|
|
581
|
+
block = blockView(storedNow);
|
|
582
|
+
if (block.block === "unusable") {
|
|
583
|
+
held = BLOCK_UNREADABLE;
|
|
584
|
+
advisory = unreadableAdvisory(block.error);
|
|
585
|
+
}
|
|
586
|
+
return true;
|
|
587
|
+
};
|
|
588
|
+
const drainSkipped = (step, code) => {
|
|
589
|
+
drains.push({ ...step, outcome: "skipped", code });
|
|
590
|
+
};
|
|
359
591
|
let addNotes;
|
|
360
592
|
const issued = [];
|
|
361
|
-
let blockChanged = false;
|
|
362
593
|
let thrown;
|
|
363
594
|
try {
|
|
364
595
|
await deps.custody([modelNodeId], async () => {
|
|
@@ -378,6 +609,65 @@ export function makeSeatPoolExecutor(deps) {
|
|
|
378
609
|
};
|
|
379
610
|
return;
|
|
380
611
|
}
|
|
612
|
+
// The block again first: one that became unreadable while the cycle waited for custody holds the leftovers too,
|
|
613
|
+
// and they stay as they are. A block stored again with another value, or removed, still lets them settle.
|
|
614
|
+
if (blockView(deps.rigRepo.getNodePool(modelNodeId)).block === "unusable") {
|
|
615
|
+
blockChangedNow();
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
// An add attempt no process runs any more (a reservation never issued, or an issued add not in flight in this
|
|
619
|
+
// process: cut off by a daemon restart, or left unknown), settled from its row. One in flight here is left alone.
|
|
620
|
+
for (const slot of deps.slots.forModel(modelNodeId)) {
|
|
621
|
+
if (slot.phase !== "adding" || slot.attemptKind !== "add" || slot.attemptId === null || inFlightAttempts.has(slot.attemptId))
|
|
622
|
+
continue;
|
|
623
|
+
const entry = settleLeftover(modelNodeId, slot);
|
|
624
|
+
if (entry)
|
|
625
|
+
reportSettled(modelNodeId, entry);
|
|
626
|
+
}
|
|
627
|
+
// A leftover settled `not_running` here drains its slot, which starts the cooldown the plan could not see: under
|
|
628
|
+
// it, this cycle's drains wait (`drain: true` keeps its exemption).
|
|
629
|
+
const stepNow = lastDrainStep(deps.slots.forModel(modelNodeId));
|
|
630
|
+
const coolingNow = !spec.drain && stepNow !== null && stepNow !== read.lastStepAt
|
|
631
|
+
&& deps.now().getTime() - Date.parse(stepNow) < spec.cooldownSeconds * 1000;
|
|
632
|
+
// A drain an earlier cycle left unfinished. One whose unconfirmed stop may have had an effect (a kill was
|
|
633
|
+
// attempted) is stopped again below, never captured again. Any other (its capture failed, it ended before the
|
|
634
|
+
// capture, or its stop is known to have had no effect) goes back to `live`: nothing was stopped, and a later plan
|
|
635
|
+
// decides again, with a new capture.
|
|
636
|
+
for (const slot of slots.filter((s) => s.phase === "draining")) {
|
|
637
|
+
const agent = read.agents.find((a) => a.slotNumber === slot.slotNumber);
|
|
638
|
+
const session = agent?.sessionName ?? null;
|
|
639
|
+
const stop = deps.slots.stopOutcome(slot.slotId);
|
|
640
|
+
if (stop?.result === "unconfirmed" && stop.partialEffect === true && typeof stop.sessionId === "string"
|
|
641
|
+
&& slot.nodeId !== null && agent?.nodeId && session) {
|
|
642
|
+
restops.push({ slot, nodeId: slot.nodeId, session, sessionId: stop.sessionId });
|
|
643
|
+
}
|
|
644
|
+
else if (deps.slots.setPhase({ slotId: slot.slotId, from: "draining", to: "live", at: at() })) {
|
|
645
|
+
drains.push({ slotNumber: slot.slotNumber, session, phase: "live", outcome: "returned", code: "drain_not_finished" });
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
// Under `drain` (after `pool: {}`, or a block with `drain: true`), a `live` agent positively gone (its latest
|
|
649
|
+
// session `exited`, or its node confirmed stopped) with no work: the planner never picks it, since only running
|
|
650
|
+
// agents drain, so it would keep the job from ending. Its slot goes to `draining`, and the checked stop below
|
|
651
|
+
// confirms the session is absent before the slot is `drained`. An unknown or stale status is not gone.
|
|
652
|
+
if (spec.drain && deps.drain && !held && !blockChangedNow()) {
|
|
653
|
+
const current = deps.slots.forModel(modelNodeId);
|
|
654
|
+
const agentsNow = readSeatPoolAgents(deps, current);
|
|
655
|
+
for (const slot of current.filter((s) => s.phase === "live" && s.nodeId !== null)) {
|
|
656
|
+
const agent = agentsNow.find((a) => a.slotNumber === slot.slotNumber);
|
|
657
|
+
if (!agent || agent.nodeId === null || agent.sessionName === null || agent.running)
|
|
658
|
+
continue;
|
|
659
|
+
if (agent.openRows > 0 || agent.heldCount > 0)
|
|
660
|
+
continue;
|
|
661
|
+
if (agent.latestSessionStatus !== "exited" && !deps.confirmedStopped(agent.nodeId))
|
|
662
|
+
continue;
|
|
663
|
+
const sessionId = planSession.get(slot.slotNumber) ?? null;
|
|
664
|
+
if (sessionId === null || latestSession(deps.db, agent.nodeId)?.id !== sessionId)
|
|
665
|
+
continue;
|
|
666
|
+
if (!deps.slots.setPhase({ slotId: slot.slotId, from: "live", to: "draining", at: at(), stop: null }))
|
|
667
|
+
continue;
|
|
668
|
+
gone.push({ slot, nodeId: agent.nodeId, session: agent.sessionName, sessionId });
|
|
669
|
+
}
|
|
670
|
+
}
|
|
381
671
|
for (const [index, d] of dispatches.entries()) {
|
|
382
672
|
// A job stopped while an earlier move awaited: no later effect.
|
|
383
673
|
if (!active()) {
|
|
@@ -385,17 +675,7 @@ export function makeSeatPoolExecutor(deps) {
|
|
|
385
675
|
break;
|
|
386
676
|
}
|
|
387
677
|
const from = read.rawDestination.get(d.qitemId);
|
|
388
|
-
|
|
389
|
-
// here, since the plan may no longer hold (a new dispatch_tag, a longer dispatch_after_s, drain, a lower max).
|
|
390
|
-
// The next evaluation plans against the block as it is then.
|
|
391
|
-
const storedNow = deps.rigRepo.getNodePool(modelNodeId);
|
|
392
|
-
if (storedNow === undefined || !("spec" in storedNow) || !sameSpec(storedNow.spec, spec)) {
|
|
393
|
-
blockChanged = true;
|
|
394
|
-
block = blockView(storedNow);
|
|
395
|
-
if (block.block === "unusable") {
|
|
396
|
-
held = BLOCK_UNREADABLE;
|
|
397
|
-
advisory = unreadableAdvisory(block.error);
|
|
398
|
-
}
|
|
678
|
+
if (blockChangedNow()) {
|
|
399
679
|
for (const rest of dispatches.slice(index)) {
|
|
400
680
|
skipped.push({ qitemId: rest.qitemId, from: read.rawDestination.get(rest.qitemId), to: plannedTo(rest.slotNumber), code: "pool_block_changed" });
|
|
401
681
|
}
|
|
@@ -418,6 +698,53 @@ export function makeSeatPoolExecutor(deps) {
|
|
|
418
698
|
else
|
|
419
699
|
failed.push({ qitemId: d.qitemId, from, to, code: result.code, message: result.message });
|
|
420
700
|
}
|
|
701
|
+
// The drains: each agent again, just before its slot goes to `draining`. The capture and the stop come after
|
|
702
|
+
// the custody lease, under the agent's own lifecycle lease.
|
|
703
|
+
for (const [index, d] of drainIntents.entries()) {
|
|
704
|
+
if (held || blockChanged)
|
|
705
|
+
break;
|
|
706
|
+
if (!active()) {
|
|
707
|
+
held = JOB_STOPPED;
|
|
708
|
+
break;
|
|
709
|
+
}
|
|
710
|
+
if (coolingNow) {
|
|
711
|
+
for (const rest of drainIntents.slice(index))
|
|
712
|
+
drainSkipped({ slotNumber: rest.slotNumber, session: plannedTo(rest.slotNumber), phase: "live" }, "cooldown");
|
|
713
|
+
break;
|
|
714
|
+
}
|
|
715
|
+
if (blockChangedNow()) {
|
|
716
|
+
for (const rest of drainIntents.slice(index))
|
|
717
|
+
drainSkipped({ slotNumber: rest.slotNumber, session: plannedTo(rest.slotNumber), phase: "live" }, "pool_block_changed");
|
|
718
|
+
break;
|
|
719
|
+
}
|
|
720
|
+
const current = deps.slots.forModel(modelNodeId);
|
|
721
|
+
const slot = current.find((s) => s.slotNumber === d.slotNumber);
|
|
722
|
+
const agent = readSeatPoolAgents(deps, current).find((a) => a.slotNumber === d.slotNumber);
|
|
723
|
+
const step = { slotNumber: d.slotNumber, session: agent?.sessionName ?? plannedTo(d.slotNumber), phase: slot?.phase ?? "live" };
|
|
724
|
+
if (!slot || !agent || slot.nodeId === null || agent.nodeId === null || agent.sessionName === null) {
|
|
725
|
+
drainSkipped(step, "agent_gone");
|
|
726
|
+
continue;
|
|
727
|
+
}
|
|
728
|
+
const sessionId = planSession.get(d.slotNumber) ?? null;
|
|
729
|
+
// An agent relaunched since the plan read it is left alone.
|
|
730
|
+
if (sessionId === null || latestSession(deps.db, slot.nodeId)?.id !== sessionId) {
|
|
731
|
+
drainSkipped(step, "relaunched");
|
|
732
|
+
continue;
|
|
733
|
+
}
|
|
734
|
+
if (slot.phase !== "live" || !freeToDrain(agent) || woken(slot.nodeId, d.idleSince)) {
|
|
735
|
+
drainSkipped(step, "agent_not_free");
|
|
736
|
+
continue;
|
|
737
|
+
}
|
|
738
|
+
if (!deps.drain) {
|
|
739
|
+
drainSkipped(step, "drain_not_composed");
|
|
740
|
+
continue;
|
|
741
|
+
}
|
|
742
|
+
if (!deps.slots.setPhase({ slotId: slot.slotId, from: "live", to: "draining", at: at(), stop: null })) {
|
|
743
|
+
drainSkipped(step, "slot_moved_on");
|
|
744
|
+
continue;
|
|
745
|
+
}
|
|
746
|
+
toDrain.push({ slot, nodeId: slot.nodeId, session: agent.sessionName, sessionId, idleSince: d.idleSince });
|
|
747
|
+
}
|
|
421
748
|
// The add, after the moves of the same cycle, under the same lease. Nothing in it awaits.
|
|
422
749
|
if (!addIntent || !deps.add || held || blockChanged)
|
|
423
750
|
return;
|
|
@@ -458,6 +785,7 @@ export function makeSeatPoolExecutor(deps) {
|
|
|
458
785
|
const launchAdditionsFrom = seatLaunchAdditionPathsForNode(deps.db, modelNodeId);
|
|
459
786
|
const issuedView = [];
|
|
460
787
|
const notIssued = [];
|
|
788
|
+
const cancelled = [];
|
|
461
789
|
for (let unit = 0; unit < addIntent.count; unit++) {
|
|
462
790
|
if (!active()) {
|
|
463
791
|
held = JOB_STOPPED;
|
|
@@ -473,19 +801,64 @@ export function makeSeatPoolExecutor(deps) {
|
|
|
473
801
|
// A pool agent is never kept alive: a kept-alive agent would be relaunched against the pool's own stops. Leaving
|
|
474
802
|
// the key out is not enough, since the add then resolves it from the agent spec's profile or defaults.
|
|
475
803
|
const member = { id: memberId, ...inherited, cwd: folder ?? raw["cwd"], keep_alive: false };
|
|
476
|
-
// The re-check just before the issue
|
|
477
|
-
//
|
|
478
|
-
//
|
|
804
|
+
// The re-check just before the issue, with nothing awaited since the reservation: the job, the holds and the
|
|
805
|
+
// stored block again, then a new plan with this reservation counted. A lower `max`, `drain: true`, any other
|
|
806
|
+
// change to the block, a hold, or surplus that reaches this reservation cancels it before any operation row
|
|
807
|
+
// or call, and ends this cycle's adds.
|
|
808
|
+
let stopped;
|
|
809
|
+
const recheck = () => {
|
|
810
|
+
if (!active())
|
|
811
|
+
return "job_stopped";
|
|
812
|
+
const holdNow = readSeatPoolHold(deps.db, rigId);
|
|
813
|
+
if (holdNow.stoppedSeq !== null) {
|
|
814
|
+
stopped = holdNow;
|
|
815
|
+
return "rig_stopped";
|
|
816
|
+
}
|
|
817
|
+
const storedSpec = deps.rigRepo.getNodePool(modelNodeId);
|
|
818
|
+
const specNow = storedSpec !== undefined && "spec" in storedSpec ? storedSpec.spec : null;
|
|
819
|
+
if (blockChangedNow()) {
|
|
820
|
+
if (specNow === null)
|
|
821
|
+
return "pool_block_changed";
|
|
822
|
+
return specNow.max < spec.max ? "max_lowered" : specNow.drain ? "drain" : "pool_block_changed";
|
|
823
|
+
}
|
|
824
|
+
const slotsNow = deps.slots.forModel(modelNodeId);
|
|
825
|
+
const replan = planSeatPool(spec, { ...readSeatPoolState(deps, model, slotsNow), lastStepAt: lastDrainStep(slotsNow) }, deps.now().getTime());
|
|
826
|
+
return replan.intents.some((i) => i.kind === "cancel" && i.slotNumber === slot.slotNumber) ? "surplus" : null;
|
|
827
|
+
};
|
|
828
|
+
let cancelCause;
|
|
829
|
+
try {
|
|
830
|
+
cancelCause = recheck();
|
|
831
|
+
}
|
|
832
|
+
catch (error) {
|
|
833
|
+
// A re-check that fails leaves no reservation behind: the reserved row goes before its error is raised.
|
|
834
|
+
try {
|
|
835
|
+
deps.slots.cancelReservedAdd(slot.slotId, attemptId);
|
|
836
|
+
}
|
|
837
|
+
catch { /* the re-check's own error is the one raised */ }
|
|
838
|
+
throw error;
|
|
839
|
+
}
|
|
840
|
+
if (cancelCause !== null) {
|
|
841
|
+
// Reported cancelled only when its reserved row went; a row that no longer holds the reservation is reported
|
|
842
|
+
// as not issued, as the issue reports it.
|
|
843
|
+
if (deps.slots.cancelReservedAdd(slot.slotId, attemptId)) {
|
|
844
|
+
cancelled.push({ slotNumber: slot.slotNumber, logicalId, attempt: { id: attemptId, status: "cancelled", message: CANCELLED_NOT_ISSUED, code: cancelCause } });
|
|
845
|
+
}
|
|
846
|
+
else {
|
|
847
|
+
notIssued.push({ slotNumber: slot.slotNumber, logicalId, code: "slot_changed" });
|
|
848
|
+
}
|
|
849
|
+
if (cancelCause === "job_stopped")
|
|
850
|
+
held = JOB_STOPPED;
|
|
851
|
+
else if (stopped !== undefined) {
|
|
852
|
+
hold = stopped;
|
|
853
|
+
held = { cause: "rig stopped", seq: stopped.stoppedSeq, message: `held: rig stopped (event ${stopped.stoppedSeq})` };
|
|
854
|
+
}
|
|
855
|
+
break;
|
|
856
|
+
}
|
|
857
|
+
// The issue: the issued attempt, what it was issued on and the operation id, in one transaction.
|
|
479
858
|
const targets = [rigId, pod];
|
|
480
859
|
const body = JSON.stringify({ member, rigRoot });
|
|
481
860
|
let operation;
|
|
482
|
-
let stopped;
|
|
483
861
|
try {
|
|
484
|
-
const recheck = readSeatPoolHold(deps.db, rigId);
|
|
485
|
-
if (!active() || recheck.stoppedSeq !== null) {
|
|
486
|
-
stopped = recheck;
|
|
487
|
-
throw new AddNotIssued("held");
|
|
488
|
-
}
|
|
489
862
|
const eventSeq = deps.db.prepare("SELECT MAX(seq) AS seq FROM events WHERE rig_id = ?").get(rigId).seq;
|
|
490
863
|
const basis = JSON.stringify({ eventSeq, targets, body });
|
|
491
864
|
operation = deps.db.transaction(() => {
|
|
@@ -506,18 +879,10 @@ export function makeSeatPoolExecutor(deps) {
|
|
|
506
879
|
catch { /* the issue's own error is the one raised */ }
|
|
507
880
|
if (!(error instanceof AddNotIssued))
|
|
508
881
|
throw error;
|
|
509
|
-
if (stopped !== undefined) {
|
|
510
|
-
if (!active())
|
|
511
|
-
held = JOB_STOPPED;
|
|
512
|
-
else {
|
|
513
|
-
hold = stopped;
|
|
514
|
-
held = { cause: "rig stopped", seq: stopped.stoppedSeq, message: `held: rig stopped (event ${stopped.stoppedSeq})` };
|
|
515
|
-
}
|
|
516
|
-
break;
|
|
517
|
-
}
|
|
518
882
|
notIssued.push({ slotNumber: slot.slotNumber, logicalId, code: error.code });
|
|
519
883
|
continue;
|
|
520
884
|
}
|
|
885
|
+
inFlightAttempts.add(attemptId);
|
|
521
886
|
issued.push({
|
|
522
887
|
slotId: slot.slotId, slotNumber: slot.slotNumber, logicalId, attemptId, rigId, rigRoot, folder, launchAdditionsFrom, operation,
|
|
523
888
|
op: { kind: "add_member", pod, member },
|
|
@@ -527,6 +892,7 @@ export function makeSeatPoolExecutor(deps) {
|
|
|
527
892
|
addNotes = {
|
|
528
893
|
...(issuedView.length ? { issued: issuedView } : {}),
|
|
529
894
|
...(notIssued.length ? { failed: notIssued } : {}),
|
|
895
|
+
...(cancelled.length ? { cancelled } : {}),
|
|
530
896
|
};
|
|
531
897
|
});
|
|
532
898
|
}
|
|
@@ -541,6 +907,306 @@ export function makeSeatPoolExecutor(deps) {
|
|
|
541
907
|
throw thrown;
|
|
542
908
|
custody = { code: thrown.code, message: thrown.message };
|
|
543
909
|
}
|
|
910
|
+
if (!held && !custody && deps.drain) {
|
|
911
|
+
const effects = deps.drain;
|
|
912
|
+
/** The slot's phase after a write, read back when the write found it moved on. */
|
|
913
|
+
const moveTo = (slot, to, stop) => deps.slots.setPhase({ slotId: slot.slotId, from: "draining", to, at: at(), ...(stop !== undefined ? { stop } : {}) })
|
|
914
|
+
? to
|
|
915
|
+
: deps.slots.forModel(modelNodeId).find((s) => s.slotId === slot.slotId)?.phase ?? "draining";
|
|
916
|
+
/** The slot after the checked stop: `stopped` and `absent` drain it, `changed_owner` leaves it `live`, and
|
|
917
|
+
* `unconfirmed` keeps it `draining`, recorded with the session it stopped so the next cycle stops it again. */
|
|
918
|
+
const settle = (s, stop, snapshotId, attemptedBefore = false) => {
|
|
919
|
+
const reported = seatPoolStopReport(stop);
|
|
920
|
+
const to = reported.result === "stopped" || reported.result === "absent" ? "drained"
|
|
921
|
+
: reported.result === "changed_owner" ? "live" : "draining";
|
|
922
|
+
// A kill attempted by an earlier stop of the same session stays on record until a stop is confirmed.
|
|
923
|
+
const partial = !stop.ok && (stop.partialEffect === true || attemptedBefore) ? { partialEffect: true } : {};
|
|
924
|
+
const phase = moveTo(s.slot, to, { ...reported, ...partial, sessionId: s.sessionId, at: at() });
|
|
925
|
+
return {
|
|
926
|
+
slotNumber: s.slot.slotNumber, session: s.session, phase,
|
|
927
|
+
outcome: to === "drained" ? "drained" : to === "live" ? "left" : "draining",
|
|
928
|
+
...(snapshotId !== undefined ? { snapshotId } : {}),
|
|
929
|
+
stop: reported,
|
|
930
|
+
};
|
|
931
|
+
};
|
|
932
|
+
const stopReason = (what) => `seat pool ${job.jobId}: ${what}`;
|
|
933
|
+
const phaseNow = (slot) => deps.slots.forModel(modelNodeId).find((s) => s.slotId === slot.slotId)?.phase ?? "draining";
|
|
934
|
+
/** What holds the pool now: the job, the model and rig holds, and the current block. Null when none does. */
|
|
935
|
+
const holdsNow = () => {
|
|
936
|
+
if (!active()) {
|
|
937
|
+
held = JOB_STOPPED;
|
|
938
|
+
return "job_stopped";
|
|
939
|
+
}
|
|
940
|
+
const modelNow = seatPoolModelOfJob(deps.db, job);
|
|
941
|
+
if (!modelNow.found) {
|
|
942
|
+
held = modelNow.cause === "node_gone"
|
|
943
|
+
? { cause: "model node gone", message: "held: model node gone" }
|
|
944
|
+
: { cause: "model has no canonical session", message: "held: model has no canonical session" };
|
|
945
|
+
return "model_held";
|
|
946
|
+
}
|
|
947
|
+
const holdNow = readSeatPoolHold(deps.db, rigId);
|
|
948
|
+
if (holdNow.stoppedSeq !== null) {
|
|
949
|
+
held = { cause: "rig stopped", seq: holdNow.stoppedSeq, message: `held: rig stopped (event ${holdNow.stoppedSeq})` };
|
|
950
|
+
return "rig_stopped";
|
|
951
|
+
}
|
|
952
|
+
if (blockChangedNow())
|
|
953
|
+
return "pool_block_changed";
|
|
954
|
+
return null;
|
|
955
|
+
};
|
|
956
|
+
/** What keeps an agent from being stopped now, read again at the checked stop's final step before each effect
|
|
957
|
+
* (after its liveness probe): the job, the rig and model holds, the current block, the agent's work and activity,
|
|
958
|
+
* and, for a retry (`idleSince` null), whether the pool still has surplus. Null when the stop may go on. */
|
|
959
|
+
const keeps = (slotNumber, nodeId, idleSince) => {
|
|
960
|
+
const holding = holdsNow();
|
|
961
|
+
if (holding !== null)
|
|
962
|
+
return holding;
|
|
963
|
+
const now = readSeatPoolState(deps, model, deps.slots.forModel(modelNodeId));
|
|
964
|
+
const agent = now.agents.find((a) => a.slotNumber === slotNumber);
|
|
965
|
+
if (!agent || agent.phase !== "draining")
|
|
966
|
+
return "slot_moved_on";
|
|
967
|
+
// Work first: `running` comes from the recorded status, so false does not prove the process is gone.
|
|
968
|
+
if (agent.openRows > 0 || agent.heldCount > 0)
|
|
969
|
+
return "work_arrived";
|
|
970
|
+
// An agent positively gone keeps nothing: the stop only confirms it. Gone is its latest session `exited`, or the
|
|
971
|
+
// node's executor confirmed stopped (session missing or pane exited); an unknown or stale status keeps it.
|
|
972
|
+
if (!agent.running) {
|
|
973
|
+
return agent.latestSessionStatus === "exited" || deps.confirmedStopped(nodeId) ? null : "not_confirmed_gone";
|
|
974
|
+
}
|
|
975
|
+
if (!agent.idleAtPrompt || (idleSince !== null && woken(nodeId, idleSince)))
|
|
976
|
+
return "woken";
|
|
977
|
+
if (idleSince === null) {
|
|
978
|
+
// A stop already attempted is finished only while the pool still has surplus, the draining agents counted as
|
|
979
|
+
// serving.
|
|
980
|
+
const serving = now.agents.map((a) => (a.phase === "draining" ? { ...a, phase: "live" } : a));
|
|
981
|
+
if (planSeatPool(spec, { ...now, agents: serving }, deps.now().getTime()).surplus === 0)
|
|
982
|
+
return "no_surplus";
|
|
983
|
+
}
|
|
984
|
+
return null;
|
|
985
|
+
};
|
|
986
|
+
/** The recheck the checked stop runs, and the code it refused with (the stop itself reports `selection_changed`). */
|
|
987
|
+
const recheckOf = (slotNumber, nodeId, idleSince) => {
|
|
988
|
+
const refused = { code: null };
|
|
989
|
+
const recheck = () => {
|
|
990
|
+
const code = keeps(slotNumber, nodeId, idleSince);
|
|
991
|
+
if (code === null)
|
|
992
|
+
return null;
|
|
993
|
+
refused.code = code;
|
|
994
|
+
return { ok: false, code: "selection_changed", message: `The seat pool drain stops nothing: ${code} right before the stop.` };
|
|
995
|
+
};
|
|
996
|
+
return { refused, recheck };
|
|
997
|
+
};
|
|
998
|
+
for (const r of restops) {
|
|
999
|
+
if (!active()) {
|
|
1000
|
+
held = JOB_STOPPED;
|
|
1001
|
+
break;
|
|
1002
|
+
}
|
|
1003
|
+
const step = { slotNumber: r.slot.slotNumber, session: r.session };
|
|
1004
|
+
try {
|
|
1005
|
+
drains.push(await effects.lifecycle([r.nodeId], async () => {
|
|
1006
|
+
if (!active()) {
|
|
1007
|
+
held = JOB_STOPPED;
|
|
1008
|
+
return { ...step, phase: "draining", outcome: "draining", code: "job_stopped" };
|
|
1009
|
+
}
|
|
1010
|
+
// The block again, under the lease: one changed or unreadable while the lease was awaited ends this cycle's
|
|
1011
|
+
// effects. A kill was attempted, so the slot stays `draining` and a later cycle stops it again.
|
|
1012
|
+
if (blockChangedNow())
|
|
1013
|
+
return { ...step, phase: "draining", outcome: "draining", code: "pool_block_changed" };
|
|
1014
|
+
// The agent again, under its lifecycle lease: one that still runs and got work or is not idle is never
|
|
1015
|
+
// stopped. A kill was attempted, so it is not given back to `live` either: the slot stays `draining`, and a
|
|
1016
|
+
// later cycle stops it once it is free.
|
|
1017
|
+
const agent = readSeatPoolAgents(deps, deps.slots.forModel(modelNodeId)).find((a) => a.slotNumber === r.slot.slotNumber);
|
|
1018
|
+
if (!agent || agent.phase !== "draining")
|
|
1019
|
+
return { ...step, phase: agent?.phase ?? "draining", outcome: "skipped", code: "slot_moved_on" };
|
|
1020
|
+
if (agent.running && (agent.openRows > 0 || agent.heldCount > 0 || !agent.idleAtPrompt)) {
|
|
1021
|
+
return { ...step, phase: "draining", outcome: "draining", code: agent.openRows > 0 || agent.heldCount > 0 ? "work_arrived" : "woken" };
|
|
1022
|
+
}
|
|
1023
|
+
const { refused, recheck } = recheckOf(r.slot.slotNumber, r.nodeId, null);
|
|
1024
|
+
const stop = await effects.stopSeat({
|
|
1025
|
+
seatRef: r.session, reason: stopReason("the drain's stop was unconfirmed; stopping again"),
|
|
1026
|
+
expected: { nodeId: r.nodeId, sessionId: r.sessionId }, recheck,
|
|
1027
|
+
});
|
|
1028
|
+
// Refused at the stop's final step before any effect: the earlier attempt stays on record, and the slot stays
|
|
1029
|
+
// `draining` until a later cycle finishes it.
|
|
1030
|
+
if (refused.code !== null && !stop.ok && stop.partialEffect !== true) {
|
|
1031
|
+
return { ...step, phase: phaseNow(r.slot), outcome: "draining", code: refused.code };
|
|
1032
|
+
}
|
|
1033
|
+
return settle(r, stop, undefined, true);
|
|
1034
|
+
}));
|
|
1035
|
+
}
|
|
1036
|
+
catch (error) {
|
|
1037
|
+
// The guard refused the lease. A stop was already tried, so the slot stays `draining` until one is confirmed.
|
|
1038
|
+
if (!(error instanceof DeliveryGuardError))
|
|
1039
|
+
throw error;
|
|
1040
|
+
drains.push({ ...step, phase: "draining", outcome: "draining", code: error.code, message: error.message });
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
/** What keeps a gone agent's slot from being `drained` now, read under its lifecycle lease and again at the
|
|
1044
|
+
* checked stop's final step: the holds, its work, and whether it is still positively gone. */
|
|
1045
|
+
const keepsGone = (slotNumber, nodeId) => {
|
|
1046
|
+
const holding = holdsNow();
|
|
1047
|
+
if (holding !== null)
|
|
1048
|
+
return holding;
|
|
1049
|
+
const agent = readSeatPoolAgents(deps, deps.slots.forModel(modelNodeId)).find((a) => a.slotNumber === slotNumber);
|
|
1050
|
+
if (!agent || agent.phase !== "draining")
|
|
1051
|
+
return "slot_moved_on";
|
|
1052
|
+
if (agent.openRows > 0 || agent.heldCount > 0)
|
|
1053
|
+
return "work_arrived";
|
|
1054
|
+
if (agent.running)
|
|
1055
|
+
return "running";
|
|
1056
|
+
return agent.latestSessionStatus === "exited" || deps.confirmedStopped(nodeId) ? null : "not_confirmed_gone";
|
|
1057
|
+
};
|
|
1058
|
+
for (const g of gone) {
|
|
1059
|
+
if (held)
|
|
1060
|
+
break;
|
|
1061
|
+
if (!active()) {
|
|
1062
|
+
held = JOB_STOPPED;
|
|
1063
|
+
break;
|
|
1064
|
+
}
|
|
1065
|
+
const step = { slotNumber: g.slot.slotNumber, session: g.session };
|
|
1066
|
+
try {
|
|
1067
|
+
drains.push(await effects.lifecycle([g.nodeId], async () => {
|
|
1068
|
+
// Relaunched since the plan read it: someone's seat now, left alone.
|
|
1069
|
+
if (latestSession(deps.db, g.nodeId)?.id !== g.sessionId)
|
|
1070
|
+
return { ...step, phase: moveTo(g.slot, "live"), outcome: "left", code: "relaunched" };
|
|
1071
|
+
const before = keepsGone(g.slot.slotNumber, g.nodeId);
|
|
1072
|
+
if (before === "slot_moved_on")
|
|
1073
|
+
return { ...step, phase: phaseNow(g.slot), outcome: "skipped", code: before };
|
|
1074
|
+
if (before !== null) {
|
|
1075
|
+
return { ...step, phase: moveTo(g.slot, "live"), outcome: before === "work_arrived" ? "returned" : "left", code: before };
|
|
1076
|
+
}
|
|
1077
|
+
const refused = { code: null };
|
|
1078
|
+
const stop = await effects.stopSeat({
|
|
1079
|
+
seatRef: g.session, reason: stopReason("its session is gone; drained"),
|
|
1080
|
+
expected: { nodeId: g.nodeId, sessionId: g.sessionId },
|
|
1081
|
+
recheck: () => {
|
|
1082
|
+
const code = keepsGone(g.slot.slotNumber, g.nodeId);
|
|
1083
|
+
if (code === null)
|
|
1084
|
+
return null;
|
|
1085
|
+
refused.code = code;
|
|
1086
|
+
return { ok: false, code: "selection_changed", message: `The seat pool drain stops nothing: ${code} right before the stop.` };
|
|
1087
|
+
},
|
|
1088
|
+
});
|
|
1089
|
+
// Refused at the stop's final step before any effect: nothing was stopped, and the slot is `live` again.
|
|
1090
|
+
if (refused.code !== null && !stop.ok && stop.partialEffect !== true) {
|
|
1091
|
+
return { ...step, phase: moveTo(g.slot, "live", null), outcome: refused.code === "work_arrived" ? "returned" : "left", code: refused.code };
|
|
1092
|
+
}
|
|
1093
|
+
// A session found absent returns before the stop's final step, so its recheck never ran: the same reading
|
|
1094
|
+
// again before the slot is `drained`. Nothing was stopped, so a slot that got work meanwhile is `live` again.
|
|
1095
|
+
if (seatPoolStopReport(stop).result === "absent") {
|
|
1096
|
+
const after = keepsGone(g.slot.slotNumber, g.nodeId);
|
|
1097
|
+
if (after === "slot_moved_on")
|
|
1098
|
+
return { ...step, phase: phaseNow(g.slot), outcome: "skipped", code: after };
|
|
1099
|
+
if (after !== null) {
|
|
1100
|
+
return { ...step, phase: moveTo(g.slot, "live", null), outcome: after === "work_arrived" ? "returned" : "left", code: after };
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
return settle(g, stop);
|
|
1104
|
+
}));
|
|
1105
|
+
}
|
|
1106
|
+
catch (error) {
|
|
1107
|
+
// The guard refused the lease: nothing was stopped, and the slot is `live` again.
|
|
1108
|
+
if (!(error instanceof DeliveryGuardError))
|
|
1109
|
+
throw error;
|
|
1110
|
+
drains.push({ ...step, phase: moveTo(g.slot, "live"), outcome: "left", code: error.code, message: error.message });
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
for (const [index, t] of toDrain.entries()) {
|
|
1114
|
+
// A job stopped, or a block changed, while an earlier drain awaited: no later effect. The slots left
|
|
1115
|
+
// `draining` go back to `live` in the next cycle, with nothing stopped.
|
|
1116
|
+
if (held)
|
|
1117
|
+
break;
|
|
1118
|
+
if (!active()) {
|
|
1119
|
+
held = JOB_STOPPED;
|
|
1120
|
+
break;
|
|
1121
|
+
}
|
|
1122
|
+
if (blockChangedNow()) {
|
|
1123
|
+
for (const rest of toDrain.slice(index))
|
|
1124
|
+
drainSkipped({ slotNumber: rest.slot.slotNumber, session: rest.session, phase: "draining" }, "pool_block_changed");
|
|
1125
|
+
break;
|
|
1126
|
+
}
|
|
1127
|
+
const step = { slotNumber: t.slot.slotNumber, session: t.session };
|
|
1128
|
+
const back = (outcome, code, message) => ({ ...step, phase: moveTo(t.slot, "live"), outcome, code, ...(message !== undefined ? { message } : {}) });
|
|
1129
|
+
try {
|
|
1130
|
+
drains.push(await effects.lifecycle([t.nodeId], async () => {
|
|
1131
|
+
// The agent again, under its lifecycle lease.
|
|
1132
|
+
const agent = readSeatPoolAgents(deps, deps.slots.forModel(modelNodeId)).find((a) => a.slotNumber === t.slot.slotNumber);
|
|
1133
|
+
if (!agent || agent.phase !== "draining")
|
|
1134
|
+
return { ...step, phase: agent?.phase ?? "draining", outcome: "skipped", code: "slot_moved_on" };
|
|
1135
|
+
// Relaunched since the plan read it (or no longer running): someone's seat now, left alone.
|
|
1136
|
+
if (latestSession(deps.db, t.nodeId)?.id !== t.sessionId)
|
|
1137
|
+
return back("left", "relaunched");
|
|
1138
|
+
if (!agent.running)
|
|
1139
|
+
return back("left", "not_running");
|
|
1140
|
+
// A row or a held message reached it, or something woke it: it serves, and nothing is stopped.
|
|
1141
|
+
if (agent.openRows > 0 || agent.heldCount > 0)
|
|
1142
|
+
return back("returned", "work_arrived");
|
|
1143
|
+
if (!agent.idleAtPrompt || woken(t.nodeId, t.idleSince))
|
|
1144
|
+
return back("returned", "woken");
|
|
1145
|
+
if (!active()) {
|
|
1146
|
+
held = JOB_STOPPED;
|
|
1147
|
+
return { ...step, phase: "draining", outcome: "draining", code: "job_stopped" };
|
|
1148
|
+
}
|
|
1149
|
+
// The block again, under the lease: one changed or unreadable while the lease was awaited ends this cycle's
|
|
1150
|
+
// effects before any capture. Nothing was stopped, so the slot goes back to `live` in a later cycle.
|
|
1151
|
+
if (blockChangedNow())
|
|
1152
|
+
return { ...step, phase: "draining", outcome: "draining", code: "pool_block_changed" };
|
|
1153
|
+
// The agent's resume metadata, refreshed as `rig down` does before its snapshot. Best-effort: a refresh that
|
|
1154
|
+
// fails still captures and stops.
|
|
1155
|
+
try {
|
|
1156
|
+
await effects.refresh({ rigId, nodeId: t.nodeId, sessionId: t.sessionId });
|
|
1157
|
+
}
|
|
1158
|
+
catch {
|
|
1159
|
+
// best-effort, as in teardown
|
|
1160
|
+
}
|
|
1161
|
+
// The job, the holds and the block again after the refresh, which can take a while: one that holds the pool
|
|
1162
|
+
// now captures nothing and stops nothing. Nothing was stopped, so the slot goes back to `live` in a later cycle.
|
|
1163
|
+
const heldAfterRefresh = holdsNow();
|
|
1164
|
+
if (heldAfterRefresh !== null)
|
|
1165
|
+
return { ...step, phase: "draining", outcome: "draining", code: heldAfterRefresh };
|
|
1166
|
+
// The capture, while the agent still runs, right before the stop. A capture that fails stops nothing.
|
|
1167
|
+
let snapshotId;
|
|
1168
|
+
try {
|
|
1169
|
+
snapshotId = effects.capture(rigId).snapshotId;
|
|
1170
|
+
}
|
|
1171
|
+
catch (error) {
|
|
1172
|
+
return { ...step, phase: "draining", outcome: "draining", code: "capture_failed", message: errorMessage(error) };
|
|
1173
|
+
}
|
|
1174
|
+
// The attempt goes on record before the stop: a daemon exit after the stop took effect and before its result
|
|
1175
|
+
// is written leaves the slot `draining` with it, and the next cycle stops the recorded session again instead
|
|
1176
|
+
// of giving back to `live` an agent that no longer runs. The result below replaces it.
|
|
1177
|
+
const inFlight = { cause: "drain", result: "unconfirmed", code: "stop_in_flight", partialEffect: true, sessionId: t.sessionId, at: at() };
|
|
1178
|
+
if (!deps.slots.setPhase({ slotId: t.slot.slotId, from: "draining", to: "draining", at: at(), stop: inFlight })) {
|
|
1179
|
+
const phase = deps.slots.forModel(modelNodeId).find((s) => s.slotId === t.slot.slotId)?.phase ?? "draining";
|
|
1180
|
+
return { ...step, phase, outcome: "skipped", code: "slot_moved_on" };
|
|
1181
|
+
}
|
|
1182
|
+
const { refused, recheck } = recheckOf(t.slot.slotNumber, t.nodeId, t.idleSince);
|
|
1183
|
+
const stop = await effects.stopSeat({
|
|
1184
|
+
seatRef: t.session, reason: stopReason(`idle since ${t.idleSince}; drained`),
|
|
1185
|
+
expected: { nodeId: t.nodeId, sessionId: t.sessionId }, recheck,
|
|
1186
|
+
});
|
|
1187
|
+
// Refused at the stop's final step before any effect: nothing was stopped, and the attempt record goes. An
|
|
1188
|
+
// agent that got work or woke serves again; otherwise the slot goes back to `live` in a later cycle.
|
|
1189
|
+
if (refused.code !== null && !stop.ok && stop.partialEffect !== true) {
|
|
1190
|
+
if (refused.code === "work_arrived" || refused.code === "woken") {
|
|
1191
|
+
return { ...step, phase: moveTo(t.slot, "live", null), outcome: "returned", code: refused.code, snapshotId };
|
|
1192
|
+
}
|
|
1193
|
+
return { ...step, phase: moveTo(t.slot, "draining", null), outcome: "draining", code: refused.code, snapshotId };
|
|
1194
|
+
}
|
|
1195
|
+
return settle(t, stop, snapshotId);
|
|
1196
|
+
}));
|
|
1197
|
+
}
|
|
1198
|
+
catch (error) {
|
|
1199
|
+
// The guard refused the lease: nothing was captured or stopped, and the agent serves again.
|
|
1200
|
+
if (!(error instanceof DeliveryGuardError))
|
|
1201
|
+
throw error;
|
|
1202
|
+
drains.push(back("returned", error.code, error.message));
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
// After `pool: {}`, the block again before the job ends: one stored again (or broken) while the cycle waited for
|
|
1207
|
+
// custody, with no effect to read it, keeps the job active. Read before the notes, which report the block it finds.
|
|
1208
|
+
const ends = removed && !held && !custody && !blockChanged && !blockChangedNow()
|
|
1209
|
+
&& deps.slots.forModel(modelNodeId).every((s) => s.phase === "drained");
|
|
544
1210
|
const restore = !held && hold && hold.unfinishedRestoreSeq !== null
|
|
545
1211
|
? {
|
|
546
1212
|
seq: hold.unfinishedRestoreSeq,
|
|
@@ -548,17 +1214,27 @@ export function makeSeatPoolExecutor(deps) {
|
|
|
548
1214
|
message: `restore at event ${hold.unfinishedRestoreSeq} has no restore.completed; nothing is held without a rig.stopped`,
|
|
549
1215
|
}
|
|
550
1216
|
: undefined;
|
|
551
|
-
|
|
1217
|
+
const notes = {
|
|
552
1218
|
...base(),
|
|
1219
|
+
...(blockChanged ? {} : removal),
|
|
553
1220
|
...(held ? { held } : {}),
|
|
554
1221
|
...(advisory ? { advisory } : {}),
|
|
555
1222
|
...(restore ? { restore } : {}),
|
|
556
1223
|
...(moved.length ? { moved } : {}),
|
|
557
1224
|
...(skipped.length ? { skipped } : {}),
|
|
558
1225
|
...(failed.length ? { failed } : {}),
|
|
1226
|
+
...(drains.length ? { drains } : {}),
|
|
559
1227
|
...(addNotes && Object.keys(addNotes).length ? { add: addNotes } : {}),
|
|
560
1228
|
...(custody ? { custody } : {}),
|
|
561
|
-
}
|
|
1229
|
+
};
|
|
1230
|
+
// After `pool: {}`: the job ends once every agent is drained (busy agents stay `live` until they are free).
|
|
1231
|
+
if (ends) {
|
|
1232
|
+
// What this cycle (or an earlier one) settled goes in the last report too.
|
|
1233
|
+
const done = settled.get(modelNodeId);
|
|
1234
|
+
settled.delete(modelNodeId);
|
|
1235
|
+
return { action: "terminal", reason: "seat_pool_removed_drained", notes: done?.length ? { ...notes, settled: done } : notes };
|
|
1236
|
+
}
|
|
1237
|
+
return report(notes);
|
|
562
1238
|
},
|
|
563
1239
|
};
|
|
564
1240
|
}
|