chore(digest): flip BRIEF_WHY_MATTERS_SHADOW to opt-in — default-on doubled gemini spend#4909
Conversation
…oubled gemini spend Shadow mode ran BOTH the analyst and gemini paths on every cache-miss story (Promise.allSettled, one result discarded) and defaulted ON at 100% sampling — a fresh deploy silently paid 2x for whyMatters long after the comparison window ended (#4893). Only exactly '1' enables it now; prod already carries an explicit '0' so behavior there is unchanged either way. Adds a source-text drift pin: the test suite's handwritten readConfig mirror now asserts the handler contains the same opt-in expression, so the mirror can't silently assert stale semantics again. Closes #4893 Claude-Session: https://claude.ai/code/session_01YTm4GsLG2M7ZuaHF9MpZih
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR flips the
Confidence Score: 5/5Safe to merge — the change is a single expression flip that stops the two-path execution by default, with no impact on the primary response path. The edit is surgically small: one boolean expression changed in the handler, one expression changed in the test mirror, one new test added. The shadow path itself is untouched; only whether it fires by default changes. The existing prod env var (BRIEF_WHY_MATTERS_SHADOW=0) continues to work correctly (still evaluates to false). The new drift-pin test closes the feedback loop that allowed the original regression to go undetected. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Cache Miss] --> B{cfg.shadowEnabled\nAND sampleHardRoll?}
B -- "BEFORE: default true\n(shadow=ON unless SHADOW=0)" --> C[Promise.allSettled\nanalyst + gemini\n2× LLM spend]
B -- "AFTER: default false\n(shadow=OFF unless SHADOW=1)" --> D{cfg.primary}
D -- analyst --> E[runAnalystPath only\n1× LLM spend]
D -- gemini --> F[runGeminiPath only\n1× LLM spend]
C --> G[choose primary result\nstore shadow diff]
E --> H[cache write + respond]
F --> H
G --> H
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[Cache Miss] --> B{cfg.shadowEnabled\nAND sampleHardRoll?}
B -- "BEFORE: default true\n(shadow=ON unless SHADOW=0)" --> C[Promise.allSettled\nanalyst + gemini\n2× LLM spend]
B -- "AFTER: default false\n(shadow=OFF unless SHADOW=1)" --> D{cfg.primary}
D -- analyst --> E[runAnalystPath only\n1× LLM spend]
D -- gemini --> F[runGeminiPath only\n1× LLM spend]
C --> G[choose primary result\nstore shadow diff]
E --> H[cache write + respond]
F --> H
G --> H
Reviews (1): Last reviewed commit: "chore(digest): flip BRIEF_WHY_MATTERS_SH..." | Re-trigger Greptile |
Problem (#4893)
api/internal/brief-why-matters.tsshipped shadow mode default-on at 100% sampling: every cache-miss story ranPromise.allSettled([analystPath, geminiPath])— two gemini completions, one used, one stored only as an observability diff. The env flip (BRIEF_WHY_MATTERS_SHADOW=0, already live on Vercel prod) protects the current deployment, but the code default meant any fresh environment silently pays 2× again.Fix
'1'enables (env.BRIEF_WHY_MATTERS_SHADOW === '1'). Prod's explicit0is unchanged/redundant-safe.readConfigmirror now also asserts the handler source contains the same opt-in expression — the mirror asserting stale semantics unnoticed is exactly how default-on shipped in the first place.Tests
tests/brief-why-matters-analyst.test.mjs: default expectation flipped (shadow=OFF), enable-token semantics inverted ('1'enables;yes/0/true/''/ondon't), plus the source-text drift pin. 64/64 ✓,typecheck:api✓, biome ✓.Closes #4893
https://claude.ai/code/session_01YTm4GsLG2M7ZuaHF9MpZih