carlos / platform Public

host: install-channel holds the system replay floor before it installs

Checking main's new system-install paths against the hunt bindings:
install-channel (now also the group launch path) read the signed router
pointer and raised the replay floor (seen.json, seen-versions.json) when
it finished, but never checked it. A box that had followed a later
promote with no applied.json yet (an update cut off before it, or a
deferred no-op request) installed a saved older pointer a bucket writer
put back at the channel key, and moved its floor back to it.

install() now refuses a pointer systemSeenAdmits refuses (hunt H6-M11),
before anything is fetched, as systemApplier does. A fresh box has no
floor, so the bootstrap and group launch paths are unchanged.

Test: TestInstallChannelRefusesAPointerOlderThanTheBoxFollowed. It
failed before (the replayed v1.4.0 was installed) and passes now; the
pointer the box followed still installs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 21426d1af094be14afc93f3b5d74bf54735d9c7d parent ffbf463
2 files changed, +68 −4
  • internal/host/installchannel.go +21 −4
  • internal/host/installchannel_test.go +47 −0
diff --git a/internal/host/installchannel.go b/internal/host/installchannel.go
index ffb129abe..b13785ab3 100644
--- a/internal/host/installchannel.go
+++ b/internal/host/installchannel.go
@@ -12,6 +12,7 @@ import (
"path/filepath"
"runtime"
"strings"
+ "time"
"github.com/carlosframework/platform/internal/cliflag"
"github.com/carlosframework/platform/internal/hostfloor"
@@ -301,6 +302,24 @@ func (in channelInstall) install(ctx context.Context) (channelInstalled, error)
return channelInstalled{}, fmt.Errorf("the %s channel could not be read, so nothing was installed: %w", a.channel, err)
}
got := channelInstalled{Version: p.Current.Version, Tag: p.Current.ReleaseTag, Channel: a.channel}
+ // The replay floor (hunt H6-M11), held here as systemApplier holds it:
+ // a box that has followed a later promote (an update cut off before
+ // applied.json, or a no-op request that was deferred) is not installed
+ // from a saved older pointer put back at the channel key. The install
+ // raises the floor at its end (systemSeenAdvance), so letting such a
+ // pointer through would also move the floor back.
+ seen, err := readSystemSeen(a.optDir)
+ if err != nil {
+ return got, fmt.Errorf("this box's replay floor could not be read, so nothing was installed: %w", err)
+ }
+ versions, err := readSystemSeenVersions(a.optDir)
+ if err != nil {
+ return got, fmt.Errorf("this box's replay floor could not be read, so nothing was installed: %w", err)
+ }
+ if !systemSeenAdmits(seen, versions, a.channel, p) {
+ return got, fmt.Errorf("replay: the %s channel names %s promoted %s, not after the pointer this box already followed (%s promoted %s), so nothing was installed",
+ a.channel, p.Current.Version, p.PromotedAt.Format(time.RFC3339), versions[a.channel], seen[a.channel].Format(time.RFC3339))
+ }
var policy *hostfloor.Policy
var policyFloor hostfloor.Verified
if in.policy != nil {
@@ -455,12 +474,10 @@ func (in channelInstall) install(ctx context.Context) (channelInstalled, error)
return got, err
}
}
- seen, err := readSystemSeen(a.optDir)
- if err != nil {
+ if seen, err = readSystemSeen(a.optDir); err != nil {
return got, err
}
- versions, err := readSystemSeenVersions(a.optDir)
- if err != nil {
+ if versions, err = readSystemSeenVersions(a.optDir); err != nil {
return got, err
}
if err := systemSeenAdvance(a.optDir, seen, versions, a.channel, p); err != nil {
diff --git a/internal/host/installchannel_test.go b/internal/host/installchannel_test.go
index ec906d135..11ff8eb0d 100644
--- a/internal/host/installchannel_test.go
+++ b/internal/host/installchannel_test.go
@@ -583,3 +583,50 @@ func TestGroupInstallFloorObservation(t *testing.T) {
}
}
}
+
+// install-channel holds the channel to the box's replay floor (hunt H6-M11,
+// seen.json and seen-versions.json) as an update does: a box that has
+// already followed a later promote, with no applied.json (an update cut off
+// before it, or a forged no-op that was deferred), is not installed from a
+// saved older pointer a bucket writer put back at the channel key. Nothing
+// is fetched and both slots stay empty. The pointer the box followed still
+// installs.
+func TestInstallChannelRefusesAPointerOlderThanTheBoxFollowed(t *testing.T) {
+ f := newChannelFixture(t, "v1.2.0")
+ ctx := context.Background()
+ key := release.SystemPointerKey("router", "stable")
+ saved, _, err := f.store.Get(ctx, key)
+ if err != nil {
+ t.Fatal(err)
+ }
+ f.publish(t, "v1.5.0", []byte("#!/bin/sh\necho carlos v1.5.0\n"))
+ followed, err := f.a.verifyPointer(ctx)
+ if err != nil {
+ t.Fatal(err)
+ }
+ seen, _ := readSystemSeen(f.a.optDir)
+ versions, _ := readSystemSeenVersions(f.a.optDir)
+ if err := systemSeenAdvance(f.a.optDir, seen, versions, "stable", followed); err != nil {
+ t.Fatal(err)
+ }
+ head, etag, err := f.store.Get(ctx, key)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if etag, err = f.store.Put(ctx, key, saved, etag); err != nil {
+ t.Fatal(err)
+ }
+ _, err = f.in.run(ctx)
+ if err == nil || !strings.Contains(err.Error(), "replay") {
+ t.Fatalf("a replayed older pointer: %v, want a replay refusal", err)
+ }
+ if cur, prev := f.slots(t); cur != nil || prev != nil || f.fetches != 0 {
+ t.Fatalf("a replayed pointer was installed: %q %q after %d fetches", cur, prev, f.fetches)
+ }
+ if _, err := f.store.Put(ctx, key, head, etag); err != nil {
+ t.Fatal(err)
+ }
+ if got, err := f.in.run(ctx); err != nil || got.Version != "v1.5.0" {
+ t.Fatalf("the pointer the box followed: %+v %v", got, err)
+ }
+}