Skip to content

fix(ci): Issue #288 follow-up — bump workflow cache key v4 → v5#298

Merged
dackclup merged 1 commit into
mainfrom
claude/issue-288-cache-key-bump-v5
May 28, 2026
Merged

fix(ci): Issue #288 follow-up — bump workflow cache key v4 → v5#298
dackclup merged 1 commit into
mainfrom
claude/issue-288-cache-key-bump-v5

Conversation

@dackclup
Copy link
Copy Markdown
Owner

Summary

Closes the silent-failure gap surfaced by Issue #287 PR A Rule 18 instrumentation on cron Run #71 (368dccd9, 2026-05-28 08:44 UTC). PR #292's GOOG/GOOGL per-class XBRL share-override fix did not fire in production despite the code being correct on the runner — warm-cache replay short-circuited Branch 3.

Root cause (per edgar-debugger 2026-05-28 verdict)

Fix scope (6 files, YAML + paired-test bump)

File Change
.github/workflows/compute-rankings.yml cache-v4-cache-v5- (key + 2 restore-keys) + comment block expanded with Issue #288 citation + 2-trigger bump taxonomy
.github/workflows/pre-merge-prod-sim.yml Mirror 3-string flip per file's own "bump together if either changes" comment — without this, simulate loses all 11 warm caches on every PR
tests/test_workflow_cache_coverage.py Paired-test bump per PR 4c.1 v3→v4 precedent. Function renamed _v4 → _v5 + docstring rewritten with 3-trigger bump taxonomy
CLAUDE.md §Phase status — drain "(in flight this PR — Issue #287 PR A)" → past tense + empirical validation note + cache-v5 in-flight note
AGENTS.md Open-issues list — #287 (PR A merged via #297), #288 (fix in flight this PR), #289 (closed by PR #293)
PHASE_STATUS_INFLIGHT.md Full in-flight entry per PR #237 side-file convention

Why Option A (cache-key bump) over alternatives

edgar-debugger evaluated 3 fix paths:

Option Trade-off Verdict
A: cache-key bump v4→v5 Matches PR 4c.1 precedent; zero compute/ change; one-time 25-50 min cold cron tax selected
B: Targeted per-ticker invalidation Cache-layer-knows-multi-class semantics; chicken-and-egg detection condition ❌ rejected
C: Move override out of fetch path Cache hit triggers live SEC call (violates semantics); FundamentalsSnapshot frozen ❌ rejected

One-time cost

~25-50 min cold cron on next weekly run (full S&P 500 live re-fetch). Subsequent crons return to warm-cache ~5-10 min budget. PR #297's timeout-minutes: 195 absorbs cold-cache reality — no operational risk.

Verification on next cron Run #72

  • metadata.multi_class_per_class_attempt_count = 2 (was 0)
  • metadata.multi_class_per_class_override_count = 2
  • stocks/GOOG.json shares_outstanding ≈ 5.429B (Class C, was 12.116B aggregate)
  • stocks/GOOGL.json shares_outstanding ≈ 5.822B (Class A, was 12.116B aggregate)
  • stocks/GOOG.json market_cap ≈ $2.09T (was $4.66T)
  • stocks/GOOGL.json market_cap ≈ $2.59T (was $4.71T)
  • metadata.fundamentals_latency_p50_seconds > 0.0 (live fetch path active)

Adjacent findings (deferred, NOT in this PR)

Pre-push 3-reviewer gate

Reviewer Verdict
phase-coordinator Mode B (sonnet) ✅ LOCKSTEP-SATISFIED — both CLAUDE.md + AGENTS.md substance touched, INFLIGHT entry well-shaped, branch in-sync with origin/main
quantrank-reviewer (opus) ✅ post-fix (was FIX-AND-RE-REVIEW with 2 FAIL — both resolved: test pin updated, simulate cache-v4 stragglers flipped)

