164 lines
11 KiB
Markdown
164 lines
11 KiB
Markdown
---
|
|
id: LSN-0096
|
|
ticket: pbs-sdk-collections
|
|
title: Shared foundations and separate collection contracts
|
|
created: 2026-10-27
|
|
tags: [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](../DSC-0088-pbs-array-type-syntax/LSN-0087-parametric-arrays-and-contextual-construction.md) | [Array/optional](../../../docs/compiler/pbs/specs/typed-arrays-and-optional-execution.md) |
|
|
| 2. Generic contracts, DSC-0089 | [LSN-0088: concrete contracts](../DSC-0089-pbs-generic-contracts/LSN-0088-concrete-generic-contracts-from-source-to-vm.md) | [Generic contracts](../../../docs/compiler/pbs/specs/generic-contracts.md) |
|
|
| 3. Generic structs/functions, DSC-0094 | [LSN-0089: concrete state/bodies](../DSC-0094-pbs-generic-structs/LSN-0089-concrete-generic-state-and-bodies.md) | [Generic structs/functions](../../../docs/compiler/pbs/specs/generic-structs-and-free-functions.md) |
|
|
| 4. List/Cursor, DSC-0090 | [LSN-0090: mutable positions/stable snapshots](../DSC-0090-pbs-sdk-list/LSN-0090-mutable-lists-and-stable-snapshot-cursors.md) | [List/shared Cursor](../../../docs/compiler/pbs/specs/sdk-list-and-cursor.md) |
|
|
| 5. Linked, DSC-0091 | [LSN-0091: private nodes/sequential phases](../DSC-0091-pbs-sdk-linked/LSN-0091-private-linked-nodes-and-atomic-publication.md) | [Linked](../../../docs/compiler/pbs/specs/sdk-linked-and-cursor.md) |
|
|
| 6. Set/Identity, DSC-0092 | [LSN-0093: reusable identity/buckets](../DSC-0092-pbs-sdk-set/LSN-0093-reusable-identity-and-source-set-buckets.md) | [Set/Identity](../../../docs/compiler/pbs/specs/sdk-set-and-identity.md) |
|
|
| 7. Map/Keyval, DSC-0093 | [LSN-0094: presence/representative keys](../DSC-0093-pbs-sdk-map-keyval/LSN-0094-map-presence-key-identity-and-captured-associations.md) | [Map/Keyval](../../../docs/compiler/pbs/specs/sdk-map-and-keyval.md) |
|
|
| 8. Stack/Queue, DSC-0097 | [LSN-0095: dense/circular arrays](../DSC-0097-pbs-sdk-stack-queue/LSN-0095-private-array-stacks-and-circular-queues.md) | [Stack/Queue](../../../docs/compiler/pbs/specs/sdk-stack-and-queue.md) |
|
|
|
|
The supporting [LSN-0092 / DSC-0096](../DSC-0096-runtime-storage-isa-consumer-migration/LSN-0092-sequential-collection-mutations-need-explicit-failure-boundaries.md)
|
|
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<T> | Fixed length; positions may be empty | Physical length is not a resizable collection contract |
|
|
| list<T> | Logical positions include holes; snapshot skips holes in index order | Size and capacity differ; clearAt keeps a position while removeAt removes it |
|
|
| linked<T> | Dense private doubly linked nodes; forward/reverse snapshots | No capacity, holes or Array u32 size bound |
|
|
| set<T> | 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<T> | Dense array; LIFO removal/snapshot order | Initial capacity does not cap collection size |
|
|
| queue<T> | 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](../../../docs/vm-arch/runtime-catalog.properties)
|
|
is `dcf6561ea73446e0a3e1cf1c73eda20923b38df0`. The latest
|
|
[complete qualification record](../DSC-0097-pbs-sdk-stack-queue/evidence/README.md)
|
|
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.
|