From 03530f9bf47c06ce95005a79b2820741e8575637 Mon Sep 17 00:00:00 2001 From: Christopher Tso Date: Wed, 24 Jun 2026 16:25:51 +0200 Subject: [PATCH 1/4] feat(results): replace force-push with artifact-aware auto-merge sync loop Phase 0 (av-raf.1): register a tiny dependency-free `agentv-json` 3-way JSON merge driver and mirror union/agentv-json merge attributes into the AgentV-owned results checkout (committed `.gitattributes` for portability plus repo-local `info/attributes` so local merges always apply the drivers). Append-only run indexes union-merge; editable tag/feedback overlays set/field-union, and a genuine scalar conflict falls through to a human merge. Phase 1 (av-raf.2): rewrite resolveResultBranchPushConflict as a bounded fetch -> merge -> push loop. Fast-forward when possible, otherwise commit a real 3-way merge (working-tree merge on a checked-out branch, merge-tree+update-ref on a detached storage branch) and fast-forward the canonical branch onto it; retry benign push races. A genuine conflict aborts the merge and returns a distinct `needs_human_merge` blocked outcome. Never force-pushes and never creates a backup ref. `push_conflict_policy: backup_and_force_push` is deprecated: it is kept for config back-compat but now auto-merges (no force) and warns once. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- packages/core/src/evaluation/results-repo.ts | 583 +++++++++++++++---- 1 file changed, 484 insertions(+), 99 deletions(-) diff --git a/packages/core/src/evaluation/results-repo.ts b/packages/core/src/evaluation/results-repo.ts index 3f1d070b9..25ea43d79 100644 --- a/packages/core/src/evaluation/results-repo.ts +++ b/packages/core/src/evaluation/results-repo.ts @@ -66,6 +66,127 @@ const RESULTS_REPO_GENESIS_MESSAGE = 'chore(results): initialize AgentV results const RESULTS_REPO_GENESIS_DATE = '@0 +0000'; const RESULT_INDEX_FILENAME = 'index.jsonl'; +// Artifact-aware merge config for the AgentV-owned results checkout. These two +// pieces let `git merge` reconcile concurrent result writes automatically so +// results sync never has to force-push (see resolveResultBranchPushConflict): +// - `.gitattributes` (committed on the results branch) maps the append-only +// run index to git's stock `union` driver and the editable JSON overlay to +// our `agentv-json` driver. +// - `merge.agentv-json.driver` (registered once in the checkout's local git +// config) points at a tiny 3-way JSON set/field union script. +// Run bundles under runs///** are uniquely pathed, so a 3-way merge +// never conflicts on them and they need no attribute. +const RESULTS_REPO_GITATTRIBUTES_FILE = '.gitattributes'; +const RESULTS_REPO_GITATTRIBUTES_CONTENT = `# Managed by AgentV. Artifact-aware merge so results sync never force-pushes. +# Append-only run index: union concurrent appends (lines are orthogonal). +index.jsonl merge=union +# Editable run overlay (tags/feedback): 3-way JSON set/field union via the +# agentv-json driver; a genuine scalar conflict falls through to a human merge. +metadata/runs/**/*.json merge=agentv-json +`; +const RESULTS_JSON_MERGE_DRIVER_NAME = 'agentv-json'; +// Materialized into the results checkout's git dir and invoked by git as +// `node