Skip to content

fix: six more findings from the architecture review - #539

Merged
chris-dare-dev merged 6 commits into
mainfrom
claude/findings-batch3
Nov 15, 2026
Merged

chris-dare-dev merged 6 commits into
mainfrom
claude/findings-batch3

Conversation

@chris-dare-dev

Copy link
Copy Markdown
Owner

Six audit findings, one commit each.

Commit Issue Change
8c8480b #326 Removes the 180-day LAST_VERIFIED age assertion, which would turn the default suite red on 2026-11-19 with no code change. The ISO-format check stays. record_spend still has no caller (the Voyage call site in server/query_encoder.py is a commented-out TODO), so arxmcp_api_spend_usd_total reads 0; the metric is unchanged.
b8f982a #302 The restore drill can read a real citation graph. Two bugs: Kùzu 0.11 stores the graph as a single file at index/kuzu, but the locator took only a directory, so a real graph was skipped as absent; past that, the count queried Paper, and the table is papers.
2afb88d #299 Every notebooks.db migration step goes through one _migrate helper: BEGIN, the statements, the user_version bump, COMMIT, and ROLLBACK on any error. v2→v3 and v3→v4 were bare autocommit ALTERs. Most of the diff is re-indentation; the store file is 4 lines shorter.
59ccc2a #353 get_paper selects section_path, chunker_version and embedder_version at the scanner instead of all 26 columns. The reply is unchanged.
3bd720c #327 A batched get_chunk passes the assembled {chunks: [...]} through cap_result_list. Trailing entries are dropped until it fits, and body_truncated is set. It calls cap_result_list without editing it, so it does not conflict with #538.
8885093 #336 The BM25 auto-build reads through project_columns with expected_rows, and a short read raises instead of writing an index that misses chunks. The server/resources.py half of the finding was already projected.

Closes #326
Closes #302
Closes #299
Closes #353
Closes #327
Closes #336

Verification

Run on Ubuntu at 8885093, on top of main at d9ddaa8.

Notes

  • Now inaccurate, not changed here: the get_chunk tool description (server/tools.py:337) says a batch returns "one entry per id", but when the cap fires trailing entries are now dropped. Changing the description moves EXPECTED_TOOL_SCHEMA_SHA256, so it waits for the next TOOL_SCHEMA_VERSION re-pin.
  • Follow-up: make bootstrap creates var/arxmcp/index/kuzu as a directory. Kùzu 0.11.3 refuses a directory there ("Database path cannot be a directory"), so graph ingest fails on a freshly bootstrapped box, and a backup of that empty directory still fails the drill.
  • Follow-up: the WAL-checkpoint part of The disaster-recovery drill can never validate the citation graph — it queries a node label that does not exist #302 is not addressed here.
  • One PR rather than six: the commits are kept one per concern.

🤖 Generated with Claude Code

test_last_verified_within_six_months failed once LAST_VERIFIED was
more than 180 days old, so the default suite would turn red on
2026-11-19 with no code change. A test that fails because the
calendar moved tests nothing, and the only way to make it pass is to
bump the date without checking any pricing page.

The age assertion is removed; the ISO-format check stays. The comment
on LAST_VERIFIED no longer claims a test enforces its age.

record_spend still has no caller: the Voyage call site in
server/query_encoder.py is a commented-out TODO, so
arxmcp_api_spend_usd_total reads 0. The metric is left as it is.

Closes #326
The drill's Kùzu check could not pass on a restored graph, for two
reasons:

- Kùzu 0.11 stores the database as a single file at index/kuzu, but
  the locator accepted only a directory there. A real graph was
  reported as absent and the check was skipped.
- Past the locator, the count queried MATCH (p:Paper). The node table
  is papers, so Kùzu raised "Table Paper does not exist" and the drill
  reported the graph as unreadable and exited 1.

The locator now takes index/kuzu whether it is a file or a directory,
and the count reads papers. The new test builds a real graph with the
ingest schema under a restic-style path prefix and checks the count;
before this only the absent case was tested.

The issue's claim about WAL checkpoints for the other SQLite stores is
left for a separate change.

Closes #302
The connection is autocommit, and the v2->v3 and v3->v4 steps ran
their ALTERs and the user_version bump as separate statements. A crash
between them left a column in place while user_version still named the
old schema, so the next open re-ran the step, hit "duplicate column
name", and the server could not start. v3->v4 has three ALTERs, so its
window was the widest. Only v4->v5 and v5->v6 opened a transaction.

Every step now goes through one helper, _migrate, which runs the
statements and the version bump between BEGIN and COMMIT and rolls back
on any error, including KeyboardInterrupt. The v4->v5 comment that
explained this in one place moves to the helper.

The new test fails the second v3->v4 ALTER, then checks that the file
is still at v3 with none of that step's columns, and that the next open
migrates to the current version and keeps a notebook written in
between.

Closes #299
get_paper read up to 10,000 chunk rows with every column, including
both 1024-float vector columns (~14 KB per row), and then used only
section_path, chunker_version, embedder_version and the row count.
That ran on every call, on the event loop.

The scan now selects those three columns at the scanner, the same
pattern as the lemma fallback and the notebook recount. The reply is
unchanged.

The new test wraps a real LanceDB table so it can see the columns each
scan returned. It checks the reply's counts and versions and that the
scan carried exactly the three columns; before the fix it returned all
26.

Closes #353
A batched get_chunk gave each element result_byte_cap // n, but
enforce_byte_cap trims only the element's primary body. Referenced
counterparts (up to 8 bodies of 4000 characters each) were never cut,
so 20 elements with include_referenced=True came to about 700 KB of
structured content, nearly three times the 256 KB cap, with no
body_truncated flag. /mcp is exempt from the response-size middleware,
so nothing downstream caught it.

The assembled {chunks: [...]} is now passed through cap_result_list,
which drops trailing entries until the reply fits and sets
body_truncated. The per-element share still trims oversized primary
bodies first, so a batch of large primaries keeps every entry, as
before.

The new test gives each of 20 elements a full set of counterparts. It
checks the reply fits the cap, is flagged, and keeps a request-order
prefix of the ids. Before the fix the reply was 706,555 bytes.

Closes #327
build_bm25_index read the pinned chunks table with tbl.to_arrow(),
which in lancedb 0.30 materializes every column, both 1024-float
vector columns included, and then used chunk_id, body_tokens and
paper_id. On a cold start with no index this ran on the startup path.

The scan now goes through project_columns with the table's row count
as expected_rows. The table is checked out at corpus_version, so a
short read means the read failed; the build raises instead of writing
an index that silently misses chunks.

The other half of the finding, the startup chunk_id cross-check in
server/resources.py, already projects through project_column.

Two new tests wrap the real table. One checks that every scan returned
exactly the three columns and the index covers every chunk (before the
fix the scan returned all 26). The other makes the scan come back one
row short and checks that nothing is written.

Closes #336
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment