diff --git a/doc/2026-11-02T00-53-51Z_feature_world_host_view/2026-11-02T00-53-51Z_feature_world_host_view.md b/doc/2026-11-02T00-53-51Z_feature_world_host_view/2026-11-02T00-53-51Z_feature_world_host_view.md
new file mode 100644
index 0000000000..04b69763f4
--- /dev/null
+++ b/doc/2026-11-02T00-53-51Z_feature_world_host_view/2026-11-02T00-53-51Z_feature_world_host_view.md
@@ -0,0 +1,21 @@
+# Authenticated, read-only world host view
+
+## Request
+
+Issue [#3378](https://github.com/developing-today/code/issues/3378) asks for an explicitly authenticated host to inspect the current authoritative world view and records without joining as a guest or creating, minting, or consuming a guest capability. The existing guest-capability flow must remain unchanged. The existing Wasm/Roc installation controls should be distinct and discoverable from the empty-program state.
+
+## Initial design
+
+- Use the existing world-admin secret, sent only in the `x-world-admin-token` HTTP header, to authorize a web-only read endpoint. Do not put credentials in a URL or add a new shell-protocol frame: `shell-contract.v1.json` explicitly defers new frame kinds.
+- Add an actor-serialized admin view/snapshot operation. The program's existing `view(Participant)` interface needs a view context, so use a reserved host viewer (`id = 0`, display name `Host`) only for rendering; do not register it, include it in the participant list, emit presence, or allow it to send events.
+- Return a bounded page of records and a continuation key. The browser fetches pages using the same admin header, renders the host view as read-only, and can refresh it explicitly.
+- Keep the guest socket/join and its capability authorization intact. Host mode closes any guest session and disables chat/input/paste/keyboard sends.
+- Move installation controls into a separate “Install or update program” host section. Use `active_module_hash` to show an actionable empty-program state.
+
+## Trade-offs and checks
+
+The web-only endpoint avoids changing the shared QUIC/WebSocket shell contract. The admin secret is already used by the web host tools and is the authority boundary for this operation. The reserved viewer is never a guest or participant; this preserves the roster/presence invariant while reusing the current program presentation interface. Verify authorization denial, no host participant/presence, unchanged guest join, bounded record pagination, and disabled host input.
+
+## Change log
+
+- 2026-11-02: Initial design before implementation for queue task 5190.
diff --git a/pkgs/id/src/web/templates.rs b/pkgs/id/src/web/templates.rs
index 37b047bfa1..e29b11b114 100644
--- a/pkgs/id/src/web/templates.rs
+++ b/pkgs/id/src/web/templates.rs
@@ -798,29 +798,33 @@ pub fn render_world_page(assets: &AssetUrls) -> String {
+
This bearer capability grants guest access. Share it privately.
-
- Host: create a guest invite
-
+
+
Host controls
+
-
+
-
+
+
+
Install or update program
+
-
+
Choose main.roc and up to 7 additional .roc files. Each file is limited to 128 KiB and all sources together to 256 KiB. Compilation runs on the host (up to 120 seconds).
Uploads run in the host's import-free Wasmtime sandbox. The current world restarts at its module seed.
-
+
@@ -1076,6 +1080,8 @@ mod tests {
assert!(html.contains("data-world-app"));
assert!(html.contains("data-world-invite"));
assert!(html.contains("data-world-join"));
+ assert!(html.contains("data-world-host-view"));
+ assert!(html.contains("Install or update program"));
assert!(html.contains("data-world-world"));
assert!(html.contains("data-world-chat-form"));
assert!(html.contains("data-world-input-form"));
diff --git a/pkgs/id/src/web/world_ws.rs b/pkgs/id/src/web/world_ws.rs
index 70ebb3d4f5..643e2acede 100644
--- a/pkgs/id/src/web/world_ws.rs
+++ b/pkgs/id/src/web/world_ws.rs
@@ -17,7 +17,7 @@ use futures::{
SinkExt, StreamExt,
stream::{SplitSink, SplitStream},
};
-use serde::Deserialize;
+use serde::{Deserialize, Serialize};
use crate::directory::Refusal;
use crate::directory_auth::{Caller, Signed};
@@ -50,6 +50,10 @@ pub fn world_routes() -> axum::Router {
axum::Router::new()
.route("/ws/world", axum::routing::get(handler))
.route("/api/world/invite", axum::routing::post(invite_handler))
+ .route(
+ "/api/world/host-view",
+ axum::routing::get(host_view_handler),
+ )
.route("/api/world/metrics", axum::routing::get(metrics_handler))
.merge(super::explore::explore_routes())
.route(
@@ -58,6 +62,125 @@ pub fn world_routes() -> axum::Router {
)
}
+#[derive(Debug, Deserialize)]
+struct HostViewQuery {
+ world: Option,
+ after: Option,
+}
+
+#[derive(Debug, Serialize)]
+struct HostViewResponse {
+ snapshot: Option,
+ view: Option,
+ surface: Option,
+ records_sequence: u64,
+ records: crate::world::Records,
+ next_after: Option,
+}
+
+/// A revision identifying the exact records snapshot, for the host view's
+/// cross-page consistency check. The watch channel's event sequence cannot
+/// serve: host-originated record changes republish records under an
+/// unchanged event sequence (`WorldActor::deliver`), so pages validated
+/// against it could silently mix snapshots. FNV-1a over the canonical
+/// (BTreeMap-ordered) JSON encoding, folded to 53 bits so the value
+/// survives JSON number round-trips in the browser exactly.
+fn records_revision(records: &crate::world::Records) -> u64 {
+ let bytes = serde_json::to_vec(records).unwrap_or_default();
+ let mut hash: u64 = 0xcbf2_9ce4_8422_2325;
+ for byte in bytes {
+ hash ^= u64::from(byte);
+ hash = hash.wrapping_mul(0x0000_0100_0000_01b3);
+ }
+ hash & ((1 << 53) - 1)
+}
+
+/// The host view uses the existing admin secret, not a guest capability. It
+/// is deliberately an HTTP read so the shared shell frame protocol is unchanged.
+async fn host_view_handler(
+ State(state): State,
+ headers: HeaderMap,
+ Query(query): Query,
+) -> Response {
+ let Some(hub) = state.hub else {
+ return StatusCode::NOT_FOUND.into_response();
+ };
+ let Some(token) = headers
+ .get("x-world-admin-token")
+ .and_then(|value| value.to_str().ok())
+ else {
+ return StatusCode::UNAUTHORIZED.into_response();
+ };
+ if !hub.admin_ok(token) {
+ return StatusCode::UNAUTHORIZED.into_response();
+ }
+ // Resolve without the admin creation path: viewing a typo must not create
+ // a new world as a side effect.
+ let lease = match hub.lease(query.world.as_deref(), None).await {
+ Ok(lease) => lease,
+ Err(ResolveError::Busy | ResolveError::TooManyWorlds) => {
+ return StatusCode::SERVICE_UNAVAILABLE.into_response();
+ }
+ Err(_) => return StatusCode::NOT_FOUND.into_response(),
+ };
+ let world = lease.service().world();
+ let (snapshot, view) = if query.after.is_none() {
+ match world.host_view().await {
+ Ok((snapshot, view)) => (Some(snapshot), view),
+ Err(_) => return StatusCode::INTERNAL_SERVER_ERROR.into_response(),
+ }
+ } else {
+ (None, None)
+ };
+ let (_, current_records) = world.records();
+ let records_sequence = records_revision(¤t_records);
+ let mut records = crate::world::Records::new();
+ let mut used = 0usize;
+ let mut last_included = None;
+ let mut more = false;
+ for (key, value) in current_records.iter() {
+ if query
+ .after
+ .as_deref()
+ .is_some_and(|after| key.as_str() <= after)
+ {
+ continue;
+ }
+ let size = key.len() + serde_json::to_vec(value).map_or(0, |bytes| bytes.len()) + 8;
+ if used + size > crate::world_session::MAX_RECORDS_PAGE_BYTES {
+ if records.is_empty() {
+ return StatusCode::PAYLOAD_TOO_LARGE.into_response();
+ }
+ more = true;
+ break;
+ }
+ used += size;
+ last_included = Some(key.clone());
+ records.insert(key.clone(), value.clone());
+ }
+ let next_after = more.then_some(last_included).flatten();
+ let surface = match view
+ .as_deref()
+ .map(crate::world_presentation::parse_surface)
+ {
+ Some(Ok(surface)) => surface,
+ Some(Err(_)) => return StatusCode::INTERNAL_SERVER_ERROR.into_response(),
+ None => None,
+ };
+ (
+ [(header::CACHE_CONTROL, "no-store")],
+ Json(HostViewResponse {
+ snapshot,
+ view,
+ surface,
+ records_sequence,
+ records,
+ next_after,
+ }),
+ )
+ .into_response()
+}
+
#[derive(Debug, Deserialize)]
pub(super) struct DirectoryQuery {
/// World to read (default world if absent).
@@ -459,7 +582,9 @@ impl SessionIo for WsIo {
#[allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
mod tests {
use super::*;
- use crate::world::{JoinCapability, WorldCore, WorldHandle, WorldLimits};
+ use crate::world::{
+ JoinCapability, Participant, WorldCore, WorldHandle, WorldLimits, WorldProgram,
+ };
use crate::world_session::WorldService;
use axum::http::StatusCode;
use axum::{body::Body, http::Request};
@@ -532,6 +657,54 @@ mod tests {
assert_eq!(response.status(), StatusCode::OK);
}
+ #[tokio::test]
+ async fn host_view_requires_admin_and_does_not_register_a_guest() {
+ struct HostViewerProgram;
+ impl WorldProgram for HostViewerProgram {
+ fn view(&mut self, viewer: &Participant) -> anyhow::Result