Uh oh!
There was an error while loading. Please reload this page.
test(server): isolate the keychain in the connections-route suite - #91
Merged
Merged
Conversation
The unit job died with exit 137 and reported nothing. Not an OOM (peak 0.37GB of 32GB, zero faults) — a segfault inside @napi-rs/keyring's native setPassword(), reached from the pasqal submit success path. Install the in-memory secret store, as the sibling amicode-connections.test.ts already does. Production is unaffected: the same write succeeds under `bun run … serve`, verified end-to-end against Pasqal with real credentials. Also swap the stub validator from a bun-executed .mjs to a python3-executed .py. amicode provisions <opsDir>/venvs/pasqal-connector and passes it as AMICO_PYTHON (harmoniqs/amicode#189), so the production interpreter is always a real python; bun-as-interpreter tested a configuration that never ships. Drop the windows unit lane: opencode.lock.json ships darwin-arm64 and linux-x64 only, and it was the ~50min long pole while red for an unrelated reason (#76). Refs #82, #76
jack-champagneforce-pushed
the
jack/test-keychain-isolation
branch
from
July 28, 2026 22:06
4875a0c to
1e83e32CompareUh oh!
There was an error while loading. Please reload this page.
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 freeto 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.
Makes
unit (linux)interpretable again. It has been dying withexit code 137and reporting nothing.Not an OOM
Turbo labels any signal-killed child "likely due to running out of memory." That label is boilerplate and it is wrong here. Bun's own report:
0.37 GB peak on a 32 GB machine, zero faults, dead in 1.5 s. A larger runner would not have helped (and is unavailable — the org is
plan=free;GET /orgs/harmoniqs/actions/hosted-runnersreturns 404).What it actually was
One test —
amicode-connections-routes.test.ts:335, "full lifecycle: submit(valid) → …" — segfaults atconnections.ts:1005:which reaches
@napi-rs/keyring's nativeEntry.setPassword(). Traced with instrumentation:[T3] before keychainprints,[T4] after keychain writenever does.That write sits only on the
valid && token !== nullbranch, which explains the pass/fail pattern exactly:full lifecycle(valid + token)valid+ tokennull token → session-onlyvalid, null tokenfailure classes(exit 2/4/1)config/invalidBisected to
467fb15cf("two-step Pasqal auth", #194), which introduced that write per the ADR 0001 addendum. The test passed at3e4b37298, the commit immediately before.Production is not affected
Verified end-to-end, not assumed. Real Pasqal login, real
pasqal_validate.py, realpasqal-cloudSDK, real keychain, againstbun run … serve:And it demonstrably reached the crash site — the keychain slot was written and the token persisted (
token_len: 1278).bun test+ Effect routebun run … serve+ Effect routebun test, keyring alonebun run, keyring aloneOnly the first combination crashes. It is a Bun-test-runner/NAPI interaction, not a product fault, and
467fb15cfis not shipping a crash to users.The fix
Install the in-memory secret store in
beforeEach— exactly what the siblingamicode-connections.test.tsalready does, which is why that file passes:Also adds
AMICO_PASQAL_KEYCHAIN_SERVICEtoENV_KEYS.pasqal-secret.tsdocuments it as existing so "an isolated sandbox / test run gets its own slot and never shares the real connection's secret"; it was unused here. Belt and braces, so a leak cannot reach the real slot even if the seam is ever removed.Worth noting independently of the crash: this suite was driving the developer's real OS keyring.
Stub validator: bun → python3
stageStubValidator()setAMICO_PYTHON = process.execPath, i.e. bun standing in as the Python interpreter. In production amicode provisions<opsDir>/venvs/pasqal-connectorand passes it asAMICO_PYTHON(harmoniqs/amicode#189, the bundled-Julia pattern), so the interpreter is always a real python. The old stub tested a configuration that never ships.Now a
python3-executed.pywith the same record/scenario contract, plusactions/setup-pythonin the unit job. The stub needs an interpreter, not the SDK — integration against the realpasqal-cloudSDK stays where it belongs, in amicode'sassert_provisioned_python.mjsgate.The env assertion now filters interpreter-owned locale vars, because CPython injects
LC_CTYPEinto its ownenvironunder PEP 538 C-locale coercion. It still asserts the real thing: that the spawner declared nothing beyondPASQAL_USERNAME/PASSWORD/PROJECT_ID+PATH.Windows unit lane dropped
opencode.lock.jsonshipsdarwin-arm64andlinux-x64only, so a windows unit lane gates a platform this fork does not distribute — and at ~50 min it is the long pole on every run. It was also red on arrival for a reason unrelated to anything under test: POSIX path separators hardcoded inamicode-vaults.test.ts(#76). e2e still runs both platforms.Verification
Before this, the full
packages/opencodesuite could not complete at all. It now runs 3234 tests to completion, leaving a readable list: the stale LLM fixtures (#80) and a umask-dependent permissions assertion intool.write(0o644vs0o664— passes on CI'sumask 0022, fails on a developerumask 0002).Refs #82, #76