test/config-schema.test.sh's doctor fixtures neutralise the config but not the environment, so a configured host inverts three assertions
Id: TD-PPagop-26082201 · Status: resolved · Filed: 2026-08-22 · Resolved: 2026-08-23 · Ref: https://github.com/Poetic-Poems/agent-ops/pull/697
TD-PPagop-26081801 established that assert_doctor fixtures must not
silently inherit state they do not name, and fixed the half of that which
comes from config.json: DOCTOR_NEUTRAL_MUTATION now clears every
merge_autonomy-adjacent and approver_* key back to its schema default
before a fixture’s own mutation is applied, so a fixture that wants one of
them set has to say so.
The other half is still open. _assert_doctor_check runs
out="$(bash "$SCRIPT_DIR/scripts/doctor.sh" --offline --config "$fixture" 2>&1)"with the ambient environment inherited, and scripts/doctor.sh reads it.
lib/approver-token.sh takes the Approver App’s identity from
PULLWRIGHT_APPROVER_APP_ID, PULLWRIGHT_APPROVER_INSTALLATION_ID and
PULLWRIGHT_APPROVER_PRIVATE_KEY_PATH, and its own header records that
doctor “reconciles them, failing a set PULLWRIGHT_APPROVER_APP_ID that
differs from a set approver_app_id, so the App the operator declared and
the App this file mints against cannot drift apart silently”. That
reconciliation is correct, and it is exactly what the fixtures walk into:
a fixture that deletes approver_app_id to construct “no Approver
configured” instead constructs “an Approver present in the environment that
the configuration does not declare” — a different case, with the opposite
verdict.
On a host where those variables are set, three assertions invert:
FAIL - doctor passes a merge_autonomy level above human once approver_app_id and approver_model_default are both setFAIL - doctor warns on an unlimited budget at agent-merges-routine or above, naming the repo and levelFAIL - …but a warn, never a fail — nothing arms automatic landing yetWhy it matters
Section titled “Why it matters”The variables are set in exactly one place a maintainer is likely to run
these tests: inside a node’s own scheduler container, where
compose.yaml passes them from the stack’s .env. That is not a perverse
environment — it is the obvious one to reach for, because the host’s jq
(1.6) differs from the image’s (1.7) and about nine other test files fail
on the host for that reason alone. So the natural escape from one
environment problem lands directly in this one, and the failures name
neither cause: they name merge-autonomy and budget rules that are working
correctly.
scripts/run-tests.sh (agent-ops#663) makes the right invocation the easy
one — a throwaway docker run container, which has none of these
variables, the same as CI. That removes the trap from the documented path
but does not make the test hermetic: run it any other way on a configured
host and it still inverts, and nothing in the file says why.
This is the same failure shape TD-PPagop-26081801 was filed for, and its
closing observation applies unchanged: “A comment cannot enforce this,
because nothing about assert_doctor’s shape tells a reader which parts of
the shipped configuration their fixture is silently inheriting.” Substitute
“environment” for “shipped configuration” and the sentence is still true, and
still unenforced.
Suggested fix
Section titled “Suggested fix”Clear the variables at the one place doctor is invoked, so every fixture is hermetic by construction rather than by where it happens to be run:
out="$(env -u PULLWRIGHT_APPROVER_APP_ID \ -u PULLWRIGHT_APPROVER_INSTALLATION_ID \ -u PULLWRIGHT_APPROVER_PRIVATE_KEY_PATH \ bash "$SCRIPT_DIR/scripts/doctor.sh" --offline --config "$fixture" 2>&1)"_assert_doctor_check is the single seam both assert_doctor and
assert_doctor_shipped pass through, so one edit covers every assertion in
the file, including the deliberately un-normalised ones — which want the
shipped config, never the host’s environment.
Worth considering alongside it:
- A positive assertion for the reconciliation rule itself. It is real
behaviour with no coverage, which is why its only appearance in this suite
is as an accident. A fixture that sets
approver_app_idto one value andPULLWRIGHT_APPROVER_APP_IDto another, asserting doctor fails and names the mismatch, would turn the trap into the test it should have been. - Whether any other test invokes a script that reads the environment. The audit is small and has not been done; this item was found by falling into it, not by looking.
References
Section titled “References”test/config-schema.test.sh—_assert_doctor_check,DOCTOR_NEUTRAL_MUTATIONlib/approver-token.sh— the reconciliation this collides withTD-PPagop-26081801— the resolved config half of the same problem- agent-ops#546, agent-ops#560 — the two config recurrences it was filed for
- agent-ops#663 —
scripts/run-tests.sh, which avoids this rather than fixing it README.md, “Running the tests” — documents the trap for a reader; this item is the code half