reviews: linked deployments slice 1 plan, round 2 findings
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+129
−0
docs/superpowers/reviews/linked-deployments-slice1-plan-R2.md+129 −0
CI passed — run details
diff --git a/docs/superpowers/reviews/linked-deployments-slice1-plan-R2.md b/docs/superpowers/reviews/linked-deployments-slice1-plan-R2.md| new file mode 100644 |
| index 000000000..dcd4d779c |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/linked-deployments-slice1-plan-R2.md |
| @@ -0,0 +1,129 @@ |
| +# Linked deployments slice 1 plan, round 2 findings |
| + |
| +Plan commit aac497dc. Astra NOT READY (3 P1, 3 P2). Fable READY AFTER FIXES (4 P2). Three Astra P1s recur in round-1 fault families, so AGENTS.md rule 2 applies: no third fix without Paul's choice. |
| + |
| +## Astra (gpt-6-astra, high) |
| + |
| +Astra R1 #1 (P1): resolved — publication retains account/app identity. |
| +Astra R1 #2 (P1): partly — ordinary streaming responses remain unrevoked. |
| +Astra R1 #3 (P1): resolved — forward writes and deletes separate ownership. |
| +Astra R1 #4 (P1): resolved — browser and CLI policy coverage added. |
| +Astra R1 #5 (P1): resolved — registration URL uses HTTPS. |
| +Astra R1 #6 (P1): resolved — production callers and registry interfaces specified. |
| +Astra R1 #7 (P1): resolved — parity and CLI documentation required. |
| +Astra R1 #8 (P2): resolved — link-purpose acknowledgement required. |
| +Astra R1 #9 (P2): resolved — fleet authentication separated; gated route coverage specified. |
| +Fable R1 #1 (P1): resolved — registration scheme corrected. |
| +Fable R1 #2 (P1): resolved — ownership inputs, dispatch arm and callers specified. |
| +Fable R1 #3 (P2): resolved — placement classes protected transactionally. |
| +Fable R1 #4 (P2): resolved — browser policy and registry-based unlink added. |
| +Fable R1 #5 (P2): resolved — expiry and unrelated revocation paths addressed. |
| +Fable R1 #6 (P2): partly — exact routing and identity checks added; import protection remains missing. |
| +Fable R1 #7 (P2): resolved — link tenancy and WebSocket witness specified. |
| +Fable R1 #8 (P2): resolved — connection sequence and startup reset specified. |
| +Fable R1 #9 (P2): partly — publication retry addressed; failed poll delivery remains unspecified. |
| + |
| +1. **P1 — Tasks 1, 4–5: channel repair can undo rotation or unlink.** |
| + Every link API request reasserts an active channel when its hash differs ([plan:172](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/docs/superpowers/plans/2026-11-10-linked-deployments-slice1.md:172)). `PutLinkChannel` is an unconditional upsert; no expected revision or irreversible revocation condition is specified ([plan:72](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/docs/superpowers/plans/2026-11-10-linked-deployments-slice1.md:72)). A request authenticated with token A can pause, then resume its repair after rotation installs B or unlink revokes the channel. It reinstalls A as active. The next reload trusts that hash; tunnel authentication compares against the registry-derived map ([tunnel.go:348](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/internal/edge/tunnel.go:348)). Rotation can therefore leave the compromised token usable indefinitely. Concurrent publication can likewise write after unlink’s enumeration. |
| + **Fix:** serialize link authorization, repair, publication and revocation around one current generation; reject stale writes and resurrection of revoked links. Add barrier-controlled race tests. **Fault family:** revocation completeness/crash consistency, recurring from Fable R1 #5/#9. |
| + |
| +2. **P1 — Task 8: `admissionRefuses` does not enforce import isolation.** |
| + The plan explicitly identifies it as the “holds and imports” stage ([plan:284](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/docs/superpowers/plans/2026-11-10-linked-deployments-slice1.md:284)). It actually checks deployment admission only ([group_admission.go:10](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/internal/edge/group_admission.go:10)). Normal dispatch separately calls `importGateAdmit` ([edge.go:2444](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/internal/edge/edge.go:2444)); that gate refuses ordinary traffic while an import is uncommitted ([importgate.go:42](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/internal/edge/importgate.go:42)). A published, ready instance subsequently acquiring `ImportGate` still satisfies `ServeLinked`’s checks, so arbitrary linked requests reach its uncommitted database. |
| + **Fix:** explicitly refuse import-gated targets on every linked request before activation or proxying, and test a gate added after publication. **Fault family:** home-side enforcement by app, recurring from Fable R1 #6. The verified bypass makes this unsafe, beyond the earlier missing-stage description. |
| + |
| +3. **P1 — Tasks 7–8: unpublish leaves non-upgraded streams serving.** |
| + `linkStreams` tracks only upgraded connections; publication lookup occurs only when a request begins ([plan:286](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/docs/superpowers/plans/2026-11-10-linked-deployments-slice1.md:286)). An already-open SSE response or streaming download never repeats that lookup and never enters the proposed WebSocket sweep. `trackUpgrade` supplies no ordinary-request cancellation either ([planthrottle.go:102](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/internal/edge/planthrottle.go:102)). A misbehaving hub can keep receiving data indefinitely after home unpublishes. |
| + **Fix:** track cancellable requests of every transport type by publication, with admission synchronized against revocation; cancel their streams when publication disappears. Test an open SSE stream and admission racing removal. **Fault family:** publication revocation must be enforced at home, recurring from Astra R1 #2. |
| + |
| +4. **P2 — Task 4: channel repair does not finish the poll-failure recovery contract.** |
| + Task 4 commits the token and consumes approval before calling `PutLinkChannel`, then relies on a subsequent authenticated API request for repair ([plan:172](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/docs/superpowers/plans/2026-11-10-linked-deployments-slice1.md:172)). Existing polling burns the request transactionally and returns the plaintext token once ([authstore.go:593](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/internal/console/authstore.go:593)); its HTTP handler returns an error without the token when polling fails ([authcli.go:810](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/internal/console/authcli.go:810)). If the added registry failure follows that convention, home has no credential with which to perform repair. |
| + **Fix:** specify token delivery despite an initial channel-write failure, together with bounded repair, or another durable recovery mechanism. Test failure immediately after the console transaction commits. **Fault family:** crash consistency, unresolved from Fable R1 #9. |
| + |
| +5. **P2 — Task 8: replacing `r.Host` breaks the public-origin contract.** |
| + `ServeLinked` changes it to the home hostname ([plan:284](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/docs/superpowers/plans/2026-11-10-linked-deployments-slice1.md:284)). Both local proxies derive the backend Host from that value ([edge.go:3634](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/internal/edge/edge.go:3634), [genproxy.go:385](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/internal/edge/genproxy.go:385)); `SetXForwarded` also recomputes forwarded host ([homemap.go:1676](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/internal/edge/homemap.go:1676)). Browser Origin remains the public Carloku origin. Same-origin checks can reject WebSockets and form submissions; generated redirects can expose an unreachable home hostname. |
| + **Fix:** separate the validated backend selector from app-visible request authority. Specify public Host/protocol forwarding without using either to select an upstream; test distinct public/home names and a backend enforcing origin equality. **Fault family:** public request metadata must survive the link. |
| + |
| +6. **P2 — Tasks 7/10: the documented lost-rotation recovery cannot complete as specified.** |
| + Recovery says remove locally, then create again ([plan:325](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/docs/superpowers/plans/2026-11-10-linked-deployments-slice1.md:325)). But removal calls the serving console before deleting local state ([plan:261](/home/paulca/.cache/tmp/claude-1001/design-linked-deployments/docs/superpowers/plans/2026-11-10-linked-deployments-slice1.md:261)). After a lost rotation response, home holds the revoked token, so that call is unauthorized; no local-forget behavior is specified. |
| + **Fix:** define removal for an invalid credential, including local cancellation/cleanup and person-side cleanup of the surviving serving link. Test lost rotation response followed by the exact recovery commands. **Fault family:** credential-loss recovery. |
| + |
| +NOT READY |
| + |
| +## Fable 5.2 |
| + |
| +## Round-1 status |
| + |
| +**Astra** |
| +1. P1 publication stored as hostname: resolved. |
| +2. P1 unpublish not enforced at home: resolved. |
| +3. P1 forward-row collision: resolved. |
| +4. P1 linked-app guard: resolved for doors (same family reopens as N3). |
| +5. P1 `wss://` URL: resolved. |
| +6. P1 interface propagation: resolved. |
| +7. P1 parity and docs gates: partly (the link door's route kind is still unspecified, N4). |
| +8. P2 old serving console: resolved. |
| +9. P2 containment proof: partly (the publish-time credential recheck is not carried to links, N1). |
| + |
| +**Fable** |
| +1. P1 `tunnel_url` scheme: resolved. |
| +2. P1 `FleetArmVerdict` callers: resolved. |
| +3. P2 host-held claim: resolved. |
| +4. P2 guard misses browser doors: partly (doors covered; non-door removals are not, N3). |
| +5. P2 token lifecycle: resolved. |
| +6. P2 `ServeLinked` stages: partly (import gate still skipped, N2). |
| +7. P2 WebSockets: resolved. |
| +8. P2 `SetLinkSeen` ordering: resolved. |
| +9. P2 retry safety: resolved. |
| + |
| +## Findings |
| + |
| +No P1. |
| + |
| +### P2 |
| + |
| +**N1. Task 3: the publish-time credential recheck is not planned for link channels.** Carried from Astra 9. |
| +- **Problem:** the plan makes `VerifyDynamic` refuse link names and adds `verifyLink` for `ServeHTTP`. It never says the second check, made under `h.mu` as the connection is published, runs for links. |
| +- **Evidence:** `internal/edge/tunnel.go:200` authenticates before the hijack. `:269-276` rechecks only `if viaDynamic`, through `verifyDynamicLocked`. `SetDynamicAuth` (`:391`) closes only connections already published. |
| +- **Failure:** a holder of a leaked token dials in a loop. One dial passes auth, then rotate or unlink reloads and the close pass finds nothing. The dial then publishes on the old token and receives visitors' traffic for every host of the link until the next hash change. If the implementer instead leaves `viaDynamic` set, every link registration is closed as "revoked". |
| +- **Fix:** add `verifyLinkLocked`, called under `h.mu` at publish for link names. Add a test using the `afterAuth` hook that rotates between auth and publish and asserts the connection is closed and unselectable. |
| +- **Family:** revocation must cut every live path (round 1: Astra 9, Fable 5). |
| + |
| +**N2. Task 8: `ServeLinked` skips the import gate.** Carried from Fable 6. |
| +- **Problem:** the plan keeps `admissionRefuses` and describes it as "holds and imports". It is neither. |
| +- **Evidence:** `internal/edge/group_admission.go:10-24` is the HA tenant admission only. The import gate is `importGateAdmit` (`internal/edge/importgate.go:35-56`), which answers 503 to everything but the tokened verify GET and strips `ImportVerifyHeader`. Hold classification and `planDisabledAdmit` (`internal/edge/plandisabled.go:75`) are also separate stages. |
| +- **Failure:** a published home app is mid-import. The tailnet edge answers 503, but public visitors through the link reach the instance and its half-replaced database, and a client-sent verify header reaches the app. Task 7's publish-time refusal does not help, because the gate appears after publication. |
| +- **Fix:** add `importGateAdmit` (with the header strip) and `planDisabledAdmit` to the kept stages, in the normal order. Add `TestLinkImportGatedAppRefused`. Correct the description of `admissionRefuses`. |
| +- **Family:** home-side protections must hold on the link path (round 1: Fable 6). |
| + |
| +**N3. Tasks 5 and 6: a linked app's row can be removed outside every door, leaving its forward row serving.** |
| +- **Problem:** `linkedAppPolicy` is keyed by route pattern. Several removal paths have no route. |
| +- **Evidence:** bucket convergence trashes and purges rows (`internal/console/materialize.go:402`, `:431`; `settle.go:102`, `:144`). `ReapAccount` deletes every app row of an account (`store.go:1829`, from `materialize.go:120`). The expiry passes purge (`expirypass.go:255`, `lifetimes_purge.go:258`). None calls `DeleteLinkForward`. Task 2 exempts link rows from retirement, and Task 3's eligibility checks only `owners.Links[id]`. |
| +- **Failure:** a tombstone written under `apps/<sqid>/shop/`, or a reaped account, removes the app row. The public URL keeps serving outside the app cap, the name is free again, and a new app of that name finds its host held. For a reaped account, the channel and token stay live with no console card to unlink from. |
| +- **Fix:** enforce at the store. `claimRawTrashAppRow` and `PurgeAppRow` refuse a row with `linked_link_id` set. `ReapAccount`'s caller runs `unlink` for each of the account's links first. Add a test that scans every `DELETE FROM apps` and trash statement, as `TestEveryAppInsertMintsALifetime` does for inserts. |
| +- **Family:** a publication must not outlive its app record (round 1: Fable 4, Astra 4). |
| + |
| +**N4. Task 5: no route kind exists for the `/api/link/` doors.** Carried from Astra 7. |
| +- **Problem:** the plan says these doors "require a `PrincipalLink`" but not how they are registered. Neither existing kind fits. |
| +- **Evidence:** a `kindPlain` handler that resolves `CLIPrincipal` fails `TestAuthCLIFamilyResolvesOnlyPersons` (`internal/console/svcroutes_test.go:1423`, identifier scan at `:1506`). `kindCLI` goes through `cliGateRefused` (`authcli.go:498`), which Task 4 makes refuse `PrincipalLink`. `routeKind.isCLI()` (`routedecls.go:30`) treats any new kind as outside parity. |
| +- **Failure:** the implementer either fails that test or hides the resolver in a helper the scan cannot see. The second option blinds the scan that Task 4's containment argument relies on. |
| +- **Fix:** specify `kindLink`, registered through one `linkRoute` gate that resolves the bearer, admits only `PrincipalLink` (others get `cliNotSignedIn`'s 401) and puts the principal on the context. Extend `registerDecls`, `TestRouteDeclsMatchRegistrations` and the scan (link handlers call no resolver themselves). State whether `kindLink` is inside parity. |
| +- **Family:** structural gates over the route table (round 1: Astra 7). |
| + |
| +### P3 |
| + |
| +- The Global Constraints ask for a parity row for every new console route. `/api/cli/` doors (Tasks 6 and 7) must not be console members (`parity_test.go:41-42`). |
| +- `accountApp` is at `server.go:4166`; `:5648` is `handlePromote`. |
| +- Task 1 gives `SetLinkSeen` two signatures (plan lines 76 and 80); keep the one with `seq`. Its Step 2 lists two tests after the run command. |
| +- `SetDynamicAuth` closes by name after releasing the lock (`tunnel.go:396-400`). A home that redials with the new token in that gap loses the fresh connection once. Close the captured connection instead. |
| +- `reconcile.go:1860` will log "the forward phase retires it" every pass for a record naming a link host. Reword for link rows. |
| +- Say where `home_link.token` (plaintext) sits and which file mode keeps it from apps (spec §8). |
| + |
| +### Checked and sound |
| + |
| +- **Forward-row consumers:** only `retirements` and `mint` need changes. `SetAccount` and `SetChannel` skip forward rows (`registry.go:2091`, `:2107`). The domains pass keeps forward rows and mints nothing because the link host is already the platform name (`domains/reconcile.go:251`, `:327-329`). `decideForward` refuses a `link/` record. Throttle, rate limit, caches, egress, root updates and the edges file treat an inert link row as they treat a fleet row. |
| +- **Credential containment:** `fleetIdentityOK`, the store door and `CLITokenAddress` cannot match a link token. `RotateServicePrincipal`, `RevokeServicePrincipal` and `PurgeAppRow`'s token delete filter on kind. |
| +- **Interfaces:** the `FleetArmVerdict` call sites are complete at `edge.go:979`, `hub.go:72`, `edgesfile.go:649` and `apiinstances.go:429`. |
| + |
| +## Verdict |
| + |
| +**READY AFTER FIXES**: N1 to N4 are fixed without another round. N1 and N2 change security behaviour in Tasks 3 and 8, so those tasks' own reviews must check the fixes. |