feat(operations): add production readiness gate (#23)

This commit is contained in:
KyuubiYoru
2026-07-16 22:19:51 +02:00
parent 6bad659c12
commit 00d5ff7764
13 changed files with 782 additions and 6 deletions
@@ -143,6 +143,10 @@ public sealed class ReleaseCompatibilityTests
pinnedConsumers.Select(static item => item.GetProperty("name").GetString()!).ToArray());
Assert.All(pinnedConsumers, static item =>
Assert.Matches("^[0-9a-f]{40}$", item.GetProperty("revision").GetString()));
string realConsumerGate = File.ReadAllText(Path.Combine(root, "scripts", "verify-real-consumers.sh"));
Assert.Contains("<PackageReference Remove=\"FinalFactory.Rendezvous.Client\" />", realConsumerGate, StringComparison.Ordinal);
Assert.Contains("<PackageReference Remove=\"FinalFactory.Rendezvous.Contracts\" />", realConsumerGate, StringComparison.Ordinal);
}
[Fact]
@@ -164,6 +168,49 @@ public sealed class ReleaseCompatibilityTests
Assert.Equal(actual, declared);
}
[Fact]
public void ProductionReadinessRecordIsFailClosedAndCanaryEvidenceIsRedacted()
{
string root = FindRepositoryRoot();
using JsonDocument readiness = JsonDocument.Parse(File.ReadAllText(Path.Combine(
root,
"docs/evidence/production-readiness-v1.json")));
JsonElement document = readiness.RootElement;
Assert.Equal(1, document.GetProperty("schemaVersion").GetInt32());
Assert.Equal("rendezvous-production-readiness", document.GetProperty("kind").GetString());
Assert.Matches("^[0-9a-f]{40}$", document.GetProperty("evaluatedCommit").GetString());
JsonElement[] local = document.GetProperty("localGates").EnumerateArray().ToArray();
JsonElement[] external = document.GetProperty("externalGates").EnumerateArray().ToArray();
Assert.Equal(6, local.Length);
Assert.Equal(13, external.Length);
JsonElement[] gates = local.Concat(external).ToArray();
Assert.Equal(gates.Length, gates.Select(static gate => gate.GetProperty("id").GetString()).Distinct().Count());
Assert.All(gates, static gate =>
{
Assert.True(gate.GetProperty("status").GetString() is "pass" or "pending" or "fail");
string evidence = Assert.IsType<string>(gate.GetProperty("evidenceRef").GetString());
Assert.False(Path.IsPathRooted(evidence));
Assert.DoesNotContain("..", evidence, StringComparison.Ordinal);
Assert.True(gate.GetProperty("note").GetString()!.Length <= 240);
});
bool allPass = gates.All(static gate => gate.GetProperty("status").GetString() == "pass");
Assert.Equal(allPass ? "ready" : "not-ready", document.GetProperty("decision").GetString());
string canary = File.ReadAllText(Path.Combine(root, "scripts/run-real-network-canary.sh"));
Assert.Contains("umask 077", canary, StringComparison.Ordinal);
Assert.Contains("client-expected-failure", canary, StringComparison.Ordinal);
Assert.Contains("exit_code\" -eq 12", canary, StringComparison.Ordinal);
Assert.Contains(".addressFamily == $family", canary, StringComparison.Ordinal);
Assert.Contains("identifiers:\"not-in-summary\"", canary, StringComparison.Ordinal);
Assert.DoesNotContain("jq -c . \"$raw_log\"", canary, StringComparison.Ordinal);
string checker = File.ReadAllText(Path.Combine(root, "eng/check_production_readiness.py"));
Assert.Contains("return 3", checker, StringComparison.Ordinal);
Assert.Contains("FORBIDDEN_KEY_PARTS", checker, StringComparison.Ordinal);
Assert.Contains("decision must be", checker, StringComparison.Ordinal);
}
private static string Property(XDocument document, string name) =>
document.Descendants(name).Single().Value;
@@ -178,12 +178,17 @@ public sealed class TestClientProcessIntegrationTests
Assert.Contains(
join.JsonEvents(),
item => item.GetProperty("event").GetString() == "join.connected"
&& item.GetProperty("endpointType").GetString() is "loopback" or "private");
&& item.GetProperty("endpointType").GetString() is "loopback" or "private"
&& item.GetProperty("addressFamily").GetString() == "ipv4");
Assert.True(join.HasEvent("join.punch", "started"), join.DiagnosticText());
Assert.True(join.HasEvent("join.direct-connect", "started"), join.DiagnosticText());
Assert.True(join.HasEvent("join.direct-traffic", "verified"), join.DiagnosticText());
Assert.True(join.HasEvent("join.outcome-report", "accepted"), join.DiagnosticText());
Assert.True(host.HasEvent("host.direct-traffic", "verified"), host.DiagnosticText());
Assert.Contains(
host.JsonEvents(),
item => item.GetProperty("event").GetString() == "host.direct-traffic"
&& item.GetProperty("addressFamily").GetString() == "ipv4");
Assert.True(host.HasEvent("host.punch", "started"), host.DiagnosticText());
Assert.True(host.HasEvent("host.direct-connect", "connected"), host.DiagnosticText());
Assert.True(host.HasEvent("host.deregistered", "complete"), host.DiagnosticText());