carlos / platform Public

Direct secrets set seals only to the published deployment key (branch review R1)

Direct-mode carlos secrets set looked for the terminal key among the fleet
owner records, and a fleet could register that key after the look and
before the write (I1). Per Paul's ruling, it now also requires the key to
match the deployment's own secrets key as the console publishes it at
control/moves-console.json, a key fleet registration refuses. With no
console record it seals only while the bucket holds no fleet owner record;
a record it cannot read refuses.

The console now publishes that record at every start when it has a
secrets key, with the moves switch off too; a keyless console with the
switch off still publishes nothing. The record's shape is unchanged.

Spec 5.3 and 7 say so.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev e53c854ad0ad93212fa9dadb586541b94fbfa756 parent 75f1dfa
10 files changed, +317 −32
  • appconfig_cli.go +40 −0
  • appconfig_cli_fleet_test.go +192 −4
  • cmd/console/main.go +2 −2
  • docs/superpowers/specs/2026-10-29-fleet-secrets-key-design.md +11 −3
  • internal/console/claim_invariant_fixtures_test.go +1 −1
  • internal/console/claim_invariant_moves_test.go +33 −6
  • internal/console/claim_workers.go +3 −3
  • internal/console/movesconsole_test.go +16 −4
  • internal/console/server.go +15 −6
  • internal/moves/floor.go +4 −3

Intent

Human

<task-notification> <task-id>byv3eztun</task-id> <tool-use-id>toolu_015ACQPp9P9mGkS8UWnj8YSj</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/2d812478-ae68-44f2-8075-b2330abd5939/tasks/byv3eztun.output</output-file> <status>completed</status> <summary>Background command "Wait for CI verdict on new tip" completed (exit code 0)</summary> </task-notification>

Human

<task-notification> <task-id>a764d07ffa82cdc36</task-id> <tool-use-id>toolu_01SuvszGvJVJQXbdoDmNkxvB</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/2d812478-ae68-44f2-8075-b2330abd5939/tasks/a764d07ffa82cdc36.output</output-file> <status>completed</status> <summary>Agent "Branch review R1 fix wave" 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. Five items fixed in six commits, unpushed, tip 75f1dfa9. The direct-mode P1 is untouched; it still waits on Paul's ruling. **Commits:** - e723c94a: a key's fingerprint now stays reserved to the fleet that registered it, even after replacement. - 0ca4cc2f: the seal guard allows Sealer field reads only in its five named methods, field writes only in `NewSealer`, and now walks every .go file so a darwin-only package is seen. - 8868a123: the seed copy's account lock is released by a defer, so a panic no longer keeps it. - 3b93618a: plan storage now applies the deny to a keyless-fleet app whose store is healthy, without minting a credential. - 5113d057: spec §7 request costs corrected, plus the Rev 5 note under the status line. - 75f1dfa9: census re-proposed (new seal `353a115c...`); the 9B8 pin for `runFrom` updated. **Tests:** every new test failed first and passes now. The two security fixes also fail when I remove them: skipping the reservation insert breaks the registry and console witnesses, and loosening the guard back breaks it. The same goes for the plan-storage healthy check. I also checked the darwin-only coverage with a temporary probe package, since deleted. The registry Fleet tests, the console fleet-key, guard, seed, plan-storage and storage-deny tests, and `go test ./internal/provision/ -run 'Census|Plan14|Plan9'` all pass. Builds pass for linux, darwin, windows and linux/arm64; vet and gofmt are clean. **Concerns:** - The census reviewer needs a fresh verdict on the re-proposed `migrateFleets` and `SetFleetSecretsKey`, and on the `runFrom` re-pin. - The reservation is keyed by fleet name, as briefed. `UpsertFleet` can change a fleet's account, and the reservation would follow the name. That behaviour was already there; this change doesn't add it. - When the registry refuses a reserved key, the other fleet's bucket owner record still lists that fingerprint (ruling R-4). Direct mode refuses any listed fingerprint, so this is the safe side. The full write-up, with RED/GREEN output, mutations and census details, is in `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-secrets-key/.superpowers/sdd/2026-10-29-fleet-secrets-key/branch-r1-fix-report.md`.</result> <usage><subagent_tokens>207876</subagent_tokens><tool_uses>79</tool_uses><duration_ms>1172644</duration_ms></usage> </task-notification>

