carlos / platform Public

console: plans 4a review fixes (notice kept per episode, only for the banner served, current period only; warnings on upload and stream clients)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 34b6c5fd0cf05beb93dffbb0bccecc40f3b08cee parent 8fdccd3
14 files changed, +330 −67
  • auth.go +17 −4
  • docs/superpowers/notes/census-proposal-plans-4-notices-grace.md +7 −1
  • docs/superpowers/notes/plans-4a-ledger.md +7 −0
  • docs/superpowers/plans/2026-10-25-plans-4a-warnings-and-grace.md +12 −0
  • docs/superpowers/specs/CODEX-FINDINGS-PLANS-4A-CODE.md +53 −0
  • internal/console/plangrace.go +5 −3
  • internal/console/plangrace_store.go +27 −21
  • internal/console/plangrace_test.go +80 −2
  • internal/console/plangrace_view_test.go +27 −1
  • internal/console/plangracepass.go +43 −29
  • internal/console/server.go +9 −2
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −1
  • internal/provision/testdata/plan14-root-reads-plans-4-notices-grace.tsv +9 −3
  • planwarnings_test.go +33 −0

CI passed — run details

diff --git a/auth.go b/auth.go
index 81b995ed1..a721fa7bf 100644
--- a/auth.go
+++ b/auth.go
@@ -392,6 +392,9 @@ type consoleClient struct {
base string
token string
httpc *http.Client
+ // warn is the one plan-warning transport every request of this client
+ // goes through, JSON, upload or stream, so a warning prints once.
+ warn *planWarningTransport
}
func newConsoleClient(base, token string) *consoleClient {
@@ -400,10 +403,11 @@ func newConsoleClient(base, token string) *consoleClient {
// new host) and surfaces unreplayable POSTs as raw 3xx — both wrong.
// Refusing uniformly lets every method see the 3xx + Location, which
// consoleMoved (apimode.go) turns into an explanation and an offer.
- return &consoleClient{base: base, token: token, httpc: &http.Client{
+ warn := &planWarningTransport{out: os.Stderr}
+ return &consoleClient{base: base, token: token, warn: warn, httpc: &http.Client{
Timeout: 30 * time.Second,
CheckRedirect: neverFollow,
- Transport: &planWarningTransport{out: os.Stderr},
+ Transport: warn,
}}
}
@@ -530,7 +534,7 @@ func (c *consoleClient) doMultipartHeaders(ctx context.Context, method, path str
// A client of its own — see shipHTTPClientTimeout above — never c.httpc,
// whose 30s absolute Timeout is sized for the JSON verbs, not a large
// upload. Same no-redirect rule as c.httpc, same reason.
- client := &http.Client{Timeout: shipHTTPClientTimeout, CheckRedirect: neverFollow}
+ client := &http.Client{Timeout: shipHTTPClientTimeout, CheckRedirect: neverFollow, Transport: c.transport()}
res, err := client.Do(req)
if err != nil {
return 0, nil, err
@@ -572,7 +576,7 @@ func (c *consoleClient) doStream(ctx context.Context, method, path string, body
if c.token != "" {
req.Header.Set("Authorization", "Bearer "+c.token)
}
- client := &http.Client{Timeout: shipHTTPClientTimeout, CheckRedirect: neverFollow}
+ client := &http.Client{Timeout: shipHTTPClientTimeout, CheckRedirect: neverFollow, Transport: c.transport()}
res, err := client.Do(req)
if err != nil {
return nil, err
@@ -584,6 +588,15 @@ func (c *consoleClient) doStream(ctx context.Context, method, path string, body
return res, nil
}
+// transport is the client's plan-warning transport, or the default one
+// for a consoleClient built without newConsoleClient.
+func (c *consoleClient) transport() http.RoundTripper {
+ if c.warn == nil {
+ return http.DefaultTransport
+ }
+ return c.warn
+}
+
// neverFollow is the one redirect policy every console client uses.
func neverFollow(*http.Request, []*http.Request) error {
return http.ErrUseLastResponse
diff --git a/docs/superpowers/notes/census-proposal-plans-4-notices-grace.md b/docs/superpowers/notes/census-proposal-plans-4-notices-grace.md
index 307ec5fee..7b818539c 100644
--- a/docs/superpowers/notes/census-proposal-plans-4-notices-grace.md
+++ b/docs/superpowers/notes/census-proposal-plans-4-notices-grace.md
@@ -4,7 +4,10 @@ Ruling `census-ruling-plans-4-notices-grace`. Every change below keeps the dispo
| unit | change | read sites | what changed |
|---|---|---|---|
+| `auth.go` `consoleClient.doMultipartHeaders` | body | unchanged (1) | the upload client uses the console client's plan-warning transport (adds a request header, prints response warnings to stderr), the same timeout and no-redirect policy (Astra plans-4a finding 5). No read added. |
| `cmd/console/main.go` `serve` | body | unchanged (3) | starts one more claim worker, StartPlanGracePass (plans 4a), beside StartPlanLimitsPass; it returns at once with no plan catalog. No read added. |
+| `internal/console/plangrace_store.go` `Store.PutCapState` | body | unchanged (1) | the upsert keeps notice already recorded for the same episode (same period and first over) instead of overwriting it (Astra plans-4a finding 1). Same table, same one statement; no read added. |
+| `internal/console/plangrace_store.go` `Store.RecordCapNotice` | body | unchanged (1) | takes the rows as shown and updates only the matching episode (period and first over), never before the first over (Astra plans-4a finding 2). One parameterised UPDATE per shown row on the same table; no read added. |
| `internal/console/store.go` `Store.migrate` | body | unchanged (2) | calls migratePlanGrace last, which creates the console's own plan_cap_state table (plans 4a). No read added here; the new store units are the plans-4a-store decision. |
| `internal/console/templates/layout.html` `external` | body | unchanged (1) | the account layout renders .PlanNotices as banner lines above main content (plans 4a). No read added. |
@@ -14,11 +17,14 @@ Review: a model from the other family than the author reads the branch's diff ag
Recorded dispositions, which each change must still satisfy:
+- `auth.go` `consoleClient.doMultipartHeaders`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-pro-6214-service-runs;identity=the carlos CLI on the caller's own machine, as that caller: a person, or a server holding a run credential as CARLOS_SERVICE_TOKEN; no box unit runs carlos run;basis=new: consoleClient.doMultipartMethod's body moved here unchanged, plus caller-supplied request headers (a run's Idempotency-Key), set before the content type and the bearer, which they cannot override; its one site, io.ReadAll of the console's response body, is doMultipartMethod's, J4 root-input as that row was
- `cmd/console/main.go` `serve`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=PROPOSED-scan-demand-revival;basis=Console service wires the optional callback signer and starts the claim-guarded queue worker. The same three data path literals move; it does not add a privileged reader.;rev3=PROPOSED-email-signin;identity=the console (cmd/console serve under console.service, user carlos-console);basis=passes CARLOS_CONSOLE_NAME to NewServer as Config.ConsoleName, the name the console's emails use; the same three /data literals at the same offsets; no read added;rev3=PROPOSED-s3-change-index;identity=the console (cmd/console serve under console.service, user carlos-console);basis=arms the record view when CARLOS_CHANGE_INDEX=read (armChangeIndex) for the run and seed sweeps and starts its backstop loop; the same three /data literals at the same offsets; no read added;rev3=census-ruling-db-region-forward-2;identity=the console (cmd/console serve under console.service, user carlos-console);basis=parses CARLOS_DB_FORWARD (dbForward) into Config.DBForward and builds its http.Server with console.NewHTTPServer, the same two timeouts; the same three /data literals at the same offsets; no read added;rev3=census-ruling-sec-sidecar-create-gate;basis=serve now parses CARLOS_SIDECAR_ACCOUNTS (sidecarAccounts, a pure env parse with log.Fatalf on a bad or empty-list value) before opening anything and passes it into console.Config.SidecarAccounts. No read was added: the same 3 root read sites.;rev3=census-ruling-sec-mail-user-boundary;basis=reads CARLOS_MAIL_USER_BOUNDARY and passes it to mail.NewAWSProvisioner; runs the one-shot boundary sweep behind CARLOS_MAIL_BOUNDARY_SWEEP=1, refused under CARLOS_HOST_CLAIM;rev3=census-ruling-pro-6214-service-runs;basis=the console (cmd/console serve, user carlos-console): reads CARLOS_RUN_KEYS, an environment variable, into Config.RunKeysEnabled; keyed run creates are refused 503 keys_not_ready unless it is on; the same three /data literals; no read added
+- `internal/console/plangrace_store.go` `Store.PutCapState`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-plans-4a-store;basis=root-input; console SQL on its own plan_cap_state table, as its store siblings (J4); plans 4a warnings and grace, which refuse nothing
+- `internal/console/plangrace_store.go` `Store.RecordCapNotice`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-plans-4a-store;basis=root-input; console SQL on its own plan_cap_state table, as its store siblings (J4); plans 4a warnings and grace, which refuse nothing
- `internal/console/store.go` `Store.migrate`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input;rev3=PROPOSED-email-signin;identity=the console (cmd/console serve under console.service, user carlos-console);basis=adds the sessions.method column (default keymail, the backfill) and calls migrateEmailSignin; SQLite DDL on CONSOLE_DB; the existing site moves
- `internal/console/templates/layout.html` `external`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=PROPOSED-console-switcher-filter;basis=Account switcher adds a client-side filter box and a scrolling list; whole embedded template remains frozen as legacy UI input.;rev3=PROPOSED-email-signin;identity=the console (cmd/console serve under console.service, user carlos-console);basis=CSS only: email inputs styled as text inputs and sign-in form labels; whole embedded template remains frozen as legacy UI input;rev3=PROPOSED-console-brand-name;identity=the console (cmd/console serve under console.service, user carlos-console);basis=the tab title and header brand name the deployment ({{.Brand}}, CARLOS_CONSOLE_NAME); no new input.
-Seal: `72dc835c04caf5b2b49cc6ecbfd865bb3123b997ee932e8ab7c0df239935a26b` → `ed240f74c02aa1d27bd2705f03736163ceef58b4358700a8cd4a3cc42b0dcf69`.
+Seal: `72dc835c04caf5b2b49cc6ecbfd865bb3123b997ee932e8ab7c0df239935a26b` → `43e430a3b3edf9333bfe2c64f24ca9e4c04475dc45ae4983d4e8bcab6a9c0bc4`.
Overlay: `internal/provision/testdata/plan14-root-reads-plans-4-notices-grace.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
## Decision (hand-written, census-ruling-plans-4a-store)
diff --git a/docs/superpowers/notes/plans-4a-ledger.md b/docs/superpowers/notes/plans-4a-ledger.md
index 2fc5192b7..8e8f48be9 100644
--- a/docs/superpowers/notes/plans-4a-ledger.md
+++ b/docs/superpowers/notes/plans-4a-ledger.md
@@ -12,3 +12,10 @@ Task 5: complete (commits 9477549..74f4885, tests: sh -c 'go test ./internal/con
Task 6: Ruling: CLI warnings hook both gates — apiPrincipalAccount (wrapper) and apiAccountAppSaying — rather than renaming apiPrincipalAccountSaying (which would have been a removed+new census pair); the phase-1 move door, which calls the Saying form directly, carries no warning — cost if wrong: that one door prints no plan line.
Task 6: Ruling: the six new store units are a hand-written census decision overlay (plans-4a-store, legacy/accepted-legacy as console SQL on its own table, J4, Plan 1's disposition); approval goes to Astra with the final review per the census recipe — cost if wrong: an escalation to Paul.
Task 6: complete (commits 74f4885..802a3fe, tests: sh -c 'GOFLAGS=-buildvcs=false go test ./internal/provision/ -run 'Plan14RootReadCensus$|Plan9B8RecordWriteCensus$'' → ok github.com/carlosframework/platform/internal/provision (cached))
+Final: fixed (1) stale upsert erased notice — TestPutCapStateKeepsConcurrentNotice RED(mutation)→GREEN, suites green
+Final: fixed (2) notice not tied to the episode shown — TestRecordCapNoticeMatchesTheEpisodeShown RED(compile)→GREEN
+Final: fixed (3) error page could count as banner notice — TestBannerNoticeOnlyWhenRendered RED(compile)→GREEN
+Final: fixed (4) expired periods due/shown — TestExpiredPeriodIsNotDueOrShown RED(mutation)→GREEN
+Final: fixed (5) upload/stream clients bypassed warnings — TestUploadAndStreamClientsPrintWarnings RED(compile)→GREEN
+Final: Ruling: test fixture overRow now dates the first over at time.Now()-1h — page views and CLI record notice at the real clock, and notice before the first over no longer counts — cost if wrong: none (fixture only).
+Final: census — Astra approved every unit and envelope technically; the six plans-4a-store dispositions are a decision for Paul (census owner).
diff --git a/docs/superpowers/plans/2026-10-25-plans-4a-warnings-and-grace.md b/docs/superpowers/plans/2026-10-25-plans-4a-warnings-and-grace.md
index 4c92b7eaa..a103b6836 100644
--- a/docs/superpowers/plans/2026-10-25-plans-4a-warnings-and-grace.md
+++ b/docs/superpowers/plans/2026-10-25-plans-4a-warnings-and-grace.md
@@ -310,3 +310,15 @@ Disk per running thing is not measured here. It needs the box quota mechanism (P
## Done when
Every task's tests pass and Review Focus 1–5 are pinned. The census card is approved by Astra. CI is green after merging current main, and Astra's whole-branch review has no open Critical or Important finding.
+
+## Astra review (2026-10-25)
+
+Findings in `docs/superpowers/specs/CODEX-FINDINGS-PLANS-4A-CODE.md`: five Important, all fixed in one pass, each test-first.
+
+1. **The pass's upsert erased concurrent notice.** `PutCapState` now keeps notice already recorded for the same episode (same period and same first over). Covered by `TestPutCapStateKeepsConcurrentNotice`.
+2. **Notice was not tied to the episode shown.** `RecordCapNotice` now takes the rows as they were shown. It updates only the matching episode, and never with a time before the first over. Covered by `TestRecordCapNoticeMatchesTheEpisodeShown`.
+3. **An error page could count as notice.** `planBanner` records nothing now. `render` records notice only after it has written a page carrying the banner. Covered by `TestBannerNoticeOnlyWhenRendered`.
+4. **Expired periods stayed due.** `afterGraceDue` requires the current period, and `planNoticesOf(states, now)` hides rows from an ended day or month. Covered by `TestExpiredPeriodIsNotDueOrShown`.
+5. **Upload and stream clients skipped warnings.** One `planWarningTransport` per console client serves the JSON, upload and stream requests. Covered by `TestUploadAndStreamClientsPrintWarnings`.
+
+Census: Astra approved every unit and envelope technically. The six `plans-4a-store` dispositions are still a decision for the census owner.
diff --git a/docs/superpowers/specs/CODEX-FINDINGS-PLANS-4A-CODE.md b/docs/superpowers/specs/CODEX-FINDINGS-PLANS-4A-CODE.md
new file mode 100644
index 000000000..a5092e5a8
--- /dev/null
+++ b/docs/superpowers/specs/CODEX-FINDINGS-PLANS-4A-CODE.md
@@ -0,0 +1,53 @@
+Reviewed `8fdccd30d76124f7245d15a7604ec9d240e6755f` against `606afcb9c2ab7749ba7b5d54f5d93a54018f8bcd`. Five **Important** findings; no Critical findings.
+
+1. **Important — the hourly pass can erase recorded notice.**
+ [plangrace_store.go:82](/home/paulca/.cache/tmp/claude-1001/plans-4-notices-grace/internal/console/plangrace_store.go:82) unconditionally replaces `notice_at`. If the pass reads a row, an owner’s page or CLI request records notice, and the pass then upserts its snapshot, notice returns to zero. The email-marking upsert has the same problem. This violates Review Focus 1 without any usage or period change. Preserve concurrent notice within the same over-cap episode, using an atomic update or transaction.
+
+2. **Important — notice is not tied to the episode actually displayed.**
+ [plangrace_store.go:108](/home/paulca/.cache/tmp/claude-1001/plans-4-notices-grace/internal/console/plangrace_store.go:108) checks only account, cap, level and an empty notice timestamp. Across midnight, a request can read yesterday’s over-email row, the pass can replace it with today’s newly over row, and the request can credit yesterday’s warning to today’s episode. The supplied timestamp can even precede the new `first_over`. Match the observed period and episode when recording notice, and reject timestamps before `first_over`.
+
+3. **Important — an error page can count as banner notice.**
+ [plangracepass.go:242](/home/paulca/.cache/tmp/claude-1001/plans-4-notices-grace/internal/console/plangracepass.go:242) records notice while constructing page data. On the account home, this happens before `AppsIn` and `Assemble`; either can fail, causing [server.go:3246](/home/paulca/.cache/tmp/claude-1001/plans-4-notices-grace/internal/console/server.go:3246) to render a separate error page without the banner. An owner who never received the warning therefore starts the notice clock. Record notice only on the rendering path that actually serves the banner.
+
+4. **Important — expired periods remain eligible for `afterGraceDue`.**
+ [plangrace.go:122](/home/paulca/.cache/tmp/claude-1001/plans-4-notices-grace/internal/console/plangrace.go:122) does not compare `st.Period` with the current period. An October bandwidth row with notice received on October 25 becomes eligible on November 1, although November must start clean. This persists until successful reevaluation, and measurement failures deliberately retain the old row. Since Plan 4b consumes this predicate, it must reject expired daily/monthly periods. Warning readers also currently display those expired rows.
+
+5. **Important — upload and streaming clients bypass warnings.**
+ [auth.go:406](/home/paulca/.cache/tmp/claude-1001/plans-4-notices-grace/auth.go:406) installs the transport only on the JSON client. `doMultipartHeaders` and `doStream` construct separate clients at lines 533 and 575. A `carlos ship` with explicit account and app flags can make only the multipart request, so it neither requests nor prints the account warning. Share the warning transport with these clients while preserving their existing streaming deadlines and redirect policy.
+
+The SQL interleavings in findings 1–2 were reproduced using an in-memory SQLite database. Targeted Go tests could not start: the read-only sandbox denied creation of Go’s build directory.
+
+The other Review Focus checks look correct in sequential execution: evaluation preserves clocks within a period, clears them on recovery or rollover, and never rolls counts or sizes; members and undeclared old CLI requests earn no notice; successful reminders are spaced by 24 hours; unavailable delivery does not record email notice. Measurements use decimal GB, floor awake hours, treat missing statements as zero, and reject unswept storage. Owner filtering and account-scoped email data are intact. Plans-off guards suppress rows and warning output. The hourly reads are console-side; the pass adds no per-box polling, though it also lists instance keys for running-things counts.
+
+Census verdicts below answer the root-read safety question separately from these correctness findings.
+
+| Unit | Verdict and basis |
+|---|---|
+| [cmd/console/main.go:606](/home/paulca/.cache/tmp/claude-1001/plans-4-notices-grace/cmd/console/main.go:606), `serve` | **Approve.** Adds the registered worker; existing data paths and service identity remain unchanged. |
+| [store.go:552](/home/paulca/.cache/tmp/claude-1001/plans-4-notices-grace/internal/console/store.go:552), `Store.migrate` | **Approve.** Calls fixed-schema DDL on the existing console database. |
+| [layout.html:594](/home/paulca/.cache/tmp/claude-1001/plans-4-notices-grace/internal/console/templates/layout.html:594), `external` | **Approve.** Renders escaped strings through the embedded template; no new path or execution input. |
+| [plangrace_store.go:9](/home/paulca/.cache/tmp/claude-1001/plans-4-notices-grace/internal/console/plangrace_store.go:9), `Store.migratePlanGrace` | **Approve technically.** Literal DDL for the console’s own table. |
+| [plangrace_store.go:43](/home/paulca/.cache/tmp/claude-1001/plans-4-notices-grace/internal/console/plangrace_store.go:43), `Store.CapStates` | **Approve technically.** Parameterized account-scoped query. |
+| [plangrace_store.go:75](/home/paulca/.cache/tmp/claude-1001/plans-4-notices-grace/internal/console/plangrace_store.go:75), `Store.PutCapState` | **Approve technically.** Parameterized state write; no new privileged input path. |
+| [plangrace_store.go:90](/home/paulca/.cache/tmp/claude-1001/plans-4-notices-grace/internal/console/plangrace_store.go:90), `Store.DeleteCapState` | **Approve technically.** Parameterized deletion scoped to account and cap. |
+| [plangrace_store.go:98](/home/paulca/.cache/tmp/claude-1001/plans-4-notices-grace/internal/console/plangrace_store.go:98), `Store.RecordCapNotice` | **Approve technically.** Dynamic SQL contains placeholder punctuation only; values remain bound parameters. |
+| [mailcounts.go:325](/home/paulca/.cache/tmp/claude-1001/plans-4-notices-grace/internal/console/mailcounts.go:325), `Store.AccountSends` | **Approve technically.** Parameterized account/day aggregate over existing console data. |
+
+The six new `plans-4a-store` dispositions remain census-owner decisions under the repository policy; technical approval does not substitute for that classification ruling.
+
+| Re-pinned envelope | Verdict |
+|---|---|
+| `.` | **Approve.** Transport wrapper adds header handling and stderr output; no privileged reader added. |
+| `cmd/console` | **Approve.** Worker startup preserves existing authority boundaries. |
+| `internal/console` | **Approve.** Fixed-table SQL, authenticated warning gates, owner-only delivery, and usage reads keyed by resolved account and server-generated dates; no root input boundary weakened. |
+| `internal/console/templates` | **Approve.** Embedded, escaped banner rendering. |
+| `internal/usage` | **Approve.** Statement read uses the existing store and key shape; the new caller supplies resolved account and calendar month. |
+
+Independently verified all nine unit digests, five envelope fingerprints, legacy fingerprints, and both overlay seals:
+
+- `plans-4a-store`: `539ae875…` → `72dc835c…`
+- `plans-4-notices-grace`: `72dc835c…` → `ed240f74…`
+
+HEAD and the working tree remain unchanged. Copy wording was not reviewed.
+
+**Verdict: changes required.**
\ No newline at end of file
diff --git a/internal/console/plangrace.go b/internal/console/plangrace.go
index 9be794f19..5d5def9c7 100644
--- a/internal/console/plangrace.go
+++ b/internal/console/plangrace.go
@@ -117,9 +117,11 @@ func evaluateCap(prev *capState, c capID, used, limit int64, now time.Time) capS
return next
}
-// afterGraceDue is whether an after-grace stage may start (spec §6): over,
-// grace run out, and an owner received notice at least 3 days before now.
+// afterGraceDue is whether an after-grace stage may start (spec §6): over
+// in the current period (a row from an ended day or month is never due,
+// Astra plans-4a finding 4), grace run out, and an owner received notice
+// at least 3 days before now.
func afterGraceDue(st capState, now time.Time) bool {
- return st.Level.over() && !st.GraceEnds.IsZero() && !now.Before(st.GraceEnds) &&
+ return st.Period == capPeriod(st.Cap, now) && st.Level.over() && !st.GraceEnds.IsZero() && !now.Before(st.GraceEnds) &&
!st.NoticeAt.IsZero() && !st.NoticeAt.After(now.Add(-72*time.Hour))
}
diff --git a/internal/console/plangrace_store.go b/internal/console/plangrace_store.go
index 46f4329aa..d4eeae170 100644
--- a/internal/console/plangrace_store.go
+++ b/internal/console/plangrace_store.go
@@ -1,9 +1,6 @@
package console
-import (
- "strings"
- "time"
-)
+import "time"
// Plans 4a's own table, kept here so the feature is one file to read.
func (s *Store) migratePlanGrace() error {
@@ -71,7 +68,10 @@ func (s *Store) CapStates(accountID int64) ([]capState, error) {
return out, nil
}
-// PutCapState writes the row for (s.AccountID, s.Cap), replacing any.
+// PutCapState writes the row for (s.AccountID, s.Cap), replacing any, except
+// that notice already recorded for the same episode (same period, same
+// first over) is kept: a page view or CLI request may record notice
+// between the pass's read and this write (Astra plans-4a finding 1).
func (s *Store) PutCapState(st capState) error {
_, err := s.db.Exec(`INSERT INTO plan_cap_state (account_id, cap, period, level, used, cap_limit,
first_over, grace_ends, warned_at, reminded_at, notice_at, updated_at)
@@ -79,7 +79,12 @@ func (s *Store) PutCapState(st capState) error {
ON CONFLICT(account_id, cap) DO UPDATE SET period = excluded.period, level = excluded.level,
used = excluded.used, cap_limit = excluded.cap_limit, first_over = excluded.first_over,
grace_ends = excluded.grace_ends, warned_at = excluded.warned_at, reminded_at = excluded.reminded_at,
- notice_at = excluded.notice_at, updated_at = excluded.updated_at`,
+ notice_at = CASE
+ WHEN plan_cap_state.period = excluded.period AND plan_cap_state.first_over = excluded.first_over
+ AND excluded.first_over <> 0 AND plan_cap_state.notice_at <> 0
+ AND (excluded.notice_at = 0 OR plan_cap_state.notice_at < excluded.notice_at)
+ THEN plan_cap_state.notice_at ELSE excluded.notice_at END,
+ updated_at = excluded.updated_at`,
st.AccountID, string(st.Cap), st.Period, string(st.Level), st.Used, st.Limit,
unixOrZero(st.FirstOver), unixOrZero(st.GraceEnds), unixOrZero(st.WarnedAt),
unixOrZero(st.RemindedAt), unixOrZero(st.NoticeAt), unixOrZero(st.UpdatedAt))
@@ -92,20 +97,21 @@ func (s *Store) DeleteCapState(accountID int64, c capID) error {
return err
}
-// RecordCapNotice records that an owner received notice of caps at `at`.
-// Only notice after a cap went over counts (spec §6), and the first such
-// notice is the one kept.
-func (s *Store) RecordCapNotice(accountID int64, caps []capID, at time.Time) error {
- if len(caps) == 0 {
- return nil
- }
- args := []any{at.Unix(), accountID}
- marks := make([]string, len(caps))
- for i, c := range caps {
- marks[i] = "?"
- args = append(args, string(c))
+// RecordCapNotice records that an owner received notice, at `at`, of the
+// caps in seen: the rows as the owner was shown them. Notice counts only
+// for the episode shown (same period and first over, Astra plans-4a
+// finding 2), only once the cap was over and not before it went over
+// (spec §6), and the first such notice is kept.
+func (s *Store) RecordCapNotice(accountID int64, seen []capState, at time.Time) error {
+ for _, st := range seen {
+ if !st.Level.over() || st.FirstOver.IsZero() || at.Before(st.FirstOver) {
+ continue
+ }
+ if _, err := s.db.Exec(`UPDATE plan_cap_state SET notice_at = ? WHERE account_id = ? AND cap = ?
+ AND period = ? AND first_over = ? AND level IN ('over', 'ceiling') AND notice_at = 0`,
+ at.Unix(), accountID, string(st.Cap), st.Period, st.FirstOver.Unix()); err != nil {
+ return err
+ }
}
- _, err := s.db.Exec(`UPDATE plan_cap_state SET notice_at = ? WHERE account_id = ?
- AND cap IN (`+strings.Join(marks, ",")+`) AND level IN ('over', 'ceiling') AND notice_at = 0`, args...)
- return err
+ return nil
}
diff --git a/internal/console/plangrace_test.go b/internal/console/plangrace_test.go
index af4f36074..4243c0082 100644
--- a/internal/console/plangrace_test.go
+++ b/internal/console/plangrace_test.go
@@ -140,10 +140,10 @@ func TestRecordCapNoticeOnlyWhenOver(t *testing.T) {
t.Fatal(err)
}
}
- if err := fx.st.RecordCapNotice(acct.ID, []capID{capEmail, capStorage}, planNow); err != nil {
+ if err := fx.st.RecordCapNotice(acct.ID, []capState{warn, over}, planNow); err != nil {
t.Fatal(err)
}
- if err := fx.st.RecordCapNotice(acct.ID, []capID{capStorage}, planNow.Add(time.Hour)); err != nil {
+ if err := fx.st.RecordCapNotice(acct.ID, []capState{over}, planNow.Add(time.Hour)); err != nil {
t.Fatal(err)
}
got, _ := fx.st.CapStates(acct.ID)
@@ -160,3 +160,81 @@ func TestRecordCapNoticeOnlyWhenOver(t *testing.T) {
}
}
}
+
+// Astra plans-4a finding 1: the pass's snapshot upsert must not erase
+// notice recorded between its read and its write, within one episode.
+func TestPutCapStateKeepsConcurrentNotice(t *testing.T) {
+ fx := newConsoleFixture(t)
+ acct, _ := fx.st.AccountBySqid(fx.sqid)
+ st := evaluateCap(nil, capStorage, 150, 100, planNow)
+ st.AccountID = acct.ID
+ if err := fx.st.PutCapState(st); err != nil {
+ t.Fatal(err)
+ }
+ snapshot := st // the pass read this before the owner's page view
+ if err := fx.st.RecordCapNotice(acct.ID, []capState{st}, planNow.Add(time.Minute)); err != nil {
+ t.Fatal(err)
+ }
+ snapshot.Used, snapshot.UpdatedAt = 160, planNow.Add(2*time.Minute)
+ if err := fx.st.PutCapState(snapshot); err != nil {
+ t.Fatal(err)
+ }
+ if got, _ := capRow(t, fx, acct, capStorage); !got.NoticeAt.Equal(planNow.Add(time.Minute).UTC().Truncate(time.Second)) {
+ t.Fatalf("notice after a stale upsert = %v, want the recorded one", got.NoticeAt)
+ }
+ // A new episode (a different first over) replaces it.
+ fresh := evaluateCap(nil, capStorage, 150, 100, planNow.Add(48*time.Hour))
+ fresh.AccountID = acct.ID
+ if err := fx.st.PutCapState(fresh); err != nil {
+ t.Fatal(err)
+ }
+ if got, _ := capRow(t, fx, acct, capStorage); !got.NoticeAt.IsZero() {
+ t.Fatalf("new episode kept the old notice %v", got.NoticeAt)
+ }
+}
+
+// Finding 2: notice counts only for the episode the owner was shown.
+func TestRecordCapNoticeMatchesTheEpisodeShown(t *testing.T) {
+ fx := newConsoleFixture(t)
+ acct, _ := fx.st.AccountBySqid(fx.sqid)
+ yesterday := evaluateCap(nil, capEmail, 150, 100, planNow.Add(-24*time.Hour))
+ yesterday.AccountID = acct.ID
+ if err := fx.st.PutCapState(yesterday); err != nil {
+ t.Fatal(err)
+ }
+ today := evaluateCap(nil, capEmail, 150, 100, planNow)
+ today.AccountID = acct.ID
+ if err := fx.st.PutCapState(today); err != nil { // the pass rolled the day after the page read yesterday's row
+ t.Fatal(err)
+ }
+ if err := fx.st.RecordCapNotice(acct.ID, []capState{yesterday}, planNow); err != nil {
+ t.Fatal(err)
+ }
+ if got, _ := capRow(t, fx, acct, capEmail); !got.NoticeAt.IsZero() {
+ t.Fatalf("yesterday's warning counted as notice for today: %v", got.NoticeAt)
+ }
+ if err := fx.st.RecordCapNotice(acct.ID, []capState{today}, planNow.Add(-time.Minute)); err != nil {
+ t.Fatal(err)
+ }
+ if got, _ := capRow(t, fx, acct, capEmail); !got.NoticeAt.IsZero() {
+ t.Fatalf("notice dated before the first over counted: %v", got.NoticeAt)
+ }
+}
+
+// Finding 4: a daily or monthly row from an ended period is never due,
+// and is not shown.
+func TestExpiredPeriodIsNotDueOrShown(t *testing.T) {
+ oct := time.Date(2026, 10, 20, 12, 0, 0, 0, time.UTC)
+ st := evaluateCap(nil, capBandwidth, 150, 100, oct)
+ st.NoticeAt = oct.Add(5 * 24 * time.Hour)
+ nov := time.Date(2026, 11, 1, 0, 0, 0, 0, time.UTC)
+ if afterGraceDue(st, nov) {
+ t.Error("October's bandwidth row is due in November")
+ }
+ if got := planNoticesOf([]capState{st}, nov); len(got) != 0 {
+ t.Errorf("October's row shown in November: %v", got)
+ }
+ if got := planNoticesOf([]capState{st}, oct.Add(time.Hour)); len(got) != 1 {
+ t.Errorf("current row not shown: %v", got)
+ }
+}
diff --git a/internal/console/plangrace_view_test.go b/internal/console/plangrace_view_test.go
index cd44e5884..c35342f57 100644
--- a/internal/console/plangrace_view_test.go
+++ b/internal/console/plangrace_view_test.go
@@ -1,8 +1,11 @@
package console
import (
+ "net/http"
+ "net/http/httptest"
"strings"
"testing"
+ "time"
)
// overRow puts the ops account over its storage cap under the example
@@ -11,7 +14,9 @@ func overRow(t *testing.T, fx *consoleFixture) *Account {
t.Helper()
fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
acct, _ := fx.st.AccountBySqid(fx.sqid)
- st := evaluateCap(nil, capStorage, 2_000_000_000, 1_000_000_000, planNow)
+ // The real clock: page views and CLI requests record notice at
+ // time.Now(), which must not fall before the first over.
+ st := evaluateCap(nil, capStorage, 2_000_000_000, 1_000_000_000, time.Now().Add(-time.Hour))
st.AccountID = acct.ID
if err := fx.st.PutCapState(st); err != nil {
t.Fatal(err)
@@ -62,3 +67,24 @@ func TestBannerWithoutACatalogUnchanged(t *testing.T) {
t.Fatal("plan banner with no catalog")
}
}
+
+// Finding 3: notice is the banner actually served, not the page data built.
+func TestBannerNoticeOnlyWhenRendered(t *testing.T) {
+ fx := newConsoleFixture(t)
+ acct := overRow(t, fx)
+ req := httptest.NewRequest(http.MethodGet, fx.u("/"), nil)
+ rec := httptest.NewRecorder()
+ p := fx.srv.accountPage(rec, req, "paul@keymail.dev", "csrf", acct, RoleOwner)
+ if st, _ := capRow(t, fx, acct, capStorage); !st.NoticeAt.IsZero() {
+ t.Fatal("building page data recorded notice")
+ }
+ fx.srv.renderMessage(rec, req, http.StatusInternalServerError, "Error", "boom") // an error page instead
+ if st, _ := capRow(t, fx, acct, capStorage); !st.NoticeAt.IsZero() {
+ t.Fatal("an error page recorded notice")
+ }
+ p.Title, p.Msg = "Apps", "ok"
+ fx.srv.render(httptest.NewRecorder(), http.StatusOK, "message", p)
+ if st, _ := capRow(t, fx, acct, capStorage); st.NoticeAt.IsZero() {
+ t.Fatal("a rendered banner recorded no notice")
+ }
+}
diff --git a/internal/console/plangracepass.go b/internal/console/plangracepass.go
index 1ee97b3c5..9e126ab88 100644
--- a/internal/console/plangracepass.go
+++ b/internal/console/plangracepass.go
@@ -144,25 +144,23 @@ func (s *Server) notifyPlanOwners(ctx context.Context, acct *Account, states []c
if !delivered {
return nil
}
- var noticed []capID
for _, st := range due {
if st.WarnedAt.IsZero() {
st.WarnedAt = now
}
if st.Level.over() {
st.RemindedAt = now
- noticed = append(noticed, st.Cap)
}
if err := s.store.PutCapState(st); err != nil {
return err
}
}
- return s.store.RecordCapNotice(acct.ID, noticed, now)
+ return s.store.RecordCapNotice(acct.ID, due, now)
}
func (s *Server) planNoticeEmail(acct *Account, due []capState) (string, string) {
lines := []string{fmt.Sprintf(planNoticeCopy["email.intro"], acct.Sqid), ""}
- for _, n := range planNoticesOf(due) {
+ for _, n := range planNoticesOf(due, time.Now()) {
lines = append(lines, planNoticeText(n, "email"))
}
settings := s.cfg.Origin + "/a/" + url.PathEscape(acct.Sqid) + "/settings"
@@ -178,12 +176,13 @@ type planNotice struct {
GraceEnds time.Time
}
-// planNoticesOf is the caps at warn or over, in capOrder.
-func planNoticesOf(states []capState) []planNotice {
+// planNoticesOf is the caps at warn or over in the current period, in
+// capOrder. A row left from an ended day or month is not shown.
+func planNoticesOf(states []capState, now time.Time) []planNotice {
var out []planNotice
for _, c := range capOrder {
for _, st := range states {
- if st.Cap == c && (st.Level == levelWarn || st.Level.over()) {
+ if st.Cap == c && st.Period == capPeriod(c, now) && (st.Level == levelWarn || st.Level.over()) {
out = append(out, planNotice{Cap: st.Cap, Level: st.Level, Used: st.Used, Limit: st.Limit, GraceEnds: st.GraceEnds})
}
}
@@ -218,32 +217,49 @@ func humanGB(b int64) string {
}
// planBanner is the account page's plan warnings, one line per cap at warn
-// or over. An owner seeing a cap that is over is notice received (spec §6);
-// a member seeing it is not. A store error shows no banner and never fails
-// the page.
-func (s *Server) planBanner(acct *Account, role string, now time.Time) []string {
+// or over, and the rows behind them when the viewer is an owner. It records
+// nothing: notice is the banner actually served, so render records it once
+// the page is written (Astra plans-4a finding 3). A store error shows no
+// banner and never fails the page.
+func (s *Server) planBanner(acct *Account, role string, now time.Time) ([]string, []capState) {
if s.cfg.PlanCatalog == nil {
- return nil
+ return nil, nil
}
states, err := s.store.CapStates(acct.ID)
if err != nil {
log.Printf("console: plan banner %s: %v", acct.Sqid, err)
- return nil
+ return nil, nil
}
var lines []string
- var over []capID
- for _, n := range planNoticesOf(states) {
+ for _, n := range planNoticesOf(states, now) {
lines = append(lines, planNoticeText(n, "banner"))
- if n.Level.over() {
- over = append(over, n.Cap)
- }
}
- if role == RoleOwner && len(over) > 0 {
- if err := s.store.RecordCapNotice(acct.ID, over, now); err != nil {
- log.Printf("console: plan banner %s: notice: %v", acct.Sqid, err)
+ if role != RoleOwner || len(lines) == 0 {
+ return lines, nil
+ }
+ return lines, shownStates(states, now)
+}
+
+// shownStates is the rows planNoticesOf shows, for recording notice.
+func shownStates(states []capState, now time.Time) []capState {
+ var out []capState
+ for _, st := range states {
+ if st.Period == capPeriod(st.Cap, now) && st.Level.over() {
+ out = append(out, st)
}
}
- return lines
+ return out
+}
+
+// recordBannerNotice records notice for a page whose banner was served to
+// an owner.
+func (s *Server) recordBannerNotice(accountID int64, seen []capState, now time.Time) {
+ if len(seen) == 0 {
+ return
+ }
+ if err := s.store.RecordCapNotice(accountID, seen, now); err != nil {
+ log.Printf("console: plan banner %d: notice: %v", accountID, err)
+ }
}
// planWarningsAccept is the request header by which a CLI says it prints
@@ -266,17 +282,15 @@ func (s *Server) writePlanWarnings(w http.ResponseWriter, r *http.Request, p Pri
log.Printf("console: plan warnings %s: %v", acct.Sqid, err)
return
}
- var over []capID
- for _, n := range planNoticesOf(states) {
+ now := time.Now()
+ for _, n := range planNoticesOf(states, now) {
w.Header().Add(planWarningHeader, planNoticeText(n, "cli"))
- if n.Level.over() {
- over = append(over, n.Cap)
- }
}
- if len(over) == 0 || p.Kind != PrincipalUser || !s.isOwner(acct, p.Address) {
+ seen := shownStates(states, now)
+ if len(seen) == 0 || p.Kind != PrincipalUser || !s.isOwner(acct, p.Address) {
return
}
- if err := s.store.RecordCapNotice(acct.ID, over, time.Now()); err != nil {
+ if err := s.store.RecordCapNotice(acct.ID, seen, now); err != nil {
log.Printf("console: plan warnings %s: notice: %v", acct.Sqid, err)
}
}
diff --git a/internal/console/server.go b/internal/console/server.go
index 894e5ead2..7d06a3500 100644
--- a/internal/console/server.go
+++ b/internal/console/server.go
@@ -1880,7 +1880,11 @@ type page struct {
// PlanNotices are the account's plan warnings (plans 4a), one banner
// line each; nil when plans are off or nothing is near a limit.
PlanNotices []string
- FlashErr string // one-shot error notice
+ // planSeen are the over rows behind PlanNotices when the viewer owns
+ // the account; render records them as notice once the page is written.
+ planSeen []capState
+ planAcctID int64
+ FlashErr string // one-shot error notice
Apps []appRow // account home
Detail *AppView // /a/{sqid}/apps/{app}
@@ -2203,7 +2207,9 @@ func (s *Server) render(w http.ResponseWriter, status int, name string, p page)
w.WriteHeader(status)
if err := templates.ExecuteTemplate(w, name, p); err != nil {
log.Printf("console: render %s: %v", name, err)
+ return
}
+ s.recordBannerNotice(p.planAcctID, p.planSeen, time.Now()) // plans 4a: the banner was served
}
func (s *Server) renderMessage(w http.ResponseWriter, r *http.Request, status int, title, msg string) {
@@ -3358,7 +3364,8 @@ func (s *Server) accountPage(w http.ResponseWriter, r *http.Request, addr, raw s
p.Accounts[i].Seg = preferredSeg(p.Accounts, &p.Accounts[i])
}
p.Nav = "/a/" + url.PathEscape(preferredSeg(p.Accounts, acct))
- p.PlanNotices = s.planBanner(acct, role, time.Now())
+ p.PlanNotices, p.planSeen = s.planBanner(acct, role, time.Now())
+ p.planAcctID = acct.ID
return p
}
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index f9a349337..024e21cd2 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -20,4 +20,4 @@ plan14-root-reads-edge-request-records-decisions.tsv c6dfb1753f33c96aee894496c2e
plan14-root-reads-edge-request-records.tsv 84cb1e17c2f9cabddcc1e6ed5b39b00ffa70395639b4418c2cc5cf9b444b3eee
plan14-root-reads-data-lifecycle-336.tsv 539ae875b4a089bc6512ae2e047fa9e353e8b760c18312b81ec3400e5e1f6d48
plan14-root-reads-plans-4a-store.tsv 72dc835c04caf5b2b49cc6ecbfd865bb3123b997ee932e8ab7c0df239935a26b
-plan14-root-reads-plans-4-notices-grace.tsv ed240f74c02aa1d27bd2705f03736163ceef58b4358700a8cd4a3cc42b0dcf69
+plan14-root-reads-plans-4-notices-grace.tsv 43e430a3b3edf9333bfe2c64f24ca9e4c04475dc45ae4983d4e8bcab6a9c0bc4
diff --git a/internal/provision/testdata/plan14-root-reads-plans-4-notices-grace.tsv b/internal/provision/testdata/plan14-root-reads-plans-4-notices-grace.tsv
index f6e03d5fb..a199b3249 100644
--- a/internal/provision/testdata/plan14-root-reads-plans-4-notices-grace.tsv
+++ b/internal/provision/testdata/plan14-root-reads-plans-4-notices-grace.tsv
@@ -1,13 +1,19 @@
# Census overlay plans-4-notices-grace, written by census-propose (#369). census-ruling-plans-4-notices-grace, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-plans-4-notices-grace.md.
-# 3 body, 0 sites, 5 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+# 6 body, 0 sites, 5 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+@legacy 6e2f8266b9c9221cdfb17d4fcf80850e42b2d0c2f1d8942f0caf8ec7ab7ce922 auth.go consoleClient.doMultipartHeaders legacy accepted-legacy accepted-legacy;rev3=census-ruling-pro-6214-service-runs;identity=the carlos CLI on the caller's own machine, as that caller: a person, or a server holding a run credential as CARLOS_SERVICE_TOKEN; no box unit runs carlos run;basis=new: consoleClient.doMultipartMethod's body moved here unchanged, plus caller-supplied request headers (a run's Idempotency-Key), set before the content type and the bearer, which they cannot override; its one site, io.ReadAll of the console's response body, is doMultipartMethod's, J4 root-input as that row was;rev3=census-ruling-plans-4-notices-grace;basis=the upload client uses the console client's plan-warning transport (adds a request header, prints response warnings to stderr), the same timeout and no-redirect policy (Astra plans-4a finding 5). No read added. file:ReadAll@1444 ee551468bd7212e7274f9d730b44ce4238b49300b53ee278919f1b5cb78c1b0d
@legacy 2f0f5af4e34aba5036f0859b93672647d00b20674a5584e138d549b4a0470a77 cmd/console/main.go serve legacy accepted-legacy accepted-legacy;rev3=PROPOSED-scan-demand-revival;basis=Console service wires the optional callback signer and starts the claim-guarded queue worker. The same three data path literals move; it does not add a privileged reader.;rev3=PROPOSED-email-signin;identity=the console (cmd/console serve under console.service, user carlos-console);basis=passes CARLOS_CONSOLE_NAME to NewServer as Config.ConsoleName, the name the console's emails use; the same three /data literals at the same offsets; no read added;rev3=PROPOSED-s3-change-index;identity=the console (cmd/console serve under console.service, user carlos-console);basis=arms the record view when CARLOS_CHANGE_INDEX=read (armChangeIndex) for the run and seed sweeps and starts its backstop loop; the same three /data literals at the same offsets; no read added;rev3=census-ruling-db-region-forward-2;identity=the console (cmd/console serve under console.service, user carlos-console);basis=parses CARLOS_DB_FORWARD (dbForward) into Config.DBForward and builds its http.Server with console.NewHTTPServer, the same two timeouts; the same three /data literals at the same offsets; no read added;rev3=census-ruling-sec-sidecar-create-gate;basis=serve now parses CARLOS_SIDECAR_ACCOUNTS (sidecarAccounts, a pure env parse with log.Fatalf on a bad or empty-list value) before opening anything and passes it into console.Config.SidecarAccounts. No read was added: the same 3 root read sites.;rev3=census-ruling-sec-mail-user-boundary;basis=reads CARLOS_MAIL_USER_BOUNDARY and passes it to mail.NewAWSProvisioner; runs the one-shot boundary sweep behind CARLOS_MAIL_BOUNDARY_SWEEP=1, refused under CARLOS_HOST_CLAIM;rev3=census-ruling-pro-6214-service-runs;basis=the console (cmd/console serve, user carlos-console): reads CARLOS_RUN_KEYS, an environment variable, into Config.RunKeysEnabled; keyed run creates are refused 503 keys_not_ready unless it is on; the same three /data literals; no read added;rev3=census-ruling-plans-4-notices-grace;basis=starts one more claim worker, StartPlanGracePass (plans 4a), beside StartPlanLimitsPass; it returns at once with no plan catalog. No read added. data-literal@4601,data-literal@5702,data-literal@5939 349665021854fbb10f1a091f8b76a066c2ec565c02b001bb9a88cd28e7ab9a20
+@legacy 1e53d248b8ade24b47c7f3a8ae4220ef0d32ee2cc08b593361c4d9846f6e67c3 internal/console/plangrace_store.go Store.PutCapState legacy accepted-legacy accepted-legacy;rev3=census-ruling-plans-4a-store;basis=root-input; console SQL on its own plan_cap_state table, as its store siblings (J4); plans 4a warnings and grace, which refuse nothing;rev3=census-ruling-plans-4-notices-grace;basis=the upsert keeps notice already recorded for the same episode (same period and first over) instead of overwriting it (Astra plans-4a finding 1). Same table, same one statement; no read added. file:Exec@60 4baf1db18c1032ab1c3345698c685c8bd45deb8a13167b24980e826ec93a08f4
+@legacy ed155196c4385de84da7c752a4ad92fa0636e3b25bb11433d18202aefdb51420 internal/console/plangrace_store.go Store.RecordCapNotice legacy accepted-legacy accepted-legacy;rev3=census-ruling-plans-4a-store;basis=root-input; console SQL on its own plan_cap_state table, as its store siblings (J4); plans 4a warnings and grace, which refuse nothing;rev3=census-ruling-plans-4-notices-grace;basis=takes the rows as shown and updates only the matching episode (period and first over), never before the first over (Astra plans-4a finding 2). One parameterised UPDATE per shown row on the same table; no read added. file:Exec@222 806dafee3937e3b79a0c306652b08d0d9b19e27115fd576cb66164124fd64df0
@legacy fcb52ef5b07b838596659cdefd7951e12d75dcbfd561e35a7ad0c32634430e7b internal/console/store.go Store.migrate legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=PROPOSED-email-signin;identity=the console (cmd/console serve under console.service, user carlos-console);basis=adds the sessions.method column (default keymail, the backfill) and calls migrateEmailSignin; SQLite DDL on CONSOLE_DB; the existing site moves;rev3=census-ruling-plans-4-notices-grace;basis=calls migratePlanGrace last, which creates the console's own plan_cap_state table (plans 4a). No read added here; the new store units are the plans-4a-store decision. file:Exec@12017,file:Exec@18103 0f08bad811be1e11fa9c1d135fbb5bf99120afa850a8f595a39e6612f7d6c69f
@legacy 28f23b6734a5104bbb023381c91fc7bd0f16e528a2a959ff8c1faa74cb60a93e internal/console/templates/layout.html external legacy accepted-legacy accepted-legacy;rev3=PROPOSED-console-switcher-filter;basis=Account switcher adds a client-side filter box and a scrolling list; whole embedded template remains frozen as legacy UI input.;rev3=PROPOSED-email-signin;identity=the console (cmd/console serve under console.service, user carlos-console);basis=CSS only: email inputs styled as text inputs and sign-in form labels; whole embedded template remains frozen as legacy UI input;rev3=PROPOSED-console-brand-name;identity=the console (cmd/console serve under console.service, user carlos-console);basis=the tab title and header brand name the deployment ({{.Brand}}, CARLOS_CONSOLE_NAME); no new input.;rev3=census-ruling-plans-4-notices-grace;basis=the account layout renders .PlanNotices as banner lines above main content (plans 4a). No read added. file:external@0 62edee2f256bfe22e8dd026b24e61e3b6f2e1f045a6dda3c301ef16211e2fae6
+auth.go consoleClient.doMultipartHeaders legacy accepted-legacy accepted-legacy;rev3=census-ruling-pro-6214-service-runs;identity=the carlos CLI on the caller's own machine, as that caller: a person, or a server holding a run credential as CARLOS_SERVICE_TOKEN; no box unit runs carlos run;basis=new: consoleClient.doMultipartMethod's body moved here unchanged, plus caller-supplied request headers (a run's Idempotency-Key), set before the content type and the bearer, which they cannot override; its one site, io.ReadAll of the console's response body, is doMultipartMethod's, J4 root-input as that row was;rev3=census-ruling-plans-4-notices-grace;basis=the upload client uses the console client's plan-warning transport (adds a request header, prints response warnings to stderr), the same timeout and no-redirect policy (Astra plans-4a finding 5). No read added. file:ReadAll@1444 ee551468bd7212e7274f9d730b44ce4238b49300b53ee278919f1b5cb78c1b0d
cmd/console/main.go serve legacy accepted-legacy accepted-legacy;rev3=PROPOSED-scan-demand-revival;basis=Console service wires the optional callback signer and starts the claim-guarded queue worker. The same three data path literals move; it does not add a privileged reader.;rev3=PROPOSED-email-signin;identity=the console (cmd/console serve under console.service, user carlos-console);basis=passes CARLOS_CONSOLE_NAME to NewServer as Config.ConsoleName, the name the console's emails use; the same three /data literals at the same offsets; no read added;rev3=PROPOSED-s3-change-index;identity=the console (cmd/console serve under console.service, user carlos-console);basis=arms the record view when CARLOS_CHANGE_INDEX=read (armChangeIndex) for the run and seed sweeps and starts its backstop loop; the same three /data literals at the same offsets; no read added;rev3=census-ruling-db-region-forward-2;identity=the console (cmd/console serve under console.service, user carlos-console);basis=parses CARLOS_DB_FORWARD (dbForward) into Config.DBForward and builds its http.Server with console.NewHTTPServer, the same two timeouts; the same three /data literals at the same offsets; no read added;rev3=census-ruling-sec-sidecar-create-gate;basis=serve now parses CARLOS_SIDECAR_ACCOUNTS (sidecarAccounts, a pure env parse with log.Fatalf on a bad or empty-list value) before opening anything and passes it into console.Config.SidecarAccounts. No read was added: the same 3 root read sites.;rev3=census-ruling-sec-mail-user-boundary;basis=reads CARLOS_MAIL_USER_BOUNDARY and passes it to mail.NewAWSProvisioner; runs the one-shot boundary sweep behind CARLOS_MAIL_BOUNDARY_SWEEP=1, refused under CARLOS_HOST_CLAIM;rev3=census-ruling-pro-6214-service-runs;basis=the console (cmd/console serve, user carlos-console): reads CARLOS_RUN_KEYS, an environment variable, into Config.RunKeysEnabled; keyed run creates are refused 503 keys_not_ready unless it is on; the same three /data literals; no read added;rev3=census-ruling-plans-4-notices-grace;basis=starts one more claim worker, StartPlanGracePass (plans 4a), beside StartPlanLimitsPass; it returns at once with no plan catalog. No read added. data-literal@4601,data-literal@5702,data-literal@5939 349665021854fbb10f1a091f8b76a066c2ec565c02b001bb9a88cd28e7ab9a20
+internal/console/plangrace_store.go Store.PutCapState legacy accepted-legacy accepted-legacy;rev3=census-ruling-plans-4a-store;basis=root-input; console SQL on its own plan_cap_state table, as its store siblings (J4); plans 4a warnings and grace, which refuse nothing;rev3=census-ruling-plans-4-notices-grace;basis=the upsert keeps notice already recorded for the same episode (same period and first over) instead of overwriting it (Astra plans-4a finding 1). Same table, same one statement; no read added. file:Exec@60 4baf1db18c1032ab1c3345698c685c8bd45deb8a13167b24980e826ec93a08f4
+internal/console/plangrace_store.go Store.RecordCapNotice legacy accepted-legacy accepted-legacy;rev3=census-ruling-plans-4a-store;basis=root-input; console SQL on its own plan_cap_state table, as its store siblings (J4); plans 4a warnings and grace, which refuse nothing;rev3=census-ruling-plans-4-notices-grace;basis=takes the rows as shown and updates only the matching episode (period and first over), never before the first over (Astra plans-4a finding 2). One parameterised UPDATE per shown row on the same table; no read added. file:Exec@222 806dafee3937e3b79a0c306652b08d0d9b19e27115fd576cb66164124fd64df0
internal/console/store.go Store.migrate legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=PROPOSED-email-signin;identity=the console (cmd/console serve under console.service, user carlos-console);basis=adds the sessions.method column (default keymail, the backfill) and calls migrateEmailSignin; SQLite DDL on CONSOLE_DB; the existing site moves;rev3=census-ruling-plans-4-notices-grace;basis=calls migratePlanGrace last, which creates the console's own plan_cap_state table (plans 4a). No read added here; the new store units are the plans-4a-store decision. file:Exec@12017,file:Exec@18103 0f08bad811be1e11fa9c1d135fbb5bf99120afa850a8f595a39e6612f7d6c69f
internal/console/templates/layout.html external legacy accepted-legacy accepted-legacy;rev3=PROPOSED-console-switcher-filter;basis=Account switcher adds a client-side filter box and a scrolling list; whole embedded template remains frozen as legacy UI input.;rev3=PROPOSED-email-signin;identity=the console (cmd/console serve under console.service, user carlos-console);basis=CSS only: email inputs styled as text inputs and sign-in form labels; whole embedded template remains frozen as legacy UI input;rev3=PROPOSED-console-brand-name;identity=the console (cmd/console serve under console.service, user carlos-console);basis=the tab title and header brand name the deployment ({{.Brand}}, CARLOS_CONSOLE_NAME); no new input.;rev3=census-ruling-plans-4-notices-grace;basis=the account layout renders .PlanNotices as banner lines above main content (plans 4a). No read added. file:external@0 62edee2f256bfe22e8dd026b24e61e3b6f2e1f045a6dda3c301ef16211e2fae6
-@coverage . 4f1cfec80e5fd4a98e0a9f6ad1c424677b8de1f6928f70f3cc275d5cf266b627
+@coverage . 52254ae8c81593fbb774e758140a654216b7629cd63704c5a2efe6b168da240a
@coverage cmd/console 7346c4e7936cf939707bf66a1ddb609622572b17abb3571c404bd1aac9742c14
-@coverage internal/console 97c8641c5dea591b9578f3f552c286c638076da51399c74bec57fcc3e4e106d3
+@coverage internal/console 72005c420b22f2e42309aacf124f5dc5df015291d3e8527d83ca6bf342dc73d9
@coverage internal/console/templates 628dd940845d129612b0b1ae59852e65b96c8f6e15693fcac7239610a7c8d132
@coverage internal/usage 6134ad82fbb3f6806661c55bb559ed47b6a85ad280647b67a7d4675aa4e68b99
diff --git a/planwarnings_test.go b/planwarnings_test.go
index 985703649..f1189a029 100644
--- a/planwarnings_test.go
+++ b/planwarnings_test.go
@@ -2,8 +2,11 @@ package main
import (
"bytes"
+ "context"
"io"
+ "mime/multipart"
"net/http"
+ "net/http/httptest"
"strings"
"testing"
)
@@ -40,3 +43,33 @@ func TestPlanWarningTransportPrintsOnce(t *testing.T) {
}
}
}
+
+// Finding 5: the upload and stream clients carry the warning transport too.
+func TestUploadAndStreamClientsPrintWarnings(t *testing.T) {
+ var seen []string
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ seen = append(seen, r.Header.Get("X-Carlos-Plan-Warnings"))
+ w.Header().Add("X-Carlos-Plan-Warning", "this account has used "+r.URL.Path)
+ w.WriteHeader(200)
+ }))
+ defer srv.Close()
+ var out bytes.Buffer
+ c := newConsoleClient(srv.URL, "tok")
+ c.warn.out = &out
+ if _, _, err := c.doMultipart(context.Background(), "/up", func(*multipart.Writer) error { return nil }); err != nil {
+ t.Fatal(err)
+ }
+ res, err := c.doStream(context.Background(), http.MethodGet, "/down", nil, -1, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ res.Body.Close()
+ if got := out.String(); !strings.Contains(got, "used /up") || !strings.Contains(got, "used /down") {
+ t.Fatalf("printed %q, want both warnings", got)
+ }
+ for _, h := range seen {
+ if h != "1" {
+ t.Fatalf("a request did not declare that this CLI prints warnings: %q", seen)
+ }
+ }
+}