Rebuild the state from the brokers after a restore and refuse an older copy

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>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-12-01 18:52:08 +01:00
1 parent 3da9b00f44
commit 4897594b87
40 files changed
+1871 -90

No files matched your search

@@ -22,6 +22,34 @@
<h2 id="interruttore">Interruttore d'emergenza</h2>
<span class="link-state @(v.BotState == "active" ? null : "down")"><span class="dot"></span>@BotText(v.BotState)</span>
</div>
@if (v.ProtectedRestart is { } restart)
{
<div class="notice notice-attention" role="status"><Icon Name="alert" Size="16" /><div>
<p><strong>Ripartenza protetta.</strong> Il database è cambiato il @Moment(restart.Since) (ripristino, importazione o copia più vecchia del conto): prima di ripartire guarda cosa ho ricostruito.</p>
<ul>
@foreach (var line in restart.Rebuilt)
{
<li>@line</li>
}
@if (restart.Working)
{
<li>Sto ancora leggendo i conti.</li>
}
else if (restart.Waiting.Count > 0)
{
<li>Non ho ancora letto: @string.Join(", ", restart.Waiting). Riprovo ogni minuto; se una chiave è scaduta, cambiala nelle Impostazioni.</li>
}
else if (restart.Rebuilt.Count == 0)
{
<li>Sui conti non c'era niente che il database non conoscesse già.</li>
}
@if (restart.ToReconfirm.Count > 0)
{
<li>Da riconfermare nella pagina Strategie, altrimenti restano in sola uscita: @string.Join(", ", restart.ToReconfirm).</li>
}
</ul>
</div></div>
}
@if (v.WaitsForRestart)
{
<p class="notice notice-attention" role="status"><Icon Name="alert" Size="16" /><span>
@@ -51,7 +79,7 @@
<form method="post" action="/azioni/bot/riattiva" class="form-inline">
<AntiforgeryToken />
<input type="hidden" name="ritorno" value="/rischio" />
<button class="btn" type="submit" disabled="@v.StopFile" data-confirm="@RestartText(v)">Riparti</button>
<button class="btn" type="submit" disabled="@(v.StopFile || v.ProtectedRestart is { CanRestart: false })" data-confirm="@RestartText(v)">Riparti</button>
</form>
}
}
@@ -293,7 +321,9 @@
private static string Where(string world) => world == Worlds.Real ? "sui conti veri" : "nel mondo simulato";
private static string RestartText(RiskView v) => v.Tripped.Count > 0
private static string RestartText(RiskView v) => v.ProtectedRestart is not null
? "Riparti dopo il ripristino: hai controllato posizioni e operazioni ricostruite? Il bot torna a operare; le strategie con soldi veri restano in sola uscita finché non le riconfermi. Confermi?"
: v.Tripped.Count > 0
? "Riparti: il massimo di riferimento riparte dal patrimonio di adesso e il bot torna a operare. Confermi?"
: "Riparti: il bot torna a operare. Confermi?";