Repository navigation
id(world): per-world total memory budget — contract + restore enforcement (#557 slice 1) - #4628
Conversation
…unting seam (task 4827, preserved from prior lane)
…phase 2, task 4827) WorldMemoryBudget ledger in id-core (typed WorldMemoryBudgetRefusal, atomic refusal, release/retry, high-water + refusal counts) and WorldCore::restore charges the fixed core charge plus every materialized journal entry (serialized length + structural allowance) against the last persisted profile budget (or the 64 MiB default) before applying any entry. An over-budget journal refuses open whole; the durable journal is untouched and reopens once the budget allows. Runtime growth, program reservations, session charges, and transient peaks remain the named #557 remainder.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 32 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. CodeRabbit Verify
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2b22aac6a3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let mut limit = crate::world_limits::DEFAULT_WORLD_TOTAL_MEMORY_BYTES; | ||
| for entry in &entries { | ||
| let persisted = match entry { | ||
| JournalEntry::ExecutionProfile { profile } => profile.total_memory_bytes, |
There was a problem hiding this comment.
Enforce the current server ceiling during restore
When the server uses a nondefault --world-total-memory-mib, restore still enforces either 64 MiB or the raw persisted request. world_store::open_world receives the configured RuntimeLimits but calls this method without them; moreover, WorldService::set_execution_profile explicitly persists the unclamped request, contrary to the assumption above this block. Consequently, lowering the server ceiling does not constrain restore, while raising it cannot reopen a budgetless journal exceeding 64 MiB. Pass the current runtime ceiling into restore and resolve the persisted profile against it before charging.
Useful? React with 👍 / 👎.
| if let Some(total) = persisted { | ||
| limit = total; | ||
| } |
There was a problem hiding this comment.
Honor budget resets in subsequent execution profiles
If a journal contains a profile with total_memory_bytes: Some(...) followed by a replacement profile with total_memory_bytes: None, this scan retains the earlier budget. However, replay replaces the entire execution profile, and None means inherit the server ceiling. Clearing a previously low budget can therefore still refuse the next reopen; clearing a high budget leaves the stale allowance enforced instead. Track the final profile, including an unset budget, rather than the last nonempty budget value.
Useful? React with 👍 / 👎.
… restore (#557, task 4827) Codex P1 (PR #4628): open_world now passes its configured RuntimeLimits into the new WorldCore::restore_with_runtime; restore resolves the persisted profile against the current ceiling before charging, instead of trusting the journaled (unclamped) request or the 64MiB default. Codex P2: the restore scan tracks the FINAL profile, including an unset budget — replay replaces the whole profile, so a later total_memory_bytes: None resets an earlier budget to inherit the current ceiling. Also fixes three pre-existing compile errors on this branch: explicit WorldExecutionProfile initializers missing the total_memory_bytes field added in Phase 1 (two sandbox-gated id-core tests, one in commands/world.rs). Tests: cargo test --lib restore_ (17+4 pass, incl. two new regression tests), world_limits (19 pass), world_store (30 pass) on the laptop.
…memory-budget # Conflicts: # pkgs/id/src/world/core.rs
|
Codex findings disposition (task 4827, lane code-k) — Both Codex findings on head |
Summary
Task 4827, slice 1 of #557 (design:
pkgs/id/doc/2026-11-01_design_id557.md, merged in PR #3877). Two phases land together because the branch already carried the Phase 1 WIP:Phase 1 — budget contract (preserved WIP, commit eabb537)
RuntimeLimits.total_memory_bytesserver ceiling (default 64 MiB) + optional lower per-worldWorldExecutionProfile.total_memory_bytes, validated and resolved (lower-only) inworld_limits.rs;--world-total-memory-mibCLI flag.Phase 2 — ledger + restore enforcement (commit 2b22aac)
WorldMemoryBudgetledger in id-core: deterministic logical charges, atomic refusal via the typedWorldMemoryBudgetRefusal(distinct from a guest trap / open-world ceiling / storage failure), release + retry, high-water and refusal counts. Exact-boundary, refusal-atomicity, release/retry, and overflow unit tests.WorldCore::restorecharges the fixed core charge plus every materialized journal entry (serialized length + structural allowance) against the last persisted profile budget (or the 64 MiB default) before applying any entry. An over-budget journal refuses open whole; restore never modifies the durable journal, so the same journal reopens once the budget allows it. Restore refusal/retry + accounting tests inworld/tests.rs.Deliberately out of scope (named #557 remainder)
Tests
CI runs the id suites. New tests: ledger boundary/refusal/release/overflow in
world_limits.rs; restore charging, typed refusal, and retry-after-raise inworld/tests.rs; Phase 1 resolution/CLI/journal-version tests from the WIP commit.Refs #557 (does not close it).
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.