You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Deliberately-deferred design option, recorded so the reasoning does not stay tribal knowledge in a rustdoc. Not a bug report and not scheduled work -- this is an option a future maintainer should weigh when next touching the LTM occurrence IR.
Current design
The LTM occurrence IR (src/simlin-engine/src/db/ltm_ir.rs) identifies each reference occurrence by a SiteId: a path of u16 child indices from the target equation's slot root. Every AST-shaped child count fits a u16 by construction, EXCEPT builtin arity -- MEAN/SUM and friends are variadic, so a call with 65,536+ arguments is representable and would overflow a child index.
That case is handled today by a three-part mechanism (added on branch roundtrips-track-a, commits b0a2a6f0 and d5eed63b):
UNADDRESSABLE_CHILD -- a reserved u16 sentinel that site_child_index never returns.
A suppress_occurrences depth counter on WalkAccum, so an unaddressable child and its whole subtree record no occurrences while STILL recording their per-edge ReferenceSites. The two views are deliberately asymmetric: a missing per-edge entry is defaulted to Bare by consumers, so suppressing the per-edge entry too would misclassify the reference.
ltm_augment::child_path maps an over-arity child to that sentinel with a checked conversion, so the wrap's lookup provably misses instead of aliasing an earlier sibling.
It also leaves behind one documented conflation: db.rs::module_output_ref_in_document_order cannot distinguish a SUPPRESSED module-output occurrence from "the target reads no output of this module" -- both return None and fall through to the signed magnitude-1 black_box_unit_transfer_equation instead of a real ceteris-paribus partial.
The simplification to consider
Reject an over-arity builtin at the LTM front door -- loudly -- instead of threading a sentinel through the IR and the wrap. That would delete:
UNADDRESSABLE_CHILD
the suppress_occurrences counter on WalkAccum
child_is_addressable
the sentinel branch in ltm_augment::child_path
the module_output_ref_in_document_order conflation
The fallback is an honest approximation, not a plausible-looking wrong number. The module-output conflation falls through to the same explicit signed-unit-transfer approximation that an unlocatable reference has always taken.
The existing mechanism is pinned from both sides (producer boundary + consumer sentinel mapping + the ref-site-preservation contract), so it is not fragile -- just more machinery than the case warrants.
Cost. Reopening it would spend another implement-and-review cycle on a branch that had already earned its keep.
What a future implementer should check
Where the front-door check lives, so BOTH views agree. The per-edge ReferenceSite view currently keeps its entries even for suppressed children. A front-door reject changes that, and consumers default a missing per-edge entry to Bare -- so the reject must be model-level or edge-level, never a silent drop of an individual site.
What "reject" means: skip-the-edge-with-a-warning vs. refuse-LTM-for-the-model, and how either interacts with model_ltm_fragment_diagnostics.
That deleting the sentinel does not reintroduce the aliasing bug. The entire point of the reserved value is that a path containing it cannot equal any recorded SiteId; an arity check must fail before any path is constructed, not merely truncate.
Commits b0a2a6f0 ("engine: make LTM arm parse failures loud, index occurrences by slot") and d5eed63b ("engine: complete the LTM over-arity SiteId guard on both sides") on roundtrips-track-a
Recorded during roundtrips-track-a review; the maintainer chose to record rather than act.
Deliberately-deferred design option, recorded so the reasoning does not stay tribal knowledge in a rustdoc. Not a bug report and not scheduled work -- this is an option a future maintainer should weigh when next touching the LTM occurrence IR.
Current design
The LTM occurrence IR (
src/simlin-engine/src/db/ltm_ir.rs) identifies each reference occurrence by aSiteId: a path ofu16child indices from the target equation's slot root. Every AST-shaped child count fits au16by construction, EXCEPT builtin arity --MEAN/SUMand friends are variadic, so a call with 65,536+ arguments is representable and would overflow a child index.That case is handled today by a three-part mechanism (added on branch
roundtrips-track-a, commitsb0a2a6f0andd5eed63b):UNADDRESSABLE_CHILD-- a reservedu16sentinel thatsite_child_indexnever returns.suppress_occurrencesdepth counter onWalkAccum, so an unaddressable child and its whole subtree record no occurrences while STILL recording their per-edgeReferenceSites. The two views are deliberately asymmetric: a missing per-edge entry is defaulted toBareby consumers, so suppressing the per-edge entry too would misclassify the reference.ltm_augment::child_pathmaps an over-arity child to that sentinel with a checked conversion, so the wrap's lookup provably misses instead of aliasing an earlier sibling.It also leaves behind one documented conflation:
db.rs::module_output_ref_in_document_ordercannot distinguish a SUPPRESSED module-output occurrence from "the target reads no output of this module" -- both returnNoneand fall through to the signed magnitude-1black_box_unit_transfer_equationinstead of a real ceteris-paribus partial.The simplification to consider
Reject an over-arity builtin at the LTM front door -- loudly -- instead of threading a sentinel through the IR and the wrap. That would delete:
UNADDRESSABLE_CHILDsuppress_occurrencescounter onWalkAccumchild_is_addressableltm_augment::child_pathmodule_output_ref_in_document_orderconflationreplacing all of it with a single arity check.
Why it was not done now
What a future implementer should check
ReferenceSiteview currently keeps its entries even for suppressed children. A front-door reject changes that, and consumers default a missing per-edge entry toBare-- so the reject must be model-level or edge-level, never a silent drop of an individual site.model_ltm_fragment_diagnostics.SiteId; an arity check must fail before any path is constructed, not merely truncate.References
b0a2a6f0("engine: make LTM arm parse failures loud, index occurrences by slot") andd5eed63b("engine: complete the LTM over-arity SiteId guard on both sides") onroundtrips-track-aRecorded during
roundtrips-track-areview; the maintainer chose to record rather than act.