Bind canonical AI admission to the project version vector
Foundry Go checks / check (push) Successful in 2m52s
Foundry Go checks / check (pull_request) Successful in 2m58s

This commit is contained in:
2026-11-08 00:28:13 +08:00
parent fa76773efc
commit 00ff738705
4 changed files with 92 additions and 11 deletions
+39
View File
@@ -56,3 +56,42 @@ func TestCanonicalAIProjectionDoesNotExecuteFutureConnections(t *testing.T) {
t.Fatal("future connection was executed or removed")
}
}
func TestCanonicalAIAdmissionVersions(t *testing.T) {
model := modelTestDocument()
model.Canvases[modelChildID] = modelCanvas{ID: modelChildID}
model.Versions[modelChildID] = 3
// Include an archived version: it must not become an executable read dependency.
model.Versions["archived"] = 8
valid := map[string]int64{}
for id := range model.Canvases {
valid[id] = model.Versions[id]
}
if code := validateCanvasAIVersions(model, modelRootID, valid[modelRootID], valid); code != "" {
t.Fatal(code)
}
for _, test := range []struct {
name string
versions map[string]int64
header int64
want string
}{
{"missing", nil, 1, "invalid_ai_versions"},
{"changed-header", valid, 99, "invalid_ai_versions"},
{"incomplete", map[string]int64{modelRootID: 1}, 1, "invalid_ai_versions"},
} {
t.Run(test.name, func(t *testing.T) {
if got := validateCanvasAIVersions(model, modelRootID, test.header, test.versions); got != test.want {
t.Fatalf("got %q want %q", got, test.want)
}
})
}
stale := map[string]int64{}
for id, version := range valid {
stale[id] = version
}
stale[modelChildID]++
if code := validateCanvasAIVersions(model, modelRootID, valid[modelRootID], stale); code != "version_conflict" {
t.Fatal(code)
}
}