feat: add in-memory diff cache with TTL and commit-hash invalidation

Adds DiffCache<T> module, extends BranchManager with getHeadCommitHash,
and wires phase-level caching into getPhaseReviewDiff and getFileDiff.
Cache is invalidated in ExecutionOrchestrator after each task merges into
the phase branch, ensuring stale diffs are never served after new commits.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lukas May
2026-03-06 19:51:04 +01:00
parent 90978d631a
commit 0996073deb
6 changed files with 112 additions and 4 deletions

View File

@@ -23,6 +23,7 @@ import type { ConflictResolutionService } from '../coordination/conflict-resolut
import { phaseBranchName, taskBranchName } from '../git/branch-naming.js';
import { ensureProjectClone } from '../git/project-clones.js';
import { createModuleLogger } from '../logger/index.js';
import { phaseMetaCache, fileDiffCache } from '../review/diff-cache.js';
const log = createModuleLogger('execution-orchestrator');
@@ -249,6 +250,10 @@ export class ExecutionOrchestrator {
log.info({ taskId, taskBranch, phaseBranch, project: project.name }, 'task branch merged into phase branch');
}
// Invalidate diff cache — phase branch HEAD has advanced after merges
phaseMetaCache.invalidateByPrefix(`${phaseId}:`);
fileDiffCache.invalidateByPrefix(`${phaseId}:`);
// Emit task:merged event
const mergedEvent: TaskMergedEvent = {
type: 'task:merged',