← Back to Pull requests

P2.6: scheduler on carv-budget; carv-caps reclaims derivation nodes; P2.9 ELF tests #150

Closed
unknown closed this pull request without merging on Oct 06, 2026 05:18 UTC
View on GitHub
unknown unknown commented on Oct 06, 2026 04:20 UTC
Author

A Phase 2 audit compared PLAN.md, CHANGELOG.md and the issue tracker. They mostly agree; the one stale item was the #59 issue body, which still said "complete" after the task was reopened. That body has been corrected outside this PR. This PR handles the next three open items: unbounded node growth in carv-caps, the scheduler's duplicated refill math, and the ELF loader having no tests.

carv-caps: bounded derivation tree


  • Every derivation node now belongs to exactly one occupied slot, so node_count() <= capacity() always holds. Node storage is reserved up front in CSpace::new.

  • delete removes the node from the tree and re-parents its children to the deleted node's parent. Revoking an ancestor still reaches descendants whose intermediate capability was deleted. The tree no longer keeps dead nodes as tombstones; that approach would have let a copy/delete chain grow without bound.

  • revoke frees the whole subtree and clears slots through a node-to-slot link. Cost is O(descendants); before, it was O(slots × descendants).

  • Freed nodes go on a free list and are reused.

  • New tests:

  • - 10 000 copy/delete cycles, and a chain of 10 000 deleted links: the node count stays bounded and revocation still works.
    - A proptest that interleaves copies and deletes, then checks revoke against a nearest-live-ancestor model.

    Scheduler (P2.6): CPU accounting via carv_budget::Budget


  • kernel now depends on carv-budget. Thread holds a Budget instead of its own copy of the refill/charge math.

  • API change: Thread::new(..) now returns Result<Self, BudgetError>.

  • Thread::with_budget is added so a thread can run on a budget carved out of a parent's.

  • Overrun keeps the previous behaviour: if charge_cpu fails, the rest of the period's allowance is drained.

  • New in-kernel test: threads with 20% and 50% budgets are throttled once both are spent and refill on the 10 ms boundary.
  • ELF loader (P2.9): in-kernel tests


    These are #[test_case] tests next to the code in kernel/src/elf.rs, built on a small image builder and a recording SegmentMapper. They cover:
  • accepting a valid image and skipping non-PT_LOAD headers;

  • rejecting truncated, wrong-class and wrong-machine headers, a bad program-header table, W+X, overrun, address wrap, misaligned or overlapping segments, an entry point outside an executable segment, and more segments than MAX_SEGMENTS;

  • map_into mapping page-rounded ranges, copying the exact file bytes, and returning MappingFailed when the mapper fails.
  • Docs


  • CHANGELOG: entries under Unreleased.

  • PLAN §8: P2.2, P2.6 and P2.9 rows updated.

  • PLAN §11: #142 marked fixed. #141 stays open; it needs an ADR for cross-CSpace derivation.
  • task: P2.6

    Diff: 343 lines (+257 / -86) across 4 files Reviewer: garrickdabbs Review duration: 58m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.42) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 343 lines diff across 4 files
    0.42
    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.349
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #150"
    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.3% (MEDIUM) · Higher = larger blast radius
    42.3%
    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.3% · Safe to merge
    18.3%