Repository navigation
fix(knowledge): read rebuild:'false' as false on embedding generate - #37127
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the change reuses the shared Notes
[DESIGN-REVIEWED] 8df0f6f Description read[DESCRIPTION-READ] 406fa71873bfd6f7b44de02da6c112dbf59a65a9646f14e7f5e066291b003959 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: |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The fix is the shared Notes
What this change shipsInventory (4 items) — 2 justifiedIntent: stop a JSON-string
[FIRST-PRINCIPLES-REVIEWED] 8df0f6f Description read[DESCRIPTION-READ] d4b5d3f79099db0684e4dc80097405273b1ef863c6c24c85bd68478efa1999e1 That sha256 names the PR description this verdict read. Recompute it with |
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: A person should decideWhy: the decider raised 2 possible problems and estimates a 50% chance that this change introduces a defect; a person should check them. The fix works for the literal "false" string, but it adds a narrower copy of the shared bool reader (config.fields._coerce_bool, which cron_jobs._coerce_bool_flag already wraps). Because of that, "0"/"off"/"no" still trigger a full re-embed, which contradicts the PR's claim that it follows cron_jobs' reading and the repo's rule to consolidate duplicated logic. The force flag also has no test. Requesting changes to reuse the shared reader. Things to check (possible problems the decider raised; at this confidence many turn out to be fine):
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 |
d758432 to
c0df6a4
Compare
|
Fixed in c0df6a4: the local reader is gone. |
c0df6a4 to
8a6f764
Compare
|
Pushed 8a6f764. The knowledge facade now names the shared bool reader in its type-checking block, as the facade test requires for every name imported from outside the family. That was the backend shard failure on Linux, Windows and macOS. On the GPT finding: this PR does not touch the security paths module. Its diff is the embeddings handler, the knowledge facade and one test file. The scratch-file check the finding names is already on main, and the adjudication note traces it to an earlier commit. The new head gets a fresh review. |
POST /api/knowledge/embedding/generate read rebuild and force with a plain truth test, so the JSON string "false" was truthy: it started a background re-embed of the whole corpus (and a forced one with force). Read both flags with the shared config.fields._coerce_bool, as the sibling handlers do: the usual spellings (true/false, 1/0, yes/no, on/off, any case) map to their value and any other value keeps the same truth test as before, so nothing is rejected. A string flag adds a warnings list to the reply telling the caller to send a JSON boolean; a reply for a JSON bool is unchanged. Fixes #37126
8a6f764 to
8df0f6f
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approved. On this head the review checked three things. _coerce_bool(raw, bool(raw)) returns JSON booleans unchanged and reads every non-string value the same way main does. Only the false-meaning strings ("false", "0", "no", "off", any case or padding) now read as False, for both rebuild and force. The facade TYPE_CHECKING block names _coerce_bool as the mirror guard requires. The only frontend caller posts {}, so its reply is unchanged. PR Readiness is green.
Done well: the fix reuses the one shared bool reader instead of adding a second copy. The parametrized test runs the real HTTP route against a real store, and a revert to main turns it red.
Optional:
- The
forcehalf has no test that fails on main. One case could post{"rebuild": true, "force": "false"}with a fake job that capturesforce, then assertforce is False. - The Proof line says three string cases fail on a revert, but the test now has five. A short PR comment could also note that "0", "no" and "off" change too, as Backwards compatibility already says, because the Not a goal line predates that.
- You could drop the
warningsfield and the_replyclosure. No caller reads them, and the fix works without them.
Problem / Motivation
Goal: Sending
"rebuild": "false"(a string) to the embedding generate route no longer starts a full re-embed of the knowledge library.POST /api/knowledge/embedding/generatereadrebuildandforcewith a plain truth test, so the JSON string"false"was truthy (#37126). It started a background re-embed of the whole corpus, and withforcea forced one.Why it matters
A full re-embed is slow and costs embedding calls for every item. A caller that sends booleans as strings (a script, a form) triggers it while asking for the opposite.
Not a goal
"true"and"false"keeps its current reading.What changed (motivation → approach → change)
dashboard/handlers/knowledge_embeddings.pybatch_embed_items: readrebuildandforcewith the sharedconfig.fields._coerce_bool(raw, bool(raw)), as the sibling handlers do (review request: no second copy of the reader). The usual spellings (true/false,1/0,yes/no,on/off, any case) map to their value, and anything else falls back to the same truth test as before. A string flag adds a warning to awarningslist in the reply, telling the caller to send a JSON boolean; the list is present only when a warning was raised.dashboard/handlers/knowledge.py: the facade'sTYPE_CHECKINGblock names_coerce_boolfrom its home module, as it does for every name an owner imports from outside the family.Backwards compatibility
Compatible: nothing is rejected. A JSON boolean, a missing key and any non-string value read exactly as on main, and their reply is unchanged (no
warningskey). The changed readings are the false-meaning strings"false","0","no"and"off", which no longer start a rebuild; any other string keeps the truth test. The only frontend caller (website/src/api/client/memory.ts) posts{}and readsembedded,totalandremaining.Removes nothing: no field, route or result shape is taken away.
Tests
test/test_knowledge_handlers_coverage.py::TestBatchEmbedItems::test_the_string_false_does_not_start_a_rebuild[false, False, " false ", 0, off]: runs the fill-NULL path, returns nojob_id, and carries the warning.test/test_knowledge_handlers_coverage.py::TestBatchEmbedItems::test_a_json_bool_reply_carries_no_warnings: pins that a JSON bool reply is unchanged./api/knowledge/embedding/generateor callsbatch_embed_items, plus the facade mirror guard, the knowledge facade test and the flake-pattern ratchet (454 passed; 270 in the facade and coverage files after the facade line below), black/isort/flake8/mypy (Linux), the black and comment-history gates.Proof: not provable -- other: run by hand rather than with prove.py; with
knowledge_embeddings.pyreverted to main the three string-false cases fail (main returns ajob_id: it started a rebuild), and they pass on head 8df0f6f (a rebase of 8a6f764 onto main for the test_tracing_otlp fix #37171, same diff).Manual verification
Not run against a live gateway; the tests drive the real aiohttp handler on a real
KnowledgeStorewith a fake embedder.Related Issues
Fixes #37126
Sibling sweep
Swept: git grep -n "body.get("rebuild"|body.get("force"" -- src/kiro_crew/dashboard/handlers
Sibling: src/kiro_crew/dashboard/handlers/knowledge_embeddings.py -- changed here
Sibling: src/kiro_crew/dashboard/handlers/updates_apply.py -- not affected -- its force flag already refuses a non-bool and reads only
is TruePattern harvest
Rule candidate: review-prompt
Pattern: a JSON body flag read with a plain truth test, so the string "false" turns the flag on
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.