test: main-suite hygiene — env-dependent failures skip cleanly, broken ones fixed (#1532) - #1533
Merged
Merged
Conversation
… under every runtime bun resolves unqualified executables from the spawn's env OPTION when given, else the process-START env snapshot — never later process.env mutations. The default inheritance therefore froze the PATH lookup at startup under bun, breaking the fake-transport injection the B1 hermetic tests rely on (they mutate PATH, not pass env). Passing env: process.env explicitly is byte-identical inheritance under node and makes the live PATH (and the tests' injection) effective under both runners.
…un's native toml parsing The #820 data-as-import contract (src/sota_seed.d.ts, esbuild's .toml: "text" loader, vitest's toml-as-text plugin) types resources/*.toml as the file's text content. Bun natively PARSES .toml imports into an object, so the seed reached validateWatchedRepoRegistry as an object and loadRegistry's bootstrap crashed on seedToml.endsWith. Normalize back to text at the import boundary (smol-toml stringify; the validator re-parses it either way) so the seed is one canonical string under every runtime.
…ails under bun and vitest - doctor.test: the usage-error message rides toMatch instead of a regex nested in toMatchObject (vitest substring-matches nested regexes, bun compares them literally); same assertion strength, both runners. - gh_cli.test: the recursion guard RESOLVES the node binary's realpath'd dir instead of assuming dirname(process.execPath) holds node (under bun it is bun's bin dir — the bundle could not even spawn). A host without any node binary skips with the requirement named. - spec_review.test: the A-11 suite-guard assertion requires the vitest setup file (test/setup.ts pins $AMICO_CRITIC_BIN); under runners that do not load it, skip with the requirement named — run pnpm test. - cloud_verb.test: the unreachable-endpoint wording is the runtime's own (node: "fetch failed"; bun: "Unable to connect...") — assert the union, never one runner's string.
…ing/runtime guards — 0 fails
The dev hosts that hit these failures run a LIVE amicode service, whose
ambient env (AMICODE_SERVICE_AUTH=open, OPENCODE_DB, partial bin/
staging) leaked into tests that never isolated it:
- amicode_service_{wiring,bootstrap_auth,contract,engine_proxy,
fleet_data_plane,auth_mode}: save/clear/restore AMICODE_SERVICE_AUTH
around the boots that pin the CREDENTIAL default (the 401 discipline
assertions). The auth_mode env-carrier cases already did this; the
boot-log case was missing it — fixed to the same idiom.
- terminal.test: clear ambient OPENCODE_DB/OPENCODE_CONFIG_DIR around
the injection describe so the no-injection assertions test the
settings, not the host env.
- amicode_service_runner.test: the dist-reason fail-loud test pointed at
the vendored engine binary, which is absent on most hosts — the runner
then failed EARLIER with 'no engine binary', the wrong named reason.
Point it at an existing stub bin so the DIST check is what fires; the
test is truly always-on now, as its describe claims.
- cli_gate.test: the staged-bins guard now requires a COMPLETE staging
(every declared bin's launcher + dist present), not a bare bin/ dir —
a partial staging (leftover dist, no launchers) skips with the
requirement named (pnpm -r run build) instead of red-failing.
- open_threads.test: the no-bun:sqlite degradation case requires the
Node runtime; under bun the module exists and the call would read the
developer's REAL session DB — skip with the requirement named (run
pnpm test).
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Closes #1532 — the 10 amico-run + 16 extension pre-existing suite failures on main @ 244e6a9, each diagnosed and made honest. No test deleted, no assertion weakened, no test marked broken.
Classification
cloud_verb› status › unreachable endpoint degrades to ONE clear line (amico-run)fetch failedstring; bun's fetch saysUnable to connect. Is the computer able to access the url?. Assert the union of both runners' wording — the intent (ONE clear named connectivity failure) is unchanged.cloud_verb› abort › preflights the channel (amico-run)sota_papers› curlSotaFetch ×3 (amico-run)execFileSync("curl", …)relied on default env inheritance; bun resolves unqualified executables from the spawn's env OPTION when given, else the process-START env snapshot — never liveprocess.envmutations — so the tests' fake-curl PATH injection was invisible and the REAL arXiv fetch ran. Fix: passenv: process.envexplicitly (byte-identical inheritance under node; live PATH honored under bun).sota_papers› lens 404 round via the production transport (amico-run)sota_codebase› loadRegistry bootstraps from the packaged seed (amico-run).toml: "text", vitesttomlAsTextplugin,src/sota_seed.d.ts); bun natively parses.tomlimports into an object, soseedToml.endsWithcrashed. Normalized back to text at the import boundary (smol-tomlstringify; the validator re-parses it either way).doctor› parseDoctorArgs usage error (amico-run)toMatchObjectsubstring-matches under vitest but is compared literally under bun. Message now asserted withtoMatch— same strength, both runners.spec_review› the no-real-model-calls guard (amico-run)test/setup.ts(it pins$AMICO_CRITIC_BINto an impossible path for the suite); bun test does not load vitest setup files.it.skipIf(!process.env.AMICO_CRITIC_BIN)— runpnpm testto exercise. The fail-closed behavior itself stays covered by the sibling opt-in case.gh_cli› gh shim recursion guard (amico-run)dirname(process.execPath)holdsnode— true under the node runner, false under bun (bun's bin dir has no node; the bundle could not even spawn, exit −1). The node dir is now RESOLVED (realpath'd, so shim dirs that carry a realghcannot defeat the guard). A host with no node binary at all skips with the requirement named.amicode_service_{bootstrap_auth ×7, contract, engine_proxy, fleet_data_plane, wiring ×2}(extension)AMICODE_SERVICE_AUTH=open(the #955 tunnel/LAN posture). Tests boot the service relying on the CREDENTIAL default and never isolated the env → open mode → every anonymous-401 pin returned 200. Save/clear/restoreAMICODE_SERVICE_AUTHaround those boots (the auth_mode file's env-carrier cases already used the idiom; the boot-log case was missing it — fixed to the same idiom).amicode_service_auth_mode› authMode exposed for the wiring's log line (extension)amicode_service_runner› a shelf without a built app dist fails with the named reason (extension)no engine binary— the wrong named reason. Now passes an existing stub bin so the DIST check is what fires; the fail-loud describe is truly "always on" as its header claims.cli_gate› the freshly staged CLI passes every check (extension)bin/existence; a PARTIAL staging (leftoverdist/, no launchers) passed the guard and red-failed the gate. Now requires every declared bin's launcher + dist present — skip names the requirement (pnpm -r run build); with a real staging the test runs and passes.terminal› OPENCODE_DB/OPENCODE_CONFIG_DIR injection ×2 (extension)process.env; the dev host exportsOPENCODE_DB, leaking into the no-injection pins. The describe now saves/clears/restores both vars so the settings, not the host env, are what's tested.open_threads› returns null when bun:sqlite is unavailable (extension;bun testsurface)bun:sqliteexists and the call would read the developer's REAL session DB.describe.skipIf(typeof Bun !== "undefined")— runpnpm testto exercise.Verification (from package dirs only, fresh state)
packages/amico-run—bun test(the campaign's baseline surface, which reproduced the 10):(baseline on main @ 244e6a9: 1698 pass / 9 skip / 10 fail — the identical 10, byte-for-byte the #1528 record)
packages/amico-run—pnpm vitest run --passWithNoTests --exclude '**/slow/**':packages/extension—pnpm vitest run --passWithNoTests:(baseline: 16 failed | 3663 passed | 62 skipped (3741) — the identical 16, byte-for-byte the #1526 record; +1 pass/−1 skip is the cli_gate real-set test running for real after staging)
bun test test/open_threads.test.tsinpackages/extension: 47 pass / 1 skip / 0 fail (the Node-runtime degradation case skips under bun with its requirement named; 48/48 under vitest).bun typecheckin both packages: 0 errors.Every skip carries its stated requirement in-code (endpoint/credential/binary/runtime + how to run it); skip guards are deterministic per environment.