Skip to content

id(serve): persisted publications registry, boot restore + shadow warnings (#2147 slice 1) - #5114

Merged
dezren39 merged 2 commits into
mainfrom
queue/5193-2147-dynamic-publications
Nov 3, 2026
Merged

dezren39 merged 2 commits into
mainfrom
queue/5193-2147-dynamic-publications

Conversation

@dezren39

@dezren39 dezren39 commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Summary

Slice 1 of #2147 (dynamic program publications): the persisted publications registry — the part of the design with no sockets in it, landed first so later slices build on a tested data model.

  • New module pkgs/id/src/publications.rs: Publication / Placement (dedicated listener vs path mount on the Explorer listener) / Registry, with the id(serve): design — how does a program appear as a website? (program-only ports, mixed ports, path mounts) #2146 world-name target model.
  • The path-override rule, enforced in the registry: mount paths are canonicalised (leading /, no empty/./.. segments); shadowing is a segment-boundary prefix relation in either direction (/worlds shadows nothing). publish refuses an unacknowledged mount that shadows an Explorer route, naming the route; with acknowledge_shadow set it succeeds and returns the loud warning text. One program per placement — a second publish must unpublish first.
  • Persistence: one JSON file (ID_PUBLICATIONS_FILE override, else publications.json in the store dir), written atomically (temp + rename). Missing file = empty registry; malformed file = error naming the file.
  • Boot restore wired into id serve: the persisted set is loaded at startup, each restored publication is named in the startup log (inspectable), and boot shadow warnings are re-issued for unacknowledged shadow mounts, per id(serve): dynamic publish/unpublish — bind and unbind programs and pages to ports, interfaces, and paths at runtime #2147. A malformed registry fails startup loudly instead of silently restoring nothing.
  • Tests: 9 unit tests in the module (canonicalisation, segment-boundary shadow detection, ack gate + warning, duplicate placement, unpublish, save/load round-trip, boot-warning conditions).

Not in this slice (remaining for #2147, in order)

  1. Runtime apply: opening/closing live listeners and path mounts from the registry without restart.
  2. Operator surface: CLI (and/or web UI) publish/unpublish/list commands driving the registry + apply step.
  3. The acceptance walk: publish to a new port at runtime and reach it; mount a shadowing path and see the warning; unpublish and see routes revert — all without restarting the node.

Evidence

Refs #2147 (slice 1 of the implementation; the issue stays open for slices 2–3).


Autofix with [code]smith
Open in [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 3, 2026 20:12
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 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-03T20:54:21.002979Z bcd90bf Manual request
ℹ️ 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: e52989c1b9

ℹ️ 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 on lines +65 to +68
pub const KNOWN_EXPLORER_ROUTES: &[&str] = &[
"/", "/api", "/blob", "/edit", "/explore", "/files", "/hash", "/invite", "/peers", "/settings",
"/view", "/world", "/ws",
];

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 Include the assets route in shadow detection

For a persisted, unacknowledged mount at /assets or any descendant, startup emits no shadow warning because this list omits /assets. The Explorer router registers /assets/{*path} in pkgs/id/src/web/routes.rs:370, and its templates reference JavaScript and CSS under that prefix. The same omission lets publish accept these collisions without acknowledgement. Include the assets prefix so both publication validation and boot warnings cover this existing Explorer route.

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.

Fixed in bcd90bf — KNOWN_EXPLORER_ROUTES now includes /assets (the Explorer router registers /assets/{*path} at pkgs/id/src/web/routes.rs:370, verified). Shadow-detection assertions for /assets and /assets/app.js added to shadow_detection_is_segment_boundaried; the publications test suite passes 9/9 on the laptop (cargo test --lib publications::).

Comment thread pkgs/id/src/publications.rs Outdated
Comment on lines +298 to +299
if !path.exists() {
return Ok(Self::default());

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 Distinguish missing registries from metadata failures

If ID_PUBLICATIONS_FILE points into an existing directory that the serve process cannot search, Path::exists() returns false on the permission error, causing startup to silently treat the persisted registry as empty. This bypasses the intended fail-loud behavior when publications cannot be read. Read the file directly and return an empty registry only for ErrorKind::NotFound, propagating other errors with the file context, as GroupLog::open already does in pkgs/id/src/groups/log.rs.

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.

Fixed in bcd90bf — Registry::load now reads the file directly and treats only ErrorKind::NotFound as an empty registry; every other read error propagates with the file context, following the GroupLog::open pattern. Regression test load_fails_loud_on_unreadable_path_not_just_missing (loading a directory must error, not silently restore an empty registry) added and passing (suite 9/9).

… registry

Codex review findings on PR #5114 (issue #2147 slice 1):
- KNOWN_EXPLORER_ROUTES omitted /assets, though the Explorer router
  registers /assets/{*path} (web/routes.rs) — unacknowledged mounts
  at /assets or below passed publish validation and drew no boot
  warning. Route added, with shadow-detection assertions.
- Registry::load probed Path::exists() first, collapsing permission
  and metadata failures into an empty registry (silent restore of
  nothing). It now reads directly and treats only NotFound as empty,
  propagating other errors with the file context — the GroupLog::open
  pattern. Regression test: load of a directory errors.

Tests: cargo test --lib publications:: — 9 passed, 0 failed.
@coderabbitai

coderabbitai Bot commented Nov 3, 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 41 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: 7874339b-c918-4ef0-ad4c-65bf19ca1c02
Commits

Reviewing files that changed from the base of the PR and between 32d47f7 and bcd90bf.

Files selected for processing: 3
  • pkgs/id/src/commands/serve.rs
  • pkgs/id/src/lib.rs
  • pkgs/id/src/publications.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.

@dezren39

dezren39 commented Nov 3, 2026

Copy link
Copy Markdown
Member Author

@codex review — both P2 findings from the first round are fixed in bcd90bf (dispositions on each thread); please re-review the new head.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: bcd90bfe82

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

@dezren39
dezren39 merged commit 52fd50d into main Nov 3, 2026
2 checks passed
@dezren39
dezren39 deleted the queue/5193-2147-dynamic-publications branch November 3, 2026 20:54
@dezren39
dezren39 restored the queue/5193-2147-dynamic-publications branch November 8, 2026 04:13
@dezren39
dezren39 deleted the queue/5193-2147-dynamic-publications branch November 8, 2026 13:25
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