carlos / platform Public

Named-unit delivery: notices share delivery's classification, respect owned environments and the instance overlay; the stale-file line claims less (review round 1 P2-4 to P2-7)

P2-4. BlockedStamps and AwaitingRestart classified by Stamped while
delivery classifies by stampedForDelivery, so a unit-backed row with its
derived stamp was reported blocked and counted as a duplicate. Both use
stampedForDelivery now; SyncExec's stale-file notice too. Pinned by
TestAwaitingRestartUnitBackedStampIsNeitherBlockedNorADuplicate.

P2-5. Blocked was emitted before the owned-environment check, so a
default-bundle write reported a blocked stamp bound to a standalone team
environment it cannot reach. The door-side rails are computed over the
full box list as before, but a host is reported only once the loop has
applied the environment narrowing and the owned boundary; Blocked still
comes before bundle resolution, so a blocked route is never reported
unresolved. Pinned by TestAwaitingRestartBlockedStampRespectsAnOwnedEnvironment.

P2-6. A stamped route was called healthy before its instance overlay was
read, though the root pass refuses delivery when that overlay will not
read. The notice now loads it and reports a failure in Unresolved. Pinned
by TestAwaitingRestartStampedRouteWithACorruptOverlayIsUnresolved.

P2-7. The stale /data/<host>.config.env line said nothing reads the file
once the route is stamped, which the unmanaged-file guard shows is not
established. It now says exec delivery has stopped updating it, carlos
will never remove it, and what still reads it must be checked before it
is deleted (a human-readable string, for copy review).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

Summary

The set-time notice classifies stamped routes as delivery does, applies owned-environment reachability before reporting a blocked stamp, resolves a stamped route's instance overlay before calling it healthy, and the stale exec-delivery file line no longer claims nothing reads the file.
claude agent, operated by paul@keymail.dev 6e69c2fe03ae54311b472eb9ca2dcc674c9271a1 parent f3118c6
3 files changed, +118 −30
  • internal/appconfig/awaitingrestart_test.go +61 −0
  • internal/appconfig/syncexec.go +54 −28
  • internal/appconfig/syncexec_test.go +3 −2

CI failed — run details

