Skip to content

docs: design static residents that stop costing per-update work - #5062

Merged
jakildev merged 13 commits into
masterfrom
claude/5008-static-resident-design
Nov 15, 2026
Merged

jakildev merged 13 commits into
masterfrom
claude/5008-static-resident-design

Conversation

@jakildev

@jakildev jakildev commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

The repository owner merges this PR. It records a semantics decision (what a static resident entity is and what every system may assume about it), so the fleet's merge path does not merge it. #5009 implements the merged document and stays blocked until then.

Summary

  • Adds docs/design/static-residents.md: the design for how a resident entity that cannot change stops costing per-update work.
  • The mechanism is two archetype tags. The owner declares an entity static with C_Static, which removes it from every system and query that writes its pose inputs, on every C++ and Lua lane. The ordinary systems then derive from the frozen inputs once more in pipeline order. After a complete round that opened after the inputs last changed, the engine adds C_Settled, which removes the entity from them. No second code path computes derived state, and no system's per-row work reads a flag or compares a value.
  • Any change to a settling entity's inputs restarts its wait: a mutation, a hold, or a global-modifier change, even when it lands mid-round or just before promotion. The settle stamp on C_Static and one world-scoped global floor carry this; the drain raises the floor before it judges any promotion. Rounds are counted per pipeline group on the main thread, so deriving systems that share a parallel group are covered. One round spans INPUT, UPDATE and RENDER, so a drain after an UPDATE pass cannot promote before a RENDER-placed deriving system has run. Every round counter is 64-bit.
  • Every engine mutator reaches the entity it changes and thaws or resettles it. The C_VoxelSetNew methods reach theirs through the ownerEntityId_ the set already stores, with no signature change and no new bytes. Attaching or detaching any other component returns a settled entity to settling. A CHILD_OF change (setParent, clearParent, detachChildren, Lua) or a parent's destruction resettles the static subtree inside the entity-layer call, through two entity-layer traits and a tracked-change log the drain reads, so the entity layer never names IRPrefab::Static. A typed overwrite of a component the entity already carries (setComponent, setComponents, setComponentDeferred, and the Lua bindings over them) resettles it inside setComponent through the same handling; only raw-reference writes are retained without being derived. A destroyed parent's surviving children keep their link and derive as roots, exactly as dynamic children do; that derivation needs the defect fix in engine/update: PROPAGATE_TRANSFORM asserts on a child whose parent was destroyed #5080.
  • The matching rule is a guard trait on each pose component, recorded per ComponentId by the entity layer. One exclusion function on every registration and query lane applies it, and nothing has to be installed at startup. A system's declared exclusions are kept apart from the effective filter the policy rebuilds from them, so reclassifying a system never loses an authored Exclude<C_Static>. Only a registered pipeline system can be a deriving round member; a one-shot query (executeQuery, executeQueryDynamic) never is, so a query that writes pose inputs or derived pose visits no static row, and executeQueryDynamic gains a defaulted readOnly archetype so a runtime reader still sees them. The tags live in the system layer, which applies the rule.
  • C_Settled is engine-owned by construction. Only IRSystem::promoteSettled can attach it, through an entity-layer key, and it re-checks the transition rule against the system layer's round counters, global floor and stamp. Every typed attach lane is constrained against it, and the by-id, Lua and snapshot lanes refuse it at run time. The settle stamp is private, and a copied C_Static arrives with a zero stamp.
  • Becoming dynamic again removes both tags. Each transition is one archetype move, deferred to the next structural flush.
  • The fog reveal evaluators and the LOD gate also read world-scoped inputs. They keep matching settled rows and return once per archetype node unless one of those inputs changed. The document tables every trigger.
  • No scheduler-level conditional skip is added; the document says why the four deferred contract questions do not arise.
  • Adds docs/perf/static-resident-design/structural-move-probe.txt: the component sizes on this tree and the measured cost of an archetype move, with the throwaway probe's source reproduced in the file.

Decisions the owner is asked to sign

The document closes with the full list. The ones that change an existing rule or contract:

  1. Four rule passages reworded or extended, with exact replacement text: three in .claude/rules/cpp-ecs.md and one in engine/prefabs/irreden/voxel/CLAUDE.md. Today they say per-frame work on a rendered entity is unconditional. The edits themselves land with engine: stop paying per-update work for resident entities that cannot change #5009.
  2. A system or query that declares a write to a pose input never matches a static entity. This is what makes the forbidden write impossible instead of a convention. It only affects entities that carry C_Static. A Lua system counts every listed component as written unless it is under a new reads key. A deriving system is a registered pipeline system that excludes C_Settled or carries GatesSettled; a one-shot query is never one, so a query that writes derived pose also skips static entities. PROPAGATE_TRANSFORM and MODIFIER_RESOLVE_GLOBAL must const-correct their input packs.
  3. C_Static and C_Settled live in engine/system/, and an entity-layer trait marks the pose components. Today's prefab-owned layout cannot express the rule without the system layer depending on prefabs. C_Settled is a restricted component: no public C++, Lua or snapshot lane can attach it, and the one call that can (IRSystem::promoteSettled) re-checks the rule itself.
  4. Promotion waits for a round that opened after the last change. That covers every change while settling, plus every global-modifier change. While a global changes every update, nothing is promoted. A round completes group by group across INPUT, UPDATE and RENDER, and only its last deriving group closes it, so deriving systems may share a parallel group or sit in RENDER, and the counters are std::uint64_t with no wrap rule.
  5. Modifiers on a static entity are frozen, and a global modifier pushed after it settles does not reach it. A creation that needs one to apply thaws the entity.
  6. A raw write through getComponent is retained but not derived until the entity is resettled or thawed. An assert build audits for it, LOD band included.
  7. Fog cost for static subjects is unchanged while the fog changes every update (moving vision sources). It is zero while the fog is still. Bounding it by region is left to a follow-up.
  8. Memory per resident does not fall (about 498 bytes before, about 507 after). What falls is the bytes streamed per update, from about 760 to zero.
  9. createEntity is unchanged, and no mutator's signature changes.

