Skip to content

fix(kit): offer lists named by host contract, host refusals keep their text and data - #31

Closed
pascalandr wants to merge 1 commit into
mainfrom
fix/kit-s0
Closed

pascalandr wants to merge 1 commit into
mainfrom
fix/kit-s0

Conversation

@pascalandr

Copy link
Copy Markdown
Collaborator

Slice S0 of the Houdini and Gaffer study: two kit defects shared by OpenCode for Houdini and Gaffer, fixed before their next versions. No publication.

Offer list named by contract. sharedOfferRegistry kept one list per application, so after an upgrade without restarting OpenCode the new plugin reused the older version's list and judged its installed part by the older range (incompatible). The kit now names each shared list after its contract (<app>.protocol-<p>.part-<range>.app-<versions>, offerRegistryName). Blender gets the same list as before.

Refusals keep the host's text and data. A HostError message now carries the host's text and its error.data (also HostError.data); Blender builds its own message from code and detail and is unchanged. Houdini's installed part no longer answers every refusal Houdini refused the request (and busy as invalid_args); Gaffer's no longer drops data. Both send their message, JSON-safe data and their own code as data.reason. Payloads rebuilt at the same versions (Houdini 0.2.1, Gaffer 0.2.0), published later with Houdini 0.3.0 and Gaffer.

Docs. The spec describes the optional error.data; the kit README no longer says the spec forbids sending code to a host.

Validation. New Houdini and Gaffer registry and tool-error tests, wire tests of both installed parts and a Houdini refusal unit test fail on 903fa2d and pass; Blender's registry test passes on both. Real Gaffer 1.7.1.0 test passes locally. lint, typecheck, build, npm test, check:markers, trace scan.

…r text and data

Two defects shared by OpenCode for Houdini and OpenCode for Gaffer, fixed in
the kit and in their installed parts before their next versions.

Offer list. sharedOfferRegistry kept one list per application on globalThis.
After an upgrade without restarting OpenCode, the older plugin version stays
loaded in the same process, and the new version reused its list, which judges
hellos by the older host range: the new installed part was called
incompatible. Blender had worked around it by passing a contract name; the
kit now names every shared list after the contract it judges by
(<app>.protocol-<p>.part-<range>.app-<versions>, offerRegistryName).
Blender passes its application name and gets the same list as before.

Refusals. The kit's HostError message was always "Host refused the request
(<code>).": the host's explanation stayed in HostError.detail, which only
Blender read, and error data was dropped. A refusal's message now carries the
host's text (control characters removed, at most 300 characters) and its
error.data object (at most 2,000 characters in the message), also kept as
HostError.data. Blender builds its own message from code and detail, so it
does not change.

Installed parts. Houdini answered every refusal "Houdini refused the request"
without data, and turned most codes, busy included, into invalid_args. Gaffer
sent the message but dropped the data. Both now send the host's message, its
data made JSON-safe (dropped above 64 KiB), and the host's own code as
data.reason when it maps to another wire code; Houdini passes every wire code
through. Their payloads are rebuilt at the same versions (Houdini 0.2.1,
Gaffer 0.2.0): they are published with Houdini 0.3.0 and the next Gaffer.

The specification describes the optional error.data. The kit README no longer
says the specification forbids sending code to a host: it has no such rule,
and Blender sends its fixed programs to its add-on's execute_code.

