popeye-cli 1.9.5 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/CONTRIBUTING.md +15 -1
- package/README.md +57 -0
- package/cheatsheet.md +65 -0
- package/dist/cli/commands/debug-context.d.ts +64 -0
- package/dist/cli/commands/debug-context.d.ts.map +1 -0
- package/dist/cli/commands/debug-context.js +221 -0
- package/dist/cli/commands/debug-context.js.map +1 -0
- package/dist/cli/commands/debug-prompts.d.ts +25 -0
- package/dist/cli/commands/debug-prompts.d.ts.map +1 -0
- package/dist/cli/commands/debug-prompts.js +80 -0
- package/dist/cli/commands/debug-prompts.js.map +1 -0
- package/dist/cli/commands/debug.d.ts +68 -0
- package/dist/cli/commands/debug.d.ts.map +1 -0
- package/dist/cli/commands/debug.js +543 -0
- package/dist/cli/commands/debug.js.map +1 -0
- package/dist/cli/commands/index.d.ts +1 -0
- package/dist/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/index.js +1 -0
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/interactive.d.ts.map +1 -1
- package/dist/cli/interactive.js +25 -0
- package/dist/cli/interactive.js.map +1 -1
- package/dist/generators/all.d.ts.map +1 -1
- package/dist/generators/all.js +2 -0
- package/dist/generators/all.js.map +1 -1
- package/dist/generators/templates/database-docker.d.ts.map +1 -1
- package/dist/generators/templates/database-docker.js +10 -0
- package/dist/generators/templates/database-docker.js.map +1 -1
- package/dist/generators/templates/fullstack.d.ts +4 -1
- package/dist/generators/templates/fullstack.d.ts.map +1 -1
- package/dist/generators/templates/fullstack.js +6 -2
- package/dist/generators/templates/fullstack.js.map +1 -1
- package/dist/pipeline/artifact-manager.d.ts +47 -0
- package/dist/pipeline/artifact-manager.d.ts.map +1 -0
- package/dist/pipeline/artifact-manager.js +251 -0
- package/dist/pipeline/artifact-manager.js.map +1 -0
- package/dist/pipeline/artifact-validators.d.ts +29 -0
- package/dist/pipeline/artifact-validators.d.ts.map +1 -0
- package/dist/pipeline/artifact-validators.js +173 -0
- package/dist/pipeline/artifact-validators.js.map +1 -0
- package/dist/pipeline/change-request.d.ts +47 -0
- package/dist/pipeline/change-request.d.ts.map +1 -0
- package/dist/pipeline/change-request.js +91 -0
- package/dist/pipeline/change-request.js.map +1 -0
- package/dist/pipeline/check-runner.d.ts +47 -0
- package/dist/pipeline/check-runner.d.ts.map +1 -0
- package/dist/pipeline/check-runner.js +417 -0
- package/dist/pipeline/check-runner.js.map +1 -0
- package/dist/pipeline/command-resolver.d.ts +9 -0
- package/dist/pipeline/command-resolver.d.ts.map +1 -0
- package/dist/pipeline/command-resolver.js +140 -0
- package/dist/pipeline/command-resolver.js.map +1 -0
- package/dist/pipeline/consensus/consensus-runner.d.ts +44 -0
- package/dist/pipeline/consensus/consensus-runner.d.ts.map +1 -0
- package/dist/pipeline/consensus/consensus-runner.js +212 -0
- package/dist/pipeline/consensus/consensus-runner.js.map +1 -0
- package/dist/pipeline/constitution.d.ts +45 -0
- package/dist/pipeline/constitution.d.ts.map +1 -0
- package/dist/pipeline/constitution.js +82 -0
- package/dist/pipeline/constitution.js.map +1 -0
- package/dist/pipeline/gate-engine.d.ts +55 -0
- package/dist/pipeline/gate-engine.d.ts.map +1 -0
- package/dist/pipeline/gate-engine.js +270 -0
- package/dist/pipeline/gate-engine.js.map +1 -0
- package/dist/pipeline/index.d.ts +26 -0
- package/dist/pipeline/index.d.ts.map +1 -0
- package/dist/pipeline/index.js +35 -0
- package/dist/pipeline/index.js.map +1 -0
- package/dist/pipeline/migration.d.ts +15 -0
- package/dist/pipeline/migration.d.ts.map +1 -0
- package/dist/pipeline/migration.js +76 -0
- package/dist/pipeline/migration.js.map +1 -0
- package/dist/pipeline/orchestrator.d.ts +28 -0
- package/dist/pipeline/orchestrator.d.ts.map +1 -0
- package/dist/pipeline/orchestrator.js +238 -0
- package/dist/pipeline/orchestrator.js.map +1 -0
- package/dist/pipeline/packets/audit-report-builder.d.ts +11 -0
- package/dist/pipeline/packets/audit-report-builder.d.ts.map +1 -0
- package/dist/pipeline/packets/audit-report-builder.js +32 -0
- package/dist/pipeline/packets/audit-report-builder.js.map +1 -0
- package/dist/pipeline/packets/consensus-packet-builder.d.ts +35 -0
- package/dist/pipeline/packets/consensus-packet-builder.d.ts.map +1 -0
- package/dist/pipeline/packets/consensus-packet-builder.js +80 -0
- package/dist/pipeline/packets/consensus-packet-builder.js.map +1 -0
- package/dist/pipeline/packets/index.d.ts +12 -0
- package/dist/pipeline/packets/index.d.ts.map +1 -0
- package/dist/pipeline/packets/index.js +8 -0
- package/dist/pipeline/packets/index.js.map +1 -0
- package/dist/pipeline/packets/plan-packet-builder.d.ts +21 -0
- package/dist/pipeline/packets/plan-packet-builder.d.ts.map +1 -0
- package/dist/pipeline/packets/plan-packet-builder.js +27 -0
- package/dist/pipeline/packets/plan-packet-builder.js.map +1 -0
- package/dist/pipeline/packets/rca-packet-builder.d.ts +19 -0
- package/dist/pipeline/packets/rca-packet-builder.d.ts.map +1 -0
- package/dist/pipeline/packets/rca-packet-builder.js +22 -0
- package/dist/pipeline/packets/rca-packet-builder.js.map +1 -0
- package/dist/pipeline/phases/architecture.d.ts +7 -0
- package/dist/pipeline/phases/architecture.d.ts.map +1 -0
- package/dist/pipeline/phases/architecture.js +60 -0
- package/dist/pipeline/phases/architecture.js.map +1 -0
- package/dist/pipeline/phases/audit.d.ts +8 -0
- package/dist/pipeline/phases/audit.d.ts.map +1 -0
- package/dist/pipeline/phases/audit.js +144 -0
- package/dist/pipeline/phases/audit.js.map +1 -0
- package/dist/pipeline/phases/consensus-architecture.d.ts +7 -0
- package/dist/pipeline/phases/consensus-architecture.d.ts.map +1 -0
- package/dist/pipeline/phases/consensus-architecture.js +84 -0
- package/dist/pipeline/phases/consensus-architecture.js.map +1 -0
- package/dist/pipeline/phases/consensus-master-plan.d.ts +7 -0
- package/dist/pipeline/phases/consensus-master-plan.d.ts.map +1 -0
- package/dist/pipeline/phases/consensus-master-plan.js +81 -0
- package/dist/pipeline/phases/consensus-master-plan.js.map +1 -0
- package/dist/pipeline/phases/consensus-role-plans.d.ts +7 -0
- package/dist/pipeline/phases/consensus-role-plans.d.ts.map +1 -0
- package/dist/pipeline/phases/consensus-role-plans.js +85 -0
- package/dist/pipeline/phases/consensus-role-plans.js.map +1 -0
- package/dist/pipeline/phases/done.d.ts +7 -0
- package/dist/pipeline/phases/done.d.ts.map +1 -0
- package/dist/pipeline/phases/done.js +45 -0
- package/dist/pipeline/phases/done.js.map +1 -0
- package/dist/pipeline/phases/implementation.d.ts +8 -0
- package/dist/pipeline/phases/implementation.d.ts.map +1 -0
- package/dist/pipeline/phases/implementation.js +42 -0
- package/dist/pipeline/phases/implementation.js.map +1 -0
- package/dist/pipeline/phases/index.d.ts +20 -0
- package/dist/pipeline/phases/index.d.ts.map +1 -0
- package/dist/pipeline/phases/index.js +19 -0
- package/dist/pipeline/phases/index.js.map +1 -0
- package/dist/pipeline/phases/intake.d.ts +8 -0
- package/dist/pipeline/phases/intake.d.ts.map +1 -0
- package/dist/pipeline/phases/intake.js +40 -0
- package/dist/pipeline/phases/intake.js.map +1 -0
- package/dist/pipeline/phases/phase-context.d.ts +30 -0
- package/dist/pipeline/phases/phase-context.d.ts.map +1 -0
- package/dist/pipeline/phases/phase-context.js +33 -0
- package/dist/pipeline/phases/phase-context.js.map +1 -0
- package/dist/pipeline/phases/production-gate.d.ts +8 -0
- package/dist/pipeline/phases/production-gate.d.ts.map +1 -0
- package/dist/pipeline/phases/production-gate.js +84 -0
- package/dist/pipeline/phases/production-gate.js.map +1 -0
- package/dist/pipeline/phases/qa-validation.d.ts +7 -0
- package/dist/pipeline/phases/qa-validation.d.ts.map +1 -0
- package/dist/pipeline/phases/qa-validation.js +50 -0
- package/dist/pipeline/phases/qa-validation.js.map +1 -0
- package/dist/pipeline/phases/recovery-loop.d.ts +7 -0
- package/dist/pipeline/phases/recovery-loop.d.ts.map +1 -0
- package/dist/pipeline/phases/recovery-loop.js +91 -0
- package/dist/pipeline/phases/recovery-loop.js.map +1 -0
- package/dist/pipeline/phases/review.d.ts +8 -0
- package/dist/pipeline/phases/review.d.ts.map +1 -0
- package/dist/pipeline/phases/review.js +127 -0
- package/dist/pipeline/phases/review.js.map +1 -0
- package/dist/pipeline/phases/role-planning.d.ts +7 -0
- package/dist/pipeline/phases/role-planning.d.ts.map +1 -0
- package/dist/pipeline/phases/role-planning.js +75 -0
- package/dist/pipeline/phases/role-planning.js.map +1 -0
- package/dist/pipeline/phases/stuck.d.ts +7 -0
- package/dist/pipeline/phases/stuck.d.ts.map +1 -0
- package/dist/pipeline/phases/stuck.js +51 -0
- package/dist/pipeline/phases/stuck.js.map +1 -0
- package/dist/pipeline/repo-snapshot.d.ts +24 -0
- package/dist/pipeline/repo-snapshot.d.ts.map +1 -0
- package/dist/pipeline/repo-snapshot.js +343 -0
- package/dist/pipeline/repo-snapshot.js.map +1 -0
- package/dist/pipeline/role-execution-adapter.d.ts +59 -0
- package/dist/pipeline/role-execution-adapter.d.ts.map +1 -0
- package/dist/pipeline/role-execution-adapter.js +159 -0
- package/dist/pipeline/role-execution-adapter.js.map +1 -0
- package/dist/pipeline/skill-loader.d.ts +34 -0
- package/dist/pipeline/skill-loader.d.ts.map +1 -0
- package/dist/pipeline/skill-loader.js +156 -0
- package/dist/pipeline/skill-loader.js.map +1 -0
- package/dist/pipeline/skills/defaults.d.ts +16 -0
- package/dist/pipeline/skills/defaults.d.ts.map +1 -0
- package/dist/pipeline/skills/defaults.js +189 -0
- package/dist/pipeline/skills/defaults.js.map +1 -0
- package/dist/pipeline/type-defs/artifacts.d.ts +202 -0
- package/dist/pipeline/type-defs/artifacts.d.ts.map +1 -0
- package/dist/pipeline/type-defs/artifacts.js +66 -0
- package/dist/pipeline/type-defs/artifacts.js.map +1 -0
- package/dist/pipeline/type-defs/audit.d.ts +256 -0
- package/dist/pipeline/type-defs/audit.d.ts.map +1 -0
- package/dist/pipeline/type-defs/audit.js +54 -0
- package/dist/pipeline/type-defs/audit.js.map +1 -0
- package/dist/pipeline/type-defs/checks.d.ts +81 -0
- package/dist/pipeline/type-defs/checks.d.ts.map +1 -0
- package/dist/pipeline/type-defs/checks.js +38 -0
- package/dist/pipeline/type-defs/checks.js.map +1 -0
- package/dist/pipeline/type-defs/enums.d.ts +43 -0
- package/dist/pipeline/type-defs/enums.d.ts.map +1 -0
- package/dist/pipeline/type-defs/enums.js +55 -0
- package/dist/pipeline/type-defs/enums.js.map +1 -0
- package/dist/pipeline/type-defs/index.d.ts +12 -0
- package/dist/pipeline/type-defs/index.d.ts.map +1 -0
- package/dist/pipeline/type-defs/index.js +12 -0
- package/dist/pipeline/type-defs/index.js.map +1 -0
- package/dist/pipeline/type-defs/packets.d.ts +806 -0
- package/dist/pipeline/type-defs/packets.d.ts.map +1 -0
- package/dist/pipeline/type-defs/packets.js +109 -0
- package/dist/pipeline/type-defs/packets.js.map +1 -0
- package/dist/pipeline/type-defs/snapshot.d.ts +52 -0
- package/dist/pipeline/type-defs/snapshot.d.ts.map +1 -0
- package/dist/pipeline/type-defs/snapshot.js +35 -0
- package/dist/pipeline/type-defs/snapshot.js.map +1 -0
- package/dist/pipeline/type-defs/state.d.ts +449 -0
- package/dist/pipeline/type-defs/state.d.ts.map +1 -0
- package/dist/pipeline/type-defs/state.js +88 -0
- package/dist/pipeline/type-defs/state.js.map +1 -0
- package/dist/pipeline/types.d.ts +16 -0
- package/dist/pipeline/types.d.ts.map +1 -0
- package/dist/pipeline/types.js +16 -0
- package/dist/pipeline/types.js.map +1 -0
- package/dist/types/audit.d.ts +6 -6
- package/dist/workflow/index.d.ts.map +1 -1
- package/dist/workflow/index.js +48 -0
- package/dist/workflow/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/ARBITRATOR.md +137 -0
- package/skills/ARCHITECT.md +167 -0
- package/skills/AUDITOR.md +128 -0
- package/skills/AUDIT_REPORT_SCHEMA.md +20 -0
- package/skills/BACKEND_PROGRAMMER.md +95 -0
- package/skills/CONSENSUS_PACKET_SCHEMA.md +166 -0
- package/skills/DB_EXPERT.md +106 -0
- package/skills/DEBUGGER.md +286 -0
- package/skills/DISPATCHER.md +157 -0
- package/skills/FRONTEND_PROGRAMMER.md +84 -0
- package/skills/JOURNALIST.md +247 -0
- package/skills/MARKETING_EXPERT.md +23 -0
- package/skills/PHASE_GATE_ENGINE_SPEC.md +171 -0
- package/skills/PLAN_PACKET_SCHEMA.md +222 -0
- package/skills/POPEYE_CONSTITUTION.md +177 -0
- package/skills/POPEYE_FULL_AUTONOMY_PIPELINE.md +537 -0
- package/skills/PRODUCTION_READINESS_SCHEMA.md +19 -0
- package/skills/QA_TESTER.md +40 -0
- package/skills/RCA_PACKET_SCHEMA.md +22 -0
- package/skills/RELEASE_MANAGER.md +60 -0
- package/skills/REVIEWER.md +133 -0
- package/skills/SOCIAL_EXPERT.md +22 -0
- package/skills/UI_UX_SPECIALIST.md +22 -0
- package/skills/WEBSITE_PROGRAMMER.md +37 -0
- package/src/cli/commands/debug-context.ts +265 -0
- package/src/cli/commands/debug-prompts.ts +91 -0
- package/src/cli/commands/debug.ts +662 -0
- package/src/cli/commands/index.ts +1 -0
- package/src/cli/index.ts +2 -0
- package/src/cli/interactive.ts +27 -0
- package/src/generators/all.ts +2 -0
- package/src/generators/templates/database-docker.ts +10 -0
- package/src/generators/templates/fullstack.ts +6 -2
- package/src/pipeline/artifact-manager.ts +339 -0
- package/src/pipeline/artifact-validators.ts +224 -0
- package/src/pipeline/change-request.ts +119 -0
- package/src/pipeline/check-runner.ts +504 -0
- package/src/pipeline/command-resolver.ts +168 -0
- package/src/pipeline/consensus/consensus-runner.ts +317 -0
- package/src/pipeline/constitution.ts +109 -0
- package/src/pipeline/gate-engine.ts +347 -0
- package/src/pipeline/index.ts +82 -0
- package/src/pipeline/migration.ts +91 -0
- package/src/pipeline/orchestrator.ts +314 -0
- package/src/pipeline/packets/audit-report-builder.ts +47 -0
- package/src/pipeline/packets/consensus-packet-builder.ts +112 -0
- package/src/pipeline/packets/index.ts +15 -0
- package/src/pipeline/packets/plan-packet-builder.ts +52 -0
- package/src/pipeline/packets/rca-packet-builder.ts +38 -0
- package/src/pipeline/phases/architecture.ts +73 -0
- package/src/pipeline/phases/audit.ts +193 -0
- package/src/pipeline/phases/consensus-architecture.ts +104 -0
- package/src/pipeline/phases/consensus-master-plan.ts +100 -0
- package/src/pipeline/phases/consensus-role-plans.ts +105 -0
- package/src/pipeline/phases/done.ts +68 -0
- package/src/pipeline/phases/implementation.ts +48 -0
- package/src/pipeline/phases/index.ts +21 -0
- package/src/pipeline/phases/intake.ts +54 -0
- package/src/pipeline/phases/phase-context.ts +86 -0
- package/src/pipeline/phases/production-gate.ts +113 -0
- package/src/pipeline/phases/qa-validation.ts +63 -0
- package/src/pipeline/phases/recovery-loop.ts +118 -0
- package/src/pipeline/phases/review.ts +149 -0
- package/src/pipeline/phases/role-planning.ts +92 -0
- package/src/pipeline/phases/stuck.ts +62 -0
- package/src/pipeline/repo-snapshot.ts +395 -0
- package/src/pipeline/role-execution-adapter.ts +238 -0
- package/src/pipeline/skill-loader.ts +192 -0
- package/src/pipeline/skills/defaults.ts +215 -0
- package/src/pipeline/type-defs/artifacts.ts +81 -0
- package/src/pipeline/type-defs/audit.ts +67 -0
- package/src/pipeline/type-defs/checks.ts +47 -0
- package/src/pipeline/type-defs/enums.ts +62 -0
- package/src/pipeline/type-defs/index.ts +12 -0
- package/src/pipeline/type-defs/packets.ts +131 -0
- package/src/pipeline/type-defs/snapshot.ts +55 -0
- package/src/pipeline/type-defs/state.ts +165 -0
- package/src/pipeline/types.ts +16 -0
- package/src/workflow/index.ts +48 -0
- package/tests/cli/commands/debug.test.ts +376 -0
- package/tests/pipeline/artifact-manager.test.ts +183 -0
- package/tests/pipeline/artifact-validators.test.ts +207 -0
- package/tests/pipeline/change-request.test.ts +180 -0
- package/tests/pipeline/check-runner.test.ts +157 -0
- package/tests/pipeline/command-resolver.test.ts +159 -0
- package/tests/pipeline/consensus-runner.test.ts +206 -0
- package/tests/pipeline/consensus-scoring.test.ts +163 -0
- package/tests/pipeline/constitution.test.ts +122 -0
- package/tests/pipeline/gate-engine.test.ts +195 -0
- package/tests/pipeline/migration.test.ts +133 -0
- package/tests/pipeline/orchestrator.test.ts +614 -0
- package/tests/pipeline/packets/builders.test.ts +347 -0
- package/tests/pipeline/repo-snapshot.test.ts +189 -0
- package/tests/pipeline/role-execution-adapter.test.ts +299 -0
- package/tests/pipeline/skill-loader.test.ts +186 -0
- package/tests/pipeline/start-env-checks.test.ts +123 -0
- package/tests/pipeline/types.test.ts +156 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pipeline Orchestrator — top-level loop driving pipeline from any phase
|
|
3
|
+
* to completion. Implements deterministic transition logic (P0-A).
|
|
4
|
+
*
|
|
5
|
+
* Key rule: requires_phase_rewind_to ONLY takes effect after RECOVERY_LOOP
|
|
6
|
+
* completes successfully. Any failure from any non-recovery phase always
|
|
7
|
+
* goes to RECOVERY_LOOP first.
|
|
8
|
+
*
|
|
9
|
+
* v1.1: Constitution verification, CR-based phase routing, gateResult merge,
|
|
10
|
+
* and RCA rewind support.
|
|
11
|
+
*/
|
|
12
|
+
import { readFileSync, existsSync } from 'node:fs';
|
|
13
|
+
import { join } from 'node:path';
|
|
14
|
+
import { createDefaultPipelineState } from './types.js';
|
|
15
|
+
import { createGateEngine } from './gate-engine.js';
|
|
16
|
+
import { createArtifactManager } from './artifact-manager.js';
|
|
17
|
+
import { createSkillLoader } from './skill-loader.js';
|
|
18
|
+
import { createConsensusRunner } from './consensus/consensus-runner.js';
|
|
19
|
+
import { verifyConstitution } from './constitution.js';
|
|
20
|
+
import { runIntake, runConsensusMasterPlan, runArchitecture, runConsensusArchitecture, runRolePlanning, runConsensusRolePlans, runImplementation, runQaValidation, runReview, runAudit, runProductionGate, runRecoveryLoop, runDone, runStuck, } from './phases/index.js';
|
|
21
|
+
// ─── Phase Dispatch Map ──────────────────────────────────
|
|
22
|
+
const PHASE_HANDLERS = {
|
|
23
|
+
INTAKE: runIntake,
|
|
24
|
+
CONSENSUS_MASTER_PLAN: runConsensusMasterPlan,
|
|
25
|
+
ARCHITECTURE: runArchitecture,
|
|
26
|
+
CONSENSUS_ARCHITECTURE: runConsensusArchitecture,
|
|
27
|
+
ROLE_PLANNING: runRolePlanning,
|
|
28
|
+
CONSENSUS_ROLE_PLANS: runConsensusRolePlans,
|
|
29
|
+
IMPLEMENTATION: runImplementation,
|
|
30
|
+
QA_VALIDATION: runQaValidation,
|
|
31
|
+
REVIEW: runReview,
|
|
32
|
+
AUDIT: runAudit,
|
|
33
|
+
PRODUCTION_GATE: runProductionGate,
|
|
34
|
+
RECOVERY_LOOP: runRecoveryLoop,
|
|
35
|
+
DONE: runDone,
|
|
36
|
+
STUCK: runStuck,
|
|
37
|
+
};
|
|
38
|
+
/** Phases after which we check for pending CRs */
|
|
39
|
+
const CR_CHECK_PHASES = new Set(['REVIEW', 'AUDIT']);
|
|
40
|
+
// ─── Orchestrator ────────────────────────────────────────
|
|
41
|
+
/** Run the full pipeline from current phase to completion */
|
|
42
|
+
export async function runPipeline(options) {
|
|
43
|
+
const { projectDir, state, consensusConfig, onPhaseStart, onPhaseComplete, onProgress, } = options;
|
|
44
|
+
// Initialize pipeline state if needed
|
|
45
|
+
const pipeline = state.pipeline
|
|
46
|
+
?? createDefaultPipelineState();
|
|
47
|
+
// Create context dependencies
|
|
48
|
+
const gateEngine = createGateEngine();
|
|
49
|
+
const artifactManager = createArtifactManager(projectDir);
|
|
50
|
+
const skillLoader = createSkillLoader(projectDir);
|
|
51
|
+
const consensusRunner = createConsensusRunner(projectDir, consensusConfig);
|
|
52
|
+
// Ensure docs structure
|
|
53
|
+
artifactManager.ensureDocsStructure();
|
|
54
|
+
const context = {
|
|
55
|
+
state,
|
|
56
|
+
pipeline,
|
|
57
|
+
projectDir,
|
|
58
|
+
skillLoader,
|
|
59
|
+
artifactManager,
|
|
60
|
+
gateEngine,
|
|
61
|
+
consensusRunner,
|
|
62
|
+
};
|
|
63
|
+
let phase = pipeline.pipelinePhase;
|
|
64
|
+
let failedPhase = null;
|
|
65
|
+
// ─── Main Loop ───────────────────────────────────────
|
|
66
|
+
while (phase !== 'DONE' && phase !== 'STUCK') {
|
|
67
|
+
onPhaseStart?.(phase);
|
|
68
|
+
onProgress?.(`Pipeline phase: ${phase}`);
|
|
69
|
+
// Execute the current phase
|
|
70
|
+
const handler = PHASE_HANDLERS[phase];
|
|
71
|
+
if (!handler) {
|
|
72
|
+
return {
|
|
73
|
+
success: false,
|
|
74
|
+
finalPhase: phase,
|
|
75
|
+
artifacts: pipeline.artifacts,
|
|
76
|
+
recoveryIterations: pipeline.recoveryCount,
|
|
77
|
+
error: `No handler for phase: ${phase}`,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
let result;
|
|
81
|
+
try {
|
|
82
|
+
result = await handler(context);
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
result = {
|
|
86
|
+
phase,
|
|
87
|
+
success: false,
|
|
88
|
+
artifacts: [],
|
|
89
|
+
message: 'Phase handler threw an exception',
|
|
90
|
+
error: err instanceof Error ? err.message : String(err),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
onPhaseComplete?.(phase, result);
|
|
94
|
+
// v1.1: Verify constitution integrity before evaluating gate
|
|
95
|
+
const constitutionCheck = verifyConstitution(pipeline, projectDir);
|
|
96
|
+
// Evaluate gate with constitution verification result
|
|
97
|
+
const gateResult = gateEngine.evaluateGate(phase, pipeline, {
|
|
98
|
+
constitutionValid: constitutionCheck.valid,
|
|
99
|
+
constitutionReason: constitutionCheck.reason,
|
|
100
|
+
});
|
|
101
|
+
// v1.1: Merge gate result with any pre-existing phase data (preserves consensus scores)
|
|
102
|
+
mergeGateResult(pipeline, phase, gateResult);
|
|
103
|
+
if (gateResult.pass) {
|
|
104
|
+
// ─── PASS ────────────────────────────────────────
|
|
105
|
+
// v1.1: Check for pending CRs after REVIEW/AUDIT — route to consensus before continuing
|
|
106
|
+
if (CR_CHECK_PHASES.has(phase)) {
|
|
107
|
+
const crRoute = getNextCRRoute(pipeline);
|
|
108
|
+
if (crRoute) {
|
|
109
|
+
onProgress?.(`CR ${crRoute.cr_id} routing to ${crRoute.target_phase}`);
|
|
110
|
+
phase = crRoute.target_phase;
|
|
111
|
+
pipeline.pipelinePhase = phase;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (phase === 'RECOVERY_LOOP') {
|
|
116
|
+
// Recovery succeeded. RCA may specify rewind target.
|
|
117
|
+
const rca = getLatestRCA(pipeline, projectDir);
|
|
118
|
+
if (rca?.requires_phase_rewind_to) {
|
|
119
|
+
phase = rca.requires_phase_rewind_to;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
// Retest the phase that failed
|
|
123
|
+
phase = failedPhase ?? 'QA_VALIDATION';
|
|
124
|
+
}
|
|
125
|
+
failedPhase = null;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
// Normal progression
|
|
129
|
+
phase = gateEngine.getNextPhase(phase, gateResult);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
// ─── FAIL ────────────────────────────────────────
|
|
134
|
+
if (pipeline.recoveryCount >= pipeline.maxRecoveryIterations) {
|
|
135
|
+
phase = 'STUCK';
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
failedPhase = phase;
|
|
139
|
+
pipeline.failedPhase = phase;
|
|
140
|
+
phase = 'RECOVERY_LOOP';
|
|
141
|
+
pipeline.recoveryCount++;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
// Update pipeline phase in state
|
|
145
|
+
pipeline.pipelinePhase = phase;
|
|
146
|
+
onProgress?.(`Transitioning to: ${phase}`);
|
|
147
|
+
}
|
|
148
|
+
// ─── Terminal State ────────────────────────────────────
|
|
149
|
+
// Run the terminal phase handler (DONE or STUCK)
|
|
150
|
+
if (phase === 'DONE' || phase === 'STUCK') {
|
|
151
|
+
const terminalHandler = PHASE_HANDLERS[phase];
|
|
152
|
+
if (terminalHandler) {
|
|
153
|
+
try {
|
|
154
|
+
await terminalHandler(context);
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
// Best-effort for terminal phases
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
success: phase === 'DONE',
|
|
163
|
+
finalPhase: phase,
|
|
164
|
+
artifacts: pipeline.artifacts,
|
|
165
|
+
recoveryIterations: pipeline.recoveryCount,
|
|
166
|
+
error: phase !== 'DONE'
|
|
167
|
+
? `Pipeline stuck after ${pipeline.recoveryCount} recovery iterations`
|
|
168
|
+
: undefined,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
/** Resume pipeline from saved state */
|
|
172
|
+
export async function resumePipeline(options) {
|
|
173
|
+
// Resume is the same as run — it picks up from pipeline.pipelinePhase
|
|
174
|
+
return runPipeline(options);
|
|
175
|
+
}
|
|
176
|
+
// ─── Helpers ─────────────────────────────────────────────
|
|
177
|
+
/**
|
|
178
|
+
* Merge gate engine result with existing phase data in gateResults.
|
|
179
|
+
* Preserves score/consensusScore stored by consensus phase handlers
|
|
180
|
+
* while updating pass/blockers from the gate engine.
|
|
181
|
+
*/
|
|
182
|
+
function mergeGateResult(pipeline, phase, gateResult) {
|
|
183
|
+
const existing = pipeline.gateResults[phase];
|
|
184
|
+
if (existing?.score !== undefined || existing?.consensusScore !== undefined) {
|
|
185
|
+
// Preserve consensus scores from the phase handler
|
|
186
|
+
pipeline.gateResults[phase] = {
|
|
187
|
+
...gateResult,
|
|
188
|
+
score: existing.score ?? gateResult.score,
|
|
189
|
+
consensusScore: existing.consensusScore ?? gateResult.consensusScore,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
pipeline.gateResults[phase] = gateResult;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Find the next pending change request that needs routing.
|
|
198
|
+
* Returns the first 'proposed' CR and marks it as 'approved' (routed).
|
|
199
|
+
*/
|
|
200
|
+
function getNextCRRoute(pipeline) {
|
|
201
|
+
const pending = pipeline.pendingChangeRequests;
|
|
202
|
+
if (!pending)
|
|
203
|
+
return undefined;
|
|
204
|
+
const nextCR = pending.find((cr) => cr.status === 'proposed');
|
|
205
|
+
if (!nextCR)
|
|
206
|
+
return undefined;
|
|
207
|
+
// Mark as approved (it has been routed to the consensus phase)
|
|
208
|
+
nextCR.status = 'approved';
|
|
209
|
+
return {
|
|
210
|
+
cr_id: nextCR.cr_id,
|
|
211
|
+
target_phase: nextCR.target_phase,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Read the latest RCA packet from stored artifacts.
|
|
216
|
+
* Parses the JSON artifact file to extract rewind targets.
|
|
217
|
+
*/
|
|
218
|
+
function getLatestRCA(pipeline, projectDir) {
|
|
219
|
+
const rcaArtifacts = pipeline.artifacts
|
|
220
|
+
.filter((a) => a.type === 'rca_report' && a.content_type === 'json')
|
|
221
|
+
.sort((a, b) => b.timestamp.localeCompare(a.timestamp));
|
|
222
|
+
if (rcaArtifacts.length === 0)
|
|
223
|
+
return undefined;
|
|
224
|
+
// Read the latest RCA artifact from disk
|
|
225
|
+
const latest = rcaArtifacts[0];
|
|
226
|
+
const rcaPath = join(projectDir, latest.path);
|
|
227
|
+
if (!existsSync(rcaPath))
|
|
228
|
+
return undefined;
|
|
229
|
+
try {
|
|
230
|
+
const content = readFileSync(rcaPath, 'utf-8');
|
|
231
|
+
const parsed = JSON.parse(content);
|
|
232
|
+
return parsed;
|
|
233
|
+
}
|
|
234
|
+
catch {
|
|
235
|
+
return undefined;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
//# sourceMapping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,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audit Report Builder — constructs structured AuditReports
|
|
3
|
+
* with auto-computed status, risk score, and recovery flag (P2-1).
|
|
4
|
+
*/
|
|
5
|
+
import type { ArtifactRef, AuditFinding, AuditReport } from '../types.js';
|
|
6
|
+
export interface BuildAuditReportArgs {
|
|
7
|
+
repoSnapshot: ArtifactRef;
|
|
8
|
+
findings: AuditFinding[];
|
|
9
|
+
}
|
|
10
|
+
export declare function buildAuditReport(args: BuildAuditReportArgs): AuditReport;
|
|
11
|
+
//# sourceMappingURL=audit-report-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-report-builder.d.ts","sourceRoot":"","sources":["../../../src/pipeline/packets/audit-report-builder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1E,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,WAAW,CAAC;IAC1B,QAAQ,EAAE,YAAY,EAAE,CAAC;CAC1B;AAUD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,oBAAoB,GAAG,WAAW,CAwBxE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audit Report Builder — constructs structured AuditReports
|
|
3
|
+
* with auto-computed status, risk score, and recovery flag (P2-1).
|
|
4
|
+
*/
|
|
5
|
+
import { randomUUID } from 'node:crypto';
|
|
6
|
+
/** Severity weights for risk score calculation */
|
|
7
|
+
const SEVERITY_WEIGHTS = {
|
|
8
|
+
P0: 40,
|
|
9
|
+
P1: 20,
|
|
10
|
+
P2: 8,
|
|
11
|
+
P3: 2,
|
|
12
|
+
};
|
|
13
|
+
export function buildAuditReport(args) {
|
|
14
|
+
const { repoSnapshot, findings } = args;
|
|
15
|
+
const hasBlockingFindings = findings.some((f) => f.blocking);
|
|
16
|
+
const overallStatus = hasBlockingFindings ? 'FAIL' : 'PASS';
|
|
17
|
+
// Risk score: sum of severity weights, capped at 100
|
|
18
|
+
const rawScore = findings.reduce((sum, f) => sum + (SEVERITY_WEIGHTS[f.severity] ?? 0), 0);
|
|
19
|
+
const systemRiskScore = Math.min(100, rawScore);
|
|
20
|
+
// Recovery needed if any blocking P0/P1 findings
|
|
21
|
+
const recoveryRequired = findings.some((f) => f.blocking && (f.severity === 'P0' || f.severity === 'P1'));
|
|
22
|
+
return {
|
|
23
|
+
audit_id: randomUUID(),
|
|
24
|
+
timestamp: new Date().toISOString(),
|
|
25
|
+
repo_snapshot: repoSnapshot,
|
|
26
|
+
overall_status: overallStatus,
|
|
27
|
+
findings,
|
|
28
|
+
system_risk_score: systemRiskScore,
|
|
29
|
+
recovery_required: recoveryRequired,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=audit-report-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-report-builder.js","sourceRoot":"","sources":["../../../src/pipeline/packets/audit-report-builder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AASzC,kDAAkD;AAClD,MAAM,gBAAgB,GAA2B;IAC/C,EAAE,EAAE,EAAE;IACN,EAAE,EAAE,EAAE;IACN,EAAE,EAAE,CAAC;IACL,EAAE,EAAE,CAAC;CACN,CAAC;AAEF,MAAM,UAAU,gBAAgB,CAAC,IAA0B;IACzD,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAExC,MAAM,mBAAmB,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC7D,MAAM,aAAa,GAAG,mBAAmB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;IAE5D,qDAAqD;IACrD,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3F,MAAM,eAAe,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAEhD,iDAAiD;IACjD,MAAM,gBAAgB,GAAG,QAAQ,CAAC,IAAI,CACpC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,QAAQ,KAAK,IAAI,IAAI,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC,CAClE,CAAC;IAEF,OAAO;QACL,QAAQ,EAAE,UAAU,EAAE;QACtB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,aAAa,EAAE,YAAY;QAC3B,cAAc,EAAE,aAAa;QAC7B,QAAQ;QACR,iBAAiB,EAAE,eAAe;QAClC,iBAAiB,EAAE,gBAAgB;KACpC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consensus Packet Builder — aggregates reviewer votes into a ConsensusPacket.
|
|
3
|
+
* Auto-computes consensus result (score, approval) and final status.
|
|
4
|
+
* v1.1: Added confidence-weighted scoring.
|
|
5
|
+
*/
|
|
6
|
+
import type { ArtifactRef, ReviewerVote, ConsensusPacket } from '../types.js';
|
|
7
|
+
export interface ConsensusRules {
|
|
8
|
+
threshold: number;
|
|
9
|
+
quorum: number;
|
|
10
|
+
min_reviewers: number;
|
|
11
|
+
}
|
|
12
|
+
export interface BuildConsensusPacketArgs {
|
|
13
|
+
planPacketRef: ArtifactRef;
|
|
14
|
+
votes: ReviewerVote[];
|
|
15
|
+
rules: ConsensusRules;
|
|
16
|
+
arbitratorResult?: {
|
|
17
|
+
decision: string;
|
|
18
|
+
merged_patch?: string;
|
|
19
|
+
artifact_ref?: ArtifactRef;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Compute both simple and confidence-weighted consensus scores.
|
|
24
|
+
*
|
|
25
|
+
* Simple score: approve count / total votes (backward compat).
|
|
26
|
+
* Weighted score: each vote's weight (APPROVE=1, CONDITIONAL=0.5, REJECT=0)
|
|
27
|
+
* multiplied by voter confidence, then averaged by total confidence.
|
|
28
|
+
* If any vote has blocking_issues, weighted_score is forced to 0.
|
|
29
|
+
*/
|
|
30
|
+
export declare function computeConsensusScore(votes: ReviewerVote[]): {
|
|
31
|
+
score: number;
|
|
32
|
+
weighted_score: number;
|
|
33
|
+
};
|
|
34
|
+
export declare function buildConsensusPacket(args: BuildConsensusPacketArgs): ConsensusPacket;
|
|
35
|
+
//# sourceMappingURL=consensus-packet-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consensus-packet-builder.d.ts","sourceRoot":"","sources":["../../../src/pipeline/packets/consensus-packet-builder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,eAAe,EAChB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,wBAAwB;IACvC,aAAa,EAAE,WAAW,CAAC;IAC3B,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,KAAK,EAAE,cAAc,CAAC;IACtB,gBAAgB,CAAC,EAAE;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,YAAY,CAAC,EAAE,WAAW,CAAC;KAC5B,CAAC;CACH;AASD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,YAAY,EAAE,GACpB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,CAwB3C;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,wBAAwB,GAAG,eAAe,CAqCpF"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consensus Packet Builder — aggregates reviewer votes into a ConsensusPacket.
|
|
3
|
+
* Auto-computes consensus result (score, approval) and final status.
|
|
4
|
+
* v1.1: Added confidence-weighted scoring.
|
|
5
|
+
*/
|
|
6
|
+
import { randomUUID } from 'node:crypto';
|
|
7
|
+
/** Vote weight mapping: APPROVE=1.0, CONDITIONAL=0.5, REJECT=0.0 */
|
|
8
|
+
const VOTE_WEIGHTS = {
|
|
9
|
+
'APPROVE': 1.0,
|
|
10
|
+
'CONDITIONAL': 0.5,
|
|
11
|
+
'REJECT': 0.0,
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Compute both simple and confidence-weighted consensus scores.
|
|
15
|
+
*
|
|
16
|
+
* Simple score: approve count / total votes (backward compat).
|
|
17
|
+
* Weighted score: each vote's weight (APPROVE=1, CONDITIONAL=0.5, REJECT=0)
|
|
18
|
+
* multiplied by voter confidence, then averaged by total confidence.
|
|
19
|
+
* If any vote has blocking_issues, weighted_score is forced to 0.
|
|
20
|
+
*/
|
|
21
|
+
export function computeConsensusScore(votes) {
|
|
22
|
+
if (votes.length === 0)
|
|
23
|
+
return { score: 0, weighted_score: 0 };
|
|
24
|
+
// Simple score (backward compat): approve ratio
|
|
25
|
+
const approvedCount = votes.filter((v) => v.vote === 'APPROVE').length;
|
|
26
|
+
const score = approvedCount / votes.length;
|
|
27
|
+
// Weighted score: confidence-weighted vote values
|
|
28
|
+
let totalWeight = 0;
|
|
29
|
+
let weightedSum = 0;
|
|
30
|
+
for (const v of votes) {
|
|
31
|
+
const w = v.confidence;
|
|
32
|
+
weightedSum += (VOTE_WEIGHTS[v.vote] ?? 0) * w;
|
|
33
|
+
totalWeight += w;
|
|
34
|
+
}
|
|
35
|
+
const rawWeighted = totalWeight > 0 ? weightedSum / totalWeight : 0;
|
|
36
|
+
// Override: any vote with blocking_issues forces weighted_score to 0
|
|
37
|
+
const hasBlockingIssues = votes.some((v) => v.blocking_issues.length > 0);
|
|
38
|
+
return {
|
|
39
|
+
score,
|
|
40
|
+
weighted_score: hasBlockingIssues ? 0 : rawWeighted,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export function buildConsensusPacket(args) {
|
|
44
|
+
const { planPacketRef, votes, rules, arbitratorResult } = args;
|
|
45
|
+
const { score, weighted_score } = computeConsensusScore(votes);
|
|
46
|
+
const approved = score >= rules.threshold && votes.length >= rules.quorum;
|
|
47
|
+
let finalStatus;
|
|
48
|
+
if (arbitratorResult) {
|
|
49
|
+
finalStatus = 'ARBITRATED';
|
|
50
|
+
}
|
|
51
|
+
else if (approved) {
|
|
52
|
+
finalStatus = 'APPROVED';
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
finalStatus = 'REJECTED';
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
metadata: {
|
|
59
|
+
packet_id: randomUUID(),
|
|
60
|
+
timestamp: new Date().toISOString(),
|
|
61
|
+
plan_packet_id: planPacketRef.artifact_id,
|
|
62
|
+
},
|
|
63
|
+
plan_packet_reference: planPacketRef,
|
|
64
|
+
reviewer_votes: votes,
|
|
65
|
+
consensus_rules: {
|
|
66
|
+
threshold: rules.threshold,
|
|
67
|
+
quorum: rules.quorum,
|
|
68
|
+
min_reviewers: rules.min_reviewers,
|
|
69
|
+
},
|
|
70
|
+
consensus_result: {
|
|
71
|
+
approved,
|
|
72
|
+
score,
|
|
73
|
+
weighted_score,
|
|
74
|
+
participating_reviewers: votes.length,
|
|
75
|
+
},
|
|
76
|
+
arbitrator_result: arbitratorResult,
|
|
77
|
+
final_status: finalStatus,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=consensus-packet-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consensus-packet-builder.js","sourceRoot":"","sources":["../../../src/pipeline/packets/consensus-packet-builder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAyBzC,oEAAoE;AACpE,MAAM,YAAY,GAA2B;IAC3C,SAAS,EAAE,GAAG;IACd,aAAa,EAAE,GAAG;IAClB,QAAQ,EAAE,GAAG;CACd,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAAqB;IAErB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,CAAC;IAE/D,gDAAgD;IAChD,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,MAAM,CAAC;IACvE,MAAM,KAAK,GAAG,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC;IAE3C,kDAAkD;IAClD,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,MAAM,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC;QACvB,WAAW,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QAC/C,WAAW,IAAI,CAAC,CAAC;IACnB,CAAC;IACD,MAAM,WAAW,GAAG,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAEpE,qEAAqE;IACrE,MAAM,iBAAiB,GAAG,KAAK,CAA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ACnC,YAAY,EAAE,WAAW;KAC1B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-exports all packet builders.
|
|
3
|
+
*/
|
|
4
|
+
export { buildPlanPacket } from './plan-packet-builder.js';
|
|
5
|
+
export type { BuildPlanPacketArgs } from './plan-packet-builder.js';
|
|
6
|
+
export { buildConsensusPacket } from './consensus-packet-builder.js';
|
|
7
|
+
export type { BuildConsensusPacketArgs, ConsensusRules } from './consensus-packet-builder.js';
|
|
8
|
+
export { buildRCAPacket } from './rca-packet-builder.js';
|
|
9
|
+
export type { BuildRCAPacketArgs } from './rca-packet-builder.js';
|
|
10
|
+
export { buildAuditReport } from './audit-report-builder.js';
|
|
11
|
+
export type { BuildAuditReportArgs } from './audit-report-builder.js';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pipeline/packets/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,YAAY,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,YAAY,EAAE,wBAAwB,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE9F,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,YAAY,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,YAAY,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-exports all packet builders.
|
|
3
|
+
*/
|
|
4
|
+
export { buildPlanPacket } from './plan-packet-builder.js';
|
|
5
|
+
export { buildConsensusPacket } from './consensus-packet-builder.js';
|
|
6
|
+
export { buildRCAPacket } from './rca-packet-builder.js';
|
|
7
|
+
export { buildAuditReport } from './audit-report-builder.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/pipeline/packets/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAG3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAGrE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAGzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plan Packet Builder — deterministic construction of PlanPackets.
|
|
3
|
+
* Auto-generates packet_id, timestamp, auto-increments version.
|
|
4
|
+
*/
|
|
5
|
+
import type { PipelinePhase, PipelineRole, ArtifactRef, DependencyEdge, Constraint, PlanPacket } from '../types.js';
|
|
6
|
+
export interface BuildPlanPacketArgs {
|
|
7
|
+
phase: PipelinePhase;
|
|
8
|
+
submittedBy: PipelineRole;
|
|
9
|
+
masterPlanRef: ArtifactRef;
|
|
10
|
+
constitutionRef: ArtifactRef;
|
|
11
|
+
repoSnapshotRef: ArtifactRef;
|
|
12
|
+
proposedArtifacts: ArtifactRef[];
|
|
13
|
+
acceptanceCriteria: string[];
|
|
14
|
+
dependencies: DependencyEdge[];
|
|
15
|
+
constraints: Constraint[];
|
|
16
|
+
openQuestions?: string[];
|
|
17
|
+
/** Override version (defaults to 1) */
|
|
18
|
+
version?: number;
|
|
19
|
+
}
|
|
20
|
+
export declare function buildPlanPacket(args: BuildPlanPacketArgs): PlanPacket;
|
|
21
|
+
//# sourceMappingURL=plan-packet-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-packet-builder.d.ts","sourceRoot":"","sources":["../../../src/pipeline/packets/plan-packet-builder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,WAAW,EACX,cAAc,EACd,UAAU,EACV,UAAU,EACX,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,aAAa,CAAC;IACrB,WAAW,EAAE,YAAY,CAAC;IAC1B,aAAa,EAAE,WAAW,CAAC;IAC3B,eAAe,EAAE,WAAW,CAAC;IAC7B,eAAe,EAAE,WAAW,CAAC;IAC7B,iBAAiB,EAAE,WAAW,EAAE,CAAC;IACjC,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,mBAAmB,GAAG,UAAU,CAoBrE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plan Packet Builder — deterministic construction of PlanPackets.
|
|
3
|
+
* Auto-generates packet_id, timestamp, auto-increments version.
|
|
4
|
+
*/
|
|
5
|
+
import { randomUUID } from 'node:crypto';
|
|
6
|
+
export function buildPlanPacket(args) {
|
|
7
|
+
return {
|
|
8
|
+
metadata: {
|
|
9
|
+
packet_id: randomUUID(),
|
|
10
|
+
timestamp: new Date().toISOString(),
|
|
11
|
+
phase: args.phase,
|
|
12
|
+
submitted_by: args.submittedBy,
|
|
13
|
+
version: args.version ?? 1,
|
|
14
|
+
},
|
|
15
|
+
references: {
|
|
16
|
+
master_plan: args.masterPlanRef,
|
|
17
|
+
constitution: args.constitutionRef,
|
|
18
|
+
repo_snapshot: args.repoSnapshotRef,
|
|
19
|
+
},
|
|
20
|
+
proposed_artifacts: args.proposedArtifacts,
|
|
21
|
+
acceptance_criteria: args.acceptanceCriteria,
|
|
22
|
+
artifact_dependencies: args.dependencies,
|
|
23
|
+
constraints: args.constraints,
|
|
24
|
+
open_questions: args.openQuestions,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=plan-packet-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-packet-builder.js","sourceRoot":"","sources":["../../../src/pipeline/packets/plan-packet-builder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA0BzC,MAAM,UAAU,eAAe,CAAC,IAAyB;IACvD,OAAO;QACL,QAAQ,EAAE;YACR,SAAS,EAAE,UAAU,EAAE;YACvB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,YAAY,EAAE,IAAI,CAAC,WAAW;YAC9B,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,CAAC;SAC3B;QACD,UAAU,EAAE;YACV,WAAW,EAAE,IAAI,CAAC,aAAa;YAC/B,YAAY,EAAE,IAAI,CAAC,eAAe;YAClC,aAAa,EAAE,IAAI,CAAC,eAAe;SACpC;QACD,kBAAkB,EAAE,IAAI,CAAC,iBAAiB;QAC1C,mBAAmB,EAAE,IAAI,CAAC,kBAAkB;QAC5C,qBAAqB,EAAE,IAAI,CAAC,YAAY;QACxC,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,cAAc,EAAE,IAAI,CAAC,aAAa;KACnC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RCA Packet Builder — constructs Root Cause Analysis packets
|
|
3
|
+
* with explicit phase rewind routing (P1-3).
|
|
4
|
+
*/
|
|
5
|
+
import type { PipelinePhase, RCAPacket } from '../types.js';
|
|
6
|
+
export interface BuildRCAPacketArgs {
|
|
7
|
+
incidentSummary: string;
|
|
8
|
+
symptoms: string[];
|
|
9
|
+
rootCause: string;
|
|
10
|
+
responsibleLayer: string;
|
|
11
|
+
originPhase: PipelinePhase;
|
|
12
|
+
governanceGap: string;
|
|
13
|
+
correctiveActions: string[];
|
|
14
|
+
prevention: string;
|
|
15
|
+
rewindTo?: PipelinePhase;
|
|
16
|
+
requiresConsensusOn?: PipelinePhase[];
|
|
17
|
+
}
|
|
18
|
+
export declare function buildRCAPacket(args: BuildRCAPacketArgs): RCAPacket;
|
|
19
|
+
//# sourceMappingURL=rca-packet-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rca-packet-builder.d.ts","sourceRoot":"","sources":["../../../src/pipeline/packets/rca-packet-builder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE5D,MAAM,WAAW,kBAAkB;IACjC,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,aAAa,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,mBAAmB,CAAC,EAAE,aAAa,EAAE,CAAC;CACvC;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,SAAS,CAelE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RCA Packet Builder — constructs Root Cause Analysis packets
|
|
3
|
+
* with explicit phase rewind routing (P1-3).
|
|
4
|
+
*/
|
|
5
|
+
import { randomUUID } from 'node:crypto';
|
|
6
|
+
export function buildRCAPacket(args) {
|
|
7
|
+
return {
|
|
8
|
+
rca_id: randomUUID(),
|
|
9
|
+
timestamp: new Date().toISOString(),
|
|
10
|
+
incident_summary: args.incidentSummary,
|
|
11
|
+
symptoms: args.symptoms,
|
|
12
|
+
root_cause: args.rootCause,
|
|
13
|
+
responsible_layer: args.responsibleLayer,
|
|
14
|
+
origin_phase: args.originPhase,
|
|
15
|
+
governance_gap: args.governanceGap,
|
|
16
|
+
corrective_actions: args.correctiveActions,
|
|
17
|
+
prevention: args.prevention,
|
|
18
|
+
requires_phase_rewind_to: args.rewindTo,
|
|
19
|
+
requires_consensus_on: args.requiresConsensusOn,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=rca-packet-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rca-packet-builder.js","sourceRoot":"","sources":["../../../src/pipeline/packets/rca-packet-builder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAiBzC,MAAM,UAAU,cAAc,CAAC,IAAwB;IACrD,OAAO;QACL,MAAM,EAAE,UAAU,EAAE;QACpB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,gBAAgB,EAAE,IAAI,CAAC,eAAe;QACtC,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,UAAU,EAAE,IAAI,CAAC,SAAS;QAC1B,iBAAiB,EAAE,IAAI,CAAC,gBAAgB;QACxC,YAAY,EAAE,IAAI,CAAC,WAAW;QAC9B,cAAc,EAAE,IAAI,CAAC,aAAa;QAClC,kBAAkB,EAAE,IAAI,CAAC,iBAAiB;QAC1C,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,wBAAwB,EAAE,IAAI,CAAC,QAAQ;QACvC,qBAAqB,EAAE,IAAI,CAAC,mBAAmB;KAChD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ARCHITECTURE phase — create system architecture + explicit contracts.
|
|
3
|
+
* Uses ARCHITECT skill via executePrompt().
|
|
4
|
+
*/
|
|
5
|
+
import type { PhaseContext, PhaseResult } from './phase-context.js';
|
|
6
|
+
export declare function runArchitecture(context: PhaseContext): Promise<PhaseResult>;
|
|
7
|
+
//# sourceMappingURL=architecture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"architecture.d.ts","sourceRoot":"","sources":["../../../src/pipeline/phases/architecture.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAIpE,wBAAsB,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CA4DjF"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ARCHITECTURE phase — create system architecture + explicit contracts.
|
|
3
|
+
* Uses ARCHITECT skill via executePrompt().
|
|
4
|
+
*/
|
|
5
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
import { successResult, failureResult } from './phase-context.js';
|
|
8
|
+
import { generateRepoSnapshot, createSnapshotArtifact } from '../repo-snapshot.js';
|
|
9
|
+
export async function runArchitecture(context) {
|
|
10
|
+
const { pipeline, artifactManager, skillLoader, projectDir } = context;
|
|
11
|
+
const artifacts = [];
|
|
12
|
+
try {
|
|
13
|
+
// 1. Load architect skill
|
|
14
|
+
const architectSkill = skillLoader.loadSkill('ARCHITECT');
|
|
15
|
+
// 2. Read approved master plan
|
|
16
|
+
const masterPlanArtifact = pipeline.artifacts.find((a) => a.type === 'master_plan');
|
|
17
|
+
let masterPlanContent = '';
|
|
18
|
+
if (masterPlanArtifact) {
|
|
19
|
+
const fullPath = join(projectDir, masterPlanArtifact.path);
|
|
20
|
+
if (existsSync(fullPath)) {
|
|
21
|
+
masterPlanContent = readFileSync(fullPath, 'utf-8');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
// 3. Generate architecture via Claude
|
|
25
|
+
const { executePrompt } = await import('../../adapters/claude.js');
|
|
26
|
+
const architecturePrompt = [
|
|
27
|
+
architectSkill.systemPrompt,
|
|
28
|
+
'',
|
|
29
|
+
'## Master Plan',
|
|
30
|
+
masterPlanContent,
|
|
31
|
+
'',
|
|
32
|
+
'## Instructions',
|
|
33
|
+
'Create the system architecture document covering:',
|
|
34
|
+
'- System topology & boundaries',
|
|
35
|
+
'- API contracts (endpoints, methods, request/response)',
|
|
36
|
+
'- Auth model and security assumptions',
|
|
37
|
+
'- Data ownership boundaries',
|
|
38
|
+
'- Env var list',
|
|
39
|
+
'- Repo layout blueprint',
|
|
40
|
+
'- Error handling strategy',
|
|
41
|
+
].join('\n');
|
|
42
|
+
const result = await executePrompt(architecturePrompt);
|
|
43
|
+
const architectureDoc = result.response;
|
|
44
|
+
// 4. Store architecture artifact
|
|
45
|
+
const archEntry = artifactManager.createAndStoreText('architecture', architectureDoc, 'ARCHITECTURE');
|
|
46
|
+
artifacts.push(archEntry);
|
|
47
|
+
// 5. Generate fresh repo snapshot
|
|
48
|
+
const snapshot = await generateRepoSnapshot(projectDir);
|
|
49
|
+
const snapshotEntry = createSnapshotArtifact(snapshot, artifactManager, 'ARCHITECTURE');
|
|
50
|
+
artifacts.push(snapshotEntry);
|
|
51
|
+
pipeline.latestRepoSnapshot = artifactManager.toArtifactRef(snapshotEntry);
|
|
52
|
+
pipeline.artifacts.push(...artifacts);
|
|
53
|
+
return successResult('ARCHITECTURE', artifacts, 'Architecture document created');
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
const message = err instanceof Error ? err.message : 'Unknown error';
|
|
57
|
+
return failureResult('ARCHITECTURE', 'Architecture creation failed', message);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=architecture.js.map
|