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
+19
View File
@@ -20,6 +20,25 @@ type canvasAIChange struct {
Incarnation int64
}
// Until a narrower read-set protocol exists, admission binds every active
// canvas in this canonical project. Archived versions are not graph inputs.
// Workspace locking keeps validation, plan freezing and admission atomic.
func validateCanvasAIVersions(model canvasModel, board string, header int64, expected map[string]int64) string {
if len(expected) != len(model.Canvases) || expected[board] != header {
return "invalid_ai_versions"
}
for id := range model.Canvases {
version, ok := expected[id]
if !ok || version < 1 || version > 9007199254740991 {
return "invalid_ai_versions"
}
if version != model.Versions[id] {
return "version_conflict"
}
}
return ""
}
func prepareModelAIPatch(before canvasModel, board, node string, patch response) (canvasModel, error) {
element := before.Elements[node]
if element == nil || element["structure"] != "node" || element["ownerCanvasId"] != board || modelInt(element["dataVersion"]) != 1 || !canvasChoice(element["componentId"], "text", "script", "plain-text", "image", "plain-image") {