Fix what the review of Phase 9 found in accounts, access, capital, health and publication

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>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-12-01 22:07:46 +01:00
1 parent 24e20584d4
commit 81d6c5f667
20 files changed
+814 -174

No files matched your search

+42
View File
@@ -147,6 +147,48 @@ public sealed class AccountsScreenTests
StringAssert.Contains(await server.TextAsync("/impostazioni"), "Trend crypto: quota 100%");
}
[TestMethod]
[TestCategory(Category.Integration)]
public async Task AMissingStopWhereAPositionWasLeftOutOffersBothChoicesAgain()
{
await using var server = await ServerHarness.StartAsync("docker", ServerHarness.DockerSqlite());
await server.SignInFirstTimeAsync();
var db = server.Host.Services!.Db;
var account = Guid.NewGuid();
var now = DateTimeOffset.UtcNow;
async Task<string> PageAsync(string reason, DateTimeOffset since, params string[] excluded)
{
var differences = System.Text.Json.JsonSerializer.Serialize(new
{
Current = new[] { new AccountDifference(DifferenceKinds.Stop, "BTC-EUR", 0.00598m, 0m, "BTC-EUR: gli stop coprono 0 su 0,00598.") },
Excluded = excluded,
});
await db.WriteAsync(async s =>
{
await s.ExecuteAsync("DELETE FROM account_status");
await s.ExecuteAsync("INSERT INTO account_status (id, account_id, mode, mode_since, mode_reason, differences, last_reconciled_at, last_outcome, created_at, updated_at) " +
"VALUES (@id, @a, 'prudent', @since, @r, @d, @now, 'different', @now, @now)",
("id", Guid.NewGuid()), ("a", account), ("since", since), ("r", reason), ("d", new DbJson(differences)), ("now", now));
});
return await server.TextAsync("/conti");
}
await db.WriteAsync(s => s.ExecuteAsync("INSERT INTO accounts (id, name, broker, environment, base_currency, created_at) VALUES (@id, 'OKX demo', 'okx', 'demo', 'EUR', @t)",
("id", account), ("t", now)));
var both = await PageAsync(Reconciler.StopReason, now.AddMinutes(-20), "position:BTC-EUR:0.00998:0.00598");
StringAssert.Contains(both, "Allinea il registro al conto");
StringAssert.Contains(both, "Lascia fuori ciò che non è del bot");
StringAssert.Contains(both, "dove avevi lasciato fuori una differenza");
// Another instrument's exclusion has nothing to do with it, and after a choice nobody is told to choose again.
var again = await PageAsync(Reconciler.StopReason, now.AddMinutes(-20), "position:ETH-EUR:1:0");
StringAssert.Contains(again, "Ricontrolla adesso");
Assert.DoesNotContain("Allinea il registro al conto", again);
var waiting = await PageAsync(Reconciler.StopReason, now.AddMinutes(-2), "position:BTC-EUR:0.00998:0.00598");
StringAssert.Contains(waiting, "torna normale da solo quando c'è");
StringAssert.Contains(await PageAsync(DifferenceKinds.Stop, now.AddMinutes(-2)), "Se entro 15 minuti si spiega da sola");
}
[TestMethod]
[TestCategory(Category.Integration)]
public async Task TheUserSplitsTheCapitalAndWithRealMoneyOnlyThroughTheProcedure()