@revisium/orchestrator 0.0.0 → 0.1.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +202 -1
- package/control-plane/bootstrap.config.json +104 -2
- package/control-plane/default-playbook/catalog/pipelines.json +657 -0
- package/control-plane/default-playbook/catalog/roles.json +65 -0
- package/control-plane/default-playbook/package.json +5 -0
- package/control-plane/default-playbook/playbook.json +13 -0
- package/control-plane/default-playbook/prompts/analyst.md +29 -0
- package/control-plane/default-playbook/prompts/developer.md +26 -0
- package/control-plane/default-playbook/prompts/integrator.md +20 -0
- package/control-plane/default-playbook/prompts/orchestrator.md +23 -0
- package/control-plane/default-playbook/prompts/reviewer.md +28 -0
- package/control-plane/default-playbook/prompts/triager.md +51 -0
- package/control-plane/default-playbook/prompts/watcher.md +24 -0
- package/dist/api/graphql-api/filters/agent-observability-exception.filter.js +24 -0
- package/dist/api/graphql-api/filters/agent-observability-exception.filter.js.map +1 -0
- package/dist/api/graphql-api/filters/graphql-validation-exception.filter.js +36 -0
- package/dist/api/graphql-api/filters/graphql-validation-exception.filter.js.map +1 -0
- package/dist/api/graphql-api/graphql-api.module.js +77 -0
- package/dist/api/graphql-api/graphql-api.module.js.map +1 -0
- package/dist/api/graphql-api/graphql-ws/agent-observability-subscription-bridge.service.js +296 -0
- package/dist/api/graphql-api/graphql-ws/agent-observability-subscription-bridge.service.js.map +1 -0
- package/dist/api/graphql-api/graphql-ws/agent-observability-subscription-mappers.js +64 -0
- package/dist/api/graphql-api/graphql-ws/agent-observability-subscription-mappers.js.map +1 -0
- package/dist/api/graphql-api/graphql-ws/constants.js +11 -0
- package/dist/api/graphql-api/graphql-ws/constants.js.map +1 -0
- package/dist/api/graphql-api/graphql-ws/pubsub.module.js +32 -0
- package/dist/api/graphql-api/graphql-ws/pubsub.module.js.map +1 -0
- package/dist/api/graphql-api/graphql-ws/run-progress-subscription-poller.service.js +101 -0
- package/dist/api/graphql-api/graphql-ws/run-progress-subscription-poller.service.js.map +1 -0
- package/dist/api/graphql-api/graphql-ws/subscription-bridge.service.js +115 -0
- package/dist/api/graphql-api/graphql-ws/subscription-bridge.service.js.map +1 -0
- package/dist/api/graphql-api/graphql-ws/subscription-mappers.js +85 -0
- package/dist/api/graphql-api/graphql-ws/subscription-mappers.js.map +1 -0
- package/dist/api/graphql-api/graphql-ws/ws.js +22 -0
- package/dist/api/graphql-api/graphql-ws/ws.js.map +1 -0
- package/dist/api/graphql-api/inbox/inbox-subscription.resolver.js +56 -0
- package/dist/api/graphql-api/inbox/inbox-subscription.resolver.js.map +1 -0
- package/dist/api/graphql-api/inbox/inbox.resolver.js +125 -0
- package/dist/api/graphql-api/inbox/inbox.resolver.js.map +1 -0
- package/dist/api/graphql-api/inbox/inputs/answer-question.input.js +33 -0
- package/dist/api/graphql-api/inbox/inputs/answer-question.input.js.map +1 -0
- package/dist/api/graphql-api/inbox/inputs/gate-decision.input.js +27 -0
- package/dist/api/graphql-api/inbox/inputs/gate-decision.input.js.map +1 -0
- package/dist/api/graphql-api/inbox/inputs/list-inbox.input.js +28 -0
- package/dist/api/graphql-api/inbox/inputs/list-inbox.input.js.map +1 -0
- package/dist/api/graphql-api/inbox/inputs/resolve-inbox-item.input.js +38 -0
- package/dist/api/graphql-api/inbox/inputs/resolve-inbox-item.input.js.map +1 -0
- package/dist/api/graphql-api/inbox/model/gate-risk.model.js +53 -0
- package/dist/api/graphql-api/inbox/model/gate-risk.model.js.map +1 -0
- package/dist/api/graphql-api/inbox/model/inbox-connection.model.js +16 -0
- package/dist/api/graphql-api/inbox/model/inbox-connection.model.js.map +1 -0
- package/dist/api/graphql-api/inbox/model/inbox-item.model.js +88 -0
- package/dist/api/graphql-api/inbox/model/inbox-item.model.js.map +1 -0
- package/dist/api/graphql-api/inbox/model/inbox-resolution.model.js +48 -0
- package/dist/api/graphql-api/inbox/model/inbox-resolution.model.js.map +1 -0
- package/dist/api/graphql-api/method/inputs/list-method.input.js +15 -0
- package/dist/api/graphql-api/method/inputs/list-method.input.js.map +1 -0
- package/dist/api/graphql-api/method/method.resolver.js +90 -0
- package/dist/api/graphql-api/method/method.resolver.js.map +1 -0
- package/dist/api/graphql-api/method/model/alternative-role-group.model.js +32 -0
- package/dist/api/graphql-api/method/model/alternative-role-group.model.js.map +1 -0
- package/dist/api/graphql-api/method/model/pipeline-connection.model.js +16 -0
- package/dist/api/graphql-api/method/model/pipeline-connection.model.js.map +1 -0
- package/dist/api/graphql-api/method/model/pipeline.model.js +69 -0
- package/dist/api/graphql-api/method/model/pipeline.model.js.map +1 -0
- package/dist/api/graphql-api/method/model/playbook-connection.model.js +16 -0
- package/dist/api/graphql-api/method/model/playbook-connection.model.js.map +1 -0
- package/dist/api/graphql-api/method/model/playbook.model.js +47 -0
- package/dist/api/graphql-api/method/model/playbook.model.js.map +1 -0
- package/dist/api/graphql-api/method/model/role-connection.model.js +16 -0
- package/dist/api/graphql-api/method/model/role-connection.model.js.map +1 -0
- package/dist/api/graphql-api/method/model/role.model.js +98 -0
- package/dist/api/graphql-api/method/model/role.model.js.map +1 -0
- package/dist/api/graphql-api/pr/inputs/pr-readiness.input.js +52 -0
- package/dist/api/graphql-api/pr/inputs/pr-readiness.input.js.map +1 -0
- package/dist/api/graphql-api/pr/model/pr-readiness.model.js +403 -0
- package/dist/api/graphql-api/pr/model/pr-readiness.model.js.map +1 -0
- package/dist/api/graphql-api/pr/pr.resolver.js +76 -0
- package/dist/api/graphql-api/pr/pr.resolver.js.map +1 -0
- package/dist/api/graphql-api/registerGraphqlEnums.js +9 -0
- package/dist/api/graphql-api/registerGraphqlEnums.js.map +1 -0
- package/dist/api/graphql-api/runs/inputs/create-run.input.js +63 -0
- package/dist/api/graphql-api/runs/inputs/create-run.input.js.map +1 -0
- package/dist/api/graphql-api/runs/inputs/get-agent-log.input.js +48 -0
- package/dist/api/graphql-api/runs/inputs/get-agent-log.input.js.map +1 -0
- package/dist/api/graphql-api/runs/inputs/get-run-attempts.input.js +32 -0
- package/dist/api/graphql-api/runs/inputs/get-run-attempts.input.js.map +1 -0
- package/dist/api/graphql-api/runs/inputs/get-run-events.input.js +28 -0
- package/dist/api/graphql-api/runs/inputs/get-run-events.input.js.map +1 -0
- package/dist/api/graphql-api/runs/inputs/list-runs.input.js +23 -0
- package/dist/api/graphql-api/runs/inputs/list-runs.input.js.map +1 -0
- package/dist/api/graphql-api/runs/inputs/simulate-route.input.js +43 -0
- package/dist/api/graphql-api/runs/inputs/simulate-route.input.js.map +1 -0
- package/dist/api/graphql-api/runs/model/agent-activity.model.js +367 -0
- package/dist/api/graphql-api/runs/model/agent-activity.model.js.map +1 -0
- package/dist/api/graphql-api/runs/model/create-run-result.model.js +53 -0
- package/dist/api/graphql-api/runs/model/create-run-result.model.js.map +1 -0
- package/dist/api/graphql-api/runs/model/run-attempt.model.js +114 -0
- package/dist/api/graphql-api/runs/model/run-attempt.model.js.map +1 -0
- package/dist/api/graphql-api/runs/model/run-connection.model.js +16 -0
- package/dist/api/graphql-api/runs/model/run-connection.model.js.map +1 -0
- package/dist/api/graphql-api/runs/model/run-cost.model.js +67 -0
- package/dist/api/graphql-api/runs/model/run-cost.model.js.map +1 -0
- package/dist/api/graphql-api/runs/model/run-digest.model.js +41 -0
- package/dist/api/graphql-api/runs/model/run-digest.model.js.map +1 -0
- package/dist/api/graphql-api/runs/model/run-event-connection.model.js +16 -0
- package/dist/api/graphql-api/runs/model/run-event-connection.model.js.map +1 -0
- package/dist/api/graphql-api/runs/model/run-event.model.js +58 -0
- package/dist/api/graphql-api/runs/model/run-event.model.js.map +1 -0
- package/dist/api/graphql-api/runs/model/run-progress.model.js +33 -0
- package/dist/api/graphql-api/runs/model/run-progress.model.js.map +1 -0
- package/dist/api/graphql-api/runs/model/run-workflow.model.js +287 -0
- package/dist/api/graphql-api/runs/model/run-workflow.model.js.map +1 -0
- package/dist/api/graphql-api/runs/model/run.model.js +57 -0
- package/dist/api/graphql-api/runs/model/run.model.js.map +1 -0
- package/dist/api/graphql-api/runs/model/usage.model.js +32 -0
- package/dist/api/graphql-api/runs/model/usage.model.js.map +1 -0
- package/dist/api/graphql-api/runs/run-digest.resolver.js +40 -0
- package/dist/api/graphql-api/runs/run-digest.resolver.js.map +1 -0
- package/dist/api/graphql-api/runs/run-events.resolver.js +45 -0
- package/dist/api/graphql-api/runs/run-events.resolver.js.map +1 -0
- package/dist/api/graphql-api/runs/run-progress.resolver.js +53 -0
- package/dist/api/graphql-api/runs/run-progress.resolver.js.map +1 -0
- package/dist/api/graphql-api/runs/runs-subscription.resolver.js +124 -0
- package/dist/api/graphql-api/runs/runs-subscription.resolver.js.map +1 -0
- package/dist/api/graphql-api/runs/runs.resolver.js +165 -0
- package/dist/api/graphql-api/runs/runs.resolver.js.map +1 -0
- package/dist/api/graphql-api/share/graphql-param-types.js +6 -0
- package/dist/api/graphql-api/share/graphql-param-types.js.map +1 -0
- package/dist/api/graphql-api/share/inputs/connection.input.js +27 -0
- package/dist/api/graphql-api/share/inputs/connection.input.js.map +1 -0
- package/dist/api/graphql-api/share/inputs/run-subscription.input.js +22 -0
- package/dist/api/graphql-api/share/inputs/run-subscription.input.js.map +1 -0
- package/dist/api/graphql-api/share/model/paginated.model.js +75 -0
- package/dist/api/graphql-api/share/model/paginated.model.js.map +1 -0
- package/dist/api/graphql-api/system/model/daemon-status.model.js +47 -0
- package/dist/api/graphql-api/system/model/daemon-status.model.js.map +1 -0
- package/dist/api/graphql-api/system/model/doctor-result.model.js +33 -0
- package/dist/api/graphql-api/system/model/doctor-result.model.js.map +1 -0
- package/dist/api/graphql-api/system/model/project.model.js +37 -0
- package/dist/api/graphql-api/system/model/project.model.js.map +1 -0
- package/dist/api/graphql-api/system/model/repository-context.model.js +70 -0
- package/dist/api/graphql-api/system/model/repository-context.model.js.map +1 -0
- package/dist/api/graphql-api/system/model/repository-validation.model.js +62 -0
- package/dist/api/graphql-api/system/model/repository-validation.model.js.map +1 -0
- package/dist/api/graphql-api/system/model/system-status.model.js +29 -0
- package/dist/api/graphql-api/system/model/system-status.model.js.map +1 -0
- package/dist/api/graphql-api/system/system.resolver.js +83 -0
- package/dist/api/graphql-api/system/system.resolver.js.map +1 -0
- package/dist/cli/commands/doctor-report.js +70 -0
- package/dist/cli/commands/doctor-report.js.map +1 -0
- package/dist/cli/commands/lifecycle.js +463 -0
- package/dist/cli/commands/lifecycle.js.map +1 -0
- package/dist/cli/commands/mcp.js +53 -8
- package/dist/cli/commands/mcp.js.map +1 -1
- package/dist/cli/commands/process-tree.js +87 -0
- package/dist/cli/commands/process-tree.js.map +1 -0
- package/dist/cli/commands/revisium-helpers.js +2 -2
- package/dist/cli/commands/rogue-reaper.js +63 -0
- package/dist/cli/commands/rogue-reaper.js.map +1 -0
- package/dist/cli/index.js +5 -29
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/program.js +7 -23
- package/dist/cli/program.js.map +1 -1
- package/dist/config.js +79 -1
- package/dist/config.js.map +1 -1
- package/dist/control-plane/bootstrap.js +101 -0
- package/dist/control-plane/bootstrap.js.map +1 -0
- package/dist/control-plane/change-notifications.js +35 -0
- package/dist/control-plane/change-notifications.js.map +1 -0
- package/dist/control-plane/client-transport.js +74 -41
- package/dist/control-plane/client-transport.js.map +1 -1
- package/dist/control-plane/data-access.js +13 -5
- package/dist/control-plane/data-access.js.map +1 -1
- package/dist/control-plane/definitions.js +1 -1
- package/dist/control-plane/definitions.js.map +1 -1
- package/dist/control-plane/inbox.js +5 -31
- package/dist/control-plane/inbox.js.map +1 -1
- package/dist/control-plane/index.js +1 -1
- package/dist/control-plane/index.js.map +1 -1
- package/dist/control-plane/json-fields.js +2 -0
- package/dist/control-plane/json-fields.js.map +1 -1
- package/dist/control-plane/resolve-cwd.js +76 -8
- package/dist/control-plane/resolve-cwd.js.map +1 -1
- package/dist/control-plane/schema-migration.js +82 -0
- package/dist/control-plane/schema-migration.js.map +1 -0
- package/dist/control-plane/seed-default-playbook.js +141 -0
- package/dist/control-plane/seed-default-playbook.js.map +1 -0
- package/dist/control-plane/steps.js +15 -349
- package/dist/control-plane/steps.js.map +1 -1
- package/dist/control-plane/tables.js +1 -0
- package/dist/control-plane/tables.js.map +1 -1
- package/dist/e2e/kit/agents.js +148 -0
- package/dist/e2e/kit/agents.js.map +1 -0
- package/dist/e2e/kit/assertions.js +163 -0
- package/dist/e2e/kit/assertions.js.map +1 -0
- package/dist/e2e/kit/crash.js +44 -0
- package/dist/e2e/kit/crash.js.map +1 -0
- package/dist/e2e/kit/drive.js +45 -0
- package/dist/e2e/kit/drive.js.map +1 -0
- package/dist/e2e/kit/env.js +16 -0
- package/dist/e2e/kit/env.js.map +1 -0
- package/dist/e2e/kit/fake-integrator.js +57 -0
- package/dist/e2e/kit/fake-integrator.js.map +1 -0
- package/dist/e2e/kit/gh-emulator.js +213 -0
- package/dist/e2e/kit/gh-emulator.js.map +1 -0
- package/dist/e2e/kit/git-target-repo.js +115 -0
- package/dist/e2e/kit/git-target-repo.js.map +1 -0
- package/dist/e2e/kit/harness.js +72 -0
- package/dist/e2e/kit/harness.js.map +1 -0
- package/dist/e2e/kit/index.js +14 -0
- package/dist/e2e/kit/index.js.map +1 -0
- package/dist/e2e/kit/mcp.js +32 -0
- package/dist/e2e/kit/mcp.js.map +1 -0
- package/dist/e2e/kit/scenarios.js +196 -0
- package/dist/e2e/kit/scenarios.js.map +1 -0
- package/dist/e2e/recovery-crash-child.js +29 -0
- package/dist/e2e/recovery-crash-child.js.map +1 -0
- package/dist/e2e/recovery-dd-crash-child.js +43 -0
- package/dist/e2e/recovery-dd-crash-child.js.map +1 -0
- package/dist/engine/dbos.module.js +2 -1
- package/dist/engine/dbos.module.js.map +1 -1
- package/dist/engine/dbos.service.js +89 -18
- package/dist/engine/dbos.service.js.map +1 -1
- package/dist/engine/ensure-postgres.js +18 -4
- package/dist/engine/ensure-postgres.js.map +1 -1
- package/dist/features/inbox/commands/handlers/inbox-command.handlers.js +80 -0
- package/dist/features/inbox/commands/handlers/inbox-command.handlers.js.map +1 -0
- package/dist/features/inbox/commands/impl/answer-question.command.js +7 -0
- package/dist/features/inbox/commands/impl/answer-question.command.js.map +1 -0
- package/dist/features/inbox/commands/impl/approve-gate.command.js +7 -0
- package/dist/features/inbox/commands/impl/approve-gate.command.js.map +1 -0
- package/dist/features/inbox/commands/impl/reject-gate.command.js +7 -0
- package/dist/features/inbox/commands/impl/reject-gate.command.js.map +1 -0
- package/dist/features/inbox/commands/impl/resolve-inbox-item.command.js +7 -0
- package/dist/features/inbox/commands/impl/resolve-inbox-item.command.js.map +1 -0
- package/dist/features/inbox/commands/index.js +8 -0
- package/dist/features/inbox/commands/index.js.map +1 -0
- package/dist/features/inbox/inbox-api.module.js +23 -0
- package/dist/features/inbox/inbox-api.module.js.map +1 -0
- package/dist/features/inbox/inbox-api.service.js +63 -0
- package/dist/features/inbox/inbox-api.service.js.map +1 -0
- package/dist/features/inbox/queries/handlers/inbox-query.handlers.js +111 -0
- package/dist/features/inbox/queries/handlers/inbox-query.handlers.js.map +1 -0
- package/dist/features/inbox/queries/impl/get-inbox-item.query.js +7 -0
- package/dist/features/inbox/queries/impl/get-inbox-item.query.js.map +1 -0
- package/dist/features/inbox/queries/impl/get-pending-decisions.query.js +7 -0
- package/dist/features/inbox/queries/impl/get-pending-decisions.query.js.map +1 -0
- package/dist/features/inbox/queries/impl/list-inbox.query.js +7 -0
- package/dist/features/inbox/queries/impl/list-inbox.query.js.map +1 -0
- package/dist/features/inbox/queries/impl/summarize-gate-risk.query.js +7 -0
- package/dist/features/inbox/queries/impl/summarize-gate-risk.query.js.map +1 -0
- package/dist/features/inbox/queries/index.js +8 -0
- package/dist/features/inbox/queries/index.js.map +1 -0
- package/dist/features/method/commands/index.js +2 -0
- package/dist/features/method/commands/index.js.map +1 -0
- package/dist/features/method/method-api.module.js +23 -0
- package/dist/features/method/method-api.module.js.map +1 -0
- package/dist/features/method/method-api.service.js +47 -0
- package/dist/features/method/method-api.service.js.map +1 -0
- package/dist/features/method/queries/handlers/method-query.handlers.js +115 -0
- package/dist/features/method/queries/handlers/method-query.handlers.js.map +1 -0
- package/dist/features/method/queries/impl/get-pipeline.query.js +7 -0
- package/dist/features/method/queries/impl/get-pipeline.query.js.map +1 -0
- package/dist/features/method/queries/impl/get-role.query.js +7 -0
- package/dist/features/method/queries/impl/get-role.query.js.map +1 -0
- package/dist/features/method/queries/impl/list-pipelines.query.js +7 -0
- package/dist/features/method/queries/impl/list-pipelines.query.js.map +1 -0
- package/dist/features/method/queries/impl/list-playbooks.query.js +7 -0
- package/dist/features/method/queries/impl/list-playbooks.query.js.map +1 -0
- package/dist/features/method/queries/impl/list-roles.query.js +7 -0
- package/dist/features/method/queries/impl/list-roles.query.js.map +1 -0
- package/dist/features/method/queries/index.js +9 -0
- package/dist/features/method/queries/index.js.map +1 -0
- package/dist/features/pr/commands/index.js +2 -0
- package/dist/features/pr/commands/index.js.map +1 -0
- package/dist/features/pr/pr-api.module.js +23 -0
- package/dist/features/pr/pr-api.module.js.map +1 -0
- package/dist/features/pr/pr-api.service.js +35 -0
- package/dist/features/pr/pr-api.service.js.map +1 -0
- package/dist/features/pr/queries/handlers/pr-query.handlers.js +48 -0
- package/dist/features/pr/queries/handlers/pr-query.handlers.js.map +1 -0
- package/dist/features/pr/queries/impl/get-pr-readiness.query.js +7 -0
- package/dist/features/pr/queries/impl/get-pr-readiness.query.js.map +1 -0
- package/dist/features/pr/queries/impl/list-pr-feedback.query.js +7 -0
- package/dist/features/pr/queries/impl/list-pr-feedback.query.js.map +1 -0
- package/dist/features/pr/queries/index.js +3 -0
- package/dist/features/pr/queries/index.js.map +1 -0
- package/dist/features/runs/commands/handlers/runs-command.handlers.js +32 -0
- package/dist/features/runs/commands/handlers/runs-command.handlers.js.map +1 -0
- package/dist/features/runs/commands/impl/create-run.command.js +7 -0
- package/dist/features/runs/commands/impl/create-run.command.js.map +1 -0
- package/dist/features/runs/commands/index.js +3 -0
- package/dist/features/runs/commands/index.js.map +1 -0
- package/dist/features/runs/queries/handlers/runs-query.handlers.js +359 -0
- package/dist/features/runs/queries/handlers/runs-query.handlers.js.map +1 -0
- package/dist/features/runs/queries/impl/get-agent-activity.query.js +7 -0
- package/dist/features/runs/queries/impl/get-agent-activity.query.js.map +1 -0
- package/dist/features/runs/queries/impl/get-agent-attempts.query.js +7 -0
- package/dist/features/runs/queries/impl/get-agent-attempts.query.js.map +1 -0
- package/dist/features/runs/queries/impl/get-agent-log.query.js +7 -0
- package/dist/features/runs/queries/impl/get-agent-log.query.js.map +1 -0
- package/dist/features/runs/queries/impl/get-run-attempts.query.js +7 -0
- package/dist/features/runs/queries/impl/get-run-attempts.query.js.map +1 -0
- package/dist/features/runs/queries/impl/get-run-digest.query.js +7 -0
- package/dist/features/runs/queries/impl/get-run-digest.query.js.map +1 -0
- package/dist/features/runs/queries/impl/get-run-events.query.js +7 -0
- package/dist/features/runs/queries/impl/get-run-events.query.js.map +1 -0
- package/dist/features/runs/queries/impl/get-run-progress.query.js +7 -0
- package/dist/features/runs/queries/impl/get-run-progress.query.js.map +1 -0
- package/dist/features/runs/queries/impl/get-run-workflow.query.js +7 -0
- package/dist/features/runs/queries/impl/get-run-workflow.query.js.map +1 -0
- package/dist/features/runs/queries/impl/get-run.query.js +7 -0
- package/dist/features/runs/queries/impl/get-run.query.js.map +1 -0
- package/dist/features/runs/queries/impl/list-runs.query.js +7 -0
- package/dist/features/runs/queries/impl/list-runs.query.js.map +1 -0
- package/dist/features/runs/queries/impl/simulate-route.query.js +7 -0
- package/dist/features/runs/queries/impl/simulate-route.query.js.map +1 -0
- package/dist/features/runs/queries/index.js +15 -0
- package/dist/features/runs/queries/index.js.map +1 -0
- package/dist/features/runs/runs-api.module.js +23 -0
- package/dist/features/runs/runs-api.module.js.map +1 -0
- package/dist/features/runs/runs-api.service.js +79 -0
- package/dist/features/runs/runs-api.service.js.map +1 -0
- package/dist/features/shared/connection.js +39 -0
- package/dist/features/shared/connection.js.map +1 -0
- package/dist/features/system/commands/index.js +2 -0
- package/dist/features/system/commands/index.js.map +1 -0
- package/dist/features/system/queries/handlers/system-query.handlers.js +96 -0
- package/dist/features/system/queries/handlers/system-query.handlers.js.map +1 -0
- package/dist/features/system/queries/impl/doctor.query.js +4 -0
- package/dist/features/system/queries/impl/doctor.query.js.map +1 -0
- package/dist/features/system/queries/impl/get-project.query.js +4 -0
- package/dist/features/system/queries/impl/get-project.query.js.map +1 -0
- package/dist/features/system/queries/impl/get-repository-context.query.js +7 -0
- package/dist/features/system/queries/impl/get-repository-context.query.js.map +1 -0
- package/dist/features/system/queries/impl/get-status.query.js +4 -0
- package/dist/features/system/queries/impl/get-status.query.js.map +1 -0
- package/dist/features/system/queries/impl/validate-repository.query.js +7 -0
- package/dist/features/system/queries/impl/validate-repository.query.js.map +1 -0
- package/dist/features/system/queries/index.js +9 -0
- package/dist/features/system/queries/index.js.map +1 -0
- package/dist/features/system/system-api.module.js +23 -0
- package/dist/features/system/system-api.module.js.map +1 -0
- package/dist/features/system/system-api.service.js +47 -0
- package/dist/features/system/system-api.service.js.map +1 -0
- package/dist/host/daemon.js +99 -0
- package/dist/host/daemon.js.map +1 -0
- package/dist/host/dbos-identity.js +42 -0
- package/dist/host/dbos-identity.js.map +1 -0
- package/dist/host/ensure-host.js +120 -0
- package/dist/host/ensure-host.js.map +1 -0
- package/dist/host/host-runtime.js +90 -0
- package/dist/host/host-runtime.js.map +1 -0
- package/dist/host/host.lifecycle.js +16 -3
- package/dist/host/host.lifecycle.js.map +1 -1
- package/dist/host/queue-ownership.js +70 -0
- package/dist/host/queue-ownership.js.map +1 -0
- package/dist/host/queue-poller-census.js +47 -0
- package/dist/host/queue-poller-census.js.map +1 -0
- package/dist/http/graphql-host.js +56 -0
- package/dist/http/graphql-host.js.map +1 -0
- package/dist/{mcp/mcp.module.js → http/graphql-host.module.js} +12 -10
- package/dist/http/graphql-host.module.js.map +1 -0
- package/dist/infrastructure/metrics/graphql/graphql-metrics.js +91 -0
- package/dist/infrastructure/metrics/graphql/graphql-metrics.js.map +1 -0
- package/dist/mcp/mcp-capabilities.js +9 -1
- package/dist/mcp/mcp-capabilities.js.map +1 -1
- package/dist/mcp/mcp-facade.service.js +68 -5
- package/dist/mcp/mcp-facade.service.js.map +1 -1
- package/dist/mcp/mcp-http.service.js +95 -0
- package/dist/mcp/mcp-http.service.js.map +1 -0
- package/dist/mcp/mcp-tools.js +93 -7
- package/dist/mcp/mcp-tools.js.map +1 -1
- package/dist/observability/agent-activity-reporter.js +185 -0
- package/dist/observability/agent-activity-reporter.js.map +1 -0
- package/dist/observability/agent-observability.service.js +1142 -0
- package/dist/observability/agent-observability.service.js.map +1 -0
- package/dist/observability/index.js +4 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/observability/types.js +11 -0
- package/dist/observability/types.js.map +1 -0
- package/dist/pipeline/await-human.js +8 -4
- package/dist/pipeline/await-human.js.map +1 -1
- package/dist/pipeline/data-driven-task.workflow.js +667 -0
- package/dist/pipeline/data-driven-task.workflow.js.map +1 -0
- package/dist/pipeline/data-driven-template.js +57 -0
- package/dist/pipeline/data-driven-template.js.map +1 -0
- package/dist/pipeline/pipeline.module.js +2 -2
- package/dist/pipeline/pipeline.module.js.map +1 -1
- package/dist/pipeline/pipeline.service.js +412 -0
- package/dist/pipeline/pipeline.service.js.map +1 -0
- package/dist/pipeline/route-contract.js +82 -0
- package/dist/pipeline/route-contract.js.map +1 -0
- package/dist/pipeline-core/index.js +16 -0
- package/dist/pipeline-core/index.js.map +1 -0
- package/dist/pipeline-core/interpret.js +353 -0
- package/dist/pipeline-core/interpret.js.map +1 -0
- package/dist/pipeline-core/kit/assertions.js +61 -0
- package/dist/pipeline-core/kit/assertions.js.map +1 -0
- package/dist/pipeline-core/kit/builders.js +138 -0
- package/dist/pipeline-core/kit/builders.js.map +1 -0
- package/dist/pipeline-core/kit/drive.js +96 -0
- package/dist/pipeline-core/kit/drive.js.map +1 -0
- package/dist/pipeline-core/kit/fixtures.js +342 -0
- package/dist/pipeline-core/kit/fixtures.js.map +1 -0
- package/dist/pipeline-core/kit/index.js +13 -0
- package/dist/pipeline-core/kit/index.js.map +1 -0
- package/dist/pipeline-core/types.js +134 -0
- package/dist/pipeline-core/types.js.map +1 -0
- package/dist/pipeline-core/validate-capability.js +23 -0
- package/dist/pipeline-core/validate-capability.js.map +1 -0
- package/dist/pipeline-core/validate-conflicts.js +37 -0
- package/dist/pipeline-core/validate-conflicts.js.map +1 -0
- package/dist/pipeline-core/validate-dataflow.js +212 -0
- package/dist/pipeline-core/validate-dataflow.js.map +1 -0
- package/dist/pipeline-core/validate-diff.js +158 -0
- package/dist/pipeline-core/validate-diff.js.map +1 -0
- package/dist/pipeline-core/validate-edges.js +44 -0
- package/dist/pipeline-core/validate-edges.js.map +1 -0
- package/dist/pipeline-core/validate-graph.js +123 -0
- package/dist/pipeline-core/validate-graph.js.map +1 -0
- package/dist/pipeline-core/validate-loops.js +226 -0
- package/dist/pipeline-core/validate-loops.js.map +1 -0
- package/dist/pipeline-core/validate-parallel.js +132 -0
- package/dist/pipeline-core/validate-parallel.js.map +1 -0
- package/dist/pipeline-core/validate-sink.js +27 -0
- package/dist/pipeline-core/validate-sink.js.map +1 -0
- package/dist/pipeline-core/validate-topology.js +140 -0
- package/dist/pipeline-core/validate-topology.js.map +1 -0
- package/dist/pipeline-core/validate-verdict.js +72 -0
- package/dist/pipeline-core/validate-verdict.js.map +1 -0
- package/dist/pipeline-core/validate.js +119 -0
- package/dist/pipeline-core/validate.js.map +1 -0
- package/dist/playbook/catalog-loader.js +14 -1
- package/dist/playbook/catalog-loader.js.map +1 -1
- package/dist/playbook/import-mapper.js +14 -38
- package/dist/playbook/import-mapper.js.map +1 -1
- package/dist/playbook/manifest.js +1 -1
- package/dist/revisium/playbooks.service.js +107 -19
- package/dist/revisium/playbooks.service.js.map +1 -1
- package/dist/revisium/roles.service.js +1 -1
- package/dist/revisium/roles.service.js.map +1 -1
- package/dist/revisium/run.service.js +55 -8
- package/dist/revisium/run.service.js.map +1 -1
- package/dist/run/append-event.js +24 -1
- package/dist/run/append-event.js.map +1 -1
- package/dist/run/block-run.js +17 -0
- package/dist/run/block-run.js.map +1 -0
- package/dist/run/complete-run.js +18 -0
- package/dist/run/complete-run.js.map +1 -0
- package/dist/run/create-run.js +33 -36
- package/dist/run/create-run.js.map +1 -1
- package/dist/run/inspect-run.js +31 -30
- package/dist/run/inspect-run.js.map +1 -1
- package/dist/run/run-outputs.js +88 -0
- package/dist/run/run-outputs.js.map +1 -0
- package/dist/run/terminal-run-status.js +66 -7
- package/dist/run/terminal-run-status.js.map +1 -1
- package/dist/runners/claude-code.service.js +5 -0
- package/dist/runners/claude-code.service.js.map +1 -1
- package/dist/runners/codex.service.js +51 -0
- package/dist/runners/codex.service.js.map +1 -0
- package/dist/runners/integrator-branch-naming.js +39 -0
- package/dist/runners/integrator-branch-naming.js.map +1 -0
- package/dist/runners/integrator-git.js +84 -0
- package/dist/runners/integrator-git.js.map +1 -0
- package/dist/runners/integrator-remote.js +34 -0
- package/dist/runners/integrator-remote.js.map +1 -0
- package/dist/runners/integrator-types.js +9 -0
- package/dist/runners/integrator-types.js.map +1 -0
- package/dist/runners/integrator.js +327 -147
- package/dist/runners/integrator.js.map +1 -1
- package/dist/runners/runner.module.js +7 -3
- package/dist/runners/runner.module.js.map +1 -1
- package/dist/runners/worktree.service.js +63 -0
- package/dist/runners/worktree.service.js.map +1 -0
- package/dist/smoke/cli.js +47 -0
- package/dist/smoke/cli.js.map +1 -0
- package/dist/smoke/isolation.js +113 -0
- package/dist/smoke/isolation.js.map +1 -0
- package/dist/task-control-plane/run-watch.service.js +281 -0
- package/dist/task-control-plane/run-watch.service.js.map +1 -0
- package/dist/task-control-plane/task-control-plane-api.service.js +569 -23
- package/dist/task-control-plane/task-control-plane-api.service.js.map +1 -1
- package/dist/task-control-plane/task-control-plane.module.js +22 -3
- package/dist/task-control-plane/task-control-plane.module.js.map +1 -1
- package/dist/worker/artifact-store.js +116 -0
- package/dist/worker/artifact-store.js.map +1 -0
- package/dist/worker/build-context.js +169 -2
- package/dist/worker/build-context.js.map +1 -1
- package/dist/worker/claude-code-runner.js +159 -68
- package/dist/worker/claude-code-runner.js.map +1 -1
- package/dist/worker/codex-runner.js +474 -0
- package/dist/worker/codex-runner.js.map +1 -0
- package/dist/worker/git-worktree-manager.js +129 -65
- package/dist/worker/git-worktree-manager.js.map +1 -1
- package/dist/worker/process-executor.js +23 -2
- package/dist/worker/process-executor.js.map +1 -1
- package/dist/worker/result-envelope.js +115 -57
- package/dist/worker/result-envelope.js.map +1 -1
- package/dist/worker/runner-common.js +106 -0
- package/dist/worker/runner-common.js.map +1 -0
- package/dist/worker/runner-dispatch.js +4 -1
- package/dist/worker/runner-dispatch.js.map +1 -1
- package/dist/worker/runner.js +11 -1
- package/dist/worker/runner.js.map +1 -1
- package/dist/worker/stub-runner.js +7 -45
- package/dist/worker/stub-runner.js.map +1 -1
- package/package.json +32 -7
- package/dist/app.module.js +0 -28
- package/dist/app.module.js.map +0 -1
- package/dist/cli/commands/bootstrap.js +0 -39
- package/dist/cli/commands/bootstrap.js.map +0 -1
- package/dist/cli/commands/dev.js +0 -143
- package/dist/cli/commands/dev.js.map +0 -1
- package/dist/cli/commands/inbox.js +0 -288
- package/dist/cli/commands/inbox.js.map +0 -1
- package/dist/cli/commands/playbook.js +0 -74
- package/dist/cli/commands/playbook.js.map +0 -1
- package/dist/cli/commands/poll-workflow-state.js +0 -144
- package/dist/cli/commands/poll-workflow-state.js.map +0 -1
- package/dist/cli/commands/revisium-context.js +0 -23
- package/dist/cli/commands/revisium-context.js.map +0 -1
- package/dist/cli/commands/revisium.js +0 -89
- package/dist/cli/commands/revisium.js.map +0 -1
- package/dist/cli/commands/run.js +0 -426
- package/dist/cli/commands/run.js.map +0 -1
- package/dist/cli/commands/work.js +0 -149
- package/dist/cli/commands/work.js.map +0 -1
- package/dist/cli/live-guard.js +0 -49
- package/dist/cli/live-guard.js.map +0 -1
- package/dist/cli/needs-host.js +0 -78
- package/dist/cli/needs-host.js.map +0 -1
- package/dist/mcp/mcp-stdio.service.js +0 -48
- package/dist/mcp/mcp-stdio.service.js.map +0 -1
- package/dist/mcp/mcp.module.js.map +0 -1
- package/dist/pipeline/develop-task.workflow.js +0 -497
- package/dist/pipeline/develop-task.workflow.js.map +0 -1
- package/dist/worker/loop.js +0 -122
- package/dist/worker/loop.js.map +0 -1
- package/dist/worker/script-runner.js +0 -28
- package/dist/worker/script-runner.js.map +0 -1
- package/dist/worker/worker-id.js +0 -18
- package/dist/worker/worker-id.js.map +0 -1
- package/dist/worker/worktree-manager.js +0 -7
- package/dist/worker/worktree-manager.js.map +0 -1
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process-tree ancestry — used by `revo doctor` to decide whether a port's listener belongs to the
|
|
3
|
+
* tracked stack. A profile's standalone tier is NOT a single pid: the tracked launcher forks a worker
|
|
4
|
+
* that binds the HTTP port and spawns embedded Postgres, so the actual port owners are *descendants*
|
|
5
|
+
* of the tracked pid. Exact-pid equality therefore mis-flags the legitimate stack as a rogue daemon;
|
|
6
|
+
* ancestry-walking is the correct test.
|
|
7
|
+
*/
|
|
8
|
+
import { execFileSync } from 'node:child_process';
|
|
9
|
+
import { existsSync } from 'node:fs';
|
|
10
|
+
// Resolve ps to a FIXED absolute path — never via $PATH (S4036: a writable PATH entry could shadow
|
|
11
|
+
// the binary). null if ps is unavailable, in which case ancestry checks degrade to "not within".
|
|
12
|
+
const PS_PATH = ['/bin/ps', '/usr/bin/ps'].find((p) => existsSync(p)) ?? null;
|
|
13
|
+
/** All processes as `{pid, command}` via `ps -ax` (full command line). Empty if ps is unavailable. */
|
|
14
|
+
export function listProcesses() {
|
|
15
|
+
if (PS_PATH === null)
|
|
16
|
+
return [];
|
|
17
|
+
try {
|
|
18
|
+
const out = execFileSync(PS_PATH, ['-axww', '-o', 'pid=,command='], {
|
|
19
|
+
encoding: 'utf8',
|
|
20
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
21
|
+
maxBuffer: 8 * 1024 * 1024,
|
|
22
|
+
});
|
|
23
|
+
const procs = [];
|
|
24
|
+
for (const line of out.split('\n')) {
|
|
25
|
+
const m = line.match(/^\s*(\d+)\s+(.*)$/);
|
|
26
|
+
if (m)
|
|
27
|
+
procs.push({ pid: Number(m[1]), command: m[2] });
|
|
28
|
+
}
|
|
29
|
+
return procs;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** Parent pid of `pid` via ps, or null (no such process / ps unavailable). Best-effort. */
|
|
36
|
+
export function parentPid(pid) {
|
|
37
|
+
if (PS_PATH === null)
|
|
38
|
+
return null;
|
|
39
|
+
try {
|
|
40
|
+
const out = execFileSync(PS_PATH, ['-o', 'ppid=', '-p', String(pid)], {
|
|
41
|
+
encoding: 'utf8',
|
|
42
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
43
|
+
}).trim();
|
|
44
|
+
const ppid = Number(out);
|
|
45
|
+
return Number.isInteger(ppid) && ppid > 0 ? ppid : null;
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return null; // process gone / ps error
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Process start time as an opaque stable string (`ps -o lstart=`, portable on macOS + Linux — avoids
|
|
53
|
+
* brittle `/proc/<pid>/stat` parsing). Returns null if the process is gone / ps unavailable. Paired
|
|
54
|
+
* with the pid it forms a reuse-proof identity: a recycled pid gets a different start time, so the
|
|
55
|
+
* rogue reaper re-checks it before SIGKILL and never kills an innocent process that inherited the pid.
|
|
56
|
+
*/
|
|
57
|
+
export function processStartTime(pid) {
|
|
58
|
+
if (PS_PATH === null)
|
|
59
|
+
return null;
|
|
60
|
+
try {
|
|
61
|
+
const out = execFileSync(PS_PATH, ['-o', 'lstart=', '-p', String(pid)], {
|
|
62
|
+
encoding: 'utf8',
|
|
63
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
64
|
+
}).trim();
|
|
65
|
+
return out.length > 0 ? out : null;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return null; // process gone / ps error
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* True if `pid` is one of `ancestors`, or descends from one — walking the parent chain via `getParent`.
|
|
73
|
+
* `getParent` is injectable so the traversal is unit-testable without real processes; production passes
|
|
74
|
+
* `parentPid`. Bounded by `maxHops` (and stops at init, pid ≤ 1) so a missing/cyclic chain can't loop.
|
|
75
|
+
*/
|
|
76
|
+
export function isPidWithin(pid, ancestors, getParent = parentPid, maxHops = 32) {
|
|
77
|
+
let current = pid;
|
|
78
|
+
for (let hops = 0; current !== null && hops <= maxHops; hops += 1) {
|
|
79
|
+
if (ancestors.has(current))
|
|
80
|
+
return true;
|
|
81
|
+
if (current <= 1)
|
|
82
|
+
return false; // reached init (or invalid) — not within the tracked tree
|
|
83
|
+
current = getParent(current);
|
|
84
|
+
}
|
|
85
|
+
return false; // exhausted hops / chain broke before reaching an ancestor
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=process-tree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-tree.js","sourceRoot":"","sources":["../../../src/cli/commands/process-tree.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,mGAAmG;AACnG,iGAAiG;AACjG,MAAM,OAAO,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AAE9E,sGAAsG;AACtG,MAAM,UAAU,aAAa;IAC3B,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IAChC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,YAAY,CAAC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
|
3
|
-
* Extracted to avoid duplication (F9).
|
|
2
|
+
* Process + log helpers shared by the lifecycle CLI (`lifecycle.ts`: stop/logs) and the daemon
|
|
3
|
+
* bring-up path (`ensure-revisium.ts`). Extracted to avoid duplication (F9).
|
|
4
4
|
*/
|
|
5
5
|
import { existsSync, readFileSync } from 'node:fs';
|
|
6
6
|
import { isAlive } from '../config.js';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rogue-reaper (slice 140 Phase 2, pure core). `revo doctor --fix` / `revo stop --all` actively EVICT
|
|
3
|
+
* a legacy/duplicate daemon that polls the `dev-tasks` queue but the advisory lock can't coordinate and
|
|
4
|
+
* the port-based stop can't see (it's an outbound poller with no inbound listener). Two mechanisms:
|
|
5
|
+
*
|
|
6
|
+
* 1. Connection eviction — `pg_terminate_backend` the rogue's DBOS connection (the immediate stop),
|
|
7
|
+
* looped to defeat the census→kill TOCTOU (a rogue can dequeue a fresh row in that window).
|
|
8
|
+
* 2. Process reap — SIGTERM→SIGKILL the rogue PROCESS (the durable stop; its pool would otherwise
|
|
9
|
+
* reconnect). This is what the manual `pkill -f "revo mcp"` did, made safe + permanent.
|
|
10
|
+
*
|
|
11
|
+
* This module holds the PURE, unit-tested decisions; the pg/ps/kill IO lives in lifecycle.ts.
|
|
12
|
+
*/
|
|
13
|
+
import { isPidWithin } from './process-tree.js';
|
|
14
|
+
/**
|
|
15
|
+
* Classify a process command line as a revo daemon / mcp-bridge, or null if unrelated.
|
|
16
|
+
*
|
|
17
|
+
* Keys on (revo entry token) + (subcommand token). The npm-GLOBAL install runs as
|
|
18
|
+
* `node …/bin/revo __daemon` — argv[1] is the bin SYMLINK (`bin/revo`, no `.js`); the package's own
|
|
19
|
+
* `bin/revo.js` does `import '../dist/cli/index.js'` (no re-exec); dev runs as
|
|
20
|
+
* `node --import tsx …/src/cli/index.ts __daemon`; a compiled run as `…/dist/cli/index.js`. Matching
|
|
21
|
+
* only `dist/cli/index.js` (or only `bin/revo.js`) MISSES the real installed daemon and the reap
|
|
22
|
+
* no-ops against the very process it must kill. The subcommand must be a whole word so an unrelated
|
|
23
|
+
* command merely containing "mcp" (e.g. `node /opt/mcp-server.js`) is not matched.
|
|
24
|
+
*/
|
|
25
|
+
export function classifyRevoProcess(command) {
|
|
26
|
+
const hasEntry = /\/bin\/revo(?:\.js)?(?:\s|$)/.test(command) || /\/cli\/index\.(?:ts|js)(?:\s|$)/.test(command);
|
|
27
|
+
if (!hasEntry)
|
|
28
|
+
return null;
|
|
29
|
+
if (/(?:^|\s)__daemon(?:\s|$)/.test(command))
|
|
30
|
+
return 'daemon';
|
|
31
|
+
if (/(?:^|\s)mcp(?:\s|$)/.test(command))
|
|
32
|
+
return 'mcp';
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The reap targets: revo daemon/mcp processes NOT within any PROTECTED tree (every profile's tracked
|
|
37
|
+
* daemon pid-tree). A process inside a tracked tree is the live stack — never reaped. `getParent` is
|
|
38
|
+
* injected so the ancestry walk is unit-testable without real processes.
|
|
39
|
+
*/
|
|
40
|
+
export function selectReapTargets(procs, protectedPids, getParent) {
|
|
41
|
+
return procs.filter((proc) => !isPidWithin(proc.pid, protectedPids, getParent));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Connection-eviction TOCTOU loop. `census()` returns the current rogue backend pids (it THROWS if the
|
|
45
|
+
* roster can't be read — privilege/DB error — which must propagate as "not converged", never as empty);
|
|
46
|
+
* `terminate(pid)` kills one backend. Re-census after each round because a rogue can transition a fresh
|
|
47
|
+
* ENQUEUED row to its own PENDING between the census and the kill. Bounded by `maxRounds`.
|
|
48
|
+
*/
|
|
49
|
+
export async function evictByTermination(census, terminate, maxRounds = 5) {
|
|
50
|
+
let terminated = 0;
|
|
51
|
+
for (let round = 1; round <= maxRounds; round += 1) {
|
|
52
|
+
const rogues = await census();
|
|
53
|
+
if (rogues.length === 0)
|
|
54
|
+
return { converged: true, rounds: round, terminated };
|
|
55
|
+
for (const pid of rogues) {
|
|
56
|
+
await terminate(pid);
|
|
57
|
+
terminated += 1;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const remaining = await census();
|
|
61
|
+
return { converged: remaining.length === 0, rounds: maxRounds, terminated };
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=rogue-reaper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rogue-reaper.js","sourceRoot":"","sources":["../../../src/cli/commands/rogue-reaper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,MAAM,QAAQ,GACZ,8BAA8B,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,iCAAiC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAClG,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3B,IAAI,0BAA0B,CAAC,IAAI,CAAC,OAAO,CAAC;QAAE,OAAO,QAAQ,CAAC;IAC9D,IAAI,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC;QAAE,OAAO,KAAK,CAAC;IACtD,OAAO,IAAI,CAAC;AACd,CAAC;AAID;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,KAA8B,EAC9B,aAAkC,EAClC,SAAyC;IAEzC,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC,CAAC;AAClF,CAAC;AAID;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,MAA+B,EAC/B,SAAyC,EACzC,SAAS,GAAG,CAAC;IAEb,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,IAAI,SAAS,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACnD,MAAM,MAAM,GAAG,MAAM,MAAM,EAAE,CAAC;QAC9B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;QAC/E,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YACzB,MAAM,SAAS,CAAC,GAAG,CAAC,CAAC;YACrB,UAAU,IAAI,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IACD,MAAM,SAAS,GAAG,MAAM,MAAM,EAAE,CAAC;IACjC,OAAO,EAAE,SAAS,EAAE,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;AAC9E,CAAC"}
|
package/dist/cli/index.js
CHANGED
|
@@ -1,32 +1,8 @@
|
|
|
1
|
+
// reflect-metadata is required by the daemon entrypoint (`revo __daemon` → NestFactory); load it once
|
|
2
|
+
// here so it is present whichever command runs.
|
|
1
3
|
import 'reflect-metadata';
|
|
2
|
-
import { isMcpCommand, needsHost } from './needs-host.js';
|
|
3
4
|
import { buildProgram } from './program.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// Nest/DBOS/AppModule are imported lazily so the host-free path never loads them.
|
|
8
|
-
const mcpCommand = isMcpCommand(argv);
|
|
9
|
-
if (mcpCommand) {
|
|
10
|
-
process.env.REVO_MCP_STDIO = '1';
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
delete process.env.REVO_MCP_STDIO;
|
|
14
|
-
}
|
|
15
|
-
const { NestFactory } = await import('@nestjs/core');
|
|
16
|
-
const { AppModule } = await import('../app.module.js');
|
|
17
|
-
const app = await NestFactory.createApplicationContext(AppModule, { logger: mcpCommand ? false : ['error', 'warn'] });
|
|
18
|
-
try {
|
|
19
|
-
await buildProgram(app).parseAsync(argv);
|
|
20
|
-
}
|
|
21
|
-
finally {
|
|
22
|
-
// onApplicationShutdown → DBOS.shutdown() only; daemon is NOT stopped (Round 3).
|
|
23
|
-
await app.close();
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
// Host-free path: revisium start/stop/status/logs, bootstrap, run, work,
|
|
28
|
-
// --help, --version, empty/unknown commands.
|
|
29
|
-
// Nest/DBOS are NOT loaded here — fast and safe for daemon-management commands.
|
|
30
|
-
await buildProgram().parseAsync(argv);
|
|
31
|
-
}
|
|
5
|
+
// The CLI is a lightweight client/process-manager (ADR 0006): it NEVER builds AppModule or launches
|
|
6
|
+
// DBOS. The only long-lived host is the daemon, spawned detached via the hidden `__daemon` command.
|
|
7
|
+
await buildProgram().parseAsync(process.argv);
|
|
32
8
|
//# sourceMappingURL=index.js.map
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,gDAAgD;AAChD,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,oGAAoG;AACpG,oGAAoG;AACpG,MAAM,YAAY,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
package/dist/cli/program.js
CHANGED
|
@@ -1,37 +1,21 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { readPackageVersion } from '../package-info.js';
|
|
3
|
-
import {
|
|
4
|
-
import { registerDev } from './commands/dev.js';
|
|
5
|
-
import { registerInbox } from './commands/inbox.js';
|
|
3
|
+
import { registerLifecycle } from './commands/lifecycle.js';
|
|
6
4
|
import { registerMcp } from './commands/mcp.js';
|
|
7
|
-
import { registerPlaybook } from './commands/playbook.js';
|
|
8
|
-
import { registerRevisium } from './commands/revisium.js';
|
|
9
|
-
import { registerRun } from './commands/run.js';
|
|
10
|
-
import { registerWork } from './commands/work.js';
|
|
11
5
|
export { readPackageVersion };
|
|
12
6
|
/**
|
|
13
|
-
* Build the
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* - When `app` is provided, dev:ping/dev:status actions are wired to the DI context.
|
|
17
|
-
* - When `app` is absent (host-free path or tests), dev command DEFINITIONS are still
|
|
18
|
-
* registered so `dev:ping --help` works; actions guard on the absent `app`.
|
|
19
|
-
* - The no-arg overload is preserved for program.test.ts compatibility.
|
|
7
|
+
* Build the Revo CLI. The CLI is lifecycle-only (ADR 0006): `revo start/stop/status/...` manage the
|
|
8
|
+
* whole stack, and `revo mcp` is a thin stdio bridge to the daemon. Orchestration (runs, inbox,
|
|
9
|
+
* method, …) is reached through the daemon's MCP + GraphQL front doors, not the CLI.
|
|
20
10
|
*/
|
|
21
|
-
export function buildProgram(
|
|
11
|
+
export function buildProgram() {
|
|
22
12
|
const program = new Command();
|
|
23
13
|
program
|
|
24
14
|
.name('revo')
|
|
25
15
|
.description('Agent orchestrator CLI')
|
|
26
16
|
.version(readPackageVersion(), '-v, --version', 'Print the revo version');
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
registerPlaybook(program);
|
|
30
|
-
registerRun(program, app);
|
|
31
|
-
registerWork(program);
|
|
32
|
-
registerInbox(program, app); // G6: forward app so gate resolve path can access DbosService
|
|
33
|
-
registerMcp(program, app);
|
|
34
|
-
registerDev(program, app);
|
|
17
|
+
registerLifecycle(program);
|
|
18
|
+
registerMcp(program);
|
|
35
19
|
return program;
|
|
36
20
|
}
|
|
37
21
|
//# sourceMappingURL=program.js.map
|
package/dist/cli/program.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"program.js","sourceRoot":"","sources":["../../src/cli/program.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"program.js","sourceRoot":"","sources":["../../src/cli/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAE9B;;;;GAIG;AACH,MAAM,UAAU,YAAY;IAC1B,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAC9B,OAAO;SACJ,IAAI,CAAC,MAAM,CAAC;SACZ,WAAW,CAAC,wBAAwB,CAAC;SACrC,OAAO,CAAC,kBAAkB,EAAE,EAAE,eAAe,EAAE,wBAAwB,CAAC,CAAC;IAC5E,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC3B,WAAW,CAAC,OAAO,CAAC,CAAC;IACrB,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/config.js
CHANGED
|
@@ -3,6 +3,17 @@ import { existsSync, mkdirSync, readFileSync, rmSync } from 'node:fs';
|
|
|
3
3
|
import { dirname, join, resolve } from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import os from 'node:os';
|
|
6
|
+
/**
|
|
7
|
+
* Runtime profiles let an installed package (`default`) and a source checkout (`dev`) run on one
|
|
8
|
+
* machine at once: a profile shifts the whole isolation band off the committed defaults, so the two
|
|
9
|
+
* never share a port, data dir, or `dbos` database. Custom layouts set the REVO_* knobs directly
|
|
10
|
+
* instead of adding a profile here. The single source of band constants (offset/suffix/db name).
|
|
11
|
+
*/
|
|
12
|
+
export const PROFILES = {
|
|
13
|
+
default: { suffix: '', portOffset: 0, dbosDb: 'dbos' },
|
|
14
|
+
dev: { suffix: '-dev', portOffset: 400, dbosDb: 'dbos_dev' },
|
|
15
|
+
};
|
|
16
|
+
export const GRAPHQL_PORT_OFFSET = 1;
|
|
6
17
|
const sourceDir = dirname(fileURLToPath(import.meta.url));
|
|
7
18
|
export const repoRoot = resolve(sourceDir, '..');
|
|
8
19
|
function expandHome(path) {
|
|
@@ -17,16 +28,69 @@ function loadConfig() {
|
|
|
17
28
|
return JSON.parse(readFileSync(configPath, 'utf8'));
|
|
18
29
|
}
|
|
19
30
|
let cachedConfig = null;
|
|
31
|
+
/** Parse a positive-integer env var, or undefined if unset/invalid. */
|
|
32
|
+
function numEnv(name, env = process.env) {
|
|
33
|
+
const raw = env[name];
|
|
34
|
+
if (raw === undefined)
|
|
35
|
+
return undefined;
|
|
36
|
+
const n = Number.parseInt(raw, 10);
|
|
37
|
+
return Number.isFinite(n) && n > 0 ? n : undefined;
|
|
38
|
+
}
|
|
39
|
+
/** Resolve the active profile from REVO_PROFILE (default `default`); unknown names fail loudly. */
|
|
40
|
+
export function resolveProfileName(env = process.env) {
|
|
41
|
+
const raw = env['REVO_PROFILE'];
|
|
42
|
+
if (!raw)
|
|
43
|
+
return 'default';
|
|
44
|
+
if (Object.prototype.hasOwnProperty.call(PROFILES, raw))
|
|
45
|
+
return raw;
|
|
46
|
+
throw new Error(`Unknown REVO_PROFILE '${raw}'. Known profiles: ${Object.keys(PROFILES).join(', ')}. ` +
|
|
47
|
+
'Set REVO_DATA_DIR/REVO_PORT/REVO_PG_PORT/REVO_DBOS_DB explicitly for a custom layout.');
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Band-default data dir for a SPECIFIC profile (config-file base + the profile's suffix). Deliberately
|
|
51
|
+
* ignores `REVO_DATA_DIR` — that env var overrides only the ACTIVE profile, so for enumerating SIBLING
|
|
52
|
+
* profiles' tracked daemons (the cross-profile-safe reap, slice 140 Phase 2) we must use band defaults.
|
|
53
|
+
* Returns the band-default dir for every profile; a custom REVO_DATA_DIR layout is not enumerable here.
|
|
54
|
+
*/
|
|
55
|
+
export function profileDataDir(profile) {
|
|
56
|
+
return expandHome(`${loadConfig().dataDir}${PROFILES[profile].suffix}`);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Layer profile + env into the data dir and ports: the profile sets the band, then an explicit
|
|
60
|
+
* REVO_* env var overrides that single knob. Pure (no fs) so the precedence is unit-testable.
|
|
61
|
+
*/
|
|
62
|
+
export function resolveProfileConfig(raw, env = process.env) {
|
|
63
|
+
const profile = resolveProfileName(env);
|
|
64
|
+
const band = PROFILES[profile];
|
|
65
|
+
return {
|
|
66
|
+
profile,
|
|
67
|
+
dataDir: env['REVO_DATA_DIR'] ?? `${raw.dataDir}${band.suffix}`,
|
|
68
|
+
preferredPort: numEnv('REVO_PORT', env) ?? raw.preferredPort + band.portOffset,
|
|
69
|
+
preferredPgPort: numEnv('REVO_PG_PORT', env) ?? raw.preferredPgPort + band.portOffset,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Test/CI isolation: env overrides keep a throwaway daemon (and its embedded Postgres + DBOS db)
|
|
74
|
+
* fully separate from the developer's dogfooding control-plane. `REVO_DATA_DIR` redirects the data
|
|
75
|
+
* directory (so runtime.json, the embedded PG, and the DBOS connection all key off it); `REVO_PORT`
|
|
76
|
+
* / `REVO_PG_PORT` give the test daemon distinct preferred ports so it never collides with a live
|
|
77
|
+
* dev daemon. Unset in normal use → the committed `revisium.config.json` values apply.
|
|
78
|
+
*/
|
|
20
79
|
export function getConfig() {
|
|
21
80
|
if (cachedConfig)
|
|
22
81
|
return cachedConfig;
|
|
23
82
|
const rawConfig = loadConfig();
|
|
24
|
-
const dataDir =
|
|
83
|
+
const { profile, dataDir: profileDataDir, preferredPort, preferredPgPort } = resolveProfileConfig(rawConfig);
|
|
84
|
+
const dataDir = expandHome(profileDataDir);
|
|
25
85
|
mkdirSync(dataDir, { recursive: true });
|
|
26
86
|
cachedConfig = {
|
|
27
87
|
...rawConfig,
|
|
88
|
+
profile,
|
|
28
89
|
dataDir,
|
|
90
|
+
preferredPort,
|
|
91
|
+
preferredPgPort,
|
|
29
92
|
logFile: join(dataDir, 'standalone.log'),
|
|
93
|
+
hostLogFile: join(dataDir, 'host.log'),
|
|
30
94
|
runtimeFile: join(dataDir, 'runtime.json'),
|
|
31
95
|
};
|
|
32
96
|
return cachedConfig;
|
|
@@ -75,6 +139,20 @@ export async function resolvePorts() {
|
|
|
75
139
|
const { preferredPort, preferredPgPort } = getConfig();
|
|
76
140
|
return { httpPort: preferredPort, pgPort: preferredPgPort };
|
|
77
141
|
}
|
|
142
|
+
export function resolveDefaultGraphqlPort() {
|
|
143
|
+
const runtime = readRuntime();
|
|
144
|
+
const basePort = runtime && isAlive(runtime.pid)
|
|
145
|
+
? runtime.httpPort
|
|
146
|
+
: getConfig().preferredPort;
|
|
147
|
+
if (!Number.isInteger(basePort) || basePort <= 0 || basePort > 65_535) {
|
|
148
|
+
throw new Error(`Cannot derive GraphQL port from invalid HTTP port ${basePort}`);
|
|
149
|
+
}
|
|
150
|
+
const port = basePort + GRAPHQL_PORT_OFFSET;
|
|
151
|
+
if (port > 65_535) {
|
|
152
|
+
throw new Error(`Cannot derive GraphQL port from HTTP port ${basePort}`);
|
|
153
|
+
}
|
|
154
|
+
return port;
|
|
155
|
+
}
|
|
78
156
|
export async function isPortFree(port) {
|
|
79
157
|
return new Promise((resolvePort) => {
|
|
80
158
|
const srv = createServer();
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,M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AG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAChE,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAY;IAC7C,KAAK,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,IAAI,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1C,IAAI,MAAM,UAAU,CAAC,CAAC,CAAC;YAAE,OAAO,CAAC,CAAC;IACpC,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,2BAA2B,IAAI,EAAE,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,IAAY;IAC1C,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACrF,OAAO,QAAQ,CAAC,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,MAAM,GAAG,GAAG,CAAC;IACzD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-process control-plane bootstrap (ADR 0006) — replaces the external `npx revisium example
|
|
3
|
+
* bootstrap` with native `@revisium/client` calls so `revo start` brings up a READY stack with no
|
|
4
|
+
* external tool. Idempotent (check-then-create): an existing install is a cheap no-op (a few reads,
|
|
5
|
+
* no writes), a fresh one gets project + REST endpoint + tables + seed rows.
|
|
6
|
+
*
|
|
7
|
+
* The whole bootstrap runs on ONE `client.revision('draft')` scope (tables via applyAdditiveSchema-
|
|
8
|
+
* Migration, then seed rows) and commits once. Table schemas + rows come from bootstrap.config.json.
|
|
9
|
+
*/
|
|
10
|
+
import { readFileSync } from 'node:fs';
|
|
11
|
+
import { join } from 'node:path';
|
|
12
|
+
import { RevisiumClient } from '@revisium/client';
|
|
13
|
+
import { baseUrl, getConfig, repoRoot } from '../config.js';
|
|
14
|
+
import { applyAdditiveSchemaMigration } from './schema-migration.js';
|
|
15
|
+
/**
|
|
16
|
+
* True ONLY for a Revisium "not found" (404) response. Existence probes use this so a 5xx/auth/network
|
|
17
|
+
* fault is NOT silently treated as "absent" (which would wrongly run a create path on a broken backend).
|
|
18
|
+
*/
|
|
19
|
+
function isNotFoundError(err) {
|
|
20
|
+
if (err && typeof err === 'object') {
|
|
21
|
+
const e = err;
|
|
22
|
+
if (e.status === 404 || e.statusCode === 404)
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
return /\b404\b|not found|NOT_FOUND/i.test(err instanceof Error ? err.message : String(err));
|
|
26
|
+
}
|
|
27
|
+
/** Absolute path to the committed control-plane bootstrap config (table schemas + seed rows). */
|
|
28
|
+
export function bootstrapConfigPath() {
|
|
29
|
+
return join(repoRoot, 'control-plane', 'bootstrap.config.json');
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Ensure the control-plane project/schema/seed exist. Safe to call on every daemon boot — when
|
|
33
|
+
* already bootstrapped it issues only existence checks and returns without writing.
|
|
34
|
+
*/
|
|
35
|
+
export async function bootstrapControlPlane(httpPort, client = new RevisiumClient({ baseUrl: baseUrl(httpPort) })) {
|
|
36
|
+
const { org, project, branch } = getConfig();
|
|
37
|
+
const configPath = bootstrapConfigPath();
|
|
38
|
+
const config = JSON.parse(readFileSync(configPath, 'utf8'));
|
|
39
|
+
const orgScope = client.org(org);
|
|
40
|
+
const projectScope = orgScope.project(project);
|
|
41
|
+
// 1. Project (+ its initial branch) — only when absent.
|
|
42
|
+
let projectExists = true;
|
|
43
|
+
try {
|
|
44
|
+
await projectScope.get();
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
if (!isNotFoundError(err))
|
|
48
|
+
throw err;
|
|
49
|
+
projectExists = false;
|
|
50
|
+
}
|
|
51
|
+
if (!projectExists) {
|
|
52
|
+
await orgScope.createProject({ projectName: project, branchName: branch });
|
|
53
|
+
}
|
|
54
|
+
// 2. REST_API endpoint — the orchestrator talks to Revisium over REST.
|
|
55
|
+
const endpoints = await projectScope.getEndpoints();
|
|
56
|
+
if (!endpoints.some((endpoint) => endpoint.type === 'REST_API')) {
|
|
57
|
+
await projectScope.createEndpoint({ type: 'REST_API' });
|
|
58
|
+
}
|
|
59
|
+
// 3+4. ONE draft scope: tables (create-if-missing + additive drift) + seed rows, then ONE commit.
|
|
60
|
+
const draft = await client.revision({ org, project, branch, revision: 'draft' });
|
|
61
|
+
const migration = await applyAdditiveSchemaMigration(draft, configPath);
|
|
62
|
+
let createdRows = 0;
|
|
63
|
+
for (const row of config.rows ?? []) {
|
|
64
|
+
let rowExists = true;
|
|
65
|
+
try {
|
|
66
|
+
await draft.getRow(row.tableId, row.rowId);
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
if (!isNotFoundError(err))
|
|
70
|
+
throw err;
|
|
71
|
+
rowExists = false;
|
|
72
|
+
}
|
|
73
|
+
if (!rowExists) {
|
|
74
|
+
await draft.createRow(row.tableId, row.rowId, row.data);
|
|
75
|
+
createdRows += 1;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (migration.patches > 0 || createdRows > 0) {
|
|
79
|
+
await draft.commit(config.commitMessage ?? 'revo control-plane bootstrap');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Installed playbooks read from a FRESH client at HEAD — the presence signal for the default-playbook
|
|
84
|
+
* seed when it runs before the daemon's service layer exists. A fresh client resolves the current head
|
|
85
|
+
* each call, so it reflects bootstrap/earlier commits made in the same boot (unlike a cached scope).
|
|
86
|
+
*/
|
|
87
|
+
export async function listInstalledPlaybooks(httpPort, client = new RevisiumClient({ baseUrl: baseUrl(httpPort) })) {
|
|
88
|
+
const { org, project, branch } = getConfig();
|
|
89
|
+
const head = await client.revision({ org, project, branch, revision: 'head' });
|
|
90
|
+
const rows = await head.getRows('playbooks', { first: 1000 });
|
|
91
|
+
// Carry the row's recorded `version` (a data column, see import-mapper) so the version-aware seed
|
|
92
|
+
// (slice 144 B1) can compare it to the bundled version — WITHOUT it, every restart reads the installed
|
|
93
|
+
// version as undefined → "older" → re-seeds on every boot.
|
|
94
|
+
return (rows.edges ?? []).flatMap((edge) => {
|
|
95
|
+
if (!edge.node)
|
|
96
|
+
return [];
|
|
97
|
+
const version = edge.node.data?.version;
|
|
98
|
+
return [{ id: edge.node.id, version: typeof version === 'string' && version ? version : undefined }];
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=bootstrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/control-plane/bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAKrE;;;GAGG;AACH,SAAS,eAAe,CAAC,GAAY;IACnC,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QACnC,MAAM,CAAC,GAAG,GAAiD,CAAC;QAC5D,IAAI,CAAC,CAAC,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,UAAU,KAAK,GAAG;YAAE,OAAO,IAAI,CAAC;IAC5D,CAAC;IACD,OAAO,8BAA8B,CAAC,IAAI,CAAC,GAAG,YAAY,KAAK,CAAC,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AAC,KAAK,UAAU,sBAAsB,CAC1C,QAAgB,EAChB,SAAyB,IAAI,cAAc,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;IAE3E,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,CAAC;IAC7C,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IAC/E,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9D,kGAAkG;IAClG,uGAAuG;IACvG,2DAA2D;IAC3D,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACzC,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE,OAAO,EAAE,CAAC;QAC1B,MAAM,OAAO,GAAI,IAAI,CAAC,IAAI,CAAC,IAA4C,EAAE,OAAO,CAAC;QACjF,OAAO,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;IACvG,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import pg from 'pg';
|
|
2
|
+
import { isAlive, readRuntime } from '../config.js';
|
|
3
|
+
export const CONTROL_PLANE_CHANGE_CHANNEL = 'revo_control_plane_changes';
|
|
4
|
+
function notificationDatabaseUrl(pgPort) {
|
|
5
|
+
return `postgresql://revisium:password@localhost:${pgPort}/postgres`;
|
|
6
|
+
}
|
|
7
|
+
export function controlPlaneNotificationDatabaseUrl() {
|
|
8
|
+
const runtime = readRuntime();
|
|
9
|
+
if (!runtime || !isAlive(runtime.pid))
|
|
10
|
+
return null;
|
|
11
|
+
return notificationDatabaseUrl(runtime.pgPort);
|
|
12
|
+
}
|
|
13
|
+
let pool = null;
|
|
14
|
+
let poolUrl = '';
|
|
15
|
+
function getPool(url) {
|
|
16
|
+
if (!pool || poolUrl !== url) {
|
|
17
|
+
pool?.end().catch(() => undefined);
|
|
18
|
+
poolUrl = url;
|
|
19
|
+
pool = new pg.Pool({ connectionString: url, max: 1 });
|
|
20
|
+
}
|
|
21
|
+
return pool;
|
|
22
|
+
}
|
|
23
|
+
export async function notifyControlPlaneChange(change) {
|
|
24
|
+
const url = controlPlaneNotificationDatabaseUrl();
|
|
25
|
+
if (!url)
|
|
26
|
+
return;
|
|
27
|
+
const payload = JSON.stringify({ ...change, emittedAt: new Date().toISOString() });
|
|
28
|
+
try {
|
|
29
|
+
await getPool(url).query('SELECT pg_notify($1, $2)', [CONTROL_PLANE_CHANGE_CHANNEL, payload]);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// Subscriptions are an access-layer feed. A notification failure must not break the sealed write verb.
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=change-notifications.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"change-notifications.js","sourceRoot":"","sources":["../../src/control-plane/change-notifications.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAIpD,MAAM,CAAC,MAAM,4BAA4B,GAAG,4BAA4B,CAAC;AAYzE,SAAS,uBAAuB,CAAC,MAAc;IAC7C,OAAO,4CAA4C,MAAM,WAAW,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,mCAAmC;IACjD,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC;IAC9B,IAAI,CAAC,OAAO,IA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