Hard constraints honored

  • ✅ No compute / scoring / schema / valuation / Rule 16 / Top-5 invariant touched
  • ✅ No new defense flag · No new dep · No new env-var
  • ✅ Schema version UNCHANGED at 0.10.9-phase4.6 (no Pydantic / TS / snapshot change)
  • ✅ YAML + paired-test diff (test discipline per PR 4c.1 precedent)

Reopens #288
Closes #288

Test plan

  • ruff check . — All checks passed (N/A: YAML + docs)
  • python -m compute.output.schema_check — in sync at 0.10.9-phase4.6 (no schema touched)
  • pytest tests/test_workflow_cache_coverage.py -v — 10/10 PASS post-fix
  • No cache-v4- stragglers in .github/ or tests/ (grep verified)
  • Vercel preview build — gated on this PR's CI (doc/YAML-only, no frontend/ touched)
  • Cron Run feat(ui): Loss Chance % heuristic chip (PR 4e) #72 (next scheduled Thu 2026-05-28 22:00 UTC OR workflow_dispatch post-merge) — empirical validation that all 7 verification items above land correct

Generated by Claude Code

Closes the silent-failure gap surfaced by Issue #287 PR A's Rule 18
instrumentation on cron Run #71 (368dccd, 2026-05-28 08:44 UTC). The
PR #292 GOOG/GOOGL per-class XBRL share-override fix did not fire in
production despite the code being correct on the runner.

