Files
gstack/test/fixtures/ceo-section-y-report.md
T
Garry TanandOpenAI Codex 9f81911136 v1.86.0.0 feat: route outside reviews by harness (#2850)
* feat: add a restricted and supervised Claude Code runner

Preserve configured authentication and models while enforcing tool access, strict completion JSON, bounded output and process cleanup. Cover argv, failure handling, session metadata and Windows process containment.

* feat: route outside reviews by harness and migrate wrapper installs

Use Claude Code from Codex and Codex from other supported hosts, with shared invocation rendering, positive gate validation and per-phase provenance. Rename /claude to /claude-code, repair managed shared and copied installations safely, and generate native Kiro skills. Add installed-workflow, failure-injection and live cross-harness regression coverage.

* test: recognize CEO mode labels without terminal spacing

The paid workflow rendered SCOPEEXPANSION at option 4, but its driver required a literal space. Match the leading mode title without cursor-spacing artifacts and ignore adjacent preview text. Preserve missing-target failures and downstream posture assertions.

* test: isolate plan-count fixtures before starting review workflows

Seed the complete test plan in a private git repository before launching Claude, so a bare slash command cannot review the live workspace while a delayed fixture message remains queued. Preserve count thresholds, parsers and budgets. Add initial-context and installed-discovery tests, and retain startup/terminal diagnostics on failed evaluations.

* test: stabilize review fixtures and Claude eval startup

Preserve source boundaries in workflow judge inputs, isolate CEO mode plans, and wait for interactive trust input readiness. Keep startup failure evidence and retain existing models, budgets, and assertions.

Co-Authored-By: OpenAI Codex <noreply@openai.com>

* test: classify collapsed review modes and isolate seeded findings

Keep review questions out of the setup count when terminal cursor positioning removes spaces. State existing webhook safeguards so the five-finding control measures its seeded defects without accidental extra security and concurrency gaps. Preserve question bands and the paired control.

Co-Authored-By: OpenAI Codex <noreply@openai.com>

* test: isolate browser daemon state across free shards

Co-Authored-By: OpenAI Codex <noreply@openai.com>

* test: stabilize native review counting and interactive navigation

Co-Authored-By: OpenAI Codex <noreply@openai.com>

* chore: prepare v1.82.0.0 release

Co-Authored-By: OpenAI Codex <noreply@openai.com>

* fix: eliminate browser and process-cleanup test flakes

Pin every CI surface to Bun 1.4.0 to avoid extra-stdio finalizers closing
reused live sockets. Add an isolated GC/listener regression that fails on
Bun 1.3.13, and prevent coordinated rollback to an affected CI runtime.

Check renderer cleanup against the render's own staging directory so
concurrent renders cannot invalidate the assertion. Make the no-pgrep
process-tree walk tolerate disappearing /proc entries, and synchronize
its test fixture through child readiness and pipe EOF instead of sleeps.

Validation: 9,157 passed, 31 skipped, zero failures across 556 files with
retries disabled. Build, all-host generation freshness, and skill checks
passed. All three races have failing-before/passing-after regressions.

* fix: count completed native review questions in evals

* fix: drive review navigation from confirmed native choices

* fix: require complete section-loading eval reports

* test: isolate telemetry HTTP transport from local assertions

* fix: keep review input on the active native question

* test: let tunnel revocation daemon choose an available port

* test: allocate available ports for pairing and watchdog fixtures

* fix: stabilize planning eval navigation and phase reporting

* test: isolate installed runtime paths in planning evals

* test: stabilize review evidence and concurrent refresh fixtures

* fix: resolve design findings before editing the plan

* fix: honor and persist disabled outside plan reviews

* fix: preserve planning decisions and terminal evidence

Load installed host reviews at autoplan phase entry and wait for completed
reviewers and saved artifacts. Reuse approved remedies while preserving
individual finding decisions.

Drive interactive evals from the current terminal viewport, bind native
questions across scrolling, and require complete native report evidence.
Cover captured stale menus, permission lifecycles, setup classification,
and disabled-review tool availability with deterministic regressions.

Advance release metadata and the upgrade migration to the unclaimed
1.83.0.0 slot.

* fix: drive native review questions and preserve current plans

Use the native single-choice keyboard protocol and current terminal viewport,
with per-question navigation inside packets and completed-call coverage.
Keep permissions, multi-select menus, and Submit controls distinct.

Send Autoplan reviewers the amended implementation plan, keep its review record
separate, and supply retained application contracts in the chain fixture.
Clarify individual DevEx decisions and complete CEO fix options; use one active
plan destination for the section-loading report.

* fix: preserve complete plan-review decisions

* fix: recognize native plan dialogs and reviewer controls

* fix: preserve review decisions and phase completion

* fix: recognize completed reviews without losing findings

* fix: preserve review continuity and native eval completion

* test: fix native review completion and eval retry isolation

* test: handle native review menus and complete eval fixtures

* test: fix native review setup, completion, and isolation failures

* test: limit native skill discovery to runtime assets

* fix: bind Autoplan reviews to full ordered phase inputs

* test: fix planning eval routing, counting, and timeout handling

* chore: advance queued release to v1.84.0.0

* fix: preserve complete review inputs and planning decisions

* fix: reconcile review approvals and preserve phase obligations

* fix: preserve review obligations and unblock eval permissions

Carry recorded Autoplan requirements into blind phase inputs, require Eng
review approvals before exit, and exercise combined asynchronous flows in
CEO reviews. Correct native finding and handoff classification and unblock
repeated report edits using scoped request identities.

* fix: retain plan requirements and complete native review dialogs

* fix: complete native review prompts and retain plan references

* fix: preserve review inputs and classify native eval evidence

* fix: check competing completion orders in CEO reviews

* fix: recognize review decisions and require phase methodology

Require the current phase methodology before Autoplan snapshots. Correct
substantive decision, closed handoff, and cache-finding classification, and
honor the recommended implementation approach in native review dialogs.

Add captured-transcript regressions without changing review thresholds,
provider models, retries, or deadlines.

* test: bind native review decisions and close completed handoffs

* fix: complete review dialogs and verify methodology delivery

* fix: preserve review evidence and unblock native eval prompts

* fix: handle native review question completions

* fix: recognize native review narration and controls

* fix: count native review decisions and isolate eval fixtures

* test: verify seeded review coverage and current artifact permissions

* test: isolate model and brain-aware skill renders

* fix: repair native workflow evaluation and clarify review steps

* fix: stabilize workflow eval evidence and review guidance

* test: repair native workflow observation and fixture isolation

* fix: recognize completed workflow evidence and owned skill reads

* test: repair seeded workflow delivery and completion evidence

* test: recognize current review evidence across native forms

* test: handle native review variants and permission redraws

* fix: honor review preferences and recognize native eval evidence

* test: recognize completed review decisions and queued permissions

* test: match current review contracts and partial-line edits

* test: recognize completed workflow evidence and bounded human waits

* fix: preserve review entry gates and native eval interactions

* fix: recognize native workflow evidence and preserve review gates

* test: recognize current review evidence and preconfigure workflow fixtures

* test: recognize completed review findings and scoped artifact permissions

* fix: stabilize native workflow review and permission evidence

* fix: recognize current review evidence and scoped edit confirmations

Clarify Design and engineering review entry instructions and Design scoring.
Recognize required legacy coverage and public Autoplan completion recaps.
Bind the pending Edit confirmation to its exact file, ordered digest, and
one-request approval when a preceding command display remains visible.
Keep reviews within their existing size limits and preserve scope gates
when extracting workflow fixtures from either supported preamble header.

Keep failure outcomes, review thresholds, provider choices, and eval budgets.

* fix: recover review workflow progress and eval evidence

* fix: recognize valid review evidence and scope selection

* test: fix review evidence parsing and repeated artifact prompts

* test: recognize valid review decisions and pending native cards

* fix(plan-eng-review): keep final navigation consistent with approved tasks

* test: recognize valid review evidence and bind legacy diff requests

* fix: stabilize review eval evidence and harness repair guidance

* docs: update project documentation for v1.85.0.0

Co-Authored-By: OpenAI Codex <noreply@openai.com>

* test: fix Windows CI fixtures and credential scan

Rebase captured JSON values and filesystem evidence using the appropriate
path convention. Compile native fake CLIs on Windows and synchronize pipe
holder readiness, with cleanup retained when assertions fail.

Assemble synthetic credential fixtures at runtime so the added-line scan
keeps enforcing the same gate without flagging its own rejection controls.

Discover generated skills directly for the empty-find regression check,
avoiding a recursive scan through saved evaluation artifacts and dependencies.

* fix: preserve source renders on Windows

Compare canonical generator paths using native separators so an output
sidecar pointing at the source cannot overwrite its skill or metadata.
Keep the regression fixture isolated from the real checkout and expose
freshness diagnostics before asserting subprocess status.

Detach Windows drain-test pipe holders from the fake provider's automatic
child cleanup while preserving the enclosing runner job and its assertions.

* fix: clarify outside review fallback and CEO decisions

Render one applicable own-harness fallback path and retain native review,
disabled policy, and missing-coverage semantics. Align report field names
and mode labels, and make the existing per-cut scope approval explicit.

Regenerate skill outputs and keep the workflow judge's model, thresholds,
and retry policy unchanged.

* chore: move release to free version slot (v1.86.0.0)

PR #2852 now claims v1.85.0.0. Align the release metadata and
rename migration so upgrades from that version still receive it.

Co-Authored-By: OpenAI Codex <noreply@openai.com>

* fix: include engineering review prerequisites and restore branch context

* fix: recognize coverage diagrams and clarify design review instructions

* fix: preserve file identities and join Windows test processes

---------

Co-authored-by: OpenAI Codex <noreply@openai.com>
2026-09-14 14:32:45 -07:00

26 KiB

Plan: cache profile summaries in one process

Measured problem and accepted scope

The existing profile-summary service has one active process. A one-week trace shows repeated reads of about 900 hot keys: DB CPU is 70%, with read p95 120 ms. Add a process-local LRU wrapper to the existing repository. Acceptance targets are at least 60% cache hits, DB CPU below 50%, and read p95 below 60 ms, with the existing error-rate and correctness SLOs unchanged. This is an internal backend change with no UI, API, schema, pricing, or developer onboarding change.

Existing contracts retained

  • All reads and writes use this repository in the same process; there are no external DB writers. Multi-process operation remains unsupported and startup rejects that configuration while caching is enabled.
  • Authentication and authorization run before repository access. Keys encode the authenticated tenant ID and validated profile ID without ambiguity. Values are immutable profile-summary DTOs; secrets and cache keys are never logged. Cached results cannot bypass authorization.
  • The existing LRU adapter supports 1000 entries, a 16 MiB byte cap, and a 30-second TTL. Recorded hot data fits those limits. Absent records use a distinct sentinel with a 10-second TTL; undefined means a cache miss.
  • Cache operations are synchronous and atomic in the single JS event loop. On any cache failure the existing adapter bypasses the cache until an empty cache is reinitialized; repository errors keep the current typed API error mapping. The existing per-key single-flight wrapper coalesces simultaneous misses and releases on failure.
  • A read already in progress when a write commits may return its earlier DB snapshot to that caller. Every read begun after that write completes must observe the committed version. TTL expiry is not a substitute for this rule.

Proposed wrapper integration

Keep the current read-through repository interface and shared adapters. These are the complete new read/write ordering rules:

AMENDMENT (Finding 1, auto-decided): The original pseudocode did not satisfy the "every read begun after write completes" invariant. A write-generation counter is added to prevent a completing in-flight read from restoring a stale cache entry after a concurrent write has deleted it. The counter adds two lines to the wrapper.

let _writeGen = 0; // process-local; reset on cache disable/enable

async function readProfile(key) {
  const cached = cache.get(key);
  if (cached !== undefined) return cached;
  const gen = _writeGen;               // capture before await
  const value = await repository.read(key);
  if (_writeGen === gen) {             // no write occurred during this read
    cache.set(key, value);
  }
  return value;
}

async function writeProfile(key, update) {
  const saved = await repository.write(key, update);
  _writeGen++;                         // increment before delete
  cache.delete(key);
  return saved;
}

Why: Without the generation counter, a read that starts before a write and completes after it calls cache.set(key, oldValue) after the write has called cache.delete(key), restoring a stale entry for all subsequent reads until TTL expiry. The invariant forbids relying on TTL for this guarantee. The counter prevents the stale restore with two lines and no new dependencies.

Residual risk: If multiple concurrent writes to different keys occur, any in-flight read skips its cache.set() even if no write touched its specific key. This increases cache misses conservatively but never produces stale results. The additional DB load from spurious misses is bounded by the single-flight wrapper and is acceptable given the hot-key distribution.

Verification: The new test for the concurrent read/write ordering (Finding 4) must confirm: (a) a read that starts before a write and completes after it does not restore the old value, and (b) a read started after the write returns the new value from DB.

Verification and rollout

Existing repository contract tests cover tenant isolation, key validation, absence, DB failures, and authorization. New wrapper tests cover hit/miss, eviction and byte limits, TTL, adapter-failure fallback, successful-write invalidation, failed-write preservation, concurrent-miss coalescing, and concurrent read/write ordering (write-generation counter correctness). The rollout uses the existing runtime feature flag: enable for 10% of keys, then 50%, then all keys after one healthy hour at each stage. Monitor hit/miss, eviction, cache bytes, fallback errors, DB CPU, and read p95 without raw IDs. On error-rate or latency regression, disable the flag immediately; both reads and writes bypass the cache while disabled, and enabling creates an empty cache. Cold starts remain within the existing DB capacity. The service owner monitors the rollout and records the results against the acceptance targets.

AMENDMENT (Finding 3, auto-decided — TODO): Alert thresholds and a post-deploy runbook are deferred to a follow-up task (T3). Minimum runbook content: disable the feature flag if fallback_errors exceeds threshold or hit rate falls below 40% in steady state; verify DB CPU trend is downward within 10 minutes of each stage transition; confirm no fallback errors in the first 5 minutes at 10%.

Out of scope

Distributed caching, cross-process coherence, prewarming, changing consistency semantics, or adding new product surfaces. The repository interface preserves a future replacement path without introducing a general cache framework now.


CEO Review — HOLD SCOPE

Mode: HOLD SCOPE. Scope is accepted as stated. Review is for correctness, coverage, and operability only. No scope additions or reductions.

All findings below were auto-decided (spawned session, no human present; recommended option selected per skill rules). Each finding is recorded once; cross-references are used in place of repetition.

Finding 1 — CRITICAL: Stale Write-Back Race (Sections 1, 4)

Evidence: In the JS event loop, readProfile has an await at repository.read(key). Between that await and the subsequent cache.set(), the event loop can run writeProfile, which calls cache.delete(key). When the original readProfile resumes, it calls cache.set(key, oldValue), restoring the stale entry. Subsequent reads started after the write return the stale cached value until TTL (up to 30 s). The plan's invariant prohibits this: "TTL expiry is not a substitute for this rule."

Schedule showing the violation:

T   | readProfile(K)           | writeProfile(K)         | cache[K]
----|--------------------------|-------------------------|----------
0   | cache.get(K) → miss      |                         | absent
1   | await repo.read(K)...    |                         | absent
2   |                          | await repo.write(K)...  | absent
3   |                          | cache.delete(K)         | absent
4   |                          | return saved            | absent
5   | ...read resolves         |                         | absent
6   | cache.set(K, old)        |                         | old ← VIOLATION
7   | return old to caller*    |                         | old
    *T=7 return is explicitly allowed; cache[K]=old is not.

Remedy (accepted): Write-generation counter — see amended pseudocode above. Residual risk: Conservative miss-skip under concurrent multi-key writes (bounded). Verification: Concurrent read/write ordering test (Finding 4 → T2).

Finding 2 — OK: Cache Adapter Error Handling (Section 2)

The plan states the existing adapter bypasses the cache on any internal failure and never propagates LRU errors to callers. The pseudocode correctly relies on this contract. The "adapter-failure fallback" test verifies it. No gap.

Finding 3 — TODO: Alert Thresholds and Post-Deploy Runbook (Sections 8, 9)

Evidence: The plan specifies metrics to monitor but does not specify alert thresholds (e.g., hit rate <40%, fallback_errors >N/min) or a runbook (what to do, in order, when each metric fires). Without thresholds, the rollout is monitored by inspection rather than automation.

Remedy (deferred to T3): Minimum viable runbook: disable flag if fallback_errors spikes or hit rate below 40% in steady state; DB CPU downward trend expected within 10 minutes of each stage; no fallback errors in first 5 minutes at 10% stage. Alert thresholds to be set based on baseline metrics at initial 10% stage.

Residual risk: Rollout relies on manual inspection until runbook is written. The feature flag mitigates this (fast disable path is documented).

Verification: Runbook reviewed by service owner before 50% stage.


NOT in scope

  1. Distributed caching — explicitly excluded; multi-process unsupported at startup.
  2. Cross-process cache coherence — single process only; enforced by startup check.
  3. Cache prewarming — hot data fills naturally via feature flag rollout.
  4. Changing consistency semantics — existing read/write ordering rules are preserved.
  5. New product surfaces (UI, API, schema, pricing) — internal backend change only.
  6. General cache framework — this wrapper is specific to this repository.
  7. Per-key write-gen tracking — conservative global counter accepted; per-key adds complexity without changing the correctness guarantee (see Finding 1 residual risk).

What already exists

Sub-problem Existing code Reused?
LRU storage Existing LRU adapter (1000 entries, 16 MiB, 30 s TTL) Yes — unchanged
Repository interface Existing read-through repo Yes — wrapper sits above it
Single-flight for concurrent misses Existing per-key single-flight in repo layer Yes — transparent to wrapper
Auth/authorization Runs before any repo access Yes — no change
Feature flag Existing runtime flag Yes — rollout gated by it
Key validation Existing tenant+profile key encoding Yes — unchanged
Error mapping Existing typed API error classes Yes — unchanged
Contract tests Existing repo contract test suite Yes — extended with new cases

Dream state delta

CURRENT STATE                 THIS PLAN                  12-MONTH IDEAL
─────────────────────         ─────────────────────      ──────────────────────
DB CPU 70%, p95 120ms  ──▶   Cache wrapper added  ──▶   If multi-process needed:
900 hot keys hit DB           LRU in single process       Redis or distributed LRU
Single process                60%+ hit rate               (separate decision gate)
No caching layer              DB CPU <50%, p95 <60ms     Current: single-process
                              Feature-flagged rollout      constraint continues to
                              Write-gen counter added       serve well if load stays
                              (correctness gap closed)      single-process

This plan moves toward the ideal. The multi-process path is preserved (startup rejection is explicit, not buried). The 12-month ideal requires a separate decision only if the service scales to multiple processes.


Diagrams

1. System Architecture

┌─────────────────────────────────────────────────┐
│              Single JS Process                   │
│                                                  │
│  Caller                                          │
│    │                                             │
│    ▼                                             │
│  ┌─────────────────────────────────────┐         │
│  │         Cache Wrapper (NEW)          │         │
│  │  readProfile / writeProfile          │         │
│  │  _writeGen counter (NEW)            │         │
│  └──────┬────────────────┬────────────┘         │
│         │ read-through   │ invalidate            │
│         ▼                ▼                       │
│  ┌─────────────┐  ┌──────────────┐               │
│  │ LRU Adapter  │  │  Repository  │               │
│  │ (existing)   │  │  (existing)  │               │
│  │ 1000 entries │  │  single-flt  │               │
│  │ 16 MiB cap   │  │  (existing)  │               │
│  │ 30 s TTL     │  └──────┬───────┘               │
│  └─────────────┘         │                       │
│    bypass on fail         ▼                       │
│                      Database                    │
└─────────────────────────────────────────────────┘

2. Data Flow (all four paths)

KEY ──▶ [cache.get(key)]
            │
     ┌──────┴──────────┐
     │ hit             │ miss
     ▼                 ▼
  RETURN          capture gen = _writeGen
  cached              │
                  [await repo.read(key)]
                      │
         ┌────────────┼────────────┐
         │ success    │ error      │ nil/not-found
         ▼            ▼            ▼
   _writeGen==gen?  propagate   sentinel set
         │           typed        (10 s TTL)
     ┌───┴───┐       error
     │Y      │N
     ▼       ▼
  cache.set  skip set
  (key,val)  (stale guard)
     │
     └──▶ RETURN value

WRITE PATH:
KEY + UPDATE ──▶ [await repo.write(key, update)]
                        │
             ┌──────────┴──────────┐
             │ success             │ error
             ▼                     ▼
       _writeGen++            propagate
       cache.delete(key)       typed error
       RETURN saved            (cache unchanged)

3. Cache State Machine

         enable flag           adapter failure
              │                      │
              ▼                      ▼
         ┌─────────┐          ┌──────────┐
         │  ACTIVE  │─────────▶  BYPASS  │
         │ (hit/miss│  error   │(all ops  │
         │  served) │          │ skip     │
         └────┬─────┘          │ cache)   │
              │                └────┬─────┘
              │ disable flag        │ empty cache
              ▼                     │ reinit
         ┌─────────┐                │
         │ DISABLED │◀──────────────┘
         │(no cache │
         │ ops)     │
         └──────────┘

4. Error Flow

                 ┌─────────────────────┐
                 │   readProfile(key)   │
                 └──────────┬──────────┘
                            │
                   cache.get() throws?
                   ┌────────┴────────┐
                   │ Y (adapter err) │ N
                   ▼                 ▼
              adapter bypass      cache hit?
              (internal to        ┌────┴────┐
               adapter)          │Y        │N
                                 ▼         ▼
                             return      repo.read()
                             cached          │
                                     ┌──────┴──────┐
                                     │ success     │ error
                                     ▼             ▼
                               gen check?     propagate
                               ┌──┴──┐        typed err
                               │Y    │N
                               ▼     ▼
                            cache.  skip
                            set()   set
                            return  return
                            value   value

5. Rollout Sequence

CODE DEPLOY
     │
     ▼
Flag: DISABLED (0%)
  All reads bypass cache → DB
     │
     ▼ enable at 10%
Flag: 10% of keys cached
  Monitor: hit/miss, fallback_errors, DB CPU, p95
  Wait: 1 healthy hour
  Gate: error rate and latency within SLO
     │
     ▼ promote to 50%
Flag: 50% of keys cached
  Monitor same metrics
  Wait: 1 healthy hour
  Gate: same
     │
     ▼ promote to 100%
Flag: ALL keys cached
  Acceptance: ≥60% hit, DB CPU <50%, p95 <60 ms
     │
  On regression at any stage:
     ▼
Flag: DISABLED immediately
  Both reads and writes bypass cache
  Re-enable creates empty cache

6. Rollback Flowchart

Regression detected (error rate or latency)
     │
     ▼
Disable feature flag (seconds, no deploy needed)
     │
     ▼
Verify: all reads/writes bypass cache, metrics normalize
     │
     ▼
Investigate root cause (logs: fallback_errors, eviction rate)
     │
     ┌──────────────────────────────┐
     │ Code bug?      │ Config bug? │
     ▼                ▼             │
  Code fix +       Adjust LRU       │
  re-deploy        limits           │
     │                ▼             │
     └──────────▶ Re-enable flag    │
                  at 10% and        │
                  retest            │
                                    ▼
                              If unresolvable:
                              git revert wrapper
                              (feature flag already
                               prevents cache ops,
                               revert is belt-and-
                               suspenders)

Stale Diagram Audit

No existing ASCII diagrams found in this plan's files (new plan). No stale diagrams.


Error & Rescue Registry

Method/Codepath What Can Go Wrong Exception Class Rescued? Rescue Action User Sees
cache.get() LRU internal error LRUError Y (adapter) Adapter bypasses cache DB read (transparent)
cache.set() LRU internal error LRUError Y (adapter) Adapter bypasses cache DB read (transparent)
cache.delete() LRU internal error LRUError Y (adapter) Adapter bypasses cache Next read hits DB
repository.read() DB connection failure DatabaseError Y (existing) Typed API error Error response
repository.read() Record not found RecordNotFound Y (existing) Sentinel (10 s TTL) Not-found response
repository.write() DB write failure DatabaseError Y (existing) Typed API error; cache NOT deleted Error response
repository.write() Conflict/constraint ConflictError Y (existing) Typed API error; cache NOT deleted Conflict response

No CRITICAL GAPS. All error paths are handled via existing adapter and repository contracts.


Failure Modes Registry

Codepath Failure Mode Rescued? Test? User Sees Logged?
readProfile cache.get() throws Y (adapter bypass) Y (adapter-failure fallback test) Transparent DB hit Y (adapter internal)
readProfile DB read error Y (existing typed) Y (existing contract) Error response Y (existing)
readProfile Stale write-back (in-flight read after write) Y (write-gen counter — AMENDED) Y (T2 — new test required) Correct value N/A (prevented)
writeProfile DB write fails, cache preserved Y (existing typed) Y (failed-write preservation test) Error response Y (existing)
writeProfile cache.delete() throws after successful write Y (adapter bypass) Y (adapter-failure fallback) Transparent; next read is DB miss Y (adapter internal)
LRU adapter Full bypass state Y (adapter) Y (adapter-failure fallback) All reads/writes hit DB Y (fallback_errors metric)

CRITICAL GAPS resolved: Finding 1 (stale write-back) is addressed by the write-gen counter amendment. The test (T2) is required before ship.


Implementation Tasks

Synthesized from this review's findings. Each task derives from a specific finding above. Run with Claude Code; checkbox as you ship.

  • T1 (P1, human: ~1h / CC: ~10min) — Cache Wrapper — Add write-generation counter to readProfile

    • Surfaced by: Finding 1 — stale write-back race violates "reads begun after write" invariant
    • Change: add let _writeGen = 0, capture gen = _writeGen before await repo.read(), conditional cache.set() only when _writeGen === gen; increment _writeGen++ in writeProfile before cache.delete()
    • Files: cache wrapper module (new file wrapping the repository)
    • Verify: all new wrapper tests pass; T2 test specifically confirms ordering invariant
  • T2 (P1, human: ~1h / CC: ~10min) — Tests — Add concurrent read/write ordering test

    • Surfaced by: Finding 4 (Section 6) — no test for stale write-back race; required to verify T1
    • Scenario: pause readProfile after cache miss, run writeProfile to completion, resume readProfile, assert next read returns new value not old
    • Files: cache wrapper test file
    • Verify: test fails without write-gen counter, passes with it; CI must include this test
  • T3 (P3, human: ~30min / CC: ~5min) — Observability — Alert thresholds and post-deploy runbook

    • Surfaced by: Finding 3 (Sections 8, 9) — metrics listed but no thresholds or runbook
    • Content: hit rate alert (<40% in steady state), fallback_errors threshold, 5-minute post-deploy checklist per rollout stage, disable-flag runbook
    • Files: ops/runbook-cache-wrapper.md (or equivalent)
    • Verify: service owner reviews before 50% stage promotion

No new tasks from Sections 3, 5, 7, 10, 11.


Completion Summary

+====================================================================+
|            MEGA PLAN REVIEW — COMPLETION SUMMARY                   |
+====================================================================+
| Mode selected        | HOLD SCOPE                                  |
| System Audit         | Skipped (test instructions)                 |
| Step 0               | HOLD SCOPE confirmed; premise valid;        |
|                      | measured problem, direct solution           |
| Section 1  (Arch)    | 1 critical finding (stale write-back race)  |
| Section 2  (Errors)  | 7 error paths mapped, 0 GAPS                |
| Section 3  (Security)| 0 issues found, 0 High severity             |
| Section 4  (Data/UX) | 1 ordering violation confirmed → Finding 1  |
| Section 5  (Quality) | 0 new issues                                |
| Section 6  (Tests)   | Diagram produced, 1 gap (race test)         |
| Section 7  (Perf)    | 0 issues found                              |
| Section 8  (Observ)  | 1 gap (no alert thresholds or runbook)      |
| Section 9  (Deploy)  | 1 gap (no post-deploy checklist — merged    |
|                      | into Finding 3 / T3)                        |
| Section 10 (Future)  | Reversibility: 4/5, 0 new debt items        |
| Section 11 (Design)  | SKIPPED (no UI scope)                       |
+--------------------------------------------------------------------+
| NOT in scope         | written (7 items)                           |
| What already exists  | written (8 items)                           |
| Dream state delta    | written                                     |
| Error/rescue registry| 7 methods, 0 CRITICAL GAPS                  |
| Failure modes        | 6 total, 1 CRITICAL GAP found and closed by |
|                      | write-gen counter amendment (T1 required)   |
| TODOS.md updates     | 1 item (T3: runbook + thresholds)           |
| Scope proposals      | 0 proposed, 0 accepted (HOLD SCOPE)         |
| CEO plan             | skipped (HOLD SCOPE)                        |
| Outside voice        | disabled (codex_reviews: disabled)          |
| Lake Score           | 3/3 recommendations chose complete option   |
| Diagrams produced    | 6 (architecture, data flow, state machine,  |
|                      | error flow, rollout sequence, rollback)     |
| Stale diagrams found | 0 (new plan)                                |
| Unresolved decisions | 0 (all auto-decided, spawned session)       |
+====================================================================+

Auto-Decided Items (spawned session)

All AskUserQuestion decision points were auto-decided per skill rules (spawned session, recommended option selected, no destructive choices):

  • Finding 1 remedy → write-generation counter (recommended: minimal, correct, no new dependencies). Alternative considered: setIfAbsent semantics (requires LRU adapter API change — more invasive). Counter selected.
  • Finding 3 → deferred to T3 as TODO (recommended: defer; rollout proceeds with manual monitoring; fast flag disable remains the primary safety mechanism).
  • Stale write-back test (Finding 4) → required as T2 (P1, blocks ship with T1).

GSTACK REVIEW REPORT

Review Trigger Why Runs Status Findings
CEO Review /plan-ceo-review Scope & strategy 1 issues_open (T1+T2 required) mode: HOLD_SCOPE, 1 critical gap (stale write-back, write-gen remedy accepted), 0 unresolved
Outside Review codex_reviews=disabled Independent 2nd opinion 0 disabled
Eng Review /plan-eng-review Architecture & tests (required) 0
Design Review /plan-design-review UI/UX gaps 0
DX Review /plan-devex-review Developer experience gaps 0

OUTSIDE COVERAGE: disabled — codex_reviews: disabled in .gstack-section-state-4pqsxp/config.yaml. No fallback dispatched; disabled is an intentional opt-out. Re-enable: gstack-config set codex_reviews enabled.

VERDICT: CEO review complete. Eng Review required before ship (not yet run). T1 (write-gen counter) and T2 (race test) are P1 blockers. T3 (runbook) is P3. eng review required.

NO UNRESOLVED DECISIONS