Repository navigation
fix(knowledge): record the text hash on a deduped artifact row - #35417
Conversation
An html artifact is hashed as markup, but the duplicate gate matches and claims the holder's items by the extracted text's hash. The deduped row stored the markup hash, so remove_artifact, release_stale_claim and _adopt_reassigned_item all looked the claim up by a hash no item carries: deleting the artifact left its claim on the holder, and a later holder deletion handed the text to the Artifacts source with nothing behind it. Record the gate's text_hash, which on_duplicate already passes. Fixes #35415
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the deduped html row now stores the hash its claimed items carry, so Notes
[DESIGN-REVIEWED] 865ac5a Description read[DESCRIPTION-READ] 357fdaacf4fd71874cee575cdd911c18c116ab0c01441f4eca23a4ba0d2f8cf9 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. This is a one-argument fix at the mechanism level: the duplicate gate already passed the right hash to the callback, and the callback ignored it. A test that fails on base shows the defect. What this change shipsInventory (4 items) — 4 justifiedIntent: when someone deletes or edits a deduped HTML artifact, its claim on the shared document is released, so no text stays searchable with nothing behind it. FIX.
[FIRST-PRINCIPLES-REVIEWED] 865ac5a Description read[DESCRIPTION-READ] 5a7a5ebc9fe418bced0d2c20da669b5059c7ce41d0b30e7b35a5975234dc14da That sha256 names the PR description this verdict read. 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: |
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: |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (3 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: a one-line knowledge-ingest fix that records the gate's text hash (not the raw markup hash) on a deduped html artifact row, plus a regression test. Spec files changed as a ride-along (a minority of the diff on both file count and changed lines), not reviewed as a design decision: docs/system-specs/modules/knowledge.md.
Problem / Motivation
Goal: A deduped html artifact's state row records the hash its claim's items carry, so deleting or editing the artifact releases that claim.
The pre-ingest duplicate gate matches and claims the holder's items by the extracted text's hash and passes it to
on_duplicate.ingest_artifactignored it (lambda _text_hash: ...) and stored the hash of the raw html body instead (#35415).remove_artifact→detach_source_location_by_hash,release_stale_claimand_adopt_reassigned_itemall look the row up by that hash, and no item carries it.Why it matters
Deleting a deduped html artifact leaves the Artifacts source holding the winner's item. When the winner is deleted later, the text moves to the Artifacts source and stays searchable with no artifact behind it, and no row names it, so nothing removes it.
Not a goal
active): they hold their own copy, and the short-circuit compares their markup hash with the next body's.What changed (motivation → approach → change)
knowledge/artifact_ingest.py: theon_duplicatefinalizer writes the gate'stext_hashinto the deduped row. For html, text hash and markup hash differ. The other kinds read through_read_text, so for them the two match.docs/system-specs/modules/knowledge.md: the sentence saying the aggregate tables store the text hash now says how that holds for a refused html artifact, and names the test.Backwards compatibility
Compatible: nothing new is refused or rejected. A deduped html row written before this keeps its markup hash until its next re-ingest (every start, since a deduped row has an empty group), when the gate rewrites it with the text hash. Because that re-ingest compares the stored text hash with the new markup hash, it releases the claim first and the gate then re-claims it in its own transaction. This is the same cost a deduped row already pays: it is re-attempted on every start.
Removes nothing: no field, route or result shape is taken away.
Tests
test/test_knowledge_artifact_ingest.py::test_a_deduped_html_artifact_records_the_hash_its_claim_names: ingests an html page into a folder source, then creates an html artifact with the same body. It asserts the duplicate status, that the row's hash equals the holder item's hash, and thatremove_artifactreleases the claim.test/test_knowledge_artifact_ingest.py(74 passed), black/isort/flake8/mypy, the black, comment-history and brand gates, the flake-pattern ratchet, the file-line cap, docs-lint.Proof: not provable -- other: run by hand rather than with prove.py; with
artifact_ingest.pyreverted to main the new test fails on the hash assert ('f7f463e2799...' != 'e67f6978ee1...'), and it passes on head 865ac5a.Manual verification
Not run against a live gateway; the test drives the real
IngestionPipeline,FileReaderandKnowledgeStore.Related Issues
Fixes #35415
Sibling sweep
Swept: git grep -n "on_duplicate=" -- src/kiro_crew
Sibling: src/kiro_crew/knowledge/artifact_ingest.py -- changed here
Sibling: src/kiro_crew/knowledge/folder_watcher.py -- not affected -- already records the gate's text_hash as
known_text_hashSibling: src/kiro_crew/knowledge/agent_source.py -- not affected -- always writes
.md, read by_read_text, so its stored hash is the text hashPattern harvest
Rule candidate: review-prompt
Pattern: a callback parameter the caller names
_xand ignores while it stores a different value in the same roleChecklist
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.