Validation: new registry and tool-error tests for Houdini and Gaffer, a wire
test of each installed part (Houdini under system Python, Gaffer's real
HostServer) and a Houdini unit test of the refusal all fail on 903fa2d and
pass. Kit tests cover the contract name and the refusal message. Blender's
registry test, adjusted to place the legacy list itself and to check the
name, passes on both. The real Gaffer test also passes with Gaffer 1.7.1.0.
lint, typecheck, build, npm test (279 pass, 5 skipped), check:markers and the
trace scan pass.
pascalandr added a commit that referenced this pull request Nov 16, 2026
…med offers and readable host errors (#32, #31)

* fix(kit): offer lists named by host contract, host refusals keep their text and data

Two defects shared by OpenCode for Houdini and OpenCode for Gaffer, fixed in
the kit and in their installed parts before their next versions.

Offer list. sharedOfferRegistry kept one list per application on globalThis.
After an upgrade without restarting OpenCode, the older plugin version stays
loaded in the same process, and the new version reused its list, which judges
hellos by the older host range: the new installed part was called
incompatible. Blender had worked around it by passing a contract name; the
kit now names every shared list after the contract it judges by
(<app>.protocol-<p>.part-<range>.app-<versions>, offerRegistryName).
Blender passes its application name and gets the same list as before.

Refusals. The kit's HostError message was always "Host refused the request
(<code>).": the host's explanation stayed in HostError.detail, which only
Blender read, and error data was dropped. A refusal's message now carries the
host's text (control characters removed, at most 300 characters) and its
error.data object (at most 2,000 characters in the message), also kept as
HostError.data. Blender builds its own message from code and detail, so it
does not change.

Installed parts. Houdini answered every refusal "Houdini refused the request"
without data, and turned most codes, busy included, into invalid_args. Gaffer
sent the message but dropped the data. Both now send the host's message, its
data made JSON-safe (dropped above 64 KiB), and the host's own code as
data.reason when it maps to another wire code; Houdini passes every wire code
through. Their payloads are rebuilt at the same versions (Houdini 0.2.1,
Gaffer 0.2.0): they are published with Houdini 0.3.0 and the next Gaffer.

The specification describes the optional error.data. The kit README no longer
says the specification forbids sending code to a host: it has no such rule,
and Blender sends its fixed programs to its add-on's execute_code.

Validation: new registry and tool-error tests for Houdini and Gaffer, a wire
test of each installed part (Houdini under system Python, Gaffer's real
HostServer) and a Houdini unit test of the refusal all fail on 903fa2d and
pass. Kit tests cover the contract name and the refusal message. Blender's
registry test, adjusted to place the legacy list itself and to check the
name, passes on both. The real Gaffer test also passes with Gaffer 1.7.1.0.
lint, typecheck, build, npm test (279 pass, 5 skipped), check:markers and the
trace scan pass.

* feat(houdini): OpenCode for Houdini 0.3.0 on the kit's shared host session

OpenCode for Houdini 0.2 offered Houdini only while its own panel was
connected, so a CodeNomad conversation alone could not use it, and its tools
were a typed apply with no code execution, inspection or verification. 0.3.0
brings it to the level of OpenCode for Blender 0.4.8, on a base extracted from
Blender into the integration kit.

Installed part (OpenCode Link 0.3.0)
- Starts with Houdini's interface (the package's scripts/python/pythonrc.py)
  and offers it to the OpenCode services every 5 s, labelled with the open
  file; OPENCODE_HOUDINI_OFFER=0 keeps it from offering itself; background
  hython never offers itself.
- hello names the process and its crash folder (houdini_temp); status answers
  off the main thread with the request running there and for how long.
- execute_code: one undo group per run, undone when the run fails, and the
  node graph compared with its state before; when that cannot be proven, the
  scene is quarantined until release with the revision of a read. A save is
  judged by the open file's date on disk (copies fire Houdini's save events
  too); a change by its nodes or undo items, never a selection.
- Hints read Houdini itself (hints.py): closest node types in the parent's
  network, the real parm names when parm() returned None, the errors of the
  nodes that failed to cook, a hou function's signature, closest attributes.
- Every request runs on Houdini's main thread, in hython too (requests queued,
  served by pump()): hou records no undo off the main thread
  (undos.areEnabled() is false there, measured in 22.0.429).
- The panel is a plain client: Connect attaches its conversation (taken back
  per file) to this Houdini's own offer, found by its label; closing it
  releases that conversation only and no longer withdraws the offer or stops
  the host.

