Skip to content

Backup check reads each archive once, not twice - #13

Merged
alexeybe1kin merged 2 commits into
mainfrom
glm/systemgate-archive-headers-only
Oct 31, 2026
Merged

alexeybe1kin merged 2 commits into
mainfrom
glm/systemgate-archive-headers-only

Conversation

@alexeybe1kin

Copy link
Copy Markdown
Collaborator

From optimization-systemgate-1 OPT-1.

GET /backups hashed every snapshot file against the manifest. Then _archive read every tar member's payload to the end, which doubled the disk reads. On a server with large Ollama or Qdrant archives, that is gigabytes per request.

The second read caught nothing the first did not:

  • The hash already proves the bytes match the manifest.
  • Walking to the next tar header raises unexpected end of data for an archive cut inside a member's data.

Now only the required SQLite store's first 16 bytes are read, for its magic check. Every other member is checked by its header.

Tests:

  • test_a_truncated_archive_is_never_a_recovery_point passes on both the old code and the new.
  • test_only_the_required_store_payload_is_opened checks that only pi.db and toolgate.db are opened.
  • test_a_required_store_that_is_not_sqlite_is_never_a_recovery_point was added by Claude: no test failed when the magic check was dropped.

Mutants, both caught:

  • restoring the full read;
  • dropping the magic check.

The full suite, ruff and the file-size check pass. GLM wrote the change; Claude reviewed it and added the magic test.

🤖 Generated with Claude Code

alexeybe1kin and others added 2 commits October 31, 2026 11:54
GET /backups hashed every snapshot file in full and then read every
archive member's payload to the end, doubling disk reads of large model
archives (Ollama, Qdrant) on each request. The hash already proves the
bytes match the manifest, and the tar header walk rejects the same
truncated archives, so members are now checked by their headers plus the
first 16 bytes of each required SQLite store.
No test failed when the magic check was dropped, before or after the read was
narrowed to that one member. Also reflow the docs paragraph.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alexeybe1kin
alexeybe1kin merged commit af7ea50 into main Oct 31, 2026
3 checks passed
@alexeybe1kin
alexeybe1kin deleted the glm/systemgate-archive-headers-only branch October 31, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant