Skip to content

Fix the stale-read flake in TestRunnerAuthz_ReadonlyAllow - #14

Merged
josephschorr merged 1 commit into
mainfrom
fix/toolcheck-readonly-allow-flake
Oct 1, 2026
Merged

josephschorr merged 1 commit into
mainfrom
fix/toolcheck-readonly-allow-flake

Conversation

@josephschorr

Copy link
Copy Markdown
Member

The flake

TestRunnerAuthz_ReadonlyAllow writes github_repo:foo#reader@user:alice and immediately checks read through a cacheless Checker. With no ZedToken cache there is no freshness floor, so CheckToolCall runs the check at MinimizeLatency — which may legally serve a quantized snapshot predating the write the test just made (the consistency notes in check_tool_call.go describe exactly this shape). The just-granted reader is then invisible and the expected allow comes back as:

expected allow; message="permission denied: user:alice does not have read on github_repo:foo"

Measured locally at 5/30 and 1/30 failing runs; it failed two consecutive CI integration jobs (main at 92f61c4, then PR #12) with the identical message. The deny sibling never flakes because a stale read still denies; TestRunnerAuthz_ZedTokenFreshness already floors its check.

The fix

Seed a ZedTokenCache with the WriteRelationships response token so the check runs AtLeastAsFresh at the write's revision — the same pattern TestRunnerAuthz_ZedTokenFreshness uses, and what production callers do. What this test claims is the readonly allow path, not floorless freshness, so the floor narrows nothing the test was asserting.

Verification

go test -tags=integration -count=60 -run '^TestRunnerAuthz_ReadonlyAllow$' ./pkg/authz/spicedb/toolcheck/ — 60/60 pass (pre-fix: 5/30 failing).

The test wrote a relationship and immediately checked it through a
cacheless Checker. With no ZedToken cache there is no freshness floor,
so CheckToolCall runs the check at MinimizeLatency — which is free to
serve a quantized snapshot predating the write this same test just
made (the consistency notes in CheckToolCall spell this out). The
just-granted reader is then invisible and the expected allow comes
back as a deny.

This is not hypothetical: the test failed 5 of 30 local runs and took
down two consecutive CI integration jobs (this branch's base and PR
one of its descendants) with the identical denial message. The deny
sibling never flakes because a stale read still denies, and the
ZedTokenFreshness sibling already floors its check.

Seed a ZedTokenCache with the WriteRelationships response token so the
check runs AtLeastAsFresh at the write's revision — the same pattern
TestRunnerAuthz_ZedTokenFreshness uses. What this test claims is the
readonly allow path, not floorless freshness. 60 of 60 local runs pass
with the floor in place.
@vercel

vercel Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
openagentprimitives Ready Ready Preview Oct 1, 2026 3:46am UTC

Request Review

@josephschorr

Copy link
Copy Markdown
Member Author

The e2e failure on the first CI run here was TestOapExportPackInstall_WithSpiceDB losing the install SSA race — the separate flake fixed by #15 (this branch predates that fix). The job has been rerun.

@josephschorr
josephschorr merged commit 7b8023d into main Oct 1, 2026
15 of 16 checks passed

This branch was successfully deployed

1 active deployment
Preview — 9fc3b3d2 Deployed Oct 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant