Skip to content

fix(runner): Grok environment allowlist, auth only from preflight, Grok login and model listing (#141, #142, #131, #132) - #150

Merged
mergify[bot] merged 5 commits into
mainfrom
fix/runner-grok-env-and-failure-classes
Oct 11, 2026
Merged

mergify[bot] merged 5 commits into
mainfrom
fix/runner-grok-env-and-failure-classes

Conversation

@ericlitman

@ericlitman ericlitman commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

Closes #141
Closes #142
Closes #131
Closes #132

Summary

Four runner fixes in one PR, one commit per issue. All four change run.ts or its provider-dispatch.md paragraph.

 childEnvironment(provider, mode)
+  grok -> only PATH HOME USER LOGNAME SHELL TMPDIR LANG TERM COLORTERM TZ,
+          proxies (both cases), SSL_CERT_FILE SSL_CERT_DIR NODE_EXTRA_CA_CERTS,
+          LC_* XDG_* GROK_* XAI_*                                 # #141, both modes
-  grok -> parent env minus Codex and Claude identity variables
   claude/codex -> unchanged (Claude writers still drop GIT_*)

 preflightPassed(grok)
-  "logged in" | "You are using XAI_API_KEY."
+  "logged in" | "You are using XAI_API_KEY." | "You are authenticated via deployment key."   # #131
 grokModelAvailable(output, model)
-  model anywhere in `grok models` output
+  model on a line under "Available models:"; no header -> unavailable   # #131

 nonzero child exit after the model call
-  unavailableStatus(output)   # auth regex could match the child's own work
+  modelFailureStatus(output)  # "unavailable-model" | "child-failed"   # #142
 preflight output
   unavailableStatus(output)   # auth classification stays here only

provider-dispatch.md now describes the Grok allowlist, the three Grok login lines, the listing rule, and the auth-only-at-preflight class rule. It also restates the malformed-output classes: malformed-output/65 after a zero exit, and the ordinary classification after a nonzero exit (#132). The design pass for each issue is recorded on #141, #142, #131 and #132.

Evidence

New tests that fail on the old run.ts and pass on this head. The lane checked each by reverting only run.ts:

Live, real grok 1.0.46, grok.com login, macOS, Claude parent, grok-4.7 at low effort. Each lane ran with PSTACK_CANARY=do-not-leak GROK_PSTACK_CANARY=visible in the parent, and its prompt was to run env and report the PSTACK_ and GROK_PSTACK_ lines. The verdict comes from grepping the runner's own files: the output, the receipt and the raw stdout stream.

Runner Mode Receipt do-not-leak found in GROK_PSTACK_CANARY=visible found in
main 0e2a3ff (before) read-only complete, grok-4.7-build verified, preflight passed output, raw stream output, raw stream
this head 99f90d0 (after) read-only complete, grok-4.7-build verified, preflight passed nowhere output, raw stream
this head 99f90d0 (after) isolated-write complete, grok-4.7-build verified, preflight passed nowhere output, raw stream

The after-runs also show that grok starts, authenticates and calls the model with only the allowlisted environment. The real grok models output passes the new listing rule (#131).

Merge Danger

Door: two-way. The change is runner code only, so a revert restores the old behavior.

Blast Radius: Grok lanes

  • Grok now receives only the allowlisted environment. A Grok setup that depends on any other variable will fail its preflight or its model call. Examples are a custom model env_key, a credential-helper variable, or enterprise TLS settings outside the listed CA variables. Such a failure is loud: a receipt-bearing dropout, not a silent fallback.
  • Claude and Codex lanes keep their environment.
  • A login that expires between the preflight and the model call is now reported as child-failed/70 instead of unauthenticated/77. The CLI's error text stays in the evidence.

Acceptance criteria

Gate results

On 99f90d0, each of these exited 0: install, Bun tests (248 pass, 0 fail), strict typecheck, manifest parse, static invariants, claude plugin validate plugins/pstack, and the verifier's tests, typecheck and Linux-platform replay.

Not verified

  • A deployment-key login against the real CLI. The operator account uses a grok.com login.
  • Grok versions that change the Available models: format. If one does, the lane fails as unavailable-model.

🤖 Generated with Claude Code

@mergify

mergify Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 All 2 merge protections satisfied — ready to merge.

Show 2 satisfied protections

🟢 Queue ready pull requests

Automatically queue non-draft pull requests targeting main after verify, Unfret, and live-gate pass on the head.

  • -draft
  • check-success=Unfret
  • check-success=live-gate
  • check-success=verify

🟢 🚦 Auto-queue

When all merge protections are satisfied and these conditions match, this pull request will be queued automatically.

  • -files~=^\.github/
  • base = main

@greptile-apps

greptile-apps Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[High impact] The PR appears safe to merge, with no actionable issues found.

Summary

This PR limits the environment passed to Grok, accepts deployment-key login, checks models below Available models:, and reserves unauthenticated for preflight failures.

  • Grok calls receive only a selected set of environment variables.
  • Grok preflight checks login and the requested model listing.
  • Model-call failures use the child result, not login wording.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Grok lane] --> B[Filter environment]
  B --> C[Run authentication and model preflight]
  C -->|Authentication fails| D[One bounded retry]
  D -->|Still fails| E[Write dropout receipt]
  C -->|Model missing| E
  C -->|Passes| F[Run model once with filtered environment]
  D -->|Passes| F
  F --> G{Model result}
  G -->|Valid success| H[Write output and receipt]
  G -->|Failure| I[Keep evidence and write failure receipt]
Loading

Reviews (1) · Last reviewed commit: "fix(runner): pass Grok lanes only an all..." · Reviewed by Greptile

@unfret-eal

unfret-eal Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

✅ No blocking findings

Walkthrough

This PR tightens how the provider runner launches and classifies Grok lanes. Grok's preflight and model call now get only an allowlisted environment (basic shell, locale, proxy and CA variables, plus anything prefixed `LC_`, `XDG_`, `GROK_` or `XAI_`) instead of the full parent environment minus harness identity markers. Preflight also accepts a deployment-key login, and it counts a model as available only when it is listed under the `Available models:` header. A nonzero exit from the model call is no longer classified as `unauthenticated`/77 just because its output mentions authentication. It becomes `child-failed`/70 or `unavailable-model`/69, so auth classification now happens only during preflight. `provider-dispatch.md` is updated to match. The PR adds tests for each change and renames the fake CLI's control variables to `GROK_FAKE_*` so they survive the new allowlist.

Area What changes
Grok environment `childEnvironment` returns only allowlisted variables for Grok in both access modes. Claude and Codex keep the parent environment minus the other harness's identity markers, and a Claude writer still loses `GIT_*`.
Grok preflight Recognizes `You are authenticated via deployment key.` as a login. The model must appear on a line after `Available models:`. A model named only on the `Default model:` line, or output with no header, yields `unavailable-model`/69.
Failure classification After the model call, a nonzero exit uses the new `modelFailureStatus` and can only be `unavailable-model` or `child-failed`. A login that expires mid-run now reports `child-failed`/70, with the CLI's error text kept in the evidence.
Tests Adds tests for the five auth phrases on stdout and stderr, the Grok listing and deployment-key cases, an env-canary check in both modes, and malformed terminal output that carries auth text after exit 1. It also converts existing preflight fixtures to the header-based listing format.
Details
Lane / stage Model Effort Outcome Duration
broad-gpt-5.6-sol-xhigh / review openai/gpt-5.6-sol → gpt-5.6-sol · primary xhigh succeeded 2 min 48 s
broad-opus-5.5-max / review anthropic/claude-opus-5-5 → claude-opus-5-5 · primary max succeeded 6 min 34 s
focal-gpt-5.6-sol-xhigh copy / review openai/gpt-6.1-sol → gpt-6.1-sol · primary xhigh succeeded 4 min 55 s
focal-gpt-5.6-sol-xhigh copy 2 / review openai/gpt-6.1-sol → gpt-6.1-sol · primary xhigh succeeded 3 min 36 s

First review of this pull request.
4 reviewers finished.
Commit 99f90d0.
Check run.
Run: GET /unfret/run/panel:99f90d08f3418e02fa0024a7f6f547e28bdf44a2:1ljQgmdGT6q:RToWeh1GvbY.

@unfret review · @unfret status · @unfret help

@unfret-eal unfret-eal Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No blocking findings
Check

@ericlitman

Copy link
Copy Markdown
Owner Author

Live evidence: Open Pstack

  • Candidate SHA: 99f90d08f3418e02fa0024a7f6f547e28bdf44a2
  • Base SHA: 0e2a3ffed00f93b27afbcd9f3852197a1fb3d63f
  • Result: PASSED — named features verified
  • Self-test: not requested
  • Publisher revision: 0e2a3ffed00f93b27afbcd9f3852197a1fb3d63f
  • Evidence-set SHA-256: e94ecccc534c826681cc974d7ba3da69478c6edfd13db2ba321e8b0176c9c9d2
  • Installation (claude): CLI 2.1.289 (Claude Code), plugin 1.6.1, candidate 99f90d08f3418e02fa0024a7f6f547e28bdf44a2, tree 9a233e8db7a3d579899b8a78dd187eb7ab4092646ae1e4f1be930bb914efce48.
  • Installation (codex): CLI codex-cli 0.159.0, plugin 1.6.1, candidate 99f90d08f3418e02fa0024a7f6f547e28bdf44a2, tree 9a233e8db7a3d579899b8a78dd187eb7ab4092646ae1e4f1be930bb914efce48.
  • Observation (claude / runner): surface claude -p stream-json with the candidate plugin-dir; action recipe runner: route-1; result passed: route-1:exit-0 route-1:runner-ran route-1:receipt-complete route-1:route:grok:grok-4.7@low route-1:file:lane-1.output.md; 5 assertions machine-checked; transcript SHA-256 78c73000ec0ecdb22a3c2ac370e56617f5b46ad6fbd2ec199868c73a31cebabb; artifact-set SHA-256 e7dbd15bed6eedd28746319e795753b20620d363cbadf24e897caecf966c9f8e.
  • Observation (codex / runner): surface codex exec --json with the run-owned candidate installation; action recipe runner: route-1; result passed: route-1:exit-0 route-1:runner-ran route-1:receipt-complete route-1:route:grok:grok-4.7@low route-1:file:lane-1.output.md; 5 assertions machine-checked; transcript SHA-256 075aacb1fb3d7fa82530fce5f23a1061d67115c2c0f3e9c94766952814c89ab1; artifact-set SHA-256 a0086a1f3d8cbcd1a2a1c169620343fa564c77508742632ec548ca0906750f11.
  • Policy: every new head requires a fresh run; this verifier does not change PR state, queue, or merge.

@mergify

mergify Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-11 20:15 UTC · Rule: default · triggered by merge protections
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-10-11 20:17 UTC · at 40f10ea8a8ff69391b775b477bb8ba9d35515a7e · merge

This pull request spent 1 minute 26 seconds in the queue, including 1 minute 12 seconds running CI.

Required conditions to merge

@mergify mergify Bot added the queued label Oct 11, 2026
@ericlitman

Copy link
Copy Markdown
Owner Author

Live evidence: Open Pstack

  • Candidate SHA: f7f5a0a3c50a872f03b6a7c4fad4a04991fcb2c6
  • Base SHA: 0e2a3ffed00f93b27afbcd9f3852197a1fb3d63f
  • Result: PASSED — named features verified
  • Self-test: not requested
  • Publisher revision: 0e2a3ffed00f93b27afbcd9f3852197a1fb3d63f
  • Evidence-set SHA-256: 44f51bb131240e904010bcc97073787be840c295f16713ed753fdb4136f48ed1
  • Installation (claude): CLI 2.1.289 (Claude Code), plugin 1.6.1, candidate f7f5a0a3c50a872f03b6a7c4fad4a04991fcb2c6, tree 9a233e8db7a3d579899b8a78dd187eb7ab4092646ae1e4f1be930bb914efce48.
  • Installation (codex): CLI codex-cli 0.159.0, plugin 1.6.1, candidate f7f5a0a3c50a872f03b6a7c4fad4a04991fcb2c6, tree 9a233e8db7a3d579899b8a78dd187eb7ab4092646ae1e4f1be930bb914efce48.
  • Observation (claude / runner): surface claude -p stream-json with the candidate plugin-dir; action recipe runner: route-1; result passed: route-1:exit-0 route-1:runner-ran route-1:receipt-complete route-1:route:grok:grok-4.7@low route-1:file:lane-1.output.md; 5 assertions machine-checked; transcript SHA-256 537ba1478cee99d3a97628728b09849ee0a7571af5c543ecba3f21271b3bd19a; artifact-set SHA-256 eb15136a77425de0a642ca8150b8dffd76703381917f4f896c4f6ec4b540cad6.
  • Observation (codex / runner): surface codex exec --json with the run-owned candidate installation; action recipe runner: route-1; result passed: route-1:exit-0 route-1:runner-ran route-1:receipt-complete route-1:route:grok:grok-4.7@low route-1:file:lane-1.output.md; 5 assertions machine-checked; transcript SHA-256 836d4a8c7c364d3b2e0102b4381344a7d106e07ed46eac4843168b634e2ba782; artifact-set SHA-256 5f56a5fe56da31efe6ff089a211d3ad372f7586f90930c31f6e4322de7575cb9.
  • Policy: every new head requires a fresh run; this verifier does not change PR state, queue, or merge.

@mergify
mergify Bot merged commit 40f10ea into main Oct 11, 2026
5 checks passed
@mergify mergify Bot removed the queued label Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant