@cotal-ai/cli 0.100.1 → 0.101.0
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/dist/chat/chat-view.d.ts.map +1 -1
- package/dist/chat/chat-view.js +5 -1
- package/dist/chat/chat-view.js.map +1 -1
- package/dist/chat/engine.d.ts +2 -1
- package/dist/chat/engine.d.ts.map +1 -1
- package/dist/chat/engine.js +2 -1
- package/dist/chat/engine.js.map +1 -1
- package/dist/chat/frontend.d.ts.map +1 -1
- package/dist/chat/frontend.js +13 -7
- package/dist/chat/frontend.js.map +1 -1
- package/dist/chat/native-session.d.ts +22 -3
- package/dist/chat/native-session.d.ts.map +1 -1
- package/dist/chat/native-session.js +91 -19
- package/dist/chat/native-session.js.map +1 -1
- package/dist/chat/open-session.d.ts +1 -0
- package/dist/chat/open-session.d.ts.map +1 -1
- package/dist/chat/open-session.js +1 -1
- package/dist/chat/open-session.js.map +1 -1
- package/dist/chat/picker.d.ts +5 -0
- package/dist/chat/picker.d.ts.map +1 -1
- package/dist/chat/picker.js +23 -10
- package/dist/chat/picker.js.map +1 -1
- package/dist/chat/plain.d.ts.map +1 -1
- package/dist/chat/plain.js +36 -10
- package/dist/chat/plain.js.map +1 -1
- package/dist/chat/session.d.ts +5 -0
- package/dist/chat/session.d.ts.map +1 -1
- package/dist/chat/static-session.d.ts +1 -0
- package/dist/chat/static-session.d.ts.map +1 -1
- package/dist/chat/static-session.js +24 -8
- package/dist/chat/static-session.js.map +1 -1
- package/dist/chat/stdio-io.d.ts +2 -0
- package/dist/chat/stdio-io.d.ts.map +1 -1
- package/dist/chat/stdio-io.js +6 -6
- package/dist/chat/stdio-io.js.map +1 -1
- package/dist/chat/stdio.d.ts +3 -2
- package/dist/chat/stdio.d.ts.map +1 -1
- package/dist/chat/stdio.js +26 -25
- package/dist/chat/stdio.js.map +1 -1
- package/dist/chat/user-session.d.ts +1 -0
- package/dist/chat/user-session.d.ts.map +1 -1
- package/dist/chat/user-session.js +1 -1
- package/dist/chat/user-session.js.map +1 -1
- package/dist/chat/view.d.ts +5 -4
- package/dist/chat/view.d.ts.map +1 -1
- package/dist/chat/view.js +10 -8
- package/dist/chat/view.js.map +1 -1
- package/dist/command.d.ts +5 -0
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +295 -82
- package/dist/command.js.map +1 -1
- package/dist/commands/agents.d.ts +29 -5
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +100 -35
- package/dist/commands/agents.js.map +1 -1
- package/dist/commands/backup-maintenance.d.ts.map +1 -1
- package/dist/commands/backup-maintenance.js +54 -21
- package/dist/commands/backup-maintenance.js.map +1 -1
- package/dist/commands/backup-read.d.ts.map +1 -1
- package/dist/commands/backup-read.js +13 -16
- package/dist/commands/backup-read.js.map +1 -1
- package/dist/commands/backup-restore.d.ts.map +1 -1
- package/dist/commands/backup-restore.js +20 -4
- package/dist/commands/backup-restore.js.map +1 -1
- package/dist/commands/backup.d.ts.map +1 -1
- package/dist/commands/backup.js +157 -29
- package/dist/commands/backup.js.map +1 -1
- package/dist/commands/channel-members.d.ts +1 -1
- package/dist/commands/channel-members.d.ts.map +1 -1
- package/dist/commands/channel-members.js +115 -29
- package/dist/commands/channel-members.js.map +1 -1
- package/dist/commands/channels.d.ts +11 -1
- package/dist/commands/channels.d.ts.map +1 -1
- package/dist/commands/channels.js +109 -20
- package/dist/commands/channels.js.map +1 -1
- package/dist/commands/chat.d.ts +11 -3
- package/dist/commands/chat.d.ts.map +1 -1
- package/dist/commands/chat.js +50 -22
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/clean.d.ts +10 -5
- package/dist/commands/clean.d.ts.map +1 -1
- package/dist/commands/clean.js +245 -42
- package/dist/commands/clean.js.map +1 -1
- package/dist/commands/completion.d.ts +15 -2
- package/dist/commands/completion.d.ts.map +1 -1
- package/dist/commands/completion.js +91 -26
- package/dist/commands/completion.js.map +1 -1
- package/dist/commands/config.d.ts +24 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +91 -15
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/console.d.ts.map +1 -1
- package/dist/commands/console.js +5 -4
- package/dist/commands/console.js.map +1 -1
- package/dist/commands/describe.d.ts +4 -2
- package/dist/commands/describe.d.ts.map +1 -1
- package/dist/commands/describe.js +4 -4
- package/dist/commands/describe.js.map +1 -1
- package/dist/commands/doctor.d.ts +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +261 -34
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/down-manifest.d.ts.map +1 -1
- package/dist/commands/down-manifest.js +9 -6
- package/dist/commands/down-manifest.js.map +1 -1
- package/dist/commands/down-services.d.ts +17 -16
- package/dist/commands/down-services.d.ts.map +1 -1
- package/dist/commands/down-services.js +29 -53
- package/dist/commands/down-services.js.map +1 -1
- package/dist/commands/down.d.ts +2 -2
- package/dist/commands/down.d.ts.map +1 -1
- package/dist/commands/down.js +96 -67
- package/dist/commands/down.js.map +1 -1
- package/dist/commands/endpoint-deregister.d.ts.map +1 -1
- package/dist/commands/endpoint-deregister.js +2 -2
- package/dist/commands/endpoint-deregister.js.map +1 -1
- package/dist/commands/endpoint.d.ts +2 -1
- package/dist/commands/endpoint.d.ts.map +1 -1
- package/dist/commands/endpoint.js +2 -2
- package/dist/commands/endpoint.js.map +1 -1
- package/dist/commands/endpoints.d.ts +1 -0
- package/dist/commands/endpoints.d.ts.map +1 -1
- package/dist/commands/endpoints.js +20 -5
- package/dist/commands/endpoints.js.map +1 -1
- package/dist/commands/feedback.d.ts.map +1 -1
- package/dist/commands/feedback.js +40 -2
- package/dist/commands/feedback.js.map +1 -1
- package/dist/commands/help.d.ts.map +1 -1
- package/dist/commands/help.js +2 -1
- package/dist/commands/help.js.map +1 -1
- package/dist/commands/history-clear.d.ts.map +1 -1
- package/dist/commands/history-clear.js +67 -51
- package/dist/commands/history-clear.js.map +1 -1
- package/dist/commands/history.d.ts +17 -2
- package/dist/commands/history.d.ts.map +1 -1
- package/dist/commands/history.js +221 -34
- package/dist/commands/history.js.map +1 -1
- package/dist/commands/join.d.ts +2 -0
- package/dist/commands/join.d.ts.map +1 -1
- package/dist/commands/join.js +132 -80
- package/dist/commands/join.js.map +1 -1
- package/dist/commands/meshes-add.d.ts +19 -4
- package/dist/commands/meshes-add.d.ts.map +1 -1
- package/dist/commands/meshes-add.js +114 -15
- package/dist/commands/meshes-add.js.map +1 -1
- package/dist/commands/meshes-wizard.d.ts +1 -0
- package/dist/commands/meshes-wizard.d.ts.map +1 -1
- package/dist/commands/meshes-wizard.js +45 -13
- package/dist/commands/meshes-wizard.js.map +1 -1
- package/dist/commands/meshes.d.ts +1 -1
- package/dist/commands/meshes.d.ts.map +1 -1
- package/dist/commands/meshes.js +76 -47
- package/dist/commands/meshes.js.map +1 -1
- package/dist/commands/mint.d.ts.map +1 -1
- package/dist/commands/mint.js +212 -19
- package/dist/commands/mint.js.map +1 -1
- package/dist/commands/models.d.ts +5 -1
- package/dist/commands/models.d.ts.map +1 -1
- package/dist/commands/models.js +21 -13
- package/dist/commands/models.js.map +1 -1
- package/dist/commands/persona-remote.d.ts.map +1 -1
- package/dist/commands/persona-remote.js +38 -19
- package/dist/commands/persona-remote.js.map +1 -1
- package/dist/commands/persona.d.ts +1 -1
- package/dist/commands/persona.d.ts.map +1 -1
- package/dist/commands/persona.js +92 -23
- package/dist/commands/persona.js.map +1 -1
- package/dist/commands/personas.d.ts.map +1 -1
- package/dist/commands/personas.js +59 -40
- package/dist/commands/personas.js.map +1 -1
- package/dist/commands/reset-space-apply.d.ts.map +1 -1
- package/dist/commands/reset-space-apply.js +69 -17
- package/dist/commands/reset-space-apply.js.map +1 -1
- package/dist/commands/reset-store-apply.d.ts +16 -0
- package/dist/commands/reset-store-apply.d.ts.map +1 -1
- package/dist/commands/reset-store-apply.js +122 -23
- package/dist/commands/reset-store-apply.js.map +1 -1
- package/dist/commands/reset.d.ts.map +1 -1
- package/dist/commands/reset.js +8 -7
- package/dist/commands/reset.js.map +1 -1
- package/dist/commands/revoke-credential.d.ts +5 -0
- package/dist/commands/revoke-credential.d.ts.map +1 -0
- package/dist/commands/revoke-credential.js +128 -0
- package/dist/commands/revoke-credential.js.map +1 -0
- package/dist/commands/send.d.ts +11 -3
- package/dist/commands/send.d.ts.map +1 -1
- package/dist/commands/send.js +284 -47
- package/dist/commands/send.js.map +1 -1
- package/dist/commands/service-actions.d.ts +2 -1
- package/dist/commands/service-actions.d.ts.map +1 -1
- package/dist/commands/service-actions.js +117 -21
- package/dist/commands/service-actions.js.map +1 -1
- package/dist/commands/service-log-follow.js +1 -1
- package/dist/commands/service-log-follow.js.map +1 -1
- package/dist/commands/service-registry.d.ts +1 -1
- package/dist/commands/service-registry.d.ts.map +1 -1
- package/dist/commands/service-registry.js +74 -30
- package/dist/commands/service-registry.js.map +1 -1
- package/dist/commands/service-set-stop.d.ts.map +1 -1
- package/dist/commands/service-set-stop.js +3 -2
- package/dist/commands/service-set-stop.js.map +1 -1
- package/dist/commands/setup-start.d.ts.map +1 -1
- package/dist/commands/setup-start.js +46 -5
- package/dist/commands/setup-start.js.map +1 -1
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +28 -13
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/space-delete.d.ts.map +1 -1
- package/dist/commands/space-delete.js +130 -41
- package/dist/commands/space-delete.js.map +1 -1
- package/dist/commands/space-registration.d.ts +13 -6
- package/dist/commands/space-registration.d.ts.map +1 -1
- package/dist/commands/space-registration.js +167 -46
- package/dist/commands/space-registration.js.map +1 -1
- package/dist/commands/space.d.ts +15 -1
- package/dist/commands/space.d.ts.map +1 -1
- package/dist/commands/space.js +66 -24
- package/dist/commands/space.js.map +1 -1
- package/dist/commands/spawn-preview.d.ts.map +1 -1
- package/dist/commands/spawn-preview.js +48 -10
- package/dist/commands/spawn-preview.js.map +1 -1
- package/dist/commands/spawn.d.ts +36 -13
- package/dist/commands/spawn.d.ts.map +1 -1
- package/dist/commands/spawn.js +263 -129
- package/dist/commands/spawn.js.map +1 -1
- package/dist/commands/stack-down.d.ts +9 -3
- package/dist/commands/stack-down.d.ts.map +1 -1
- package/dist/commands/stack-down.js +344 -64
- package/dist/commands/stack-down.js.map +1 -1
- package/dist/commands/stack-gone.d.ts +17 -0
- package/dist/commands/stack-gone.d.ts.map +1 -0
- package/dist/commands/stack-gone.js +218 -0
- package/dist/commands/stack-gone.js.map +1 -0
- package/dist/commands/stack-up.d.ts +64 -4
- package/dist/commands/stack-up.d.ts.map +1 -1
- package/dist/commands/stack-up.js +482 -55
- package/dist/commands/stack-up.js.map +1 -1
- package/dist/commands/status.d.ts +76 -2
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +550 -112
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/team-agent-apply.d.ts.map +1 -1
- package/dist/commands/team-agent-apply.js +4 -3
- package/dist/commands/team-agent-apply.js.map +1 -1
- package/dist/commands/team-agent-remove.d.ts.map +1 -1
- package/dist/commands/team-agent-remove.js +4 -4
- package/dist/commands/team-agent-remove.js.map +1 -1
- package/dist/commands/team-boot-controller.d.ts.map +1 -1
- package/dist/commands/team-boot-controller.js +8 -2
- package/dist/commands/team-boot-controller.js.map +1 -1
- package/dist/commands/team-channel-remove.d.ts.map +1 -1
- package/dist/commands/team-channel-remove.js +26 -10
- package/dist/commands/team-channel-remove.js.map +1 -1
- package/dist/commands/team-deploy-apply.d.ts.map +1 -1
- package/dist/commands/team-deploy-apply.js +4 -3
- package/dist/commands/team-deploy-apply.js.map +1 -1
- package/dist/commands/team-mixed-remove.js +5 -5
- package/dist/commands/team-mixed-remove.js.map +1 -1
- package/dist/commands/team.d.ts.map +1 -1
- package/dist/commands/team.js +94 -32
- package/dist/commands/team.js.map +1 -1
- package/dist/commands/telemetry.d.ts +1 -1
- package/dist/commands/telemetry.d.ts.map +1 -1
- package/dist/commands/telemetry.js +5 -3
- package/dist/commands/telemetry.js.map +1 -1
- package/dist/commands/topology.d.ts.map +1 -1
- package/dist/commands/topology.js +11 -7
- package/dist/commands/topology.js.map +1 -1
- package/dist/commands/up.d.ts +6 -6
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +963 -240
- package/dist/commands/up.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +9 -3
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/use.d.ts +5 -1
- package/dist/commands/use.d.ts.map +1 -1
- package/dist/commands/use.js +55 -12
- package/dist/commands/use.js.map +1 -1
- package/dist/commands/watch.d.ts +4 -1
- package/dist/commands/watch.d.ts.map +1 -1
- package/dist/commands/watch.js +15 -3
- package/dist/commands/watch.js.map +1 -1
- package/dist/commands/who.d.ts +2 -0
- package/dist/commands/who.d.ts.map +1 -1
- package/dist/commands/who.js +18 -5
- package/dist/commands/who.js.map +1 -1
- package/dist/commands/whoami.d.ts +44 -5
- package/dist/commands/whoami.d.ts.map +1 -1
- package/dist/commands/whoami.js +168 -16
- package/dist/commands/whoami.js.map +1 -1
- package/dist/console/app.d.ts +1 -1
- package/dist/console/app.d.ts.map +1 -1
- package/dist/console/app.js +15 -9
- package/dist/console/app.js.map +1 -1
- package/dist/console/launch.d.ts +25 -0
- package/dist/console/launch.d.ts.map +1 -0
- package/dist/console/launch.js +56 -0
- package/dist/console/launch.js.map +1 -0
- package/dist/console/ui/CommandPalette.d.ts +5 -4
- package/dist/console/ui/CommandPalette.d.ts.map +1 -1
- package/dist/console/ui/CommandPalette.js +136 -45
- package/dist/console/ui/CommandPalette.js.map +1 -1
- package/dist/console/ui/Help.js +1 -1
- package/dist/console/ui/Help.js.map +1 -1
- package/dist/console/ui/Modal.d.ts +10 -0
- package/dist/console/ui/Modal.d.ts.map +1 -0
- package/dist/console/ui/Modal.js +8 -0
- package/dist/console/ui/Modal.js.map +1 -0
- package/dist/console/ui/NewAgent.d.ts +14 -0
- package/dist/console/ui/NewAgent.d.ts.map +1 -0
- package/dist/console/ui/NewAgent.js +114 -0
- package/dist/console/ui/NewAgent.js.map +1 -0
- package/dist/console/ui/StatusBar.d.ts +1 -2
- package/dist/console/ui/StatusBar.d.ts.map +1 -1
- package/dist/console/ui/StatusBar.js +6 -8
- package/dist/console/ui/StatusBar.js.map +1 -1
- package/dist/console/ui/topo/Map.d.ts.map +1 -1
- package/dist/console/ui/topo/Map.js +1 -2
- package/dist/console/ui/topo/Map.js.map +1 -1
- package/dist/console/ui/topo/Matrix.js +2 -2
- package/dist/console/ui/topo/Matrix.js.map +1 -1
- package/dist/console/ui/topo/Sequence.d.ts.map +1 -1
- package/dist/console/ui/topo/Sequence.js +5 -4
- package/dist/console/ui/topo/Sequence.js.map +1 -1
- package/dist/console/ui/topo/model.d.ts +2 -1
- package/dist/console/ui/topo/model.d.ts.map +1 -1
- package/dist/console/ui/topo/model.js +4 -3
- package/dist/console/ui/topo/model.js.map +1 -1
- package/dist/exec-endpoint/service-adapter.d.ts.map +1 -1
- package/dist/exec-endpoint/service-adapter.js +13 -3
- package/dist/exec-endpoint/service-adapter.js.map +1 -1
- package/dist/ext-loader.d.ts +4 -0
- package/dist/ext-loader.d.ts.map +1 -1
- package/dist/ext-loader.js +6 -0
- package/dist/ext-loader.js.map +1 -1
- package/dist/help.d.ts.map +1 -1
- package/dist/help.js +44 -23
- package/dist/help.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +59 -54
- package/dist/index.js.map +1 -1
- package/dist/lib/agent-skills.d.ts.map +1 -1
- package/dist/lib/agent-skills.js +2 -1
- package/dist/lib/agent-skills.js.map +1 -1
- package/dist/lib/attach-client.js +2 -2
- package/dist/lib/attach-client.js.map +1 -1
- package/dist/lib/backup-artifact.d.ts +36 -8
- package/dist/lib/backup-artifact.d.ts.map +1 -1
- package/dist/lib/backup-artifact.js +156 -26
- package/dist/lib/backup-artifact.js.map +1 -1
- package/dist/lib/broker-service.d.ts +27 -3
- package/dist/lib/broker-service.d.ts.map +1 -1
- package/dist/lib/broker-service.js +135 -27
- package/dist/lib/broker-service.js.map +1 -1
- package/dist/lib/broker-store-health.d.ts +89 -0
- package/dist/lib/broker-store-health.d.ts.map +1 -0
- package/dist/lib/broker-store-health.js +171 -0
- package/dist/lib/broker-store-health.js.map +1 -0
- package/dist/lib/cancel.d.ts +4 -4
- package/dist/lib/cancel.d.ts.map +1 -1
- package/dist/lib/cancel.js +5 -5
- package/dist/lib/cancel.js.map +1 -1
- package/dist/lib/completion-install.d.ts +11 -2
- package/dist/lib/completion-install.d.ts.map +1 -1
- package/dist/lib/completion-install.js +79 -21
- package/dist/lib/completion-install.js.map +1 -1
- package/dist/lib/completion-scripts.d.ts.map +1 -1
- package/dist/lib/completion-scripts.js +2 -2
- package/dist/lib/completion-scripts.js.map +1 -1
- package/dist/lib/completion.d.ts +5 -1
- package/dist/lib/completion.d.ts.map +1 -1
- package/dist/lib/completion.js +10 -0
- package/dist/lib/completion.js.map +1 -1
- package/dist/lib/concrete-channel.d.ts +6 -0
- package/dist/lib/concrete-channel.d.ts.map +1 -0
- package/dist/lib/concrete-channel.js +17 -0
- package/dist/lib/concrete-channel.js.map +1 -0
- package/dist/lib/confirmation-required.d.ts +3 -12
- package/dist/lib/confirmation-required.d.ts.map +1 -1
- package/dist/lib/confirmation-required.js +9 -8
- package/dist/lib/confirmation-required.js.map +1 -1
- package/dist/lib/connect.d.ts +9 -0
- package/dist/lib/connect.d.ts.map +1 -1
- package/dist/lib/connect.js +27 -0
- package/dist/lib/connect.js.map +1 -1
- package/dist/lib/control.d.ts +42 -12
- package/dist/lib/control.d.ts.map +1 -1
- package/dist/lib/control.js +130 -31
- package/dist/lib/control.js.map +1 -1
- package/dist/lib/controller-restore.d.ts.map +1 -1
- package/dist/lib/controller-restore.js +12 -7
- package/dist/lib/controller-restore.js.map +1 -1
- package/dist/lib/credential-authority.d.ts.map +1 -1
- package/dist/lib/credential-authority.js +3 -0
- package/dist/lib/credential-authority.js.map +1 -1
- package/dist/lib/credential-exports.d.ts +17 -0
- package/dist/lib/credential-exports.d.ts.map +1 -0
- package/dist/lib/credential-exports.js +21 -0
- package/dist/lib/credential-exports.js.map +1 -0
- package/dist/lib/debug-flag.d.ts +4 -0
- package/dist/lib/debug-flag.d.ts.map +1 -0
- package/dist/lib/debug-flag.js +7 -0
- package/dist/lib/debug-flag.js.map +1 -0
- package/dist/lib/default-persona.d.ts +2 -0
- package/dist/lib/default-persona.d.ts.map +1 -1
- package/dist/lib/default-persona.js +2 -0
- package/dist/lib/default-persona.js.map +1 -1
- package/dist/lib/delivery-proc.d.ts +1 -1
- package/dist/lib/delivery-proc.d.ts.map +1 -1
- package/dist/lib/delivery-proc.js +5 -4
- package/dist/lib/delivery-proc.js.map +1 -1
- package/dist/lib/delivery-responder.d.ts +7 -3
- package/dist/lib/delivery-responder.d.ts.map +1 -1
- package/dist/lib/delivery-responder.js +8 -4
- package/dist/lib/delivery-responder.js.map +1 -1
- package/dist/lib/denied-write.d.ts +8 -0
- package/dist/lib/denied-write.d.ts.map +1 -0
- package/dist/lib/denied-write.js +24 -0
- package/dist/lib/denied-write.js.map +1 -0
- package/dist/lib/endpoint-capability-gates.js +2 -2
- package/dist/lib/endpoint-capability-gates.js.map +1 -1
- package/dist/lib/flag-value-refusal.d.ts +8 -0
- package/dist/lib/flag-value-refusal.d.ts.map +1 -0
- package/dist/lib/flag-value-refusal.js +10 -0
- package/dist/lib/flag-value-refusal.js.map +1 -0
- package/dist/lib/install-umask.d.ts +5 -0
- package/dist/lib/install-umask.d.ts.map +1 -1
- package/dist/lib/install-umask.js +25 -0
- package/dist/lib/install-umask.js.map +1 -1
- package/dist/lib/interrupt-notice.d.ts +23 -1
- package/dist/lib/interrupt-notice.d.ts.map +1 -1
- package/dist/lib/interrupt-notice.js +27 -6
- package/dist/lib/interrupt-notice.js.map +1 -1
- package/dist/lib/interrupt-report.d.ts +7 -0
- package/dist/lib/interrupt-report.d.ts.map +1 -0
- package/dist/lib/interrupt-report.js +24 -0
- package/dist/lib/interrupt-report.js.map +1 -0
- package/dist/lib/isolated-broker.d.ts +1 -1
- package/dist/lib/isolated-broker.d.ts.map +1 -1
- package/dist/lib/isolated-broker.js +17 -8
- package/dist/lib/isolated-broker.js.map +1 -1
- package/dist/lib/legacy-start.d.ts +8 -6
- package/dist/lib/legacy-start.d.ts.map +1 -1
- package/dist/lib/legacy-start.js +36 -36
- package/dist/lib/legacy-start.js.map +1 -1
- package/dist/lib/manager-choice.d.ts +45 -4
- package/dist/lib/manager-choice.d.ts.map +1 -1
- package/dist/lib/manager-choice.js +214 -24
- package/dist/lib/manager-choice.js.map +1 -1
- package/dist/lib/manager-proc.d.ts.map +1 -1
- package/dist/lib/manager-proc.js +7 -6
- package/dist/lib/manager-proc.js.map +1 -1
- package/dist/lib/manifest/index.d.ts +5 -1
- package/dist/lib/manifest/index.d.ts.map +1 -1
- package/dist/lib/manifest/index.js +50 -5
- package/dist/lib/manifest/index.js.map +1 -1
- package/dist/lib/manifest/preflight.d.ts +4 -0
- package/dist/lib/manifest/preflight.d.ts.map +1 -1
- package/dist/lib/manifest/preflight.js +18 -1
- package/dist/lib/manifest/preflight.js.map +1 -1
- package/dist/lib/manifest/resolve.d.ts +8 -0
- package/dist/lib/manifest/resolve.d.ts.map +1 -1
- package/dist/lib/manifest/resolve.js +104 -11
- package/dist/lib/manifest/resolve.js.map +1 -1
- package/dist/lib/missing-flags.js +1 -1
- package/dist/lib/missing-flags.js.map +1 -1
- package/dist/lib/nats-bin.d.ts +28 -5
- package/dist/lib/nats-bin.d.ts.map +1 -1
- package/dist/lib/nats-bin.js +85 -7
- package/dist/lib/nats-bin.js.map +1 -1
- package/dist/lib/nearest-word.d.ts +14 -0
- package/dist/lib/nearest-word.d.ts.map +1 -0
- package/dist/lib/nearest-word.js +76 -0
- package/dist/lib/nearest-word.js.map +1 -0
- package/dist/lib/no-expiry-record.d.ts +8 -0
- package/dist/lib/no-expiry-record.d.ts.map +1 -0
- package/dist/lib/no-expiry-record.js +27 -0
- package/dist/lib/no-expiry-record.js.map +1 -0
- package/dist/lib/paths.d.ts +31 -0
- package/dist/lib/paths.d.ts.map +1 -1
- package/dist/lib/paths.js +92 -2
- package/dist/lib/paths.js.map +1 -1
- package/dist/lib/persona-files.d.ts +29 -6
- package/dist/lib/persona-files.d.ts.map +1 -1
- package/dist/lib/persona-files.js +179 -36
- package/dist/lib/persona-files.js.map +1 -1
- package/dist/lib/personas.d.ts +18 -1
- package/dist/lib/personas.d.ts.map +1 -1
- package/dist/lib/personas.js +65 -6
- package/dist/lib/personas.js.map +1 -1
- package/dist/lib/prompts.d.ts +7 -1
- package/dist/lib/prompts.d.ts.map +1 -1
- package/dist/lib/prompts.js +43 -3
- package/dist/lib/prompts.js.map +1 -1
- package/dist/lib/registry-errors.d.ts +2 -1
- package/dist/lib/registry-errors.d.ts.map +1 -1
- package/dist/lib/registry-errors.js +6 -2
- package/dist/lib/registry-errors.js.map +1 -1
- package/dist/lib/reset-space-plan.d.ts +2 -0
- package/dist/lib/reset-space-plan.d.ts.map +1 -1
- package/dist/lib/reset-space-plan.js +1 -1
- package/dist/lib/reset-space-plan.js.map +1 -1
- package/dist/lib/restore.d.ts +45 -3
- package/dist/lib/restore.d.ts.map +1 -1
- package/dist/lib/restore.js +248 -35
- package/dist/lib/restore.js.map +1 -1
- package/dist/lib/rolled-back-runs.d.ts +36 -0
- package/dist/lib/rolled-back-runs.d.ts.map +1 -0
- package/dist/lib/rolled-back-runs.js +96 -0
- package/dist/lib/rolled-back-runs.js.map +1 -0
- package/dist/lib/service-definitions.d.ts +16 -3
- package/dist/lib/service-definitions.d.ts.map +1 -1
- package/dist/lib/service-definitions.js +99 -27
- package/dist/lib/service-definitions.js.map +1 -1
- package/dist/lib/service-instances.d.ts +13 -1
- package/dist/lib/service-instances.d.ts.map +1 -1
- package/dist/lib/service-instances.js +56 -12
- package/dist/lib/service-instances.js.map +1 -1
- package/dist/lib/service-presets.d.ts.map +1 -1
- package/dist/lib/service-presets.js +16 -0
- package/dist/lib/service-presets.js.map +1 -1
- package/dist/lib/service-process.d.ts +51 -8
- package/dist/lib/service-process.d.ts.map +1 -1
- package/dist/lib/service-process.js +385 -48
- package/dist/lib/service-process.js.map +1 -1
- package/dist/lib/space-streams.d.ts +18 -0
- package/dist/lib/space-streams.d.ts.map +1 -0
- package/dist/lib/space-streams.js +35 -0
- package/dist/lib/space-streams.js.map +1 -0
- package/dist/lib/spawn-defaults.d.ts +25 -1
- package/dist/lib/spawn-defaults.d.ts.map +1 -1
- package/dist/lib/spawn-defaults.js +37 -1
- package/dist/lib/spawn-defaults.js.map +1 -1
- package/dist/lib/stack-journal.d.ts +157 -14
- package/dist/lib/stack-journal.d.ts.map +1 -1
- package/dist/lib/stack-journal.js +406 -49
- package/dist/lib/stack-journal.js.map +1 -1
- package/dist/lib/stack-listeners.d.ts +17 -0
- package/dist/lib/stack-listeners.d.ts.map +1 -0
- package/dist/lib/stack-listeners.js +54 -0
- package/dist/lib/stack-listeners.js.map +1 -0
- package/dist/lib/stack-members.d.ts +13 -0
- package/dist/lib/stack-members.d.ts.map +1 -0
- package/dist/lib/stack-members.js +24 -0
- package/dist/lib/stack-members.js.map +1 -0
- package/dist/lib/stack-resume.d.ts.map +1 -1
- package/dist/lib/stack-resume.js +5 -2
- package/dist/lib/stack-resume.js.map +1 -1
- package/dist/lib/stack-runs.d.ts +34 -0
- package/dist/lib/stack-runs.d.ts.map +1 -0
- package/dist/lib/stack-runs.js +75 -0
- package/dist/lib/stack-runs.js.map +1 -0
- package/dist/lib/status.d.ts +11 -0
- package/dist/lib/status.d.ts.map +1 -1
- package/dist/lib/status.js +4 -5
- package/dist/lib/status.js.map +1 -1
- package/dist/lib/stdout-owner.d.ts +12 -3
- package/dist/lib/stdout-owner.d.ts.map +1 -1
- package/dist/lib/stdout-owner.js +33 -5
- package/dist/lib/stdout-owner.js.map +1 -1
- package/dist/lib/store-dir.d.ts +68 -4
- package/dist/lib/store-dir.d.ts.map +1 -1
- package/dist/lib/store-dir.js +253 -17
- package/dist/lib/store-dir.js.map +1 -1
- package/dist/lib/team-additive-attempt.d.ts +1 -1
- package/dist/lib/team-channel-removal.d.ts.map +1 -1
- package/dist/lib/team-channel-removal.js +4 -0
- package/dist/lib/team-channel-removal.js.map +1 -1
- package/dist/lib/team-deploy-inspection.d.ts +13 -0
- package/dist/lib/team-deploy-inspection.d.ts.map +1 -1
- package/dist/lib/team-deploy-inspection.js +12 -0
- package/dist/lib/team-deploy-inspection.js.map +1 -1
- package/dist/lib/team-text.d.ts +6 -0
- package/dist/lib/team-text.d.ts.map +1 -0
- package/dist/lib/team-text.js +36 -0
- package/dist/lib/team-text.js.map +1 -0
- package/dist/lib/transient.d.ts +14 -8
- package/dist/lib/transient.d.ts.map +1 -1
- package/dist/lib/transient.js +72 -11
- package/dist/lib/transient.js.map +1 -1
- package/dist/lib/unusable-file.d.ts +13 -0
- package/dist/lib/unusable-file.d.ts.map +1 -0
- package/dist/lib/unusable-file.js +12 -0
- package/dist/lib/unusable-file.js.map +1 -0
- package/dist/lib/up-report.d.ts +6 -0
- package/dist/lib/up-report.d.ts.map +1 -1
- package/dist/lib/up-report.js +13 -0
- package/dist/lib/up-report.js.map +1 -1
- package/dist/lib/verdict.d.ts +14 -0
- package/dist/lib/verdict.d.ts.map +1 -0
- package/dist/lib/verdict.js +15 -0
- package/dist/lib/verdict.js.map +1 -0
- package/dist/managed-handoff.d.ts +11 -6
- package/dist/managed-handoff.d.ts.map +1 -1
- package/dist/managed-handoff.js +27 -18
- package/dist/managed-handoff.js.map +1 -1
- package/dist/render.d.ts +5 -2
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +44 -10
- package/dist/render.js.map +1 -1
- package/dist/telemetry.d.ts +4 -3
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +14 -6
- package/dist/telemetry.js.map +1 -1
- package/dist/ui.d.ts +3 -2
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +6 -4
- package/dist/ui.js.map +1 -1
- package/dist/view/mesh-view.d.ts.map +1 -1
- package/dist/view/mesh-view.js +4 -1
- package/dist/view/mesh-view.js.map +1 -1
- package/dist/watch-data.d.ts +9 -1
- package/dist/watch-data.d.ts.map +1 -1
- package/dist/watch-data.js +17 -3
- package/dist/watch-data.js.map +1 -1
- package/dist/watch-json.js +4 -3
- package/dist/watch-json.js.map +1 -1
- package/package.json +5 -5
|
@@ -6,27 +6,72 @@
|
|
|
6
6
|
* recorded as such under its definition's lock and is not stopped again, so a repeated stop is a
|
|
7
7
|
* no-op. Shared registry and credential cleanup follow only a complete confirmed stop. Nothing
|
|
8
8
|
* outside the recorded members is touched. The whole apply holds the root's maintenance lock. */
|
|
9
|
+
import { accessSync, constants } from "node:fs";
|
|
10
|
+
import { dirname } from "node:path";
|
|
9
11
|
import * as prompts from "../lib/prompts.js";
|
|
10
|
-
import { DEFAULT_SPACE } from "@cotal-ai/core";
|
|
11
|
-
import { CommandFailure, canonicalRoot, deliveryCredsKey, isCommandFailure, isConnectRefusal, oneLine, presentationOf,
|
|
12
|
-
import {
|
|
12
|
+
import { CotalEndpoint, DEFAULT_SPACE, deliveryLeaseHolderFor, mintCreds, newIdentity } from "@cotal-ai/core";
|
|
13
|
+
import { CommandFailure, ConfirmationRequired, canonicalRoot, deliveryCredsKey, findMesh, getSpaceAuth, homeCotalDir, isCommandFailure, isConnectRefusal, oneLine, presentationOf, processStopped, readBrokerPolicy, readNatsInfoGreeting, recordMesh, recordOperationSpace, recordPreparedSpace, releaseMaintenanceLock, removeMesh, removeMeshesByRoot, renderReport, resolveMeshTarget, stackHomeRemedy, stackRunsUnderOtherHome, terminalWidth, workspaceSecretStore, writeResult, } from "@cotal-ai/workspace";
|
|
14
|
+
import { brokerLaunchAt } from "../lib/broker-service.js";
|
|
15
|
+
import { fullStoreStopRefusal, jetStreamDisabled, jetStreamDisabledRefusal, readStoredBytes, recordedStore, storeFull, storeRefusedWrite } from "../lib/broker-store-health.js";
|
|
16
|
+
import { yesRequired } from "../lib/confirmation-required.js";
|
|
17
|
+
import { noticeOnInterrupt } from "../lib/interrupt-notice.js";
|
|
18
|
+
import { shellWord } from "../lib/endpoint-errors.js";
|
|
13
19
|
import { canPrompt } from "./meshes-wizard.js";
|
|
14
|
-
import {
|
|
20
|
+
import { nativeImpactView } from "./service-actions.js";
|
|
15
21
|
import { serviceDefinitionStore } from "../lib/service-definitions.js";
|
|
16
|
-
import { instanceProjection, observeServiceProcess, serviceInstances, serviceInstanceStore } from "../lib/service-instances.js";
|
|
17
|
-
import { abandonableSignalStop, assertNoServiceUnitAttempts, prepareKernelServiceStop, prepareNativeServiceStop, retainedStopRequest, settleExitedInstance, stopProcessService } from "../lib/service-process.js";
|
|
18
|
-
import { abandonRemedy, abandonRetainedStackStop, acquireStackOperationLock, newStackOperation, previewStackSettlement, processGone, readStackJournal,
|
|
22
|
+
import { instanceProjection, observeServiceProcess, serviceInstances, serviceInstanceStore, serviceRecordsWriteProblem } from "../lib/service-instances.js";
|
|
23
|
+
import { abandonableSignalStop, assertNoServiceUnitAttempts, prepareKernelServiceStop, prepareNativeServiceStop, readinessAddressSurvivors, resumableSignalStop, retainedStopRequest, settleExitedInstance, PROCESS_STOP_GRACE_MS, stopProcessService } from "../lib/service-process.js";
|
|
24
|
+
import { abandonLaunchRemedy, abandonRemedy, abandonRetainedStackStop, abandonUnresolvedStackLaunch, acquireStackOperationLock, interruptedUpLeftManagerOut, newStackOperation, localRecords, previewStackSettlement, processGone, readStackJournal, recordedProcessesUnder, recordedProcessLine, refuseControllerCut, removeStaleLocalRecords, RESUME_REMEDY, runningStackRoles, settleRetainedStackStops, STACK_DEFINITION, STACK_ROLES, settleStackOperation, stackJournalPath, stackMaintenanceFence, stackNeverStarted, stackOperationUnsettled, stackScopeRefusals, stackSettlementNotice, staleRecordNotice, withSettledMembers, writeStackJournal } from "../lib/stack-journal.js";
|
|
25
|
+
import { readStackRuns } from "../lib/stack-runs.js";
|
|
19
26
|
const STOP_ORDER = ["manager", "delivery", "auth", "broker"];
|
|
20
27
|
/** The controller route applies whenever the root has a stack journal. */
|
|
21
28
|
export function controllerStackRecorded(root) {
|
|
22
29
|
return readStackJournal(canonicalRoot(root)) !== undefined;
|
|
23
30
|
}
|
|
31
|
+
/** The root of the controller stack this machine started for `space` in a folder other than `root`,
|
|
32
|
+
* or undefined. `cotal down` stops only the stack of the folder it runs in, so a refusal names it. */
|
|
33
|
+
export function stackRootElsewhere(space, root) {
|
|
34
|
+
try {
|
|
35
|
+
const mesh = findMesh(space);
|
|
36
|
+
return mesh && mesh.origin === "up" && canonicalRoot(mesh.root) !== canonicalRoot(root) && controllerStackRecorded(mesh.root) ? mesh.root : undefined;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** The same `down`, without `--space`, for a refusal that names the folder to run it from. */
|
|
43
|
+
export const sameDown = (values) => ["cotal down", ...["dry-run", "with-agents", "preserve-state", "yes"].filter((flag) => values[flag] === true).map((flag) => `--${flag}`)].join(" ");
|
|
44
|
+
/** A stop records each member's stop under the space's service instance records, so a folder there this
|
|
45
|
+
* account cannot write refuses before the plan, naming it, rather than leaving every member running
|
|
46
|
+
* after an unknown first stop. */
|
|
47
|
+
function assertServiceRecordsWritable(root, space, values) {
|
|
48
|
+
const dir = serviceRecordsWriteProblem(space, ["instances"]);
|
|
49
|
+
if (dir)
|
|
50
|
+
throw new CommandFailure("refused", "PERMISSION_DENIED", `this account cannot write ${dir}, where down records each member's stop; no member was stopped`, {
|
|
51
|
+
target: { root, space, path: dir },
|
|
52
|
+
remedy: `make it writable with chmod u+w ${dir}, then run \`${sameDown({ ...values, "dry-run": undefined, yes: true })}\``,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/** A stop records each step in the stack journal in the root's `.cotal`, so a folder this account
|
|
56
|
+
* cannot write refuses before the plan, naming it, rather than after the plan at the first write. */
|
|
57
|
+
function assertJournalWritable(root, values) {
|
|
58
|
+
const dir = dirname(stackJournalPath(root));
|
|
59
|
+
try {
|
|
60
|
+
accessSync(dir, constants.W_OK | constants.X_OK);
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
throw new CommandFailure("refused", "PERMISSION_DENIED", `this account cannot write ${dir}, where down records each step of the stop in the stack journal; no member was stopped`, {
|
|
64
|
+
target: { root, path: dir },
|
|
65
|
+
remedy: `make it writable with chmod u+w ${shellWord(dir)}, then run \`${sameDown({ ...values, "dry-run": undefined, yes: true })}\``,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
24
69
|
export function validateStackDownArguments(root, values) {
|
|
25
70
|
const preserve = values["preserve-state"] === true;
|
|
26
|
-
const allowed = new Set(preserve ? ["space", "yes", "json", "plain", "preserve-state", "store-dir", "session-store"] : ["space", "yes", "dry-run", "json", "plain", "with-agents", "abandon-stop"]);
|
|
71
|
+
const allowed = new Set(preserve ? ["space", "yes", "json", "plain", "preserve-state", "store-dir", "session-store"] : ["space", "yes", "dry-run", "json", "plain", "with-agents", "abandon-stop", "abandon-launch"]);
|
|
27
72
|
const unsupported = Object.keys(values).filter((name) => !allowed.has(name) && values[name] !== undefined && !(Array.isArray(values[name]) && values[name].length === 0));
|
|
28
73
|
if (unsupported.length)
|
|
29
|
-
throw new CommandFailure("refused", "USAGE_INVALID", preserve ? "a controller stack's preserve accepts only --space, --store-dir, --session-store, --yes and presentation flags; it is exclusive with --with-agents and --dry-run" : "a controller stack's bare down accepts only --space, --with-agents, --abandon-stop, --yes, --dry-run and presentation flags; no other option was ignored", { target: { options: unsupported } });
|
|
74
|
+
throw new CommandFailure("refused", "USAGE_INVALID", preserve ? "a controller stack's preserve accepts only --space, --store-dir, --session-store, --yes and presentation flags; it is exclusive with --with-agents and --dry-run" : "a controller stack's bare down accepts only --space, --with-agents, --abandon-stop, --abandon-launch, --yes, --dry-run and presentation flags; no other option was ignored", { target: { options: unsupported } });
|
|
30
75
|
if (values["dry-run"] === true && values.yes === true)
|
|
31
76
|
throw new CommandFailure("refused", "USAGE_INVALID", "--yes acknowledges a guarded apply, not a read-only stack preview");
|
|
32
77
|
if (values["abandon-stop"] !== undefined) {
|
|
@@ -35,7 +80,13 @@ export function validateStackDownArguments(root, values) {
|
|
|
35
80
|
if (values["with-agents"] === true)
|
|
36
81
|
throw new CommandFailure("refused", "USAGE_INVALID", "--abandon-stop cannot be combined with --with-agents: the abandoned stop's manager has exited, so no manager can stop the agents");
|
|
37
82
|
if (values.yes !== true)
|
|
38
|
-
throw new
|
|
83
|
+
throw new ConfirmationRequired("--abandon-stop needs --yes, because it gives up the only record of what that stop did", { remedy: `run cotal down --abandon-stop ${values["abandon-stop"]} --yes to give it up` });
|
|
84
|
+
}
|
|
85
|
+
if (values["abandon-launch"] !== undefined) {
|
|
86
|
+
if (values["dry-run"] === true)
|
|
87
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "--abandon-launch records a member launch failed, so a read-only preview cannot take it");
|
|
88
|
+
if (values.yes !== true)
|
|
89
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "--abandon-launch needs --yes, because a process that launch started without recording it is not excluded");
|
|
39
90
|
}
|
|
40
91
|
if (preserve)
|
|
41
92
|
refuseControllerCut(root, "down --preserve-state");
|
|
@@ -57,12 +108,12 @@ function readMembers(journal) {
|
|
|
57
108
|
const state = observeServiceProcess(instance.record.value);
|
|
58
109
|
const inspect = `inspect it with cotal service status ${row.definition} --instance ${row.instanceId} --space ${journal.space}`;
|
|
59
110
|
if (!processGone(state) && state !== "running")
|
|
60
|
-
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "a recorded stack member is foreign, unreadable or has an unresolved launch; no member was stopped", { target: instanceProjection(instance), remedy: inspect });
|
|
111
|
+
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "a recorded stack member is foreign, unreadable or has an unresolved launch; no member was stopped", { target: instanceProjection(instance), remedy: state === "unresolved-launch" ? `${inspect}; ${abandonLaunchRemedy(row.instanceId)}` : inspect });
|
|
61
112
|
const retained = retainedStopRequest(instance.record.value);
|
|
62
113
|
if (instance.record.value.state === "stopping" || retained)
|
|
63
114
|
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", retained?.publication === "unknown"
|
|
64
115
|
? "a recorded stack member's stop request file does not read as its own, so whether a stop was published is unknown; nothing was resubmitted and no member was stopped"
|
|
65
|
-
: "a recorded stack member retains an unconfirmed stop request; it was not resubmitted and no member was stopped", { target: { ...instanceProjection(instance), ...(retained ? { requestId: retained.requestId, stopPublication: retained.publication } : {}) }, remedy: retained?.publication === "published" ? `${inspect}; ${abandonRemedy(retained.requestId)}` : abandonableSignalStop(instance.record.value) ? `${inspect}; ${abandonRemedy(instance.record.value.requestId)}` : inspect });
|
|
116
|
+
: "a recorded stack member retains an unconfirmed stop request; it was not resubmitted and no member was stopped", { target: { ...instanceProjection(instance), ...(retained ? { requestId: retained.requestId, stopPublication: retained.publication } : {}) }, remedy: retained?.publication === "published" ? `${inspect}; ${abandonRemedy(retained.requestId)}` : abandonableSignalStop(instance.record.value) ? `${inspect}; ${abandonRemedy(instance.record.value.requestId)}` : resumableSignalStop(instance.record.value) ? `${inspect}; ${RESUME_REMEDY}` : inspect });
|
|
66
117
|
assertNoServiceUnitAttempts(journal.space, row.definition);
|
|
67
118
|
members.push({ role: row.role, definition, instance, live: state === "running" });
|
|
68
119
|
}
|
|
@@ -70,26 +121,59 @@ function readMembers(journal) {
|
|
|
70
121
|
}
|
|
71
122
|
/** A live manager's agent impact is read through the broker on an authenticated stack. When the
|
|
72
123
|
* stack's broker is gone that read cannot succeed, so the refusal names the command that brings
|
|
73
|
-
* the broker back while keeping the live manager.
|
|
124
|
+
* the broker back while keeping the live manager. A broker whose process runs but sends no
|
|
125
|
+
* greeting, as a suspended one does, is named with its pid; the broker stops last, so it is not
|
|
126
|
+
* signalled here. */
|
|
74
127
|
async function managerImpact(journal, members, manager, withAgents) {
|
|
75
128
|
try {
|
|
76
129
|
return await prepareNativeServiceStop(manager.definition, manager.instance, withAgents);
|
|
77
130
|
}
|
|
78
131
|
catch (caught) {
|
|
132
|
+
if (storeRefusedWrite(caught)) {
|
|
133
|
+
let store;
|
|
134
|
+
try {
|
|
135
|
+
store = recordedStore(journal.root, journal.space);
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
store = undefined;
|
|
139
|
+
}
|
|
140
|
+
throw fullStoreStop(journal, manager, store);
|
|
141
|
+
}
|
|
142
|
+
// Nothing was submitted: the stop's credential could not be recorded on a broker without JetStream.
|
|
143
|
+
const disabled = jetStreamDisabled(journal.root, journal.space);
|
|
144
|
+
if (disabled && !(isCommandFailure(caught) && caught.outcome !== "unknown"))
|
|
145
|
+
throw disabledJetStreamStop(journal, manager, disabled);
|
|
79
146
|
// The read connects through the broker, so a gone broker surfaces as the connect refusal.
|
|
80
147
|
const error = isConnectRefusal(caught) ? caught.failure() : caught;
|
|
81
|
-
|
|
148
|
+
const broker = members.find((member) => member.role === "broker" && member.live);
|
|
149
|
+
const pid = broker?.instance.record.value.process?.pid;
|
|
150
|
+
if (pid !== undefined && isCommandFailure(error) && !await readNatsInfoGreeting(journal.server, 2000)) {
|
|
151
|
+
throw new CommandFailure("refused", "TARGET_UNAVAILABLE", `the stack's broker runs as pid ${pid} but does not answer at ${journal.server}, so the live manager's agent impact cannot be read; no member was stopped`, { target: { root: journal.root, space: journal.space, broker: broker.instance.name, pid, manager: manager.instance.name }, native: { code: error.code, outcome: error.outcome, detail: error.message }, remedy: `if pid ${pid} is suspended, resume it with kill -CONT ${pid} and run cotal down again; if it stays unresponsive, end it with kill -KILL ${pid}, then run cotal up --space ${journal.space} to restart the broker while the manager keeps running, then run cotal down` });
|
|
152
|
+
}
|
|
153
|
+
if (broker || !isCommandFailure(error))
|
|
82
154
|
throw caught;
|
|
83
155
|
throw new CommandFailure("refused", error.code, "the stack's broker is not running, so the live manager's agent impact cannot be read; no member was stopped", { target: { root: journal.root, space: journal.space, manager: manager.instance.name }, native: { code: error.code, outcome: error.outcome, detail: error.message }, remedy: `run cotal up --space ${journal.space} to restart the broker from its recorded inputs while the manager keeps running, then run cotal down` });
|
|
84
156
|
}
|
|
85
157
|
}
|
|
158
|
+
/** The full-store refusal of a stack's manager stop, before any member is stopped. Making room
|
|
159
|
+
* purges the space's channel history; a plain SIGTERM to the manager's own process needs no
|
|
160
|
+
* credential, so it stops the stack without that loss. */
|
|
161
|
+
function fullStoreStop(journal, manager, store) {
|
|
162
|
+
const pid = manager.instance.record.value.process?.pid;
|
|
163
|
+
return fullStoreStopRefusal("the manager", store, "no member was stopped", { root: journal.root, space: journal.space, manager: manager.instance.name }, `make room with cotal history clear --yes, which purges all of this space's channel history, then run cotal down${pid !== undefined ? `; to keep that history, end the manager on this host with kill -TERM ${pid}, which stops its agents by its default policy, then run cotal down, and cotal up --max-file-store <bytes> with a larger cap` : ""}`);
|
|
164
|
+
}
|
|
165
|
+
/** The refusal of a stack's manager stop while its broker has JetStream disabled, before any member
|
|
166
|
+
* is stopped. */
|
|
167
|
+
function disabledJetStreamStop(journal, manager, write) {
|
|
168
|
+
return jetStreamDisabledRefusal(write, journal.root, journal.space, "stopping the manager needs a credential whose issuance record the broker cannot store", "no member was stopped", { root: journal.root, space: journal.space, manager: manager.instance.name }, manager.instance.record.value.process?.pid);
|
|
169
|
+
}
|
|
86
170
|
/** Everything outside the recorded members that would be cut off refuses before the first signal.
|
|
87
171
|
* Returns a settled active restore of this stack that was admitted, for the result to name. */
|
|
88
172
|
function scopeRefusals(journal) {
|
|
89
173
|
const maintenance = stackMaintenanceFence(journal.root, journal);
|
|
90
174
|
if (maintenance.fenced)
|
|
91
175
|
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "this root retains a maintenance attempt; the controller stack was not stopped under it", { target: { root: journal.root } });
|
|
92
|
-
stackScopeRefusals(journal, "bare cotal down");
|
|
176
|
+
stackScopeRefusals(journal, "bare `cotal down`");
|
|
93
177
|
return maintenance.admittedRestore;
|
|
94
178
|
}
|
|
95
179
|
/** A stack its own down stopped completely, with no recorded member and no other service instance of
|
|
@@ -110,9 +194,10 @@ function alreadyStopped(journal, members) {
|
|
|
110
194
|
* record and its pid in the message and the remedy, because no command shows another space's
|
|
111
195
|
* records; nothing is stopped, adopted or removed. A real --with-agents refuses too, because no
|
|
112
196
|
* running manager can stop the agents, unless the caller knows none can remain: the last down took
|
|
113
|
-
* --with-agents, or the root never started a stack. Its preview shows the no-op
|
|
114
|
-
* answers the same way. `warnings` report what this command changed before
|
|
115
|
-
|
|
197
|
+
* --with-agents, or the root never started a stack. Its `preview` shows the no-op and warns with that
|
|
198
|
+
* refusal. The legacy route answers the same way. `warnings` report what this command changed before
|
|
199
|
+
* it found nothing running. */
|
|
200
|
+
export function nothingRunning(presentation, target, withAgents, warnings = [], preview = false) {
|
|
116
201
|
// A root that names no space resolves to the default one, as `resolveSpace` answers.
|
|
117
202
|
const remaining = recordedProcessesUnder(target.root, [target.space ?? DEFAULT_SPACE]);
|
|
118
203
|
if (remaining.length) {
|
|
@@ -123,13 +208,52 @@ export function nothingRunning(presentation, target, withAgents, warnings = [])
|
|
|
123
208
|
remedy: `check ${checks.join(", ")}; stop each process where it was started, or remove a record whose process is gone, then run \`cotal down\` again`,
|
|
124
209
|
});
|
|
125
210
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
211
|
+
const agents = withAgents ? new CommandFailure("refused", "LIFECYCLE_BLOCKED", "--with-agents needs the stack's running manager, and this folder's stack is not running; nothing was stopped", { target, remedy: "start it with `cotal up`, then run `cotal down --with-agents`" }) : undefined;
|
|
212
|
+
if (agents && !preview)
|
|
213
|
+
throw agents;
|
|
214
|
+
const shown = agents ? [...warnings, { code: agents.code, target, message: `the real stop would refuse: ${agents.message}; ${agents.remedy}` }] : warnings;
|
|
215
|
+
writeResult(presentation, { command: "down", target, result: { kind: "stack-not-running", ...target }, noOp: true, ...(shown.length ? { warnings: shown } : {}) }, () => ({ sections: [
|
|
129
216
|
{ title: `The stack in ${target.root} is not running`, blocks: [{ kind: "lines", lines: ["Nothing was stopped."] }] },
|
|
130
217
|
{ title: "Next", blocks: [{ kind: "commands", items: [{ command: "cotal up", description: "Start it" }] }] },
|
|
131
218
|
] }));
|
|
132
219
|
}
|
|
220
|
+
/** The registration `cotal up` wrote for this stack is how its members' stops reach it. An older
|
|
221
|
+
* `meshes rm --force` dropped it, and an older `meshes add --force` replaced it with one added by
|
|
222
|
+
* hand. When it is missing, or a hand-added one names this same root and broker, the stop rebuilds
|
|
223
|
+
* it from the journal, but only while the stack's broker is the exact launch the journal records
|
|
224
|
+
* there. A hand-added registration of another address or folder is not replaced: removing it takes
|
|
225
|
+
* an act that names it. One another stack started, or a catalog lists, resolves as before. */
|
|
226
|
+
function strandedRegistration(journal, members) {
|
|
227
|
+
const registered = findMesh(journal.space);
|
|
228
|
+
if (registered && registered.origin !== "manual" || !members.some((member) => member.live))
|
|
229
|
+
return undefined;
|
|
230
|
+
const target = { root: journal.root, space: journal.space, server: journal.server };
|
|
231
|
+
if (registered && (registered.server !== journal.server || canonicalRoot(registered.root) !== journal.root))
|
|
232
|
+
throw new CommandFailure("refused", "CONFLICT", `"${journal.space}" is registered by hand at ${registered.server} for ${registered.root}, and this stack's broker is ${journal.server} in ${journal.root}; a registration added by hand is not replaced, so nothing was stopped`, { target, remedy: `if that registration names no other mesh you use, forget it with \`cotal space forget ${journal.space}\`, then run \`cotal down --yes\` here` });
|
|
233
|
+
const what = registered ? "is registered by hand" : "has no registration";
|
|
234
|
+
if (journal.mode === "user")
|
|
235
|
+
throw new CommandFailure("refused", "UNSUPPORTED", `"${journal.space}" ${what}, and a user-auth stack's registration holds sign-in settings its journal does not, so it was not rebuilt; nothing was stopped`, { target, remedy: `inspect the recorded members with \`cotal service --space ${journal.space}\`` });
|
|
236
|
+
const broker = members.find((member) => member.role === "broker");
|
|
237
|
+
if (!broker?.live || !brokerLaunchAt(journal.space, broker.instance.name, broker.instance.record.value.launchRequestId, journal.root, journal.server))
|
|
238
|
+
throw new CommandFailure("refused", "CONFLICT", `"${journal.space}" ${what}, and the stack's broker is not the launch its journal records at ${journal.server}, so its registration was not rebuilt; nothing was stopped`, { target, remedy: `inspect the recorded members with \`cotal service --space ${journal.space}\`` });
|
|
239
|
+
const tlsRequired = readBrokerPolicy(journal.root)?.transport.kind === "tls-required";
|
|
240
|
+
return { previous: registered, entry: {
|
|
241
|
+
space: journal.space, server: journal.server, root: journal.root, mode: journal.mode, origin: "up", ts: new Date().toISOString(),
|
|
242
|
+
...(tlsRequired ? { tlsRequired: true } : {}),
|
|
243
|
+
...(journal.broker ? { storeDir: journal.broker.storeDir, ...(journal.broker.maxFileStore !== undefined ? { maxFileStore: journal.broker.maxFileStore } : {}), ...(journal.broker.host !== undefined ? { attachHost: journal.broker.host } : {}) } : {}),
|
|
244
|
+
} };
|
|
245
|
+
}
|
|
246
|
+
/** A stale process record a complete stop removed, or for a preview, one it would remove. */
|
|
247
|
+
function staleWarning(root, row, preview = false) {
|
|
248
|
+
return { code: "STALE_PROCESS_RECORD", target: { root, path: row.path, pid: row.pid, state: row.state }, message: staleRecordNotice(row, preview) };
|
|
249
|
+
}
|
|
250
|
+
/** What a stop that rebuilt the registration says it did, or for a preview, what it would do. */
|
|
251
|
+
function strandedNotice(journal, previous, preview = false) {
|
|
252
|
+
const used = preview ? "the stop would use" : "the stop used";
|
|
253
|
+
return { code: "REGISTRATION_REBUILT", target: { root: journal.root, space: journal.space, server: journal.server }, message: previous
|
|
254
|
+
? `"${journal.space}" ${preview ? "is" : "was"} registered by hand at this stack's own root and broker; ${used} the registration \`cotal up\` writes for this stack, rebuilt from its journal, in its place`
|
|
255
|
+
: `"${journal.space}" ${preview ? "has" : "had"} no registration; ${used} the one \`cotal up\` writes for this stack, rebuilt from its journal` };
|
|
256
|
+
}
|
|
133
257
|
/** What an abandoned member stop leaves unconfirmed. */
|
|
134
258
|
function abandonNotice(role, abandonment) {
|
|
135
259
|
const receipts = abandonment.receipts.length ? `only ${abandonment.receipts.join(" and ")} receipts` : "no receipt";
|
|
@@ -164,15 +288,42 @@ export async function stackDown(rootInput, values) {
|
|
|
164
288
|
// The preview reads without the lock and writes nothing. The real stop holds the root's
|
|
165
289
|
// maintenance lock from its first read to its last write, so no other whole-stack operation runs.
|
|
166
290
|
if (values["dry-run"] === true)
|
|
167
|
-
return previewStackStop(root, values, presentation, withAgents);
|
|
168
|
-
|
|
291
|
+
return await previewStackStop(root, values, presentation, withAgents);
|
|
292
|
+
// A signal ends the stop where it is, and the notice names the members that still run. It is
|
|
293
|
+
// installed before the lock, so no moment of the stop exits without it.
|
|
294
|
+
const release = noticeOnInterrupt(() => stackStopInterruptNotice(root));
|
|
169
295
|
try {
|
|
170
|
-
|
|
296
|
+
// A busy root's refusal names the recorded space, as every refusal after the lock does.
|
|
297
|
+
const recorded = readStackJournal(root)?.journal.space;
|
|
298
|
+
if (recorded !== undefined)
|
|
299
|
+
recordOperationSpace(recorded);
|
|
300
|
+
const lock = acquireStackOperationLock(root);
|
|
301
|
+
try {
|
|
302
|
+
await applyStackStop(root, values, presentation, interactive, withAgents, lock);
|
|
303
|
+
}
|
|
304
|
+
finally {
|
|
305
|
+
releaseMaintenanceLock(lock);
|
|
306
|
+
}
|
|
171
307
|
}
|
|
172
308
|
finally {
|
|
173
|
-
|
|
309
|
+
release();
|
|
174
310
|
}
|
|
175
311
|
}
|
|
312
|
+
/** What an interrupted bare down left: the members still running, and the down that finishes it. A
|
|
313
|
+
* member it left `stopping` under a signal is stopped again by that down while it runs, and once it
|
|
314
|
+
* has exited only `--abandon-stop` settles it, so the notice names both. */
|
|
315
|
+
function stackStopInterruptNotice(root) {
|
|
316
|
+
const space = readStackJournal(root)?.journal.space;
|
|
317
|
+
const running = space === undefined ? [] : runningStackRoles(space);
|
|
318
|
+
const signalled = space === undefined ? undefined : STACK_ROLES.flatMap((role) => serviceInstances(space, STACK_DEFINITION[role])
|
|
319
|
+
.filter(({ record: { value } }) => !value.nativeStopRequired && value.state === "stopping").map(({ record: { value } }) => ({ role, requestId: value.requestId })))[0];
|
|
320
|
+
const left = running.length ? `${running.join(", ")} ${running.length === 1 ? "is" : "are"} still running` : "no member is running";
|
|
321
|
+
if (signalled)
|
|
322
|
+
return `Interrupted while stopping the stack in ${root}; ${left}. The stop of ${signalled.role} is not confirmed: while it runs, cotal down --yes stops it again, and once it has exited, cotal down --abandon-stop ${signalled.requestId} --yes finishes the stop.`;
|
|
323
|
+
return running.length
|
|
324
|
+
? `Interrupted while stopping the stack in ${root}; ${left}. Run cotal down --yes to finish the stop.`
|
|
325
|
+
: `Interrupted while stopping the stack in ${root}; no member is running. Run cotal down --yes to finish its cleanup.`;
|
|
326
|
+
}
|
|
176
327
|
/** The recorded stack this stop targets, with every refusal that needs no lock or write. An earlier
|
|
177
328
|
* preserve or resume with no outcome is decided by its own maintenance attempt; an earlier up or
|
|
178
329
|
* down with none is classified read-only from its members, and refuses if any is unresolved. */
|
|
@@ -181,9 +332,17 @@ function stopTarget(root, values) {
|
|
|
181
332
|
if (!previous)
|
|
182
333
|
throw new CommandFailure("refused", "TARGET_NOT_FOUND", "this root has no controller stack journal", { target: { root } });
|
|
183
334
|
const journal0 = previous.journal;
|
|
335
|
+
if (values.space !== undefined && values.space !== journal0.space) {
|
|
336
|
+
const space = String(values.space), elsewhere = stackRootElsewhere(space, root);
|
|
337
|
+
recordOperationSpace(space);
|
|
338
|
+
throw new CommandFailure("refused", "CONFLICT", `--space ${space} ${elsewhere ? `names a controller stack rooted at ${elsewhere}` : "is not this folder's stack"}, and \`cotal down\` stops only the stack of the folder it runs in; this folder's stack is ${journal0.space}, so no member was stopped`, {
|
|
339
|
+
target: { root, space, recordedSpace: journal0.space, ...(elsewhere ? { stackRoot: elsewhere } : {}) },
|
|
340
|
+
remedy: elsewhere ? `run \`${sameDown(values)}\` from ${elsewhere}` : `run \`${sameDown(values)}\` from the folder whose stack is ${space}, or drop --space to stop ${journal0.space} here`,
|
|
341
|
+
});
|
|
342
|
+
}
|
|
184
343
|
recordOperationSpace(journal0.space);
|
|
185
|
-
if (
|
|
186
|
-
throw new CommandFailure("refused", "
|
|
344
|
+
if (stackRunsUnderOtherHome(root, journal0))
|
|
345
|
+
throw new CommandFailure("refused", "TARGET_UNAVAILABLE", "this root's controller stack runs under another Cotal home; this one holds no record of its members, so no member was stopped", { target: { root, space: journal0.space, cotalHome: homeCotalDir() }, remedy: stackHomeRemedy() });
|
|
187
346
|
if (stackOperationUnsettled(journal0) && journal0.operation.kind !== "up" && journal0.operation.kind !== "down")
|
|
188
347
|
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "an earlier preserve or resume on this root has no settled outcome; it is decided by its own maintenance attempt and no member was stopped", { target: { root, operation: journal0.operation }, remedy: `inspect the root's maintenance attempt and the stack's members with cotal service --space ${journal0.space}` });
|
|
189
348
|
const settlement = previewStackSettlement(journal0);
|
|
@@ -193,28 +352,82 @@ function stopTarget(root, values) {
|
|
|
193
352
|
const members = readMembers(scoped);
|
|
194
353
|
return { previous, journal0: scoped, settlement, members, target: { root, space: journal0.space, server: journal0.server } };
|
|
195
354
|
}
|
|
196
|
-
function previewStackStop(root, values, presentation, withAgents) {
|
|
355
|
+
async function previewStackStop(root, values, presentation, withAgents) {
|
|
197
356
|
const { journal0, settlement, members, target } = stopTarget(root, values);
|
|
198
|
-
|
|
199
|
-
|
|
357
|
+
// As the real stop does, a stack its own down stopped refuses --with-agents unless that down took it.
|
|
358
|
+
const stopped = alreadyStopped(journal0, members);
|
|
359
|
+
if (stopped || stackNeverStarted(journal0))
|
|
360
|
+
return nothingRunning(presentation, target, stopped && withAgents && !journal0.operation.withAgents, [], true);
|
|
200
361
|
// A preview reports what would refuse the real stop instead of refusing itself.
|
|
201
|
-
let blocked, restore;
|
|
362
|
+
let blocked, restore, stranded;
|
|
202
363
|
try {
|
|
203
364
|
restore = scopeRefusals(journal0);
|
|
365
|
+
stranded = strandedRegistration(journal0, members);
|
|
366
|
+
assertJournalWritable(root, values);
|
|
367
|
+
assertServiceRecordsWritable(root, journal0.space, values);
|
|
204
368
|
}
|
|
205
369
|
catch (error) {
|
|
206
370
|
if (!isCommandFailure(error))
|
|
207
371
|
throw error;
|
|
208
372
|
blocked = error;
|
|
209
373
|
}
|
|
210
|
-
|
|
374
|
+
// A live manager's stop needs room in the store, so the preview reads how much the space holds.
|
|
375
|
+
const manager = members.find((member) => member.role === "manager" && member.live);
|
|
376
|
+
const brokerPid = members.find((member) => member.role === "broker" && member.live)?.instance.record.value.process?.pid;
|
|
377
|
+
if (!blocked && manager && brokerPid !== undefined && !processStopped(brokerPid)) {
|
|
378
|
+
// A broker that disabled JetStream answers no read of the store, so its own log decides first.
|
|
379
|
+
const disabled = jetStreamDisabled(root, journal0.space);
|
|
380
|
+
let used;
|
|
381
|
+
if (!disabled)
|
|
382
|
+
try {
|
|
383
|
+
used = await readStoredBytes(resolveMeshTarget(root, { space: journal0.space, readOnly: true }), "down-preview");
|
|
384
|
+
}
|
|
385
|
+
catch {
|
|
386
|
+
used = undefined;
|
|
387
|
+
}
|
|
388
|
+
const full = used === undefined ? undefined : storeFull(root, journal0.space, used);
|
|
389
|
+
if (disabled)
|
|
390
|
+
blocked = disabledJetStreamStop(journal0, manager, disabled);
|
|
391
|
+
else if (full)
|
|
392
|
+
blocked = fullStoreStop(journal0, manager, full);
|
|
393
|
+
}
|
|
394
|
+
const warnings = blocked ? [{ code: blocked.code, target: blocked.target, message: `the real stop would refuse: ${blocked.message}${blocked.remedy ? `; ${blocked.remedy}` : ""}` }]
|
|
395
|
+
: [...stranded ? [strandedNotice(journal0, stranded.previous, true)] : [], ...localRecords(root, journal0.space).filter((row) => row.state !== "live").map((row) => staleWarning(root, row, true))];
|
|
211
396
|
// A preview that changes nothing succeeds. It is partial only in what it read: no provider and
|
|
212
397
|
// no manager impact, which the real stop reads and confirms before any signal.
|
|
213
398
|
writeResult(presentation, { command: "down", target, result: { kind: "controller-stack-stop-preview", ...target, withAgents, members: members.map((member) => ({ role: member.role, definition: member.definition.name, instanceId: member.instance.name, process: member.live ? "running" : "gone" })), settlesOperation: settlement ?? null, blockedBy: blocked?.detail() ?? null, nativeImpactChecked: false, dryRun: true, signalled: false, admittedRestore: restore ?? null }, completeness: "partial", warnings }, () => {
|
|
214
399
|
const view = planView(journal0, members, withAgents, settlement);
|
|
215
|
-
return { ...view, sections: [...view.sections, ...restoreNotice(restore), { title: "Preview", blocks: [{ kind: "lines", lines: ["Nothing was stopped or written. The preview reads recorded members
|
|
400
|
+
return { ...view, sections: [...view.sections, ...restoreNotice(restore), { title: "Preview", blocks: [{ kind: "lines", lines: ["Nothing was stopped or written. The preview reads recorded members and, with a live manager, how much the space's store holds; it loads no provider and queries no manager impact. The real stop reads and confirms that impact before any signal."] }] }] };
|
|
216
401
|
});
|
|
217
402
|
}
|
|
403
|
+
/** Whether shard 0 of the delivery lease still names the daemon this root's stored credential gave,
|
|
404
|
+
* read over an observer credential after the daemon's stop while the broker still runs. A daemon
|
|
405
|
+
* that was killed, or whose release write the broker refused, as a full store refuses it, leaves its
|
|
406
|
+
* row until the lease expires. The holder is the one that credential gives, never a name or pid.
|
|
407
|
+
* "unread" when the row could not be read. */
|
|
408
|
+
async function deliveryLeaseAfterStop(root, space, server) {
|
|
409
|
+
const store = workspaceSecretStore(root);
|
|
410
|
+
let ep;
|
|
411
|
+
try {
|
|
412
|
+
const creds = await store.get(deliveryCredsKey(space, { injected: false, root }));
|
|
413
|
+
if (creds === undefined)
|
|
414
|
+
return "released";
|
|
415
|
+
const auth = await getSpaceAuth(store, space);
|
|
416
|
+
if (!auth)
|
|
417
|
+
return "unread";
|
|
418
|
+
const id = newIdentity();
|
|
419
|
+
ep = new CotalEndpoint({ space, servers: server, tls: readBrokerPolicy(root)?.transport.kind === "tls-required", creds: await mintCreds(auth, id, "observer"), channels: [], consume: false, registerPresence: false, watchPresence: false, watchChannels: false, card: { id: id.id, name: "down-delivery-lease", kind: "endpoint" } });
|
|
420
|
+
ep.on("error", () => { });
|
|
421
|
+
await ep.start();
|
|
422
|
+
return (await ep.readDeliveryLease(0))?.holder === deliveryLeaseHolderFor(creds) ? "held" : "released";
|
|
423
|
+
}
|
|
424
|
+
catch {
|
|
425
|
+
return "unread";
|
|
426
|
+
}
|
|
427
|
+
finally {
|
|
428
|
+
await ep?.stop().catch(() => { });
|
|
429
|
+
}
|
|
430
|
+
}
|
|
218
431
|
async function applyStackStop(root, values, presentation, interactive, withAgents, lock) {
|
|
219
432
|
// A member stop an earlier down could not confirm in time is settled from its own receipt first.
|
|
220
433
|
const recorded = readStackJournal(root)?.journal;
|
|
@@ -223,43 +436,80 @@ async function applyStackStop(root, values, presentation, interactive, withAgent
|
|
|
223
436
|
await settleRetainedStackStops(ours);
|
|
224
437
|
// A stop no receipt can settle is abandoned only when the operator names its request.
|
|
225
438
|
const abandoned = ours && typeof values["abandon-stop"] === "string" ? await abandonRetainedStackStop(ours, values["abandon-stop"]) : undefined;
|
|
226
|
-
|
|
439
|
+
// So is a launch whose record names no process, when the operator names its instance.
|
|
440
|
+
const launch = ours && typeof values["abandon-launch"] === "string" ? abandonUnresolvedStackLaunch(ours, values["abandon-launch"]) : undefined;
|
|
441
|
+
const abandonWarnings = [
|
|
442
|
+
...(abandoned ? [{ code: "STOP_ABANDONED", target: { ...instanceProjection(abandoned.row), role: abandoned.role, requestId: abandoned.abandonment.requestId, receipts: abandoned.abandonment.receipts }, message: abandonNotice(abandoned.role, abandoned.abandonment) }] : []),
|
|
443
|
+
...(launch ? [{ code: "LAUNCH_ABANDONED", target: { ...instanceProjection(launch.row), role: launch.role }, message: `the ${launch.role} launch ${launch.row.name} was recorded failed: the up that started it exited before it recorded a process. A process that launch started without recording it is not excluded, and this down does not stop it` }] : []),
|
|
444
|
+
];
|
|
227
445
|
const { previous, journal0, settlement, members, target } = stopTarget(root, values);
|
|
228
446
|
// The completed down that stopped the stack also stopped its agents when it took --with-agents, so
|
|
229
447
|
// a repeat has nothing left to stop. A stack that never started has no agents either.
|
|
230
448
|
if (alreadyStopped(journal0, members))
|
|
231
|
-
return nothingRunning(presentation, target, withAgents && !journal0.operation.withAgents, abandonWarnings);
|
|
449
|
+
return nothingRunning(presentation, target, withAgents && !journal0.operation.withAgents, [...abandonWarnings, ...await readinessAddressSurvivors(journal0.space)]);
|
|
232
450
|
if (stackNeverStarted(journal0))
|
|
233
451
|
return nothingRunning(presentation, target, false, abandonWarnings);
|
|
452
|
+
// A stopped broker takes connections and never answers, so every read through it would wait out
|
|
453
|
+
// its budget and the broker's own stop would wait on a signal it cannot act on.
|
|
454
|
+
const broker = members.find((member) => member.role === "broker" && member.live);
|
|
455
|
+
const brokerPid = broker?.instance.record.value.process?.pid;
|
|
456
|
+
if (brokerPid !== undefined && processStopped(brokerPid))
|
|
457
|
+
throw new CommandFailure("refused", "TARGET_UNAVAILABLE", `the stack's broker, pid ${brokerPid}, is stopped, so it accepts connections at ${journal0.server} and never answers; no member was stopped`, { target: { ...target, broker: broker.instance.name, pid: brokerPid }, remedy: `resume it with kill -CONT ${brokerPid} and run cotal down again` });
|
|
234
458
|
const admittedRestore = scopeRefusals(journal0);
|
|
459
|
+
assertJournalWritable(root, values);
|
|
460
|
+
assertServiceRecordsWritable(root, journal0.space, values);
|
|
235
461
|
if (!values.yes && !interactive)
|
|
236
|
-
throw new ConfirmationRequired("stopping the whole controller stack
|
|
462
|
+
throw new ConfirmationRequired(yesRequired("stopping the whole controller stack", presentation === "json"), { target, remedy: "run `cotal down --yes` to stop it; `cotal down --dry-run` shows what it stops" });
|
|
463
|
+
// A missing or hand-added registration is rebuilt from the journal before anything resolves the
|
|
464
|
+
// members, and put back as it was when the stop ends before any member stops.
|
|
465
|
+
const stranded = strandedRegistration(journal0, members);
|
|
466
|
+
if (stranded)
|
|
467
|
+
recordMesh(stranded.entry);
|
|
468
|
+
const putBack = () => {
|
|
469
|
+
if (!stranded)
|
|
470
|
+
return;
|
|
471
|
+
if (stranded.previous)
|
|
472
|
+
recordMesh(stranded.previous);
|
|
473
|
+
else
|
|
474
|
+
removeMesh(journal0.space);
|
|
475
|
+
};
|
|
237
476
|
// Complete native impact before confirmation. The broker's own kernel scope cannot be prepared
|
|
238
477
|
// while its dependants run; it is recomputed after they stop and refuses on any change then.
|
|
239
478
|
const manager = members.find((member) => member.role === "manager" && member.live);
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
else if (withAgents)
|
|
246
|
-
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "--with-agents needs the stack's live manager and its native impact; no member was stopped", { target });
|
|
247
|
-
if (presentation !== "json") {
|
|
248
|
-
console.log(renderReport(planView(journal0, members, withAgents, settlement), presentation, terminalWidth(process.stdout)));
|
|
249
|
-
if (manager?.native)
|
|
250
|
-
console.log(renderReport(nativeImpactView(manager.native), presentation, terminalWidth(process.stdout)));
|
|
251
|
-
}
|
|
252
|
-
if (!values.yes) {
|
|
253
|
-
const answer = await prompts.confirm({ message: `Stop every displayed member of ${oneLine(journal0.space)}'s controller stack with only the displayed native impact?`, initialValue: false });
|
|
254
|
-
if (prompts.isCancel(answer) || !answer) {
|
|
255
|
-
writeResult(presentation, { command: "down", target, result: { kind: "controller-stack-stop", ...target, cancelled: true, members: journal0.members }, noOp: true, warnings: [{ code: "USER_CANCELLED", target, message: "no member was stopped" }] }, () => planView(journal0, members, withAgents, settlement));
|
|
256
|
-
return;
|
|
479
|
+
try {
|
|
480
|
+
if (manager) {
|
|
481
|
+
manager.native = await managerImpact(journal0, members, manager, withAgents);
|
|
482
|
+
if (!manager.native)
|
|
483
|
+
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "the manager's native agent impact could not be established; no member was stopped", { target: instanceProjection(manager.instance) });
|
|
257
484
|
}
|
|
485
|
+
else if (withAgents)
|
|
486
|
+
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "--with-agents needs the stack's live manager and its native impact; no member was stopped", { target });
|
|
487
|
+
if (!values.yes) {
|
|
488
|
+
// What the prompt asks to confirm. The receipt names the mesh, so the plan does not.
|
|
489
|
+
if (presentation !== "json") {
|
|
490
|
+
console.log(renderReport({ sections: planView(journal0, members, withAgents, settlement).sections }, presentation, terminalWidth(process.stdout)));
|
|
491
|
+
if (manager?.native)
|
|
492
|
+
console.log(renderReport(nativeImpactView(manager.native), presentation, terminalWidth(process.stdout)));
|
|
493
|
+
}
|
|
494
|
+
const answer = await prompts.confirm({ message: `Stop every displayed member of ${oneLine(journal0.space)}'s controller stack with only the displayed native impact?`, initialValue: false });
|
|
495
|
+
if (prompts.isCancel(answer) || !answer) {
|
|
496
|
+
putBack();
|
|
497
|
+
writeResult(presentation, { command: "down", target, result: { kind: "controller-stack-stop", ...target, cancelled: true, members: journal0.members }, noOp: true, warnings: [{ code: "USER_CANCELLED", target, message: "no member was stopped" }] }, () => planView(journal0, members, withAgents, settlement));
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
catch (error) {
|
|
503
|
+
putBack();
|
|
504
|
+
throw error;
|
|
258
505
|
}
|
|
506
|
+
// A store reset lists the runs it removes from this record, read while the manager still answers:
|
|
507
|
+
// the broker is the store's only reader and is stopped by then. A failed read never blocks the stop.
|
|
508
|
+
const runs = manager ? await readStackRuns(journal0.space) : { observedAt: new Date().toISOString(), read: false, reason: "the stack's manager was not running" };
|
|
259
509
|
// An earlier operation with no outcome is recorded as failed from its members' evidence first.
|
|
260
510
|
const { snapshot: settledSnapshot, settled } = settleStackOperation(lock, previous);
|
|
261
511
|
// A replacement an earlier `up` journaled is resolved from its own record, as the stop planned it.
|
|
262
|
-
let journal = { ...settledSnapshot.journal, operation: newStackOperation("down", withAgents), members: withSettledMembers(settledSnapshot.journal, undefined).members.map((row) => ({ ...row, state: row.instanceId === null ? "not-attempted" : "planned", code: undefined })), updatedAt: new Date().toISOString() };
|
|
512
|
+
let journal = { ...settledSnapshot.journal, operation: { ...newStackOperation("down", withAgents), runs }, members: withSettledMembers(settledSnapshot.journal, undefined).members.map((row) => ({ ...row, state: row.instanceId === null ? "not-attempted" : "planned", code: undefined })), updatedAt: new Date().toISOString() };
|
|
263
513
|
let snapshot = writeStackJournal(root, settledSnapshot, journal);
|
|
264
514
|
const mark = (role, change) => {
|
|
265
515
|
journal = { ...journal, members: journal.members.map((row) => row.role === role ? { ...row, ...change } : row), updatedAt: new Date().toISOString() };
|
|
@@ -271,8 +521,11 @@ async function applyStackStop(root, values, presentation, interactive, withAgent
|
|
|
271
521
|
};
|
|
272
522
|
settle("applying");
|
|
273
523
|
const changed = [];
|
|
524
|
+
// A member that outlived its SIGTERM grace was killed, which its record keeps; the receipt names it.
|
|
525
|
+
const killed = [];
|
|
274
526
|
let failure;
|
|
275
527
|
let deliveryCredentialKept = false;
|
|
528
|
+
let deliveryLease;
|
|
276
529
|
for (const member of members) {
|
|
277
530
|
const role = member.role;
|
|
278
531
|
const holds = serviceDefinitionStore(journal.space).pin(member.definition);
|
|
@@ -294,13 +547,16 @@ async function applyStackStop(root, values, presentation, interactive, withAgent
|
|
|
294
547
|
// Recheck the whole scope now that earlier members are confirmed stopped.
|
|
295
548
|
scopeRefusals(journal);
|
|
296
549
|
kernel = await prepareKernelServiceStop(member.definition, current);
|
|
297
|
-
if (kernel && presentation !== "json")
|
|
298
|
-
console.log(renderReport(kernelImpactView(kernel), presentation, terminalWidth(process.stdout)));
|
|
299
550
|
}
|
|
300
551
|
const stopped = await stopProcessService(member.definition, current, holds, { plan: role === "manager" ? member.native : undefined, withAgents: role === "manager" && withAgents }, { plan: kernel });
|
|
301
552
|
mark(role, { state: stopped.noOp ? "already-stopped" : "stopped" });
|
|
302
553
|
if (!stopped.noOp)
|
|
303
554
|
changed.push(instanceProjection(stopped.instance));
|
|
555
|
+
const stop = stopped.instance.record.value.processStop;
|
|
556
|
+
if (!stopped.noOp && stop?.signal === "SIGKILL")
|
|
557
|
+
killed.push({ role, instanceId: stopped.instance.record.value.instanceId, pid: stop.process.pid });
|
|
558
|
+
if (role === "delivery" && !stopped.noOp)
|
|
559
|
+
deliveryLease = await deliveryLeaseAfterStop(journal.root, journal.space, journal.server);
|
|
304
560
|
}
|
|
305
561
|
catch (error) {
|
|
306
562
|
const classified = isCommandFailure(error) ? error : undefined;
|
|
@@ -319,16 +575,19 @@ async function applyStackStop(root, values, presentation, interactive, withAgent
|
|
|
319
575
|
catch { /* The reservation release is not confirmed; outcomes above stand. */ }
|
|
320
576
|
}
|
|
321
577
|
}
|
|
578
|
+
if (failure && !changed.length)
|
|
579
|
+
putBack();
|
|
322
580
|
if (!failure) {
|
|
323
581
|
// Shared cleanup only after the whole recorded set is confirmed stopped. An open stack never
|
|
324
582
|
// had a delivery credential, so none is removed or claimed removed. Each step is idempotent.
|
|
325
|
-
// A delivery daemon that was already gone never released shard 0, and
|
|
326
|
-
//
|
|
327
|
-
//
|
|
583
|
+
// A delivery daemon that was already gone never released shard 0, and one that was killed, or
|
|
584
|
+
// whose release a full store refused, left its row too. Its credential is how the next up
|
|
585
|
+
// recognises that row as this folder's stopped daemon's and waits it out, so it stays until that
|
|
586
|
+
// up replaces it, and it stays as well when the row could not be read.
|
|
328
587
|
try {
|
|
329
588
|
if (journal.mode !== "open") {
|
|
330
589
|
const store = workspaceSecretStore(root), key = deliveryCredsKey(journal.space, { injected: false, root });
|
|
331
|
-
if (journal.members.find((row) => row.role === "delivery")?.state === "already-stopped")
|
|
590
|
+
if (journal.members.find((row) => row.role === "delivery")?.state === "already-stopped" || deliveryLease === "held" || deliveryLease === "unread")
|
|
332
591
|
deliveryCredentialKept = await store.get(key) !== undefined;
|
|
333
592
|
else
|
|
334
593
|
await store.delete(key);
|
|
@@ -343,10 +602,31 @@ async function applyStackStop(root, values, presentation, interactive, withAgent
|
|
|
343
602
|
failure = new CommandFailure("partial", "OPERATION_PARTIAL", journal.mode === "open" ? "every member stopped, but the mesh registration cleanup did not confirm" : "every member stopped, but the delivery credential or mesh registration cleanup did not confirm", { target, changed, remedy: journal.mode === "open" ? "inspect the root's registry entry; nothing was retried" : "inspect the root's delivery credential and registry entry; nothing was retried" });
|
|
344
603
|
}
|
|
345
604
|
}
|
|
605
|
+
// A record whose process is gone, or whose pid now runs another start, fronts nothing, so a
|
|
606
|
+
// complete stop removes it, as a crashed member leaves its own.
|
|
607
|
+
let cleared = [];
|
|
608
|
+
if (!failure) {
|
|
609
|
+
try {
|
|
610
|
+
cleared = removeStaleLocalRecords(root, journal.space);
|
|
611
|
+
}
|
|
612
|
+
catch (error) {
|
|
613
|
+
failure = new CommandFailure("partial", "OPERATION_PARTIAL", `every member stopped, but a stale process record under the root was not removed (${error.message})`, { target, changed, remedy: "inspect the process records under the root's .cotal; nothing was retried" });
|
|
614
|
+
}
|
|
615
|
+
}
|
|
346
616
|
settle(failure ? (failure.outcome === "unknown" ? "unknown" : failure.outcome === "partial" ? "partial" : failure.outcome === "failed" ? "failed" : "refused") : "completed");
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
617
|
+
const warnings = [
|
|
618
|
+
...(settled || abandoned || stranded || cleared.length ? [
|
|
619
|
+
...abandonWarnings,
|
|
620
|
+
...(settled ? [{ code: "OPERATION_SETTLED", target: { ...target, operation: settled.operation.id }, message: stackSettlementNotice(settled) }] : []),
|
|
621
|
+
...(stranded ? [strandedNotice(journal0, stranded.previous)] : []),
|
|
622
|
+
...cleared.map((row) => staleWarning(root, row)),
|
|
623
|
+
] : []),
|
|
624
|
+
...killed.map(({ role, instanceId, pid }) => ({ code: "STOP_ESCALATED", target: { ...target, role, instanceId, pid }, message: `the ${role} member, pid ${pid}, did not exit within ${PROCESS_STOP_GRACE_MS / 1000} s of SIGTERM, so it was stopped with SIGKILL` })),
|
|
625
|
+
...(deliveryLease === "unread" ? [{ code: "DELIVERY_LEASE_UNREAD", target, message: "the delivery lease could not be read after the delivery member stopped, so its credential was kept; the next up waits out a lease row that still names it" }] : []),
|
|
626
|
+
...await readinessAddressSurvivors(journal.space),
|
|
627
|
+
];
|
|
628
|
+
writeResult(presentation, { command: "down", target, result: { kind: "controller-stack-stop", ...target, operation: journal.operation, withAgents, members: journal.members, changed, managerImpact: manager?.native ?? null, atomic: false, cleanup: failure ? "not-confirmed" : journal.mode === "open" ? "registration-removed-no-delivery-credential" : deliveryCredentialKept ? "registration-removed-delivery-credential-kept" : "delivery-credential-and-registration-removed", admittedRestore: admittedRestore ?? null, settledOperation: settled ?? null }, ...(warnings.length ? { warnings } : {}), ...(failure ? { failure, completeness: "partial" } : changed.length ? {} : { noOp: true }) }, (result) => ({ sections: [...restoreNotice(admittedRestore), { title: failure ? "Controller stack stop incomplete" : changed.length ? "Controller stack stopped" : "Controller stack was not running; nothing was stopped", blocks: [
|
|
629
|
+
{ kind: "table", columns: [{ key: "role", label: "Member" }, { key: "instance", label: "Full instance" }, { key: "state", label: "Result" }], rows: result.members.filter((row) => row.instanceId !== null).sort((a, b) => STOP_ORDER.indexOf(a.role) - STOP_ORDER.indexOf(b.role)).map((row) => ({ role: row.role, instance: row.instanceId ?? "none", state: { text: killed.some((k) => k.role === row.role) ? "stopped with SIGKILL" : row.state.replaceAll("-", " "), tone: ["stopped", "already-stopped"].includes(row.state) ? "ok" : ["refused", "failed"].includes(row.state) ? "failed" : "waiting" } })) },
|
|
630
|
+
] }, ...(failure ? [] : [{ title: "Next", blocks: [{ kind: "commands", items: [{ command: `cotal up${interruptedUpLeftManagerOut(previous.journal) ? " --no-manager" : ""}`, description: "Start the stack again from its journal and saved definitions" }] }] }])] }));
|
|
351
631
|
}
|
|
352
632
|
//# sourceMappingURL=stack-down.js.map
|