Fase 13 — Campionato: unità di lavoro, piano e statistica #188

Merged
Alby96 merged 6 commits from fase-13 into main 2026-12-04 15:53:44 +01:00
Owner

Costruisce il giudice del campionato prima dei concorrenti. Nessuna pagina e nessun comando nuovi: il giudice si prova su serie costruite apposta. Le scelte sono nell'ADR 0029.

Cosa cambia

  • Unità di lavoro e operai (#122).

    • TrialRunner.Run = Judge(Variants()), in due tempi.
    • Ogni esecuzione del motore è un'unità registrata in tournament_units, con l'esito compresso e l'impronta degli ingressi (dati, versione del motore, build). Dopo un'interruzione si rifanno solo le unità in corso, o quelle calcolate su ingressi diversi.
    • Le unità girano su un gruppo di thread a priorità bassa. Quanti lo dice l'impostazione laboratory.workers, in Impostazioni → Sistema (predefinita 1). Le prove restano una alla volta.
  • Statistica (#124), in Backtest/TournamentStatistics.cs:

    • conteggio comune delle prove: campo, combinazioni, registro, le 27 da riga di comando;
    • asticella e varianza del campo sugli Sharpe annui;
    • probabilità di sovra-adattamento comune su un calendario solo;
    • numero effettivo di scommesse e intervallo a blocchi.

    Il generatore a seme fisso è passato nel nucleo senza cambiare un bit.

  • Controllo contro il caso (Backtest/Surrogates.cs): ogni giorno tutti gli strumenti cambiano segno insieme. La copia è centrata per chi è solo in acquisto. Si fanno 200 copie, e il finalista passa se al più il 5% fa altrettanto bene.

  • Piano e tempi del campionato (#123, #125):

    • il piano è immutabile, ha un'impronta e si scrive insieme alle prove dei concorrenti, prima di ogni risultato;
    • i finalisti sono uno per gruppo e mercato, al più 8;
    • il tratto finale si apre una volta sola, e solo per i finalisti;
    • un finalista passa solo se supera tutti e sette i controlli;
    • combinazioni e prove di stress sono già nel piano, e si eseguono nella Fase 16.

Prove

  • Criterio 1, le unità (TrialUnitTests):

    • Judge(Variants()) dà il JSON di Run sui tre rapporti d'oro della Fase 12, che non sono cambiati;
    • quattro operai danno il rapporto di uno;
    • una corsa ricaricata dalla sua unità dà lo stesso rapporto;
    • dopo un'interruzione le unità finite non si rifanno.
  • Criterio 2, il piano e il tratto finale (TournamentTests): il piano è scritto prima di ogni risultato e non cambia; il tratto finale si apre una volta sola e solo per i finalisti.

  • Criteri 3 e 4, il controllo contro il caso (SurrogateTests):

    • la copia conserva il valore assoluto di ogni rendimento e le correlazioni, mentre una serie con memoria la perde;
    • su una serie che rientra (dimezzamento a 50 barre) la regola di rientro supera il controllo con 200 copie;
    • su un cammino con deriva la regola di tendenza in solo acquisto non lo supera.
  • Criterio 5, la statistica (TournamentStatisticsTests):

    • 28 serie identiche valgono una scommessa;
    • una strategia senza vantaggio provata in 100 varianti resta sotto 0,90;
    • la probabilità di sovra-adattamento comune sul rumore è circa 0,5;
    • 8 finalisti danno 87 combinazioni.
  • Criterio 6, il campo costruito apposta (TournamentTests): con due concorrenti con un vantaggio e quattro di rumore, e 200 copie, passano solo i primi due.

  • Comandi e CI:

    • ./tasks.ps1 check: 904 test, 878 superati, 26 ignorati, 0 falliti;
    • la CI di Gitea è verde su SQLite, PostgreSQL e immagine per i commit della fase spinti prima di questo.
  • Revisione indipendente con verifica a contraddittorio: 4 problemi confermati e corretti, ognuno con una prova che falliva prima; 8 respinti.

    • Un errore nel giudizio di un campionato fermava la coda del Laboratorio.
    • Le unità riprese potevano mescolare dati o build diversi.
    • Il piano cambiato di un concorrente non era controllato.
    • Una frase delle Impostazioni era sbagliata.

    Correggendo ne è emerso un quinto, chiuso anche lui e provato rompendo apposta la correzione: dati di ricerca cambiati tra la prova e il giudizio.

Da sapere

  • Lo Sharpe corretto comune alza l'asticella anche con i concorrenti buoni. Se molte varianti del campo hanno un vantaggio, la varianza del campo cresce e quelli buoni faticano a passare. Nella prova del criterio 6, i due concorrenti con un vantaggio sono stati cercati con meno varianti di quelli di rumore. È la scelta prudente; l'ADR 0029 (Conseguenze) lo scrive.
  • Il controllo contro il caso non vale ancora per gli strumenti con azioni societarie (le azioni): si rivede nella Fase 23.
  • Sul mio computer la prova su PostgreSQL non si fa per mancanza di memoria: PostgreSQL lo prova la CI.

refs #122, refs #123, refs #124, refs #125, refs #126

🤖 Generated with Claude Code

Costruisce il giudice del campionato prima dei concorrenti. Nessuna pagina e nessun comando nuovi: il giudice si prova su serie costruite apposta. Le scelte sono nell'ADR 0029. **Cosa cambia** - **Unità di lavoro e operai (#122).** - `TrialRunner.Run` = `Judge(Variants())`, in due tempi. - Ogni esecuzione del motore è un'unità registrata in `tournament_units`, con l'esito compresso e l'impronta degli ingressi (dati, versione del motore, build). Dopo un'interruzione si rifanno solo le unità in corso, o quelle calcolate su ingressi diversi. - Le unità girano su un gruppo di thread a priorità bassa. Quanti lo dice l'impostazione `laboratory.workers`, in Impostazioni → Sistema (predefinita 1). Le prove restano una alla volta. - **Statistica (#124)**, in `Backtest/TournamentStatistics.cs`: - conteggio comune delle prove: campo, combinazioni, registro, le 27 da riga di comando; - asticella e varianza del campo sugli Sharpe annui; - probabilità di sovra-adattamento comune su un calendario solo; - numero effettivo di scommesse e intervallo a blocchi. Il generatore a seme fisso è passato nel nucleo senza cambiare un bit. - **Controllo contro il caso** (`Backtest/Surrogates.cs`): ogni giorno tutti gli strumenti cambiano segno insieme. La copia è centrata per chi è solo in acquisto. Si fanno 200 copie, e il finalista passa se al più il 5% fa altrettanto bene. - **Piano e tempi del campionato (#123, #125):** - il piano è immutabile, ha un'impronta e si scrive insieme alle prove dei concorrenti, prima di ogni risultato; - i finalisti sono uno per gruppo e mercato, al più 8; - il tratto finale si apre una volta sola, e solo per i finalisti; - un finalista passa solo se supera tutti e sette i controlli; - combinazioni e prove di stress sono già nel piano, e si eseguono nella Fase 16. **Prove** - **Criterio 1**, le unità (`TrialUnitTests`): - `Judge(Variants())` dà il JSON di `Run` sui tre rapporti d'oro della Fase 12, che non sono cambiati; - quattro operai danno il rapporto di uno; - una corsa ricaricata dalla sua unità dà lo stesso rapporto; - dopo un'interruzione le unità finite non si rifanno. - **Criterio 2**, il piano e il tratto finale (`TournamentTests`): il piano è scritto prima di ogni risultato e non cambia; il tratto finale si apre una volta sola e solo per i finalisti. - **Criteri 3 e 4**, il controllo contro il caso (`SurrogateTests`): - la copia conserva il valore assoluto di ogni rendimento e le correlazioni, mentre una serie con memoria la perde; - su una serie che rientra (dimezzamento a 50 barre) la regola di rientro supera il controllo con 200 copie; - su un cammino con deriva la regola di tendenza in solo acquisto non lo supera. - **Criterio 5**, la statistica (`TournamentStatisticsTests`): - 28 serie identiche valgono una scommessa; - una strategia senza vantaggio provata in 100 varianti resta sotto 0,90; - la probabilità di sovra-adattamento comune sul rumore è circa 0,5; - 8 finalisti danno 87 combinazioni. - **Criterio 6**, il campo costruito apposta (`TournamentTests`): con due concorrenti con un vantaggio e quattro di rumore, e 200 copie, passano solo i primi due. - **Comandi e CI:** - `./tasks.ps1 check`: 904 test, 878 superati, 26 ignorati, 0 falliti; - la CI di Gitea è verde su SQLite, PostgreSQL e immagine per i commit della fase spinti prima di questo. - **Revisione indipendente** con verifica a contraddittorio: 4 problemi confermati e corretti, ognuno con una prova che falliva prima; 8 respinti. - Un errore nel giudizio di un campionato fermava la coda del Laboratorio. - Le unità riprese potevano mescolare dati o build diversi. - Il piano cambiato di un concorrente non era controllato. - Una frase delle Impostazioni era sbagliata. Correggendo ne è emerso un quinto, chiuso anche lui e provato rompendo apposta la correzione: dati di ricerca cambiati tra la prova e il giudizio. **Da sapere** - Lo Sharpe corretto comune alza l'asticella anche con i concorrenti buoni. Se molte varianti del campo hanno un vantaggio, la varianza del campo cresce e quelli buoni faticano a passare. Nella prova del criterio 6, i due concorrenti con un vantaggio sono stati cercati con meno varianti di quelli di rumore. È la scelta prudente; l'ADR 0029 (Conseguenze) lo scrive. - Il controllo contro il caso non vale ancora per gli strumenti con azioni societarie (le azioni): si rivede nella Fase 23. - Sul mio computer la prova su PostgreSQL non si fa per mancanza di memoria: PostgreSQL lo prova la CI. refs #122, refs #123, refs #124, refs #125, refs #126 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Alby96 added this to the Fase 13 — Campionato: unità di lavoro, piano e statistica milestone 2026-12-04 14:32:33 +01:00
Alby96 added 5 commits 2026-12-04 14:32:34 +01:00
The tournament of Phase 13 needs many trials to run on more than one thread
and to survive a restart without redoing finished work. The judge was one
monolithic call on one thread, so a restart redid the whole trial.

TrialRunner.Run is now Judge(Variants()): Variants does every engine execution
as a keyed unit in two stages (grid and outside-grid run, then, after the
plateau choice, costed runs, benchmark and look-ahead), and Judge is the old
pure judging code working on runs assembled by key. Both Run overloads keep
their signatures; on one thread the engine is called in the order of today,
and the three golden reports do not move.

The single low-priority worker becomes a pool of N threads (setting
laboratory.workers, default 1, at most one less than the processors, shown in
Impostazioni > Sistema). The Laboratory records each unit in the new
tournament_units table (migration 0016, which also creates tournaments for the
next part of the phase): claimed as running, then done with the gzip of its
run. A resumed trial drops its running units, reloads the done ones and runs
only the rest; a run reloaded from storage gives the same report byte for
byte. Plain trials drop their unit outcomes when they finish or fail. The pool
no longer disposes its queue while a thread may still read it.

refs #122

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add the tournament statistics and the surrogate series of the control
ci / test (postgres) (push) Successful in 7m30s
ci / test (sqlite) (push) Successful in 5m52s
ci / image (push) Successful in 2m8s
8967575d2c
The championship judge needs statistics the single-trial protocol does not
have: one common number of trials for the whole field and the bar it sets,
a field variance taken on annualised Sharpe ratios so crypto and weekday
markets compare, the common probability of overfitting on one calendar,
the effective number of bets, a block-bootstrap interval and the control
against chance. The control replays a rule on surrogate prices where every
day all instruments change sign together, centred on the mean for
long-only rules, so sizes, tails and correlations stay while any tendency
to revert or to go on is lost. Instruments with corporate actions are
refused for now.

The seeded SplitMix64 generator of the tests moves to Anubis.Core as
SeededRandom, unchanged, so the control and the intervals draw from it;
the tests keep calling it Gen through a global alias.

refs #124

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Plan, run and judge a tournament of contenders in the laboratory
ci / test (postgres) (push) Successful in 7m47s
ci / test (sqlite) (push) Successful in 6m27s
ci / image (push) Successful in 1m57s
8aafa5ad32
A tournament judges many contenders together so that a rule cannot win by
chance alone. Its plan (contenders with rules version and grid, data, costs,
thresholds with the control share, the finalists rule, control repetitions
and seed, combinations, stress windows, variants counted before) is written
with the trials of its contenders in one transaction, before any result, and
keeps its fingerprint like a trial plan. The contender trials read only the
search window; when the last one finishes the tournament goes to its judge.

The judge picks at most eight finalists, one per group and market, by
walk-forward Sharpe, and writes them as the final tract is opened: the
opening is a compare-and-set, so a resumed judge gets back the same
finalists. Each finalist then runs the control against chance on surrogate
series and its chosen variant on the final tract at plain and doubled costs;
these are units in tournament_units, so a judge stopped halfway redoes only
what it had not finished and reads the final tract only for finalists. The
report counts every variant in a common N (field, combinations of the
finalists, the register at the opening, prior protocols), deflates each
finalist against the field variance, computes the common PBO, the effective
number of bets and a block-bootstrap Sharpe interval, and a finalist passes
only if every check passes. Unit outcomes are dropped when it ends.

The trial engine gains LongOnly and Surrogate with default members, so other
engines keep compiling; the daily engine centres its control. Tests cover the
plan written first and never changed, the final tract read once, a resumed
judge, the finalists rule, and a built field where only the two contenders
with an edge pass with 200 repetitions.

refs #123, refs #125

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An error while judging a tournament (a plan that no longer reads, the database out
of reach) could stop the whole laboratory queue or leave the tournament unjudged
until a restart. The judge now reads inside its failure handling, so an unreadable
plan fails the tournament with an Italian reason; every call of the judge is
guarded; and a finished contender trial that comes back to the queue brings its
tournament to the judge.

Resumed trials and judges reused finished units without checking they were
computed on the same inputs, so a restart after new bars or an image update mixed
runs of two data sets or two engines. Every unit now records its fingerprint (the
data, the engine version, the build) and only units on the same inputs are reused;
the runs on the final tract are checked on the build and, when the tract is read,
on its data.

The judge also checks that each contender trial is the one the tournament plan
wrote: plan hash, grid, data source, capital, slippage and reference share.

The settings hint now says the workers are calculations of one trial; trials still
run one at a time.

refs #122, refs #123

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refuse a judge whose search data changed, and close Phase 13
ci / test (postgres) (push) Failing after 10m23s
ci / test (sqlite) (push) Successful in 7m44s
ci / image (push) Skipped
ci / test (postgres) (pull_request) Successful in 10m3s
ci / test (sqlite) (pull_request) Successful in 7m35s
ci / image (pull_request) Successful in 2m31s
9e98c70727
The control compares the replicas with the Sharpe ratio stored by the
contender's own trial. If the search data changed between that trial and
the judge, the replicas would run on new data against a result from the
old, so the tournament now fails with the reason. A test changes one bar
after the trial and fails without the guard.

ADR 0029 records the choices of the phase: the trial judge split into
resumable units on a pool of low-priority workers, the common count of
trials and the field statistics, the control against chance on surrogate
prices, the immutable tournament plan with a final tract read once, and
the seven checks a finalist must pass. ROADMAP and STATE are updated.

refs #122, refs #123, refs #124, refs #125, refs #126

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Alby96 added 1 commit 2026-12-04 14:52:32 +01:00
Give the engine health test thirty seconds instead of a hundred polls
ci / test (postgres) (push) Successful in 9m39s
ci / test (sqlite) (push) Successful in 8m6s
ci / test (postgres) (pull_request) Successful in 10m13s
ci / test (sqlite) (pull_request) Successful in 7m36s
ci / image (push) Successful in 1m55s
ci / image (pull_request) Successful in 58s
7b162aa4bc
The test waited for the engine to start for at most a hundred polls, about
ten seconds, and passed in eleven on PostgreSQL in CI. Phase 13 adds
CPU-heavy tournament and control tests that run in parallel with it, and
on a busy runner the engine took longer to start, so the test failed with
the engine still starting. It now waits up to thirty seconds of wall time,
polling as before; it still requires the engine to reach ok, then not
started, then ok again.

refs #126

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Alby96 merged commit cfa2a4da0e into main 2026-12-04 15:53:44 +01:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: BalboSoft/Anubis#188