GeezerVison is showing github.com — id(world): per-world total memory budget — contract + restore enforcement (#557 slice 1) by dezren39 · Pull Request #4628 · developing-today/code
Conversation
dezren39
commented
Nov 2, 2026
•
edited by blacksmith-sh
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
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_bytes server ceiling (default 64 MiB) + optional lower per-world WorldExecutionProfile.total_memory_bytes, validated and resolved (lower-only) in world_limits.rs; --world-total-memory-mib CLI flag.
- Journal version 4 gating: a persisted profile/checkpoint budget bumps the header so older binaries refuse it instead of silently ignoring the budget (Define rollback compatibility for world profile journal entries #227 contract).
Phase 2 — ledger + restore enforcement (commit 2b22aac)
WorldMemoryBudget ledger in id-core: deterministic logical charges, atomic refusal via the typed WorldMemoryBudgetRefusal (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::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; restore never modifies the durable journal, so the same journal reopens once the budget allows it. Restore refusal/retry + accounting tests in world/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 in world/tests.rs; Phase 1 resolution/CLI/journal-version tests from the WIP commit.
Refs #557 (does not close it).
![Autofix with [code]smith](/api/image?u=https%3A%2F%2Fcamo.githubusercontent.com%2F33b6f70f3541c4e93f4503d29cbfec051fa1b040d8e0ae9313a51c4ece44a627%2F68747470733a2f2f70722d636f6d6d656e74732d6173736574732e626c61636b736d6974682e73682f636f6465736d6974682f6175746f6669782d776974682d636f6465736d6974682d6461726b2d33782e706e67)
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
chatgpt-codex-connector[bot] reacted with thumbs up emoji
…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.
coderabbitai
Bot
commented
Nov 2, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Warning
Review limit reached
You'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.
Check out review usage here.
View limit details
-
Limit details: You’ve used the included review currently available.
Learn how review limits work.
Review configuration:
Run configuration
-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: defaults
- Review profile: CHILL
- Plan: Advanced
- Run ID:
7c330094-66d8-4926-8776-1c96a69cdb59
Commits
-
Reviewing files that changed from the base of the PR and between 0400795 and b3ade6a.
Files selected for processing: 7
-
pkgs/id/crates/id-core/src/world_limits.rs
pkgs/id/src/cli.rs
pkgs/id/src/commands/world.rs
pkgs/id/src/world/core.rs
pkgs/id/src/world/mod.rs
pkgs/id/src/world/tests.rs
pkgs/id/src/world_store.rs
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Share
-
CodeRabbit Verify
- Run CodeRabbit Verify to test the changes in this pull request.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Codex Review Summary
This comment shows the latest Codex review activity on this pull request.
| Review |
Status |
Commit |
Review trigger |
| 📝 Code Review |
✅ Completed 2026-11-03T00:03:01.862669Z |
b3ade6a |
New commits |
ℹ️ 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" or "@codex security review".
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 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".
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+230
to
+233
|
|
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 👍 / 👎.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+241
to
+243
|
|
if let Some(total) = persisted {
|
|
|
limit = total;
|
|
|
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 👍 / 👎.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Nov 2, 2026
… 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 2b22aac6a are FIXED in 4b48f9877 (thread replies returned GitHub 422 abuse errors, so disposition is recorded here and in the commit message). P1: open_world passes its configured RuntimeLimits into the new WorldCore::restore_with_runtime; restore resolves the persisted profile against the CURRENT ceiling before charging; regression test restore_resolves_the_persisted_budget_against_the_current_server_ceiling. P2: the restore scan tracks the FINAL profile-bearing entry including an unset (None) budget reset; regression test restore_tracks_the_final_profile_including_a_budget_reset. Also fixed three pre-existing branch compile errors (initializers missing total_memory_bytes). Verified on laptop after merging main (b3ade6a91): restore_ 19+4, world_limits 19, world_store 30 — all pass.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|