carlos / platform Public

alias-socket-follow-338: Astra r1 P2, LayoutSibling recognises the nested shape first (host "app")

Astra round 1: READY AFTER FIXES, no P1, all census units approved.
The P2: for the host "app" the nested socket's base name equals the
flat one, so the flat case won. Nested is now checked first; the
registry, provision parity and host repair tests cover "app". 9B8
digest and the registry envelope re-pinned.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev c01d13242badb50b0d40ec4beb8fd73c4df0b51a parent ae549c5
7 files changed, +85 −5
  • docs/superpowers/reviews/CODEX-FINDINGS-alias-socket-follow-338.md +44 −0
  • internal/host/aliassocket_test.go +32 −0
  • internal/provision/layoutsibling_test.go +1 −1
  • internal/provision/plan9_b8_census_test.go +1 −1
  • internal/provision/testdata/plan14-root-reads-alias-socket-follow-338.tsv +1 −1
  • internal/registry/aliassocket.go +4 −2
  • internal/registry/aliassocket_test.go +2 −0

CI passed — run details

diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-alias-socket-follow-338.md b/docs/superpowers/reviews/CODEX-FINDINGS-alias-socket-follow-338.md
new file mode 100644
index 000000000..ff8e5ba42
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-FINDINGS-alias-socket-follow-338.md
@@ -0,0 +1,44 @@
+Census verdicts for `ae549c5f2d0af2fb9aecb7fda9698897f0e7267c`, reviewing `git diff origin/main...HEAD`:
+
+| Unit or envelope | Verdict | Evidence and basis |
+|---|---|---|
+| `liveSocket` | APPROVE | [aliassocket.go:39](/home/paulca/amadan.net/carlos/platform-alias-socket/internal/host/aliassocket.go:39): agent-side `Lstat`; no file opening or new root caller. |
+| `repairPlatformAliases` | APPROVE | [aliassocket.go:46](/home/paulca/amadan.net/carlos/platform-alias-socket/internal/host/aliassocket.go:46): filters by effective account and app, excludes platform/sidecar sources, requires one matching source. Transaction revalidates tenancy. |
+| `aliasLayout` | APPROVE | [layoutleg.go:237](/home/paulca/amadan.net/carlos/platform-alias-socket/internal/host/layoutleg.go:237): status-only socket check. |
+| `Registry.RepointPlatformSocket` | APPROVE | [aliassocket.go:127](/home/paulca/amadan.net/carlos/platform-alias-socket/internal/registry/aliassocket.go:127): rereads both rows under the write lock; checks platform/source shape, tenant and sibling relationship before updating. |
+| `Registry.inImmediateTx` | APPROVE | [aliassocket.go:100](/home/paulca/amadan.net/carlos/platform-alias-socket/internal/registry/aliassocket.go:100): rejects remote handles; uses the existing transaction implementation and rolls back errors. |
+| `carriesAliases` | APPROVE | [aliassocket.go:64](/home/paulca/amadan.net/carlos/platform-alias-socket/internal/registry/aliassocket.go:64): column predicate only; excludes sidecars and platform sources. |
+| `carryAliasesTx` | APPROVE | [aliassocket.go:76](/home/paulca/amadan.net/carlos/platform-alias-socket/internal/registry/aliassocket.go:76): updates only matching platform rows of the source’s effective account and app. |
+| `sameTenant` | APPROVE | [aliassocket.go:70](/home/paulca/amadan.net/carlos/platform-alias-socket/internal/registry/aliassocket.go:70): uses the established effective-account rule and exact app equality. |
+| `upsertRoute` | APPROVE | [registry.go:1334](/home/paulca/amadan.net/carlos/platform-alias-socket/internal/registry/registry.go:1334): extracted SQL and error handling are byte-identical to the previous implementation, apart from the executor name. Ownership refusal and normalization remain intact. |
+| `layoutStatusReport` | APPROVE | [layoutleg.go:214](/home/paulca/amadan.net/carlos/platform-alias-socket/internal/host/layoutleg.go:214): changes the reported classification of unmanaged platform sockets. |
+| `unmanagedLayoutReport` | APPROVE | [layoutleg.go:265](/home/paulca/amadan.net/carlos/platform-alias-socket/internal/host/layoutleg.go:265): journal/hold checks retain precedence; root’s separate downgrade guard still checks nested paths directly. |
+| `Registry.SetInstancePaths` | APPROVE | [registry.go:1993](/home/paulca/amadan.net/carlos/platform-alias-socket/internal/registry/registry.go:1993): preserves CAS conditions and error texts; carries aliases only after success, within the same transaction. |
+| `Registry.Upsert` | APPROVE | [registry.go:1300](/home/paulca/amadan.net/carlos/platform-alias-socket/internal/registry/registry.go:1300): preserves remote dispatch; ownership refusal precedes carry; previous sockets are followed only across the same tenant. |
+| `internal/host` envelope | APPROVE | Reviewed the above host changes and [agent.go:3797](/home/paulca/amadan.net/carlos/platform-alias-socket/internal/host/agent.go:3797). Repair runs after health stamping on each non-fleet domains tick, outside the housekeeper lease gate. |
+| `internal/registry` envelope | APPROVE | Reviewed both changed production files and transaction/remote callers. No new root filesystem access or weakened tenant boundary found. Functional issue below remains. |
+| New 9B8 `LayoutSibling` row | APPROVE | [plan9_b8_census_test.go:656](/home/paulca/amadan.net/carlos/platform-alias-socket/internal/provision/plan9_b8_census_test.go:656): pure path construction, no record write. Its recorded digest matches the function’s source. |
+
+P1: None found.
+
+**P2 — Brief §4: `LayoutSibling` misclassifies the nested socket for host `app`.**
+
+At [internal/registry/aliassocket.go:54](/home/paulca/amadan.net/carlos/platform-alias-socket/internal/registry/aliassocket.go:54), the generic flat-socket case precedes the nested case. Consequently:
+
+```text
+LayoutSibling("app", "/run/carlos/instances/app/app.sock")
+returns /run/carlos/instances/app/instances/app/app.sock
+wanted /run/carlos/app.sock
+```
+
+`app` is a valid hostname under [ValidHostShape](/home/paulca/amadan.net/carlos/platform-alias-socket/launchctx/controlname/names.go:18), and [addRail](/home/paulca/amadan.net/carlos/platform-alias-socket/cli.go:1389) permits it. For an already-nested source named `app` with an alias still pointing at `/run/carlos/app.sock`, repair finds no source and leaves the alias broken. Inserting that nested source over the stale alias also misses the carry.
+
+Fix: recognize the complete nested shape before the generic flat basename. Add `app` to the provision parity test and cover this stale-alias repair case. **Fault family:** flat/nested socket identity must round-trip for every supported host. Tenant isolation remains intact.
+
+P3: None found.
+
+The layout tests call the real `Pass` and registry, including recovery. Socket changes participate in the edge fingerprint. Formatting and `git diff --check` passed. Targeted Go tests could not start: the read-only sandbox refused creation of Go’s build directory. No full suites ran, and no files changed.
+
+This round has no P1; apply the P2 without reopening general review, retaining the required census check for the changed function and envelope.
+
+READY AFTER FIXES
\ No newline at end of file
diff --git a/internal/host/aliassocket_test.go b/internal/host/aliassocket_test.go
index 6939aa39f..254e9963c 100644
--- a/internal/host/aliassocket_test.go
+++ b/internal/host/aliassocket_test.go
@@ -182,3 +182,35 @@ func TestLayoutReportFlagsAnAliasWithNoSocket(t *testing.T) {
check(t, w, r)
})
}
+
+// Astra r1 P2: the host "app", whose nested socket's base name is also
+// its flat one, is repaired like any other.
+func TestRepairPlatformAliasesHostNamedApp(t *testing.T) {
+ dir, err := os.MkdirTemp("", "as")
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(func() { os.RemoveAll(dir) })
+ flat := filepath.Join(dir, "app.sock")
+ nested := filepath.Join(dir, "instances", "app", "app.sock")
+ reg, err := registry.Open(filepath.Join(t.TempDir(), "registry.db"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(func() { reg.Close() })
+ for _, rt := range []registry.Route{
+ {Host: "app", Kind: "instance", App: "shop", Account: "abc", Hibernate: true, Socket: nested, Status: "ready"},
+ {Host: "shop.abc.example.com", Kind: "instance", App: "shop", Account: "abc", Platform: true, Socket: flat, Status: "ready"},
+ } {
+ if err := reg.Upsert(rt); err != nil {
+ t.Fatal(err)
+ }
+ }
+ listenAt(t, nested)
+ if n := repairPlatformAliases(reg, liveSocket); n != 1 {
+ t.Fatalf("repaired %d, want 1", n)
+ }
+ if got := socketAt(t, reg, "shop.abc.example.com"); got != nested {
+ t.Errorf("alias = %q, want %q", got, nested)
+ }
+}
diff --git a/internal/provision/layoutsibling_test.go b/internal/provision/layoutsibling_test.go
index 9b00ef054..9bbdc4121 100644
--- a/internal/provision/layoutsibling_test.go
+++ b/internal/provision/layoutsibling_test.go
@@ -12,7 +12,7 @@ import (
// short host and a host long enough to be hashed, the flat and nested
// sockets are each other's sibling (#338).
func TestLayoutSiblingIsProvisionsLayout(t *testing.T) {
- for _, host := range []string{"shop.abc.example.com", strings.Repeat("a", MaxInstanceID+1) + ".example.com", strings.Repeat("b", MaxInstanceID)} {
+ for _, host := range []string{"shop.abc.example.com", strings.Repeat("a", MaxInstanceID+1) + ".example.com", strings.Repeat("b", MaxInstanceID), "app"} {
flat, nested := DefaultSocket(host), NestedSocket(host)
if got := registry.LayoutSibling(host, flat); got != nested {
t.Errorf("%s: sibling of flat = %q, want %q", host, got, nested)
diff --git a/internal/provision/plan9_b8_census_test.go b/internal/provision/plan9_b8_census_test.go
index 944399698..f8e715ef2 100644
--- a/internal/provision/plan9_b8_census_test.go
+++ b/internal/provision/plan9_b8_census_test.go
@@ -653,7 +653,7 @@ var plan9B8CensusInventory = []censusEntry{
{"schedule.go", "renderScheduleList", "key-site", "lit:instances", "af6d666083fbbc753eecc98809d3d307344cc15110362a7e93afab573749ea6e"},
{"internal/activator/layout.go", "LayoutInputs.sockets", "key-site", "lit:instances", "1d11ac5ac5be6a42e676e064771141fe8f4367c78cbb7e5c5cca072f40c27c42"},
// #338: the flat/nested socket sibling of a host, a socket path under /run/carlos/instances/<id>/, never a record key; it writes nothing.
- {"internal/registry/aliassocket.go", "LayoutSibling", "key-site", "lit:instances", "26051a9ea7ad1f40157c0a46c1764bd0ed2f85a7aaeece0bce46ec755e70d135"},
+ {"internal/registry/aliassocket.go", "LayoutSibling", "key-site", "lit:instances", "675ab91403b73f0ce0a492d1ae09067d62e41ab202c20714b236501860d8435c"},
{"internal/activator/paths.go", "ExecBackend.pathsFor", "key-site", "lit:instances", "cbc01865e27934cb38baab9329a0867b899149531b4706a533a6956afc7c71b3"},
// Re-digested for fix-empty-app-key (census-ruling-fix-empty-app-key, platform-1e 2026-10-16): DayKey now returns an error for an empty or invalid account, app, box or date, and UpsertDay returns it before any Get or Put. Same single Put of the app-day file; no record key.
{"internal/analytics/day.go", "UpsertDay", "nonrecord", "sel:Put", "ab892656cdbce1c80f0c33441341cf9c94dd22f06716ffffbd6c025100adb1b8"},
diff --git a/internal/provision/testdata/plan14-root-reads-alias-socket-follow-338.tsv b/internal/provision/testdata/plan14-root-reads-alias-socket-follow-338.tsv
index f850a40cf..e94321d4b 100644
--- a/internal/provision/testdata/plan14-root-reads-alias-socket-follow-338.tsv
+++ b/internal/provision/testdata/plan14-root-reads-alias-socket-follow-338.tsv
@@ -25,4 +25,4 @@ internal/host/layoutleg.go unmanagedLayoutReport diagnostic H3 no-effect;rev3=ce
internal/registry/registry.go Registry.SetInstancePaths legacy accepted-legacy accepted-legacy;rev3=J1,J4;basis=route-and-input;rev3=census-ruling-alias-socket-follow-338;basis=#338: the same CAS UPDATE now runs in one IMMEDIATE transaction that also carries the row's same-tenant platform aliases from fromSock to toSock; a missed CAS carries nothing file:Exec@343,file:QueryRow@637,registry:remote@123,registry:remote@93,whole:Route@1012,whole:Route@1071,whole:remoteClient@125,whole:remoteClient@95 d0a1a2f13254d529054d664eb7107a3afaf570bf46b737a47cf595a1ce0ebe09
internal/registry/registry.go Registry.Upsert authority E3 rev3=census-ruling-self-serve-moves-1;basis=the registry's SQLite side, as carlos: in the agent (/opt/carlos/carlos agent, carlos-edge.service) and in the registry child (carlos __registry-child, which a root pass forks as the service user); the remote arm, unchanged, in the process that holds a remote handle, root passes included: census-ruling-seeded-instances's body with two more columns (incarnation, serving_seq) bound through routeArgs; the conflict clause names them only to keep an existing row's pair (a fresh insert writes the mint's), and the tenant-change rule E3 names is unchanged; main's E3 authority retained; self-serve moves 1 Task 7;rev3=census-ruling-rootfs-apps-2;basis=main's body (with main's rate_limit rule and, from the merge of origin/main 3c33f2eb, the assets_off and asset_gen pair rule of edge asset cache plan 1, and, from the merge of 953b9fda, the incarnation and serving_seq pair of self-serve moves plan 1) plus the runtime column's conflict rule: a re-tenanted host takes the incoming runtime, the same tenant keeps the stored one (fixed at mint); the bind is routeArgs, re-frozen in rootfs-apps-2-new; the same nine sites, no read added;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328/#329 plan 1 Task 4: the conflict clause gains egress_allow, size and policy_expires_at under the tenant-change rule (a re-tenanted host takes the incoming values, empty included; the same tenant keeps the stored value when the incoming one is empty, else takes it), bound through routeArgs; the same nine sites, no read added.;rev3=census-ruling-region-ha-p1a;basis=the conflict clause gains ha=MAX(routes.ha, excluded.ha), so no full-row write ever clears a stored born-HA mark and a fresh row takes the incoming value; the bind is routeArgs; the same nine sites, no read added;rev3=census-ruling-alias-socket-follow-338;basis=#338: a non-platform row with a socket and app is upserted in one IMMEDIATE transaction that then carries same-tenant platform aliases naming its other-layout socket (LayoutSibling) or its previous socket (same tenant only); the upsert statement and its claim-ownership refusal are unchanged; platform and other rows take the old single-statement path registry:Host@564,registry:Host@700,registry:Host@791,registry:Platform@836,registry:Socket@801,registry:Socket@904,registry:remote@47,registry:remote@77,registry:sql@207,whole:Route@128,whole:Route@136,whole:Route@181,whole:Route@214,whole:Route@636,whole:Route@727,whole:Route@819,whole:Route@866,whole:Route@874,whole:Route@951,whole:remoteClient@49,whole:remoteClient@79 33844302d6d4886e5f553f562f0834dd551c4e1697db22fb00dcd2f29c6aacd8
@coverage internal/host e83cad942dd3c2a13525e73253ada346f14a62881de66142048a924b39f7327d
-@coverage internal/registry f43a10db6213cc832be08bc7cecdbf2793b50d09ddb940a4ed08d68c6970c42f
+@coverage internal/registry 35523d2fb75a87ca5614a1a2d74a6a1ddee55b1fed93a2fa2de2c18bb52cd1b1
diff --git a/internal/registry/aliassocket.go b/internal/registry/aliassocket.go
index b96881e3a..3c0fb0e6a 100644
--- a/internal/registry/aliassocket.go
+++ b/internal/registry/aliassocket.go
@@ -50,11 +50,13 @@ func LayoutSibling(host, socket string) string {
}
dir, base := filepath.Dir(socket), filepath.Base(socket)
id := layoutInstanceID(host)
+ // The nested shape first: for the host "app" its nested socket's base
+ // name is also host+".sock" (Astra r1 P2).
switch {
- case base == host+".sock":
- return filepath.Join(dir, "instances", id, "app.sock")
case base == "app.sock" && filepath.Base(dir) == id && filepath.Base(filepath.Dir(dir)) == "instances":
return filepath.Join(filepath.Dir(filepath.Dir(dir)), host+".sock")
+ case base == host+".sock":
+ return filepath.Join(dir, "instances", id, "app.sock")
}
return ""
}
diff --git a/internal/registry/aliassocket_test.go b/internal/registry/aliassocket_test.go
index eebdbcea0..f5cbc84b6 100644
--- a/internal/registry/aliassocket_test.go
+++ b/internal/registry/aliassocket_test.go
@@ -143,6 +143,8 @@ func TestLayoutSibling(t *testing.T) {
{aliasSrc, "/run/carlos/instances/other.example.com/app.sock", ""},
{aliasSrc, "/run/carlos/other.example.com.sock", ""},
{aliasSrc, "", ""},
+ {"app", "/run/carlos/app.sock", "/run/carlos/instances/app/app.sock"},
+ {"app", "/run/carlos/instances/app/app.sock", "/run/carlos/app.sock"},
{"", "/run/carlos/.sock", ""},
} {
if got := LayoutSibling(tc.host, tc.sock); got != tc.want {