console: env Save shows the section unavailable on a seal-key read failure
Branch fix check P2-F1: configRefusalSealKey (only ever a storage failure in the seal check's key read) joins configRefusalStore in the form door's one unavailable/no-draft branch. JSON door unchanged. Guard closes the fixture database just before the writer.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
internal/console/envformgate_test.go+23 −0internal/console/envsave.go+11 −2
CI passed — run details
Intent
<task-notification> <task-id>bhe5ir6ie</task-id> <tool-use-id>toolu_0183gk19zoXAnZ3qg6x8tznp</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/abe35d56-e4c2-40df-9005-6e66b76b1f50/tasks/bhe5ir6ie.output</output-file> <status>completed</status> <summary>Background command "until [ -f .superpowers/sdd/2026-11-08-console-secrets/astra-census2.done ]; do sleep 30; done; cat .superpowers/sdd/2026-11-08-console-secrets/astra-census2-findings.md | cut -c1-800" completed (exit code 0)</summary> </task-notification>
Attributed to this commit: 9.79 g CO₂e (1,244,086 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on design-console-secrets, 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/console/envformgate_test.go b/internal/console/envformgate_test.go| index d1259fd85..2ef9be085 100644 |
| --- a/internal/console/envformgate_test.go |
| +++ b/internal/console/envformgate_test.go |
| @@ -623,3 +623,26 @@ func TestEnvSaveLateBundleReadRefused(t *testing.T) { |
| mustShowUnread(t, body, "fast-r3", "MODE", "NEW_SECRET", env, f.Get("sealed_to")) |
| }) |
| } |
| + |
| +// Branch fix check P2-F1: the seal check's key read is storage too. With |
| +// the console's database gone just before the writer, a Save carrying a |
| +// sealed secret writes nothing and draws the section unavailable, with |
| +// nothing posted drawn back. |
| +func TestEnvSaveSealKeyStorageFailureRefused(t *testing.T) { |
| + e := newEnvFx(t) |
| + e.saving() |
| + f := envFields(t, e.page(t)) |
| + env := e.seal(t, "late-seal") |
| + f.Set("new.default.MODE", "fast-seal") |
| + f.Set("newenv.default.NEW_SECRET", env) |
| + f.Set("fp.default.NEW_SECRET", f.Get("sealed_to")) |
| + f.Set("bundle", "default") |
| + envSaveBeforeWrite = func() { _ = e.fx.st.Close() } |
| + t.Cleanup(func() { envSaveBeforeWrite = nil }) |
| + status, body := e.post(t, f, "save") |
| + if status != http.StatusBadGateway { |
| + t.Fatalf("status = %d, want 502:\n%s", status, envBanner(body)) |
| + } |
| + e.noWrites(t) |
| + mustShowUnread(t, body, "fast-seal", "MODE", "NEW_SECRET", env, f.Get("sealed_to")) |
| +} |
diff --git a/internal/console/envsave.go b/internal/console/envsave.go| index 60b9e6e8d..be5392699 100644 |
| --- a/internal/console/envsave.go |
| +++ b/internal/console/envsave.go |
| @@ -107,6 +107,10 @@ func envOutcomeOf(c envPageCopy, bundle, title string, count int, keys []string, |
| return o |
| } |
| +// envSaveBeforeWrite, when set, runs in Save just before the shared |
| +// writer: a test hook, nil in production. |
| +var envSaveBeforeWrite func() |
| + |
| // envFormSave is Save: the staged bundle's one write at the version the |
| // page showed, then the outcome. The gates before it (membership, CSRF, the |
| // form's own refusals) are handleEnvForm's; the write boundary's rules |
| @@ -146,6 +150,9 @@ func (s *Server) envFormSave(w http.ResponseWriter, r *http.Request, p page, acc |
| ref = &configRefusal{Code: configRefusalConflict, Status: http.StatusConflict} |
| } else { |
| in, unset := d.writeInput() |
| + if envSaveBeforeWrite != nil { |
| + envSaveBeforeWrite() |
| + } |
| removed, ref = s.writeConfig(ctx, acct, p.AppName, d.envName(), &want, in, unset) |
| if ref == nil { |
| bundle := configBundleName(d.envName()) |
| @@ -165,8 +172,10 @@ func (s *Server) envFormSave(w http.ResponseWriter, r *http.Request, p page, acc |
| return |
| } |
| } |
| - if ref.Code == configRefusalStore { |
| - // Storage failed during the save: a read or a write, of any kind. |
| + if ref.Code == configRefusalStore || ref.Code == configRefusalSealKey { |
| + // Storage failed during the save: a read or a write, of any kind, |
| + // the seal check's key read included (configRefusalSealKey is only |
| + // ever a storage failure; a key that does not match is its own code). |
| // As for a read that failed when the page was assembled, the |
| // section is unavailable and nothing posted is drawn back (no |
| // draft, no values, no envelopes, no fingerprints). The one place |