← Back to Pull requests

P3.1: carv-rt — `_start`, syscall wrappers, budget-backed user heap, panic → exit, `println!` #158

Closed
unknown closed this pull request without merging on Oct 12, 2026 03:24 UTC
View on GitHub
unknown unknown commented on Oct 12, 2026 01:50 UTC
Author

P3.1 asks for a user-space runtime, carv-rt, with _start, syscall wrappers, a heap that grows from the budget, panic → exit and println! through a console cap. Its acceptance criterion is a hello-world program built separately from the kernel.

#![no_std]
#![no_main]
extern crate alloc;

carv_rt::entry!(main);

fn main() {
    let v: alloc::vec::Vec<u8> = alloc::vec![0; 1 << 20]; // grows the heap via ADDRESS_SPACE_MAP
    carv_rt::println!("hello, world: {}", v.len());
}

  • crates/carv-rt

  • - entry!(main) defines _start. It runs main, then exits by destroying the thread cap in init::THREAD.
    - sys has one wrapper per syscall and per invoke method, returning Result<_, SysError>. Unassigned error codes are kept as raw values.
    - The global allocator is linked_list_allocator over [0x4000_0000, +1 GiB). It starts empty and maps pages on demand with ADDRESS_SPACE_MAP, so each page is charged to the address space's budget. When the budget runs out, alloc returns null.
    - The panic handler prints the message and exits. It is guarded against recursive panics.
    - println! writes to debug_putc. After set_console_cap(slot) it sends WRITE messages to that endpoint instead, batching up to 40 bytes per message. This encoding is defined only in carv-rt and is not part of the frozen ABI, so P3.2/P3.4 can change it.
    - The syscall asm, sys and runtime are compiled only for target_os = "none". Heap growth, message encoding, status decoding and the spin lock are pure and have host unit tests.
  • userland/hello: prints, sums some squares and grows the heap to 1 MiB.

  • userland/init: its hand-rolled syscall code is replaced by carv-rt. Its serial output strings are unchanged.

  • Shared linker script: userland/init/linker.ld moved to crates/carv-rt/linker.ld. Both programs' build.rs point at it.

  • xtask

  • - build now builds every entry in USERLAND_PACKAGES.
    - assemble_iso and build_image_with take a root_task package.
    - There is a new hello smoke scenario that boots hello as boot/init and asserts its output, including the heap growth. That makes 8 scenarios.
  • CI and docs

  • - build.yml gains a clippy step for -p carv-rt -p init -p hello --target x86_64-unknown-none. Host clippy skips that code, so the syscall asm was otherwise unlinted.
    - README, CLAUDE.md, PLAN.md §4/§7/§11 and the CHANGELOG are updated.

    Review notes

  • docs/abi.md and crates/carv-abi are untouched.

  • There is no unmap in the ABI, so freed heap pages stay mapped and are reused.

  • exit() assumes the thread cap is in init::THREAD, which the kernel's create_process sets for every process. Threads started with THREAD_START in a shared CSpace should call exit_thread(slot).

  • The panic → exit path was checked by hand with a temporary panic in hello, but no smoke scenario covers it.
  • task: P3.1

    <!-- START COPILOT CODING AGENT SUFFIX -->

  • Fixes #67
  • Diff: 373 lines (+279 / -94) across 4 files Reviewer: garrickdabbs Review duration: 94m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.43) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 373 lines diff across 4 files
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.354
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #158"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.8% (MEDIUM) · Higher = larger blast radius
    42.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.5% · Safe to merge
    18.5%