Repository navigation
fix(cron): probe the store before deciding a secret grant - #22824
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
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: |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS This fix reuses the probe and 409 helper that already exist. It points the boundary test at the real cause: a skip matched on the bare file name, which hid both handlers. What this change shipsInventory (3 items) — 3 justifiedIntent: when
[FIRST-PRINCIPLES-REVIEWED] cd0407b Description read[DESCRIPTION-READ] 8adcf841784536b897cd229a237c81870dec4b5f742d068156238cb0da7b4841 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns. The fix adds the shared unreadable-store probe to the two grant handlers that lacked it. The fix also stops the boundary scan from skipping files by bare name, which is what hid those handlers. [DESIGN-REVIEWED] cd0407b Description read[DESCRIPTION-READ] 4d729f506c6a4cdcec793a594afd774ca34db8f18028ed44f3f8553d752b1121 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: |
64aeb69 to
294e808
Compare
294e808 to
cd0407b
Compare
|
Review-ready at head cd0407b: pr_status.py exited 0 (rollup: total=104 running=0 failing=0; PR Readiness success; label: readiness: passed). GPT and Opus lanes are fresh on this head; Design and First Principles both PASS; no unresolved threads. Main has moved since this head went green (base +13 commits (622844a -> c428ea0), overlap: src/kiro_crew/dashboard/chat_runner.py (import), test/test_dashboard_origin.py (test-stem), test/test_safe_read_file_bytes_descriptor.py (import), test/test_slack_gateway_more_coverage.py (import), test/test_spawn_backend.py (import), test/test_spawn_release_queued.py (import)). None of these are files this PR edits. This PR has been rebased three times already, so I am holding the head here rather than rebasing again; the maintainer can rebase before merging if wanted. Waiting on maintainer review. I will not merge, approve, or arm auto-merge. 🤖 AI-assisted comment 🤖 |
buluoray
left a comment
There was a problem hiding this comment.
Reviewed at cd0407b. Approving.
The probe reads only the _load_failed flag that the preceding get_job_async just set (store_sync.py:498-516), so it adds no IO on the event loop, and both call sites put it after the read as its docstring requires. The window between read and probe is harmless: if the flag flips after a successful read the answer is a conservative 409, and if the store recovers in between the answer is the same 404 as main. The grant writes themselves still pass update_job_async's write-time guard, which already maps to the same 409, so the probe makes the error answer accurate and does not replace the safety guard. The vault and epoch side effects all come after the job check, so an unreadable store never reaches them.
Mutation check: removing either probe turns its named test red (test_store_unreadable_on_read_is_409_not_job_not_found, test_store_unreadable_at_promotion_read_is_409). Narrowing the boundary-test skip to the full path is a good catch.
Nit: the commit has a title but no body; the PR description covers the why.
Problem / Motivation
Goal: When the cron store cannot be read, approving, denying or revoking a script job's secret grant answers the same "cron store unreadable" 409 every other cron change answers, instead of "job not found".
An unreadable
crons.jsonloads as an empty job list without raising. The secret-grant route (PUT /api/crons/{id}/secrets) and its promotion path look the job up, find nothing, and answer 404job_not_found. The owner is told the job is gone while it is still on disk, and gets no hint that the store needs repair.Why it matters
The owner acts on the answer. "Job not found" over a corrupt store hides the real fault and its fix ("Move the unreadable file aside"). Every other read-decide-write cron route already answers the unreadable 409; these two were missed because a test skip hid them.
Not a goal
What changed (motivation → approach → change)
Symptom: on an unreadable store, the secret-grant route says "job not found". Cause:
api_cron_secret_grantand_promote_pending_grantread the job and then write it, but never callraise_if_store_unreadable(). The boundary test that requires that call skipped every file namedcron.py, and after the #21672 split it also skippedcron_secret_grants.pyby name. So it never saw them.Change:
state.crons.raise_if_store_unreadable()right after their job read and return the shared unreadable 409.src/kiro_crew/cron.py, matched on its full path. With the old skip and without the probes, it names exactly these two functions.Backwards compatibility
Compatible: on a readable store nothing changes; on an unreadable store a 404 becomes the 409 the other cron routes already send.
Removes nothing: the change adds a refusal branch and narrows a test skip; no route, field or record is removed.
Tests
test_store_unreadable_on_read_is_409_not_job_not_found: approve, deny and revoke on a corrupt store each answer 409cron_store_unreadable(not 404), and the store bytes stay untouched.test_store_unreadable_at_promotion_read_is_409: the store turns unreadable between the route's read and the promotion's own re-read; the answer is the 409 and nothing is promoted.test_every_read_decide_write_caller_probes_or_is_exemptnow scanscron_secret_grants.pyanddashboard/handlers/cron.py.Proof: with
cron_secret_grants.pyreverted toorigin/main, both new route tests fail and the boundary test names_promote_pending_grantandapi_cron_secret_grant. With the fix all pass.Determinism: the two new tests passed 20/20 at
-n0; the whole grant-endpoint file passed 10/10 at-n 4; both changed files (67 tests) passed in a seeded shuffled order (seed 21358).Manual verification
N/A — unit coverage sufficient: the route tests drive the real aiohttp handler over a real corrupt store file.
Related Issues
Closes #21358
Part of #20192
Pattern harvest
Rule candidate: review-prompt
Pattern: a test skip matched on a bare file name (
path.name == "x.py") hides every same-named file; match on the full package path.Checklist