Repository navigation
test(adapters-selfhosted): reach the asset model's situations by construction, not by a random draw - #131
Merged
Conversation
…truction, not by a random draw `model_asset_methods_match_the_reference_against_postgres` ended with a check that its 24 random sequences had, among them, reached every one of 14 "situations" (AGENTS.md rule 8: what the model must get to, or it proves less than it seems to). Some situations need a chain of unlikely steps: a delete is one step in twenty, and `mark-of-a-deleted-one` then needs a mark of that very asset. The seed is random, so the check failed on a fair share of runs, each time for a different situation: `mark-of-a-deleted-one`, `marked-again` and `cover-replaced` in the three CI failures of one PR (#128, whose changes are not in this crate), which passed on main's merge commits for #124 and #127. Nothing the model compares was ever wrong in those runs. The assertion was wrong, not the code, and it is replaced by a stronger one that does not depend on chance (AGENTS.md rule 3): three pinned sequences, run first through the same `run_case` against the same Postgres, reach every situation by construction, and the test fails at once, naming the situation, if they do not. The random sequences follow, as before, to look for what no one thought to pin; what the run reached is printed (`ASSET-MODEL-OBSERVATION`) and no longer asserted. Measured (2026-11-11, a real Postgres container): the test passes six times in a row (each run draws its own seed), and reaches all 14 situations in the pinned sequences alone. Control: with the last step of the third sequence removed, it fails with `no pinned sequence gets to "cover-replaced"`. Refs: #44 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This was referenced Nov 12, 2026
aRustyDev
added a commit
that referenced
this pull request
Nov 17, 2026
…y a random draw (#280) `model_assets_match_the_reference_over_any_sequence` ended with a check that its 256 random sequences had, among them, reached every one of 17 "situations" (AGENTS.md rule 8: what the model must get to, or it proves less than it seems to). The seed is random, so the check failed on a share of runs, for the rarest situation: `opened-in-project` on #215 (run 43813860948, a change to docs and the oracle corpus), the only failure of 4239 test cases. Nothing the model compares was wrong. #131 fixed the same defect in the self-hosted adapters' twin of this test; this is the core's. Measured on the unchanged test (2026-11-17): 3000 independent runs of the 256-case batch, 1 would have failed the check, and the situation it missed was `opened-in-project`. Per sequence, over 100,000 random sequences, `opened-in-project` (a create, an upload, a confirm, an attach, then an open by someone in the project) is reached by 3.4%, so a batch misses it with probability 1.3e-4, about one run in 7,900. The next rarest, `attached-some-left-out` (5.5%), is missed once in 1.8 million runs; every other one is rarer still. The check also did not run at all below 128 cases. The assertion was wrong, not the code, and it is replaced by one that does not depend on chance (AGENTS.md rule 3): three pinned sequences, run first through the same `run_model`, reach every situation by construction, and the test fails at once, naming the situation, if they do not. The random sequences follow, as before, to look for what no one thought to pin; what the run reached is printed (`ASSET-MODEL-OBSERVATION`) and no longer asserted. `docs/src/testing/techniques/model-based.md` says so. Controls: with the step that opens the project's asset as a member removed from the second pinned sequence, the test fails with `no pinned sequence gets to "opened-in-project"`; with `open_asset` planted to skip its access check and `PROPTEST_CASES=1`, a pinned sequence fails (`left "ok", right "no-access": Open { actor: OutsiderA, asset: 0 }`), so the pinned part catches it alone; with `PROPTEST_CASES=4` the test passes and the pinned check still runs. `cargo nextest run -p thrust-core`: 1611 passed. Refs: #44 Co-authored-by: Claude Sonnet 5.5 <[email protected]>
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.
What
model_asset_methods_match_the_reference_against_postgres(the model test of the asset methods against real Postgres, from #124) fails CI on a fair share of runs, and fails thepg-adapterjob and with itgate. This makes it deterministic where it was flaky, and stronger.Part of #44's asset stage (not closing anything).
The flake
The test ended with a check that its 24 random sequences had, among them, reached every one of 14 "situations" (AGENTS.md rule 8). Some need a chain of unlikely steps: a delete is one step in twenty, and
mark-of-a-deleted-onethen needs a mark of that very asset. The seed is random, so the check failed on many runs, each time for a different situation.Observed on #128's CI (that PR changes nothing in this crate): 3 failures in 4 executions of the test.
mark-of-a-deleted-onemarked-againcover-replacedIt passed on main's merge commits for #124 and #127. Nothing the model compares was ever wrong: it is the coverage assertion, not Postgres and not the adapter.
The fix
The assertion was wrong, not the code, so it is replaced by a stronger one that does not depend on chance (AGENTS.md rule 3):
pinned(): three short sequences that between them reach all 14 situations by construction (an asset read through another workspace, uploaded twice, public, deleted and marked; a grant spent, asked for again, with the wrong token and at exactly its expiry; a cover named from another workspace's asset, with someone else's asset left out, and replaced by another caller's).run_caseagainst the same Postgres, and the test fails at once, naming the situation, if one is not reached.ASSET-MODEL-OBSERVATION) and no longer asserted.Evidence (2026-11-11, a real Postgres container, local)
no pinned sequence gets to "cover-replaced".cargo fmt --all --checkandcargo clippy -p thrust-adapters-selfhosted --all-targets -- -D warnings: clean.tests/assets/mod.rschanges (+58 −7).Not done
The random run no longer asserts what it reached. If a situation should be reached by generation as well as by construction, the way is a model-only replay of sampled sequences (like
model_asset_strategy_reaches_every_step_classdoes for the kinds of step), which means extracting the situations fromrun_case's interleaving of Postgres calls and the model; that is a larger change than a flake fix.🤖 Generated with Claude Code