Skip to content

feat(id): F11.7 slice 1 — host metrics core + world stats surfacing (#553) - #1437

Merged
dezren39 merged 5 commits into
mainfrom
queue/1305-553-metrics-core
Oct 27, 2026
Merged

dezren39 merged 5 commits into
mainfrom
queue/1305-553-metrics-core

Conversation

@dezren39

@dezren39 dezren39 commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

F11.7 slice 1 — host metrics core (queue task 1305)

Implements slice 1 of #553 per the triage decomposition (queue task 1261). Slices 2 (Prometheus endpoint) and 3 (tracing spans) are follow-up queue tasks against #553.

  • New WorldMetrics registry (world/metrics.rs): atomic counters + fixed-bucket histograms — actor queue depth (+max), command latency, journal append latency (fsync included), checkpoint duration, frame bytes; session count supplied at snapshot time. No allocation or locking on hot paths.
  • Instrumented at the actor dequeue/handle loop, journal append + checkpoint paths (world_store), and every session send (send_json meters frame bytes).
  • Surfaced two ways: id world stats JSON gains a metrics object, and a capability-authorized metrics session frame (client + server frames added to the shell contract and its exhaustive frame tests).
  • Tests: scripted-session test reads back every metric after a session; durable-world test counts journal appends on a journaled world.

This resume's completion work

The branch had lapsed mid-verification with 18 compile errors: run_session_with's pre-lease sends referenced a nonexistent service, the first-frame match had no Metrics arm, and the shell contract lacked the new frames. Fixed by metering pre-lease/hub sends into a throwaway registry (they belong to no world), routing post-lease sends via lease.service(), routing Metrics first-frames to the query session, adding the contract frames, and rustfmt. Merged current main (one conflict in world_store.rs tests — both new tests kept).

Verification (laptop, per CI-first policy local runs are on the laptop)

  • cargo check --all-targets — pass
  • cargo test --lib -- metrics shell_contract world_session world_store — 85 passed post-merge (170 passed across the wider targeted set pre-merge)
  • Note: cli::tests::test_cli_parse_world_new_and_stats stack-overflows under the default test-thread stack in this environment; cli.rs is untouched by this PR and the test passes with RUST_MIN_STACK=16777216 — pre-existing stack-size sensitivity, not a regression here.

Refs #553


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

Muse Sweep and others added 5 commits October 27, 2026 03:34
… mid-verification, resume from here

Metrics registry (world/metrics.rs, atomics + fixed-bucket histograms)
shared by actor/handle/session; actor records command latency, queue
depth, journal append latency (in persist), checkpoint duration (in
compact_if_due); session layer meters frame bytes in send_json;
Metrics actor command + handle.metrics(); metrics session frame
(pre-join and joined, capability-authorized like info); client
WorldClient::metrics; id world stats gains a metrics object.
Tests: metrics unit test, session scripted-session metrics test,
durable journal-append metrics test.

Verification state at handoff: cargo check --lib showed the Histogram
Default error (fixed after that run) plus two 'service not in scope'
errors in the meter threading to locate; cargo check --tests was still
compiling. Next: cargo check --no-default-features --tests, fix any
remaining meter scope sites, run the three metrics tests, then PR.
…view (queue task 1305 resume)

Both functions take &WorldHandle, not &WorldService, so the WIP's
service.frame_meter() calls there do not resolve. Add a meter:
&WorldMetrics parameter (the send_delegation pattern) and pass
service.frame_meter() at all 9 call sites.
… 1305)

Pre-lease frames in run_session_with referenced a nonexistent service: meter hub-level/pre-lease sends into a throwaway WorldMetrics and post-lease isolation/policy sends via lease.service(). Route first-frame Metrics to query_session, add metrics client+server frames to the shell contract and its exhaustive test list, and rustfmt the branch. cargo check --all-targets passes; 170 targeted tests pass on the laptop.
…s-core

# Conflicts:
#	pkgs/id/src/world_store.rs
@dezren39
dezren39 requested a review from a team as a code owner October 27, 2026 15:38
@coderabbitai

coderabbitai Bot commented Oct 27, 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 2 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: 7e008ad3-1377-422c-a354-55f22bf73fa5
Commits

Reviewing files that changed from the base of the PR and between 95cd41f and 6e0639b.

Files selected for processing: 12
  • pkgs/id/contract/shell-contract.v1.json
  • pkgs/id/src/commands/world.rs
  • pkgs/id/src/shell_contract/tests.rs
  • pkgs/id/src/world/actor.rs
  • pkgs/id/src/world/handle.rs
  • pkgs/id/src/world/metrics.rs
  • pkgs/id/src/world/mod.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

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 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-10-27T15:41:20.362679Z 6e0639b PR opened
ℹ️ 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: 6e0639bade

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

}
// Like `info`, the joined phase may read the world's metrics with
// the session's own capability.
ClientFrame::Metrics { .. } => match world.metrics().await {

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 Reauthorize the joined capability before reporting metrics

If a client joins before its capability expires and keeps the session open on an idle world, this branch continues returning metrics after expiration because world.metrics() does not validate the session token. The joined loop has no expiration timer, so authorization at join time is insufficient. Both the query-phase metrics handler and the adjacent joined-phase Info handler validate through snapshot(token), which checks capability and ancestor expiration. Revalidate the session capability here before returning the metrics snapshot.

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.

1 participant