carlos / platform Public

activator: unpinned live-link launches publish unknown inputs

With no LiveExecGate, a flat or nested live-link launch reads the
link's version and then runs the mutable link, so a repoint between
the two would label the new build with the old one's fingerprint.
Such launches now carry unknown inputs, so the host's pages bypass.
Gated and staged launches, which run a file resolved once, keep
theirs. The Service's ordinary exec wake is pinned (StartGenExe on
the settled identity), so it is unaffected.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev caa38c88c922d7eed0b5d516a4b01914c805b876 parent bfbd844
2 files changed, +167 −48
  • internal/activator/backend_exec.go +25 −10
  • internal/activator/inputs_test.go +142 −38

CI failed — run details

Intent

Human

<task-notification> <task-id>a25dffddbef0516f2</task-id> <tool-use-id>toolu_018VyLR7HrtvtLftvqwBkJ3X</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/d79ef2b4-4291-4945-bd45-b3f16796c4ba/tasks/a25dffddbef0516f2.output</output-file> <status>completed</status> <summary>Agent "Implement Task 6: current and launch inputs" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>Status: DONE. Each process now records the inputs it was started from and hands them to the edge cache only when it becomes current. Every scratch directory I created is gone, and nothing I started is still running. Commit: `bfbd844e activator: current inputs and per-process launch inputs, published when current` Tests: the brief's `go test ./internal/activator` run passes, covering all the brief's tests (`TestStagedSuccessorPublishesAtSwitch` covers flat, native nested and rootfs) plus 2 I added. `-run 'Purge|Gen|Swap'` passes, as do the exec-gate, rootfs, nested, recovery and StartGen runs, the edge `Cache|Purge|Control` run, `go build ./...`, and the darwin/windows builds. 7 deliberate code breakages each failed the tests they should. Concerns: 1. Beyond the brief: the cache key also includes ctime, and a file changed in the last 2 s is re-read rather than cached (the escrow's existing rule). For stateless rows, `CurrentInputs` drops `CARLOS_DB` the way the spawn does; without that they could never match. 2. Live-link spawns without `LiveExecGate` read the build name just before exec, with the same tiny race as existing code: a repoint in that window labels the process with the older build. With the gate set, the build is exact. 3. `rt.Version` must be the same string as the versions directory name, or pages never store. That is safe but silent, so it is worth checking on a real box in Task 10. 4. Nested and rootfs spawns publish only when they become current, not at spawn: their existing purge also runs for staged successors, so publishing there would expose a successor's inputs before the switch. A process whose inputs are unknown clears the host's entry, so its pages bypass. Stateless follower-escrow and HA hosts never match, which is safe. 5. Cross-OS `go vet` fails on darwin/windows in two test files I did not touch (`stateless_fix2_test.go`, `activator_test.go`). The cross-builds pass. Report: /home/paulca/amadan.net/carlos/platform/.claude/worktrees/edge-page-cache-1/.superpowers/sdd/2026-11-08-edge-page-cache-plan-1-home/task-6-report.md</result> <usage><subagent_tokens>251246</subagent_tokens><tool_uses>85</tool_uses><duration_ms>1382868</duration_ms></usage> </task-notification>

Human

<task-notification> <task-id>b1pguvivw</task-id> <tool-use-id>toolu_013WKk6fSp1jA2cSXd3N2sDi</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/d79ef2b4-4291-4945-bd45-b3f16796c4ba/tasks/b1pguvivw.output</output-file> <status>completed</status> <summary>Background command "Run Astra review of Task 6" completed (exit code 0)</summary> </task-notification>

Attributed to this commit: 26.2 g CO₂e (3,378,480 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on edge-page-cache-1, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/internal/activator/backend_exec.go b/internal/activator/backend_exec.go
index 0a26c8356..73978417e 100644
--- a/internal/activator/backend_exec.go
+++ b/internal/activator/backend_exec.go
@@ -2357,9 +2357,10 @@ func (b *ExecBackend) killGenAfterFailedStart(ctx context.Context, rt registry.R
// deadline and the termination. tier is that artifact's own tier; zero is
// the live tier (b.tier). n is the generation number plan 2's containment
// places the child by. build is the version a staged exe is (its
-// generation's Build); the live link's is resolved here. The process
-// carries its launch inputs (launchInputs) over that build and the env
-// read below, and a live-link spawn publishes them at once, as it purges.
+// generation's Build). The process carries its launch inputs
+// (launchInputs) over the build it runs and the env read below, unknown
+// for an exec of the unpinned live link, and a live-link spawn publishes
+// them at once, as it purges.
func (b *ExecBackend) spawnChildFrom(ctx context.Context, rt registry.Route, sock string, n uint64, exe, build string, tier cgroup.Limit) (Proc, string, error) {
host := rt.Host
paths := b.pathsFor(rt)
@@ -2516,6 +2517,11 @@ func (b *ExecBackend) spawnChildFrom(ctx context.Context, rt registry.Route, soc
// cannot be resolved fails the wake, as a missing one does. With the gate
// nil this is today's read and today's exec of the link.
spawnVer := ""
+ // pinnedVer is the build this spawn execs by a path it resolved once:
+ // the gate's resolved file below. "" when the spawn execs the mutable
+ // live link, whose spawnVer read can name a build other than the one
+ // the kernel resolves at the exec.
+ pinnedVer := ""
var liveGate func() error
if exe == "" && b.LiveExecGate != nil {
id, err := release.ResolveLivePath(b.OptDir, host)
@@ -2525,20 +2531,25 @@ func (b *ExecBackend) spawnChildFrom(ctx context.Context, rt registry.Route, soc
}
return nil, "", fmt.Errorf("%s: %w", host, err)
}
- bin, spawnVer = id.StagedPath, id.Version
+ bin, spawnVer, pinnedVer = id.StagedPath, id.Version, id.Version
liveGate = func() error { return b.LiveExecGate(rt, id.Version) }
} else if exe == "" {
spawnVer, _ = b.LiveVersion(host)
}
// The page cache's launch inputs (inputs.go): computed once, here,
// from the env this spawn read (fileEnv, before any agent-owned
- // variable) and the build it is about to exec. A live-link spawn names
- // the build it resolved above, a staged one the build its caller named.
+ // variable) and the build it is about to exec. They must name the
+ // build that actually runs, since they authorize page storage: a
+ // staged spawn's is the build its caller named for the file it execs
+ // by path, and a gated live-link spawn's is the file it resolved once
+ // and execs by path. An unpinned live-link spawn (no gate) execs the
+ // link itself, which root can repoint between the spawnVer read and
+ // the exec, so its inputs are unknown (""): its host's pages bypass.
// Never recomputed: a file rewritten after this read is not what the
// process was handed.
ranBuild := build
if exe == "" {
- ranBuild = spawnVer
+ ranBuild = pinnedVer
}
inputs := launchInputs(ranBuild, fileEnv)
// Spawned through the cgroup manager (nil-tolerant: no delegation means
@@ -2591,7 +2602,8 @@ func (b *ExecBackend) spawnChildFrom(ctx context.Context, rt registry.Route, soc
// becomes current (noteCurrent).
if b.Cache != nil && exe == "" {
// The live link's process is the host's only one: it is current
- // from here, so the inputs it was started from are the host's.
+ // from here, so the inputs it was started from are the host's. An
+ // unpinned exec's are unknown, which withdraws the host's.
b.Cache.NoteProcessInputs(rt.Host, inputs)
// A fresh process for this host is exactly the moment its cached
// content becomes suspect: a deploy/redeploy means new code and
@@ -2787,8 +2799,11 @@ func (b *ExecBackend) spawnUnitFrom(ctx context.Context, rt registry.Route, sock
}
// The page cache's launch inputs (inputs.go), once, from this read's
// env and the build root is asked to bind: a staged or pinned exe's
- // own version, else the live link's, read just above.
- ranBuild := spawnVer
+ // own version, which root validates and binds in place of the link.
+ // With no exe root binds the mutable live link, which can move after
+ // the spawnVer read above, so the inputs are unknown ("") and the
+ // host's pages bypass.
+ ranBuild := ""
if exe != nil {
ranBuild = exe.Version
}
diff --git a/internal/activator/inputs_test.go b/internal/activator/inputs_test.go
index fd4c6dc4e..99459b4eb 100644
--- a/internal/activator/inputs_test.go
+++ b/internal/activator/inputs_test.go
@@ -10,6 +10,7 @@ import (
"time"
"github.com/carlosframework/platform/internal/appconfig"
+ "github.com/carlosframework/platform/internal/cgroup"
"github.com/carlosframework/platform/internal/edge"
"github.com/carlosframework/platform/internal/registry"
"github.com/carlosframework/platform/internal/release"
@@ -285,7 +286,9 @@ func TestCurrentInputsStatCache(t *testing.T) {
// R3-2: the published inputs are the fingerprint of the env the spawn
// captured, never a re-read. The config file is replaced after the
-// capture and before the exec.
+// capture and before the exec. The wake is the Service's own path for an
+// exec row: the live link resolved once (LiveIdentity) and that file run
+// by path (StartGenExe), published as noteCurrent publishes it.
func TestLaunchInputsUseCapturedEnv(t *testing.T) {
requireUnixSockets(t)
k := newInputsKit(t)
@@ -293,16 +296,11 @@ func TestLaunchInputsUseCapturedEnv(t *testing.T) {
stageServingLiveAt(t, k.b, k.rt.Host, "v1")
k.deliver(t, map[string]string{"LOG_LEVEL": "debug"})
k.b.launchHook = onCall(1, func() { k.deliver(t, map[string]string{"LOG_LEVEL": "info"}) })
- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
- defer cancel()
- proc, _, err := k.b.Start(ctx, k.rt)
- if err != nil {
- t.Fatalf("Start: %v", err)
- }
+ proc := pinnedWake(t, k.b, k.rt)
defer proc.Stop(context.Background())
published, ok := k.b.Cache.ProcessInputs(k.rt.Host)
if !ok {
- t.Fatal("the spawn published no inputs")
+ t.Fatal("the wake published no inputs")
}
if cur := mustCurrent(t, k.b, k.rt); published == cur {
t.Fatalf("the published inputs %q equal the config delivered after the capture", published)
@@ -315,6 +313,26 @@ func TestLaunchInputsUseCapturedEnv(t *testing.T) {
}
}
+// pinnedWake is the Service's wake of an exec row on the real backend: the
+// identity step resolves the live link once (LiveIdentity), StartGenExe
+// runs that file by path and waits for health, and the install publishes
+// the process's inputs (noteCurrent's publishLaunchInputs).
+func pinnedWake(t *testing.T, b *ExecBackend, rt registry.Route) Proc {
+ t.Helper()
+ ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+ defer cancel()
+ id, err := b.LiveIdentity(ctx, rt)
+ if err != nil {
+ t.Fatalf("LiveIdentity: %v", err)
+ }
+ proc, _, err := b.StartGenExe(ctx, rt, nextGen(), true, id)
+ if err != nil {
+ t.Fatalf("StartGenExe: %v", err)
+ }
+ b.publishLaunchInputs(rt, proc)
+ return proc
+}
+
// R3-2: a generation whose build is not the installed one publishes inputs
// that never equal the current ones.
func TestRetainedBuildNeverMatches(t *testing.T) {
@@ -352,9 +370,12 @@ func TestRetainedBuildNeverMatches(t *testing.T) {
}
}
-// A fresh spawn on the live link publishes, at the spawn, inputs equal to
-// CurrentInputs: the current side reads and fingerprints the same two
-// layers the same way.
+// A fresh spawn publishes inputs equal to CurrentInputs: the current side
+// reads and fingerprints the same two layers the same way. Both pinned
+// paths: the Service's wake (the live link resolved once and run by path,
+// published at noteCurrent), and a gated live-link spawn (LiveExecGate
+// set: it resolves the link once and execs that file), which publishes at
+// the spawn.
func TestNonStagedSpawnPublishesInputs(t *testing.T) {
requireUnixSockets(t)
k := newInputsKit(t)
@@ -362,31 +383,119 @@ func TestNonStagedSpawnPublishesInputs(t *testing.T) {
stageServingLiveAt(t, k.b, k.rt.Host, "v1")
k.deliver(t, map[string]string{"LOG_LEVEL": "debug"})
writeOwnEnv(t, k.b, k.rt, "OWN=1\n")
- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
- defer cancel()
- proc, ver, err := k.b.Start(ctx, k.rt)
- if err != nil {
- t.Fatalf("Start: %v", err)
- }
- defer proc.Stop(context.Background())
- if ver != "v1" {
- t.Fatalf("spawn version %q, want v1", ver)
- }
- published, ok := k.b.Cache.ProcessInputs(k.rt.Host)
- if !ok {
- t.Fatal("a live-link spawn published no inputs")
- }
- if cur := mustCurrent(t, k.b, k.rt); published != cur {
- t.Fatalf("published %q, current %q: a fresh spawn with nothing changed must match", published, cur)
- }
- if procLaunchInputs(proc) != published {
- t.Fatalf("the process carries %q, published %q", procLaunchInputs(proc), published)
- }
+
+ t.Run("wake", func(t *testing.T) {
+ k.b.Cache.NoteProcessInputs(k.rt.Host, "")
+ proc := pinnedWake(t, k.b, k.rt)
+ defer proc.Stop(context.Background())
+ published, ok := k.b.Cache.ProcessInputs(k.rt.Host)
+ if cur := mustCurrent(t, k.b, k.rt); !ok || published != cur {
+ t.Fatalf("published %q, %v; current %q: a fresh wake with nothing changed must match", published, ok, cur)
+ }
+ })
+ t.Run("gated live link", func(t *testing.T) {
+ k.b.Cache.NoteProcessInputs(k.rt.Host, "")
+ k.b.LiveExecGate = func(registry.Route, string) error { return nil }
+ defer func() { k.b.LiveExecGate = nil }()
+ ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+ defer cancel()
+ proc, ver, err := k.b.Start(ctx, k.rt)
+ if err != nil {
+ t.Fatalf("Start: %v", err)
+ }
+ defer proc.Stop(context.Background())
+ if ver != "v1" {
+ t.Fatalf("spawn version %q, want v1", ver)
+ }
+ published, ok := k.b.Cache.ProcessInputs(k.rt.Host)
+ if !ok {
+ t.Fatal("a gated live-link spawn published no inputs at the spawn")
+ }
+ if cur := mustCurrent(t, k.b, k.rt); published != cur {
+ t.Fatalf("published %q, current %q: a fresh spawn with nothing changed must match", published, cur)
+ }
+ if procLaunchInputs(proc) != published {
+ t.Fatalf("the process carries %q, published %q", procLaunchInputs(proc), published)
+ }
+ })
+}
+
+// Task 6 review (Important): launch inputs must name the build that runs.
+// With no LiveExecGate a live-link spawn reads the link's version, then
+// execs the mutable link, so root repointing it between the two would run
+// v2 under v1's fingerprint, which the edge would accept while rt.Version
+// is still v1. Such a spawn publishes unknown inputs, withdrawing the
+// host's. A gated spawn resolves the link once and execs that file: the
+// repoint changes neither what runs nor what is published.
+func TestLiveLinkRepointBeforeExecPublishesNoInputs(t *testing.T) {
+ requireUnixSockets(t)
+ t.Run("flat unpinned", func(t *testing.T) {
+ b, rt, _, v2, out := flatLiveFixture(t)
+ rt.Version = "v1"
+ b.Cache = edge.NewCache(10, 1<<20)
+ b.Cache.NoteProcessInputs(rt.Host, "an earlier process")
+ b.launchHook = onCall(1, func() { repointLive(t, b, rt.Host, v2) })
+ p, ver, err := b.spawnChildFrom(context.Background(), rt, rt.Socket, 0, "", "", cgroup.Limit{})
+ if err != nil {
+ t.Fatalf("spawn = %v", err)
+ }
+ defer p.Stop(context.Background())
+ if got := strings.TrimSpace(waitForFileContent(t, out, 5*time.Second)); got != b.liveLink(rt.Host) || ver != "v1" {
+ t.Fatalf("$0 = %q, version %q; want the live link exec'd, recorded as v1", got, ver)
+ }
+ if got := procLaunchInputs(p); got != "" {
+ t.Fatalf("an unpinned live-link spawn carries %q, want unknown", got)
+ }
+ if got, ok := b.Cache.ProcessInputs(rt.Host); ok {
+ t.Fatalf("ProcessInputs = %q after an unpinned spawn, want the host's withdrawn", got)
+ }
+ })
+ t.Run("flat gated", func(t *testing.T) {
+ b, rt, v1, v2, out := flatLiveFixture(t)
+ rt.Version = "v1"
+ b.Cache = edge.NewCache(10, 1<<20)
+ b.LiveExecGate = func(registry.Route, string) error { return nil }
+ b.launchHook = onCall(1, func() { repointLive(t, b, rt.Host, v2) })
+ p, _, err := b.spawnChildFrom(context.Background(), rt, rt.Socket, 0, "", "", cgroup.Limit{})
+ if err != nil {
+ t.Fatalf("spawn = %v", err)
+ }
+ defer p.Stop(context.Background())
+ if got := strings.TrimSpace(waitForFileContent(t, out, 5*time.Second)); got != v1 {
+ t.Fatalf("$0 = %q, want the resolved v1 %s", got, v1)
+ }
+ got, ok := b.Cache.ProcessInputs(rt.Host)
+ if want := mustCurrent(t, b, rt); !ok || got != want {
+ t.Fatalf("published %q, %v; want v1's inputs %q", got, ok, want)
+ }
+ moved := rt
+ moved.Version = "v2"
+ if got == mustCurrent(t, b, moved) {
+ t.Fatal("the gated spawn published the repointed build's inputs")
+ }
+ })
+ t.Run("nested unpinned", func(t *testing.T) {
+ ctl := &fakeControl{inv: "inv1"}
+ b, rt := nestedBackend(t, ctl, &fakeUnit{})
+ rt.Version = "v1"
+ p, ver, err := b.spawnUnitFrom(context.Background(), rt, rt.Socket, 0, nil, cgroup.Limit{})
+ if err != nil {
+ t.Fatalf("spawnUnitFrom = %v", err)
+ }
+ defer p.Stop(context.Background())
+ if ver != "v1" {
+ t.Fatalf("spawn version %q, want v1", ver)
+ }
+ if got := procLaunchInputs(p); got != "" {
+ t.Fatalf("a nested start of the unpinned live link carries %q, want unknown", got)
+ }
+ })
}
// Sleep, then wake with nothing changed: the second process publishes the
// inputs the first did (the admin token and instance key minted at the
-// first spawn are read by both).
+// first spawn are read by both). Each wake is the Service's own pinned
+// path (pinnedWake).
func TestWakeSameInputsSameValue(t *testing.T) {
requireUnixSockets(t)
k := newInputsKit(t)
@@ -395,12 +504,7 @@ func TestWakeSameInputsSameValue(t *testing.T) {
k.deliver(t, map[string]string{"LOG_LEVEL": "debug"})
wake := func() (Proc, string) {
t.Helper()
- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
- defer cancel()
- proc, _, err := k.b.StartGen(ctx, k.rt, nextGen(), true)
- if err != nil {
- t.Fatalf("StartGen: %v", err)
- }
+ proc := pinnedWake(t, k.b, k.rt)
got, ok := k.b.Cache.ProcessInputs(k.rt.Host)
if !ok {
t.Fatal("the wake published no inputs")