Checked Block creation — plan

PLAN approved with binding conditions in /tmp/unimem-block-creation-plan-review.txt. Implementation follows those conditions; fresh CODE review remains required. Base: 9593c7218e14e2b5b816d9008b45ab60b9580cf3, branch fix/unimem-block-creation. Serves kadek foundation row 6 / row 3 admission and unimem's canonical Block creation/error contract. Research pins source, SDK and evidence.

Contract and focused compatibility changes

Keep one raw row: width=requested bytes, height=1, bytes-per-element=1, pixel-format=0. Align row stride using the native BytesPerRow requirement, then align its total extent using AllocSize's requirement. This preserves shape and existing ≥requested-size callers, but intentionally changes small unaligned requests' returned size. SDK IOSurfaceRef.h:373–382 justifies amending the current row=size spec. Preserve Block::open, address/size/id/handle and slice signatures.

Public concrete API, no generic allocator/ownership layer:

Block::plan(requested: usize) -> Result<BlockPlan, MemError>
Block::open(requested: usize) -> Result<Block, MemError> // plan()?.open()
// BlockPlan has private fields; no Default or unchecked constructor.
BlockPlan::requested_size(&self) -> usize
BlockPlan::row_bytes(&self) -> usize
BlockPlan::allocation_size(&self) -> usize
BlockPlan::open(&self) -> Result<Block, MemError>

BlockPlan is an immutable Copy/Clone/Debug value holding the exact checked request, stride and allocation extent. Planning creates no CF object or surface; it queries native alignment. Open uses stored properties without recomputing or rounding them. The reusable plan carries numbers only and grants no reservation. A caller can reserve allocation_size plus its own owner/metadata before open; this unit implements no reservation ledger. Plan conveys neither initialized contents nor immutable publication. Keep native initialization assumptions out of its contract; a future writer initializes visible output.

Correct public raw FFI CFIndex/CFNumberType to isize and IOSurfaceCreate's input to CFDictionaryRef; add immutable dictionary/property functions and borrowed keys. Retain otherwise unchanged public raw declarations. Remove private cf_str/cf_i64 helpers when unused. These type corrections and new MemError variants break some source uses; record actual semver diagnostics against v0.2.0 and origin, rather than requiring a fabricated clean comparison. On the supported Apple LP64 target, isize and i64 have the same ABI; these are SDK declaration repairs, with no observed prior runtime miscompile asserted.

Algorithm and exact failure order

  1. Amend existing spec Block properties/API/error paragraphs first → verify: SDK alignment rationale, retained raw shape, ≥requested extent, precise returned-failure scope; keep observed numbers in audit, not specs.
  2. Validate request before native object creation → verify: zero → ZeroSize; request, row and final extent must fit usize, i64/CFNumber storage and isize::MAX slice length. Conversion/checked-add failure → SizeOverflow. Query row and allocation alignment; zero → BlockAlignmentInvalid. Use remainder-based checked round-up (no power-of-two assumption), then cross-check IOSurfaceAlignProperty for both already-representable values; disagreement → BlockAlignmentInvalid. Never pass an overflowing value to C.
  3. Construct six number values with correct-width FFI and private RAII CF owners; borrow the six SDK key pointer constants. Take callback structure addresses with addr_of!, without forming references to their opaque declarations. Build immutable CFDictionaryCreate from fixed stack arrays and kCFType callbacks → verify: each returned null yields BlockPropertiesFailed and releases all previously owned numbers. Dictionary retains entries, then local references release exactly once. No CString, Vec, Box, mutable dictionary insertion or library unwrap/expect.
  4. IOSurfaceCreate null → existing BlockCreateFailed. Retain an owning surface guard; GetAllocSize must equal the planned extent, otherwise BlockExtentMismatch { expected, actual }, release without locking. Lock failure → existing BlockLockFailed(code), release without unlock. After lock, require nonnull base, alignment for existing u16/f32 slices and checked address+extent without wrap; failure → BlockAddressInvalid. Success transfers the locked owner to Block → verify: every successful lock is followed by exactly one unlock before exactly one final release, including post-lock errors; no allocation is published on failure.
  5. Preserve accessors, Tape/Grid/Layout behavior and owned surface drop → verify: existing roundtrip oracles, first/last requested bytes and actual-extent lengths. Changing public aliasing and safe GPU-import APIs stays separate.

