Skip to content

data: R01 - superseding reassessment writer for a live revision (ADR-0074 A2.3) - #530

Merged
NeoNix-Lab merged 1 commit into
implement/fidfrom
agent/issue-519-dgr-r01-superseding-reassessment
Oct 25, 2026
Merged

NeoNix-Lab merged 1 commit into
implement/fidfrom
agent/issue-519-dgr-r01-superseding-reassessment

Conversation

@NeoNix-Lab

Copy link
Copy Markdown
Owner

data: R01 - superseding reassessment writer for a live revision (ADR-0074 Amendment 2, A2.3)

Refs #519. Parent: DG-R (SCOPE.md Part D, R01). Post-version; R02 (#520) comes after.

What changes

src/quant_platform/data/quality_reassessment.py (new, next to quality_lifecycle.py; data plane, no import of access):

  • reassess_live_partition(connection, inputs=..., status="fail"|"pass", ...) appends one new catalog.quality_reports row for the current live revision of one natural partition, then applies the existing A16 seam (QualityLifecycleCatalog.apply_partition_lifecycle): fail takes a valid revision to invalid, a superseding pass takes it back to valid. Nothing is deleted or rewritten.
  • The report is filed under the same check suite and certification profile as the assessment it supersedes, copies its bound evidence unchanged (certification_profile, natural_partition_identity, manifest and artifact hashes, coverage ids and hashes, the evidence categories), sets the coverage category status and, for fail, a violation legacy_publication_incomplete_day naming the archive identity; metrics.supersedes_assessment_signature is the exact semantic signature of the current leaf; code_ref is the producing commit. It must pass current_partition_report before anything is written.
  • Idempotent: the same call twice adds no leaf and no state change; a fail with another archive identity or another commit is a different assessment and supersedes the current one.
  • Refuses (nothing written): a revision that is superseded, writing or closed (ordinary S13 owns closed, record_quality_report is unchanged), a revision absent from its key, a foreign dataset, durable evidence that does not equal the catalog (hashes, coverage, storage root), a warn leaf that a pass cannot be built over, a bad status, a blank commit, a fail with no archive identity.
  • Lock order is the lifecycle's (dataset row FOR UPDATE, then the key's topology). Two short transactions, each committed on its own, as the issue's design 4 says: the report, then the seam. A crash between them leaves a current fail with the state still valid; repeating the call converges (no second report; the seam applies the state).
  • load_lifecycle_inputs(dataset_manifest, partition_manifest, coverage_manifests) reads and hashes the three durable manifests with the loader S13 uses and returns what the seam needs.
  • CI: new job quality-reassessment-postgres (own database). Module map entry in the package-boundary test.

To verify first (issue): who reacts to invalid

  • Reads: access/catalog.py selects p.state = ANY(policy states); invalid is in none of the three lifecycle policies, so VALID_ONLY, VALID_AND_CLOSED and VALID_CLOSED_AND_DEGRADED all exclude it (proved on PostgreSQL).
  • Retention (operations/retention.py): candidates must be in _FINALIZED_STATES = {closed, valid, degraded, superseded}; invalid is not one, so a retired revision is refused as a deletion candidate, not offered as one.
  • S14: the publication state is catalog.partitions.state itself (no separate eligibility table); K12 admitted inputs read through the gateway.
  • A10 repair (data/repair.py): an invalid live revision with a fail leaf is REPAIR_REQUIRED if someone runs a repair intent for that key. Nothing runs one automatically (ADR-0044: no authoritative repair source). Worth knowing for R02; no change here.