Root cause (edgar-debugger 2026-05-28 verdict):

  - PR #292 (e9aaab3, 04:22 UTC) landed the per-class XBRL override
    at compute/ingest/fundamentals.py:1043-1067 (Branch 3 of
    _build_snapshot).
  - Branch 3 only executes on live EDGAR fetch — fetch_fundamentals
    short-circuits at _is_fresh() (line 1292-1294) when cached parquet
    age by latest_filed_date < FUNDAMENTALS_REFETCH_DAYS = 45.
  - Earlier same-day cron 0ad1d57 (03:22 UTC, pre-PR-#292) wrote a
    stale aggregate parquet (GOOG shares_outstanding = 12.116B).
  - Cron Run #71 restored that parquet from the GitHub Actions cache;
    _is_fresh() returned True on latest_filed_date=2026-04-30 (28d
    < 45d), and Branch 3 never ran.
  - metadata.multi_class_per_class_attempt_count = 0 (PR #292 Rule 18
    disambiguator working as designed — the smoking gun).
  - fundamentals_latency_p50_seconds = 0.0 (warm-cache replay confirmed
    universe-wide).

Fix scope (6 files, YAML + paired test bump):

  - .github/workflows/compute-rankings.yml — 3 instances cache-v4- →
    cache-v5- (key + 2 restore-keys) + comment block expanded to cite
    Issue #288 follow-up + PR #292 + PR #269 + introduce a 2-trigger
    bump taxonomy (schema change OR value-correctness fix in live-
    fetch-only path).
  - .github/workflows/pre-merge-prod-sim.yml — mirror 3-string flip
    per the file's own "bump together if either changes" comment.
    Without this the simulate workflow would lose all 11 warm caches
    on every PR.
  - tests/test_workflow_cache_coverage.py — paired-test bump per the
    PR 4c.1 v3→v4 precedent. Function renamed
    test_workflow_cache_key_is_v4 → _v5; docstring rewritten to cite
    Issue #288 + PR #292 + the 3-trigger bump taxonomy.
  - CLAUDE.md §Phase status — drain stale "in flight" wording for
    PR #297 (now merged) + empirical-validation note for cron Run #71
    + "in flight this PR" entry for the cache-v5 bump.
  - AGENTS.md open-issues list — update #287 (PR A merged via #297),
    #288 (fix in flight this PR), #289 (closed by PR #293).
  - PHASE_STATUS_INFLIGHT.md — full in-flight entry appended per
    PR #237 side-file convention.

Why Option A (cache-key bump) over alternatives (per edgar-debugger):

  - Option B (targeted per-ticker invalidation): introduces cache-layer-
    knows-multi-class semantics + chicken-and-egg "detect stale
    aggregate from cached parquet" condition.
  - Option C (refactor override out of fetch path): cache hit triggers
    live SEC call (violates cache semantics) + FundamentalsSnapshot is
    frozen.
  - Option A: matches PR 4c.1 v3→v4 precedent exactly + zero compute/
    change + guaranteed correctness on next cron.

One-time cost: ~25-50 min cold cron on the immediately-following
weekly run (full S&P 500 universe live re-fetch). Subsequent crons
return to warm-cache ~5-10 min budget. No timeout-minutes impact —
PR #297 just bumped to 195m which absorbs cold-cache reality.

Verification on next cron Run #72:

  - metadata.multi_class_per_class_attempt_count = 2 (was 0)
  - metadata.multi_class_per_class_override_count = 2
  - stocks/GOOG.json shares_outstanding ≈ 5.429B (Class C, was 12.116B)
  - stocks/GOOGL.json shares_outstanding ≈ 5.822B (Class A, was 12.116B)
  - stocks/GOOG.json market_cap ≈ $2.09T (was $4.66T)
  - stocks/GOOGL.json market_cap ≈ $2.59T (was $4.71T)
  - metadata.fundamentals_latency_p50_seconds > 0.0 (live fetch active)

Adjacent findings deferred (NOT in this PR):

  - FOX / FOXA / NWS / NWSA: same multi_class_aggregate_shares_suspected
    annotate firing but they are on MULTI_CLASS_SHARE_ALLOWLIST
    (UNDERCOUNT path, PR #257). Decision on whether to add to overcount
    allowlist deferred to Q3 2026-08-19 quarterly cohort audit per
    methodology-scientist precedent (needs live XBRL probe).
  - OSAP wall-clock 347.1s on Run #71: cold OSAP download (cache > 31d
    mtime or evicted). Single observation; not a regression. Watch on
    next 2-3 crons.

Hard constraints honored:

  - No compute / scoring / schema / valuation / Rule 16 / Top-5
    invariant touched
  - No new defense flag · No new dep · No new env-var
  - YAML + paired-test diff (per quantrank-reviewer feedback on
    PR-title framing — original "YAML-only" was misleading)
  - Schema version UNCHANGED at 0.10.9-phase4.6 (no Pydantic / TS /
    snapshot change)

Pre-push 3-reviewer gate:

  - phase-coordinator Mode B (sonnet): LOCKSTEP-SATISFIED — both
    CLAUDE.md + AGENTS.md substance touched, INFLIGHT entry well-
    shaped, branch in-sync with origin/main (no rebase needed)
  - quantrank-reviewer (opus): FIX-AND-RE-REVIEW → 2 FAIL + 4 WARN.
    Both FAILs fixed in this commit (tests/test_workflow_cache_coverage.py
    test pin + pre-merge-prod-sim.yml cache-v4 stragglers). WARN 1
    (Issue #288 lifecycle) addressed via Reopens/Closes directives
    below. WARN 2 (AGENTS.md cron #69 cross-ref), WARN 3 (comment
    density) deferred — minor.

Reopens #288
Closes #288

https://claude.ai/code/session_01AGU8d6pm4u2fQQ5cebg9qa
@vercel
Copy link
Copy Markdown

vercel Bot commented May 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
quantrank Ready Ready Preview, Comment May 28, 2026 10:07am

@dackclup dackclup marked this pull request as ready for review May 28, 2026 10:17
@dackclup dackclup merged commit 030675e into main May 28, 2026
4 checks passed
@dackclup dackclup deleted the claude/issue-288-cache-key-bump-v5 branch May 28, 2026 10:17
dackclup added a commit that referenced this pull request May 28, 2026
…rkers + bump pointers (#299)

Closes today's 10-PR cycle (#286 / #290 / #291 / #292 / #293 / #294 /
#295 / #296 / #297 / #298). Mirror of PR #286 (post-v1.4.0 cycle
drain) for the post-cron-#71 cycle.

Three stale `(in flight, 2026-05-28)` markers in
PHASE_STATUS_INFLIGHT.md drained to `(merged 2026-05-28, <SHA>)`:

  - PR #295 (`2d2ec83e`) — Post-session housekeeping drain 6 INFLIGHT
    + bump pointers
  - PR #297 (`ecb60e64`) — Issue #287 PR A: durable timeout + cache
    canary + per-loop wall-clock Metadata (schema 0.10.8 → 0.10.9-phase4.6)
  - PR #298 (`030675e9`) — Issue #288 follow-up: cache-key bump v4 → v5

Bodies preserved (historical record).

CLAUDE.md §Phase status — drained the "(In flight this PR — cache-v5)"
qualifier (PR #298 merged) + added post-PR-#298 confirmation note +
cron Run #71 production-verified pointer.

AGENTS.md open-issues list — #288 status flipped "(fix in flight this
PR)" → "(closed by PR #298 cache-v5 bump)" + clarified the silent-
failure root-cause + Run #72 verification gate.

Why this PR exists: without end-of-day drain, session N+1 reading
CLAUDE.md / PHASE_STATUS_INFLIGHT.md would see 3 PRs still marked
"in flight" despite them merging hours earlier — the same friction
pattern PR #286 closed for the post-v1.4.0 cycle. Three same-day
drains in one PR keeps the side-file disciplined.

Scope (3 files, doc-only):

  - PHASE_STATUS_INFLIGHT.md — 3 header substitutions + this PR's
    own in-flight entry appended per PR #237 side-file convention
  - CLAUDE.md §Phase status pointer refresh
  - AGENTS.md open-issues list #288 status update

Hard constraints honored:

  - No code / scoring / schema / valuation / Rule 16 / Top-5
    invariant touched
  - No new defense flag · No new dep · No new env-var
  - Doc-only diff (Markdown only)
  - Schema version UNCHANGED at 0.10.9-phase4.6 (no Pydantic / TS /
    snapshot change)

PHASE_STATUS_INFLIGHT.md side-file satisfies §Conventions "ship with
every PR" lockstep per PR #237 convention. Same drain template as
PR #286 (post-v1.4.0 cycle).

https://claude.ai/code/session_01AGU8d6pm4u2fQQ5cebg9qa

Co-authored-by: Claude <noreply@anthropic.com>
dackclup added a commit that referenced this pull request May 28, 2026
…ULD-FIX cross-doc drifts (#301)

Comprehensive .md housekeeping closing today's 11-PR session day.
Output of docs-reviewer (sonnet) full Tier 1 + Tier 2 audit on main
(post-PR-#299) — verdict NEEDS-CROSS-REF-FIX with 14 prioritized
findings; this PR applies all 8 MUST-FIX + 6 SHOULD-FIX. 3 NICE-TO-FIX
deferred to follow-up.

Scope (7 files, doc-only):

  - SKILL.md schema-version history table (line 240) — prepend 2 new
    rows: 0.10.9-phase4.6 (PR #297, 4 *_wall_clock_seconds fields +
    195m timeout + cache canary, empirically validated cron Run #71)
    + 0.10.10-phase4.6 (PR #300 in flight — Issue #67 follow-up per-
    sector delta). Closes the canonical-history gap where PR #297 +
    PR #300 were absent.

  - PHASE_STATUS.md §Current state — schema row 0.10.8 → 0.10.9 +
    PR #300 in-flight note; Post-tag production patches row extended
    with PR #295/#296/#297/#298/#299 SHAs + one-liners; Production
    run pointer 0ad1d57 cron #69368dccd cron Run #71 with the
    PR #297 wall-clock empirical numbers + Issue #288 cache-replay
    smoking gun (multi_class_per_class_attempt_count=0 +
    fundamentals_latency_p50_seconds=0.0). Recently merged block
    extended 6 → 11 PRs. Issue closure status updated. Next
    deliverables refreshed: Issue #67 flip removed (PR #294 already
    executed); item 2 now = Issue #287 PR B FORM4 revert; PR #300
    per-sector delta added as item 3. Open issues list refreshed
    (#288 + #289 marked closed; #287 PR A vs PR B split).

  - CLAUDE.md §Phase status Recently merged block — extended 6 → 11
    PRs with full SHA + one-liner per PR. New "In flight" sub-section
    added for PR #300.

  - AGENTS.md §Phase + version state — Production-verified run
    cron #69 (233117a, 13m 16s) → cron Run #71 (368dccd, 14m 32s,
    2026-05-28 08:44 UTC, schema 0.10.7 → 0.10.9-phase4.6); 4 new
    wall-clock field values cited; Issue #288 cache-replay smoking
    gun captured; closed-issue note for #288 + #289 + #287 PR A.

  - CONTEXT.md §Live snapshot — schema 0.10.8 → 0.10.9 + PR #300
    in-flight note; new "Post-tag patches" row listing PRs #292-#299
    + PR #300 in flight; cron status cron #69 2026-05-27 → Run #71
    2026-05-28; Sector-CoE row updated with empirical 132 → 109;
    §Roadmap Stage 0 description refreshed.

  - WORKFLOW.md §Agentic 6-Phase Cadence session-start protocol —
    inline schema 0.10.7-phase4.6 replaced with current 0.10.9-phase4.6
    + pointer guidance to PHASE_STATUS.md §Current state as the
    canonical bump-per-schema-PR target. Closes the recurring inline-
    schema drift pattern.

  - PHASE_STATUS_INFLIGHT.md — this PR's in-flight entry appended per
    PR #237 side-file convention.

docs-reviewer lockstep cross-check after this PR:

  - SCHEMA_VERSION: ALIGNED across all 6 canonical docs at
    0.10.9-phase4.6 with PR #300 in-flight note where applicable
  - Defense layer 33 declared: ALIGNED (was already)
  - USE_SECTOR_COE = True post-PR #294: ALIGNED (was stale in
    AGENTS.md issue #67 framing + PHASE_STATUS.md Next deliverables;
    both fixed)
  - Subagent count 18: ALIGNED (was already)
  - Skill count 45: ALIGNED (was already)
  - Latest cron Run #71 368dccd: ALIGNED (was stale in AGENTS.md +
    PHASE_STATUS.md + CONTEXT.md; all fixed)
  - Issue #288 + #289 closure status: ALIGNED (was stale as open in
    AGENTS.md + PHASE_STATUS.md; both fixed)

3 NICE-TO-FIX deferred:

  - README.md Honest Limitations does not reference Phase 4.6 honest
    re-validation harness (PR #283). Coverage gap, not break.
  - WORKFLOW.md Phase 4.5 row cites v1.2.0; technically closed at
    v1.3.0-phase4.5e. Historical-context only.
  - METHODOLOGY.md USE_SECTOR_COE framing needs verification before
    edit.

Hard constraints honored:

  - No code / scoring / schema / valuation / Rule 16 / Top-5
    invariant touched
  - No new defense flag · No new dep · No new env-var
  - Markdown-only diff (no JSON / YAML / Python / TS change)
  - Schema version UNCHANGED on main at 0.10.9-phase4.6 (PR #300 will
    bump 0.10.10 on its merge)
  - AGENTS.md substance lockstep with CLAUDE.md per the established
    delegation pattern

Verification:

  - ruff check .                          PASS (no Python touched)
  - python -m compute.output.schema_check PASS (no schema touched)
  - pytest tests/ -m "not network"        N/A (no test surface)
  - Cross-reference grep — all 7 anchor strings consistent across
    all 6 docs after fix

https://claude.ai/code/session_01AGU8d6pm4u2fQQ5cebg9qa

Co-authored-by: Claude <noreply@anthropic.com>
dackclup pushed a commit that referenced this pull request May 28, 2026
… instrumentation

Methodology-scientist Mode B Q2 follow-up deferred from PR #294 (sector-
CoE flip, 2026-05-28 05:39 UTC). Adds
`Metadata.value_trap_risk_delta_by_sector: dict[str, int] | None` so
Q3 2026-08-19 quarterly cohort audit has visible per-sector shape
evidence — not just the aggregate `value_trap_risk_count_*_sector_coe`
scalars that landed in PR #204.

Schema PATCH bump 0.10.9 → 0.10.10-phase4.6 (additive Metadata-only).

Methodology context (Damodaran 2019 Ch. 8.4 §"Industry Beta"):

  After `USE_SECTOR_COE = True` per-sector Ke replaces the flat 10%
  baseline at SECTOR_COST_OF_EQUITY (11 GICS sectors, Ke 6%-12%).
  Directional predictions:

  - Lower-Ke sectors (Utilities ~6-7% / Real Estate ~7-8% / Consumer
    Staples ~7-8%): ROE ≥ Ke threshold relaxed → fewer RIM-skipped →
    POSITIVE delta (sector DROPPED flags)
  - Higher-Ke sectors (Information Technology ~11-12% / Energy
    ~10-12%): ROE ≥ Ke tightened → more RIM-skipped → NEGATIVE delta
  - Neutral sectors (6 GICS sectors at ~9-11%): small delta near zero

Cron #69 + Run #71 universe-wide already confirmed the aggregate:
132 → 109 (−23 tickers, −17.4%). This PR breaks the −23 down by sector.

Scope (10 files, additive only):

  - compute/output/schemas.py — new value_trap_risk_delta_by_sector
    field with full docstring (methodology-scientist verdict +
    Damodaran 2019 anchor + direction semantics)
  - frontend/lib/types.ts — mirror TS field as Record<string, number> | null
  - frontend/lib/schema-snapshot.json — regenerated via --update-snapshot
  - compute/config.py — SCHEMA_VERSION = "0.10.10-phase4.6"
  - compute/main.py — 3 surgical edits mirroring existing scalar
    dual-counter pattern (init two dict[str, int] counters / per-sector
    increment co-located with the existing scalar bump in both branches
    / delta computation in Metadata constructor)
  - tests/test_config.py — schema version pin bump + docstring rewrite
  - tests/test_output/test_value_trap_delta_by_sector_schema.py (NEW) —
    2 active GREEN schema-contract tests (mirror test_wall_clock_schema.py
    pattern from PR #297)
  - CLAUDE.md — §Phase status pointer block refresh
  - AGENTS.md — open-issues #67 status: flip landed + per-sector
    follow-up in flight this PR
  - PHASE_STATUS_INFLIGHT.md — full in-flight entry per PR #237
    side-file convention

Implementation note:

  Per-sector dict construction uses
  `sorted(set(without) | set(with))` for stable key ordering;
  `.get(sec, 0)` fallback handles sectors appearing in only one path;
  `{} or None` falls back to None when both dicts are empty (test-mode
  universe). Co-located with the existing scalar bump in both
  `_rim_flat` (flat-Ke) and `_rim_sector` (sector-Ke) branches at the
  same `value_trap_risk_roe_below_cost_of_equity` reason guard — scalar
  and dict always stay in lockstep.

Verification ladder:

  - ruff check .                              PASS
  - python -m compute.output.schema_check     PASS (triple in sync 0.10.10)
  - pytest tests/test_config.py -v            11/11 PASS (pin held)
  - python -m pytest tests/test_output/       2/2 NEW PASS
  - Full offline suite via test-engineer      1367 → 1369 (+2 NEW)

Pre-push 3-reviewer gate:

  - schema-sentinel (sonnet)        PASS (52 fields, triple aligned,
                                    PATCH bump correct, snapshot
                                    alphabetical ordering held)
  - test-engineer (sonnet)          GREEN (2/2 new tests pass,
                                    1367 → 1369, 0 regressions,
                                    0 skipped stubs)
  - quantrank-reviewer (opus)       READY-TO-PUSH (0 FAIL, 4 WARN
                                    all pre-existing PR-#297-era
                                    drift, defer to next housekeeping
                                    PR — incl. SKILL.md/PHASE_STATUS.md
                                    schema-table tops still on 0.10.8)

Empirical validation gate (post-merge, next cron Run #72):

  - metadata.value_trap_risk_delta_by_sector populates as non-null dict
  - Damodaran shape directionally correct: Util/Real Estate/Staples
    POSITIVE, Information Technology/Energy NEGATIVE
  - sum(delta.values()) == without_sector_coe_count - with_sector_coe_count
    (= 23 per Run #71 universe-wide; matches within rounding)

Note: per-sector accumulation runs in the Step 8 per-ticker loop,
INDEPENDENT of cache-v5 cache busting (PR #298). Field populates on
next cron regardless of warm/cold fetch path.

Hard constraints honored:

  - No new defense flag · No scoring formula change · No Rule 16 /
    Top-5 violation
  - Additive-only schema change (PATCH bump)
  - Field nullable per Rule 18 graceful-degradation
  - Phase 4.5e PR 5 (cluster weight promotion) gate-data UNCHANGED —
    independent track

Methodology decision: methodology-scientist verdict NOT re-requested —
this is the EXACT field shape Mode B Q2 verdict from PR #294 explicitly
authorized. Future re-trigger only if post-merge cron shows sector
breakdown contradicting Damodaran prediction OR Q3 2026-08-19 audit
reads ≥ 6 crons of data and per-sector decay pattern needs interpretation.

https://claude.ai/code/session_01AGU8d6pm4u2fQQ5cebg9qa
dackclup added a commit that referenced this pull request May 28, 2026
…ta instrumentation (#300)

Methodology-scientist Mode B Q2 follow-up deferred from PR #294 (sector-
CoE flip, 2026-05-28 05:39 UTC). Adds
`Metadata.value_trap_risk_delta_by_sector: dict[str, int] | None` so
Q3 2026-08-19 quarterly cohort audit has visible per-sector shape
evidence — not just the aggregate `value_trap_risk_count_*_sector_coe`
scalars that landed in PR #204.

Schema PATCH bump 0.10.9 → 0.10.10-phase4.6 (additive Metadata-only).

Methodology context (Damodaran 2019 Ch. 8.4 §"Industry Beta"):

  After `USE_SECTOR_COE = True` per-sector Ke replaces the flat 10%
  baseline at SECTOR_COST_OF_EQUITY (11 GICS sectors, Ke 6%-12%).
  Directional predictions:

  - Lower-Ke sectors (Utilities ~6-7% / Real Estate ~7-8% / Consumer
    Staples ~7-8%): ROE ≥ Ke threshold relaxed → fewer RIM-skipped →
    POSITIVE delta (sector DROPPED flags)
  - Higher-Ke sectors (Information Technology ~11-12% / Energy
    ~10-12%): ROE ≥ Ke tightened → more RIM-skipped → NEGATIVE delta
  - Neutral sectors (6 GICS sectors at ~9-11%): small delta near zero

Cron #69 + Run #71 universe-wide already confirmed the aggregate:
132 → 109 (−23 tickers, −17.4%). This PR breaks the −23 down by sector.

Scope (10 files, additive only):

  - compute/output/schemas.py — new value_trap_risk_delta_by_sector
    field with full docstring (methodology-scientist verdict +
    Damodaran 2019 anchor + direction semantics)
  - frontend/lib/types.ts — mirror TS field as Record<string, number> | null
  - frontend/lib/schema-snapshot.json — regenerated via --update-snapshot
  - compute/config.py — SCHEMA_VERSION = "0.10.10-phase4.6"
  - compute/main.py — 3 surgical edits mirroring existing scalar
    dual-counter pattern (init two dict[str, int] counters / per-sector
    increment co-located with the existing scalar bump in both branches
    / delta computation in Metadata constructor)
  - tests/test_config.py — schema version pin bump + docstring rewrite
  - tests/test_output/test_value_trap_delta_by_sector_schema.py (NEW) —
    2 active GREEN schema-contract tests (mirror test_wall_clock_schema.py
    pattern from PR #297)
  - CLAUDE.md — §Phase status pointer block refresh
  - AGENTS.md — open-issues #67 status: flip landed + per-sector
    follow-up in flight this PR
  - PHASE_STATUS_INFLIGHT.md — full in-flight entry per PR #237
    side-file convention

Implementation note:

  Per-sector dict construction uses
  `sorted(set(without) | set(with))` for stable key ordering;
  `.get(sec, 0)` fallback handles sectors appearing in only one path;
  `{} or None` falls back to None when both dicts are empty (test-mode
  universe). Co-located with the existing scalar bump in both
  `_rim_flat` (flat-Ke) and `_rim_sector` (sector-Ke) branches at the
  same `value_trap_risk_roe_below_cost_of_equity` reason guard — scalar
  and dict always stay in lockstep.

Verification ladder:

  - ruff check .                              PASS
  - python -m compute.output.schema_check     PASS (triple in sync 0.10.10)
  - pytest tests/test_config.py -v            11/11 PASS (pin held)
  - python -m pytest tests/test_output/       2/2 NEW PASS
  - Full offline suite via test-engineer      1367 → 1369 (+2 NEW)

Pre-push 3-reviewer gate:

  - schema-sentinel (sonnet)        PASS (52 fields, triple aligned,
                                    PATCH bump correct, snapshot
                                    alphabetical ordering held)
  - test-engineer (sonnet)          GREEN (2/2 new tests pass,
                                    1367 → 1369, 0 regressions,
                                    0 skipped stubs)
  - quantrank-reviewer (opus)       READY-TO-PUSH (0 FAIL, 4 WARN
                                    all pre-existing PR-#297-era
                                    drift, defer to next housekeeping
                                    PR — incl. SKILL.md/PHASE_STATUS.md
                                    schema-table tops still on 0.10.8)

Empirical validation gate (post-merge, next cron Run #72):

  - metadata.value_trap_risk_delta_by_sector populates as non-null dict
  - Damodaran shape directionally correct: Util/Real Estate/Staples
    POSITIVE, Information Technology/Energy NEGATIVE
  - sum(delta.values()) == without_sector_coe_count - with_sector_coe_count
    (= 23 per Run #71 universe-wide; matches within rounding)

Note: per-sector accumulation runs in the Step 8 per-ticker loop,
INDEPENDENT of cache-v5 cache busting (PR #298). Field populates on
next cron regardless of warm/cold fetch path.

Hard constraints honored:

  - No new defense flag · No scoring formula change · No Rule 16 /
    Top-5 violation
  - Additive-only schema change (PATCH bump)
  - Field nullable per Rule 18 graceful-degradation
  - Phase 4.5e PR 5 (cluster weight promotion) gate-data UNCHANGED —
    independent track

Methodology decision: methodology-scientist verdict NOT re-requested —
this is the EXACT field shape Mode B Q2 verdict from PR #294 explicitly
authorized. Future re-trigger only if post-merge cron shows sector
breakdown contradicting Damodaran prediction OR Q3 2026-08-19 audit
reads ≥ 6 crons of data and per-sector decay pattern needs interpretation.

https://claude.ai/code/session_01AGU8d6pm4u2fQQ5cebg9qa

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(ingest): PR #269 GOOG/GOOGL per-class XBRL fix never fires — display market_cap 2.2× inflated

2 participants