Fix canonical archive writes and retain scoped lifecycle evidence
Foundry Go checks / check (push) Successful in 2m41s
Foundry Go checks / check (pull_request) Successful in 2m40s

This commit is contained in:
2026-11-07 22:34:42 +08:00
parent b85e8bd2ca
commit 12458e10dc
5 changed files with 118 additions and 22 deletions
@@ -214,4 +214,26 @@ func TestCanonicalModelMigrationAndIncrementalLifecycle(t *testing.T) {
if call("GET", base+"/model", nil, "", 200)["model"].(map[string]any)["complete"] != true {
t.Fatal("initial read has no explicit coverage")
}
// An object created and removed inside one transaction still has a lifecycle fact.
ghostID := modelTestID(4000)
ghost := modelTestNode(ghostID, root)
edit(1008, map[string]int64{root: 6}, modelChange{Kind: "element", ID: ghostID, Before: modelJSON(nil), After: modelJSON(ghost)}, modelChange{Kind: "element", ID: ghostID, Before: modelJSON(ghost), After: modelJSON(nil)})
model = read()
if model.Tombstones[ghostID] != 1 || model.Elements[ghostID] != nil {
t.Fatal("in-batch create/delete lost its tombstone")
}
ghost["incarnation"] = float64(2)
edit(1009, map[string]int64{root: 7}, modelChange{Kind: "element", ID: ghostID, Before: modelJSON(nil), After: modelJSON(ghost)})
if modelInt(read().Elements[ghostID]["incarnation"]) != 2 {
t.Fatal("restore after an in-batch delete did not preserve identity")
}
// Session changes cannot send an old account's queued request as a new account.
request := httptest.NewRequest("GET", base+"/model", nil)
request.Header.Set("Authorization", "Bearer "+token)
request.Header.Set("X-Expected-Account", modelTestID(7777))
writer := httptest.NewRecorder()
mux.ServeHTTP(writer, request)
if writer.Code != 409 {
t.Fatal("expected-account barrier was ignored")
}
}