Repository navigation
live: O03 - configuration, runbook and window evidence tool for the continuous session (ADR-0075 slice 9.3) - #526
Conversation
…ool (O03, ADR-0075 slice 9.3) (#525) - CLI: --mode {cycles,continuous} (default cycles, unchanged) and --slice-seconds, --slice-max-trades, --buffer-messages, valid only with continuous; empty value = default so a unit whose env file predates the options still starts; invalid values refused before any connection. - Units and env examples (BTCUSDT unit and @ template): mode and the three bounds rendered into ExecStart; defaults cycles with empty bounds. - Runbook: operating the continuous session, rollback to cycles, the one-hour real-provider proof procedure and its stop conditions. - Evidence tool (read-only): archive vs strict DataGateway read over the claimed windows, holes, ordering violations and health counters from the captured signals; stop conditions on an undeclared loss, a refused strict read, a double or out-of-order read, a payload that differs. - Tests: CLI, artifacts, runbook, evidence (unit, mutation-checked) and PostgreSQL phase 7. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
GitHub rifiuta la review formale perche autore e revisore condividono la credenziale NeoNix-Lab (Can not request changes on your own pull request). Questo commento e il report di fallback: REQUEST CHANGES e il verdetto tecnico, senza stato formale di review GitHub. Review indipendente / avversaria di #526 (O03, issue #525), sul commit Esito: REQUEST CHANGES. Un P1 e due P2 riprodotti nello strumento di evidenza. La CI e verde; la prova reale da almeno un'ora resta non eseguita e O03 non e conclusa. R1. [P1] Non giustificare automaticamente ogni buco del catalogo come gap dichiarato
[P1] Non giustificare automaticamente ogni buco del catalogo come gap dichiarato. Qui basta che un trade mancante cada tra due catene di slice per escluderlo dagli stop: non vengono letti/verificati i gap espliciti ne gli span dei segnali, e signals_text viene solo riassunto dopo la decisione. #525 design 4 e criteri 5/7 richiedono invece lo stop per una perdita fuori da un intervallo registrato. Riprodotto anche sul percorso PostgreSQL reale: due slice pubblicate con S13/S14, 6 trade leggibili su 9 in archivio, zero known_gap e log senza interruzioni; il vero CLI restituisce exit 0 / passed=true, classificando i tre assenti come missing_inside_unclaimed_spans. L assenza di una partizione non e la dichiarazione della causa del buco. Legare l esenzione a evidenza di span effettivamente registrata (gap manifest/segnale attribuibile, inclusa l eventuale dichiarazione idle-midnight) e fallire quando il trade mancante non e coperto da tale evidenza. Aggiungere il negativo con le stesse slice ma nessun gap registrato. R2. [P2] Conservare la finestra UTC richiesta nel confronto
[P2] Conservare la finestra UTC richiesta nel confronto. Anche quando --start/--end sono espliciti, qui i limiti vengono rimpiazzati con quelli delle slice rimaste; _claimed inoltre esclude interamente le slice che intersecano solo in parte la finestra. I trade di archivio prima della prima slice e dopo l ultima spariscono da denominatore e classificazione delle perdite. Probe: richiesta [10:00,11:00), unica slice [10:10,10:15), archivio con un trade in testa, uno nella slice e uno in coda: passed=true, window.seconds=300, archive_trades_in_window=1, captured_ratio=1, senza traccia dei due mancanti. Il criterio #525 chiede un report della finestra del run, non un suo sottoinsieme scelto dai dati disponibili. Mantenere i limiti espliciti, conteggiare/classificare anche testa e coda e gestire le slice che intersecano i bordi (clipping, oppure rifiuto esplicito di limiti non supportati). Richiedere gli archivi dei giorni dell intera finestra, non soltanto delle slice superstiti. R3. [P2] Verificare anche il trade_id per i timestamp uguali
[P2] Verificare anche il trade_id per i timestamp uguali. La chiave costruita sopra contiene exchange_ts e trade_id, ma il controllo usa soltanto b[0] < a[0]. Il contratto Bybit canonico e il gateway impiegano l ordine totale (exchange_ts, trade_id), come bybit_trade_v1_ordering_key; due trade nello stesso millisecondo restituiti come b,a passano qui senza stop. Ho riprodotto passed=true e stop_conditions=[] su questa sequenza. Confrontare la chiave completa o usare il provider canonico e aggiungere la regressione sulle parita di timestamp; il requisito di fermarsi su un read fuori ordine deve includere il tie-break congelato. Prova indipendente di R1 su PostgreSQL. Cluster 16 UTF8 dedicato in WSL, clone Git del commit esatto, catalogo/storage nuovi. Ho pubblicato le due slice attraverso publish_live_slice, vera materializzazione/S13/S14, con tre trade ciascuna; tra esse il mondo dell'archivio contiene altri tre trade. Nessun gap manifest registrato e nessuna interruzione nel log. Eseguito il vero entry point tools/live_window_evidence.py sul catalogo e sullo stesso archivio: sei trade letti, nove in archivio, tre mancanti, exit 0, passed=true, stop_conditions=[]. Il numero di partizioni resta invariato (il tool legge soltanto). Report completo conservato come false-pass-report.json. Il falso positivo non dipende da un mock del DataGateway. R2 e R3 sono riprodotti direttamente sulla logica con reader scriptato, separati dalla prova di catalogo. La diversa regola descritta nel nuovo runbook e nel test che accetta qualunque hole non sostituisce l'autorita di #525 e ADR-0040/0042/0044/0075: le interruzioni non dimostrate devono restare esplicite e attribuibili. Non basta dedurre un gap registrato dall'assenza di copertura. Questi finding riguardano l'attendibilita del report che chiuderebbe O03, non una nuova perdita misurata su Bybit reale. Verifiche concluse:
Prova reale / criterio 7. Non e stata eseguita in questa review e non puo essere dichiarata superata dai gate scriptati. Ho chiesto quale host/catalogo/root dedicati usare, come richiede la scelta del maintainer in #525; la destinazione non e ancora indicata. Il report finale richiede inoltre gli archivi del giorno dopo la chiusura UTC. Restano quindi separati: review del codice, eventuale acquisizione di un'ora, confronto successivo con l'archivio e governance di chiusura. In ogni caso i falsi positivi del tool vanno corretti prima di usarne passed come attestazione finale. Evidenze fuori Git in WSL |
Review fixes (cc commit below)All three findings were valid. R1 (P1) — any hole excused a missing trade. A hole between slices is now declared only by recorded evidence: an explicit gap record under R2 (P2) — requested window reduced. The requested R3 (P2) — tie-break. The out-of-order check uses the canonical Runbook updated to the same rules (declaration, requested window, stop conditions, Verification. Evidence unit tests 35 (new: declared/undeclared holes by gap record and by signal, gap of another interval, empty hole, unreadable manifests, head/tail, straddling slice, archive days of the whole window, ties); PostgreSQL gates (session with the extended phase 7, slices, two instruments) PASS on WSL; mutation: 11 new mutants (declaration conditions, head/tail, requested window, straddling, tie-break, manifests, archive days) plus the earlier 33, 0 survivors; ruff, markdown links, 🤖 Generated with Claude Code |
…eps the requested window, orders by trade_id (#525) Review of #526: - P1: a hole between slices excused any missing trade. Now a hole is declared only by an explicit gap record under --storage-root (last durable key in the segment before it) or an unclaimed_span signal covering it; otherwise the missing trades are an undeclared loss. Unreadable gap manifests are a stop. The tool requires --storage-root. - P2: the requested window was replaced by the surviving slices. It is kept: the head and the tail are compared (stop), a slice crossing a bound is refused, and the archive days are those of the whole window. - P2: the read order was checked by exchange_ts only; it is now the canonical (exchange_ts, trade_id) key. Tests: unit for each rule, runbook, PostgreSQL phase 7 (declared holes of the real run; same slices with no gap record fail; a one-hour request around a few seconds of slices); mutation: 11 new mutants, 0 survivors. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
GitHub rifiuta la review formale perche autore e revisore condividono la credenziale NeoNix-Lab (Can not request changes on your own pull request). Questo commento e il report di fallback: REQUEST CHANGES e il verdetto tecnico, senza stato formale di review GitHub. Riesame indipendente / avversario di #526 sul commit Esito: REQUEST CHANGES. R2 e R3 corretti; resta un P1 nella classificazione dei trade rispetto ai limiti del gap registrato. Sola revisione, come richiesto dal maintainer: nessuna prova reale. R1 residuo: il manifest esiste, ma il report ne estende indebitamente lo span. [P1] Applicare i limiti temporali del gap, non soltanto la sua anchor. read_declared_gaps conserva solo start_key.exchange_ts e coverage_id, scartando la fine dell assertion known_gap. Questo predicato riconosce poi l intero buco per la sola posizione dell anchor e tutti i suoi trade mancanti diventano missing_inside_declared_gaps. Riprodotto con catalogo, S13/S14, gateway e manifest prodotti dai seam reali: slice [10:00:00.000,.007) e [.018,.025), tre trade mancanti a .009/.012/.015; gap registrato dal vero record_explicit_long_gap con assertion [.006,.010). Solo .009 e nel gap, ma il CLI esce 0 / passed=true e giustifica tutti e tre, anche t-4/t-5 fuori dallo span. Senza manifest la nuova versione rifiuta correttamente: R1 e quindi solo parzialmente risolto. Portare nel modello anche start/end della coverage autorevole e classificare ciascun trade mancante contro lo span registrato (o l unione degli span), senza ampliare un gap a tutta la hole per la sola anchor. La regressione deve richiedere exit 1 e due perdite non dichiarate per il gap corto, ed exit 0 quando lo span copre davvero tutti e tre, come chiede #525 criteri 5/7. Prova PostgreSQL indipendente: ho ripreso il precedente riproduttore (originale preservato), adeguando soltanto la directory scratch e il nuovo flag obbligatorio --storage-root. Prima, con due slice, sei trade leggibili su nove in archivio e nessun gap: exit 1, passed=false, tre perdite non dichiarate. Questo fix positivo e confermato. Ho poi registrato attraverso record_explicit_long_gap il manifest corto [.006,.010), con l anchor vera dell ultimo trade pubblicato della prima slice (t-2, .006). t-3 (.009) e nello span; t-4 (.012) e t-5 (.015) ne sono fuori. Il report effettivo del CLI e exit 0, passed=true, missing_inside_declared_gaps=3, stop_conditions=[]. Il report falso positivo e conservato come short-gap-false-pass-report.json. Nel controllo positivo, il successivo manifest della stessa anchor estende davvero il gap fino a .018: allora tutte e tre le assenze sono dentro l assertion e l esito PASS e corretto. Il codice attuale non distingue i due casi perche elimina coverage_end quando carica il record. Non e un mock della lettura: catalogo, materializzazione, certificazione, pubblicazione, file, gateway e manifest dei gap sono reali; il mondo dei trade e scriptato. Nessuna nuova misura del provider reale. Finding precedenti riconfermati/chiusi:
Verifiche sul nuovo head:
Perimetro operativo: il maintainer ha specificato per ora solo revisione della PR. Non ho avviato una prova reale ne cerco una destinazione operativa: criterio 7 / run di almeno un ora e successivo confronto con l archivio restano pendenti. Questi test non concludono O03 e non autorizzano governance di chiusura. Evidenze fuori Git in WSL |
Second review fixP1 — the end of a recorded gap was ignored: valid, fixed. Tests. Unit: a short gap excuses only what it contains (four span positions), end exclusive, two spans together, a signalled span excuses only its trades, a span elsewhere is not attributed. PostgreSQL phase 7, with the real Checks. Evidence/template/boundary unit tests, three PostgreSQL gates on WSL, ruff, markdown links, 🤖 Generated with Claude Code |
…orded gap span (#525) Second review of #526: the loader kept only the anchor of a recorded gap, so a gap that ended at .010 excused trades lost at .012 and .015. The span of the known_gap assertion [coverage_start, coverage_end) now travels with the gap (end exclusive) and a missing trade in a hole is excused only by the span that contains it (a gap record attributed to the hole by its anchor, or an unclaimed_span signal); the others are an undeclared loss. Per hole the report gives declared and undeclared trades. Tests: unit (short gap, end exclusive, union of spans, signal span, span elsewhere) and PostgreSQL phase 7 with the real record_explicit_long_gap: a short gap excuses one trade of the hole, the superseding manifest over the whole hole excuses all; 0 survivors on 8 new mutants. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
GitHub rifiuta la review formale perche autore e revisore condividono la credenziale NeoNix-Lab (Can not request changes on your own pull request). Questo commento e il report di fallback: REQUEST CHANGES e il verdetto tecnico, senza stato formale di review GitHub. Riesame indipendente / avversario di #526 sul commit Esito: REQUEST CHANGES per un nuovo P2 di complessita nella classificazione. Tutti i finding funzionali precedenti sono chiusi nei casi riprodotti, incluso il P1 del gap corto. Nuovo P2, [P2] Costruire il set degli ID coperti una sola volta per buco. set(covered) e nella condizione della comprehension: viene ricostruito per ciascun trade_ids, non una volta per il gruppo. Per N perdite tutte comprese in un gap dichiarato, anche covered ha N elementi e questa differenza fra liste esegue N costruzioni di N elementi, O(N^2). Il caso che deve semplicemente riconoscere un outage lungo diventa molto costoso a volumi ordinari di mercato. Misurato sulla funzione reale con un unico gap interamente dichiarato e gli stessi dati: 2000 ID 0.050 s, 4000 0.164 s, 8000 0.900 s, 16000 4.320 s; 32000 ID impiegano 28.213 s contro 0.012 s al precedente head d349bb0 nello stesso caso positivo equivalente. Non includo costruzione dei fixture o I/O nel tempo: e sola classificazione in memoria. Precalcolare covered_set fuori dalla comprehension e riutilizzarlo per tutte le membership, preservando l ordine degli esempi e i nuovi conteggi. Rieseguire il caso di scala insieme ai probe funzionali: il fix dello span e corretto, questa e una regressione di costo introdotta dalla nuova riga. Il confronto di prestazioni usa il modulo precedente letto direttamente dalla storia Git, caricato soltanto in memoria, e il modulo attuale. La fixture e un gap che copre integralmente tutte le perdite, quindi i due codici hanno gli stessi esiti corretti (passed=true e 32000 missing_inside_declared_gaps). Il precedente problema del limite corto non e parte di questo confronto. Il workload contiene un solo gap e due sole slice/record letti: la crescita non viene da molti segmenti, dal catalogo o dai file. Non e una misura del throughput reale di Bybit, ne una stima dei tempi di un run di produzione; dimostra il costo quadratico del report sui record mancanti. L entita di 32000 ID e gia inferiore al default slice_max_trades=50000, non richiede un input patologico. Finding precedenti verificati come risolti:
Verifiche sul nuovo head:
Perimetro: sola revisione, come richiesto dal maintainer. Nessuna prova reale da un ora; criterio 7 e successivo confronto con l archivio restano pendenti, O03 non e conclusa. Nessuna richiesta di destinazione operativa e nessuna azione di chiusura/governance. Evidenze fuori Git in WSL |
Third review fixP2 — quadratic classification: valid, fixed. The per-trade Test. 60,000 missing trades in one hole with a gap covering half of them: the counts are exact (30,000 / 30,000) and the run is bounded at 5 s (it takes a fraction of a second); the quadratic form does not finish within a 170 s timeout. The rest of the classification is unchanged: unit tests (40), the PostgreSQL gate with phase 7, ruff, The real-provider run (criterion 7) is still pending the host/catalog/root from the maintainer. 🤖 Generated with Claude Code |
…time (#525) Third review of #526: the per-trade set(covered) made the classification quadratic (28 s for 32,000 missing ids). Each missing trade is now tested once against the few recorded spans of its hole. Test: 60,000 missing trades in one hole with a half-covering gap, bounded at 5 s; the quadratic form does not finish within the timeout. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
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 sul codice, senza stato formale di approvazione GitHub. Riesame indipendente / avversario del codice di #526 sul commit Esito: APPROVE sul codice. Nessun finding aperto nel perimetro riesaminato; tutti i finding precedenti sono risolti nei probe. Questa approvazione non conclude O03: il criterio 7, prova reale di almeno un ora e report contro l archivio, resta pendente. Nessun merge eseguito. P2 del costo quadratico: risolto e misurato personalmente. Il delta partiziona ogni lista di trade mancanti in un singolo passaggio, verificando gli span del buco e aggiungendo ciascun ID alla lista dichiarata o non dichiarata. Nessuna ricostruzione di set per ID e nessuna modifica ai limiti semantici degli span. Sullo stesso benchmark con 32000 ID in un gap completamente dichiarato, il nuovo codice impiega 0.02137 s (il precedente head 320aee5 aveva impiegato 28.21281 s). Rilanciato anche il probe di scala precedente, senza cambiarne la logica: 2000/4000/8000/16000 ID richiedono circa 0.0012/0.0021/0.0052/0.0121 s. Controllo aggiuntivo indipendente con gap che copre meta dei record: 8000/16000/32000/60000 mancanti impiegano circa 0.0044/0.0088/0.0207/0.0452 s; conteggi esatti a ogni dimensione. A 60000: 30000 dichiarati, 30000 non dichiarati, stop corretto per la meta fuori dallo span. Le misure sono locali, includono la costruzione del report ma non dei fixture, e non sono una garanzia di latenza di produzione. Non ho ripetuto il mutante da 170 secondi dichiarato dall'autore: il vecchio benchmark e il nuovo caso parziale sono stati eseguiti direttamente. Regressioni funzionali confermate:
Verifiche sul commit esatto:
Perimetro operativo: sola revisione del codice, come richiesto. Nessuna acquisizione reale e nessuna richiesta di host/catalogo/root in questo lavoro. Il run di almeno un ora, l archivio del giorno e il report misurato restano necessari per il criterio 7; nessun credito di completamento O03/T02 o governance di chiusura e implicato dall'approvazione del codice. Evidenze fuori Git in WSL |
live: O03 - configuration, runbook and window evidence tool for the continuous session (ADR-0075 slice 9.3)
Refs #525. Parent: DG-O (
SCOPE.mdPart C,O03); closesT02once its one-hour proof is recorded. Builds onO02(PR #524): the engine is unchanged.Status: the code, the tool, the artifacts and the runbook are ready for review. Acceptance criterion 7 of #525 (the real-provider run of at least one hour and its evidence report) is the operator's run and is not done here; this PR is not the end of
O03until that evidence is recorded (a comment or a follow-up commit once the archive of the day exists).What changes
tools/live_ingest_server.py):--mode {cycles,continuous}(defaultcycles: today's behaviour,continuous_session is None) and--slice-seconds,--slice-max-trades,--buffer-messages(defaults 300 / 50 000 / 20 000 fromLiveSessionConfig). The bounds are valid only withcontinuous: withcyclesthey are a usage error (exit 2), never silently ignored; non-positive, non-integer or fractional values are refused before any connection. An empty value means the default, because systemd renders an unset${VAR}as an empty string: a unit whose environment file predates the options still starts, incycles.--recent-limitalso reaches the session. The CLI only builds the typed configuration (C05); startup prints the mode and the bounds.@template:QP_LIVE_INGEST_MODE(cycles) and the three bounds (empty) are rendered intoExecStartas--mode=${...}etc. The pinned-hash guard of the existing BTC unit/env now removes exactly the O03 addition and compares the rest with the original, byte for byte; the template unit still refusesBTCUSDT, builds the checkpoint from the instance and does not read the instrument from the environment.cycles, and the one-hour proof procedure with its stop conditions. Deployment stays a manual operator step; nothing here starts or installs anything.tools/live_window_evidence.py, logic inapplication/live_window_evidence.py; read-only, writes nothing): for the window the run claimed (the valid live slices), it compares the archive trades with astrictDataGatewayread of each exact chain (chunks of at most twelve slices, ending on slice boundaries), reports the captured ratio, the holes between chains with the archive trades inside each (the declared cost of an interruption), the slices (count, rows, seconds), and the session counters from the captured stdout (ordering violations, reconnects, buffer high-water, slice lag, interruptions). Stop conditions (exit 1): an archive trade inside a claimed window that is not read back (undeclared loss); a refused strict read; a trade read twice or out of order; a payload that differs from the archive; valid slices that overlap; no valid slice. A shortfall inside an unclaimed span is reported, not hidden, and not a failure; an ordering violation is a measurement.Tests
tests/test_live_ingest_server_cli_v1.py(+7): default/empty mode = cycles; continuous builds the session with the defaults; bounds and--recent-limitreach it; empty bounds are the defaults; bound without continuous refused; invalid bounds/modes refused before the server starts.tests/test_live_ingest_template_artifacts_v1.py(+10): both units pass mode and bounds; both env examples default tocycleswith empty bounds; the example environments start the cycle loop in both units; an environment file that predates the options still renders a valid command (run through the real CLI); the continuous mode and its bounds reach the session from either environment; the runbook documents every variable/flag/default, the rollback, the operator boundary, the proof and its stop conditions.tests/test_live_window_evidence_v1.py(24): full ratio; a hole with archive trades is reported and not a stop; a loss inside a claimed window, a conflict (price/size values; a trailing zero is not one; side; millisecond), a double read, an out-of-order read, a refused read, overlapping slices are stops; extras reported; archive outside the window excluded (boundaries both sides); invalid slices not a claim; chunked reads; the signal counters.tests/integration_live_session_postgres.pyphase 7, real PostgreSQL, the real catalog andDataGateway: the archive is every trade the scripted world made; the tool passes, states the shortfall (the unlistened intervals are holes the run left, none inside a claimed window) and fails on an archive trade inside a claimed window that was never published.Not claimed
exchange_ts, the real captured share and slice sizes remain assumptions until the operator's run is recorded.cycles(flipping it is the maintainer's decision after the numbers); the ping/pong/backoff are not configuration; no governance file changed; nothing is credited (the closeout is a separate governance issue).Checks
python tools/run_tests.pyon Windows: 162 of 163, the one failure istest_promote_main_v1(test_merge_stays_pinned_to_the_validated_oid_despite_a_concurrent_push), which does not touch this change and passes on Linux. On Linux (WSL): the new and touched unit tests (147) pass and the three live PostgreSQL gates (session with phase 7, slices, two instruments) pass against a disposable PostgreSQL 16. Ruff PASS, markdown links PASS,git diff --checkclean,workflow.py preflight --base implement/fidpassed. I have not read this PR's CI.🤖 Generated with Claude Code