New unit error variants are exactly SizeOverflow, BlockAlignmentInvalid, BlockPropertiesFailed, BlockExtentMismatch { expected: usize, actual: usize }, BlockAddressInvalid; existing ZeroSize/BlockCreateFailed/BlockLockFailed remain. Display uses fixed phrases plus numeric context, with no heap-owned error data. Planning and creation errors carry no generic OOM recovery promise: validate returned-null/native error channels; opaque CF/kernel abort behavior is outside the API's control. Existing “allocation failure always returns” wording narrows accordingly. Allocation size means API-visible backing; CF/kernel bookkeeping and residency are not counted as that extent. Equality check defends the stated platform extent contract; it is not an allocate-first admission strategy.

Files and decisive tests

Production: unimem/src/{block,ffi,lib}.rs; optional private unimem/src/block/{creation,tests}.rs to keep each source ≤500 lines. Specs: focused edits only in unimem/specs/{README,api-sketch}.md. Tests: new unimem/tests/block_creation.rs; retain tests/roundtrip.rs oracles. Task docs and later exact receipts under audit/; no manifests/dependency versions, sibling source, hardware import, public mutable-view or platform edits.

  • Pure planning cases: zero, isize/usize boundaries, exact multiples, one above, unusual non-power-of-two alignment, zero alignment, arithmetic overflow; independent quotient/remainder expectations and native cross-checks.
  • Compile-negative examples separately show private plan fields and no unchecked constructor; positive path reserves a test counter before the plan is opened.
  • Native boundaries around queried row alignment and page size, plus existing 4096-byte/large roundtrip tests: planned == actual, width preserved, stride aligned, address typed-aligned, write/read initialized first/last bytes. Query surface width/row through test-only SDK declarations; no new public introspection API merely for tests and no reading unknown initial contents.
  • A private cfg(test), thread-local fault/trace seam around the concrete native calls retains real CF/surface objects. Fail each number creation, dictionary, surface creation, lock, extent query, null/misaligned/wrapping base result. Observe owned Create/Release and lock/unlock events; exact balance/order and no subsequent forbidden call. CF numbers may be cached: count ownership acquisitions, not unique pointers. Never pass synthetic handles to CF.
  • Production tests use the actual native path. Fault injection does not model every CF internal allocation, prove kernel memory reclamation, or serve as a native framework Miri test. Fresh source review checks callback retain rules.

Verification isolation and gates

After approval, archive base and v0.2.0 into fresh temporary roots; overlay only the named owned changed sources for the local candidate, record their hashes. Build standalone unimem copies with their exact src/tests, one explicit isolated workspace manifest: package unimem 0.2.0/edition2021; only runtime dependencies crossbeam-queue =0.3.12, mutants =0.0.3; no examples/benches or unrelated dev dependencies. Seed upstream lock's reachable runtime subgraph including crossbeam-utils 0.8.21; save the adapted manifest/lock and verify checksums against upstream Cargo.lock. This is a documented gate harness, not a production manifest change or compatibility shim. All subsequent commands use --locked and a private target. Never resolve sibling paths from the dirty originals.

Isolated commands: cargo fmt --check; cargo clippy --all-targets --locked -- -D warnings; cargo test --locked; cargo test --release --locked; cargo doc --no-deps --locked with RUSTDOCFLAGS=-Dwarnings; cargo semver-checks check-release --manifest-path <candidate>/Cargo.toml --baseline-root <baseline> against both v0.2.0 and origin. Record intentional enum/FFI source breaks, unexpected findings and actual exits separately. Run git diff --check in the owned checkout and review source/spec byte deltas.

Required actual upstream gates, from an isolated exact-origin sibling closure: root cargo fmt --all -- --check, cargo clippy --workspace -- -W warnings, cargo build --release --workspace, cargo test --workspace; unimem cargo build, cargo test, cargo bench, cargo run --example pipeline --release. Enforce zero warnings and record toolchain/host/commands/exits. Honeycrisp's cyb-nebu versus strata-origin strata-nebu mismatch is an existing source prerequisite for those gates. Do not claim isolated tests close it or silently rename/patch dependencies. Ring ≥1: public unimem APIs reach acpu/rane/aruminium and downstream mir; dependent gates need their own exact origin closures. This plan can be reviewed/implemented independently, but full merge readiness remains conditional on those required gates and dependency fix.