diff --git a/internal/appconfig/awaitingrestart_test.go b/internal/appconfig/awaitingrestart_test.go
index a9c6f799e..565aa38a6 100644
--- a/internal/appconfig/awaitingrestart_test.go
+++ b/internal/appconfig/awaitingrestart_test.go
@@ -470,3 +470,64 @@ func TestAwaitingRestartBlockedStampsAreNarrowedToTheWrittenEnvironment(t *testi
t.Fatalf("Blocked = %+v, want both prod and staging for a default-bundle write", got.Blocked)
}
}
+
+// Review round 1 P2-4: delivery and its notices share one classification.
+// A unit-backed row carrying its derived stamp is delivered on the
+// carlos-app@ path (stampedForDelivery), so the socket and name rails do
+// not report it blocked, and it does not count toward another route's
+// duplicate-unit refusal.
+func TestAwaitingRestartUnitBackedStampIsNeitherBlockedNorADuplicate(t *testing.T) {
+ ctx, s, _, _, _, _ := execKit(t)
+ if err := SetEnv(ctx, s, "bab", "relay", map[string]string{"K": "v"}); err != nil {
+ t.Fatal(err)
+ }
+ unitBacked := registry.Route{Host: "km.example.com", Kind: "instance", App: "relay", Account: "bab", Status: "ready",
+ Backing: registry.BackingUnit, Socket: "/run/carlos/apps/km.example.com.sock", Unit: "carlos-app@km.example.com.service"}
+ twin := unitBacked
+ twin.Host, twin.Socket, twin.Backing, twin.Addr = "twin.example.com", "", "", "127.0.0.1:1"
+ twin.Unit = "shared.service"
+ shadow := unitBacked
+ shadow.Host, shadow.Unit = "shadow.example.com", "shared.service"
+ got := AwaitingRestart(ctx, s, []registry.Route{unitBacked, twin, shadow}, "bab", "relay", "", []string{"K"})
+ if len(got.Blocked) != 0 {
+ t.Fatalf("Blocked = %+v, want none: a unit-backed stamp is not the by-unit path's and must not count as its duplicate", got.Blocked)
+ }
+}
+
+// Review round 1 P2-5: a blocked stamped route bound to an OWNED
+// environment is reported only by a write that reaches it, never by a
+// default-bundle write.
+func TestAwaitingRestartBlockedStampRespectsAnOwnedEnvironment(t *testing.T) {
+ ctx, s, _ := ownedWorld(t)
+ rt := registry.Route{Host: "one.docs.example", Kind: "instance", App: "docs", Account: "bab", Status: "ready",
+ Socket: "/run/one.sock", Environment: "team", Unit: "docs.service"}
+ if got := AwaitingRestart(ctx, s, []registry.Route{rt}, "bab", "docs", "", []string{"OWNER_CANARY"}); !got.Empty() {
+ t.Fatalf("a default-bundle write reported a route on an owned environment: %+v", got)
+ }
+ got := AwaitingRestart(ctx, s, []registry.Route{rt}, "bab", "docs", "team", []string{"TEAM_ONLY"})
+ if len(got.Blocked) != 1 || got.Blocked[0].Host != "one.docs.example" || !strings.Contains(got.Blocked[0].Reason, "socket") {
+ t.Fatalf("the owned bundle's own write must report the blocked stamp: %+v", got)
+ }
+}
+
+// Review round 1 P2-6: the root pass loads a stamped route's instance
+// overlay and refuses delivery when it will not read, so the notice must
+// not call such a route healthy.
+func TestAwaitingRestartStampedRouteWithACorruptOverlayIsUnresolved(t *testing.T) {
+ ctx, s, _, _, _, _ := execKit(t)
+ if err := SetEnv(ctx, s, "bab", "relay", map[string]string{"K": "v"}); err != nil {
+ t.Fatal(err)
+ }
+ rt := addrRoute("relay.example.com", "relay", "bab", "")
+ rt.Unit = "relay.service"
+ if got := AwaitingRestart(ctx, s, []registry.Route{rt}, "bab", "relay", "", nil); !got.Empty() {
+ t.Fatalf("healthy stamped route must be silent, got %+v", got)
+ }
+ if _, err := s.Put(ctx, InstancesConfigPrefix("bab", "relay")+"relay.example.com.json", []byte("{"), ""); err != nil {
+ t.Fatal(err)
+ }
+ got := AwaitingRestart(ctx, s, []registry.Route{rt}, "bab", "relay", "", nil)
+ if len(got.Unresolved) != 1 || got.Unresolved[0] != "relay.example.com" || len(got.Blocked) != 0 || len(got.Hosts) != 0 {
+ t.Fatalf("a stamped route with a corrupt overlay must be Unresolved, got %+v", got)
+ }
+}
diff --git a/internal/appconfig/syncexec.go b/internal/appconfig/syncexec.go
index 89b500c98..55669f900 100644
--- a/internal/appconfig/syncexec.go
+++ b/internal/appconfig/syncexec.go
@@ -725,22 +725,24 @@ func SyncExecWithCallbacks(ctx context.Context, reg *registry.Registry, s releas
continue // nothing was ever staged for this route: nothing to warn about
}
fmt.Printf(" %s: exec_delivery is off (or was never set) but %s still exists from an earlier opt-in — it holds DECRYPTED secrets and carlos will never update or remove it while this app stays un-opted-in; delete it by hand once the app's own supervisor has stopped reading it\n", rt.Host, path)
- case Stamped(rt):
+ case stampedForDelivery(rt):
// A route can gain a unit stamp AFTER exec delivery already
// staged this file (the test above this comment's home,
// TestSyncExecLeavesAStampedRoutesOldFileAlone, does exactly
// that): execAddrCandidate excludes it the moment it is
// stamped, so the opt-out branch above never sees it again and
// stays silent forever. The same "frozen, not updated" fact is
- // true here for a different reason — the unit's drop-in now
- // owns EnvironmentFile, so nothing even reads this file — and
- // it deserves the same one-line-per-pass notice rather than
- // silence.
+ // true here and deserves the same one-line-per-pass notice.
+ // What this line does NOT claim is that nothing reads the file:
+ // a unit still loading it is exactly what the root pass's
+ // unmanaged-file guard refuses (unitsync.go, planStamped), and
+ // the stamp alone is no evidence the unit moved off it (review
+ // round 1 P2-7).
path := ConfigEnvPath(dataDir, rt)
if _, err := os.Stat(path); err != nil {
continue // nothing was ever staged for this route: nothing to warn about
}
- fmt.Printf(" %s: %s is from before this route named its unit; nothing reads it now (the unit's drop-in resets its EnvironmentFile list) and carlos will never update or remove it — delete it once you are satisfied\n", rt.Host, path)
+ fmt.Printf(" %s: %s was written by exec delivery before this route named its unit; exec delivery has stopped updating it and carlos will never remove it. Check what still reads it before deleting it\n", rt.Host, path)
}
}
// An empty route list is never authority to delete anything —
@@ -1089,24 +1091,28 @@ func (r RestartPending) Empty() bool {
}
// BlockedStamps applies the door-side rails to the stamped routes of
-// (acct, app) in routes. Uniqueness is checked against the FULL list
-// regardless of envName, so a route of another account or another
+// (acct, app) in routes, the routes planStamped would deliver
+// (stampedForDelivery, the one classification for delivery and its
+// notices; review round 1 P2-4). Uniqueness is checked against the FULL
+// list regardless of envName, so a route of another account or another
// environment still blocks this one's unit — but only this account's
// hosts are returned, no other account's host is named in a reason, and
// (spec §3.4: "the same environment and account narrowing applies as for
// Hosts") only routes bound to envName ("" = every route of the app) are
// returned, so a write to one environment does not report a blocked route
-// it never reached.
+// it never reached. Owned-environment reachability is AwaitingRestart's
+// (it needs the bundle), which is why the notice applies it before taking
+// a host from here.
func BlockedStamps(routes []registry.Route, acct, app, envName string) []BlockedHost {
byUnit := map[string]int{}
for _, rt := range routes {
- if Stamped(rt) && StampShape(rt) == nil && DeliverableUnitName(rt.Unit) == nil && BareHostname(rt.Host) {
+ if stampedForDelivery(rt) && StampShape(rt) == nil && DeliverableUnitName(rt.Unit) == nil && BareHostname(rt.Host) {
byUnit[rt.Unit]++
}
}
var out []BlockedHost
for _, rt := range routes {
- if !Stamped(rt) || rt.App != app || release.RouteAccount(rt) != acct {
+ if !stampedForDelivery(rt) || rt.App != app || release.RouteAccount(rt) != acct {
continue
}
if envName != "" && rt.Environment != envName {
@@ -1156,10 +1162,13 @@ func BlockedStamps(routes []registry.Route, acct, app, envName string) []Blocked
// short list read as a complete one.
func AwaitingRestart(ctx context.Context, s release.Store, routes []registry.Route, acct, app, envName string, keys []string) RestartPending {
var out RestartPending
- out.Blocked = BlockedStamps(routes, acct, app, envName)
- blocked := map[string]bool{}
- for _, b := range out.Blocked {
- blocked[b.Host] = true
+ // The door-side rails over the full box list; a blocked host is
+ // reported only once the loop below has established that this write
+ // reaches it (environment narrowing, and an owned environment's
+ // standalone boundary; review round 1 P2-5).
+ blocked := map[string]string{}
+ for _, b := range BlockedStamps(routes, acct, app, envName) {
+ blocked[b.Host] = b.Reason
}
// The instance layer, through the same loader the sweeps use, so this
// notice and the pass that writes the files agree about what sits above
@@ -1198,7 +1207,7 @@ func AwaitingRestart(ctx context.Context, s release.Store, routes []registry.Rou
return e
}
for _, rt := range routes {
- stamped := Stamped(rt) && !blocked[rt.Host]
+ stamped := stampedForDelivery(rt)
if (!execAddrCandidate(rt) && !stamped) || rt.App != app || release.RouteAccount(rt) != acct {
continue
}
@@ -1214,6 +1223,26 @@ func AwaitingRestart(ctx context.Context, s release.Store, routes []registry.Rou
def := loadDefault
if rt.Environment != "" {
eb = loadEnv(rt.Environment)
+ // An OWNED environment is standalone (team-scoped credentials
+ // §3): a default-bundle write reaches none of its routes, and
+ // its opt-in never inherits the default bundle's. Decided
+ // before the blocked notice, which is about routes the write
+ // reaches; a bundle that cannot be read decides nothing here.
+ if eb.err == nil && eb.found && eb.m.Owned() {
+ if envName == "" {
+ continue
+ }
+ def = standaloneDefault
+ }
+ }
+ // Blocked is decided before bundle resolution (spec §3.4): a route
+ // the root pass will refuse is reported as blocked, not as healthy
+ // and not as unresolved.
+ if reason, bad := blocked[rt.Host]; bad {
+ out.Blocked = append(out.Blocked, BlockedHost{Host: rt.Host, Reason: reason})
+ continue
+ }
+ if rt.Environment != "" {
if eb.err != nil {
out.Unresolved = append(out.Unresolved, rt.Host)
continue
@@ -1227,15 +1256,6 @@ func AwaitingRestart(ctx context.Context, s release.Store, routes []registry.Rou
out.Unresolved = append(out.Unresolved, rt.Host)
continue
}
- // An OWNED environment is standalone (team-scoped credentials
- // §3): a default-bundle write reaches none of its routes, and
- // its opt-in never inherits the default bundle's.
- if eb.m.Owned() {
- if envName == "" {
- continue
- }
- def = standaloneDefault
- }
}
v, err := resolveExecDelivery(eb.m, eb.found, def)
if err != nil {
@@ -1243,10 +1263,15 @@ func AwaitingRestart(ctx context.Context, s release.Store, routes []registry.Rou
continue
}
// A stamped route is delivered and restarted by the root pass within
- // seconds of this write; it has nothing to be told about unless its
- // bundle would not resolve, which the checks above have already
- // reported (spec §3.4, codex R1-8).
+ // seconds of this write; it has nothing to be told about unless a
+ // layer it is rendered from would not resolve. The bundles were
+ // checked above; the instance overlay is checked here, because the
+ // root pass loads it for a stamped route and refuses delivery when
+ // it will not read (sync.go; review round 1 P2-6).
if stamped {
+ if _, _, instErr := overlayFor(acct, app, rt.Host); instErr != nil {
+ out.Unresolved = append(out.Unresolved, rt.Host)
+ }
continue
}
// Not opted in — including the Unknown case, which decides "off" —
@@ -1291,6 +1316,7 @@ func AwaitingRestart(ctx context.Context, s release.Store, routes []registry.Rou
// across passes, where registry order is not. Same discipline as
// ExecConfigApps'.
sort.Slice(out.Hosts, func(i, j int) bool { return out.Hosts[i].Host < out.Hosts[j].Host })
+ sort.Slice(out.Blocked, func(i, j int) bool { return out.Blocked[i].Host < out.Blocked[j].Host })
sort.Strings(out.Unresolved)
sort.Strings(out.Undelivered)
return out
diff --git a/internal/appconfig/syncexec_test.go b/internal/appconfig/syncexec_test.go
index 1ea2759d0..329e8e30b 100644
--- a/internal/appconfig/syncexec_test.go
+++ b/internal/appconfig/syncexec_test.go
@@ -2784,8 +2784,9 @@ func TestSyncExecLeavesAStampedRoutesOldFileAlone(t *testing.T) {
// The frozen-secrets warning must still fire once the route is
// stamped, not just for the exec opt-out shape it was written for
// (final review item B): this file still holds decrypted secrets and
- // carlos still won't ever touch it again.
- if !strings.Contains(out, "relay.example.com") || !strings.Contains(out, "never update or remove") {
+ // carlos still won't ever touch it again. It must not claim nothing
+ // reads the file (review round 1 P2-7).
+ if !strings.Contains(out, "relay.example.com") || !strings.Contains(out, "stopped updating it") || !strings.Contains(out, "before deleting it") || strings.Contains(out, "nothing reads it") {
t.Fatalf("no stamped-route frozen-secrets notice for relay.example.com: %q", out)
}
}