diff --git a/appconfig_cli.go b/appconfig_cli.go
index e5ccb6432..cefa6a28e 100644
--- a/appconfig_cli.go
+++ b/appconfig_cli.go
@@ -19,6 +19,7 @@ import (
"strings"
"github.com/carlosframework/platform/internal/appconfig"
+ "github.com/carlosframework/platform/internal/moves"
"github.com/carlosframework/platform/internal/registry"
"github.com/carlosframework/platform/internal/release"
)
@@ -1040,7 +1041,19 @@ func runSecretsSet(args []string) {
// refuses too when it cannot list the bucket or read a record: a check that
// did not run is not a pass. The refusal for an owning account carries the
// literal "<app>", which the caller fills in.
+//
+// Those two look for a fleet key, and a fleet can register pub after they
+// read (branch review R1). So the check that decides is positive (Paul's
+// ruling, 2026-10-29): pub must be the deployment's own secrets key, as the
+// console publishes it at moves.ConsoleKey on every start, and fleet
+// registration refuses that key. With no such record there is no console to
+// name the key, so pub passes only while the bucket holds no fleet owner
+// record at all; a console never wrote one.
func directSealRefusal(ctx context.Context, st release.Store, acct string, pub *ecdh.PublicKey) error {
+ deploymentFP, err := directDeploymentFP(ctx, st)
+ if err != nil {
+ return errors.New(directRefuseNoCheck)
+ }
keys, err := st.List(ctx, "accounts/")
if err != nil {
return errors.New(directRefuseNoCheck)
@@ -1070,9 +1083,36 @@ func directSealRefusal(ctx context.Context, st release.Store, acct string, pub *
return errors.New(directRefuseFleetKey)
}
}
+ switch {
+ case deploymentFP != "":
+ if fp != deploymentFP {
+ return errors.New(directRefuseFleetKey)
+ }
+ case len(records) > 0:
+ return errors.New(directRefuseNoCheck)
+ }
return nil
}
+// directDeploymentFP reads the deployment key's fingerprint from the record
+// the console publishes at each start. An absent record, or one naming no
+// key, is "" with no error; a record that cannot be read or parsed is an
+// error.
+func directDeploymentFP(ctx context.Context, st release.Store) (string, error) {
+ body, _, err := st.Get(ctx, moves.ConsoleKey)
+ if errors.Is(err, os.ErrNotExist) {
+ return "", nil
+ }
+ if err != nil {
+ return "", err
+ }
+ var rec moves.ConsoleRecord
+ if err := json.Unmarshal(body, &rec); err != nil {
+ return "", err
+ }
+ return rec.SecretsKeyFP, nil
+}
+
// Fleet secrets key copy rows FSK-C48 to FSK-C50.
const (
directRefuseOwnsFleet = "this account owns a fleet, and a direct write cannot tell which key <app> needs. unset CARLOS_DEPLOYMENT_BUCKET and CARLOS_DEPLOYMENT_DIR in your terminal and run carlos secrets set through a signed-in console"
diff --git a/appconfig_cli_fleet_test.go b/appconfig_cli_fleet_test.go
index 12528443e..d55fcb0e8 100644
--- a/appconfig_cli_fleet_test.go
+++ b/appconfig_cli_fleet_test.go
@@ -10,8 +10,10 @@ import (
"path/filepath"
"strings"
"testing"
+ "time"
"github.com/carlosframework/platform/internal/appconfig"
+ "github.com/carlosframework/platform/internal/moves"
"github.com/carlosframework/platform/internal/release"
)
@@ -118,6 +120,15 @@ func TestDirectSecretsSetRefusesOnListError(t *testing.T) {
if err == nil || err.Error() != wantDirectRefuseNoCheck {
t.Fatalf("malformed record: err = %v, want %q", err, wantDirectRefuseNoCheck)
}
+ // And a console record that does not parse: no deployment key is named.
+ badConsole := release.NewDirStore(t.TempDir())
+ if _, err := badConsole.Put(context.Background(), moves.ConsoleKey, []byte("{not json"), ""); err != nil {
+ t.Fatal(err)
+ }
+ err = directSealRefusal(context.Background(), badConsole, "bab", directPub(t, b64))
+ if err == nil || err.Error() != wantDirectRefuseNoCheck {
+ t.Fatalf("malformed console record: err = %v, want %q", err, wantDirectRefuseNoCheck)
+ }
}
func TestDirectSecretsSetRefusesAnyListedFingerprint(t *testing.T) {
@@ -131,10 +142,12 @@ func TestDirectSecretsSetRefusesAnyListedFingerprint(t *testing.T) {
t.Errorf("%s fingerprint: err = %v, want %q", name, err, wantDirectRefuseFleetKey)
}
}
- // A key no fleet ever carried passes.
- otherB64, _ := directKey(t)
+ // A key no fleet ever carried passes when the console published it as
+ // the deployment's key.
+ otherB64, otherFP := directKey(t)
+ directConsoleRecord(t, st, otherFP)
if err := directSealRefusal(context.Background(), st, "bab", directPub(t, otherB64)); err != nil {
- t.Errorf("an unlisted key was refused: %v", err)
+ t.Errorf("the published deployment key was refused: %v", err)
}
}
@@ -156,9 +169,12 @@ func TestDirectSecretsSetPlatformAppStillWorks(t *testing.T) {
t.Fatal(err)
}
directSetEnv(t, dir, pubB64)
- // Another account owns a fleet with some other key: no bearing.
+ // Another account owns a fleet with some other key: no bearing. The
+ // console published the terminal's key as the deployment's.
_, otherFP := directKey(t)
directFleetRecord(t, release.NewDirStore(dir), "xyz", "away", otherFP)
+ deployFP, _ := appconfig.PublicFingerprint(pubB64)
+ directConsoleRecord(t, release.NewDirStore(dir), deployFP)
runCapturingRealStdout(t, func() {
runSecretsSet([]string{"-account-id", "bab", "-app", "shop", "API_KEY=hunter2"})
@@ -217,3 +233,175 @@ func TestDirectSecretsSetRefusalWritesNothing(t *testing.T) {
t.Fatalf("a refused set wrote the app's record: %+v", m)
}
}
+
+// Paul's ruling (2026-10-29, branch review R1): direct mode seals only to a
+// terminal key that positively matches the deployment's own secrets key, as
+// its console publishes it at control/moves-console.json. Fleet registration
+// refuses that key (Task 3), so no registration racing the check can turn it
+// into a fleet key.
+
+// directConsoleRecord publishes the console record naming fp as the
+// deployment's secrets key, as a console start does.
+func directConsoleRecord(t *testing.T, st release.Store, fp string) {
+ t.Helper()
+ body, err := json.Marshal(moves.ConsoleRecord{V: 1, Protocol: moves.ProtocolVersion, SecretsKeyFP: fp, At: time.Now().UTC()})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if _, err := st.Put(context.Background(), moves.ConsoleKey, body, ""); err != nil {
+ t.Fatal(err)
+ }
+}
+
+// directChildSet is the child half of directSetInChild: in the re-executed
+// test binary it runs the real command and reports that it did.
+func directChildSet() bool {
+ if os.Getenv("DIRECT_REFUSAL_DIR") == "" {
+ return false
+ }
+ runSecretsSet([]string{"-account-id", "bab", "-app", "shop", "API_KEY=hunter2"})
+ return true
+}
+
+// directSetInChild runs the real direct-mode `secrets set` for bab/shop
+// against dir with pubB64 as the terminal's key, in a child process (a
+// refusal is log.Fatal). It fails the test if the command succeeded or wrote
+// the app's record, and returns the command's output.
+func directSetInChild(t *testing.T, test, dir, pubB64 string) string {
+ t.Helper()
+ cmd := exec.Command(os.Args[0], "-test.run=^"+test+"$")
+ cmd.Env = append(os.Environ(),
+ "DIRECT_REFUSAL_DIR="+dir,
+ "CARLOS_DEPLOYMENT_DIR="+dir,
+ "CARLOS_DEPLOYMENT_BUCKET=",
+ "CARLOS_CONSOLE=",
+ "CARLOS_SERVICE_TOKEN=",
+ "CARLOS_SECRETS_PUBKEY="+pubB64,
+ "HOME="+t.TempDir(),
+ "CARLOS_CREDENTIALS="+filepath.Join(t.TempDir(), "credentials"),
+ )
+ out, err := cmd.CombinedOutput()
+ if err == nil {
+ t.Fatalf("the command succeeded:\n%s", out)
+ }
+ if m, err := appconfig.Get(context.Background(), release.NewDirStore(dir), "bab", "shop"); err == nil && len(m.Vars) != 0 {
+ t.Fatalf("a refused set wrote the app's record: %+v", m)
+ }
+ return string(out)
+}
+
+// directSealedTo runs the real direct-mode `secrets set` in process and
+// returns the fingerprint the value was sealed to.
+func directSealedTo(t *testing.T, dir, pubB64 string) string {
+ t.Helper()
+ directSetEnv(t, dir, pubB64)
+ runCapturingRealStdout(t, func() {
+ runSecretsSet([]string{"-account-id", "bab", "-app", "shop", "API_KEY=hunter2"})
+ })
+ m, err := appconfig.Get(context.Background(), release.NewDirStore(dir), "bab", "shop")
+ if err != nil {
+ t.Fatal(err)
+ }
+ return m.Vars["API_KEY"].SealedTo
+}
+
+func TestDirectSecretsSetRequiresThePublishedDeploymentKey(t *testing.T) {
+ if directChildSet() {
+ return
+ }
+ deployB64, deployFP := directKey(t)
+
+ // The terminal holds the deployment key the console published: sealed.
+ dir := t.TempDir()
+ directConsoleRecord(t, release.NewDirStore(dir), deployFP)
+ if got := directSealedTo(t, dir, deployB64); got != deployFP {
+ t.Fatalf("sealed_to = %q, want the deployment key's %s", got, deployFP)
+ }
+
+ // The terminal holds some other key that no fleet record lists: refused,
+ // because it is not the deployment's.
+ dir = t.TempDir()
+ directConsoleRecord(t, release.NewDirStore(dir), deployFP)
+ otherB64, _ := directKey(t)
+ out := directSetInChild(t, "TestDirectSecretsSetRequiresThePublishedDeploymentKey", dir, otherB64)
+ if !strings.Contains(out, wantDirectRefuseFleetKey) {
+ t.Fatalf("output = %q, want %q", out, wantDirectRefuseFleetKey)
+ }
+}
+
+// registerAfterReadStore is a fleet registration that lands between direct
+// mode's read of a fleet owner record and its write: the read answers the
+// record as it was, then the record gains fp.
+type registerAfterReadStore struct {
+ release.Store
+ t *testing.T
+ key string
+ fp string
+ landed bool
+}
+
+func (s *registerAfterReadStore) Get(ctx context.Context, key string) ([]byte, string, error) {
+ body, etag, err := s.Store.Get(ctx, key)
+ if err != nil || key != s.key || s.landed {
+ return body, etag, err
+ }
+ var rec release.FleetOwner
+ if err := json.Unmarshal(body, &rec); err != nil {
+ s.t.Fatal(err)
+ }
+ rec.SecretsKeyFPs = append(rec.SecretsKeyFPs, s.fp)
+ next, err := json.Marshal(rec)
+ if err != nil {
+ s.t.Fatal(err)
+ }
+ if _, err := s.Store.Put(ctx, key, next, etag); err != nil {
+ s.t.Fatal(err)
+ }
+ s.landed = true
+ return body, etag, nil
+}
+
+func TestDirectSecretsSetRaceRegistrationAfterCheck(t *testing.T) {
+ st := release.NewDirStore(t.TempDir())
+ _, deployFP := directKey(t)
+ directConsoleRecord(t, st, deployFP)
+ // Account xyz's fleet away is registering the terminal's key K; its
+ // owner record does not list K yet when direct mode reads it.
+ kB64, kFP := directKey(t)
+ _, oldFP := directKey(t)
+ directFleetRecord(t, st, "xyz", "away", oldFP)
+ race := &registerAfterReadStore{Store: st, t: t, key: release.FleetOwnerKey("xyz", "away"), fp: kFP}
+
+ err := directSealRefusal(context.Background(), race, "bab", directPub(t, kB64))
+ if !race.landed {
+ t.Fatal("the registration never landed: the check did not read away's owner record")
+ }
+ body, _, _ := st.Get(context.Background(), release.FleetOwnerKey("xyz", "away"))
+ if !strings.Contains(string(body), kFP) {
+ t.Fatalf("away's record does not list K after the registration: %s", body)
+ }
+ if err == nil || err.Error() != wantDirectRefuseFleetKey {
+ t.Fatalf("a key registered to a fleet after the check was not refused: err = %v, want %q", err, wantDirectRefuseFleetKey)
+ }
+}
+
+func TestDirectSecretsSetConsolelessNoFleets(t *testing.T) {
+ b64, fp := directKey(t)
+ if got := directSealedTo(t, t.TempDir(), b64); got != fp {
+ t.Fatalf("sealed_to = %q, want the terminal key's %s", got, fp)
+ }
+}
+
+func TestDirectSecretsSetNoConsoleRecordButFleets(t *testing.T) {
+ if directChildSet() {
+ return
+ }
+ dir := t.TempDir()
+ _, otherFP := directKey(t)
+ directFleetRecord(t, release.NewDirStore(dir), "xyz", "away", otherFP)
+ b64, _ := directKey(t)
+ out := directSetInChild(t, "TestDirectSecretsSetNoConsoleRecordButFleets", dir, b64)
+ if !strings.Contains(out, wantDirectRefuseNoCheck) {
+ t.Fatalf("output = %q, want %q", out, wantDirectRefuseNoCheck)
+ }
+}
diff --git a/cmd/console/main.go b/cmd/console/main.go
index 2ed8f8de2..6a3ddddcd 100644
--- a/cmd/console/main.go
+++ b/cmd/console/main.go
@@ -678,8 +678,8 @@ func serve() {
go srv.RunClaimWorker(context.Background(), "StartAlertWatcher")
// The geoip orphan sweep and D1 expiry, at startup and daily.
go srv.RunClaimWorker(context.Background(), "StartGeoipJobs")
- // The moves console record (moves Task 13): only with the switch on,
- // best-effort, logged by the method itself.
+ // The moves console record (moves Task 13): with the switch on or a
+ // secrets key, best-effort, logged by the method itself.
go srv.RunClaimWorker(context.Background(), "PublishMovesConsole")
// The economics pass writes the daily usage/census/storage/statement
// objects and pulls the AWS bill (internal/console/economicspass.go).
diff --git a/docs/superpowers/specs/2026-10-29-fleet-secrets-key-design.md b/docs/superpowers/specs/2026-10-29-fleet-secrets-key-design.md
index f4e3a231f..027785307 100644
--- a/docs/superpowers/specs/2026-10-29-fleet-secrets-key-design.md
+++ b/docs/superpowers/specs/2026-10-29-fleet-secrets-key-design.md
@@ -342,7 +342,14 @@ plan; they test the lock, not I1.
terminal and targets account A. A miss of the owner-record check above
then seals to the deployment key, which only
platform boxes and the operator running direct mode hold, so I1 holds;
- the fleet box refuses the instance and §5.7 shows it.
+ the fleet box refuses the instance and §5.7 shows it. (Paul's ruling,
+ branch review R1) That lookup cannot see a fleet that registers the key
+ after it reads, so direct mode also requires the terminal key's
+ fingerprint to equal the deployment key's as the console publishes it in
+ `control/moves-console.json` at every start with a secrets key, a key
+ fleet registration refuses (§5.1), and refuses when that record cannot be
+ read. With no console record it seals only while the bucket holds no
+ fleet owner record at all.
- (B9) `scanSecretHash` hashes the whole `Var`
(`internal/console/scankeysync.go:16-23`), so adding `SealedTo` changes
what it covers: the plan keeps the hash's input as it is today (or
@@ -448,8 +455,9 @@ exclusion is needed; a guard test pins it.
- Cost and requests: `sealKeyFor` reads the console's own store and
registry, no bucket. Two user-invoked commands add bucket reads, and
nothing polls:
- - direct-mode `carlos secrets set` lists `accounts/` and reads each
- fleet owner record, to refuse a fleet's key (§5.3);
+ - direct-mode `carlos secrets set` reads `control/moves-console.json`,
+ lists `accounts/` and reads each fleet owner record, to refuse a
+ fleet's key (§5.3);
- `carlos fleets ls`, and the key door's answer, read the config bundles
of each keyed fleet's placed apps to count stale values (§5.1).
- Provider boundary: no cloud API. The fleet key is ECDH-P256 like the
diff --git a/internal/console/claim_invariant_fixtures_test.go b/internal/console/claim_invariant_fixtures_test.go
index 5cf9c73d4..21c340ca8 100644
--- a/internal/console/claim_invariant_fixtures_test.go
+++ b/internal/console/claim_invariant_fixtures_test.go
@@ -2150,7 +2150,7 @@ var claimFixtures = map[string]claimFixture{
// ---- workers ----
"worker LogPlacementDiscrepancies": claimRead("logs region drift between the registry and instance records; writes nothing"),
- "worker PublishMovesConsole": claimNonApp("the moves console record (control/moves-console.json): the platform's moves protocol and key fingerprint; no app, and nothing with the moves switch off"),
+ "worker PublishMovesConsole": claimNonApp("the moves console record (control/moves-console.json): the platform's moves protocol and key fingerprint; no app, and nothing with the moves switch off and no secrets key"),
"worker ReportApexSquats": claimRead("logs apex squats found in the registry; writes nothing"),
"worker StartRunSweep": claimRead("off on a host-claim console, where every run route refuses: it logs that and writes nothing"),
"worker StartSeedsPass": claimRead("off on a host-claim console, where every seed door and finishSeed refuse: it logs that and writes nothing"),
diff --git a/internal/console/claim_invariant_moves_test.go b/internal/console/claim_invariant_moves_test.go
index da4263e7d..cf11964f5 100644
--- a/internal/console/claim_invariant_moves_test.go
+++ b/internal/console/claim_invariant_moves_test.go
@@ -11,7 +11,8 @@ package console
// a refused fixture, not a probe: only an exact status and message from
// claimUnsupported may stand for a route that does not work yet.
// - one worker, PublishMovesConsole (control/moves-console.json), registered
-// in every console and a no-op with the switch off. Its probe is in
+// in every console and a no-op with the switch off unless the console has
+// a secrets key (fleet secrets key, branch review R1). Its probe is in
// claim_invariant_probes_worker_test.go, with the switch turned on.
import (
@@ -21,6 +22,7 @@ import (
"strings"
"testing"
+ "github.com/carlosframework/platform/internal/appconfig"
"github.com/carlosframework/platform/internal/moves"
)
@@ -115,21 +117,46 @@ func TestClaimMovesEntriesAreCovered(t *testing.T) {
}
}
-// With the switch off the worker publishes nothing: the entry is registered in
-// every console, and only the switch makes it write.
-func TestClaimPublishMovesConsoleIsInertWithTheSwitchOff(t *testing.T) {
+// TestConsolePublishesTheDeploymentKeyOnStart (fleet secrets key, branch
+// review R1): with the moves switch off, a console with a secrets key still
+// publishes the record at each start, naming the deployment key's
+// fingerprint. It is what direct-mode `carlos secrets set` seals against.
+func TestConsolePublishesTheDeploymentKeyOnStart(t *testing.T) {
cx := newClaimCase(t)
if cx.srv.cfg.MovesEnabled {
t.Fatal("the base console has the moves switch on")
}
+ want, err := appconfig.PublicFingerprint(cx.srv.cfg.SecretsPub)
+ if err != nil || want == "" {
+ t.Fatalf("the base console has no secrets key: %q %v", want, err)
+ }
+ claimWorkerReply("PublishMovesConsole")(t, cx)
+ cx.quiesce()
+ var rec moves.ConsoleRecord
+ if !cx.bucketJSON(moves.ConsoleKey, &rec) {
+ t.Fatalf("no %s published with the moves switch off and a secrets key", moves.ConsoleKey)
+ }
+ if rec.SecretsKeyFP != want || rec.V != 1 || rec.At.IsZero() {
+ t.Fatalf("record = %+v, want the deployment key's %s", rec, want)
+ }
+}
+
+// With the switch off and no secrets key the worker publishes nothing: the
+// entry is registered in every console, and only the switch or a key makes it
+// write.
+func TestClaimPublishMovesConsoleIsInertWithTheSwitchOff(t *testing.T) {
+ cx := newClaimCaseWith(t, func(c *Config) { c.SecretsPub = "" })
+ if cx.srv.cfg.MovesEnabled {
+ t.Fatal("the base console has the moves switch on")
+ }
m := cx.rec.mark()
claimWorkerReply("PublishMovesConsole")(t, cx)
cx.quiesce()
if cx.bucketHas(moves.ConsoleKey) {
- t.Fatalf("%s published with the moves switch off", moves.ConsoleKey)
+ t.Fatalf("%s published with the moves switch off and no secrets key", moves.ConsoleKey)
}
if events := cx.rec.since(m); len(events) != 0 {
- t.Fatalf("the worker wrote with the moves switch off: %v", events)
+ t.Fatalf("the worker wrote with the moves switch off and no secrets key: %v", events)
}
}
diff --git a/internal/console/claim_workers.go b/internal/console/claim_workers.go
index 47998a67c..bee9c5330 100644
--- a/internal/console/claim_workers.go
+++ b/internal/console/claim_workers.go
@@ -45,10 +45,10 @@ func (s *Server) registerClaimWorkers() {
// publishMovesConsoleWorker is PublishMovesConsole as a recorded worker. The
// method logs its own failure (it is best-effort and the console serves
// regardless), so the worker drops the returned error. It is a no-op with the
-// moves switch off, and then records no run, so the job drops off the
-// operator pages' list (RunClaimWorker).
+// moves switch off and no secrets key, and then records no run, so the job
+// drops off the operator pages' list (RunClaimWorker).
func (s *Server) publishMovesConsoleWorker(ctx context.Context) {
- if !s.cfg.MovesEnabled || s.cfg.Releases == nil {
+ if !s.publishesConsoleRecord() {
return
}
_ = s.jobs.Run(ctx, "PublishMovesConsole", s.PublishMovesConsole)
diff --git a/internal/console/movesconsole_test.go b/internal/console/movesconsole_test.go
index 176dae529..635b9bbdf 100644
--- a/internal/console/movesconsole_test.go
+++ b/internal/console/movesconsole_test.go
@@ -15,8 +15,11 @@ import (
"github.com/carlosframework/platform/internal/release"
)
-// D13: the console publishes control/moves-console.json only with the
-// moves switch on, and a second start replaces the first start's record.
+// D13: the console publishes control/moves-console.json with the moves
+// switch on, and a second start replaces the first start's record. Since the
+// fleet secrets key's branch review R1 it also publishes with the switch off
+// when it has a secrets key, so direct mode can read the deployment key's
+// fingerprint; with neither it publishes nothing.
func TestConsoleRecordNeedsTheSwitch(t *testing.T) {
ctx := context.Background()
priv, err := ecdh.P256().NewPrivateKey(bytes.Repeat([]byte{1}, 32))
@@ -26,12 +29,21 @@ func TestConsoleRecordNeedsTheSwitch(t *testing.T) {
pubB64 := base64.StdEncoding.EncodeToString(priv.PublicKey().Bytes())
store := release.NewDirStore(t.TempDir())
+ none := &Server{cfg: Config{Releases: store}}
+ if err := none.PublishMovesConsole(ctx); err != nil {
+ t.Fatal(err)
+ }
+ if _, _, err := store.Get(ctx, moves.ConsoleKey); !errors.Is(err, os.ErrNotExist) {
+ t.Fatalf("switch off and no key, yet %s: %v", moves.ConsoleKey, err)
+ }
+
off := &Server{cfg: Config{Releases: store, SecretsPub: pubB64}}
if err := off.PublishMovesConsole(ctx); err != nil {
t.Fatal(err)
}
- if _, _, err := store.Get(ctx, moves.ConsoleKey); !errors.Is(err, os.ErrNotExist) {
- t.Fatalf("switch off, yet %s: %v", moves.ConsoleKey, err)
+ var offRec moves.ConsoleRecord
+ if body, _, err := store.Get(ctx, moves.ConsoleKey); err != nil || json.Unmarshal(body, &offRec) != nil || offRec.SecretsKeyFP != appconfig.KeyFingerprint(priv.PublicKey()) {
+ t.Fatalf("switch off with a key: %s = %+v, %v", moves.ConsoleKey, offRec, err)
}
on := &Server{cfg: Config{Releases: store, SecretsPub: pubB64, MovesEnabled: true}}
diff --git a/internal/console/server.go b/internal/console/server.go
index 0367ee493..e1f52889e 100644
--- a/internal/console/server.go
+++ b/internal/console/server.go
@@ -2014,13 +2014,16 @@ func NewServer(cfg Config, st *Store) (*Server, error) {
// PublishMovesConsole writes control/moves-console.json: the moves
// protocol this console speaks and the fingerprint of its
// CARLOS_SECRETS_PUBKEY (empty when unset), so a box can check the console
-// it is moving for (moves Task 13). Only with the moves switch on (index
-// D13: off publishes nothing). Called once per start, by the console's
-// main, never by NewServer, so constructing a Server in a test writes
-// nothing. A later start replaces the record. Best-effort: a failure is
-// logged and returned, and the console serves regardless.
+// it is moving for (moves Task 13). With the moves switch on, or with a
+// secrets key: direct-mode `carlos secrets set` seals only to the key this
+// record names (fleet secrets key, branch review R1), so a console with a
+// key publishes it whatever the switch says (index D13 still holds for a
+// keyless console: off publishes nothing). Called once per start, by the
+// console's main, never by NewServer, so constructing a Server in a test
+// writes nothing. A later start replaces the record. Best-effort: a
+// failure is logged and returned, and the console serves regardless.
func (s *Server) PublishMovesConsole(ctx context.Context) error {
- if !s.cfg.MovesEnabled || s.cfg.Releases == nil {
+ if !s.publishesConsoleRecord() {
return nil
}
fp, _ := appconfig.PublicFingerprint(s.cfg.SecretsPub)
@@ -2035,6 +2038,12 @@ func (s *Server) PublishMovesConsole(ctx context.Context) error {
return nil
}
+// publishesConsoleRecord is whether PublishMovesConsole writes anything: a
+// bucket, and the moves switch or a secrets key.
+func (s *Server) publishesConsoleRecord() bool {
+ return s.cfg.Releases != nil && (s.cfg.MovesEnabled || s.cfg.SecretsPub != "")
+}
+
// StartGeoipJobs runs the orphan sweep and D1 expiry at startup and then
// daily (geoip spec §3, D1), until ctx ends. It is the recorded worker
// "StartGeoipJobs" (claim_workers.go) and, like every worker, blocks: cmd/console
diff --git a/internal/moves/floor.go b/internal/moves/floor.go
index 0704ea932..d1cc9ea3c 100644
--- a/internal/moves/floor.go
+++ b/internal/moves/floor.go
@@ -19,9 +19,10 @@ const ProtocolVersion = 1
// release bucket.
const FloorKey = "control/moves-protocol.json"
-// ConsoleKey is where a console with the moves switch on publishes the
-// protocol it speaks and the fingerprint of its secrets public key, once at
-// each start (replacing the last start's record).
+// ConsoleKey is where a console with the moves switch on, or with a secrets
+// key, publishes the protocol it speaks and the fingerprint of its secrets
+// public key, once at each start (replacing the last start's record).
+// Direct-mode `carlos secrets set` seals only to the key it names.
const ConsoleKey = "control/moves-console.json"
// ConsoleRecord is the body at ConsoleKey.