Skip to content

test(wakatime): start the read-audit cache cold so the status load count is exact - #37726

Merged
bolichen97 merged 1 commit into
mainfrom
fix/wakatime-status-load-count
Nov 16, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/wakatime-status-load-count

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: test_status_loads_config_off_the_event_loop stops failing on main whenever it runs in a shard without the tests that warm its caches.

The test asserts on_loop == [False]: exactly one KiroCrewConfig.load, off the loop. The status route now loads config twice, both off the loop: once in oauth._client_credentials for the client id, and once more when the vault's read audit (secrets.read_audit._enabled) runs on the secret read beside it. Run alone, the test sees [False, False] and fails. It fails on main ce18586acb run by itself, and it reddened Backend Tests (3.12, 1) on #37698 and #37646, whose shards put it first.

Why it matters

Unrelated PRs go red on backend shard 1 and on Coverage Gate, which fails closed on it.

Not a goal

  • No change to the route or to the read audit.

What changed (motivation -> approach -> change)

The count depends on hidden process-wide state (the live snapshot and the read-audit cache), so pin that state instead of loosening the count -> the test sets live.snapshot to return None and read_audit._loaded to None -> it asserts the exact cold-cache sequence on_loop == [False, False]: one load for the client id, one for the audit switch, both off the loop.

Backwards compatibility

Compatible: test-only.

Removes nothing: the assertion stays an exact sequence. A load on the loop, or an extra or missing load, still fails it.

Tests

  • test/test_wakatime_handlers.py: the test passes alone, and with test/test_vault_read_audit.py run before and after it (68 passed each order).

Proof: not provable -- test-only change

Manual verification

N/A: test-only. The two loads were confirmed with a stack probe: oauth.py:_client_credentials and vault.py:get -> read_audit.py:_enabled.

Screenshots / video

N/A: no user-visible UI change.

Related Issues

Seen on #37698 and #37646.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 16, 2026
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

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

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ⏭️ skipped

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

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks. This is a test-only change: it pins the process-wide cache state the count depends on, and the assertion stays an exact sequence.

[DESIGN-REVIEWED] a0d12de

Description read

[DESCRIPTION-READ] 8c02c93fb46129c2a4c4bd2733464f407d88088dbc0a99e138c4eb0017a52d8e

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

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] a0d12de

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

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

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] a0d12de

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

…unt is exact

The status route reads the OAuth client secret beside the client id. That
secret read asks the vault's read audit whether it is on, and with no live
snapshot `secrets.read_audit._enabled` loads config.json once per TTL and
caches the answer process-wide. So the route loads config twice on a cold
cache and once on a warm one, and the test's exact `[False]` pin passed or
failed depending on which test ran before it.

Pin both inputs: no live snapshot and an empty audit cache. The test now
asserts the exact cold-cache sequence `[False, False]`, both loads off the
event loop, whatever ran first.
@chenmingwei23
chenmingwei23 force-pushed the fix/wakatime-status-load-count branch from feae664 to a0d12de Compare November 16, 2026 00:10
@chenmingwei23 chenmingwei23 changed the title test(wakatime): assert the status route loads config off the loop, not how often test(wakatime): start the read-audit cache cold so the status load count is exact Nov 16, 2026
@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 16, 2026
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: the decider estimates a 5% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes.

Test-only fix, and it is correct. The status route loads config twice, both off the event loop inside asyncio.to_thread(oauth._client_credentials). The first load is oauth.py:144 (KiroCrewConfig.load() for the client id). The second comes from SecretVault.get → _note_reads → read_audit._enabled. That one only loads config.json when live.snapshot() is None and read_audit._loaded is cold or past its TTL, so the count changed depending on which tests ran first in the shard. The test now patches live.snapshot and read_audit._loaded, the exact names _enabled reads (from kiro_crew.config import KiroCrewConfig, live; module global _loaded). It also patches KiroCrewConfig.load on the class, so both loads hit the stub. The assertion is still an exact sequence ([False, False]), so a load on the loop, an extra load or a missing load still fails it. monkeypatch restores both values, so nothing leaks to other tests. test/test_vault_read_audit.py:52 already resets _loaded the same way. No production code changes. All CI checks passed, including backend shard 1 and Coverage Gate.

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

@bolichen97
bolichen97 merged commit 5c8ce43 into main Nov 16, 2026
100 of 108 checks passed
@bolichen97
bolichen97 deleted the fix/wakatime-status-load-count branch November 16, 2026 01:16
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 16, 2026
bolichen97 added a commit that referenced this pull request Nov 16, 2026
…7659

testing-conventions §4 already says a new process-global ships its floor
entry. #37659's secrets.read_audit._loaded did not, and made
test_status_loads_config_off_the_event_loop red by order (fixed in #37726,
floor entry in #37754). Record why the rule did not stop it and add a
pre-push grep that flags new module-level state, plus a writing-tests
pointer and checklist item.

Part of #37737
bolichen97 added a commit that referenced this pull request Nov 16, 2026
…7659 (#37750)

testing-conventions §4 already says a new process-global ships its floor
entry. #37659's secrets.read_audit._loaded did not, and made
test_status_loads_config_off_the_event_loop red by order (fixed in #37726,
floor entry in #37754). Record why the rule did not stop it and add a
pre-push grep that flags new module-level state, plus a writing-tests
pointer and checklist item.

Part of #37737
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.

3 participants