tests: fix six review findings, four of which were guards not guarding - #23
Merged
ualtinok merged 1 commit intoAug 30, 2026
Merged
Conversation
A reviewer found six issues across the three PRs that merged today. All six
are real. Four are the same shape as the defects those PRs were written to
fix, which is the part worth reading.
THE GATE'S SKIP GUARD WAS A MAGIC-STRING CHECK WEARING DERIVATION CLOTHES.
I had replaced an --ignored-keyed guard with one that "asks the source"
whether a target can emit a skip notice. It greps case-sensitively for the
token SKIPPING. cli_admin.rs emitted its notice in lowercase, so the probe
stayed silent for that target -- and run_expect's own downstream skip check
greps case-sensitively too, so even with --nocapture that arm's skip was
invisible to the guard. I swapped one magic string for another and described
the result as derived.
Fixed by standardizing the convention rather than widening the matcher:
cli_admin.rs now emits the uppercase token, and its gate arm passes
--nocapture so the newly-armed probe has something to see. Widening the
matcher instead would have false-fired on that arm -- its skipping test is
filtered out by the test-name selector, which the probe cannot observe -- and
an over-firing guard is not the safe direction, because the next person hits a
red on an arm they know is fine and deletes the guard rather than narrowing
it.
THE ARGUMENT SCAN RAN PAST THE SEPARATOR, so a --test after -- overwrote the
target, last-one-wins, and could point the probe at a file with no skip path.
Target capture now stops at --; --nocapture detection deliberately does not,
because the real_daemon arm places it after the separator.
THE FRAME PIN DID NOT EXERCISE THE ROUTE. It hand-built {"result": ...} and
compared against itself, so renaming the wrapper in handle_read_request broke
every consumer while the test stayed green. That is the defect the pin exists
to catch, one level in: it pinned my belief about my own route rather than the
route's output. Both now go through wrap_result, and mutating the wrapper
inside the production helper turns the test red.
THE NON-ACTIVE TEST BUILT ITS STATE OFF-PATH, reaching needs_reauth through
the unversioned store.invalidate rather than the version-fenced call the
engine makes when a refresh fails. Same state today, so it passed; if the
engine's path ever also cleared stale_pending, the test would have stayed
green while production diverged.
The two NoHttp stubs are now one #[cfg(test)] helper. Verified it stays out of
the shipped artifact: zero occurrences in the release binary against a control
string that scores three.
Master's 01f76b1 and 004fc06 were checked for interaction and have none --
the first adds scripts only, the second touches the manifest path.
Gate: exit 0, nine real-daemon e2e arms executing. Mutation-checked: wrapper
rename red, version fence red, NoHttp symbol red, guard red without
--nocapture and green with it, post-separator override red, non-skipping
target green.
There was a problem hiding this comment.
1 issue found across 6 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="crates/credentials-module/src/main.rs">
<violation number="1" location="crates/credentials-module/src/main.rs:4681">
P2: This test bypasses `RefreshEngine`: `report_auth_failure` only marks the record stale, then this direct store call manufactures `NeedsReauth`. Drive a failing refresh through `RefreshEngine` (including its observation), or the test remains green if the production failure path diverges.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| // touched by any of the seven state-update paths, which is the bug pinned here. | ||
| store | ||
| .invalidate("oauth:needs_reauth_after_stale") | ||
| .invalidate_if_version_reported( |
There was a problem hiding this comment.
P2: This test bypasses RefreshEngine: report_auth_failure only marks the record stale, then this direct store call manufactures NeedsReauth. Drive a failing refresh through RefreshEngine (including its observation), or the test remains green if the production failure path diverges.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At crates/credentials-module/src/main.rs, line 4681:
<comment>This test bypasses `RefreshEngine`: `report_auth_failure` only marks the record stale, then this direct store call manufactures `NeedsReauth`. Drive a failing refresh through `RefreshEngine` (including its observation), or the test remains green if the production failure path diverges.</comment>
<file context>
@@ -4723,11 +4674,16 @@ mod tests {
+ // touched by any of the seven state-update paths, which is the bug pinned here.
store
- .invalidate("oauth:needs_reauth_after_stale")
+ .invalidate_if_version_reported(
+ "oauth:needs_reauth_after_stale",
+ 1,
</file context>
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.
Six issues the reviewer raised on #20, #21 and #22 after they merged. I checked each against source rather than taking the read. All six are real, and four are the same shape as the defects those PRs were written to fix.
The gate's skip guard was a magic-string check wearing derivation clothes
#21 replaced an
--ignored-keyed guard with one that "asks the source" whether a target can emit a skip notice. It greps case-sensitively forSKIPPING:The probe stayed silent for
cli_admin. Worse,run_expect's own downstream skip check greps case-sensitively too — so even with--nocapture, that arm's skip was invisible to the guard. I swapped one magic string for another and called the result derived.Fixed by standardizing the convention, not widening the matcher.
cli_admin.rsnow emits the uppercase token, and its gate arm passes--nocaptureso the newly-armed probe has something to see.Widening the matcher was the tempting fix and it is wrong: it false-fires on that arm, whose skipping test is excluded by the test-name selector — something the probe cannot observe. An over-firing guard is not the conservative failure. The next person hits a red on an arm they know is fine, concludes the guard is broken, and deletes it rather than narrowing it.
The argument scan ran past the separator
A
--testappearing after--overwrotetarget, last-one-wins, and could aim the probe at a file with no skip path. Target capture now stops at--.--nocapturedetection deliberately does not, because the real_daemon arm places it after the separator.The frame pin did not exercise the route
#20 added a pin that hand-built
json!({"result": inner})and compared it against itself. Renaming the wrapper inhandle_read_requestwould break every consumer while the test stayed green — the exact defect the pin exists to catch, one level in. It pinned my belief about my own route rather than the route's output.Both now go through
wrap_result. Mutating the wrapper inside the production helper turns the test red:The non-Active test built its state off-path
It reached
needs_reauththrough the unversionedstore.invalidaterather than the version-fenced call the engine makes when a refresh fails. Same resulting state today, which is why it passed. If the engine's path ever also clearedstale_pending, the test would have stayed green while production diverged.Two
NoHttpstubs became one#[cfg(test)]-gated. Verified it stays out of the shipped artifact — zero occurrences in the release binary, against a control string that scores three.Master interaction
01f76b1adds scripts only;004fc06touches the manifest path. Neither overlaps these changes.Verification
bash scripts/gate.shexit 0, nine real-daemon e2e arms executing.Mutation-checked, each red then restored green: wrapper rename, version fence,
NoHttpsymbol, guard without--nocapture, post-separator override, and a non-skipping target staying green. That last one is the control that matters — a guard which has only ever fired has shown it can trigger, not that it can distinguish.One thing left open, deliberately
Eight route sites still hand-roll
json!({ "result": ... })rather than callingwrap_result. Thegetpath this pin covers goes through the helper, so the finding is closed — but a helper one call site uses is a convention, not a seam. Worth folding the rest in, and it is a wider change than a review-fix PR should carry.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by cubic
Fixes six review findings on the merged PRs #20–#22; four were guards that did not guard the same shape of defect those PRs were written to fix.
SKIPPINGtoken;cli_admin.rsemits it and its gate arm passes--nocaptureso the probe can see the notice. Widening the matcher would have false-fired because the probe cannot observe test-name filters.run_expecttarget capture now stops at--, so a--testafter the separator can no longer overwrite the target;--nocapturedetection still reads past it.wrap_resulthelper instead of hand-building{"result": ...}and comparing against itself, so renaming the wrapper inhandle_read_requestturns the test red.needs_reauththrough the engine's version-fencedinvalidate_if_version_reportedrather than the unversionedstore.invalidate.NoHttpstubs became one#[cfg(test)]helper intest_support.rs; verified absent from the release binary.Left for a follow-up: eight route sites still hand-roll
json!({ "result": ... })instead of callingwrap_result; folding them in is a wider change than a review-fix PR should carry.Written for commit b921061. Summary will update on new commits.