Repository navigation
fix(ingest): send knowledge text as a knowledge_base item so search returns the text (OSS-70) - #56
Conversation
…eturns the text (OSS-70) `hydradb ingest --kind knowledge --text ...` sent an app_knowledge item with no kind. The server chunks such an item as its whole JSON record, including the acl_* fields it stamps on it, so query returned that JSON and not the text. A knowledge_base item is rendered from its fields, so the CLI now sends app_kind=knowledge_base with the text in app_fields.body_text. The client id, title, acl and infer are sent as before. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: adityamishra-hydradb <[email protected]>
|
@hydra-mira-review review |
|
/devin review |
Mira score 5/5 · 🟢 Good to merge
Knowledge text ingested through the CLI now appears in search as a title and content, without internal record fields. The payload uses Before this ships · 1 in place
How this PR works · 2 changes, 1 medium risk, 1 low riskKnowledge text appeared in search as a JSON record containing internal ACL fields, wasting tokens and exposing implementation details. This PR sends knowledge text as a typed knowledge-base item so the server renders its title and body. It retains the stored text and existing item options. 1. Send knowledge text through the knowledge-base renderer · 🟠 medium risk ·
|
OpenHack SummarySecurity review of fix(ingest): send knowledge text as a knowledge_base item so search returns the text (OSS-70). 3 changed files; 0 findings at or above the low reporting threshold. Confidence Score: 5/5No reportable security findings were detected in this scan. Security merge-readiness rubric: 1 = critical, 2 = high, 3 = medium, 4 = low, 5 = no reportable findings. This score reflects scan findings, not a guarantee of correctness or complete coverage. Files Needing Attention: None Important Files Changed
Last reviewed commit: 665f442 · View review on OpenHack
|
…t (OSS-70) The live tier showed that inspect reads the stored text from content.text, which the previous commit left empty. The knowledge_base renderer does not read content.text, so sending the text there too keeps inspect working and does not change the chunk (checked on prod: one chunk, title and text only). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: adityamishra-hydradb <[email protected]>
|
@hydra-mira-review review |
|
/devin review |
For humans
Problem.
hydradb ingest --kind knowledge --text "..."stored the text, but search did not return it. Search returned a JSON record with internal fields (acl_snapshot_signature,acl_admission_id, ...) and the text inside it. This is bad context for an LLM, it uses about 5 times more tokens, and it shows internal fields to the user. Linear: OSS-70.Cause. The CLI sent the text as an
app_knowledgeitem with nokind. The server chunks an item with no kind as its whole JSON record, including theacl_*fields that the server adds.Fix. The CLI now sends the text as a
knowledge_baseitem, with the text infields.body_text. The server renders that item as "Title + Content", so search returns only the title and the text. The text also stays incontent.text, becausehydradb inspectshows it from there (the renderer does not read it, so the chunk does not change). The client id (--source-id),--title,--acland--no-inferwork as before. One file changed insrc/.Proof on prod (a throwaway database in the throwaway org, deleted after the test). The same text, ingested by a 0.2.3 wheel from
main(A) and from this branch (B):main{"acl_revision_captured":true,"acl_source_deployment_id":"free","acl_admission_id":"566e…",…,"content":{"text":"Q4 pricing…"}…}(~650 characters)## Title\n\nGlimmer B\n\n## Content\n\nQ4 pricing for Quuxcorp: the Glimmerfang plan costs 57 dollars per seat per month.source_typedocumentknowledge_baseAlso checked on prod with this branch: the
--source-idis kept;list --kind knowledge,update --acl,update --additional-metadata,relationsanddelete <id>work;--acl user:xhides the item from another principal; a 16 KB text gives 7 normal chunks; no--source-idgives a server id and a clean chunk; re-ingesting an id that an older CLI stored replaces the old JSON chunk.Not in this PR.
hydradb inspect <id>still shows the stored JSON record with theacl_*fields. The server returns that record for everyapp_knowledgeitem, so the fix is on the server (/context/inspectshould drop theacl_*fields).## Unreleasedsection at the same place, so a line here would conflict. Add it after PR 55 merges.For agents
src/hydradb_cli/hydra/client.py,_Context.ingest, knowledge-text branch. The item was{"id", "content": {"text"}}. It is now{"id", "content": {"text"}, "app_kind": "knowledge_base", "app_fields": {"body_text": text}}, plustitle,infer: falseandaclas before.app_kind/app_fieldsare theAppKnowledgeModelJSON names, which are already in the simulator allowlistAPP_KNOWLEDGE_ITEM_KEYS.ingestion/internal/temporal/activities/chunk.goproduceKnowledgeChunkssends an item withAppKind != ""to the app-source renderer, else it chunks the raw file.ingestion/internal/platform/appsource/render.goKnowledgeBaseFields.renderusesbody_markdown, elsebody_text. It ignorescontent.text, sokindalone indexes the title only (tested on prod: chunk## Title\n\nPricing KB).documents.md upload (as the MCP does): the server makes a new uuid for adocumentsupload, so--source-idwould stop working fordeleteandverify(see the docstring ofingest).content.textback: thelivejob on a177732 failedinspect.content,inspect.alias.fetch_contentandburst.inspect, which read the stored text fromcontent.text. Checked on prod after the change: one chunk (## Title\n\nPemberwick\n\n## Content\n\nThe Pemberwick gateway…) and inspectcontent.text= the text.tests/test_wrapper.py::TestIngest::test_ingest_knowledge_text_is_a_knowledge_base_item(new) andtests/e2e/sim/test_simulated.py::test_knowledge_text_ingest_sends_accepted_keys(new expected item). Both fail onmainand pass here.make lintandmake testpass (1898 passed, 133 skipped).🤖 Generated with Claude Code