Adds two interlocking PBIs:
PBI-9 — Worktree foundation + persistent product-worktrees for idea-jobs
- src/git/worktree-paths.ts: centralised root + skip-set + lock-path helpers
- src/git/file-lock.ts: proper-lockfile wrapper, deadlock-safe ordered acquire
- src/git/product-worktree.ts: detached-HEAD worktree per product, .scratch/
excluded via git rev-parse --git-path (handles linked .git file)
- src/git/job-locks.ts: setupProductWorktrees + releaseLocksOnTerminal
- wait-for-job.ts: idea-branch wires product-worktrees for IDEA_GRILL/MAKE_PLAN
- update-job-status.ts + pbi-cascade.ts + stale-reset: release on all four
server-side terminal transitions (DONE/FAILED/CANCELLED/stale)
- cleanup-my-worktrees: skip _products/ + *.lock
- README: worktrees section with single-host invariant + advisory-lock path
PBI-47 — Sprint-flow P0 corrections + PAUSED flow with rich pause_context
- prisma schema: ClaudeJob.{base_sha,head_sha} + SprintRun.pause_context
- tryClaimJob captures base_sha; prepareDoneUpdate captures head_sha
- verify-task-against-plan diffs vs base_sha (no more origin/main fallback);
rejects with MISSING_BASE_SHA when null — fixes per-task verify-scope P0
- pr.ts: createPullRequest enableAutoMerge default false; new
enableAutoMergeOnPr with --match-head-commit guard + 5-category typed
EnableAutoMergeResult — fixes STORY auto-merge timing P0
- src/flow/{effects,worktree-lease,pr-flow,sprint-run}.ts: pure transition
modules + idempotent declarative effects executor
- update-job-status: STORY auto-merge fires only on the last task of the
story (story.status === DONE), with head_sha as merge guard; MERGE_CONFLICT
routes to sprint-run flow which produces CREATE_CLAUDE_QUESTION +
SET_SPRINT_RUN_STATUS effects with rich pause_context
Tests: 31 test files, 242 passing. Pure-transition tests cover STORY 3-tasks
auto-merge timing, SPRINT draft→ready, MERGE_CONFLICT pause/resume, file-lock
deadlock prevention, worktree-lease lifecycle, delete-only verify (ALIGNED),
per-job verify scope (base_sha isolation), 5-category auto-merge errors.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
55 lines
2.1 KiB
TypeScript
55 lines
2.1 KiB
TypeScript
import { describe, it, expect, beforeAll, afterAll } from 'vitest'
|
|
import * as fs from 'node:fs/promises'
|
|
import * as path from 'node:path'
|
|
import * as os from 'node:os'
|
|
import { execFile } from 'node:child_process'
|
|
import { promisify } from 'node:util'
|
|
import { getDiffInWorktree } from '../../src/tools/verify-task-against-plan.js'
|
|
|
|
const exec = promisify(execFile)
|
|
|
|
describe('verify scope per-job (PBI-47 P0)', () => {
|
|
let tmpRepo: string
|
|
let baseSha: string
|
|
let task1Sha: string
|
|
|
|
beforeAll(async () => {
|
|
tmpRepo = await fs.mkdtemp(path.join(os.tmpdir(), 'verify-scope-'))
|
|
await exec('git', ['init', '-b', 'main'], { cwd: tmpRepo })
|
|
await exec('git', ['config', 'user.email', 't@t.local'], { cwd: tmpRepo })
|
|
await exec('git', ['config', 'user.name', 'Test'], { cwd: tmpRepo })
|
|
await fs.writeFile(path.join(tmpRepo, 'README.md'), '# init\n')
|
|
await exec('git', ['add', '-A'], { cwd: tmpRepo })
|
|
await exec('git', ['commit', '-m', 'init'], { cwd: tmpRepo })
|
|
const baseRev = await exec('git', ['rev-parse', 'HEAD'], { cwd: tmpRepo })
|
|
baseSha = baseRev.stdout.trim()
|
|
|
|
// Simulate task 1: add a.ts
|
|
await fs.writeFile(path.join(tmpRepo, 'a.ts'), 'task 1\n')
|
|
await exec('git', ['add', '-A'], { cwd: tmpRepo })
|
|
await exec('git', ['commit', '-m', 'task 1'], { cwd: tmpRepo })
|
|
const t1Rev = await exec('git', ['rev-parse', 'HEAD'], { cwd: tmpRepo })
|
|
task1Sha = t1Rev.stdout.trim()
|
|
|
|
// Simulate task 2: add b.ts
|
|
await fs.writeFile(path.join(tmpRepo, 'b.ts'), 'task 2\n')
|
|
await exec('git', ['add', '-A'], { cwd: tmpRepo })
|
|
await exec('git', ['commit', '-m', 'task 2'], { cwd: tmpRepo })
|
|
})
|
|
|
|
afterAll(async () => {
|
|
await fs.rm(tmpRepo, { recursive: true, force: true })
|
|
})
|
|
|
|
it('diff vs base = origin/main → both task 1 and task 2 visible', async () => {
|
|
const diff = await getDiffInWorktree(tmpRepo, baseSha)
|
|
expect(diff).toContain('a.ts')
|
|
expect(diff).toContain('b.ts')
|
|
})
|
|
|
|
it('diff vs base = task1_sha → only task 2 visible', async () => {
|
|
const diff = await getDiffInWorktree(tmpRepo, task1Sha)
|
|
expect(diff).not.toContain('a.ts')
|
|
expect(diff).toContain('b.ts')
|
|
})
|
|
})
|