Fix corpus inventory indexing and provenance
CI / tests-and-images (pull_request) Successful in 2m25s
Runner smoke test / runner-smoke (pull_request) Successful in 2s

This commit is contained in:
agent committed 2026-10-18 19:22:00 +03:00
1 parent 4b2e5578cd
commit 4d106903e1
5 files changed
+319 -36

No files matched your search

+66 -9
View File
@@ -17,8 +17,10 @@ python3 infra/deploy/verify_corpus.py \
--output-dir "$artifact_dir"
```
The tool writes `result.json` and `inventory.sqlite3` into that directory. Keep
the directory private: the inventory contains source paths and checksums. Exit
The tool writes `result.json`, `inventory.sqlite3`, and a persistent lock file
into that directory. Keep the directory private: the inventory contains source
paths and checksums. A second run against the same artifact directory is
rejected while a scan is active. Exit
status `0` means the scan and structural checks completed without errors; `1`
means findings were recorded or the run is incomplete; `2` means the arguments
or artifact path were invalid. Read `result.json` to distinguish those states.
@@ -31,19 +33,65 @@ reports added, changed, and removed paths relative to entries already stored
in the inventory. After resuming an interrupted first pass, those counters are
relative to the partial saved inventory; the full rehash and final checks still
cover every path. A successful result therefore describes the latest complete
pass. Run against a quiescent corpus; do not
normalize, fetch, or copy files into either source tree during the scan. Do not
point `--output-dir` inside either
source tree or through a symlink. The verifier rejects such paths before
pass. Run against a quiescent corpus; do not normalize, fetch, or copy files
into either source tree during the scan. Do not point `--output-dir` inside
either source tree or through a symlink. The verifier rejects such paths before
creating or changing them; it also flags symlinks, reparse points, hard links,
unsupported file types, and files that change while being read.
The inventory database schema is versioned. Resume requires the same root
metadata and verifier SHA-256 recorded in `result.json`; start a new artifact
directory after changing the verifier. `entries` counts files plus directories;
`files` and `directories` are separate counts. Document-prefix checks use
indexed path ranges, and stale-path reporting streams rows from SQLite.
The audit checks SQLite integrity, manifest/document directory agreement,
normalized schema and normalizer versions, source inventory checksums,
fragment identities and text hashes, required output files, and text assembled
from fragments. It does not establish the legal authority, completeness, or
semantic correctness of MinJust content.
## Compare source and staging before transfer
Run a complete inventory of the approved normalized source and the copied
staging tree into separate private artifact directories, using
`--normalized-root` for each. Require `status: complete` and
`verification_status: passed` in both results. Then compare every relative
path, size, and SHA-256 from the two `inventory.sqlite3` files. This streaming
comparison uses constant memory and reports only a mismatch count and the first
few differing paths:
```bash
python3 - "$source_artifacts/inventory.sqlite3" "$staging_artifacts/inventory.sqlite3" <<'PY'
import itertools
import sqlite3
import sys
def rows(path):
db = sqlite3.connect(f"file:{path}?mode=ro&immutable=1", uri=True)
yield from db.execute(
"SELECT relative_path,size,sha256 FROM files "
"WHERE root_id='normalized' AND status='hashed' ORDER BY relative_path"
)
db.close()
differences = 0
for source, staging in itertools.zip_longest(rows(sys.argv[1]), rows(sys.argv[2])):
if source != staging:
differences += 1
if differences <= 20:
print("mismatch:", source, staging)
print("mismatch_rows:", differences)
sys.exit(1 if differences else 0)
PY
```
Use absolute artifact database paths in the command. A zero exit status confirms
that both inventories contain the same ordered path/size/SHA-256 rows. Keep the
source and staging trees quiescent during their scans and comparison. This is
an equality check only; the owner still reviews the code `6` disposition and
approves the transfer destination.
## Current data disposition
As measured on 2026-10-18, both local manifests contain 209,958 documents and
@@ -65,9 +113,18 @@ From the VPS, a metadata-only HTTPS check to `CheckAvailable` failed at the
HTTP/2 transport layer (`curl` exit 92, `INTERNAL_ERROR`, HTTP status `000`,
TLS verification `0`). An HTTP/1.1 retry was not completed.
The full local file inventory and normalized cross-check are still in progress
until a `result.json` reports `status: complete` or `status: failed` and
`scan_status: complete`. Do not treat progress output as a completed audit.
The first full pass (run `b4a4556e30cc464d90bc8d75ef1673e9`) stopped before
validation with `Python int too large to convert to SQLite INTEGER` after
2,120,420 raw entries and 397,856 normalized entries. This was an inventory
metadata storage failure, not a corpus finding. The verifier now stores file
identity values as text and records its own SHA-256. A complete rehash with the
updated verifier is required; do not treat the failed pass or progress output
as a completed audit.
A fresh full rehash is now running in `/tmp/akyldash-corpus-audit-final.gtsD87vc`,
run `f4dd5e53020f442bbbecee2d0e4986a6`, verifier SHA-256
`83dac230099fc91972cd14e86e9f8ec72d13bca08f53d402f13a169e096d98f5`. Check
its private `result.json` for final counters, findings, and manifest comparison.
## Production transfer and indexing gates
+15 -8
View File
@@ -133,12 +133,18 @@ protected file metadata remain unverified.
is 31,571,968 bytes with SHA-256
`1679c20e6d0f3e5a9b50737c006c4417a28ebcaf7467d194d3bf8243538f83bf`; all
entries are `success`, schema `1`, normalizer `1.0.0`.
- A streaming full-file inventory and cross-check is running read-only with
artifacts only in `/tmp/akyldash-corpus-audit.Mjr6aa`. Latest progress was
run `b4a4556e30cc464d90bc8d75ef1673e9`; live counters are in its private
`result.json`, updated every 1,000 entries. The normalized tree has not yet
started. Progress is not a completed audit; record the final result and full
manifest comparison when the run finishes.
- The read-only full-file inventory in `/tmp/akyldash-corpus-audit.Mjr6aa`
stopped before validation in run `b4a4556e30cc464d90bc8d75ef1673e9` with
`Python int too large to convert to SQLite INTEGER`. At stop it had processed
2,120,420 raw entries (1,081,428 files, 1,038,992 directories) and 397,856
normalized entries (246,321 files, 151,535 directories). This is a verifier
metadata storage failure, not a corpus finding. A full rehash with the
corrected, versioned verifier is required before readiness can be stated.
- A fresh full rehash is running in `/tmp/akyldash-corpus-audit-final.gtsD87vc`,
run `f4dd5e53020f442bbbecee2d0e4986a6`, with verifier SHA-256
`83dac230099fc91972cd14e86e9f8ec72d13bca08f53d402f13a169e096d98f5`.
`result.json` currently reports `scan_status: running`; its live counters
must be recorded after completion. Sources remain read-only.
- Through the repository client, bounded MinJust OpenData requests for
`GetDocumentListByQuery`, `GetDocument(6)`, control `GetDocument(1096)`, and
`CheckAvailable` each returned HTTP `404`. The list API returned no code list;
@@ -194,6 +200,7 @@ protected file metadata remain unverified.
Adds a read-only, resumable full-file corpus inventory and normalized-data
cross-check, synthetic regression tests, and an operator handoff runbook. CI's
existing `infra/deploy` unittest discovery includes the new tests. No workflow,
runner, VPS, production data, or Docker settings are changed. The real corpus
scan is still in progress and the source API's code `6` outcome remains
runner, VPS, production data, or Docker settings are changed. The first real
corpus scan stopped on an integer-storage bug; full validation with the
corrected verifier is still required. The source API's code `6` outcome remains
unconfirmed.
+3 -2
View File
@@ -71,8 +71,9 @@ Application deployment remains owner-run. The repository-scoped `act_runner`
separate loop-backed filesystem. CI run 75 and smoke run 76 succeeded on main
head `0e276ae6`. Runner job containers have neither Docker socket nor production
secrets. CI has no image publishing or production deployment step. The
installed sudo helpers support fixed verification, read-only Compose
`config`/`status`, and guarded rollback. They do not start or stop services.
repository defines sudo helpers for fixed verification, read-only Compose
`config`/`status`, and guarded rollback, but none is installed on the VPS. They
do not start or stop services.
## CI