Bind canonical AI admission to the project version vector
This commit is contained in:
@@ -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") {
|
||||
|
||||
Reference in New Issue
Block a user