Launch the JavaFX 2 project shell on Java 25 with an interactive viewport, managed Play lifecycle and project mutation guards. Preserve headless/MCP and save compatibility, and qualify exact runtime executable bundles. Separate unit JaCoCo gates from opt-in integration suites and use the internal Pong fixture for the headless visual pilot. Move maintenance and native conformance tools into tooling; retain the VS Code extension and update current navigation links. Validation: tooling make verify passed, including 1064 Studio unit tests, JaCoCo thresholds and 22 headless integration tests.
261 lines
16 KiB
Markdown
261 lines
16 KiB
Markdown
---
|
||
id: LSN-0090
|
||
ticket: pbs-sdk-list
|
||
title: Mutable Lists and Stable Snapshot Cursors
|
||
created: 2026-10-22
|
||
tags: [compiler-pbs, collections, snapshot-cursor, failure-phases, runtime-conformance]
|
||
---
|
||
|
||
## Original problem and final result
|
||
|
||
Owner: `compiler/pbs`. Transversal owners: `compiler/general` for neutral IR/PBX
|
||
and the runtime provider for storage, faults, ownership and resource accounting.
|
||
DSC-0090 implemented accepted DEC-0075 through PLN-0153, covering R1–R14.
|
||
The workflow control artifacts are disposable; the
|
||
[List/Cursor specification](../../../docs/specs/compiler-languages/pbs/21.%20SDK%20List%20and%20Cursor%20Specification.md)
|
||
is the durable normative reference.
|
||
|
||
PBS needed a resizable collection whose existing references remain valid, together
|
||
with a traversal that survives later collection edits. Both now live in the
|
||
executable SDK: ordinary generic `list<T>`, the shared `Cursor<T>` contract and
|
||
private snapshot nodes. The compiler provides trusted private bindings and source
|
||
projections; ordinary typed storage and ARRAY_COPY preserve complete stored groups.
|
||
|
||
This lesson was reconciled during AGD89 closure on 2026-10-27 with accepted
|
||
DEC-0077 / PLN-0155, consolidated in
|
||
[LSN-0092](../DSC-0096-runtime-storage-isa-consumer-migration/LSN-0092-sequential-collection-mutations-need-explicit-failure-boundaries.md).
|
||
That migration replaced the original guard/publication instructions and universal
|
||
whole-method refusal guarantee. The current explanation below follows the
|
||
sequential-store contract; the original evidence remains explicitly historical.
|
||
Other collection APIs are documented in their own specifications and lessons.
|
||
|
||
## Separate collection identity, logical positions and physical storage
|
||
|
||
A List is a shared object containing a private fixed-length array and logical size.
|
||
Growth replaces the backing reference inside that same object. Existing aliases
|
||
therefore continue to observe the collection after growth, reserve or trim.
|
||
|
||
Size includes holes. Capacity alone does not create valid positions. For example,
|
||
`new list<int>(16)` has size zero; `resize(3)` creates three valid empty positions.
|
||
Writing position zero then stores a present value without changing size. Zero and
|
||
false remain present values. `clearAt` leaves a hole, while `removeAt` removes a
|
||
position and shifts the complete suffix, including its holes.
|
||
|
||
The complete API includes constructors, size/capacity, bracket access, add, insert,
|
||
clearAt, removeAt, clear, resize, reserve, trim and cursor. The
|
||
[specification](../../../docs/specs/compiler-languages/pbs/21.%20SDK%20List%20and%20Cursor%20Specification.md) defines
|
||
their exact results, geometric growth, structural limits and fault classifications.
|
||
Clear, shrink and removal erase discarded references; later growth cannot resurrect
|
||
old values. Directly optional elements are rejected, including through grouping;
|
||
an optional List remains valid. Applications are invariant, and argument values
|
||
do not infer the element type.
|
||
|
||
## A snapshot freezes the sequence of references
|
||
|
||
List capture scans its logical positions backwards and prepends one node per
|
||
present occurrence. The resulting chain visits increasing source indices, skips
|
||
holes and preserves duplicates. Nodes are private, immutable, singly linked and
|
||
non-circular. Capture finishes before the Cursor is returned. There is no second
|
||
array, source-slot alias or source collection reference needed for traversal.
|
||
|
||
Replacing, inserting, removing, clearing or resizing the List cannot change this
|
||
captured sequence. A captured object reference still identifies the same object,
|
||
so later mutations of its fields remain visible. This distinction lets gameplay
|
||
change its collections while a consumer walks a stable sequence.
|
||
|
||
The private cursor object stores its current-node reference. It can replace that
|
||
root as it advances without changing any node link. Once other owners and call
|
||
frames release consumed nodes, the prefix becomes collectible. The current node
|
||
retains the remaining suffix.
|
||
|
||
### Successor-based hasNext and a retained last element
|
||
|
||
`current()` initially reports the first element. `hasNext()` asks whether that
|
||
element has a successor. `next()` follows an existing successor and otherwise
|
||
does nothing.
|
||
|
||
| Snapshot/state | hasNext() | current() |
|
||
| --- | --- | --- |
|
||
| Empty, initially or after repeated next | false | none |
|
||
| [A], initially or after repeated next | false | some(A) |
|
||
| [A, B], initially | true | some(A) |
|
||
| [A, B], after one or any further next | false | some(B) |
|
||
|
||
Process current, then either advance or stop. A hasNext-only loop omits the last
|
||
element. A loop waiting for current to become none never finishes a nonempty
|
||
snapshot. The
|
||
[distributed example](../../../prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/resources/pbs-knowledge/examples/game/1/src/collections.pbs)
|
||
captures 20 and 22 around a hole, clears the List, visits both captured values and
|
||
returns 42. Current still contains 22 afterwards.
|
||
|
||
The outer optional describes whether a node exists. A producer with optional T
|
||
must preserve `some(none)` as a present node whose payload is none. A synthetic
|
||
non-List producer qualifies that distinction independently of List's element rule.
|
||
Linked/Set produce Cursor<T>; Map entries use Cursor<keyval<K,V>>, and Stack/Queue
|
||
capture in removal order. Their construction rules and ordering guarantees belong
|
||
to their own specifications. These producers reuse the same Cursor state table.
|
||
|
||
## Prepare values, then perform sequential updates
|
||
|
||
Logical index/length checks are executable PBS comparisons and branches ending in
|
||
the trusted private terminal TRAP_EXPLICIT binding. They are not INDEX_GUARD or
|
||
ARRAY_CHECK_LENGTH instructions. ARRAY_COPY remains a neutral complete-group,
|
||
overlap-safe transfer; STORAGE_PUBLISH and FIELDS_PUBLISH were retired by the
|
||
migration in LSN-0092. No compound publication instruction is available.
|
||
|
||
For insertion with growth, allocate a private candidate and copy prefix/suffix
|
||
directly into their final positions, including holes and presence tags. Store
|
||
the new value privately, then assign backing and length in sequence. Without
|
||
growth, first prepare the inserted stored group in a private one-slot array,
|
||
shift the suffix with ARRAY_COPY, copy the prepared slot and update length.
|
||
The temporary array and both copies retain ordinary allocation, scratch,
|
||
validation and charging costs, including empty copies.
|
||
|
||
Removal prepares its optional return, shifts the suffix, clears the old tail and
|
||
updates length. Clear and in-capacity resize clear the selected interval in index
|
||
order before assigning length. Growing resize prepares/copies a candidate before
|
||
backing/length installation; reserve/trim prepare/copy candidates and replace only
|
||
backing. Indexed replacement/clearAt update one checked position. Complete stored
|
||
groups move without unpacking/reboxing every shifted element.
|
||
|
||
| Outcome | Current guarantee |
|
||
| --- | --- |
|
||
| Logical rejection or preparation refusal before the first visible write | Previous backing, capacity, size and slots survive; argument effects and provisional allocations are not undone |
|
||
| Successful return | All collection, cleanup, identity, group and snapshot invariants hold |
|
||
| Internal/resource fault after visible writes start | Earlier writes may remain and invariants may be incomplete; no rollback, safe reuse, retry or recovery is promised |
|
||
|
||
Preparing values/returns does not make every subsequent instruction infallible.
|
||
A refused instruction preserves its own entry state, not earlier successful
|
||
stores. BudgetExhausted/debugger pauses are resumable boundaries; a method is not
|
||
an atomic host observation region. No callback or explicit suspension is inserted
|
||
between mutation updates. Candidates, temporary arrays and scratch follow normal
|
||
ownership/quotas; immediate GC or quota return is not promised.
|
||
|
||
The provider has no List/Cursor opcode, category or syscall; algorithms remain in
|
||
[SDK source](../../../prometeu-compiler/frontends/prometeu-frontend-pbs/src/main/resources/game/stdlib/1/sdk/collections/main.pbs).
|
||
|
||
## Compiler and tooling integration
|
||
|
||
Reserved SDK attributes carry trusted definition origin. Copying their names into
|
||
a project cannot grant private primitive access, and a user struct named list does
|
||
not acquire SDK indexing or constructor rules. The public barrel exports List and
|
||
Cursor; backing fields, storage bindings, nodes and bracket adapters stay private.
|
||
|
||
SDK executable functions and implementations use the ordinary generic pipeline.
|
||
Supporting them exposed reusable shape requirements: optional recursive payload
|
||
members, concrete contract methods, applicable implementations and native group
|
||
field maps must survive specialization. Complete values include vec2, pixel,
|
||
tuples, nested arrays, contracts and function references.
|
||
|
||
List index/length arguments accept localized lossless int-to-long promotion.
|
||
Receiver and arguments execute once in source order, including named arguments.
|
||
General numeric conversion rules stay unchanged. Common aggregation, optimization,
|
||
emission and preload verification carry ordinary typed stores, ARRAY_COPY and the
|
||
terminal operation. Retired encodings are rejected even in dead instructions;
|
||
matching byte values inside ordinary immediates are not retired instructions.
|
||
|
||
Editor projections show concrete public List/Cursor methods, optional results,
|
||
constructor overloads and SDK definitions. Hover/completion hide private adapters
|
||
and backing fields. Installed JAR tests load the actual packaged SDK, normative
|
||
spec and example outside the checkout, generate PBX and execute it in the provider.
|
||
|
||
## Current qualification and historical evidence
|
||
|
||
The current selected pin is [the catalog revision](../../../docs/vm-arch/runtime-catalog.properties),
|
||
`dcf6561ea73446e0a3e1cf1c73eda20923b38df0`. The
|
||
[migration evidence](../DSC-0096-runtime-storage-isa-consumer-migration/runtime-conformance-evidence.json)
|
||
qualifies sequential stores, logical traps and mutation phases. Later complete
|
||
[debug/release evidence](../DSC-0097-pbs-sdk-stack-queue/evidence/README.md) includes
|
||
the current List/Cursor corpus with both producers. This editorial reconciliation
|
||
does not rerun those suites or change their recorded scope.
|
||
|
||
The following table and the original JSON are historical delivery evidence for
|
||
the superseded storage design, not proof of whole-method preservation today.
|
||
The original selected provider was clean commit
|
||
`d9b9eeb171d2861ec660d4cf5703b0795eac49a9`. Studio changes were tested over base
|
||
`76a8b074e89e17c7425220888eeec38427261d46`. Qualification used macOS 27.0.1 arm64,
|
||
Rust 1.98.1/LLVM 22.1.8, the dev runtime profile with resource-diagnostics,
|
||
capabilities NONE, Gradle 9.3.1 and the repository's Java 21 toolchain
|
||
(Corretto 21.0.4). Ordinary and optimized producer paths were exercised.
|
||
|
||
| Historical delivery gate | Result on the original pin |
|
||
| --- | --- |
|
||
| Provider bytecode and VM libraries | 6 + 302 passed; 2 existing measurement tests ignored |
|
||
| Full Studio regression and installed knowledge | Passed; existing skipped tests retained |
|
||
| Final frontend/editor, LSP, source generation and installed checks | Passed; both installed tests passed |
|
||
| PBS List/Cursor through production verifier/VM | 27 cases in each producer mode: 54 passed |
|
||
| Non-PBS common IR | 2 storage fixtures executed through production VM |
|
||
| Compound-publication refusals, now retired | 71 attempts; prior List state preserved on the original pin |
|
||
| Cursor GC | Nodes/items: 1200/1200 → 1/1 → 1/1 → 0/0 |
|
||
| Reexports and installed example execution | Both passed; final captured value 22 retained |
|
||
| Provider catalogs and canonical mirrors | Clean pinned provider; catalog parity and all four mirrors match |
|
||
|
||
That historical refusal matrix lowered GuestBytes, HandleSlots, AuxiliaryBytes and TemporaryBytes
|
||
around candidate allocation, no-growth publication scratch, optional return
|
||
preparation, node creation and frame/operand preparation. It compared the typed
|
||
List fields and every backing group before and after each refusal, and verified
|
||
resource accounting returned to zero after VM drop. The original provider tests also
|
||
covered overlapping multi-slot transfers, late invalid fields/ranges, immutable
|
||
Dynamic-box identity and malformed encodings.
|
||
|
||
Controlled normal GC safepoints prove consumed-prefix reclamation, retention of
|
||
the final value 1199 despite repeated next calls, and release after dropping the
|
||
Cursor. No source or snapshot Array remains live for that payload type at those
|
||
safepoints. Optional carriers and other legitimate owners still have their normal
|
||
allocation and retention costs. Capturing n positions with k present values takes
|
||
O(n) time and O(k) additional nodes; next follows one link in O(1).
|
||
|
||
[Historical machine-readable evidence](runtime-conformance-evidence.json) records commands,
|
||
source and PBX hashes, default ceilings, every lowered refusal quota, GC observations
|
||
and tested provenance. New cases are mandatory; missing fixtures fail the harness.
|
||
The full harness also reports two pre-existing response-schema gaps, LifecycleRole
|
||
and NonFiniteValue, with original payloads preserved. These were not changed by
|
||
this original delivery. That historical run makes no release-profile or cross-platform
|
||
claim; later debug/release qualification is linked separately above.
|
||
|
||
The original R1–R5 mapping used type/construction/bounds/mutation/capacity fixtures; R6–R9 used
|
||
snapshot states, identity, non-List optional production and GC; R10–R11 used direct
|
||
provider tests, common IR and the refusal matrix; R12 used editor/import/distribution
|
||
gates; R13 used resource accounting and retention observations; R14 used the mandatory
|
||
production corpus, full regressions and pinned provenance.
|
||
|
||
## Pitfalls to preserve in future work
|
||
|
||
- Treat logical size and capacity separately. An index inside physical capacity
|
||
can still fail the SDK's logical check with TRAP_EXPLICIT; a hole is an optional
|
||
result only at a valid index. Physical Array instructions retain their own faults.
|
||
- Keep faults distinct from absence. Long overflow, invalid bounds and resource
|
||
refusal cannot become none or a truncated index.
|
||
- Prepare optional returns and temporary groups before visible writes. Preparation
|
||
and individual instruction preservation do not provide whole-method rollback.
|
||
- Preserve complete stored groups while shifting. Public optional reboxing can
|
||
change identity, roots, costs and refusal boundaries.
|
||
- Follow the Cursor state table. Never advance a nonempty cursor past its last
|
||
node or retain an initial-head root just to support an unrequested reset.
|
||
- Account for node and optional-carrier allocation. A linked snapshot has no
|
||
promise of lower memory use than an array or immediate quota recovery.
|
||
- Preserve source-selected store/copy order through linking and optimization, and
|
||
compare refusal observations with the successful prefix at the actual failure phase.
|
||
- Keep privileged bindings origin-based and private. Names and copied attributes
|
||
are insufficient authority.
|
||
|
||
## References and reproduction
|
||
|
||
- [List/Cursor specification](../../../docs/specs/compiler-languages/pbs/21.%20SDK%20List%20and%20Cursor%20Specification.md)
|
||
and [Array/optional foundation](../../../docs/specs/compiler-languages/pbs/14.%20Typed%20Arrays%20and%20Optional%20Execution%20Specification.md).
|
||
- [Common Registry/PBX specification](../../../docs/specs/compiler/25.%20Typed%20Registry%20and%20PBX%20v0%20Specification.md),
|
||
[current provider copy code](../../../../runtime/crates/console/prometeu-vm/src/virtual_machine/array_copy.rs)
|
||
and [ordinary typed storage](../../../../runtime/crates/console/prometeu-vm/src/virtual_machine/collections.rs).
|
||
- [Source fixture generator](../../../prometeu-architecture-tests/src/test/java/p/studio/compiler/backend/irvm/PbsListCursorTest.java),
|
||
[neutral IR fixtures](../../../prometeu-compiler/prometeu-build-pipeline/src/test/java/p/studio/compiler/backend/registry/StoragePublicationPipelineTest.java)
|
||
and [production harness instructions](../../../../tooling/scripts/pbx-conformance/README.md).
|
||
- [Mutation-phase migration](../DSC-0096-runtime-storage-isa-consumer-migration/LSN-0092-sequential-collection-mutations-need-explicit-failure-boundaries.md),
|
||
[generic structs lesson](../DSC-0094-pbs-generic-structs/LSN-0089-concrete-generic-state-and-bodies.md)
|
||
and [generic contracts lesson](../DSC-0089-pbs-generic-contracts/LSN-0088-concrete-generic-contracts-from-source-to-vm.md).
|
||
|
||
Run `./gradlew test :prometeu-app:installedKnowledgeTest --console=plain` before
|
||
`python3 tools/pbx-conformance/run.py --runtime ../runtime` so the complete fixture
|
||
corpus, including the installed example, exists. Select the current pin and use
|
||
the migration/later evidence for current reproduction. The original JSON retains
|
||
its original provider, commands and configuration unchanged.
|