Rebuild the object in a reference image as a code-only, procedural, quality-gated, animation-ready Three.js model. Token-efficient image-to-3D.
Python 3dai-agentsclaude-codecomputer-graphicsgenerativeimage-to-3dprocedural-generationthreejstypescriptwebgl
feat: animated-character served by the installed plugin
kokorolxf651263347c5
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 78fafd9..ef438f1 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -9,6 +9,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Changed — BREAKING+- **`animated-character` is served by the installed plugin-character** (`img2 add+ img2threejs/plugin-character`, requires harness >= 0.2.3). The in-repo domain module is removed;+ without the plugin the profile fails loud naming what is available, and an in-flight workspace is+ refused while the provider is absent, resuming unchanged on reinstall. Persisted checklists do NOT+ migrate: a workspace initialized before the switch keeps base `forge/stage5_rig/...` commands and+ runs the base library copies -- re-init to adopt the plugin's steps. Gate participation is now+ rig-aware: a domain declaring `rigSteps` is not due until its rig track begins, so the plugin-gates+ sweep no longer fires a rig gate one phase early. `state.py` degrades to generic-only profile+ choices when the registry itself is broken instead of dying for every profile.+- **A domain is no longer inferred from the target's name.** `detect_cs2_intent` and its 17-keywordtable (including bare `"fade"` and `"karambit"`) are removed, so a target called`"AK-47 | Redline"` or `"Karambit Doppler"` no longer identifies itself as CS2 — it resolves to thediff --git a/README.md b/README.mdindex c93760f..1aa1977 100644--- a/README.md+++ b/README.md@@ -91,7 +91,7 @@ It runs under Claude Code, Codex, or OpenCode. It is agent-agnostic: wherever th- **Maximum likeness for a specific person or character.** An opt-in projection-first path fits a parametric template to image landmarks, de-lights the photo, camera-matches the render, and projects the reference onto the mesh. A single image cannot guarantee 100 percent likeness, so the pipeline reports per-region confidence and asks for more views when it matters. Details: `grimoire/character/likeness_maximization.md`.- **Multi-view silhouette carving.** An opt-in `geometryDescriptor.visualHull` intersects at least two deterministic orthographic binary silhouettes into a bounded, welded voxel mesh. It records unseen areas as low-confidence rather than inventing hidden detail. Schema and runtime check: `grimoire/scripts.md`.- **CS2 weapon review gates.** Knife and Glock-18 routes use family-specific component contracts. The review records exactness tier, family identity, painted-region and projection coverage, per-region confidence, approximation notes, and versioned review-scene metadata; component-coverage and map-stripped blockout gates prevent a convincing texture from standing in for real structure. Ships with the CS2 domain plugin; see its `docs/cs2/review-gates.md`.-- **Resumable local workflow.** `forge/state.py` records an ordered, evidence-backed intake/pass checklist for the generic profile and every registered domain (in-repo `character`/`animated-character`, plus installed domain plugins such as CS2). `forge/next.py --state` resumes from that checklist while the existing spec, render, and review gates remain authoritative.+- **Resumable local workflow.** `forge/state.py` records an ordered, evidence-backed intake/pass checklist for the generic profile and every registered domain (in-repo `character`, plus installed domain plugins such as CS2 and `animated-character` from plugin-character). `forge/next.py --state` resumes from that checklist while the existing spec, render, and review gates remain authoritative.- **Material reference pipeline.** Every visible material region can be cropped, analyzed, resolved against the versioned Three.js material registry, fitted into `ObjectSculptSpec`, rendered from controlled camera views, and accepted only after a per-region comparison gate. See [`docs/materials/README.md`](docs/materials/README.md).- **Python-assisted browser rendering.** Python may orchestrate camera batches, hashes, manifests, and deterministic diagnostics, but the target browser Three.js route remains the rendering authority. See [`grimoire/build/python_threejs_render_bridge.md`](grimoire/build/python_threejs_render_bridge.md).@@ -137,7 +137,7 @@ A staged sculpting pipeline turns the reference image into a spec, then generateAn installed domain plugin contributes its own checklist steps, evidence collection, specaugmentation (quality floors merge raise-only), and a blocking review gate — and registers itsprofile with `forge/state.py init --profile <id>`. With no plugins installed, `generic`,- `character`, and `animated-character` are available; a profile whose plugin is missing fails+ and `character` are available; a profile whose plugin is missing (`cs2`, `animated-character`) failsloud naming what is installed, never silently downgrades. `img2 remove <id>` reverses cleanly.Writing your own plugin: the harness repo's `docs/WRITING_A_PLUGIN.md`.diff --git a/SKILL.md b/SKILL.mdindex 5d95c55..62344f2 100644--- a/SKILL.md+++ b/SKILL.md@@ -62,7 +62,7 @@ Conversation context is disposable; `.img2threejs/state.json` is the local checkInitialize once per reconstruction, then gate every step through it:```bash-python3 forge/state.py init --state .img2threejs/state.json --reference <img> --profile <generic|character|animated-character|installed-domain> --spec object-sculpt-spec.json+python3 forge/state.py init --state .img2threejs/state.json --reference <img> --profile <generic|character|installed-domain> --spec object-sculpt-spec.jsonpython3 forge/next.py --state .img2threejs/state.json [object-sculpt-spec.json]python3 forge/state.py mark <step-id> --state .img2threejs/state.json --evidence <path>```@@ -74,11 +74,11 @@ python3 forge/state.py mark <step-id> --state .img2threejs/state.json --evidencesilent omission is forbidden. Loop counts derive from `reviewHistory` actions(`refine-spec`/`refine-code`), not agent memory. Defaults: 3 corrections per pass, 6 total.- A domain profile's steps, gates and reference material come from the **registry**: in-repo- modules (`character`, `animated-character`) and installed plugins register identically, and+ modules (`character`) and installed plugins (`cs2`, `animated-character` from plugin-character) register identically, and`forge/state.py init` names what is available. A profile adds mandatory gates without changingthe core order -- a domain plugin typically requires an authoritative classification, an intakemanifest, and a machine-readable domain review before AI review; `character` requires the- character contracts and landmark evidence; `animated-character` adds all of `character` plus the+ character contracts and landmark evidence; `animated-character` (requires the installed plugin-character) adds all of `character` plus thenine Stage R steps (`grimoire/readiness/animation_contract.md`). Pick it whenever the rig mustMOVE — on `character` the Stage R gates are absent and the build completes without ever runningthem, which is how animation used to ship broken. Its order is load-bearing: repair the mesh,@@ -299,8 +299,10 @@ attachment, material, detail inventory, rig payload, character track). In short:passes a straight cone occupying roughly the right cells.- Character builds validate the rig payload (`stage5_rig/validate_rig_payload.py`) before binding a`THREE.Skeleton`; it proves payload integrity only, never pose stress or likeness.-- A rig that must MOVE runs the animation gates too (`grimoire/readiness/animation_contract.md`,- `stage5_rig/rig_gates.py`). A clip that exists is not a clip that plays: only G1+- A rig that must MOVE runs the animation gates too (`grimoire/readiness/animation_contract.md`;+ the checklist steps and gate come from the installed plugin-character -- `stage5_rig/` remains in+ this repo as the emitter's library, not the checklist authority). A clip that exists is not a+ clip that plays: only G1(`maxSampledBindingDelta <= 2^-23`) separates the two, and a gate whose input is missing reports`unevaluated`, never a pass. Bind at IDENTITY in attached mode and take the display offset fromthe mesh bounds alone; loop is decided by `poseReturn`, never by travel.diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.mdindex 98f673c..80163bb 100644--- a/docs/ARCHITECTURE.md+++ b/docs/ARCHITECTURE.md@@ -142,7 +142,12 @@ The net effect: you still get a faithful 3D model from an image, but the expensi| `stage1_intake/run_vision_adapter.py` | Invoke optional isolated SAM2, MediaPipe, and Depth Anything evidence adapters. || `stage3_build/bake_projected_texture.py` | Emit a projection/UV-bake descriptor for photo-texture projection. |-### Character rig — `stage5_rig/`+### Character rig — `stage5_rig/` (library; the checklist authority is plugin-character)++The `animated-character` checklist steps and the rigging gate are served by the installed+plugin-character (`extract-animated-character`); the modules below remain in-repo as the library+the emitters import (`rig_spec` in the factory) and as reference implementations with their own+tests.| Script | Role || --- | --- |diff --git a/docs/GLB_ANIMATED_CHARACTER_PROMPT.md b/docs/GLB_ANIMATED_CHARACTER_PROMPT.mdindex 814c3ed..17310f7 100644--- a/docs/GLB_ANIMATED_CHARACTER_PROMPT.md+++ b/docs/GLB_ANIMATED_CHARACTER_PROMPT.md@@ -1,5 +1,11 @@# GLB animated-character prompt+> **Checklist authority note (extract-animated-character, 2026-09-03):** the `animated-character`+> profile is served by the installed **plugin-character** (`img2 add img2threejs/plugin-character`);+> its `domain.json` owns the rig-step order and invokes the plugin's `tools/` ports. The+> `forge/stage5_rig/...` commands below remain runnable as the base LIBRARY the emitters use, but+> the checklist runs the plugin's copies -- when the two disagree, the plugin is the authority.+One copy-paste prompt that carries a subject from a GLB reference to a **rigged, animated,gate-cleared** procedural Three.js character, for img2threejs 1.5.2 and later.diff --git a/docs/STAGE_R_BACKLOG.md b/docs/STAGE_R_BACKLOG.mdindex 38693c9..b69d201 100644--- a/docs/STAGE_R_BACKLOG.md+++ b/docs/STAGE_R_BACKLOG.md@@ -1,5 +1,11 @@# Stage R backlog — what is missing, in the order it should be closed+> **Checklist authority note (extract-animated-character, 2026-09-03):** the `animated-character`+> profile is served by the installed **plugin-character** (`img2 add img2threejs/plugin-character`);+> its `domain.json` owns the rig-step order and invokes the plugin's `tools/` ports. The+> `forge/stage5_rig/...` commands below remain runnable as the base LIBRARY the emitters use, but+> the checklist runs the plugin's copies -- when the two disagree, the plugin is the authority.+Distilled from building the 1.5.2 rigging and animation pipeline. Every claim here was verified byrunning something, not by reading; where a claim could not be verified it says so.diff --git a/docs/STAGE_R_TEST_PLAN.md b/docs/STAGE_R_TEST_PLAN.mdindex 68881b9..d182d38 100644--- a/docs/STAGE_R_TEST_PLAN.md+++ b/docs/STAGE_R_TEST_PLAN.md@@ -1,5 +1,11 @@# Stage R test plan — does the animation pipeline still break meshes?+> **Checklist authority note (extract-animated-character, 2026-09-03):** the `animated-character`+> profile is served by the installed **plugin-character** (`img2 add img2threejs/plugin-character`);+> its `domain.json` owns the rig-step order and invokes the plugin's `tools/` ports. The+> `forge/stage5_rig/...` commands below remain runnable as the base LIBRARY the emitters use, but+> the checklist runs the plugin's copies -- when the two disagree, the plugin is the authority.+A runbook for img2threejs 1.5.2, written to **falsify** the fix rather than confirm it.**Status of what it tests:** the Stage R modules are unit-tested (1343 tests, `OK (skipped=30)`) anddiff --git a/docs/standard-prompts/build.md b/docs/standard-prompts/build.mdindex d5ca30f..72b973b 100644--- a/docs/standard-prompts/build.md+++ b/docs/standard-prompts/build.md@@ -18,7 +18,7 @@ Rebuild the subject in this reference as a procedural Three.js model, using img2- Reference: <ABSOLUTE_PATH_TO_IMAGE>- Subject name: <SubjectName>- Demo id: <subject-id>-- Profile: <character | animated-character | object>+- Profile: <character | animated-character (requires plugin-character installed) | object>- Real longest dimension: <e.g. 1.70 m> # sanity-checks scale; never used to scale## Step 0 — Can this subject be built at all?diff --git a/forge/_shared/domains/animated_character.py b/forge/_shared/domains/animated_character.pydeleted file mode 100644index 52c0fda..0000000--- a/forge/_shared/domains/animated_character.py+++ /dev/null@@ -1,87 +0,0 @@-"""Animated-character domain profile (Stage R, v1.5.2's rigging/animation pipeline).--Ported from the hardcoded `RIG_STEPS`/profile branch v1.5.2 added on main into the registry the-CS2 extraction introduced, in the same merge that brought the two together: an animated character-is a character (same setup contributions) plus the rig track appended after the FINAL steps.--Rig docs: docs/pipelines/character-rigging-animation-1.5.2.md.--These rig steps exist as a checklist scope because the 1.5.2 gates were reachable only by hand:-every module under forge/stage5_rig/ was callable, and nothing in the workflow ever told anyone to-call one. A gate that nothing invokes reports a clean verdict forever, which is the exact failure-the whole gate system exists to end.--The ORDER of rigSteps is load-bearing and is not a preference:- - mesh repair happens BEFORE the freeze, because a mesh may legitimately need fixing;- - the freeze happens BEFORE any rig work, because after it the geometry is evidence;- - mesh-parity is verified AFTER binding, because that is the only moment the claim- "implementation did not touch the mesh" can be falsified.-Moving the freeze later would let a bind quietly rewrite vertices and then freeze the result, and-the manifest would certify the damage instead of catching it.-"""--from __future__ import annotations--from typing import Any, Final--DOMAIN: Final[dict[str, Any]] = {- "id": "animated-character",- # An animated character is still a character; the anatomy contract must not be lost. The two- # steps are declared here rather than imported from character.py: registry modules load- # independently (importlib by path), and each declaration stays readable on its own.- "setupSteps": (- (- "character-contract-read",- "Read grimoire/character/reconstruction.md and grimoire/character/likeness_maximization.md completely",- ),- (- "character-landmarks",- "python3 forge/stage1_intake/extract_landmarks.py {reference} --out anatomy.json --overlay landmarks.png",- ),- ),- "setupAnchorBefore": "local-spec-search",- "rigSteps": (- (- "rig-contract-read",- "Read grimoire/readiness/animation_contract.md and docs/pipelines/character-rigging-animation-1.5.2.md completely",- ),- (- "glb-rig-reference",- "python3 forge/stage5_rig/glb_rig_reference.py {reference} --out glb-rig.json "- "(skeleton, skin joint order, inverse binds and clips read FROM the GLB; skip with a reason only when there is no GLB)",- ),- (- "mesh-repair",- "Inspect the meshes for breakage and repair them now, before the freeze; "- "record what was repaired, or skip with a reason when nothing is broken",- ),- (- "mesh-freeze",- "node runtime/scripts/export_mesh_buffers.mjs --url <preview> --out meshes.json && "- "python3 forge/stage5_rig/mesh_parity.py freeze meshes.json --out mesh-manifest.json",- ),- (- "rig-payload-validate",- "python3 forge/stage5_rig/validate_rig_payload.py --payload rig-payload.json "- "(structural payload integrity ONLY -- never pose stress or likeness; a sculpt spec is NOT "- "a rig payload, they are different schemas)",- ),- (- "rig-bind",- "Bind the skeleton: ADD skeleton, skinIndex and skinWeight only. Vertex positions, normals, uvs and indices are frozen evidence",- ),- (- "mesh-parity-verify",- "node runtime/scripts/export_mesh_buffers.mjs --url <preview> --out meshes-after.json && "- "python3 forge/stage5_rig/mesh_parity.py verify mesh-manifest.json meshes-after.json",- ),- (- "clip-measure",- "python3 forge/stage5_rig/clip_features.py sampled-clips.json (measure, classify, name, and decide loop from poseReturn)",- ),- (- "rig-gates",- "python3 forge/stage5_rig/rig_gates.py rig-gate-payload.json (G1-G10; an unevaluated gate is not a pass)",- ),- ),-}diff --git a/forge/stage3_build/run_gates.py b/forge/stage3_build/run_gates.pyindex 54b64c6..7f2db27 100644--- a/forge/stage3_build/run_gates.py+++ b/forge/stage3_build/run_gates.py@@ -109,6 +109,14 @@ def domain_step_ids(profile: str, home: Path) -> tuple[str, ...]:return setup + passes+def domain_rig_step_ids(profile: str, home: Path) -> tuple[str, ...]:+ """The rig-track step ids a domain declares, or () when it declares none."""+ domain = domain_profile(profile)+ if domain is None:+ return ()+ return tuple(step_id for step_id, _ in (domain.get("rigSteps") or ()))++def domain_owner_plugin(profile: str, home: Path) -> str | None:"""The registry plugin id that owns this domain profile, derived from the REGISTRY LAYOUTitself rather than assumed. Each installed plugin's domain declaration lives at@@ -167,7 +175,16 @@ def plugin_contributed_a_step(state: dict[str, Any], plugin_id: str, home: Path)profile = state.get("profile")if profile and domain_owner_plugin(profile, home) == plugin_id:by_id = {entry["id"]: entry for entry in state.get("checklist", [])}- if any(+ rig_ids = domain_rig_step_ids(profile, home)+ if rig_ids:+ # Rig-aware participation (extract-animated-character, D1): a domain that declares a+ # rig track is not DUE until that track has begun. The gate sweep at plugin-gates runs+ # in the FINAL scope, strictly before the rig scope, and a rig domain's gate inputs are+ # produced by rig steps -- sweeping it on the strength of done SETUP steps fired the+ # gate one whole phase early, against a payload nothing had produced yet.+ if any(by_id.get(step_id, {}).get("status") == "done" for step_id in rig_ids):+ return True+ elif any(by_id.get(step_id, {}).get("status") == "done"for step_id in domain_step_ids(profile, home)):diff --git a/forge/state.py b/forge/state.pyindex eeba404..6021e42 100644--- a/forge/state.py+++ b/forge/state.py@@ -9,7 +9,7 @@ from pathlib import PathROOT = Path(__file__).resolve().parentsys.path.insert(0, str(ROOT / "_shared"))-from domains import registered_domains # noqa: E402+from domains import DomainRegistryError, registered_domains # noqa: E402from workflow_state import ( # noqa: E402WorkflowStateError,load_state,@@ -29,7 +29,15 @@ def build_parser() -> argparse.ArgumentParser:init.add_argument("--reference", required=True)# Choices come from the registry, so installing a domain makes its profile available here without# editing the base CLI. new_state() re-checks and names the available set on a bad value.- init.add_argument("--profile", choices=("generic", *sorted(registered_domains())), default="generic")+ # Guarded: registered_domains() at argparse-construction time is exactly the shape targets.py+ # documents avoiding -- a broken registry (e.g. a duplicate domain id during a half-applied+ # extraction) must degrade THIS parser to generic-only choices, not kill `status`/`mark` for+ # every profile on the machine. new_state() then reports the real registry error.+ try:+ profile_choices = ("generic", *sorted(registered_domains()))+ except DomainRegistryError:+ profile_choices = ("generic",)+ init.add_argument("--profile", choices=profile_choices, default="generic")init.add_argument("--spec", default="")init.add_argument("--max-per-pass", type=int, default=3)init.add_argument("--max-total", type=int, default=6)diff --git a/forge/tests/test_domain_registry.py b/forge/tests/test_domain_registry.pyindex 09ef0de..5e31bfd 100644--- a/forge/tests/test_domain_registry.py+++ b/forge/tests/test_domain_registry.py@@ -41,9 +41,9 @@ class Registry(unittest.TestCase):# happens to have under ~/.img2 -- the old form of this test asserted the INSTALLED cs2# plugin and was green or red depending on the machine, which is what turned CI red.with self._temp_img2_home({}):- self.assertEqual(sorted(registered_domains()), ["animated-character", "character"])+ self.assertEqual(sorted(registered_domains()), ["character"])with self._temp_img2_home({"fixture-plugin": {"id": "fixture-dom"}}):- self.assertEqual(sorted(registered_domains()), ["animated-character", "character", "fixture-dom"])+ self.assertEqual(sorted(registered_domains()), ["character", "fixture-dom"])def test_an_unregistered_profile_fails_loud_and_names_what_is_available(self) -> None:with self.assertRaises(DomainRegistryError) as ctx:diff --git a/forge/tests/test_rig_workflow_steps.py b/forge/tests/test_rig_workflow_steps.pyindex a4258ac..3ba6d37 100644--- a/forge/tests/test_rig_workflow_steps.py+++ b/forge/tests/test_rig_workflow_steps.py@@ -1,22 +1,22 @@#!/usr/bin/env python3-"""The Stage R checklist -- that it exists, and that its ORDER cannot drift.--This file exists because of a specific failure: every forge/stage5_rig/ module was callable and-nothing in the workflow ever told anyone to call one. `next.py` walks the checklist, so a gate-absent from the checklist is a gate that never runs, and a gate that never runs reports a clean-verdict forever.--The order assertions are the load-bearing half. "Repair, then freeze, then bind, then verify" is-not a stylistic preference -- moving the freeze after the bind would let the bind rewrite vertices-and then certify the rewritten buffer, so the manifest would attest to the damage instead of-catching it. A reordering like that is invisible in review and total in effect, which is exactly-the class of defect this suite is for.+"""The rig scope's dispatch mechanism -- that a registry domain declaring `rigSteps` reaches the+checklist, dispatches after the FINAL scope, and blocks completion while pending.++The `animated-character` domain itself moved to the plugin-character plugin+(`extract-animated-character`): its `domain.json` is now the canonical rig-step ORDER, pinned by+the plugin's own two-file drift pin (`tests/test_domain_declaration.py` there), so this file no+longer asserts order or command text against an in-repo module -- a fixture the test writes cannot+pin the real order, and pretending it can is a tautology. What the BASE owns, and what this file+tests, is the MECHANISM: the splice, the scope ordering, the dispatcher, and completion semantics.+Those are legitimately tested against a fixture domain. One test reads the *installed* plugin's+declaration when present, so the real order is still checkable from the base without depending on it.Pure Python 3.10+ stdlib."""from __future__ import annotations+import jsonimport osimport sysimport tempfile@@ -26,18 +26,46 @@ from pathlib import PathROOT = Path(__file__).resolve().parents[1]sys.path.insert(0, str(ROOT / "_shared"))-# Profiles resolve through the domain registry, which reads installed plugins from IMG2_HOME.-# Pinned to an empty temp home so a developer's real ~/.img2 (malformed or colliding domain.json)-# can never fail these tests -- the test_search_specs.py pattern.+from workflow_state import ( # noqa: E402+ WorkflowStateError,+ new_state,+ next_entry,+ recompute,+ status_payload,+)++# The fixture rig domain: exercises the mechanism, deliberately NOT the real animated-character+# order (the plugin owns that). Ids are fixture-local so no one mistakes this for the real track.+FIXTURE_RIG_STEPS = [+ ["fix-rig-first", "Read {plugin_dir}/contract.md completely"],+ ["fix-rig-mid", "Run python3 {plugin_dir}/tools/mid.py --out mid.json"],+ ["fix-rig-last", "Run python3 {plugin_dir}/tools/last.py --payload p.json"],+]+_TMP_HOME: tempfile.TemporaryDirectory | None = None_OLD_HOME: str | None = Nonedef setUpModule() -> None:+ """Pin IMG2_HOME to a scratch home carrying ONE fixture plugin that declares a rig domain --+ the registry's plugin path, which is how the real animated-character now arrives."""global _TMP_HOME, _OLD_HOME_TMP_HOME = tempfile.TemporaryDirectory()+ home = Path(_TMP_HOME.name)+ plugin_dir = home / "plugins" / "rig-fixture"+ plugin_dir.mkdir(parents=True)+ (home / "plugins.json").write_text(json.dumps({+ "version": 1,+ "plugins": [{"id": "rig-fixture", "repo": "x", "ref": "v1", "resolvedSha": "sha", "addedAt": "2026-01-01"}],+ }), encoding="utf-8")+ (plugin_dir / "domain.json").write_text(json.dumps({+ "id": "rig-fixture-dom",+ "setupSteps": [["fixture-contract-read", "Read {plugin_dir}/contract.md completely"]],+ "setupAnchorBefore": "local-spec-search",+ "rigSteps": FIXTURE_RIG_STEPS,+ }), encoding="utf-8")_OLD_HOME = os.environ.get("IMG2_HOME")- os.environ["IMG2_HOME"] = _TMP_HOME.name+ os.environ["IMG2_HOME"] = str(home)def tearDownModule() -> None:@@ -48,85 +76,37 @@ def tearDownModule() -> None:if _TMP_HOME is not None:_TMP_HOME.cleanup()-from domains.animated_character import DOMAIN as ANIMATED_CHARACTER # noqa: E402-from workflow_state import ( # noqa: E402- WorkflowStateError,- new_state,- next_entry,- recompute,- status_payload,-)-def rig_ids(state: dict) -> list[str]:return [step["id"] for step in state["checklist"] if step["scope"] == "rig"]-class AnimatedCharacterProfile(unittest.TestCase):+class RigDomainProfile(unittest.TestCase):def setUp(self) -> None:- self.state = new_state("subject.glb", profile="animated-character", spec="spec.json")+ self.state = new_state("subject.glb", profile="rig-fixture-dom", spec="spec.json")def test_the_profile_is_accepted(self) -> None:- self.assertEqual(self.state["profile"], "animated-character")+ self.assertEqual(self.state["profile"], "rig-fixture-dom")- def test_every_rig_step_reaches_the_checklist(self) -> None:- self.assertEqual(rig_ids(self.state), [step_id for step_id, _command in ANIMATED_CHARACTER["rigSteps"]])+ def test_every_declared_rig_step_reaches_the_checklist(self) -> None:+ self.assertEqual(rig_ids(self.state), [step_id for step_id, _ in FIXTURE_RIG_STEPS])- def test_it_keeps_the_character_steps_too(self) -> None:- """An animated character is still a character; the anatomy contract must not be lost."""+ def test_it_keeps_the_setup_contribution_too(self) -> None:ids = [step["id"] for step in self.state["checklist"]]- self.assertIn("character-contract-read", ids)- self.assertIn("character-landmarks", ids)+ self.assertIn("fixture-contract-read", ids)def test_a_plain_character_build_gets_no_rig_steps(self) -> None:"""Rigging is opt-in. A static character must not be blocked on animation gates."""self.assertEqual(rig_ids(new_state("subject.png", profile="character")), [])def test_profiles_without_rig_steps_get_none(self) -> None:- # "cs2" left this list when the domain moved to its installed plugin (a registry profile- # would need IMG2_HOME pinned here); generic and character cover the no-rigSteps rule.- for profile in ("generic", "character"):- with self.subTest(profile=profile):- self.assertEqual(rig_ids(new_state("subject.png", profile=profile)), [])+ self.assertEqual(rig_ids(new_state("subject.png", profile="generic")), [])def test_an_unknown_profile_is_still_refused(self) -> None:with self.assertRaises(WorkflowStateError):new_state("subject.glb", profile="animated")-class StageROrderIsLoadBearing(unittest.TestCase):- def setUp(self) -> None:- self.ids = rig_ids(new_state("subject.glb", profile="animated-character", spec="spec.json"))-- def index(self, step_id: str) -> int:- self.assertIn(step_id, self.ids)- return self.ids.index(step_id)-- def test_repair_precedes_the_freeze(self) -> None:- """A mesh may legitimately need fixing; freezing a broken mesh certifies the breakage."""- self.assertLess(self.index("mesh-repair"), self.index("mesh-freeze"))-- def test_the_freeze_precedes_every_rig_step(self) -> None:- """After the freeze the geometry is evidence. Binding before it leaves nothing to compare."""- freeze = self.index("mesh-freeze")- self.assertLess(freeze, self.index("rig-payload-validate"))- self.assertLess(freeze, self.index("rig-bind"))-- def test_parity_is_verified_after_the_bind(self) -> None:- """Binding is the only moment "implementation did not touch the mesh" can be falsified."""- self.assertLess(self.index("rig-bind"), self.index("mesh-parity-verify"))-- def test_the_glb_reference_precedes_binding(self) -> None:- """Rigging refers FROM the GLB, so its skeleton must be read before anything is bound."""- self.assertLess(self.index("glb-rig-reference"), self.index("rig-bind"))-- def test_the_contract_is_read_first(self) -> None:- self.assertEqual(self.ids[0], "rig-contract-read")-- def test_the_gates_run_last(self) -> None:- self.assertEqual(self.ids[-1], "rig-gates")--class TheDispatcherActuallyReachesThem(unittest.TestCase):"""The half the first version of this suite missed, and the reason it is written this way now.@@ -134,8 +114,7 @@ class TheDispatcherActuallyReachesThem(unittest.TestCase):passed while `next_entry()` had no branch for scope "rig" at all: the steps sat pending forever,`recompute()` declared the build `complete` after the final scope, and `next.py` never once askedfor a rig step. Presence in a list is not reachability, and asserting the list is not asserting- the behaviour -- which is precisely the defect the Stage R wiring exists to end, reproduced one- layer up. These tests drive the real state machine instead.+ the behaviour. These tests drive the real state machine against the fixture domain."""def drain(self, profile: str) -> tuple[list[str], dict]:@@ -160,12 +139,12 @@ class TheDispatcherActuallyReachesThem(unittest.TestCase):return dispatched, statedef test_every_rig_step_is_actually_dispatched(self) -> None:- dispatched, _state = self.drain("animated-character")- self.assertEqual(dispatched, [step_id for step_id, _command in ANIMATED_CHARACTER["rigSteps"]])+ dispatched, _state = self.drain("rig-fixture-dom")+ self.assertEqual(dispatched, [step_id for step_id, _ in FIXTURE_RIG_STEPS])def test_the_build_is_not_complete_while_a_rig_step_is_pending(self) -> None:- """The exact bug: `complete` was reached with all nine rig steps still pending."""- state = new_state("subject.glb", profile="animated-character", spec="spec.json")+ """The exact bug this suite exists for: `complete` reached with rig steps still pending."""+ state = new_state("subject.glb", profile="rig-fixture-dom", spec="spec.json")state["currentPass"] = "complete"for step in state["checklist"]:if step["scope"] != "rig":@@ -176,59 +155,60 @@ class TheDispatcherActuallyReachesThem(unittest.TestCase):def test_rig_steps_come_after_the_final_scope(self) -> None:"""Rigging is additive to a finished mesh; binding one whose parts still move freezes- geometry that has not settled."""- dispatched, _state = self.drain("animated-character")- state = new_state("subject.glb", profile="animated-character", spec="spec.json")+ geometry that has not settled. This ordering is also why gate participation is rig-aware+ (run_gates.py): the plugin-gates sweep in FINAL runs before any rig step can produce."""+ dispatched, _state = self.drain("rig-fixture-dom")+ state = new_state("subject.glb", profile="rig-fixture-dom", spec="spec.json")order = [step["scope"] for step in state["checklist"]]self.assertLess(max(i for i, s in enumerate(order) if s == "final"),min(i for i, s in enumerate(order) if s == "rig"))self.assertTrue(dispatched)def test_a_plain_character_build_still_completes(self) -> None:- """Adding the rig scope must not strand a profile that has no rig steps."""dispatched, state = self.drain("character")self.assertEqual(dispatched, [])self.assertEqual(state["status"], "complete")def test_rig_steps_are_visible_in_status(self) -> None:"""Invisible in status output is unreachable in practice: nobody knows to run them."""- state = new_state("subject.glb", profile="animated-character", spec="spec.json")+ state = new_state("subject.glb", profile="rig-fixture-dom", spec="spec.json")pending = status_payload(state)["pending"]- for step_id, _command in ANIMATED_CHARACTER["rigSteps"]:+ for step_id, _ in FIXTURE_RIG_STEPS:self.assertIn(step_id, pending)-class StepsNameTheirTooling(unittest.TestCase):- def setUp(self) -> None:- self.commands = dict(ANIMATED_CHARACTER["rigSteps"])-- def test_each_gate_step_names_the_script_that_runs_it(self) -> None:- for step_id, script in (- ("glb-rig-reference", "glb_rig_reference.py"),- ("mesh-freeze", "mesh_parity.py"),- ("mesh-parity-verify", "mesh_parity.py"),- ("rig-payload-validate", "validate_rig_payload.py"),- ("clip-measure", "clip_features.py"),- ("rig-gates", "rig_gates.py"),+class InstalledPluginOrderIsCheckedWhenPresent(unittest.TestCase):+ """The canonical animated-character order lives in the installed plugin's domain.json (the+ plugin's own suite pins it with a two-file pin). This base-side check reads the REAL installed+ declaration when one exists, so the load-bearing sequence stays checkable from here without+ making the base depend on the plugin."""++ def test_installed_animated_character_order_invariants(self) -> None:+ home = Path(os.environ.get("IMG2_REAL_HOME") or Path.home() / ".img2")+ declaration = home / "plugins" / "character" / "domain.json"+ if not declaration.is_file():+ self.skipTest("plugin-character not installed; the plugin's own suite pins the order")+ ids = [step_id for step_id, _ in json.loads(declaration.read_text(encoding="utf-8"))["rigSteps"]]+ order = {step_id: index for index, step_id in enumerate(ids)}+ self.assertLess(order["mesh-repair"], order["mesh-freeze"])+ self.assertLess(order["mesh-freeze"], order["rig-bind"])+ self.assertLess(order["rig-bind"], order["mesh-parity-verify"])+ self.assertEqual(ids[0], "rig-contract-read")+ self.assertEqual(ids[-1], "rig-gates")+++class SetupStepAssetsAgreement(unittest.TestCase):+ """The plugin's animated-character setupSteps reference these base assets verbatim and+ base-relative (its static-character half stays in-repo). Doctor cannot file-check domain rows,+ so THIS is the enforcement point: renaming either asset must fail here, not in a user's run."""++ def test_the_referenced_setup_assets_exist(self) -> None:+ for rel in (+ "grimoire/character/reconstruction.md",+ "grimoire/character/likeness_maximization.md",+ "forge/stage1_intake/extract_landmarks.py",):- with self.subTest(step=step_id):- self.assertIn(script, self.commands[step_id])-- def test_freeze_and_verify_use_the_matching_subcommands(self) -> None:- self.assertIn("mesh_parity.py freeze", self.commands["mesh-freeze"])- self.assertIn("mesh_parity.py verify", self.commands["mesh-parity-verify"])-- def test_the_bind_step_states_what_it_may_add(self) -> None:- """The whole mesh-immutability rule lives in this string; a rewrite that drops it is a bug."""- command = self.commands["rig-bind"]- for token in ("skinIndex", "skinWeight", "frozen"):- self.assertIn(token, command)-- def test_the_payload_validator_states_its_own_limits(self) -> None:- """A green structural payload is not evidence the mesh survives animation."""- self.assertIn("structural payload integrity ONLY", self.commands["rig-payload-validate"])- # The CLI takes --payload, and a sculpt spec is a different schema from a rig payload.- self.assertIn("--payload", self.commands["rig-payload-validate"])+ self.assertTrue((ROOT.parent / rel).is_file(), rel)if __name__ == "__main__":diff --git a/forge/tests/test_run_gates.py b/forge/tests/test_run_gates.pyindex be55a51..b1c6163 100644--- a/forge/tests/test_run_gates.py+++ b/forge/tests/test_run_gates.py@@ -212,6 +212,64 @@ class UninvolvedPluginRunsNone(RunGatesTestBase):self.assertEqual(results, {})+class RigDomainsAreNotDueUntilTheRigTrackBegins(RunGatesTestBase):+ """extract-animated-character D1: the gate sweep at plugin-gates (FINAL scope) runs before the+ rig scope, and a rig domain's gate inputs are produced by rig steps -- participation on the+ strength of done SETUP steps fired the blocking gate one whole phase early, against a payload+ nothing had produced yet (machine-proven in review)."""++ def _write_rig_domain(self, plugin_id: str) -> None:+ (self.home / "plugins" / plugin_id / "domain.json").write_text(json.dumps({+ "id": "rig-dom",+ "setupSteps": [["rig-dom-setup", "Read {plugin_dir}/contract.md completely"]],+ "setupAnchorBefore": "local-spec-search",+ "rigSteps": [["rig-dom-track", "Run python3 {plugin_dir}/tools/track.py --payload p.json"]],+ }), encoding="utf-8")++ def _state_with(self, done_ids: list[str]) -> dict:+ state = _action_ready_state(self.workspace, self.spec_path, profile="rig-dom")+ for entry in state["checklist"]:+ entry["status"] = "done" if entry["id"] in done_ids else "pending"+ from workflow_state import save_state+ save_state(self.workspace / ".img2threejs" / "state.json", state)+ return state++ def test_setup_steps_alone_do_not_involve_a_rig_domain(self):+ _write_gated_plugin(+ self.home, "rigged",+ gate_body=PASS_GATE.format(gate_id="rigged-gate", plugin_id="rigged"),+ )+ self._write_rig_domain("rigged")+ state = self._state_with(["rig-dom-setup", "action-ready"])+ self.assertFalse(run_gates.plugin_contributed_a_step(state, "rigged", self.home))++ def test_a_done_rig_step_makes_the_domain_due(self):+ _write_gated_plugin(+ self.home, "rigged",+ gate_body=PASS_GATE.format(gate_id="rigged-gate", plugin_id="rigged"),+ )+ self._write_rig_domain("rigged")+ state = self._state_with(["rig-dom-setup", "rig-dom-track", "action-ready"])+ self.assertTrue(run_gates.plugin_contributed_a_step(state, "rigged", self.home))++ def test_a_domain_without_rig_steps_keeps_the_old_rule(self):+ _write_gated_plugin(+ self.home, "plain",+ gate_body=PASS_GATE.format(gate_id="plain-gate", plugin_id="plain"),+ )+ (self.home / "plugins" / "plain" / "domain.json").write_text(json.dumps({+ "id": "plain-dom",+ "setupSteps": [["plain-setup", "Read {plugin_dir}/contract.md completely"]],+ "setupAnchorBefore": "local-spec-search",+ }), encoding="utf-8")+ state = _action_ready_state(self.workspace, self.spec_path, profile="plain-dom")+ for entry in state["checklist"]:+ entry["status"] = "done" if entry["id"] == "plain-setup" else "pending"+ from workflow_state import save_state+ save_state(self.workspace / ".img2threejs" / "state.json", state)+ self.assertTrue(run_gates.plugin_contributed_a_step(state, "plain", self.home))++class ParticipationLookupFailureFailsLoudNotOpen(RunGatesTestBase):"""A DomainRegistryError during the participation check used to be swallowed as "uninvolved",which silently skipped a blocking gate whose domain steps had actually run -- fail-open in the