Skip to content

fix(id): export host events through authorized journal history - #3998

Merged
dezren39 merged 8 commits into
mainfrom
fix/id-242
Nov 3, 2026
Merged

dezren39 merged 8 commits into
mainfrom
fix/id-242

Conversation

@dezren39

@dezren39 dezren39 commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Fixes #242.

Summary

id world record --admin-token
  -> admin-authorized journal history
  -> ordered fixture with host System events interleaved with inputs
  • Adds an admin-only history protocol. Host System events remain excluded from participant streams, snapshots, and events_after; capability results stay host/admin-only.
  • Persists bounded ordered host history and open-presence state in checkpoint version 4. Older/incomplete checkpoints remain partial and get bounded host-only cleanup leaves; oversized checkpoints are deferred rather than made unrestorable.
  • Adds strict journal validation, aggregate response-frame limits, routed admin authorization before world lookup, and fixture replay coverage including territory.
  • Records the decision and design in the issue and doc/2026-11-01T17-30-12Z_design_host_event_export/.

Evidence

  • Before: host events were journaled but not in the participant retained deque; events_after could not return them and fixtures missed them.
  • After: cargo test --lib -- --test-threads=4 — id: 1,516 passed, 0 failed, 5 ignored; id_core: 238 passed, 0 failed, 1 ignored. This includes authorization, non-disclosure, partial checkpoint recording, and territory replay tests.
  • Changed Rust files pass rustfmt --check; git diff --check is clean.
  • Broader checks were not fully clean in this environment: just ci stopped on formatting differences in unrelated base files; all-features cargo check hit missing generated web/dist and a russh signature mismatch; Clippy hit incompatible cached Rust artifacts.

Merge Danger

Door: Two-way — the change is revertible, but the journal format bump requires version-aware readers.

Blast Radius: Medium — admin recording, fixture replay, and checkpoint persistence change; participant delivery semantics do not.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 1, 2026 21:28
@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

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 5 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: 33c0248d-cbdb-4cbd-a35b-cb4094c8ebaa
Commits

Reviewing files that changed from the base of the PR and between 4a29ec8 and 6bc2e82.

Files selected for processing: 18
  • doc/2026-11-01T17-30-12Z_design_host_event_export/2026-11-01T17-30-12Z_design_host_event_export.md
  • pkgs/id/contract/shell-contract.v1.json
  • pkgs/id/crates/id-core/src/world_caps.rs
  • pkgs/id/src/cli.rs
  • pkgs/id/src/commands/world.rs
  • pkgs/id/src/shell_contract/tests.rs
  • pkgs/id/src/store_traits.rs
  • pkgs/id/src/world/actor.rs
  • pkgs/id/src/world/core.rs
  • pkgs/id/src/world/handle.rs
  • pkgs/id/src/world/mod.rs
  • pkgs/id/src/world/tests.rs
  • pkgs/id/src/world_fixture.rs
  • pkgs/id/src/world_net.rs
  • pkgs/id/src/world_session/mod.rs
  • pkgs/id/src/world_session/tests.rs
  • pkgs/id/src/world_session/types.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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

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-03T02:52:36.444242Z 6bc2e82 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

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: 47937fe3e7

ℹ️ 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".

Comment thread pkgs/id/src/world/core.rs
Comment on lines +1328 to +1329
while self.admin_history.len() > self.limits.retained_events.min(MAX_ADMIN_HISTORY_EVENTS)
|| admin_history_bytes(&self.admin_history) > MAX_ADMIN_HISTORY_BYTES

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Track retained history bytes incrementally

With a substantial retained history, every accepted input, chat message, or host event calls admin_history_bytes, which allocates and JSON-serializes every retained event again. With the default 1,024-event retention and valid 16 KiB inputs, this can re-encode tens of megabytes for each new event, even when no export is requested. This synchronous work runs inside the single world actor, delaying subsequent inputs, ticks, and view requests; byte-limit trimming can repeat the full scan for each removed event. Cache encoded event sizes and maintain a running byte total as events enter and leave the deque.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disposition (queue task 6505, rebase/land of PR #3998): tracked as its own follow-up in #4633 — admin_history_bytes re-serializes the retained admin history per accepted event; track retained bytes incrementally. Not fixed in this PR: this task is the rebase/land of the recorded #242 decision, and the retained history is bounded (retained_events cap + MAX_ADMIN_HISTORY_BYTES byte cap checked on the same path), so the cost is bounded per event; the incremental-byte-tracking optimization is scoped and accepted on #4633.

@dezren39

dezren39 commented Nov 2, 2026

Copy link
Copy Markdown
Member Author

Cross-link: the Codex P2 on admin_history_bytes (review comment r4437438581) is now tracked as issue #4633 — admin_history_bytes re-serializes the entire retained admin history on every accepted event; the issue carries the verified evidence on this PR's head (47937fe3) and acceptance criteria for tracking retained bytes incrementally. Filed by the new-issue-creator lane after pr-comment-review validated the finding but hit its per-repo filing cap.

# Conflicts:
#	pkgs/id/src/cli.rs
#	pkgs/id/src/world/actor.rs
#	pkgs/id/src/world/core.rs
#	pkgs/id/src/world/handle.rs
#	pkgs/id/src/world/mod.rs
#	pkgs/id/src/world/tests.rs
# Conflicts:
#	pkgs/id/src/world/core.rs
@dezren39
dezren39 merged commit 07b7d70 into main Nov 3, 2026
1 check passed
@dezren39
dezren39 deleted the fix/id-242 branch November 3, 2026 02:48

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

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: 6bc2e8244e

ℹ️ 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".

Comment thread pkgs/id/src/world/core.rs
Comment on lines +1725 to +1727
ensure!(
events.len() <= self.limits.retained_events.min(MAX_ADMIN_HISTORY_EVENTS),
"checkpoint admin history exceeds its event bound"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Trim restored admin history to the current retention limit

For library callers reopening a compacted world with a lower WorldLimits::retained_events, this check rejects an otherwise valid journal whenever its persisted admin history exceeds the new limit. Previously, lowering retention worked because restore trims checkpoint participant events to the supplied limit; the new admin-history field now makes WorldCore::restore and open_world fail instead. Validate the persisted history against the stable format bound, then trim it to the current retention limit and mark it incomplete if events are removed.

Useful? React with 👍 / 👎.

Comment thread pkgs/id/src/world/core.rs
Comment on lines +1000 to +1003
admin_history: Some(JournalAdminHistory {
events: self.admin_history.iter().cloned().collect(),
complete: self.admin_history_complete,
}),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep retained history checkpoint entries replicable

For a snapshot-capable world with small program state and few participant events, retaining 1,000 sub-kilobyte host capability results can now create a single checkpoint entry larger than 256 KiB. Previously those host events were separate journal entries and the checkpoint could remain small. After compaction publishes a replication reset, world_replication_net.rs::send_snapshot calls split_entry_payload, which rejects any individual entry above MAX_REPLICATION_PAYLOAD_BYTES (world/replication.rs:179–180). Existing replication streams consequently fail, and reconnecting cannot transfer the same compacted checkpoint. Keep the checkpoint within the replication entry bound, defer compaction when it exceeds that bound, or store retained history in separately replicable entries.

Useful? React with 👍 / 👎.

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.

Host-originated events are not retained in the event stream

1 participant