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:
1 parent
24e20584d4
commit
81d6c5f667
20 files changed
+814
-174
No files matched your search
@@ -62,6 +62,7 @@ internal sealed partial class AnubisHost(
|
||||
|
||||
private readonly AccessGuards _accessGuards = new(clock);
|
||||
private readonly TimeSpan _interval = overrides?.DatabaseCheckInterval ?? TimeSpan.FromSeconds(5);
|
||||
private readonly TimeSpan _tradingRetry = overrides?.TradingRetry ?? TimeSpan.FromMinutes(1);
|
||||
private readonly Lock _gate = new();
|
||||
|
||||
// One step of the loop or one error-page choice at a time: a restore must not race the start that would follow it.
|
||||
@@ -666,7 +667,11 @@ internal sealed partial class AnubisHost(
|
||||
{
|
||||
try
|
||||
{
|
||||
await trading.StartAsync(cancellationToken).ConfigureAwait(false);
|
||||
while (!await TryStartAsync(trading, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
await Task.Delay(_tradingRetry, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await trading.RunAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
|
||||
@@ -678,6 +683,20 @@ internal sealed partial class AnubisHost(
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<bool> TryStartAsync(TradingService trading, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
await trading.StartAsync(cancellationToken).ConfigureAwait(false);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex) when (ex is not OperationCanceledException || !cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
LogTradingStartFailed(logger, ex, _tradingRetry);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// The jobs table keeps the outcome of the last run of each job (Diario e sistema, SPEC 13.6).
|
||||
private async Task RecordJobsAsync(EventSubscription<JobRun> runs, CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -813,6 +832,9 @@ internal sealed partial class AnubisHost(
|
||||
[LoggerMessage(Level = LogLevel.Error, Message = "Trading stopped")]
|
||||
private static partial void LogTradingFailed(ILogger logger, Exception exception);
|
||||
|
||||
[LoggerMessage(Level = LogLevel.Error, Message = "Trading could not start: tried again in {Delay}")]
|
||||
private static partial void LogTradingStartFailed(ILogger logger, Exception exception, TimeSpan delay);
|
||||
|
||||
[LoggerMessage(Level = LogLevel.Warning, Message = "Could not record the run of job {Job}")]
|
||||
private static partial void LogJobRecordFailed(ILogger logger, Exception exception, string job);
|
||||
}
|
||||
Reference in new issue
Block a user