feat(miner-hands): parse Codex's JSONL stdout for its real error object in the CLI-subprocess driver (#5169) - #5262
Conversation
…ct in the CLI-subprocess driver (JSONbored#5169) Ports src/selfhost/ai.ts's codexErrorFromStdout scanner (and its adjacent auth-failure special case) into cli-subprocess-driver.ts (redeclared, not imported, per this file's no-src-import convention). Codex's stderr is typically just an uninformative "Reading prompt from stdin..." startup banner; the real error lives in its JSONL stdout. On a non-zero exit from codex, the driver now scans stdout in reverse for a structured error object and prefers it over the generic exit-code/stderr error when found. When no structured detail is found AND stderr is exactly the stdin-reading banner, that specific combination means auth.json was present at boot but is now missing or expired -- the driver resolves this to a distinct, actionable "run `codex auth`" remediation instead of a useless exit-code string. Any other case (no detail, different stderr) falls back to today's raw stderr-based shape unchanged. The folded error passes through the same knownSecrets-aware redactSecrets call every other error path here uses.
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5262 +/- ##
=======================================
Coverage 94.36% 94.36%
=======================================
Files 474 474
Lines 40096 40114 +18
Branches 14620 14627 +7
=======================================
+ Hits 37836 37854 +18
Misses 1585 1585
Partials 675 675
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ Gittensory review result - approve/merge recommendedReview updated: 2026-07-12 12:28:36 UTC
✅ Suggested Action - Approve/Merge
Review summary Nits — 5 non-blocking
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
[BETA] Chat with GittensoryAsk Gittensory a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://gittensory.aethereal.dev/docs/gittensory-commands 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Summary
${command}_exit_${code}: ${stderr}error shape surfaces nothing useful when acodex-cliattempt fails. The real error object lives in Codex's JSONL stdout instead.codexErrorFromStdout-style scanner fromsrc/selfhost/ai.tsintopackages/gittensory-engine/src/miner/cli-subprocess-driver.ts(redeclared, not imported -- this package stays standalone per the file's own header comment). Scans stdout lines in reverse for a structured error object (error/message/msg/error.messageshapes) on a non-zero exit fromcodex-- no new process spawned, purely reading already-captured stdout.auth.jsonwas present at boot but is now missing or expired. The driver resolves this to a distinctcodex_no_auth: ... run \codex auth` to authenticate` remediation instead of a useless exit-code string.knownSecrets-awareredactSecretscall every other error path in this driver already uses.Test plan
npx vitest run test/unit/cli-subprocess-driver.test.ts-- 25/25 passing, including the newdescribe("Codex JSONL stdout error diagnostics (#5169)", ...)block: real error object preferred over generic error, reverse-scan picks the last detail-bearing line while skipping malformed/non-JSON/blank lines, nestederror.messageshape, falsy (empty-string)errorfield falls through to the next field, the auth-failure remediation case, the regression fallback when nothing is parseable and stderr isn't the exact banner, non-codexcommand never scans stdout, and an invariant that a folded JSONL-detail error is never left unredacted.npx vitest run test/contract/coding-agent-driver-parity.test.ts-- 18/18 passing (unaffected).npx vitest run test/unit/coding-agent-miner.test.ts-- 57/57 passing (unaffected).npm --workspace @jsonbored/gittensory-engine run build-- clean.npm run typecheck-- clean.COVERAGE_NO_THRESHOLDS=1 npx vitest run test/unit/cli-subprocess-driver.test.ts --coverage --coverage.include="packages/gittensory-engine/src/miner/cli-subprocess-driver.ts"-- 100% statements/branches/functions/lines.npm run docs:drift-check-- clean.npm run test:coveragelocally (shared/resource-contended machine); relying on CI's Codecov patch-coverage gate plus the isolated-coverage check above.Fixes #5169.