Skip to content

fix(results): root results branch at a stable deterministic genesis#1448

Merged
christso merged 1 commit into
mainfrom
fix/results-stable-genesis
Jun 19, 2026
Merged

fix(results): root results branch at a stable deterministic genesis#1448
christso merged 1 commit into
mainfrom
fix/results-stable-genesis

Conversation

@christso

Copy link
Copy Markdown
Collaborator

Summary

Makes the git-native results branch (e.g. agentv/results/v1) a self-rooted orphan with its own, stable history — first results push builds on a fixed genesis, and the branch is never based on main. This mirrors entire-cli's entire/checkpoints/v1 model (and the single-ref/append philosophy beads uses over Dolt's refs/dolt/data).

Problem

createOrphanResultsBranch minted the genesis with git commit-tree <empty-tree> without pinning author/committer dates, so the root SHA embedded wall-clock time and was non-deterministic. In the containerized deploy — which clones eval repos --depth=1 --filter=blob:none --single-branch --branch master and re-clones every boot — the results branch is never present locally, and the publish path didn't fetch it by name. So each boot minted a different divergent orphan root and pushes were rejected non-fast-forward / reconciled by replacing the base ("uses the latest base") instead of all clients sharing one genesis and appending.

Fix (3 parts)

  1. Deterministic genesis: createOrphanResultsBranch pins identity and dates to epoch @0 +0000 → byte-identical empty-tree root SHA everywhere. (Stricter than entire-cli, which uses time.Now().) Concurrent first-inits converge by fast-forward instead of diverging.
  2. Root + append: brand-new branches root at that genesis and parent the first run commit on it (own, independent history).
  3. Detect-remote-first: fetchResultsRepo now also fetches refs/heads/<branch> by name (tolerant of absence) across publish/checkout/sync/WIP paths, so shallow single-branch clones discover the remote tip and append; the genesis is created only when the branch is truly absent on the remote.

Compatibility

No one-time re-init needed — existing branches keep their root via the append path (we base on the remote tip, whatever it is). The flat runs/ layout and missing-branch tolerance (#1439) are untouched.

Testing

  • Full core bun test: 1911 pass / 0 fail (results-repo.test.ts 36/36, +4 new); tsc --noEmit 0 errors; biome check clean; bun run build success.
  • New tests assert: self-rooted orphan (empty-tree genesis, zero parents, main not an ancestor — incl. the simulated shallow --single-branch publish); genesis determinism across wall-clock times; append-from-fresh-clone preserves the root; two independent first-inits reconcile onto one shared genesis.
  • Manual UAT (tmp-git deploy reproduction): post-fix the remote branch has a single empty-tree root dated 1970-01-01, history genesis → expA → expB, master not an ancestor, and the second shallow-clone boot's push now succeeds by appending (previously rejected).

🤖 Generated with Claude Code

The git-native results branch (default agentv/results/v1) must be a
self-rooted orphan whose first push is its first commit, building its own
history independent of main/master. Two defects broke this:

1. Non-deterministic genesis. The orphan init (and the first run commit on
   a brand-new branch) embedded the current wall-clock date, so the root
   SHA differed per machine/clone. Each client that initialized the branch
   minted a different root → divergent histories → pushes replaced the
   remote with the newest base instead of all clients sharing one genesis.

2. Shallow single-branch clones never detected the remote branch. The
   containerized deploy clones eval repos with
   `--depth=1 --single-branch --branch <default>`, whose fetch refspec
   covers only the default branch. `git fetch --prune` never brought in
   agentv/results/v1, so every boot re-rooted a fresh divergent orphan and
   the push was rejected non-fast-forward.

Fix (entire-cli entire/checkpoints/v1 single-ref/append model):

- createOrphanResultsBranch now mints a byte-identical empty-tree genesis
  with fixed identity and epoch author/committer dates, so two inits at
  different wall-clock times — on different machines — yield the same root.
- Brand-new branches root at that genesis and parent the first run commit
  on it (instead of the run commit being the parentless root), so
  independent first-inits converge on one genesis and reconcile by
  fast-forward instead of producing divergent orphans.
- The publish/checkout/sync paths now fetch refs/heads/<branch> by name
  (tolerant of absence) so shallow single-branch clones detect the remote
  tip and append to it. The genesis is created only when the branch truly
  does not exist on the remote.

Existing branches with the old non-deterministic root keep that root via
the append-to-remote path (we base on whatever the remote tip is); no
one-time re-init is needed. The flat runs/ layout and missing-branch
tolerance (#1439) are preserved.

Tests: self-rooted orphan with empty-tree genesis and no main ancestry
(incl. simulated shallow single-branch clone), genesis determinism across
wall-clock times, append-from-fresh-clone preserves the root, and two
independent first-inits reconcile onto one shared genesis.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying agentv with  Cloudflare Pages  Cloudflare Pages

Latest commit: ccdd939
Status: ✅  Deploy successful!
Preview URL: https://40a1077d.agentv.pages.dev
Branch Preview URL: https://fix-results-stable-genesis.agentv.pages.dev

View logs

@christso christso merged commit 9b65fbb into main Jun 19, 2026
8 checks passed
@christso christso deleted the fix/results-stable-genesis branch June 19, 2026 12:46
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