Skip to content

fix(blender): OpenCode for Blender 0.4.4, find the API and verify by criteria - #26

Merged
pascalandr merged 1 commit into
mainfrom
feat/blender-0.4.4
Nov 14, 2026
Merged

pascalandr merged 1 commit into
mainfrom
feat/blender-0.4.4

Conversation

@pascalandr

Copy link
Copy Markdown
Collaborator

OpenCode for Blender 0.4.4, from the 0.4.3 exercises (QA journal, Luna section): an agent finds Blender's API from the running Blender and verifies by measurement. Every answer is read from the running Blender (RNA, bpy.ops, node types made in a temporary tree); no embedded tables, no new tool.

What changes

  1. Errors that say what is valid. A failed execute_code run on Blender's API carries a hint, read before the run is undone: the closest names and the type's properties (unknown attribute, e.g. Sculpt.detail_type → detail_type_method), the operator's real signature with its collections' element type (unknown or missing argument), the closest items (invalid enum value), the collection's keys (missing key, node sockets included), the node types the tree creates with their sockets (unknown node type), Blender's reason and the context the code had (failed poll).
  2. blender_inspect. search finds words in types, properties, functions and operators, with their paths and the properties that lead to a type; operators show their collections' element type (OperatorStrokeElement) and their poll here with Blender's reason; tree makes a node type in the tree named (shader, geometry, compositing, texture) or lists what that tree creates; entries beyond limit are named, never cut; match takes words or a glob.
  3. blender_verify by criteria. criteria: the agent's checks (read-only expression or bpy.data path, comparison, value, frames), measured on the evaluated scene, passed or failed with the value (bounds(name), ev(name), world(name) helpers). visible: whether an object shows in the render at a frame, otherwise every reason found (out of frame, hidden in render, collection excluded, view layer not rendered, holdout, transparent or zero-density material, no geometry, hidden behind another object). The render runs when asked, or without them.
  4. Sculpt crash. A Blender 5.3 defect, established without the add-on (details below). OpenCode Link creates the multires mask layer before a scripted mask stroke, as Blender's interactive path does, and pushes a first undo step before a sculpt-mode operator in a background Blender that has none; both say so in warnings. After a closure, the next call says "Blender closed" with the crash report path (the add-on's hello names its process and crash folder).
  5. UI operators (asset previews). They run from execute_code in a Blender with a window when given their context (temp_override(id=...)); the failed poll's hint and inspect now show Blender's reason and that context.
  6. Method. Inspect the exact element, read an error's hint and inspect again, set measurable criteria and conclude with blender_verify (still 10 lines at most).

The sculpt crash (Blender 5.3.0)

  • Minimal sequence: UV sphere → Multires, one multires_subdivide → Sculpt mode → one sculpt.brush_stroke(stroke=[2 elements], brush_toggle='MASK') in temp_override(window, area, region). 3/3 crashes (Ubuntu VM, plain timer script, no add-on); removing multires, or using toggle None/SMOOTH, gives 0/12. The real Mask brush crashes too.
  • Legitimate calls: arguments as 5.3's RNA describes them; brush_toggle='MASK' is what the default keymap binds to Alt+drag; the override is the documented context API and the poll needs it.
  • By hand: Alt+drag ×3 and Mask brush ×3 (real input events, 3 runs each) paint the mask and never crash; the same exec stroke run from the Text editor's Run Script crashes. The timer is not the cause.
  • Cause (source v5.3.0): sculpt_brush_stroke_invoke calls BKE_sculpt_mask_layers_ensure for a mask brush; sculpt_brush_stroke_exec does not, so the stroke writes into grid masks that were never allocated (heap corruption, then layerCopy_mdisps on the mode switch). With the layer created first: 0/15 crashes, the mask painted. Not filed upstream.
  • Background: without an undo stack (no undo step yet), every sculpt-mode operator closes Blender (ED_undosys_stack_memfile_id_changed_tag); after one ed.undo_push, 10/10 survive.

