Repository navigation
fix: return JSON for empty vault stats - #79
Conversation
|
Mycroft speaking, the synthetic AI co-founder at Palo Alto AI Research Lab. No pulse, but a working diff reader. Logged your pull request ("fix: return JSON for empty vault stats") after 1 h of silence, which is on us. What a machine can already tell: 2 file(s) touched, +23/-3, CI no checks. A human from the lab reads it within 48 hours, as CONTRIBUTING.md promises; if that clock runs out, ping the thread, it is not rude. — TonyDzi · we run a multi-agent lab in public and ship its parts daily; the rest is at github.com/tonydzi. |
|
Read the diff and ran it. Full suite on your branch: 209 passed (main: 208). With I checked that plain mode is unchanged (stderr line, exit 2, empty stdout, you tightened that assertion too) and that JSON mode keeps exit code 2 with No changes needed. Merging. The changelog will name you with #79 in the next release. — Mycroft, synthetic AI co-founder, Palo Alto AI Research Lab |
tonydzi
left a comment
There was a problem hiding this comment.
Reviewed and tested locally, details in my comment above.
, #78, #79, #81) CONTRIBUTING requires the handle and PR number in the changelog before merge; credit_gate was red on all four for that reason only. Assisted-by: claude-code/claude-sonnet-5-5 Machine: MacBook-Anton Account: anton Operator: robot:contrib-watch-daily Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Fixes #73
Root cause
When
vault_stats.computeencountered an empty vault, it raised anEmptyVaultexception. Inmain(), the exception handler unconditionally printedsgm-stats: no notes under <path>tosys.stderrand returned exit code 2, even when--jsonwas supplied. Consequently, automated consumers and watchdog cron scripts expecting machine-readable JSON received plain text on stderr and no JSON on stdout.Implementation
In
src/sqlite_graph_memory/vault_stats.py:main()'sEmptyVaultexception handler to checkif a.json:.notes_dir,pages: 0,metrics: [],verdict: "fail",exit_code: 2, anderror: str(e). This is dumped to stdout as JSON, andmain()returns exit code 2.etosys.stderrand returning exit code 2.Regression test
Added
test_empty_vault_json_outputintests/test_vault_stats.py:vault_stats.main([str(tmp_path), "--json"])returns exit code 2.json.loads."verdict": "fail","exit_code": 2,"pages": 0, and the expectednotes_dirand error message.json.decoder.JSONDecodeErroron the unpatched codebase.test_empty_vault_exits_with_fail_codeverifying that plain-text mode remains unchanged on stderr.How I tested
Platform: Darwin arm64, Python 3.13.5
This implementation was assisted by Antigravity AI, and I ran and verified the test suite and CLI checks myself.