Skip to content

fix(knowledge): read rebuild:'false' as false on embedding generate - #37127

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
crew/conductor/embed-rebuild-string-bool
Nov 14, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
crew/conductor/embed-rebuild-string-bool

Conversation

@RohanK6

@RohanK6 RohanK6 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

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/generate read rebuild and force with a plain truth test, so the JSON string "false" was truthy (#37126). It started a background re-embed of the whole corpus, and with force a 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

  • Rejecting non-boolean values: every value other than the strings "true" and "false" keeps its current reading.
  • Other routes that read flags with a truth test.

What changed (motivation → approach → change)

  • dashboard/handlers/knowledge_embeddings.py batch_embed_items: read rebuild and force with the shared config.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 a warnings list 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's TYPE_CHECKING block names _coerce_bool from 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 warnings key). 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 reads embedded, total and remaining.

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 no job_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.
  • Ran: every test file that posts to /api/knowledge/embedding/generate or calls batch_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.
  • Local review: Opus (CI contract, both stages): PASS, no findings, on the first version; the First Principles lane then asked to reuse the shared reader, which this head does.

Proof: not provable -- other: run by hand rather than with prove.py; with knowledge_embeddings.py reverted to main the three string-false cases fail (main returns a job_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 KnowledgeStore with 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 True

Pattern 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

  • 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

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@RohanK6
RohanK6 requested review from a team and KiroCrewCaptain as code owners November 14, 2026 06:49
@RohanK6
RohanK6 requested a review from dodgeblaster November 14, 2026 06:49
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 14, 2026
@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 8df0f6f1249a2e6c83d7c27fc9acad5bb2121a8d 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 14, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the change reuses the shared _coerce_bool reader that sibling handlers already use, so a false-meaning string no longer starts a re-embed. Every non-string value keeps its old reading.

Notes

  • The new warnings key only appears when a flag arrives as a string, which makes the reply shape conditional. If more routes pick up this pattern, give them one shared reply envelope instead of a per-handler _reply closure.

[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 .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 14, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 8df0f6f

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

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

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 8df0f6f1249a2e6c83d7c27fc9acad5bb2121a8d — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

The fix is the shared _coerce_bool reader, and it removes #37126 on its own. The new warnings reply field is extra surface that nothing reads.

Notes

  • Item 2 — rides along, zero consumers: the PR adds "warnings": warnings to every reply, but the only frontend caller, website/src/api/client/memory.ts, posts {} and never reads it. The sibling _coerce_bool readers don't add a warning: 3 counted, memory_embeddings.py:498, session_storage.py:364 and diagnostics.py:98. The message text is a second copy of the string branch of cron_jobs.py:416 _coerce_bool_flag. Subtraction: delete the warnings list, the isinstance(raw, str) branch and _reply, and go back to plain web.json_response.

What this change ships

Inventory (4 items) — 2 justified

Intent: stop a JSON-string "false" sent to the embedding-generate route from starting a full re-embed of the knowledge library. This is a FIX.

  1. The strings "false", "0", "no" and "off" for rebuild no longer start a full re-embed — justified
  2. The reply gains a warnings list when a flag arrives as a string — rides along, zero consumers, wording copied from cron_jobs._coerce_bool_flag
  3. The same false-meaning strings for force no longer force a re-embed — justified
  4. The facade's TYPE_CHECKING block now names _coerce_bool — rides along

[FIRST-PRINCIPLES-REVIEWED] 8df0f6f

Description read

[DESCRIPTION-READ] d4b5d3f79099db0684e4dc80097405273b1ef863c6c24c85bd68478efa1999e1

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 8df0f6f

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

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: 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):

  • Second, divergent copy of the shared string-bool reader. AGENTS.md asks to consolidate duplicated logic and treat a finding as a class; the same bug class (a falsy string spelling triggering a costly full re-embed) is left open on the same route. Reuse _coerce_bool / _coerce_bool_flag for rebuild an (src/kiro_crew/dashboard/handlers/knowledge_embeddings.py, medium)
  • The force half of the change has no test that would fail on main. (test/test_knowledge_handlers_coverage.py, low)

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

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 14, 2026
@RohanK6
RohanK6 force-pushed the crew/conductor/embed-rebuild-string-bool branch from d758432 to c0df6a4 Compare November 14, 2026 08:29
@RohanK6

RohanK6 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

Fixed in c0df6a4: the local reader is gone. rebuild and force are now read with the shared config.fields._coerce_bool(raw, bool(raw)), the same as the sibling handlers, so "0" and "off" read as False too. Removing the helper also clears the facade mirror guard failure on shards 7 and Windows 2. The CodeQL reds were the shared rate limit.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 14, 2026
@RohanK6
RohanK6 force-pushed the crew/conductor/embed-rebuild-string-bool branch from c0df6a4 to 8a6f764 Compare November 14, 2026 10:17
@RohanK6

RohanK6 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

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.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 14, 2026
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
@RohanK6
RohanK6 force-pushed the crew/conductor/embed-rebuild-string-bool branch from 8a6f764 to 8df0f6f Compare November 14, 2026 13:17
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 14, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) November 14, 2026 18:35

@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.

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 force half has no test that fails on main. One case could post {"rebuild": true, "force": "false"} with a fake job that captures force, then assert force 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 warnings field and the _reply closure. No caller reads them, and the fix works without them.

@KiroCrewCaptain
KiroCrewCaptain merged commit 78e25d2 into main Nov 14, 2026
156 of 163 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the crew/conductor/embed-rebuild-string-bool branch November 14, 2026 18:35
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 14, 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.

Embedding generate starts a full re-embed when rebuild is the string "false"

2 participants