Skip to content

Full kernel replacement Phase 2: all 13 modules to decision struct pattern#4

Merged
avrabe merged 2 commits into
mainfrom
worktree-full-kernel-replacement
Mar 20, 2026
Merged

Full kernel replacement Phase 2: all 13 modules to decision struct pattern#4
avrabe merged 2 commits into
mainfrom
worktree-full-kernel-replacement

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented Mar 19, 2026

Summary

Convert ALL 13 wired kernel modules from arithmetic-oracle pattern to Extract→Decide→Apply decision struct pattern. Rust now owns all kernel logic decisions; C shims are minimal ABI adapters.

Modules Converted (12 new + 1 from Phase 1)

Module Decision Structs Difficulty
sem (Phase 1) GaleSemGiveDecision, GaleSemTakeDecision Low
stack GaleStackPushDecision, GaleStackPopDecision Low
fifo/lifo GaleFifoPutDecision, GaleFifoGetDecision Low
mem_slab GaleMemSlabAllocDecision, GaleMemSlabFreeDecision Low
timer GaleTimerExpireDecision, GaleTimerStatusDecision Medium
event GaleEventPostDecision, GaleEventWaitDecision Medium
timeout GaleTimeoutDecision Medium
msgq GaleMsgqPutDecision, GaleMsgqGetDecision Medium
queue GaleQueueAppendDecision, GaleQueueGetDecision Medium
mbox GaleMboxPutDecision, GaleMboxGetDecision Medium
mutex GaleMutexLockDecision, GaleMutexUnlockDecision High
pipe GalePipeWriteDecision, GalePipeReadDecision High

Architecture

Each C shim now follows: Extract state → Call Rust → Apply action

  • Rust returns #[repr(C)] decision struct with action + updated values
  • C applies: wake thread, pend current, update count, reschedule
  • Data movement (memcpy, ring buffer) stays in C
  • Spinlock/tracing/syscall marshaling stays in C

Test plan

  • cargo test — 62 test suites, 0 failures
  • cargo build --manifest-path ffi/Cargo.toml — compiles
  • CI: Rust CI passes
  • CI: All 20 Zephyr test suites pass on qemu_cortex_m3
  • CI: All 3 Renode boards pass (M4F/M33/R5)

See docs/superpowers/specs/2026-03-19-full-kernel-replacement-design.md for full spec.

🤖 Generated with Claude Code

avrabe and others added 2 commits March 19, 2026 22:20
…logic

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@avrabe avrabe merged commit 46f14d6 into main Mar 20, 2026
25 checks passed
@avrabe avrabe changed the title Full kernel replacement: semaphore decision struct PoC Full kernel replacement Phase 2: all 13 modules to decision struct pattern Mar 20, 2026
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