Repository navigation
fix: keep command tests independent of ambient Gateway tokens - #118577
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 3, 2026, 4:36 AM ET / 08:36 UTC. ClawSweeper reviewWhat this changesThe branch makes Gateway-token command tests explicitly control their environment so credentials inherited from a runner cannot alter their expected outcomes. Merge readinessKeep this PR open for maintainer handling: current main still has the ambient-environment dependency, while the branch makes the two affected test boundaries explicit without changing production Gateway authentication or service-repair behavior. The linked issue remains open until this candidate fix lands. Priority: P2 Review scores
Verification
How this fits togetherGateway authentication resolves its token from configuration plus an environment object, while Doctor's Gateway-service repair reads the process environment to determine the expected service token. These command tests simulate those paths; their setup must isolate runner state so test results reflect only the case being modeled. flowchart LR
A[Runner environment] --> B[Command test setup]
B --> C[Gateway auth command]
B --> D[Doctor service repair]
C --> E[Token resolution]
D --> E
E --> F[Expected test assertions]
Decision needed
Why: The patch appears to be the narrow owner-boundary repair, but the protected Before merge
Agent review detailsSecurityNone. PR surfaceTests +7. Total +7 across 2 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the runtime token contract unchanged, merge the focused test-boundary isolation once required current-head checks are resolved, then let the linked regression close after the merge. Do we have a high-confidence way to reproduce the issue? Yes. Current source proves both command paths consume the ambient environment, and the PR provides a deterministic forced-token command and before/after terminal results; this read-only review did not rerun the suite. Is this the best way to solve the issue? Yes. The patch fixes the owner boundary by making test inputs explicit while retaining the intentional production environment-resolution contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0cad02313a9c. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Land-ready at
|
|
Merged via squash.
|
…ion-routing * origin/main: refactor(agents): remove stale runner state plumbing (#118495) test(gateway): skip servers for handler fixtures (#118581) test(tui): reuse real gateway PTY fixture (#118567) fix: keep command tests independent of ambient Gateway tokens (#118577) fix: show effective channel model in Telegram status (#118548) test(system-agent): reuse approval CLI fixture (#118572) test(macos): deduplicate Claude session catalog fixtures (#118571)
…aw#118577) * test(commands): isolate missing gateway token environment * test(commands): isolate doctor gateway token environment
Closes #118574
What Problem This Solves
Fixes an issue where command-suite validation would fail on credential-hydrated runners when
OPENCLAW_GATEWAY_TOKENwas present in the ambient environment. Correct production auth resolution changed six unrelated doctor staging assertions and made a missing-token CLI test resolve instead of reject.Why This Change Was Made
The test boundary now owns the state it depends on. The missing-token CLI case injects an empty environment explicitly, while the doctor Gateway-service suite clears and restores the Gateway token around each test; cases that intentionally exercise the token still set it through the tracked environment helper. Runtime token precedence and service-repair behavior are unchanged.
User Impact
There is no runtime behavior change. Maintainers and CI receive deterministic command-suite results regardless of Gateway credentials available on the runner.
This PR is AI-assisted with Codex. I reviewed the implementation and understand the changes.
Evidence
OPENCLAW_GATEWAY_TOKEN=ambient-test-token node scripts/run-vitest.mjs src/commands/gateway-auth-token.test.ts src/commands/doctor-gateway-services.test.tsfailed 6 of 80 assertions in the doctor suite while the auth-token suite exposed the same ambient-state dependency.tbx_01kz395mx0a1px4c5zrg2q5b3cpassed typecheck, lint, formatting, environment/max-lines ratchets, dependency pins, architecture boundaries, and dead-export checks. Run: https://github.com/openclaw/openclaw/actions/runs/30794620596tbx_01kz39hznhe52w80fxetk7cs0cpassed commands-light 463/463 and full commands 3,717 passed with 3 intentional skips (3,720 total). Run: https://github.com/openclaw/openclaw/actions/runs/30795029764f3b5718ae80534c0be874113ba8fe705e82abb41. Run: https://github.com/openclaw/openclaw/actions/runs/30796088862The Testbox wrapper returned exit 0 for both successful remote commands. Their backing Actions run may show cancellation after external lease cleanup because Blacksmith owns the delegated session lifecycle.