Repository navigation
test(gateway): isolate instance fixture from caller env and torn reads - #131
Merged
Merged
Conversation
The in-process worker hands its own environment to native harnesses, so the instance fixture inherited the provider variables of whoever ran the tests. In an agent session (ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL, CLAUDE_*) every native turn looked proxied and the native→proxy→native checks failed with proxy: true. The fixture now removes the caller's provider variables for its lifetime and restores them on close. The test also polls probe.jsonl while harness processes append to it. A read in the middle of an append sees a torn last line, and the strict JSON decode threw "Expected a valid JSON string" (the GROK CI flake on #115; its switches were then never audited, so the audit test saw 4 rows instead of 6). Only newline-terminated lines are parsed now. Related: #85
This was referenced Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes two causes of flaky failures in
tests/integration/instance-changes.test.ts. Both are in the test fixture; product code is unchanged.ANTHROPIC_AUTH_TOKEN,ANTHROPIC_BASE_URLorCLAUDE_*(for example an agent session) made every native turn look proxied, so the native→proxy→native checks failed. The fixture now removes provider variables (ANTHROPIC_,CLAUDE,CODEX_,OPENAI_,XAI_,GROK_) while it runs and restores them on close.probe.jsonlwhile harness processes append to it. A read could catch half a line, and the strict decoder threwExpected a valid JSON string. Grok's instance switches were then never audited, so the audit test saw 4 rows instead of 6. Only lines that end with a newline are parsed now.No sleeps, retries, raised timeouts or weaker assertions.
Related: #85