Files
prometeu-studio/discussion/lessons/DSC-0087-pbs-sdk-collections/LSN-0096-shared-foundations-and-separate-collection-contracts.md

11 KiB

id, ticket, title, created, tags
id ticket title created tags
LSN-0096 pbs-sdk-collections Shared foundations and separate collection contracts 2026-10-27
compiler-pbs
sdk
collections
umbrella
navigation
failure-phases

Shared foundations and separate collection contracts

Worker: Lesson Worker. Owner domain: compiler/pbs. DSC-0087 / AGD89 coordinated eight completed child discussions. Their accepted decisions/plans remain the sources of technical choices, consolidated in the specifications and lessons below. This umbrella closes coordination and the previously authorized editorial reconciliation; it introduces no new collection contract or implementation scope.

Original problem and resolution

Array syntax, generic language mechanisms, identity policies and several collection APIs were initially mixed into one discussion. A monolithic decision would have made prerequisites, product choices and execution gates hard to distinguish. The user chose an umbrella with separate domain-owned children, ordered as shown below, then added generic structs as a prerequisite and Stack/Queue as one further child. Order of execution did not prescribe one collection's implementation over another.

The result is a qualified source SDK catalog over shared language/storage mechanisms. Each child completed its own agenda → decision → plan → implementation → lesson flow. The final umbrella task reconciled List/Linked lessons with the already accepted sequential-storage migration and repaired their provider links. Original evidence files retain their original bytes and provider provenance.

Reading and ownership map

Read the foundations first, then the collection needed by the caller. Specifications are normative; lessons teach the choices and retain implementation/evidence context.

Sequence / discussion Durable lesson Normative specification
1. Array, DSC-0088 LSN-0087: contextual parametric arrays Array/optional
2. Generic contracts, DSC-0089 LSN-0088: concrete contracts Generic contracts
3. Generic structs/functions, DSC-0094 LSN-0089: concrete state/bodies Generic structs/functions
4. List/Cursor, DSC-0090 LSN-0090: mutable positions/stable snapshots List/shared Cursor
5. Linked, DSC-0091 LSN-0091: private nodes/sequential phases Linked
6. Set/Identity, DSC-0092 LSN-0093: reusable identity/buckets Set/Identity
7. Map/Keyval, DSC-0093 LSN-0094: presence/representative keys Map/Keyval
8. Stack/Queue, DSC-0097 LSN-0095: dense/circular arrays Stack/Queue

The supporting LSN-0092 / DSC-0096 explains accepted DEC-0077 / PLN-0155: source checks, ordinary stores/ARRAY_COPY, failure phases and current-provider provenance. It supersedes the early compound publication guarantees without changing the delivered List/Linked APIs or Cursor. Compiler/general owns neutral IR/PBX; the provider owns storage, ISA, quotas and GC.

Similar syntax does not imply identical collection semantics

Concrete generic applications are invariant. Explicit and contextual lowercase construction follow the accepted language rules; argument values do not infer generic parameters. Shared object instances remain shared through collection insertion, mutation and snapshots. No deep freezing or structural equality is silently introduced.

Surface Logical content and traversal Important distinction
array Fixed length; positions may be empty Physical length is not a resizable collection contract
list Logical positions include holes; snapshot skips holes in index order Size and capacity differ; clearAt keeps a position while removeAt removes it
linked Dense private doubly linked nodes; forward/reverse snapshots No capacity, holes or Array u32 size bound
set Unique members under selected Identity; unordered snapshot Hash filters; equality resolves collisions; private buckets are not a shared universal table
map<K,V> Key associations; unordered read-only Keyval snapshots Lookup/previous-value optional describes entry existence independently of optional V
stack Dense array; LIFO removal/snapshot order Initial capacity does not cap collection size
queue Circular array; FIFO removal/snapshot order Wrapped growth linearizes occupied segments; dequeue does not shift values

Array/List/Linked/Set/Stack/Queue reject directly optional elements. Map rejects a directly optional K but admits optional V; an independent Keyval can hold optional components. Valid objects containing optional fields and optional collections remain distinct from those restrictions. Zero/false are present values; faults are not absence.