Validation

  • ops044_tests.py (12) and three plugin tests in a background Blender 5.3: fail on 0.4.3 (the first through a real crash), pass on 0.4.4.
  • Windowed Blender 5.3 (Ubuntu VM), through the add-on's execute_code: minimal stroke and the full ex02 sequence 6/6 alive with 0.4.4, 2/3 crashes with 0.4.3 in the same harness; asset preview generated (128 × 128).
  • lint, typecheck, npm test, build, check:markers, trace scan, Blender suites (20/20, extension 1/1), native sessions with OpenCode 2.2.5.
  • Manual protocol: steps 9 (scripted mask stroke) and 10 (asset preview) added to test/MANUAL.md for the real trial.

…criteria

The 0.4.3 exercises showed agents guessing Blender's Python API (a property
name, an operator's stroke elements, a node's sockets, the 5.3 compositing
tree), declaring results they had not measured, and a scripted sculpt stroke
closing Blender 5.3. 0.4.4 answers from the running Blender itself, never from
embedded tables, and keeps the tool surface as it was.

Errors that say what is valid: a failed execute_code run on Blender's API
carries a hint, read before the run is undone: the closest names and the
type's properties for an unknown attribute, the operator's real signature
(with its collections' element type) for its arguments, the closest items for
an invalid enumeration value, a collection's keys for a missing key (node
sockets included), the node types the tree creates for an unknown node type,
Blender's reason and the context the code had for a failed poll. The add-on
wraps the bpy.ops callables created during the run (same call, poll,
get_rna_type and repr; restored afterwards) to name the failing operator, and
reads a failing collection or node tree from the failing line with names,
attribute reads and constant subscripts only.

blender_inspect: search finds words in this Blender's types, properties,
functions and operators, with their paths and the properties that lead to a
type; an operator shows its collections' element type and its poll here with
Blender's reason; tree makes a node type in the tree named (shader, geometry,
compositing, texture) or lists what that tree creates instead; entries beyond
limit are named instead of cut, and match takes words as well as a glob.

blender_verify: criteria are the agent's own checks (a read-only expression or
a bpy.data path, a comparison, a value, frames), measured on the evaluated
scene and returned passed or failed with the value; visible says whether an
object shows in the render at a frame, or every reason found (out of frame,
hidden in render, collection excluded, view layer not rendered, holdout,
transparent or zero-density material, no geometry, hidden behind another
object). The render runs when asked, or without criteria and visible.

The sculpt crash is a Blender 5.3 defect, established without the add-on: the
script path of sculpt.brush_stroke skips the grid mask layer its interactive
path creates (BKE_sculpt_mask_layers_ensure), so a mask stroke (the Mask brush
or brush_toggle='MASK', which the default keymap binds to Alt+drag) on a
multiresolution object corrupts the heap. A sphere with one Multires level and
one scripted mask stroke closes Blender from a timer and from the Text
editor's Run Script alike; the same strokes by hand never do. OpenCode Link
now creates the layer first, as the interactive path does (inverting the mask
twice keeps its values), and says so in warnings. A background Blender has no
undo stack until a first undo step, and every sculpt-mode operator closes it
without one: a first step is pushed when none was. The add-on's hello names
its process and crash folder, so a call after Blender closed says so with the
crash report it wrote instead of an unreachable host (not under WSL, where
Blender's process is on Windows).

Asset previews run from execute_code in a Blender with a window when the
operator gets its data-block (temp_override(id=...)); the failed poll's hint
and inspect now show that. The working method asks to inspect the exact
element, read an error's hint and inspect again, set measurable criteria and
conclude with blender_verify, within its 10 lines.

Validation: ops044_tests.py (12 tests) and three plugin tests in a background
Blender 5.3 fail on 0.4.3 (the first through a real crash) and pass on 0.4.4;
unit tests for the closed-Blender notice. Windowed Blender 5.3 on Ubuntu,
through the add-on's execute_code: the minimal mask stroke and the full ex02
sequence 6/6 alive with 0.4.4, 2/3 crashes with 0.4.3 in the same harness;
asset previews generated. lint, typecheck, npm test, build, check:markers,
trace scan, Blender suites (20/20, extension 1/1) and native sessions with
OpenCode 2.2.5 pass.
@pascalandr
pascalandr merged commit 4e27579 into main Nov 14, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant