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
@@ -211,7 +211,7 @@ func TestCanonicalAIAdmissionAndLifecycle(t *testing.T) {
command := func(board, target, model string, incarnation int64) (response, string) {
next += 2
key := modelTestID(next)
return response{"protocol_version": 2, "request_id": key, "operation_id": modelTestID(next + 1), "target_incarnation": incarnation, "node_id": target, "model_id": model, "prompt": "Generate", "parameters": response{}, "propagate": false}, key
return response{"protocol_version": 2, "request_id": key, "operation_id": modelTestID(next + 1), "target_incarnation": incarnation, "expected_versions": read().Versions, "node_id": target, "model_id": model, "prompt": "Generate", "parameters": response{}, "propagate": false}, key
}
start := func(board, target, model string, incarnation int64) response {
input, key := command(board, target, model, incarnation)
@@ -235,6 +235,7 @@ func TestCanonicalAIAdmissionAndLifecycle(t *testing.T) {
if !modelEqual(admitted, retry) {
t.Fatal("admission retry changed result")
}
call("POST", base(root)+"/ai/runs", input, 409, sourceVersion+1, key)
queried := call("GET", base(root)+"/ai/operations/"+key, nil, 200, 0, "")
if !modelEqual(admitted, queried) {
t.Fatal("lost admission response not recoverable")
@@ -364,6 +365,13 @@ func TestCanonicalAIAdmissionAndLifecycle(t *testing.T) {
if e = s.completeCanvasRun(ctx, *moving, nil); e != nil {
t.Fatal(e)
}
staleInput, staleKey := command(child, imageID, "image", 1)
staleVersions := staleInput["expected_versions"].(map[string]int64)
staleVersions[root]-- // The target version is current; its ancestor context is not.
call("POST", base(child)+"/ai/runs", staleInput, 412, read().Versions[child], staleKey)
missingInput, missingKey := command(child, imageID, "image", 1)
delete(missingInput, "expected_versions")
call("POST", base(child)+"/ai/runs", missingInput, 400, read().Versions[child], missingKey)
childRun := start(child, imageID, "image", 1)
execute(childRun["run_id"].(string))
if read().Elements[imageID]["ownerCanvasId"] != child {