Make df12-build-odw dryRun avoid real worktree creation (#31)#48
Make df12-build-odw dryRun avoid real worktree creation (#31)#48pandalump wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Sorry @pandalump, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
WalkthroughDry-run handling in ChangesDry-run pre-worktree short-circuit
Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 17 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (17 passed)
📋 Issue PlannerBuilt with CodeRabbit's Coding Plans for faster development and fewer bugs. View plan used: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
44ca92c to
d6993c1
Compare
A dry run against a repository with surviving roadmap-* branches failed: runTask called createWorktree unconditionally, and createWorktree runs `git worktree add -b roadmap-... origin/<base>` with no DRY_RUN guard, so the run tripped the branch collision before it could validate anything. Short-circuit DRY_RUN at the head of runTask, ahead of worktree creation and the write-access preflight, returning a terminal `dry-run` status with stage `pre-worktree`. A single check precedes the addendum/normal branch, so it covers both lanes; markDryRun keys off task.isAddendum, not the result. Remove the two now-unreachable post-worktree dry-run short-circuits (addendum and post-design). The recovery/continue lane's own dry-run handling over pre-existing worktrees is left untouched. Add a no-mutation dry-run test that drives runTask against a fixture repo holding colliding roadmap-* branches and asserts an unchanged repo-state snapshot, and align the architecture and user-guide docs with the new stop-before-worktree semantics. Regenerate workflows/df12-build-odw.js from source. Closes #31
d6993c1 to
fa690d3
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai resume |
✅ Action performedReviews resumed. |
Address review feedback on the dry-run short-circuit in runTask: it was silent, only regression-tested at one point, and undocumented for contributors. - Emit a structured, parseable log() at the DRY_RUN decision boundary so operators see why a task stopped (task id, lane derived from task.isAddendum, stage=pre-worktree), not just the terminal status. The returned result object is unchanged. - Add a fast-check property over arbitrary task shapes (ids that do and do not collide with surviving roadmap-* branches, either lane, generated requires/subtasks) and repo states, asserting a dry run always terminates at pre-worktree, dispatches no agent, and leaves durable git state byte-for-byte unchanged. - Document the boundary in the developers-guide ODW workflow contract, matching the wording already in the architecture and users' guides. - Regenerate workflows/df12-build-odw.js from source. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@coderabbitai Have the following failed checks now been resolved? If further work is required, please provide an AI agent prompt for the remaining work to be done to address these failures. Do not treat warnings as optional or aspirational. Where a change is out of scope for this PR, propose a GitHub issue unless one exists already. (Treat documentation and validation coverage as in scope). ❌ Failed checks (3 warnings)
|
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
gh pr view 48 --json headRefName,commits -q '.headRefName' 2>/dev/null || true
gh pr diff 48 --name-only 2>/dev/null || true
echo "---developers-guide---"
fd -i developers-guide
echo "---search dry-run in developers-guide---"
rg -n -i 'dry.?run' docs/developers-guide.md || true
echo "---search for fast-check---"
rg -n 'fast-check' -g '*.json' -g '*.mjs' -g '*.ts' || true
echo "---search property test files---"
fd -i 'property'
echo "---search structured log near DRY_RUN in run-task.ts---"
rg -n 'DRY_RUN' -A5 -B5 src/workflows/df12-build-odw/run-task.ts
echo "---workflows file---"
rg -n 'DRY_RUN2' -A8 -B5 workflows/df12-build-odw.jsLength of output: 2622 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "---developers-guide---"
fd -i developers-guide
echo "---search dry-run in developers-guide---"
rg -n -i 'dry.?run' docs/developers-guide.md || true
echo "---search for fast-check usage---"
rg -n 'fast-check' -g '*.json' -g '*.mjs' -g '*.ts' || true
echo "---search property test files---"
fd -i 'property'
echo "---search structured log near DRY_RUN in run-task.ts---"
rg -n 'DRY_RUN' -A6 -B6 src/workflows/df12-build-odw/run-task.ts
echo "---workflows file---"
rg -n 'DRY_RUN2' -A8 -B5 workflows/df12-build-odw.js
echo "---package.json deps---"
rg -n 'fast-check' package.json || trueLength of output: 2573
Treat all three as in-scope, per your instruction. No new GitHub issue is warranted since this work belongs in the current PR. 1. Developer Documentation — outstandingAdd a 2. Testing (Property / Proof) — outstandingAdd a fast-check property test asserting the no-mutation invariant holds across arbitrary task IDs and repo states. 3. Observability — outstandingEmit a structured log at the new ✏️ Learnings added
|
Refine the review-feedback follow-up on the pre-worktree dry-run boundary. - Add a `reason=dry-run` field to the boundary log() so the trace carries all four structured fields (task id, lane, stage=pre-worktree, reason); regenerate workflows/df12-build-odw.js. - Extract the runTask-loading harness into tests/fixtures/load-run-task.mjs, which now captures the injected log() output so tests can assert the emitted trace. The regression suite asserts the boundary log carries the task id, lane, stage=pre-worktree, and reason=dry-run for both lanes. - Move the property test into its own file (tests/df12-build-odw-dry-run.property.test.mjs) and raise it to 100 fast-check iterations over arbitrary task ids (including fully arbitrary strings and branch-colliding ids), both lanes, and a pooled set of repo states, asserting status=dry-run, stage=pre-worktree, no agent dispatch, and an unchanged durable-state snapshot. - Expand the developers-guide note: record that the earlier addendum-specific and post-design dry-run exits were removed as unreachable, and cross-reference the architecture "Enforcement boundary" table and the users' guide "Workflow arguments" section so all three docs agree. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Summary
A dry run against a repository with surviving
roadmap-*branches failed on abranch collision:
runTaskcalledcreateWorktreeunconditionally, andcreateWorktreerunsgit worktree add -b roadmap-... origin/<base>with noDRY_RUNguard. A dry run should be a safe, read-only validation path, so itmust never mutate git state.
Changes
DRY_RUNat the head ofrunTask(inrun-task.ts), ahead ofworktree creation and the write-access preflight, returning a terminal
dry-runstatus with stagepre-worktree. The single check precedes theaddendum/normal branch, covering both lanes.
addendum-lane and the post-design blocks).
pre-existing worktrees) untouched.
tests/df12-build-odw-dry-run.test.mjs: drivesrunTaskwithdryRun: trueagainst a fixture repo whoseroadmap-*branches wouldcollide, and asserts an unchanged repo-state snapshot (no new branch, no new
worktree) and that no agent was dispatched.
docs/architecture.mdanddocs/users-guide.mdwith the newstop-before-worktree semantics.
workflows/df12-build-odw.jsfrom source viamake workflow-build.Follows the CodeRabbit implementation plan (guard at the top of
runTask,Option 2). Deviation: the CodeRabbit result shape included
proposals: []; theplan text omitted only
worktree/plan/branch, which are omitted here.Review-feedback follow-up
Addresses the three review warnings on the initial fix:
DRY_RUNearly return emits a structured, parseablelog()at the decision boundary carrying all four fields: task id,lane(derived from
task.isAddendum),stage=pre-worktree, andreason=dry-run.The returned result object's shape (
status,stage,detail,proposals)is unchanged. The
logsink is injectable in the test harness, so theregression suite asserts the emitted fields for both the normal and addendum
lanes.
fast-checkproperty(
tests/df12-build-odw-dry-run.property.test.mjs, 100 iterations) sweepsarbitrary task ids (fully arbitrary strings, roadmap-shaped dotted ids, and
branch-colliding ids), both lanes, and pooled repo states, asserting a dry
run always returns
status=dry-run/stage=pre-worktree, dispatches noagent, and leaves the durable git-state snapshot byte-for-byte unchanged. The
runTaskharness is extracted intotests/fixtures/load-run-task.mjsandshared with the regression suite.
docs/developers-guide.md(ODW workflowcontract) documents the pre-worktree boundary, records that the earlier
addendum-specific and post-design dry-run exits were removed as unreachable,
and cross-references the architecture
Enforcement boundarytable and theusers' guide
Workflow argumentssection so all three docs agree. No trackedroadmap/execplan work-item exists for Make df12-build-odw dryRun avoid real worktree creation #31, so none required a status update.
Gates pass:
make check-fmt,make lint,make typecheck,make test,make markdownlint, andmake nixieare all green.Closes #31
References