Skip to content

fix(ci): measure the PR candidate in the fork drift receipt and record tip SHAs (CLO-1117) - #243

Open
nullStack65 wants to merge 1 commit into
release/native-0.1.10from
fix/clo-1117-fork-drift-receipt-shas
Open

nullStack65 wants to merge 1 commit into
release/native-0.1.10from
fix/clo-1117-fork-drift-receipt-shas

Conversation

@nullStack65

Copy link
Copy Markdown
Owner

Addresses the T3 Code factory audit item T1-03 in the t3code CI guard and hygiene issue (CLO-1117).

Problem

The ARC CI "Fork drift receipt" step measured origin/<target branch> against upstream/main. In a pull request it reported the target branch's drift, not the candidate's, so an upstream-sync PR looked exactly as far behind as the line it fixes. The receipt also printed ref names but no SHAs, so its numbers could not be reproduced once the refs moved.

Change

  • scripts/fork-drift-receipt.mjs resolves base, head and upstream to commit SHAs once and computes every number from those SHAs.
  • New --head <ref>: the candidate is the merge of base and head. Ahead = commits in either tip not in upstream; behind = upstream commits in neither tip; the merge base pairs upstream with that hypothetical merge (git merge-base upstream base head). Without --head the candidate is base, so the weekly run is unchanged.
  • New --upstream <ref> (default upstream/main), and every receipt carries baseSha, headSha, upstreamSha and a reproduce command.
  • closura-arc-ci.yml passes --head = PR head SHA (the pushed SHA on a push) through an env var. The head is a parent of the merge ref, so it is already in the checkout.
  • docs/operations/fork-sync.md documents the replay.

Evidence

  • node --test scripts/fork-drift-receipt.test.mjs scripts/fork-sync-plan.test.mjs: 11/11 pass. New tests:
    • the receipt records all three tip SHAs (40-hex, equal to rev-parse);
    • a PR that merges upstream measures behind 0 while the target alone measures behind 2;
    • after base, PR and upstream all gain commits, replaying from the recorded SHAs gives identical mergeBase/ahead/behind/changedFiles;
    • a missing head fails closed; an option-shaped ref (--all) is refused.
  • Live parity on origin/release/native-0.1.10 (53ae52a) vs upstream/main (63a7126): old and new scripts both report ahead 238, behind 670, 1576 files, merge base 3418648.
  • node .github/scripts/arc-ci-coverage.cjs passes; coverage, trust-gate and no-hosted-runner tests 39/39 pass.
  • vp fmt --check clean after formatting. vp lint could not load the repo's TypeScript lint plugin in this local checkout; CI lint is the check of record.

Prior art

Searched: 2026-11-27, git docs and the existing script.

  • git merge-base A B C (stock git): used as-is to get the merge base of upstream and the candidate merge without creating a merge commit.
  • git rev-list --count with negated tips (stock git): used for ahead/behind across two tips.
  • Measuring refs/pull/N/merge directly: rejected, that merge commit is not durable, so the receipt would not be reproducible.

Model: claude-opus-5-5
Task: CLO-1117
Agent: claude-code
Harness: t3/claude-code
Model-family: claude
Model-generation: 5
Skills-SHA: 22a90292e171517bd204efcea6e4ee03965caec9
Deploy: none

🤖 Generated with Claude Code

…d tip SHAs (CLO-1117)

The fork drift receipt measured only the target branch, so a pull request
that syncs upstream reported the same drift as the line it targets. It also
named refs but no SHAs, so once the branches moved nobody could reproduce
its numbers.

The receipt now resolves base, head and upstream to commit SHAs once and
computes everything from those SHAs. With --head, the candidate is the merge
of base and head: commits in either tip but not upstream are ahead, upstream
commits in neither are behind, and the merge base pairs upstream with that
hypothetical merge. Without --head the candidate is base, and the numbers
match the old receipt exactly (checked on the live release line: ahead 238,
behind 670, 1576 files). Each receipt carries baseSha, headSha, upstreamSha
and a reproduce command. ARC CI passes the PR head SHA (the pushed SHA on a
push).

Audit item T1-03 of the T3 Code factory audit.

Model: claude-opus-5-5
Task: CLO-1117
Agent: claude-code
Harness: t3/claude-code
Model-family: claude
Model-generation: 5
Skills-SHA: 22a90292e171517bd204efcea6e4ee03965caec9
Deploy: none
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 27, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@nullStack65

Copy link
Copy Markdown
Owner Author

Reviewed exactly head e74b9a2 (base 53ae52a, unchanged). R1–R4 hold.

The receipt resolves base, head and upstream to one tip SHA each and derives ahead, behind and the changed-file count from those SHAs, so the printed reproduce command replays the numbers after the refs move. In CI, --head is the pull request head SHA and falls back to github.sha on push, so a pull request measures the candidate merge of base and head rather than the target branch alone. With head equal to base the counts match the old two-dot rev-list --left-right --count and merge-base. Refs are passed as execFileSync arguments, and an option-shaped or empty ref is rejected before git sees it. node --test scripts/fork-drift-receipt.test.mjs passes 6/6, including the replay-after-move case.

No findings.

{"reviewed_base": "53ae52a745a55ba295151a915132cda2963031ab", "reviewed_head": "e74b9a2f79391e5d8043de598b7e22167fa40ea4", "reviewer": "Grok 4.7, T3 Magpie route", "reviewer_family": "grok", "author_session": "claudeAgent claude-opus-5-5 mcp:6da90aa2-5851-447a-843b-d1c06e77acfc", "reviewer_session": "thread:delegated-task:command%3Amcp%3A2b632ee4-6554-4fd4-872c-5d8d6105eba4%3Adelegate-task%3A311e7c56-5618-445f-b928-fd0902356142", "fresh_context": true, "review_kind": "full", "round_id": "thread:delegated-task:command%3Amcp%3A2b632ee4-6554-4fd4-872c-5d8d6105eba4%3Adelegate-task%3A311e7c56-5618-445f-b928-fd0902356142", "intent": ["R1", "R2", "R3", "R4"], "prior_findings": [], "findings": []}

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant