agentic-orchestrator 0.1.2 → 0.1.4
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/.claude/settings.local.json +15 -0
- package/CLAUDE.md +126 -0
- package/README.md +166 -25
- package/agentic/orchestrator/adapters.yaml +3 -0
- package/agentic/orchestrator/gates.yaml +47 -0
- package/agentic/orchestrator/policy.yaml +89 -0
- package/agentic/orchestrator/schemas/adapters.schema.json +12 -0
- package/agentic/orchestrator/schemas/gates.schema.json +6 -1
- package/agentic/orchestrator/schemas/index.schema.json +14 -0
- package/agentic/orchestrator/schemas/multi-project.schema.json +41 -0
- package/agentic/orchestrator/schemas/policy.schema.json +449 -52
- package/agentic/orchestrator/schemas/state.schema.json +16 -0
- package/agentic/orchestrator/tools/catalog.json +68 -0
- package/agentic/orchestrator/tools/schemas/input/cost.get.input.schema.json +10 -0
- package/agentic/orchestrator/tools/schemas/input/cost.record.input.schema.json +13 -0
- package/agentic/orchestrator/tools/schemas/input/feature.send_message.input.schema.json +11 -0
- package/agentic/orchestrator/tools/schemas/input/performance.get_analytics.input.schema.json +10 -0
- package/agentic/orchestrator/tools/schemas/input/performance.record_outcome.input.schema.json +18 -0
- package/agentic/orchestrator/tools/schemas/output/cost.get.output.schema.json +13 -0
- package/agentic/orchestrator/tools/schemas/output/cost.record.output.schema.json +13 -0
- package/agentic/orchestrator/tools/schemas/output/feature.ready_to_merge.output.schema.json +7 -0
- package/agentic/orchestrator/tools/schemas/output/feature.send_message.output.schema.json +23 -0
- package/agentic/orchestrator/tools/schemas/output/performance.get_analytics.output.schema.json +46 -0
- package/agentic/orchestrator/tools/schemas/output/performance.record_outcome.output.schema.json +10 -0
- package/agentic/orchestrator/tools.md +5 -0
- package/apps/control-plane/scripts/validate-architecture-rules.mjs +28 -2
- package/apps/control-plane/scripts/validate-docker-mcp-contract.mjs +12 -0
- package/apps/control-plane/scripts/validate-mcp-contracts.ts +92 -0
- package/apps/control-plane/src/application/adapters/adapter-registry.ts +169 -0
- package/apps/control-plane/src/application/multi-project-loader.ts +119 -0
- package/apps/control-plane/src/application/services/activity-monitor-service.ts +199 -0
- package/apps/control-plane/src/application/services/cost-tracking-service.ts +82 -0
- package/apps/control-plane/src/application/services/dependency-scheduler-service.ts +86 -0
- package/apps/control-plane/src/application/services/feature-deletion-service.ts +8 -7
- package/apps/control-plane/src/application/services/gate-interpolation-service.ts +15 -0
- package/apps/control-plane/src/application/services/gate-service.ts +38 -2
- package/apps/control-plane/src/application/services/instance-isolation-service.ts +18 -0
- package/apps/control-plane/src/application/services/issue-tracker-service.ts +469 -0
- package/apps/control-plane/src/application/services/merge-service.ts +67 -3
- package/apps/control-plane/src/application/services/notifier-service.ts +295 -0
- package/apps/control-plane/src/application/services/performance-analytics-service.ts +122 -0
- package/apps/control-plane/src/application/services/plan-service.ts +51 -0
- package/apps/control-plane/src/application/services/pr-monitor-service.ts +262 -0
- package/apps/control-plane/src/application/services/reactions-service.ts +175 -0
- package/apps/control-plane/src/application/services/reporting-service.ts +17 -2
- package/apps/control-plane/src/application/services/run-lease-service.ts +16 -38
- package/apps/control-plane/src/application/tools/tool-metadata.ts +4 -1
- package/apps/control-plane/src/cli/aop.ts +1 -1
- package/apps/control-plane/src/cli/attach-command-handler.ts +120 -0
- package/apps/control-plane/src/cli/cleanup-command-handler.ts +190 -0
- package/apps/control-plane/src/cli/cli-argument-parser.ts +69 -3
- package/apps/control-plane/src/cli/dashboard-command-handler.ts +57 -0
- package/apps/control-plane/src/cli/help-command-handler.ts +163 -0
- package/apps/control-plane/src/cli/init-command-handler.ts +609 -0
- package/apps/control-plane/src/cli/resume-command-handler.ts +1 -0
- package/apps/control-plane/src/cli/retry-command-handler.ts +138 -0
- package/apps/control-plane/src/cli/run-command-handler.ts +115 -3
- package/apps/control-plane/src/cli/send-command-handler.ts +65 -0
- package/apps/control-plane/src/cli/status-command-handler.ts +102 -2
- package/apps/control-plane/src/cli/types.ts +26 -1
- package/apps/control-plane/src/core/constants.ts +8 -2
- package/apps/control-plane/src/core/error-codes.ts +3 -1
- package/apps/control-plane/src/core/gates.ts +170 -50
- package/apps/control-plane/src/core/kernel.ts +280 -5
- package/apps/control-plane/src/core/path-layout.ts +12 -0
- package/apps/control-plane/src/core/tool-caller.ts +36 -0
- package/apps/control-plane/src/core/workspace-hooks.ts +87 -0
- package/apps/control-plane/src/interfaces/cli/bootstrap.ts +258 -9
- package/apps/control-plane/src/providers/providers.ts +235 -14
- package/apps/control-plane/src/supervisor/build-wave-executor.ts +129 -8
- package/apps/control-plane/src/supervisor/qa-wave-executor.ts +123 -5
- package/apps/control-plane/src/supervisor/run-coordinator.ts +143 -6
- package/apps/control-plane/src/supervisor/runtime.ts +135 -6
- package/apps/control-plane/src/supervisor/types.ts +12 -21
- package/apps/control-plane/src/supervisor/worker-decision-loop.ts +8 -0
- package/apps/control-plane/test/activity-monitor.spec.ts +294 -0
- package/apps/control-plane/test/adapter-registry.spec.ts +132 -0
- package/apps/control-plane/test/batch-operations.spec.ts +112 -0
- package/apps/control-plane/test/bootstrap-attach.spec.ts +102 -0
- package/apps/control-plane/test/bootstrap-edge-cases.spec.ts +252 -0
- package/apps/control-plane/test/bootstrap.spec.ts +560 -0
- package/apps/control-plane/test/cleanup-command.spec.ts +301 -0
- package/apps/control-plane/test/cli-helpers.spec.ts +404 -1
- package/apps/control-plane/test/cli.unit.spec.ts +182 -1
- package/apps/control-plane/test/collision-queue.spec.ts +104 -1
- package/apps/control-plane/test/core-utils.spec.ts +175 -2
- package/apps/control-plane/test/cost-tracking.spec.ts +143 -0
- package/apps/control-plane/test/dashboard-api.integration.spec.ts +247 -0
- package/apps/control-plane/test/dashboard-client.spec.ts +116 -0
- package/apps/control-plane/test/dashboard-command.spec.ts +103 -0
- package/apps/control-plane/test/dependency-scheduler.spec.ts +189 -0
- package/apps/control-plane/test/epoch-tracking.spec.ts +4 -4
- package/apps/control-plane/test/feature-deletion-service.spec.ts +422 -0
- package/apps/control-plane/test/feature-lifecycle.spec.ts +202 -0
- package/apps/control-plane/test/git-spawn-error.spec.ts +24 -0
- package/apps/control-plane/test/incremental-gates.spec.ts +137 -0
- package/apps/control-plane/test/init-wizard.spec.ts +506 -0
- package/apps/control-plane/test/instance-isolation.spec.ts +83 -0
- package/apps/control-plane/test/issue-tracker.spec.ts +890 -0
- package/apps/control-plane/test/kernel.coverage.spec.ts +3 -5
- package/apps/control-plane/test/kernel.coverage2.spec.ts +871 -0
- package/apps/control-plane/test/kernel.spec.ts +13 -11
- package/apps/control-plane/test/lock-service.spec.ts +508 -0
- package/apps/control-plane/test/mcp-helpers.spec.ts +176 -0
- package/apps/control-plane/test/mcp.spec.ts +50 -15
- package/apps/control-plane/test/merge-service.spec.ts +67 -4
- package/apps/control-plane/test/multi-project.spec.ts +372 -0
- package/apps/control-plane/test/notifier-service.spec.ts +388 -0
- package/apps/control-plane/test/parallel-gates.spec.ts +312 -0
- package/apps/control-plane/test/patch-service.spec.ts +253 -0
- package/apps/control-plane/test/performance-analytics.spec.ts +338 -0
- package/apps/control-plane/test/planning-wave-executor.spec.ts +168 -0
- package/apps/control-plane/test/pr-monitor.spec.ts +385 -0
- package/apps/control-plane/test/providers.spec.ts +344 -1
- package/apps/control-plane/test/reactions.spec.ts +392 -0
- package/apps/control-plane/test/resume-command.spec.ts +390 -0
- package/apps/control-plane/test/run-coordinator.spec.ts +481 -2
- package/apps/control-plane/test/schema-date-time.spec.ts +46 -0
- package/apps/control-plane/test/service-retry-paths.spec.ts +30 -0
- package/apps/control-plane/test/services.spec.ts +95 -2
- package/apps/control-plane/test/session-management.spec.ts +450 -0
- package/apps/control-plane/test/spec-ingestion.spec.ts +190 -0
- package/apps/control-plane/test/supervisor-collaborators.spec.ts +699 -2
- package/apps/control-plane/test/supervisor.spec.ts +36 -30
- package/apps/control-plane/test/supervisor.unit.spec.ts +405 -0
- package/apps/control-plane/test/worker-decision-loop.spec.ts +57 -0
- package/apps/control-plane/test/workspace-hooks.spec.ts +177 -0
- package/apps/control-plane/vitest.config.ts +21 -5
- package/dist/apps/control-plane/application/adapters/adapter-registry.d.ts +44 -0
- package/dist/apps/control-plane/application/adapters/adapter-registry.js +76 -0
- package/dist/apps/control-plane/application/adapters/adapter-registry.js.map +1 -0
- package/dist/apps/control-plane/application/multi-project-loader.d.ts +31 -0
- package/dist/apps/control-plane/application/multi-project-loader.js +82 -0
- package/dist/apps/control-plane/application/multi-project-loader.js.map +1 -0
- package/dist/apps/control-plane/application/services/activity-monitor-service.d.ts +43 -0
- package/dist/apps/control-plane/application/services/activity-monitor-service.js +132 -0
- package/dist/apps/control-plane/application/services/activity-monitor-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/cost-tracking-service.d.ts +28 -0
- package/dist/apps/control-plane/application/services/cost-tracking-service.js +48 -0
- package/dist/apps/control-plane/application/services/cost-tracking-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/dependency-scheduler-service.d.ts +26 -0
- package/dist/apps/control-plane/application/services/dependency-scheduler-service.js +75 -0
- package/dist/apps/control-plane/application/services/dependency-scheduler-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/feature-deletion-service.d.ts +2 -0
- package/dist/apps/control-plane/application/services/feature-deletion-service.js +6 -7
- package/dist/apps/control-plane/application/services/feature-deletion-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/gate-interpolation-service.d.ts +7 -0
- package/dist/apps/control-plane/application/services/gate-interpolation-service.js +7 -0
- package/dist/apps/control-plane/application/services/gate-interpolation-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/gate-service.js +32 -2
- package/dist/apps/control-plane/application/services/gate-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/instance-isolation-service.d.ts +11 -0
- package/dist/apps/control-plane/application/services/instance-isolation-service.js +17 -0
- package/dist/apps/control-plane/application/services/instance-isolation-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/issue-tracker-service.d.ts +65 -0
- package/dist/apps/control-plane/application/services/issue-tracker-service.js +358 -0
- package/dist/apps/control-plane/application/services/issue-tracker-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/merge-service.d.ts +4 -0
- package/dist/apps/control-plane/application/services/merge-service.js +44 -2
- package/dist/apps/control-plane/application/services/merge-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/notifier-service.d.ts +74 -0
- package/dist/apps/control-plane/application/services/notifier-service.js +212 -0
- package/dist/apps/control-plane/application/services/notifier-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/performance-analytics-service.d.ts +39 -0
- package/dist/apps/control-plane/application/services/performance-analytics-service.js +75 -0
- package/dist/apps/control-plane/application/services/performance-analytics-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/plan-service.d.ts +1 -0
- package/dist/apps/control-plane/application/services/plan-service.js +53 -0
- package/dist/apps/control-plane/application/services/plan-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/pr-monitor-service.d.ts +44 -0
- package/dist/apps/control-plane/application/services/pr-monitor-service.js +192 -0
- package/dist/apps/control-plane/application/services/pr-monitor-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/reactions-service.d.ts +67 -0
- package/dist/apps/control-plane/application/services/reactions-service.js +114 -0
- package/dist/apps/control-plane/application/services/reactions-service.js.map +1 -0
- package/dist/apps/control-plane/application/services/reporting-service.d.ts +1 -0
- package/dist/apps/control-plane/application/services/reporting-service.js +13 -2
- package/dist/apps/control-plane/application/services/reporting-service.js.map +1 -1
- package/dist/apps/control-plane/application/services/run-lease-service.d.ts +2 -0
- package/dist/apps/control-plane/application/services/run-lease-service.js +14 -38
- package/dist/apps/control-plane/application/services/run-lease-service.js.map +1 -1
- package/dist/apps/control-plane/application/tools/tool-metadata.js +3 -1
- package/dist/apps/control-plane/application/tools/tool-metadata.js.map +1 -1
- package/dist/apps/control-plane/cli/aop.d.ts +1 -1
- package/dist/apps/control-plane/cli/aop.js +1 -1
- package/dist/apps/control-plane/cli/attach-command-handler.d.ts +12 -0
- package/dist/apps/control-plane/cli/attach-command-handler.js +98 -0
- package/dist/apps/control-plane/cli/attach-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/cleanup-command-handler.d.ts +12 -0
- package/dist/apps/control-plane/cli/cleanup-command-handler.js +162 -0
- package/dist/apps/control-plane/cli/cleanup-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/cli-argument-parser.js +73 -3
- package/dist/apps/control-plane/cli/cli-argument-parser.js.map +1 -1
- package/dist/apps/control-plane/cli/dashboard-command-handler.d.ts +7 -0
- package/dist/apps/control-plane/cli/dashboard-command-handler.js +45 -0
- package/dist/apps/control-plane/cli/dashboard-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/help-command-handler.d.ts +8 -0
- package/dist/apps/control-plane/cli/help-command-handler.js +146 -0
- package/dist/apps/control-plane/cli/help-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/init-command-handler.d.ts +26 -0
- package/dist/apps/control-plane/cli/init-command-handler.js +517 -0
- package/dist/apps/control-plane/cli/init-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/resume-command-handler.js +1 -1
- package/dist/apps/control-plane/cli/resume-command-handler.js.map +1 -1
- package/dist/apps/control-plane/cli/retry-command-handler.d.ts +8 -0
- package/dist/apps/control-plane/cli/retry-command-handler.js +111 -0
- package/dist/apps/control-plane/cli/retry-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/run-command-handler.d.ts +5 -0
- package/dist/apps/control-plane/cli/run-command-handler.js +82 -3
- package/dist/apps/control-plane/cli/run-command-handler.js.map +1 -1
- package/dist/apps/control-plane/cli/send-command-handler.d.ts +8 -0
- package/dist/apps/control-plane/cli/send-command-handler.js +55 -0
- package/dist/apps/control-plane/cli/send-command-handler.js.map +1 -0
- package/dist/apps/control-plane/cli/status-command-handler.d.ts +12 -1
- package/dist/apps/control-plane/cli/status-command-handler.js +55 -2
- package/dist/apps/control-plane/cli/status-command-handler.js.map +1 -1
- package/dist/apps/control-plane/cli/types.d.ts +26 -1
- package/dist/apps/control-plane/cli/types.js +15 -1
- package/dist/apps/control-plane/cli/types.js.map +1 -1
- package/dist/apps/control-plane/core/constants.d.ts +6 -0
- package/dist/apps/control-plane/core/constants.js +8 -2
- package/dist/apps/control-plane/core/constants.js.map +1 -1
- package/dist/apps/control-plane/core/error-codes.d.ts +2 -0
- package/dist/apps/control-plane/core/error-codes.js +3 -1
- package/dist/apps/control-plane/core/error-codes.js.map +1 -1
- package/dist/apps/control-plane/core/gates.d.ts +4 -0
- package/dist/apps/control-plane/core/gates.js +140 -43
- package/dist/apps/control-plane/core/gates.js.map +1 -1
- package/dist/apps/control-plane/core/kernel.d.ts +50 -1
- package/dist/apps/control-plane/core/kernel.js +220 -7
- package/dist/apps/control-plane/core/kernel.js.map +1 -1
- package/dist/apps/control-plane/core/path-layout.d.ts +3 -0
- package/dist/apps/control-plane/core/path-layout.js +9 -0
- package/dist/apps/control-plane/core/path-layout.js.map +1 -1
- package/dist/apps/control-plane/core/tool-caller.d.ts +32 -0
- package/dist/apps/control-plane/core/tool-caller.js +2 -0
- package/dist/apps/control-plane/core/tool-caller.js.map +1 -0
- package/dist/apps/control-plane/core/workspace-hooks.d.ts +20 -0
- package/dist/apps/control-plane/core/workspace-hooks.js +69 -0
- package/dist/apps/control-plane/core/workspace-hooks.js.map +1 -0
- package/dist/apps/control-plane/interfaces/cli/bootstrap.js +245 -9
- package/dist/apps/control-plane/interfaces/cli/bootstrap.js.map +1 -1
- package/dist/apps/control-plane/providers/providers.d.ts +42 -3
- package/dist/apps/control-plane/providers/providers.js +216 -5
- package/dist/apps/control-plane/providers/providers.js.map +1 -1
- package/dist/apps/control-plane/supervisor/build-wave-executor.d.ts +3 -0
- package/dist/apps/control-plane/supervisor/build-wave-executor.js +115 -6
- package/dist/apps/control-plane/supervisor/build-wave-executor.js.map +1 -1
- package/dist/apps/control-plane/supervisor/qa-wave-executor.d.ts +3 -0
- package/dist/apps/control-plane/supervisor/qa-wave-executor.js +109 -5
- package/dist/apps/control-plane/supervisor/qa-wave-executor.js.map +1 -1
- package/dist/apps/control-plane/supervisor/run-coordinator.d.ts +15 -0
- package/dist/apps/control-plane/supervisor/run-coordinator.js +132 -6
- package/dist/apps/control-plane/supervisor/run-coordinator.js.map +1 -1
- package/dist/apps/control-plane/supervisor/runtime.d.ts +3 -0
- package/dist/apps/control-plane/supervisor/runtime.js +110 -6
- package/dist/apps/control-plane/supervisor/runtime.js.map +1 -1
- package/dist/apps/control-plane/supervisor/types.d.ts +9 -16
- package/dist/apps/control-plane/supervisor/types.js.map +1 -1
- package/dist/apps/control-plane/supervisor/worker-decision-loop.d.ts +3 -0
- package/dist/apps/control-plane/supervisor/worker-decision-loop.js +5 -0
- package/dist/apps/control-plane/supervisor/worker-decision-loop.js.map +1 -1
- package/eslint.config.mjs +2 -1
- package/package.json +12 -2
- package/packages/web-dashboard/next-env.d.ts +5 -0
- package/packages/web-dashboard/next.config.js +7 -0
- package/packages/web-dashboard/package.json +26 -0
- package/packages/web-dashboard/src/app/api/actions/route.ts +64 -0
- package/packages/web-dashboard/src/app/api/events/route.ts +51 -0
- package/packages/web-dashboard/src/app/api/features/[id]/checkout/route.ts +256 -0
- package/packages/web-dashboard/src/app/api/features/[id]/diff/route.ts +10 -0
- package/packages/web-dashboard/src/app/api/features/[id]/evidence/[artifact]/route.ts +25 -0
- package/packages/web-dashboard/src/app/api/features/[id]/review/route.ts +63 -0
- package/packages/web-dashboard/src/app/api/features/[id]/route.ts +16 -0
- package/packages/web-dashboard/src/app/api/projects/route.ts +31 -0
- package/packages/web-dashboard/src/app/api/status/route.ts +15 -0
- package/packages/web-dashboard/src/app/globals.css +2 -0
- package/packages/web-dashboard/src/app/layout.tsx +15 -0
- package/packages/web-dashboard/src/app/page.tsx +393 -0
- package/packages/web-dashboard/src/lib/aop-client.ts +244 -0
- package/packages/web-dashboard/src/lib/multi-project-config.ts +116 -0
- package/packages/web-dashboard/src/lib/orchestrator-tools.ts +284 -0
- package/packages/web-dashboard/src/lib/types.ts +58 -0
- package/packages/web-dashboard/tsconfig.json +40 -0
- package/packages/web-dashboard/vitest.config.ts +6 -0
- package/spec-files/completed/agentic_orchestrator_feature_gaps_closure_spec.md +1764 -0
- package/spec-files/outstanding/agentic_orchestrator_enterprise_governance_dashboard_spec.md +348 -0
- package/spec-files/outstanding/agentic_orchestrator_knowledge_canary_spec.md +344 -0
- package/spec-files/outstanding/agentic_orchestrator_observability_integrity_diagnostics_spec.md +374 -0
- package/spec-files/outstanding/agentic_orchestrator_performance_improvements_spec.md +1059 -0
- package/spec-files/outstanding/agentic_orchestrator_planning_review_quality_spec.md +466 -0
- package/spec-files/outstanding/agentic_orchestrator_quality_adoption_execution_spec.md +198 -0
- package/spec-files/outstanding/agentic_orchestrator_validator_hardening_spec.md +365 -0
- package/spec-files/progress.md +481 -52
- /package/spec-files/{agentic_orchestrator_cli_delete_command_spec.md → completed/agentic_orchestrator_cli_delete_command_spec.md} +0 -0
- /package/spec-files/{agentic_orchestrator_dot_aop_generated_artifacts_spec.md → completed/agentic_orchestrator_dot_aop_generated_artifacts_spec.md} +0 -0
- /package/spec-files/{agentic_orchestrator_mcp_formalization_spec.md → completed/agentic_orchestrator_mcp_formalization_spec.md} +0 -0
- /package/spec-files/{agentic_orchestrator_oop_refactor_spec.md → completed/agentic_orchestrator_oop_refactor_spec.md} +0 -0
- /package/spec-files/{agentic_orchestrator_single_global_orchestrator_spec.md → completed/agentic_orchestrator_single_global_orchestrator_spec.md} +0 -0
- /package/spec-files/{agentic_orchestrator_spec.md → completed/agentic_orchestrator_spec.md} +0 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { promisify } from 'node:util';
|
|
3
|
+
import { TOOLS } from '../../core/constants.js';
|
|
4
|
+
const execFileAsync = promisify(execFile);
|
|
5
|
+
export function createGhRunner(fn) {
|
|
6
|
+
if (fn !== undefined) {
|
|
7
|
+
return fn;
|
|
8
|
+
}
|
|
9
|
+
return async (args) => {
|
|
10
|
+
try {
|
|
11
|
+
const { stdout } = await execFileAsync('gh', args, { timeout: 15_000 });
|
|
12
|
+
return { stdout, exitCode: 0 };
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
const e = err;
|
|
16
|
+
if (e['code'] === 'ENOENT' || e['code'] === 127) {
|
|
17
|
+
return { stdout: '', exitCode: 127 };
|
|
18
|
+
}
|
|
19
|
+
const exitCode = typeof e['code'] === 'number' ? e['code'] : 1;
|
|
20
|
+
return { stdout: '', exitCode };
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function mapCiStatus(checks) {
|
|
25
|
+
if (!checks || checks.length === 0) {
|
|
26
|
+
return 'none';
|
|
27
|
+
}
|
|
28
|
+
const upper = checks.map((c) => c.state.toUpperCase());
|
|
29
|
+
if (upper.some((s) => s === 'FAILURE' || s === 'ERROR')) {
|
|
30
|
+
return 'failing';
|
|
31
|
+
}
|
|
32
|
+
if (upper.some((s) => s === 'PENDING' || s === 'IN_PROGRESS' || s === 'EXPECTED' || s === 'WAITING')) {
|
|
33
|
+
return 'pending';
|
|
34
|
+
}
|
|
35
|
+
return 'passing';
|
|
36
|
+
}
|
|
37
|
+
function mapReviewDecision(decision) {
|
|
38
|
+
if (!decision) {
|
|
39
|
+
return 'none';
|
|
40
|
+
}
|
|
41
|
+
switch (decision.toUpperCase()) {
|
|
42
|
+
case 'APPROVED':
|
|
43
|
+
return 'approved';
|
|
44
|
+
case 'CHANGES_REQUESTED':
|
|
45
|
+
return 'changes_requested';
|
|
46
|
+
case 'REVIEW_REQUIRED':
|
|
47
|
+
return 'pending';
|
|
48
|
+
default:
|
|
49
|
+
return 'none';
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export class PrMonitorService {
|
|
53
|
+
toolCaller;
|
|
54
|
+
notifier;
|
|
55
|
+
reactionsPolicy;
|
|
56
|
+
ghRunner;
|
|
57
|
+
constructor(dependencies) {
|
|
58
|
+
this.toolCaller = dependencies.toolCaller;
|
|
59
|
+
this.notifier = dependencies.notifier;
|
|
60
|
+
this.reactionsPolicy = dependencies.reactionsPolicy;
|
|
61
|
+
this.ghRunner = dependencies.ghRunner ?? createGhRunner();
|
|
62
|
+
}
|
|
63
|
+
async detectPr(featureId, branch) {
|
|
64
|
+
const candidates = [...new Set([branch, featureId, `feature/${featureId}`].map((value) => value.trim()).filter(Boolean))];
|
|
65
|
+
let parsed = null;
|
|
66
|
+
for (const candidate of candidates) {
|
|
67
|
+
const result = await this.ghRunner([
|
|
68
|
+
'pr', 'view', '--head', candidate,
|
|
69
|
+
'--json', 'number,url,statusCheckRollup,reviewDecision,mergeable,reviewThreads'
|
|
70
|
+
]);
|
|
71
|
+
if (result.exitCode !== 0 || !result.stdout.trim()) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
const maybeParsed = JSON.parse(result.stdout);
|
|
76
|
+
if (maybeParsed.number) {
|
|
77
|
+
parsed = maybeParsed;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
// Try the next candidate branch.
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (!parsed?.number) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
const ci_status = mapCiStatus(parsed.statusCheckRollup);
|
|
89
|
+
const review_decision = mapReviewDecision(parsed.reviewDecision);
|
|
90
|
+
const has_conflicts = parsed.mergeable === 'CONFLICTING';
|
|
91
|
+
const merge_ready = parsed.mergeable === 'MERGEABLE' && ci_status === 'passing' && review_decision === 'approved';
|
|
92
|
+
const pending_review_threads = parsed.reviewThreads?.filter((t) => !t.isResolved).length ?? 0;
|
|
93
|
+
const partial = {
|
|
94
|
+
number: parsed.number,
|
|
95
|
+
url: parsed.url,
|
|
96
|
+
ci_status,
|
|
97
|
+
review_decision,
|
|
98
|
+
merge_ready,
|
|
99
|
+
pending_review_threads,
|
|
100
|
+
has_conflicts
|
|
101
|
+
};
|
|
102
|
+
const merge_score = this.computeMergeScore({ ...partial, merge_score: 0 });
|
|
103
|
+
return { ...partial, merge_score };
|
|
104
|
+
}
|
|
105
|
+
async storePrState(featureId, prInfo) {
|
|
106
|
+
const current = await this.toolCaller.callTool('orchestrator', TOOLS.FEATURE_STATE_GET, { feature_id: featureId });
|
|
107
|
+
await this.toolCaller.callTool('orchestrator', TOOLS.FEATURE_STATE_PATCH, {
|
|
108
|
+
feature_id: featureId,
|
|
109
|
+
expected_version: current.data.front_matter.version,
|
|
110
|
+
patch: {
|
|
111
|
+
front_matter: {
|
|
112
|
+
pr: {
|
|
113
|
+
number: prInfo.number,
|
|
114
|
+
url: prInfo.url,
|
|
115
|
+
ci_status: prInfo.ci_status,
|
|
116
|
+
review_decision: prInfo.review_decision,
|
|
117
|
+
merge_ready: prInfo.merge_ready,
|
|
118
|
+
pending_review_threads: prInfo.pending_review_threads,
|
|
119
|
+
has_conflicts: prInfo.has_conflicts,
|
|
120
|
+
merge_score: prInfo.merge_score
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
computeMergeScore(prInfo) {
|
|
127
|
+
let score = 0;
|
|
128
|
+
if (prInfo.ci_status === 'passing') {
|
|
129
|
+
score += 40;
|
|
130
|
+
}
|
|
131
|
+
if (prInfo.review_decision === 'approved') {
|
|
132
|
+
score += 40;
|
|
133
|
+
}
|
|
134
|
+
if (!prInfo.has_conflicts) {
|
|
135
|
+
score += 15;
|
|
136
|
+
}
|
|
137
|
+
if (prInfo.pending_review_threads === 0) {
|
|
138
|
+
score += 5;
|
|
139
|
+
}
|
|
140
|
+
return score;
|
|
141
|
+
}
|
|
142
|
+
async handleChangesRequested(featureId, prInfo) {
|
|
143
|
+
const reaction = this.reactionsPolicy?.changes_requested;
|
|
144
|
+
if (!reaction?.enabled) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (reaction.action !== 'send_review_context_to_agent') {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const reviewResult = await this.ghRunner(['pr', 'view', String(prInfo.number), '--json', 'reviews']);
|
|
151
|
+
let reviewBody = '';
|
|
152
|
+
if (reviewResult.exitCode === 0 && reviewResult.stdout.trim()) {
|
|
153
|
+
try {
|
|
154
|
+
const parsed = JSON.parse(reviewResult.stdout);
|
|
155
|
+
const lastReview = parsed.reviews?.[parsed.reviews.length - 1];
|
|
156
|
+
reviewBody = lastReview?.body ?? '';
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
// ignore parse errors
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
await this.toolCaller.callTool('orchestrator', TOOLS.FEATURE_LOG_APPEND, {
|
|
163
|
+
feature_id: featureId,
|
|
164
|
+
note: `PR #${prInfo.number} changes requested. Review context:\n${reviewBody}`
|
|
165
|
+
});
|
|
166
|
+
await this.toolCaller
|
|
167
|
+
.callTool('orchestrator', TOOLS.FEATURE_SEND_MESSAGE, {
|
|
168
|
+
feature_id: featureId,
|
|
169
|
+
message: `PR review requested changes:\n${reviewBody || '(no review body provided)'}`,
|
|
170
|
+
})
|
|
171
|
+
.catch(() => undefined);
|
|
172
|
+
if (this.notifier) {
|
|
173
|
+
await this.notifier.notify('changes_requested', {
|
|
174
|
+
feature_id: featureId,
|
|
175
|
+
message: `PR #${prInfo.number} has changes requested for feature '${featureId}'.`,
|
|
176
|
+
details: { pr_number: prInfo.number, pr_url: prInfo.url }
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
async checkAndUpdate(featureId, branch) {
|
|
181
|
+
const prInfo = await this.detectPr(featureId, branch);
|
|
182
|
+
if (!prInfo) {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
await this.storePrState(featureId, prInfo);
|
|
186
|
+
if (prInfo.review_decision === 'changes_requested') {
|
|
187
|
+
await this.handleChangesRequested(featureId, prInfo);
|
|
188
|
+
}
|
|
189
|
+
return prInfo;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=pr-monitor-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pr-monitor-service.js","sourceRoot":"","sources":["../../../../../apps/control-plane/src/application/services/pr-monitor-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAIhD,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAwB1C,MAAM,UAAU,cAAc,CAAC,EAAa;IAC1C,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;QACrB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,KAAK,EAAE,IAAc,EAAE,EAAE;QAC9B,IAAI,CAAC;YACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;YACxE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;QACjC,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACtB,MAAM,CAAC,GAAG,GAA8B,CAAC;YACzC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC;gBAChD,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;YACvC,CAAC;YACD,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC/D,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC;QAClC,CAAC;IACH,CAA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QACpD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QACtD,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAE3C,IAAI,MAAM,CAAC,eAAe,KAAK,mBAAmB,EAAE,CAAC;YACnD,MAAM,IAAI,CAAC,sBAAsB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QACvD,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ToolCaller as SupervisorToolCaller } from '../../core/tool-caller.js';
|
|
2
|
+
import type { NotifierService } from './notifier-service.js';
|
|
3
|
+
export interface GateFailedReaction {
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
max_retries: number;
|
|
6
|
+
action: 'retry_with_agent_repair' | 'notify_only';
|
|
7
|
+
escalate_after: number;
|
|
8
|
+
retry_delay_ms: number;
|
|
9
|
+
}
|
|
10
|
+
export interface ReactionsPolicy {
|
|
11
|
+
gate_failed?: GateFailedReaction;
|
|
12
|
+
agent_stuck?: {
|
|
13
|
+
enabled: boolean;
|
|
14
|
+
action: string;
|
|
15
|
+
idle_threshold_ms: number;
|
|
16
|
+
escalate_after: number;
|
|
17
|
+
};
|
|
18
|
+
collision_detected?: {
|
|
19
|
+
enabled: boolean;
|
|
20
|
+
action: string;
|
|
21
|
+
};
|
|
22
|
+
ready_to_merge?: {
|
|
23
|
+
enabled: boolean;
|
|
24
|
+
action: string;
|
|
25
|
+
};
|
|
26
|
+
changes_requested?: {
|
|
27
|
+
enabled: boolean;
|
|
28
|
+
action: string;
|
|
29
|
+
escalate_after: number;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export interface GateRepairContext {
|
|
33
|
+
featureId: string;
|
|
34
|
+
gateName: string;
|
|
35
|
+
exitCode: number;
|
|
36
|
+
logs: string;
|
|
37
|
+
evidenceSummary: string;
|
|
38
|
+
retryCount: number;
|
|
39
|
+
failureHistory?: Array<{
|
|
40
|
+
attempt: number;
|
|
41
|
+
gate_name: string;
|
|
42
|
+
exit_code: number;
|
|
43
|
+
evidence_summary: string;
|
|
44
|
+
logs_excerpt: string;
|
|
45
|
+
failed_at: string;
|
|
46
|
+
retry_delay_ms?: number;
|
|
47
|
+
}>;
|
|
48
|
+
}
|
|
49
|
+
export interface ReactionsServiceDependencies {
|
|
50
|
+
toolCaller: SupervisorToolCaller;
|
|
51
|
+
notifier?: NotifierService;
|
|
52
|
+
policy?: ReactionsPolicy;
|
|
53
|
+
}
|
|
54
|
+
export declare class ReactionsService {
|
|
55
|
+
private readonly toolCaller;
|
|
56
|
+
private readonly notifier;
|
|
57
|
+
private readonly policy;
|
|
58
|
+
constructor(dependencies: ReactionsServiceDependencies);
|
|
59
|
+
shouldRetry(_featureId: string, retryCount: number): boolean;
|
|
60
|
+
retryDelayMs(): number;
|
|
61
|
+
maxRetries(): number;
|
|
62
|
+
waitBeforeRetry(): Promise<void>;
|
|
63
|
+
buildRepairPrompt(ctx: GateRepairContext): string;
|
|
64
|
+
recordRetry(featureId: string, retryCount: number): Promise<void>;
|
|
65
|
+
shouldEscalate(retryCount: number): boolean;
|
|
66
|
+
notifyEscalation(featureId: string, ctx: GateRepairContext): Promise<void>;
|
|
67
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { TOOLS } from '../../core/constants.js';
|
|
2
|
+
const DEFAULT_GATE_FAILED_REACTION = {
|
|
3
|
+
enabled: false,
|
|
4
|
+
max_retries: 2,
|
|
5
|
+
action: 'notify_only',
|
|
6
|
+
escalate_after: 2,
|
|
7
|
+
retry_delay_ms: 30000
|
|
8
|
+
};
|
|
9
|
+
export class ReactionsService {
|
|
10
|
+
toolCaller;
|
|
11
|
+
notifier;
|
|
12
|
+
policy;
|
|
13
|
+
constructor(dependencies) {
|
|
14
|
+
this.toolCaller = dependencies.toolCaller;
|
|
15
|
+
this.notifier = dependencies.notifier;
|
|
16
|
+
this.policy = dependencies.policy ?? {};
|
|
17
|
+
}
|
|
18
|
+
shouldRetry(_featureId, retryCount) {
|
|
19
|
+
const reaction = this.policy.gate_failed ?? DEFAULT_GATE_FAILED_REACTION;
|
|
20
|
+
if (!reaction.enabled) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
if (reaction.action !== 'retry_with_agent_repair') {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
return retryCount < reaction.max_retries;
|
|
27
|
+
}
|
|
28
|
+
retryDelayMs() {
|
|
29
|
+
const reaction = this.policy.gate_failed ?? DEFAULT_GATE_FAILED_REACTION;
|
|
30
|
+
if (typeof reaction.retry_delay_ms === 'number' && Number.isFinite(reaction.retry_delay_ms) && reaction.retry_delay_ms >= 0) {
|
|
31
|
+
return Math.floor(reaction.retry_delay_ms);
|
|
32
|
+
}
|
|
33
|
+
return DEFAULT_GATE_FAILED_REACTION.retry_delay_ms;
|
|
34
|
+
}
|
|
35
|
+
maxRetries() {
|
|
36
|
+
const reaction = this.policy.gate_failed ?? DEFAULT_GATE_FAILED_REACTION;
|
|
37
|
+
if (typeof reaction.max_retries === 'number' && Number.isFinite(reaction.max_retries) && reaction.max_retries >= 0) {
|
|
38
|
+
return Math.floor(reaction.max_retries);
|
|
39
|
+
}
|
|
40
|
+
return DEFAULT_GATE_FAILED_REACTION.max_retries;
|
|
41
|
+
}
|
|
42
|
+
async waitBeforeRetry() {
|
|
43
|
+
const delayMs = this.retryDelayMs();
|
|
44
|
+
if (delayMs <= 0) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
48
|
+
}
|
|
49
|
+
buildRepairPrompt(ctx) {
|
|
50
|
+
const maxRetries = this.maxRetries();
|
|
51
|
+
const delayMs = this.retryDelayMs();
|
|
52
|
+
const failureSummary = Array.isArray(ctx.failureHistory) && ctx.failureHistory.length > 0
|
|
53
|
+
? ctx.failureHistory
|
|
54
|
+
.slice(-3)
|
|
55
|
+
.map((item) => `- attempt=${item.attempt}; gate=${item.gate_name}; exit=${item.exit_code}; at=${item.failed_at}; evidence=${item.evidence_summary || 'n/a'}`)
|
|
56
|
+
.join('\n')
|
|
57
|
+
: '(none)';
|
|
58
|
+
return [
|
|
59
|
+
'Gate execution failed. Review the error logs below and apply fixes.',
|
|
60
|
+
'',
|
|
61
|
+
`Gate: ${ctx.gateName}`,
|
|
62
|
+
`Exit Code: ${ctx.exitCode}`,
|
|
63
|
+
'',
|
|
64
|
+
'Logs:',
|
|
65
|
+
ctx.logs,
|
|
66
|
+
'',
|
|
67
|
+
'Evidence:',
|
|
68
|
+
ctx.evidenceSummary,
|
|
69
|
+
'',
|
|
70
|
+
`Retry: ${ctx.retryCount + 1} of ${maxRetries}`,
|
|
71
|
+
`Retry delay (ms): ${delayMs}`,
|
|
72
|
+
'',
|
|
73
|
+
'Failure history (most recent first):',
|
|
74
|
+
failureSummary
|
|
75
|
+
].join('\n');
|
|
76
|
+
}
|
|
77
|
+
async recordRetry(featureId, retryCount) {
|
|
78
|
+
const current = await this.toolCaller.callTool('orchestrator', TOOLS.FEATURE_STATE_GET, { feature_id: featureId });
|
|
79
|
+
await this.toolCaller.callTool('orchestrator', TOOLS.FEATURE_STATE_PATCH, {
|
|
80
|
+
feature_id: featureId,
|
|
81
|
+
expected_version: current.data.front_matter.version,
|
|
82
|
+
patch: {
|
|
83
|
+
front_matter: {
|
|
84
|
+
gate_retry_count: retryCount,
|
|
85
|
+
last_retry_at: new Date().toISOString()
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
shouldEscalate(retryCount) {
|
|
91
|
+
const reaction = this.policy.gate_failed ?? DEFAULT_GATE_FAILED_REACTION;
|
|
92
|
+
return retryCount >= reaction.escalate_after;
|
|
93
|
+
}
|
|
94
|
+
async notifyEscalation(featureId, ctx) {
|
|
95
|
+
if (!this.notifier) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
await this.notifier.notify('gate_failed', {
|
|
99
|
+
feature_id: featureId,
|
|
100
|
+
message: `Gate '${ctx.gateName}' failed after ${ctx.retryCount} retries on feature '${featureId}'.`,
|
|
101
|
+
details: {
|
|
102
|
+
gate_name: ctx.gateName,
|
|
103
|
+
exit_code: ctx.exitCode,
|
|
104
|
+
retry_count: ctx.retryCount,
|
|
105
|
+
retry_delay_ms: this.retryDelayMs(),
|
|
106
|
+
max_retries: this.maxRetries(),
|
|
107
|
+
escalate_after: (this.policy.gate_failed ?? DEFAULT_GATE_FAILED_REACTION).escalate_after,
|
|
108
|
+
last_failure: ctx.failureHistory?.at(-1) ?? null,
|
|
109
|
+
failure_history: ctx.failureHistory ?? []
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=reactions-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactions-service.js","sourceRoot":"","sources":["../../../../../apps/control-plane/src/application/services/reactions-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AA4ChD,MAAM,4BAA4B,GAAuB;IACvD,OAAO,EAAE,KAAK;IACd,WAAW,EAAE,CAAC;IACd,MAAM,EAAE,aAAa;IACrB,cAAc,EAAE,CAAC;IACjB,cAAc,EAAE,KAAK;CACtB,CAAC;AAEF,MAAM,OAAO,gBAAgB;IACV,UAAU,CAAuB;IACjC,QAAQ,CAA8B;IACtC,MAAM,CAAkB;IAEzC,YAAY,YAA0C;QACpD,IAAI,CAAC,UAAU,GAAG,YAAY,CAAC,UAAU,CAAC;QAC1C,IAAI,CAAC,QAAQ,GAAG,YAAY,CAAC,QAAQ,CAAC;QACtC,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC,MAAM,I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c,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI;gBAChD,eAAe,EAAE,GAAG,CAAC,cAAc,IAAI,EAAE;aAC1C;SACF,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { detectPlanCollisions } from '../../core/collisions.js';
|
|
2
|
-
import { pathExists, stableHash } from '../../core/fs.js';
|
|
2
|
+
import { pathExists, readJson, stableHash } from '../../core/fs.js';
|
|
3
3
|
function normalizeSet(array) {
|
|
4
4
|
return [...new Set(array)].sort((a, b) => a.localeCompare(b));
|
|
5
5
|
}
|
|
@@ -55,13 +55,24 @@ export class ReportingService {
|
|
|
55
55
|
continue;
|
|
56
56
|
}
|
|
57
57
|
const state = await this.port.readState(featureId);
|
|
58
|
+
const costData = await readJson(this.port.featureCostPath(featureId), null);
|
|
58
59
|
features.push({
|
|
59
60
|
feature_id: featureId,
|
|
60
61
|
status: state.frontMatter.status,
|
|
62
|
+
branch: typeof state.frontMatter.worktree_branch === 'string'
|
|
63
|
+
? state.frontMatter.worktree_branch
|
|
64
|
+
: typeof state.frontMatter.branch === 'string'
|
|
65
|
+
? state.frontMatter.branch
|
|
66
|
+
: null,
|
|
61
67
|
locks: readHeldLocks(state.frontMatter),
|
|
62
68
|
gate_profile: state.frontMatter.gate_profile,
|
|
63
69
|
gates: state.frontMatter.gates,
|
|
64
|
-
|
|
70
|
+
pr: state.frontMatter.pr ?? null,
|
|
71
|
+
last_updated: state.frontMatter.last_updated,
|
|
72
|
+
activity_state: state.frontMatter.activity_state,
|
|
73
|
+
activity_last_event_at: state.frontMatter.activity_last_event_at,
|
|
74
|
+
activity_detected_via: state.frontMatter.activity_detected_via,
|
|
75
|
+
cost: costData ? { estimated_cost_usd: costData.estimated_cost_usd, tokens_used: costData.tokens_used } : null
|
|
65
76
|
});
|
|
66
77
|
}
|
|
67
78
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reporting-service.js","sourceRoot":"","sources":["../../../../../apps/control-plane/src/application/services/reporting-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"reporting-service.js","sourceRoot":"","sources":["../../../../../apps/control-plane/src/application/services/reporting-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAKpE,SAAS,YAAY,CAAC,KAAe;IACnC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,aAAa,CAAC,WAAsB;IAC3C,MAAM,KAAK,GAAG,WAAW,EAAE,KAAK,IAAI,OAAO,WAAW,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IACnG,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IACzD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,IAAa,EAAkB,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC;AAClF,CAAC;AAED,SAAS,0BAA0B,CAAC,UAAmB;IACrD,OAAO,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;AAChD,CAAC;AAcD,MAAM,OAAO,gBAAgB;IACV,IAAI,CAAuB;IAE5C,YAAY,IA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exSnapshot): Promise<void>;
|
|
29
|
+
readRunLease(): Promise<RuntimeSessionsSnapshot>;
|
|
30
|
+
writeRunLease(data: RuntimeSessionsSnapshot): Promise<void>;
|
|
29
31
|
normalizeRuntimeSessions(value: unknown, at?: string): RuntimeSessionsSnapshot;
|
|
30
32
|
isRunLeaseFresh(runtimeSessions: RuntimeSessionsSnapshot): boolean;
|
|
31
33
|
emptyRuntimeSessions(at?: string): RuntimeSessionsSnapshot;
|
|
@@ -21,8 +21,7 @@ export class RunLeaseService {
|
|
|
21
21
|
? input.provider_config_ref_hash
|
|
22
22
|
: stableHash('none');
|
|
23
23
|
return await this.port.withIndexLock(async () => {
|
|
24
|
-
const
|
|
25
|
-
const current = this.port.normalizeRuntimeSessions(index.runtime_sessions);
|
|
24
|
+
const current = this.port.normalizeRuntimeSessions(await this.port.readRunLease());
|
|
26
25
|
const hasLease = current.run_id !== 'none' && current.owner_instance_id !== 'none';
|
|
27
26
|
const fresh = hasLease && this.port.isRunLeaseFresh(current);
|
|
28
27
|
const sameOwner = current.run_id === input.run_id && current.owner_instance_id === input.owner_instance_id;
|
|
@@ -71,10 +70,7 @@ export class RunLeaseService {
|
|
|
71
70
|
claimed.orchestrator_session_id = 'unknown';
|
|
72
71
|
claimed.feature_sessions = {};
|
|
73
72
|
}
|
|
74
|
-
|
|
75
|
-
index.version += 1;
|
|
76
|
-
index.updated_at = nowIso();
|
|
77
|
-
await this.port.writeIndex(index);
|
|
73
|
+
await this.port.writeRunLease(claimed);
|
|
78
74
|
return {
|
|
79
75
|
data: {
|
|
80
76
|
runtime_sessions: claimed,
|
|
@@ -95,8 +91,7 @@ export class RunLeaseService {
|
|
|
95
91
|
}
|
|
96
92
|
const ttlMs = this.port.runLeaseTtlSeconds() * 1000;
|
|
97
93
|
return await this.port.withIndexLock(async () => {
|
|
98
|
-
const
|
|
99
|
-
const current = this.port.normalizeRuntimeSessions(index.runtime_sessions);
|
|
94
|
+
const current = this.port.normalizeRuntimeSessions(await this.port.readRunLease());
|
|
100
95
|
if (current.run_id !== runId || current.owner_instance_id !== ownerInstanceId) {
|
|
101
96
|
throw {
|
|
102
97
|
normalizedResponse: fail(ERROR_CODES.RUN_LEASE_NOT_OWNED, 'Cannot renew a run lease not owned by this instance', {
|
|
@@ -114,10 +109,7 @@ export class RunLeaseService {
|
|
|
114
109
|
last_heartbeat_at: nowIso(),
|
|
115
110
|
lease_expires_at: new Date(Date.now() + ttlMs).toISOString()
|
|
116
111
|
};
|
|
117
|
-
|
|
118
|
-
index.version += 1;
|
|
119
|
-
index.updated_at = nowIso();
|
|
120
|
-
await this.port.writeIndex(index);
|
|
112
|
+
await this.port.writeRunLease(updated);
|
|
121
113
|
return {
|
|
122
114
|
data: {
|
|
123
115
|
lease_expires_at: updated.lease_expires_at
|
|
@@ -127,15 +119,11 @@ export class RunLeaseService {
|
|
|
127
119
|
}
|
|
128
120
|
async releaseRunLease(runId, ownerInstanceId) {
|
|
129
121
|
return await this.port.withIndexLock(async () => {
|
|
130
|
-
const
|
|
131
|
-
const current = this.port.normalizeRuntimeSessions(index.runtime_sessions);
|
|
122
|
+
const current = this.port.normalizeRuntimeSessions(await this.port.readRunLease());
|
|
132
123
|
if (current.run_id !== runId || current.owner_instance_id !== ownerInstanceId) {
|
|
133
124
|
return { data: { released: false } };
|
|
134
125
|
}
|
|
135
|
-
|
|
136
|
-
index.version += 1;
|
|
137
|
-
index.updated_at = nowIso();
|
|
138
|
-
await this.port.writeIndex(index);
|
|
126
|
+
await this.port.writeRunLease(this.port.emptyRuntimeSessions(nowIso()));
|
|
139
127
|
return { data: { released: true } };
|
|
140
128
|
});
|
|
141
129
|
}
|
|
@@ -150,8 +138,7 @@ export class RunLeaseService {
|
|
|
150
138
|
};
|
|
151
139
|
}
|
|
152
140
|
return await this.port.withIndexLock(async () => {
|
|
153
|
-
const
|
|
154
|
-
const current = this.port.normalizeRuntimeSessions(index.runtime_sessions);
|
|
141
|
+
const current = this.port.normalizeRuntimeSessions(await this.port.readRunLease());
|
|
155
142
|
if (current.run_id !== run_id || current.owner_instance_id !== owner_instance_id) {
|
|
156
143
|
throw {
|
|
157
144
|
normalizedResponse: fail(ERROR_CODES.RUN_LEASE_NOT_OWNED, 'Cannot update orchestrator session without run ownership', {
|
|
@@ -172,10 +159,7 @@ export class RunLeaseService {
|
|
|
172
159
|
orchestrator_session_id,
|
|
173
160
|
orchestrator_epoch: nextEpoch
|
|
174
161
|
};
|
|
175
|
-
|
|
176
|
-
index.version += 1;
|
|
177
|
-
index.updated_at = nowIso();
|
|
178
|
-
await this.port.writeIndex(index);
|
|
162
|
+
await this.port.writeRunLease(updated);
|
|
179
163
|
return {
|
|
180
164
|
data: {
|
|
181
165
|
runtime_sessions: updated
|
|
@@ -186,8 +170,7 @@ export class RunLeaseService {
|
|
|
186
170
|
async updateFeatureSessionAssignment(params) {
|
|
187
171
|
const { run_id, owner_instance_id, feature_id, planner_session_id, builder_session_id, qa_session_id } = params;
|
|
188
172
|
return await this.port.withIndexLock(async () => {
|
|
189
|
-
const
|
|
190
|
-
const current = this.port.normalizeRuntimeSessions(index.runtime_sessions);
|
|
173
|
+
const current = this.port.normalizeRuntimeSessions(await this.port.readRunLease());
|
|
191
174
|
if (current.run_id !== run_id || current.owner_instance_id !== owner_instance_id) {
|
|
192
175
|
throw {
|
|
193
176
|
normalizedResponse: fail(ERROR_CODES.RUN_LEASE_NOT_OWNED, 'Cannot update feature sessions without run ownership', {
|
|
@@ -208,21 +191,17 @@ export class RunLeaseService {
|
|
|
208
191
|
qa_session_id
|
|
209
192
|
}
|
|
210
193
|
};
|
|
211
|
-
|
|
194
|
+
await this.port.writeRunLease({
|
|
212
195
|
...current,
|
|
213
196
|
feature_sessions: nextFeatureSessions
|
|
214
|
-
};
|
|
215
|
-
index.version += 1;
|
|
216
|
-
index.updated_at = nowIso();
|
|
217
|
-
await this.port.writeIndex(index);
|
|
197
|
+
});
|
|
218
198
|
return { data: { updated: true } };
|
|
219
199
|
});
|
|
220
200
|
}
|
|
221
201
|
async pruneFeatureSessionAssignments(params) {
|
|
222
202
|
const active = new Set(params.active_feature_ids);
|
|
223
203
|
return await this.port.withIndexLock(async () => {
|
|
224
|
-
const
|
|
225
|
-
const current = this.port.normalizeRuntimeSessions(index.runtime_sessions);
|
|
204
|
+
const current = this.port.normalizeRuntimeSessions(await this.port.readRunLease());
|
|
226
205
|
if (current.run_id !== params.run_id || current.owner_instance_id !== params.owner_instance_id) {
|
|
227
206
|
throw {
|
|
228
207
|
normalizedResponse: fail(ERROR_CODES.RUN_LEASE_NOT_OWNED, 'Cannot prune feature sessions without run ownership', {
|
|
@@ -247,13 +226,10 @@ export class RunLeaseService {
|
|
|
247
226
|
}
|
|
248
227
|
}
|
|
249
228
|
if (removed.length > 0) {
|
|
250
|
-
|
|
229
|
+
await this.port.writeRunLease({
|
|
251
230
|
...current,
|
|
252
231
|
feature_sessions: kept
|
|
253
|
-
};
|
|
254
|
-
index.version += 1;
|
|
255
|
-
index.updated_at = nowIso();
|
|
256
|
-
await this.port.writeIndex(index);
|
|
232
|
+
});
|
|
257
233
|
}
|
|
258
234
|
removed.sort((a, b) => a.localeCompare(b));
|
|
259
235
|
return { data: { removed } };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-lease-service.js","sourceRoot":"","sources":["../../../../../apps/control-plane/src/application/services/run-lease-service.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"run-lease-service.js","sourceRoot":"","sources":["../../../../../apps/control-plane/src/application/services/run-lease-service.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAA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