carlos / platform Public

reviews: linked deployments slice 1 plan, round 3 findings

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev bb6bb22ec3ba90e1a6aa02acb18db47589e7369e parent 31f5000
1 file changed, +115 −0
  • docs/superpowers/reviews/linked-deployments-slice1-plan-R3.md +115 −0

CI failed — run details

diff --git a/docs/superpowers/reviews/linked-deployments-slice1-plan-R3.md b/docs/superpowers/reviews/linked-deployments-slice1-plan-R3.md
new file mode 100644
index 000000000..b3559231f
--- /dev/null
+++ b/docs/superpowers/reviews/linked-deployments-slice1-plan-R3.md
@@ -0,0 +1,115 @@
+# Linked deployments slice 1 plan, round 3 findings
+
+Plan commit 31f50008 (rev 3). Astra NOT READY (2 P1, 1 P2), both P1s in the revocation-completeness family. Fable READY AFTER FIXES (4 P2). Round 3 is the budget limit; a fourth round or a further fix in this family needs Paul's go (AGENTS.md rules 1 and 2).
+
+## Astra (gpt-6-astra, high)
+
+Astra R2 #1 (P1): resolved — generations and terminal revocation prevent stale channel repair.
+Astra R2 #2 (P1): resolved — the normal pipeline includes the import gate.
+Astra R2 #3 (P1): partly — connection replacement misses publication removal and reuse between reloads; finding 1.
+Astra R2 #4 (P2): resolved — poll delivers the credential despite initial sync failure.
+Astra R2 #5 (P2): partly — backend Host is corrected, but forwarded authority and gate-origin checks remain inconsistent; finding 3.
+Astra R2 #6 (P2): resolved — local removal and person-side cleanup are specified.
+Fable R2 N1 (P2): resolved — link authentication is repeated under the publication lock.
+Fable R2 N2 (P2): resolved — import and plan-disabled checks remain in the pipeline.
+Fable R2 N3 (P2): resolved — store-level removal guards and unlink-before-reap are specified.
+Fable R2 N4 (P2): resolved — `kindLink`, its gate and structural scan changes are specified.
+
+1. **P1 — Tasks 7–8: publication-name comparison can miss revocation.**
+
+ **Evidence:** [plan:298](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/docs/superpowers/plans/2026-11-10-linked-deployments-slice1.md:298) replaces the connection only when a published **name disappears**. Publication state is keyed by name ([plan:264](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/docs/superpowers/plans/2026-11-10-linked-deployments-slice1.md:264)). The watcher samples current state every two seconds ([edge.go:3545](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/internal/edge/edge.go:3545)); it does not deliver each mutation.
+
+ **Failure:** `shop` is published as `demo`, with an open SSE response. Unpublish it, then publish another home app as `demo` before either edge reloads. The home loop sees the same name set and never cancels its connection. The original stream continues from `shop`, which is no longer published. Even a changed fingerprint cannot help: the replacement predicate still sees no missing name.
+
+ **Fix:** increment a durable connection generation atomically with every unpublish or publication-target replacement. Replace the connection whenever that generation changes, regardless of the final name set. Test remove-and-reuse between watch ticks with an open SSE response and WebSocket.
+
+ **Fault family:** publication revocation must terminate existing access at home; carried from Astra R2 #3.
+
+2. **P1 — Tasks 4–5: failed revocation delivery can leave the old credential serving indefinitely.**
+
+ **Evidence:** [plan:212](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/docs/superpowers/plans/2026-11-10-linked-deployments-slice1.md:212) commits console revocation before syncing the registry. The specified repair triggers are console startup and authenticated link requests ([plan:176](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/docs/superpowers/plans/2026-11-10-linked-deployments-slice1.md:176)). But revoked links cannot resolve to `PrincipalLink`, and `linkRoute` authenticates before syncing ([plan:173](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/docs/superpowers/plans/2026-11-10-linked-deployments-slice1.md:173), [plan:206](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/docs/superpowers/plans/2026-11-10-linked-deployments-slice1.md:206)). Tunnel authentication reads the registry-derived hash ([tunnel.go:348](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/internal/edge/tunnel.go:348)).
+
+ **Failure:** unlink commits, then `RevokeLinkChannel` fails once. The registry retains its active channel and forward rows. Subsequent requests with the old credential fail before repair; ordinary hub reloads keep reading the old registry state. Without a restart or person-side retry, the existing tunnel remains usable and the old token can redial. Rotation has the same delivery gap when the new credential is not received.
+
+ **Fix:** persist pending synchronization with the console transaction and retry through `syncLinkChannel` automatically, including revoked links, until the registry acknowledges it. Preserve the one-writer and terminal-revocation rules. Inject a post-commit registry failure and prove closure and redial refusal without another API request or restart.
+
+ **Fault family:** revocation completeness across the console/registry boundary.
+
+3. **P2 — Task 8: public-origin preservation is incomplete.**
+
+ **Evidence:** [plan:294](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/docs/superpowers/plans/2026-11-10-linked-deployments-slice1.md:294) changes `r.Host` to the home hostname and leaves the password gate unchanged. That gate compares browser `Origin` directly with `r.Host` ([gate.go:189](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/internal/gate/gate.go:189)). The proxy correction specifies public `Host` and HTTPS, but not `X-Forwarded-Host`; `setForwarded` recomputes forwarded authority from the rewritten request ([homemap.go:1677](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/internal/edge/homemap.go:1677)).
+
+ **Failure:** after a published app gains a password gate, a browser login from its public origin gets 403 despite the correct password. Apps using forwarded authority can likewise still derive the private home origin.
+
+ **Fix:** keep public request authority separate from the pinned routing selector throughout origin-sensitive stages. Explicitly set public `Host`, `X-Forwarded-Host` and HTTPS at the backend boundary. Test a successful gate login after publication and an app that uses forwarded authority.
+
+ **Fault family:** public request metadata must survive the link; carried from Astra R2 #5.
+
+The two P1s share the revocation-completeness family but have different causes: missed transitions and failed delivery without automatic retry. Refusing publication-name reuse or retargeting removes finding 1’s case; it does not remove finding 2. Cutting dynamic links removes both. The specified fixes retain Paul’s chosen mechanisms.
+
+**NOT READY** — P1 findings 1 and 2 remain.
+
+## Fable 5.2
+
+**Round-2 status**
+
+Astra
+1. P1 channel repair undoes rotation or unlink: resolved (generations, revoked is terminal, one writer).
+2. P1 import isolation: resolved (the normal pipeline runs `importGateAdmit`, `edge.go:2444`).
+3. P1 unpublish leaves non-upgraded streams: resolved (connection replacement; `serveUntilDead` closes the conn on cancel, `tunnelclient.go:161`).
+4. P2 poll-failure recovery: resolved for the poll. The same gap remains for rotate and unlink, carried as F2.
+5. P2 `r.Host` breaks the public origin: partly. Host is fixed; `X-Forwarded-Host` and the home caches are not. Carried as F1.
+6. P2 lost-rotation recovery: resolved (`?local=1`).
+
+Fable
+- N1 publish-time recheck: resolved (`verifyLinkLocked`, captured connection).
+- N2 import gate skipped: resolved.
+- N3 linked rows removed outside doors: resolved (cleanup gap is P3 below).
+- N4 route kind for link doors: resolved (`kindLink`, `linkRoute`).
+
+**Findings**
+
+No P1.
+
+**F1 (P2, carried from Astra R2 #5). Task 8: the public origin reaches only the Host header.**
+- **Problem:** `ServeLinked` sets `r.Host = want.Host` and has the proxy send `Host: PublicHost` (plan:294-296). Nothing else in the pipeline learns the public name.
+- **Evidence:** every proxy Rewrite calls `setForwarded`, which calls `pr.SetXForwarded()` (`homemap.go:1676`; `edge.go:3631`, `genproxy.go:382`). That writes `X-Forwarded-Host` from `pr.In.Host`, the home hostname. The home LRU and page cache key on the same `host` (`edge.go:2793`, `pagecache.go:452`). `maybeStore` keeps any 2xx with a max-age and no Set-Cookie (`edge.go:3032`).
+- **Failure:** an app that prefers `X-Forwarded-Host` (Rails does) builds redirects and origin checks from the home hostname, so form POSTs through the link fail. `TestLinkAppSeesPublicOrigin` still passes because it checks only `Host`. A cacheable page rendered for one origin is replayed to the other: public visitors get tailnet hostnames in links, tailnet visitors get public ones. A `Carlos-Purge-Host` naming the Host the app received matches no home route.
+- **Fix:** under a pin, set `X-Forwarded-Host` to `PublicHost`. Pinned requests skip the LRU, page cache and asset catch in both directions, as forward rows do (`edge.go:2790`). Treat a purge host equal to `PublicHost` as the route's own. Assert `X-Forwarded-Host` in the test, and that a cacheable link response is never replayed to a tailnet request.
+- **Family:** public request metadata must survive the link.
+
+**F2 (P2, family of Astra R2 #4). Tasks 4 to 6: a failed sync after rotate or unlink is never retried.**
+- **Problem:** the plan reruns `syncLinkChannel` at console start and before every `/api/link/` handler (plan:176-177). `linkRoute` admits only an unrevoked link principal (plan:206). After unlink no handler runs again. After a rotate whose sync failed, home holds a revoked token, so none runs either.
+- **Failure:** `RevokeLinkChannel` or `PutLinkChannel` returns an error (busy registry). The console records the link revoked or rotated. The hub registry keeps the old hash active with its forward rows, so the tunnel keeps serving on the leaked token until the console restarts. Unlink's third step is skipped, and the linked `apps` rows have no remover left (plan:213).
+- **Fix:** make `unlink` re-runnable on an already revoked link from Task 6's person doors, and keep the card until the registry and `apps` rows are clean. Rotate and unlink retry the sync with a bounded backoff. An existing console ticker re-syncs every link, revoked ones included (no bucket reads). Test a registry that fails once on revoke and once on rotate: the old channel closes without a restart.
+- **Family:** revocation completeness.
+
+**F3 (P2). Task 8: the pin names functions, not selection sites.**
+- **Problem:** the plan pins "selection" (plan:295), but `lookupUpstreamPath(host, path)` takes no request (`edge.go:1840`) and several request-path sites call it.
+- **Evidence:** `edge.go:2126`, the login re-resolution at `edge.go:2405`, `demo.go:94` and `:116` (reached first, from `edge.go:1998`), `pagecache.go:533`.
+- **Failure:** the implementer pins `:2126`. A hub sends a login POST to the gate path on published host H with `next=/<prefix>/`, where a `route_paths` prefix on H selects unpublished, gated `admin`. `:2405` resolves to `admin` and `gate.Admit` (`:2611`) judges the password against `admin`'s gate. The hub gets a password oracle on an unpublished app. The instance is not reached, since login POSTs are never proxied, hence P2.
+- **Fix:** one `selectUpstream(r, host, path)` that honours the pin and that every request-path site calls. Add a test that fails when `ServeHTTP`'s call tree calls `lookupUpstreamPath` directly. Add the login POST case to `TestLinkIgnoresPathMapAndEdgeHandlers`.
+- **Family:** anti-goal 1, home enforcement by published app.
+
+**F4 (P2). Task 4: the route walk covers a named subset, so it cannot catch every later route.**
+- **Problem:** the walk covers "every route under `/api/cli/` and every person-only door" (plan:185).
+- **Evidence:** `cliGateRefused` refuses only `PrincipalService` by role (`authcli.go:515`), so a new principal kind falls through to the handler wherever it is not refused by hand. A second resolver site already sits outside that gate (`app_source.go:179`).
+- **Fix:** walk every `routeDecl` except `kindLink`, under every gate, and assert a link bearer gets the same status as no bearer. Add the reverse: each `kindLink` door answers 401 to person, app and service tokens.
+- **Family:** credential containment.
+
+**P3**
+- The pin compares raw `Account` (plan:295). An empty account and the ops account are one tenant elsewhere (`registry.go:1469`, `purge_header.go:569`). Compare through `registry.EffectiveAccount`, or ops-account home apps answer 502.
+- The pin's skipped-handler list (ACME, purge, status, devbox, admin) is not the set inside `ServeHTTP`. That set is HA control (`edge.go:1984`), hop acceptance (`:2088`), burst notice (`:2094`) and the replica probe (`:2137`; a link channel is `FromTunnel`, `replicaprobe.go:99`). All are gated by home mesh keys or fail closed, so not unsafe. List and test the real ones.
+- Unpublish and unlink delete "the apps row". Share `PurgeAppRow`'s cleanup (`store.go:2136`: stars, lapse items) so a re-created name inherits nothing.
+- Task 1: the table column is `rev` (plan:83) but the field is `Generation`. `TestPutForwardAcceptsLinkPlacement` (plan:88) now needs an active channel first.
+- The loop compares names only. Unpublish then publish the same name for another home app within one watch keeps the old streams. Compare name, home account and home app.
+- Say what `linkRoute` does when its pre-handler sync fails (refuse with 503).
+
+**Checked and sound**
+- **Forward-row reuse:** `retirements` and `mint` are the only consumers needing changes. `PutForward` already forces `Status "ready"`, and the edges file and egress check treat an inert link row as a fleet row.
+- **Containment:** the store door, `fleetIdentityOK`, `CLITokenAddress` and `ConnectedOfFleet` cannot match a link name or token.
+- **Interfaces:** the four `FleetArmVerdict` call sites are complete. `reserveUpgrade` compares tenancies by struct equality, so adding `Link` works.
+
+**Verdict**
+
+**READY AFTER FIXES**: F1 to F4 are fixed without another round. F1 and F3 change security behaviour in Task 8, so that task's own review must check the fixes.