Skip to content

fix(flaky): brain-sync auth check ignores the remote URL, browse binds its port after launch, paid-eval clarity repairs (GST-1438) - #4035

Merged
capy-ai[bot] merged 1 commit into
mainfrom
capy/flaky-fix-2026-11-05
Nov 5, 2026
Merged

capy-ai[bot] merged 1 commit into
mainfrom
capy/flaky-fix-2026-11-05

Conversation

@garrytan

@garrytan garrytan commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner
{
  "schema_version": 1,
  "pr": 4035,
  "head": "1cf203fe60e2d68788e4dab6f1049d9e32e8d6f7",
  "version": "1.96.0.0",
  "base": "main",
  "gate": {
    "focused": {
      "pass": 338,
      "fail": 0,
      "skip": 0
    }
  },
  "session_kind": "unattended",
  "head_tree": "9c3dd35ec946bb277723f2f78320da016d3d7a10",
  "product_patch_id": "17413b8ba3cf9b099bd2f3102ff9e991290ec3c6",
  "gstack_version": "1.96.0.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 15,
    "rules": "70895942bb8a8ee2",
    "base": "467be16ab2f8d30ef1008e451c4ccad2814501c3",
    "registry": "467be16ab2f8d30ef1008e451c4ccad2814501c3",
    "gate_scan": {
      "tagged": 0,
      "head": "1cf203fe60e2d68788e4dab6f1049d9e32e8d6f7"
    },
    "reasons": [
      "gate-class",
      "runtime=15"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @9c3dd35ec946 (7 checks, current for 1cf203fe60e2)",
  "requires_remote": [
    "free-tests.yml/cso-macos-launcher: https://github.com/garrytan/gstack/actions/runs/42045682799/attempts/1",
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/42045682799/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/42045682710/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=9c3dd35ec946 tests=35621 skipped=69 runs=42045682799/1 profiles=ci-reuse/free-tests heads=1cf203fe60e2 verified=2026-11-05T15:37:31.782Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "README.md, AGENTS.md, CLAUDE.md, CONTRIBUTING.md, docs/ (plus BROWSER.md, ARCHITECTURE.md read for the port contract)"
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 0,
    "deferred": 0,
    "noted": 1,
    "fixed": 0,
    "scope": "frozen",
    "rounds": 1,
    "ledgers_read": 3,
    "dispatches": {
      "specialist": 1,
      "red-team": 1
    }
  }
}

What changed

brain-sync's auth check now ignores git's To <url> line and quoted URLs, so a remote path like /tmp/x403y no longer skips the fetch-and-merge retry

brain-sync's auth check now ignores git's To <url> line and quoted URLs, so a remote path like /tmp/x403y no longer skips the fetch-and-merge retry.

Before/after as text: brain-sync's auth check now ignores git's To url line and quoted URLs, so a remote path like /tmp/x403y no longer skips the fetch-and-merge retry
--- Before · before.txt · captured output
+++ After · after.txt · captured output
   # Push. On reject, fetch + merge (merge driver handles JSONL) + retry once.
   local push_err
   push_err=$(git -C "$GSTACK_HOME" push origin HEAD 2>&1 >/dev/null) || {
+    # Check if this is an auth error first — no point retrying. The remote's
+    # URL or path (git's "To <url>" line and every quoted '<url>') is not
+    # evidence: a remote under /tmp/x403y or named author-notes would read as
+    # an auth failure and skip the fetch-and-merge retry.
+    if printf '%s\n' "$push_err" | grep -v '^To ' | sed "s/'[^']*'//g" | grep -qiE "auth|permission|403|401|forbidden"; then
-    # Check if this is an auth error first — no point retrying.
-    if echo "$push_err" | grep -qiE "auth|permission|403|401|forbidden"; then
       local hint
 

Why

Free Tests 41847262176 turned eight brain-sync tests red at once because the shard's temporary folder name contained "403", and Free Tests 41951644962 died with "Failed to start server. Is port 43780 in use?". A real user whose sync remote lives under a path like github.com/author/notes hits the first bug too, and the sync stays push_failed until someone pushes by hand. Now the sync retries such pushes, the browse daemon picks its port right before it binds, and three paid evals get clearer prompts or diagnostics.

Blast radius

The brain-sync change only narrows which push errors count as auth failures, so the worst case is one extra fetch-and-merge attempt that fails the same way; a real HTTP 403 still reports as auth (QA capture 004 ran it against a local 403 server). The browse change moves findPort() after browserManager.launch(), and nothing between the launch and Bun.serve reads the port (read at browse/src/server.ts; the only reader of LOCAL_LISTEN_PORT is a request handler, and requests start after the bind). The other edits are tests, eval prompts and a test helper.

Approvals

No approvals recorded for branch capy/flaky-fix-2026-11-05.

Summary

Daily flaky pass for 2026-11-05 (GST-1438). The harvest of the last 24 hours (269 eval and free-test runs) found 5 paid gate-flake records and 5 free retry-passes. This PR repairs six of them. Two are product bugs; the rest are fixture, prompt or diagnostic repairs. No thresholds, trial counts, case kinds or retries change.

Product fixes

gstack-brain-sync misread a rejected push as an auth error when the remote's path contained an auth word. The check searched git's whole error text for auth|permission|403|401|forbidden, and that text includes git's To <url> line and the quoted URL. A remote like github.com/author/notes (or a CI shard folder like /tmp/gstack-free-shard-q403Zx) skipped the fetch-and-merge retry, so the sync stayed push_failed. The check now ignores the To line and quoted spans. Proof: with TMPDIR=/tmp/gstack-free-shard-q403Zx/tmp or …-xAuThq/tmp, main fails two of the #3704 cases with CI's exact messages, and a plain folder name passes. The new remote-path case fails on main and passes here. A true-positive control (The requested URL returned error: 403, with the keyword after git's quoted URL) is still reported as auth and never fetches. Source: Free Tests 41847262176 shard 3 (8 tests red at once).

The browse daemon picked its port seconds before binding it. start() checked that a random port was free, launched Chromium, and only then called Bun.serve. During the launch another process could take the port, and the daemon died with "Failed to start server. Is port 43780 in use?" The port is now picked after the launch, right before the bind, with no await in between. An order test fails on main. Source: Free Tests 41951644962 shard 6 (make-pdf combined-gate).

Fixture, prompt and diagnostic repairs

  • test/gate-reuse.test.ts: the bare origin sets maintenance.auto=false and gc.auto=0, as fix(redact): a short sha is not a phone number or a bc1 wallet; plan-reality receipt and pregate fixture flakes #3998 did for the pregate fixture. A traced push shows child_start … git maintenance run --auto --quiet --detach without them (the new test fails with that line). Source: 41980850843 shard 5, "unable to write file ./objects/3f/…".
  • ship-docsync-store (paid, a repeat): replaying both captures through main's observer one call at a time shows each red is one read line carrying a no-op mkdir stand-in (mkdir -p /dev/null 2>/dev/null, mkdir_check=1). The interface offered "a new directory you create there" without saying how. It now names the one form the observer admits, which is one mkdir <home>/<name> as its own call. Both captured lines stay refused. Focused paid run at 1cf203f (one trial) passed for $0.97, and the model made its folder with mkdir <home>/docs-gate as its own call. Sources: test(flaky): plan-design no-mockup Voices text, docsync private mkdir, autoplan-guard-pty journal on unverified allow #3997 screen 41850017482 slice 2, census 41987975678 slice 4.
  • plan-eng-coverage-audit (paid, a repeat): the first call read SKILL.md, a grep of the section and both files all in one batch, before the model reached the section's "read them in a dedicated tool call" rule (review-sections.md:662). The prompt now asks for the file reads after the skill files. The detector is unchanged. Focused paid run at 1cf203f (one trial) passed for $0.16. The model read the skill and section first, then ran cat -n src/billing.ts && echo -- && cat -n test/billing.test.ts on its own. Source: census 41932813292 slice 5.
  • qa-only-no-fix (paid): cleanup failed with "terminal identity is unavailable", and the artifacts held no daemon log. Cleanup still fails closed, but now names the terminal record, the port file, daemon liveness and how old the state is. It also prints the last terminal-agent lines of browse-server.log; the outside review found that a CLI-spawned daemon writes those lines to browse-daemon.log instead, so that part reads "none" until a follow-up points it at the right file (see Review notes). Source: census 41962523474 slice 10.

Not repaired: ship-docsync-stale-after (41932813292 slice 13) is a correct refusal. The model wrote Step 14.5's record to <shard>/repo/.gstack/tmp/docs-audit.json, which is outside the fixture because it dropped tmp/ds-…/ from the repo path. The review-pass and touch-commands retry-passes came from #4004 runs on a base older than #3998 and #3956, so they were already covered.

Test Coverage

Coverage: deterministic (each of the 2 changed runtime files has a changed test naming it; no audit reader).
Tests ran: focused 338

Pre-Landing Review

No issues at the blocking floor (would fail a test, break production, or lose data or secrets). Specialists (testing, security, state machines) and the Red Team returned no findings; the adversarial pass and the outside voice returned Low notes only, listed below.

REVIEW_LOOP: passes=1 blocking_found=0 deferred=0 noted=1 fixed=0 scope=frozen ledgers_read=3 dispatches=2

Gate edits: none detected (10 listed, 3 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)

Outside review: completed (openai/gpt-6.1-sol, host subagent): "approve with follow-up" for one Low finding.

Review notes

Below the blocking floor; recorded here and not fixed in this PR.

  • INFORMATIONAL test/helpers/qa-only-cleanup.ts:58 (outside voice): the new diagnostic reads browse-server.log, but a CLI-spawned daemon writes terminal-agent output to browse-daemon.log (browse/src/cli.ts:694), so the log part of the message reads "none". One-word follow-up plus a fixture.
  • INFORMATIONAL bin/gstack-brain-sync:1479 (adversarial, core): the classifier still reads ref names in git's ! [rejected] HEAD -> <ref> line, so a branch like oauth-notes still counts as auth; a line with an apostrophe before a quoted span can lose its auth word; and under pipefail a SIGPIPE on more than about 4 KB of push output reads as not-auth. Each case only changes which fallback runs, never loses the locally kept commit.
  • INFORMATIONAL browse/src/server.ts:1948 (adversarial, core): the probe-then-bind gap is now milliseconds, not gone, and an explicit busy BROWSE_PORT now fails after the Chromium launch instead of before it (same message, exit 1, no Chromium left behind per QA capture 005).
  • INFORMATIONAL test/brain-sync.test.ts:470: gitShim resolves the real git with command -v git. On a Capy shared-tree machine that is the guard wrapper, which execs the first git on PATH (the shim), so the two exec each other forever and the file hangs. CI has no wrapper; this predates the diff, and the new auth test reuses the helper.

Exploratory QA

Functional surface (CLI), smoke budget 300 s, 6 captures in an owned fixture under the run directory:

  • Capture 003, pass: a rejected push to …/x403y-oauth-permission/author-401-forbidden.git fetched, merged and pushed (pushed 1 file(s) after rebase; the remote holds both files and a merge commit).
  • Capture 004, pass: pointing origin at a local server that answers 403 gives push_failed with "push failed: auth error", and nothing reaches the remote.
  • Capture 005, pass: the browse daemon with a busy BROWSE_PORT exits 1 with "Port … is in use" and leaves no Chromium behind.
  • Capture 006, inconclusive: with BROWSE_PORT=0 the partial output shows the state-file port listening and /health 200, but the capture ended when the probe stopped the daemon. The focused lane's real-Chromium qa-only-cleanup cases cover the same start (pass).
  • Captures 001 and 002, superseded: they inherited the gstack launch file's ephemeral state variables, which make the drain a no-op.

Limits: the evidence tool's materialize step refused the run because capture 006 has no receipt, so these links are this summary rather than a generated report.

Design Review

No frontend files changed — design review skipped.

Eval Results

The PR profile selects 113 of 266 paid cases across 84 shards (scripts/test-paid-shards.ts --tier gate --profile pr --list), because bin/gstack-brain-sync is a derived reference for every gate case. That is over this lane's $8 dispatch cap, so it was not run here; the merge train's full gate covers it. The two prompt changes were run as focused paid cases at 1cf203f: ship-docsync-store passed its one trial ($0.97) and plan-eng-coverage-audit passed its one trial ($0.16).

Review bot comments

No review bot comments.

Scope Drift

Scope Check: CLEAN

Plan Completion

Plan completion audit: not run (no plan is bound to this branch and no docs/designs/ file matches). Fix: add "Plan: " to the PR body, or run /autoplan.

Verification Results

No plan-specific verification items (no plan file); automatic QA results are under Exploratory QA.

TODOS

No TODO items completed in this PR.

Documentation

Scope: the diff from base 467be16 to head 1cf203f. It has 12 files: a brain-sync push-error check, a browse daemon port-selection reorder, test fixtures, and a changelog.d fragment. Result: current, no doc edits. The fragment already describes every user-visible change. The only docs that mention port selection (BROWSER.md, ARCHITECTURE.md) describe the 10000–49151 range and collision retry, and neither says when the port is chosen, so they stay accurate. docs/gbrain-sync-errors.md and docs/gbrain-sync.md describe the push_failed status and its auth hint; the change only stops URL text from triggering the auth branch, so they are unchanged. Debt: none found.

Test plan

  • Focused lane (bun test on the six changed test files, with the launch variables and the Capy git guard removed from the environment): 338 pass, 0 fail
  • Free Tests at 1cf203f (run 42045682799, carried by the pregate): green, including the macOS lanes; Windows Smoke run 42045682710: green
  • Pregate guards: typecheck, module-size, conflict markers pass; secrets stage warns on 13 MEDIUM pii.phone.e164 matches, all of them CI run ids

Open in Capy

…s its port after launch, three paid-eval clarity repairs (GST-1438)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@trunk-io

trunk-io Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

@capy-ai
capy-ai Bot merged commit 8a51aeb into main Nov 5, 2026
47 checks passed
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