@openrig/cli 0.7.25 → 0.7.26
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.d.cts +9 -2
- package/daemon/assets/claude-permission-policies.cjs +18 -1
- package/daemon/assets/claude-permission-policies.d.cts +1 -0
- package/daemon/assets/claude-team-permissions.cjs +22 -1
- package/daemon/assets/guidance/openrig-context-entry.md +4 -5
- package/daemon/assets/guidance/openrig-start.md +3 -0
- package/daemon/assets/plugins/openrig/.claude-plugin/plugin.json +1 -1
- package/daemon/assets/plugins/openrig/.codex-plugin/plugin.json +1 -1
- package/daemon/assets/plugins/openrig/.cursor-plugin/plugin.json +1 -1
- package/daemon/assets/plugins/openrig/README.md +5 -3
- package/daemon/assets/plugins/openrig/plugin.json +1 -1
- package/daemon/assets/plugins/openrig/skills/working-with-an-openrig-team/SKILL.md +15 -5
- package/daemon/assets/plugins/openrig-codex/.codex-plugin/plugin.json +1 -1
- package/daemon/assets/plugins/openrig-codex/skills/working-with-an-openrig-team/SKILL.md +15 -5
- 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/skills/openrig-user/SKILL.md +23 -6
- package/daemon/assets/plugins/openrig-core/skills/session-compaction-and-restore/SKILL.md +5 -2
- package/daemon/assets/skills/rigs/SKILL.md +90 -33
- package/daemon/assets/skills/rigs/references/installing-for-someone.md +1 -1
- 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 +82 -20
- package/daemon/context-packs/reference/getting-started.md +63 -11
- package/daemon/context-packs/reference/manifest.yaml +1 -1
- package/daemon/context-packs/reference/rig-spec.md +40 -14
- package/daemon/context-packs/reference/whats-new.md +102 -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/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/SKILL.md +9 -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 +15 -5
- 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 +23 -6
- 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/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/SKILL.md +5 -2
- 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.map +1 -1
- package/daemon/dist/adapters/claude-code-adapter.js +10 -4
- package/daemon/dist/adapters/claude-code-adapter.js.map +1 -1
- package/daemon/dist/adapters/claude-resume.d.ts +2 -0
- package/daemon/dist/adapters/claude-resume.d.ts.map +1 -1
- package/daemon/dist/adapters/claude-resume.js +24 -6
- package/daemon/dist/adapters/claude-resume.js.map +1 -1
- package/daemon/dist/adapters/kernel-authority.d.ts.map +1 -1
- package/daemon/dist/adapters/kernel-authority.js +3 -1
- package/daemon/dist/adapters/kernel-authority.js.map +1 -1
- package/daemon/dist/adapters/pi-runner.d.ts.map +1 -1
- package/daemon/dist/adapters/pi-runner.js +9 -0
- package/daemon/dist/adapters/pi-runner.js.map +1 -1
- package/daemon/dist/adapters/pi-session-cwd.d.ts +26 -0
- package/daemon/dist/adapters/pi-session-cwd.d.ts.map +1 -0
- package/daemon/dist/adapters/pi-session-cwd.js +89 -0
- package/daemon/dist/adapters/pi-session-cwd.js.map +1 -0
- package/daemon/dist/adapters/shell-quote.d.ts +2 -0
- package/daemon/dist/adapters/shell-quote.d.ts.map +1 -1
- package/daemon/dist/adapters/shell-quote.js +43 -0
- package/daemon/dist/adapters/shell-quote.js.map +1 -1
- package/daemon/dist/adapters/tmux-credential-env.d.ts +15 -2
- package/daemon/dist/adapters/tmux-credential-env.d.ts.map +1 -1
- package/daemon/dist/adapters/tmux-credential-env.js +82 -2
- package/daemon/dist/adapters/tmux-credential-env.js.map +1 -1
- package/daemon/dist/adapters/tmux-exec.d.ts.map +1 -1
- package/daemon/dist/adapters/tmux-exec.js +2 -6
- package/daemon/dist/adapters/tmux-exec.js.map +1 -1
- package/daemon/dist/adapters/tmux.d.ts.map +1 -1
- package/daemon/dist/adapters/tmux.js +5 -3
- package/daemon/dist/adapters/tmux.js.map +1 -1
- package/daemon/dist/bind-plan-surface.d.ts +3 -0
- package/daemon/dist/bind-plan-surface.d.ts.map +1 -0
- package/daemon/dist/bind-plan-surface.js +5 -0
- package/daemon/dist/bind-plan-surface.js.map +1 -0
- package/daemon/dist/build-info.js +3 -3
- package/daemon/dist/db/migrations/202_network_requester_questions.d.ts +4 -0
- package/daemon/dist/db/migrations/202_network_requester_questions.d.ts.map +1 -0
- package/daemon/dist/db/migrations/202_network_requester_questions.js +10 -0
- package/daemon/dist/db/migrations/202_network_requester_questions.js.map +1 -0
- package/daemon/dist/db/migrations/203_outbox_runner_receipts_index.d.ts +3 -0
- package/daemon/dist/db/migrations/203_outbox_runner_receipts_index.d.ts.map +1 -0
- package/daemon/dist/db/migrations/203_outbox_runner_receipts_index.js +22 -0
- package/daemon/dist/db/migrations/203_outbox_runner_receipts_index.js.map +1 -0
- package/daemon/dist/domain/agent-activity-store.d.ts +4 -0
- package/daemon/dist/domain/agent-activity-store.d.ts.map +1 -1
- package/daemon/dist/domain/agent-activity-store.js +16 -0
- package/daemon/dist/domain/agent-activity-store.js.map +1 -1
- package/daemon/dist/domain/agent-images/agent-image-destination.d.ts +15 -0
- package/daemon/dist/domain/agent-images/agent-image-destination.d.ts.map +1 -0
- package/daemon/dist/domain/agent-images/agent-image-destination.js +79 -0
- package/daemon/dist/domain/agent-images/agent-image-destination.js.map +1 -0
- package/daemon/dist/domain/agent-images/agent-image-library-service.d.ts.map +1 -1
- package/daemon/dist/domain/agent-images/agent-image-library-service.js +9 -1
- package/daemon/dist/domain/agent-images/agent-image-library-service.js.map +1 -1
- package/daemon/dist/domain/bootstrap-orchestrator.d.ts +4 -3
- package/daemon/dist/domain/bootstrap-orchestrator.d.ts.map +1 -1
- package/daemon/dist/domain/bootstrap-orchestrator.js +55 -11
- package/daemon/dist/domain/bootstrap-orchestrator.js.map +1 -1
- package/daemon/dist/domain/bundle-content-routing.d.ts +7 -0
- package/daemon/dist/domain/bundle-content-routing.d.ts.map +1 -1
- package/daemon/dist/domain/bundle-content-routing.js +20 -15
- package/daemon/dist/domain/bundle-content-routing.js.map +1 -1
- package/daemon/dist/domain/claude-compaction-enforcer.js +3 -3
- package/daemon/dist/domain/claude-compaction-enforcer.js.map +1 -1
- package/daemon/dist/domain/claude-continuation-launch.d.ts +19 -2
- package/daemon/dist/domain/claude-continuation-launch.d.ts.map +1 -1
- package/daemon/dist/domain/claude-continuation-launch.js +143 -3
- package/daemon/dist/domain/claude-continuation-launch.js.map +1 -1
- package/daemon/dist/domain/claude-managed-launch.d.ts +22 -5
- package/daemon/dist/domain/claude-managed-launch.d.ts.map +1 -1
- package/daemon/dist/domain/claude-managed-launch.js +41 -5
- package/daemon/dist/domain/claude-managed-launch.js.map +1 -1
- package/daemon/dist/domain/claude-permission-rules.d.ts +3 -1
- package/daemon/dist/domain/claude-permission-rules.d.ts.map +1 -1
- package/daemon/dist/domain/claude-permission-rules.js +8 -7
- package/daemon/dist/domain/claude-permission-rules.js.map +1 -1
- package/daemon/dist/domain/claude-seat-token.d.ts +23 -1
- package/daemon/dist/domain/claude-seat-token.d.ts.map +1 -1
- package/daemon/dist/domain/claude-seat-token.js +49 -7
- package/daemon/dist/domain/claude-seat-token.js.map +1 -1
- package/daemon/dist/domain/codex-auth.d.ts +34 -0
- package/daemon/dist/domain/codex-auth.d.ts.map +1 -1
- package/daemon/dist/domain/codex-auth.js +212 -0
- package/daemon/dist/domain/codex-auth.js.map +1 -1
- package/daemon/dist/domain/community-harness-launch-result.d.ts +9 -0
- package/daemon/dist/domain/community-harness-launch-result.d.ts.map +1 -1
- package/daemon/dist/domain/community-harness-launch-result.js +14 -2
- package/daemon/dist/domain/community-harness-launch-result.js.map +1 -1
- package/daemon/dist/domain/compaction-restore-notice.d.ts.map +1 -1
- package/daemon/dist/domain/compaction-restore-notice.js +4 -2
- package/daemon/dist/domain/compaction-restore-notice.js.map +1 -1
- package/daemon/dist/domain/crash-cart-detect.d.ts +7 -0
- package/daemon/dist/domain/crash-cart-detect.d.ts.map +1 -1
- package/daemon/dist/domain/crash-cart-detect.js +10 -5
- package/daemon/dist/domain/crash-cart-detect.js.map +1 -1
- package/daemon/dist/domain/crash-cart-discovery.d.ts +9 -16
- package/daemon/dist/domain/crash-cart-discovery.d.ts.map +1 -1
- package/daemon/dist/domain/crash-cart-discovery.js +22 -40
- package/daemon/dist/domain/crash-cart-discovery.js.map +1 -1
- package/daemon/dist/domain/crash-cart-emit.d.ts +1 -1
- package/daemon/dist/domain/crash-cart-emit.d.ts.map +1 -1
- package/daemon/dist/domain/crash-cart-emit.js +4 -0
- package/daemon/dist/domain/crash-cart-emit.js.map +1 -1
- package/daemon/dist/domain/cwd-resolution.d.ts +12 -1
- package/daemon/dist/domain/cwd-resolution.d.ts.map +1 -1
- package/daemon/dist/domain/cwd-resolution.js +39 -2
- package/daemon/dist/domain/cwd-resolution.js.map +1 -1
- package/daemon/dist/domain/draft-held-reoffer.d.ts +17 -1
- package/daemon/dist/domain/draft-held-reoffer.d.ts.map +1 -1
- package/daemon/dist/domain/draft-held-reoffer.js +76 -0
- package/daemon/dist/domain/draft-held-reoffer.js.map +1 -1
- package/daemon/dist/domain/gateway/destination-resolver.d.ts +4 -0
- package/daemon/dist/domain/gateway/destination-resolver.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/destination-resolver.js +9 -3
- package/daemon/dist/domain/gateway/destination-resolver.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/queue-access.js +1 -1
- package/daemon/dist/domain/gateway/slack/queue-access.js.map +1 -1
- package/daemon/dist/domain/managed-restore-read-access.d.ts +6 -2
- package/daemon/dist/domain/managed-restore-read-access.d.ts.map +1 -1
- package/daemon/dist/domain/managed-restore-read-access.js +29 -3
- package/daemon/dist/domain/managed-restore-read-access.js.map +1 -1
- package/daemon/dist/domain/mission-control/notification-adapter-from-env.d.ts +8 -0
- package/daemon/dist/domain/mission-control/notification-adapter-from-env.d.ts.map +1 -0
- package/daemon/dist/domain/mission-control/notification-adapter-from-env.js +17 -0
- package/daemon/dist/domain/mission-control/notification-adapter-from-env.js.map +1 -0
- package/daemon/dist/domain/model-divergence/codex-thread-homes.d.ts +12 -0
- package/daemon/dist/domain/model-divergence/codex-thread-homes.d.ts.map +1 -0
- package/daemon/dist/domain/model-divergence/codex-thread-homes.js +19 -0
- package/daemon/dist/domain/model-divergence/codex-thread-homes.js.map +1 -0
- package/daemon/dist/domain/network/hub-client.d.ts +14 -4
- package/daemon/dist/domain/network/hub-client.d.ts.map +1 -1
- package/daemon/dist/domain/network/hub-client.js +26 -9
- package/daemon/dist/domain/network/hub-client.js.map +1 -1
- package/daemon/dist/domain/network/network-connector.d.ts +2 -0
- package/daemon/dist/domain/network/network-connector.d.ts.map +1 -1
- package/daemon/dist/domain/network/network-connector.js +162 -16
- package/daemon/dist/domain/network/network-connector.js.map +1 -1
- package/daemon/dist/domain/network/network-requests.d.ts +4 -1
- package/daemon/dist/domain/network/network-requests.d.ts.map +1 -1
- package/daemon/dist/domain/network/network-requests.js +141 -14
- package/daemon/dist/domain/network/network-requests.js.map +1 -1
- package/daemon/dist/domain/node-inventory.d.ts.map +1 -1
- package/daemon/dist/domain/node-inventory.js +13 -0
- package/daemon/dist/domain/node-inventory.js.map +1 -1
- package/daemon/dist/domain/outbox-handler.d.ts +9 -0
- package/daemon/dist/domain/outbox-handler.d.ts.map +1 -1
- package/daemon/dist/domain/outbox-handler.js +23 -5
- package/daemon/dist/domain/outbox-handler.js.map +1 -1
- package/daemon/dist/domain/permission-account.d.ts.map +1 -1
- package/daemon/dist/domain/permission-account.js +4 -0
- package/daemon/dist/domain/permission-account.js.map +1 -1
- package/daemon/dist/domain/policies/parked-owner-consumer.d.ts.map +1 -1
- package/daemon/dist/domain/policies/parked-owner-consumer.js +6 -0
- package/daemon/dist/domain/policies/parked-owner-consumer.js.map +1 -1
- package/daemon/dist/domain/policies/seat-pool.d.ts +2 -1
- package/daemon/dist/domain/policies/seat-pool.d.ts.map +1 -1
- package/daemon/dist/domain/policies/seat-pool.js.map +1 -1
- package/daemon/dist/domain/profile-resolver.d.ts +2 -0
- package/daemon/dist/domain/profile-resolver.d.ts.map +1 -1
- package/daemon/dist/domain/profile-resolver.js +10 -4
- package/daemon/dist/domain/profile-resolver.js.map +1 -1
- package/daemon/dist/domain/provider/assignment-apply.d.ts.map +1 -1
- package/daemon/dist/domain/provider/assignment-apply.js +2 -1
- package/daemon/dist/domain/provider/assignment-apply.js.map +1 -1
- package/daemon/dist/domain/provider/claude-seat-switch.d.ts.map +1 -1
- package/daemon/dist/domain/provider/claude-seat-switch.js +11 -3
- package/daemon/dist/domain/provider/claude-seat-switch.js.map +1 -1
- package/daemon/dist/domain/provider/provider-service.d.ts +4 -3
- package/daemon/dist/domain/provider/provider-service.d.ts.map +1 -1
- package/daemon/dist/domain/queue-repository.d.ts +26 -7
- package/daemon/dist/domain/queue-repository.d.ts.map +1 -1
- package/daemon/dist/domain/queue-repository.js +159 -37
- package/daemon/dist/domain/queue-repository.js.map +1 -1
- package/daemon/dist/domain/queue-stuck-sweep.d.ts.map +1 -1
- package/daemon/dist/domain/queue-stuck-sweep.js +1826 -1821
- package/daemon/dist/domain/queue-stuck-sweep.js.map +1 -1
- package/daemon/dist/domain/queue-waiting.d.ts +9 -0
- package/daemon/dist/domain/queue-waiting.d.ts.map +1 -1
- package/daemon/dist/domain/queue-waiting.js.map +1 -1
- package/daemon/dist/domain/queue-wake-ladder.d.ts +6 -1
- package/daemon/dist/domain/queue-wake-ladder.d.ts.map +1 -1
- package/daemon/dist/domain/queue-wake-ladder.js +29 -12
- package/daemon/dist/domain/queue-wake-ladder.js.map +1 -1
- package/daemon/dist/domain/restore-orchestrator.d.ts.map +1 -1
- package/daemon/dist/domain/restore-orchestrator.js +4 -0
- package/daemon/dist/domain/restore-orchestrator.js.map +1 -1
- package/daemon/dist/domain/rigspec-exporter.d.ts +2 -0
- package/daemon/dist/domain/rigspec-exporter.d.ts.map +1 -1
- package/daemon/dist/domain/rigspec-exporter.js +38 -2
- package/daemon/dist/domain/rigspec-exporter.js.map +1 -1
- package/daemon/dist/domain/rigspec-instantiator.d.ts +4 -1
- package/daemon/dist/domain/rigspec-instantiator.d.ts.map +1 -1
- package/daemon/dist/domain/rigspec-instantiator.js +32 -13
- package/daemon/dist/domain/rigspec-instantiator.js.map +1 -1
- package/daemon/dist/domain/rigspec-preflight.d.ts +3 -0
- package/daemon/dist/domain/rigspec-preflight.d.ts.map +1 -1
- package/daemon/dist/domain/rigspec-preflight.js +25 -7
- package/daemon/dist/domain/rigspec-preflight.js.map +1 -1
- package/daemon/dist/domain/runtime-adapter.d.ts +2 -0
- package/daemon/dist/domain/runtime-adapter.d.ts.map +1 -1
- package/daemon/dist/domain/runtime-adapter.js.map +1 -1
- package/daemon/dist/domain/seat-delivery-guard.d.ts +5 -0
- package/daemon/dist/domain/seat-delivery-guard.d.ts.map +1 -1
- package/daemon/dist/domain/seat-delivery-guard.js +13 -0
- package/daemon/dist/domain/seat-delivery-guard.js.map +1 -1
- package/daemon/dist/domain/seat-lifecycle-service.d.ts +18 -0
- package/daemon/dist/domain/seat-lifecycle-service.d.ts.map +1 -1
- package/daemon/dist/domain/seat-lifecycle-service.js +28 -1
- package/daemon/dist/domain/seat-lifecycle-service.js.map +1 -1
- package/daemon/dist/domain/seat-pool-dispatch-guard.d.ts +28 -0
- package/daemon/dist/domain/seat-pool-dispatch-guard.d.ts.map +1 -0
- package/daemon/dist/domain/seat-pool-dispatch-guard.js +123 -0
- package/daemon/dist/domain/seat-pool-dispatch-guard.js.map +1 -0
- package/daemon/dist/domain/seat-pool-executor.d.ts +5 -1
- package/daemon/dist/domain/seat-pool-executor.d.ts.map +1 -1
- package/daemon/dist/domain/seat-pool-executor.js +695 -95
- package/daemon/dist/domain/seat-pool-executor.js.map +1 -1
- package/daemon/dist/domain/seat-pool-slots.d.ts +68 -3
- package/daemon/dist/domain/seat-pool-slots.d.ts.map +1 -1
- package/daemon/dist/domain/seat-pool-slots.js +60 -8
- package/daemon/dist/domain/seat-pool-slots.js.map +1 -1
- package/daemon/dist/domain/seat-pool-spec.d.ts +4 -1
- package/daemon/dist/domain/seat-pool-spec.d.ts.map +1 -1
- package/daemon/dist/domain/seat-pool-spec.js +14 -2
- package/daemon/dist/domain/seat-pool-spec.js.map +1 -1
- package/daemon/dist/domain/seat-reaper-eligibility.d.ts.map +1 -1
- package/daemon/dist/domain/seat-reaper-eligibility.js +5 -2
- package/daemon/dist/domain/seat-reaper-eligibility.js.map +1 -1
- package/daemon/dist/domain/seat-restart-in-place.d.ts +2 -3
- package/daemon/dist/domain/seat-restart-in-place.d.ts.map +1 -1
- package/daemon/dist/domain/seat-restart-in-place.js +3 -43
- package/daemon/dist/domain/seat-restart-in-place.js.map +1 -1
- package/daemon/dist/domain/seat-startup-text.d.ts +159 -0
- package/daemon/dist/domain/seat-startup-text.d.ts.map +1 -0
- package/daemon/dist/domain/seat-startup-text.js +200 -0
- package/daemon/dist/domain/seat-startup-text.js.map +1 -0
- package/daemon/dist/domain/seat-status-service.d.ts +3 -0
- package/daemon/dist/domain/seat-status-service.d.ts.map +1 -1
- package/daemon/dist/domain/seat-status-service.js +1 -0
- package/daemon/dist/domain/seat-status-service.js.map +1 -1
- package/daemon/dist/domain/startup-orchestrator.d.ts +8 -20
- package/daemon/dist/domain/startup-orchestrator.d.ts.map +1 -1
- package/daemon/dist/domain/startup-orchestrator.js +93 -26
- package/daemon/dist/domain/startup-orchestrator.js.map +1 -1
- package/daemon/dist/domain/startup-submission-evidence.d.ts +3 -1
- package/daemon/dist/domain/startup-submission-evidence.d.ts.map +1 -1
- package/daemon/dist/domain/startup-submission-evidence.js +10 -0
- package/daemon/dist/domain/startup-submission-evidence.js.map +1 -1
- package/daemon/dist/domain/terminal/earlier-tile-attach-0724.d.ts +2 -0
- package/daemon/dist/domain/terminal/earlier-tile-attach-0724.d.ts.map +1 -0
- package/daemon/dist/domain/terminal/earlier-tile-attach-0724.js +54 -0
- package/daemon/dist/domain/terminal/earlier-tile-attach-0724.js.map +1 -0
- package/daemon/dist/domain/terminal/tile-attach.d.ts +4 -4
- package/daemon/dist/domain/terminal/tile-attach.d.ts.map +1 -1
- package/daemon/dist/domain/terminal/tile-attach.js +14 -8
- package/daemon/dist/domain/terminal/tile-attach.js.map +1 -1
- package/daemon/dist/domain/types.d.ts +19 -1
- package/daemon/dist/domain/types.d.ts.map +1 -1
- package/daemon/dist/domain/types.js.map +1 -1
- package/daemon/dist/domain/user-settings/settings-store.d.ts.map +1 -1
- package/daemon/dist/domain/user-settings/settings-store.js +1 -2
- package/daemon/dist/domain/user-settings/settings-store.js.map +1 -1
- package/daemon/dist/domain/watchdog-scheduler.d.ts +4 -0
- package/daemon/dist/domain/watchdog-scheduler.d.ts.map +1 -1
- package/daemon/dist/domain/watchdog-scheduler.js +14 -0
- package/daemon/dist/domain/watchdog-scheduler.js.map +1 -1
- package/daemon/dist/domain/workspace/project-registration.d.ts +5 -1
- package/daemon/dist/domain/workspace/project-registration.d.ts.map +1 -1
- package/daemon/dist/domain/workspace/project-registration.js +11 -7
- package/daemon/dist/domain/workspace/project-registration.js.map +1 -1
- package/daemon/dist/rig-lookup-surface.d.ts +2 -0
- package/daemon/dist/rig-lookup-surface.d.ts.map +1 -0
- package/daemon/dist/rig-lookup-surface.js +5 -0
- package/daemon/dist/rig-lookup-surface.js.map +1 -0
- package/daemon/dist/routes/network.d.ts.map +1 -1
- package/daemon/dist/routes/network.js +19 -1
- package/daemon/dist/routes/network.js.map +1 -1
- package/daemon/dist/routes/queue.js +1 -1
- package/daemon/dist/routes/queue.js.map +1 -1
- package/daemon/dist/routes/rigspec.d.ts.map +1 -1
- package/daemon/dist/routes/rigspec.js +4 -0
- package/daemon/dist/routes/rigspec.js.map +1 -1
- package/daemon/dist/routes/seat.d.ts.map +1 -1
- package/daemon/dist/routes/seat.js +8 -0
- package/daemon/dist/routes/seat.js.map +1 -1
- package/daemon/dist/routes/terminal-ws.d.ts +0 -5
- package/daemon/dist/routes/terminal-ws.d.ts.map +1 -1
- package/daemon/dist/routes/terminal-ws.js +0 -6
- package/daemon/dist/routes/terminal-ws.js.map +1 -1
- package/daemon/dist/routes/transport.js +1 -1
- package/daemon/dist/routes/transport.js.map +1 -1
- package/daemon/dist/server.d.ts +1 -1
- package/daemon/dist/server.d.ts.map +1 -1
- package/daemon/dist/server.js +3 -6
- package/daemon/dist/server.js.map +1 -1
- package/daemon/dist/startup.d.ts.map +1 -1
- package/daemon/dist/startup.js +33 -35
- package/daemon/dist/startup.js.map +1 -1
- package/daemon/docs/reference/agent-startup-guide.md +18 -0
- package/daemon/docs/reference/agent-state-taxonomy.md +8 -0
- package/daemon/docs/reference/daemon-http-clients.md +4 -0
- package/daemon/docs/reference/getting-started.md +63 -11
- package/daemon/docs/reference/hosted-members.md +1 -1
- package/daemon/docs/reference/network-connector.md +66 -1
- package/daemon/docs/reference/quickstart.md +4 -4
- package/daemon/docs/reference/rig-bundle.md +25 -0
- package/daemon/docs/reference/rig-spec.md +40 -14
- package/daemon/docs/reference/seat-delivery.md +11 -2
- package/daemon/docs/reference/seat-pools.md +119 -14
- package/daemon/docs/reference/seat-scaling.md +2 -1
- package/daemon/docs/reference/whats-new.md +102 -12
- package/daemon/specs/agents/development/implementer/guidance/role.md +11 -0
- package/daemon/specs/agents/development/qa/guidance/role.md +5 -0
- package/daemon/specs/agents/shared/skills/core/cross-host-rig-commands/SKILL.md +9 -1
- package/daemon/specs/agents/shared/skills/core/working-with-an-openrig-team/SKILL.md +15 -5
- package/daemon/specs/rigs/launch/kernel/agents/operator/agent/guidance/role.md +8 -3
- package/dist/build-info.js +3 -3
- package/dist/cli-error.d.ts +2 -0
- package/dist/cli-error.d.ts.map +1 -1
- package/dist/cli-error.js +25 -8
- package/dist/cli-error.js.map +1 -1
- package/dist/client.d.ts +1 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +13 -0
- package/dist/client.js.map +1 -1
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +52 -1
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/crash-cart.d.ts.map +1 -1
- package/dist/commands/crash-cart.js +65 -17
- package/dist/commands/crash-cart.js.map +1 -1
- package/dist/commands/daemon.d.ts +7 -20
- package/dist/commands/daemon.d.ts.map +1 -1
- package/dist/commands/daemon.js +83 -50
- package/dist/commands/daemon.js.map +1 -1
- package/dist/commands/doctor.d.ts +26 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +143 -1
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +4 -2
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/network.d.ts +4 -0
- package/dist/commands/network.d.ts.map +1 -1
- package/dist/commands/network.js +78 -10
- package/dist/commands/network.js.map +1 -1
- package/dist/commands/provider.d.ts.map +1 -1
- package/dist/commands/provider.js +12 -4
- package/dist/commands/provider.js.map +1 -1
- package/dist/commands/ps.d.ts +8 -0
- package/dist/commands/ps.d.ts.map +1 -1
- package/dist/commands/ps.js +19 -3
- package/dist/commands/ps.js.map +1 -1
- package/dist/commands/queue-transfer.d.ts.map +1 -1
- package/dist/commands/queue-transfer.js +12 -6
- package/dist/commands/queue-transfer.js.map +1 -1
- package/dist/commands/queue.d.ts.map +1 -1
- package/dist/commands/queue.js +5 -4
- package/dist/commands/queue.js.map +1 -1
- package/dist/commands/seat.d.ts.map +1 -1
- package/dist/commands/seat.js +74 -6
- package/dist/commands/seat.js.map +1 -1
- package/dist/commands/setup.d.ts +34 -0
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +105 -17
- package/dist/commands/setup.js.map +1 -1
- package/dist/daemon-lifecycle.d.ts +46 -2
- package/dist/daemon-lifecycle.d.ts.map +1 -1
- package/dist/daemon-lifecycle.js +381 -174
- package/dist/daemon-lifecycle.js.map +1 -1
- package/dist/daemon-start-lock.d.ts +28 -0
- package/dist/daemon-start-lock.d.ts.map +1 -1
- package/dist/daemon-start-lock.js +107 -13
- package/dist/daemon-start-lock.js.map +1 -1
- package/dist/mcp-server.d.ts +1 -1
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/mcp-server.js +65 -1
- package/dist/mcp-server.js.map +1 -1
- package/dist/process-liveness.d.ts +21 -0
- package/dist/process-liveness.d.ts.map +1 -0
- package/dist/process-liveness.js +43 -0
- package/dist/process-liveness.js.map +1 -0
- package/dist/remote-host-ops.d.ts +1 -1
- package/dist/remote-host-ops.d.ts.map +1 -1
- package/dist/remote-host-ops.js +3 -14
- package/dist/remote-host-ops.js.map +1 -1
- package/dist/system-preflight.d.ts +9 -0
- package/dist/system-preflight.d.ts.map +1 -1
- package/dist/system-preflight.js +22 -7
- package/dist/system-preflight.js.map +1 -1
- package/package.json +4 -2
package/dist/daemon-lifecycle.js
CHANGED
|
@@ -5,6 +5,7 @@ import { DaemonClient, ForeignLocalDaemonError, connectionErrorCode, formatDaemo
|
|
|
5
5
|
import { daemonFetch, SandboxProxyError } from "./daemon-transport.js";
|
|
6
6
|
import { blockedConnectionGuidance, daemonMayAnswer, isBlockedConnectionCode } from "./daemon-reachability.js";
|
|
7
7
|
export { daemonMayAnswer } from "./daemon-reachability.js";
|
|
8
|
+
import { observeStartReservation } from "./daemon-start-lock.js";
|
|
8
9
|
import { DAEMON_START_READINESS_WAIT_MS as STARTUP_READINESS_DEADLINE_MS, DAEMON_START_PROBE_TIMEOUT_MS as STARTUP_PROBE_TIMEOUT_MS, DAEMON_STOP_WAIT_MS, DAEMON_SHUTDOWN_RECEIPT, occupiedPortGuidance } from "../daemon/dist/daemon-shutdown.js";
|
|
9
10
|
import { ConfigStore } from "./config-store.js";
|
|
10
11
|
import { OPENRIG_HOME, LEGACY_RIGGED_HOME, readOpenRigEnv, readOpenRigUrl } from "./openrig-compat.js";
|
|
@@ -92,12 +93,24 @@ export function daemonStatusGuard(status, opts) {
|
|
|
92
93
|
process.exitCode = 1;
|
|
93
94
|
return false;
|
|
94
95
|
}
|
|
96
|
+
/** #4101: the guard's stable code for a `--json` caller, one per case of {@link statusGuardMessage}. The guard stops
|
|
97
|
+
* before the command makes its request, so its outcome is always `not_delivered`. */
|
|
98
|
+
export function statusGuardCode(status) {
|
|
99
|
+
if (status.state === "stopped" || status.state === "stale")
|
|
100
|
+
return "daemon_not_running";
|
|
101
|
+
if (isBlockedConnectionCode(status.probeErrorCode))
|
|
102
|
+
return "daemon_connection_blocked";
|
|
103
|
+
if (status.startPending)
|
|
104
|
+
return "daemon_starting";
|
|
105
|
+
return "daemon_unreachable";
|
|
106
|
+
}
|
|
95
107
|
/** The guard's words for a daemon that can't answer, without failing the command: for one that goes on anyway, as
|
|
96
108
|
* `rig mcp serve` over stdio does when an app starts it before the daemon. */
|
|
97
109
|
export function printStatusGuard(status, opts) {
|
|
98
110
|
const err = statusGuardMessage(status);
|
|
99
111
|
if (opts?.json) {
|
|
100
|
-
|
|
112
|
+
// The transport errors' shape (#4101), with `message` as in every other CLI error: a script branches on `code`.
|
|
113
|
+
console.log(JSON.stringify({ ok: false, error: { code: statusGuardCode(status), outcome: "not_delivered", message: err.fact, ...err } }));
|
|
101
114
|
}
|
|
102
115
|
else {
|
|
103
116
|
console.error(`Error: ${err.fact}`);
|
|
@@ -489,10 +502,135 @@ function pickFreePort(host) {
|
|
|
489
502
|
});
|
|
490
503
|
});
|
|
491
504
|
}
|
|
505
|
+
/** #1786, #1743 — the readiness a start requires of the child it owns, within one elapsed budget: the health endpoint at
|
|
506
|
+
* the launch address names the child's PID, and so does every required listener its bind reports
|
|
507
|
+
* (verifyRequiredListeners); only listeners other than the launch endpoint may stay uncertain, for
|
|
508
|
+
* STARTUP_SECONDARY_GRACE_MS. `assertChild` throws once the child is gone or is no longer that process, `failed`
|
|
509
|
+
* rejects when it fails, and `childFailed` says it already has. The start that spawned the child and a later start
|
|
510
|
+
* that finishes it both wait for this. Throws StartupIdentityError when another process answers or the listener gate
|
|
511
|
+
* fails. */
|
|
512
|
+
async function awaitOwnedReadiness(input) {
|
|
513
|
+
const { deps, pid, port, probeHost, assertChild } = input;
|
|
514
|
+
const failed = input.failed ?? new Promise(() => { });
|
|
515
|
+
const healthzUrl = `http://${formatDaemonHostForUrl(probeHost)}:${port}/healthz`;
|
|
516
|
+
const readinessStartedAt = Date.now();
|
|
517
|
+
const deadline = readinessStartedAt + input.waitMs;
|
|
518
|
+
const remaining = () => Math.max(0, deadline - Date.now());
|
|
519
|
+
const readOwnedHealth = async (url) => {
|
|
520
|
+
assertChild();
|
|
521
|
+
// No new primary or listener fetch once the deadline has passed: a 0ms timer would still start one.
|
|
522
|
+
if (remaining() <= 0)
|
|
523
|
+
throw new HealthProbeTimeoutError(url);
|
|
524
|
+
let timer;
|
|
525
|
+
try {
|
|
526
|
+
return await Promise.race([
|
|
527
|
+
failed,
|
|
528
|
+
new Promise((_, reject) => {
|
|
529
|
+
timer = setTimeout(() => reject(new HealthProbeTimeoutError(url)), Math.min(STARTUP_PROBE_TIMEOUT_MS, remaining()));
|
|
530
|
+
}),
|
|
531
|
+
(async () => {
|
|
532
|
+
const res = await deps.fetch(url);
|
|
533
|
+
if (!res.ok)
|
|
534
|
+
return null;
|
|
535
|
+
let body;
|
|
536
|
+
try {
|
|
537
|
+
body = res.json ? await res.json() : null;
|
|
538
|
+
}
|
|
539
|
+
catch {
|
|
540
|
+
throw new StartupIdentityError(`Daemon startup identity unavailable at ${url}: expected child PID ${pid}; invalid health response`);
|
|
541
|
+
}
|
|
542
|
+
if (body?.pid !== pid) {
|
|
543
|
+
throw new StartupIdentityError(`Daemon startup identity mismatch at ${url}: expected child PID ${pid}, observed ${typeof body?.pid === "number" ? body.pid : "unknown"}; state not published`);
|
|
544
|
+
}
|
|
545
|
+
assertChild();
|
|
546
|
+
return body;
|
|
547
|
+
})(),
|
|
548
|
+
]);
|
|
549
|
+
}
|
|
550
|
+
finally {
|
|
551
|
+
if (timer)
|
|
552
|
+
clearTimeout(timer);
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
let healthy = false;
|
|
556
|
+
let verified = [];
|
|
557
|
+
let databaseWarnings = [];
|
|
558
|
+
let lastProbe = "health endpoint not responding";
|
|
559
|
+
let unverified = null;
|
|
560
|
+
let nextProgressAt = readinessStartedAt + STARTUP_PROGRESS_INTERVAL_MS;
|
|
561
|
+
// Since when only listeners other than the probed one have been uncertain, round after round.
|
|
562
|
+
let secondaryOnlySince = null;
|
|
563
|
+
while (remaining() > 0) {
|
|
564
|
+
unverified = null;
|
|
565
|
+
try {
|
|
566
|
+
const body = await readOwnedHealth(healthzUrl);
|
|
567
|
+
if (body) {
|
|
568
|
+
databaseWarnings = readDatabaseWarnings(body.databaseWarnings);
|
|
569
|
+
const bind = body.bind;
|
|
570
|
+
if (!bind || !["explicit", "default"].includes(bind.mode) || !Array.isArray(bind.hosts)
|
|
571
|
+
|| bind.hosts.length === 0 || !bind.hosts.every((host) => typeof host === "string" && host.length > 0)
|
|
572
|
+
|| typeof bind.tailscaleDetected !== "boolean") {
|
|
573
|
+
throw new StartupIdentityError(`Daemon startup listener identity unavailable for child PID ${pid}; state not published`);
|
|
574
|
+
}
|
|
575
|
+
const gate = await verifyRequiredListeners({ bind, port, probe: async (url) => {
|
|
576
|
+
try {
|
|
577
|
+
return await readOwnedHealth(url) ? "healthy" : "unhealthy";
|
|
578
|
+
}
|
|
579
|
+
catch (error) {
|
|
580
|
+
if (error instanceof StartupIdentityError || input.childFailed?.())
|
|
581
|
+
throw error;
|
|
582
|
+
const code = error.code
|
|
583
|
+
?? error.cause?.code;
|
|
584
|
+
return code === "ECONNREFUSED" ? "unhealthy" : "indeterminate";
|
|
585
|
+
}
|
|
586
|
+
} });
|
|
587
|
+
if (gate.ok === false)
|
|
588
|
+
throw new StartupIdentityError(`Daemon child ${pid} FAILED the listener adoption gate: ${gate.reason}`);
|
|
589
|
+
if (gate.ok === true) {
|
|
590
|
+
healthy = true;
|
|
591
|
+
verified = gate.verified;
|
|
592
|
+
break;
|
|
593
|
+
}
|
|
594
|
+
unverified = gate.hosts;
|
|
595
|
+
lastProbe = gate.reason;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
catch (error) {
|
|
599
|
+
assertChild();
|
|
600
|
+
if (error instanceof StartupIdentityError)
|
|
601
|
+
throw error;
|
|
602
|
+
lastProbe = error instanceof Error ? error.message : String(error);
|
|
603
|
+
}
|
|
604
|
+
// A clear answer may still come in the next few rounds; past the grace, start and say which is unverified.
|
|
605
|
+
if (unverified === null || unverified.some((host) => formatDaemonHostForUrl(host) === formatDaemonHostForUrl(probeHost)))
|
|
606
|
+
secondaryOnlySince = null;
|
|
607
|
+
else if (Date.now() - (secondaryOnlySince ??= Date.now()) >= STARTUP_SECONDARY_GRACE_MS)
|
|
608
|
+
break;
|
|
609
|
+
if (remaining() > 0 && Date.now() >= nextProgressAt) {
|
|
610
|
+
console.error(input.progress(Math.floor((Date.now() - readinessStartedAt) / 1000)));
|
|
611
|
+
nextProgressAt = Date.now() + STARTUP_PROGRESS_INTERVAL_MS;
|
|
612
|
+
}
|
|
613
|
+
await Promise.race([new Promise((resolve) => setTimeout(resolve, Math.min(HEALTHZ_DELAY_MS, remaining()))), failed]);
|
|
614
|
+
}
|
|
615
|
+
return { healthy, verified, unverified, lastProbe, databaseWarnings };
|
|
616
|
+
}
|
|
492
617
|
export async function startDaemon(opts, deps) {
|
|
493
618
|
if (!deps.acquireStartLock)
|
|
494
619
|
throw new Error("Daemon startup requires a local launch reservation");
|
|
495
|
-
|
|
620
|
+
// A start that ended pending left its child running and its reservation naming it: finish that start first.
|
|
621
|
+
const finish = await finishPendingStart(opts, deps);
|
|
622
|
+
if (typeof finish === "object")
|
|
623
|
+
return finish;
|
|
624
|
+
let lock;
|
|
625
|
+
try {
|
|
626
|
+
lock = deps.acquireStartLock();
|
|
627
|
+
}
|
|
628
|
+
catch (error) {
|
|
629
|
+
// Its reservation still refuses this start; say why this start didn't finish it.
|
|
630
|
+
if (finish && error instanceof Error)
|
|
631
|
+
throw new Error(`${error.message} ${finish}`, { cause: error });
|
|
632
|
+
throw error;
|
|
633
|
+
}
|
|
496
634
|
let preserve = false;
|
|
497
635
|
try {
|
|
498
636
|
return await startOwnedDaemon(opts, deps, lock);
|
|
@@ -554,7 +692,10 @@ async function startOwnedDaemon(opts, deps, lock) {
|
|
|
554
692
|
}
|
|
555
693
|
// WSL2 can silently drop probes to an unused port. A slow live daemon can
|
|
556
694
|
// also time out: do not run a second child's initialization against its DB.
|
|
557
|
-
|
|
695
|
+
// Only a refusal says nothing listens. Any other failure (a timeout, a listener that resets the connection, a
|
|
696
|
+
// blocked probe) gets the bind check, so a positively occupied endpoint never reaches a spawn: not even after a
|
|
697
|
+
// start reservation whose child died was reclaimed, once start's preflight let that child's port through.
|
|
698
|
+
if (!isRefusedError(error) && await deps.isPortOccupied?.(probeHost, port)) {
|
|
558
699
|
throw new Error(occupiedPortGuidance(port));
|
|
559
700
|
}
|
|
560
701
|
}
|
|
@@ -637,107 +778,14 @@ async function startOwnedDaemon(opts, deps, lock) {
|
|
|
637
778
|
throw new Error(`Daemon child ${pid} exited before startup completed`);
|
|
638
779
|
};
|
|
639
780
|
const healthzUrl = `http://${formatDaemonHostForUrl(probeHost)}:${port}/healthz`;
|
|
640
|
-
let deadline = Number.POSITIVE_INFINITY;
|
|
641
|
-
const remaining = () => Math.max(0, deadline - Date.now());
|
|
642
|
-
const readOwnedHealth = async (url) => {
|
|
643
|
-
assertChild();
|
|
644
|
-
// No new primary or listener fetch once the deadline has passed: a 0ms timer would still start one.
|
|
645
|
-
if (remaining() <= 0)
|
|
646
|
-
throw new HealthProbeTimeoutError(url);
|
|
647
|
-
let timer;
|
|
648
|
-
try {
|
|
649
|
-
return await Promise.race([
|
|
650
|
-
failed,
|
|
651
|
-
new Promise((_, reject) => {
|
|
652
|
-
timer = setTimeout(() => reject(new HealthProbeTimeoutError(url)), Math.min(STARTUP_PROBE_TIMEOUT_MS, remaining()));
|
|
653
|
-
}),
|
|
654
|
-
(async () => {
|
|
655
|
-
const res = await deps.fetch(url);
|
|
656
|
-
if (!res.ok)
|
|
657
|
-
return null;
|
|
658
|
-
let body;
|
|
659
|
-
try {
|
|
660
|
-
body = res.json ? await res.json() : null;
|
|
661
|
-
}
|
|
662
|
-
catch {
|
|
663
|
-
throw new StartupIdentityError(`Daemon startup identity unavailable at ${url}: expected child PID ${pid}; invalid health response`);
|
|
664
|
-
}
|
|
665
|
-
if (body?.pid !== pid) {
|
|
666
|
-
throw new StartupIdentityError(`Daemon startup identity mismatch at ${url}: expected child PID ${pid}, observed ${typeof body?.pid === "number" ? body.pid : "unknown"}; state not published`);
|
|
667
|
-
}
|
|
668
|
-
assertChild();
|
|
669
|
-
return body;
|
|
670
|
-
})(),
|
|
671
|
-
]);
|
|
672
|
-
}
|
|
673
|
-
finally {
|
|
674
|
-
if (timer)
|
|
675
|
-
clearTimeout(timer);
|
|
676
|
-
}
|
|
677
|
-
};
|
|
678
781
|
try {
|
|
679
782
|
assertChild();
|
|
680
|
-
lock.recordChild(pid, { startToken: deps.processStartToken?.(pid), pidNamespace: deps.pidNamespace?.(), host: probeHost, port });
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
deadline = readinessStartedAt + readinessWaitMs;
|
|
687
|
-
let nextProgressAt = readinessStartedAt + STARTUP_PROGRESS_INTERVAL_MS;
|
|
688
|
-
// Since when only listeners other than the probed one have been uncertain, round after round.
|
|
689
|
-
let secondaryOnlySince = null;
|
|
690
|
-
while (remaining() > 0) {
|
|
691
|
-
unverified = null;
|
|
692
|
-
try {
|
|
693
|
-
const body = await readOwnedHealth(healthzUrl);
|
|
694
|
-
if (body) {
|
|
695
|
-
databaseWarnings = readDatabaseWarnings(body.databaseWarnings);
|
|
696
|
-
const bind = body.bind;
|
|
697
|
-
if (!bind || !["explicit", "default"].includes(bind.mode) || !Array.isArray(bind.hosts)
|
|
698
|
-
|| bind.hosts.length === 0 || !bind.hosts.every((host) => typeof host === "string" && host.length > 0)
|
|
699
|
-
|| typeof bind.tailscaleDetected !== "boolean") {
|
|
700
|
-
throw new StartupIdentityError(`Daemon startup listener identity unavailable for child PID ${pid}; state not published`);
|
|
701
|
-
}
|
|
702
|
-
const gate = await verifyRequiredListeners({ bind, port, probe: async (url) => {
|
|
703
|
-
try {
|
|
704
|
-
return await readOwnedHealth(url) ? "healthy" : "unhealthy";
|
|
705
|
-
}
|
|
706
|
-
catch (error) {
|
|
707
|
-
if (error instanceof StartupIdentityError || childFailure)
|
|
708
|
-
throw error;
|
|
709
|
-
const code = error.code
|
|
710
|
-
?? error.cause?.code;
|
|
711
|
-
return code === "ECONNREFUSED" ? "unhealthy" : "indeterminate";
|
|
712
|
-
}
|
|
713
|
-
} });
|
|
714
|
-
if (gate.ok === false)
|
|
715
|
-
throw new StartupIdentityError(`Daemon child ${pid} FAILED the listener adoption gate: ${gate.reason}`);
|
|
716
|
-
if (gate.ok === true) {
|
|
717
|
-
healthy = true;
|
|
718
|
-
break;
|
|
719
|
-
}
|
|
720
|
-
unverified = gate.hosts;
|
|
721
|
-
lastProbe = gate.reason;
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
catch (error) {
|
|
725
|
-
assertChild();
|
|
726
|
-
if (error instanceof StartupIdentityError)
|
|
727
|
-
throw error;
|
|
728
|
-
lastProbe = error instanceof Error ? error.message : String(error);
|
|
729
|
-
}
|
|
730
|
-
// A clear answer may still come in the next few rounds; past the grace, start and say which is unverified.
|
|
731
|
-
if (unverified === null || unverified.some((host) => formatDaemonHostForUrl(host) === formatDaemonHostForUrl(probeHost)))
|
|
732
|
-
secondaryOnlySince = null;
|
|
733
|
-
else if (Date.now() - (secondaryOnlySince ??= Date.now()) >= STARTUP_SECONDARY_GRACE_MS)
|
|
734
|
-
break;
|
|
735
|
-
if (remaining() > 0 && Date.now() >= nextProgressAt) {
|
|
736
|
-
console.error(`Waiting for daemon child ${pid} readiness (${Math.floor((Date.now() - readinessStartedAt) / 1000)}s elapsed; ${readinessWaitMs / 1000}s limit). This start has not published readiness.`);
|
|
737
|
-
nextProgressAt = Date.now() + STARTUP_PROGRESS_INTERVAL_MS;
|
|
738
|
-
}
|
|
739
|
-
await Promise.race([new Promise((resolve) => setTimeout(resolve, Math.min(HEALTHZ_DELAY_MS, remaining()))), failed]);
|
|
740
|
-
}
|
|
783
|
+
lock.recordChild(pid, { startToken: deps.processStartToken?.(pid), pidNamespace: deps.pidNamespace?.(), host: probeHost, port, db });
|
|
784
|
+
const { healthy, databaseWarnings, lastProbe, unverified } = await awaitOwnedReadiness({
|
|
785
|
+
deps, pid: pid, port, probeHost, waitMs: readinessWaitMs, assertChild, failed,
|
|
786
|
+
childFailed: () => childFailure !== undefined,
|
|
787
|
+
progress: (elapsed) => `Waiting for daemon child ${pid} readiness (${elapsed}s elapsed; ${readinessWaitMs / 1000}s limit). This start has not published readiness.`,
|
|
788
|
+
});
|
|
741
789
|
// In the last round the child's own endpoint named its PID, and only another listener's check stayed
|
|
742
790
|
// uncertain: start, and say which listener is unverified.
|
|
743
791
|
const unverifiedSecondary = unverified !== null
|
|
@@ -751,7 +799,7 @@ async function startOwnedDaemon(opts, deps, lock) {
|
|
|
751
799
|
assertChild();
|
|
752
800
|
if (deps.isProcessAlive(pid)) {
|
|
753
801
|
assertChild();
|
|
754
|
-
throw new StartupChildPendingError(`Daemon startup is pending after the readiness deadline (child PID ${pid}). Readiness is not confirmed; child left running and startup reservation retained. Last probe: ${lastProbe}. Launch endpoint: ${healthzUrl}. Inspect that URL and ${LOG_FILE}; this check does not publish readiness, adopt the child or release the reservation. To restart manually, stop child PID ${pid} and wait for exit; inspect ${path.join(OPENRIG_DIR, "daemon-start.lock")}, and only after both recorded launcher and child PIDs are absent, archive it and run 'rig daemon start'. Once this launcher has exited, 'rig daemon stop' can check this child against this reservation (when its start token and pid namespace were recorded) and, if it is confirmed, stop it and release the reservation; until
|
|
802
|
+
throw new StartupChildPendingError(`Daemon startup is pending after the readiness deadline (child PID ${pid}). Readiness is not confirmed; child left running and startup reservation retained. Last probe: ${lastProbe}. Launch endpoint: ${healthzUrl}. Inspect that URL and ${LOG_FILE}; this check does not publish readiness, adopt the child or release the reservation. To restart manually, stop child PID ${pid} and wait for exit; inspect ${path.join(OPENRIG_DIR, "daemon-start.lock")}, and only after both recorded launcher and child PIDs are absent, archive it and run 'rig daemon start'. Once child PID ${pid} is ready, run 'rig daemon start' again to finish this start: it checks this child against this reservation, publishes daemon.json for it and retires the reservation, without starting another daemon. Once this launcher has exited, 'rig daemon stop' can check this child against this reservation (when its start token and pid namespace were recorded) and, if it is confirmed, stop it and release the reservation; until one of them does, another start remains blocked by it.`);
|
|
755
803
|
}
|
|
756
804
|
throw new Error(`${summarizeDaemonStartFailure(healthzUrl, deps.readFile(resolveLifecycleFile(deps, "daemon.log")))}. Last probe: ${lastProbe}`);
|
|
757
805
|
}
|
|
@@ -848,12 +896,17 @@ function sharesPidNamespace(state, deps) {
|
|
|
848
896
|
return own === state.pidNamespace;
|
|
849
897
|
return own === "host" || own === INITIAL_PID_NAMESPACE;
|
|
850
898
|
}
|
|
851
|
-
|
|
899
|
+
/** Removes daemon.json while it still names exactly `state`, or, given `restore`, writes those bytes back in its place. */
|
|
900
|
+
function removeMatchingState(deps, stateFile, state, restore) {
|
|
852
901
|
// A concurrent start/rebind must not have its state removed by an old stop/status.
|
|
853
902
|
const current = readState(deps);
|
|
854
903
|
if (current?.pid === state.pid && current.startedAt === state.startedAt && current.port === state.port
|
|
855
|
-
&& current.host === state.host && current.db === state.db)
|
|
856
|
-
|
|
904
|
+
&& current.host === state.host && current.db === state.db) {
|
|
905
|
+
if (restore === undefined)
|
|
906
|
+
deps.removeFile(stateFile);
|
|
907
|
+
else
|
|
908
|
+
deps.writeFile(stateFile, restore);
|
|
909
|
+
}
|
|
857
910
|
}
|
|
858
911
|
/** #3315 — the strict read stop acts on: exactly the launcher record and the one child record startDaemon writes,
|
|
859
912
|
* then only the retention records an earlier stop appended (#3637). */
|
|
@@ -895,6 +948,204 @@ function readStartReservation(deps, file) {
|
|
|
895
948
|
return {
|
|
896
949
|
raw, launcherPid: head.launcherPid, bootId: text(head.bootId), childPid: child.childPid,
|
|
897
950
|
startToken: text(child.startToken), pidNamespace: text(child.pidNamespace), endpoint,
|
|
951
|
+
host, port, db: text(child.db), retained: lines.length > 2,
|
|
952
|
+
};
|
|
953
|
+
}
|
|
954
|
+
/** #3315 — whether a start reservation still names its child, as stop and a finishing start both check it: the same
|
|
955
|
+
* boot, the child's pid namespace (this shell's), the launcher gone (that start can no longer publish), and the child
|
|
956
|
+
* alive with its recorded start token (a reused PID matches only within the OS start-time resolution). Returns why
|
|
957
|
+
* not, or `recheck`, which reads liveness and the token again right before acting. Userspace checks, not atomic with
|
|
958
|
+
* what follows them. */
|
|
959
|
+
function reservedChildIdentity(deps, r, liveness) {
|
|
960
|
+
const ownBoot = deps.bootId?.();
|
|
961
|
+
if (!r.bootId || !ownBoot || r.bootId !== ownBoot)
|
|
962
|
+
return { refusal: "its boot ID is not this boot's" };
|
|
963
|
+
// An unknown namespace is no evidence of the host's: the record must name one, and this shell must read the same.
|
|
964
|
+
if (!r.pidNamespace)
|
|
965
|
+
return { refusal: "it records no pid namespace for its child" };
|
|
966
|
+
const ownNamespace = deps.pidNamespace?.();
|
|
967
|
+
if (!ownNamespace)
|
|
968
|
+
return { refusal: "this shell's pid namespace is unknown" };
|
|
969
|
+
if (ownNamespace !== r.pidNamespace)
|
|
970
|
+
return { refusal: "its PIDs are numbered in another pid namespace than this shell's" };
|
|
971
|
+
const launcher = liveness(r.launcherPid);
|
|
972
|
+
if (launcher !== "dead") {
|
|
973
|
+
return { refusal: `launcher PID ${r.launcherPid} is ${launcher === "alive" ? "alive; startup may still be in progress" : "of unknown liveness"}` };
|
|
974
|
+
}
|
|
975
|
+
const recheck = (when) => {
|
|
976
|
+
const child = liveness(r.childPid);
|
|
977
|
+
if (child !== "alive")
|
|
978
|
+
return `child PID ${r.childPid} is ${child === "dead" ? "absent" : "of unknown liveness"}${when}`;
|
|
979
|
+
const token = deps.processStartToken?.(r.childPid);
|
|
980
|
+
if (token === r.startToken)
|
|
981
|
+
return undefined;
|
|
982
|
+
return token === undefined
|
|
983
|
+
? `child PID ${r.childPid} start identity is unavailable${when}`
|
|
984
|
+
: `PID ${r.childPid} is now another process than the reserved child (start ${token}, reserved ${r.startToken})${when}`;
|
|
985
|
+
};
|
|
986
|
+
const before = recheck("");
|
|
987
|
+
return before ? { refusal: before } : { recheck };
|
|
988
|
+
}
|
|
989
|
+
/** Where a daemon.json already present fails to describe the reserved launch in full, apart from its database. */
|
|
990
|
+
function descriptorMismatch(state, r) {
|
|
991
|
+
if (state.pid !== r.childPid)
|
|
992
|
+
return `daemon.json names PID ${state.pid}, not child PID ${r.childPid}`;
|
|
993
|
+
if (state.port !== r.port)
|
|
994
|
+
return `daemon.json names port ${state.port}, not the launch's port ${r.port}`;
|
|
995
|
+
if ((state.host ?? DEFAULT_HOST) !== r.host)
|
|
996
|
+
return `daemon.json names host ${state.host}, not the launch's host ${r.host}`;
|
|
997
|
+
// A start records the namespace only when it isn't "host" (an OS without pid namespaces).
|
|
998
|
+
if ((state.pidNamespace ?? "host") !== r.pidNamespace) {
|
|
999
|
+
return `daemon.json names pid namespace ${state.pidNamespace ?? "host"}, not the launch's ${r.pidNamespace}`;
|
|
1000
|
+
}
|
|
1001
|
+
if (typeof state.db !== "string" || !state.db)
|
|
1002
|
+
return "daemon.json names no database";
|
|
1003
|
+
if (typeof state.startedAt !== "string" || !Number.isFinite(Date.parse(state.startedAt)))
|
|
1004
|
+
return "daemon.json has no valid start time";
|
|
1005
|
+
return undefined;
|
|
1006
|
+
}
|
|
1007
|
+
/** A start that ended pending (StartupChildPendingError) left its child running and its reservation naming it, and only
|
|
1008
|
+
* that start could have published daemon.json. A later start finishes it: once the reservation still names that child
|
|
1009
|
+
* (reservedChildIdentity, as stop checks it) and the child passes this start's own readiness, it publishes daemon.json
|
|
1010
|
+
* for exactly that child, or keeps a daemon.json that already describes it in full, and then retires that launch's
|
|
1011
|
+
* reservation, under the claim every remover takes. The database is the one the launch recorded; an older CLI's
|
|
1012
|
+
* reservation records none, so then it is the one daemon.json names (or this start's), only while the child holds that
|
|
1013
|
+
* file open. It never spawns or signals a process, and the only file it replaces is a daemon.json whose PID is
|
|
1014
|
+
* positively gone (an earlier daemon's leftover), while its bytes are unchanged. Returns undefined when there is no such start, why it
|
|
1015
|
+
* didn't finish one (that reservation then refuses this start, as before), or what it finished. */
|
|
1016
|
+
async function finishPendingStart(opts, deps) {
|
|
1017
|
+
if (!deps.finishStartReservation)
|
|
1018
|
+
return undefined;
|
|
1019
|
+
const file = path.join(deps.homeDir ?? OPENRIG_DIR, "daemon-start.lock");
|
|
1020
|
+
const r = readStartReservation(deps, file);
|
|
1021
|
+
if (r === "absent" || r === "malformed")
|
|
1022
|
+
return undefined;
|
|
1023
|
+
const not = (why) => `This start did not finish the earlier start of child PID ${r.childPid}: ${why}. Nothing was published or retired.`;
|
|
1024
|
+
if (r.retained)
|
|
1025
|
+
return not("a 'rig daemon stop' kept it after a shutdown it couldn't verify");
|
|
1026
|
+
if (!r.startToken || !r.host || !r.port)
|
|
1027
|
+
return not("its reservation records no child identity (an older CLI's, or one whose start couldn't identify its child)");
|
|
1028
|
+
const liveness = (pid) => deps.processLiveness
|
|
1029
|
+
? deps.processLiveness(pid)
|
|
1030
|
+
: deps.isProcessAlive(pid) ? "alive" : "dead";
|
|
1031
|
+
const identity = reservedChildIdentity(deps, r, liveness);
|
|
1032
|
+
if ("refusal" in identity)
|
|
1033
|
+
return not(identity.refusal);
|
|
1034
|
+
// A daemon.json already present must describe this launch in full: someone may have published it by hand.
|
|
1035
|
+
const stateFile = resolveLifecycleFile(deps, "daemon.json");
|
|
1036
|
+
const existingRaw = deps.exists(stateFile) ? deps.readFile(stateFile) : null;
|
|
1037
|
+
if (existingRaw === null && deps.exists(stateFile))
|
|
1038
|
+
return not("daemon.json is present but unreadable");
|
|
1039
|
+
let existing;
|
|
1040
|
+
// A daemon.json naming another process that is positively gone, numbered in this shell's pid namespace, is an earlier
|
|
1041
|
+
// daemon's leftover (a crash, a kill, a power loss), not a step this launch completed: as an ordinary start does, the
|
|
1042
|
+
// finish publishes over it, and only while its bytes are still the ones read here. A live or uninspectable PID, or
|
|
1043
|
+
// one from another namespace, still declines.
|
|
1044
|
+
let leftover;
|
|
1045
|
+
if (existingRaw !== null) {
|
|
1046
|
+
try {
|
|
1047
|
+
existing = JSON.parse(existingRaw);
|
|
1048
|
+
}
|
|
1049
|
+
catch {
|
|
1050
|
+
return not("daemon.json is present but unreadable");
|
|
1051
|
+
}
|
|
1052
|
+
if (existing && typeof existing === "object" && existing.pid !== r.childPid && Number.isSafeInteger(existing.pid)
|
|
1053
|
+
&& existing.pid > 0 && liveness(existing.pid) === "dead" && sharesPidNamespace(existing, deps)) {
|
|
1054
|
+
leftover = existing;
|
|
1055
|
+
existing = undefined;
|
|
1056
|
+
}
|
|
1057
|
+
else {
|
|
1058
|
+
const mismatch = existing && typeof existing === "object" ? descriptorMismatch(existing, r) : "daemon.json is present but unreadable";
|
|
1059
|
+
if (mismatch)
|
|
1060
|
+
return not(mismatch);
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
let db = r.db;
|
|
1064
|
+
if (!db) {
|
|
1065
|
+
const candidate = existing?.db ?? opts.db ?? DEFAULT_DB;
|
|
1066
|
+
const held = deps.databaseHeldBy?.(r.childPid, candidate) ?? { failure: "which files a process holds open can't be read here" };
|
|
1067
|
+
if (held !== true) {
|
|
1068
|
+
return not(`its reservation records no database (an older CLI's), and ${held === false
|
|
1069
|
+
? `child PID ${r.childPid} does not hold ${candidate} open`
|
|
1070
|
+
: `whether child PID ${r.childPid} holds ${candidate} open couldn't be read: ${held.failure}`}`);
|
|
1071
|
+
}
|
|
1072
|
+
db = candidate;
|
|
1073
|
+
}
|
|
1074
|
+
if (existing && existing.db !== db)
|
|
1075
|
+
return not(`daemon.json names database ${existing.db}, not the launch's ${db}`);
|
|
1076
|
+
const waitMs = opts.readinessWaitSeconds !== undefined ? opts.readinessWaitSeconds * 1000 : STARTUP_READINESS_DEADLINE_MS;
|
|
1077
|
+
const endpoint = `http://${formatDaemonHostForUrl(r.host)}:${r.port}/healthz`;
|
|
1078
|
+
console.error(`An earlier start's child PID ${r.childPid} is reserved: waiting up to ${waitMs / 1000}s for its readiness at ${endpoint} to finish that start, not starting another daemon.`);
|
|
1079
|
+
let readiness;
|
|
1080
|
+
try {
|
|
1081
|
+
readiness = await awaitOwnedReadiness({
|
|
1082
|
+
deps, pid: r.childPid, port: r.port, probeHost: r.host, waitMs,
|
|
1083
|
+
assertChild: () => { const why = identity.recheck(" during the readiness check"); if (why)
|
|
1084
|
+
throw new Error(why); },
|
|
1085
|
+
progress: (elapsed) => `Waiting for daemon child ${r.childPid} of an earlier start to become ready (${elapsed}s elapsed; ${waitMs / 1000}s limit). Nothing is published yet.`,
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
1088
|
+
catch (error) {
|
|
1089
|
+
return not(error instanceof Error ? error.message : String(error));
|
|
1090
|
+
}
|
|
1091
|
+
const unverifiedSecondary = readiness.unverified !== null
|
|
1092
|
+
&& !readiness.unverified.some((host) => formatDaemonHostForUrl(host) === formatDaemonHostForUrl(r.host));
|
|
1093
|
+
if (!readiness.healthy && !unverifiedSecondary) {
|
|
1094
|
+
return not(`its readiness is not confirmed at ${endpoint} within ${waitMs / 1000}s (last probe: ${readiness.lastProbe}); child PID ${r.childPid} was left running`);
|
|
1095
|
+
}
|
|
1096
|
+
let published;
|
|
1097
|
+
const publish = () => {
|
|
1098
|
+
const why = identity.recheck(" at publication");
|
|
1099
|
+
if (why)
|
|
1100
|
+
throw new Error(why);
|
|
1101
|
+
if (existing) {
|
|
1102
|
+
if ((deps.exists(stateFile) ? deps.readFile(stateFile) : null) !== existingRaw)
|
|
1103
|
+
throw new Error("daemon.json changed while this start checked the child");
|
|
1104
|
+
published = { state: existing, publication: "already-correct" };
|
|
1105
|
+
return;
|
|
1106
|
+
}
|
|
1107
|
+
const now = deps.exists(stateFile) ? deps.readFile(stateFile) : undefined;
|
|
1108
|
+
if (leftover ? now !== existingRaw : now !== undefined) {
|
|
1109
|
+
throw new Error(leftover ? "daemon.json changed while this start checked the child" : "a daemon.json appeared while this start checked the child");
|
|
1110
|
+
}
|
|
1111
|
+
const state = {
|
|
1112
|
+
pid: r.childPid, port: r.port, host: r.host, db: db, startedAt: new Date().toISOString(),
|
|
1113
|
+
...(r.pidNamespace !== "host" ? { pidNamespace: r.pidNamespace } : {}),
|
|
1114
|
+
};
|
|
1115
|
+
try {
|
|
1116
|
+
deps.writeFile(STATE_FILE, JSON.stringify(state, null, 2));
|
|
1117
|
+
// As a start does: check the child on the other side of publication.
|
|
1118
|
+
const after = identity.recheck(" at publication");
|
|
1119
|
+
if (after)
|
|
1120
|
+
throw new Error(`${after}; startup not accepted`);
|
|
1121
|
+
}
|
|
1122
|
+
catch (error) {
|
|
1123
|
+
// Take back only what this attempt wrote: a leftover it replaced in this path goes back as it was, so nothing has
|
|
1124
|
+
// changed. One read from the legacy home was never touched, so only the attempted daemon.json is removed.
|
|
1125
|
+
removeMatchingState(deps, STATE_FILE, state, leftover && stateFile === STATE_FILE ? existingRaw : undefined);
|
|
1126
|
+
throw error;
|
|
1127
|
+
}
|
|
1128
|
+
published = { state, publication: "written" };
|
|
1129
|
+
};
|
|
1130
|
+
let retired;
|
|
1131
|
+
try {
|
|
1132
|
+
retired = deps.finishStartReservation(file, r.raw, publish);
|
|
1133
|
+
}
|
|
1134
|
+
catch (error) {
|
|
1135
|
+
return not(`its publication failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
1136
|
+
}
|
|
1137
|
+
if (!published)
|
|
1138
|
+
return not("its reservation is held by another operation, or it changed while this start checked it");
|
|
1139
|
+
for (const warning of readiness.databaseWarnings)
|
|
1140
|
+
console.error(`Warning: ${warning}`);
|
|
1141
|
+
return {
|
|
1142
|
+
...published.state,
|
|
1143
|
+
finished: {
|
|
1144
|
+
publication: published.publication,
|
|
1145
|
+
...(leftover && published.publication === "written" ? { replacedPid: leftover.pid } : {}),
|
|
1146
|
+
reservation: retired ? { retired } : { kept: `it couldn't be moved; inspect ${file}, and run 'rig daemon start' again to retire it` },
|
|
1147
|
+
readiness: readiness.healthy ? { verified: readiness.verified } : { unverified: readiness.unverified },
|
|
1148
|
+
},
|
|
898
1149
|
};
|
|
899
1150
|
}
|
|
900
1151
|
/** #3315 — with no recorded state, a start that ended pending (StartupChildPendingError) leaves its child running and
|
|
@@ -931,35 +1182,10 @@ async function stopReservedChild(deps, ctx) {
|
|
|
931
1182
|
if (new URL(ctx.target).origin !== r.endpoint) {
|
|
932
1183
|
return refuse(`its child was launched to listen at ${r.endpoint}, not at the checked ${ctx.check} (set OPENRIG_URL=${r.endpoint} to check it)`);
|
|
933
1184
|
}
|
|
934
|
-
const
|
|
935
|
-
if (
|
|
936
|
-
return refuse(
|
|
937
|
-
|
|
938
|
-
if (!r.pidNamespace)
|
|
939
|
-
return refuse("it records no pid namespace for its child");
|
|
940
|
-
const ownNamespace = deps.pidNamespace?.();
|
|
941
|
-
if (!ownNamespace)
|
|
942
|
-
return refuse("this shell's pid namespace is unknown");
|
|
943
|
-
if (ownNamespace !== r.pidNamespace)
|
|
944
|
-
return refuse("its PIDs are numbered in another pid namespace than this shell's");
|
|
945
|
-
const launcher = liveness(r.launcherPid);
|
|
946
|
-
if (launcher !== "dead") {
|
|
947
|
-
return refuse(`launcher PID ${r.launcherPid} is ${launcher === "alive" ? "alive; startup may still be in progress" : "of unknown liveness"}`);
|
|
948
|
-
}
|
|
949
|
-
const childIdentity = (when) => {
|
|
950
|
-
const child = liveness(r.childPid);
|
|
951
|
-
if (child !== "alive")
|
|
952
|
-
return `child PID ${r.childPid} is ${child === "dead" ? "absent" : "of unknown liveness"}${when}`;
|
|
953
|
-
const token = deps.processStartToken?.(r.childPid);
|
|
954
|
-
if (token === r.startToken)
|
|
955
|
-
return undefined;
|
|
956
|
-
return token === undefined
|
|
957
|
-
? `child PID ${r.childPid} start identity is unavailable${when}`
|
|
958
|
-
: `PID ${r.childPid} is now another process than the reserved child (start ${token}, reserved ${r.startToken})${when}`;
|
|
959
|
-
};
|
|
960
|
-
const before = childIdentity("");
|
|
961
|
-
if (before)
|
|
962
|
-
return refuse(before);
|
|
1185
|
+
const identity = reservedChildIdentity(deps, r, liveness);
|
|
1186
|
+
if ("refusal" in identity)
|
|
1187
|
+
return refuse(identity.refusal);
|
|
1188
|
+
const childIdentity = identity.recheck;
|
|
963
1189
|
// The whole identity read is bounded, the body included: an answer with no readable PID in time is no identity.
|
|
964
1190
|
// At the deadline this check's own request and body are aborted, so nothing it opened outlives the decision.
|
|
965
1191
|
const probe = new AbortController();
|
|
@@ -1015,7 +1241,9 @@ async function stopReservedChild(deps, ctx) {
|
|
|
1015
1241
|
if ("written" in mark)
|
|
1016
1242
|
current = mark.written;
|
|
1017
1243
|
else {
|
|
1018
|
-
// A claim that is not this stop's may be a removal in progress, which only follows a dead child
|
|
1244
|
+
// A claim that is not this stop's may be a removal in progress, which only follows a dead child, or a start finishing
|
|
1245
|
+
// this launch, whose child is alive and which holds it for its publication only. Either way the stop checks the
|
|
1246
|
+
// child again and goes on: a person asked for it, and a claim an interrupted operation left must not block every stop.
|
|
1019
1247
|
const again = childIdentity(" after the stopping mark");
|
|
1020
1248
|
if (again) {
|
|
1021
1249
|
mark.release?.();
|
|
@@ -1309,44 +1537,23 @@ function findSiblingHome(deps) {
|
|
|
1309
1537
|
/** T2 — read-only: the live launcher (else child) PID named by a start reservation, or undefined
|
|
1310
1538
|
* when there is no reservation, it is unreadable, or every PID it names is dead. */
|
|
1311
1539
|
function liveStartReservation(deps) {
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
if (typeof rec.startedAt === "string")
|
|
1330
|
-
since = rec.startedAt;
|
|
1331
|
-
}
|
|
1332
|
-
catch {
|
|
1333
|
-
// partial line: keep whatever parsed
|
|
1334
|
-
}
|
|
1335
|
-
}
|
|
1336
|
-
for (const pid of [launcherPid, childPid]) {
|
|
1337
|
-
if (pid === undefined)
|
|
1338
|
-
continue;
|
|
1339
|
-
const liveness = deps.processLiveness
|
|
1340
|
-
? deps.processLiveness(pid)
|
|
1341
|
-
: deps.isProcessAlive(pid) ? "alive" : "dead";
|
|
1342
|
-
if (liveness !== "dead")
|
|
1343
|
-
return { pid, ...(since ? { since } : {}) };
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
catch {
|
|
1347
|
-
// best-effort only: a status read must never fail on the reservation
|
|
1348
|
-
}
|
|
1349
|
-
return undefined;
|
|
1540
|
+
const reservation = pendingStartEndpoint(deps);
|
|
1541
|
+
return reservation && { pid: reservation.pid, ...(reservation.since ? { since: reservation.since } : {}) };
|
|
1542
|
+
}
|
|
1543
|
+
/** The same read, with the endpoint the reservation's child was launched at: start's preflight lets that child hold
|
|
1544
|
+
* that port, since the start then checks it against the reservation before anything else. */
|
|
1545
|
+
export function pendingStartEndpoint(deps) {
|
|
1546
|
+
const reservation = observeStartReservation({
|
|
1547
|
+
home: deps.homeDir ?? OPENRIG_DIR,
|
|
1548
|
+
bootId: deps.bootId?.(),
|
|
1549
|
+
readFile: (file) => deps.exists(file) ? deps.readFile(file) : null,
|
|
1550
|
+
processLiveness: (pid) => deps.processLiveness
|
|
1551
|
+
? deps.processLiveness(pid) : deps.isProcessAlive(pid) ? "alive" : "dead",
|
|
1552
|
+
});
|
|
1553
|
+
if (!reservation || reservation.liveness === "dead" || reservation.pid === undefined)
|
|
1554
|
+
return undefined;
|
|
1555
|
+
return { pid: reservation.pid, ...(reservation.since ? { since: reservation.since } : {}),
|
|
1556
|
+
...(reservation.host ? { host: reservation.host } : {}), ...(reservation.port ? { port: reservation.port } : {}) };
|
|
1350
1557
|
}
|
|
1351
1558
|
export async function getDaemonStatus(deps, options = {}) {
|
|
1352
1559
|
// If OPENRIG_URL is set, bypass daemon.json and probe that URL directly. Commands reach
|