Fase 9 — Rifinitura e consegna in Docker #111

Merged
Alby96 merged 18 commits from fase-9 into main 2026-12-03 14:07:16 +01:00
Owner

Chiude la Fase 9 (scelte nell'ADR 0020) e registra la nuova rotta decisa il 2 dicembre 2026.

Cosa contiene

  • Sicurezza (#68), salvataggi e ripartenza protetta (#69), CI e pubblicazione sui tag v* (#70), template Unraid con test (#71), manuali MANUALE.md, RUNBOOK.md, GO-LIVE.md provati da zero (#72), esportazione per la dichiarazione (#73), candidate, migliorie in osservazione e revisione trimestrale (#74).
  • Correzioni di tre revisioni indipendenti (#75, ADR 0020 punti 35–49).
  • La nuova rotta: piano approvato in docs/piani/2026-12-02-nuova-rotta.md (fasi 10–24, solo Docker) e il documento da cui viene in docs/ricerca/. Nell'immagine non entrano. STATE.md punta alla Fase 10 «Nuova rotta: solo Docker».

Prove

  • tasks check: 709 test, 683 superati, 26 ignorati (categoria LiveDemo e simili), nessun errore.
  • tasks ci: test su SQLite (685 superati) e su PostgreSQL (684 superati), nessun errore; immagine costruita; esercitazione della guardia nell'immagine superata.

Restano in attesa dell'utente: #70 (REGISTRY_TOKEN e prossimo tag v*), #71 (prova su Unraid), #55 (rapporto della prova di durata). La pull request #110 resta una decisione a parte.

Closes #68
Closes #72
Closes #73
Closes #74
Closes #75

🤖 Generated with Claude Code

Chiude la Fase 9 (scelte nell'ADR 0020) e registra la nuova rotta decisa il 2 dicembre 2026. **Cosa contiene** - Sicurezza (#68), salvataggi e ripartenza protetta (#69), CI e pubblicazione sui tag `v*` (#70), template Unraid con test (#71), manuali `MANUALE.md`, `RUNBOOK.md`, `GO-LIVE.md` provati da zero (#72), esportazione per la dichiarazione (#73), candidate, migliorie in osservazione e revisione trimestrale (#74). - Correzioni di tre revisioni indipendenti (#75, ADR 0020 punti 35–49). - La nuova rotta: piano approvato in `docs/piani/2026-12-02-nuova-rotta.md` (fasi 10–24, solo Docker) e il documento da cui viene in `docs/ricerca/`. Nell'immagine non entrano. `STATE.md` punta alla Fase 10 «Nuova rotta: solo Docker». **Prove** - `tasks check`: 709 test, 683 superati, 26 ignorati (categoria `LiveDemo` e simili), nessun errore. - `tasks ci`: test su SQLite (685 superati) e su PostgreSQL (684 superati), nessun errore; immagine costruita; esercitazione della guardia nell'immagine superata. **Restano in attesa dell'utente:** #70 (`REGISTRY_TOKEN` e prossimo tag `v*`), #71 (prova su Unraid), #55 (rapporto della prova di durata). La pull request #110 resta una decisione a parte. Closes #68 Closes #72 Closes #73 Closes #74 Closes #75 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Alby96 added this to the Fase 9 — Rifinitura e consegna in Docker milestone 2026-12-03 11:44:09 +01:00
Alby96 added 16 commits 2026-12-03 11:44:09 +01:00
A restore, an import or an adopted database restarts protected: the engine
stays stopped, reads from the broker what the archive does not know (orders,
stops, executions, also from the OKX history up to 89 days), cancels orders
left working, protects what it finds and waits for the user. Strategies with
real money stay exit only until confirmed again. The database of before the
restore, put back by mistake, is refused by its fingerprint.

A failed migration leaves the engine off with one backup and a way to try
again; an archive is checked whole before the database is touched; a changed
secret key no longer crashes anything, and "anubis access reset" gives the
access back to whoever holds the computer. The image runs the db and access
commands without the guard.

refs #69

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A session alone could change the password, switch the second factor on or
off, send the key of the language model to another address and remove the
rules that stop purchases. Each now needs the password and the code, with
one limit on wrong attempts that a restart of the services does not clear,
and the other sessions end when the password or the factor changes.

Requests to the brokers pass a list of allowed calls, never follow a
redirect with a key and are signed by one client only. Pages are closed by
default, nothing is cached, requests are limited to 1 MB, secrets are
masked in logs and notifications, exported tables cannot run as formulas,
archives carry no sessions and the container refuses to run as root.

refs #68

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A v* tag now builds, tries and publishes the image: the version must be the
one of Directory.Build.props, latest only moves forward and the registry
token is in one step, given to docker on its input. The same script works by
hand. The image says its version and commit, and its health check also
covers the engine loop and the live prices.

The Unraid template is final: a test compares it with appendix E and with
the variables the loader really reads, and another reads the workflow.

refs #70
refs #71

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every execution, dividend and correction of a world, with its value in euro
at the ECB rate of its own Italian day or the last one before it, and for
sales the cost of what was sold. Costs come from the executions of the whole
account, so the method (LIFO by default, or FIFO) can be changed at any
time. A missing rate leaves the cell empty and says so.

The ECB download no longer leaves holes after a pause, and each execution
keeps the reference rate in force when it happened (SPEC 6.8).

refs #73

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Relative momentum among coins and all-time highs on stocks are now in the
code as candidates: they collect signals, have no share, no capital and no
order path, and every way forward refuses them. The crypto one ran the
protocol once and failed it (DSR 0.744, worst fall 35.3%), so it is archived
and decides nothing; the stock one waits for the Alpaca history.

refs #74

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each improvement is measured on the signals the bot already collects, in its own
savepoint after the decision, so no order depends on it: the correlation filter,
the volatility cap, the sector cap, the market filter, the entry time and the
choice of the model. The laboratory shows how many cases each one has and how far
to trust it. Sectors come from the SEC only with a contact given by the user.

refs #74

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every quarter the base strategies are tried again on the longer history with
the slippage in force, compared with how they did live, and the report is
published in the laboratory with the base rates measured again and the balance
of the restrictions of 10.5. In observation the outcome replaces the old one and
a strategy that passed goes to simulation after its 90 days; with capital
nothing moves but the demotion condition of 12.3. A restart halfway goes on and
the review concludes once; the outcome of a review survives a restart with an
older build.

refs #74

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The manual, the runbook and the go-live list are written and checked claim by
claim against the code, and the installation is done from zero by following
them on both engines. That found real defects, now fixed:

- with SQLite a missing database file left no way to restore a backup: the
  choices appear, and the file is created only by the user's choice;
- an account whose difference vanished after the 15 minutes stayed prudent
  with no button, a missing stop could be left out for good, and a choice
  made while the broker was silent used old numbers;
- after "Ferma tutto" the positions could not be closed without restarting;
- a refused key looked like a silent broker: it has its own notice now;
- the split of the capital between the strategies of a broker (SPEC 13.5)
  could not be changed from the interface.

refs #72 #68

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A position left out together with its stop kept the account prudent for good: the
stop was still asked for shares that no longer exist. The cover required now stops
at what the account holds, the stops are compared again after the choice, and where
one is still missing Align takes the excluded position up again. After the choice
the account waits for the stop with its own reason, so it returns to normal by
itself also past the 15 minutes; a new difference still gets its own 15 minutes.

A right password alone no longer clears the wrong second-factor codes: it takes
back only its own attempt.

Capital and shares are planned and written in one transaction, so overlapping
changes cannot apply twice and an interruption leaves nothing halfway; sending the
same figures again completes what an old one left. The cash that purchases under
way still hold is no longer given away, counted as the risk engine counts it.

/health said healthy when the trading engine had failed to start. It now says so at
once, or after ten minutes of a stalled start, and the host tries the start again
every minute; the guard still sees a start that does not move.

The image of the manual publication says its version and its commit, marked when
the tree is dirty, and publish.sh refuses before any login an image that does not
come from the commit of the tag.

refs #75

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The independent review found that a rebuild cut halfway was never finished
(stops canceled or lowered), that old stop executions replayed from the broker
queued a real sale, that a pending "close all" survived the restore, and that
reconciliation and corporate actions touched accounts not rebuilt yet. The
rebuild now keeps its starting point until it ends, protects the bot before the
first row, meets the splits at their date and leaves the ledger alone until it
is done. Dividends count the shares of after a split. A failed restore of a
missing SQLite file leaves no empty database, and a failed migration can be
tried again from the choice page.

refs #69 #75

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The quarterly review judged the best variant of the grid instead of the one
that trades: the plan now fixes the variant in use and the protocol measures
that one, while the tries are still those of the grid. A failure while the
history is prepared is a reason in the report and no longer stops the review,
and a strategy whose protocol does not exist says so when its data are there.

The volatility improvement compared books of different days and stages: the
book keeps its stage and its previous day, and a case without a book valid on
its day is left out. Fewer than six months give no interval, the others use
the clustered error with the Student t.

The restriction balance counts a case in the period in which its outcome
became known, so no case is lost or counted twice between two reviews.

The contact given to the SEC travels only on the client that never follows a
redirect, so it cannot reach another site.

refs #75

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What an account did while the bot was off is now written before the splits and
the dividends of those days, once and without acting on it; an attempt cut
halfway is taken up from the same point. Until then the account is not valued
at today's price, the guard keeps the last figures it knew with their time,
and a stop order only cancels what is open. Protective sales of the archive
are not continued, and the rest of a stop that fired in part is sold.

Also the decisions of the phase (ADR 0020), the manuals and the dates under
the equity chart.

refs #69 #72 #75

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A difference that comes and goes no longer makes the account ask about a stop
the user has already chosen on. The balance of the restrictions adds each
period to what was published, so a change of capital does not rewrite the
past. An image is published only under a tag that exists, and a file that is
not part of it no longer marks it as unclean.

refs #70 #74 #75

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Close Phase 9 and record the new route of 2 December 2026
ci / test (postgres) (push) Failing after 7m12s
ci / test (sqlite) (push) Successful in 11m19s
ci / image (push) Skipped
ci / test (postgres) (pull_request) Failing after 7m46s
ci / test (sqlite) (pull_request) Successful in 10m6s
ci / image (pull_request) Skipped
f3a603d491
Phase 9 ends with its last documents: the review fixes in ADR 0020
(points 35-49), the publication rule in SVILUPPO.md and the state.

The user changed the project's route on 2 December 2026: maths-only
decisions, the basket mean-reversion logic of a research document, a
championship of strategies, leverage and short selling only on margin
accounts that can never be real, currencies on the eToro Demo, and
Docker only. The approved plan (phases 10-24) and the document now live
in docs/piani and docs/ricerca, so the route does not stay on one disk.
STATE.md points the next session to Phase 10 "Nuova rotta: solo Docker";
ROADMAP.md marks the old desktop phase as superseded and keeps #70 and
#71 open while they wait for the user.

refs #75

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Alby96 added 1 commit 2026-12-03 12:56:24 +01:00
Merge main into fase-9: SQLite test databases in memory on the CI
ci / test (postgres) (push) Failing after 6m53s
ci / test (sqlite) (push) Failing after 5m26s
ci / image (push) Skipped
ci / test (postgres) (pull_request) Failing after 7m47s
ci / test (sqlite) (pull_request) Canceled after 1m49s
ci / image (pull_request) Canceled after 0s
4aea2d0be7
The CI of Phase 9 failed on seven tests that start the server on a SQLite
file: on the runner's disk the migrations alone took 24 seconds, past the
30-second start limit. PR #110 (ADR 0019), now in main, keeps the test
databases in a tmpfs folder on the CI. STATE.md no longer lists #110 as
waiting for the user.

refs #75

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Alby96 added 1 commit 2026-12-03 13:23:10 +01:00
Let the tests run their fake tools from the CI's memory folder
ci / test (postgres) (push) Successful in 7m50s
ci / test (sqlite) (push) Successful in 5m23s
ci / test (sqlite) (pull_request) Successful in 5m24s
ci / image (push) Successful in 3m54s
ci / test (postgres) (pull_request) Successful in 7m19s
ci / image (pull_request) Successful in 1m36s
76c19d533b
Docker mounts a tmpfs noexec by default. The publish script tests of
Phase 9 write fake git and docker into the temp folder and run them;
on /test-tmp they could not, the real git ran instead and 18 tests
failed. Reproduced in the CI's SDK container: 18 of 37 delivery tests
fail without exec, all 37 pass with it. ADR 0019 says why.

refs #75

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

CI della Fase 9, cosa è successo e cosa ho fatto:

  1. Prima corsa (f3a603d): il lavoro PostgreSQL cadeva su sette test che avviano il server su un file SQLite: sul disco dell'esecutore le sole migrazioni impiegavano 24 secondi, oltre il limite di 30 secondi all'avvio. È il caso della #110, che ho unito in main e portato qui (4aea2d0).
  2. Seconda corsa (4aea2d0): il tmpfs della #110 è montato da Docker senza permesso di esecuzione, e i test dello script di pubblicazione (Fase 9) eseguono lì i loro git e docker finti: 18 test caduti. Riprodotto nel contenitore della CI (18 su 37 senza exec, 37 su 37 con), corretto con size=4g,exec e scritto nell'ADR 0019 (76c19d5). Tutta la batteria SQLite passa nel contenitore della CI con il montaggio nuovo.
  3. Terza corsa (76c19d5): nella corsa del push PostgreSQL e SQLite sono verdi. In quella della pull request un solo test, WithAnotherSecretKeyNothingCrashesAndTheAccessIsResetFromTheCommandLine, è caduto per un timeout di lettura nell'autenticazione a PostgreSQL. Il registro del servizio mostra il motivo: in quei secondi PostgreSQL aspetta un processo che non risponde (still waiting for backend … ProcSignalBarrier), e poco prima un checkpoint ha impiegato 25 secondi anche con fsync spento. È il disco dell'esecutore dell'ADR 0015, non il codice: ho rilanciato solo quel lavoro.

Resta da sapere: i dati del servizio PostgreSQL della CI stanno ancora sul disco dell'esecutore. Il rimedio naturale è lo stesso dell'ADR 0019 (dati del servizio in un tmpfs), da fare a parte.

🤖 Generated with Claude Code

CI della Fase 9, cosa è successo e cosa ho fatto: 1. **Prima corsa (f3a603d):** il lavoro PostgreSQL cadeva su sette test che avviano il server su un file SQLite: sul disco dell'esecutore le sole migrazioni impiegavano 24 secondi, oltre il limite di 30 secondi all'avvio. È il caso della #110, che ho unito in `main` e portato qui (4aea2d0). 2. **Seconda corsa (4aea2d0):** il `tmpfs` della #110 è montato da Docker senza permesso di esecuzione, e i test dello script di pubblicazione (Fase 9) eseguono lì i loro `git` e `docker` finti: 18 test caduti. Riprodotto nel contenitore della CI (18 su 37 senza `exec`, 37 su 37 con), corretto con `size=4g,exec` e scritto nell'ADR 0019 (76c19d5). Tutta la batteria SQLite passa nel contenitore della CI con il montaggio nuovo. 3. **Terza corsa (76c19d5):** nella corsa del push PostgreSQL e SQLite sono verdi. In quella della pull request un solo test, `WithAnotherSecretKeyNothingCrashesAndTheAccessIsResetFromTheCommandLine`, è caduto per un timeout di lettura nell'autenticazione a PostgreSQL. Il registro del servizio mostra il motivo: in quei secondi PostgreSQL aspetta un processo che non risponde (`still waiting for backend … ProcSignalBarrier`), e poco prima un checkpoint ha impiegato 25 secondi anche con `fsync` spento. È il disco dell'esecutore dell'ADR 0015, non il codice: ho rilanciato solo quel lavoro. Resta da sapere: i dati del servizio PostgreSQL della CI stanno ancora sul disco dell'esecutore. Il rimedio naturale è lo stesso dell'ADR 0019 (dati del servizio in un `tmpfs`), da fare a parte. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Alby96 merged commit db563a0ebf into main 2026-12-03 14:07:16 +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#111