Skip to content

test: isolate provider-home env vars so developer shells cannot leak sessions - #1064

Merged
iamtoruk merged 2 commits into
getagentseal:mainfrom
avs-io:fix/test-isolate-provider-homes
Aug 21, 2026
Merged

iamtoruk merged 2 commits into
getagentseal:mainfrom
avs-io:fix/test-isolate-provider-homes

Conversation

@avs-io

@avs-io avs-io commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Fixture-based tests parse the developer's real provider sessions whenever a data-dir override is set in the shell. The named hole is HERMES_HOME: vitest setup redirects HOME into a sandbox but left HERMES_HOME intact, so src/providers/hermes.ts (override ?? process.env['HERMES_HOME'] ?? ~/.hermes) reads the live Hermes DB. That is green on CI (no HERMES_HOME) and red on a Hermes-shell laptop — 50 local failures in one wave, all pre-existing, none from product code.

This is not a Hermes-only spelling. PROVIDER_ENV_VARS already fingerprints the override for cache invalidation; eight other entries in that map were equally missing from the test CLEARED list.

Root cause

tests/setup/env-isolation.ts claims to delete every provider's explicit override. The list was maintained by hand and drifted from PROVIDER_ENV_VARS. There was no guard that a new *_HOME / CODEBURN_*_DIR in the fingerprint map also has to be isolated.

Change

  • Clear the missing data-dir overrides: HERMES_HOME, DSH_HOME, KIMI_CODE_HOME, LINGTAI_HOME, LINGTAI_TUI_HOME, LINGTAI_TUI_GLOBAL_DIR, QUICKWORK_HOME, CODEBURN_OPEN_DESIGN_DIR, CODEBURN_OPENCLAUDE_DIR.
  • Also clear CODEBURN_COPILOT_GLOBAL_STORAGE_DIR next to the other Copilot dir overrides already on the list (Copilot stays undeclared in PROVIDER_ENV_VARS on purpose).
  • Add tests/env-isolation-declarations.test.ts: every PROVIDER_ENV_VARS entry must appear in CLEARED ∪ REDIRECTED. Sabotage: drop HERMES_HOME from CLEARED → the new test fails with hermes:HERMES_HOME.

User impact

None for codeburn status / caches / pricing. Developers running the suite inside a Hermes (or Lingtai / DSH / …) shell no longer ingest live session DBs into fixture parses.

Preservation

No src/ change. No CACHE_VERSION / parse-version bump. CODEBURN_PRICING_SNAPSHOT_ONLY and CODEBURN_FX_NO_FETCH stay forced-on (not cleared). Copilot remains undeclared in PROVIDER_ENV_VARS. No Keychain / Buzz / #868 / #916 / #998. Does not invent rates.

Testing

  • 1 new declaration test; sabotage proven
  • tests/provider-env-declarations.test.ts (3)
  • tests/providers/hermes.test.ts (26) + tests/hermes-pr-links-pipeline.test.ts (1)
  • sibling provider suites whose homes were added: dsh, kimicode, lingtai-tui, open-design, openclaude, quickdesk
  • Extra High MERGE AFTER FIX (/tmp/codeburn-xhigh-review/VERDICT-1064.md): source-scrape treated a comment containing 'HERMES_HOME' as isolation. Follow-up 094f9f1 moves CLEARED/REDIRECTED to a side-effect-free module that applyIsolation and the guard both import. Comment-only sabotage now fails with hermes:HERMES_HOME.
  • 31 focused tests after the follow-up; tsc --noEmit clean

avs-io added 2 commits August 21, 2026 18:45
…sessions

HERMES_HOME and eight sibling PROVIDER_ENV_VARS data-dir overrides were
fingerprinted for cache invalidation but never CLEARED by the vitest
setup file, so a Hermes-shell laptop parsed real sessions in fixtures.
A static guard fails closed when the map grows another undeclared home.
Extra High MERGE AFTER FIX: source-scraping the setup file treated a
comment containing 'HERMES_HOME' as isolation. The lists now live in a
side-effect-free module that applyIsolation and the declaration test
both import. Comment-only sabotage fails with hermes:HERMES_HOME.
@iamtoruk
iamtoruk merged commit e12fb39 into getagentseal:main Aug 21, 2026
5 checks passed
iamtoruk added a commit to kelchm/codeburn that referenced this pull request Aug 22, 2026
Resolves the conflicts getagentseal#946 accumulated while it was in validation. Eight
files conflicted; the session-store accounting is unchanged.

src/daily-cache.ts — version collision. This PR minted 25 when main was at
24; getagentseal#1056 (`codex-auto-review` pricing) then spent 25 on main. The bump moves
to 26/MIN 26 and daily-cache.v26.json, with main's full comment ladder kept as
the foundation and this PR's paragraph rewritten to name 26 and record the
collision. PENDING_REDERIVE_PROVIDERS and the B1 migration semantics from
b6481c1 carry over intact, retargeted at 26.

src/models.ts, src/parser.ts, src/audit-report.ts, src/models-report.ts —
getagentseal#1075/getagentseal#1078 replaced the per-site "reasoning is already inside output" tests
with billableOutputTokens() and REASONING_INCLUDED_IN_OUTPUT. This PR had
added copilot to that case at three sites independently. Union: all three
sites take main's helper call verbatim, and copilot joins claude and codex in
the set — same accounting this PR shipped, now through main's single source of
truth. It also reaches parser.ts activeGeneratedTokens (a fourth site, from
getagentseal#1079), which is the same correction: a copilot supplementary call carries
reasoning with output 0, so counting it as generated repeats the per-turn
output. The audit legend already said so on this side.

src/providers/copilot.ts — comment-only. getagentseal#1054's lastEventTimestamp-first
shutdown fallback was derived from this branch, so the code was already
identical on both sides: the `shutdownTimestamp` expression and the
`copilot:<sid>:shutdown:<model>:<n>` key are byte-for-byte main's. Both
rationales are kept (leg-collapse on date, and residual anchoring).

src/session-cache.ts — PROVIDER_PARSE_VERSIONS.copilot takes this PR's
`-session-store-v3` suffix; main's getagentseal#1051 note about why a fingerprint change
is expensive is kept above it. Codex keeps main's getagentseal#1092 suffix chain untouched.

src/main.ts — getagentseal#1067 deleted the unreachable live dailyMap fallback that this
PR had taught behavioral weight. Main's deletion wins; the now-unused
isBehavioralTurn import goes with it.

tests/parser.test.ts — import union.

Also: scripts/upgrade-path/run.mjs NEW_DAILY_CACHE -> daily-cache.v26.json,
CODEBURN_COPILOT_SESSION_STORE_DB added to the getagentseal#1064 env-isolation CLEARED
list, and the CHANGELOG entry's stale "v21" corrected to v26.

Verified: tsc clean; 3132 tests pass across 223 files; test:locks 26/26;
verify:upgrade PASSED, re-deriving daily-cache.v26.json and holding durable
copilot history across the bump. getagentseal#1054's regression ("keeps three stampless
shutdown legs as :n keys with lastEventTimestamp") passes on the merged tree.
Real-corpus A/B against origin/main over 2026-07-01..2026-08-22: codex, grok,
kimicode and opencode byte-identical in export, audit and models; claude drifts
only monotonically with run order (a live session writing transcripts, confirmed
by interleaving four runs). This machine has no copilot data, so the copilot
recovery semantics rest on the suites and the upgrade-path corpus.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants