Repository navigation
data: R02 - operator-run rebuild of selected closed legacy live days (ADR-0074 Amendment 2) - #531
Conversation
… days (ADR-0074 A2) (#520) Plan (read-only, with a digest), execute (one day at a time: retire with R01, import the archive day as revision 1 of dt=<day>/seg=000000.000 through S13/S14, verify) and verify, restore, as tools/rebuild_bybit_legacy_days.py over application/bybit_legacy_day_rebuild.py. - Importer variant: the invalid live revision of the exact key dt=<day> does not occupy the day; any other partition of the day still refuses; the key is fixed; the lock is the day's. - Refusals: open day (< 24 h), live slice, checkpoint binding, open gap, incumbent not valid (or invalid but not retired by this operation for the same archive), failed strict parsing, and conservation (every incumbent record exists in the archive file of its own day with equal fields, and that day is readable afterwards). Nothing changes for a refused day. - The digest binds what the operation depends on, not its progress: a crash between steps is recovered by running the same plan; anything changed makes it stale. - Runbook section 6. Real-PostgreSQL gate and CI job; 34 mutants, 0 survivors; the rebuild of a pilot-sized synthetic day (1,568,861 rows) measured. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
CI fix ( |
… plan digest (#520) tests/test_canonical_v1.py inventories every canonical_bytes call site; the plan digest of the R02 rebuild (sorted-compact-ascii-v1, allow_nan False) is declared there like the other application codecs. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…in the plan, refuse a duplicated trade id (#520 review) - The live publisher before the slices (#510) wrote partition-manifest-<HHMMSS>.json and coverage-manifest-<HHMMSS>.json in the dataset root, not beside the Parquet. The rebuild now looks beside the artifact and then in the root, and the catalog's manifest hash chooses the location, so a root file that a later day overwrote in the same second is never taken for this revision's. - The plan loads the incumbent's manifests with the S13 loader and compares the coverage hashes and ids with those its quality reports certified; the coverage and assertion ids are part of the plan's identity. A manifest that does not load or is not the certified one refuses the day in the plan, not at the retire. - A trade id that the incumbent holds twice with different content refuses the day instead of keeping the last row. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Review findings validated against the code and the history of the live publisher; fixed in B1 (CI red on B2 (valid): the legacy manifests are in the dataset root. Confirmed in M1 (valid): coverage manifest checked in the plan. The plan now loads the incumbent's manifests with the S13 loader, compares the coverage hashes and ids with those its quality reports certified ( M2 (valid): duplicated trade id. The incumbent's rows were put in a dict keyed by Section 3 (what to expect on the server) - both points are already covered and I added nothing for them: the neighbouring archive files are required by the conservation check (a missing one is a refusal naming the file), and a neighbour whose Tests. Unit: manifest location by the catalog hash (beside, root, overwritten, both), duplicate trade ids (different and identical), the coverage and assertion ids in the digest. PostgreSQL gate: a tampered coverage manifest (not the certified one), an unreadable one, reports certifying two sets, and a day in the root layout planned with the located manifests. 7 mutants on the new code, one at a time: 6 caught at once, 1 survived (the ids not in the digest) and drove its test; all caught. Full suite 164/165 (the known Windows Not proved. The retire with the manifests in the root layout is not exercised on PostgreSQL: simulating that layout by renaming files leaves the partition manifest naming the old artifact, and the lifecycle refuses it. The root layout is proved up to the plan (the located files and the checks); the retire only joins the same relative paths. The real server files remain the operator's check, and a plan that cannot find or verify them refuses the day and says why. 🤖 Generated with Claude Code |
|
Fallback di review per identità condivisa: GitHub ha rifiutato la review formale REQUEST_CHANGES perché autore e revisore usano lo stesso account. Questo commento registra il verdetto tecnico; non imposta lo stato formale di review. Revisione indipendente di PR #531: REQUEST CHANGES tecnico. Head verificato:
Verifiche positive, che non coprono questi casi:
Prove locali conservate in |
…the restore, bind the import to the approved archive hash (#520 review) - The records of the incumbent that belong to another day must stay served: a valid partition of that day must hold those very records, or that day must be in the same plan and not refused (a refused day contributes nothing; the refusal propagates). Decided in the plan, before the retire. The plan also binds the hash of every neighbouring archive file it read. - The restore takes the day's import lock and decides under it: it cannot slip in between the import's check and its publication, so the two cannot leave both partitions valid. - The rebuild import and the verification check the SHA-256 of the bytes they parse against the plan's: a file replaced after the plan is refused (SOURCE), a file replaced after the import fails the verification. `verify --plan` binds a standalone verification too. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
The three P1 of the review of P1-1, conservation of other days' records (valid).
P1-2, restore vs import (valid). P1-3, the digest and the imported bytes (valid). The importer variant now requires Checks. 12 mutants on the new code, one at a time: 11 caught; one survived (the held check counting a partition that is not Not claimed: nothing on the server or on real data; the retire in the legacy root layout is still proved only up to the plan (see the previous comment). 🤖 Generated with Claude Code |
|
Fallback per identità condivisa: GitHub ha rifiutato la review formale REQUEST_CHANGES perché autore e revisore usano lo stesso account. Questo è il verdetto tecnico della rivalidazione, non uno stato di review formale. Rivalidazione indipendente di PR #531: REQUEST CHANGES tecnico su un nuovo P2. I tre P1 della revisione precedente sono corretti. Head: [P2] Il progresso di un piano con giorni collegati modifica il digest e impedisce il recupero con lo stesso piano. In Riproduzione con PostgreSQL reale e gli stessi costruttori di fixture live della prima review:
Distinguere nel digest le prove vincolanti e immutabili dal progresso previsto dei target della stessa esecuzione, mantenendo i controlli sui cambiamenti esterni; aggiungere una regressione di crash/retry di un piano multi-giorno con una reale dipendenza di conservazione. Non basta il retry di un giorno isolato. Violati il recupero con lo stesso piano di A2.5 e il criterio 3 della #520. Chiusura dei finding precedenti (prove ripetute, non solo lettura dei nuovi test):
Verifiche: 68 test mirati passati, 1 skip (campione archivio esterno assente), 115 subtest; i quattro gate PostgreSQL 16 (R02, import archivio, R01, live slices) passati; Ruff, Markdown (124 file), diff check e preflight sulla base passati. CI run Prove: |
|
The P2 of the revalidation of Fix. Tests.
Full suite 164/165 (the known Windows 🤖 Generated with Claude Code |
…digest (#520 review) `outside_held` (whether a valid partition of another day holds the incumbent's records of that day) turns true when the plan itself rebuilds that day, so it was progress inside the digest and a crash before the second day's verification made the original plan STALE. It is left out of the digest; its consequence for the plan is in the refusals, which stay bound, so a change from outside still changes the digest. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Fallback per identità condivisa: GitHub ha rifiutato la review formale REQUEST_CHANGES perché autore e revisore usano lo stesso account. Questo commento registra il verdetto tecnico, non lo stato di review formale. Rivalidazione indipendente PR #531, head Il P2 della review precedente è corretto: ho ripetuto il medesimo fixture live A/B con cross-B e il crash prima della verifica di B. [P2] L'esclusione incondizionata di outside_held nasconde una dipendenza esterna persa dopo il ritiro. Riproduzione su PostgreSQL 16 temporaneo, con pubblicazioni live/S13/S14 e ritiro R01 reali:
La perdita di copertura di B avviene già con la seconda operazione: non attribuisco al retry di A una cancellazione o un nuovo P1 di perdita dei byte. Il difetto è accettare il piano obsoleto e certificare il suo completamento senza più la condizione di conservazione esterna sulla quale era stato approvato. Il controllo A2.4 sui cambiamenti di catalogo e la promessa del fix nelle righe 333-335 non sono soddisfatti. Il digest precedente, che includeva questo booleano, rilevava la differenza. Distinguere il progresso dei target del medesimo piano dalle dipendenze esterne: mantenere il controllo della conservazione esterna anche nei retry Verifiche positive: 68 test mirati, 1 skip (campione archivio esterno assente), 115 subtest; 4/4 gate PostgreSQL 16 (R02, import archivio, R01, live slices); Ruff, Markdown (124 file), diff check e preflight passati. CI Prove conservate: |
|
The P2 of the revalidation of Fix. Tests.
Full suite 164/165 (the known Windows 🤖 Generated with Claude Code |
…oo (#520 review) `outside_held` is out of the digest because the plan's own progress changes it, but the digest then relied on the refusals to notice a dependency lost from outside, and `_resolve_dependencies` skipped the days already retired or rebuilt. A day retired by something else between the retire of the first day and its retry therefore left the digest unchanged and the retry completed. Every day that is not refused is now judged on each planning: the progress of the days of the plan is allowed, the loss of an external dependency is a refusal, so the digest changes (STALE) before any further change. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Fallback per identità condivisa: GitHub ha rifiutato la review formale APPROVE perché autore e revisore usano lo stesso account. Questo commento registra l APPROVE tecnico della rivalidazione, non uno stato di approvazione formale GitHub. Rivalidazione indipendente di PR #531: APPROVE tecnico sul commit Ho confrontato l'ultimo fix con Prove indipendenti su PostgreSQL 16 temporaneo, con gli stessi fixture live e punti di interleaving conservati dalle review precedenti:
Verifiche positive sull'head esatto:
Prove conservate in Convalida del codice e dei test, non esecuzione operativa: il pilot reale 2026-10-20, i 31 giorni del server e la misura di scala dell'autore non sono stati rieseguiti. Nessuna modifica al codice della PR, merge, push, deploy, modifica di governance o operazione sui dati reali. |
data: R02 - operator-run rebuild of selected closed legacy live days (ADR-0074 Amendment 2)
Refs #520. Parent: DG-R (
SCOPE.mdPart D,R02); builds onR01(PR #530). Post-version. Nothing here runs on the server: the execution on2026-10-20and any further day is the operator's, from a reviewed plan.What changes
tools/rebuild_bybit_legacy_days.pyoverapplication/bybit_legacy_day_rebuild.py(BTCUSDT only):plan(read-only, writes a plan file that is never overwritten, prints its digest),execute --plan --digest(one day at a time),verify(read-only, repeatable),restore(explicit, never automatic). The DSN comes from an environment variable, never from the command line; the producing commit is the cleanHEADor--code-ref.dt=<day>with theR01reassessment (valid -> invalid, nothing deleted), import the whole archive day as revision 1 ofdt=<day>/seg=000000.000through the ordinary S13/S14 path, verify it (the Parquet is identical to the archive field by field, and a strictDataGatewayread returns exactly the archive records, in(exchange_ts, trade_id)order, once each).bybit_archive_import.import_bybit_archive_day_after_retirement, never a--force): the live revision of the exact keydt=<day>in the stateinvaliddoes not occupy the day; avalid/closed/degraded/writingrevision of that key and every partitiondt=<day>/...(the key it would create included) still refuse; the key is fixed; the lock is the day's (.import-dt=<day>.lock, the same file as the ordinary import, which a two-level key name would have broken); the coverage id carries a-rebuildsuffix. The ordinary importer is unchanged and still refuses an occupied day, a retired one included.STALE) if the digest differs; it never takes another target nor widens the days (at most 31, ascending, named by the operator). The digest binds what the operation depends on, not its progress (the incumbent's state and the action are excluded), so a plan stays current after a retire that was not followed by the import; the executor then acts on the live state of the same targets.valid(orinvalidbut not retired by this operation for the same archive file); the key to create exists in another state or two valid partitions would cover the day; the incumbent's Parquet or durable manifests are missing or do not hash to the catalog's; the archive file is missing or fails Amendment 1's strict parsing; conservation: every record of the incumbent, by(exchange_ts, trade_id), exists in the archive file of its own UTC day with equal venue, instrument, exchange time (millisecond), side, price and size (a trailing zero is a text difference, not a value one), that day's archive file is present, and that day is readable afterwards (in the same plan or alreadyvalid). Any difference refuses the day: no partial acceptance.docs/engineering/BYBIT_ARCHIVE_IMPORT_RUNBOOK.mdsection 6 (before, plan, execute, verify and the way back, what it does not do). CI: joblegacy-day-rebuild-postgres.Tests
tests/integration_bybit_legacy_day_rebuild_postgres.py, real PostgreSQL, the real importer, S13/S14,R01and theDataGateway. Legacy-shaped days are made with the ordinary importer (a partial archive day is onevalidrevision ofdt=<day>). Pilot-shaped day2026-10-20: after the rebuild a strict read returns exactly the archive's records, in order, without duplicates, equal field by field, with nullreceive_tsandsequence; the retired incumbent's bytes, the other days' states and files, and the live checkpoint are byte-identical. Each refusal above, each on its own, leaves the catalog, every file and the checkpoint byte-identical; a wrong or edited digest and a stale plan do nothing; both crash windows are recovered by the same plan; the restore (refused over a rebuilt day, returning a retired day tovalidand the day still rebuildable afterwards); a neighbouring day whose legacy coverage crossed midnight overlaps the rebuilt day (the strict read is refused) until it is rebuilt by its own plan; conservation across days (rows of a neighbouring day found, missing, differing, not readable, readable because in the plan); the variant's own guards; the verification's checks of count, order, duplicates and non-identity (with the gateway's answer altered).tests/test_bybit_legacy_day_rebuild_v1.py(10): request rules, manifest naming by artifact suffix, field comparison, the digest (what it binds and what it ignores), command-line usage errors, the runbook.Not claimed
d4589…447dper the amendment), the 31-date inventory, the manifests of the real legacy days (the incumbent's manifest and coverage file names are derived from its artifact suffix and checked against the catalog hashes; whether the server's 31 days have them where this expects them is the operator's check, and a plan that cannot find them says so as a refusal) are not exercised. The 529 rows outside 2026-10-20 are handled by the conservation check across days but only proved on a crafted Parquet.sequenceon the rows the incumbent served is declared and accepted (A2.4); the old bytes are kept. Nothing is deleted; retention of retired or superseded revisions stays the maintainer's. No A10 repair, atomic replacement, S13/S14 change, checkpoint or live-slice change, schema or governance file.Checks
Ruff, markdown links,
git diff --check,workflow.py preflight --base implement/fid, package boundaries; the new PostgreSQL gate and the regression gates of the archive import, the live slices andR01pass on a disposable PostgreSQL 16.🤖 Generated with Claude Code