Fase 10 — Nuova rotta: solo Docker (#184)
ci / test (postgres) (push) Successful in 4m50s
ci / test (sqlite) (push) Failing after 4m21s
ci / image (push) Skipped

ADR 0021-0026 for the new course of 2 December 2026, roadmap of phases 10-24. The desktop application is gone: Docker is the only form, and outside a container the server runs only for development and tests with --data-dir, on this computer only. Lighter image (829 MB to 410 MB), rotating logs, backtest and learning as one-shot commands.

refs #113 #114 #115 #78 #80 #81

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #184.
This commit is contained in:
Alby96andClaude Opus 5.5 authored and Alby96 committed 2026-12-03 19:59:00 +01:00
1 parent 3c57b3e84c
commit 1bc7e067fd
96 files changed
+1433 -1606

No files matched your search

+49 -57
View File
@@ -1,8 +1,9 @@
using Anubis.Demo;
using Anubis.Platform;
namespace Anubis.Tests;
/// <summary>Startup configuration in Docker and on desktop (issue #7, SPEC 15.1, 15.6).</summary>
/// <summary>Startup configuration of the container, and what is left outside it (issue #7, SPEC 15.1, ADR 0022).</summary>
[TestClass]
public sealed class PlatformTests
{
@@ -94,60 +95,39 @@ public sealed class PlatformTests
[TestMethod]
[TestCategory(Category.Unit)]
public void TomlSubsetParsesAndRejectsWithLineNumbers()
public void TheContainerFindsItsDataAndOutsideItTheFolderIsGivenByHand()
{
var values = Toml.Parse("""
# comment
allow_live = false
port = 8_787 # trailing comment
name = "a \"quoted\" # not a comment"
// The rule of the server and of the guard alike (ADR 0022): no ANUBIS_PLATFORM, no user folder.
var container = new Dictionary<string, string?> { ["DOTNET_RUNNING_IN_CONTAINER"] = "true" };
Assert.AreEqual("/data", DataDirectory.Locate(null, container));
Assert.AreEqual(Path.GetFullPath("dati-di-prova"), DataDirectory.Locate("dati-di-prova", container));
Assert.AreEqual(Path.GetFullPath("dati-di-prova"), DataDirectory.Locate("dati-di-prova", new Dictionary<string, string?>()));
[database]
engine = "postgres"
""");
Assert.IsFalse((bool)values["allow_live"]);
Assert.AreEqual(8787L, values["port"]);
Assert.AreEqual("a \"quoted\" # not a comment", values["name"]);
Assert.AreEqual("postgres", values["database.engine"]);
var error = Assert.Throws<FormatException>(() => Toml.Parse("a = 1\nb = [1, 2]\n"));
Assert.Contains("Riga 2", error.Message);
Assert.Throws<FormatException>(() => Toml.Parse("a = 1\na = 2"));
Assert.Throws<FormatException>(() => Toml.Parse("a = \"open"));
var outside = new Dictionary<string, string?> { ["ANUBIS_PLATFORM"] = "docker" };
var refused = Assert.Throws<StartupRefusedException>(() => DataDirectory.Locate(null, outside));
Assert.Contains("--data-dir", refused.Message);
Assert.Contains("Fuori da un container", refused.Message);
}
[TestMethod]
[TestCategory(Category.Integration)]
public void DesktopStartsFromAnEmptyFolderAndKeepsSecretsOutOfConfigToml()
public void TheDemoStartsFromAnEmptyFolderAndCreatesItsOwnKey()
{
var folder = TempFolder.Create("desktop");
var folder = TempFolder.Create("demo-key");
try
{
var data = new DataDirectory(folder);
var store = ProtectedSecretKey.DefaultStore(data);
var first = DesktopPlatform.Load(data, store);
Assert.IsTrue(first.NeedsFirstRun);
Assert.IsFalse(first.IsComplete);
var first = DemoMode.Config(data);
Assert.IsTrue(first.IsComplete, string.Join("; ", first.Problems.Select(p => p.What)));
Assert.AreEqual(data.SqliteFile, first.Db!.SqlitePath);
Assert.IsFalse(first.AllowLive);
Assert.IsFalse(first.SecretKey.HasKey, "An empty folder has no key yet.");
var key = first.SecretKey.GetOrCreateKey();
DesktopPlatform.WriteConfig(data, store, new DbSettings { Engine = DbEngine.Postgres, Host = "localhost", Password = "fake-pg-pass-1" });
var text = File.ReadAllText(data.ConfigFile);
Assert.Contains("allow_live = false", text);
Assert.IsFalse(text.Contains("fake-pg-pass-1", StringComparison.Ordinal), "la password del database non va in config.toml");
Assert.IsFalse(text.Contains(Convert.ToBase64String(key), StringComparison.Ordinal), "la chiave dei segreti non va in config.toml");
Assert.IsFalse(text.Contains("secret", StringComparison.OrdinalIgnoreCase) && text.Contains("key =", StringComparison.Ordinal));
var second = DesktopPlatform.Load(data, store);
Assert.IsTrue(second.IsComplete, string.Join("; ", second.Problems.Select(p => p.What)));
Assert.AreEqual("fake-pg-pass-1", second.Db!.Password);
CollectionAssert.AreEqual(key, second.SecretKey.GetOrCreateKey(), "la chiave resta la stessa tra un avvio e l'altro");
Assert.IsFalse(second.AllowLive);
Assert.IsFalse(second.AllowNetwork);
DesktopPlatform.WriteConfig(data, store, new DbSettings { Engine = DbEngine.Sqlite });
var sqlite = DesktopPlatform.Load(data, store);
Assert.AreEqual(data.SqliteFile, sqlite.Db!.SqlitePath);
Assert.HasCount(32, key);
Assert.IsNotEmpty(Directory.EnumerateFiles(Path.Combine(folder, "keys")).ToList(), "The key lives in a file of the demo folder.");
CollectionAssert.AreEqual(key, DemoMode.Config(data).SecretKey.GetOrCreateKey(), "The same key at the next start.");
Assert.DoesNotContain("Windows", first.SecretKey.Description);
}
finally
{
@@ -157,22 +137,34 @@ public sealed class PlatformTests
[TestMethod]
[TestCategory(Category.Unit)]
public void BrokenConfigTomlIsAProblemNotAGuess()
public void NothingOfTheDesktopIsLeftInTheProduct()
{
var folder = TempFolder.Create("desktop-bad");
try
// ADR 0022: the desktop application, its configuration file and its guided first run are gone.
string[] words = ["config.toml", "primo-avvio", "PlatformKind", "ANUBIS_PLATFORM", "DesktopPlatform", "ProtectedData"];
var found = Repo.Files()
.Where(file => Repo.Relative(file) is var path && (path.StartsWith("src/", StringComparison.Ordinal) ||
path.StartsWith("tools/", StringComparison.Ordinal) || path.StartsWith("deploy/", StringComparison.Ordinal)))
.Where(file => file.Extension is not (".png" or ".ico" or ".ttf" or ".onnx"))
.SelectMany(file => words.Where(word => File.ReadAllText(file.FullName).Contains(word, StringComparison.Ordinal))
.Select(word => Repo.Relative(file) + ": " + word))
.ToList();
Assert.IsEmpty(found, string.Join("; ", found));
}
[TestMethod]
[TestCategory(Category.Unit)]
public void TheSolutionHasFiveProjects()
{
var solution = System.Xml.Linq.XDocument.Load(Path.Combine(Repo.Root.FullName, "Anubis.slnx"));
var projects = solution.Descendants("Project").Select(p => (string)p.Attribute("Path")!).Order(StringComparer.Ordinal).ToList();
CollectionAssert.AreEqual(new[]
{
var data = new DataDirectory(folder);
File.WriteAllText(data.ConfigFile, "[database]\nengine = sqlite\n");
var config = DesktopPlatform.Load(data, ProtectedSecretKey.DefaultStore(data));
Assert.IsNull(config.Db);
Assert.IsFalse(config.IsComplete);
Assert.Contains("Riga 2", config.Problems[0].What);
}
finally
{
TempFolder.Delete(folder);
}
"src/Anubis.Guard/Anubis.Guard.csproj",
"src/Anubis.Server/Anubis.Server.csproj",
"src/Anubis/Anubis.csproj",
"tests/Anubis.Tests/Anubis.Tests.csproj",
"tools/Anubis.Tasks/Anubis.Tasks.csproj",
}, projects);
}
[TestMethod]