carlos / platform Public

Fix deploy credential scope for default edge pipelines (#718)

Squashed from fix/deploy-edge-718 into main.
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev b1bf1e02ba6c3071456a53912b491ab86b9a819d parent 7f4bdf3
10 files changed, +205 −15
  • docs/superpowers/notes/census-proposal-deploy-edge-718.md +11 −0
  • docs/superpowers/reviews/CODEX-REVIEW-BRIEF-deploy-edge-718.md +56 −0
  • internal/console/apicli.go +5 −5
  • internal/console/apigatepass.go +1 −1
  • internal/console/deployscope.go +3 −2
  • internal/console/deployscope_test.go +84 −1
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −0
  • internal/provision/testdata/plan14-root-reads-deploy-edge-718.tsv +3 −0
  • pipeline.go +1 −6
  • pipeline_test.go +40 −0

CI passed — run details

diff --git a/docs/superpowers/notes/census-proposal-deploy-edge-718.md b/docs/superpowers/notes/census-proposal-deploy-edge-718.md
new file mode 100644
index 000000000..41f341bbf
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-deploy-edge-718.md
@@ -0,0 +1,11 @@
+# Census approval: deploy-edge-718
+
+Ruling `census-ruling-deploy-edge-718`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+
+Envelopes re-pinned: `.`.
+
+Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner.
+
+Seal: `250e3ba91e1bc5fcd6be5cc2bafce4c7d6645d2d2f0c080913b99f01b1d19129` → `250e3ba91e1bc5fcd6be5cc2bafce4c7d6645d2d2f0c080913b99f01b1d19129`.
+
+Overlay: `internal/provision/testdata/plan14-root-reads-deploy-edge-718.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-deploy-edge-718.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-deploy-edge-718.md
new file mode 100644
index 000000000..3f1e4f8cf
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-deploy-edge-718.md
@@ -0,0 +1,56 @@
+# Review brief: deploy edge default, round 1 of 3
+
+Repo carlos/platform, branch `fix/deploy-edge-718`.
+Under review: the full diff from origin/main to the branch tip containing this brief.
+Authorities: discussion #718; merged specs
+`docs/superpowers/specs/2026-10-05-deploy-credential-design.md` (especially R2, R5 and section 7);
+release pipelines v2 design in platform-infrastructure at
+`platform-design/superpowers/specs/2026-08-20-release-pipelines-v2-design.md`.
+The issue's option 1 narrows the meaning of pipelined for deploy scope: the
+exact default single edge channel with no bake or rules is exempt. Everything
+else remains restricted. Explicit bake strings, including 0s, remain restricted.
+
+You are an independent Opus reviewer. Read the diff and verify against code.
+No completed review rounds yet. Sonnet investigation and Opus availability
+attempts were rejected by the provider's weekly usage limit; neither produced
+findings or constitutes a completed review. Maximum three rounds. Stop at the
+first round with no P1. Fix P2s without reopening, subject to census and review
+of newly changed security behavior. P3s are follow-ups only. Two consecutive
+rounds finding the same invariant broken require stopping for the owner's choice.
+
+## Fixed: do not re-argue
+
+- Keep apps create's signed pipeline file; absence retains the legacy ladder.
+- Keep rung scope, hotfix refusal, stable refusal and scoped signing.
+- No new CLI command, production change or new user-facing wording.
+
+## What to check
+
+1. Every early and primitive callback scope check receives the actual pipeline.
+2. Only the exact single unrestricted edge channel is exempt, including gate
+ passes. All approval rules, bake strings, other single channels, empty and
+ multiple channel configurations remain restricted. Unreadable pipeline
+ handling and rechecks before writes remain intact.
+3. The CLI uses the existing table for every nondefault configuration and
+ preserves the existing missing-pipeline display.
+4. Read the census card `docs/superpowers/notes/census-proposal-deploy-edge-718.md`
+ and approve or reject every entry and envelope with file:line evidence.
+ No new root reads are intended. The root package envelope changes because
+ runPipelineShow's display condition changes.
+5. Tests cover grant scope, protected configurations, promote, rollback and
+ signed grants. Consider authorization races and the accepted R5 gap.
+
+## Severity
+
+- P1: unsafe, would not compile, a test fails, or would not work. Blocks merge.
+- P2: wrong or missing. Fix without another round; census and newly changed
+ security behavior still need checking.
+- P3: clarity or polish. Record as follow-up, never start another round.
+
+Each finding states scenario, verified file:line evidence, concrete fix and
+invariant or trust boundary (fault family). Do not raise P2 to P1 to keep review open.
+End with exactly one verdict: READY (no P1/P2), READY AFTER FIXES (P2 only),
+or NOT READY (P1 present). Round 3 NOT READY also names whether a shared cause
+can be removed by refusing the case or cutting the feature.
+
+Do not edit files, spawn reviewers or subagents, or run full test suites.
diff --git a/internal/console/apicli.go b/internal/console/apicli.go
index ab9180672..e294ba2e7 100644
--- a/internal/console/apicli.go
+++ b/internal/console/apicli.go
@@ -988,7 +988,7 @@ func (s *Server) handleAPIPromote(w http.ResponseWriter, r *http.Request) {
jsonError(w, http.StatusBadGateway, "could not read the pipeline for "+app)
return
}
- if err := deployScopeAllows(p, pipe != nil, channel, req.Hotfix); err != nil {
+ if err := deployScopeAllows(p, pipe, channel, req.Hotfix); err != nil {
s.writeDeployRefusal(w, err)
return
}
@@ -1129,7 +1129,7 @@ func (s *Server) handleAPIPromote(w http.ResponseWriter, r *http.Request) {
}
signer = sg
authorize = func(pp *release.Pipeline) error {
- return deployScopeAllows(p, pp != nil, channel, req.Hotfix)
+ return deployScopeAllows(p, pp, channel, req.Hotfix)
}
}
res, err := signer.PromoteOnLadder(ctx, s.cfg.Releases, acct.Sqid, app, channel, version,
@@ -1305,7 +1305,7 @@ func (s *Server) handleAPIRollback(w http.ResponseWriter, r *http.Request) {
jsonError(w, http.StatusBadGateway, "could not read the pipeline for "+app)
return
}
- if err := deployScopeAllows(p, pipe != nil, channel, false); err != nil {
+ if err := deployScopeAllows(p, pipe, channel, false); err != nil {
s.writeDeployRefusal(w, err)
return
}
@@ -1437,7 +1437,7 @@ func (s *Server) refuseStableOverAPI(w http.ResponseWriter, p Principal, acct *A
if rung, _ := release.Rung(channel); rung != release.RungStable {
return false
}
- if err := deployScopeAllows(p, false, channel, false); err != nil {
+ if err := deployScopeAllows(p, nil, channel, false); err != nil {
s.writeDeployRefusal(w, err)
return true
}
@@ -1458,7 +1458,7 @@ func (s *Server) writePasskeyRefusal(w http.ResponseWriter, acct *Account, app,
// inside its admitted mutation, of the pipeline read there.
func deployScopeAuthorize(p Principal, channel string) func(*release.Pipeline) error {
return func(pp *release.Pipeline) error {
- return deployScopeAllows(p, pp != nil, channel, false)
+ return deployScopeAllows(p, pp, channel, false)
}
}
diff --git a/internal/console/apigatepass.go b/internal/console/apigatepass.go
index 169610364..c22501e28 100644
--- a/internal/console/apigatepass.go
+++ b/internal/console/apigatepass.go
@@ -124,7 +124,7 @@ func (s *Server) handleAPIInstanceGatePass(w http.ResponseWriter, r *http.Reques
// pipeline: the channels a deploy credential ships its own build straight
// onto, with nothing in between.
func deployGatePassAllowed(p Principal, pipe *release.Pipeline, channel string) bool {
- if deployScopeAllows(p, pipe != nil, channel, false) != nil {
+ if deployScopeAllows(p, pipe, channel, false) != nil {
return false
}
if rung, _ := release.Rung(channel); rung == release.RungBeta {
diff --git a/internal/console/deployscope.go b/internal/console/deployscope.go
index ddde52175..0d88784a4 100644
--- a/internal/console/deployscope.go
+++ b/internal/console/deployscope.go
@@ -90,7 +90,7 @@ func (e *deployRefusal) Error() string { return e.msg }
// times per write: early in the handler for the message, and by the release
// primitives on their own pipeline reads (Task 7). For every principal that
// is not a deploy credential it returns nil and changes nothing.
-func deployScopeAllows(p Principal, pipelined bool, channel string, hotfix bool) error {
+func deployScopeAllows(p Principal, pipe *release.Pipeline, channel string, hotfix bool) error {
if p.Kind != PrincipalService || p.Role != svcrole.Deploy {
return nil
}
@@ -114,7 +114,8 @@ func deployScopeAllows(p Principal, pipelined bool, channel string, hotfix bool)
if !inScope {
return &deployRefusal{fmt.Sprintf("deploy credential %s may move %s only, and %s is not one of them.", p.Name, held, channel)}
}
- if pipelined && rung != release.RungCanary {
+ defaultEdge := pipe != nil && len(pipe.Channels) == 1 && pipe.Channels[0] == (release.PipelineChannel{Name: release.RungEdge})
+ if pipe != nil && !defaultEdge && rung != release.RungCanary {
return &deployRefusal{fmt.Sprintf("%s has a pipeline, so deploy credential %s may move canary/<name> channels only.", p.App, p.Name)}
}
return nil
diff --git a/internal/console/deployscope_test.go b/internal/console/deployscope_test.go
index 3e8341877..6f0ef0dd4 100644
--- a/internal/console/deployscope_test.go
+++ b/internal/console/deployscope_test.go
@@ -38,7 +38,11 @@ func TestDeployScopeAllows(t *testing.T) {
{"publish untouched", pub, true, "stable", true, true},
{"person untouched", person, true, "stable", true, true},
} {
- err := deployScopeAllows(tc.p, tc.pipelined, tc.channel, tc.hotfix)
+ var pipe *release.Pipeline
+ if tc.pipelined {
+ pipe = &release.Pipeline{Channels: []release.PipelineChannel{{Name: "edge"}, {Name: "stable"}}}
+ }
+ err := deployScopeAllows(tc.p, pipe, tc.channel, tc.hotfix)
if (err == nil) != tc.ok {
t.Errorf("%s: err = %v, want ok=%v", tc.name, err, tc.ok)
}
@@ -180,3 +184,82 @@ func TestDeployRollbackOfStableIsD22(t *testing.T) {
}
stableAbsent()
}
+
+func TestDeployScopeSingleChannel(t *testing.T) {
+ p := Principal{Kind: PrincipalService, Role: svcrole.Deploy, Name: "ci", App: "hello", Rungs: []string{"canary", "edge", "beta"}}
+ for _, tc := range []struct {
+ name string
+ channels []release.PipelineChannel
+ allowed bool
+ }{
+ {"default", release.DefaultPipelineChannels(), true},
+ {"empty", nil, false},
+ {"beta", []release.PipelineChannel{{Name: "beta"}}, false},
+ {"custom", []release.PipelineChannel{{Name: "production"}}, false},
+ {"bake", []release.PipelineChannel{{Name: "edge", Bake: "1h"}}, false},
+ {"explicit zero bake", []release.PipelineChannel{{Name: "edge", Bake: "0s"}}, false},
+ {"passkey", []release.PipelineChannel{{Name: "edge", Rules: release.ChannelRules{Passkey: true}}}, false},
+ {"promote approvals", []release.PipelineChannel{{Name: "edge", Rules: release.ChannelRules{PromoteApprovals: 1}}}, false},
+ {"change approvals", []release.PipelineChannel{{Name: "edge", Rules: release.ChannelRules{ChangeApprovals: 1}}}, false},
+ {"multiple", []release.PipelineChannel{{Name: "edge"}, {Name: "beta"}}, false},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ pipe := &release.Pipeline{Channels: tc.channels}
+ if err := deployScopeAllows(p, pipe, "edge", false); (err == nil) != tc.allowed {
+ t.Fatalf("edge: %v, want allowed=%v", err, tc.allowed)
+ }
+ if err := deployScopeAuthorize(p, "edge")(pipe); (err == nil) != tc.allowed {
+ t.Fatalf("write authorization: %v, want allowed=%v", err, tc.allowed)
+ }
+ if got := deployGatePassAllowed(p, pipe, "edge"); got != tc.allowed {
+ t.Fatalf("gate pass: %v, want %v", got, tc.allowed)
+ }
+ if err := deployScopeAllows(p, pipe, "edge", true); err == nil {
+ t.Fatal("hotfix allowed")
+ }
+ if err := deployScopeAllows(p, pipe, "stable", false); err == nil {
+ t.Fatal("stable allowed")
+ }
+ if err := deployScopeAllows(p, pipe, "canary/test", false); err != nil {
+ t.Fatal(err)
+ }
+ restricted := p
+ restricted.Rungs = []string{"canary"}
+ if err := deployScopeAllows(restricted, pipe, "edge", false); err == nil {
+ t.Fatal("edge allowed without edge grant")
+ }
+ })
+ }
+}
+
+func TestDeployDefaultPipelinePromoteAndRollback(t *testing.T) {
+ fx, _, deploy := deployFixture(t)
+ ctx := context.Background()
+ if _, err := release.SetPipeline(ctx, fx.rel, fx.priv, "bab", "hello", release.DefaultPipelineChannels(), "paul@keymail.dev"); err != nil {
+ t.Fatal(err)
+ }
+ fx.forgetFrame("hello")
+ for _, version := range []string{"v1", "v2"} {
+ status, out := postJSON(t, fx.ts.URL+"/api/cli/apps/bab/hello/promote", map[string]any{"version": version, "channel": "edge"}, deploy)
+ if status != http.StatusOK || str(t, out, "result") != "promoted" {
+ t.Fatalf("promote %s: %d %v", version, status, out)
+ }
+ if g := pointerGrant(t, fx, "edge"); g == nil || g["name"] != "deploy.ci" {
+ t.Fatalf("grant: %v", g)
+ }
+ }
+ status, out := postJSON(t, fx.ts.URL+"/api/cli/apps/bab/hello/rollback", map[string]any{"channel": "edge"}, deploy)
+ if status != http.StatusOK || str(t, out, "result") != "rolled back" {
+ t.Fatalf("rollback: %d %v", status, out)
+ }
+ cp, err := release.Channel(ctx, fx.rel, fx.pub, "bab", "hello", "edge")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if cp.Version != "v1" {
+ t.Fatalf("version: %s", cp.Version)
+ }
+ if g := pointerGrant(t, fx, "edge"); g == nil || g["name"] != "deploy.ci" {
+ t.Fatalf("rollback grant: %v", g)
+ }
+}
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 51af650d7..63371612d 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -140,3 +140,4 @@ plan14-root-reads-gvisor-update-dirs.tsv 1f1b2fdb569b7be42e75e10d1943d7e51270829
plan14-root-reads-region-ha-held-build.tsv beb085e4c6cdb3d430d12a8dc3c93f25cc3faf1aa7d62be37698ff9c9c82ecce
plan14-root-reads-fixedbox-health-alarms.tsv 0f7153571df8c1b4b50c31f57efcfdf60c71a12c80fd935fb3ea202fa0201dd5
plan14-root-reads-fixed-host-ignore-user-data.tsv 250e3ba91e1bc5fcd6be5cc2bafce4c7d6645d2d2f0c080913b99f01b1d19129
+plan14-root-reads-deploy-edge-718.tsv 250e3ba91e1bc5fcd6be5cc2bafce4c7d6645d2d2f0c080913b99f01b1d19129
diff --git a/internal/provision/testdata/plan14-root-reads-deploy-edge-718.tsv b/internal/provision/testdata/plan14-root-reads-deploy-edge-718.tsv
new file mode 100644
index 000000000..1832650c1
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-deploy-edge-718.tsv
@@ -0,0 +1,3 @@
+# Census overlay deploy-edge-718, written by census-propose (#369). census-ruling-deploy-edge-718, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-deploy-edge-718.md.
+# 0 body, 0 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+@coverage . b988bc9ed43b956dbda0907c623554df11d014c9bdcadc2aaecdc88fc5ac738a
diff --git a/pipeline.go b/pipeline.go
index 88889ea30..addb49c41 100644
--- a/pipeline.go
+++ b/pipeline.go
@@ -260,12 +260,7 @@ func runPipelineShow(args []string) {
log.Fatal(err)
}
channels := pipelineOrDefault(p)
- // A single-channel pipeline (the "no pipeline.json" default, or a real
- // one-channel pipeline someone composed down to that) is not shown as a
- // one-row ladder table — there is no order or rule to tabulate yet, and
- // a table with one row reads as ceremony around nothing (Task 10
- // controller ruling 5). The hint names the one command that grows it.
- if len(channels) == 1 {
+ if len(channels) == 1 && channels[0] == (apiPipelineChannel{Name: "edge"}) {
fmt.Fprintf(stdout, "%s — one channel, no pipeline set (carlos pipeline init --template edge-production|full-ladder adds more)\n",
channels[0].Name)
} else {
diff --git a/pipeline_test.go b/pipeline_test.go
index 28948b6c5..76e3605be 100644
--- a/pipeline_test.go
+++ b/pipeline_test.go
@@ -547,3 +547,43 @@ func TestPipelineDirectModeRefused(t *testing.T) {
t.Fatal("want direct mode (nil session) with CARLOS_DEPLOYMENT_DIR set")
}
}
+
+func TestPipelineShowSingleChannelRules(t *testing.T) {
+ for _, tc := range []struct {
+ name string
+ channel apiPipelineChannel
+ defaultPipeline bool
+ }{
+ {"default", apiPipelineChannel{Name: "edge"}, true},
+ {"passkey", apiPipelineChannel{Name: "edge", Passkey: true}, false},
+ {"promote approvals", apiPipelineChannel{Name: "edge", PromoteApprovals: 1}, false},
+ {"change approvals", apiPipelineChannel{Name: "edge", ChangeApprovals: 1}, false},
+ {"bake", apiPipelineChannel{Name: "edge", Bake: "1h"}, false},
+ {"zero bake", apiPipelineChannel{Name: "edge", Bake: "0s"}, false},
+ {"custom", apiPipelineChannel{Name: "production"}, false},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ useTempCredentials(t)
+ clearDeploymentEnv(t)
+ mux := http.NewServeMux()
+ mux.HandleFunc("GET /api/cli/apps/"+apiTestAccount+"/titogo/pipeline", func(w http.ResponseWriter, r *http.Request) {
+ json.NewEncoder(w).Encode(map[string]any{"pipeline": apiPipeline{Channels: []apiPipelineChannel{tc.channel}}})
+ })
+ mux.HandleFunc("GET /api/cli/apps/"+apiTestAccount+"/titogo/pending", func(w http.ResponseWriter, r *http.Request) {
+ json.NewEncoder(w).Encode(map[string]any{"pending": []map[string]any{}})
+ })
+ ts := httptest.NewServer(mux)
+ defer ts.Close()
+ loginTo(t, ts.URL, "vicky@keymail.dev")
+ buf := captureStdout(t)
+ runPipeline([]string{"show", "-app", "titogo", "-account", apiTestAccount})
+ out := buf.String()
+ if strings.Contains(out, "no pipeline set") != tc.defaultPipeline {
+ t.Fatalf("unexpected description: %s", out)
+ }
+ if strings.Contains(out, "RULES") == tc.defaultPipeline {
+ t.Fatalf("unexpected table: %s", out)
+ }
+ })
+ }
+}