From b49ed6a0d960653220c7850dced71afac4d94411 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Tue, 17 Nov 2026 22:45:34 +0800 Subject: [PATCH] Ubicloud pack no longer fails while git rewrites a ref, and the HOLD SCOPE eval stops requiring the mode name (#4447) Packing a checkout for a Ubicloud run no longer fails when git running beside it is rewriting a ref, and the /plan-ceo-review HOLD SCOPE eval no longer fails a review whose follow-up question doesn't repeat the mode name. Why: both made tests fail at random. The pack race failed Free Tests twice on 2026-11-17, and the HOLD check failed the weekly eval census on main. Nothing to do. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- .../ubicloud-pack-skips-refs-being-rewritten.md | 2 ++ scripts/ubicloud/ubi-runner.sh | 6 +++++- test/ceo-hold-posture-review.test.ts | 10 ++++++++++ test/helpers/ceo-hold-posture-review.ts | 5 +++-- test/ubicloud-runner.test.ts | 13 +++++++++++++ 5 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 changelog.d/ubicloud-pack-skips-refs-being-rewritten.md diff --git a/changelog.d/ubicloud-pack-skips-refs-being-rewritten.md b/changelog.d/ubicloud-pack-skips-refs-being-rewritten.md new file mode 100644 index 000000000..3066cce58 --- /dev/null +++ b/changelog.d/ubicloud-pack-skips-refs-being-rewritten.md @@ -0,0 +1,2 @@ +- **Packing a checkout for a Ubicloud run no longer fails when git beside it is rewriting a ref.** `ubi-runner.sh pack` asked git's upload-pack for every ref, and upload-pack advertises a ref it cannot read (a loose ref file caught mid-write or mid-delete) with a null id, so the snapshot failed with "not our ref 0000…". Pack now reads the refs once with `git for-each-ref`, which skips an unreadable ref, and fetches those exact objects. Seen twice in Free Tests on 2026-11-17 (runs 44063454800 and 44050883970); an empty loose ref file reproduces it every time. +- **The /plan-ceo-review HOLD SCOPE eval no longer fails a review because its follow-up question didn't repeat the mode name.** The check required the decision's "Project/branch/task" line to say "HOLD SCOPE", which the skill never asks for; the decision is already tied to the HOLD answer by session and order. A line naming another mode, or past or hypothetical work, still fails. diff --git a/scripts/ubicloud/ubi-runner.sh b/scripts/ubicloud/ubi-runner.sh index 371c1ab66..32662d5d4 100755 --- a/scripts/ubicloud/ubi-runner.sh +++ b/scripts/ubicloud/ubi-runner.sh @@ -1703,7 +1703,11 @@ cmd_pack() { trap "rm -rf $(printf %q "$tmp")" EXIT # No template hooks from a global init.templateDir, and no auto-gc under the tar. git -c gc.auto=0 init -q --bare --template= "$tmp/.git" - git -C "$tmp/.git" -c gc.auto=0 fetch -q --no-tags --update-shallow "$src" '+refs/*:refs/*' \ + # Fetch the object ids one for-each-ref read, not upload-pack's own ref list: a ref that git running beside pack is + # deleting is advertised with a null id that no fetch can want, while for-each-ref skips it as broken. + git -C "$src" for-each-ref --format='+%(objectname):%(refname)' refs/ \ + | git -C "$tmp/.git" -c gc.auto=0 fetch -q --no-tags --update-shallow --stdin \ + --upload-pack='git -c uploadpack.allowAnySHA1InWant=true upload-pack' "$src" \ || die "pack: could not snapshot the refs of $src" if [ -z "$branch" ]; then branch="detached-${head:0:12}" diff --git a/test/ceo-hold-posture-review.test.ts b/test/ceo-hold-posture-review.test.ts index 11accf0cb..763372a01 100644 --- a/test/ceo-hold-posture-review.test.ts +++ b/test/ceo-hold-posture-review.test.ts @@ -284,3 +284,13 @@ test('a decision whose grounding line names no plan file stays bound by the owne unread.publicTools=unread.publicTools.filter(e=>e.toolUseId!==sourceId); expect(()=>buildCeoHoldPostureReview(unread)).toThrow('complete original source Read/ACK'); }); + +test('a decision whose grounding line does not restate the mode stays bound by its HOLD answer (census 43815320847 HOLD D4)',()=>{ + const line='Project/branch/task: main branch, PLAN.md saved project views; the repo contains only PLAN.md and CLAUDE.md.'; + const f=input();revise(f,q=>{q.question=q.question.replace(/Project\/branch\/task:[^\n]*/,line);}); + expect(buildCeoHoldPostureReview(f)!.plan).toBe(f.source.content); + for(const other of ['SELECTIVE EXPANSION','SCOPE REDUCTION','previous']){ + const g=input();revise(g,q=>{q.question=q.question.replace(/Project\/branch\/task:[^\n]*/,line.replace('main branch,',`main branch, ${other} review,`));}); + expect(()=>buildCeoHoldPostureReview(g)).toThrow('decision is not current HOLD work'); + } +}); diff --git a/test/helpers/ceo-hold-posture-review.ts b/test/helpers/ceo-hold-posture-review.ts index d7b97646b..3904a0690 100644 --- a/test/helpers/ceo-hold-posture-review.ts +++ b/test/helpers/ceo-hold-posture-review.ts @@ -68,8 +68,9 @@ export function buildCeoHoldPostureReview(input: CeoHoldPostureReviewInput): Pla if (plans.length > 1 || (plans.length === 1 && plans[0] !== name && plans[0] !== source.path)) fail('native source context differs from original plan'); } const decisionContext = /Project\/branch\/task:([^\n]*)/i.exec(decision.questions[0]!.question)?.[1] ?? ''; - if (!/\bHOLD SCOPE\b/.test(decisionContext) || - /\b(?:SCOPE EXPANSION|SELECTIVE EXPANSION|SCOPE REDUCTION|historical|previous|example|hypothetical|withdrawn)\b/i.test(decisionContext)) + // The decision is bound to the HOLD answer by session and chronology above; the skill never asks its grounding + // line to restate the mode, so only a context naming another mode or past or hypothetical work disqualifies it. + if (/\b(?:SCOPE EXPANSION|SELECTIVE EXPANSION|SCOPE REDUCTION|historical|previous|example|hypothetical|withdrawn)\b/i.test(decisionContext)) fail('decision is not current HOLD work'); const sourceLines = source.content.split('\n').length; const loaded = events.some(request => { diff --git a/test/ubicloud-runner.test.ts b/test/ubicloud-runner.test.ts index 4ce8d5d2c..fbc8d635f 100644 --- a/test/ubicloud-runner.test.ts +++ b/test/ubicloud-runner.test.ts @@ -520,6 +520,19 @@ test('pack ships a linked worktree with a self-contained .git on the checked-out } finally { rmSync(d, { recursive: true, force: true }); } }, 90_000); + // Value: protects=pack snapshots a checkout while git beside it is mid-way through writing or deleting a ref (two Free Tests reds on 2026-11-17, runs 44063454800 and 44050883970, from the churn test above); fails_when=pack asks upload-pack for every ref, which advertises a ref it cannot read with a null id, and the fetch then fails "not our ref 0000…"; why_new=the churn test hits that window about once in 600 fetches, an empty loose ref file is the same state held still; seam=none + test('pack skips a ref git cannot read (an empty loose ref file) and still ships every readable ref', () => { + const d = mkdtempSync(join(tmpdir(), 'ubi-pack-broken-ref-')); + try { + const sh = (cmd: string, cwd: string) => { const r = Bun.spawnSync(['bash', '-c', cmd], { cwd, timeout: 30_000, env: { ...process.env, GIT_AUTHOR_NAME: 't', GIT_AUTHOR_EMAIL: 't@t', GIT_COMMITTER_NAME: 't', GIT_COMMITTER_EMAIL: 't@t' } }); expect(r.exitCode, `${cmd}\n${r.stderr.toString()}`).toBe(0); return r.stdout.toString(); }; + sh('git init -q -b main src && cd src && echo a > a && git add a && git commit -qm one && git tag -a v1 -m v1 && git branch side && : > .git/refs/heads/broken', d); + sh(`mkdir vm && bash ${JSON.stringify(join(DIR, 'ubi-runner.sh'))} pack src | tar -xzf - -C vm`, d); + const head = sh('git rev-parse HEAD', join(d, 'src')).trim(); + expect(sh('git for-each-ref --format="%(refname) %(objectname)" refs/heads && git rev-parse v1^{commit}', join(d, 'vm')).split('\n').filter(Boolean)) + .toEqual([`refs/heads/main ${head}`, `refs/heads/side ${head}`, head]); + } finally { rmSync(d, { recursive: true, force: true }); } + }, 60_000); + // Value: protects=pack never lets macOS tar add AppleDouble ._* entries (files with extended attributes), which the VM's tree check would count as untracked files and fail the run with UBI_VM_TREE_MISMATCH; fails_when=a tar call in pack runs without COPYFILE_DISABLE=1; why_new=only Apple's tar reads the variable, so no Linux run can see the ._* entries themselves; seam=PATH (a tar shim records its environment, then runs the real tar); no_claim=Apple tar's metadata behavior itself (checked by hand on a Mac) test('pack runs every tar with COPYFILE_DISABLE=1, for a checkout and for a plain directory', () => { const d = mkdtempSync(join(tmpdir(), 'ubi-pack-copyfile-'));