Repository navigation
Issue-222: Hunt refusal codes and API errors - #239
zakiyyah-osman wants to merge 3 commits into
Conversation
One builder per hunt: code namespace of A22.7.4 with a parser, the seven hunt errors of A22.7.1, and shared/hunt-codes.json with the codes, their proposed words and the errors. The register now uses the builders. Q-530 records the shapes the spec does not state. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
JoottunAtish
left a comment
There was a problem hiding this comment.
Thanks, this is clean work. It covers all of #222, the code shapes and error statuses match A22.7.4 and A22.7.1, and the hunt-code and register tests pass locally (50 passed). One blocker, then some smaller points.
Blocking
1. Q-530 is already taken by #238. #238 was opened 11 minutes earlier and also records its decision as Q-530, with "Next free" set to Q-531. Please renumber this PR's decision to Q-531 and set "Next free" to Q-532, in:
docs/decisions/discovery-hunts.md(the "Hunt codes and errors" section and the header line)docs/decisions/README.md(the index row and the Next free line)docs/README.md(the Discovery hunts routing row; #238 edits the same row, so rebase after it merges)docs/architecture/refusals.mdshared/README.md- the docstring in
backend/app/core/hunts/codes.py
Should fix before the scan route uses check_hunts
2. The hunt:disabled message shows the raw code (backend/app/api/hunts.py:33-35). The message reads "Hunt 'dark_companions' is disabled: hunt:dark_companions:needs_release:gaia_dr4." The scan screen shows detail as-is (frontend/src/app/area/scanStore.ts, failView), so the user would see the code (Q-477). Word the message in plain prose, or put the reason in its own field.
Non-blocking
- Placeholders in
shared/hunt-codes.json. Q-531 should say where each placeholder gets its value.{release}would fill withgaia_dr4rather than "Gaia DR4" (the register'sreleaseshas the readable name), and{criterion}withr_lt_18rather than "r < 18".{percent},{square},{count}and{why}are not parts of the code at all. <where>for catalogue hunts. These hunts cover the whole patch, not one square (A22.4, R-10). Say what<where>holds for them, for examplepatch.HUNT_IDS(codes.py:99-100). The way it is derived depends on the generated type's exact shape. Add a comment pointing attest_hunt_ids_are_the_register_ids.- The AST guard only catches string literals that start with
hunt:. An f-string or a joined string gets past it. A note in the test is enough. - The
register.py:5docstring lost detail: it changed fromhunt:<id>:not_builttonot_built. shared/hunt-codes.jsonis hand-written, with no schema. Say so inshared/README.md, so nobody expects the generator to produce it.check_huntscould move intocore/hunts/when the scan route starts using it.
Please also keep an eye on CI: your first Vitest run had 10 failures that did not come back.
Renumber the decision to Q-531 (#238 takes Q-530), word the hunt:disabled detail without the raw code, set <where> to "patch" for catalogue hunts, say where each placeholder comes from, and make the review's small doc and comment fixes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Thanks for the review. Pushed in 55c9d53: 1. Renumbered to Q-531, "Next free" is Q-532 (also updated the docstring in 2. 3–4. Q-531 now gives proposed placeholder sources (no reply field holds 5–8. Done. On 6: an f-string that starts with 9. Leaving until the scan route uses |
Q-531 states this form and the row schema of PR #238 requires it, but the builder and parser accepted any segment. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
JoottunAtish
left a comment
There was a problem hiding this comment.
Re-reviewed at 02a4e45. Thanks for the quick turnaround: everything from the last review is fixed, and CI is green. Approving.
What I checked:
- Q-531 is renumbered everywhere, and "Next free" is Q-532.
- The
hunt:disabledmessage is now plain prose and has a test. - The placeholder sources are recorded in Q-531.
- The
<where>rule (square_<n>orpatch) is recorded and enforced in the parser, and every code in #238's fixture parses under it. - The comment, docstring and README points are all done.
Moving check_hunts into core/hunts/ can wait until the scan route uses it, as you said.
Nits (non-blocking, fine as a follow-up)
- One fact, two decisions. #238's Q-530 point 10 states the same
<where>rule as Q-531 point 2. Let Q-531 own it, since the rule lives incodes.py, and have Q-530 refer to it. Whichever PR merges second can do this when it rebases. - Release names are duplicated.
backend/app/api/hunts.py:29hard-codesRELEASE_NAMES = {"gaia_dr4": "Gaia DR4"}, butregister.pyalready hasreleases=("Gaia DR4",), and Q-531 point 3 names the register as the source. A newneeds_releasehunt would quietly fall back to "a later data release". Read the name from the register, or add a test that everyneeds_releasereason has an entry. - Malformed reason gives a 500.
hunt_disabledcallscodes.parse(reason)(api/hunts.py:39), so a malformedavailability.reasonwould raiseHuntCodeErrorand return a 500 instead of the 422. This can't happen today, because every reason is built bycodes. - Wording. For the dark-companions hunt the message reads "'Gaia DR4 dark companions' cannot run. It opens with Gaia DR4.", which names Gaia DR4 twice.
After #238 merges, rebase for the routing row in docs/README.md and the "Next free" line. Q-531 still needs Kevin's and Moon's confirmation.
Closes #222
What changed
backend/app/core/hunts/codes.py: one builder perhunt:namespace of A22.7.4 (includingnot_built) and a parser. Unknown hunts, namespaces, suffixes and badly formed segments raiseHuntCodeError.backend/app/api/hunts.py: the seven errors of A22.7.1 in the{error, detail}body, andcheck_hunts()for the empty, unknown and disabled cases.backend/app/core/hunts/register.py: reason strings now come from the builders. The register data is unchanged.shared/hunt-codes.json: every code with its proposed words, and every error with its status.refusals.md,shared/README.md.For review (Q-531, open)
a-z, digits and_, as the register schema already requires.no_sectororoutside_footprint, so they arenull. Hunt picker card (against fixtures) #225 / Results by hunt and the row card (against fixtures) #226 will need to word them.<where>issquare_<index>for pixel hunts andpatchfor catalogue hunts; the builder and parser refuse anything else.hunt:disableddetail names the hunt and the reason in plain words, with no raw code (Q-477).Limits
check_hunts()yet, and the routes behindhunt_not_in_run,row_not_found,hunt_not_doneandroute_not_availabledo not exist. Their status and body are tested through a temporary route.Tests
<where>check (02a4e45): 1922 passed, 5 skipped (sky assets not baked locally).src/test/Vitest files (38 passed) and the Prettier check ofhunt-codes.jsonwere rerun locally; the frontend results above are from the first commit.ci-gatepassed, including the backend job, the frontend typecheck, lint, test and build job, all four Playwright shards and the engine speed check. e2e was not run locally.🤖 Generated with Claude Code