Repository navigation
Description
Evidence
On origin/main (6741fc50a4), pkgs/id/src/app_manifest.rs:381-445 validates each web app's route and optional socket by repeatedly scanning every previously registered app with discovery.apps.iter().find(...). With N valid web apps whose paths are all distinct, all four scans miss for each new app, so discovery performs Θ(N²) route/socket comparisons. commands::serve calls discover_apps during startup (pkgs/id/src/commands/serve.rs:1451), making this cost part of serving startup when an installation has many local apps.
The current contract intentionally rejects duplicate routes and cross-kind route/socket collisions (#6454); this is a performance gap in implementing that contract, not a request to change its semantics.
Why it matters
Adding apps increases discovery work quadratically. A large but valid local app set can make id serve startup disproportionately slow, and the current repeated scans make future growth harder to reason about.
Acceptance criteria
- Keep route uniqueness, socket uniqueness, and route↔socket collision behavior (including the existing first-conflict diagnostics) unchanged.
- Track already-registered route and socket values in lookup structures so each app's collision checks are expected O(1), rather than rescanning all registered apps; preserve the conflicting app identity/path needed by errors.
- Add/adjust tests covering duplicate routes, duplicate sockets, and both cross-kind collision directions, with an oracle that checks the same winning app and rejection/error behavior as today.
- Add a non-timing-based structural or benchmark check demonstrating discovery no longer performs a full prior-app scan per new app; avoid flaky wall-clock thresholds.
- Run the focused
pkgs/idapp-manifest tests and relevant formatting/checks.
Activity
developing-today commentedon Nov 12, 2026
CODE-2732