diff --git a/brokkr-ctl/src/blender.rs b/brokkr-ctl/src/blender.rs index e404585..dc47866 100644 --- a/brokkr-ctl/src/blender.rs +++ b/brokkr-ctl/src/blender.rs @@ -278,6 +278,20 @@ fn wait_for_receipt( } None => { println!("status: timeout"); + // The add-on deletes an intent when it claims it, before it runs, so the queue says which timeout this is. + let key = format!("{INTENT_PREFIX}{id}"); + let queued = store + .pull_all()? + .iter() + .any(|e| e.key == key && e.r#type == INTENT_SCHEMA); + println!( + "message: {}", + if queued { + "the intent is still queued: Blender has not claimed it (is Agent Commands on and the add-on running?); it has not run" + } else { + "Blender claimed the intent but wrote no receipt: it may or may not have run; look at the scene before sending it again" + } + ); Ok(Outcome::Timeout.code()) } } @@ -412,7 +426,8 @@ brokkr-ctl blender: send typed intents to the live Blender add-on and read what Every command needs --store or $BROKKR_BLENDER_STORE (the add-on's .ccmp). send needs $EUREKA_INSTANCE and --agent or $BROKKR_AGENT; requestedBy is '/'. Output is 'key: value' lines. Exit: 0 accepted, 2 denied or failed, 3 stopped, 4 timeout, -1 usage or store error. send refuses an intent the action table refuses (exit 1, nothing written); +1 usage or store error. On timeout a message says whether the intent is still queued (not run) or was claimed by +Blender with no receipt (it may or may not have run). send refuses an intent the action table refuses (exit 1, nothing written); the add-on decides the rest and its refusal comes back in the receipt. " .to_string() diff --git a/brokkr-ctl/tests/cli.rs b/brokkr-ctl/tests/cli.rs index 59d0444..9936d7f 100644 --- a/brokkr-ctl/tests/cli.rs +++ b/brokkr-ctl/tests/cli.rs @@ -162,6 +162,27 @@ fn wait_matches_the_exact_receipt_key() { assert!(stdout(&output).contains("status: timeout")); } +/// Exit 4 is two situations the sender must tell apart: the intent was never claimed (still in the queue, not run), +/// or Blender claimed it (deleted it from the queue) and no receipt landed (it may have run). +#[test] +fn a_timeout_says_whether_the_intent_is_still_queued_or_was_claimed() { + let dir = tempfile::tempdir().unwrap(); + let path = store_with_receipts(dir.path(), &[("seed", "accepted")]); + let sent = ctl(&path, &["send", "createObject", "--agent", "hands", "--timeout", "0.3"], Some("nibu")); + assert_eq!(sent.status.code(), Some(4)); + let text = stdout(&sent); + assert!(text.contains("status: timeout") && text.contains("still queued") && text.contains("it has not run"), "{text}"); + let id = text.lines().find_map(|l| l.strip_prefix("commandId: ")).unwrap().to_string(); + // Blender claims it: the intent leaves the queue, and no receipt is written + let mut store = SingleFileMessagePackBackingStore::new(&path); + let queued = store.pull_all().unwrap().into_iter().find(|e| e.key == format!("blender/commands/{id}")).unwrap(); + store.delete(&queued).unwrap(); + let waited = ctl(&path, &["wait", &id, "--timeout", "0.3"], None); + assert_eq!(waited.status.code(), Some(4)); + let text = stdout(&waited); + assert!(text.contains("claimed the intent but wrote no receipt") && text.contains("may or may not have run"), "{text}"); +} + #[test] fn exit_code_follows_the_receipt() { let dir = tempfile::tempdir().unwrap(); diff --git a/surfaces/blender/brokkr_bridge/action_table.py b/surfaces/blender/brokkr_bridge/action_table.py index dafbe9e..3ecaa2f 100644 --- a/surfaces/blender/brokkr_bridge/action_table.py +++ b/surfaces/blender/brokkr_bridge/action_table.py @@ -117,7 +117,8 @@ def _check_spec(spec: dict[str, Any], where: str, charsets: dict, siblings: dict def validate(command: dict[str, Any]) -> dict[str, Any]: - """The normalized copy of an intent (nulls dropped, defaults filled), or IntentInvalid naming the rule.""" + """The normalized copy of an intent (nulls dropped, whole numbers of integer fields as int, defaults filled), or + IntentInvalid naming the rule. It raises nothing else, whatever the document holds.""" action = command.get("action", "") row = entry(action) if row is None: @@ -126,6 +127,8 @@ def validate(command: dict[str, Any]) -> dict[str, Any]: _fields(row["fields"], present, None, action, set(table()["envelope"])) result = dict(present) for field in row["fields"]: + if field["type"] == "integer" and field["name"] in result: + result[field["name"]] = int(result[field["name"]]) # a whole float (1920.0) is the same intent; Blender refuses a float for an int property if field["name"] not in result and "default" in field: result[field["name"]] = field["default"] return result @@ -135,7 +138,7 @@ def _fields(specs: list[dict[str, Any]], values: dict[str, Any], parent: str | N """The fields of an action (parent None) or of a closed object: unknown names first, sorted, then each declared field in table order.""" declared = [s["name"] for s in specs] - for key in sorted(k for k in values if k not in skip and k not in declared): + for key in sorted((k for k in values if k not in skip and k not in declared), key=str): # str: a store writer may mix key types raise IntentInvalid(f"{where} has no field '{key}'; its fields: {_list(declared) or 'none'}.") for spec in specs: path = spec["name"] if parent is None else f"{parent}.{spec['name']}" diff --git a/surfaces/blender/brokkr_bridge/blender_target.py b/surfaces/blender/brokkr_bridge/blender_target.py index 4ab155d..f87da9c 100644 --- a/surfaces/blender/brokkr_bridge/blender_target.py +++ b/surfaces/blender/brokkr_bridge/blender_target.py @@ -775,6 +775,11 @@ class BrokkrBlenderTarget: parent = self.bpy.data.objects.get(parent_name) if parent_name else None if parent_name and parent is None: return self._receipt(command, "failed", f"Parent Blender object was not found: {parent_name}", obj.name) + ancestor = parent + while ancestor is not None: # Blender raises for a loop after the undo step is owed: refuse it before + if ancestor.name == obj.name: + raise sa.ActionRefused(f"{obj.name!r} cannot be parented to itself or to one of its own children.") + ancestor = getattr(ancestor, "parent", None) obj.parent = parent return self._receipt(command, "accepted", "Blender object parent updated.", obj.name) diff --git a/surfaces/blender/docs/install.md b/surfaces/blender/docs/install.md index 337b2e3..1bd94b9 100644 --- a/surfaces/blender/docs/install.md +++ b/surfaces/blender/docs/install.md @@ -41,6 +41,11 @@ blender --command extension build --source-dir surfaces/blender/brokkr_bridge -- blender --command extension install-file --repo user_default --enable /brokkr_bridge-0.2.0.zip ``` +To try a build without touching your own Blender, run both commands (and any live test) with private +`BLENDER_USER_CONFIG`, `BLENDER_USER_EXTENSIONS` and `BLENDER_USER_SCRIPTS` directories set. Blender 5.3 ignores +`BLENDER_USER_RESOURCE_PATH`, so `install-file` under it replaces the `user_default` copy in your own extensions +folder. The live tests refuse to start without the three variables. + The wheel is one pure-Python msgpack, so the extension carries no platform restriction (Blender 5.3 or newer, any OS). msgpack then runs its pure-Python fallback, which CultLib `9fc4bdda` (PR #180) decodes. diff --git a/surfaces/blender/tests/action_cases.json b/surfaces/blender/tests/action_cases.json index fb5a8e0..2c082f1 100644 --- a/surfaces/blender/tests/action_cases.json +++ b/surfaces/blender/tests/action_cases.json @@ -229,5 +229,10 @@ {"action": "unlinkSockets", "fields": {"treeKey": "G", "toNode": "b", "toSocket": "i"}, "expect": "ok"}, {"action": "addModifier", "fields": {"objectName": "o", "treeKey": "G"}, "expect": "ok"}, {"action": "removeModifier", "fields": {"objectName": "o"}, "expect": "ok"}, - {"action": "setModifierInput", "fields": {"objectName": "o", "socket": "s", "value": 1}, "expect": "ok"} + {"action": "setModifierInput", "fields": {"objectName": "o", "socket": "s", "value": 1}, "expect": "ok"}, + {"action": "renderStill", "fields": {"outputPath": "a.png", "resolutionX": 1920.0, "resolutionY": 1080.0}, "expect": "ok"}, + {"action": "renderStill", "fields": {"outputPath": "a.png", "resolutionY": 4.0}, "expect": "ok"}, + {"action": "renderStill", "fields": {"outputPath": "a.png", "resolutionX": 3.0}, "expect": "resolutionX must be between 4 and 16384."}, + {"action": "renderStill", "fields": {"outputPath": "a.png", "resolutionX": 1920.5}, "expect": "resolutionX must be a whole number."}, + {"action": "renderStill", "fields": {"outputPath": "a.png", "resolutionY": 16384.0}, "expect": "ok"} ] diff --git a/surfaces/blender/tests/live/action_table.py b/surfaces/blender/tests/live/action_table.py index 0c3967a..24db485 100644 --- a/surfaces/blender/tests/live/action_table.py +++ b/surfaces/blender/tests/live/action_table.py @@ -5,10 +5,9 @@ BROKKR_CULTLIB= blender --python action_table.py -- -Run it in a Blender with private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories -(this Blender build ignores BLENDER_USER_RESOURCE_PATH, so `extension install-file` would land in the operator's own -extensions folder), the extension installed there with `blender --command extension install-file --repo user_default ---enable ` under the same variables. Every intent is put into the node +Run it in Blender with private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories +(Blender 5.3 ignores BLENDER_USER_RESOURCE_PATH; without them the operator's own extensions folder is used). The script +refuses to run when they are unset. Every intent is put into the node database as brokkr-ctl does and answered by the add-on's own 1 s drain (the sink is on). For every action in actions.json: * malformed intents generated from its table entry (an unknown field, a wrong type, an enum miss, a bound miss, @@ -29,6 +28,14 @@ from pathlib import Path import bpy +import os as _os + +for _name in ("BLENDER_USER_CONFIG", "BLENDER_USER_EXTENSIONS", "BLENDER_USER_SCRIPTS"): + if not _os.environ.get(_name): # this Blender ignores BLENDER_USER_RESOURCE_PATH: without these, her own extensions folder is used + raise SystemExit(f"{_name} is not set: run this in private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories") +if _os.path.normcase(_os.path.abspath(bpy.utils.user_resource("EXTENSIONS"))) != _os.path.normcase(_os.path.abspath(_os.environ["BLENDER_USER_EXTENSIONS"])): + raise SystemExit("Blender's extensions folder is not BLENDER_USER_EXTENSIONS; refusing to touch it") + SCRATCH = Path(os.environ["BROKKR_SCRATCH"]).resolve() SCRATCH.mkdir(parents=True, exist_ok=True) OUT = sys.argv[sys.argv.index("--") + 1] @@ -142,7 +149,7 @@ SAMPLES = [ # (action, prep intents queued and run unmeasured first, the valid ("setCamera", [], {"targetObjectName": "Camera", "lens": 35, "cameraType": "PANO", "panoramaType": "FISHEYE_EQUIDISTANT", "active": True}), ("setLight", [], {"targetObjectName": "Light", "energy": 500, "color": [1, 0.5, 0], "lightType": "SUN"}), ("setWorld", [], {"color": [0.1, 0.1, 0.2], "strength": 1.5}), - ("renderStill", [], {"outputPath": "live.png", "engine": "CYCLES", "resolutionX": 8, "resolutionY": 8}), + ("renderStill", [], {"outputPath": "live.png", "engine": "CYCLES", "resolutionX": 8.0, "resolutionY": 8}), # a whole float: the table hands Blender an int ("look", [], {}), ("createNodeGroup", [], {"treeKey": "LiveG", "interface": [{"inOut": "INPUT", "name": "Geometry", "type": "Geometry"}, {"inOut": "OUTPUT", "name": "Geometry", "type": "Geometry"}, diff --git a/surfaces/blender/tests/live/action_table.result.json b/surfaces/blender/tests/live/action_table.result.json index b21b4c1..981a3a6 100644 --- a/surfaces/blender/tests/live/action_table.result.json +++ b/surfaces/blender/tests/live/action_table.result.json @@ -24,7 +24,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: createObject ive-0001", "lookPath": "", - "observedAt": "2026-11-28T01:56:40.145813+00:00" + "observedAt": "2026-11-28T02:36:27.076161+00:00" } }, { @@ -72,7 +72,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: createObject ive-0024", "lookPath": "", - "observedAt": "2026-11-28T01:56:45.785882+00:00" + "observedAt": "2026-11-28T02:36:32.724431+00:00" } }, { @@ -104,7 +104,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: createObject ive-0026", "lookPath": "", - "observedAt": "2026-11-28T01:56:49.944500+00:00" + "observedAt": "2026-11-28T02:36:36.860973+00:00" } }, { @@ -156,7 +156,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: deleteObject ive-0030", "lookPath": "", - "observedAt": "2026-11-28T01:56:54.485651+00:00" + "observedAt": "2026-11-28T02:36:41.174327+00:00" } }, { @@ -188,7 +188,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: createObject ive-0031", "lookPath": "", - "observedAt": "2026-11-28T01:56:56.566254+00:00" + "observedAt": "2026-11-28T02:36:43.258961+00:00" } }, { @@ -238,7 +238,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: setObjectTransform ive-0053", "lookPath": "", - "observedAt": "2026-11-28T01:57:03.202116+00:00" + "observedAt": "2026-11-28T02:36:49.152690+00:00" } }, { @@ -270,7 +270,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: createObject ive-0054", "lookPath": "", - "observedAt": "2026-11-28T01:57:05.306686+00:00" + "observedAt": "2026-11-28T02:36:51.255025+00:00" } }, { @@ -320,7 +320,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: setObjectVisibility ive-0059", "lookPath": "", - "observedAt": "2026-11-28T01:57:09.874099+00:00" + "observedAt": "2026-11-28T02:36:55.787695+00:00" } }, { @@ -352,7 +352,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: createObject ive-0060", "lookPath": "", - "observedAt": "2026-11-28T01:57:11.974525+00:00" + "observedAt": "2026-11-28T02:36:57.891977+00:00" } }, { @@ -402,7 +402,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: setObjectParent ive-0065", "lookPath": "", - "observedAt": "2026-11-28T01:57:16.563563+00:00" + "observedAt": "2026-11-28T02:37:02.443984+00:00" } }, { @@ -434,7 +434,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: createObject ive-0066", "lookPath": "", - "observedAt": "2026-11-28T01:57:18.681337+00:00" + "observedAt": "2026-11-28T02:37:04.556676+00:00" } }, { @@ -484,7 +484,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: setObjectCustomProperty ive-0072", "lookPath": "", - "observedAt": "2026-11-28T01:57:22.508309+00:00" + "observedAt": "2026-11-28T02:37:09.259197+00:00" } }, { @@ -516,7 +516,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: createObject ive-0073", "lookPath": "", - "observedAt": "2026-11-28T01:57:24.630024+00:00" + "observedAt": "2026-11-28T02:37:11.382979+00:00" } }, { @@ -566,7 +566,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: selectObject ive-0078", "lookPath": "", - "observedAt": "2026-11-28T01:57:29.310576+00:00" + "observedAt": "2026-11-28T02:37:16.017922+00:00" } }, { @@ -598,7 +598,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: createObject ive-0079", "lookPath": "", - "observedAt": "2026-11-28T01:57:31.515585+00:00" + "observedAt": "2026-11-28T02:37:18.151455+00:00" } }, { @@ -648,7 +648,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: assignMaterial ive-0090", "lookPath": "", - "observedAt": "2026-11-28T01:57:37.550809+00:00" + "observedAt": "2026-11-28T02:37:23.926592+00:00" } }, { @@ -680,7 +680,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: createObject ive-0091", "lookPath": "", - "observedAt": "2026-11-28T01:57:39.704717+00:00" + "observedAt": "2026-11-28T02:37:26.063118+00:00" } }, { @@ -730,7 +730,7 @@ "note": "", "undoLabel": "", "lookPath": "", - "observedAt": "2026-11-28T01:57:48.919027+00:00" + "observedAt": "2026-11-28T02:37:33.358972+00:00" } }, { @@ -757,7 +757,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: createObject ive-0103", "lookPath": "", - "observedAt": "2026-11-28T01:57:51.228716+00:00" + "observedAt": "2026-11-28T02:37:35.528127+00:00" } }, { @@ -807,7 +807,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: importGltf ive-0107", "lookPath": "", - "observedAt": "2026-11-28T01:57:56.255504+00:00" + "observedAt": "2026-11-28T02:37:40.218377+00:00" } }, { @@ -839,7 +839,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: createObject ive-0108", "lookPath": "", - "observedAt": "2026-11-28T01:57:58.437908+00:00" + "observedAt": "2026-11-28T02:37:42.369543+00:00" } }, { @@ -895,7 +895,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: setCamera ive-0129", "lookPath": "", - "observedAt": "2026-11-28T01:58:11.054773+00:00" + "observedAt": "2026-11-28T02:37:54.650323+00:00" } }, { @@ -927,7 +927,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: createObject ive-0130", "lookPath": "", - "observedAt": "2026-11-28T01:58:13.248452+00:00" + "observedAt": "2026-11-28T02:37:56.820173+00:00" } }, { @@ -983,7 +983,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: setLight ive-0145", "lookPath": "", - "observedAt": "2026-11-28T01:58:22.382198+00:00" + "observedAt": "2026-11-28T02:38:05.386213+00:00" } }, { @@ -1015,7 +1015,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: createObject ive-0146", "lookPath": "", - "observedAt": "2026-11-28T01:58:24.582227+00:00" + "observedAt": "2026-11-28T02:38:07.578985+00:00" } }, { @@ -1071,7 +1071,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: setWorld ive-0158", "lookPath": "", - "observedAt": "2026-11-28T01:58:31.393393+00:00" + "observedAt": "2026-11-28T02:38:14.740238+00:00" } }, { @@ -1103,7 +1103,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: createObject ive-0159", "lookPath": "", - "observedAt": "2026-11-28T01:58:33.598048+00:00" + "observedAt": "2026-11-28T02:38:16.953350+00:00" } }, { @@ -1159,7 +1159,7 @@ "note": "", "undoLabel": "", "lookPath": "", - "observedAt": "2026-11-28T01:58:44.631878+00:00" + "observedAt": "2026-11-28T02:38:28.064380+00:00" } }, { @@ -1186,7 +1186,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: createObject ive-0174", "lookPath": "", - "observedAt": "2026-11-28T01:58:47.857036+00:00" + "observedAt": "2026-11-28T02:38:31.281935+00:00" } }, { @@ -1242,10 +1242,10 @@ "note": "", "undoLabel": "", "lookPath": "F:\\aeth-wt\\brokkr-action-table-live\\scratch\\out\\look\\live-0177.png", - "observedAt": "2026-11-28T01:58:53.654873+00:00", + "observedAt": "2026-11-28T02:38:37.045877+00:00", "captureSource": "region", "sceneUpdateSeq": 95, - "sessionId": "3b3d62619afb43d0a8548fc3f2ce4a4f", + "sessionId": "0cc3e9cdaf454a249a30cc24e617581c", "humanEditSeq": 83, "humanEditsSinceLook": 83, "editedSinceLook": [ @@ -1288,7 +1288,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: createObject ive-0178", "lookPath": "", - "observedAt": "2026-11-28T01:58:56.864241+00:00" + "observedAt": "2026-11-28T02:38:39.309535+00:00" } }, { @@ -1344,7 +1344,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: createNodeGroup ive-0193", "lookPath": "", - "observedAt": "2026-11-28T01:59:10.270729+00:00" + "observedAt": "2026-11-28T02:38:51.073058+00:00" } }, { @@ -1376,7 +1376,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: createObject ive-0194", "lookPath": "", - "observedAt": "2026-11-28T01:59:12.510947+00:00" + "observedAt": "2026-11-28T02:38:53.324909+00:00" } }, { @@ -1432,7 +1432,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: addNode ive-0223", "lookPath": "", - "observedAt": "2026-11-28T01:59:47.731039+00:00" + "observedAt": "2026-11-28T02:39:29.096510+00:00" } }, { @@ -1464,7 +1464,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: createObject ive-0224", "lookPath": "", - "observedAt": "2026-11-28T01:59:49.993525+00:00" + "observedAt": "2026-11-28T02:39:31.428197+00:00" } }, { @@ -1520,7 +1520,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: linkSockets ive-0247", "lookPath": "", - "observedAt": "2026-11-28T02:00:17.375246+00:00" + "observedAt": "2026-11-28T02:39:59.079008+00:00" } }, { @@ -1552,7 +1552,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: createObject ive-0248", "lookPath": "", - "observedAt": "2026-11-28T02:00:19.737999+00:00" + "observedAt": "2026-11-28T02:40:01.374248+00:00" } }, { @@ -1608,7 +1608,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: unlinkSockets ive-0269", "lookPath": "", - "observedAt": "2026-11-28T02:00:45.997967+00:00" + "observedAt": "2026-11-28T02:40:29.839429+00:00" } }, { @@ -1640,7 +1640,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: createObject ive-0270", "lookPath": "", - "observedAt": "2026-11-28T02:00:48.315493+00:00" + "observedAt": "2026-11-28T02:40:32.156639+00:00" } }, { @@ -1696,7 +1696,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: removeNode ive-0284", "lookPath": "", - "observedAt": "2026-11-28T02:01:03.364715+00:00" + "observedAt": "2026-11-28T02:40:48.986174+00:00" } }, { @@ -1728,7 +1728,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: createObject ive-0285", "lookPath": "", - "observedAt": "2026-11-28T02:01:05.767376+00:00" + "observedAt": "2026-11-28T02:40:51.316429+00:00" } }, { @@ -1784,7 +1784,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: addModifier ive-0302", "lookPath": "", - "observedAt": "2026-11-28T02:01:26.890644+00:00" + "observedAt": "2026-11-28T02:41:12.934572+00:00" } }, { @@ -1816,7 +1816,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: createObject ive-0303", "lookPath": "", - "observedAt": "2026-11-28T02:01:29.307569+00:00" + "observedAt": "2026-11-28T02:41:15.376364+00:00" } }, { @@ -1872,7 +1872,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: setModifierInput ive-0311", "lookPath": "", - "observedAt": "2026-11-28T02:01:37.160827+00:00" + "observedAt": "2026-11-28T02:41:23.279634+00:00" } }, { @@ -1894,7 +1894,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: createObject ive-0312", "lookPath": "", - "observedAt": "2026-11-28T02:01:39.514028+00:00" + "observedAt": "2026-11-28T02:41:25.653006+00:00" } }, { @@ -1950,7 +1950,7 @@ "note": "", "undoLabel": "Brokkr nibu/hands: removeModifier ive-0320", "lookPath": "", - "observedAt": "2026-11-28T02:01:47.535687+00:00" + "observedAt": "2026-11-28T02:41:34.791771+00:00" } }, { diff --git a/surfaces/blender/tests/live/agent_turn_queue.py b/surfaces/blender/tests/live/agent_turn_queue.py index 5f8a68c..aa0204b 100644 --- a/surfaces/blender/tests/live/agent_turn_queue.py +++ b/surfaces/blender/tests/live/agent_turn_queue.py @@ -8,6 +8,7 @@ are drained by the add-on's own 1 s timer as one undo step each, with write-once BROKKR_CULTLIB= BROKKR_PYLIBS= + Private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS are required (refused otherwise). blender --factory-startup --python agent_turn_queue.py -- Intents are put into the node database as brokkr-ctl does; a command JSON dropped under the debug @@ -23,6 +24,14 @@ from pathlib import Path import bpy +import os as _os + +for _name in ("BLENDER_USER_CONFIG", "BLENDER_USER_EXTENSIONS", "BLENDER_USER_SCRIPTS"): + if not _os.environ.get(_name): # this Blender ignores BLENDER_USER_RESOURCE_PATH: without these, her own extensions folder is used + raise SystemExit(f"{_name} is not set: run this in private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories") +if _os.path.normcase(_os.path.abspath(bpy.utils.user_resource("EXTENSIONS"))) != _os.path.normcase(_os.path.abspath(_os.environ["BLENDER_USER_EXTENSIONS"])): + raise SystemExit("Blender's extensions folder is not BLENDER_USER_EXTENSIONS; refusing to touch it") + if os.environ.get("BROKKR_PYLIBS"): sys.path.insert(0, os.environ["BROKKR_PYLIBS"]) SCRATCH = Path(os.environ["BROKKR_SCRATCH"]).resolve() diff --git a/surfaces/blender/tests/live/agent_turn_undo.py b/surfaces/blender/tests/live/agent_turn_undo.py index c8bec53..8347907 100644 --- a/surfaces/blender/tests/live/agent_turn_undo.py +++ b/surfaces/blender/tests/live/agent_turn_undo.py @@ -1,4 +1,6 @@ """Live proof, in GUI Blender, that every agent intent is one undo step. +Launch Blender with private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories +(Blender 5.3 ignores BLENDER_USER_RESOURCE_PATH); see docs/install.md. BROKKR_ADDON= \ blender --factory-startup --python agent_turn_undo.py -- diff --git a/surfaces/blender/tests/live/export_gltf.py b/surfaces/blender/tests/live/export_gltf.py index ff9e0bc..e133e7a 100644 --- a/surfaces/blender/tests/live/export_gltf.py +++ b/surfaces/blender/tests/live/export_gltf.py @@ -1,4 +1,6 @@ """Live proof of exportGltf on real bpy: the option names exist on the real exporter, extras reach the +Launch Blender with private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories +(Blender 5.3 ignores BLENDER_USER_RESOURCE_PATH); see docs/install.md. file, selection filters, .gltf writes its .bin and textures without overwriting, a refused or failed export leaves nothing behind. diff --git a/surfaces/blender/tests/live/gn_actions.py b/surfaces/blender/tests/live/gn_actions.py index b5b2e0e..87eda23 100644 --- a/surfaces/blender/tests/live/gn_actions.py +++ b/surfaces/blender/tests/live/gn_actions.py @@ -1,4 +1,6 @@ """Live proof of the node-graph actions: rebuild three geometry-node setups through Brokkr actions only. +Launch Blender with private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories +(Blender 5.3 ignores BLENDER_USER_RESOURCE_PATH); see docs/install.md. BROKKR_ADDON= \ blender -b --factory-startup --python gn_actions.py -- result.json diff --git a/surfaces/blender/tests/live/gn_recreation.py b/surfaces/blender/tests/live/gn_recreation.py index c7dc47d..2281812 100644 --- a/surfaces/blender/tests/live/gn_recreation.py +++ b/surfaces/blender/tests/live/gn_recreation.py @@ -1,4 +1,6 @@ """Recreate geometry-node setups through the Brokkr scene/object actions and compare with the native result. +Launch Blender with private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories +(Blender 5.3 ignores BLENDER_USER_RESOURCE_PATH); see docs/install.md. BROKKR_ADDON= \ blender -b --factory-startup --python gn_recreation.py -- result.json diff --git a/surfaces/blender/tests/live/headless_smoke.py b/surfaces/blender/tests/live/headless_smoke.py index 1d21601..40e6fff 100644 --- a/surfaces/blender/tests/live/headless_smoke.py +++ b/surfaces/blender/tests/live/headless_smoke.py @@ -1,4 +1,6 @@ """Live Blender smoke for the scene actions. Not part of the unittest run: it needs Blender. +Launch Blender with private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories +(Blender 5.3 ignores BLENDER_USER_RESOURCE_PATH); see docs/install.md. BROKKR_RUN= BROKKR_ADDON= \ blender --background --factory-startup --python surfaces/blender/tests/live/headless_smoke.py diff --git a/surfaces/blender/tests/live/material_colour.py b/surfaces/blender/tests/live/material_colour.py index 07c2f4d..d31533d 100644 --- a/surfaces/blender/tests/live/material_colour.py +++ b/surfaces/blender/tests/live/material_colour.py @@ -1,4 +1,6 @@ """Live proof of assignMaterial colour and idempotence on real bpy. +Launch Blender with private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories +(Blender 5.3 ignores BLENDER_USER_RESOURCE_PATH); see docs/install.md. BROKKR_ADDON= \ blender -b --factory-startup --python material_colour.py -- result.json diff --git a/surfaces/blender/tests/live/perception.py b/surfaces/blender/tests/live/perception.py index a62aeb8..7523763 100644 --- a/surfaces/blender/tests/live/perception.py +++ b/surfaces/blender/tests/live/perception.py @@ -6,7 +6,9 @@ BROKKR_CULTLIB= blender --python perception.py -- -Run it in a Blender whose resource path is fresh (BLENDER_USER_RESOURCE_PATH) so the add-on's preferences are the +Run it in Blender with private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories +(Blender 5.3 ignores BLENDER_USER_RESOURCE_PATH; without them the operator's own extensions folder is used). The script +refuses to run when they are unset. The add-on's preferences are then the defaults. The driver stands in for the operator's hands only: it saves the blend, ticks the sink and sets the render output directory (the two preferences an operator sets), enters Edit Mode, selects, moves objects and presses undo. Every intent is sent by brokkr-ctl and answered by the add-on's own timer. Writes .result.json, then quits. @@ -25,6 +27,14 @@ from pathlib import Path import bmesh import bpy +import os as _os + +for _name in ("BLENDER_USER_CONFIG", "BLENDER_USER_EXTENSIONS", "BLENDER_USER_SCRIPTS"): + if not _os.environ.get(_name): # this Blender ignores BLENDER_USER_RESOURCE_PATH: without these, her own extensions folder is used + raise SystemExit(f"{_name} is not set: run this in private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories") +if _os.path.normcase(_os.path.abspath(bpy.utils.user_resource("EXTENSIONS"))) != _os.path.normcase(_os.path.abspath(_os.environ["BLENDER_USER_EXTENSIONS"])): + raise SystemExit("Blender's extensions folder is not BLENDER_USER_EXTENSIONS; refusing to touch it") + SCRATCH = Path(os.environ["BROKKR_SCRATCH"]).resolve() SCRATCH.mkdir(parents=True, exist_ok=True) CTL = os.environ["BROKKR_CTL"] diff --git a/surfaces/blender/tests/live/perception_fixes.py b/surfaces/blender/tests/live/perception_fixes.py index 7facba2..d535a51 100644 --- a/surfaces/blender/tests/live/perception_fixes.py +++ b/surfaces/blender/tests/live/perception_fixes.py @@ -1,6 +1,6 @@ """Live proof of the live-5 fix batch, in GUI Blender with the add-on installed as an extension, real brokkr-ctl looks. -Same environment as perception.py (BROKKR_SCRATCH, BROKKR_CTL, BROKKR_CULTLIB; a fresh BLENDER_USER_RESOURCE_PATH). +Same environment as perception.py (BROKKR_SCRATCH, BROKKR_CTL, BROKKR_CULTLIB; private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS; the script refuses to run without them). blender --python perception_fixes.py -- The driver stands in for the operator: it saves the blend, ticks the sink, sets the output directory, minimises and restores the Blender window (Windows ShowWindow on this process's own window), moves objects, enters Edit Mode. @@ -19,6 +19,14 @@ from pathlib import Path import bmesh import bpy + +import os as _os + +for _name in ("BLENDER_USER_CONFIG", "BLENDER_USER_EXTENSIONS", "BLENDER_USER_SCRIPTS"): + if not _os.environ.get(_name): # this Blender ignores BLENDER_USER_RESOURCE_PATH: without these, her own extensions folder is used + raise SystemExit(f"{_name} is not set: run this in private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories") +if _os.path.normcase(_os.path.abspath(bpy.utils.user_resource("EXTENSIONS"))) != _os.path.normcase(_os.path.abspath(_os.environ["BLENDER_USER_EXTENSIONS"])): + raise SystemExit("Blender's extensions folder is not BLENDER_USER_EXTENSIONS; refusing to touch it") import numpy SCRATCH = Path(os.environ["BROKKR_SCRATCH"]).resolve() diff --git a/surfaces/blender/tests/live/refusals.py b/surfaces/blender/tests/live/refusals.py index 16823cb..a7292ad 100644 --- a/surfaces/blender/tests/live/refusals.py +++ b/surfaces/blender/tests/live/refusals.py @@ -1,4 +1,6 @@ """Live proof of the renderStill GL refusal and the createObject meshType refusal on real bpy. +Launch Blender with private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories +(Blender 5.3 ignores BLENDER_USER_RESOURCE_PATH); see docs/install.md. BROKKR_ADDON= \ blender -b --factory-startup --python refusals.py -- result.json diff --git a/surfaces/blender/tests/live/stop_presence.py b/surfaces/blender/tests/live/stop_presence.py index b1889f8..9e0c8a3 100644 --- a/surfaces/blender/tests/live/stop_presence.py +++ b/surfaces/blender/tests/live/stop_presence.py @@ -4,6 +4,7 @@ BROKKR_CTL= BROKKR_ADDON_MODULE= BROKKR_CULTLIB= + Private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS are required (refused otherwise). blender --factory-startup --python stop_presence.py -- Run a second Blender on the same store with BROKKR_PHASE=closed for the sink-off, node-closed answer. @@ -23,6 +24,14 @@ from pathlib import Path import bpy +import os as _os + +for _name in ("BLENDER_USER_CONFIG", "BLENDER_USER_EXTENSIONS", "BLENDER_USER_SCRIPTS"): + if not _os.environ.get(_name): # this Blender ignores BLENDER_USER_RESOURCE_PATH: without these, her own extensions folder is used + raise SystemExit(f"{_name} is not set: run this in private BLENDER_USER_CONFIG, BLENDER_USER_EXTENSIONS and BLENDER_USER_SCRIPTS directories") +if _os.path.normcase(_os.path.abspath(bpy.utils.user_resource("EXTENSIONS"))) != _os.path.normcase(_os.path.abspath(_os.environ["BLENDER_USER_EXTENSIONS"])): + raise SystemExit("Blender's extensions folder is not BLENDER_USER_EXTENSIONS; refusing to touch it") + SCRATCH = Path(os.environ["BROKKR_SCRATCH"]).resolve() SCRATCH.mkdir(parents=True, exist_ok=True) CTL = os.environ["BROKKR_CTL"] diff --git a/surfaces/blender/tests/test_action_table.py b/surfaces/blender/tests/test_action_table.py index d548b1b..858920a 100644 --- a/surfaces/blender/tests/test_action_table.py +++ b/surfaces/blender/tests/test_action_table.py @@ -78,6 +78,37 @@ class ParityFixtureTests(unittest.TestCase): self.assertNotEqual([c for c in CASES if validate(c["action"], c["fields"]) != c["expect"]], [], mutant.__name__) +class NormalizationTests(unittest.TestCase): + def test_a_whole_float_for_an_integer_field_reaches_the_handler_as_an_int(self): + normal = at.validate({"action": "renderStill", "outputPath": "a.png", "resolutionX": 1920.0, "resolutionY": 4.0}) + self.assertEqual((normal["resolutionX"], normal["resolutionY"]), (1920, 4)) + self.assertIs(type(normal["resolutionX"]), int) + + def test_validate_never_raises_whatever_the_document_holds(self): + """A store writer outside brokkr-ctl can put anything in an intent; the drain has already claimed it, so a raise + here would lose the intent without a receipt. Every hostile shape ends as ok or IntentInvalid.""" + hostile = [ + {"action": "createObject", 1: "a", "zz": "b"}, + {"action": "createObject", (1, 2): 1, None: 2, "zz": 3}, + {"action": "createNodeGroup", "treeKey": "G", "interface": [{1: "a", "name": "x", "inOut": "INPUT", "type": "Int"}]}, + {"action": "createNodeGroup", "treeKey": "G", "interface": [{"inOut": "INPUT", "name": "x", "type": "Int", 5: 6, None: 7}]}, + {"action": ["createObject"]}, {"action": {"a": 1}}, {"action": None}, {"action": 7}, {}, + {"action": "createObject", "location": [10 ** 400, float("nan"), float("inf")]}, + {"action": "renderStill", "outputPath": b"bytes", "resolutionX": 10 ** 400}, + {"action": "renderStill", "outputPath": "a.png", "resolutionX": float("inf")}, + {"action": "addNode", "treeKey": "G", "id": "a", "blIdname": "ShaderNodeMath", "properties": {1: 2, (3,): 4}}, + {"action": "createObject", "objectType": ["MESH"]}, {"action": "createObject", "objectType": {"a": 1}}, + {"action": "setObjectCustomProperty", "targetObjectName": "c", "value": object()}, + ] + for command in hostile: + try: + at.validate(command) + except at.IntentInvalid: + pass + except Exception as error: # noqa: BLE001 + self.fail(f"{command!r} raised {error!r}") + + class HandlerCoverageTests(unittest.TestCase): def test_each_table_action_resolves_to_exactly_one_handler_and_each_handler_has_an_entry(self): names = [a["name"] for a in at.table()["actions"]] diff --git a/surfaces/blender/tests/test_agent_turn.py b/surfaces/blender/tests/test_agent_turn.py index 9f23465..b9fa12e 100644 --- a/surfaces/blender/tests/test_agent_turn.py +++ b/surfaces/blender/tests/test_agent_turn.py @@ -310,6 +310,25 @@ class DrainTests(unittest.TestCase): self.assertEqual(denial["status"], "denied") self.assertEqual(sorted(node.deleted), ["blender/commands/a", "blender/commands/b"]) + def test_a_mixed_key_intent_in_the_queue_ends_as_a_denied_receipt(self): + # a store writer can mix key types; the drain has claimed the intent, so validate must not raise + node = FakeNode({"blender/commands/a": {"commandId": "mixed-1", "requestedBy": "nibu/hands", "action": "createObject", 1: "a", "zz": "b"}}) + receipts = self.drain(node) + self.assertEqual([r["status"] for r in receipts], ["denied"]) + self.assertEqual(node.puts[0][0], "blender/receipts/mixed-1") + self.assertEqual(node.docs[bt.COMMAND_INTENT_SCHEMA], {}) + + def test_parenting_an_object_to_itself_or_its_own_child_is_refused_before_any_undo_step(self): + self.bpy.lamp.parent = self.bpy.mesh + for target, parent in (("Cube", "Cube"), ("Cube", "Lamp")): # Lamp is Cube's child + receipt = self.run_action(action="setObjectParent", targetObjectName=target, parentObjectName=parent) + self.assertEqual(receipt["status"], "failed", (target, parent)) + self.assertEqual(receipt["undoLabel"], "") + self.assertEqual(self.bpy.undo.pushes, []) + self.bpy.lamp.parent = None + self.assertEqual(self.run_action(action="setObjectParent", targetObjectName="Lamp", parentObjectName="Cube")["status"], "accepted") + self.assertEqual(len(self.bpy.undo.pushes), 1) + # claim-first: an intent leaves the queue before it runs, so no failure can run it twice def test_the_intent_is_deleted_before_its_handler_runs(self): node = FakeNode({"blender/commands/a": self.intent("claim-1")})