8.0 KiB
RR-17: SQLite archive database member validation
Baseline2fb10f7b, isolated codex/recovery-archive-validation. The old name-only tar listing accepted symlinks/hardlinks/FIFO/device entries, empty or unrelated bytes named jobtracker.db, and database paths outside the archive root. Ten negative subtests freshly reproduced successful verification and continuation to the mocked next deployment gate.
The existing deployment verifier now calls a small Python standard-library streaming tar reader. Python3 is already required by the mandatory ingress validator. It checks each matching database basename for a safe relative path, regular-file type and the16-byte SQLite signature; it reads through the archive without extracting members. Root, dot-prefixed and nested supported database names remain accepted. Real SQLite test fixtures are created with stdlib sqlite3. No package, database/schema, production configuration or persistent data is changed by these tests.
- Final29/29 backup methods PASSED,0skips; includes earlier26 and three new methods/ten negative subtests. Bash syntax/whitespace PASSED. Existing dump/parser, upload, retention and permission checks remain. Real local gzip and Python tar/SQLite fixture creation were exercised; no Docker, actual backup, recovery or deployment.
- Initial red fixture had14 Windows cleanup errors because a context-managed sqlite connection had not been closed. After explicitly closing it, corrected red had10 failures and0errors; these are the valid application defect reproductions. Original draft errors are retained and are not product defects.
- First whole-suite green exposed three inherited permission-fixture failures: those tests mocked the old Docker validator over arbitrary bytes. Recovery permission fixtures now use a genuine gzip/tar with a format header and the real Python validator, preserving byte-equality/no-removal/next-gate assertions. Final29 rerun adds a Docker trap in member tests to prove no container validation occurs. Intermediate results overlap29.
- Exact native logs/gzip plus final source hashes: receipts. Original production baseline is bound. Red test fixture bytes were not frozen at execution; don't claim an immutable full red-test snapshot. Test helper changes after red and all intermediate failures are documented.
This checks format, not SQLite integrity or usefulness: a signature-only regular file satisfies this bounded predicate. It does not validate arbitrary other archive members, select an authoritative database among multiple compatible paths, prove WAL consistency, restore records, verify keys/tombstones/off-host encryption, qualify RPO/RTO or replace recovery rehearsal. MariaDB's dump path is unchanged. Actual Linux/container/host deployment remains NOT RUN. No release/security approval is granted.
Rollback restores verify_volume_backup and removes the helper/associated fixture changes on this isolated branch. No data rollback is required. Original release worktree and A3 application branch remain untouched by this package.
Host archive producer compatibility, 19 November 2026
The test at BackupDatabaseMemberTests.test_host_tar_producer_with_database_and_sidecar uses the deployment command's tar czf … -C data . arguments with a temporary synthetic volume. It creates a real SQLite database with one row and closes the connection. The host tar command archives it alongside an inert file named jobtracker.db-wal. The production Python validator accepts the archive, and a read-only comparison confirms the database member matches the source bytes. A second archive containing only the sidecar name is rejected.
| Windows producer | Verification | Result |
|---|---|---|
| Git for Windows GNU tar 1.35 | Full backup suite, Python 3.12.10 / SQLite 3.49.1 | 30 methods passed in 12.486 seconds |
| Windows bsdtar 3.8.9 / libarchive 3.8.9 | Focused producer method with the same positive and negative cases | Passed in 0.192 seconds |
The focused run overlaps the full suite. To repeat, put the desired tar directory first on PATH and run python scripts/test-deploy-backup.py BackupDatabaseMemberTests.test_host_tar_producer_with_database_and_sidecar -v. The test resolves the absolute producer path before invocation. Source baseline 5718d9521be0935e1c0364a775ed8ce7d0702f43. The validator and deployment script are unchanged.
Linux/Alpine producer qualification remains blocked on a pre-existing isolated Linux environment. WSL listed only a stopped Docker Desktop distribution. This fixture's sidecar exercises filename classification only. Live WAL consistency, restore, deployment, permissions, encryption and recovery-set completeness remain open.
Committed WAL data, 20 November 2026
An open SQLite writer committed row 1, checkpointed, and committed row 2 with automatic checkpoints disabled. The source contained both rows before the backup started. A synthetic padding file and pipe backpressure let the test force a normal checkpoint after GNU tar read the main file and before it read the WAL. The reproducer uses a temporary volume, a real tar czf producer and the deployment's existing archive verifier.
| Legacy archive | Tar | Format verifier | Restored integrity check | Restored row IDs |
|---|---|---|---|---|
| Open writer, stable WAL | 0 | 0 | ok | 1, 2 |
| Open writer, checkpoint between member reads | 0 | 0 | ok | 1 |
The new producer opens each matching regular SQLite database read-only, holds a read transaction while copying with SQLite's backup API, and writes a self-contained database with rollback journaling enabled. GNU tar archives these snapshots at their original relative paths and omits their obsolete WAL, SHM and rollback journals. Other files retain the original tar path and type handling. The isolated tests recovered both committed rows from the database member alone while a third row remained uncommitted. They checked nested database paths containing brackets/spaces, ordinary adjacent files, unrelated sidecars, and rejection of empty or corrupt input before the next deployment gate.
The SQLite branch now requires the project's existing python:3.12.10-slim-bookworm base image on the Docker host, including Python's sqlite3 module, GNU tar and gzip. The default Docker pull policy can require image acquisition if it is absent. The helper runs with container networking disabled and the source volume mounted read-only. The disposable container filesystem needs room for the separate uncompressed snapshots. Snapshotting holds a database read transaction during copying, which can delay WAL truncation or a rollback-journal writer. Restore consumers continue to receive jobtracker-sqlite-<stamp>.tar.gz and the original database member names.
Local evidence. Windows x64, Python 3.12.10, SQLite 3.49.1, Git for Windows GNU tar 1.35. python -Werror scripts/test-deploy-backup.py -v passed 35 methods in 33.602 seconds. python -Werror scripts/test-deploy-rollback.py -v passed six methods in 0.867 seconds. Git Bash syntax validation passed. The two focused snapshot methods overlap the 35. The fixture runs the actual deployment backup and verification functions with the Docker invocation mapped to the same shell/Python helper on the host. No image was pulled or executed. An early harness run selected Windows bsdtar, which rejected GNU's anchored exclusions. The producer now resolves the executable from PATH and the Windows harness selects Git's GNU tar.
Remaining qualification. Exercise the image, GNU tar metadata and Linux read-only WAL locking on a disposable target host. Include an idle WAL database with no sidecars, since SQLite can need directory writes to establish them. A read-only open or backup error aborts the gate. Custom connection strings pointing outside the volume, independently changing databases/files, Data Protection keys, tombstones, remote encryption and retrieval, full restore, RPO/RTO and production approval still require their own evidence. Reverting the isolated producer change restores the previous raw-volume behavior and its demonstrated race.