@openrig/cli 0.7.10 → 0.7.11
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 +5 -5
- package/daemon/assets/claude-permission-policies.cjs +41 -0
- package/daemon/assets/claude-permission-policies.d.cts +3 -0
- package/daemon/assets/claude-team-permissions.cjs +13 -3
- package/daemon/assets/openshell/README.md +1 -1
- package/daemon/assets/pi-account-lock.cjs +39 -0
- package/daemon/assets/plugins/openrig/.claude-plugin/marketplace.json +15 -0
- package/daemon/assets/plugins/openrig/.claude-plugin/plugin.json +32 -0
- package/daemon/assets/plugins/openrig/.codex-plugin/plugin.json +39 -0
- package/daemon/assets/plugins/openrig/.cursor-plugin/plugin.json +6 -0
- package/daemon/assets/plugins/openrig/LICENSE +200 -0
- package/daemon/assets/plugins/openrig/README.md +106 -0
- package/daemon/assets/plugins/openrig/assets/logo.svg +1 -0
- package/daemon/assets/plugins/openrig/mcp.json +10 -0
- package/daemon/assets/plugins/openrig/plugin.json +14 -0
- package/daemon/assets/plugins/openrig/skills/working-with-an-openrig-team/SKILL.md +90 -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/hooks/scripts/activity-relay.cjs +20 -0
- package/daemon/assets/plugins/openrig-core/hooks/scripts/refocus.cjs +7 -0
- package/daemon/assets/plugins/openrig-core/skills/openrig-skills/SKILL.md +1 -0
- package/daemon/assets/plugins/openrig-core/skills/openrig-user/SKILL.md +24 -8
- package/daemon/assets/plugins/openrig-core/skills/refocusing/SKILL.md +5 -0
- package/daemon/assets/plugins/openrig-core/skills/refocusing/scripts/trace-to-root.py +26 -4
- 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 +72 -9
- package/daemon/context-packs/reference/acp-agents.md +68 -0
- package/daemon/context-packs/reference/getting-started.md +3 -2
- package/daemon/context-packs/reference/manifest.yaml +4 -1
- package/daemon/context-packs/reference/rig-spec.md +63 -6
- package/daemon/context-packs/reference/tmux-servers.md +214 -0
- package/daemon/context-packs/reference/whats-new.md +271 -21
- 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 +7 -0
- 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/SKILL.md +1 -0
- 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 +90 -0
- package/daemon/context-packs/skills/core/working-with-an-openrig-team/manifest.yaml +10 -0
- 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 +24 -8
- 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/SKILL.md +5 -0
- package/daemon/context-packs/skills/refocusing/manifest.yaml +1 -1
- package/daemon/context-packs/skills/refocusing/scripts/trace-to-root.py +26 -4
- 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 +3 -1
- package/daemon/dist/adapters/claude-code-adapter.d.ts.map +1 -1
- package/daemon/dist/adapters/claude-code-adapter.js +41 -12
- package/daemon/dist/adapters/claude-code-adapter.js.map +1 -1
- package/daemon/dist/adapters/claude-resume.d.ts +1 -1
- package/daemon/dist/adapters/claude-resume.d.ts.map +1 -1
- package/daemon/dist/adapters/claude-resume.js +17 -3
- package/daemon/dist/adapters/claude-resume.js.map +1 -1
- package/daemon/dist/adapters/codex-resume.d.ts +1 -1
- package/daemon/dist/adapters/codex-resume.d.ts.map +1 -1
- package/daemon/dist/adapters/codex-resume.js +6 -2
- package/daemon/dist/adapters/codex-resume.js.map +1 -1
- package/daemon/dist/adapters/codex-runtime-adapter.d.ts +2 -0
- package/daemon/dist/adapters/codex-runtime-adapter.d.ts.map +1 -1
- package/daemon/dist/adapters/codex-runtime-adapter.js +36 -11
- package/daemon/dist/adapters/codex-runtime-adapter.js.map +1 -1
- package/daemon/dist/adapters/kernel-authority.d.ts +2 -4
- package/daemon/dist/adapters/kernel-authority.d.ts.map +1 -1
- package/daemon/dist/adapters/kernel-authority.js +10 -41
- package/daemon/dist/adapters/kernel-authority.js.map +1 -1
- package/daemon/dist/adapters/openshell-podman-observer.d.ts.map +1 -1
- package/daemon/dist/adapters/openshell-podman-observer.js +5 -3
- package/daemon/dist/adapters/openshell-podman-observer.js.map +1 -1
- package/daemon/dist/adapters/pi-resume.d.ts +4 -1
- package/daemon/dist/adapters/pi-resume.d.ts.map +1 -1
- package/daemon/dist/adapters/pi-resume.js +38 -9
- package/daemon/dist/adapters/pi-resume.js.map +1 -1
- package/daemon/dist/adapters/pi-runner-protocol.d.ts +4 -0
- package/daemon/dist/adapters/pi-runner-protocol.d.ts.map +1 -1
- package/daemon/dist/adapters/pi-runner-protocol.js +7 -0
- package/daemon/dist/adapters/pi-runner-protocol.js.map +1 -1
- package/daemon/dist/adapters/pi-runner.d.ts +5 -0
- package/daemon/dist/adapters/pi-runner.d.ts.map +1 -1
- package/daemon/dist/adapters/pi-runner.js +79 -8
- package/daemon/dist/adapters/pi-runner.js.map +1 -1
- package/daemon/dist/adapters/pi-runtime-adapter.d.ts +6 -0
- package/daemon/dist/adapters/pi-runtime-adapter.d.ts.map +1 -1
- package/daemon/dist/adapters/pi-runtime-adapter.js +58 -23
- package/daemon/dist/adapters/pi-runtime-adapter.js.map +1 -1
- package/daemon/dist/adapters/tmux-control.d.ts +32 -1
- package/daemon/dist/adapters/tmux-control.d.ts.map +1 -1
- package/daemon/dist/adapters/tmux-control.js +149 -9
- package/daemon/dist/adapters/tmux-control.js.map +1 -1
- package/daemon/dist/adapters/tmux-server.d.ts +9 -0
- package/daemon/dist/adapters/tmux-server.d.ts.map +1 -1
- package/daemon/dist/adapters/tmux-server.js +12 -0
- package/daemon/dist/adapters/tmux-server.js.map +1 -1
- package/daemon/dist/adapters/tmux.d.ts +18 -0
- package/daemon/dist/adapters/tmux.d.ts.map +1 -1
- package/daemon/dist/adapters/tmux.js +164 -12
- package/daemon/dist/adapters/tmux.js.map +1 -1
- package/daemon/dist/build-info.js +3 -3
- package/daemon/dist/db/all-migrations.d.ts.map +1 -1
- package/daemon/dist/db/all-migrations.js +10 -0
- package/daemon/dist/db/all-migrations.js.map +1 -1
- package/daemon/dist/db/migrations/150_node_launch_wrapper.d.ts +3 -0
- package/daemon/dist/db/migrations/150_node_launch_wrapper.d.ts.map +1 -0
- package/daemon/dist/db/migrations/150_node_launch_wrapper.js +5 -0
- package/daemon/dist/db/migrations/150_node_launch_wrapper.js.map +1 -0
- package/daemon/dist/db/migrations/151_pi_account_switches.d.ts +4 -0
- package/daemon/dist/db/migrations/151_pi_account_switches.d.ts.map +1 -0
- package/daemon/dist/db/migrations/151_pi_account_switches.js +44 -0
- package/daemon/dist/db/migrations/151_pi_account_switches.js.map +1 -0
- package/daemon/dist/db/migrations/152_workflow_instance_spec.d.ts +8 -0
- package/daemon/dist/db/migrations/152_workflow_instance_spec.d.ts.map +1 -0
- package/daemon/dist/db/migrations/152_workflow_instance_spec.js +13 -0
- package/daemon/dist/db/migrations/152_workflow_instance_spec.js.map +1 -0
- package/daemon/dist/db/migrations/153_events_retention_marks.d.ts +7 -0
- package/daemon/dist/db/migrations/153_events_retention_marks.d.ts.map +1 -0
- package/daemon/dist/db/migrations/153_events_retention_marks.js +17 -0
- package/daemon/dist/db/migrations/153_events_retention_marks.js.map +1 -0
- package/daemon/dist/db/migrations/154_workflow_instance_root_objective.d.ts +7 -0
- package/daemon/dist/db/migrations/154_workflow_instance_root_objective.d.ts.map +1 -0
- package/daemon/dist/db/migrations/154_workflow_instance_root_objective.js +11 -0
- package/daemon/dist/db/migrations/154_workflow_instance_root_objective.js.map +1 -0
- package/daemon/dist/domain/activity-taxonomy.d.ts +9 -0
- package/daemon/dist/domain/activity-taxonomy.d.ts.map +1 -1
- package/daemon/dist/domain/activity-taxonomy.js.map +1 -1
- package/daemon/dist/domain/agent-manifest.d.ts.map +1 -1
- package/daemon/dist/domain/agent-manifest.js +11 -1
- package/daemon/dist/domain/agent-manifest.js.map +1 -1
- package/daemon/dist/domain/claude-compaction-enforcer.d.ts +43 -3
- package/daemon/dist/domain/claude-compaction-enforcer.d.ts.map +1 -1
- package/daemon/dist/domain/claude-compaction-enforcer.js +306 -22
- package/daemon/dist/domain/claude-compaction-enforcer.js.map +1 -1
- package/daemon/dist/domain/claude-managed-launch.d.ts +2 -0
- package/daemon/dist/domain/claude-managed-launch.d.ts.map +1 -1
- package/daemon/dist/domain/claude-managed-launch.js +12 -2
- package/daemon/dist/domain/claude-managed-launch.js.map +1 -1
- package/daemon/dist/domain/context-monitor.d.ts.map +1 -1
- package/daemon/dist/domain/context-monitor.js +3 -0
- package/daemon/dist/domain/context-monitor.js.map +1 -1
- package/daemon/dist/domain/context-usage-store.d.ts.map +1 -1
- package/daemon/dist/domain/context-usage-store.js +10 -1
- package/daemon/dist/domain/context-usage-store.js.map +1 -1
- package/daemon/dist/domain/desired-claude-activity-hooks.d.ts +4 -3
- package/daemon/dist/domain/desired-claude-activity-hooks.d.ts.map +1 -1
- package/daemon/dist/domain/desired-claude-activity-hooks.js +49 -15
- package/daemon/dist/domain/desired-claude-activity-hooks.js.map +1 -1
- package/daemon/dist/domain/draft-aware-delivery.d.ts.map +1 -1
- package/daemon/dist/domain/draft-aware-delivery.js +5 -1
- package/daemon/dist/domain/draft-aware-delivery.js.map +1 -1
- package/daemon/dist/domain/event-bus.d.ts +31 -0
- package/daemon/dist/domain/event-bus.d.ts.map +1 -1
- package/daemon/dist/domain/event-bus.js +87 -1
- package/daemon/dist/domain/event-bus.js.map +1 -1
- package/daemon/dist/domain/execution-view.d.ts +9 -0
- package/daemon/dist/domain/execution-view.d.ts.map +1 -1
- package/daemon/dist/domain/execution-view.js +13 -0
- package/daemon/dist/domain/execution-view.js.map +1 -1
- package/daemon/dist/domain/gateway/connections-projection.d.ts +13 -1
- package/daemon/dist/domain/gateway/connections-projection.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/connections-projection.js +38 -10
- package/daemon/dist/domain/gateway/connections-projection.js.map +1 -1
- package/daemon/dist/domain/gateway/dispatcher.d.ts +2 -0
- package/daemon/dist/domain/gateway/dispatcher.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/dispatcher.js +14 -1
- package/daemon/dist/domain/gateway/dispatcher.js.map +1 -1
- package/daemon/dist/domain/gateway/gateway-subsystem.d.ts +2 -0
- package/daemon/dist/domain/gateway/gateway-subsystem.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/gateway-subsystem.js +1 -0
- package/daemon/dist/domain/gateway/gateway-subsystem.js.map +1 -1
- package/daemon/dist/domain/gateway/human-readiness.d.ts +7 -0
- package/daemon/dist/domain/gateway/human-readiness.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/human-readiness.js +45 -0
- package/daemon/dist/domain/gateway/human-readiness.js.map +1 -1
- package/daemon/dist/domain/gateway/human-registry.d.ts +23 -3
- package/daemon/dist/domain/gateway/human-registry.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/human-registry.js +66 -34
- package/daemon/dist/domain/gateway/human-registry.js.map +1 -1
- package/daemon/dist/domain/gateway/operator-delivery-engine.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/operator-delivery-engine.js +8 -2
- package/daemon/dist/domain/gateway/operator-delivery-engine.js.map +1 -1
- package/daemon/dist/domain/gateway/relay-config.d.ts +80 -0
- package/daemon/dist/domain/gateway/relay-config.d.ts.map +1 -0
- package/daemon/dist/domain/gateway/relay-config.js +290 -0
- package/daemon/dist/domain/gateway/relay-config.js.map +1 -0
- package/daemon/dist/domain/gateway/relay-inbound.d.ts +74 -0
- package/daemon/dist/domain/gateway/relay-inbound.d.ts.map +1 -0
- package/daemon/dist/domain/gateway/relay-inbound.js +739 -0
- package/daemon/dist/domain/gateway/relay-inbound.js.map +1 -0
- package/daemon/dist/domain/gateway/relay-outbound.d.ts +215 -0
- package/daemon/dist/domain/gateway/relay-outbound.d.ts.map +1 -0
- package/daemon/dist/domain/gateway/relay-outbound.js +770 -0
- package/daemon/dist/domain/gateway/relay-outbound.js.map +1 -0
- package/daemon/dist/domain/gateway/slack/open-asks.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/open-asks.js +14 -1
- package/daemon/dist/domain/gateway/slack/open-asks.js.map +1 -1
- package/daemon/dist/domain/gateway/slack/slack-subsystem.d.ts.map +1 -1
- package/daemon/dist/domain/gateway/slack/slack-subsystem.js +224 -32
- package/daemon/dist/domain/gateway/slack/slack-subsystem.js.map +1 -1
- package/daemon/dist/domain/hosts/pairing-ask.d.ts +10 -0
- package/daemon/dist/domain/hosts/pairing-ask.d.ts.map +1 -0
- package/daemon/dist/domain/hosts/pairing-ask.js +9 -0
- package/daemon/dist/domain/hosts/pairing-ask.js.map +1 -0
- package/daemon/dist/domain/launch-wrapper.d.ts +28 -0
- package/daemon/dist/domain/launch-wrapper.d.ts.map +1 -0
- package/daemon/dist/domain/launch-wrapper.js +93 -0
- package/daemon/dist/domain/launch-wrapper.js.map +1 -0
- package/daemon/dist/domain/mission-control/mission-control-write-contract.d.ts +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 +85 -28
- package/daemon/dist/domain/mission-control/mission-control-write-contract.js.map +1 -1
- package/daemon/dist/domain/model-divergence/current-model-reader.d.ts.map +1 -1
- package/daemon/dist/domain/model-divergence/current-model-reader.js +14 -3
- package/daemon/dist/domain/model-divergence/current-model-reader.js.map +1 -1
- package/daemon/dist/domain/native-process-lineage.d.ts.map +1 -1
- package/daemon/dist/domain/native-process-lineage.js +32 -9
- package/daemon/dist/domain/native-process-lineage.js.map +1 -1
- package/daemon/dist/domain/node-inventory.d.ts.map +1 -1
- package/daemon/dist/domain/node-inventory.js +7 -0
- package/daemon/dist/domain/node-inventory.js.map +1 -1
- package/daemon/dist/domain/node-launcher.d.ts.map +1 -1
- package/daemon/dist/domain/node-launcher.js +9 -2
- package/daemon/dist/domain/node-launcher.js.map +1 -1
- package/daemon/dist/domain/outbox-handler.d.ts +53 -3
- package/daemon/dist/domain/outbox-handler.d.ts.map +1 -1
- package/daemon/dist/domain/outbox-handler.js +101 -6
- package/daemon/dist/domain/outbox-handler.js.map +1 -1
- package/daemon/dist/domain/parent-session-env.d.ts +2 -1
- package/daemon/dist/domain/parent-session-env.d.ts.map +1 -1
- package/daemon/dist/domain/parent-session-env.js +9 -1
- package/daemon/dist/domain/parent-session-env.js.map +1 -1
- package/daemon/dist/domain/parked-query.d.ts +6 -0
- package/daemon/dist/domain/parked-query.d.ts.map +1 -1
- package/daemon/dist/domain/parked-query.js +1 -0
- package/daemon/dist/domain/parked-query.js.map +1 -1
- package/daemon/dist/domain/pi-account-state.d.ts +6 -0
- package/daemon/dist/domain/pi-account-state.d.ts.map +1 -0
- package/daemon/dist/domain/pi-account-state.js +14 -0
- package/daemon/dist/domain/pi-account-state.js.map +1 -0
- package/daemon/dist/domain/policies/parked-owner-consumer.d.ts +6 -0
- package/daemon/dist/domain/policies/parked-owner-consumer.d.ts.map +1 -1
- package/daemon/dist/domain/policies/parked-owner-consumer.js +10 -1
- package/daemon/dist/domain/policies/parked-owner-consumer.js.map +1 -1
- package/daemon/dist/domain/policies/quiet-release.d.ts.map +1 -1
- package/daemon/dist/domain/policies/quiet-release.js +6 -3
- package/daemon/dist/domain/policies/quiet-release.js.map +1 -1
- package/daemon/dist/domain/projection-planner.d.ts +4 -1
- package/daemon/dist/domain/projection-planner.d.ts.map +1 -1
- package/daemon/dist/domain/projection-planner.js +3 -0
- package/daemon/dist/domain/projection-planner.js.map +1 -1
- package/daemon/dist/domain/queue-pickup.d.ts +20 -1
- package/daemon/dist/domain/queue-pickup.d.ts.map +1 -1
- package/daemon/dist/domain/queue-pickup.js +38 -6
- package/daemon/dist/domain/queue-pickup.js.map +1 -1
- package/daemon/dist/domain/queue-recovery.d.ts +14 -0
- package/daemon/dist/domain/queue-recovery.d.ts.map +1 -1
- package/daemon/dist/domain/queue-recovery.js +33 -1
- package/daemon/dist/domain/queue-recovery.js.map +1 -1
- package/daemon/dist/domain/queue-repository.d.ts +76 -10
- package/daemon/dist/domain/queue-repository.d.ts.map +1 -1
- package/daemon/dist/domain/queue-repository.js +351 -44
- package/daemon/dist/domain/queue-repository.js.map +1 -1
- package/daemon/dist/domain/queue-retention.d.ts +68 -0
- package/daemon/dist/domain/queue-retention.d.ts.map +1 -1
- package/daemon/dist/domain/queue-retention.js +133 -0
- package/daemon/dist/domain/queue-retention.js.map +1 -1
- package/daemon/dist/domain/queue-stuck-sweep.d.ts +22 -1
- package/daemon/dist/domain/queue-stuck-sweep.d.ts.map +1 -1
- package/daemon/dist/domain/queue-stuck-sweep.js +577 -158
- package/daemon/dist/domain/queue-stuck-sweep.js.map +1 -1
- package/daemon/dist/domain/queue-transition-log.d.ts +49 -1
- package/daemon/dist/domain/queue-transition-log.d.ts.map +1 -1
- package/daemon/dist/domain/queue-transition-log.js +216 -3
- package/daemon/dist/domain/queue-transition-log.js.map +1 -1
- package/daemon/dist/domain/queue-waiting.d.ts +1 -1
- package/daemon/dist/domain/queue-waiting.d.ts.map +1 -1
- package/daemon/dist/domain/queue-wake-ladder.d.ts.map +1 -1
- package/daemon/dist/domain/queue-wake-ladder.js +7 -2
- package/daemon/dist/domain/queue-wake-ladder.js.map +1 -1
- package/daemon/dist/domain/quiet-hold-custody.d.ts.map +1 -1
- package/daemon/dist/domain/quiet-hold-custody.js +7 -3
- package/daemon/dist/domain/quiet-hold-custody.js.map +1 -1
- package/daemon/dist/domain/restore-orchestrator.d.ts +13 -2
- package/daemon/dist/domain/restore-orchestrator.d.ts.map +1 -1
- package/daemon/dist/domain/restore-orchestrator.js +63 -26
- package/daemon/dist/domain/restore-orchestrator.js.map +1 -1
- package/daemon/dist/domain/rig-repository.d.ts +3 -0
- package/daemon/dist/domain/rig-repository.d.ts.map +1 -1
- package/daemon/dist/domain/rig-repository.js +46 -1
- package/daemon/dist/domain/rig-repository.js.map +1 -1
- package/daemon/dist/domain/rigspec-codec.d.ts.map +1 -1
- package/daemon/dist/domain/rigspec-codec.js +4 -0
- package/daemon/dist/domain/rigspec-codec.js.map +1 -1
- package/daemon/dist/domain/rigspec-exporter.d.ts.map +1 -1
- package/daemon/dist/domain/rigspec-exporter.js +5 -0
- package/daemon/dist/domain/rigspec-exporter.js.map +1 -1
- package/daemon/dist/domain/rigspec-instantiator.d.ts +17 -1
- package/daemon/dist/domain/rigspec-instantiator.d.ts.map +1 -1
- package/daemon/dist/domain/rigspec-instantiator.js +68 -20
- 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 +10 -0
- package/daemon/dist/domain/rigspec-preflight.js.map +1 -1
- package/daemon/dist/domain/rigspec-schema.d.ts.map +1 -1
- package/daemon/dist/domain/rigspec-schema.js +26 -1
- package/daemon/dist/domain/rigspec-schema.js.map +1 -1
- package/daemon/dist/domain/runtime-adapter.d.ts +1 -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/runtime-switch-materials.d.ts +1 -1
- package/daemon/dist/domain/runtime-switch-materials.d.ts.map +1 -1
- package/daemon/dist/domain/runtime-switch-materials.js +2 -2
- package/daemon/dist/domain/runtime-switch-materials.js.map +1 -1
- package/daemon/dist/domain/seat-activity-service.d.ts +38 -1
- package/daemon/dist/domain/seat-activity-service.d.ts.map +1 -1
- package/daemon/dist/domain/seat-activity-service.js +59 -1
- package/daemon/dist/domain/seat-activity-service.js.map +1 -1
- package/daemon/dist/domain/seat-attention-reconciler.d.ts +13 -0
- package/daemon/dist/domain/seat-attention-reconciler.d.ts.map +1 -1
- package/daemon/dist/domain/seat-attention-reconciler.js +45 -1
- package/daemon/dist/domain/seat-attention-reconciler.js.map +1 -1
- package/daemon/dist/domain/seat-handover-service.d.ts +1 -0
- package/daemon/dist/domain/seat-handover-service.d.ts.map +1 -1
- package/daemon/dist/domain/seat-handover-service.js +38 -11
- package/daemon/dist/domain/seat-handover-service.js.map +1 -1
- package/daemon/dist/domain/seat-launch-environment.d.ts +10 -0
- package/daemon/dist/domain/seat-launch-environment.d.ts.map +1 -1
- package/daemon/dist/domain/seat-launch-environment.js +62 -15
- package/daemon/dist/domain/seat-launch-environment.js.map +1 -1
- package/daemon/dist/domain/seat-lifecycle-service.d.ts.map +1 -1
- package/daemon/dist/domain/seat-lifecycle-service.js +7 -3
- package/daemon/dist/domain/seat-lifecycle-service.js.map +1 -1
- package/daemon/dist/domain/seat-restart-in-place.d.ts +2 -1
- package/daemon/dist/domain/seat-restart-in-place.d.ts.map +1 -1
- package/daemon/dist/domain/seat-restart-in-place.js +19 -1
- package/daemon/dist/domain/seat-restart-in-place.js.map +1 -1
- package/daemon/dist/domain/seat-runtime-home.d.ts +4 -1
- package/daemon/dist/domain/seat-runtime-home.d.ts.map +1 -1
- package/daemon/dist/domain/seat-runtime-home.js +6 -4
- package/daemon/dist/domain/seat-runtime-home.js.map +1 -1
- package/daemon/dist/domain/seat-runtime-switch-service.d.ts.map +1 -1
- package/daemon/dist/domain/seat-runtime-switch-service.js +73 -10
- package/daemon/dist/domain/seat-runtime-switch-service.js.map +1 -1
- package/daemon/dist/domain/seat-skill-storage.d.ts +57 -4
- package/daemon/dist/domain/seat-skill-storage.d.ts.map +1 -1
- package/daemon/dist/domain/seat-skill-storage.js +338 -8
- package/daemon/dist/domain/seat-skill-storage.js.map +1 -1
- package/daemon/dist/domain/seat-status-service.d.ts +2 -2
- package/daemon/dist/domain/seat-status-service.d.ts.map +1 -1
- package/daemon/dist/domain/seat-status-service.js +3 -2
- package/daemon/dist/domain/seat-status-service.js.map +1 -1
- package/daemon/dist/domain/self-attach-service.d.ts.map +1 -1
- package/daemon/dist/domain/self-attach-service.js +11 -4
- package/daemon/dist/domain/self-attach-service.js.map +1 -1
- package/daemon/dist/domain/session-transport.d.ts +25 -2
- package/daemon/dist/domain/session-transport.d.ts.map +1 -1
- package/daemon/dist/domain/session-transport.js +199 -30
- package/daemon/dist/domain/session-transport.js.map +1 -1
- package/daemon/dist/domain/skill-catalog.d.ts +37 -0
- package/daemon/dist/domain/skill-catalog.d.ts.map +1 -1
- package/daemon/dist/domain/skill-catalog.js +152 -3
- package/daemon/dist/domain/skill-catalog.js.map +1 -1
- package/daemon/dist/domain/slices/slice-detail-projector.d.ts +1 -1
- package/daemon/dist/domain/slices/slice-detail-projector.d.ts.map +1 -1
- package/daemon/dist/domain/slices/slice-detail-projector.js +11 -13
- package/daemon/dist/domain/slices/slice-detail-projector.js.map +1 -1
- package/daemon/dist/domain/startup-orchestrator.d.ts.map +1 -1
- package/daemon/dist/domain/startup-orchestrator.js +7 -1
- package/daemon/dist/domain/startup-orchestrator.js.map +1 -1
- package/daemon/dist/domain/successor-session-launcher.d.ts +1 -0
- package/daemon/dist/domain/successor-session-launcher.d.ts.map +1 -1
- package/daemon/dist/domain/successor-session-launcher.js +1 -0
- package/daemon/dist/domain/successor-session-launcher.js.map +1 -1
- package/daemon/dist/domain/terminal/earlier-tile-attach-0711.d.ts +2 -0
- package/daemon/dist/domain/terminal/earlier-tile-attach-0711.d.ts.map +1 -0
- package/daemon/dist/domain/terminal/earlier-tile-attach-0711.js +146 -0
- package/daemon/dist/domain/terminal/earlier-tile-attach-0711.js.map +1 -0
- package/daemon/dist/domain/terminal/earlier-tile-attach.d.ts +1 -0
- package/daemon/dist/domain/terminal/earlier-tile-attach.d.ts.map +1 -1
- package/daemon/dist/domain/terminal/earlier-tile-attach.js +42 -1
- package/daemon/dist/domain/terminal/earlier-tile-attach.js.map +1 -1
- package/daemon/dist/domain/terminal/herdr-follow-view.d.ts.map +1 -1
- package/daemon/dist/domain/terminal/herdr-follow-view.js +43 -19
- package/daemon/dist/domain/terminal/herdr-follow-view.js.map +1 -1
- package/daemon/dist/domain/terminal/herdr-viewer.d.ts +7 -4
- package/daemon/dist/domain/terminal/herdr-viewer.d.ts.map +1 -1
- package/daemon/dist/domain/terminal/herdr-viewer.js +101 -47
- package/daemon/dist/domain/terminal/herdr-viewer.js.map +1 -1
- package/daemon/dist/domain/terminal/terminal-following.js +3 -3
- package/daemon/dist/domain/terminal/terminal-following.js.map +1 -1
- package/daemon/dist/domain/terminal/terminal-service.d.ts.map +1 -1
- package/daemon/dist/domain/terminal/terminal-service.js +16 -1
- package/daemon/dist/domain/terminal/terminal-service.js.map +1 -1
- package/daemon/dist/domain/terminal/tile-attach.d.ts +6 -3
- package/daemon/dist/domain/terminal/tile-attach.d.ts.map +1 -1
- package/daemon/dist/domain/terminal/tile-attach.js +11 -46
- package/daemon/dist/domain/terminal/tile-attach.js.map +1 -1
- package/daemon/dist/domain/tmux-server-selection.d.ts.map +1 -1
- package/daemon/dist/domain/tmux-server-selection.js +8 -2
- package/daemon/dist/domain/tmux-server-selection.js.map +1 -1
- package/daemon/dist/domain/types.d.ts +18 -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 +1 -1
- package/daemon/dist/domain/user-settings/settings-store.d.ts.map +1 -1
- package/daemon/dist/domain/user-settings/settings-store.js +48 -0
- package/daemon/dist/domain/user-settings/settings-store.js.map +1 -1
- package/daemon/dist/domain/view-event-bridge.js +1 -1
- package/daemon/dist/domain/view-event-bridge.js.map +1 -1
- package/daemon/dist/domain/view-projector.d.ts +4 -1
- package/daemon/dist/domain/view-projector.d.ts.map +1 -1
- package/daemon/dist/domain/view-projector.js +9 -4
- package/daemon/dist/domain/view-projector.js.map +1 -1
- package/daemon/dist/domain/wake-recovery.d.ts.map +1 -1
- package/daemon/dist/domain/wake-recovery.js +9 -2
- package/daemon/dist/domain/wake-recovery.js.map +1 -1
- package/daemon/dist/domain/workflow-exception-escalation.d.ts +3 -2
- package/daemon/dist/domain/workflow-exception-escalation.d.ts.map +1 -1
- package/daemon/dist/domain/workflow-exception-escalation.js +1 -1
- package/daemon/dist/domain/workflow-exception-escalation.js.map +1 -1
- package/daemon/dist/domain/workflow-instance-store.d.ts +8 -1
- package/daemon/dist/domain/workflow-instance-store.d.ts.map +1 -1
- package/daemon/dist/domain/workflow-instance-store.js +21 -3
- package/daemon/dist/domain/workflow-instance-store.js.map +1 -1
- package/daemon/dist/domain/workflow-reconciliation.d.ts.map +1 -1
- package/daemon/dist/domain/workflow-reconciliation.js +2 -1
- package/daemon/dist/domain/workflow-reconciliation.js.map +1 -1
- package/daemon/dist/domain/workflow-runtime.d.ts +4 -1
- package/daemon/dist/domain/workflow-runtime.d.ts.map +1 -1
- package/daemon/dist/domain/workflow-runtime.js +20 -7
- package/daemon/dist/domain/workflow-runtime.js.map +1 -1
- package/daemon/dist/domain/workflow-spec-cache.d.ts +24 -4
- package/daemon/dist/domain/workflow-spec-cache.d.ts.map +1 -1
- package/daemon/dist/domain/workflow-spec-cache.js +87 -7
- package/daemon/dist/domain/workflow-spec-cache.js.map +1 -1
- package/daemon/dist/domain/workflow-spec-unregister.d.ts +36 -0
- package/daemon/dist/domain/workflow-spec-unregister.d.ts.map +1 -0
- package/daemon/dist/domain/workflow-spec-unregister.js +105 -0
- package/daemon/dist/domain/workflow-spec-unregister.js.map +1 -0
- package/daemon/dist/domain/workflow-types.d.ts +14 -0
- package/daemon/dist/domain/workflow-types.d.ts.map +1 -1
- package/daemon/dist/index.d.ts +2 -1
- package/daemon/dist/index.d.ts.map +1 -1
- package/daemon/dist/index.js +23 -5
- package/daemon/dist/index.js.map +1 -1
- package/daemon/dist/learned-host-bindings-surface.d.ts +2 -0
- package/daemon/dist/learned-host-bindings-surface.d.ts.map +1 -0
- package/daemon/dist/learned-host-bindings-surface.js +4 -0
- package/daemon/dist/learned-host-bindings-surface.js.map +1 -0
- package/daemon/dist/routes/activity.d.ts.map +1 -1
- package/daemon/dist/routes/activity.js +37 -2
- package/daemon/dist/routes/activity.js.map +1 -1
- package/daemon/dist/routes/adapters.d.ts.map +1 -1
- package/daemon/dist/routes/adapters.js +4 -0
- package/daemon/dist/routes/adapters.js.map +1 -1
- package/daemon/dist/routes/compaction.js +2 -0
- package/daemon/dist/routes/compaction.js.map +1 -1
- package/daemon/dist/routes/events.js +4 -0
- package/daemon/dist/routes/events.js.map +1 -1
- package/daemon/dist/routes/gateway.d.ts +3 -0
- package/daemon/dist/routes/gateway.d.ts.map +1 -1
- package/daemon/dist/routes/gateway.js +58 -8
- package/daemon/dist/routes/gateway.js.map +1 -1
- package/daemon/dist/routes/hosts.d.ts.map +1 -1
- package/daemon/dist/routes/hosts.js +298 -35
- package/daemon/dist/routes/hosts.js.map +1 -1
- package/daemon/dist/routes/queue.d.ts.map +1 -1
- package/daemon/dist/routes/queue.js +10 -3
- package/daemon/dist/routes/queue.js.map +1 -1
- package/daemon/dist/routes/seat.d.ts.map +1 -1
- package/daemon/dist/routes/seat.js +4 -3
- package/daemon/dist/routes/seat.js.map +1 -1
- package/daemon/dist/routes/terminal-ws.d.ts +1 -0
- package/daemon/dist/routes/terminal-ws.d.ts.map +1 -1
- package/daemon/dist/routes/terminal-ws.js +1 -1
- package/daemon/dist/routes/terminal-ws.js.map +1 -1
- package/daemon/dist/routes/workflow.d.ts.map +1 -1
- package/daemon/dist/routes/workflow.js +24 -0
- package/daemon/dist/routes/workflow.js.map +1 -1
- package/daemon/dist/server.d.ts +2 -0
- package/daemon/dist/server.d.ts.map +1 -1
- package/daemon/dist/server.js +7 -2
- package/daemon/dist/server.js.map +1 -1
- package/daemon/dist/startup.d.ts.map +1 -1
- package/daemon/dist/startup.js +65 -15
- package/daemon/dist/startup.js.map +1 -1
- package/daemon/dist/terminal/TerminalSessionBroker.d.ts +18 -13
- package/daemon/dist/terminal/TerminalSessionBroker.d.ts.map +1 -1
- package/daemon/dist/terminal/TerminalSessionBroker.js +113 -76
- package/daemon/dist/terminal/TerminalSessionBroker.js.map +1 -1
- package/daemon/dist/terminal/window-pin.d.ts +3 -3
- package/daemon/dist/terminal/window-pin.d.ts.map +1 -1
- package/daemon/dist/terminal/window-pin.js +2 -2
- package/daemon/dist/terminal/window-pin.js.map +1 -1
- package/daemon/docs/reference/acp-agents.md +68 -0
- package/daemon/docs/reference/agent-spec.md +53 -1
- package/daemon/docs/reference/agent-startup-guide.md +28 -0
- package/daemon/docs/reference/agent-state-taxonomy.md +7 -0
- package/daemon/docs/reference/daemon-http-clients.md +16 -7
- package/daemon/docs/reference/gateway-participants.md +4 -1
- package/daemon/docs/reference/gateway-relay.md +239 -0
- package/daemon/docs/reference/getting-started.md +3 -2
- package/daemon/docs/reference/hosted-members.md +38 -1
- package/daemon/docs/reference/project-workspace.md +4 -0
- package/daemon/docs/reference/quickstart.md +1 -1
- package/daemon/docs/reference/reconstructions.md +90 -0
- package/daemon/docs/reference/rig-spec.md +63 -6
- package/daemon/docs/reference/seat-delivery.md +20 -0
- package/daemon/docs/reference/terminal-sessions.md +88 -26
- package/daemon/docs/reference/tmux-servers.md +48 -0
- package/daemon/docs/reference/whats-new.md +271 -21
- package/daemon/specs/agents/shared/skills/core/cross-host-rig-commands/SKILL.md +7 -0
- package/daemon/specs/agents/shared/skills/core/openrig-skills/SKILL.md +1 -0
- package/daemon/specs/agents/shared/skills/core/working-with-an-openrig-team/SKILL.md +90 -0
- package/dist/acp/agent-server.d.ts +126 -0
- package/dist/acp/agent-server.d.ts.map +1 -0
- package/dist/acp/agent-server.js +449 -0
- package/dist/acp/agent-server.js.map +1 -0
- package/dist/acp/json-rpc-stdio.d.ts +24 -10
- package/dist/acp/json-rpc-stdio.d.ts.map +1 -1
- package/dist/acp/json-rpc-stdio.js +58 -36
- package/dist/acp/json-rpc-stdio.js.map +1 -1
- package/dist/bin-wrapper.d.ts.map +1 -1
- package/dist/bin-wrapper.js +3 -1
- 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 -0
- package/dist/client.js.map +1 -1
- package/dist/commands/acp.d.ts +14 -0
- package/dist/commands/acp.d.ts.map +1 -1
- package/dist/commands/acp.js +189 -2
- package/dist/commands/acp.js.map +1 -1
- package/dist/commands/attach.js +1 -1
- package/dist/commands/attach.js.map +1 -1
- package/dist/commands/capture.js +6 -6
- package/dist/commands/capture.js.map +1 -1
- package/dist/commands/compact.d.ts.map +1 -1
- package/dist/commands/compact.js +14 -2
- package/dist/commands/compact.js.map +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +35 -6
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/context-reconstruction.d.ts +5 -0
- package/dist/commands/context-reconstruction.d.ts.map +1 -0
- package/dist/commands/context-reconstruction.js +69 -0
- package/dist/commands/context-reconstruction.js.map +1 -0
- package/dist/commands/context.d.ts.map +1 -1
- package/dist/commands/context.js +2 -0
- package/dist/commands/context.js.map +1 -1
- package/dist/commands/daemon.d.ts.map +1 -1
- package/dist/commands/daemon.js +5 -2
- package/dist/commands/daemon.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +61 -0
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/gateway.d.ts.map +1 -1
- package/dist/commands/gateway.js +15 -7
- package/dist/commands/gateway.js.map +1 -1
- package/dist/commands/host.d.ts.map +1 -1
- package/dist/commands/host.js +59 -12
- package/dist/commands/host.js.map +1 -1
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +29 -5
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/provider.d.ts.map +1 -1
- package/dist/commands/provider.js +4 -1
- package/dist/commands/provider.js.map +1 -1
- package/dist/commands/ps.d.ts +2 -0
- package/dist/commands/ps.d.ts.map +1 -1
- package/dist/commands/ps.js +3 -1
- package/dist/commands/ps.js.map +1 -1
- package/dist/commands/queue.d.ts +3 -0
- package/dist/commands/queue.d.ts.map +1 -1
- package/dist/commands/queue.js +203 -67
- package/dist/commands/queue.js.map +1 -1
- package/dist/commands/seat.d.ts.map +1 -1
- package/dist/commands/seat.js +15 -3
- package/dist/commands/seat.js.map +1 -1
- package/dist/commands/stream.d.ts.map +1 -1
- package/dist/commands/stream.js +24 -1
- package/dist/commands/stream.js.map +1 -1
- package/dist/commands/terminal.js +1 -1
- package/dist/commands/workflow-render.d.ts +4 -0
- package/dist/commands/workflow-render.d.ts.map +1 -1
- package/dist/commands/workflow-render.js +7 -0
- package/dist/commands/workflow-render.js.map +1 -1
- package/dist/commands/workflow.d.ts.map +1 -1
- package/dist/commands/workflow.js +69 -1
- package/dist/commands/workflow.js.map +1 -1
- package/dist/config-store.d.ts +8 -1
- package/dist/config-store.d.ts.map +1 -1
- package/dist/config-store.js +52 -1
- package/dist/config-store.js.map +1 -1
- package/dist/daemon-lifecycle.d.ts +2 -0
- package/dist/daemon-lifecycle.d.ts.map +1 -1
- package/dist/daemon-lifecycle.js +38 -5
- package/dist/daemon-lifecycle.js.map +1 -1
- package/dist/daemon-reachability.d.ts +1 -1
- package/dist/daemon-reachability.d.ts.map +1 -1
- package/dist/daemon-reachability.js +4 -2
- package/dist/daemon-reachability.js.map +1 -1
- package/dist/lib/reconstruction-reader.d.ts +122 -0
- package/dist/lib/reconstruction-reader.d.ts.map +1 -0
- package/dist/lib/reconstruction-reader.js +481 -0
- package/dist/lib/reconstruction-reader.js.map +1 -0
- package/dist/lib/work-install.d.ts +28 -0
- package/dist/lib/work-install.d.ts.map +1 -1
- package/dist/lib/work-install.js +80 -20
- package/dist/lib/work-install.js.map +1 -1
- package/dist/mcp-http.d.ts +7 -0
- package/dist/mcp-http.d.ts.map +1 -1
- package/dist/mcp-http.js +30 -6
- package/dist/mcp-http.js.map +1 -1
- package/dist/mcp-server.d.ts +33 -3
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/mcp-server.js +443 -52
- package/dist/mcp-server.js.map +1 -1
- package/dist/queue-artifact.d.ts +57 -0
- package/dist/queue-artifact.d.ts.map +1 -0
- package/dist/queue-artifact.js +70 -0
- package/dist/queue-artifact.js.map +1 -0
- package/dist/queue-receipt.d.ts.map +1 -1
- package/dist/queue-receipt.js +4 -3
- package/dist/queue-receipt.js.map +1 -1
- package/dist/system-preflight.d.ts.map +1 -1
- package/dist/system-preflight.js +15 -7
- package/dist/system-preflight.js.map +1 -1
- package/dist/terminal-window.d.ts.map +1 -1
- package/dist/terminal-window.js +13 -10
- package/dist/terminal-window.js.map +1 -1
- package/package.json +1 -1
- package/tui/dist/attention/attention-model.d.ts +2 -1
- package/tui/dist/attention/attention-model.d.ts.map +1 -1
- package/tui/dist/attention/attention-model.js +18 -4
- package/tui/dist/attention/attention-model.js.map +1 -1
- package/tui/dist/config/config-model.d.ts.map +1 -1
- package/tui/dist/config/config-model.js +2 -1
- package/tui/dist/config/config-model.js.map +1 -1
- package/tui/dist/daemon-client.d.ts +7 -0
- package/tui/dist/daemon-client.d.ts.map +1 -1
- package/tui/dist/daemon-client.js +15 -4
- package/tui/dist/daemon-client.js.map +1 -1
- package/tui/dist/demo-data.js +2 -2
- package/tui/dist/demo-data.js.map +1 -1
- package/tui/dist/main.js +5 -1
- package/tui/dist/main.js.map +1 -1
- package/ui/dist/assets/index-BOYrLyfQ.js +623 -0
- package/ui/dist/assets/index-DqSRu4OY.css +32 -0
- package/ui/dist/index.html +2 -2
- package/ui/dist/assets/index-BFOs3ejL.css +0 -32
- package/ui/dist/assets/index-CdkFwtld.js +0 -623
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { currentParkedOwnerNoInputFailure } from "./policies/parked-owner-consumer.js";
|
|
2
2
|
import { resolveEscalationOwner, ESCALATION_HOP_TAG, hasConsumedEscalationHop } from "./escalation-owner.js";
|
|
3
|
-
import {
|
|
3
|
+
import { createRecoveryLookup, recoveryId, recoveryTag } from "./queue-recovery.js";
|
|
4
4
|
import { quietHoldCustody } from "./quiet-hold-custody.js";
|
|
5
5
|
import { queueWaitNotice } from "./queue-wait-backoff.js";
|
|
6
6
|
import { lastMeaningfulTransition, pendingSince } from "./queue-waiting.js";
|
|
@@ -28,7 +28,7 @@ import { resolvePickupThresholdMinutes } from "./queue-pickup.js";
|
|
|
28
28
|
import { resolveOperatorSeat, resolveRecoveryAgentSeat, resolveSessionNodeId } from "./queue-owner.js";
|
|
29
29
|
import { nodeExecutorStoppedReason } from "./node-inventory.js";
|
|
30
30
|
import { isBoundTerminalSeat } from "./terminal-seat.js";
|
|
31
|
-
import { deriveCrossHostSuccessorId, hasLinkedSuccessor, matchesRecordedHandoffTarget, QueueRepositoryError } from "./queue-repository.js";
|
|
31
|
+
import { createLinkedSuccessorLookup, deriveCrossHostSuccessorId, hasLinkedSuccessor, matchesRecordedHandoffTarget, QueueRepositoryError } from "./queue-repository.js";
|
|
32
32
|
import { stalledPickupFinding } from "./queue-pickup.js";
|
|
33
33
|
import { SettingsStore } from "./user-settings/settings-store.js";
|
|
34
34
|
import { loadHostRegistry } from "./hosts/hosts-registry-reader.js";
|
|
@@ -86,6 +86,12 @@ export function resolveLadderSuppressionMinutes() {
|
|
|
86
86
|
export function findingDedupTag(kind, qitemId) {
|
|
87
87
|
return `stuck-sweep:${kind}:${qitemId}`;
|
|
88
88
|
}
|
|
89
|
+
/** Idempotency key of a seat's standing unclaimed-backlog notice: one open notice per seat. */
|
|
90
|
+
export function unclaimedBacklogTag(seat) {
|
|
91
|
+
return `stuck-sweep:unclaimed-backlog:${seat}`;
|
|
92
|
+
}
|
|
93
|
+
/** How many of a seat's unclaimed rows its standing notice lists by id; the rest are counted. */
|
|
94
|
+
export const UNCLAIMED_BACKLOG_LISTED_ROWS = 20;
|
|
89
95
|
/** The loop's observable heartbeat — surfaced on /healthz so a quiet sweep is cheap but
|
|
90
96
|
* never invisible, and a failing sweep is loud without needing a row. */
|
|
91
97
|
export function createStuckSweepStatus() {
|
|
@@ -95,6 +101,8 @@ export function createStuckSweepStatus() {
|
|
|
95
101
|
lastError: null,
|
|
96
102
|
consecutiveFailures: 0,
|
|
97
103
|
findingsRouted: 0,
|
|
104
|
+
runningSince: null,
|
|
105
|
+
skippedTicks: 0,
|
|
98
106
|
};
|
|
99
107
|
return {
|
|
100
108
|
record(outcome, detail) {
|
|
@@ -105,6 +113,10 @@ export function createStuckSweepStatus() {
|
|
|
105
113
|
if (detail?.findings)
|
|
106
114
|
state.findingsRouted += detail.findings;
|
|
107
115
|
},
|
|
116
|
+
pass(pass) {
|
|
117
|
+
state.runningSince = pass.runningSince;
|
|
118
|
+
state.skippedTicks = pass.skippedTicks;
|
|
119
|
+
},
|
|
108
120
|
snapshot() {
|
|
109
121
|
return { ...state };
|
|
110
122
|
},
|
|
@@ -410,17 +422,84 @@ function evidenceBody(db, c) {
|
|
|
410
422
|
`why: ${c.why}\n` +
|
|
411
423
|
`Resolve the underlying row; the sweep closes this finding itself once the row is no longer stuck.`);
|
|
412
424
|
}
|
|
425
|
+
/** The last line of a standing notice's body: every row it stands for, so the sweep knows what it covered. */
|
|
426
|
+
const BACKLOG_ROWS_PREFIX = "Every row this notice stands for: ";
|
|
427
|
+
/** A seat's standing unclaimed-backlog notice: its rows by id, how to list them, and how to send their findings to a seat
|
|
428
|
+
* that watches this one. Built only from the rows' fixed facts, so a pass rewrites it only when the rows change. */
|
|
429
|
+
function unclaimedBacklogText(seat, rows, thresholdMinutes, node) {
|
|
430
|
+
const sorted = [...rows].sort((a, b) => a.since.localeCompare(b.since) || a.qitemId.localeCompare(b.qitemId));
|
|
431
|
+
const listed = sorted.slice(0, UNCLAIMED_BACKLOG_LISTED_ROWS).map((r) => {
|
|
432
|
+
const about = r.summary ? `: ${r.summary.replace(/\s+/g, " ").trim().slice(0, 120)}` : "";
|
|
433
|
+
return `- ${r.qitemId}, unclaimed since ${r.since}, from ${r.from}${about}`;
|
|
434
|
+
});
|
|
435
|
+
if (sorted.length > listed.length)
|
|
436
|
+
listed.push(`- and ${sorted.length - listed.length} more`);
|
|
437
|
+
const count = `${rows.length} ${rows.length === 1 ? "row" : "rows"}`;
|
|
438
|
+
const edge = node ? `rig edge add ${node.rig} ${node.logicalId} <watching seat> --kind escalates_to` : "an escalates_to edge from this seat";
|
|
439
|
+
return {
|
|
440
|
+
summary: `Stuck sweep: unclaimed-backlog on ${seat} (${count})`,
|
|
441
|
+
body: `STUCK SWEEP FINDING (unclaimed-backlog)\n` +
|
|
442
|
+
`seat: ${seat}\n` +
|
|
443
|
+
`unclaimed: ${count} (the threshold is ${thresholdMinutes} min)\n` +
|
|
444
|
+
`${listed.join("\n")}\n` +
|
|
445
|
+
`why: nobody has claimed these rows, and this seat has no delegation parent and no escalates_to route, so this one ` +
|
|
446
|
+
`notice stands for them instead of a finding per row. It follows the rows as they come and go.\n` +
|
|
447
|
+
`List them: rig queue list --destination ${seat} --state pending\n` +
|
|
448
|
+
`To send these findings to a seat that watches this one, one finding per row: ${edge}\n` +
|
|
449
|
+
`The sweep closes this notice itself once every row it stands for is claimed, parked or closed.\n` +
|
|
450
|
+
`${BACKLOG_ROWS_PREFIX}${JSON.stringify(sorted.map((r) => r.qitemId))}`,
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
/** The rows a standing notice's body says it stands for, or null when the line is missing or unreadable: unknown, which is
|
|
454
|
+
* never read as "none". */
|
|
455
|
+
function backlogRowsOf(body) {
|
|
456
|
+
const line = body.split("\n").reverse().find((l) => l.startsWith(BACKLOG_ROWS_PREFIX));
|
|
457
|
+
if (!line)
|
|
458
|
+
return null;
|
|
459
|
+
try {
|
|
460
|
+
const ids = JSON.parse(line.slice(BACKLOG_ROWS_PREFIX.length));
|
|
461
|
+
return Array.isArray(ids) ? new Set(ids.filter((id) => typeof id === "string")) : null;
|
|
462
|
+
}
|
|
463
|
+
catch {
|
|
464
|
+
return null;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
413
467
|
/**
|
|
414
468
|
* One sweep pass. Instance-wide (no rig scope — the loop is the net for every rig the
|
|
415
469
|
* daemon carries). Never throws: a sweep that cannot run reports outcome=failed loudly
|
|
416
470
|
* on the status surface and the log, because a silent skip is exactly the class this
|
|
417
471
|
* slice exists to kill.
|
|
418
472
|
*/
|
|
473
|
+
/** Rows a sweep pass handles between two yields of the event loop. A pass over a large queue used to hold the loop
|
|
474
|
+
* for its whole length (seconds on a queue of tens of thousands of rows, with healthz and every request waiting);
|
|
475
|
+
* every this many rows it now lets timers and requests run. */
|
|
476
|
+
export const STUCK_SWEEP_YIELD_EVERY_ROWS = 50;
|
|
419
477
|
export async function runStuckSweep(deps) {
|
|
420
478
|
const log = deps.log ?? ((line) => console.error(line));
|
|
421
479
|
const status = deps.status;
|
|
422
480
|
try {
|
|
423
481
|
const now = deps.now ?? new Date();
|
|
482
|
+
// One recovery index and one linked-successor read per stretch of the pass, instead of one json_each scan per
|
|
483
|
+
// candidate and per custody row. Each is a snapshot that is only valid while no other code runs, so both are
|
|
484
|
+
// dropped (and rebuilt on the next lookup) after every yield and every awaited write.
|
|
485
|
+
const recoveries = createRecoveryLookup(deps.db);
|
|
486
|
+
let successors = null;
|
|
487
|
+
// Every yield and every awaited write lets other code run: indexes read before it are dropped, and `othersRan`
|
|
488
|
+
// tells a list read before it that its rows need a fresh read.
|
|
489
|
+
let othersRan = 0;
|
|
490
|
+
const othersMayHaveRun = () => { othersRan++; recoveries.invalidate(); successors?.invalidate(); };
|
|
491
|
+
// A synchronous read with both indexes lent to what it calls deep inside (a getById's waiting view and handoff
|
|
492
|
+
// advisory ask the same questions per row). Never spans an await: the lend ends when fn returns.
|
|
493
|
+
const indexed = (fn) => recoveries.run(() => (successors ? successors.run(fn) : fn()));
|
|
494
|
+
// `if (dueToYield()) await yieldLoop();` and never a bare await per row: even an await that does not yield lets
|
|
495
|
+
// queued microtasks (other requests' continuations) run and write between two rows the snapshot still covers.
|
|
496
|
+
let rowsSinceYield = 0;
|
|
497
|
+
const dueToYield = () => ++rowsSinceYield >= STUCK_SWEEP_YIELD_EVERY_ROWS;
|
|
498
|
+
const yieldLoop = async () => {
|
|
499
|
+
rowsSinceYield = 0;
|
|
500
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
501
|
+
othersMayHaveRun();
|
|
502
|
+
};
|
|
424
503
|
const suppressionMinutes = deps.ladderSuppressionMinutes ?? resolveLadderSuppressionMinutes();
|
|
425
504
|
/** The dedup tags of the candidates the LADDER suppressed in this pass, and only those:
|
|
426
505
|
* a row the ladder alone would have stopped. A finding for such a row stays open,
|
|
@@ -446,42 +525,42 @@ export async function runStuckSweep(deps) {
|
|
|
446
525
|
};
|
|
447
526
|
const isRegisteredHost = deps.isRegisteredHost ?? defaultIsRegisteredHost(log);
|
|
448
527
|
const candidates = [];
|
|
528
|
+
const nowIso = now.toISOString();
|
|
529
|
+
// SQLite's LIKE ignores ASCII case; the per-row rules below match the queries they stand in for.
|
|
530
|
+
const startsWithCI = (value, prefix) => (value ?? "").toLowerCase().startsWith(prefix);
|
|
531
|
+
// Each kind's rule for ONE row, applied to the row as it is now. The loops below enumerate the rows; the same
|
|
532
|
+
// rules run again on a fresh read right before a finding is created (stillStuck), because a pass that yields
|
|
533
|
+
// cannot trust what it read before the yield: a claim, a delivered wake, a moved deadline, a note or a new
|
|
534
|
+
// successor may have landed since.
|
|
449
535
|
// Half 1 — claimed-never-closed. The claimant holds the obligation; the finding
|
|
450
536
|
// routes to them.
|
|
451
|
-
|
|
537
|
+
const overdueCandidate = (row) => {
|
|
452
538
|
if (isFindingRow(row))
|
|
453
|
-
|
|
454
|
-
|
|
539
|
+
return null;
|
|
540
|
+
return {
|
|
455
541
|
kind: "overdue-claim",
|
|
456
542
|
row,
|
|
457
543
|
route: row.destinationSession,
|
|
458
544
|
ageMinutes: minutesSince(row.closureRequiredAt ?? row.claimedAt, now),
|
|
459
545
|
evidenceAt: latestIso(lastMeaningfulTransition(deps.db, row.qitemId)?.at, row.closureRequiredAt, row.claimedAt),
|
|
460
546
|
why: "claimed and past closure_required_at with no closure",
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
deps.queueRepo.recordClosureOverdue(row.qitemId, { now: now.toISOString() });
|
|
464
|
-
}
|
|
465
|
-
catch (err) {
|
|
466
|
-
log(`[stuck-sweep] failed to record closure-overdue for ${row.qitemId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
467
|
-
}
|
|
468
|
-
}
|
|
547
|
+
};
|
|
548
|
+
};
|
|
469
549
|
// S04 seam — a claimed row with no later motion past the pickup threshold. The
|
|
470
|
-
// pickup module remains the ONE derivation rule; this
|
|
471
|
-
const
|
|
472
|
-
|
|
473
|
-
.all();
|
|
474
|
-
for (const { qitem_id } of claimedRows) {
|
|
475
|
-
const row = deps.queueRepo.getById(qitem_id);
|
|
550
|
+
// pickup module remains the ONE derivation rule; this only enumerates and routes.
|
|
551
|
+
const stalledCandidate = (qitemId) => {
|
|
552
|
+
const row = indexed(() => deps.queueRepo.getById(qitemId));
|
|
476
553
|
if (!row || isFindingRow(row))
|
|
477
|
-
|
|
554
|
+
return null;
|
|
555
|
+
if ((row.state !== "pending" && row.state !== "in-progress") || !row.claimedAt)
|
|
556
|
+
return null;
|
|
478
557
|
const stalled = stalledPickupFinding(row);
|
|
479
558
|
if (!stalled)
|
|
480
|
-
|
|
559
|
+
return null;
|
|
481
560
|
// Keep this null arm for the 0.5.7 mechanized-pull turn-end hook that knows the in-flight row;
|
|
482
561
|
// it is the first honest row-scoped writer, and wiring reopens only in that slice.
|
|
483
562
|
const evidenceAt = latestIso(lastMeaningfulTransition(deps.db, row.qitemId)?.at, row.lastHeartbeat, row.claimedAt);
|
|
484
|
-
|
|
563
|
+
return {
|
|
485
564
|
kind: stalled.kind,
|
|
486
565
|
row,
|
|
487
566
|
route: resolveOrch(stalled.target, row) ?? stalled.target,
|
|
@@ -490,69 +569,85 @@ export async function runStuckSweep(deps) {
|
|
|
490
569
|
ageMinutes: wholeMinutesSince(evidenceAt, now),
|
|
491
570
|
evidenceAt,
|
|
492
571
|
why: stalled.evidence,
|
|
493
|
-
}
|
|
494
|
-
}
|
|
572
|
+
};
|
|
573
|
+
};
|
|
495
574
|
// The timer delivered one transition-specific notice (or recorded a failed
|
|
496
575
|
// attempt). This existing sweep owns its bounded recovery, not another full
|
|
497
576
|
// packet or a parked-owner replay. A real owner response ends the occurrence.
|
|
498
|
-
const
|
|
499
|
-
|
|
500
|
-
|
|
577
|
+
const waitCandidate = (jobId) => {
|
|
578
|
+
const job = deps.db.prepare("SELECT spec_yaml FROM watchdog_jobs WHERE job_id = ? AND state = 'active' AND policy = 'periodic-reminder'")
|
|
579
|
+
.get(jobId);
|
|
580
|
+
const notice = job ? queueWaitNotice(job.spec_yaml) : null;
|
|
501
581
|
if (!notice || now.getTime() - Date.parse(notice.at) <= resolvePickupThresholdMinutes() * 60_000)
|
|
502
|
-
|
|
503
|
-
const binding = deps.db.prepare("SELECT qitem_id FROM queue_transition_wakes WHERE wake_ref = ? AND phase = 'armed' ORDER BY transition_id DESC LIMIT 1").get(
|
|
504
|
-
const row = binding ? deps.queueRepo.getById(binding.qitem_id) : null;
|
|
505
|
-
if (!row || row.state !== "blocked" || deps.queueRepo.getParkWakeStatus(row.qitemId)?.ref !==
|
|
506
|
-
|
|
582
|
+
return null;
|
|
583
|
+
const binding = deps.db.prepare("SELECT qitem_id FROM queue_transition_wakes WHERE wake_ref = ? AND phase = 'armed' ORDER BY transition_id DESC LIMIT 1").get(jobId);
|
|
584
|
+
const row = binding ? indexed(() => deps.queueRepo.getById(binding.qitem_id)) : null;
|
|
585
|
+
if (!row || row.state !== "blocked" || deps.queueRepo.getParkWakeStatus(row.qitemId)?.ref !== jobId)
|
|
586
|
+
return null;
|
|
507
587
|
const response = lastMeaningfulTransition(deps.db, row.qitemId);
|
|
508
588
|
if (response && Date.parse(response.at) > Date.parse(notice.at))
|
|
509
|
-
|
|
589
|
+
return null;
|
|
510
590
|
const ownerActivity = deps.queueRepo.ownerActivity(row.destinationSession);
|
|
511
591
|
if (ownerActivity?.activity === "working" && !ownerActivity.needsInput.count && notice.deliveryStatus === "ok")
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
ageMinutes: minutesSince(notice.at, now), evidenceAt: notice.at,
|
|
515
|
-
why: `wait notice delivery=${notice.deliveryStatus}; no later owner response; activity=${ownerActivity?.activity ?? "unknown"}; inspect exact blocker ${row.blockedOn}` }
|
|
516
|
-
}
|
|
592
|
+
return null;
|
|
593
|
+
return { kind: "unconsumed-wait", row, route: resolveOrch(row.destinationSession, row) ?? row.sourceSession,
|
|
594
|
+
ageMinutes: minutesSince(notice.at, now), evidenceAt: notice.at, jobId,
|
|
595
|
+
why: `wait notice delivery=${notice.deliveryStatus}; no later owner response; activity=${ownerActivity?.activity ?? "unknown"}; inspect exact blocker ${row.blockedOn}` };
|
|
596
|
+
};
|
|
517
597
|
// The parked policy stops repeating a positively no-input failure. Unhealthy blocked rows
|
|
518
598
|
// have no retry ladder: the same sweep/recovery route owns their actionable disposition.
|
|
519
|
-
const
|
|
520
|
-
|
|
521
|
-
const row = deps.queueRepo.getById(qitem_id);
|
|
599
|
+
const parkedCandidate = (qitemId) => {
|
|
600
|
+
const row = indexed(() => deps.queueRepo.getById(qitemId));
|
|
522
601
|
if (!row || isFindingRow(row))
|
|
523
|
-
|
|
524
|
-
|
|
602
|
+
return null;
|
|
603
|
+
if (row.state !== "blocked" || !startsWithCI(row.lastNudgeResult, "failed:"))
|
|
604
|
+
return null;
|
|
605
|
+
const wake = deps.queueRepo.getParkWakeStatus(qitemId);
|
|
525
606
|
if ((wake?.live === true && (!wake.unconsumed || wake.recoveryOwner === "queue-stuck-sweep"))
|
|
526
|
-
|| deps.queueRepo.parkWakeServedByOwnReminder(
|
|
527
|
-
|
|
528
|
-
const transitions = deps.queueRepo.listTransitions(
|
|
607
|
+
|| deps.queueRepo.parkWakeServedByOwnReminder(qitemId))
|
|
608
|
+
return null;
|
|
609
|
+
const transitions = deps.queueRepo.listTransitions(qitemId);
|
|
529
610
|
const failure = currentParkedOwnerNoInputFailure(transitions);
|
|
530
611
|
if (!failure)
|
|
531
|
-
|
|
612
|
+
return null;
|
|
532
613
|
// Another seat's incidental note is not the owner's response. This kind follows
|
|
533
614
|
// the parked policy's owner-or-state-change rule, leaving other sweep kinds alone.
|
|
534
615
|
if (transitions.some((t, i) => t.transitionId > (failure.transitionId ?? Number.POSITIVE_INFINITY)
|
|
535
616
|
&& (t.actorSession === row.destinationSession || t.state !== transitions[i - 1]?.state)))
|
|
536
|
-
|
|
537
|
-
|
|
617
|
+
return null;
|
|
618
|
+
return { kind: "parked-owner-no-input", row, route: resolveOrch(row.destinationSession, row) ?? row.sourceSession,
|
|
538
619
|
ageMinutes: minutesSince(failure.ts, now), evidenceAt: failure.ts,
|
|
539
|
-
why: `Automated parked-owner reminder refused before input (${failure.code}); repeated input stopped. Inspect the retained quota/guard or route terminal work to an agent. Original blocker remains ${row.blockedOn}` }
|
|
540
|
-
}
|
|
620
|
+
why: `Automated parked-owner reminder refused before input (${failure.code}); repeated input stopped. Inspect the retained quota/guard or route terminal work to an agent. Original blocker remains ${row.blockedOn}` };
|
|
621
|
+
};
|
|
541
622
|
// Half 2 — sender-believed-delivered-never-woken. Nobody holds it (the wake failed),
|
|
542
623
|
// so it routes to the destination's orchestrator when one is derivable. Rows with a
|
|
543
624
|
// live S01 ladder are S01's territory; an exhausted ladder is the handback and lands
|
|
544
625
|
// here exactly once (the dedup tag keeps it to one finding).
|
|
545
|
-
|
|
626
|
+
// A wake recorded unroutable because the seat's pane wasn't bound yet (#2151). Once its binding exists, deliver the
|
|
627
|
+
// row's own wake intent instead of reporting it: the intent is claimed and settled, so a startup drain doesn't send it
|
|
628
|
+
// again, and one already in flight or settled isn't sent twice. The next tick reads the new result, so a failed send
|
|
629
|
+
// is reported then. A row with a live retry ladder is left to the ladder.
|
|
630
|
+
const wakeToRetry = (row, humanNotice) => !humanNotice
|
|
631
|
+
&& startsWithCI(row.lastNudgeResult, "unroutable:")
|
|
632
|
+
&& !hasLiveLadder(deps.db, row.qitemId, now, suppressionMinutes)
|
|
633
|
+
&& deps.queueRepo.classifyDestinationOf(row.destinationSession).class === "pane-bound";
|
|
634
|
+
const isHumanNotice = (row) => row.deliveryOutcome === "never-posted" || row.deliveryOutcome === "transport-failed";
|
|
635
|
+
/** The checks that run before the wake retry, as in the loop this replaces: a row they exclude is never woken. */
|
|
636
|
+
const wakeRetryEligible = (row) => !row.claimedAt
|
|
637
|
+
&& !deps.queueRepo.isLocalHumanDecisionWithoutGateway(row)
|
|
638
|
+
&& !["held", "released"].includes(quietHoldCustody(deps.db, row.qitemId, now)?.state ?? "");
|
|
639
|
+
/** `row` comes from findUndelivered (it carries the delivery verdict). Call it after any wake retry the row needs. */
|
|
640
|
+
const undeliveredCandidate = (row, recordSuppression) => {
|
|
546
641
|
if (isFindingRow(row))
|
|
547
|
-
|
|
548
|
-
const humanNotice = row
|
|
642
|
+
return null;
|
|
643
|
+
const humanNotice = isHumanNotice(row);
|
|
549
644
|
// A claim supersedes a retained failed wake, including on a row returned to
|
|
550
645
|
// pending. Its pickup finding must not be replaced by that historical failure;
|
|
551
646
|
// a separate human notification still needs its own delivery evidence.
|
|
552
647
|
if (!humanNotice && row.claimedAt)
|
|
553
|
-
|
|
648
|
+
return null;
|
|
554
649
|
if (!humanNotice && deps.queueRepo.isLocalHumanDecisionWithoutGateway(row))
|
|
555
|
-
|
|
650
|
+
return null;
|
|
556
651
|
const notification = humanNotice ? deps.queueRepo.transitionLog.latestOwnerNotificationForQitem(row.qitemId) : null;
|
|
557
652
|
const resolutionNotice = notification?.ownerNotificationKind === "human-decision-resolved";
|
|
558
653
|
// Match the notification source in slack/queue-access.ts, not the agent wake's escalator.
|
|
@@ -566,26 +661,16 @@ export async function runStuckSweep(deps) {
|
|
|
566
661
|
// live release job is orphaned: both stay findings, with their own reason.
|
|
567
662
|
const quiet = quietHoldCustody(deps.db, row.qitemId, now);
|
|
568
663
|
if (quiet && (quiet.state === "held" || quiet.state === "released"))
|
|
569
|
-
|
|
570
|
-
// A wake recorded unroutable because the seat's pane wasn't bound yet (#2151). Once its binding exists, deliver the
|
|
571
|
-
// row's own wake intent instead of reporting it: the intent is claimed and settled, so a startup drain doesn't send it
|
|
572
|
-
// again, and one already in flight or settled isn't sent twice. The next tick reads the new result, so a failed send
|
|
573
|
-
// is reported then. A row with a live retry ladder is left to the ladder.
|
|
574
|
-
if (!humanNotice && row.lastNudgeResult?.startsWith("unroutable:")
|
|
575
|
-
&& !hasLiveLadder(deps.db, row.qitemId, now, suppressionMinutes)
|
|
576
|
-
&& deps.queueRepo.classifyDestinationOf(row.destinationSession).class === "pane-bound") {
|
|
577
|
-
await deps.queueRepo.deliverWakeForSuccessor(row.qitemId, row.destinationSession, true, row.sourceSession);
|
|
578
|
-
if (!deps.queueRepo.getById(row.qitemId)?.lastNudgeResult?.startsWith("unroutable:"))
|
|
579
|
-
continue;
|
|
580
|
-
}
|
|
664
|
+
return null;
|
|
581
665
|
// The ladder check runs LAST, so only a row the ladder ALONE would have stopped counts
|
|
582
666
|
// as ladder-suppressed (#1419). Agent wake retries do not own the separate notice to a
|
|
583
667
|
// person: a human notice is never the ladder's to suppress.
|
|
584
668
|
if (!humanNotice && hasLiveLadder(deps.db, row.qitemId, now, suppressionMinutes)) {
|
|
585
|
-
|
|
586
|
-
|
|
669
|
+
if (recordSuppression)
|
|
670
|
+
suppressedTags.add(findingDedupTag("undelivered-wake", row.qitemId));
|
|
671
|
+
return null;
|
|
587
672
|
}
|
|
588
|
-
|
|
673
|
+
return {
|
|
589
674
|
kind: humanNotice ? "undelivered-human-notice" : "undelivered-wake",
|
|
590
675
|
row,
|
|
591
676
|
route: humanNotice ? noticeOwner : resolveOrch(row.destinationSession, row) ?? row.destinationSession,
|
|
@@ -598,58 +683,56 @@ export async function runStuckSweep(deps) {
|
|
|
598
683
|
: humanNotice
|
|
599
684
|
? `${failure}; check human-notification delivery rather than retrying the agent wake`
|
|
600
685
|
: `${failure} and nothing retried it`,
|
|
601
|
-
}
|
|
602
|
-
}
|
|
686
|
+
};
|
|
687
|
+
};
|
|
688
|
+
const undeliveredNow = (qitemId) => indexed(() => deps.queueRepo.findUndelivered({ qitemId }))[0];
|
|
603
689
|
// The A1 net — created-with-destination rows carrying real obligations, unclaimed past
|
|
604
690
|
// the config-keyed age. Parks (state=blocked) legitimately wait and never appear here;
|
|
605
691
|
// failed-nudge rows already surfaced in half 2; laddered rows are S01's.
|
|
606
692
|
const cutoff = new Date(now.getTime() - ageMinutes * 60_000).toISOString();
|
|
607
|
-
const
|
|
608
|
-
|
|
609
|
-
WHERE state = 'pending'
|
|
610
|
-
AND claimed_at IS NULL
|
|
611
|
-
AND destination_session IS NOT NULL AND destination_session != ''
|
|
612
|
-
AND ts_created <= ?
|
|
613
|
-
AND (last_nudge_result IS NULL OR last_nudge_result NOT LIKE 'failed:%')`)
|
|
614
|
-
.all(cutoff);
|
|
615
|
-
for (const { qitem_id } of unclaimedRows) {
|
|
616
|
-
const row = deps.queueRepo.getById(qitem_id);
|
|
693
|
+
const unclaimedCandidate = (qitemId, recordSuppression) => {
|
|
694
|
+
const row = indexed(() => deps.queueRepo.getById(qitemId));
|
|
617
695
|
if (!row || isFindingRow(row))
|
|
618
|
-
|
|
696
|
+
return null;
|
|
697
|
+
// The query's own predicate, on the row as it is now.
|
|
698
|
+
if (row.state !== "pending" || row.claimedAt || !row.destinationSession || row.tsCreated > cutoff
|
|
699
|
+
|| startsWithCI(row.lastNudgeResult, "failed:"))
|
|
700
|
+
return null;
|
|
619
701
|
if (deps.queueRepo.isLocalHumanDecisionWithoutGateway(row))
|
|
620
|
-
|
|
702
|
+
return null;
|
|
621
703
|
const actionableAt = pendingSince(deps.db, row.qitemId) ?? row.tsCreated;
|
|
622
704
|
if (actionableAt > cutoff)
|
|
623
|
-
|
|
705
|
+
return null;
|
|
624
706
|
// #514 — an ask already posted to its registered human in the current delivery episode waits on
|
|
625
707
|
// that human; it is not stuck, and a finding would post the human again. Unposted, failed,
|
|
626
708
|
// legacy and non-human rows keep this net.
|
|
627
709
|
if (deps.queueRepo.humanNotificationPostedThisEpisode(row.qitemId))
|
|
628
|
-
|
|
710
|
+
return null;
|
|
629
711
|
// An ask placed on Steering without an alert waits on its person there by design; a finding would alert them.
|
|
630
712
|
if (deps.queueRepo.humanAskWithoutAlert(row.qitemId))
|
|
631
|
-
|
|
713
|
+
return null;
|
|
632
714
|
// Quiet hours: a held ask whose window's release job is live waits on that job, and one already released waits on
|
|
633
715
|
// its post; neither is stuck. A release whose post failed is reported once, by the undelivered-wake loop above. A
|
|
634
716
|
// hold with no live release job is stuck: nothing will ever release it.
|
|
635
717
|
const quiet = quietHoldCustody(deps.db, row.qitemId, now);
|
|
636
718
|
if (quiet && quiet.state !== "orphaned")
|
|
637
|
-
|
|
719
|
+
return null;
|
|
638
720
|
// An explicit informational update to a currently registered human is for reading, not an obligation to claim,
|
|
639
721
|
// unless its quiet-hours hold has been orphaned before release.
|
|
640
722
|
if (!quiet && deps.queueRepo.isRegisteredHumanUpdate(row))
|
|
641
|
-
|
|
723
|
+
return null;
|
|
642
724
|
// The seat's typing guard or interruption level held its wake on purpose: it's held and readable at the seat, not
|
|
643
725
|
// stuck. (A handed-off baton's one held notice is the wake ladder's.)
|
|
644
726
|
if (row.lastNudgeResult === "retained:typing_guard")
|
|
645
|
-
|
|
727
|
+
return null;
|
|
646
728
|
// The ladder check runs LAST here too: a row the ladder alone would have stopped is
|
|
647
729
|
// ladder-suppressed, and its finding stays open (#1419).
|
|
648
730
|
if (hasLiveLadder(deps.db, row.qitemId, now, suppressionMinutes)) {
|
|
649
|
-
|
|
650
|
-
|
|
731
|
+
if (recordSuppression)
|
|
732
|
+
suppressedTags.add(findingDedupTag("unclaimed-obligation", row.qitemId));
|
|
733
|
+
return null;
|
|
651
734
|
}
|
|
652
|
-
|
|
735
|
+
return {
|
|
653
736
|
kind: "unclaimed-obligation",
|
|
654
737
|
row,
|
|
655
738
|
route: resolveOrch(row.destinationSession, row) ?? row.destinationSession,
|
|
@@ -658,8 +741,8 @@ export async function runStuckSweep(deps) {
|
|
|
658
741
|
why: quiet?.state === "orphaned"
|
|
659
742
|
? `held for quiet hours (window ${quiet.windowId}) for ${minutesSince(actionableAt, now)} min, but no release job is live for that window: nothing will release it`
|
|
660
743
|
: `actionable with a destination and unclaimed for ${minutesSince(actionableAt, now)} min (threshold ${ageMinutes})`,
|
|
661
|
-
}
|
|
662
|
-
}
|
|
744
|
+
};
|
|
745
|
+
};
|
|
663
746
|
// The custody class — a terminal row whose closure names one or more successor
|
|
664
747
|
// qitems or seat-address targets (closure_reason = 'handed_off_to'). A local miss is
|
|
665
748
|
// never proof of absence: the successor may live in another registered host's database.
|
|
@@ -682,48 +765,21 @@ export async function runStuckSweep(deps) {
|
|
|
682
765
|
// owner, so skip only recorded handoffs whose current target still matches (#341).
|
|
683
766
|
// Closures outside the recent 24-hour window without open findings are skipped so upgrading
|
|
684
767
|
// a real queue history does not raise a flood of historical findings.
|
|
685
|
-
|
|
686
|
-
const
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
for (const { tags } of deps.db
|
|
690
|
-
.prepare(`SELECT tags FROM queue_items WHERE state IN ('pending', 'in-progress', 'blocked') AND tags LIKE ?`)
|
|
691
|
-
.all(`%"${danglingPrefix}%`)) {
|
|
692
|
-
try {
|
|
693
|
-
for (const tag of JSON.parse(tags)) {
|
|
694
|
-
if (tag.startsWith(danglingPrefix)) {
|
|
695
|
-
openDanglingIds.push(tag.slice(danglingPrefix.length));
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
catch {
|
|
700
|
-
// Skip malformed tags
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
const custodyRows = deps.db
|
|
704
|
-
.prepare(
|
|
705
|
-
// Bound candidates before checking state: including handed-off in the
|
|
706
|
-
// state index scan would otherwise revisit all historical atomic handoffs.
|
|
707
|
-
`WITH custody_candidates AS MATERIALIZED (
|
|
708
|
-
SELECT qitem_id, state, handed_off_to, closure_target, closure_reason
|
|
709
|
-
FROM queue_items WHERE ts_updated >= ?
|
|
710
|
-
UNION
|
|
711
|
-
SELECT qitem_id, state, handed_off_to, closure_target, closure_reason
|
|
712
|
-
FROM queue_items WHERE qitem_id IN (SELECT value FROM json_each(?))
|
|
713
|
-
)
|
|
714
|
-
SELECT q.qitem_id FROM custody_candidates q
|
|
715
|
-
WHERE (q.state IN ('done', 'canceled') OR (q.state = 'handed-off'
|
|
716
|
-
AND (q.handed_off_to IS NULL OR q.closure_target IS NOT q.handed_off_to)))
|
|
717
|
-
AND (q.closure_target LIKE 'qitem-%' OR q.closure_reason = 'handed_off_to')`)
|
|
718
|
-
.all(custodyCutoff, JSON.stringify(openDanglingIds));
|
|
719
|
-
for (const { qitem_id } of custodyRows) {
|
|
720
|
-
const row = deps.queueRepo.getById(qitem_id);
|
|
768
|
+
/** `recheck`: read live without the lent indexes, and don't log the registry fallback a second time. */
|
|
769
|
+
const custodyCandidate = (qitemId, hasSuccessor, recheck = false) => {
|
|
770
|
+
// A recheck reads live, without the lent indexes: one row's own queries cost less than a rebuilt successor index.
|
|
771
|
+
const row = recheck ? deps.queueRepo.getById(qitemId) : indexed(() => deps.queueRepo.getById(qitemId));
|
|
721
772
|
if (!row || isFindingRow(row))
|
|
722
|
-
|
|
773
|
+
return null;
|
|
774
|
+
// The query's own predicate, on the row as it is now.
|
|
775
|
+
const closed = row.state === "done" || row.state === "canceled"
|
|
776
|
+
|| (row.state === "handed-off" && (row.handedOffTo == null || (row.closureTarget ?? null) !== row.handedOffTo));
|
|
777
|
+
if (!closed || !(startsWithCI(row.closureTarget, "qitem-") || row.closureReason === "handed_off_to"))
|
|
778
|
+
return null;
|
|
723
779
|
// Local recorded targets were filtered in SQL; remote keys use the same
|
|
724
780
|
// derivation as the cross-host close, without reading successor history.
|
|
725
781
|
if (row.state === "handed-off" && matchesRecordedHandoffTarget(row.qitemId, row.handedOffTo, row.closureTarget))
|
|
726
|
-
|
|
782
|
+
return null;
|
|
727
783
|
const targets = (row.closureTarget ?? row.handedOffTo ?? "")
|
|
728
784
|
.split(",")
|
|
729
785
|
.map((target) => target.trim())
|
|
@@ -746,17 +802,17 @@ export async function runStuckSweep(deps) {
|
|
|
746
802
|
}
|
|
747
803
|
if (target === row.qitemId)
|
|
748
804
|
return true;
|
|
749
|
-
return !deps.queueRepo.getById(target);
|
|
805
|
+
return !indexed(() => deps.queueRepo.getById(target));
|
|
750
806
|
}
|
|
751
807
|
try {
|
|
752
|
-
return !
|
|
808
|
+
return !hasSuccessor(row.qitemId, target);
|
|
753
809
|
}
|
|
754
810
|
catch {
|
|
755
811
|
return true;
|
|
756
812
|
}
|
|
757
813
|
});
|
|
758
814
|
if (verificationTargets.length === 0)
|
|
759
|
-
|
|
815
|
+
return null;
|
|
760
816
|
let route = row.destinationSession;
|
|
761
817
|
try {
|
|
762
818
|
route = custodyFindingRoute(deps.db, deps.queueRepo, row);
|
|
@@ -766,9 +822,10 @@ export async function runStuckSweep(deps) {
|
|
|
766
822
|
throw err;
|
|
767
823
|
// The registry may not exist before the first human is registered. Losing
|
|
768
824
|
// owner refinement must not stop unrelated findings or their resolution.
|
|
769
|
-
|
|
825
|
+
if (!recheck)
|
|
826
|
+
log(`[stuck-sweep] keeping custody route for ${row.qitemId} at ${row.destinationSession}: ${err.message}`);
|
|
770
827
|
}
|
|
771
|
-
|
|
828
|
+
return {
|
|
772
829
|
kind: "dangling-closure",
|
|
773
830
|
row,
|
|
774
831
|
route,
|
|
@@ -776,7 +833,174 @@ export async function runStuckSweep(deps) {
|
|
|
776
833
|
evidenceAt: latestIso(row.tsUpdated),
|
|
777
834
|
why: `closed (${row.closureReason ?? "?"}) with successor custody that this local store cannot fully verify`,
|
|
778
835
|
verificationTargets,
|
|
779
|
-
}
|
|
836
|
+
};
|
|
837
|
+
};
|
|
838
|
+
const armedJobOf = (qitemId) => deps.db.prepare("SELECT wake_ref FROM queue_transition_wakes WHERE qitem_id = ? AND phase = 'armed' ORDER BY transition_id DESC LIMIT 1").get(qitemId)?.wake_ref;
|
|
839
|
+
/** A kind's rule, again, on the row as it is now (read live, without the lent indexes): the candidate it makes now,
|
|
840
|
+
* with its current route, reason and targets, or null when it no longer holds. */
|
|
841
|
+
const freshCandidate = (kind, id, jobId) => {
|
|
842
|
+
switch (kind) {
|
|
843
|
+
case "overdue-claim": {
|
|
844
|
+
const row = deps.queueRepo.findOverdue({ now: nowIso, qitemId: id })[0];
|
|
845
|
+
return row ? overdueCandidate(row) : null;
|
|
846
|
+
}
|
|
847
|
+
case "stalled-after-claim": return stalledCandidate(id);
|
|
848
|
+
case "unconsumed-wait": {
|
|
849
|
+
const job = jobId ?? armedJobOf(id);
|
|
850
|
+
const c = job ? waitCandidate(job) : null;
|
|
851
|
+
return c?.row.qitemId === id ? c : null;
|
|
852
|
+
}
|
|
853
|
+
case "parked-owner-no-input": return parkedCandidate(id);
|
|
854
|
+
case "undelivered-wake":
|
|
855
|
+
case "undelivered-human-notice": {
|
|
856
|
+
const row = undeliveredNow(id);
|
|
857
|
+
// the wake retry already ran in this pass; a row that still needs it now was not woken by it
|
|
858
|
+
const c = row ? undeliveredCandidate(row, false) : null;
|
|
859
|
+
return c?.kind === kind ? c : null;
|
|
860
|
+
}
|
|
861
|
+
case "unclaimed-obligation": return unclaimedCandidate(id, false);
|
|
862
|
+
case "dangling-closure": return custodyCandidate(id, (source, target) => hasLinkedSuccessor(deps.db, source, target), true);
|
|
863
|
+
default: return null;
|
|
864
|
+
}
|
|
865
|
+
};
|
|
866
|
+
/** Whether a kind's rule still holds now, leaving the routing notes (routeNotes, routed) as they were. */
|
|
867
|
+
const ruleHolds = (kind, id, jobId) => {
|
|
868
|
+
const notes = new Map(routeNotes);
|
|
869
|
+
const wasRouted = new Set(routed);
|
|
870
|
+
try {
|
|
871
|
+
return !!freshCandidate(kind, id, jobId);
|
|
872
|
+
}
|
|
873
|
+
finally {
|
|
874
|
+
routeNotes.clear();
|
|
875
|
+
for (const [k, v] of notes)
|
|
876
|
+
routeNotes.set(k, v);
|
|
877
|
+
routed.clear();
|
|
878
|
+
for (const k of wasRouted)
|
|
879
|
+
routed.add(k);
|
|
880
|
+
}
|
|
881
|
+
};
|
|
882
|
+
const stillStuck = (c) => ruleHolds(c.kind, c.row.qitemId, c.jobId);
|
|
883
|
+
/** The kinds the resolution closes on "no longer detected" alone (the others need source evidence). */
|
|
884
|
+
const resolvedByRule = new Set(["overdue-claim", "stalled-after-claim", "unconsumed-wait", "parked-owner-no-input", "dangling-closure"]);
|
|
885
|
+
// The rows each rule looks at. The id lists are judged on a fresh getById per row; the two finders return whole
|
|
886
|
+
// rows, which are read again by id once other code may have run since the list was read.
|
|
887
|
+
let listedAt = othersRan;
|
|
888
|
+
for (const listed of indexed(() => deps.queueRepo.findOverdue({ now: nowIso }))) {
|
|
889
|
+
if (dueToYield())
|
|
890
|
+
await yieldLoop();
|
|
891
|
+
const row = listedAt !== othersRan ? indexed(() => deps.queueRepo.findOverdue({ now: nowIso, qitemId: listed.qitemId }))[0] : listed;
|
|
892
|
+
const c = row ? overdueCandidate(row) : null;
|
|
893
|
+
if (!c)
|
|
894
|
+
continue;
|
|
895
|
+
candidates.push(c);
|
|
896
|
+
try {
|
|
897
|
+
// Only a transition and an event: no index or listed row changes.
|
|
898
|
+
deps.queueRepo.recordClosureOverdue(row.qitemId, { now: nowIso });
|
|
899
|
+
}
|
|
900
|
+
catch (err) {
|
|
901
|
+
log(`[stuck-sweep] failed to record closure-overdue for ${row.qitemId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
for (const { qitem_id } of deps.db
|
|
905
|
+
.prepare("SELECT qitem_id FROM queue_items WHERE state IN ('pending', 'in-progress') AND claimed_at IS NOT NULL")
|
|
906
|
+
.all()) {
|
|
907
|
+
if (dueToYield())
|
|
908
|
+
await yieldLoop();
|
|
909
|
+
const c = stalledCandidate(qitem_id);
|
|
910
|
+
if (c)
|
|
911
|
+
candidates.push(c);
|
|
912
|
+
}
|
|
913
|
+
for (const { job_id } of deps.db.prepare("SELECT job_id FROM watchdog_jobs WHERE state = 'active' AND policy = 'periodic-reminder'")
|
|
914
|
+
.all()) {
|
|
915
|
+
if (dueToYield())
|
|
916
|
+
await yieldLoop();
|
|
917
|
+
const c = waitCandidate(job_id);
|
|
918
|
+
if (c)
|
|
919
|
+
candidates.push(c);
|
|
920
|
+
}
|
|
921
|
+
for (const { qitem_id } of deps.db.prepare("SELECT qitem_id FROM queue_items WHERE state='blocked' AND last_nudge_result LIKE 'failed:%'")
|
|
922
|
+
.all()) {
|
|
923
|
+
if (dueToYield())
|
|
924
|
+
await yieldLoop();
|
|
925
|
+
const c = parkedCandidate(qitem_id);
|
|
926
|
+
if (c)
|
|
927
|
+
candidates.push(c);
|
|
928
|
+
}
|
|
929
|
+
listedAt = othersRan;
|
|
930
|
+
for (const listed of indexed(() => deps.queueRepo.findUndelivered())) {
|
|
931
|
+
if (dueToYield())
|
|
932
|
+
await yieldLoop();
|
|
933
|
+
let row = listedAt !== othersRan ? undeliveredNow(listed.qitemId) : listed;
|
|
934
|
+
if (!row || isFindingRow(row))
|
|
935
|
+
continue;
|
|
936
|
+
if (wakeRetryEligible(row) && wakeToRetry(row, isHumanNotice(row))) {
|
|
937
|
+
await deps.queueRepo.deliverWakeForSuccessor(row.qitemId, row.destinationSession, true, row.sourceSession);
|
|
938
|
+
othersMayHaveRun();
|
|
939
|
+
// judged again on the row as the send (and anyone else during it) left it
|
|
940
|
+
row = undeliveredNow(row.qitemId);
|
|
941
|
+
if (!row || !startsWithCI(row.lastNudgeResult, "unroutable:"))
|
|
942
|
+
continue;
|
|
943
|
+
}
|
|
944
|
+
const c = undeliveredCandidate(row, true);
|
|
945
|
+
if (c)
|
|
946
|
+
candidates.push(c);
|
|
947
|
+
}
|
|
948
|
+
for (const { qitem_id } of deps.db
|
|
949
|
+
.prepare(`SELECT qitem_id FROM queue_items
|
|
950
|
+
WHERE state = 'pending'
|
|
951
|
+
AND claimed_at IS NULL
|
|
952
|
+
AND destination_session IS NOT NULL AND destination_session != ''
|
|
953
|
+
AND ts_created <= ?
|
|
954
|
+
AND (last_nudge_result IS NULL OR last_nudge_result NOT LIKE 'failed:%')`)
|
|
955
|
+
.all(cutoff)) {
|
|
956
|
+
if (dueToYield())
|
|
957
|
+
await yieldLoop();
|
|
958
|
+
const c = unclaimedCandidate(qitem_id, true);
|
|
959
|
+
if (c)
|
|
960
|
+
candidates.push(c);
|
|
961
|
+
}
|
|
962
|
+
const custodyHours = deps.custodyWindowHours ?? STUCK_SWEEP_CUSTODY_WINDOW_HOURS;
|
|
963
|
+
const custodyCutoff = new Date(now.getTime() - custodyHours * 3_600_000).toISOString();
|
|
964
|
+
const openDanglingIds = [];
|
|
965
|
+
const danglingPrefix = "stuck-sweep:dangling-closure:";
|
|
966
|
+
for (const { tags } of deps.db
|
|
967
|
+
.prepare(`SELECT tags FROM queue_items WHERE state IN ('pending', 'in-progress', 'blocked') AND tags LIKE ?`)
|
|
968
|
+
.all(`%"${danglingPrefix}%`)) {
|
|
969
|
+
try {
|
|
970
|
+
for (const tag of JSON.parse(tags)) {
|
|
971
|
+
if (tag.startsWith(danglingPrefix)) {
|
|
972
|
+
openDanglingIds.push(tag.slice(danglingPrefix.length));
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
catch {
|
|
977
|
+
// Skip malformed tags
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
const custodyRows = deps.db
|
|
981
|
+
.prepare(
|
|
982
|
+
// Bound candidates before checking state: including handed-off in the
|
|
983
|
+
// state index scan would otherwise revisit all historical atomic handoffs.
|
|
984
|
+
`WITH custody_candidates AS MATERIALIZED (
|
|
985
|
+
SELECT qitem_id, state, handed_off_to, closure_target, closure_reason
|
|
986
|
+
FROM queue_items WHERE ts_updated >= ?
|
|
987
|
+
UNION
|
|
988
|
+
SELECT qitem_id, state, handed_off_to, closure_target, closure_reason
|
|
989
|
+
FROM queue_items WHERE qitem_id IN (SELECT value FROM json_each(?))
|
|
990
|
+
)
|
|
991
|
+
SELECT q.qitem_id FROM custody_candidates q
|
|
992
|
+
WHERE (q.state IN ('done', 'canceled') OR (q.state = 'handed-off'
|
|
993
|
+
AND (q.handed_off_to IS NULL OR q.closure_target IS NOT q.handed_off_to)))
|
|
994
|
+
AND (q.closure_target LIKE 'qitem-%' OR q.closure_reason = 'handed_off_to')`)
|
|
995
|
+
.all(custodyCutoff, JSON.stringify(openDanglingIds));
|
|
996
|
+
successors = createLinkedSuccessorLookup(deps.db, custodyRows.map((r) => r.qitem_id));
|
|
997
|
+
const lookup = successors;
|
|
998
|
+
for (const { qitem_id } of custodyRows) {
|
|
999
|
+
if (dueToYield())
|
|
1000
|
+
await yieldLoop();
|
|
1001
|
+
const c = custodyCandidate(qitem_id, (source, target) => lookup.has(source, target));
|
|
1002
|
+
if (c)
|
|
1003
|
+
candidates.push(c);
|
|
780
1004
|
}
|
|
781
1005
|
// A finding for a confirmed-missing session goes to a live recovery seat when one is available,
|
|
782
1006
|
// since nothing would ever wake the missing one (the ladder covers handed-off batons only): the
|
|
@@ -790,9 +1014,9 @@ export async function runStuckSweep(deps) {
|
|
|
790
1014
|
};
|
|
791
1015
|
const sessionMissing = deps.sessionConfirmedMissing ?? ((session) => stoppedReason(session) !== null);
|
|
792
1016
|
let recoverySeats;
|
|
793
|
-
|
|
1017
|
+
const routeAroundMissing = (c) => {
|
|
794
1018
|
if (!sessionMissing(c.route))
|
|
795
|
-
|
|
1019
|
+
return;
|
|
796
1020
|
const stoppedDescription = stoppedReason(c.route) === "pane_exited"
|
|
797
1021
|
? "has a confirmed exited pane (pane_exited)" : "is confirmed missing (session_missing)";
|
|
798
1022
|
recoverySeats ??= [(deps.resolveRecoveryAgentSeat ?? resolveRecoveryAgentSeat)(), (deps.resolveOperatorSeat ?? resolveOperatorSeat)()];
|
|
@@ -801,12 +1025,12 @@ export async function runStuckSweep(deps) {
|
|
|
801
1025
|
const floor = chosen < 0 ? null : choices[chosen];
|
|
802
1026
|
if (!floor) {
|
|
803
1027
|
c.why += `; ${c.route} ${stoppedDescription} and no live recovery seat is available (operator agent, operator seat and creator are each unset, missing or this seat; an operator agent setting that's unreadable or isn't an agent's session counts as unset), so this finding stays addressed to it`;
|
|
804
|
-
|
|
1028
|
+
return;
|
|
805
1029
|
}
|
|
806
1030
|
// Name the rule that chose it, so whoever receives the finding knows why, and which setting to change.
|
|
807
1031
|
c.why += `; ${c.route} ${stoppedDescription}, so this finding goes to ${floor}, ${RECOVERY_SEAT_RULES[chosen]}`;
|
|
808
1032
|
c.route = floor;
|
|
809
|
-
}
|
|
1033
|
+
};
|
|
810
1034
|
// A destination its own wake found unroutable, and still is (no terminal, not a person: a hosted member, or a
|
|
811
1035
|
// mistyped address), can't hear its finding either; a seat launched since its wake keeps its own. A hosted member
|
|
812
1036
|
// OpenRig rings, whose work is still unclaimed (its ring failed, or it didn't pick the work up by the unclaimed
|
|
@@ -816,14 +1040,14 @@ export async function runStuckSweep(deps) {
|
|
|
816
1040
|
// unroutable or a terminal seat itself. A bound terminal seat goes the same way: the queue wake types nothing into
|
|
817
1041
|
// it, and nothing there can claim work.
|
|
818
1042
|
const classOf = (seat) => deps.queueRepo.classifyDestinationOf(seat).class;
|
|
819
|
-
|
|
1043
|
+
const routeAroundNoWake = (c) => {
|
|
820
1044
|
if (c.route !== c.row.destinationSession)
|
|
821
|
-
|
|
1045
|
+
return;
|
|
822
1046
|
const destination = classOf(c.row.destinationSession);
|
|
823
1047
|
const noRoute = destination === "unroutable" && !!c.row.lastNudgeResult?.startsWith("unroutable:");
|
|
824
1048
|
const terminalSeat = destination === "pane-bound" && isBoundTerminalSeat(deps.db, c.row.destinationSession);
|
|
825
1049
|
if (!noRoute && !terminalSeat && !(destination === "hosted" && !c.row.claimedAt))
|
|
826
|
-
|
|
1050
|
+
return;
|
|
827
1051
|
const operatorSeat = (deps.resolveOperatorSeat ?? resolveOperatorSeat)();
|
|
828
1052
|
const person = operatorSeat && classOf(operatorSeat) === "gateway-routable" ? operatorSeat : null;
|
|
829
1053
|
const choices = [person, c.row.sourceSession, (deps.resolveRecoveryAgentSeat ?? resolveRecoveryAgentSeat)()];
|
|
@@ -836,22 +1060,76 @@ export async function runStuckSweep(deps) {
|
|
|
836
1060
|
: `; ${c.route} is a hosted member. OpenRig rang its trigger (${c.row.lastNudgeResult ?? "no ring recorded"}), and it hasn't claimed this work. It sees work only when it checks, so ask it to`;
|
|
837
1061
|
if (chosen < 0) {
|
|
838
1062
|
c.why += `. No person, creator or operator agent that can be reached is available, so this finding stays addressed to it`;
|
|
839
|
-
|
|
1063
|
+
return;
|
|
840
1064
|
}
|
|
841
1065
|
c.why += `. This finding goes to ${choices[chosen]}, ${NO_WAKE_ROUTE_RULES[chosen]}`;
|
|
842
1066
|
c.route = choices[chosen];
|
|
1067
|
+
};
|
|
1068
|
+
/** The two re-routes, in order, for one candidate. */
|
|
1069
|
+
const routeCandidate = (c) => { routeAroundMissing(c); routeAroundNoWake(c); };
|
|
1070
|
+
for (const c of candidates) {
|
|
1071
|
+
if (dueToYield())
|
|
1072
|
+
await yieldLoop();
|
|
1073
|
+
routeAroundMissing(c);
|
|
1074
|
+
}
|
|
1075
|
+
for (const c of candidates) {
|
|
1076
|
+
if (dueToYield())
|
|
1077
|
+
await yieldLoop();
|
|
1078
|
+
routeAroundNoWake(c);
|
|
843
1079
|
}
|
|
844
1080
|
// Route: idempotent per (row, kind). An existing open finding refreshes its age; a
|
|
845
1081
|
// new one is created durable + waking (the create path's default nudge).
|
|
846
1082
|
const findings = [];
|
|
847
1083
|
const liveDedupTags = new Set();
|
|
1084
|
+
const candidateIds = new Set(candidates.map((c) => c.row.qitemId));
|
|
848
1085
|
// A finding that could not be created (a row whose destination no longer resolves, say) must not
|
|
849
1086
|
// stop the others: it is reported, its row stays detected, and the pass is still a failure.
|
|
850
1087
|
const failedCreates = [];
|
|
1088
|
+
// #2430: an unclaimed row whose finding would go back to its own agent seat (no delegation parent and no escalates_to
|
|
1089
|
+
// route declared) tells that seat nothing: it already holds the row. A seat that reads its rows without claiming
|
|
1090
|
+
// them, a person's front door, got one such finding per row. Those rows share one standing notice per seat instead
|
|
1091
|
+
// (below). A finding per row stays for a person's address or a terminal seat, for a declared route that failed (its
|
|
1092
|
+
// finding names why, and a declared delegation parent with no session is one), and for a row that already has a
|
|
1093
|
+
// recovery.
|
|
1094
|
+
const agentSeats = new Map();
|
|
1095
|
+
/** An agent seat's node: one whose runtime isn't a terminal, with no declared delegation parent, at an address that
|
|
1096
|
+
* isn't a person's. An address the human registry can't classify counts as a person's. null for anything else. Read
|
|
1097
|
+
* once per seat per pass. */
|
|
1098
|
+
const agentSeatNode = (session) => {
|
|
1099
|
+
if (agentSeats.has(session))
|
|
1100
|
+
return agentSeats.get(session);
|
|
1101
|
+
const nodeId = resolveSessionNodeId(deps.db, session);
|
|
1102
|
+
const node = nodeId ? deps.db.prepare(`SELECT n.logical_id AS logicalId, n.runtime AS runtime, r.name AS rig,
|
|
1103
|
+
EXISTS (SELECT 1 FROM edges e WHERE e.target_id = n.id AND e.kind = 'delegates_to') AS parent
|
|
1104
|
+
FROM nodes n JOIN rigs r ON r.id = n.rig_id WHERE n.id = ?`)
|
|
1105
|
+
.get(nodeId) : undefined;
|
|
1106
|
+
let agent = null;
|
|
1107
|
+
try {
|
|
1108
|
+
if (node && node.runtime !== "terminal" && !node.parent && !deps.queueRepo.isHumanDestination(session)) {
|
|
1109
|
+
agent = { logicalId: node.logicalId, rig: node.rig };
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
catch { /* unclassifiable: a person's, as above */ }
|
|
1113
|
+
agentSeats.set(session, agent);
|
|
1114
|
+
return agent;
|
|
1115
|
+
};
|
|
1116
|
+
const selfRoutedUnclaimed = (c) => c.kind === "unclaimed-obligation"
|
|
1117
|
+
&& c.route === c.row.destinationSession && !routeNotes.has(c.row.qitemId) && agentSeatNode(c.route) !== null;
|
|
1118
|
+
const unclaimedBacklog = new Map();
|
|
851
1119
|
for (const c of [...new Map(candidates.map(c => [c.row.qitemId, c])).values()]) {
|
|
1120
|
+
if (dueToYield())
|
|
1121
|
+
await yieldLoop();
|
|
852
1122
|
const dedupTag = findingDedupTag(c.kind, c.row.qitemId);
|
|
853
|
-
const shared =
|
|
854
|
-
|
|
1123
|
+
const shared = recoveries.find(c.row.qitemId);
|
|
1124
|
+
if (!shared && selfRoutedUnclaimed(c)) {
|
|
1125
|
+
const rows = unclaimedBacklog.get(c.route);
|
|
1126
|
+
if (rows)
|
|
1127
|
+
rows.push(c);
|
|
1128
|
+
else
|
|
1129
|
+
unclaimedBacklog.set(c.route, [c]);
|
|
1130
|
+
continue;
|
|
1131
|
+
}
|
|
1132
|
+
const sharedRow = shared ? indexed(() => deps.queueRepo.getById(shared.qitemId)) : null;
|
|
855
1133
|
// A later accepted deadline can expire after the previous finding closed.
|
|
856
1134
|
// Its newer time is fresh evidence even when the pickup candidate wins this row.
|
|
857
1135
|
// An OPEN recovery still owns custody.
|
|
@@ -874,7 +1152,8 @@ export async function runStuckSweep(deps) {
|
|
|
874
1152
|
const humanUpdateNotice = currentKind === "unclaimed-obligation"
|
|
875
1153
|
&& c.kind === "undelivered-human-notice"
|
|
876
1154
|
&& deps.queueRepo.isRegisteredHumanUpdate(c.row);
|
|
877
|
-
if (currentKind && currentKind !== c.kind && ((pickupOrDeadline(currentKind) && pickupOrDeadline(c.kind)) || humanUpdateNotice)
|
|
1155
|
+
if (currentKind && currentKind !== c.kind && ((pickupOrDeadline(currentKind) && pickupOrDeadline(c.kind)) || humanUpdateNotice)
|
|
1156
|
+
&& stillStuck(c)) { // the new reason must still hold on the row as it is now
|
|
878
1157
|
const marker = "\n\n--- Original finding (historical) ---\n";
|
|
879
1158
|
const original = sharedRow.body.includes(marker) ? sharedRow.body.split(marker, 2)[1] : sharedRow.body;
|
|
880
1159
|
const body = evidenceBody(deps.db, c) + marker + original;
|
|
@@ -904,33 +1183,155 @@ export async function runStuckSweep(deps) {
|
|
|
904
1183
|
findings.push({ kind: c.kind, qitemId: c.row.qitemId, findingQitemId: existing.qitem_id, action: "refreshed" });
|
|
905
1184
|
}
|
|
906
1185
|
else if (renewedDeadline || !existing || evidenceIsNewer(c.evidenceAt, existing.ts_updated)) {
|
|
1186
|
+
// The row was found stuck before the pass's later yields and awaited writes: its rule runs again on the row as
|
|
1187
|
+
// it is now, and a row that no longer qualifies gets no new finding (its dedup tag stays live this pass).
|
|
1188
|
+
// the escalation note and hop recorded at listing belong to that route; keep only what this run records
|
|
1189
|
+
routeNotes.delete(c.row.qitemId);
|
|
1190
|
+
routed.delete(c.row.qitemId);
|
|
1191
|
+
const now_ = freshCandidate(c.kind, c.row.qitemId, c.jobId);
|
|
1192
|
+
if (!now_)
|
|
1193
|
+
continue;
|
|
1194
|
+
routeCandidate(now_); // its destination, reason and targets as they are now
|
|
907
1195
|
const input = {
|
|
908
1196
|
qitemId: recoveryId(deps.db, c.row.qitemId, renewedDeadline ? c.row.closureRequiredAt : undefined),
|
|
909
1197
|
// The detector is machinery, not a seat: the obligation's own creator is the
|
|
910
1198
|
// finding's source (the workflow-exception precedent).
|
|
911
1199
|
sourceSession: c.row.sourceSession,
|
|
912
|
-
destinationSession:
|
|
913
|
-
body: evidenceBody(deps.db,
|
|
914
|
-
summary:
|
|
915
|
-
? custodyHeadline(c.row.qitemId,
|
|
916
|
-
: `Stuck sweep: ${c.kind} on ${c.row.qitemId} (${
|
|
1200
|
+
destinationSession: now_.route,
|
|
1201
|
+
body: evidenceBody(deps.db, now_) + (routeNotes.has(c.row.qitemId) ? `\nescalation route: ${routeNotes.get(c.row.qitemId)}` : ""),
|
|
1202
|
+
summary: now_.verificationTargets
|
|
1203
|
+
? custodyHeadline(c.row.qitemId, now_.verificationTargets, now_.ageMinutes)
|
|
1204
|
+
: `Stuck sweep: ${c.kind} on ${c.row.qitemId} (${now_.ageMinutes} min)`,
|
|
917
1205
|
evidenceRef: `rig queue show ${c.row.qitemId}`,
|
|
918
1206
|
tags: [STUCK_SWEEP_FINDING_TAG, dedupTag, recoveryTag(c.row.qitemId),
|
|
919
|
-
...(routed.has(c.row.qitemId) ||
|
|
1207
|
+
...(routed.has(c.row.qitemId) || now_.row.tags?.includes(ESCALATION_HOP_TAG) ? [ESCALATION_HOP_TAG] : [])],
|
|
920
1208
|
// OpenRig's own finding, whoever created the stuck row.
|
|
921
1209
|
wakeTrigger: "openrig",
|
|
922
1210
|
};
|
|
923
1211
|
try {
|
|
924
1212
|
const created = await deps.queueRepo.create(input);
|
|
1213
|
+
othersMayHaveRun();
|
|
925
1214
|
findings.push({ kind: c.kind, qitemId: c.row.qitemId, findingQitemId: created.qitemId, action: "created" });
|
|
926
1215
|
}
|
|
927
1216
|
catch (err) {
|
|
928
|
-
const message = `${c.kind} finding for ${c.row.qitemId} to ${
|
|
1217
|
+
const message = `${c.kind} finding for ${c.row.qitemId} to ${now_.route} not created: ${err instanceof Error ? err.message : String(err)}`;
|
|
1218
|
+
othersMayHaveRun();
|
|
929
1219
|
log(`[stuck-sweep] ${message}`);
|
|
930
1220
|
failedCreates.push(message);
|
|
931
1221
|
}
|
|
932
1222
|
}
|
|
933
1223
|
}
|
|
1224
|
+
// A seat's standing notice for those rows. It stands for every row it has listed until that row is resolved at its
|
|
1225
|
+
// source (the evidence a finding per row needs to close: claimed, parked, closed) or gets a finding of its own, so a
|
|
1226
|
+
// detection filter (a raised threshold, the wake ladder) never reads as done. While any is left it stays open and is
|
|
1227
|
+
// rewritten in place; once none is, the sweep closes it. A closed notice, dismissed or resolved, holds back only the
|
|
1228
|
+
// rows it stood for, each only until it has newer evidence than the close: any other row files a new notice. It wakes
|
|
1229
|
+
// the seat once, when it's filed.
|
|
1230
|
+
const backlogRow = (c) => ({ qitemId: c.row.qitemId, since: c.evidenceAt, from: c.row.sourceSession, summary: c.row.summary });
|
|
1231
|
+
const backlogPrefix = unclaimedBacklogTag("");
|
|
1232
|
+
const backlogSeats = new Set(unclaimedBacklog.keys());
|
|
1233
|
+
for (const { tags } of deps.db.prepare(`SELECT tags FROM queue_items WHERE state IN ('pending', 'in-progress', 'blocked')
|
|
1234
|
+
AND (tags LIKE '%"stuck-sweep:%') AND tags LIKE ?`).all(`%"${backlogPrefix}%`)) {
|
|
1235
|
+
try {
|
|
1236
|
+
for (const tag of JSON.parse(tags))
|
|
1237
|
+
if (tag.startsWith(backlogPrefix))
|
|
1238
|
+
backlogSeats.add(tag.slice(backlogPrefix.length));
|
|
1239
|
+
}
|
|
1240
|
+
catch { /* Skip malformed tags */ }
|
|
1241
|
+
}
|
|
1242
|
+
for (const seat of backlogSeats) {
|
|
1243
|
+
if (dueToYield())
|
|
1244
|
+
await yieldLoop();
|
|
1245
|
+
const rows = unclaimedBacklog.get(seat) ?? [];
|
|
1246
|
+
const tag = unclaimedBacklogTag(seat);
|
|
1247
|
+
liveDedupTags.add(tag);
|
|
1248
|
+
const node = agentSeatNode(seat);
|
|
1249
|
+
const last = deps.db
|
|
1250
|
+
.prepare(
|
|
1251
|
+
// The first term lets the planner use idx_queue_items_recovery_tags, as the finding lookup above does.
|
|
1252
|
+
`SELECT qitem_id, state, ts_updated, summary, body FROM queue_items
|
|
1253
|
+
WHERE (tags LIKE '%"stuck-sweep:%') AND tags LIKE ? ESCAPE '\\'
|
|
1254
|
+
ORDER BY CASE WHEN state IN ('pending', 'in-progress', 'blocked') THEN 0 ELSE 1 END,
|
|
1255
|
+
ts_updated DESC, ts_created DESC, qitem_id DESC
|
|
1256
|
+
LIMIT 1`)
|
|
1257
|
+
.get(`%"${tag.replace(/[\\%_]/g, (ch) => `\\${ch}`)}"%`);
|
|
1258
|
+
if (last && ["pending", "in-progress", "blocked"].includes(last.state)) {
|
|
1259
|
+
const listedNow = new Set(rows.map((c) => c.row.qitemId));
|
|
1260
|
+
const stoodFor = backlogRowsOf(last.body);
|
|
1261
|
+
const still = [...(stoodFor ?? [])].filter((id) => !listedNow.has(id)).flatMap((id) => {
|
|
1262
|
+
const row = indexed(() => deps.queueRepo.getById(id));
|
|
1263
|
+
// Gone, someone else's now, resolved at its source, or held by a finding or recovery of its own: one actually
|
|
1264
|
+
// written, so a create that failed this pass leaves the row here.
|
|
1265
|
+
if (!row || row.destinationSession !== seat || recoveries.find(id)
|
|
1266
|
+
|| deliveryResolutionEvidence(deps, "unclaimed-obligation", id, now))
|
|
1267
|
+
return [];
|
|
1268
|
+
return [{ qitemId: id, since: pendingSince(deps.db, id) ?? row.tsCreated, from: row.sourceSession, summary: row.summary }];
|
|
1269
|
+
});
|
|
1270
|
+
const standsFor = [...rows.map(backlogRow), ...still];
|
|
1271
|
+
// With its list unreadable, the notice may still stand for rows: it's left as it is, never closed.
|
|
1272
|
+
if (standsFor.length === 0 && !stoodFor) {
|
|
1273
|
+
findings.push({ kind: "unclaimed-backlog", qitemId: seat, findingQitemId: last.qitem_id, action: "refreshed" });
|
|
1274
|
+
continue;
|
|
1275
|
+
}
|
|
1276
|
+
if (standsFor.length === 0) {
|
|
1277
|
+
await deps.queueRepo.update({
|
|
1278
|
+
qitemId: last.qitem_id,
|
|
1279
|
+
actorSession: "stuck-sweep@system",
|
|
1280
|
+
state: "done",
|
|
1281
|
+
closureReason: "no-follow-on",
|
|
1282
|
+
transitionNote: `stuck-sweep resolved: unclaimed-backlog on ${seat}: every row it stood for is claimed, parked, closed or has its own finding`,
|
|
1283
|
+
});
|
|
1284
|
+
othersMayHaveRun();
|
|
1285
|
+
findings.push({ kind: "unclaimed-backlog", qitemId: seat, findingQitemId: last.qitem_id, action: "closed" });
|
|
1286
|
+
continue;
|
|
1287
|
+
}
|
|
1288
|
+
const text = unclaimedBacklogText(seat, standsFor, ageMinutes, node);
|
|
1289
|
+
if (text.summary !== last.summary || text.body !== last.body) {
|
|
1290
|
+
deps.db.prepare("UPDATE queue_items SET body = ?, summary = ? WHERE qitem_id = ? AND body = ? AND summary IS ? AND state IN ('pending', 'in-progress', 'blocked')")
|
|
1291
|
+
.run(text.body, text.summary, last.qitem_id, last.body, last.summary);
|
|
1292
|
+
}
|
|
1293
|
+
findings.push({ kind: "unclaimed-backlog", qitemId: seat, findingQitemId: last.qitem_id, action: "refreshed" });
|
|
1294
|
+
continue;
|
|
1295
|
+
}
|
|
1296
|
+
if (rows.length === 0)
|
|
1297
|
+
continue;
|
|
1298
|
+
// Each row's rule again, on the row as it is now, as a finding per row is checked right before it's created.
|
|
1299
|
+
const current = rows.flatMap((c) => {
|
|
1300
|
+
routeNotes.delete(c.row.qitemId);
|
|
1301
|
+
routed.delete(c.row.qitemId);
|
|
1302
|
+
const now_ = freshCandidate(c.kind, c.row.qitemId);
|
|
1303
|
+
if (now_)
|
|
1304
|
+
routeCandidate(now_);
|
|
1305
|
+
return now_ && selfRoutedUnclaimed(now_) && now_.route === seat && !recoveries.find(now_.row.qitemId) ? [now_] : [];
|
|
1306
|
+
});
|
|
1307
|
+
if (current.length === 0)
|
|
1308
|
+
continue;
|
|
1309
|
+
// A closed notice whose list is unreadable holds back every row, each until it has newer evidence than the close.
|
|
1310
|
+
const covered = last ? backlogRowsOf(last.body) : null;
|
|
1311
|
+
if (last && !current.some((c) => (covered !== null && !covered.has(c.row.qitemId)) || evidenceIsNewer(c.evidenceAt, last.ts_updated)))
|
|
1312
|
+
continue;
|
|
1313
|
+
const text = unclaimedBacklogText(seat, current.map(backlogRow), ageMinutes, node);
|
|
1314
|
+
try {
|
|
1315
|
+
const created = await deps.queueRepo.create({
|
|
1316
|
+
// A notice to a seat about its own rows comes from that seat, as a restore notice does; OpenRig wakes it.
|
|
1317
|
+
sourceSession: seat,
|
|
1318
|
+
destinationSession: seat,
|
|
1319
|
+
body: text.body,
|
|
1320
|
+
summary: text.summary,
|
|
1321
|
+
evidenceRef: `rig queue list --destination ${seat} --state pending`,
|
|
1322
|
+
tags: [STUCK_SWEEP_FINDING_TAG, tag],
|
|
1323
|
+
wakeTrigger: "openrig",
|
|
1324
|
+
});
|
|
1325
|
+
othersMayHaveRun();
|
|
1326
|
+
findings.push({ kind: "unclaimed-backlog", qitemId: seat, findingQitemId: created.qitemId, action: "created" });
|
|
1327
|
+
}
|
|
1328
|
+
catch (err) {
|
|
1329
|
+
const message = `unclaimed-backlog notice for ${seat} not created: ${err instanceof Error ? err.message : String(err)}`;
|
|
1330
|
+
othersMayHaveRun();
|
|
1331
|
+
log(`[stuck-sweep] ${message}`);
|
|
1332
|
+
failedCreates.push(message);
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
934
1335
|
// Resolution: an open finding whose underlying condition is no longer detected closes
|
|
935
1336
|
// with its reason — the sweep cleans up after itself, no human unwind.
|
|
936
1337
|
const openFindings = deps.db
|
|
@@ -939,6 +1340,8 @@ export async function runStuckSweep(deps) {
|
|
|
939
1340
|
AND tags LIKE ?`)
|
|
940
1341
|
.all(`%"${STUCK_SWEEP_FINDING_TAG}"%`);
|
|
941
1342
|
for (const f of openFindings) {
|
|
1343
|
+
if (dueToYield())
|
|
1344
|
+
await yieldLoop();
|
|
942
1345
|
let tags = [];
|
|
943
1346
|
try {
|
|
944
1347
|
tags = JSON.parse(f.tags);
|
|
@@ -955,6 +1358,10 @@ export async function runStuckSweep(deps) {
|
|
|
955
1358
|
// prove resolution either: delivery/pickup findings need source evidence.
|
|
956
1359
|
if (suppressedTags.has(dedupTag))
|
|
957
1360
|
continue;
|
|
1361
|
+
// #2661: a claim working only on a grace (a background shell, a pending managed restore) is not resolved: the
|
|
1362
|
+
// grace stops new detection, and an open stall recovery stays open, so the ceiling's expiry stays actionable.
|
|
1363
|
+
if (kind === "stalled-after-claim" && stuckId && deps.queueRepo.getById(stuckId)?.pickup?.grace)
|
|
1364
|
+
continue;
|
|
958
1365
|
let resolution = "no longer detected";
|
|
959
1366
|
if (stuckId && (kind === "undelivered-wake" || kind === "undelivered-human-notice" || kind === "unclaimed-obligation")) {
|
|
960
1367
|
const evidence = deliveryResolutionEvidence(deps, kind, stuckId, now);
|
|
@@ -962,6 +1369,17 @@ export async function runStuckSweep(deps) {
|
|
|
962
1369
|
continue;
|
|
963
1370
|
resolution = evidence;
|
|
964
1371
|
}
|
|
1372
|
+
// The list was read before this loop's yields: the finding's owner may have closed it since (done -> done is
|
|
1373
|
+
// refused, and would fail the whole pass).
|
|
1374
|
+
const current = deps.db.prepare("SELECT state FROM queue_items WHERE qitem_id = ?").get(f.qitem_id);
|
|
1375
|
+
if (!current || !["pending", "in-progress", "blocked"].includes(current.state))
|
|
1376
|
+
continue;
|
|
1377
|
+
// "No longer detected" rests on lists read before this loop's yields: a row that came back (blocked, then
|
|
1378
|
+
// in-progress past its deadline) during the pass still holds, so its rule runs again on the row as it is now.
|
|
1379
|
+
// (A row this pass did find, whose finding isn't live because another recovery now holds its custody, closes as
|
|
1380
|
+
// the base closed it.)
|
|
1381
|
+
if (kind && stuckId && resolvedByRule.has(kind) && !candidateIds.has(stuckId) && ruleHolds(kind, stuckId))
|
|
1382
|
+
continue;
|
|
965
1383
|
await deps.queueRepo.update({
|
|
966
1384
|
qitemId: f.qitem_id,
|
|
967
1385
|
// The sweep performed this transition; ownership stays on the existing row.
|
|
@@ -970,6 +1388,7 @@ export async function runStuckSweep(deps) {
|
|
|
970
1388
|
closureReason: "no-follow-on",
|
|
971
1389
|
transitionNote: `stuck-sweep resolved: ${kind ?? "finding"} on ${stuckId ?? "row"} ${resolution}`,
|
|
972
1390
|
});
|
|
1391
|
+
othersMayHaveRun();
|
|
973
1392
|
if (kind && stuckId) {
|
|
974
1393
|
findings.push({
|
|
975
1394
|
kind: kind,
|