GeezerVison is showing github.com — Design: failure is not a result — one success-only memoization contract for lazy initializers (aggregator first) · Issue #3879 · developing-today/code
Design: failure is not a result — one success-only memoization contract for lazy initializers (aggregator first) #3879Closed 3 / 33 of 3 issues completedClosed 3 / 33 of 3 issues completed Labels app/aggregatorPackage/app: aggregator (pm-stack in this repo)app/pm-stackpm-stack (Pad/Grist) in developing-today/codeeffort/lLarge: multi-day or open-ended; expect staged check-insepicMeta-issue grouping multiple items (org Project Type=Epic)kind/designA design proposal (design-architect): multi-step, phased, decision-bearingpriority/normalOrdinary priority (the default)source/design-architectFiled by the repo design architect jobtask/triageQueue packet kind: verify, reproduce, and route this item DescriptionSummary
Three lazy initializers in the aggregator memoize their first failure forever, defeating the one layer that was designed to heal:
Both origins are priority/high with verified laptop probes. The shared dependency already states the intended bound: src/secrets.ts caches a null for only 5 minutes precisely so failures heal — the consumers widen that to forever.
The rule that fixes this already exists in this repo, stated for one app: #2668 recorded for pm-dispatch that "memoized init caches success only (clear-on-reject, in-flight promise still shared)", generalising fetchGithubJwks' success-only cache; its instance #2663 has since closed. The aggregator never adopted the rule. This design generalises it.
Full design doc: files/designs/code-success-only-memoization.md in the keep-the-four-repos-healthy goal workspace. Audit baseline: origin/main 064ce9e5 (all three latch sites read verbatim at HEAD this pass).
The contract
A lazy initializer memoizes success, never failure. Concurrent callers share the one in-flight attempt; once that attempt settles, a failure — a rejection, or a fail-soft failure value (null, false) — leaves no memo behind, so the next caller retries. A success is memoized for the process lifetime unless the module already has an explicit invalidation path, which stays. Per-call fail-soft behaviour is unchanged: the contract removes the permanence, not the posture.
Conforming embodiments already in-tree: secrets.ts (5-minute null cache + forgetBwsSecret), dispatch/src/auth.ts fetchGithubJwks (success-only), aggregator server.ts priming (self-clearing + 60s gate), sources/live.ts TTL caches (assigned only on success), bin/antigravity-direct.mjs token promise (cleared in finally).
Recorded decisions
- Clear on settle, not a consumer-side failure TTL. The shared dependency already bounds retry cost (secrets' 5-minute null cache means a retry re-reads a map, not bws); a second per-site TTL delays healing past the designed bound by an arbitrary per-site number.
- Every layer clears independently (stacked-latch rule). aggregator(alerts): getSupabaseClient and getAlertsStore both memoize a transient null forever — the alerts ledger stays unavailable until restart #3732's evidence: fixing the client alone does not heal the store. "The layer below retries" is never a reason for a layer to keep a failure.
- Failure values count as failure. All three sites fail soft (
.catch(() => null/false)), so the success test is on the resolved value: non-null client/store, true configure.
- In-flight sharing preserved. Clear at settle (a
finally/settle handler), never before — concurrent first callers still trigger exactly one resolution.
- Existing invalidation stays. Push's 401/403 reset +
forgetBwsSecret remain the rotation path; no timers, reset endpoints, or in-call retry loops are added. Retry drivers already exist: the tick, the next request, the next send.
Alternatives that lose (in the doc): per-site failure TTLs; retry-with-backoff inside the initializer; an operator reset surface; repo-wide scope from day one (unexamined sites get dispositions in Phase 3, not presumed fixes).
Phased breakdown
- Phase 1 — the alerts ledger heals (adopted: aggregator(alerts): getSupabaseClient and getAlertsStore both memoize a transient null forever — the alerts ledger stays unavailable until restart #3732). Contract applied at both layers (
getSupabaseClient, getAlertsStore), fail-once-then-succeed tests per layer plus the stacked case. Lands first — every alerts surface, and Design: delivered means delivered — one truth contract for the aggregator alert throat #3702's throat contract, sits on this store.
- Phase 2 — push configuration heals (adopted: aggregator(push): ensurePushConfigured memoizes a failed VAPID configure forever — one transient bws failure disables Web Push for the process lifetime #3729).
ensurePushConfigured clears on false; the 401/403 reset preserved verbatim; probe-shaped test. Independent of Phase 1 in code.
- Phase 3 — closing inventory + contract statement (new issue, gated on Phases 1–2). Contract into
pm-stack/aggregator/README.md + pointer comments at the three sites; a repo-wide promise-memo inventory with a disposition per site (known candidates: bin/muse-proxy.mjs cliCapsPromise, pkgs/id/web highlighterPromise; expected-conforming sites verified, not re-fixed); a cross-note on design(pm-dispatch): launch pipeline, staged — validate the whole request at the boundary, one commit point, nothing after it can fail the launch #2668 that its rule is now the aggregator's contract too.
Open questions stay in the design doc (supabase client token rotation — no invalidation path, no failure evidence yet; genuinely-absent config cost, bounded by the secrets cache and recorded acceptable; Go/Rust sync.Once latches — no filed instance).
Related: #2668 (the rule's first statement), #3702 (neighbouring throat contract — different mechanism, no phase overlap). Not this design: #3701 (batch scheduling), the settings-kind numeric cluster (pass 32's trigger has not fired).
🤖 Design architect pass 33 (2026-11-01), audit at origin/main 064ce9e5. Sub-issuesCollapse Sub-issuesSub-issues3 of 33 of 3 Issues completedLoading 3 sub-issues Activityadded epicMeta-issue grouping multiple items (org Project Type=Epic) effort/lLarge: multi-day or open-ended; expect staged check-ins kind/designA design proposal (design-architect): multi-step, phased, decision-bearing on Nov 1, 2026dezren39 commented on Nov 1, 2026 🤖 Agent note · design filed
- Agent: design architect (repo-design-architect-code), pass 33
- Task: Originated design Design: failure is not a result — one success-only memoization contract for lazy initializers (aggregator first) #3879 — failure is not a result: one success-only memoization contract for lazy initializers, generalising design(pm-dispatch): launch pipeline, staged — validate the whole request at the boundary, one commit point, nothing after it can fail the launch #2668's pm-dispatch rule to the aggregator, whose three promise latches (aggregator(alerts): getSupabaseClient and getAlertsStore both memoize a transient null forever — the alerts ledger stays unavailable until restart #3732 ×2 layers, aggregator(push): ensurePushConfigured memoizes a failed VAPID configure forever — one transient bws failure disables Web Push for the process lifetime #3729) memoize a transient bws failure for the process lifetime and defeat secrets.ts's designed 5-minute healing bound.
- Outcome: Design doc at
files/designs/code-success-only-memoization.md (keep-the-four-repos-healthy goal workspace); central register entry added (status: proposed). Phases linked as sub-issues: Phase 1 = aggregator(alerts): getSupabaseClient and getAlertsStore both memoize a transient null forever — the alerts ledger stays unavailable until restart #3732 (adopted), Phase 2 = aggregator(push): ensurePushConfigured memoizes a failed VAPID configure forever — one transient bws failure disables Web Push for the process lifetime #3729 (adopted), Phase 3 = Phase 3 (audit) of #3879 — closing promise-memo inventory + contract statement #3880 (new closing inventory + contract statement, gated on Phases 1–2).
- Recorded pins: clear on settle, NOT a consumer-side failure TTL (secrets' 5-min null cache already bounds retry cost); every layer clears independently (stacked-latch rule); failure values (null/false) count as failure; in-flight sharing preserved; push's 401/403 reset stays.
- Links: aggregator(alerts): getSupabaseClient and getAlertsStore both memoize a transient null forever — the alerts ledger stays unavailable until restart #3732, aggregator(push): ensurePushConfigured memoizes a failed VAPID configure forever — one transient bws failure disables Web Push for the process lifetime #3729, Phase 3 (audit) of #3879 — closing promise-memo inventory + contract statement #3880, design(pm-dispatch): launch pipeline, staged — validate the whole request at the boundary, one commit point, nothing after it can fail the launch #2668, Design: delivered means delivered — one truth contract for the aggregator alert throat #3702
developing-today commented on Nov 8, 2026 🤖 Agent note · handed off
developing-today commented on Nov 8, 2026 🤖 Agent note · handed off
dezren39 commented on Nov 8, 2026 dezren39 commented on Nov 8, 2026 🤖 Agent note · triage complete — all phases landed; verified closure
- Agent: queue worker (repo-worker-code), lane 1a180ae5-384f-4e71-8d77-08f7b1652c75
- Session / ID: task 12125
- Found via: OpenChamber scheduled lane claim (partial-verification remainder)
Fresh verification 2026-11-08:
All three adopted phases and the design's closing inventory/dispositions are complete. Closing #3879 with the merged PRs above as evidence; no follow-up packet is needed.
MetadataMetadataapp/aggregatorPackage/app: aggregator (pm-stack in this repo)app/pm-stackpm-stack (Pad/Grist) in developing-today/codeeffort/lLarge: multi-day or open-ended; expect staged check-insepicMeta-issue grouping multiple items (org Project Type=Epic)kind/designA design proposal (design-architect): multi-step, phased, decision-bearingpriority/normalOrdinary priority (the default)source/design-architectFiled by the repo design architect jobtask/triageQueue packet kind: verify, reproduce, and route this item DevelopmentNo branches or pull requestsIssue actions
|