Tests

  • tests/test_quality_reassessment_v1.py (5): the argument rules, no catalog access on a refused call.
  • tests/integration_quality_reassessment_postgres.py, real PostgreSQL, a partial ETHUSDT day imported through the ordinary S13/S14 path (a valid revision with a pass): retire (valid -> invalid), the supersession link equals the original leaf's signature, the evidence is copied unchanged (all categories but coverage), the violation names the archive; every lifecycle policy excludes the retired revision (and a strict read refuses); the Parquet, the partition manifest, the catalog row and the earlier report are byte-identical; idempotence; restore by a superseding pass, re-retire supersedes the restore; refusals (wrong status/commit/archive, wrong partition or dataset hash, coverage end, storage root, missing revision, writing, closed, superseded, a foreign dataset) each write nothing; a concurrent S13 import on the same dataset waits for the writer's transaction and proceeds, and no lock is held afterwards (FOR UPDATE NOWAIT succeeds); the crash window converges; a warn leaf refuses a pass and accepts a fail; record_quality_report still refuses a partition that is not closed.
  • Mutation checks: 22 changes, one at a time (supersession link, coverage status, repeat recognition, archive/commit sensitivity of a repeat, state sets, superseded/writing checks, evidence verification, current_partition_report gate, dataset lock, seam applied, commit before the seam, argument rules, violation content, inserted flag, superseded signature). Four survived the first round: two were redundant checks (removed or merged: the writing message and the live-revision equality, which the unique index and the superseded check already imply), one needed the warn test, one needed the crash test to read through a second connection; all caught now.

Not claimed

  • The importer variant, the plan, the rebuild and the 31 days are R02; no production run; nothing deleted; no retention or cleanup code touched; no governance file, ADR, schema or migration changed.
  • integration_a10_repair_postgres.py fails in my local WSL PostgreSQL 16 ("injected mid-cutover DB failure was not raised") with or without this change (checked on a clean tree); it does not import the new module. I have not read this PR's CI.

Checks

Unit tests of the area, ruff, markdown links, git diff --check, workflow.py preflight --base implement/fid, package boundaries; the new PostgreSQL gate and the publication-certification gate pass on a disposable PostgreSQL 16.

🤖 Generated with Claude Code