Set/Map reuse Identity/hash policies and helpers, with separate private nodes and algorithms. Eligible object keys use instance identity by default; explicit content strategies must remain coherent while keys are stored. Hashing does not supply an implicit structural equality or freeze mutable key content.

One Cursor protocol, collection-specific capture

The shared Cursor captures complete values in immutable private singly linked, non-circular nodes, independent of source slots/editable nodes. It has no public node, live iterator, reset or removal operation. Captured references remain shared objects; later edits to collection membership do not rewrite the captured sequence.

A nonempty Cursor begins on first; hasNext tests successor; next without successor is a no-op; only an empty-born Cursor has absent current. Process current before testing whether to advance. Consumed prefixes can become collectible, but final current remains retained. List, Linked, Set, Map, Stack and Queue select their payload/order while reusing this exact state table.

Current failure guarantees and historical evidence

Prepare checks, complete values, return carriers and candidates before visible mutation, then execute source-selected ordinary stores and copies. Before the first visible write, refusal preserves the prior collection. Success restores all invariants. A later internal/resource fault may retain earlier writes and incomplete invariants; no rollback, safe reuse, retry or recovery is promised. Per-instruction preservation does not establish whole-method atomicity. Budget/ debugger pauses remain resumable instruction boundaries.

The List/Linked lessons now teach this contract and link to LSN-0092. Their early INDEX_GUARD/ARRAY_CHECK_LENGTH/STORAGE_PUBLISH/FIELDS_PUBLISH mechanisms are marked retired or historical. Their original evidence JSONs still describe their original provider pins and stronger publication results, not current guarantees. The old missing provider-publication links now point to existing typed-storage/copy sources. The historical Linked filename is retained to preserve existing references.

The current selected catalog pin is dcf6561ea73446e0a3e1cf1c73eda20923b38df0. The latest complete qualification record includes all existing collection corpora in debug/release and both producer paths, 1,091 standard JUnit cases with no failures/errors and 13 existing skips, plus two passing installed-JAR tests. Those are retained implementation results; this documentation-only closure validates workflow/links/provenance and does not claim a new test run, benchmark, other-host qualification or game readiness.

Candidate backlog retained at closure

These remain candidates, without accepted APIs, delivery commitments or new discussions created by this closure:

Candidate Questions requiring a separate discussion
Deque Two-ended API, order/capacity and whether to reuse a circular mechanism
Pools Distinguish capacity from object creation; acquire/release/reset, full state, duplicate returns and stale references/generations
Priority queue Priority/order/equality policy, storage and resource behavior
Bitset Representation, bounds and intended operations
Sparse set Sparse/dense representation, identity and removal policy

Audio, guest lifecycle, memcard, game qualification, installed Build/Play/headless readiness and handoffs to AGD75/AGD88 are outside this umbrella's closure, as explicitly directed by the user. General documentation migration is a separate discussion; the local reconciliation does not require completing that migration.

Closure and maintenance guidance

All eight children and the supporting migration are done, with only lessons in their workflow records. The remaining List/Linked editorial task is complete. DSC-0087 closes through discussion housekeep, retaining this English navigation lesson and preserving candidate backlog and scope boundaries. The CLI owns index updates and workflow removal; no manual index edits or runtime writes are involved.

Avoid these maintenance errors:

  • Do not turn an umbrella's delivery order into a physical implementation dependency.
  • Do not reinterpret a child decision while planning another collection.
  • Do not inherit capacity, optional eligibility, equality or traversal order by analogy.
  • Do not teach a historical provider guarantee as current merely because its evidence passed.
  • Do not edit historical evidence to make its pin/counts match later implementations.
  • Do not turn backlog candidates or adjacent runtime-readiness work into accepted scope.

The CLI currently has no dedicated umbrella/dependency relationship or standalone lesson-ID allocation command. Existing tags and durable links express relationships; the read-only model accessor supplies the next lesson ID and housekeeping owns registration/counter advancement. These tooling gaps remain explicit rather than being filled with manual index conventions.