Skip to content

test: step one clock for the enable cutoff and the hook mint in the app token test - #35809

Merged
Pearcekieser merged 1 commit into
mainfrom
pearcekieser/app-token-test-clock
Nov 12, 2026
Merged

Pearcekieser merged 1 commit into
mainfrom
pearcekieser/app-token-test-clock

Conversation

@Pearcekieser

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Make the in-process app token test pass on any clock speed.

test_the_hook_context_mints_this_apps_token in test/test_app_in_process_secret.py reads the live clock two times. The first read sets the app's token cutoff when the test enables the app. The second read sets the iat of the token that the hook mints. The token check is iat > 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 > cutoff comparison in token_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) from kiro_crew.testing.clock on kiro_crew.apps.manager_records and on kiro_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_token now runs on the stepped clock. With ManualClock(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 -n0 and 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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Fixes #35808

…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.
@Pearcekieser
Pearcekieser requested review from a team and KiroCrewCaptain as code owners November 12, 2026 10:45
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ⏭️ skipped

Revision af46afd2810ae71f8dfceede795a4b71462b92e4 ships no reviewable capability (docs, tests or generated files only), so there is nothing to inventory. Does not block merge.

@github-actions

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision af46afd2810ae71f8dfceede795a4b71462b92e4 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of af46afd2810ae71f8dfceede795a4b71462b92e4 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Test-only fix: one injected stepped clock removes the tie between the cutoff and the iat. No production code changes, and nothing is taken away.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed af46afd2810ae71f8dfceede795a4b71462b92e4 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] af46afd

Verdict parsed from the review's SHA-scoped output markers for commit af46afd2810ae71f8dfceede795a4b71462b92e4.

False positive or not applicable? A repository writer can comment:
/ai-review override fable af46afd2810ae71f8dfceede795a4b71462b92e4 false-positive: <reason, 20 to 500 characters>

@github-actions

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of af46afd2810ae71f8dfceede795a4b71462b92e4 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] af46afd

False positive or not applicable? A repository writer can comment:
/ai-review override gpt af46afd2810ae71f8dfceede795a4b71462b92e4 false-positive: <reason, 20 to 500 characters>

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: 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 af46afd281 · 10 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 12, 2026
@Pearcekieser
Pearcekieser enabled auto-merge (squash) November 12, 2026 11:50

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Pearcekieser
Pearcekieser merged commit 15f6aec into main Nov 12, 2026
99 checks passed
@Pearcekieser
Pearcekieser deleted the pearcekieser/app-token-test-clock branch November 12, 2026 12:30
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 12, 2026
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.

test: the in-process app token test can fail when two clock reads tie

3 participants