kitbash_pose.py: each metric read before its check, bounds by the margin rule; live result files

Bounds set from the shipped readings and nine mutants applied once each to a scratch copy (R1 atan2(A, B), R2 the
farther root, R3 roll without the seat, R4 no closures, R5 no aim floor, R6 left-handed roll_terms, R7 attach's
inline write kept, R8 the dot without its hypot, R9 sockets swapped in write_connection): every one fails a
unit test or a live check by name. kitbash, kitbash_assembly and kitbash_pose result files from Blender 5.3.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-12-02 02:25:44 +01:00
commit b6cbca079a
4 changed files with 270 additions and 53 deletions

View file

@ -2,7 +2,7 @@
"blender": "5.3.0",
"checks": [
{
"name": "the nine kitbash rows load as host actions with no errors",
"name": "the twelve kitbash rows load as host actions with no errors",
"ok": true,
"detail": null
},
@ -412,6 +412,9 @@
"brokkr_kitbash.report",
"brokkr_kitbash.attach",
"brokkr_kitbash.detach",
"brokkr_kitbash.roll",
"brokkr_kitbash.aim",
"brokkr_kitbash.reach",
"brokkr_kitbash.close",
"brokkr_kitbash.boolean",
"brokkr_kitbash.apply"

View file

@ -2,7 +2,7 @@
"blender": "5.3.0",
"checks": [
{
"name": "the nine kitbash rows load as host actions with no errors",
"name": "the twelve kitbash rows load as host actions with no errors",
"ok": true,
"detail": null
},

View file

@ -57,23 +57,27 @@ target.reload_host_actions()
R = {"blender": bpy.app.version_string, "checks": [], "hostErrors": target.host_actions()[1], "readings": {}}
COUNT = [0]
kit = core.load_kit("mechanical")
# Each mutant's reading below is its least over the cases here that it changes; the shipped reading is the worst.
# Metres (or a difference of unit vectors) between where a posed part's socket is and where its mate puts it, read
# from the two world matrices. Shipped worst 2.4e-07 (float32 matrices); least claimed mutant 0.24 (R3, roll writes
# kit_roll without seating: the actuator, read against the roll its strut states); separation 1.0e6.
SEATED = 2.4e-4
# Degrees between the roll read from the two world frames and the roll stated. Shipped worst 1.4e-05; least claimed
# mutant 15 (R3, at the smallest turn here); separation 1.1e6.
ROLL = 1.4e-2
# Metres between how far the actuator's pin moved and how far the strut's socket that carries it moved. Shipped
# worst 2.4e-07; least claimed mutant 0.38 (R3: the strut's socket is read at the stated roll, the actuator stays).
CARRIED = 3.0e-4
# The dot aim reports against the dot read from the scene, and its roll (degrees) against core.aim_roll on the
# scene's float32 matrices. Shipped worst 6.0e-08 and 3.4e-06; least claimed mutant 1.0 and 90 (R1); the roll's
# bound is ROLL's.
AIMED = 2.4e-4
# Metres between the socket reach moved and the plane asked for, read from the scene. Shipped worst 2.4e-07; least
# claimed mutant 0.36 (R6, a left-handed roll_terms: the root it solves is the mirror's).
REACHED = 2.9e-4
# from the two world matrices. Shipped worst 1.1e-06 (float32 matrices); least claimed mutant 0.25 (R9,
# write_connection seats with the two sockets swapped); separation 2.3e5.
SEATED = 5.2e-4
# Degrees between the roll read from the two world frames and the roll stated. Shipped worst 8.4e-06; least claimed
# mutant 15 (R3, roll writes kit_roll without seating, at the smallest turn here); separation 1.8e6.
ROLL = 1.1e-2
# Metres the actuator's pin moves when the strut it hangs from is rolled. Shipped least 0.55 (the 45 degree turn);
# least claimed mutant reads at most 5e-08 (R3: nothing moves); separation 1.1e7.
TURNED = 1.7e-4
# The dot aim reports against the dot read from the scene, and how far a roll on the 1-degree grid passes the dot
# read. Shipped worst 3.3e-07; least claimed mutant 0.0014 (R6, a left-handed roll_terms, at the aim nearest its
# mirror); R1 (atan2(A, B)) reads 0.81 and R8 (the dot without its hypot) 0.86; separation 4.2e3.
AIMED = 2.1e-5
# Metres between the socket reach moved and the plane asked for, read from the scene. Shipped worst 2.1e-07; least
# claimed mutant 0.42 (R6); separation 2.0e6.
REACHED = 3.0e-4
# Degrees the other root stands farther from the roll the part had than the root reach took. A rule, the sign: shipped
# least 74; R2 (the farther root) reads -74.
NEARER = 0.0
def check(name, ok, detail=None):
@ -85,6 +89,11 @@ def reading(name, value):
return float(value)
def least(name, value):
R["readings"][name] = min(R["readings"].get(name, math.inf), float(value))
return float(value)
def send(action, **fields):
COUNT[0] += 1
receipt = target.run_intent(bpy.context, {"commandId": f"live-{COUNT[0]}", "requestedBy": "test/driver", "action": action, **fields})
@ -191,52 +200,46 @@ for turn in (65.0, -160.0, 35.0): # from the 20 it was attached at
was, pin, before = stated(strut), frame(ram, "base")[:3, 3].copy(), (stated(ram), ram["kit_roll"], np.array(ram.matrix_basis).tolist())
sent = COUNT[0]
receipt, report = send("brokkr_kitbash.roll", object_name="Strut", roll=turn)
carried = frame(strut, "end_b")[:3, 3] - pin # where the socket that carries the actuator stands now, from where the actuator's pin was
gap, off = reading("seated", seated(strut, "end_a", mount, "pivot", turn)), R["readings"]["roll"]
check(f"roll {turn:g} turns the strut where it hangs: one intent, its parent, sockets and parent inverse as they were, its roll stated and seated",
receipt["status"] == "accepted" and COUNT[0] == sent + 1 and stated(strut) == was and strut["kit_roll"] == turn
and reading("seated", seated(strut, "end_a", mount, "pivot", turn)) < SEATED and R["readings"]["roll"] < ROLL
receipt["status"] == "accepted" and COUNT[0] == sent + 1 and stated(strut) == was and strut["kit_roll"] == turn and gap < SEATED and off < ROLL
and report and report["object"] == "Strut" and holds(report["connection"], "Mount", "end_a", "pivot", turn) and holds(connection("Strut"), "Mount", "end_a", "pivot", turn),
[receipt["message"], report and report["connection"], R["readings"]])
[receipt["message"], report and report["connection"], gap, off])
moved, gap = least("turned", float(np.linalg.norm(frame(ram, "base")[:3, 3] - pin))), reading("seated", seated(ram, "base", strut, "end_b", -35.0))
check(f"and the actuator follows through its own connection, which nothing rewrote (roll {turn:g})",
(stated(ram), ram["kit_roll"], np.array(ram.matrix_basis).tolist()) == before and float(np.linalg.norm(carried)) > 0.1
and reading("carried", np.abs(frame(ram, "base")[:3, 3] - pin - carried).max()) < CARRIED
and reading("seated", seated(ram, "base", strut, "end_b", -35.0)) < SEATED and R["readings"]["roll"] < ROLL and holds(connection("Ram"), "Strut", "base", "end_b", -35.0),
[carried.tolist(), connection("Ram"), R["readings"]])
reading("turned", float(np.linalg.norm(carried)))
(stated(ram), ram["kit_roll"], np.array(ram.matrix_basis).tolist()) == before and moved > TURNED and gap < SEATED and R["readings"]["roll"] < ROLL
and holds(connection("Ram"), "Strut", "base", "end_b", -35.0), [moved, gap, connection("Ram"), R["readings"]])
# --- roll: the closures it opens ----------------------------------------------------------------------------------------
check("the rolls above opened the brace's closure and reported it before the one that holds, whatever its name", report and report.get("closures") == [
check("the rolls above opened the brace's closure and reported it before the one that holds, whatever its name", (report or {}).get("closures") == [
{"part": "Brace", "to": "Ram", "holds": False}, {"part": "Aa_Loose", "to": "Aa_Anchor", "holds": True}] and report["closure"] is None, report and report.get("closures"))
receipt, report = send("brokkr_kitbash.roll", object_name="Strut", roll=20.0)
check("rolled back to where the brace met it, the closure holds again: read from where the parts stand", receipt["status"] == "accepted" and report["closures"] == [
check("rolled back to where the brace met it, the closure holds again: read from where the parts stand", receipt["status"] == "accepted" and (report or {}).get("closures") == [
{"part": "Aa_Loose", "to": "Aa_Anchor", "holds": True}, {"part": "Brace", "to": "Ram", "holds": True}], report and report.get("closures"))
send("setObjectTransform", targetObjectName="Aa_Loose", location=[0.0, -25.0, 0.0], rotationEuler=[0.0, 0.0, 0.0])
receipt, report = send("brokkr_kitbash.roll", object_name="Ram", roll=-35.0)
check("a roll lists the closures its own part is an end of first, before a broken one elsewhere", receipt["status"] == "accepted" and report["closures"] == [
check("a roll lists the closures its own part is an end of first, before a broken one elsewhere", receipt["status"] == "accepted" and (report or {}).get("closures") == [
{"part": "Brace", "to": "Ram", "holds": True}, {"part": "Aa_Loose", "to": "Aa_Anchor", "holds": False}], report and report.get("closures"))
receipt, report = send("brokkr_kitbash.roll", object_name="Ram", roll=-36.0)
check("and a roll of the part a closure names opens it; no roll seats or rewrites a closure", receipt["status"] == "accepted" and report["closures"] == [
check("and a roll of the part a closure names opens it; no roll seats or rewrites a closure", receipt["status"] == "accepted" and (report or {}).get("closures") == [
{"part": "Brace", "to": "Ram", "holds": False}, {"part": "Aa_Loose", "to": "Aa_Anchor", "holds": False}]
and {k: brace[k] for k in brace.keys() if k.startswith("kit_close")} == closing and brace.parent is None, [report and report.get("closures"), dict(brace.items())])
# --- aim ----------------------------------------------------------------------------------------------------------------
for axis, direction in (("+z", (1.0, 0.0, 0.0)), ("-x", (0.0, -3.0, 4.0)), ("+z", (0.2, 0.1, -2.0))):
world = np.array(mount.matrix_world, dtype=np.float64)
want, dot = core.aim_roll(world, socket(mount, "pivot"), socket(strut, "end_a"), core.AXES[axis], direction)
world, unit = np.array(mount.matrix_world, dtype=np.float64), np.array(direction) / np.linalg.norm(direction)
receipt, report = send("brokkr_kitbash.aim", object_name="Strut", axis=axis, direction_x=direction[0], direction_y=direction[1], direction_z=direction[2])
aimed = (report or {}).get("aimed") or {"roll": 1e9, "dot": 1e9}
read = float(np.array(strut.matrix_world, dtype=np.float64)[:3, :3] @ np.array(core.AXES[axis]) @ (np.array(direction) / np.linalg.norm(direction)))
grid = max(float((world @ core.mate(socket(mount, "pivot"), socket(strut, "end_a"), float(r)))[:3, :3] @ np.array(core.AXES[axis]) @ (np.array(direction) / np.linalg.norm(direction)))
for r in range(-180, 180))
check(f"aim points the strut's {axis} at {direction} as far as its pin lets it: the dot core solves, the dot the scene reads, and no roll on a 1-degree grid passes it",
receipt["status"] == "accepted" and reading("aimed roll", abs((aimed["roll"] - want + 180.0) % 360.0 - 180.0)) < ROLL
and reading("aimed dot", max(abs(aimed["dot"] - dot), abs(aimed["dot"] - read))) < AIMED and grid < aimed["dot"] + AIMED and 0.2 < aimed["dot"] < 0.999,
[receipt["message"], aimed, want, dot, read, grid])
read = float(np.array(strut.matrix_world, dtype=np.float64)[:3, :3] @ np.array(core.AXES[axis]) @ unit)
grid = max(float((world @ core.mate(socket(mount, "pivot"), socket(strut, "end_a"), float(r)))[:3, :3] @ np.array(core.AXES[axis]) @ unit) for r in range(-180, 180))
apart, short = reading("aimed", abs(aimed["dot"] - read)), reading("aimed short", max(grid - read, 0.0))
check(f"aim points the strut's {axis} at {direction} as far as its pin lets it: the dot it reports is the dot the scene reads, and no roll on a 1-degree grid passes it",
receipt["status"] == "accepted" and apart < AIMED and short < AIMED and 0.2 < aimed["dot"] < 0.999, [receipt["message"], aimed, read, grid])
gap, off = reading("seated", seated(strut, "end_a", mount, "pivot", aimed["roll"])), R["readings"]["roll"]
check(f"and it is stated and seated as roll's: the connection holds at the aimed roll, the actuator with it, closures reported ({axis})",
aimed["roll"] == round(strut["kit_roll"], 6) and -180.0 < aimed["roll"] <= 180.0
and holds(report and report["connection"], "Mount", "end_a", "pivot", aimed["roll"]) and reading("seated", seated(strut, "end_a", mount, "pivot", aimed["roll"])) < SEATED
and R["readings"]["roll"] < ROLL and holds(connection("Ram"), "Strut", "base", "end_b", -36.0) and len(report.get("closures", [])) == 2,
[dict(strut.items()), report and report["connection"], report and report.get("closures")])
aimed["roll"] == round(strut["kit_roll"], 6) and -180.0 < aimed["roll"] <= 180.0 and holds(report and report["connection"], "Mount", "end_a", "pivot", aimed["roll"])
and gap < SEATED and off < ROLL and holds(connection("Ram"), "Strut", "base", "end_b", -36.0) and len((report or {}).get("closures", [])) == 2,
[dict(strut.items()), report and report["connection"], report and report.get("closures"), gap, off])
# --- reach --------------------------------------------------------------------------------------------------------------
for direction, part, offset in (((0.0, 0.0, 1.0), 0.5, 40.0), ((0.0, 0.0, 1.0), 0.5, -40.0), ((1.0, 2.0, -0.5), -0.8, 100.0)):
@ -245,20 +248,20 @@ for direction, part, offset in (((0.0, 0.0, 1.0), 0.5, 40.0), ((0.0, 0.0, 1.0),
current = float(round(math.degrees(math.atan2(B, A)) + offset)) # the two rolls that reach stand either side of the middle: start nearer one
send("brokkr_kitbash.roll", object_name="Strut", roll=current)
height = round(C + part * math.hypot(A, B), 3)
want, _ = core.reach_roll(world, socket(mount, "pivot"), socket(strut, "end_a"), socket(strut, "end_b")["matrix"][:3, 3], unit, height, current)
other = (2.0 * math.degrees(math.atan2(B, A)) - want + 180.0) % 360.0 - 180.0
fields = {"direction_x": direction[0], "direction_y": direction[1], "direction_z": direction[2]} if direction != (0.0, 0.0, 1.0) else {} # world z is the default
receipt, report = send("brokkr_kitbash.reach", object_name="Strut", socket="end_b", height=height, **fields)
reached = (report or {}).get("reached") or {"roll": 1e9, "residual": 1e9}
apart = lambda roll: abs((roll - current + 180.0) % 360.0 - 180.0) # noqa: E731
off_plane = reading("reached", abs(float(frame(strut, "end_b")[:3, 3] @ unit) - height))
farther = least("reach other root", apart(2.0 * math.degrees(math.atan2(B, A)) - reached["roll"]) - apart(reached["roll"])) # the other root mirrors it about the middle
check(f"reach brings the strut's end_b to {height} m along {direction} from roll {current:g}, by the nearer of the two rolls that do",
receipt["status"] == "accepted" and reading("reached", abs(float(frame(strut, "end_b")[:3, 3] @ unit) - height)) < REACHED and reached["residual"] < REACHED
and reading("reached roll", abs((reached["roll"] - want + 180.0) % 360.0 - 180.0)) < ROLL
and abs((want - current + 180.0) % 360.0 - 180.0) + 10.0 < abs((other - current + 180.0) % 360.0 - 180.0),
[receipt["message"], reached, want, other, float(frame(strut, "end_b")[:3, 3] @ unit)])
receipt["status"] == "accepted" and off_plane < REACHED and reached["residual"] < REACHED and farther > NEARER,
[receipt["message"], reached, off_plane, farther])
gap, off = reading("seated", seated(strut, "end_a", mount, "pivot", reached["roll"])), R["readings"]["roll"]
check(f"and it is stated and seated as roll's ({direction}, from {current:g})", reached["roll"] == round(strut["kit_roll"], 6) and -180.0 < reached["roll"] <= 180.0
and holds(report and report["connection"], "Mount", "end_a", "pivot", reached["roll"]) and reading("seated", seated(strut, "end_a", mount, "pivot", reached["roll"])) < SEATED
and R["readings"]["roll"] < ROLL and holds(connection("Ram"), "Strut", "base", "end_b", -36.0) and len(report.get("closures", [])) == 2,
[dict(strut.items()), report and report["connection"]])
and holds(report and report["connection"], "Mount", "end_a", "pivot", reached["roll"]) and gap < SEATED and off < ROLL
and holds(connection("Ram"), "Strut", "base", "end_b", -36.0) and len((report or {}).get("closures", [])) == 2,
[dict(strut.items()), report and report["connection"], gap, off])
# --- refusals -----------------------------------------------------------------------------------------------------------
send("setObjectParent", targetObjectName="Orphan", parentObjectName="")

View file

@ -0,0 +1,211 @@
{
"blender": "5.3.0",
"checks": [
{
"name": "roll, aim and reach load as host actions after detach, with no errors",
"ok": true,
"detail": null
},
{
"name": "the chain stands: tank, bracket, strut, actuator",
"ok": true,
"detail": null
},
{
"name": "a brace closes on the actuator's rod pin",
"ok": true,
"detail": null
},
{
"name": "and a second closure, named to sort first, holds far from it",
"ok": true,
"detail": null
},
{
"name": "roll 65 turns the strut where it hangs: one intent, its parent, sockets and parent inverse as they were, its roll stated and seated",
"ok": true,
"detail": null
},
{
"name": "and the actuator follows through its own connection, which nothing rewrote (roll 65)",
"ok": true,
"detail": null
},
{
"name": "roll -160 turns the strut where it hangs: one intent, its parent, sockets and parent inverse as they were, its roll stated and seated",
"ok": true,
"detail": null
},
{
"name": "and the actuator follows through its own connection, which nothing rewrote (roll -160)",
"ok": true,
"detail": null
},
{
"name": "roll 35 turns the strut where it hangs: one intent, its parent, sockets and parent inverse as they were, its roll stated and seated",
"ok": true,
"detail": null
},
{
"name": "and the actuator follows through its own connection, which nothing rewrote (roll 35)",
"ok": true,
"detail": null
},
{
"name": "the rolls above opened the brace's closure and reported it before the one that holds, whatever its name",
"ok": true,
"detail": null
},
{
"name": "rolled back to where the brace met it, the closure holds again: read from where the parts stand",
"ok": true,
"detail": null
},
{
"name": "a roll lists the closures its own part is an end of first, before a broken one elsewhere",
"ok": true,
"detail": null
},
{
"name": "and a roll of the part a closure names opens it; no roll seats or rewrites a closure",
"ok": true,
"detail": null
},
{
"name": "aim points the strut's +z at (1.0, 0.0, 0.0) as far as its pin lets it: the dot it reports is the dot the scene reads, and no roll on a 1-degree grid passes it",
"ok": true,
"detail": null
},
{
"name": "and it is stated and seated as roll's: the connection holds at the aimed roll, the actuator with it, closures reported (+z)",
"ok": true,
"detail": null
},
{
"name": "aim points the strut's -x at (0.0, -3.0, 4.0) as far as its pin lets it: the dot it reports is the dot the scene reads, and no roll on a 1-degree grid passes it",
"ok": true,
"detail": null
},
{
"name": "and it is stated and seated as roll's: the connection holds at the aimed roll, the actuator with it, closures reported (-x)",
"ok": true,
"detail": null
},
{
"name": "aim points the strut's +z at (0.2, 0.1, -2.0) as far as its pin lets it: the dot it reports is the dot the scene reads, and no roll on a 1-degree grid passes it",
"ok": true,
"detail": null
},
{
"name": "and it is stated and seated as roll's: the connection holds at the aimed roll, the actuator with it, closures reported (+z)",
"ok": true,
"detail": null
},
{
"name": "reach brings the strut's end_b to 4.23 m along (0.0, 0.0, 1.0) from roll -38, by the nearer of the two rolls that do",
"ok": true,
"detail": null
},
{
"name": "and it is stated and seated as roll's ((0.0, 0.0, 1.0), from -38)",
"ok": true,
"detail": null
},
{
"name": "reach brings the strut's end_b to 4.23 m along (0.0, 0.0, 1.0) from roll -118, by the nearer of the two rolls that do",
"ok": true,
"detail": null
},
{
"name": "and it is stated and seated as roll's ((0.0, 0.0, 1.0), from -118)",
"ok": true,
"detail": null
},
{
"name": "reach brings the strut's end_b to 0.885 m along (1.0, 2.0, -0.5) from roll 135, by the nearer of the two rolls that do",
"ok": true,
"detail": null
},
{
"name": "and it is stated and seated as roll's ((1.0, 2.0, -0.5), from 135)",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: roll of a part nobody attached",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: aim of a part nobody attached",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: reach of a part nobody attached",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: roll of a part whose parent was cleared",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: roll of a mesh that is not a kit part",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: aim of the axis along the pin",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: aim at no direction",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: reach past the circle the socket turns on, naming what it reaches",
"ok": true,
"detail": null
},
{
"name": "and the range it names is the one core solves",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: reach with a socket the part does not have",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: reach along no direction",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: a roll past a turn, by the action table",
"ok": true,
"detail": null
},
{
"name": "refused, scene unchanged: an axis that is not one of the six, by the action table",
"ok": true,
"detail": null
}
],
"hostErrors": [],
"readings": {
"aimed": 3.3e-07,
"aimed short": 0.0,
"reach other root": 74.0,
"reached": 2.1e-07,
"roll": 8.4e-06,
"seated": 1.1e-06,
"turned": 0.55
},
"ok": true
}