Skip to content

W-017 spike: operational take-and-detach move lowering + selective detach (#200) - #370

Open
sonson0910 wants to merge 10 commits into
limitlessprojects:mainfrom
sonson0910:spike/w017-operational-take-and-detach
Open

sonson0910 wants to merge 10 commits into
limitlessprojects:mainfrom
sonson0910:spike/w017-operational-take-and-detach

Conversation

@sonson0910

@sonson0910 sonson0910 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add a bounded, dependency-free feasibility spike (spikes/spike12-operational-take-and-detach/) for MOONSHOT.md ledger entry W-017 (Slot 17, Family A, [wildcard] Stop erasing move to a no-op: Operational Take-and-Detach Lowering in hy-emit + Deleting the CGo/Rust Staticlib Bridge #200).
  • Incorporates the MOONSHOT.md triage scope note: drops the CGo/Rust staticlib bridge deletion and preserves the shipped u64 generation-checked HandleTable (runtime/rust + runtime/go/hyrt on arm64 and x86_64), unifying move h on Rust own handles (__hy_take(&h) zeroes the Go uint64 handle variable to 0, InvalidHandle in hyrt) with operational Go-side move (__hy_take + selective __hy_detach_<Shape> + 3-index slice capacity clipping s[:len(s):len(s)]).
  • Includes:
    1. take_detach_model.rs: dependency-free Rust model (184 physical lines / 154 code lines above #[cfg(test)], within the <250 LOC gate) with 12 tests: 3 core mechanism tests, a 30-shape executable matrix (executable_30_case_corpus_and_p0_matrix), and 8 red-team regression tests (R1–R8) covering sentinel HeapId(0) non-collision, mixed-struct double-move prevention, recursive slice capacity clipping inside structs, and own handle linearity (HYB-E3005).
    2. work/take_detach_test.go & work/edge_test.go: Go 1.26 -race verification harness and microbenchmarks (M0..M4), including 6 positive race-free tests across the #38/#105/#120, #75/#137/#206, and #98/#138 P0 report chains plus 5 negative race-detector controls (HY_NEG=TestNeg_...) that deterministically fire WARNING: DATA RACE when each mechanism is omitted.
    3. RESULTS.md: pre-registered predictions & falsifiers, raw 5-run benchmark tables, 30-shape matrix, and honest architectural boundaries.

Evidence

  • Standalone Rust model (12 passed, 0 failed):
    rustc --edition=2021 --test spikes/spike12-operational-take-and-detach/take_detach_model.rs -o /tmp/spike12_model && /tmp/spike12_model
  • Go -race harness (6 passed, 5 skipped negative controls unless HY_NEG=<TestName> is set):
    cd spikes/spike12-operational-take-and-detach/work
    CC=gcc CGO_ENABLED=1 go test -race -v ./...
  • Microbenchmarks (go1.26.4 linux/amd64, 5 runs):
    • M0_NoopMove: 0.3586 ns/op, 0 B/op, 0 allocs/op
    • M1_HyTake_FastPath_Inline: 0.2993 ns/op, 0 B/op, 0 allocs/op
    • M1b_HyTake_FastPath_NoInline: 1.136 ns/op, 0 B/op, 0 allocs/op
    • M2_HyTake_ClippedSlice: 0.7505 ns/op, 0 B/op, 0 allocs/op
    • M3_HyDetach_SharedMap8: 73.55 ns/op, 256 B/op, 2 allocs/op
    • M4_HyTake_RustOwnHandle: 0.2736 ns/op, 0 B/op, 0 allocs/op
  • git diff --check passes cleanly.

Scope and honest limitations

This PR is a research/feasibility spike only (spikes/spike12-operational-take-and-detach/); it does not modify compiler/crates/*. As documented in RESULTS.md:

  1. Intra-procedural may_share is simplified, not eliminated: fast-path selection (__hy_take without __hy_detach) requires knowing no live peer binding, closure capture, or evaluated defer argument still shares backing storage (TestNeg_FastPathMissedAlias, TestNeg_DeferArgEvaluatedBeforeMove, r8). What W-017 eliminates is the need to prove which alias path is dead after joins/rebinds — conservative may_share safely emits __hy_detach_<Shape>.
  2. Static HYB-E3003 remains required: in Go, reads (m["k"], len, range) and append on zeroed (nil) maps/slices succeed silently without panicking (TestNilAndEmptyMoves).
  3. __hy_take(&x) writes the source slot: zeroing x in place introduces a write to x (TestNeg_TakeWritesCapturedSlot), so prior closure variable captures by reference must be treated as live loans (HYB-E3101).
  4. Nested reference shapes require recursive detach synthesis: maps.Clone is shallow (TestNeg_ShallowDetachMapOfSlices), so __hy_detach_<Shape> must recurse per mutable reference level and fail closed (HYB-E3005) on cyclic pointer graphs.

Links

@limitlessprojects

Copy link
Copy Markdown
Owner

Thank you, @sonson0910 — attached to W-017, slot 17 in the 2026-11-01 review window (discussion #365); the MOONSHOT.md ledger row now names this PR. One-line assessment: this is the strongest incoming spike of the window — pre-registered predictions and falsifiers, a 30-shape executable matrix, and negative controls that deterministically fire the race detector when each mechanism is omitted, which is exactly the verification standard the track wants. Honoring the triage scope note (HandleTable preserved, bridge deletion dropped) while still making move operationally real is the right narrowing. M1 verdict lands 2026-11-01 in #365; your pre-answer in the slot thread is already part of the review record.

@sonson0910
sonson0910 force-pushed the spike/w017-operational-take-and-detach branch from 8722369 to 65b9935 Compare October 18, 2026 09:00
@limitlessprojects limitlessprojects added triage:new New arrival (<= 3 days old), awaiting recon triage:wildcard-hold Wildcard Track spike artifact — stays open, never merges (Track 3); window verdicts in MOONSHOT.md labels Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage:new New arrival (<= 3 days old), awaiting recon triage:wildcard-hold Wildcard Track spike artifact — stays open, never merges (Track 3); window verdicts in MOONSHOT.md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants