Repository navigation
Isolate the plugin test suite from host secrets - #3435
Conversation
The suite inherited the host process environment, so on a machine whose /run/secrets holds the workspace runtime key and seal key, eleven tests failed for reasons unrelated to the code under test. Give the plugin an explicit environment instead. `apply()` accepts `config.env` (defaulting to `process.env`), `loadFeatures()` and `featureHost()` carry it as `env` (defaulting to `process.env`), and the agents feature passes `host.env` to `loadPersonalAgentBootstrap()`, which already takes an env object. No production call site passes `env`, so the default keeps today's behaviour; the host object stays frozen. The tests build identity and hosts from an explicit `TEST_ENV` object whose key paths cannot exist, and the seal-key fallback test uses a non-existent operator key path instead of an empty string, which `lib/b4/seal.js` treats as falsy and replaces with the host default. Measured locally on node v22.23.5, `--test-concurrency=2`: the three classes this slice covers go from 22/29, 8/9 and 29/31 to 29/29, 9/9 and 31/31. The whole directory still reports four `cancelledByParent` tests on node 22 (497 tests, 493 pass, 0 fail, 4 cancelled, exit 1) and is green on node 24 (497/497, exit 0). Those four are a node 22 event-loop mechanism tracked separately, not part of this change. Related #3434
|
Lead review record — exact head Verified coordinates (REST, this session): Slice. One reviewable change: the plugin test suite stops reading host secrets, via one explicit optional
Test side: Acceptance evidence — local, on this head's content (QA Engineer and Runtime Dev, node v22.23.5,
Acceptance evidence — CI, same head, read by me: Local green and CI green are reported separately above; neither is a claim of parity or of overall acceptance. Out of scope, deliberately not fixed here: the 4 node-22 Any new commit voids this record. Related #3434 |
The
runtime/flybot-workspace-webtest suite inherited the host process environment. On a machine whose/run/secretsholds the workspace runtime key (10,873 B) and seal key (32 B), and whose shell exportsFLYBOT_WORKSPACE_ROUTING_INSTANCE_ID, eleven tests failed for reasons unrelated to the code under test.What changes
One injection seam, added as optional parameters with today's defaults:
index.js:config.env ?? process.env; identity built from thatenv; the sameenvpassed toloadFeatures.src/features.js:loadFeatures({ ..., env = process.env }),featureHost({ ..., env = process.env }), exposed ashost.env; the host stays frozen.features/agents/index.js:1664and:1677:loadPersonalAgentBootstrap(host.env). That loader already takes(env = process.env, reader = readFileSync), so it is unchanged.No production call site passes
env, so production behaviour is unchanged.lib/b4/seal.jsis untouched, including its empty-string fallback to the host key file.Test side:
test/helpers.jsexports a frozenTEST_ENVwhose key paths cannot exist,boot()anddeliverBundle()default to it, and the files that build feature hosts pass it explicitly.test/model-api.test.jsuses a non-existent operator key path instead of an empty string, whichlib/b4/seal.jstreats as falsy and replaces with the host default.Why not tests only
Eight of the eleven failures left through
loadPersonalAgentBootstrap()called with no arguments, readingprocess.envand the real secrets path. The host object handed to a feature carried no environment andapply()hard-codedprocess.env, so no test-side change could reach it. Wiring that one seam is the smallest change that does.Measured locally (not CI, not acceptance)
On node
v22.23.5with--test-concurrency=2, at the content of this head (tree93a2fb2d):chat,agent-api,agentsmodel-apimeetings,searchWhole directory, same head: node 22
497 tests / 493 pass / 0 fail / 4 cancelled / exit 1; node 24497 / 497 / 0 / 0 / exit 0.Not fixed here
The four
cancelledByParenttests on node 22 (features.test.js:156,:168,memory-extras.test.js:356,:412) are an event-loop mechanism of that node version and are tracked separately. The suite is therefore not fully green on node 22 after this change, and this pull request does not claim that it is. CI is unaffected either way: the runtime image job pins node 24 and runs from a clean checkout.Related #3434