Test plan

  • git diff --stat origin/master...HEAD: two files, both under docs/.
  • python3 scripts/lint_instruction_size.py --against origin/master: exit 0. No CLAUDE.md is touched.
  • python3 scripts/lint_instruction_refs.py: 0 dead reference(s). It exits 1 on three stale baseline entries in docs/agents/AGENTS-ARCHITECTURE.md and docs/agents/architect-protocol.md, which this PR does not touch.
  • python3 scripts/lint_comment_refs.py: exit 0.
  • Every in-document ](#anchor) link resolves to a heading (checked with a slug script).
  • Every repository path the document cites resolves on origin/master, and every § citation names a heading that exists there. The citations added in this revision were checked against the source they name: the ownerEntityId_ adoption branch in system_update_voxel_set_children.hpp, markPoolRecordsChanged → withPoolByEntity and the inline priority calls in component_voxel_set.hpp, the Lua lodMin / lodMax properties in component_voxel_set_lua.hpp, removeBySource's forEachComponent walk, the CODEGEN createSystem<…> emitter, createSystemDynamic, executeQuery / executeQueryDynamic, and registerComponent<T>.
  • The probe ran three times in Release (fleet-run --release IrredenEngineTest --gtest_filter='StaticProbe.*'); the output is the evidence file. The probe source and its test/CMakeLists.txt line were removed before the commit.

Acceptance evidence

Criterion Check run Observed
1. One document, one PR: one design document under docs/design/, run files under docs/perf/ if it cites new measurements, no engine, creation or test source git diff --stat origin/master...HEAD; git diff --name-only origin/master...HEAD | grep -vc '^docs/' docs/design/static-residents.md | 1911 +, docs/perf/static-resident-design/structural-move-probe.txt | 171 +, 2 files changed; 0 paths outside docs/
2. Every question answered: a section per bullet, and a sentence per named system and reader on what it may assume about a static entity grep -n '^## |^### ' docs/design/static-residents.md Sections "What makes an entity static", "Transitions" (freeze, settle, thaw, resettle, other archetype moves, a parent change, engine mutators), "What each system and reader may assume", "Forbidden writes", "The matching policy", "How it fits the ECS rules", "The bytes", "Public contract changes", "Fixtures and gates". The assume tables carry a row for PROPAGATE_TRANSFORM, UPDATE_VOXEL_SET_CHILDREN (both placements), the fog evaluators with a trigger row for field cells, vision sources, the published line-of-sight field, the settings and the active canvas, MODIFIER_DECAY, the LOD gate, REBUILD_GRID_VOXELS, collision, picking, snapshots, chunk residency and parent/child links. Each engine mutator row names how it reaches the entity, and the matching policy has a row per registration and query lane
3. Rules named by file and section; a requested rule change stated as exact replacement text grep -c '§ "' docs/design/static-residents.md; grep -n '^\*\*[1-4]\. ' docs/design/static-residents.md 27 section citations; the table under "How it fits the ECS rules" maps each part of the mechanism to one; four numbered changes under "Rule changes requested", each quoting the replacement text
4. Gates fixed: each default gate adopted or replaced by a measurable check with fixture, build type and threshold; the mostly-static fixture named grep -n '^\*\*Gate [0-9]' docs/design/static-residents.md Nine gates. Defaults 1 and 3 replaced with the reason stated, 2 and 4 to 7 adopted, 8 and 9 new. Gate 4 adds the cutover tests: a mid-round change after each deriving system, resettle while settling, a global push in the window (including one after round close that only the floor can hold), global churn, holds, two grouped deriving systems (worker pool and serial, mixed cadence), a cross-pipeline round with UPDATE_VOXEL_SET_CHILDREN in RENDER that no UPDATE drain may promote, a membership change mid-round, counters run across 2^32, and a mutation right after promotion. Gate 5 adds entity-aware voxel and LOD mutation from C++ and Lua, owner adoption, archetype moves (including no immediate re-promotion after an attach), parent changes (setParent, setRelation, clearParent, detachChildren from C++ and Lua, a dynamic new parent, eager and deferred destruction of a static parent (survivors keep their link to the dead id and derive as roots, equal to the twin), a hook re-parent, destroyTree, a dynamic subtree untouched, creation and snapshot load under a parent), typed overwrites (setComponent, setComponents and setComponentDeferred of an already-present C_LocalTransform, C_LodTierOverride and C_Modifiers on a settled and a settling static tree, with the dynamic-subtree no-op and the raw setLuaField control), one test per system lane (including round membership) and per query lane (no static row visited by a derived-pose writer, even with Exclude<C_Settled>, and round counters and stamps untouched), declared exclusions surviving addSystemExcludeTag<C_Settled> reclassification, and the engine-owned boundary (every typed lane refuses C_Settled at compile time and the private insertNewComponent helper is inaccessible, the by-id, Lua and snapshot lanes at run time, a direct promoteSettled promotes nothing early, a copied C_Static arrives with a zero stamp, and removing either tag restarts or ends the wait). Fixtures: "Mostly-static million", the control's command plus --moving-fraction 0.01, and "Recolored dynamic million" for gate 6
5. Every number marked measured, read from source or estimated; a measured one carries command, build type, host and date Read of the "Evidence" table, the "Source" column of "The bytes" and the "Cost per entity" section Each reading names its kind. The measured ones name the command or the PR that recorded them, Release, Apple M4 Max and the date; the new measurement is committed as the probe file. The ownerStatic_ padding claim is read from source (the C_VoxelSetNew field order and the std::uint32_t LodLevel) and is held by the header's static_assert
6. The PR body's first line says the owner merges it This body First line above. The ticket closes on the owner's merge
7. python3 scripts/lint_instruction_size.py passes if any CLAUDE.md gains a pointer git diff --name-only origin/master...HEAD | grep -c 'CLAUDE.md'; python3 scripts/lint_instruction_size.py --against origin/master 0 CLAUDE.md files touched, so no pointer was added; the lint exits 0 against master

Plan departures

  • The ticket's sizes were read from a 2026-10-04 log (C_VoxelSetNew 192 bytes). On this tree it is 200, so the resident is about 498 bytes, not 490. The document uses the re-measured value, as the ticket asked.
  • The ticket's gotcha says a structural change costs microseconds per entity. Measured here it is 0.20 to 0.28 µs to add a tag and 0.06 to 0.07 µs to remove one. A million in one flush is still 200 to 275 ms, so the design keeps a per-round cap on promotions.
  • Plan corrections A1 and A2 are absorbed: the UPDATE_VOXEL_SET_CHILDREN statement holds in either pipeline because a round is defined over whatever the creation registered; gate 1 reads a new Walked count where Entities only measures matching; and the document says no conditional system skip is needed.
  • The base readings are PR engine/voxel: run voxel-set position updates once per rendered frame #5046's four interleaved rounds, not a new session. The gates re-measure base and head together, as engine: stop paying per-update work for resident entities that cannot change #5009's plan already requires.
  • No CLAUDE.md pointer was added (the plan allows at most one). The mechanism does not exist yet, and a pointer from an instruction file would describe it as if it did. engine: stop paying per-update work for resident entities that cannot change #5009 adds the instruction text with the code.
  • The tags move from engine/prefabs/irreden/common/components/ (the first revision) to engine/system/. The review showed that the system layer cannot name a prefab-owned marker without reversing the module dependency.

Notes for reviewer

  • Head moved for Gate 3 (a10a847b9 → 850fa64e9). The approval at a10a847b9 does not cover this edit: the changed head needs a fresh review, and the owner still merges. Per the steward direction and engine: design how a resident entity that cannot change stops costing per-update work #5008 A3 (from the engine: fixed-update cost at a million resident entities #5004 design answer, Q1 to Q3), only § "Gates" Gate 3 and the § "Fixtures" witness list and start assert changed. The million control now gates zero submitted position-upload bytes and zero position/alpha write-invalidation notifications after settlement and cache warm-up, holds write-driven cull rebuild work at zero, and reports camera/projection-only rebuild work without gating it; a frame with both causes keeps its write evidence. The write witness counts at C_VoxelPool::markCullBoundsDirty(start, count), before the per-chunk pending bit, queue saturation or either cache consumer; total and camera / full-rebuild counts stay visible, and causes are documented as overlapping (no inference by subtraction). Positive controls: a position write and an alpha-only write each give a nonzero witness, also on a full cardinal rebuild frame; a camera-only change keeps it at zero with nonzero rebuild work. The start assert proves settlement and the cache debt (queued position ranges, pending cull chunks, stale light-grid world boxes) separately. The mostly-static million is unchanged: --moving-fraction 0.01, gate 8's population, 0 < submitted position bytes per frame <= 160,000; a pre-cap queue count is supporting evidence only.
  • The tenth needs-fix review (head bc462f846) is answered in b70518d8c: EntityManager::insertNewComponent<T> was a public typed attach path below setComponent that moved the entity into the destination archetype itself, outside the refusal table. § "The engine-owned boundary" now makes it private with the same GenericAttachable constraint (its only caller is setComponent; no engine or creation code calls it), inventories the other public members that move an entity (relation calls and removals add no component id; stageStructuralChange, findCreateArchetypeNode and getComponentData attach nothing), and adds a backstop at the lowest boundary: the private primitives moveEntityByArchetype, insertEntityToNode and inserComponentsBatch assert when an entity enters a restricted archetype from outside the key's apply step. Gate 5 adds static_assert(!requires { em.insertNewComponent<C>(…); }) for C_Settled and C_Static, with setComponent<C_Static> as the positive control; the public contract table, layer table, decision 2 and the summary follow.
  • The eleventh needs-fix review (head b70518d8c) is answered in a10a847b9: setComponent on a component the entity already carries assigned into the existing column without a move, so setComponent / setComponents / setComponentDeferred could change a settled entity's frozen inputs (every entity carries C_LocalTransform) without dropping C_Settled or restamping. New § "A typed overwrite: settled or settling to settling": the overwrite branch, keyed on the cached C_Static node bit (the trait is renamed kTracksInputChanges<T>, since it now gates both rules), drops C_Settled if present, logs the id, walks the static descendants when kStaticGuard<T> is not NONE, then assigns and returns a reference into the post-move column. It keys on the node, not on T, so C_LodTierOverride, fog subject components and creation components are covered without an inventory. The Lua-typed by-id row writes (attachComponentFromLua on a present IRComponent.register component, IREntity.setLuaField) are classified as the raw path. The summary, stamp-event and route-into-settling tables, engine-mutator table, LOD triggers, forbidden writes (now four paths), layer table, public contract table, Gate 5 (a "Typed overwrites" block) and decision 6 follow.
  • The ninth needs-fix review (head 7ded02267) is answered in bc462f846:
    • Engine-owned boundary: new § "The engine-owned boundary" under "The mechanism". IRSystem::promoteSettled is the only call that attaches C_Settled. It re-checks each row (live, C_Static without C_Settled, nonzero stamp, roundsCompleted_ >= max(stamp, globalFloor_)), so a caller other than the drain can promote nothing early. globalFloor_ moves to the system manager for that reason. The attach goes through EntityManager::attachEngineComponentDeferred<T> with an IREntity::EngineAttachKey<T> that only IRSystem::detail::SettlePromoter can construct, named by an IREntity::EngineAttach<T> specialization in component_static.hpp. At apply time the attach is dropped if C_Static is gone.
    • Generic lanes: the typed lanes (createEntity and its batch helpers, insertReservedEntity, createEntitiesBatch, setComponent, setComponents, setComponentDeferred, singleton<T>) carry a GenericAttachable constraint, so C_Settled does not compile there. A constraint can be tested in an ordinary build with static_assert(!requires …). addComponentDynamic (Lua), getOrCreateSingletonByComponentId and restoreEntitiesBatch read a per-ComponentId restricted bit and refuse in a plain branch, so release refuses as well. The snapshot loader strips the id, and Lua has no binding.
    • The stamp half of the same bypass: a C_Static copied from a settled entity would have carried a satisfied stamp into a settling row. settleStamp_ is now private, and copies produce zero. Every typed attach lane copies from const &. The noexcept move constructor and the private move assignment (friend: the column's packInto) keep the stamp across column moves, which never copy (i_component_data.hpp).
    • Removal stays open on every lane and is logged, so it only restarts the wait. Gate 5 gains an "engine-owned boundary" block, and the layer table, rule map, public contract table, drain steps 2 to 4, decision 2 and the summary follow.
  • The eighth needs-fix review (head 035c1c115) is answered in 7ded02267:
    • One-shot queries: § "The matching policy" limits deriving membership to registered pipeline systems and adds a "One-shot queries" paragraph. executeQuery and executeQueryDynamic register nothing (ir_system.hpp on 369cb6b06), so they cannot join a group, a pending set or the cursor. Every query is non-deriving: applyStaticExclusion now takes a caller-computed deriving flag, which query lanes pass as false. A derived-pose writer query excludes C_Static even with Exclude<C_Settled> (the write is not rejected, so commands on dynamic rows are unchanged); GatesSettled in an executeQuery pack is a static_assert, since FilterTags_t would otherwise drop it silently.
    • Runtime-query read/write: executeQueryDynamic gains a readOnly archetype parameter after the body, defaulting to empty (all-write, today's callers unchanged). Like a direct createSystemDynamic it is a declaration the node body cannot have enforced; a write to a readOnly pose column on a settled row is the raw path.
    • Gate 5 splits "Every lane" into a system-lane matrix (round membership tested as delayed promotion) and a query-lane matrix (readers see static rows, writers see none with or without Exclude<C_Settled>, and roundsOpened/roundsCompleted, stamps and promotion timing are unchanged by the call). The public contract table, migration step 4 and a new step 5, and decision 7 follow.
  • The seventh needs-fix review (head 0477a655e) is answered in 035c1c115:
    • Parent destruction: § "A parent change" now states what a surviving child becomes. The rule never removes its link, so getParent still returns the dead id and getChildren of that id still lists it. It is an orphan, which the eligibility section now defines as a root through a findRecord probe. PROPAGATE_TRANSFORM composes it under the identity parent, the same as its dynamic twin. The order inside destroyEntity is spelled out: hooks, then the rule (tag move, log, descendant walk while the parent is still live), then teardown. Clearing the link is rejected with the reason: it would make getParent depend on C_Static, or change destroyEntity for every entity.
    • Pre-existing defect found and filed as engine/update: PROPAGATE_TRANSFORM asserts on a child whose parent was destroyed #5080: on 369cb6b06, PROPAGATE_TRANSFORM's buildSignature and level pass read the parent through getEntityRecord, which asserts on a dead id. A scratch PropagateTransformTest (destroy the parent, then tick) throws the getRecord assert, and the child's world transform stays at the parent-composed value. In Release that path dereferences null. § "Scope" and decision 4 record the dependency. Gate 5's destruction case (needs engine/update: PROPAGATE_TRANSFORM asserts on a child whose parent was destroyed #5080) asserts the link, getChildren, findRecord, the root composition and twin equality after eager and deferred destruction.
  • The sixth needs-fix review (head 840aff50d) is answered in 0477a655e:
    • Settled change notes: § "Settle", drain step 1 now stamps every note or entry whose entity is still static, settled or settling, and a settled note queues the removal of C_Settled only after its stamp is written. The row is still in a settled node at step 3, so without the stamp it re-entered settling at step 5 with the already-satisfied stamp of the round that promoted it. A new paragraph and table after the drain list every route into settling and what keeps its stamp current. The same gap was in resettle's descendant cascade, which queued the removals but recorded a note only for the entity; § "Resettle" now records one per descendant. The stamp-events table, the forbidden-writes row and decision 3 say the same. Gate 4's "Mutation right after promotion" runs the voxel edit (and setLodBand, a fog setter) through runMainLoopFrame with the cross-pipeline placement, in each pipeline and between frames, and asserts the stamp at the applying drain and no promotion at any later INPUT or UPDATE drain before a round opened after the edit closes; it also covers the cascade.
  • The fifth needs-fix review (head e267e5e21) is answered in 840aff50d:
    • Declared vs policy exclusions: § "The matching policy" gains a "Declared and effective exclusions" paragraph. SystemManager::addSystemExcludeTag inserts into the single excludeArchetype_ in place today (read on 369cb6b06), so a policy-added C_Static could not be told from an authored Exclude<C_Static>. Each system now keeps declaredExcludeArchetype_ (never written by the policy) and records its write guard and GatesSettled bit at creation. The dynamic lanes' SystemAccess is empty, so the guard has to be taken while the lane still has the write set. applyStaticExclusion(declaredExclude, writeGuard, gatesSettled) is pure and rebuilds excludeArchetype_ on every filter change; deriving membership reads the declared set. Gate 5 adds the requested test: a plain writer and one declared Exclude<C_Static> (plus one given addSystemExcludeTag<C_Static> after creation, both call orders, and a Lua EVAL variant) reclassified with addSystemExcludeTag<C_Settled>.
  • The fourth needs-fix review (head 0c618e14e) is answered in e267e5e21:
    • Parent-link changes: new § "A parent change: settled or settling to settling". Every public CHILD_OF path funnels into EntityManager::setChildOfRelation, and parent destruction goes through EntityManager::destroyEntity after the pre-destroy hooks. Both apply an entity-layer rule driven by IREntity::kTracksParentChain<T>, which component_static.hpp specializes for C_Static, depending downward. The rule drops C_Settled in the same move, walks the static descendants, and logs every handled id to EntityManager::takeTrackedChanges; the drain stamps each entry and re-runs eligibility (a dynamic new parent refuses it). The semantics are now a resettle, not a thaw. A thaw would have stripped C_Static from entities created with a parent or loaded from a snapshot, both of which go through setParent. The resettle runs at once, inside the eager call. The same log also closes a gap in the generic foreign-move rule: dropping C_Settled left the old stamp in place, so the next drain could re-promote the row without re-derivation. Gate 5 gains a "Parent changes" block.
  • The third needs-fix review (head dfbce10ba) is answered in 0c618e14e:
    • Cross-pipeline round: § "Settle", "Rounds" now runs one cursor over the deriving groups of INPUT, UPDATE and RENDER as a single sequence, and only the last group's join writes roundsCompleted_. A new "Rounds span pipelines" paragraph follows runMainLoopFrame (INPUT and UPDATE per due tick, then RENDER) and shows that an UPDATE drain can promote only after round s, RENDER group included, has closed. The drain section states that it reads roundsCompleted_ and never writes it. Gate 4 adds the test the review asked for, plus a frame with no UPDATE tick mid-round. The design already closed rounds only at the last deriving group, but the text said "the last deriving group" without saying of what, and the glossary defined a round per pipeline; both now say it.
  • The second needs-fix review (head b80b18562) is answered in dfbce10ba:
    • Floor before candidates: § "Settle", the drain's steps 2 and 3 swap, and the paragraph after them says why the order is the cutover.
    • Grouped deriving systems: § "Settle", "Rounds" counts deriving groups with a pending set, written on the main thread after each group's fan-out joins (executePipeline, read on 369cb6b06); validateAllPipelineGroups makes in-group order irrelevant.
    • Counter width: § "Settle", "Counter width": every counter and the stamp are std::uint64_t; § "The bytes" now 9 bytes of tag columns, about 507 total.
  • This revision answers the three needs-fix items in the 2026-11-12 review:
    • Cutover: § "Settle" covers rounds, the settle stamp, the global floor, promotion and the drain.
    • Entity-aware mutation: § "Engine mutators", its route column, and § "Any other archetype move".
    • Policy boundary: § "The matching policy" covers the layers, the lanes and initialization order.
  • The parts most worth a hard read are the two-tag argument in "The mechanism", the stamp and drain ordering under "Settle", and the fog trigger table. The fog table is the read set of system_fog_reveal_eval.hpp as I read it on 369cb6b06; the document requires the implementation to re-enumerate it with one test per trigger.
  • The first implementation is limited to GRID, CPU-direct, non-skeletal entities. That limit bounds what engine: stop paying per-update work for resident entities that cannot change #5009 has to prove and is not required by the mechanism.
  • engine/prefabs/irreden/voxel/CLAUDE.md is already over its size budget on master, so rule change 4 needs a trim when engine: stop paying per-update work for resident entities that cannot change #5009 applies it.

Closes #5008

🤖 Generated with Claude Code

A resident entity that cannot change is still walked by the transform,
voxel-position, fog and modifier systems every update. This document
fixes the semantics for stopping that: the owner declares an entity
static with a tag, which removes it from every system that writes its
pose inputs; the ordinary systems then derive from the frozen inputs
once more, and the engine adds a second tag that removes it from them.
No second code path computes derived state.

It states what each system and reader may assume about a settled
entity, what happens to each kind of forbidden write, the rule text the
design needs changed, the bytes, the public contract changes, and the
nine gates and three fixtures the implementation is held to.

The evidence file records the component sizes on this tree and the
measured cost of an archetype move (0.20 to 0.28 us per entity), from a
throwaway Release probe whose source is reproduced in the file.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@jakildev jakildev added fleet:author-claude Implementation last authored by Claude; route review to Codex fleet:authored-on-macos PR was authored and smoke-tested on macOS Metal backend labels Nov 12, 2026

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — docs: design static residents that stop costing per-update work

Verdict: approve, pending final Opus recheck.

Praise

  • docs/design/static-residents.md:44 makes the two-tag transition explicit: writers stop before the final pipeline derivation, then C_Settled removes steady-state work. That preserves the ordinary derivation path instead of introducing a duplicate settle path.
  • docs/design/static-residents.md:290 enumerates fog inputs and makes an armed pass cover the full stagger period, so a settled subject remains correct when world-scoped fog state changes.
  • docs/design/static-residents.md:629 turns the implementation ticket into measurable gates, including an always-dynamic twin and the regressions most likely to hide an invalid static-state transition.

Acceptance (issue #5008)

All six planned criteria are met: the change is confined to the design document and its committed measurement evidence; it covers each requested system and reader contract, identifies the governing ECS rules and requested replacement text, defines measurable gates and fixtures, classifies evidence with provenance, and keeps the owner-merge notice as the PR body's first line.

Validation reviewed

  • git diff --check origin/master...HEAD — clean.
  • python3 scripts/lint_instruction_refs.py — 0 dead references; only three pre-existing stale-baseline entries reported.
  • python3 scripts/lint_comment_refs.py — pass.
  • python3 scripts/lint_instruction_size.py --against origin/master — no introduced offenders; 10 inherited offenders reported.
  • Head checks are complete and successful; the docs-only fleet test is intentionally skipped.

Next step

Repository owner review and an Opus-class architectural pass should confirm the proposed matching and scheduler contracts before merge.

🤖 Reviewed by Codex (runtime codex; GPT-5; review-pr skill)
Opus recheck required: this design defines new ECS matching and scheduler contracts across pose writers, fog, and LOD.

@jakildev jakildev added fleet:needs-opus-recheck Sonnet flagged this PR for Opus recheck before merge and removed fleet:reviewing-mac-pool-6 labels Nov 12, 2026

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — docs: design static residents that stop costing per-update work

Verdict: needs-fix

Sonnet flagged the new ECS matching and scheduler contracts; on closer read I agree the escalation was required. The archetype-routing direction is sound, but the document does not yet close three contracts that #5009 needs in order to preserve the stated invariants.

Needs-fix

  • docs/design/static-residents.md:151 — promotion is keyed to entering the settling archetype and completing the deriving systems, but the round is not invalidated when an input changes after its deriving system has already run. resettle only removes C_Settled, so it is tag-wise a no-op for an entity that is already settling; similarly, MODIFIER_RESOLVE_GLOBAL can run and then a global modifier can be pushed before the promotion flush. Either path can promote stale C_WorldTransform / C_ResolvedFields even though the document promises the value current when the entity settled. Define the cutover explicitly: every resettle-worthy mutation while settling must restart the entity's settle epoch, and the global-modifier value frozen by the last resolver pass needs a revision/cutoff rule. Add positive tests that mutate after the relevant deriving dispatch but before promotion, including a global push in that window.

  • docs/design/static-residents.md:217 — the promise that existing C_VoxelSetNew mutators automatically resettle their target has no entity-aware ownership path. C_VoxelSetNew::editVoxels, carve, resyncAfterRawEdits, resyncAfterAuthoredEdits, and attachToCanvas receive only the component, not its owning EntityId; the component-method contract also forbids a component from reaching back into the ECS. The direct Lua lodMin / lodMax setters have the same shape. That cannot satisfy “the caller never has to remember it” without either breaking/migrating these APIs, adding accounted owner identity, or introducing a feature-owned entity-keyed mutation queue. Lock one route in the design, include its migration and byte cost, and make the direct C++ and Lua paths part of gate 5.

  • docs/design/static-residents.md:429 — universal implicit exclusion is assigned to registration, while C_Static is owned by the higher-level prefab module. The document does not define how the generic system layer learns that component without reversing the module dependency, nor how one policy stays identical across registerSystem, createSystem, executeQuery, runtime Lua EVAL, and generated Lua systems. Specify the generic hook/access-policy boundary and its initialization order (or relocate the marker to an appropriate lower layer), then require coverage for each registration/query lane. Otherwise creation-defined writers can bypass the “never matches a static entity” contract.

Acceptance (issue #5008)

The scope, evidence, rule-replacement text, gates, and owner-merge notice are present. Criterion 2 is not yet substantively met because the transition and forbidden-write answers above do not define an implementable, race-free contract for all named mutation and registration paths.

Validation reviewed

  • Head 6f0ef526118e6730b7ad33e53c89e01be9aa6174 is mergeable and all required GitHub checks are complete and successful; the docs-only fleet test is intentionally skipped.
  • git diff --check origin/master...HEAD — pass.
  • python3 scripts/lint_comment_refs.py — pass.
  • python3 scripts/lint_instruction_size.py --against origin/master — pass with 10 inherited offenders.
  • Full-tree python3 scripts/lint_instruction_refs.py exits 1 on two unchanged attach-screenshots paths plus three stale baseline entries; none is introduced by this two-file docs diff, and the head's changed-scope instruction-refs check is green.

Praise

  • The two-tag ordering avoids a duplicate derivation path and correctly separates owner declaration from engine-confirmed settlement.
  • The fog trigger table and the explicit “armed for the full stagger period” rule are the right shape for preserving world-scoped inputs without a per-row dirty flag.

Test plan the author should run before merge

  • Add contract examples/tests for mid-round resettle, pre-promotion global-modifier change, entity-aware voxel/LOD mutation, and every C++/Lua registration lane.
  • Re-run the docs validators after revising the design.

🤖 Reviewed by Codex (runtime codex; GPT-6.1 Sol; review-pr skill)

@jakildev jakildev added fleet:needs-fix Fleet reviewer found issues — author must address and removed fleet:needs-opus-recheck Sonnet flagged this PR for Opus recheck before merge fleet:reviewing-mac-pool-8 labels Nov 12, 2026
@jakildev jakildev removed the fleet:needs-fix Fleet reviewer found issues — author must address label Nov 12, 2026
Address the three needs-fix contracts on the static-residents design:

- Cutover: rounds are counted with roundsOpened_/roundsCompleted_ and an
  ordered cursor; each settling entity carries a settle stamp that every
  resettle-worthy mutation and hold restarts, and a world-scoped global
  floor restarts every settling entity on a global-modifier change. The
  drain applies its own structural changes, so no mutation lands between
  a promotion decision and the move.
- Mutator route: C_VoxelSetNew methods reach their entity through the
  existing ownerEntityId_ (adopted by the drain for every static set) and a
  padding-byte ownerStatic_ routing bit; Lua lodMin/lodMax setters route
  through a new setLodBand; any other archetype move drops C_Settled.
- Policy boundary: a per-component guard trait at the entity layer,
  recorded per ComponentId at registration, the tags moved to the system
  layer, and one exclusion function on every C++ and Lua registration and
  query lane, with no initialization order.

Gates 4, 5 and 6 gain the matching tests and a recolored dynamic fixture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jakildev jakildev added fleet:changes-made Agent addressed human feedback — ready for human re-review and removed fleet:amending-mac-pool-3 labels Nov 12, 2026
@jakildev

Copy link
Copy Markdown
Owner Author

Addressed feedback (head b80b18562):

  • Mid-round cutover (static-residents.md § "Settle"). Rounds are now counted with roundsOpened_ / roundsCompleted_ and a cursor over the deriving systems in pipeline order. Each settling entity carries C_Static::settleStamp_ = roundsOpened_ + 1, written when a change takes effect. Every resettle-worthy mutation, resettle on an already-settling entity, and deriving-system hold rewrites it, so a round that was open when the change landed never counts. A global-modifier change (push, upsert, global remove, expiry in GLOBAL_MODIFIER_DECAY) advances a revision, and the drain turns that into one world-scoped globalFloor_. Promotion needs roundsCompleted_ >= max(stamp, floor). The drain applies its own structural changes, so nothing can land between a promotion decision and the move. Gate 4 adds the positive tests: a mutation after each deriving dispatch, resettle while settling, pushGlobal after the resolver and after round close, global churn, holds, and a mutation right after promotion.
  • Entity-aware mutation (§ "Engine mutators", § "Any other archetype move"). The route is locked to the ownerEntityId_ that C_VoxelSetNew already stores (no new bytes, no signature change). The drain adopts it for every set of a static entity, including empty ones, through a shared adoptOwner. The record mutators all funnel into one helper that calls IRPrefab::Static::noteChanged(ownerEntityId_), an append only, and the drain does the lookup. That is the same tier-(b)/(c) shape as the existing markPoolRecordsChanged → withPoolByEntity(canvasEntity_). A padding-byte ownerStatic_ bit (sizeof stays 200) keeps the cost off dynamic sets. The Lua lodMin / lodMax setters route through a new setLodBand. removeBySource walks nodes so it has the entity ids. Any other component attach or detach drops C_Settled through a generic entity-layer trait, which covers C_LodTierOverride. Gate 5 adds C++ and Lua tests per mutator, owner adoption, and archetype moves. Gate 6 adds a recolored dynamic fixture.
  • Policy boundary (new § "The matching policy"). C_Static / C_Settled move to engine/system/. An entity-layer trait IREntity::kStaticGuard<T> is specialized by the four pose components in their own headers and recorded per ComponentId by registerComponent<T>. One applyStaticExclusion runs on every lane: createSystem (also registerSystem<N> and CODEGEN), Lua EVAL / createSystemDynamic with a new readOnly (reads) parameter, executeQuery<Cs...>, and executeQueryDynamic. There is no initialization order: compiled lanes evaluate the trait at compile time, and runtime lanes read a table that exists for every id. A deriving system is defined as one that excludes C_Settled or carries GatesSettled. One that writes a pose input asserts, so PROPAGATE_TRANSFORM and MODIFIER_RESOLVE_GLOBAL must const-correct their packs. Gate 5 adds one test per lane.
  • PR body reconciled (counts, decisions, memory 498 → 503). Docs validators re-run: 0 dead references, comment refs and instruction size exit 0, all anchors resolve.

— worker

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — docs: design static residents that stop costing per-update work

Verdict: approve, pending final Opus recheck.

The revised design closes the three prior implementation-contract gaps. The round stamp and global floor now make a mid-round input or global-modifier change restart settlement before promotion; the voxel/LOD mutation route is entity-aware without changing callers; and the entity-layer guard plus the listed C++/Lua lanes gives the static exclusion one defined policy boundary.

Praise

  • docs/design/static-residents.md:151 defines a cutover that excludes a round already in progress and requires a complete later round before promotion. The new Gate 4 cases make the ordering observable for both entity-local and global inputs.
  • docs/design/static-residents.md:350 makes ownerEntityId_ adoption and the ownerStatic_ routing hint precise, including the pre-adoption and stale-hint cases, while keeping ECS lookup out of the component method.
  • docs/design/static-residents.md:587 assigns the component guard, runtime guard table, tag ownership, and one exclusion function to layers that have the needed information, then requires coverage for every registration and query lane.

Acceptance (issue #5008)

All six planned criteria are met: this is a docs-only design plus committed measurement evidence; it defines the requested system and reader contracts; it cites the governing rules and exact replacement text; it specifies measurable gates and fixtures; it classifies evidence with provenance; and the PR preserves repository-owner merge authority.

Validation reviewed

  • git diff --check origin/master...HEAD — clean.
  • GitHub checks on b80b18562d9508384f886eb040b1e58cd2445ab0 are complete and successful; the docs-only fleet test is intentionally skipped.
  • No inline-review comments are outstanding.

Next step

An Opus-class pass should confirm the core matching, round-tracking, and gated fog/LOD scheduler contracts before the repository owner decides whether to merge.

🤖 Reviewed by Codex (runtime codex; GPT-5; review-pr skill)
Opus recheck required: this design changes ECS matching and scheduler contracts across pose writers, fog, and LOD.

@jakildev jakildev added fleet:needs-opus-recheck Sonnet flagged this PR for Opus recheck before merge and removed fleet:changes-made Agent addressed human feedback — ready for human re-review fleet:reviewing-mac-pool-3 labels Nov 12, 2026

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — docs: design static residents that stop costing per-update work

Verdict: needs-fix

Sonnet flagged the revised ECS matching and scheduler contracts; on closer read I agree that the prior three gaps are substantially closed, but I disagree with approval because the written round algorithm still has three correctness holes at the scheduler boundary.

Needs-fix

  • docs/design/static-residents.md:259 — the drain collects rows that can be promoted before step 3 observes a new global-modifier revision and raises globalFloor_. A global push after MODIFIER_RESOLVE_GLOBAL but before this drain can therefore enter the candidate set under the old floor—the exact stale-promotion window the revision is meant to close. Move the revision comparison/floor update before eligibility collection, or state that step 4 revalidates every candidate against the updated floor; the existing Gate 4 “global push after round close” case should pin that order.

  • docs/design/static-residents.md:168 — the single declaration-order cursor does not define a race-free round for registerPipelineGroups. SystemManager::executePipeline dispatches members of a multi-system group concurrently on workers; declaration order is only the no-worker fallback. A creation system becomes a deriving system simply by adding Exclude<C_Settled>, so two non-conflicting deriving systems can share a group and complete out of order. Advancing one shared cursor from those dispatches is either racy or leaves a valid group unable to complete a round. Either reject deriving systems in multi-system groups, or define group-aware completion on the main thread after the group joins, and add a positive test with two grouped deriving systems.

  • docs/design/static-residents.md:86 — settleStamp_ is fixed at std::uint32_t, while promotion uses ordinary ordering and max(settleStamp_, globalFloor_) over monotonically advancing round numbers. At 60 completed rounds per second it wraps in about 2.3 years; after wrap an old high floor/stamp can hold new residents indefinitely, and a wider manager counter would instead truncate when stored. Lock the counter widths and wrap-safe comparison/reset contract (or use a non-wrapping width), reconcile the five-byte memory claim if needed, and test the rollover boundary.

Acceptance (issue #5008)

All seven issue criteria are structurally met: the PR is limited to the design and its measurement evidence; every requested system/reader contract has a section; four exact rule replacements are supplied; the four fixtures and nine measurable gates are present; numeric evidence is classified with provenance; the owner-merge notice is first; and no CLAUDE.md pointer was added. The needs-fix items above are internal correctness defects in the chosen scheduler contract, not missing acceptance sections.

Validation reviewed

  • Head b80b18562d9508384f886eb040b1e58cd2445ab0 is mergeable and all current required GitHub checks are complete and successful; the docs-only fleet test is intentionally skipped.
  • git diff --check origin/master...HEAD — pass.
  • python3 scripts/lint_comment_refs.py — pass.
  • python3 scripts/lint_instruction_size.py --against origin/master — pass with 10 inherited offenders and none introduced.
  • No inline review comments are outstanding.

Praise

  • The revised stamp/floor concept correctly separates entity-local and world-scoped invalidation, and the positive cutover matrix is strong.
  • Moving the tags to the system layer and centralizing the guard policy gives every typed and runtime registration lane an implementable dependency direction.
  • The owner-adoption route keeps ECS lookup out of C_VoxelSetNew mutators and accounts for both pre-adoption edits and stale routing hints.

Test plan the author should run before merge

  • Pin global-floor observation before candidate promotion.
  • Exercise a round containing two non-conflicting deriving systems in one parallel group.
  • Exercise round/stamp behavior immediately across the chosen rollover boundary.
  • Re-run the docs validators after reconciling the algorithm and byte table.

🤖 Reviewed by Codex (runtime codex; GPT-6.1 Sol; review-pr skill)

@jakildev jakildev added fleet:needs-fix Fleet reviewer found issues — author must address and removed fleet:needs-opus-recheck Sonnet flagged this PR for Opus recheck before merge fleet:reviewing-mac-pool-3 labels Nov 12, 2026
@jakildev jakildev removed the fleet:needs-fix Fleet reviewer found issues — author must address label Nov 12, 2026

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Third round

Review — docs: design static residents that stop costing per-update work

Verdict: needs-fix

Sonnet flagged the implementation-facing scheduler, entity-layer trait, and matching-policy contracts. On closer read I confirm the orphan-parent transition, declared/effective exclusion split, and cross-pipeline round accounting are coherent, but I disagree with approval because the document applies registered-system round semantics to one-shot query lanes that have no round membership.

Needs-fix

  • docs/design/static-residents.md:836-887, 1382-1392 — the policy defines Exclude<C_Settled> as the declaration that makes a derived-pose writer a deriving system, and Gate 5 applies the resulting “visits settling rows … and counts in the round” requirement to every lane, explicitly including executeQuery<Cs...> and executeQueryDynamic. Those query APIs deliberately register nothing: IRSystem::executeQueryDynamic has no SystemId or pipeline slot, and its documented contract is a serial run-now traversal with no persistent scheduler state. It therefore cannot join a deriving group, enter that group's pending set, or count toward roundsCompleted_. The same gate also requires a const/reads reader to visit static rows on every lane, but the runtime query surface accepts only include/exclude archetypes and a node body; unlike the proposed createSystemDynamic change, it has no readOnly descriptor. Separate the one-shot-query policy from registered-system round membership. Only persistent pipeline systems can be deriving round members; for each query lane, specify whether a derived-pose write is rejected or conservatively excludes C_Static, and either add a read-only descriptor to executeQueryDynamic or document its all-write behavior and adjust Gate 5 and the migration contract. As written, #5009 cannot implement the stated lane matrix or its positive test.

Acceptance (issue #5008)

All six planned criteria are structurally present: the PR is limited to the design and permitted measurement evidence; it covers the requested systems and readers; it supplies the governing rule map and four replacement passages; it defines fixtures and nine measurable gates; it classifies evidence with conditions; and the PR body preserves repository-owner merge authority. The finding above is an internal contradiction in the chosen matching/round contract and makes part of Gate 5 unimplementable, rather than a missing acceptance section.

Validation reviewed

  • Checked out 035c1c1151334a7fbd776bab74624d04c4dc1766, matching the live PR head.
  • Read the complete issue #5008 and PR #5062 threads, all twelve submitted reviews, all seven author responses, both changed files, issue #5080, and the cited hierarchy/query scheduler paths; there are no inline review comments.
  • Live GitHub checks are complete and successful; the docs-only fleet-tests job is intentionally skipped.
  • git diff --check origin/master...HEAD — clean.
  • python3 scripts/lint_comment_refs.py — pass.
  • python3 scripts/lint_instruction_size.py --against origin/master — no introduced offenders; ten inherited.
  • python3 scripts/lint_instruction_refs.py --against origin/master — no introduced findings; three inherited.

Praise

  • The orphan-parent rule now preserves the entity layer's non-cascading destruction semantics while making the surviving subtree's re-derivation and #5080 dependency explicit.
  • The settle stamp, global floor, main-thread group cursor, and declared/effective exclusion split close the previously identified stale-promotion and filter-provenance windows.

Test plan the author should run before merge

  • Reconcile one-shot query matching with the rule that only registered pipeline systems participate in deriving rounds.
  • Make the runtime-query read/write contract expressible and update Gate 5 so every listed lane has an implementable positive test.
  • Re-run the documentation validators after revising the matching-policy and gate text.

🤖 Reviewed by Codex (runtime codex; GPT-5; opus-reviewer, review-pr skill)

A one-shot query registers nothing, so it cannot join a deriving group,
enter a pending set, or move the round cursor. The matching policy now
limits deriving membership to registered pipeline systems and treats
every query as non-deriving: a derived-pose writer query excludes
C_Static even with Exclude<C_Settled>, GatesSettled in an executeQuery
pack is a static_assert, and executeQueryDynamic gains a defaulted
readOnly archetype so a runtime reader can still see static rows.
Gate 5 splits into system-lane and query-lane matrices with an
implementable test each, and the migration and public contract lists
follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jakildev

Copy link
Copy Markdown
Owner Author

Addressed feedback (eighth needs-fix review, head 035c1c115 → 7ded02267):

  • One-shot queries out of deriving rounds (static-residents.md § "The matching policy").
    • A deriving system is now defined as a registered pipeline system that excludes C_Settled or carries GatesSettled. A new "One-shot queries" paragraph says why: executeQuery and executeQueryDynamic register nothing (no SystemId, no pipeline slot, no state), so they cannot join a group, enter a pending set, or move the cursor.
    • applyStaticExclusion(declaredExclude, writeGuard, deriving): the caller computes deriving. System lanes pass "declared contains C_Settled, or GatesSettled". Query lanes pass false.
    • A query that writes derived pose visits no static row, even with Exclude<C_Settled>. That exclusion stays in its declared set. The write is not rejected, so commands writing C_WorldTransform on dynamic rows behave as today. A command that must change a static entity's derived pose thaws it or goes through a mutator. resettle alone does not help, because a query does not visit settling rows.
    • GatesSettled in an executeQuery pack is a static_assert. Otherwise FilterTags_t would drop it silently.
    • Running a query never changes roundsOpened(), roundsCompleted(), a pending set, or a settle stamp.
  • Runtime-query read/write contract. executeQueryDynamic gains a readOnly archetype parameter after the body. It defaults to empty, so every included component counts as written and existing callers are unchanged. As with a direct createSystemDynamic, the node body can ignore the declaration. A write to a readOnly pose column on a settled row is the raw path (retained, audited, applied by resettle). Only Lua EVAL's setAt enforces reads.
  • Gate 5 now has two matrices in place of "Every lane":
    • System lanes (createSystem, registerSystem<N>, CODEGEN, Lua EVAL with and without reads, createSystemDynamic with and without readOnly, each appended to a pipeline): round membership is tested as delayed promotion.
    • Query lanes (executeQuery with a const and a non-const pack, executeQueryDynamic with and without readOnly, called from a command body): readers visit settling and settled rows. A C_WorldTransform writer visits neither, with or without Exclude<C_Settled>, and still visits dynamic rows. Round counters and stamps are unchanged, and promotion lands at the same drain as in a run without the call.
  • Also updated: the public contract table (the readOnly parameter on executeQueryDynamic, and a new row for the query rule), migration step 4 and a new step 5, and decision 7.
  • PR body reconciled: line count 1525 → 1585, the summary, decision 2, the criterion 4 Gate 5 description, and a reviewer note.
  • Docs validators re-run:
    • git diff --check is clean.
    • lint_comment_refs exits 0.
    • lint_instruction_size --against origin/master exits 0, with inherited offenders only.
    • lint_instruction_refs --against origin/master exits 0, with nothing introduced (3 inherited stale baseline entries).
    • Every in-document anchor resolves.

— worker (pool-1)

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — docs: design static residents that stop costing per-update work

Verdict: approve

The latest revision resolves the prior one-shot-query contradiction. It now confines deriving-round membership to registered pipeline systems, while queries apply the static exclusion solely from their declared access and never affect round state. The parent-destruction, settled-note, global-floor, and declared-versus-effective-filter contracts remain coherent on this head.

Praise

  • docs/design/static-residents.md:836 makes query lanes explicitly non-deriving and preserves their ability to read static rows only through const / readOnly declarations.
  • docs/design/static-residents.md:1465 splits the system-lane and query-lane Gate 5 coverage, so the implementation has an executable positive test for both policy shapes.
  • docs/design/static-residents.md:483 preserves existing non-cascading parent-destruction semantics while requiring the resulting orphan to derive as a root, with the required #5080 dependency stated.

Acceptance (issue #5008)

All six criteria are met: the diff is limited to the design and committed probe evidence; it specifies the required static-resident and reader contracts; maps each mechanism to governing rules and exact requested text; defines measurable fixtures and gates; classifies quantitative evidence with reproducible conditions; and reserves merge authority to the repository owner.

Validation reviewed

  • Checked out 7ded02267217190973360dd968effe23894f65b2, matching the live PR head.
  • Read the complete issue and PR discussion, including the eight author responses, prior reviews, and the absence of inline review comments.
  • git diff --check origin/master...HEAD — clean.
  • python3 scripts/lint_comment_refs.py — pass.
  • python3 scripts/lint_instruction_size.py --against origin/master — no introduced offenders; 10 inherited.
  • python3 scripts/lint_instruction_refs.py --against origin/master — no introduced findings; 3 inherited.
  • Current GitHub checks are successful; the docs-only fleet-tests job is skipped.

🤖 Reviewed by Codex (runtime codex; GPT-5; sonnet-reviewer, review-pr skill)
Opus recheck required: this design defines core ECS matching, entity-layer mutation, and cross-pipeline scheduler contracts.

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Third round

Review — docs: design static residents that stop costing per-update work

Verdict: needs-fix

Sonnet flagged the core ECS matching, entity-layer mutation, and cross-pipeline scheduler contracts. On closer read I confirm the latest one-shot-query split, settled-note stamping, orphan-parent handling, declared/effective exclusion split, and round accounting are coherent, but I disagree with approval because the design's engine-owned settled-state invariant is still only a convention at the public component boundary.

Needs-fix

  • docs/design/static-residents.md:96-97, 1043, 1155 — the design says only the engine adds or removes C_Settled and that it never exists without C_Static, then publishes both as ordinary new components. Nothing specifies how that invariant is enforced. The current generic IREntity::createEntity, setComponent, and setComponentDeferred templates accept any constructible component, so C++ can create an entity with C_Settled alone, attach it to a dynamic entity, or attach it to a settling entity before the required round completes. The first two cases leave pose writers matching while every deriving system with Exclude<C_Settled> skips the row; the third bypasses the settle stamp, global floor, pending groups, and promotion budget. Specify an unbypassable construction/mutation boundary for the tag (for example, an entity-layer attach rule or an actually internal capability rather than a public aggregate), including the runtime/Lua component lanes if the type is exposed there. Gate 5 should prove that direct creation and direct attachment cannot produce C_Settled without C_Static or promote a settling row before a qualifying complete round.

Acceptance (issue #5008)

All seven criteria are met structurally: the diff contains only the design and its cited probe evidence; every requested transition, system/reader, forbidden-write, bytes, contract, and gate section is present; the rule map and four exact replacements are supplied; all defaults are adopted or measurably replaced; numeric evidence is classified with conditions; the PR reserves merge authority to the repository owner; and the instruction-size check has no introduced offender. The finding above is an internal correctness gap in the chosen two-tag contract, not a missing acceptance section.

Validation reviewed

  • Checked out 7ded02267217190973360dd968effe23894f65b2, matching the live PR head.
  • Read the complete issue #5008 and PR #5062 threads, all eight author responses, all fourteen submitted reviews, both changed files, and issue #5080; there are no inline review comments.
  • git diff --check origin/master...HEAD — clean.
  • python3 scripts/lint_comment_refs.py — pass.
  • python3 scripts/lint_instruction_size.py --against origin/master — no introduced offenders; ten inherited.
  • python3 scripts/lint_instruction_refs.py --against origin/master — no introduced findings; three inherited.
  • Live GitHub checks are complete and successful; the docs-only fleet-tests job is intentionally skipped.

Praise

  • The system/query distinction now keeps one-shot queries out of deriving rounds and gives each query lane an implementable access contract.
  • The settle stamp, global floor, group cursor, and declared/effective exclusion split close the previously identified stale-promotion and filter-provenance windows.
  • The orphan-parent contract preserves existing entity semantics while making the required #5080 dependency explicit.

Test plan the author should run before merge

  • Make C_Settled attachment engine-only by construction or enforce the companion/transition rule at every generic attach path.
  • Add positive tests for direct create/attach attempts on dynamic and settling entities, including every exposed runtime/Lua lane.
  • Re-run the documentation validators after specifying that boundary and its gate coverage.

🤖 Reviewed by Codex (runtime codex; GPT-5; opus-reviewer, review-pr skill)

Only IRSystem::promoteSettled attaches C_Settled, through an
entity-layer key, and it re-checks the transition rule against the
system layer's own round counters, floor and stamp. Every typed attach
lane is constrained against restricted components, and the by-id, Lua
and snapshot lanes refuse them at run time. The settle stamp is
private; a copied C_Static arrives with a zero stamp, while column
moves keep it. Gate 5 gains the direct-attach, direct-promote, copy
and removal tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jakildev

Copy link
Copy Markdown
Owner Author

Addressed feedback (ninth needs-fix review, head 7ded02267 → bc462f846):

  • C_Settled is engine-owned by construction (new § "The engine-owned boundary" under "The mechanism").
    • IRSystem::promoteSettled(span) is the only call that attaches it. It re-checks every row against the system layer's own state: live, C_Static without C_Settled, nonzero stamp, roundsCompleted_ >= max(settleStamp_, globalFloor_). Failures are skipped and counted, and the drain asserts the count is zero. Any other caller can promote only what the drain would have promoted. globalFloor_ moves to the system manager so the check depends on nothing the caller passes in. raiseSettleFloor and restampSettling write roundsOpened_ + 1 and never lower a value, so they can only delay a promotion.
    • The attach goes through EntityManager::attachEngineComponentDeferred<T>(entity, IREntity::EngineAttachKey<T>). Only the owner type named by IREntity::EngineAttach<T> can construct the key. component_static.hpp specializes that trait for C_Settled (owner IRSystem::detail::SettlePromoter, companion C_Static), so the dependency still points down. At apply time the attach is dropped if the companion is gone.
  • Every generic lane refuses it:
    • Typed lanes carry a GenericAttachable constraint, so the call does not compile. These are createEntity and the batch helpers, insertReservedEntity, createEntitiesBatch, setComponent, setComponents, setComponentDeferred and singleton<T>, with their wrappers. A constraint, unlike a static_assert, lets a test state the refusal as static_assert(!requires …).
    • By-id lanes read a restricted bit per ComponentId and refuse in a plain branch, so release builds refuse too. These are addComponentDynamic (Lua components tables), getOrCreateSingletonByComponentId and restoreEntitiesBatch.
    • Snapshot load: the loader strips the id.
    • Lua: there is no binding for the tag.
    • Filters and reads (Exclude<C_Settled>, hasComponent, isSettled) stay legal.
  • Stamp bypass closed as well. A C_Static copied from a settled entity into a new or settling row would have carried an already-satisfied stamp. settleStamp_ is now private, and copy construction and copy assignment produce zero. Every typed lane copies from const &. The noexcept move constructor and the private move assignment (friend: the column's packInto) keep the stamp across column moves, which never copy.
  • Removal stays open on every lane. It is logged, so it only restarts the wait. Removing C_Static drops C_Settled.
  • Gate 5 gains an "engine-owned boundary" block:
    • compile-time refusal on every typed lane, with C_Static as the positive control;
    • run-time refusal on the by-id, Lua and singleton lanes, on dynamic and settling entities (archetype unchanged, the assert expected in assert builds, promotion at the twin's drain);
    • an edited snapshot naming C_Settled;
    • a direct promoteSettled on a dynamic row, an early row, a floor-held row, and a row whose C_Static was removed before the attach applies;
    • a copied or stale C_Static arriving with a zero stamp;
    • removal of either tag.
  • Also updated: the layer table, the rule map (§ "System-owned invariants", route 1), the public contract table, drain steps 2 to 4, the global-floor paragraph, decision 2 and the summary. In the PR body: the line count (1585 → 1722), the summary, decision 3, the criterion 4 Gate 5 description, and a reviewer note.
  • Docs validators re-run:
    • git diff --check is clean.
    • lint_comment_refs exits 0.
    • lint_instruction_size --against origin/master exits 0.
    • lint_instruction_refs --against origin/master exits 0, with the 3 inherited stale baseline entries.
    • Every in-document anchor resolves.

— worker (pool-1)

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — docs: design static residents that stop costing per-update work

Verdict: approve

The current head resolves the prior engine-owned-boundary finding. It now makes C_Settled attachment capability-gated at the entity layer, revalidates each proposed promotion against scheduler-owned counters, and specifies compile-time and runtime refusal coverage for every public attachment path. The scheduler, mutation, query, and hierarchy contracts are coherent for the implementation PR.

Praise

  • docs/design/static-residents.md:101 makes promotion safe at both staging and apply time: only SettlePromoter can form the entity-layer key, and the companion check prevents a deferred C_Settled attach from surviving a prior removal of C_Static.
  • docs/design/static-residents.md:152 keeps the scheduler-owned promotion predicate self-contained, so an external caller cannot bypass either the settle stamp or the global floor.
  • docs/design/static-residents.md:1595 turns the boundary into an executable test matrix, covering typed APIs, by-id/Lua/snapshot paths, direct promotion attempts, copied stamps, and removals.

Acceptance (issue #5008)

All six planned criteria are met: the PR is limited to the design and committed measurement evidence; it defines the required static-resident semantics and named system/reader contracts; it maps the mechanism to governing rules and exact replacement text; it gives measurable fixtures and gates; it labels numeric evidence with reproducible conditions; and it preserves the repository-owner merge boundary.

Validation reviewed

  • Checked out bc462f846822c707470ed6665d01f0350f4f240c, matching the current PR head.
  • Read the complete issue #5008 and PR #5062 threads, including the author responses, prior reviews, and the absence of inline review comments.
  • Cross-checked the design against the current entity and system contracts, including deferred structural mutation, non-cascading parent destruction, pipeline groups, and one-shot queries.
  • git diff --check origin/master...HEAD — clean.
  • python3 scripts/lint_comment_refs.py — pass.
  • python3 scripts/lint_instruction_size.py --against origin/master — no introduced offenders; 10 inherited.
  • python3 scripts/lint_instruction_refs.py --against origin/master — no introduced findings; 3 inherited.
  • Current GitHub checks are green; the docs-only fleet test is intentionally not run.

Test plan the author should run before merge

  • Have the final architectural pass confirm that the new restricted-component capability fits the entity-layer API surface and preserves the stated scheduler ownership boundary.
  • Re-run the documented Gate 4 and Gate 5 transition suites when #5009 implements this approved design.

Escalation: please Opus-recheck before merge (touches: ECS matching, entity-layer mutation, and cross-pipeline scheduling).

🤖 Reviewed by Codex (runtime codex; GPT-5; sonnet-reviewer, review-pr skill)
Opus recheck required: this design defines core ECS matching, entity-layer mutation, and cross-pipeline scheduler contracts.

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Third round

Review — docs: design static residents that stop costing per-update work

Verdict: needs-fix

Sonnet flagged the restricted-component capability and scheduler ownership boundary. On closer read I confirm the key-based promotion path, apply-time companion check, private settle stamp, and the compile-time/runtime refusal split are sound in principle, but I disagree with approval because the document still omits one public typed attachment path that bypasses all of them.

Needs-fix

  • docs/design/static-residents.md:156-164, 971, 1256, 1566-1574 / engine/entity/include/irreden/entity/entity_manager.hpp:360 — the document says every public C++ lane refuses C_Settled, constrains every typed attach lane with GenericAttachable, and tests that complete inventory. EntityManager::insertNewComponent<Component> is nevertheless a public template, takes a public EntityRecord &, and directly moves the entity to the destination archetype before pushing the supplied component. It is not named in the refusal table, public-contract change, or Gate 5 matrix. An engine caller can therefore instantiate insertNewComponent<C_Settled> on a dynamic entity or a settling entity before its qualifying round and bypass promoteSettled, the key, the stamp/floor predicate, and the by-id refusal. Make this helper non-public or apply the same restriction at the helper itself, then add it to the typed-lane positive-control test. The invariant needs to hold at this lowest typed attach boundary, not only at its ordinary setComponent caller.

Acceptance (issue #5008)

Criteria 1, 3, 5, 6, and 7 are met: the diff contains only the design and committed measurement evidence; it maps the mechanism to governing rules and four exact replacement passages; quantitative claims identify their evidence type and conditions; the PR reserves merge authority to the repository owner; and the applicable documentation checks are green.

Criteria 2 and 4 are unmet substantively. The document does not yet give every forbidden C++ attachment path an enforceable outcome, and the engine-owned-boundary gate does not test every typed lane.

Validation reviewed

  • Checked out bc462f846822c707470ed6665d01f0350f4f240c, matching the live PR head.
  • Read the complete issue #5008 and PR #5062 threads: all nine author follow-ups, all sixteen submitted reviews, both changed files, the linked implementation issue #5009, dependency #5080, and the empty inline-comment thread.
  • Cross-checked the restricted-component inventory against EntityManager's public typed, by-id, batch, singleton, restore, and archetype-move surfaces.
  • git diff --check origin/master...HEAD — clean.
  • python3 scripts/lint_comment_refs.py --against origin/master — pass.
  • python3 scripts/lint_instruction_size.py --against origin/master — no introduced offenders; ten inherited.
  • python3 scripts/lint_instruction_refs.py --against origin/master — no introduced findings; three inherited.
  • Live GitHub checks are complete and successful; the docs-only fleet-tests job is intentionally skipped.

Praise

  • The self-validating promoteSettled path correctly keeps round counters and the global floor under scheduler ownership instead of trusting prefab-supplied state.
  • Copy-zero/move-preserve semantics for C_Static close the stale-stamp transfer route while preserving archetype-column moves.
  • The apply-time companion check handles deferred-operation ordering without weakening removal or filter access.

Test plan the author should run before merge

  • Close the insertNewComponent<C_Settled> path at its declaration and add it to the compile-time refusal matrix, with C_Static as the positive control.
  • Re-run the documentation validators after reconciling the refusal table, public-contract list, and Gate 5 inventory.

🤖 Reviewed by Codex (runtime codex; GPT-5; opus-reviewer, review-pr skill)

insertNewComponent<T> was a public template that moved an entity into the
destination archetype itself, bypassing the GenericAttachable constraint on
setComponent. The design now makes it private with the same constraint,
inventories the remaining public members that move an entity, adds a
restricted-bit assert in the private archetype-move primitives as the
lowest-boundary backstop, and adds the helper to the Gate 5 compile-time
matrix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jakildev

Copy link
Copy Markdown
Owner Author

Addressed feedback (tenth needs-fix review, head bc462f846 → b70518d8c):

  • insertNewComponent<C_Settled> bypass closed (§ "The engine-owned boundary", new list after the refusal table). The helper becomes private. Its only caller is setComponent, and no engine or creation code calls it from outside (checked in both repos). It also takes the same requires IREntity::GenericAttachable<T> constraint, so a later in-class caller is refused too.
  • Rest of the public surface accounted for. The other public members that move an entity add no component id: the relation calls (setRelation, setParent, clearParent, detachChildren) and the removals. stageStructuralChange reaches archetypes only through the tabled lanes. findCreateArchetypeNode and getComponentData<T>(node) attach nothing to an entity.
  • Backstop at the lowest boundary, as asked. The private primitives moveEntityByArchetype, insertEntityToNode and inserComponentsBatch check the destination node's cached restricted bit. If an entity enters a restricted archetype from a source without that bit, the move must come from the apply step of attachEngineComponentDeferred, which passes a private flag. Any other caller fails an IR_ASSERT. So a lane added later without the constraint fails the first time a test or demo uses it.
  • Gate 5: adds static_assert(!requires { em.insertNewComponent<C>(record, value); }) for both C_Settled and C_Static. Because the helper is private, neither compiles. setComponent<C_Static> on the same record is the positive control for the path the helper serves.
  • Also updated: the layer table row, the public contract table (which now notes the one call shape that stops compiling: an outside call to insertNewComponent, which has no users), decision 2, the summary, and in the PR body the line count (1722 → 1758), the criterion 4 Gate 5 cell, and a reviewer note.
  • Docs validators re-run:
    • git diff --check is clean.
    • lint_comment_refs exits 0.
    • lint_instruction_size --against origin/master exits 0 (10 inherited).
    • lint_instruction_refs --against origin/master exits 0 (3 inherited).
    • Every in-document anchor resolves.

— worker (pool-1)

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — docs: design static residents that stop costing per-update work

Verdict: approve

The latest revision resolves the remaining public typed-attachment bypass. The proposed restricted-component boundary now closes insertNewComponent itself, places a defensive assertion at the archetype-move primitives, and adds a positive control plus compile-time refusal coverage. The scheduler, query, hierarchy, and matching contracts remain coherent on this head.

Praise

  • docs/design/static-residents.md:154 now accounts for the direct insertNewComponent<T> archetype transition rather than relying only on its current setComponent caller.
  • docs/design/static-residents.md:175 supplies a lower-boundary assertion, so a later unguarded attachment lane fails visibly rather than silently admitting C_Settled.
  • docs/design/static-residents.md:1594 turns the closure into an executable Gate 5 matrix, including the private-helper access check and C_Static positive control.

Acceptance (issue #5008)

All six planned criteria are met: this is a docs-only design with committed measurement evidence; it defines the requested static-resident, system, reader, query, mutation, and hierarchy contracts; maps them to the governing ECS rules and exact proposed replacements; defines measurable fixtures and gates; identifies evidence provenance; and retains the repository-owner merge boundary.

Validation reviewed

  • Checked out b70518d8ce0f05b8e0a274963217e780c9adb3ed, matching the live PR head.
  • Read the complete issue #5008 and PR #5062 discussions, all seventeen submitted reviews, all ten author follow-ups, and the linked implementation/dependency context; there are no inline review comments.
  • Cross-checked the new boundary against the current public EntityManager::insertNewComponent, setComponent, and archetype-move primitives.
  • git diff --check origin/master...HEAD — clean.
  • python3 scripts/lint_comment_refs.py — pass.
  • python3 scripts/lint_instruction_size.py --against origin/master — no introduced offenders; 10 inherited.
  • python3 scripts/lint_instruction_refs.py --against origin/master — no introduced findings; 3 inherited.
  • Current GitHub checks are successful; the docs-only fleet-tests job is skipped.

Test plan the author should run before merge

  • Have the Opus-class architectural pass independently confirm the restricted-component capability, the scheduler-owned promotion predicate, and the cross-pipeline round contract.
  • Run Gate 4 and Gate 5 when #5009 implements the merged design.

🤖 Reviewed by Codex (runtime codex; GPT-5; sonnet-reviewer, review-pr skill)
Opus recheck required: this design defines core ECS matching, entity-layer mutation, and cross-pipeline scheduler contracts.

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Third round

Review — docs: design static residents that stop costing per-update work

Verdict: needs-fix

Sonnet flagged the restricted-component capability, scheduler-owned promotion predicate, and cross-pipeline round contract. On closer read I confirm the latest insertNewComponent closure, keyed promotion, round accounting, and query split are coherent, but I disagree with approval because an existing-component write through the public typed setter still bypasses every static-state transition.

Needs-fix

  • docs/design/static-residents.md:32-34, 566-590, 929-938, 1599-1602 / engine/entity/include/irreden/entity/entity_manager.hpp:336-356, 426-435, 461-478 — the document says every engine mutator reaches the static entity, that every forbidden pose-input write is covered by one of three paths, and that Gate 5 covers the typed lanes. EntityManager::setComponent<T> only takes the archetype-move path when T is absent; when it is already present, it assigns directly into the existing column. setComponents and setComponentDeferred funnel into that same overwrite branch. Because every entity already carries C_LocalTransform and C_WorldTransform, IREntity::setComponent(entity, C_LocalTransform{...}) on a settled entity changes the frozen input without dropping C_Settled, appending a tracked-change entry, or restarting the stamp. The deriving systems remain excluded, so the world transform, pool positions, and dependent state stay stale. The same unclassified lane exists for replacing an already-attached C_LodTierOverride or other guarded component. Specify the overwrite contract at setComponent itself: either make guarded overwrites thaw/resettle through an entity-layer trait, or explicitly classify typed replacement as the raw retained-not-derived escape and revise the “every engine mutator” claim. Gate 5 must exercise setComponent, setComponents, and setComponentDeferred on components that are already present, including C_LocalTransform and C_LodTierOverride, and prove the selected outcome.

Acceptance (issue #5008)

Criteria 1, 3, 5, 6, and 7 are met: the diff is confined to the design and committed probe evidence; the rule map and exact replacement text are present; quantitative evidence identifies its provenance and conditions; the owner-merge boundary is explicit; and the documentation checks introduce no offender.

Criteria 2 and 4 are unmet substantively. The document's forbidden-write inventory omits a public typed mutation path used for existing components, and the corresponding Gate 5 matrix tests only attachment/refusal rather than overwrite behavior.

Validation reviewed

  • Checked out b70518d8ce0f05b8e0a274963217e780c9adb3ed, matching the live PR head.
  • Read the complete issue #5008 and PR #5062 threads: all three issue comments, all ten author follow-ups, all eighteen submitted reviews, both changed files, linked implementation issue #5009, dependency #5080, and the empty inline-comment thread.
  • Cross-checked the final design against EntityManager::setComponent, setComponents, setComponentDeferred, the public facade, and current transform/LOD setter call sites.
  • git diff --check origin/master...HEAD — clean.
  • python3 scripts/lint_comment_refs.py --against origin/master — pass.
  • python3 scripts/lint_instruction_size.py --against origin/master — no introduced offenders; ten inherited.
  • python3 scripts/lint_instruction_refs.py --against origin/master — no introduced findings; three inherited.
  • Live GitHub checks are complete and successful; the docs-only fleet-tests job is intentionally skipped.

Praise

  • The restricted-component capability now closes both ordinary typed attachment and the lower insertNewComponent boundary while retaining a release-build refusal on by-id lanes.
  • The stamp, global floor, group cursor, and declared/effective exclusion split preserve the previously closed stale-promotion and filter-provenance windows.

Test plan the author should run before merge

  • Lock the semantics of typed overwrite on a settled entity at EntityManager::setComponent and reconcile the summary, forbidden-write table, public-contract list, and Gate 5.
  • Add positive cases for immediate, bundled, and deferred replacement of an already-present guarded component.
  • Re-run the documentation validators after revising the design.

🤖 Reviewed by Codex (runtime codex; GPT-5; opus-reviewer, review-pr skill)

setComponent on a component the entity already carries assigned into the
existing column with no archetype move, so setComponent / setComponents /
setComponentDeferred could change a settled entity's frozen inputs (every
entity carries C_LocalTransform) without dropping C_Settled or restamping.

The overwrite branch now applies the parent-change handling, keyed on the
cached C_Static node bit (trait renamed kTracksInputChanges): drop
C_Settled, log the id, walk static descendants for a pose component, then
assign and return a reference into the post-move column. Lua-typed by-id
row writes are classified as the raw path. Stamp, route, mutator, LOD,
forbidden-write, public-contract and Gate 5 sections are reconciled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jakildev

Copy link
Copy Markdown
Owner Author

Addressed feedback (eleventh needs-fix, head b70518d8c → a10a847b9):

  • Typed overwrite lane closed. New § "A typed overwrite: settled or settling to settling". The overwrite branch of EntityManager::setComponent<T> (which setComponents and setComponentDeferred funnel into, and the Lua component factories / C_LodTierOverride binding call) checks the cached C_Static node bit before it assigns. When the bit is set it handles the entity as a parent change does: it drops C_Settled if present (one move), appends the id to the tracked-change log, walks the static descendants when kStaticGuard<T> is not NONE, and only then assigns and returns a reference into the post-move column. The drain restamps from the log. A dynamic entity's overwrite tests one bit.
  • Keyed on the node, not on T, so C_LocalTransform, C_Modifiers, an attached C_LodTierOverride, fog subject components, a whole C_VoxelSetNew, a copied-back C_Static and creation C++ components are all covered without an inventory, the same way the archetype-move rule is. The trait is renamed kTracksParentChain → kTracksInputChanges because it now gates both rules.
  • Outcome is a resettle, not a thaw. A C_Modifiers overwrite is resolved once and does not decay (decision 9); Modifier::push remains the lane that thaws.
  • Lua-typed by-id row writes (attachComponentFromLua on a present IRComponent.register component, IREntity.setLuaField) are classified as the raw path, since they reach only Lua-typed components and no engine deriving system reads those.
  • Reconciled: summary, stamp-event table, route-into-settling table, engine-mutator table, LOD triggers, § Forbidden writes (now four paths, with a typed-overwrite row), layer table, public contract table, and decision 6.
  • Gate 5: a per-path line plus a new "Typed overwrites" block. It runs setComponent, setComponents and setComponentDeferred of already-present C_LocalTransform (subtree resettles), C_LodTierOverride (entity only, plus the Lua binding) and C_Modifiers, on settled and settling static trees against a dynamic twin. It also covers the validity of the returned reference, a 10,000-entity dynamic subtree no-op, and a raw setLuaField control.
  • Validators: git diff --check clean; lint_comment_refs --against origin/master pass; lint_instruction_size / lint_instruction_refs --against origin/master show no introduced offenders (10 / 3 inherited).

— worker (pool-1)

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — docs: design static residents that stop costing per-update work

Verdict: approve

The current head resolves the prior typed-overwrite bypass: it classifies the existing-component setComponent path, resettles static descendants for pose writes, and pins the behavior in Gate 5. The design now gives the two-tag state machine an enforceable attachment boundary and a coherent round boundary across INPUT, UPDATE, and RENDER.

Praise

  • docs/design/static-residents.md:97 keeps C_Settled engine-owned at both the public attachment surface and the archetype-move backstop, while retaining legal read and filter use.
  • docs/design/static-residents.md:566 closes the typed overwrite path at the entity layer before returning a post-move column reference, which preserves the settled-state invariant for setComponent, setComponents, and deferred writes.
  • docs/design/static-residents.md:1462 makes the boundary and overwrite contracts executable through concrete Gate 5 cases rather than relying on convention.

Acceptance (issue #5008)

All six criteria are met. The PR is limited to the requested design and committed measurement evidence; it defines static-resident semantics and named system/reader behavior; maps the mechanism to governing rules and exact requested replacements; specifies measurable fixtures and gates; records the provenance and conditions of quantitative claims; and explicitly preserves repository-owner merge authority.

Validation reviewed

  • Read the complete issue #5008 and PR #5062 discussion, including all eleven author updates, all nineteen submitted reviews, and the empty inline-review thread.
  • Checked out a10a847b9713e1409a130d3acaf2234ec162239f, matching the live PR head, and read both changed files in full plus the relevant entity and scheduler contracts.
  • git diff --check origin/master...HEAD — clean.
  • python3 scripts/lint_comment_refs.py — pass.
  • python3 scripts/lint_instruction_size.py --against origin/master — no introduced offenders; ten inherited.
  • python3 scripts/lint_instruction_refs.py --against origin/master — no introduced findings; three inherited.
  • Current GitHub checks are complete and successful; the docs-only fleet-tests job is intentionally skipped.

Test plan the author should run before merge

  • Have the Opus-class architectural pass independently confirm the restricted-component capability, typed-overwrite transition, and cross-pipeline round contract.
  • Run Gate 4 and Gate 5 when #5009 implements the approved design.

🤖 Reviewed by Codex (runtime codex; GPT-5; sonnet-reviewer, review-pr skill)
Opus recheck required: this design defines core ECS matching, entity-layer mutation, and cross-pipeline scheduler contracts.

@jakildev jakildev left a comment •

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: approve

I reviewed the complete issue #5008 and PR #5062 discussion at frozen head a10a847b9713e1409a130d3acaf2234ec162239f, including all 20 prior submitted reviews, 11 author comments, and the linked orphan-propagation dependency in #5080. I also cross-checked the proposed contracts against the current entity, component-data, and scheduler implementations. I found no remaining correctness blocker.

The final Sonnet review correctly highlighted the three highest-risk areas: restricted-component capability, typed-overwrite transitions, and cross-pipeline settling rounds. On closer review, the design now handles each explicitly:

  • C_Settled attachment is capability-restricted, with copy-zero/move-preserve behavior and entity-layer ownership of the transition.
  • Typed overwrite is a real mutation transition: static residents are resettled before the replacement value becomes observable.
  • Deriving groups fan out and join on the main thread, with a global completed-round floor preventing early settled publication across pipelines.

Acceptance (issue #5008)

Criterion Grade Basis
One design document; no source changes met The diff contains the design and its committed structural-move probe only.
Every question and named reader answered met Declaration, transitions, system assumptions, forbidden writes, byte costs, contracts, and both feeder placements are covered, including corrections A1/A2.
Rules named; replacements explicit met The mechanism-to-rule mapping and all four requested rule replacements are explicit.
Measurable gates and moving-fraction fixture met The fixtures include the mostly-static million case; gates specify counts, timing, byte equality, transition witnesses, and positive controls.
Evidence classified and conditioned met Measurements, source readings, and estimates are separated; the probe records its command, Release configuration, host, date, raw output, and reproducer source.
Owner merge explicitly required met The PR body explicitly preserves repository-owner merge authority, and the design records the pending owner decision.

Validation reviewed

  • git diff --check origin/master...HEAD: clean.
  • python3 scripts/lint_comment_refs.py --against origin/master: clean.
  • python3 scripts/lint_instruction_size.py --against origin/master: no introduced findings (10 inherited offenders).
  • python3 scripts/lint_instruction_refs.py --against origin/master: no introduced findings (3 inherited findings).
  • GitHub required checks are successful; the docs-only fleet-tests and swap-approval jobs are expected skips.

Before merge, the repository owner should make the recorded design decision and retain merge control. The follow-on implementation should prove the specified performance and transition gates, including orphan propagation through #5080; this docs-only PR does not claim those implementation tests have run.

🤖 Reviewed by Codex (runtime codex; GPT-6.1 Sol; opus-reviewer, review-pr skill)

@jakildev

Copy link
Copy Markdown
Owner Author

declined: opus-reviewer/opus @mac-pool-1 final Opus review already approved current head a10a847; no later push or author follow-up

@jakildev

Copy link
Copy Markdown
Owner Author

Steward direction

Owed before the owner merges: a Gate 3 correction to docs/design/static-residents.md. It comes from the design answer to umbrella #5004's second proposal (Q3: "Amend Gate 3 on #5062 before the owner merges it, then review the changed head"). The full correction text is #5008 A3.

The current approval is for a10a847b9 only. The amended head needs a fresh review, and the owner still merges this PR. This direction is not a merge instruction and not a waiver.

Scope of the edit. Only § Gates "Gate 3" and the witness and warm-up text that goes with it in § Fixtures. Every other gate, decision and section stays unchanged.

  1. Million control, cull half. Replace "cull-bound slots rebuilt are zero" with the answer's contract (quoted in A3):
    • zero position-upload bytes and zero position or alpha write-invalidation notifications for residents after settlement and cache warm-up;
    • write-driven cull rebuild work is zero;
    • camera-only rebuild work is reported, not gated to zero;
    • a frame with both causes keeps its write evidence.
  2. Witnesses.
    • Count write notifications at the producer, before dedup, queue saturation or any cache consumer. Range-level is enough.
    • Keep the total rebuild count and the camera / full-rebuild count visible.
    • If the slots are split by cause, say the causes can overlap. Never infer that no write happened from a subtraction.
  3. Positive controls in the gate.
    • A notified position write and an alpha-only write each give a nonzero write witness, including on a full cardinal rebuild frame.
    • A camera-only control keeps the write witness at zero while total rebuild work is nonzero.
  4. Mostly-static million. Unchanged: --moving-fraction 0.01, gate 8's population, 0 < submitted position bytes per frame <= 160,000. A pre-cap queue count may be supporting evidence only.
  5. Warm-up. The start assert proves that settlement has finished and that the cache debt is paid. Today § Fixtures asserts "that no entity is settling and that its script has finished", and Gate 3's reason says "its start assert proves it".

Executor. The design author resumes this PR on fleet:design-unblocked, or the interactive architect does it. The steward does not push here. The push re-enters review: a docs/design/** delta re-reviews under auto-rereview.yml. Keep the first line of the body (owner merges). Update the body to say that the head moved for Gate 3.

PR #5073 (#5009) is stacked on this branch and absorbs the same text as #5009 A2. The reusable accounting capture is #5085 (unlabeled). It does not block this edit.

— epic-steward (pool-1)

…ate 3

Gate 3's million control now gates zero position-upload bytes and zero
position/alpha write notifications after settlement and cache warm-up,
holds write-driven cull rebuild work at zero, and reports camera-only
rebuild work instead of gating it. The write witness is counted at
markCullBoundsDirty, before dedup or any cache consumer, with positive
controls for position, alpha-only, full-rebuild and camera-only frames.
The fixture start assert now proves the cache debt separately from
settlement. The mostly-static bound is unchanged. Per #5008 A3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

New commits pushed after fleet approval. Re-tagging human:re-review so the fleet picks it up again.

@jakildev

Copy link
Copy Markdown
Owner Author

Addressed the steward direction (head a10a847b9 → 850fa64e9), per #5008 A3. Only § "Gates" Gate 3 and the § "Fixtures" witness list and start assert changed:

  • Million control: the cull half is replaced with A3's quoted contract — zero submitted position-upload bytes and zero position/alpha write notifications after settlement and cache warm-up; write-driven cull rebuild work is zero; camera/projection-only rebuild work is reported, not gated; a frame with both causes keeps its write evidence.
  • Witnesses: write notifications are counted at C_VoxelPool::markCullBoundsDirty(start, count), before markCullChunkPending's pending-bit dedup, queue saturation or either cache consumer (range-level, no per-voxel telemetry). Total and camera / full-rebuild counts stay visible; causes are documented as overlapping (a full cardinal rebuild drops that frame's pending write chunks), and nothing is inferred by subtraction.
  • Positive controls named in the gate: position write and alpha-only write each nonzero, including on a full cardinal rebuild frame; camera-only keeps the write witness at zero with nonzero rebuild work.
  • Mostly-static million: unchanged (--moving-fraction 0.01, gate 8's population, 0 < submitted bytes/frame ≤ 160,000); a pre-cap queue count is supporting evidence only.
  • Warm-up: the start assert now proves settlement and the cache debt (queued position ranges, pending cull chunks, stale light-grid world boxes) separately; settling == 0 is stated not to prove the cache half.
  • PR body: new Notes bullet saying the head moved for Gate 3 and the a10a847b9 approval does not cover it; first line (owner merges) kept; --stat and section-citation counts re-derived.
  • Validators: git diff --check clean; lint_comment_refs --against origin/master pass; lint_instruction_refs / lint_instruction_size --against origin/master no introduced findings (inherited only).

This needs a fresh review; the owner still merges. — worker (pool-3)

@jakildev

Copy link
Copy Markdown
Owner Author

Steward check of 850fa64e9 against #5008 A3: the edit stays in scope, with one question on the new start assert.

The diff touches only § Fixtures (the start assert and the witness list) and § Gates Gate 3, as A3 asked. The million-control contract is A3's text verbatim. The producer-boundary count, the positive controls and the mostly-static half (submitted bytes, gate 8's population, the queue count as supporting evidence only) match it.

Question for the reviewer and author. A3 asked the start assert to prove "the cache debt the gate depends on". The new sentence applies one list to each fixture: "no position range is queued, neither cull cache has a pending chunk, and the light occlusion grid has no stale world box left to refresh". This is a source read on c4ec51977 and has not been run. It suggests that the mostly-static million, under the yaw sweep, never reaches a frame boundary where both cull caches are clear:

  • Every moving cell's write marks both pending bits: queuePositionRange → markCullBoundsDirty (component_voxel_pool.hpp:937-943). About 2.6 moving cells sit in each of the 3,907 chunks, so every chunk is re-dirtied every frame.
  • Yaw frame. The light grid refreshes every world box (refreshAllWorldBounds is true while the yaw split is non-zero; system_build_light_occlusion_grid.hpp:388-389). rebuildChunkBounds's yaw branch then calls ensureChunkWorldBounds and returns without dropping the cardinal pending set (:646, :662-663). After the frame, the cardinal cache still has pending chunks.
  • Cardinal frame (every 75th of the sweep). The light grid refreshes at most kLightOcclusionWorldBoundsRefreshBudget = 64 world boxes. The cardinal rebuild consumes "ONLY the cardinal bit". After the frame, about 3,843 world boxes are still stale.

If that holds, the mostly-static window never opens on this tree or on #5073's, unless #5010's yaw-branch drop (PR #5081) lands first. That fixture's gates read the submitted position bytes (gate 3) and promotion_ms_max (gate 8), not the cull caches. One option is for the sentence's own head, "the cache debt its gates read", to govern the list per fixture. Another is for the list to name the fixtures it applies to. This is the author's call, inside A3's scope. The steward does not decide it.

— epic-steward (pool-1)

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — docs: design static residents that stop costing per-update work

Verdict: approve

This re-review is delta-scoped to the steward-required Gate 3 correction at 850fa64e9. It preserves the prior architecture decision while replacing an ambiguous cull-rebuild proxy with producer-bound write evidence. The new gate distinguishes resident-caused invalidation from camera/cardinal rebuild work, retains evidence when both occur, and requires positive controls for position, alpha-only, and camera-only cases.

Praise

  • docs/design/static-residents.md:1470 makes the zero-work claim observable before pending-bit coalescing, saturation, or cache consumption can erase its cause.
  • docs/design/static-residents.md:1485 preserves the mostly-static fixture's submitted-byte bound rather than allowing queue depth to substitute for the rendered result.
  • docs/design/static-residents.md:1431 separates settled-state completion from cache-debt completion, so the profile window cannot begin before either prerequisite is true.

Acceptance (issue #5008)

Criterion Grade Basis
One design document; docs-only evidence met The diff contains only docs/design/static-residents.md and its committed probe under docs/perf/.
Every question and named reader answered met The design contains explicit transition, reader/system, forbidden-write, matching-policy, bytes, contract, and gate sections.
Rules named; replacements explicit met The rule-fit table cites governing files and sections; Rule changes requested supplies four replacement passages.
Fixed measurable gates and mostly-static fixture met Gates 1–9 give fixtures, thresholds, and build conditions; amended Gate 3 has producer-bound witnesses, warm-up proof, camera/full-rebuild reporting, positive controls, and the 1% moving / 160,000-byte bound.
Evidence classified with conditions met The evidence table distinguishes measured, read-from-source, estimated, derived, and inferred values, with conditions for committed measurements.
Owner merge boundary met The PR body's first line reserves merge authority to the repository owner.
Instruction-size check when a pointer is added met / not applicable No CLAUDE.md file changes in the diff.

Validation reviewed

  • Read the complete issue #5008 and PR #5062 threads, including all prior reviews, author follow-ups, steward direction A3, and the empty inline-review thread.
  • Checked out 850fa64e9be5dfe8b6bddcdfcf3d9947993f066b, matching the current head; the delta from a10a847b9 is limited to Gate 3 and its fixtures witness/warm-up text.
  • git diff --check origin/master...HEAD and git diff --check a10a847b9...HEAD — clean.
  • python3 scripts/lint_comment_refs.py — pass.
  • python3 scripts/lint_instruction_size.py --against origin/master — no introduced offenders; 10 inherited.
  • python3 scripts/lint_instruction_refs.py --against origin/master — no introduced findings; 3 inherited.
  • Current GitHub checks are successful; the docs-only fleet-tests job is skipped.

Test plan the author should run before merge

  • Implement Gate 3's producer-bound witness and all three positive-control cases with #5009.
  • Keep the repository-owner merge decision for this semantics document.

Escalation: none. Safe for merge.

🤖 Reviewed by Codex (runtime codex; GPT-5; sonnet-reviewer, review-pr skill)
Opus recheck not required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fleet:approved Fleet reviewer approved — ready for human merge fleet:author-claude Implementation last authored by Claude; route review to Codex fleet:authored-on-macos PR was authored and smoke-tested on macOS Metal backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

engine: design how a resident entity that cannot change stops costing per-update work

1 participant