@openrig/cli 0.4.4 → 0.4.6
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/daemon/assets/plugins/openrig-core/skills/mission-slice-sop/SKILL.md +6 -8
- package/daemon/assets/plugins/openrig-core/skills/openrig-cmux/SKILL.md +86 -0
- package/daemon/assets/plugins/openrig-core/skills/openrig-herdr/SKILL.md +158 -0
- package/daemon/assets/plugins/openrig-core/skills/openrig-user/SKILL.md +744 -96
- package/daemon/dist/adapters/codex-runtime-adapter.d.ts.map +1 -1
- package/daemon/dist/adapters/codex-runtime-adapter.js +12 -8
- package/daemon/dist/adapters/codex-runtime-adapter.js.map +1 -1
- package/daemon/dist/adapters/pi-resume.d.ts +32 -0
- package/daemon/dist/adapters/pi-resume.d.ts.map +1 -0
- package/daemon/dist/adapters/pi-resume.js +125 -0
- package/daemon/dist/adapters/pi-resume.js.map +1 -0
- package/daemon/dist/adapters/pi-runner-protocol.d.ts +88 -0
- package/daemon/dist/adapters/pi-runner-protocol.d.ts.map +1 -0
- package/daemon/dist/adapters/pi-runner-protocol.js +153 -0
- package/daemon/dist/adapters/pi-runner-protocol.js.map +1 -0
- package/daemon/dist/adapters/pi-runner.d.ts +99 -0
- package/daemon/dist/adapters/pi-runner.d.ts.map +1 -0
- package/daemon/dist/adapters/pi-runner.js +519 -0
- package/daemon/dist/adapters/pi-runner.js.map +1 -0
- package/daemon/dist/adapters/pi-runtime-adapter.d.ts +61 -0
- package/daemon/dist/adapters/pi-runtime-adapter.d.ts.map +1 -0
- package/daemon/dist/adapters/pi-runtime-adapter.js +356 -0
- package/daemon/dist/adapters/pi-runtime-adapter.js.map +1 -0
- package/daemon/dist/adapters/tmux.d.ts +22 -1
- package/daemon/dist/adapters/tmux.d.ts.map +1 -1
- package/daemon/dist/adapters/tmux.js +40 -1
- package/daemon/dist/adapters/tmux.js.map +1 -1
- package/daemon/dist/build-info.js +3 -3
- package/daemon/dist/builtins/workflow-specs/branched-remediation.yaml +31 -0
- package/daemon/dist/builtins/workflow-specs/factory-rsi.yaml +152 -0
- package/daemon/dist/builtins/workflow-specs/gated-release.yaml +26 -0
- package/daemon/dist/builtins/workflow-specs/linear-build.yaml +21 -0
- package/daemon/dist/db/migrations/049_workflow_instance_version.d.ts +20 -0
- package/daemon/dist/db/migrations/049_workflow_instance_version.d.ts.map +1 -0
- package/daemon/dist/db/migrations/049_workflow_instance_version.js +24 -0
- package/daemon/dist/db/migrations/049_workflow_instance_version.js.map +1 -0
- package/daemon/dist/db/migrations/050_workflow_spec_json.d.ts +22 -0
- package/daemon/dist/db/migrations/050_workflow_spec_json.d.ts.map +1 -0
- package/daemon/dist/db/migrations/050_workflow_spec_json.js +26 -0
- package/daemon/dist/db/migrations/050_workflow_spec_json.js.map +1 -0
- package/daemon/dist/db/migrations/051_workflow_resume.d.ts +22 -0
- package/daemon/dist/db/migrations/051_workflow_resume.d.ts.map +1 -0
- package/daemon/dist/db/migrations/051_workflow_resume.js +27 -0
- package/daemon/dist/db/migrations/051_workflow_resume.js.map +1 -0
- package/daemon/dist/db/migrations/052_workflow_instance_bound_rig.d.ts +26 -0
- package/daemon/dist/db/migrations/052_workflow_instance_bound_rig.d.ts.map +1 -0
- package/daemon/dist/db/migrations/052_workflow_instance_bound_rig.js +30 -0
- package/daemon/dist/db/migrations/052_workflow_instance_bound_rig.js.map +1 -0
- package/daemon/dist/db/migrations/053_sessions_node_id_index.d.ts +48 -0
- package/daemon/dist/db/migrations/053_sessions_node_id_index.d.ts.map +1 -0
- package/daemon/dist/db/migrations/053_sessions_node_id_index.js +53 -0
- package/daemon/dist/db/migrations/053_sessions_node_id_index.js.map +1 -0
- package/daemon/dist/db/migrations/054_queue_transitions_archive.d.ts +34 -0
- package/daemon/dist/db/migrations/054_queue_transitions_archive.d.ts.map +1 -0
- package/daemon/dist/db/migrations/054_queue_transitions_archive.js +49 -0
- package/daemon/dist/db/migrations/054_queue_transitions_archive.js.map +1 -0
- package/daemon/dist/domain/claim-service.d.ts +11 -0
- package/daemon/dist/domain/claim-service.d.ts.map +1 -1
- package/daemon/dist/domain/claim-service.js +3 -1
- package/daemon/dist/domain/claim-service.js.map +1 -1
- package/daemon/dist/domain/discovery-types.d.ts +1 -1
- package/daemon/dist/domain/discovery-types.d.ts.map +1 -1
- package/daemon/dist/domain/hosts/hosts-registry-reader.d.ts +1 -0
- package/daemon/dist/domain/hosts/hosts-registry-reader.d.ts.map +1 -1
- package/daemon/dist/domain/hosts/hosts-registry-reader.js +19 -0
- package/daemon/dist/domain/hosts/hosts-registry-reader.js.map +1 -1
- package/daemon/dist/domain/hosts/hosts-registry-writer.d.ts +11 -0
- package/daemon/dist/domain/hosts/hosts-registry-writer.d.ts.map +1 -0
- package/daemon/dist/domain/hosts/hosts-registry-writer.js +54 -0
- package/daemon/dist/domain/hosts/hosts-registry-writer.js.map +1 -0
- package/daemon/dist/domain/hosts/read-through.d.ts +28 -0
- package/daemon/dist/domain/hosts/read-through.d.ts.map +1 -0
- package/daemon/dist/domain/hosts/read-through.js +139 -0
- package/daemon/dist/domain/hosts/read-through.js.map +1 -0
- package/daemon/dist/domain/hosts/remote-daemon-http.d.ts +21 -0
- package/daemon/dist/domain/hosts/remote-daemon-http.d.ts.map +1 -1
- package/daemon/dist/domain/hosts/remote-daemon-http.js +49 -0
- package/daemon/dist/domain/hosts/remote-daemon-http.js.map +1 -1
- package/daemon/dist/domain/node-inventory.d.ts +18 -0
- package/daemon/dist/domain/node-inventory.d.ts.map +1 -1
- package/daemon/dist/domain/node-inventory.js +206 -95
- package/daemon/dist/domain/node-inventory.js.map +1 -1
- package/daemon/dist/domain/node-launcher.d.ts +11 -0
- package/daemon/dist/domain/node-launcher.d.ts.map +1 -1
- package/daemon/dist/domain/node-launcher.js +10 -0
- package/daemon/dist/domain/node-launcher.js.map +1 -1
- package/daemon/dist/domain/policies/workflow-keepalive.d.ts +7 -0
- package/daemon/dist/domain/policies/workflow-keepalive.d.ts.map +1 -1
- package/daemon/dist/domain/policies/workflow-keepalive.js +93 -13
- package/daemon/dist/domain/policies/workflow-keepalive.js.map +1 -1
- package/daemon/dist/domain/ps-projection.d.ts.map +1 -1
- package/daemon/dist/domain/ps-projection.js +37 -26
- package/daemon/dist/domain/ps-projection.js.map +1 -1
- package/daemon/dist/domain/queue-repository.d.ts +105 -0
- package/daemon/dist/domain/queue-repository.d.ts.map +1 -1
- package/daemon/dist/domain/queue-repository.js +193 -4
- package/daemon/dist/domain/queue-repository.js.map +1 -1
- package/daemon/dist/domain/queue-retention.d.ts +130 -0
- package/daemon/dist/domain/queue-retention.d.ts.map +1 -0
- package/daemon/dist/domain/queue-retention.js +224 -0
- package/daemon/dist/domain/queue-retention.js.map +1 -0
- package/daemon/dist/domain/restore-orchestrator.d.ts +5 -0
- package/daemon/dist/domain/restore-orchestrator.d.ts.map +1 -1
- package/daemon/dist/domain/restore-orchestrator.js +29 -2
- package/daemon/dist/domain/restore-orchestrator.js.map +1 -1
- package/daemon/dist/domain/resume-token-capture.d.ts +13 -0
- package/daemon/dist/domain/resume-token-capture.d.ts.map +1 -1
- package/daemon/dist/domain/resume-token-capture.js +14 -1
- package/daemon/dist/domain/resume-token-capture.js.map +1 -1
- package/daemon/dist/domain/resume-token-validation.d.ts +1 -1
- package/daemon/dist/domain/resume-token-validation.d.ts.map +1 -1
- package/daemon/dist/domain/resume-token-validation.js +58 -10
- package/daemon/dist/domain/resume-token-validation.js.map +1 -1
- package/daemon/dist/domain/review/compose.d.ts +50 -1
- package/daemon/dist/domain/review/compose.d.ts.map +1 -1
- package/daemon/dist/domain/review/compose.js +92 -3
- package/daemon/dist/domain/review/compose.js.map +1 -1
- package/daemon/dist/domain/review/fleet-compose.d.ts +52 -0
- package/daemon/dist/domain/review/fleet-compose.d.ts.map +1 -0
- package/daemon/dist/domain/review/fleet-compose.js +294 -0
- package/daemon/dist/domain/review/fleet-compose.js.map +1 -0
- package/daemon/dist/domain/review/gather.d.ts +16 -1
- package/daemon/dist/domain/review/gather.d.ts.map +1 -1
- package/daemon/dist/domain/review/gather.js +177 -41
- package/daemon/dist/domain/review/gather.js.map +1 -1
- package/daemon/dist/domain/review/types.d.ts +104 -1
- package/daemon/dist/domain/review/types.d.ts.map +1 -1
- package/daemon/dist/domain/rig-expansion-service.d.ts.map +1 -1
- package/daemon/dist/domain/rig-expansion-service.js +3 -0
- package/daemon/dist/domain/rig-expansion-service.js.map +1 -1
- package/daemon/dist/domain/rig-repository.d.ts +7 -6
- package/daemon/dist/domain/rig-repository.d.ts.map +1 -1
- package/daemon/dist/domain/rig-repository.js +33 -11
- 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 +3 -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 +4 -0
- package/daemon/dist/domain/rigspec-exporter.js.map +1 -1
- package/daemon/dist/domain/rigspec-instantiator.d.ts.map +1 -1
- package/daemon/dist/domain/rigspec-instantiator.js +11 -0
- package/daemon/dist/domain/rigspec-instantiator.js.map +1 -1
- package/daemon/dist/domain/rigspec-preflight.d.ts +6 -0
- package/daemon/dist/domain/rigspec-preflight.d.ts.map +1 -1
- package/daemon/dist/domain/rigspec-preflight.js +26 -1
- 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 +20 -1
- package/daemon/dist/domain/rigspec-schema.js.map +1 -1
- package/daemon/dist/domain/runtime-verifier.d.ts +7 -1
- package/daemon/dist/domain/runtime-verifier.d.ts.map +1 -1
- package/daemon/dist/domain/runtime-verifier.js +39 -1
- package/daemon/dist/domain/runtime-verifier.js.map +1 -1
- package/daemon/dist/domain/seat-handover-service.d.ts +9 -0
- package/daemon/dist/domain/seat-handover-service.d.ts.map +1 -1
- package/daemon/dist/domain/seat-handover-service.js +2 -0
- package/daemon/dist/domain/seat-handover-service.js.map +1 -1
- package/daemon/dist/domain/seat-identity-store.d.ts +7 -0
- package/daemon/dist/domain/seat-identity-store.d.ts.map +1 -1
- package/daemon/dist/domain/seat-identity-store.js +27 -0
- package/daemon/dist/domain/seat-identity-store.js.map +1 -1
- package/daemon/dist/domain/seat-status-service.d.ts.map +1 -1
- package/daemon/dist/domain/seat-status-service.js +6 -4
- package/daemon/dist/domain/seat-status-service.js.map +1 -1
- package/daemon/dist/domain/session-name.d.ts +22 -0
- package/daemon/dist/domain/session-name.d.ts.map +1 -1
- package/daemon/dist/domain/session-name.js +29 -0
- package/daemon/dist/domain/session-name.js.map +1 -1
- package/daemon/dist/domain/slices/slice-detail-projector.d.ts.map +1 -1
- package/daemon/dist/domain/slices/slice-detail-projector.js +4 -5
- package/daemon/dist/domain/slices/slice-detail-projector.js.map +1 -1
- package/daemon/dist/domain/spec-library-workflow-scanner.d.ts +18 -2
- package/daemon/dist/domain/spec-library-workflow-scanner.d.ts.map +1 -1
- package/daemon/dist/domain/spec-library-workflow-scanner.js +23 -1
- package/daemon/dist/domain/spec-library-workflow-scanner.js.map +1 -1
- package/daemon/dist/domain/startup-proof.d.ts +10 -6
- package/daemon/dist/domain/startup-proof.d.ts.map +1 -1
- package/daemon/dist/domain/startup-proof.js +35 -7
- package/daemon/dist/domain/startup-proof.js.map +1 -1
- package/daemon/dist/domain/successor-session-launcher.d.ts +16 -0
- package/daemon/dist/domain/successor-session-launcher.d.ts.map +1 -1
- package/daemon/dist/domain/successor-session-launcher.js +13 -0
- package/daemon/dist/domain/successor-session-launcher.js.map +1 -1
- package/daemon/dist/domain/terminal/cmux-provider-adapter.d.ts +27 -0
- package/daemon/dist/domain/terminal/cmux-provider-adapter.d.ts.map +1 -0
- package/daemon/dist/domain/terminal/cmux-provider-adapter.js +67 -0
- package/daemon/dist/domain/terminal/cmux-provider-adapter.js.map +1 -0
- package/daemon/dist/domain/terminal/herdr-adapter.d.ts +77 -0
- package/daemon/dist/domain/terminal/herdr-adapter.d.ts.map +1 -0
- package/daemon/dist/domain/terminal/herdr-adapter.js +266 -0
- package/daemon/dist/domain/terminal/herdr-adapter.js.map +1 -0
- package/daemon/dist/domain/terminal/herdr-transport.d.ts +50 -0
- package/daemon/dist/domain/terminal/herdr-transport.d.ts.map +1 -0
- package/daemon/dist/domain/terminal/herdr-transport.js +145 -0
- package/daemon/dist/domain/terminal/herdr-transport.js.map +1 -0
- package/daemon/dist/domain/terminal/terminal-provider.d.ts +88 -0
- package/daemon/dist/domain/terminal/terminal-provider.d.ts.map +1 -0
- package/daemon/dist/domain/terminal/terminal-provider.js +17 -0
- package/daemon/dist/domain/terminal/terminal-provider.js.map +1 -0
- package/daemon/dist/domain/terminal/terminal-service.d.ts +60 -0
- package/daemon/dist/domain/terminal/terminal-service.d.ts.map +1 -0
- package/daemon/dist/domain/terminal/terminal-service.js +174 -0
- package/daemon/dist/domain/terminal/terminal-service.js.map +1 -0
- package/daemon/dist/domain/terminal/terminal-views-store.d.ts +77 -0
- package/daemon/dist/domain/terminal/terminal-views-store.d.ts.map +1 -0
- package/daemon/dist/domain/terminal/terminal-views-store.js +146 -0
- package/daemon/dist/domain/terminal/terminal-views-store.js.map +1 -0
- package/daemon/dist/domain/terminal/view-composer.d.ts +42 -0
- package/daemon/dist/domain/terminal/view-composer.d.ts.map +1 -0
- package/daemon/dist/domain/terminal/view-composer.js +137 -0
- package/daemon/dist/domain/terminal/view-composer.js.map +1 -0
- package/daemon/dist/domain/tmux-option-defaults.d.ts +89 -0
- package/daemon/dist/domain/tmux-option-defaults.d.ts.map +1 -0
- package/daemon/dist/domain/tmux-option-defaults.js +132 -0
- package/daemon/dist/domain/tmux-option-defaults.js.map +1 -0
- package/daemon/dist/domain/types.d.ts +34 -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 +92 -0
- package/daemon/dist/domain/user-settings/settings-store.js.map +1 -1
- package/daemon/dist/domain/workflow/slice-workflow-projection.d.ts.map +1 -1
- package/daemon/dist/domain/workflow/slice-workflow-projection.js +6 -2
- package/daemon/dist/domain/workflow/slice-workflow-projection.js.map +1 -1
- package/daemon/dist/domain/workflow-boot-sweep.d.ts +28 -0
- package/daemon/dist/domain/workflow-boot-sweep.d.ts.map +1 -0
- package/daemon/dist/domain/workflow-boot-sweep.js +102 -0
- package/daemon/dist/domain/workflow-boot-sweep.js.map +1 -0
- package/daemon/dist/domain/workflow-deadline.d.ts +74 -0
- package/daemon/dist/domain/workflow-deadline.d.ts.map +1 -0
- package/daemon/dist/domain/workflow-deadline.js +165 -0
- package/daemon/dist/domain/workflow-deadline.js.map +1 -0
- package/daemon/dist/domain/workflow-exception-escalation.d.ts +33 -0
- package/daemon/dist/domain/workflow-exception-escalation.d.ts.map +1 -0
- package/daemon/dist/domain/workflow-exception-escalation.js +104 -0
- package/daemon/dist/domain/workflow-exception-escalation.js.map +1 -0
- package/daemon/dist/domain/workflow-exception-router.d.ts +33 -0
- package/daemon/dist/domain/workflow-exception-router.d.ts.map +1 -0
- package/daemon/dist/domain/workflow-exception-router.js +96 -0
- package/daemon/dist/domain/workflow-exception-router.js.map +1 -0
- package/daemon/dist/domain/workflow-exception.d.ts +90 -0
- package/daemon/dist/domain/workflow-exception.d.ts.map +1 -0
- package/daemon/dist/domain/workflow-exception.js +122 -0
- package/daemon/dist/domain/workflow-exception.js.map +1 -0
- package/daemon/dist/domain/workflow-frontier-guard.d.ts +24 -0
- package/daemon/dist/domain/workflow-frontier-guard.d.ts.map +1 -0
- package/daemon/dist/domain/workflow-frontier-guard.js +30 -0
- package/daemon/dist/domain/workflow-frontier-guard.js.map +1 -0
- package/daemon/dist/domain/workflow-instance-store.d.ts +28 -0
- package/daemon/dist/domain/workflow-instance-store.d.ts.map +1 -1
- package/daemon/dist/domain/workflow-instance-store.js +66 -10
- package/daemon/dist/domain/workflow-instance-store.js.map +1 -1
- package/daemon/dist/domain/workflow-keepalive-arming.d.ts +35 -0
- package/daemon/dist/domain/workflow-keepalive-arming.d.ts.map +1 -0
- package/daemon/dist/domain/workflow-keepalive-arming.js +87 -0
- package/daemon/dist/domain/workflow-keepalive-arming.js.map +1 -0
- package/daemon/dist/domain/workflow-projector.d.ts +117 -2
- package/daemon/dist/domain/workflow-projector.d.ts.map +1 -1
- package/daemon/dist/domain/workflow-projector.js +672 -41
- package/daemon/dist/domain/workflow-projector.js.map +1 -1
- package/daemon/dist/domain/workflow-role-context.d.ts +57 -0
- package/daemon/dist/domain/workflow-role-context.d.ts.map +1 -0
- package/daemon/dist/domain/workflow-role-context.js +120 -0
- package/daemon/dist/domain/workflow-role-context.js.map +1 -0
- package/daemon/dist/domain/workflow-role-resolver.d.ts +65 -0
- package/daemon/dist/domain/workflow-role-resolver.d.ts.map +1 -0
- package/daemon/dist/domain/workflow-role-resolver.js +108 -0
- package/daemon/dist/domain/workflow-role-resolver.js.map +1 -0
- package/daemon/dist/domain/workflow-runtime.d.ts +157 -1
- package/daemon/dist/domain/workflow-runtime.d.ts.map +1 -1
- package/daemon/dist/domain/workflow-runtime.js +718 -11
- package/daemon/dist/domain/workflow-runtime.js.map +1 -1
- package/daemon/dist/domain/workflow-spec-cache.d.ts +26 -1
- package/daemon/dist/domain/workflow-spec-cache.d.ts.map +1 -1
- package/daemon/dist/domain/workflow-spec-cache.js +327 -13
- package/daemon/dist/domain/workflow-spec-cache.js.map +1 -1
- package/daemon/dist/domain/workflow-types.d.ts +143 -8
- package/daemon/dist/domain/workflow-types.d.ts.map +1 -1
- package/daemon/dist/domain/workflow-types.js +14 -1
- package/daemon/dist/domain/workflow-types.js.map +1 -1
- package/daemon/dist/domain/workflow-validator.d.ts +11 -1
- package/daemon/dist/domain/workflow-validator.d.ts.map +1 -1
- package/daemon/dist/domain/workflow-validator.js +246 -1
- package/daemon/dist/domain/workflow-validator.js.map +1 -1
- package/daemon/dist/index.d.ts +17 -0
- package/daemon/dist/index.d.ts.map +1 -1
- package/daemon/dist/index.js +44 -0
- package/daemon/dist/index.js.map +1 -1
- package/daemon/dist/routes/activity.js +22 -0
- package/daemon/dist/routes/activity.js.map +1 -1
- package/daemon/dist/routes/hosts.d.ts +5 -0
- package/daemon/dist/routes/hosts.d.ts.map +1 -0
- package/daemon/dist/routes/hosts.js +346 -0
- package/daemon/dist/routes/hosts.js.map +1 -0
- package/daemon/dist/routes/queue.d.ts +2 -7
- package/daemon/dist/routes/queue.d.ts.map +1 -1
- package/daemon/dist/routes/queue.js +264 -9
- package/daemon/dist/routes/queue.js.map +1 -1
- package/daemon/dist/routes/review.d.ts.map +1 -1
- package/daemon/dist/routes/review.js +26 -0
- package/daemon/dist/routes/review.js.map +1 -1
- package/daemon/dist/routes/seat.js +13 -0
- package/daemon/dist/routes/seat.js.map +1 -1
- package/daemon/dist/routes/terminal.d.ts +11 -0
- package/daemon/dist/routes/terminal.d.ts.map +1 -0
- package/daemon/dist/routes/terminal.js +104 -0
- package/daemon/dist/routes/terminal.js.map +1 -0
- package/daemon/dist/routes/workflow.d.ts.map +1 -1
- package/daemon/dist/routes/workflow.js +102 -10
- package/daemon/dist/routes/workflow.js.map +1 -1
- package/daemon/dist/server.d.ts +5 -0
- package/daemon/dist/server.d.ts.map +1 -1
- package/daemon/dist/server.js +22 -0
- package/daemon/dist/server.js.map +1 -1
- package/daemon/dist/startup.d.ts.map +1 -1
- package/daemon/dist/startup.js +221 -12
- package/daemon/dist/startup.js.map +1 -1
- package/daemon/specs/agents/factory-rsi/dogfood/agent.yaml +29 -0
- package/daemon/specs/agents/factory-rsi/dogfood/guidance/role.md +37 -0
- package/daemon/specs/agents/factory-rsi/release-manager/agent.yaml +29 -0
- package/daemon/specs/agents/factory-rsi/release-manager/guidance/role.md +40 -0
- package/daemon/specs/agents/shared/skills/core/mission-slice-sop/SKILL.md +6 -8
- package/daemon/specs/agents/shared/skills/core/openrig-cmux/SKILL.md +86 -0
- package/daemon/specs/agents/shared/skills/core/openrig-herdr/SKILL.md +158 -0
- package/daemon/specs/agents/shared/skills/core/openrig-user/SKILL.md +6 -6
- package/daemon/specs/rigs/launch/factory-rsi/CULTURE.md +47 -0
- package/daemon/specs/rigs/launch/factory-rsi/rig.yaml +115 -0
- package/dist/build-info.js +3 -3
- package/dist/commands/broadcast.d.ts +6 -1
- package/dist/commands/broadcast.d.ts.map +1 -1
- package/dist/commands/broadcast.js +101 -15
- package/dist/commands/broadcast.js.map +1 -1
- package/dist/commands/capture.d.ts.map +1 -1
- package/dist/commands/capture.js +99 -8
- package/dist/commands/capture.js.map +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +4 -0
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/down.d.ts.map +1 -1
- package/dist/commands/down.js +5 -0
- package/dist/commands/down.js.map +1 -1
- package/dist/commands/host.d.ts +14 -0
- package/dist/commands/host.d.ts.map +1 -1
- package/dist/commands/host.js +338 -14
- package/dist/commands/host.js.map +1 -1
- package/dist/commands/launch.d.ts.map +1 -1
- package/dist/commands/launch.js +5 -0
- package/dist/commands/launch.js.map +1 -1
- package/dist/commands/ps.d.ts.map +1 -1
- package/dist/commands/ps.js +10 -4
- package/dist/commands/ps.js.map +1 -1
- package/dist/commands/queue.d.ts +36 -0
- package/dist/commands/queue.d.ts.map +1 -1
- package/dist/commands/queue.js +73 -7
- package/dist/commands/queue.js.map +1 -1
- package/dist/commands/restore-packet.d.ts.map +1 -1
- package/dist/commands/restore-packet.js +13 -2
- package/dist/commands/restore-packet.js.map +1 -1
- package/dist/commands/send.d.ts.map +1 -1
- package/dist/commands/send.js +114 -9
- package/dist/commands/send.js.map +1 -1
- package/dist/commands/terminal.d.ts +6 -0
- package/dist/commands/terminal.d.ts.map +1 -0
- package/dist/commands/terminal.js +116 -0
- package/dist/commands/terminal.js.map +1 -0
- package/dist/commands/transcript.d.ts +6 -1
- package/dist/commands/transcript.d.ts.map +1 -1
- package/dist/commands/transcript.js +113 -30
- package/dist/commands/transcript.js.map +1 -1
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +9 -0
- package/dist/commands/up.js.map +1 -1
- package/dist/commands/whoami.d.ts.map +1 -1
- package/dist/commands/whoami.js +11 -0
- package/dist/commands/whoami.js.map +1 -1
- package/dist/commands/workflow-errors.d.ts +23 -0
- package/dist/commands/workflow-errors.d.ts.map +1 -0
- package/dist/commands/workflow-errors.js +100 -0
- package/dist/commands/workflow-errors.js.map +1 -0
- package/dist/commands/workflow-follow.d.ts +71 -0
- package/dist/commands/workflow-follow.d.ts.map +1 -0
- package/dist/commands/workflow-follow.js +259 -0
- package/dist/commands/workflow-follow.js.map +1 -0
- package/dist/commands/workflow-render.d.ts +114 -0
- package/dist/commands/workflow-render.d.ts.map +1 -0
- package/dist/commands/workflow-render.js +223 -0
- package/dist/commands/workflow-render.js.map +1 -0
- package/dist/commands/workflow.d.ts +1 -0
- package/dist/commands/workflow.d.ts.map +1 -1
- package/dist/commands/workflow.js +278 -14
- package/dist/commands/workflow.js.map +1 -1
- package/dist/config-store.d.ts +15 -1
- package/dist/config-store.d.ts.map +1 -1
- package/dist/config-store.js +103 -0
- package/dist/config-store.js.map +1 -1
- package/dist/cross-host-cli-helpers.d.ts +13 -0
- package/dist/cross-host-cli-helpers.d.ts.map +1 -1
- package/dist/cross-host-cli-helpers.js +27 -0
- package/dist/cross-host-cli-helpers.js.map +1 -1
- package/dist/cross-host-target.d.ts +49 -0
- package/dist/cross-host-target.d.ts.map +1 -0
- package/dist/cross-host-target.js +35 -0
- package/dist/cross-host-target.js.map +1 -0
- package/dist/host-registry.d.ts +8 -0
- package/dist/host-registry.d.ts.map +1 -1
- package/dist/host-registry.js +32 -0
- package/dist/host-registry.js.map +1 -1
- package/dist/host-selection.d.ts +13 -0
- package/dist/host-selection.d.ts.map +1 -0
- package/dist/host-selection.js +54 -0
- package/dist/host-selection.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/remote-host-ops.d.ts +1 -0
- package/dist/remote-host-ops.d.ts.map +1 -1
- package/dist/remote-host-ops.js +11 -4
- package/dist/remote-host-ops.js.map +1 -1
- package/dist/session-name.d.ts +23 -0
- package/dist/session-name.d.ts.map +1 -0
- package/dist/session-name.js +61 -0
- package/dist/session-name.js.map +1 -0
- package/package.json +1 -1
- package/ui/dist/assets/index-CFqxa0zW.css +32 -0
- package/ui/dist/assets/index-zrFqS7gL.js +623 -0
- package/ui/dist/index.html +2 -2
- package/ui/dist/assets/index-D69ZhNIr.js +0 -598
- package/ui/dist/assets/index-DJYun-8d.css +0 -32
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// OPR.0.4.6.WF1 FR-4 (G5): the startup resume sweep — the workflow
|
|
2
|
+
// twin of the existing rig/session boot reconcile.
|
|
3
|
+
//
|
|
4
|
+
// Before this slice NOTHING re-examined in-flight workflow instances
|
|
5
|
+
// at daemon boot: a nudge lost to the commit-then-crash window stayed
|
|
6
|
+
// lost, keepalives armed in a prior process (or never armed, pre-WF-1)
|
|
7
|
+
// stayed dead, and a stuck instance surfaced nowhere. The sweep closes
|
|
8
|
+
// all three on every boot:
|
|
9
|
+
//
|
|
10
|
+
// 1. RE-ARM — every active|waiting instance gets its per-instance
|
|
11
|
+
// keepalive ensured (idempotent; heals pre-WF-1 instances that
|
|
12
|
+
// never had one).
|
|
13
|
+
// 2. LOST-NUDGE RECOVERY — a PENDING frontier packet whose
|
|
14
|
+
// last_nudge_attempt is NULL was routed but never nudged (the
|
|
15
|
+
// daemon died between the scribe commit and the post-commit
|
|
16
|
+
// nudge — the exact FR-3 window). It is re-nudged NOW, not after
|
|
17
|
+
// a threshold: the potato is provably alive on restart.
|
|
18
|
+
// 3. DEADLINE EVALUATION — the FR-2 evaluator runs over each
|
|
19
|
+
// instance's frontier; overdue instances are surfaced (log line +
|
|
20
|
+
// re-nudge with the stuck steering) — never silently parked.
|
|
21
|
+
//
|
|
22
|
+
// The sweep is observable: ONE summary line naming counts. Zero
|
|
23
|
+
// in-flight instances → a no-op (no state side effects).
|
|
24
|
+
//
|
|
25
|
+
// BR-2 holds: the sweep arms, nudges, and logs — it never advances an
|
|
26
|
+
// instance (project() stays the sole advance write path).
|
|
27
|
+
import { evaluateStepDeadline } from "./workflow-deadline.js";
|
|
28
|
+
import { ensureWorkflowKeepaliveArmed } from "./workflow-keepalive-arming.js";
|
|
29
|
+
export async function runWorkflowBootSweep(deps) {
|
|
30
|
+
const log = deps.log ?? (() => { });
|
|
31
|
+
const now = (deps.now ?? (() => new Date()))();
|
|
32
|
+
const instances = [
|
|
33
|
+
...deps.instanceStore.listByStatus("active"),
|
|
34
|
+
...deps.instanceStore.listByStatus("waiting"),
|
|
35
|
+
];
|
|
36
|
+
const result = {
|
|
37
|
+
instancesSwept: instances.length,
|
|
38
|
+
keepalivesArmed: 0,
|
|
39
|
+
lostNudgesReissued: 0,
|
|
40
|
+
stuckSurfaced: 0,
|
|
41
|
+
exceptionItemsCreated: 0,
|
|
42
|
+
};
|
|
43
|
+
if (instances.length === 0) {
|
|
44
|
+
log("workflow boot sweep: 0 in-flight instances (no-op)");
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
for (const instance of instances) {
|
|
48
|
+
const packets = instance.currentFrontier
|
|
49
|
+
.map((id) => deps.queueRepo.getById(id))
|
|
50
|
+
.filter((p) => p != null);
|
|
51
|
+
// 1. Re-arm the keepalive (idempotent; heals pre-WF-1 instances).
|
|
52
|
+
const fallbackOwner = packets[0]?.destinationSession ?? instance.createdBySession;
|
|
53
|
+
if (fallbackOwner && fallbackOwner.includes("@")) {
|
|
54
|
+
const armed = ensureWorkflowKeepaliveArmed(deps.watchdogJobsRepo, {
|
|
55
|
+
instanceId: instance.instanceId,
|
|
56
|
+
targetSession: fallbackOwner,
|
|
57
|
+
registeredBySession: instance.createdBySession,
|
|
58
|
+
});
|
|
59
|
+
if (armed.newlyArmed)
|
|
60
|
+
result.keepalivesArmed += 1;
|
|
61
|
+
}
|
|
62
|
+
// 2. Lost-nudge recovery: routed-but-never-nudged pending packets.
|
|
63
|
+
for (const packet of packets) {
|
|
64
|
+
if (packet.state === "pending" && packet.lastNudgeAttempt === null) {
|
|
65
|
+
result.lostNudgesReissued += 1;
|
|
66
|
+
await deps.queueRepo.maybeNudge(packet.qitemId, packet.destinationSession, undefined, instance.createdBySession);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// 3. Deadline evaluation (derived; the unclaimed frontier is a
|
|
70
|
+
// FIRST-CLASS case here — never invisible to an in-progress-only
|
|
71
|
+
// scan like findOverdue).
|
|
72
|
+
const verdict = evaluateStepDeadline(instance, packets, now);
|
|
73
|
+
if (verdict.state !== "healthy" && verdict.evidence) {
|
|
74
|
+
result.stuckSurfaced += 1;
|
|
75
|
+
log(`workflow boot sweep: instance ${instance.instanceId} STUCK (${verdict.state}) — step ${verdict.evidence.stepId ?? "?"}, packet ${verdict.evidence.packetId}, owner ${verdict.evidence.ownerSession}, anchor ${verdict.evidence.anchor}@${verdict.evidence.anchorAt}, overdue ${verdict.evidence.overdueBySeconds}s`);
|
|
76
|
+
// Re-nudge the overdue owner (the keepalive will keep firing on
|
|
77
|
+
// its own cadence; boot gives the immediate wake).
|
|
78
|
+
await deps.queueRepo.maybeNudge(verdict.evidence.packetId, verdict.evidence.ownerSession, undefined, instance.createdBySession);
|
|
79
|
+
// OPR.0.4.6.WF5 FR-2 class (b): ensure the durable exception item
|
|
80
|
+
// at detection. Non-fatal: an item failure must not break the
|
|
81
|
+
// sweep's other legs (the next pass re-detects — the guarantee).
|
|
82
|
+
if (deps.ensureStuckExceptionItem) {
|
|
83
|
+
try {
|
|
84
|
+
const ensured = await deps.ensureStuckExceptionItem({
|
|
85
|
+
workflowName: instance.workflowName,
|
|
86
|
+
workflowVersion: instance.workflowVersion,
|
|
87
|
+
createdBySession: instance.createdBySession,
|
|
88
|
+
verdict,
|
|
89
|
+
});
|
|
90
|
+
if (ensured.outcome === "created")
|
|
91
|
+
result.exceptionItemsCreated += 1;
|
|
92
|
+
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
log(`workflow boot sweep: exception-item ensure failed (non-fatal) for ${instance.instanceId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
log(`workflow boot sweep: ${result.instancesSwept} in-flight instance(s) — ${result.keepalivesArmed} keepalive(s) armed, ${result.lostNudgesReissued} lost nudge(s) reissued, ${result.stuckSurfaced} stuck surfaced, ${result.exceptionItemsCreated} exception item(s) created`);
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=workflow-boot-sweep.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-boot-sweep.js","sourceRoot":"","sources":["../../src/domain/workflow-boot-sweep.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,mDAAmD;AACnD,EAAE;AACF,qEAAqE;AACrE,sEAAsE;AACtE,uEAAuE;AACvE,uEAAuE;AACvE,2BAA2B;AAC3B,EAAE;AACF,oEAAoE;AACpE,oEAAoE;AACpE,uBAAuB;AACvB,6DAA6D;AAC7D,mEAAmE;AACnE,iEAAiE;AACjE,sEAAsE;AACtE,6DAA6D;AAC7D,+DAA+D;AAC/D,uEAAuE;AACvE,kEAAkE;AAClE,EAAE;AACF,gEAAgE;AAChE,yDAAyD;AACzD,EAAE;AACF,sEAAsE;AACtE,0DAA0D;AAK1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AA0B9E,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,IAA2B;IAE3B,MAAM,GAAG,GAAG,IAAI,CAA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C,YAAY,EAC7B,SAAS,EACT,QAAQ,CAAC,gBAAgB,CAC1B,CAAC;YACF,kEAAkE;YAClE,8DAA8D;YAC9D,iEAAiE;YACjE,IAAI,IAAI,CAAC,wBAAwB,EAAE,CAAC;gBAClC,IAAI,CAAC;oBACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,wBAAwB,CAAC;wBAClD,YAAY,EAAE,QAAQ,CAAC,YAAY;wBACnC,eAAe,EAAE,QAAQ,CAAC,eAAe;wBACzC,gBAAgB,EAAE,QAAQ,CAAC,gBAAgB;wBAC3C,OAAO;qBACR,CAAC,CAAC;oBACH,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS;wBAAE,MAAM,CAAC,qBAAqB,IAAI,CAAC,CAAC;gBACvE,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,GAAG,CACD,qEAAqE,QAAQ,CAAC,UAAU,KAAK,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAChJ,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,GAAG,CACD,wBAAwB,MAAM,CAAC,cAAc,4BAA4B,MAAM,CAAC,eAAe,wBAAwB,MAAM,CAAC,kBAAkB,4BAA4B,MAAM,CAAC,aAAa,oBAAoB,MAAM,CAAC,qBAAqB,4BAA4B,CAC7Q,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export interface DeadlineInstanceView {
|
|
2
|
+
instanceId: string;
|
|
3
|
+
status: string;
|
|
4
|
+
currentFrontier: string[];
|
|
5
|
+
currentStepId: string | null;
|
|
6
|
+
}
|
|
7
|
+
export interface DeadlinePacketView {
|
|
8
|
+
qitemId: string;
|
|
9
|
+
state: string;
|
|
10
|
+
destinationSession: string;
|
|
11
|
+
tsCreated: string;
|
|
12
|
+
claimedAt: string | null;
|
|
13
|
+
closureRequiredAt: string | null;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* THE single threshold home (arch gate-leg ruling: EXPORTED, documented
|
|
17
|
+
* as the one place this number lives — WF-5's class-(b) stuck/overdue
|
|
18
|
+
* thresholds bind to this constant by ruling; they never redefine it).
|
|
19
|
+
*
|
|
20
|
+
* Derivation: the shipped routine-tier SLA (TIER_SLA_SECONDS.routine =
|
|
21
|
+
* 4h in hot-potato-enforcer.ts — module-private there, so the value is
|
|
22
|
+
* restated rather than imported; the derivation is this sentence).
|
|
23
|
+
* Workflow step packets carry tier "mode2" with no SLA entry, so this
|
|
24
|
+
* constant is the effective deadline for both unclaimed anchors and
|
|
25
|
+
* the claimed-null-deadline anchor.
|
|
26
|
+
*/
|
|
27
|
+
export declare const WORKFLOW_STEP_STUCK_THRESHOLD_SECONDS: number;
|
|
28
|
+
export type WorkflowStepDeadlineState = "healthy" | "overdue-claimed" | "overdue-unclaimed";
|
|
29
|
+
export interface WorkflowStepDeadlineEvidence {
|
|
30
|
+
instanceId: string;
|
|
31
|
+
/** The instance's durable current step binding (may be null pre-R2). */
|
|
32
|
+
stepId: string | null;
|
|
33
|
+
packetId: string;
|
|
34
|
+
ownerSession: string;
|
|
35
|
+
packetState: string;
|
|
36
|
+
/** Which anchor classified this packet (the JSDoc classification). */
|
|
37
|
+
anchor: "closure_required_at" | "claimed_at" | "created_at";
|
|
38
|
+
/** ISO timestamp the anchor points at (deadline or anchor start). */
|
|
39
|
+
anchorAt: string;
|
|
40
|
+
/** Seconds past the effective deadline (>= 0 when overdue). */
|
|
41
|
+
overdueBySeconds: number;
|
|
42
|
+
/** Age of the packet since creation, seconds. */
|
|
43
|
+
ageSeconds: number;
|
|
44
|
+
/** claimed_at when the row still carries it (sub-states 1/2). */
|
|
45
|
+
claimedAt: string | null;
|
|
46
|
+
}
|
|
47
|
+
export interface WorkflowDeadlineVerdict {
|
|
48
|
+
state: WorkflowStepDeadlineState;
|
|
49
|
+
/** Present iff state != healthy. */
|
|
50
|
+
evidence: WorkflowStepDeadlineEvidence | null;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Evaluate one instance's frontier against the deadline model. Pure:
|
|
54
|
+
* (instance, packets, now) -> verdict. `packets` are the queue rows
|
|
55
|
+
* for instance.currentFrontier (missing rows are ignored — a frontier
|
|
56
|
+
* id that no longer resolves is a different corruption class, guarded
|
|
57
|
+
* elsewhere).
|
|
58
|
+
*
|
|
59
|
+
* Only `active` and `waiting` instances can be overdue; terminal
|
|
60
|
+
* instances are always healthy (nothing to nudge).
|
|
61
|
+
*/
|
|
62
|
+
export declare function evaluateStepDeadline(instance: DeadlineInstanceView, packets: Array<DeadlinePacketView | null | undefined>, now: Date): WorkflowDeadlineVerdict;
|
|
63
|
+
/**
|
|
64
|
+
* FR-6 (G4) helper: the max_hops comparison, structured against an
|
|
65
|
+
* EFFECTIVE BASELINE (arch N1 ruling). v1 pins baseline = 0
|
|
66
|
+
* (MAX_HOPS_BASELINE_V1); WF-5 FR-4's resume later amends the baseline
|
|
67
|
+
* so each redrive gets one bounded window — this helper is the seam,
|
|
68
|
+
* never hard-welded to lifetime-total.
|
|
69
|
+
*
|
|
70
|
+
* Returns true when executing ONE MORE hop would exceed the guard.
|
|
71
|
+
*/
|
|
72
|
+
export declare const MAX_HOPS_BASELINE_V1 = 0;
|
|
73
|
+
export declare function exceedsMaxHops(hopCount: number, baseline: number, maxHops: number | undefined): boolean;
|
|
74
|
+
//# sourceMappingURL=workflow-deadline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-deadline.d.ts","sourceRoot":"","sources":["../../src/domain/workflow-deadline.ts"],"names":[],"mappings":"AAwDA,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,aAAa,EAAE,MAAM,GAAG,IAAI,CA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;AAEtC,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,OAAO,CAST"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// OPR.0.4.6.WF1 FR-2: the step-deadline evaluator (pure).
|
|
2
|
+
//
|
|
3
|
+
// Closes G1 — the 0.4.3 dead-seat class: before this slice a dead or
|
|
4
|
+
// compacted seat parked a workflow step forever because NO deadline
|
|
5
|
+
// existed anywhere in the workflow domain. This evaluator derives a
|
|
6
|
+
// stuck/overdue verdict for an instance from queue mechanics the
|
|
7
|
+
// system already records — it introduces NO new clock, NO new stored
|
|
8
|
+
// state, and NO queue-layer change.
|
|
9
|
+
//
|
|
10
|
+
// STUCK IS DERIVED STATE, NEVER STORED (ACK plan commit 2): every
|
|
11
|
+
// caller (keepalive policy, boot sweep, list/show/trace surfaces)
|
|
12
|
+
// recomputes the verdict from (instance, frontier packets, now); a
|
|
13
|
+
// normal re-projection therefore self-clears the stuck marker (the
|
|
14
|
+
// FR-2 AC) and nothing can go stale. BR-1 holds: this evaluator is
|
|
15
|
+
// consumed by observability + nudge paths ONLY — never by a routing
|
|
16
|
+
// decision.
|
|
17
|
+
//
|
|
18
|
+
// THE ANCHOR CLASSIFICATION (arch gate-leg ruling + third-state note,
|
|
19
|
+
// Rev-1; extended by the mode2-tier source discovery, flagged to arch
|
|
20
|
+
// 2026-07-06):
|
|
21
|
+
//
|
|
22
|
+
// 1. CLAIMED with a deadline — state=in-progress and
|
|
23
|
+
// closure_required_at set (computed only at claim,
|
|
24
|
+
// queue-repository.ts:858-870). Anchor = closure_required_at.
|
|
25
|
+
// NOTE: workflow step packets ship with tier "mode2", which has
|
|
26
|
+
// no TIER_SLA_SECONDS entry, so TODAY this sub-state is empty for
|
|
27
|
+
// workflow packets — kept because it is the honest anchor the
|
|
28
|
+
// moment tiers change, and the evaluator must never silently
|
|
29
|
+
// ignore a real closure_required_at.
|
|
30
|
+
// 2. CLAIMED with NO deadline — state=in-progress,
|
|
31
|
+
// closure_required_at NULL (the mode2 reality). Anchor =
|
|
32
|
+
// claimed_at + WORKFLOW_STEP_STUCK_THRESHOLD_SECONDS.
|
|
33
|
+
// 3. NEVER-CLAIMED — state=pending, never claimed (the
|
|
34
|
+
// dead-seat-BEFORE-claim / lost-nudge case: the projector creates
|
|
35
|
+
// the next packet PENDING in-txn and nudges only post-commit, so
|
|
36
|
+
// a dead owner leaves it unclaimed forever). Anchor =
|
|
37
|
+
// created_at + threshold.
|
|
38
|
+
// 4. UNCLAIMED-AFTER-CLAIM (the arch third state) — state=pending
|
|
39
|
+
// after an unclaim, which NULLs claimed_at AND
|
|
40
|
+
// closure_required_at (queue-repository.ts:908-917), making the
|
|
41
|
+
// row indistinguishable from never-claimed. Anchor = created_at +
|
|
42
|
+
// threshold — deliberately INCLUDING the elapsed claimed period,
|
|
43
|
+
// so the packet may surface overdue immediately after unclaim.
|
|
44
|
+
// That direction is safe (early nudge noise beats silent parking;
|
|
45
|
+
// BR-4 — nothing blocks). Claim history remains recoverable via
|
|
46
|
+
// queue_transitions; callers that render evidence may enrich from
|
|
47
|
+
// there.
|
|
48
|
+
//
|
|
49
|
+
// A `blocked` frontier packet (a waiting park) is HEALTHY here: the
|
|
50
|
+
// park is an honest recorded state and waiting instances are already
|
|
51
|
+
// keepalive-eligible; park-duration policy is WF-5's lane.
|
|
52
|
+
/**
|
|
53
|
+
* THE single threshold home (arch gate-leg ruling: EXPORTED, documented
|
|
54
|
+
* as the one place this number lives — WF-5's class-(b) stuck/overdue
|
|
55
|
+
* thresholds bind to this constant by ruling; they never redefine it).
|
|
56
|
+
*
|
|
57
|
+
* Derivation: the shipped routine-tier SLA (TIER_SLA_SECONDS.routine =
|
|
58
|
+
* 4h in hot-potato-enforcer.ts — module-private there, so the value is
|
|
59
|
+
* restated rather than imported; the derivation is this sentence).
|
|
60
|
+
* Workflow step packets carry tier "mode2" with no SLA entry, so this
|
|
61
|
+
* constant is the effective deadline for both unclaimed anchors and
|
|
62
|
+
* the claimed-null-deadline anchor.
|
|
63
|
+
*/
|
|
64
|
+
export const WORKFLOW_STEP_STUCK_THRESHOLD_SECONDS = 4 * 60 * 60;
|
|
65
|
+
/**
|
|
66
|
+
* Evaluate one instance's frontier against the deadline model. Pure:
|
|
67
|
+
* (instance, packets, now) -> verdict. `packets` are the queue rows
|
|
68
|
+
* for instance.currentFrontier (missing rows are ignored — a frontier
|
|
69
|
+
* id that no longer resolves is a different corruption class, guarded
|
|
70
|
+
* elsewhere).
|
|
71
|
+
*
|
|
72
|
+
* Only `active` and `waiting` instances can be overdue; terminal
|
|
73
|
+
* instances are always healthy (nothing to nudge).
|
|
74
|
+
*/
|
|
75
|
+
export function evaluateStepDeadline(instance, packets, now) {
|
|
76
|
+
if (instance.status !== "active" && instance.status !== "waiting") {
|
|
77
|
+
return { state: "healthy", evidence: null };
|
|
78
|
+
}
|
|
79
|
+
const nowMs = now.getTime();
|
|
80
|
+
const thresholdMs = WORKFLOW_STEP_STUCK_THRESHOLD_SECONDS * 1000;
|
|
81
|
+
for (const packet of packets) {
|
|
82
|
+
if (!packet)
|
|
83
|
+
continue;
|
|
84
|
+
if (!instance.currentFrontier.includes(packet.qitemId))
|
|
85
|
+
continue;
|
|
86
|
+
if (packet.state === "in-progress") {
|
|
87
|
+
// Sub-states 1 + 2: claimed.
|
|
88
|
+
const deadlineMs = packet.closureRequiredAt
|
|
89
|
+
? new Date(packet.closureRequiredAt).getTime()
|
|
90
|
+
: packet.claimedAt
|
|
91
|
+
? new Date(packet.claimedAt).getTime() + thresholdMs
|
|
92
|
+
: new Date(packet.tsCreated).getTime() + thresholdMs;
|
|
93
|
+
if (nowMs >= deadlineMs) {
|
|
94
|
+
return {
|
|
95
|
+
state: "overdue-claimed",
|
|
96
|
+
evidence: buildEvidence(instance, packet, nowMs, {
|
|
97
|
+
anchor: packet.closureRequiredAt
|
|
98
|
+
? "closure_required_at"
|
|
99
|
+
: packet.claimedAt
|
|
100
|
+
? "claimed_at"
|
|
101
|
+
: "created_at",
|
|
102
|
+
anchorAt: packet.closureRequiredAt ??
|
|
103
|
+
packet.claimedAt ??
|
|
104
|
+
packet.tsCreated,
|
|
105
|
+
deadlineMs,
|
|
106
|
+
}),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
else if (packet.state === "pending") {
|
|
111
|
+
// Sub-states 3 + 4: never-claimed OR unclaimed-after-claim
|
|
112
|
+
// (indistinguishable at the row after unclaim NULLs claimed_at;
|
|
113
|
+
// both deliberately anchor on created_at).
|
|
114
|
+
const deadlineMs = new Date(packet.tsCreated).getTime() + thresholdMs;
|
|
115
|
+
if (nowMs >= deadlineMs) {
|
|
116
|
+
return {
|
|
117
|
+
state: "overdue-unclaimed",
|
|
118
|
+
evidence: buildEvidence(instance, packet, nowMs, {
|
|
119
|
+
anchor: "created_at",
|
|
120
|
+
anchorAt: packet.tsCreated,
|
|
121
|
+
deadlineMs,
|
|
122
|
+
}),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// `blocked` (waiting park) and any closed state on the frontier:
|
|
127
|
+
// healthy by classification.
|
|
128
|
+
}
|
|
129
|
+
return { state: "healthy", evidence: null };
|
|
130
|
+
}
|
|
131
|
+
function buildEvidence(instance, packet, nowMs, input) {
|
|
132
|
+
return {
|
|
133
|
+
instanceId: instance.instanceId,
|
|
134
|
+
stepId: instance.currentStepId,
|
|
135
|
+
packetId: packet.qitemId,
|
|
136
|
+
ownerSession: packet.destinationSession,
|
|
137
|
+
packetState: packet.state,
|
|
138
|
+
anchor: input.anchor,
|
|
139
|
+
anchorAt: input.anchorAt,
|
|
140
|
+
overdueBySeconds: Math.max(0, Math.floor((nowMs - input.deadlineMs) / 1000)),
|
|
141
|
+
ageSeconds: Math.max(0, Math.floor((nowMs - new Date(packet.tsCreated).getTime()) / 1000)),
|
|
142
|
+
claimedAt: packet.claimedAt,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* FR-6 (G4) helper: the max_hops comparison, structured against an
|
|
147
|
+
* EFFECTIVE BASELINE (arch N1 ruling). v1 pins baseline = 0
|
|
148
|
+
* (MAX_HOPS_BASELINE_V1); WF-5 FR-4's resume later amends the baseline
|
|
149
|
+
* so each redrive gets one bounded window — this helper is the seam,
|
|
150
|
+
* never hard-welded to lifetime-total.
|
|
151
|
+
*
|
|
152
|
+
* Returns true when executing ONE MORE hop would exceed the guard.
|
|
153
|
+
*/
|
|
154
|
+
export const MAX_HOPS_BASELINE_V1 = 0;
|
|
155
|
+
export function exceedsMaxHops(hopCount, baseline, maxHops) {
|
|
156
|
+
// Guard blocker 2 hardening: only an ENFORCEABLE guard compares.
|
|
157
|
+
// The parser rejects malformed values going forward; this check
|
|
158
|
+
// protects against pre-fix cached spec_json blobs (a string would
|
|
159
|
+
// silently never trip; a null would coerce to 0 and ALWAYS trip).
|
|
160
|
+
if (typeof maxHops !== "number" || !Number.isInteger(maxHops) || maxHops < 1) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
return hopCount + 1 - baseline > maxHops;
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=workflow-deadline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-deadline.js","sourceRoot":"","sources":["../../src/domain/workflow-deadline.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,EAAE;AACF,qEAAqE;AACrE,oEAAoE;AACpE,oEAAoE;AACpE,iEAAiE;AACjE,qEAAqE;AACrE,oCAAoC;AACpC,EAAE;AACF,kEAAkE;AAClE,kEAAkE;AAClE,mEAAmE;AACnE,mEAAmE;AACnE,mEAAmE;AACnE,oEAAoE;AACpE,YAAY;AACZ,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,eAAe;AACf,EAAE;AACF,uDAAuD;AACvD,wDAAwD;AACxD,mEAAmE;AACnE,qEAA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 +1,33 @@
|
|
|
1
|
+
import type Database from "better-sqlite3";
|
|
2
|
+
import type { QueueRepository } from "./queue-repository.js";
|
|
3
|
+
import type { WorkflowDeadlineVerdict } from "./workflow-deadline.js";
|
|
4
|
+
import { type WorkflowExceptionClass } from "./workflow-exception.js";
|
|
5
|
+
import type { ExceptionRoute } from "./workflow-exception-router.js";
|
|
6
|
+
export interface EnsureStuckExceptionInput {
|
|
7
|
+
workflowName: string;
|
|
8
|
+
workflowVersion: string;
|
|
9
|
+
/** The session recorded as the item's source (the instance creator —
|
|
10
|
+
* a real, validated session; the detector is machinery, not a seat). */
|
|
11
|
+
createdBySession: string;
|
|
12
|
+
verdict: WorkflowDeadlineVerdict;
|
|
13
|
+
}
|
|
14
|
+
export interface EnsureStuckExceptionResult {
|
|
15
|
+
outcome: "skipped-healthy" | "deduped" | "created";
|
|
16
|
+
qitemId?: string;
|
|
17
|
+
}
|
|
18
|
+
export type EnsureStuckExceptionItem = (input: EnsureStuckExceptionInput) => Promise<EnsureStuckExceptionResult>;
|
|
19
|
+
export interface StuckExceptionDeps {
|
|
20
|
+
db: Database.Database;
|
|
21
|
+
queueRepo: QueueRepository;
|
|
22
|
+
/** The maturity-dial resolution for a cached spec (runtime-owned —
|
|
23
|
+
* spec lookup + the shipped role resolution live there). null =
|
|
24
|
+
* spec not cached; the never-lost fallback applies.
|
|
25
|
+
* OPR.0.4.6.FAC1 (arch Q3): boundRig = the stuck instance's bound
|
|
26
|
+
* rig (read from workflow_instances at detection time) so the
|
|
27
|
+
* orchestrator-role dial position resolves capability-aware. */
|
|
28
|
+
resolveRoute: (workflowName: string, workflowVersion: string, exceptionClass: WorkflowExceptionClass, boundRig?: string | null) => ExceptionRoute | null;
|
|
29
|
+
humanFallbackSeat?: string;
|
|
30
|
+
log?: (line: string) => void;
|
|
31
|
+
}
|
|
32
|
+
export declare function makeEnsureStuckExceptionItem(deps: StuckExceptionDeps): EnsureStuckExceptionItem;
|
|
33
|
+
//# sourceMappingURL=workflow-exception-escalation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-exception-escalation.d.ts","sourceRoot":"","sources":["../../src/domain/workflow-exception-escalation.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,MAAM,WAAW,yBAAyB;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB;6EACyE;IACzE,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,uBAAuB,CAAC;CAClC;AAED,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,iBAAiB,GAAG,SAAS,GAAG,SAAS,CAAC;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,wBAAwB,GAAG,CACrC,KAAK,EAAE,yBAAyB,KAC7B,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAEzC,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,QAAQ,CAAC,QAAQ,CAAC;IACtB,SAAS,EAAE,eAAe,CAAC;IAC3B;;;;;qEAKiE;IACjE,YAAY,EAAE,CACZ,YAAY,EAAE,MAAM,EACpB,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,sBAAsB,EACtC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,KACrB,cAAc,GAAG,IAAI,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9B;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,kBAAkB,GAAG,wBAAwB,CAwF/F"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// OPR.0.4.6.WF5 FR-2 class (b): detection-time exception items for
|
|
2
|
+
// STUCK/OVERDUE instances.
|
|
3
|
+
//
|
|
4
|
+
// Class (b) has NO state-change transaction to ride — the item is created
|
|
5
|
+
// AT DETECTION TIME by the sweep/keepalive evaluation, and its never-lost
|
|
6
|
+
// guarantee is WF-1's crash-surviving sweep: re-detection re-creates a
|
|
7
|
+
// missed item on the next pass (P2 cleanup honored: no same-txn claim is
|
|
8
|
+
// made or implemented here).
|
|
9
|
+
//
|
|
10
|
+
// DEDUP (the occurrence contract): exactly ONE OPEN item per
|
|
11
|
+
// (instance, step, class, occurrence) — the occurrence key is the overdue
|
|
12
|
+
// packet id named by the WF-1 evaluator's evidence. Re-detections of the
|
|
13
|
+
// same unresolved episode find the open item by TAG QUERY (never summary
|
|
14
|
+
// parsing) and re-nudge it instead of minting a duplicate. A resolved/
|
|
15
|
+
// closed item with the episode still live is a MISSED item — the next
|
|
16
|
+
// detection re-creates it (the sweep guarantee), keeping exactly one
|
|
17
|
+
// OPEN item per occurrence at all times.
|
|
18
|
+
//
|
|
19
|
+
// The policy shape is untouched (X5 stands: PolicyEvaluation remains
|
|
20
|
+
// send|skip|terminal) — the keepalive calls this injected helper as a
|
|
21
|
+
// side effect of its EXISTING evaluation; the sweep likewise. Injection
|
|
22
|
+
// at startup per the validateRig precedent.
|
|
23
|
+
import { classifyDeadlineVerdict, workflowExceptionTags, } from "./workflow-exception.js";
|
|
24
|
+
export function makeEnsureStuckExceptionItem(deps) {
|
|
25
|
+
const log = deps.log ?? (() => { });
|
|
26
|
+
const fallbackSeat = deps.humanFallbackSeat ?? "human@host";
|
|
27
|
+
return async (input) => {
|
|
28
|
+
const exception = classifyDeadlineVerdict(input.workflowName, input.verdict);
|
|
29
|
+
if (!exception)
|
|
30
|
+
return { outcome: "skipped-healthy" };
|
|
31
|
+
// Dedup by tag query against OPEN states only (pending | in-progress
|
|
32
|
+
// | blocked): one open item per occurrence; a closed item with the
|
|
33
|
+
// episode still live is missed and gets re-created.
|
|
34
|
+
const open = deps.db
|
|
35
|
+
.prepare(`SELECT qitem_id, destination_session FROM queue_items
|
|
36
|
+
WHERE state IN ('pending','in-progress','blocked')
|
|
37
|
+
AND tags LIKE ? AND tags LIKE ?`)
|
|
38
|
+
.get(`%"occurrence:${exception.identity.occurrenceKey}"%`, `%"exception:stuck_overdue"%`);
|
|
39
|
+
if (open) {
|
|
40
|
+
// Re-detection of the same unresolved episode: re-nudge the ONE
|
|
41
|
+
// item (best-effort — the durable item is the guarantee).
|
|
42
|
+
await deps.queueRepo.maybeNudge(open.qitem_id, open.destination_session, undefined);
|
|
43
|
+
return { outcome: "deduped", qitemId: open.qitem_id };
|
|
44
|
+
}
|
|
45
|
+
// OPR.0.4.6.FAC1 (arch Q3): each exception item is a FRESH routing
|
|
46
|
+
// decision at its own detection moment — read the stuck instance's
|
|
47
|
+
// bound rig NOW (defensive to a pre-052 fixture db: absent column
|
|
48
|
+
// reads as unbound, the shipped behavior).
|
|
49
|
+
let detectionBoundRig = null;
|
|
50
|
+
const stuckInstanceId = exception.deadlineEvidence?.instanceId;
|
|
51
|
+
if (stuckInstanceId) {
|
|
52
|
+
try {
|
|
53
|
+
const row = deps.db
|
|
54
|
+
.prepare(`SELECT bound_rig FROM workflow_instances WHERE instance_id = ?`)
|
|
55
|
+
.get(stuckInstanceId);
|
|
56
|
+
detectionBoundRig = row?.bound_rig ?? null;
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
detectionBoundRig = null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const route = deps.resolveRoute(input.workflowName, input.workflowVersion, "stuck_overdue", detectionBoundRig) ?? {
|
|
63
|
+
position: "fallback",
|
|
64
|
+
destinationSession: fallbackSeat,
|
|
65
|
+
tier: "human-gate",
|
|
66
|
+
humanRouted: true,
|
|
67
|
+
resolvedVia: "engine-default",
|
|
68
|
+
};
|
|
69
|
+
const e = exception.deadlineEvidence;
|
|
70
|
+
const evidenceRef = `rig workflow trace ${e.instanceId}`;
|
|
71
|
+
const body = `WORKFLOW EXCEPTION (stuck_overdue)\n` +
|
|
72
|
+
`workflow: ${input.workflowName} v${input.workflowVersion}\n` +
|
|
73
|
+
`instance: ${e.instanceId}\n` +
|
|
74
|
+
`step: ${e.stepId ?? "(unbound)"} — packet ${e.packetId} held by ${e.ownerSession} (${e.packetState})\n` +
|
|
75
|
+
`deadline: ${e.overdueBySeconds}s past the ${e.anchor} anchor (${e.anchorAt}); packet age ${e.ageSeconds}s\n` +
|
|
76
|
+
`reason: ${exception.reason}\n` +
|
|
77
|
+
`evidence: ${evidenceRef}\n` +
|
|
78
|
+
`resolve: re-nudge/replace the owner per the WF-1 dead-seat mechanics (the step re-projects and the flow continues from this step); this item clears when the instance leaves the exception state.`;
|
|
79
|
+
const createItem = (destination, tier) => deps.queueRepo.create({
|
|
80
|
+
sourceSession: input.createdBySession,
|
|
81
|
+
destinationSession: destination,
|
|
82
|
+
body,
|
|
83
|
+
priority: "urgent",
|
|
84
|
+
tier,
|
|
85
|
+
tags: workflowExceptionTags(exception.identity),
|
|
86
|
+
summary: exception.reason,
|
|
87
|
+
evidenceRef,
|
|
88
|
+
});
|
|
89
|
+
let created;
|
|
90
|
+
try {
|
|
91
|
+
created = await createItem(route.destinationSession, route.tier);
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// THE NEVER-LOST WRITE-GATE FALLBACK (same contract as class (a)):
|
|
95
|
+
// a gate-rejected routed destination re-routes human@host rather
|
|
96
|
+
// than losing the exception. A failure of THIS create is a real
|
|
97
|
+
// storage error and propagates to the caller's non-fatal handling.
|
|
98
|
+
created = await createItem(fallbackSeat, "human-gate");
|
|
99
|
+
}
|
|
100
|
+
log(`workflow exception: stuck_overdue item ${created.qitemId} created for instance ${e.instanceId} (step ${e.stepId ?? "?"}, ${route.position})`);
|
|
101
|
+
return { outcome: "created", qitemId: created.qitemId };
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=workflow-exception-escalation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-exception-escalation.js","sourceRoot":"","sources":["../../src/domain/workflow-exception-escalation.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,2BAA2B;AAC3B,EAAE;AACF,0EAA0E;AAC1E,0EAA0E;AAC1E,uEAAuE;AACvE,yEAAyE;AACzE,6BAA6B;AAC7B,EAAE;AACF,6DAA6D;AAC7D,0EAA0E;AAC1E,yEAAyE;AACzE,yEAAyE;AACzE,uEAAuE;AACvE,sEAAsE;AACtE,qEAAqE;AACrE,yCAAyC;AACzC,EAAE;AACF,qEAAqE;AACrE,sEAAsE;AACtE,wEAAwE;AACxE,4CAA4C;AAK5C,OAAO,EACL,uBAAuB,EACvB,qBAAqB,GAEtB,MAAM,yBAAyB,CAAC;AAwCjC,MAAM,UAAU,4BAA4B,CAAC,IAAwB;IACnE,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACnC,MAAM,YAAY,GAAG,IAAI,CAAC,iBAAiB,IAAI,YAAY,CAAC;IAC5D,OAAO,KAAK,EAAE,KAAgC,EAAuC,EAAE;QACrF,MAAM,SAAS,GAAG,uBAAuB,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAC7E,IAAI,CAAC,SAAS;YAAE,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC;QAEtD,qEAAqE;QACrE,mEAAmE;QACnE,oDAAoD;QACpD,MAAM,IAAI,GAAG,IAAI,CAAC,EAAE;aACjB,OAAO,CACN;;2CAEmC,CACpC;aACA,GAAG,CACF,gBAAgB,SAAS,CAAC,QAAQ,CAAC,aAAa,IAAI,EACpD,6BAA6B,CACmC,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AAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { WorkflowExceptionClass } from "./workflow-exception.js";
|
|
2
|
+
import type { WorkflowExceptionDialPosition, WorkflowSpec } from "./workflow-types.js";
|
|
3
|
+
/** The ordinary workflow-packet tier (the shipped default the attention
|
|
4
|
+
* union deliberately does NOT match on). */
|
|
5
|
+
export declare const WORKFLOW_EXCEPTION_ORCHESTRATOR_TIER = "mode2";
|
|
6
|
+
/** The human-routed tier — the attention union's first leg. */
|
|
7
|
+
export declare const WORKFLOW_EXCEPTION_HUMAN_TIER = "human-gate";
|
|
8
|
+
export interface ExceptionRouteInput {
|
|
9
|
+
exceptionClass: WorkflowExceptionClass;
|
|
10
|
+
spec: Pick<WorkflowSpec, "exception_routing" | "roles">;
|
|
11
|
+
/** The host-level dial default (settings `workflow.exception_routing`),
|
|
12
|
+
* read by the caller; null = key unset. */
|
|
13
|
+
hostDialDefault: WorkflowExceptionDialPosition | null;
|
|
14
|
+
/** The shipped role→preferred_targets resolution, wrapped by the caller
|
|
15
|
+
* (workflow-runtime owns runtime matching). null = unresolvable. */
|
|
16
|
+
resolveRoleTarget: (roleName: string) => string | null;
|
|
17
|
+
/** The honest never-lost fallback seat (human@<host> form). */
|
|
18
|
+
humanFallbackSeat: string;
|
|
19
|
+
}
|
|
20
|
+
export interface ExceptionRoute {
|
|
21
|
+
/** Where the chain landed. `fallback` = orchestrator position whose
|
|
22
|
+
* role target did not resolve (still never lost). */
|
|
23
|
+
position: "orchestrator" | "human_only" | "fallback";
|
|
24
|
+
destinationSession: string;
|
|
25
|
+
/** THE TIER SPLIT — human-gate iff humanRouted. */
|
|
26
|
+
tier: string;
|
|
27
|
+
humanRouted: boolean;
|
|
28
|
+
/** Which chain link decided the position (recorded in item evidence —
|
|
29
|
+
* the dial walks assert it). */
|
|
30
|
+
resolvedVia: "class-intrinsic" | "class-declared" | "workflow-declared" | "host-default" | "engine-default";
|
|
31
|
+
}
|
|
32
|
+
export declare function resolveExceptionRoute(input: ExceptionRouteInput): ExceptionRoute;
|
|
33
|
+
//# sourceMappingURL=workflow-exception-router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-exception-router.d.ts","sourceRoot":"","sources":["../../src/domain/workflow-exception-router.ts"],"names":[],"mappings":"AAkCA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,KAAK,EAAE,6BAA6B,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEvF;6CAC6C;AAC7C,eAAO,MAAM,oCAAoC,UAAU,CAAC;AAC5D,+DAA+D;AAC/D,eAAO,MAAM,6BAA6B,eAAe,CAAC;AAE1D,MAAM,WAAW,mBAAmB;IAClC,cAAc,EAAE,sBAAsB,CAAC;IACvC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,mBAAmB,GAAG,OAAO,CAAC,CAAC;IACxD;gDAC4C;IAC5C,eAAe,EAAE,6BAA6B,GAAG,IAAI,CAAC;IACtD;yEACqE;IACrE,iBAAiB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IACvD,+DAA+D;IAC/D,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,cAAc;IAC7B;0DACsD;IACtD,QAAQ,EAAE,cAAc,GAAG,YAAY,GAAG,UAAU,CAAC;IACrD,kBAAkB,EAAE,MAAM,CAAC;IAC3B,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,OAAO,CAAC;IACrB;qCACiC;IACjC,WAAW,EAAE,iBAAiB,GAAG,gBAAgB,GAAG,mBAAmB,GAAG,cAAc,GAAG,gBAAgB,CAAC;CAC7G;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,mBAAmB,GAAG,cAAc,CAsDhF"}
|