From 2306493a7714295abc96916272581e59d95bf8fb Mon Sep 17 00:00:00 2001 From: Jon Chery Date: Fri, 29 May 2026 19:46:46 +0000 Subject: [PATCH] fix(P01): replace hardcoded phase=1 in orchestrator and fix getDecisions double-fetch ---ci--- project: ci phase: 1 milestone: v0.8 status: in_progress decisions: - id: D-021 decision: 6-phase wave-ordered vertical slices for v0.8 rationale: Each phase independently demoable; critical fixes first confidence: 0.90 requirements: covered: [FIX-01, FIX-06] ---/ci--- FIX-01: Replace 5 hardcoded phase=1 literals in orchestrator.ts mechanical execution path with this.pipelineState!.current_phase. The orchestrator correctly tracks current_phase but commits always embedded literal 1. FIX-06: Replace getDecisions() redundant double-fetch with single getRecentCommits(50) call, delegating to existing getDecisionsFromCommits(). Old code called getRecentCommits(50) once per grep match entry (O(N*M) when it should be O(1)). --- package-lock.json | 7 +++---- src/agents/orchestrator.ts | 10 +++++----- src/core/git-context.ts | 22 ++-------------------- 3 files changed, 10 insertions(+), 29 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5741ddc..87093c7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,12 @@ { "name": "@continuous-intelligence/ciagent", - "version": "0.5.0", + "version": "0.7.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "@continuous-intelligence/ciagent", - "version": "0.5.0", - "hasInstallScript": true, + "name": "@continuous-intelligence/ciagent", + "version": "0.7.0", "license": "MIT", "dependencies": { "commander": "^12.1.0", diff --git a/src/agents/orchestrator.ts b/src/agents/orchestrator.ts index 9cda11c..77ab775 100644 --- a/src/agents/orchestrator.ts +++ b/src/agents/orchestrator.ts @@ -500,7 +500,7 @@ export class OrchestratorAgent extends BaseAgent { case "research": { this.log("Researching project domain..."); - this.decisionEngine!.setPhase(1); + this.decisionEngine!.setPhase(this.pipelineState!.current_phase); const archMd = this.ciFiles!.readArchitectureMd(); if (!archMd) { @@ -519,7 +519,7 @@ export class OrchestratorAgent extends BaseAgent { if (this.config.git.auto_commit && this.gitContext!.isGitRepo()) { const researchCommit = CommitBuilder.buildResearchCommit( - 1, + this.pipelineState!.current_phase, this.currentMilestone, "initial domain research", ["Research completed. Key findings in .ciagent/ARCHITECTURE.md and .ciagent/PROJECT.md updates."] @@ -543,7 +543,7 @@ export class OrchestratorAgent extends BaseAgent { this.log("Planning phase execution..."); if (this.config.git.branching_strategy === "phase" && this.gitBranch && this.gitContext!.isGitRepo()) { - this.gitBranch.createPhaseBranch(1, "initial-phase"); + this.gitBranch.createPhaseBranch(this.pipelineState!.current_phase, "initial-phase"); } this.pipelineState!.plan_completed = true; @@ -623,7 +623,7 @@ export class OrchestratorAgent extends BaseAgent { if (this.config.git.auto_commit && this.gitContext!.isGitRepo()) { const verifyCommit = CommitBuilder.buildVerifyCommit({ - phase: 1, + phase: this.pipelineState!.current_phase, milestone: this.currentMilestone, subject: "automated verification passed", requirements: { covered: [], partial: [] }, @@ -646,7 +646,7 @@ export class OrchestratorAgent extends BaseAgent { if (this.config.git.auto_commit && this.gitContext!.isGitRepo()) { const completionCommit = CommitBuilder.buildPhaseCompletionCommit({ - phase: 1, + phase: this.pipelineState!.current_phase, milestone: this.currentMilestone, phaseName: "initial-phase", tasksCompleted: 0, diff --git a/src/core/git-context.ts b/src/core/git-context.ts index b7b684e..b636e8d 100644 --- a/src/core/git-context.ts +++ b/src/core/git-context.ts @@ -185,26 +185,8 @@ export class GitContext { } getDecisions(phase?: number): CommitDecision[] { - const grepArg = phase !== undefined ? `--grep="phase: ${phase}"` : '--grep="decisions:"'; - const raw = this.git(`log --all ${grepArg} --format="%B%x01"`); - - if (!raw) return []; - - const decisions: CommitDecision[] = []; - const entries = raw.split("\x01").filter(Boolean); - - for (const entry of entries) { - const commits = this.getRecentCommits(50); - for (const commit of commits) { - if (commit.ci?.decisions) { - if (phase === undefined || commit.ci.phase === phase) { - decisions.push(...commit.ci.decisions); - } - } - } - } - - return decisions; + const commits = this.getRecentCommits(50); + return this.getDecisionsFromCommits(commits, phase); } getDecisionsFromCommits(commits: ParsedCIAgentCommit[], phase?: number): CommitDecision[] {