Skip to content

fix(refactor): exclude Storybook-only evidence from production liveness - #1085

Open
azizur100389 wants to merge 1 commit into
tirth8205:stagingfrom
azizur100389:codex/fix-storybook-dead-code
Open

azizur100389 wants to merge 1 commit into
tirth8205:stagingfrom
azizur100389:codex/fix-storybook-dead-code

Conversation

@azizur100389

@azizur100389 azizur100389 commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Linked issue

Closes #902.

What & why

A component used only by its Storybook story currently appears live. Classify CSF story filenames through the shared parser file classifier and exclude story-only calls, imports, references, TESTED_BY evidence and class-member calls from dead-code liveness. Path checks cover previously built graphs too. Preserve genuine production callers, including the bare-call fallback, and ordinary test evidence.

How it was tested

Applied the same regression/affected-module/full-baseline methodology used in my previous PRs (#274, #276, #279, #353 and #354), against unchanged staging 6b12d11625cbec3b6773e076cb3d136464fa90e5.

  • Final regression module: 11 passed. Bugs reproduce on unchanged staging; compatibility guards cover existing behavior.
  • Affected modules: 255 passed, 1 existing Windows failure. Failure identities are a subset of the unchanged-staging affected baseline (1,169 passed, 15 Windows failures); no new failures.
  • Ruff clean; Bandit zero findings; git diff --check clean.
  • Mypy: the same three pre-existing Windows fcntl LOCK_EX/LOCK_NB/flock errors in daemon.py as staging; no new errors.
  • Schema remains version 13.
python -m pytest tests/test_storybook_dead_code.py tests/test_refactor.py tests/test_test_file_detection.py -q --tb=short
$env:GIT_CEILING_DIRECTORIES = $env:TEMP.Replace('\\', '/') + ';' + (Split-Path $PWD).Replace('\\', '/')
python -m pytest -q --tb=short -m 'not browser and not upgrade' --cov=code_review_graph --cov-report=term --cov-fail-under=65
ruff check code_review_graph tests/test_storybook_dead_code.py
mypy code_review_graph --ignore-missing-imports --no-strict-optional
bandit -r code_review_graph -c pyproject.toml

GitHub CI: 17 applicable checks passed on the final commit, including Python 3.10–3.13, browser tests, native Windows tests, and the three MCP-client platforms. Python 3.13: 4,279 passed, 804 skipped, 46 deselected, 2 xfailed, 2 xpassed; 85.87% coverage (65% required). The manual upgrade job is skipped by design.

Full local Windows suite: 4,153 passed, 111 failed, 819 skipped, 46 deselected, 2 xfailed, 2 xpassed; 86% coverage. Unchanged staging full baseline: 4,143 passed, 110 failed. The extra daemon-status assertion rejects the word dead anywhere in its printed output, including the temporary directory name crg-fix-storybook-dead-code-retry. The reported watcher is alive. The same test fails on unchanged staging under a path containing dead; it passes 3/3 neutral-path reruns on this branch and 3/3 neutral-path reruns on unchanged staging. This is a path-sensitive existing test assertion, not changed daemon behavior. An earlier parallel local attempt ended without a final report in the watch tests. This complete rerun used per-test diagnostics and short temporary paths; the earlier partial log is retained. PATH/PYTHONPATH select the isolated checkout, and Git ceilings keep fixture repositories away from the enclosing home Git repository. Browser tests passed in CI; browser and opt-in upgrade tests were excluded locally.

All ten issue fixes were additionally tested together: 283 regression checks passed, and the combined affected suite had 1,142 passed / 25 unchanged-staging Windows failures, with no new failure identities. The tested combination is preserved in this integration branch.

Merge coordination: this PR and #1082 both change find_dead_code. If #1082 lands first, retain its single streaming edge scan and exclude Storybook rows before adding them to the evidence maps. The integration branch contains the tested resolution (the shared regex import plus if _STORYBOOK_FILE_RE.search(file_path): continue in that scan). Both the Storybook and constant-query-count regressions pass together.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

code-review-graph review

Overall risk: 0.55 (MEDIUM) — 6 changed function(s)/class(es), 47 affected flow(s), 0 test gap(s)

Risk-scored changes

Risk Level Symbol Location Tested
0.55 medium code_review_graph/refactor.py::find_dead_code code_review_graph/refactor.py:236 yes
0.05 low tests/test_storybook_dead_code.py::test_story_filename_is_nonproduction tests/test_storybook_dead_code.py:13 (test)
0.05 low tests/test_storybook_dead_code.py::test_story_like_production_paths_remain_production tests/test_storybook_dead_code.py:21 (test)
0.05 low tests/test_storybook_dead_code.py::test_only_story_callers_do_not_keep_component_alive tests/test_storybook_dead_code.py:26 (test)
0.05 low tests/test_storybook_dead_code.py::test_story_call_does_not_hide_bare_production_caller_fallback tests/test_storybook_dead_code.py:43 (test)
0.05 low tests/test_storybook_dead_code.py::test_story_member_calls_do_not_keep_class_alive tests/test_storybook_dead_code.py:55 (test)

Affected execution flows

  • process — criticality 0.74, 538 node(s) across 14 file(s)
  • _run — criticality 0.74, 565 node(s) across 16 file(s)
  • build_or_update_graph_tool — criticality 0.73, 617 node(s) across 24 file(s)
  • main — criticality 0.72, 923 node(s) across 40 file(s)
  • run_token_benchmark — criticality 0.70, 38 node(s) across 5 file(s)
  • ...and 42 more affected flow(s)

Powered by code-review-graph — local-first analysis; no code leaves the CI runner.

@azizur100389
azizur100389 marked this pull request as ready for review October 1, 2026 17:59

This branch has not been deployed

No deployments
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.

dead_code false-negatives on any component with a Storybook .stories.tsx file

1 participant