… (ADR-0074 A2.3) (#519)

Appends one new quality report (a fail that retires a valid revision, or a pass that restores it)
for the current live revision of one natural partition, then runs the existing A16 lifecycle seam.
The report is filed under the same suite and profile as the assessment it supersedes, copies its
bound evidence unchanged, carries metrics.supersedes_assessment_signature = the exact signature of
the current leaf, and must pass current_partition_report before anything is written. Idempotent;
refuses a superseded, writing or closed revision, foreign evidence, a different dataset or key.
Two short transactions (report, then the seam); a crash between them converges on a repeat.

Tests: unit (argument rules), real-PostgreSQL gate (retire/restore, supersession link, evidence
copy, reads exclude the retired revision under every policy, bytes/manifests/reports untouched,
refusals write nothing, a concurrent S13 publication waits for the writer, no lock held after,
crash window), a CI job, mutation: 22 mutants, 0 survivors.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@NeoNix-Lab

Copy link
Copy Markdown
Owner Author

GitHub rifiuta la review formale perche autore e revisore condividono la credenziale NeoNix-Lab (Can not approve your own pull request). Questo commento e il report di fallback: APPROVE e il verdetto tecnico, senza stato formale di approvazione GitHub.

Review indipendente / avversaria di #530 (R01, issue #519), commit a05b91d80b9014ad4c2bb17c217bbb20f8efb67f, base implement/fid a 8acc6c250cbf5249bb144808df465eb64d849bce.

Esito: APPROVE tecnico sul perimetro R01 esaminato. Nessun finding azionabile. Nessun merge o operazione sui dati di produzione eseguito.

Semantica e confini. Ho letto il mandato #519, SCOPE Part D, ADR-0074 Amendment 2 A2.3/A2.5/A2.7 e ADR-0030, oltre ai documenti canonici del repository. Il delta e limitato al nuovo writer data-plane, ai test, alla mappa dei moduli e al job CI. Nessuna modifica di schemi, ADR, governance, S13/S14, repair, retention o contratti frozen. Il writer usa il dataset lock prima della topologia, seleziona il current leaf con il resolver A16, copia le evidenze legate al target e il relativo profilo/suite e applica lo stato tramite la seam A16. Non sostituisce la registrazione ordinaria di S13.

Prova PostgreSQL della PR rieseguita sul commit esatto: valid -> invalid -> valid; supersession link e firma del leaf; evidenze e report precedenti conservati; idempotenza; invariabilita di Parquet e manifest; rifiuti senza scrittura nei casi previsti (bound evidence, dataset/key/revision, stati non ammessi, warn -> pass); esclusione da tutte le lifecycle policy; pubblicazione S13 concorrente su un altro giorno dello stesso dataset bloccata dalla transazione del writer e poi completata; nessun lock trattenuto dopo; crash tra report e lifecycle e retry; sensitivita del fail ad archive identity e commit; record_quality_report ordinario continua a rifiutare una partizione non closed. Gate PASS.

Probe aggiuntivi indipendenti, su un altro database e fixture importata dal percorso canonico:

  • due writer fail simultanei con la stessa richiesta: un solo nuovo report, una sola firma/leaf, entrambi gli esiti invalid; nessun trade leggibile con alcuna LifecyclePolicy;
  • due restore pass simultanei con la stessa richiesta: un solo nuovo report, una sola firma/leaf, entrambi valid; i due trade originali tornano leggibili;
  • errore iniettato dopo il commit del report e prima della seam: da una seconda connessione si vede il fail persistito con stato ancora valid; il retry applica invalid senza un report aggiuntivo. Hash dei file originali invariati;
  • una seconda root applicabile ma indipendente rende la selezione ambigua: il writer rifiuta e non aggiunge report ne muta lo stato.

La finestra fra commit del report e applicazione della lifecycle resta quella esplicitamente descritta dal disegno a due transazioni: non e una rivalutazione atomica con l'import. Ho verificato la convergenza del retry, non un effetto di cutover atomico, che ADR-0074 A2.8 esclude da questa slice.

Consumer dello stato invalid: le tre LifecyclePolicy di access non lo includono e il catalogo filtra gli stati in un unico SELECT; la prova PostgreSQL conferma l'esclusione anche da VALID_AND_CLOSED e VALID_CLOSED_AND_DEGRADED e il rifiuto strict. Retention ammette solo closed/valid/degraded/superseded, quindi invalid non diventa automaticamente un candidato di cancellazione. L'ammissione K12 seleziona tramite DataGateway; nessun meccanismo di revoca o riscrittura di manifest gia sigillati e introdotto qui. L'A10 puo riconoscere il trigger invalid/fail soltanto quando qualcuno invoca esplicitamente un repair intent; nessun automatismo o nuova fonte di repair e aggiunto.

Altre verifiche:

  • 139 test mirati + 135 subtest PASS in due run: reassessment, lifecycle, package boundaries; retention, certificazione, eligibility bridge v1/v2 e admitted-input manifest.
  • Tre integrazioni locali PASS, ciascuna su database indipendente di un cluster PostgreSQL 16 UTF8 dedicato in WSL e clone Git del commit esatto: nuovo quality-reassessment gate, S13 publication-certification, S14 publication-eligibility. Le prove concorrenti e di crash aggiuntive sono separate dai gate ordinari.
  • Ruff sui nuovi moduli/test PASS; Markdown links PASS (124 file); preflight su implement/fid PASS; diff whitespace e worktree puliti.
  • CI riletta sul medesimo SHA: run 40179749754, 12/12 job SUCCESS, suite CI 164/164 script; integrazioni CI PostgreSQL 17. Non rieseguito tutto il runner Windows, non riconfermati i 22 mutanti dichiarati dall'autore. Non ho rieseguito il gate A10 segnalato come fallente in WSL dall'autore; non ne dichiaro una nuova riproduzione o risoluzione.

Evidenze fuori Git in WSL /var/tmp/qp-review530-g8rbtzgg/: reassessment-adversarial-probe.py/.log, reassessment.log, certification.log, eligibility.log, bootstrap/shutdown/server log e fixture dei probe personali. Cluster dedicato fermato; clone e cluster temporanei rimossi a fine prove.

La review non attesta R02, rebuild delle 31 giornate, scelta o esecuzione di un piano sui dati reali, cleanup/retention, deployment o governance di chiusura. Nessuna patch, push, merge o operazione su sistemi/dati di produzione.

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