Repository navigation
OSS-152 OSS-155 OSS-168: CLI reads cover both kinds, delete finds the kind, -t - reads to EOF, errors show the request id - #59
Conversation
…kind, stdin to EOF, request ids - ingest -t - reads piped stdin until EOF (no 0.1 s cut-off); a TTY is an error. - list/query/relations without --kind cover both kinds (type=all); --kind all accepted. relations reads knowledge, then memory, since the API's type=all there reads knowledge only. - delete without --kind looks the ids up and deletes from the one kind that holds them; an id stored as both kinds or ids split across kinds delete nothing. - API errors carry the request id (json "request_id" key, human "request id:" line). - A config file that is not valid JSON is an error, and is never overwritten. 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
Users can read both record kinds, delete records without choosing a kind, and ingest piped text that starts slowly. Errors now include request IDs, and invalid configuration files produce errors instead of being silently ignored. Tests and documentation cover these changes. Before this ships · 1 to confirm
How this PR works · 7 changes, 1 high risk, 4 medium risk, 2 low riskThe CLI currently misses stored memories, rejects slow piped input, and hides information needed to diagnose failures. This PR changes read defaults, discovers the kind before deletion, and waits for explicit stdin input to finish. It also preserves request IDs and rejects corrupt configuration before saved credentials can be overwritten. 1. Carry request IDs from API failures to CLI errors · 🟢 low risk ·
|
…ructural links, request ids on file rows and no-op deletes Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: adityamishra-hydradb <[email protected]>
|
@hydra-mira-review review |
|
/devin review |
…on-UTF-8 config file is a named error Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: adityamishra-hydradb <[email protected]>
|
@hydra-mira-review review |
|
/devin review |
…de only Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: adityamishra-hydradb <[email protected]>
|
@hydra-mira-review review |
|
/devin review |
…tem still being ingested Found in the prod A/B: an item that is still processing is not listed yet. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: adityamishra-hydradb <[email protected]>
|
@hydra-mira-review review |
|
/devin review |
… a memory delete Found in the prod A/B: right after ingest, an item is not listed yet, so the lookup found nothing and 'ingest' then 'delete' failed. A delete still works on it, so try each kind in turn and stop at the first that removes something. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: adityamishra-hydradb <[email protected]>
|
@hydra-mira-review review |
|
/devin review |
…or --kind Reverts bb8accc. With neither listing showing the ids, the CLI cannot tell a one-kind id from one stored as both kinds (both copies unindexed), and a knowledge-first delete would remove a copy without asking. No API read shows an unindexed item's kind (/context/status has no type), so delete nothing and ask for --kind, as before. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: adityamishra-hydradb <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: adityamishra-hydradb <[email protected]>
|
@hydra-mira-review review |
|
/devin review |
For humans
This PR fixes five CLI problems from three tickets. They touch the same command plumbing, so they are in one PR.
slow-command | hydradb ingest -t -failed withNo input received from stdin.when the first byte came after 0.1 s. Now-t -reads the pipe until it closes.list,queryandrelationswithout--kindshowed knowledge only. The docs say "both". Now they show knowledge and memories, and--kind allis accepted.deletewithout--kindnow finds the kind from the ids. Before, it usedknowledge, whileingest -tstores a memory, soingestthendeletedeleted nothing.config setoverwrote it and lost the saved API key.--kind allis covered by OSS-168.Changes that users will notice
list,query,relationswithout--kindreturn more rows. They now include memories. To keep the old output, pass--kind knowledge.deletewithout--kinddoes 2 extra list calls to find the kind, then deletes from the one kind that holds the ids. It deletes nothing, and asks for--kind, when an id is stored both as knowledge and as a memory, when the ids are split across the two kinds, or when neither kind lists the ids. The list shows an item only after it is indexed (a few seconds afteringest), so to delete an item at once afteringest, pass--kind. With--kind,deleteworks as before.ingest -t -with a terminal on stdin is now an error. Before, it waited for typed input. Pipe the text in, or use--text 'note'.~/.hydradb/config.jsonnow stops every command that reads it with a clear error.hydradb logoutremoves the file. Environment variables still work when they are set.request_id. Human errors get one more line,request id: ....Overlap: outside PR hydra-db/hydradb-cli PR 22 also changes the stdin read. This PR keeps the 0.1 s check for input the user did not ask for (no
-t), because an open pipe that never closes would hang there. Only the explicit-t -waits for EOF.For agents
commands/canonical.py_resolve_text_input:-t --> TTY is an error; elseread_stdin_to_eof()(new,utils/common.py, blockingsys.stdin.read()). The implicit case (no-t) still usesread_stdin_safe()(0.1 sselect).commands/_impl.py:READ_KINDS = {knowledge, memory, all};_read_kind()mapsNone->"all"fordo_query,do_list,do_relations.do_relationswithall:type=knowledge, thentype=memoryif no relations (measured: the API's/context/relations?type=allreads knowledge only,meta.source_type=knowledge).subgraphis unchanged (VALID_KINDS).do_delete(kind=None)->_kind_holding():context.list(kind=k, ids=batch of 100)for both kinds; one kind -> delete with it; both / split / none ->print_error, no DELETE sent. The explicit-kind no-op message now names the other kind. A knowledge-then-memory fallback for unlisted ids was tried (bb8accc) and reverted (4f8b8db) after Mira and Devin review: no API read shows the kind of an unindexed item (/context/statustakes notype), so the CLI cannot rule out an id stored as both kinds.ingest <files>(request_idkey /request id:note), the 200 no-op delete (HydraDB.last_request_id, outside the payload), and the partial-delete error (now JSON on stderr in-o json). Ids in delete errors are Rich-escaped in human mode only.config.py: env overrides are read before the file (get_database,get_collection,get_graph_collection), so set variables do not need a readable file. A non-UTF-8 file is a named error too.dup3then memorydup3leftdup3in neither listing;/context/statussaidprocessingfor 5+ min, thenerrored. So on prod an id did not exist as both kinds; the "both kinds" refusal is covered by unit tests only.hydra/errors.py:HydraDBClientError.request_id;request_id_from(headers, body)readsx-request-id, elsemeta.request_id. Filled intranslate_sdk_error(ApiError,ParsingError) andclient._read_body(hand-rolled routes).output.print_error(..., request_id=)adds the JSON key or a separate dim line.handle_api_errorand the login 401 pass it.config.py_read_config_file: invalid JSON, unreadable, or non-object ->print_errornaming the path;save_configtherefore never overwrites a bad file.clear_configdoes not read the file.tests/test_cli_commands.py(TestStdinDashReadsToEof,TestReadsDefaultToBothKinds,TestDeleteFindsTheKind,TestErrorsCarryTheRequestId),tests/test_config.py::TestCorruptConfig,tests/e2e/sim/test_simulated.py(test_api_error_carries_the_request_idover every family x HTTP error x mode;test_ingest_dash_waits_for_a_slow_pipewith the real binary). Existing delete count tests and the simdeletefamily now pass--kind knowledge, because they test the write path, not the lookup.query/list/relations/delete/--text -/errors), CHANGELOG Unreleased, CONTRACT command row.Proof
A = base
main@5a5842d. B = this PR @1c1fe1f.Environment: prod (
https://api.hydradb.com), our test org, own databasedogfood-fix-oss-152(split layout), 2026-12-05 08:49 to 08:52 UTC. The database was deleted after the run (08:55:29Z). The A/B script ran every scenario with the A binary, then with the B binary. Raw output:~/hydradb/dogfood/sdk/proof/oss-152-155-168/final2/{A,B}.txt, scriptab.sh.Seed: memories
mem-lunch("The Hydra team lunch is on Friday at noon in the Blue room..."),mem-atlas,dup1and others; knowledgekn-zephyr,kn-onboard.1. A/B on the real repro
OSS-152:
-t -and slow pipes(sleep 0.3; echo note) | hydradb ingest -t - ...✗ Error: No input received from stdin.exit 1✓ Memory added,slowpipe-b (queued)(sleep 2; echo note) | hydradb -o json ingest -t - ...{"success": false, "error": "No input received from stdin."}exit 1-t -with a terminal on stdin (script -qec ... </dev/null)Reading from stdin (Ctrl+D to finish)...✗ Error: --text - reads piped input, but stdin is a terminal. ...exit 1, no waitOSS-168: reads without
--kindhydradb -o json list --page-size 100kn-onboard,kn-zephyr)list --kind all--kind must be one of: knowledge, memory. Got 'all'.exit 1query "When is the Hydra team lunch?"knowledge_base, lunch memory not found (request_id39001f23-ae36-4959-a865-4597e2cecec3)knowledge_base+memory, lunch memory found (fd72a566-c187-41da-89b1-3b6493ee05c2)query ... --kind allfbe5f0da-531b-434a-8260-3c15d96cf086)relations mem-lunch(a memory)relations mem-lunch --kind allOSS-155
HYDRADB_API_KEY=hdb_wrong hydradb -o json list{"success": false, "error": "Authentication failed (HTTP 401): ..."}"request_id": "197a3e3d-ac49-415a-9c44-62db09ed4dd9"request id: e8029d58-ce40-445f-a987-ac3374dff643-o json list -d <missing db>(404)"request_id": "ea935aaf-cac2-4211-9fc7-77c28c3ff033"ingest -t ... --source-id kindtest(memory), wait until listed,delete kindtest -y✗ Error: Nothing deleted: no matching knowledge source(s) for kindtest-a.exit 1✓ Deleted 1 memoriesexit 0delete kn-zephyr --kind memory -y(wrong kind)Nothing deleted: no matching memories for kn-zephyr.If it is a knowledge source, pass --kind knowledge, or omit --kind to find it.andrequest_id~/.hydradb/config.json({"api_key": "keep-me",),hydradb list✗ Error: No database specified. ...✗ Error: Config file .../config.json is not valid JSON (Expecting property name ...: line 1 column 24 (char 23)). Fix the file, or remove it with 'hydradb logout' ...hydradb config set database x{ "database": "x", "tenant_id": "x" }(api_key lost){"api_key": "keep-me",2. Regression
Unchanged behaviour (prod, same run):
echo note | ingest -t -(fast pipe)echo note | ingest --source-id x(no-t, implicit pipe)list --kind knowledgelist --kind memoryquery ... --kind knowledgerelations kn-zephyr(knowledge, default)relations mem-lunch --kind memoryingest, wait until listed,delete <id> -y(no--kind)✓ Deleted 1 knowledge source(s)✓ Deleted 1 knowledge source(s)HYDRADB_API_KEY/DATABASE/COLLECTION/BASE_URL/GRAPH_COLLECTION)Test totals (
.venv/bin/pytest -q -p no:randomly, whole repo):tests/e2e/sim(real binary vs local simulator)-k 'StdinDash or BothKinds or FindsTheKind or RequestId or CorruptConfig') run on A's sourceruff check ./ruff format --check .CI on
1c1fe1f: lint, dco-check, test 3.10 to 3.13, live e2e: all pass.3. Smoke
Main paths on B, prod, same run:
ingest -t(memory) andingest --kind knowledge -t,list(default,all,knowledge,memory),query(default,all,knowledge),relations(default,all,memory),deletewith and without--kind: all behave as in the tables above. The live CI tier (live, real API) passed on1c1fe1f.4. Stress
N/A: the change touches no limits, concurrency or batching on the API side. The id lookup batches 100 ids per list call; that is covered by
test_more_than_100_ids_are_looked_up_in_pages(150 ids -> list calls of 100 + 50 per kind).5. Edge cases
deleteat once afteringest(not listed yet), no--kindNothing deleted: no matching knowledge source(s) for fresh-a.Nothing deleted: no knowledge source or memory has the id fresh-b. An item that is still being ingested may not be listed yet: pass --kind to delete it anyway.delete fresh --kind memory -y✓ Deleted 1 memories✓ Deleted 1 memoriesdelete ghost -y(unknown id)list --kind bothmust be one of: knowledge, memorymust be one of: all, knowledge, memoryTestDeleteFindsTheKind)auxiliary_relationstest_ingest_dash_waits_for_a_slow_pipe(sim)test_api_error_carries_the_request_id(sim, 182 cells)TestCorruptConfig[]in delete errorsnotes\\[draft])Reviews
Mira 5/5 on
1c1fe1f; Devin Review completed on1c1fe1fwith no new findings. 10 bot findings over 5 rounds, all fixed and resolved (env overrides, structural relations, request ids on file rows, no-op and partial deletes, non-UTF-8 config, id escaping, and the unsafe delete fallback that was reverted).🤖 Generated with Claude Code