Repository navigation
test: step one clock for the enable cutoff and the hook mint in the app token test - #35809
Conversation
…pp token test test_the_hook_context_mints_this_apps_token read the live clock for the enable cutoff and for the token iat. The token check is iat > cutoff, so two reads in the same clock tick made the test fail with 'invalid signature'. The test now installs ManualClock(tick=1.0) on manager_records and token_auth_tokens. With tick=0 the test fails, so the step is what keeps it green.
First Principles Review (Opus 5.5) — ⏭️ skippedRevision |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Test-only fix: one injected stepped clock removes the tie between the cutoff and the [DESIGN-REVIEWED] af46afd Description read[DESCRIPTION-READ] a0e52acdb7813c92171ec115f2a78dd45eb71b3c6c174a451b49482166a3db7a That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Code change approver recommendation: ApproveWhy: the decider estimates a 4% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes. Test-only change: one test installs ManualClock(tick=1.0) on manager_records and token_auth_tokens. The cutoff is set in manager_records._next_token_cutoff (time.time when the record is created at install). The token is minted, stamped (iat, exp, session_exp) and checked inside token_auth_tokens. Both modules are patched, so every timestamp the test compares comes from one stepped clock and iat > cutoff always holds. Neither patched module has a sleep loop or deadline that the stepped clock would break. Patches go through monkeypatch, which matches testing-conventions D3/D11. No production code changes and the strict comparison is untouched, as the description says. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: test (1 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: test-only change to test/test_app_in_process_secret.py that installs one stepped ManualClock for the enable cutoff and the token mint, so the iat > cutoff check cannot tie; no source file changes.
bolichen97
left a comment
There was a problem hiding this comment.
Read the full diff, a test-only change for #35808. One ManualClock(tick=1.0) is installed on both manager_records (the enable cutoff) and token_auth_tokens (the mint), so iat is always past the cutoff and the two reads can no longer tie. No product code changes. LGTM.
Problem / Motivation
Goal: Make the in-process app token test pass on any clock speed.
test_the_hook_context_mints_this_apps_tokenintest/test_app_in_process_secret.pyreads the live clock two times. The first read sets the app's token cutoff when the test enables the app. The second read sets theiatof the token that the hook mints. The token check isiat > cutoff. If the two reads return the same value, the check refuses the token and the test fails with "invalid signature".Why it matters
The test came in with #35533. It passes today because the two reads are some milliseconds apart. A runner with a coarse clock, or a fast machine, can make the two reads equal. Then the test fails with no code change. The approver on #35533 named this tie.
Not a goal
This PR does not change the strict
iat > cutoffcomparison intoken_auth_tokens.py. The exchange route uses the same comparison, and #35533 did not change it.What changed (motivation → approach → change)
The test now owns its clock, so the result does not depend on how fast the machine is. It installs
ManualClock(tick=1.0)fromkiro_crew.testing.clockonkiro_crew.apps.manager_recordsand onkiro_crew.dashboard.token_auth_tokens. Each clock read moves the time forward by one second, so the mint always comes after the cutoff. No production file changes.Backwards compatibility
No effect. The change is in one test function.
Tests
test/test_app_in_process_secret.py::test_the_hook_context_mints_this_apps_tokennow runs on the stepped clock. WithManualClock(tick=0)the test fails with "invalid signature", so the step is what keeps the test green. The test passed 10 of 10 runs at-n0and the file passed at-n 4.Proof: not provable -- test-only change
Gate proof: tree 7dec4139ff2c; ran 21; skipped none
Manual verification
N/A: unit coverage is sufficient. The change is to one test, and the test runs in CI.
Screenshots / video
Why no screenshot: the change is to a backend test only.
Related Issues
Follow-up to #35533.
Sibling sweep
Swept: git grep -n "def test_" -- test/test_app_in_process_secret.py
Sibling: test/test_app_in_process_secret.py::test_a_context_kept_past_a_disable_mints_nothing -- not affected -- it expects the mint to fail, so a tie cannot change its result
Sibling: test/test_app_in_process_secret.py::test_boot_moves_the_secret_of_an_app_installed_before_it_left_the_folder -- not affected -- it validates the secret, not a minted token
Pattern harvest
Rule candidate: none
Pattern: a test that compares two timestamps with a strict inequality needs a clock that it controls.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Fixes #35808