Plugin
- Tools from manifests: houdini_hosts (listing asks no permission),
  houdini_context (+ release_quarantine), houdini_execute_code, houdini_inspect,
  houdini_verify (criteria, node errors, render; saved by a background hython),
  houdini_save, houdini_render (ROP render or PDG cook as a task),
  houdini_apply kept as it was, houdini_install_host. The fixed programs
  (programs/*.py) run read only through execute_code.
- The only free compatible Houdini attaches itself at the first call; the
  working method joins the conversation; attachments survive an OpenCode
  restart and a file change.
- A crash is said within two seconds of the crash files Houdini writes for
  its process (its log, or the scene saved at the crash, which recovers the
  changes); closed, frozen or still busy are said as such.
- Installation finds the newest Houdini 21+ preferences folder; an earlier
  OpenCode package (packages/opencode_houdini.json) is a legacy_install notice.
- Waits: 120 s per request by default, up to an hour for execute_code; the
  installed part waits up to an hour for the main thread and answers busy
  when it cannot take a request within 10 s.

Shared base (packages/integration-kit)
- host-session.ts: ownership, attached offer, automatic and restored
  attachment, host calls with crash, close and status diagnosis, the hosts
  tool and maintain; attachments.ts, closed.ts (crashWatch), method.ts,
  scripts.ts. Names and texts come from each integration; nothing knows an
  application. Blender now uses them through thin wrappers with its own names
  and texts: its tests pass unchanged.
- The fake test host answers asynchronous methods.
- Gaffer's payload is rebuilt at 0.2.0: the kit's new exports rename its
  minified bundle's identifiers; its unminified code is unchanged.

Validation: new and rewritten Houdini tests (plugin, contract, conformance with
the code execution gate, system-Python host and hint probes) pass; on real
Houdini 22.0.429 Apprentice, 15 hython tests (programs, hints, execute_code
undo, status, saves) pass, and a windowed Houdini on a hidden desktop offered
itself to a private OpenCode 2.2.5 service without a panel, ran every tool,
kept another conversation attached when its panel closed, and was reported
crashed 2.0 s after a real crash with its recovery scene. Blender's suites
(unit, plugin, 27 real-Blender tests, native sessions) and the real Gaffer
test pass. lint, typecheck, build, npm test (288 pass), check:markers and the
trace scan pass.

* fix(houdini): offers that hold during cooks, crashed renders said as crashes

The Sol trial lost Houdini offers while another Houdini cooked or loaded,
saw two offers with one label, and an OpenGL ROP render crashed both its
background hython and, rendered again in the interface, the open Houdini.

hello is now answered off Houdini's main thread from values read once at
start (protocol, capabilities, process) and the current script state.
OpenCode checks new offers one at a time with hello; a hello waiting
behind a cook held every offer of the computer back, until their leases
ran out and conversations were detached (the service logged 499s).

The advertiser renews straight at the services that accepted the offer,
one request each with 8 s for a busy service, discovers again after a
failure and every 12 renewals, and retries 1 s after a failed renewal
instead of 5 s (an offer lasts 15 s).

houdini_hosts adds same_label when several offers share a label (two
Houdinis with the same file open).

Measured with Houdini 22.0.429: an OpenGL ROP with High Quality Lighting
off crashes in its Vulkan renderer every time, in hython as in the
interface. houdini_render says so in facts.crash_risk when it starts such
a render (a warning, not a refusal); the task tracker reads a crashed
hython's log (Fatal error / Caught signal and its first frames) and says
"the background hython crashed (...); the open Houdini is not affected"
with that note. The working method asks for long renders and cooks
through houdini_render; the README's Limits say the same.

Tests: hello answered while the main thread is busy, renewals straight to
the service and rediscovery after a failure (host_probe), same_label
(plugin.test), a crashed render log said as a crash (tasks.test), and
the real hython crash and its warning (programs_hython). The first four
fail on the previous commit.

* fix(houdini): verify saved never waits on Houdini's main thread, says what it read and where it stopped

In the Sol ex03 retrial, houdini_verify saved: true on a Vellum scene
with 48 cached frames ran 10 minutes and said only that Houdini was
still running execute_code. The verify itself takes 2 s on that file
(16 criteria, the cache read from disk): it never started.

In Houdini's interface hou serialises its calls across threads. The
host's gate called hou.isUIAvailable() and hou.ui.postEventCallback()
on the request's thread, so a request waited for whatever the main
thread ran (here the agent's own execute_code that reloaded the file)
and its 10 s "busy" answer never came; houdini_context waited 120 s and
houdini_verify 600 s. Measured on a hidden-desktop Houdini: a context
sent during a 40 s execute_code waited 37 s.

The gate now queues requests without any hou call on their thread; an
event loop callback registered once on the main thread runs them, never
one inside another. A request not taken within 10 s is answered with
what runs and since when.

verify saved no longer holds the main thread while its background
hython reads the file: verify_saved.py only starts it (with Houdini's
environment) and returns. The plugin follows it outside Houdini
(saved-verify.ts): its result, its crash, and timeout_s, after which it
stops the hython and says what it was doing (the OPENCODE_STEP lines of
its log: loading, criterion i/n and its label and frame, the error
scan's cooks, the render). verify.py times each criterion and lists in
facts.read where the geometry it read came from: files on disk (a File
SOP, a File Cache that loads), cooked, or simulated from the start frame
by an upstream solver with no cache read. Its error scan no longer cooks
the display node inside a network of its own kind (a solver asset's
inside), which could simulate up to the current frame.

Tests: the gate under a HOM-like lock (host_probe), following a
background verify to its result, its crash and its timeout
(saved-verify.test), and in real hython a cached simulation read back
(cache files vs simulated solver, steps in the log) plus reloading the
open file through execute_code. The first and the hython ones fail on
the previous commit; saved-verify.ts is new. A real trial on a copy of
the ex03 scene in a hidden-desktop Houdini: 16/16 in 2.1 s with
cached_cloth read from $HIP/cache/vellum; refused in 10.0 s while the
main thread was busy; a criterion reading the solver at frame 48 with
timeout_s 6 stopped at 6.5 s naming that criterion.
@pascalandr

Copy link
Copy Markdown
Collaborator Author

Merged as part of #32 (Houdini 0.3.0 was stacked on this branch).

@pascalandr pascalandr closed this Nov 16, 2026
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