refactor(vm)!: remove publication and logical guard opcodes
Intrepid/Prometeu/Runtime/pipeline/head This commit looks good

Remove INDEX_GUARD, ARRAY_CHECK_LENGTH, STORAGE_PUBLISH and FIELDS_PUBLISH
from decoding, metadata, tooling, verification and execution. Keep ARRAY_LEN
and overlap-safe ARRAY_COPY with complete-group ownership and early charging
of calculable copy work, including refused attempts.

Update specifications, producer handoff, qualification evidence and lessons.
Share collection test support and remove redundant Copy clones for Clippy.

Validation: make ci-domains passed with 1,095 workspace tests, five separately
executed debugger socket tests and all 15 unchanged coverage domain gates.
VM release, resource diagnostics and layer/quality suites also passed.

BREAKING CHANGE: PBX using opcodes 0xA7, 0xA8, 0xAA or 0xAB is rejected,
including unreachable instructions. Consumers must adapt their emission and
collection algorithms or operational guarantees.
This commit is contained in:
2026-10-23 23:37:56 +01:00
parent 69ad1931de
commit dcf6561ea7
27 changed files with 1407 additions and 1013 deletions
@@ -0,0 +1,135 @@
---
id: LSN-0072
ticket: vm-storage-publication-neutrality
title: Primitives Need Independent Semantics and Failed Attempts Still Cost Work
created: 2026-10-23
tags: [vm, isa, storage, atomicity, ownership, cycles, frontend-neutrality]
---
## Context and Published Result
DEC-0067, accepted from AGD-0068 and implemented by PLN-0198, reduced the storage
ISA after reviewing additions requested by a consumer. The runtime removed
INDEX_GUARD (0xA7), ARRAY_CHECK_LENGTH (0xA8), STORAGE_PUBLISH (0xAA) and
FIELDS_PUBLISH (0xAB). ARRAY_COPY remains at 0xA9 and ARRAY_LEN at 0xA4. The
supported encodings and fault/cost contracts live in the
[canonical ISA](../../../docs/specs/runtime/02-vm-instruction-set.md#typed-array-range-copy),
[time model](../../../docs/specs/runtime/01-time-model-and-cycles.md#collection-attempt-charging)
and [memory specification](../../../docs/specs/runtime/03-memory-stack-heap-and-allocation.md#prepared-array-range-copy).
The [producer handoff](../../../docs/vm-arch/collection-producer-handoff.md) and
[qualification record](../../../docs/vm-arch/STORAGE_QUALIFICATION.md) describe
integration obligations and executable evidence. This lesson explains the result;
it does not establish a separate contract.
## A Consumer Request Is Evidence, Not a Permanent ISA Commitment
A real compiler or SDK can expose missing capabilities. That makes its use cases
valuable evidence, but delivery in one consumer does not make every added helper
an enduring machine primitive. Re-evaluate the operation's own semantics, failure
boundary and reuse across representations. Backward compatibility was explicitly
not a requirement for this revision.
The removed guards expressed logical limits and allocation-free validation that
the producer can organize through its existing control flow. ARRAY_LEN remains
useful as a direct physical query; removing logical helpers does not remove
physical validation from allocation and array access. A collection's logical
length can differ from its backing array's physical length.
The removed publications coupled several mutations into fixed or schema-selected
batches. Supporting one current collection algorithm did not justify maintaining
those compound machine guarantees. ARRAY_COPY survives because strict typed
range transfer, snapshot overlap and complete-group ownership provide independent
machine semantics without identifying a source collection.
Learning from Java, C#, Rust and Go means examining principles and tradeoffs,
not selecting a mandatory frontend. JavaScript and Lua were philosophical tests
of the architecture's independence. No engine, frontend or object from either
language was needed to implement or qualify this change.
## An Instruction Boundary Does Not Roll Back a Source Operation
ARRAY_COPY starts with five prepared operands. It reserves full scratch, captures
all source groups and then commits prevalidated writes. Failure preserves its
operands and destinations while releasing provisional scratch. Earlier source
calculations, allocations or callbacks keep their effects.
Snapshot preparation explains overlap: when copying indices 0..3 to 1..4 of the
same array, the source sequence is captured before any destination store. Native
String owners, HeapRefs, Dynamic tags/boxes and Trait groups travel together.
Splitting carriers or cloning payload graphs would change the operation.
A series of individually validated STRUCT_SET or ARRAY_SET instructions does not
inherit a shared rollback boundary. A consumer that previously relied on a batch
must establish its invariant through an appropriate algorithm/representation or
explicitly revise its operational guarantee. A renamed helper emitting sequential
stores does not prove equivalence. Consumer migration remains an independent
delivery; it does not block publication of the runtime's own supported surface.
## Select Cost Early Without Selecting the First Fault Early
Let N be count and W the immutable Registry element-slot width. ARRAY_COPY charges
4+2*N*W when all five temporary operands are available and N is an exact Int64 in
0..u32::MAX. For ten one-slot elements the attempt costs 24 even if a receiver is
null, a range is invalid or scratch reservation fails. That charge records the
planned work of an admitted attempt, independently of published state.
Inspecting N early only selects cost. It does not move an invalid count ahead of
an invalid receiver in ordinary fault precedence. If count has a wrong carrier or
is outside the calculable domain, charge base 4 and follow normal validation.
With null source and negative count, the receiver fault still wins. Frame locals
must never stand in for missing temporary operands.
Zero count still validates both receivers and ranges and costs 4. Identity and
aliasing do not discount a copy. Checked total-cost overflow has its explicit
base-charge/SizeOverflow path; synthetic widths test this defense without claiming
that such widths are admitted guest layouts.
This extends the reasoning in
[Collection Attempts Preserve Groups and Charge Work Before Publication](../DSC-0051-game-state-collections-and-objects/LSN-0060-collection-attempts-preserve-groups-and-charge-work-before-publication.md):
unchanged state and consumed cycles are compatible outcomes. Positive budget
admits an entire instruction with overshoot; zero admits none. A failed attempt
reports its trap and charged cycles, but contributes no successful target step.
## Remove Support at Every Boundary
Removing dispatch alone leaves assemblers, decoder metadata or dead-code
verification advertising obsolete capabilities. This implementation removes all
four variants, encodings, metadata, assembler/disassembler cases, Registry effects,
verifier paths and executors. Unsupported instruction positions reject during
admission, including after HALT. The same byte values inside a legitimate immediate
remain data, so a raw byte search is not an admission rule.
The retained copy now has a dedicated executor. Tests inherited from the compound
publication paths were migrated to copy-specific overlap, quota and group cases.
That preserves relevant evidence while eliminating tests of obsolete successes.
## Evidence and Practical Limits
The qualification record identifies the source baseline and working-tree
fingerprints rather than attributing uncommitted code to a new provider SHA.
Tests use independent literal encodings and serialized neutral PBX, the production
loader/VM, exact cycle/fault oracles, quota and allocation-failure injection,
late invalid source groups, overlap in both directions, frame temporary floors,
zero/positive budgets, and native/guest owners across collection.
Internal state injection is labeled separately from admitted-program evidence.
The checked-cost overflow test uses synthetic widths; it does not relax Registry
layout rules. Test-only cleanup also shares the collection fixture module and
removes redundant Copy clones to satisfy Clippy without changing identity/hash
semantics. Full gate results and remaining ignored tests are recorded with their
actual execution status.
These results do not establish the Studio SDK's migration, its old compound
atomicity guarantees, new collection algorithms, or JavaScript/Lua conformance.
Those claims require the consumer's own accepted contract and new evidence on
an identified provider.
## Pitfalls
- Keeping a primitive solely because a delivered SDK already emits it.
- Removing a logical guard while accidentally weakening physical bounds checks.
- Charging only after receiver/range validation, which changes failed-attempt cost.
- Letting cost inspection reorder value faults or read below the temporary floor.
- Dropping ownership/overlap coverage when deleting the old compound executor.
- Treating stores as a transaction, or claiming old consumer evidence for a new provider.
- Searching arbitrary payload bytes instead of actual instruction boundaries.