Five failure questions

  1. Can large input truncate or become an oversized Rust slice? Reject before Create; independently check rounding overflow, final isize limit and pointer range, including unexpected actual extent. Never attempt enormous native allocs.
  2. Can reservation use a different extent from creation? One private checked plan stores the actual properties; create never silently adjusts them. Preserve native extent premise and reject returned mismatch before exposing Block.
  3. Can a returned failure leak or double-release a CF/native owner? RAII owns every Create result immediately; test each stage and locked/unlocked cleanup.
  4. Does aligning the row secretly change consumer semantics? Preserve logical width/one-row format, explicitly document padding, verify ≥requested callers and actual-size hardware bindings; do not promise old byte-equal small sizes.
  5. Could green local tests overstate safety or release readiness? Label the isolated manifest, unresolved dependency gate, CF failure scope and unmodified aliasing/import/init/platform gaps. Fresh PLAN then CODE review precedes merge; no Kadek row closure, decoder admission or fully fallible allocator claim.

Homonyms

plan
plan the schedule: standing orders and deferred intents. the seed exists — the mining standing order in cy/specs/body|body is the first plan entry; it generalizes into the robot acting at 3am so you don't have to. cyb/parts/time|time reads the plan forward as the future half of its screen. part of…
warriors/erga/plan
erga — ERGO (Autolykos v2) miner for Apple Silicon Zero-copy Autolykos v2 miner on Rust using the honeycrisp hardware driver stack. ERGO uses Autolykos v2: a memory-hard k-sum PoW where each nonce attempt requires 32 random reads from a 2+ GB precomputed table R, summed, and Blake2b256-hashed…
cy/specs/plan
neural/rune/PLAN
rune implementation plan rune = open-computation language for the cyber soft3 stack. Full spec: `~/cyber/cyber/root/rune.md`. architecture Two registers, one AST, one Nox target: `rust` — classic, Rust-familiar surface `rune` — pure, Hoon-style sigil surface Three proof tiers: pure: unconditional…
soft3/mir/docs/plan
Graph World — Rendering Implementation Plan Protocol spec: `cybergraph/reference/render.md` (R-1.0) Implementation spec: `cyb/render/specs/render.md` (R-1.0-cyb) Architectural decisions Barnes-Hut vs BVH The deeper question is not "which algorithm for rendering cull" but "does this manifold need…
neural/inf/rs/plan
plan
soft3/radio/audit/2026-10-11-bao-bounded-traversal/plan
Checked traversal PLAN evidence Research and proposed tests only, on actual Radio parent `a96d86e28d384cdf656aadc4282c78c0c170c102` (PR38). Production is unchanged. The [PLAN](/soft3/radio/.claude/tasks/bao-bounded-traversal/plan) specifies one admitted byte range, one emitted geometric item per…
soft3/nox/.claude/tasks/hemera-no-std/plan
Preserve nox's no_std dependency boundary Stage: revised PLAN v2, awaiting fresh different-vendor review. Parent: `0b1407a4b855e4961ede07e1b7ea199cb8018c30`. Lineage and measured failures are in [research.md](/soft3/nox/.claude/tasks/hemera-no-std/research); exact feature/ring analysis is in…
soft3/radio/.claude/tasks/bao-bounded-reducer/plan
Bounded BAO group reducer — proposed PLAN Serves: owner's Kadek phase-1 closure · Radio/soft3 · foundation row 4, bounded authenticated-range prerequisite. Source research is pinned in research-inputs.json at Radio `a11d342594949d4ea542b26366f71d56ef21662d` and Hemera…
soft3/radio/.claude/tasks/bao-bounded-traversal/plan
Bounded BAO range traversal Stage: draft; independent PLAN review pending, no production changed. Serves the owner's Kadek phase-1 closure, Radio/soft3 and foundation row 4 (bounded authenticated source ranges). Discovered from the [measured traversal…
soft3/radio/.claude/tasks/audit-cargo-packaging/plan
Lossless archival Cargo manifests Status: draft; fresh different-vendor PLAN approval required before edits to existing artifacts. Serves Kadek foundation row 4 through Radio; discovered from PR40's committed Git consumer. Parent: `ce0fb312faa8770e80efe9afa864106ae6b51552`. Result Rename exactly…
warriors/erga/.claude/tasks/blake-batch-owner/plan
Close the Blake benchmark batch owner Stage draft; awaits root and fresh different-vendor PLAN approval. No production changes. Base Erga848e17e2522db2f6225ad72d9b1797f8735d26d0; Honeycrisp9cbd4807, Strata494df7, exact full pins/source evidence in research.md. Serves Kadek native Image ownership…
cyb/honeycrisp/.claude/tasks/unimem-block-access/plan
Raw Block access — PLAN v3 candidate Serves Kadek foundation row6/native ownership prerequisite; upstream unimem CPU access and aruminium import contracts. Base `7b148906263da5ea8aabc5ddb0e2e44ff2288ecc`; [research](/cyb/honeycrisp/.claude/tasks/unimem-block-access/research) records parent and…
soft3/radio/.claude/tasks/bao-hemera-pin/plan
Pin the shared Hemera dependency Serves: owner's Kadek phase-1 closure · Radio/soft3 · consumable dependency prerequisite for bounded BAO verification, foundation row 4. Stage: draft. Source parent Radio a11d342594949d4ea542b26366f71d56ef21662d; Hemera source…
soft3/radio/.claude/tasks/bao-bounded-proof/plan
Bounded complete-buffer BAO proof verification Proposed PLAN; no production implementation or approval. Serves Kadek foundation row 4 through Radio, declared part of soft3; the future Kadek adapter reaches Cyb. Radio implementation parent is b933829cbe273d2f31fe75ca83125f3ddd8917a2 (PR39); research…
warriors/erga/.claude/tasks/mine-owner/plan
Mine owner plan Stage draft; implementation waits for fresh different-vendor PLAN approval. Serves Kadek foundation row6; discovered-from Honeycrisp PR14 and Erga PR2. Base `8dcb33888868d74ddfda3eeeb9bc90e58677b394`, Honeycrisp `9cbd4807`, Strata `494df7a`; full pins/evidence in research. No…
warriors/erga/.claude/tasks/rtable-owner/plan
RTable owner plan Stage draft; implementation waits for fresh different-vendor PLAN approval. Serves Kadek foundation row 6; discovered-from Honeycrisp PR14 and Erga PR1. Base `14b40d667b7fa927f62f46423cd8096f01cf704f`, Honeycrisp `9cbd4807`, Strata `494df7a`; full revisions/evidence are in…
soft3/radio/audit/2026-10-12-bao-proof-research/prerequisite/plan
Bounded BAO range traversal Stage: draft; independent PLAN review pending, no production changed. Serves the owner's Kadek phase-1 closure, Radio/soft3 and foundation row 4 (bounded authenticated source ranges). Discovered from the [measured traversal…
soft3/radio/audit/2026-10-12-bao-proof-research/task/plan
Bounded complete-buffer BAO proof verification Proposed PLAN; no production implementation or approval. Serves Kadek foundation row 4 through Radio, declared part of soft3; the future Kadek adapter reaches Cyb. Radio implementation parent is b933829cbe273d2f31fe75ca83125f3ddd8917a2 (PR39); research…
soft3/radio/.claude/tasks/kadek-export-pairs/plan
Correct actual BAO exporter pair width Status: source-only plan awaiting fresh different-vendor approval; no code/tests edited or builds run. Base origin/main `764d732ac38fb9116c4cf525a6d1bb463d409a06`. Owned branch/worktree: `fix/kadek-export-pairs` /…
soft3/radio/.claude/tasks/bao-root-policy/plan
Canonical BAO ROOT finalization Status: draft v3, awaiting correction PLAN review; no implementation. Serves: Kadek phase-1 foundation row 4 and runtime proof-before-admission clause; radio's Hemera BAO dependency, pinned tree ROOT finalization contract. Base: radio…
soft3/radio/.claude/tasks/kadek-slice-traversal/plan
Correct sync slice traversal Status: implementation source frozen for fresh code review. Scoped tests pass; unrelated Clippy/full-workspace/tooling failures remain visible in research. Base: radio `db1d62e2cd1e4b2f309fa19bcc158bd29b44753d`, freshly fetched origin/main. Owned worktree:…
soft3/radio/.claude/tasks/kadek-memstore-pairs/plan
Canonical in-memory BAO parent pairs Status: proposed PLAN v2; fresh different-vendor approval required before source edits. Serves: Kadek phase-1 row4, existing radio verified-range import/storage dependency. Base radio `0d11468503c052aa5dcefb0dabc4602bd8efdc60`, exact Hemera…
cyb/honeycrisp/.claude/tasks/nebu-package-identity/plan
nebu package identity — plan One manifest identity repair restores origin-source Cargo resolution for the unimem gate prerequisite. Root owns implementation/review/commit/PR; this unit does not overlap the Block constructor's source/spec files. 1. Record `rustc -Vv`, `cargo -V`, host and target:…
soft3/radio/.claude/tasks/bao-empty-status/plan
Fs synthetic empty status — PLAN amendment Stage: active. Fresh Grok4.7 PLAN APPROVE preceded production edits; the exact reviewed draft and raw verdict remain frozen in the audit. Fresh CODE APPROVE and root disposition are retained in audit/2026-10-11-empty-status/. Serves Kadek phase 1…

Graph