Repository navigation
fix(build-cache): look in the cache again once the lock is taken - #4159
Conversation
"builds a commit once when its jobs start together" failed once on a loaded host's check fast. A job looks in the cache, misses, and only then tries the lock. If the job that held the lock stores its build and lets go in between, the late job takes the free lock and builds the same commit a second time (the test counts two builds). Once a job holds the lock it now looks in the cache again, and if the build is there it restores it, lets the lock go and exits, so a commit is built once whatever the timing.
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
|
Merged through Build-cache script fix (lead t10k asked for it): a job that took the lock looks in the cache again before building, closing a check-then-lock race that let a commit be built twice. Reviews: dori review CLEAR at 7ced6a7; CodeRabbit on this PR. Merged by the lane on the lead's word. Evidence: build-cache tests 52/52, check fast green; the flake did not reproduce in 148 runs (stated in the PR). |
…pe, worktree focus and agy temp links (#4550) ## What Test bundle B5 of the test-suite plan: regression tests for four fixes that went in without one (two of them regressed before). Tests only; no production file changes. | # | Fix | Test | |---|---|---| | A1 | #4159 `scripts/build-cache.ts` re-checks the cache after taking the lock | `scripts/build-cache.test.ts`: two real `build-cache.ts` jobs on one key, ordered by gate files (`fs.watch`, no sleep). Job 2 misses the cache, meets job 1's lock, and is paused just before its retry; job 1 stores its build and releases. Both exit 0, one build in total, job 2's `dist/` restored from the cache. | | A2 | #3028 Changes keeps its scope when Files moves to another pane/PC | new `src/components/FilesDialog.test.tsx`: render `FilesDialog`, pick Branch, compare with `main`, rerender with another `paneId`, then the stale pane's answer arrives: Branch stays pressed and the stale file is not shown. | | A3 | #1222 the new worktree dialog focuses the Branch field | `src/components/WorktreeDialog.test.tsx`: in create mode focus is on the Branch input with its suggested value fully selected. | | A4 | #2030 agy catalog under a symlinked temp dir (macOS `/var -> /private/var`) | `server/agy.test.ts`: a new row of the WAL-catalog table runs the reader with `TMPDIR`/`TEMP`/`TMP` pointing at a symlink. | ## Evidence: each test goes red when its fix is reverted Each mutation was written into the production file, the test run, and the original bytes restored (sha256 checked; production diff is empty). | # | Revert | Result | |---|---|---| | A1 | `if (owner && restored())` -> `if (false && ...)` (no look under the lock) | red: builds `[1, 1]` instead of `[1, 0]` | | A2 | put back `key={`${machineId}:${paneId}`}` on `<RepoChanges>` (the key cbdcafa removed) | red: scope falls back to Working tree | | A3 | move `ref={first}` from the Branch input to the Name input (pre-#1222) | red: focus and selection on the Name input | | A4 | remove `snapshot = realpathSync(snapshot)` in `server/agy.ts` | red: only the symlinked row fails with `AgyUnavailable`; the other three rows stay green. **This reproduces on Linux too**: SQLite's `SQLITE_OPEN_NOFOLLOW` refuses a path with a symlinked directory component, so Linux CI guards #2030. | ## Validation - `bun test scripts/build-cache.test.ts src/components/FilesDialog.test.tsx src/components/WorktreeDialog.test.tsx server/agy.test.ts`: all new tests pass. - `bun scripts/typecheck.ts`: exit 0. - `bun run check fast` (P620, 241 s): typecheck, build, generated files ok; unit 24,890 pass, 160 skip, **1 fail**: `scripts/conventions.test.ts` "waits marked fixed" on `scripts/relay-new-pc-press-regression.ts:180`, which fails on `origin/main` itself (1d71a71) and is fixed by #4547; this PR does not touch that file. The branch takes main in once #4547 lands. - Browser regressions that name FilesDialog or the worktree dialog (`file-viewer-regression`, `files-panel-demo-regression`, `repo-diff-browser-qa`, `ui-regression`, `phone-worktree-sheet-regression`, ...): not run locally since no component code changes; they run in this PR's Integration and browser job (CI runner image).
Summary
scripts/build-cache.test.ts"builds a commit once when its jobs start together" failed once inbun run check faston aloaded host (hosthatch) and passes elsewhere.
scripts/build-cache.tshas a check-then-lock race: a job looks in the cache, misses, and only then tries the lock. Ifthe job holding the lock stores its build and lets go in between, the late job takes the free lock and builds the same
commit a second time, which is what the test counts (exactly one build across four jobs).
Fix: once a job holds the lock it looks in the cache again; if the build is there it restores it, lets the lock go and
exits. No timing is involved, so a commit is built once however the jobs interleave.
Validation
bun test scripts/build-cache.test.ts: 52 pass, 0 fail.bun run check fast: green.48 as six parallel copies of the file, 80 as sixteen parallel copies with every core busy). The race above is the
path through the code that produces two builds; the original failure's assertion would confirm it.