carlos / platform Public

channels digests: the REPAIR listing walks the bucket, not the console

Astra round 2, finding 2 (and Fable P2-4): the report enumerated only
the console's claimed apps, so a bucket-only app or account could leave
an empty listing over heads a fresh box refuses. It now lists every
account and app directory in the bucket; a failed listing answers no
report. Bucket-only account rows are marked so a marker request never
reads as having reached them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev a4dd6a093b70b8290da6e5efd3b5c40c8f1d3a36 parent 21d1c36
7 files changed, +154 −16
  • README.md +1 −1
  • apimode.go +3 −0
  • channels_digests.go +3 −7
  • channels_digests_test.go +7 −0
  • internal/console/apidigests.go +40 −8
  • internal/console/apidigests_test.go +66 −0
  • internal/release/digests.go +34 −0
diff --git a/README.md b/README.md
index f5443bf64..d273540f8 100644
--- a/README.md
+++ b/README.md
@@ -306,7 +306,7 @@ the release you are about to roll.
**Pointer digests (#253): writers before readers.** Once a box has verified a channel pointer that carries manifest digests, it refuses pointers for that channel without them. So digests are turned on in order. First upgrade every writer: every console, and every CLI or deploy script that promotes, rolls back or fast-tracks. Then run `carlos channels digests on`. Then watch `carlos channels digests`: a channel marked as written by an old writer means one is still in use. Rolling a writer back below this release stops it writing pointers boxes accept; `carlos channels digests off` suspends digests while it is fixed, but does not clear the boxes that have already seen them. When `carlos channels digests` lists nothing, set `CARLOS_REQUIRE_POINTER_DIGEST=on` in every box's host.env, so a new box refuses old pointers too.
-**Account binding and record-less heads: repair before rolling (hunt H3-M8, H3-M1).** From this release a new or replaced box refuses two kinds of channel head. One is a pointer signed before the account binding, which names no account. The other is a head that signs no manifest digest and has no promotion record to bind its bytes. Boxes that already run a build keep running it. Before the release rolls, run `carlos channels digests` against dev and against flagship. It lists both kinds under REPAIR, by account, app and channel, whether or not digests are on. Roll only when it lists nothing on both. Repair each line, then run the listing again:
+**Account binding and record-less heads: repair before rolling (hunt H3-M8, H3-M1).** From this release a new or replaced box refuses two kinds of channel head. One is a pointer signed before the account binding, which names no account. The other is a head that signs no manifest digest and has no promotion record to bind its bytes. Boxes that already run a build keep running it. Before the release rolls, run `carlos channels digests` against dev and against flagship. It lists both kinds under REPAIR, by account, app and channel, whether or not digests are on. It reads every account and app in the deployment bucket, including apps shipped straight to the bucket that the console has no record of, and gives no report at all if the bucket cannot be listed. Roll only when it lists nothing on both. Repair each line, then run the listing again:
- **no account.** Promote the version the channel already names, again: `carlos promote --app <app> --account <sqid> <version> <channel>`. A repeat promote re-signs the pointer with its account, with or without digests, and is the repair for an account whose digests are off. If the console refuses it (stable, or a channel that needs a passkey or an approval), run the same command against the bucket with the root key, as in step 10 above: `AWS_PROFILE` for the deployment, `CARLOS_DEPLOYMENT_BUCKET` set to its bucket, and `CARLOS_RELEASE_KEY` from SSM `/carlos/release-key` set for that one command. For an account whose digests are on, `carlos channels resign --app <app> --account <sqid> <channel>` also binds it. The console's resign door refuses stable and passkey channels too, so use the same bucket-and-root-key form for those.
- **no promotion record.** `carlos releases authorize --app <app> --account <sqid> <version>`. It shows the manifest and artifact digests and signs a record for them when you type yes. It signs whatever the bucket holds now, so check the digests against the build you shipped first.
diff --git a/apimode.go b/apimode.go
index 435e1d9a3..527ce5ea7 100644
--- a/apimode.go
+++ b/apimode.go
@@ -1701,6 +1701,9 @@ type apiDigestAccount struct {
On bool `json:"on"`
Since string `json:"since"`
Error string `json:"error"`
+ // BucketOnly is an account the bucket holds and the console does not:
+ // listed for its heads, never one a marker request reached.
+ BucketOnly bool `json:"bucket_only"`
}
type apiDigestChannel struct {
Account string `json:"account"`
diff --git a/channels_digests.go b/channels_digests.go
index b7b97150d..f7d6e2471 100644
--- a/channels_digests.go
+++ b/channels_digests.go
@@ -274,7 +274,7 @@ func checkNamedAccounts(rep apiPointerDigests, ids []string) error {
for _, id := range ids {
known := false
for _, a := range rep.Accounts {
- known = known || a.Account == id
+ known = known || (a.Account == id && !a.BucketOnly)
}
if !known {
return fmt.Errorf(textUnknownAccount, id)
@@ -312,17 +312,13 @@ func localPointerDigests(ctx context.Context, s release.Store, verb string, ids
if marker != nil {
row.On, row.Since = true, marker.At.UTC().Format(time.RFC3339)
}
- dirs, err := s.ListDirs(ctx, "apps/"+acct+"/")
+ apps, err := release.BucketApps(ctx, s, acct)
if err != nil {
row.Error = err.Error()
rep.Accounts = append(rep.Accounts, row)
continue
}
- for _, d := range dirs {
- app := strings.TrimSuffix(strings.TrimPrefix(d, "apps/"+acct+"/"), "/")
- if !release.ValidApp(app) {
- continue
- }
+ for _, app := range apps {
states, _, err := release.DigestReport(ctx, s, pub, acct, app)
if err != nil {
row.Error = err.Error()
diff --git a/channels_digests_test.go b/channels_digests_test.go
index 337f90df5..1441277cb 100644
--- a/channels_digests_test.go
+++ b/channels_digests_test.go
@@ -289,6 +289,13 @@ func TestCheckNamedAccounts(t *testing.T) {
if err == nil || err.Error() != fmt.Sprintf(textUnknownAccount, "zzz") {
t.Fatalf("unknown account: %v", err)
}
+ // An account the report lists only because the bucket holds it was
+ // never reached by a marker request (fix round 2).
+ rep.Accounts = append(rep.Accounts, apiDigestAccount{Account: "zqx", BucketOnly: true})
+ err = checkNamedAccounts(rep, []string{"zqx"})
+ if err == nil || err.Error() != fmt.Sprintf(textUnknownAccount, "zqx") {
+ t.Fatalf("bucket-only account: %v", err)
+ }
}
func runDigests(t *testing.T, args ...string) string {
diff --git a/internal/console/apidigests.go b/internal/console/apidigests.go
index 61d820c02..d81d42182 100644
--- a/internal/console/apidigests.go
+++ b/internal/console/apidigests.go
@@ -22,6 +22,13 @@ const (
textActivityResigned = "re-signed %s at %s with manifest digests (cli)"
)
+// The repair listing's inventory refusals (fix round 2). Not yet through
+// copy review.
+const (
+ textBucketList = "could not list the accounts in the deployment bucket, so there is no report"
+ textBucketListApps = "could not list the apps of %s in the deployment bucket: %v"
+)
+
// handleAPIChannelResign answers `carlos channels resign` (#253, spec §4.6).
// A body naming only the channel gets the plan; a body that also carries
// the digests the operator confirmed signs them, if a plan made now is
@@ -206,11 +213,36 @@ func (s *Server) handleAPISystemPointerDigests(w http.ResponseWriter, r *http.Re
jsonError(w, http.StatusInternalServerError, "could not load accounts")
return
}
+ // The bucket is the inventory, not this console's database (Astra
+ // round 2, finding 2): every account and app directory in it, the
+ // console's own accounts first, then any only the bucket holds. A
+ // listing that fails answers no report at all, since a shorter one
+ // could read as "no channel needs a repair".
+ sqids := make([]string, 0, len(accts))
+ known := map[string]bool{}
+ for _, a := range accts {
+ sqids = append(sqids, a.Sqid)
+ known[a.Sqid] = true
+ }
+ inBucket, err := release.BucketAccounts(ctx, s.cfg.Releases)
+ if err != nil {
+ log.Printf("console: pointer digests: listing the bucket's accounts: %v", err)
+ jsonError(w, http.StatusBadGateway, textBucketList)
+ return
+ }
+ for _, sqid := range inBucket {
+ if !known[sqid] {
+ sqids = append(sqids, sqid)
+ }
+ }
type acctRow struct {
Account string `json:"account"`
On bool `json:"on"`
Since string `json:"since,omitempty"`
Error string `json:"error,omitempty"`
+ // BucketOnly is an account the bucket holds and this console does
+ // not: listed for its heads; a marker request never names it.
+ BucketOnly bool `json:"bucket_only,omitempty"`
}
type chRow struct {
Account string `json:"account"`
@@ -231,9 +263,9 @@ func (s *Server) handleAPISystemPointerDigests(w http.ResponseWriter, r *http.Re
NoRecord bool `json:"no_record,omitempty"`
}
acctRows, chRows, repRows := []acctRow{}, []chRow{}, []repRow{}
- for _, a := range accts {
- row := acctRow{Account: a.Sqid}
- m, err := release.ReadDigestMarker(ctx, s.cfg.Releases, s.cfg.ReleasePub, a.Sqid)
+ for _, sqid := range sqids {
+ row := acctRow{Account: sqid, BucketOnly: !known[sqid]}
+ m, err := release.ReadDigestMarker(ctx, s.cfg.Releases, s.cfg.ReleasePub, sqid)
if err != nil {
row.Error = err.Error()
acctRows = append(acctRows, row)
@@ -242,14 +274,14 @@ func (s *Server) handleAPISystemPointerDigests(w http.ResponseWriter, r *http.Re
if m != nil {
row.On, row.Since = true, m.At.UTC().Format(time.RFC3339)
}
- apps, err := s.store.AppsIn(a.ID)
+ apps, err := release.BucketApps(ctx, s.cfg.Releases, sqid)
if err != nil {
- row.Error = "could not load apps"
+ row.Error = fmt.Sprintf(textBucketListApps, sqid, err)
acctRows = append(acctRows, row)
continue
}
for _, app := range apps {
- states, _, err := release.DigestReport(ctx, s.cfg.Releases, s.cfg.ReleasePub, a.Sqid, app)
+ states, _, err := release.DigestReport(ctx, s.cfg.Releases, s.cfg.ReleasePub, sqid, app)
if err != nil {
row.Error = err.Error()
break
@@ -263,13 +295,13 @@ func (s *Server) handleAPISystemPointerDigests(w http.ResponseWriter, r *http.Re
row.Error = st.Err
}
case !st.HeadDigest:
- chRows = append(chRows, chRow{Account: a.Sqid, App: app, Channel: st.Channel, Version: st.Version, Straggler: st.Straggler})
+ chRows = append(chRows, chRow{Account: sqid, App: app, Channel: st.Channel, Version: st.Version, Straggler: st.Straggler})
}
if st.Err == "" && st.RecordErr != "" && row.Error == "" {
row.Error = st.RecordErr // unknown whether it needs a repair
}
if st.Err == "" && st.NeedsRepair() {
- repRows = append(repRows, repRow{Account: a.Sqid, App: app, Channel: st.Channel, Version: st.Version, Unbound: st.Unbound, NoRecord: st.NoRecord})
+ repRows = append(repRows, repRow{Account: sqid, App: app, Channel: st.Channel, Version: st.Version, Unbound: st.Unbound, NoRecord: st.NoRecord})
}
}
}
diff --git a/internal/console/apidigests_test.go b/internal/console/apidigests_test.go
index 777ae95be..b15184ea3 100644
--- a/internal/console/apidigests_test.go
+++ b/internal/console/apidigests_test.go
@@ -485,3 +485,69 @@ func TestSystemDigestsDoorListsRepairsWithTheMarkerOff(t *testing.T) {
}
}
}
+
+// Fix round 2 (Astra round 2, finding 2): the repair listing's inventory is
+// the bucket, not this console's database. An app shipped straight to the
+// bucket under a known account, with no console row, and an account only
+// the bucket holds, each with an account-less head a fresh box refuses,
+// are both listed; the bucket-only account's row says so, so a marker
+// request never reads as having reached it.
+func TestSystemDigestsDoorListsHeadsTheConsoleDoesNotKnow(t *testing.T) {
+ fx := newDigestsFixture(t)
+ ctx := context.Background()
+ const stranger = "zqx"
+ if !release.ValidAccount(stranger) {
+ t.Fatalf("control: %q is not an account name", stranger)
+ }
+ unbound := func(acct, app string) {
+ t.Helper()
+ legacy := release.ChannelPointer{Schema: 1, App: app, Channel: "stable", Version: "v1", PromotedAt: time.Date(2026, 6, 1, 0, 0, 0, 0, time.UTC)}
+ payload, _ := json.MarshalIndent(legacy, "", " ")
+ b64 := base64.StdEncoding.EncodeToString(payload)
+ wire, _ := json.Marshal(map[string]string{"payload": b64, "sig": base64.StdEncoding.EncodeToString(ed25519.Sign(fx.priv, []byte(b64)))})
+ if _, err := fx.store.Put(ctx, release.ChannelKey(acct, app, "stable"), wire, ""); err != nil {
+ t.Fatal(err)
+ }
+ }
+ unbound(release.OpsAccount, "direct")
+ unbound(stranger, "shop")
+ st, out := getRaw(t, fx.ts.URL+"/api/cli/system/pointer-digests", fx.operator)
+ if st != http.StatusOK {
+ t.Fatalf("report: %d %s", st, out)
+ }
+ var rep struct {
+ Accounts []struct {
+ Account, Error string
+ BucketOnly bool `json:"bucket_only"`
+ } `json:"accounts"`
+ Repairs []struct {
+ Account, App, Channel string
+ Unbound bool `json:"unbound"`
+ } `json:"repairs"`
+ }
+ if err := json.Unmarshal([]byte(out), &rep); err != nil {
+ t.Fatalf("report body %s: %v", out, err)
+ }
+ listed := map[string]bool{}
+ for _, r := range rep.Repairs {
+ listed[r.Account+"/"+r.App+"/"+r.Channel] = r.Unbound
+ }
+ for _, want := range []string{release.OpsAccount + "/direct/stable", stranger + "/shop/stable"} {
+ if !listed[want] {
+ t.Fatalf("%s is not listed as an unbound head: %s", want, out)
+ }
+ }
+ rows := map[string]bool{}
+ for _, a := range rep.Accounts {
+ if a.Error != "" {
+ t.Fatalf("%s's row reads unknown: %q", a.Account, a.Error)
+ }
+ rows[a.Account] = a.BucketOnly
+ }
+ if bucketOnly, ok := rows[stranger]; !ok || !bucketOnly {
+ t.Fatalf("no bucket-only row for %s: %s", stranger, out)
+ }
+ if rows[release.OpsAccount] {
+ t.Fatalf("the console's own account reads as bucket-only: %s", out)
+ }
+}
diff --git a/internal/release/digests.go b/internal/release/digests.go
index 4d5b6c2a5..d5c79893c 100644
--- a/internal/release/digests.go
+++ b/internal/release/digests.go
@@ -6,6 +6,7 @@ import (
"crypto/sha256"
"errors"
"fmt"
+ "slices"
"strings"
"time"
)
@@ -176,6 +177,39 @@ func DigestStateOf(p *ChannelPointer, marker *DigestMarker) ChannelDigestState {
return st
}
+// BucketAccounts is every account directory under apps/ in the deployment
+// bucket, and BucketApps every app directory under one account: the
+// inventory the repair listing walks (Astra round 2, finding 2), whatever a
+// console's database knows. A box reads a head by its bucket key, so an app
+// shipped straight to the bucket, with no console row, or one the console
+// has trashed or forgotten, holds heads a fresh box refuses like any other.
+// A name that is not a valid account or app is skipped: no box builds a key
+// from one. A listing that fails is an error, never a shorter inventory.
+func BucketAccounts(ctx context.Context, s Store) ([]string, error) {
+ return bucketDirNames(ctx, s, "apps/", ValidAccount)
+}
+
+// BucketApps: see BucketAccounts.
+func BucketApps(ctx context.Context, s Store, acct string) ([]string, error) {
+ return bucketDirNames(ctx, s, "apps/"+acct+"/", ValidApp)
+}
+
+func bucketDirNames(ctx context.Context, s Store, prefix string, valid func(string) bool) ([]string, error) {
+ dirs, err := s.ListDirs(ctx, prefix)
+ if err != nil {
+ return nil, err
+ }
+ var out []string
+ for _, d := range dirs {
+ name := strings.TrimSuffix(strings.TrimPrefix(d, prefix), "/")
+ if valid(name) {
+ out = append(out, name)
+ }
+ }
+ slices.Sort(out)
+ return out, nil
+}
+
// DigestReport is every channel of one app, plus the account's marker. A
// pointer that cannot be read or does not verify is never skipped: it comes
// back as a line with Err set, its state unknown. It reports, with or