Skip to content

chore(github): timeout the gh auth status probe — the last un-timed network execSync (#1075 follow-up) #1099

Closed

Description

@admarble

What happens

GitHubProvider.checkAuthSync() (src/lib/workflow/platforms/github.ts:136) runs execSync("gh auth status", { stdio: "ignore" }) with no timeout. gh auth status reaches the network, so a stalled request or a hung gh hangs every caller with no output and no way out but Ctrl-C. Callers today: src/lib/system.ts:30 (checkGhAuth, used by doctor) and src/lib/upstream/assessment.ts:64.

#1075 bounded the three sibling probes in doctor.ts (opencode --version, codex --version, codex login status) and its QA named this one as "the true cross-file sibling" left out only because GitHubProvider owns gh. This is that follow-up.

Scoped repo-wide before filing: every other un-timed execSync in src/ is local (git …, command -v, which aider). This is the last network-reaching one.

Fix shape

Pass timeout (the #1075 constants are the precedent: 10s for a network-reaching auth check) and let ETIMEDOUT fall into the existing catch → false. No new error handling. Update the two unit tests that assert the exact execSync options (github.test.ts:43, system.test.ts:74).

Release-graph plan — pre-2.16.0 follow-ups (2026-09-19)

Graph: pre-2.16.0 follow-ups Tier: mechanical Wave: 2
May touch: src/lib/workflow/platforms/github.ts, src/lib/workflow/platforms/github.test.ts, src/lib/workflow/platforms/github.integration.test.ts (new), src/lib/system.test.ts, CHANGELOG.md

Acceptance Criteria

  • AC-1: checkAuthSync passes a timeout to execSync — Evidence: grep -A4 '"gh auth status"' src/lib/workflow/platforms/github.ts | grep -c "timeout:" prints 1 (today 0)
  • AC-2: a hanging gh on PATH makes checkAuthSync() return false within the timeout instead of hanging — Evidence: npx vitest run src/lib/workflow/platforms/github.integration.test.ts -t "1099" 2>&1 | grep -E "Tests +[1-9][0-9]* passed" prints a passed line (a sleeping gh stub on PATH, a bounded wall-time assertion, and the result asserted false)
  • AC-3: the existing unit assertions on the exact execSync options are updated, not loosened — Evidence: npx vitest run src/lib/workflow/platforms/github.test.ts src/lib/system.test.ts 2>&1 | grep -E "Tests +[1-9][0-9]* passed" prints a passed line and grep -c "timeout" src/lib/workflow/platforms/github.test.ts src/lib/system.test.ts | grep -vc ":0$" prints 2
  • AC-4: no other network-reaching execSync in src/ is left un-timed — Evidence: grep -rn 'execSync("gh \|execSync(gh ' src --include='*.ts' | grep -v ".test." | wc -l | tr -d " "prints the same number asgrep -rn -A4 'execSync("gh |execSync(gh ' src --include='*.ts' | grep -v "\.test\." | grep -c "timeout:"

AC-2 is a gate test: mutation-verify (drop the timeout option → the case fails its wall-time bound) and record the marker.

Placement note

The sleeping-stub case goes in a new github.integration.test.ts next to github.test.ts — the integration vitest project matches **/*.integration.test.ts anywhere; a file without .integration. runs under the 5s unit budget (#842) and a timeout test will blow it. Stub with exec sleep 25 so the killed child is the direct child (see #1075's PR body).

Activity

  1. added
    enhancement
    on Sep 19, 2026
  2. admarble commented on Sep 19, 2026

    @admarble
    ContributorAuthor

    Runner context (2026-09-19, wave 2 of the pre-2.16.0 graph)

  3. admarble commented on Sep 19, 2026

    @admarble
    ContributorAuthor

    /spec — Plan (#1099)

    Complexity: Standard (4 ACs, 2 directories)

    AC Quality Check

    lintAcceptanceCriteria: 3/4 passed, 1 flagged. AC-4 trips the "open_ended" pattern on the word "other" ("no other network-reaching execSync..."). False positive — the AC carries a fully computable Evidence: clause (two grep -c counts that must match), so "other" is scoped by the grep pattern, not left vague. No action needed.

    Behavior-rule detector: no AC matches (default|always|never|rule|behavior|skip, or an always/never X unless Y pattern) — no Rule Touchpoints section.

    Scope Assessment

    Non-Goals: not present as a section, but the body scopes itself explicitly (single function, "Fix shape" section, exact call sites named). Adequate for a mechanical node.

    Metric Value Status
    Feature count 1 ✅
    AC items 4 ✅
    Directory spread 1 (all under src/lib/) ✅

    Verdict: ⚠️ SCOPE_WARNING (missing Non-Goals section only — every metric is green; not a scope-splitting signal for a 1-function, 1-file fix).


    Acceptance Criteria — verification

    AC-1 — checkAuthSync passes a timeout to execSync
    Verification: Integration Test (grep gate)
    Scenario: Given github.ts:136 → When grep -A4 '"gh auth status"' ... | grep -c "timeout:" → Then prints 1.

    AC-2 — a hanging gh on PATH makes checkAuthSync() return false within the timeout, not hang [GATE]
    Verification: Integration Test (parser infers "unit_test" from keywords, but the Evidence clause targets a new github.integration.test.ts — must live there, not in github.test.ts, per the Placement note)
    Scenario: Given a gh stub on PATH that exec sleep 25s → When checkAuthSync() is called → Then returns false and elapsed wall time stays under a bound comfortably below 25s but above the new timeout.
    Assumptions: execSync inherits process.env.PATH; stub must exec sleep 25 (not fork it) so the killed child is the direct child — a forked grandchild can outlive SIGTERM and hold the pipe open past the timeout (same failure mode #1075 called out).

    AC-3 — existing unit assertions on the exact execSync options are updated, not loosened
    Verification: Unit Test — github.test.ts:43 and system.test.ts:74 currently assert toHaveBeenCalledWith("gh auth status", { stdio: "ignore" }); both must gain timeout: <N> in that same object, not a separate looser matcher (e.g. expect.objectContaining).

    AC-4 — no other network-reaching execSync in src/ is left un-timed
    Verification: Integration Test (grep gate) — confirmed now: grep -rn 'execSync("gh \|execSync(\gh ' src --include='*.ts' | grep -v '.test.'returns exactly one hit,github.ts:136` — the one this issue fixes. No other sibling to sweep in.


    Implementation Plan

    Phase 1 — src/lib/workflow/platforms/github.ts (AC-1)

    1. Add a module constant AUTH_PROBE_TIMEOUT_MS = 10_000 next to checkAuthSync (precedent: chore(doctor/templates): timeout the codex+opencode CLI probes; add the missing templates/codex routing test #1075's AUTH_PROBE_TIMEOUT_MS in doctor.ts, same 10s bound reasoning — gh auth status reaches the network, so a legitimately slow check over a poor link must not be misreported as unauthenticated).
    2. Add timeout: AUTH_PROBE_TIMEOUT_MS to the execSync("gh auth status", { stdio: "ignore" }) call at line 136. No new error handling — Node throws ETIMEDOUT into the existing catch { return false; }, which every caller (system.ts, doctor.ts, upstream/assessment.ts) already treats identically to "not authenticated."

    Phase 2 — src/lib/workflow/platforms/github.integration.test.ts (new file, AC-2)
    3. New file (doesn't exist yet). Mirror #1075's doctor.integration.test.ts stub-on-PATH pattern: describe.skipIf(process.platform === "win32")("checkAuthSync timeout (#1099)", { timeout: 45_000 }, ...).
    4. beforeEach writes a gh stub (#!/bin/sh\nexec sleep 25\n, mode 0o755) into a mkdtemp dir; a withStubPath(fn) helper prepends it to PATH in a try/finally, scoped to the callback (not a file-level hook) so no other case in the suite leaks the stub.
    5. One case, name containing 1099 (the evidence command greps -t "1099"): call new GitHubProvider().checkAuthSync(), assert false and Date.now() - t0 < 15_000 (1.5× the 10s timeout, generous for CI, well under the 25s stub — same ratio #1075 used for its auth-probe case).
    6. Lives in *.integration.test.ts deliberately — the unit project keeps vitest's 5s default (#842) and this case needs up to 10s+.

    Phase 3 — github.test.ts + system.test.ts (AC-3)
    7. Update both toHaveBeenCalledWith("gh auth status", { stdio: "ignore", ... }) assertions (github.test.ts:43, system.test.ts:74) to include timeout: 10000 in the same object literal — an exact-match update, not expect.objectContaining, so the assertion stays a real gate on the option value.

    Phase 4 — mutation verification (AC-2)
    8. Start from git status --short | wc -l = 0 (commit Phases 1–3 first). Drop the timeout: line from github.ts → the new 1099 integration case fails on the wall-time bound (sleeps the full 25s, inside the 45s describe budget — it fails, it does not hang, since execSync is synchronous and vitest cannot interrupt it). Restore, then record Mutation-verified: AC-2 — dropped timeout: AUTH_PROBE_TIMEOUT_MS from checkAuthSync's execSync call; github.integration.test.ts > checkAuthSync timeout (#1099) > ... failed on the elapsed-time assertion; restored. plus its <!-- SEQUANT_MUTATION: {"ac":"AC-2", ...} --> anchor (failedTest must start with src/lib/workflow/platforms/github.integration.test.ts > ...) in the PR body.
    9. Add a ### Fixed bullet under [Unreleased] in CHANGELOG.md, keeping every existing entry.

    Design Review

    1. Where does this belong? Entirely inside GitHubProvider.checkAuthSync() — it already owns the gh auth status call and its catch → false contract; a hang is just a slower form of "not authenticated."
    2. Simplest correct approach? One constant, one option key. Rejected: spawnSync with manual process management (same semantics, more code); wrapping in Promise.race (would force checkAuthSync async, rippling into every sync caller — system.ts, doctor.ts, upstream/assessment.ts — for no user-visible gain, exactly the tradeoff chore(doctor/templates): timeout the codex+opencode CLI probes; add the missing templates/codex routing test #1075 rejected for the same reason).
    3. Existing pattern? chore(doctor/templates): timeout the codex+opencode CLI probes; add the missing templates/codex routing test #1075's AUTH_PROBE_TIMEOUT_MS treatment of codex login status — same "network-reaching, needs a longer bound than a local probe" reasoning, same 10s value.
    4. What would a reviewer challenge? "Why 10s, not 5s?" — same answer as chore(doctor/templates): timeout the codex+opencode CLI probes; add the missing templates/codex routing test #1075: a real but slow gh auth status over a bad connection must not be misreported as unauthenticated, and every caller already tolerates a false checkAuthSync() gracefully (init/doctor print a hint, upstream assessment skips silently).

    Feature Quality Planning

    All standard checks pass. Notable items:

    Sibling-site scan

    Repo-wide grep (execSync("gh \|execSync(\gh , excluding *.test.ts`) returns exactly one hit — the one AC-1 fixes. No further siblings to flag; AC-4 already gates against a regression here becoming untrue later.

    Open Questions

    1. AUTH_PROBE_TIMEOUT_MS = 10_000 — reuse chore(doctor/templates): timeout the codex+opencode CLI probes; add the missing templates/codex routing test #1075's exact value, or define independently? — Recommendation: reuse 10_000 (same constant name pattern, not a shared import — the two modules don't otherwise depend on each other). Impact if wrong: a shared constant would couple doctor.ts and github.ts for no benefit; a different value would need its own justification, and 10s already has one from chore(doctor/templates): timeout the codex+opencode CLI probes; add the missing templates/codex routing test #1075.

    Recommended Workflow

    Phases: exec → qa
    Quality Loop: disabled
    Reasoning: SCOPE_OK on every metric (only the Non-Goals heuristic trips SCOPE_WARNING), 4 tight evidence-bearing ACs, ~2 lines of source plus tests. testgen is deliberately skipped even though AC-2/3 declare test evidence: the tests are the deliverable and are already specified down to the stub script and assertion bounds (mirroring #1075's identical reasoning), so generated stubs would be overwritten immediately. No UI, so no test phase; no new auth/secret surface, so no security-review.

    Label Review

    Current: enhancement
    Recommended: add planned, cli, no-browser-test
    Reason: CLI-surface chore with no UI; no-browser-test makes the skipped test phase explicit rather than inferred (same set #1075 landed with).
    Quality Loop: Won't auto-enable — SCOPE_OK on every metric.

    → gh issue edit 1099 --add-label planned --add-label cli --add-label no-browser-test

  4. added
    planned
    cli
    no-browser-test
    on Sep 19, 2026
  5. admarble commented on Sep 19, 2026

    @admarble
    ContributorAuthor

    Runner note (2026-09-19) — previous exec killed at the 30-minute wall; resuming

    The first exec pass was killed by the MCP phase watchdog while running the full suite (two worktrees plus a third session's suite were sharing the machine). Your WIP checkpoint commits survived in the worktree; the runner restored tracked root files a killed test had moved aside. Resume from the committed state.

    For this resume, in both exec and qa:

    • Do not run the full npm test. Run npm run build, npm run lint, and only the test files this diff touches (plus the AC evidence commands). The runner runs the full suite once before merge and records the result on the PR.
    • Commit before mutation-verifying; record the markers with failedTest starting with the test file path.
    • Open the PR when the ACs pass. Stop at PR.
  6. admarble commented on Sep 19, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

    AC coverage: 0/6 met

    Gaps:

    • The mutation-verification marker the issue body explicitly required is malformed and is rejected as fabricated by the repo's own parser; harmless today only because isGateTestEvidence returns false for AC-2, but it would floor the verdict at AC_NOT_MET if §6i's scope widens per feat(qa): mutation-verification becomes a parseable §7 gate instead of honor-system prose #939 AC-5
    • The PR's recorded pre-existing-failure set does not match the observed one, though both belong to the same known environmental classes (bug(test): suite isn't hermetic against the SEQUANT_* env phases inject — exec sees red tests it didn't cause and opens no PR #1086 env leak, worktree es-toolkit dep gap)
    • chore-prefixed commit subjects silently disable the CHANGELOG quality gate for a user-facing change; the entry exists on author diligence rather than gate enforcement
    • The SEQUANT_MUTATION marker is malformed and this repo's own parser rejects it. The PR body records "failedTest":"1099: a hanging gh makes checkAuthSync() return false within the timeout, not hang" — the test name with no file segment. classifyMutationMarker (mutation-marker.ts:139) does marker.failedTest.split(">")[0].trim() and matches that against the diff's test files; with no > the whole title is taken as the filename and matches nothing. Run against this PR:

    Suggestions:

  7. added a commit that references this issue on Sep 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    clienhancementno-browser-testplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions