Skip to content

feat(memory): Storage — the one byte owner: sealed kinds, Owner, StorageId, StorageClosedException, Heap on every target (SKEEP-003 P2, S1.1a) - #1062

Merged
michalharakal merged 1 commit into
feature/1017-trace-sink-apifrom
feature/1018-storage-common-heap
Aug 23, 2026
Merged

michalharakal merged 1 commit into
feature/1017-trace-sink-apifrom
feature/1018-storage-common-heap

Conversation

@michalharakal

Copy link
Copy Markdown
Contributor

Summary

SKEEP-003 slice S1.1a (milestone M1 #1002, PRD M1-F1 core): Storage — the one and only owner of bytes (§4.2–4.4, rules 1–2), with the common Heap kind on every target. TensorView (S1.3) interprets a storage; Tensor is the DSL handle over a view — neither owns bytes.

Stacked on #1017 (TraceSink — allocation events); retarget to develop after it merges.

Test plan

Full local gate (scripts/pr-gate.sh, JDK 25); results in the first comment. Targeted: lang-core sk.ainet.lang.memory.* 36/36.

Closes #1018

🤖 Generated with Claude Code

…ageId, StorageClosedException, Heap on every target (SKEEP-003 P2)

Milestone M1 (#1002), PRD M1-F1 (core). SKEEP-003 §4.2–4.4, rules 1–2:
exactly one byte owner; ownership is a constructor argument and then
enforced.

- sk.ainet.lang.memory.Storage (sealed, AutoCloseable): id, sizeBytes,
  owner, domain, scope (from the owner), debugOrigin TensorId, isAlive,
  isMutable, checkAlive() → StorageClosedException(id, origin), close()
  (idempotent; owned = freed once, borrowed = forgotten, alias =
  detached; emits TraceEvent.Free), slice() → Owner.Alias view that
  keeps the parent alive, delegates mutability and dies with it.
  Kinds: Heap (final, common), OffHeap / Mapped / Device (abstract,
  bound per platform in #1019/#1020; Device is a placeholder).
- Storage.Heap: one Kotlin array (floats | ints | bytes) + arrayOffset +
  sizeBytes; floats()/ints()/bytes() allocate owned storage for a scope
  kind and emit TraceEvent.Allocation; wrap(array, …) borrows without
  copying (the #782 copyOf replacement) and is never freed by us.
  Kernels unwrap once per call (floats/ints/bytes + arrayOffset), per
  the Phase-2 spike (#1016).
- Owner (sealed): Owned(scope) | Borrowed(external) | Alias(parent).
  StorageId: monotonic per-process value class (kotlin.concurrent.atomics).
  MemoryDomain gains HOST_OFFHEAP (additive).
- StorageTest: owned lifecycle + trace events, ids, borrowed release
  without touching the lender's bytes, alias lifetime/mutability/
  nesting, slice bounds/alignment, rendering. BCV: lang-core jvm dump
  regenerated (additions only).

Closes #1018

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@michalharakal

Copy link
Copy Markdown
Contributor Author

Local gate scripts/pr-gate.sh (JDK 25) on 5b9b0e4 (stacked on #1061):

=== pr-gate: JVM tests ===                                      BUILD SUCCESSFUL in 4m 47s
=== pr-gate: apiCheck ===                                       BUILD SUCCESSFUL in 1m 15s
=== pr-gate: verifyNpmPins jsTest wasmJsTest wasmWasiTest ===   BUILD SUCCESSFUL
=== pr-gate: linuxX64Test ===                                   BUILD SUCCESSFUL in 2m 1s
=== pr-gate: assemble ===                                       BUILD SUCCESSFUL
=== pr-gate: :skainet-test:skainet-test-java:test ===           BUILD SUCCESSFUL
pr-gate: all legs passed.

Targeted: lang-core sk.ainet.lang.memory.* 36/36.

@michalharakal
michalharakal requested a review from aharakal August 23, 2026 12:08
@michalharakal
michalharakal merged commit 7757302 into feature/1017-trace-sink-api Aug 23, 2026
3 checks passed
@michalharakal
michalharakal deleted the feature/1018-storage-common-heap branch August 23, 2026 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant