Public report of bojieli/ai-agent-book, published 3 November 2026. It has the same score, grades and number of findings as the full report. The details of security findings (where they are in the code, which known vulnerabilities and which passwords or keys were found) are left out, so nobody can use them against the project.
Public
Executive report Measured under the Code Assurance Index, an open standard for code quality, using its published scoring rules (rubric version 2026.11.4). Assert signed this survey and filed it in the standard's public register, where anyone can look it up by its survey ID. Check this survey → Signed and filed in the standard's public register, 15 November 2026, 19:08 UTC · Survey ID cd_9aa47d98bcde48a98b2d913944c2673d

bojieli/ai-agent-book

Measured 3 November 2026, 18:35 UTC, at code version dbc046e

CAI score 32out of 100 At risk Up 2 since the last survey

The score is built from these lenses. Each lens grades one area of the code, such as how easy it is to change or how well it is protected. The weakest lens counts most, so one weak area pulls the score down instead of being averaged away.

A large codebase: 267,236 lines of product code in 103 projects, tests not counted · Estimated rebuild effort: about 1.9 person-years · Weakest lens: Production Readiness, 14

Findings by how serious they are

320 critical 2300 serious 201 minor

8 dimensions are left out of the score. For each one, we either couldn't measure it in this code, or found no evidence of the safeguard we look for, such as a tested backup restore. They count neither for nor against the score, and Limitations lists each one with its reason.

This survey was produced by

Assert small markCanine Code Analyzer
Producer
Canine Development
Analyzer
Canine Code Analyzer engine 1.0.0
Measured
3 November 2026, 18:35 UTC

A measurement, not a certificate. The Code Assurance Index records a number together with the evidence it was worked out from, so anyone can recalculate it, but it doesn't certify or guarantee the code. The standard was written by Canine Development, which also builds the Canine Code Analyzer. It is open to any tool that implements it, and today the Canine Code Analyzer is the only one that does.

A critical security finding is open, such as a library with a known critical vulnerability or a password or key found in the code. The score itself is unchanged, but its band shows At risk until the finding is fixed. See the Security and Compliance lens.

The score is deterministic, which means the same code always gets the same score. We work it out with tools that follow published rules, and an AI model never decides it, so anyone who applies the same rules to the same code gets the same number. How it is done is explained under Methodology ▸

89of 89 dimensions measured by tools.
2783of 2821 findings point to an exact file and line, so you can open each one in the code. The other 38 concern the repository as a whole, such as missing documentation.
89dimensions across 8 lenses, read from 267,236 lines of product code in 103 projects.
Chapters

Executive summary

bojieli/ai-agent-book is rated At risk because critical security findings are open. Its score is held back because nine passwords or keys sit in the current code and we found no automated security scanning of the code, its secrets or its dependencies. It scores 32 out of 100, which the At risk rating leaves unchanged.

Production Readiness, at 14, is the weakest lens and counts most in the score. The best first step is replacing the nine exposed passwords or keys and switching the old ones off, worth about 15 points. Raising Production Readiness to 70 would lift the score to about 47.

127 known security holes in the packages the code depends on can be used by attackers. Sixty passwords or keys in the code's history and nine in the code are open to anyone who can read the repository, and thirty-four places in the code run text as code, which an attacker could use. Updating the vulnerable packages, replacing each exposed password or key and replacing text run as code with direct calls would close these risks. Pinning each tool to an exact version would fix the 21 pipeline tools referenced by a changeable name, and the 15 unsafe settings in infrastructure or container files need changing to safe values. The 13 pages or frames without a title need a descriptive title.

The product code is 267,236 lines, about €280,000 to rebuild.

A lens is capped at Adequate while one of its dimensions scores below 4 out of 10, however well the rest of the lens does. That way a serious problem in one place always shows in the lens's rating.

How the score is built: what each lens counts for The lenses don't count equally. The weakest lens counts most, the next weakest a little less, and so on, so a weak area pulls the score down instead of being averaged away. In the bar below, each part's width shows how much that lens counts and its colour shows its rating. Improving the widest part moves the score most, and as that lens improves, it counts for less, because another lens becomes the weakest.
Production Readiness 14 · counts for 45%Accessibility 38 · counts for 25%Code Health 42 · counts for 14%Performance 60 · counts for 8%Security and Compliance 64 · counts for 4%Maturity 74 · counts for 2%Architecture 97 · counts for 1%Domain Modelling 100 · counts for 1%

If Production Readiness rose from 14 to 70, the lowest score rated Strong, the score would rise from 32 to about 47.

Code composition: what the lines of code are
Product code 82%Tests 18%
New since the last survey: 149 findings

These 149 critical or serious findings weren't in the previous survey, on 20 October 2026. The first 100 are listed here, and the findings file in the download package lists them all.

We compare every finding with the previous survey's. A finding that has only moved to another line in the same file counts as the same finding, so only new findings appear here. Advisory notes from the AI model are left out, because the model words them afresh in every survey.

Fixed since the last survey: 261 findings

These 261 critical or serious findings were in the previous survey, on 20 October 2026, and are gone from this one. The first 100 are listed here.

  • Cyclomatic Complexity · book-markdown.bookMarkdown (cyclomatic 84) REDACTED
  • Cognitive Complexity · book-markdown.bookMarkdown (cognitive 59) REDACTED
  • Secrets (history) · High secret: REDACTED REDACTED
  • Secrets (history) · High secret: REDACTED REDACTED
  • Static Analysis (SAST) · High: watchdog-unpinned-package-install-in-run REDACTED
  • Static Analysis (SAST) · High: watchdog-unpinned-package-install-in-run REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regexp-from-parameter-ts REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regex-match-index-beyond-capture-groups-js REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regexp-from-parameter-ts REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regex-match-index-beyond-capture-groups-js REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regexp-from-parameter-ts REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regex-match-index-beyond-capture-groups-js REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regexp-from-parameter-ts REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regex-match-index-beyond-capture-groups-js REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regex-match-index-beyond-capture-groups-js REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regex-match-index-beyond-capture-groups-js REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regex-match-index-beyond-capture-groups-js REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regex-match-index-beyond-capture-groups-js REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regexp-from-parameter-ts REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regexp-from-parameter-ts REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regex-match-index-beyond-capture-groups-js REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regex-match-index-beyond-capture-groups-js REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regexp-from-parameter-ts REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regexp-from-parameter-ts REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regexp-from-parameter-ts REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regex-match-index-beyond-capture-groups-js REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regex-match-index-beyond-capture-groups-js REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regex-match-index-beyond-capture-groups-js REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regex-match-index-beyond-capture-groups-js REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regex-match-index-beyond-capture-groups-js REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regex-match-index-beyond-capture-groups-js REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regexp-from-parameter-ts REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regexp-from-parameter-ts REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regexp-from-parameter-ts REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regex-match-index-beyond-capture-groups-js REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regexp-from-parameter-ts REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regex-match-index-beyond-capture-groups-js REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regex-match-index-beyond-capture-groups-js REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regex-match-index-beyond-capture-groups-js REDACTED
  • Static Analysis (SAST) · Medium: watchdog-regex-match-index-beyond-capture-groups-js REDACTED
  • Dependency Vulnerabilities · Critical vulnerability: [GHSA redacted] REDACTED
  • Dependency Vulnerabilities · Critical vulnerability: [GHSA redacted] REDACTED
  • Dependency Vulnerabilities · High CVE: REDACTED REDACTED
  • Dependency Vulnerabilities · High CVE: REDACTED REDACTED
  • Dependency Vulnerabilities · High CVE: REDACTED REDACTED
  • Dependency Vulnerabilities · High CVE: REDACTED REDACTED
  • Dependency Vulnerabilities · High CVE: [GHSA redacted] REDACTED
  • Dependency Vulnerabilities · High CVE: REDACTED REDACTED
  • Dependency Vulnerabilities · High CVE: REDACTED REDACTED
  • Dependency Vulnerabilities · High CVE: REDACTED REDACTED
  • Dependency Vulnerabilities · High CVE: REDACTED REDACTED
  • Dependency Vulnerabilities · High CVE: REDACTED REDACTED
  • Dependency Vulnerabilities · High CVE: REDACTED REDACTED
  • Dependency Vulnerabilities · High CVE: REDACTED REDACTED
  • Dependency Vulnerabilities · High CVE: [GHSA redacted] REDACTED
  • Dependency Vulnerabilities · High CVE: [GHSA redacted] REDACTED
  • Dependency Vulnerabilities · High CVE: [GHSA redacted] REDACTED
  • Dependency Vulnerabilities · High CVE: [GHSA redacted] REDACTED
  • Dependency Vulnerabilities · High CVE: [CVE redacted] REDACTED
  • Dependency Vulnerabilities · Medium CVE: [GHSA redacted] REDACTED
  • Dependency Vulnerabilities · Medium CVE: REDACTED REDACTED
  • Dependency Vulnerabilities · Medium CVE: REDACTED REDACTED
  • Dependency Vulnerabilities · Medium CVE: REDACTED REDACTED
  • Dependency Vulnerabilities · Medium CVE: [GHSA redacted] REDACTED
  • Dependency Vulnerabilities · Medium CVE: [GHSA redacted] REDACTED
  • Dependency Vulnerabilities · Medium CVE: [GHSA redacted] REDACTED
  • Dependency Vulnerabilities · Medium CVE: [GHSA redacted] REDACTED
  • Dependency Vulnerabilities · Medium CVE: [GHSA redacted] REDACTED
  • Dependency Vulnerabilities · Medium CVE: [GHSA redacted] REDACTED
  • Dependency Vulnerabilities · Medium CVE: [CVE redacted] REDACTED
  • Dependency Vulnerabilities · Medium CVE: REDACTED REDACTED
  • Code Duplication · Duplicated block (11 lines × 3 locations) chapter2/attention_visualization/frontend/components/AttentionModal.tsx
  • Code Duplication · Duplicated block (11 lines × 2 locations) REDACTED
  • Code Duplication · Duplicated block (11 lines × 2 locations) web-astro/scripts/collaboration-context-figures.mjs
  • Code Duplication · Duplicated block (11 lines × 3 locations) web-astro/scripts/collaboration-manager-figures.mjs
  • Code Duplication · Duplicated block (11 lines × 2 locations) web-astro/scripts/collaboration-society-figures.mjs
  • Code Duplication · Duplicated block (11 lines × 2 locations) web-astro/scripts/evolution-flow-figures.mjs
  • Code Duplication · Duplicated block (11 lines × 5 locations) web-astro/scripts/prepare-assets.mjs
  • Code Duplication · Duplicated block (10 lines × 2 locations) chapter6/live-audio/backend/server.js
  • Code Duplication · Duplicated block (10 lines × 2 locations) web-astro/scripts/agent-loop-figure.mjs
  • Code Duplication · Duplicated block (10 lines × 2 locations) REDACTED
  • Code Duplication · Duplicated block (9 lines × 3 locations) REDACTED
  • Code Duplication · Duplicated block (9 lines × 2 locations) REDACTED
  • Code Duplication · Duplicated block (9 lines × 2 locations) REDACTED
  • Code Duplication · Duplicated block with local edits (8 matched lines × 2 locations) chapter2/attention_visualization/frontend/components/AttentionModal.tsx
  • Code Duplication · Duplicated block (8 lines × 3 locations) chapter2/attention_visualization/frontend/components/AttentionStats.tsx
  • Code Duplication · Duplicated block (8 lines × 2 locations) REDACTED
  • Code Duplication · Duplicated block (8 lines × 2 locations) slides/chapter1-pilot.mjs
  • Code Duplication · Duplicated block (8 lines × 2 locations) REDACTED
  • Code Duplication · Duplicated block (8 lines × 2 locations) REDACTED
  • Code Duplication · Duplicated block (8 lines × 2 locations) REDACTED
  • Code Duplication · Duplicated block (8 lines × 3 locations) REDACTED
  • Code Duplication · Duplicated block (8 lines × 5 locations) web-astro/scripts/prepare-assets.mjs
  • Code Duplication · Duplicated block (8 lines × 2 locations) REDACTED
  • Code Duplication · Duplicated block (7 lines × 2 locations) chapter6/live-audio/backend/server.js
  • Code Duplication · Duplicated block (7 lines × 6 locations) chapter6/live-audio/frontend/components/ui/card.tsx
  • Code Duplication · Duplicated block with local edits (7 matched lines × 2 locations) REDACTED
  • Code Duplication · Duplicated block (7 lines × 2 locations) REDACTED
  • Code Duplication · Duplicated block (7 lines × 2 locations) web-astro/scripts/retrieval-workflow-layout.mjs
  • Code Duplication · Duplicated block (6 lines × 2 locations) chapter6/live-audio/backend/run_real_validation.js
Rebuild cost: about €280,000 · Estimate
Cost to rebuild€92,000 to €460,000, for 1,541 to 4,888 hours of work, about 1.9 person-years for 1 to 4 engineers
Difficulty of the problemStandard, judged from the kind of software and how it is built. Code that solves a harder problem, such as payments or medical bookings, costs more per line to write.
Quality factor×0.7 at a score of 32. Better code takes more work to write, so the factor is ×1.0 at a score of 70, lower below it and higher above it.
SizeLarge: 267,236 lines of product code
What it is notNot a quotation: nobody has offered to build it for that. Not a valuation: it says nothing about what the business is worth. Not a certified figure: no professional has signed it as one.

How the estimate is made: We price the hours a team would need to write this code again, at €60 to €95 an hour. Declarations and boilerplate are priced at a fast rate and logic at a slower one, and the logic is then multiplied by the difficulty of the problem and by the quality factor. The estimate can be about 30% off either way, and it moves most with the hourly rate and the difficulty. For this code, every line is priced as straight logic, which keeps the estimate on the low side.

Top priorities

The three actions that raise the score most for the work they take. The full ranked list is in the Roadmap.

1
Resolve the 9 Leaked secret finding(s) in REDACTED Scanning — start with REDACTED (3), REDACTED (2), REDACTED.
Raises the score by about 15 points · Low effort · REDACTED Scanning
2
Add a SAST step to CI running what this repository's stack ships: bandit, `semgrep --config=p/python`, or CodeQL's python pack — so a security regression fails the build instead of landing.
Raises the score by about 2 points · Medium effort · Security & performance tooling
3
Codify backups + geo-recovery in IaC and document RTO/RPO and the restore procedure — a persistence guard alone is not disaster recovery.
Raises the score by about 2 points · Medium effort · DR & Backup

Diagnosis: what the measurements show together

Each conclusion below combines several dimensions into one point that no single dimension shows, and lists the measurements it rests on.

Where the investment is most exposed · Value at risk
This code would cost about €280,000 to build again, about 1.9 person-years of work. Its weakest lens is Production Readiness, at 14 (Critical). Production Readiness is about whether the product is ready to run in production and to change without breaking. Because the weakest lens counts most in the score, work on Production Readiness also moves the score most.
Based on: the rebuild estimate · the Production Readiness grade · how much each lens counts
What to do: Start with the Production Readiness actions in Top priorities.
If you do one thing first · First action
Resolve the 9 Leaked secret finding(s) in REDACTED Scanning. Of all the actions in this report, it raises the score most for the work it takes: about 15 points for low effort, because it clears the 9 REDACTED Scanning findings. The next survey will show the change in the score.
Based on: the ranked actions in Top priorities, by score gain and effort
What hard-to-read code costs each year · Cost
Four dimensions measure how easy the code is to work in: two measure how tangled its logic is, one how much of it is copied, and one how well each part sticks to a single job. In this codebase they average 6.2 out of 10. Code at that level is slower to change than clean code, and we estimate the extra work at 4% to 10% on every change. The history of the code shows how much it changes: about 1,729,844 lines over the last 90 days, which is about 7,015,478 lines a year. At that pace, the extra work comes to an estimated 777 to 4661.8 engineer-days a year, and it grows as more code changes.
How this is estimated: The number of changed lines is measured from the history of the code. The rest rests on two assumptions of our own: code scoring 8 out of 10 or more adds no extra work, and each point below 8 adds 2.5% to 5.6% to every change, never less than 2% to 5% and never more than 40% to 60% in all; and an engineer changes 150 to 400 lines in a day. The result is a range for planning, not a measurement.
Based on: Cyclomatic Complexity · Cognitive Complexity · Code Duplication · Cohesion (LCOM4) · the code's change history
What to do: Start with the files listed under Churn × Complexity Hotspots, which change often and are hard to read, because that is where the extra work is paid most often.

Architecture: which parts of the code depend on which

The code is divided into modules, groups of code that each handle one part of the product, and a module depends on another when it uses code from it. The table lists the modules both down the side and across the top, in an order where each module should only use modules listed above it. A number in a cell means the module on that row uses the module in that column, and it counts the pairs of building blocks (types) that connect them. The one thing to look for is a mark above the diagonal line. It means two or more modules use each other in a loop (a dependency cycle), so none of them can be changed, tested or released on its own.

745 modules, with 394 dependencies between them. One loop runs through 5 of the modules, marked above the diagonal.

The table shows the 40 modules with the most connections; 705 more are left out to keep it readable.

Which modules use which. The module on each row uses the module in each column, and the number counts the pairs of types that connect them. A cell above the diagonal is part of a loop.
uses →1 chapter10.autonomous-phone-registration.browser2 chapter10.voice-werewolf.werewolf.roles3 chapter2.attention_visualization.frontend.components4 chapter2.context-compression.compression_strategies5 chapter2.prompt-engineering.tau_bench.envs.tool6 chapter2.prompt-engineering.tau_bench.model_utils.model.general_model7 chapter2.prompt-engineering.tau_bench.types8 chapter3.agentic-rag-for-user-memory.indexer9 chapter3.contextual-retrieval-for-user-memory.indexer10 chapter3.mem0.agent11 chapter3.structured-index12 chapter3.user-memory.config13 chapter5.coding-agent.tools.base14 chapter5.permission-embedded-data-objects.pedo.core.store15 chapter6.agent-with-event-trigger16 chapter9.browser-use-rpa.browser-use.browser_use.browser.profile17 chapter9.browser-use-rpa.browser-use.browser_use.dom.views18 chapter9.browser-use-rpa.browser-use.browser_use.llm.base19 chapter9.browser-use-rpa.browser-use.browser_use.llm.messages20 chapter9.browser-use-rpa.learning_agent.workflow21 chapter10.autonomous-phone-registration.orchestration22 chapter10.voice-werewolf.werewolf.agent23 chapter2.prompt-engineering.tau_bench.envs.base24 chapter2.prompt-engineering.tau_bench.model_utils.api.datapoint25 chapter2.prompt-engineering.tau_bench.model_utils.model.chat26 chapter5.permission-embedded-data-objects.pedo.eval.dataguardbench.agentspec_wrap27 chapter9.browser-use-rpa.browser-use.browser_use.browser.events28 chapter9.browser-use-rpa.browser-use.browser_use.browser.views29 chapter10.autonomous-phone-registration30 chapter2.prompt-engineering.tau_bench.agents.base31 chapter2.prompt-engineering.tau_bench.model_utils.api.router32 chapter5.permission-embedded-data-objects.pedo.eval.dataguardbench33 chapter9.browser-use-rpa.browser-use.browser_use.agent.message_manager.service34 chapter9.browser-use-rpa.browser-use.browser_use.agent.views35 chapter9.browser-use-rpa.browser-use.browser_use.browser.session36 chapter2.prompt-engineering.tau_bench.model_utils.api.api37 chapter9.browser-use-rpa.browser-use.browser_use.agent.service38 chapter9.browser-use-rpa.browser-use.browser_use.browser.watchdog_base39 chapter9.browser-use-rpa.browser-use.browser_use.tools.service40 chapter2.prompt-engineering.tau_bench.model_utils.api
1 chapter10.autonomous-phone-registration.browser
2 chapter10.voice-werewolf.werewolf.roles
3 chapter2.attention_visualization.frontend.components
4 chapter2.context-compression.compression_strategies
5 chapter2.prompt-engineering.tau_bench.envs.tool
6 chapter2.prompt-engineering.tau_bench.model_utils.model.general_model
7 chapter2.prompt-engineering.tau_bench.types
8 chapter3.agentic-rag-for-user-memory.indexer
9 chapter3.contextual-retrieval-for-user-memory.indexer
10 chapter3.mem0.agent
11 chapter3.structured-index
12 chapter3.user-memory.config
13 chapter5.coding-agent.tools.base
14 chapter5.permission-embedded-data-objects.pedo.core.store
15 chapter6.agent-with-event-trigger
16 chapter9.browser-use-rpa.browser-use.browser_use.browser.profile
17 chapter9.browser-use-rpa.browser-use.browser_use.dom.views
18 chapter9.browser-use-rpa.browser-use.browser_use.llm.base
19 chapter9.browser-use-rpa.browser-use.browser_use.llm.messages
20 chapter9.browser-use-rpa.learning_agent.workflow
21 chapter10.autonomous-phone-registration.orchestration2
22 chapter10.voice-werewolf.werewolf.agent1
23 chapter2.prompt-engineering.tau_bench.envs.base4
24 chapter2.prompt-engineering.tau_bench.model_utils.api.datapoint7
25 chapter2.prompt-engineering.tau_bench.model_utils.model.chat1
26 chapter5.permission-embedded-data-objects.pedo.eval.dataguardbench.agentspec_wrap1
27 chapter9.browser-use-rpa.browser-use.browser_use.browser.events1
28 chapter9.browser-use-rpa.browser-use.browser_use.browser.views1
29 chapter10.autonomous-phone-registration11
30 chapter2.prompt-engineering.tau_bench.agents.base11
31 chapter2.prompt-engineering.tau_bench.model_utils.api.router6
32 chapter5.permission-embedded-data-objects.pedo.eval.dataguardbench11
33 chapter9.browser-use-rpa.browser-use.browser_use.agent.message_manager.service11
34 chapter9.browser-use-rpa.browser-use.browser_use.agent.views1
35 chapter9.browser-use-rpa.browser-use.browser_use.browser.session1192
36 chapter2.prompt-engineering.tau_bench.model_utils.api.api111
37 chapter9.browser-use-rpa.browser-use.browser_use.agent.service1113
38 chapter9.browser-use-rpa.browser-use.browser_use.browser.watchdog_base1
39 chapter9.browser-use-rpa.browser-use.browser_use.tools.service11
40 chapter2.prompt-engineering.tau_bench.model_utils.api311
Uses a module listed above itPart of a loopThe module itself
1 chapter10.autonomous-phone-registration.browser2 chapter10.voice-werewolf.werewolf.roles3 chapter2.attention_visualization.frontend.components4 chapter2.context-compression.compression_strategies5 chapter2.prompt-engineering.tau_bench.envs.tool6 chapter2.prompt-engineering.tau_bench.model_utils.model.general_model7 chapter2.prompt-engineering.tau_bench.types8 chapter3.agentic-rag-for-user-memory.indexer9 chapter3.contextual-retrieval-for-user-memory.indexer10 chapter3.mem0.agent11 chapter3.structured-index12 chapter3.user-memory.config13 chapter5.coding-agent.tools.base14 chapter5.permission-embedded-data-objects.pedo.core.store15 chapter6.agent-with-event-trigger16 chapter9.browser-use-rpa.browser-use.browser_use.browser.profile17 chapter9.browser-use-rpa.browser-use.browser_use.dom.views18 chapter9.browser-use-rpa.browser-use.browser_use.llm.base19 chapter9.browser-use-rpa.browser-use.browser_use.llm.messages20 chapter9.browser-use-rpa.learning_agent.workflow21 chapter10.autonomous-phone-registration.orchestration22 chapter10.voice-werewolf.werewolf.agent23 chapter2.prompt-engineering.tau_bench.envs.base24 chapter2.prompt-engineering.tau_bench.model_utils.api.datapoint25 chapter2.prompt-engineering.tau_bench.model_utils.model.chat26 chapter5.permission-embedded-data-objects.pedo.eval.dataguardbench.agentspec_wrap27 chapter9.browser-use-rpa.browser-use.browser_use.browser.events28 chapter9.browser-use-rpa.browser-use.browser_use.browser.views29 chapter10.autonomous-phone-registration30 chapter2.prompt-engineering.tau_bench.agents.base31 chapter2.prompt-engineering.tau_bench.model_utils.api.router32 chapter5.permission-embedded-data-objects.pedo.eval.dataguardbench33 chapter9.browser-use-rpa.browser-use.browser_use.agent.message_manager.service34 chapter9.browser-use-rpa.browser-use.browser_use.agent.views35 chapter9.browser-use-rpa.browser-use.browser_use.browser.session36 chapter2.prompt-engineering.tau_bench.model_utils.api.api37 chapter9.browser-use-rpa.browser-use.browser_use.agent.service38 chapter9.browser-use-rpa.browser-use.browser_use.browser.watchdog_base39 chapter9.browser-use-rpa.browser-use.browser_use.tools.service40 chapter2.prompt-engineering.tau_bench.model_utils.apichapter10.autonomous-phone-registration.browser1chapter10.voice-werewolf.werewolf.roles2chapter2.attention_visualization.frontend.components3chapter2.context-compression.compression_strategies4chapter2.prompt-engineering.tau_bench.envs.tool5chapter2.prompt-engineering.tau_bench.model_utils.model.general_model6chapter2.prompt-engineering.tau_bench.types7chapter3.agentic-rag-for-user-memory.indexer8chapter3.contextual-retrieval-for-user-memory.indexer9chapter3.mem0.agent10chapter3.structured-index11chapter3.user-memory.config12chapter5.coding-agent.tools.base13chapter5.permission-embedded-data-objects.pedo.core.store14chapter6.agent-with-event-trigger15chapter9.browser-use-rpa.browser-use.browser_use.browser.profile16chapter9.browser-use-rpa.browser-use.browser_use.dom.views17chapter9.browser-use-rpa.browser-use.browser_use.llm.base18chapter9.browser-use-rpa.browser-use.browser_use.llm.messages19chapter9.browser-use-rpa.learning_agent.workflow20chapter10.autonomous-phone-registration.orchestration21chapter10.voice-werewolf.werewolf.agent22chapter2.prompt-engineering.tau_bench.envs.base23chapter2.prompt-engineering.tau_bench.model_utils.api.datapoint24chapter2.prompt-engineering.tau_bench.model_utils.model.chat25chapter5.permission-embedded-data-objects.pedo.eval.dataguardbench.agentspec_wrap26chapter9.browser-use-rpa.browser-use.browser_use.browser.events27chapter9.browser-use-rpa.browser-use.browser_use.browser.views28chapter10.autonomous-phone-registration29chapter2.prompt-engineering.tau_bench.agents.base30chapter2.prompt-engineering.tau_bench.model_utils.api.router31chapter5.permission-embedded-data-objects.pedo.eval.dataguardbench32chapter9.browser-use-rpa.browser-use.browser_use.agent.message_manager.service33chapter9.browser-use-rpa.browser-use.browser_use.agent.views34chapter9.browser-use-rpa.browser-use.browser_use.browser.session35chapter2.prompt-engineering.tau_bench.model_utils.api.api36chapter9.browser-use-rpa.browser-use.browser_use.agent.service37chapter9.browser-use-rpa.browser-use.browser_use.browser.watchdog_base38chapter9.browser-use-rpa.browser-use.browser_use.tools.service39chapter2.prompt-engineering.tau_bench.model_utils.api4021471111111161111111921111113111311+705 more modules (most-connected shown)

At a glance — Code Health · 42% · Weak · gated by D2, R1, X4 ·

At a glance — Architecture · 97% · Exemplary ·

At a glance — Maturity · 74% · Strong ·

At a glance — Readiness · 14% · Critical · gated by D12, D13, R8, P3, P5, P7 ·

At a glance — Security · 64% · Adequate · gated by D28, D29, D30, D31, D36 ·

At a glance — Domain Modelling · 100% · Exemplary ·

At a glance — Accessibility · 38% · Weak · gated by AC1, AC4 ·

At a glance — Performance · 60% · Adequate ·

Security & Compliance — OWASP Top-10 mapping

Findings mapped to OWASP categories; the specific CVEs/secrets are in the Security dimension cards below and findings.md (redacted only on the public version of this report).

OWASP categoryFindingsSeverity
A03:2025 — Software Supply Chain Failures218High / Critical
A05:2025 — Injection172High / Critical
A07:2025 — Authentication Failures70High / Critical
A02:2025 — Security Misconfiguration42High / Critical

Roadmap

Top priorities: Resolve the 9 Leaked secret finding(s) in REDACTED Scanning — start with REDACTED (3), REDACTED (2), REDACTED; Add a SAST step to CI running what this repository's stack ships: bandit, `semgrep --config=p/python`, or CodeQL's python pack — so a security regression fails the build instead of landing; Codify backups + geo-recovery in IaC and document RTO/RPO and the restore procedure — a persistence guard alone is not disaster recovery.

Ranked by impact ÷ effort. "Helps" is the estimated gain on the 0–100 health score.

Do thisHelpsEffortDimension
Resolve the 9 Leaked secret finding(s) in REDACTED Scanning — start with REDACTED (3), REDACTED (2), REDACTED.+15.4 ptsLowREDACTED Scanning
Add a SAST step to CI running what this repository's stack ships: bandit, `semgrep --config=p/python`, or CodeQL's python pack — so a security regression fails the build instead of landing.+2.4 ptsMediumSecurity & performance tooling
Codify backups + geo-recovery in IaC and document RTO/RPO and the restore procedure — a persistence guard alone is not disaster recovery.+2.4 ptsMediumDR & Backup
Remove unused dependencies, declare unlisted imports explicitly, and demote type-/test-only packages to devDependencies.+2.4 ptsMediumDependency Hygiene
Add a text alternative — alt on images (alt="" for purely decorative ones), a title or aria-label on meaningful svg, an aria-label or inner fallback content on canvas, and a captions <track> on video.+2.0 ptsMediumText alternatives
Python: await the async equivalent (asyncio.sleep, an async HTTP client such as httpx.AsyncClient or aiohttp, asyncio.create_subprocess_exec), or move the blocking call off the loop with `await asyncio.to_thread(...)`; never call asyncio.run inside a coroutine — await the coroutine.+1.3 ptsMediumAsync & latency hygiene
Migrate the remaining .js/.jsx files to TypeScript.+1.2 ptsMediumType Safety
Make custom controls keyboard-operable (role + tabindex + key handler), drop positive tabindex, and give anchors a real href.+1.2 ptsMediumKeyboard semantics

File quality

Per-file score 0–10 — a quality signature. Of 587 files carrying findings, judged against the Production bar: 5% slop · 73% mixed · 22% near-clean.

FileScoreBandWorst signal
REDACTED0.0SlopDependency Vulnerabilities: Critical CVE: REDACTED
REDACTED0.0SlopDependency Vulnerabilities: Critical CVE: REDACTED
REDACTED0.0SlopDependency Vulnerabilities: Critical CVE: REDACTED
REDACTED0.0SlopDependency Vulnerabilities: High CVE: REDACTED
REDACTED0.0SlopIaC & Container Security: High IaC: REDACTED
REDACTED0.1SlopDependency Vulnerabilities: High CVE: REDACTED
REDACTED0.4SlopStatic Analysis (SAST): High: REDACTED
REDACTED0.5SlopDependency Vulnerabilities: High CVE: REDACTED
REDACTED0.6SlopDependency Vulnerabilities: Critical CVE: REDACTED
REDACTED1.0SlopStatic Analysis (SAST): High: REDACTED
REDACTED1.2SlopSecrets (history): REDACTED: REDACTED
REDACTED1.4SlopDependency Vulnerabilities: Critical CVE: REDACTED
REDACTED1.6SlopDependency Vulnerabilities: High CVE: REDACTED
REDACTED1.6SlopDependency Vulnerabilities: High CVE: REDACTED
REDACTED1.6SlopDependency Vulnerabilities: High CVE: REDACTED
REDACTED1.6SlopDependency Vulnerabilities: High CVE: REDACTED
REDACTED1.9SlopIaC & Container Security: High IaC: REDACTED
REDACTED1.9SlopIaC & Container Security: High IaC: REDACTED
REDACTED2.1SlopStatic Analysis (SAST): High: REDACTED
REDACTED2.1SlopStatic Analysis (SAST): High: REDACTED

How the grades work

Every finding carries one of four grades. Three say how serious it is. The fourth says this survey could not settle it — and it is a grade, not a gap.

Critical — 320

A definite problem that already costs you something and drags the score down: a missing authorisation check, a dependency with a known exploit, a build that does not reproduce. Failure here tends to cause failures elsewhere.

Serious — 2300

Likely wrong, but not failing yet. It degrades the codebase over a longer horizon and can cause failures elsewhere — not urgent this week, not something to carry for two years either.

Minor — 201

Recorded, with no effect on how the codebase functions. Present so the survey is complete, not because it needs doing.

Could not be resolved — 8

Something this survey could not settle from the outside, and which could be critical or serious. Either a control was required and no positive evidence of it exists in the repository — a backup job that nothing shows was ever restored from proves nothing about restores — or our own analysis could not run over that part of the tree. This is not a clean result. These are excluded from the score rather than awarded a pass, so the number on the cover neither rewards nor penalises them: if you act on this survey without resolving them, you carry that risk yourself. Each one is named under Limitations.

Methodology & how to trust this report

This survey is a deep, periodic assessment — run each sprint, monthly, or quarterly, taking the time to go wider and deeper than a quick check and surfacing in one coherent report what you'd otherwise piece together from a dozen separate tools. It scores deterministically: the same commit yields the same score, every run. All 89 evaluated dimensions are computed by tools and static analysis; no language model sets or judges any of them. Overall confidence is 0.9, the weighted average across measured dimensions.

Every figure here is one of two kinds, and we label which: ✓ Measured — a deterministic fact (LoC, complexity, coverage); ~ Modeled — an estimate from a stated model (cost, effort, value-at-risk), always a range with its assumptions, never a precise fact. We never present a modelled estimate as if it were measured. Perfect or absent scores carry their provenance too (ADR-0011): ✓ Tool-verified means the property itself was measured across the surface; ○ Nothing flagged means the probes came back clean — a claim bounded by what a repository can show; ⊘ Not evidenced means a working control (a tested restore, an automated rollback) showed no positive evidence — absence of evidence is not evidence of a control, so it's excluded from the score rather than awarded a spurious 10.

What we checked — 89 dimensions across the health lenses
D1D2D3D4D5D6D9D10D11D12D13D15D16D17D19D20D24D26D27D28D29D30D31D34D35D36D43D44AC1AC2AC3AC4AC5AC6AC7AX10AX2AX3AX4C2DM6M1M2M3M4P1P10P2P3P4P5P6P7PF3R1R10R11R2R3R4R5R6R7R8R9S1X1X12X13X14X15X16X17X18X19X2X21X22X23X24X25X26X27X28X29X3X30X4X5

Each chip is a dimension scored from real signals across architecture, testing, dependencies, security & compliance, documentation, git-history and code quality — in one coherent pass. A surface report typically covers a handful.

How to trust any code-health report — three questions
  1. Can you open the finding? Real findings cite a repo-relative file and line you can open at the cited line — never an absolute scratch path. Here, 2783 of 2821 do; the remainder are repo-wide signals — a dimension-level measurement, not a single line. (Every path in this report is repo-relative by construction: paths are normalized at the producer and the report is rejected if any rooted path leaks through.)
  2. Is there a tool behind the number? Every score below names the method that produced it: Roslyn, git or a scanner, not a narrative.
  3. Does re-running give the same result? Run it again on the same commit and the score — and this report, byte for byte — is identical. A report whose numbers move between runs is describing the run, not the code.

This report answers yes to all three. That's the bar to hold any assessment to.

Tools & methods

The actual versions used this run (captured at analysis time) — re-run on the same commit for the identical score.

MethodBacksVersionEvaluator
Roslyn static analysisComplexity, cohesion, coupling, dead code, API surface, layering5.3.0✓ deterministic
Native secret scannerHardcoded secrets / credentials1.0.0✓ deterministic
Canine Code Analyzer duplication detector (in-process)Code duplication1.0.0✓ deterministic
Coverage (coverlet / dotnet-coverage)Line & branch coverage10.0.400✓ deterministic
NuGet / dotnetOutdated, vulnerable & deprecated dependencies10.0.400✓ deterministic
git / LibGit2SharpChurn hotspots, knowledge concentration, history2.43.0 · 0.31.0✓ deterministic
gitleaks · semgrep · trivy · checkovSecrets in history, SAST, CVEs, IaC & container, PII / GDPR1.86.0 · 0.69.3 · 3.2.533✓ deterministic

Every finding is locatable in findings.md. Run 01a1a2b2-393b-7533-bac6-f677191c661a.

The exact command behind every deep-scan dimension — tool, version, invocation and retained raw output — is in Appendix B — Reproduction & audit trail.

Run transparency — what happened this run

What ran differently this time — a tool absent, degraded, or that fell back to an estimate. Named openly, not folded silently into the scores. A degraded run also records its exact cause in diagnostics.md.

  • D8 Code Coverage — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Coverage NOT MEASURED: this repository's production source spans .ts, .tsx, .py, and our analyzer cannot run the .py test suite(s) — so no coverage was collected for the repository as a whole. The JavaScript/TypeScript half did build and run, and its own line coverage came back at 94.8% — but that is a figure for one half of the product, and we do not publish a partial one as if it were complete. This is OUR limitation, not a defect in the repo — coverage is excluded from the score rather than counted as a near-zero. In the meantime, produce a coverage report in a standard format (lcov — `vitest --coverage`, `jest --coverage`, `bun test --coverage --coverage-reporter=lcov`, or `nyc`, or `coverage run -m pytest` then `coverage xml`) and commit it — a hosted scan measures a clone of the repository, so a report that exists only in a working tree, a CI runner's or your own, never reaches it; the artefact is commonly gitignored, so `git add -f` that one file (or un-ignore its path) and commit it alongside the code it measures and real coverage will be read. You can widen what we reach: optional: produce a coverage report in a standard format (`coverage run -m pytest` then `coverage xml`) and commit it — a hosted scan measures a clone of the repository, so a report that exists only in a working tree, a CI runner's or your own, never reaches it; the artefact is commonly gitignored, so `git add -f` that one file (or un-ignore its path) and commit it alongside the code it measures — then both halves are read on the next scan.
  • D10 Test Quality — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. The 220 test(s) behind this row are the ones the JavaScript/TypeScript census could read, and this repository also carries at least 611 test source file(s) (.py) that it cannot: it reads JavaScript/TypeScript test declarations off disk, so a JUnit/pytest-style suite is invisible to it. Skipped tests, zero-assertion tests and the other quality signals on this row are UNMEASURED in that suite — their absence from the counts above is a gap in this analyzer's language coverage, not a finding that those tests are sound.
  • D14 License Compliance — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Not scored — this repository's Python dependency closure is larger than this pass walks (the dependency closure exceeded 500 distributions), so only part of it was read, and a licence verdict over part of a dependency graph is not a licence verdict. Nothing is asserted about this repository's licensing in either direction.
  • D19 Documentation Quality — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. Each ecosystem's manifests (what makes a folder runnable or a published package) need their own proof before D19 judges its units. Until then those folders' READMEs are judged only as documents (boilerplate, structure), never counted as complete.
  • D19 Documentation Quality — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. This kind did not reach the 95 % precision gate in three adjudicated runs (docs/plans/deterministic-engine/adjudication/D19-sample3-v3.md), so by the pre-registered fallback it publishes no row until a re-measurement shows it does. The candidates are counted here, not reported as findings, and the score does not include them.
  • D21 Naming Consistency — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. D21's deterministic naming rules are gated on C# first (docs/plans/deterministic-engine.md, P5): each other language is switched on only after its own concept suite and A/B gate pass. Until then its declarations carry no naming verdict this run — this says nothing about whether its names are consistent.
  • D22 Internal API Consistency — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. D22 identifies the intentionally-exposed surface from `IsPackable` and `.Contracts` project names, MSBuild conventions read off the loaded project set. This target exposed no such projects, so the probe never ran; this says nothing about whether the repository has a public API. This repository commits no C#/VB source at all, so there was never an MSBuild project set to read these conventions off. That is OUR side and it is a COLLECTOR gap, not an environment fault: it declares a published package (REDACTED), but no published-package marker D22 reads admitted any project here, so this ecosystem's public API has no collector, and the remedy is to write one — no change to the scan image can close it.
  • D24 Comment Value — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. Each source language's comment syntax, and the code a comment annotates in it, needs its own proof before D24 judges it. Until then those comments are left unread, not counted as clean.
  • D31 IaC & Container Security — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. Chapter9/self-modifying-agent/Dockerfile.sandbox.dockerignore carries no `FROM` instruction, so it declares no build stage and every REDACTED rule this engine owns — the runtime-hardening, key-material, mutable-clone, no-op-shim, build-context, trust-anchor, install-guard, setuid and world-writable-path rules — is outside its own premise there and returned nothing. That silence is deliberate and correct: with no base image there is no image to reason about. It is reported here because it is NOT the same fact as a clean file, and coverage is stated as 10 of 11 Infrastructure-as-Code manifest(s) fully judged rather than as 100%. The vendor scanners (trivy, checkov) do read these files and their findings above stand; only this engine's own stage-keyed rules are absent. No owner action: a build file with no FROM is a legitimate include fragment.
  • D32 Data Compliance (PII/GDPR) — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. `chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-055102/scripts/corrected-final-attempt-3.py`, `slides/review.mjs`, `web-astro/scripts/check-deployment.mjs`, `web-astro/scripts/prepare-assets.mjs`, `web-astro/src/lib/edition-source.mjs`, … (+1 more) produced a parse error, so every rule in this engine's `gdpr.yml` was absent there. That absence is NOT a clean result: these rules detect personal data crossing a boundary into a log sink, a URL or browser storage, and a file that was never parsed cannot report any of the three. The rest of the tree analysed normally and its rows above stand; only these files are unaccounted for. You can widen what we reach: fix the syntax error (or exclude the file deliberately) and re-scan to cover it.
  • AC3 Page structure — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. 28 further occurrence(s) are not listed individually; the score already reflects all 68.
  • AX1 Captive dependencies — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads Microsoft.Extensions.DependencyInjection registrations in C# and Spring beans in Java/Kotlin only, and this repository defines its own container in chapter5/permission-embedded-data-objects/pedo/core/store.py, whose lifetimes are not modelled yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • AXR1 Runtime accessibility — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Render strategy: boot via DockerCompose (chapter4/docker-compose.yml). compose up failed (exit 17 — an image could not be built) — failed to solve: process "/bin/sh -c apt-get update && apt-get install -y curl wget git build-essential software-properties-common ca-certificates libgl1-mesa-glx libglib2.0-0 poppler-utils tesseract-ocr tesseract-ocr-eng tesseract-ocr-chi-sim && rm -rf /var/lib/apt/lists/*" did not complete successfully: exit code: 100; runtime evidence skipped.
  • C1 Data Protection — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These personal data controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks personal data controls.
  • GD1 Unfinished & placeholder code — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, F#, JavaScript/TypeScript, Dart, Ruby and Scala source only, and this repository's Python, lua is most of its product and is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • IC1 Incompleteness & stubs — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, JavaScript/TypeScript, Java, Dart, Ruby and Scala source only, and this repository's Python, lua is most of its product and is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • M4 Documentation accuracy — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. M4 checks only the claim kinds adjudicated at or above 95 % precision: links and versions (PREREGISTRATION version 9), and artefact counts an order of magnitude off. Paths, command arguments, installs, environment variables, settings, projects, packages, routes, cd targets, infrastructure products and removed modules are read but not checked, and none of them is reported or counted.
  • R10 Code Duplication — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. The filesystem refused the listing or the read of: chapter4/perception-tools/validation/experiment_4_2/real_mcp_20260729T214301Z/fixtures/mutation_workspace/escape-link, chapter4/perception-tools/validation/experiment_4_2/real_mcp_20260729T214721Z/fixtures/mutation_workspace/escape-link, chapter4/perception-tools/validation/experiment_4_2/real_mcp_dashscope_20260730T061500Z/fixtures/mutation_workspace/escape-link, chapter4/perception-tools/validation/experiment_4_2/real_mcp_dashscope_intl_20260730T065000Z/fixtures/mutation_workspace/escape-link, chapter4/perception-tools/validation/experiment_4_2/real_mcp_dashscope_intl_20260730T070000Z/fixtures/mutation_workspace/escape-link. Every other path was read.
  • R10 Code Duplication — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. 33 further occurrence(s) are not listed individually; the score already reflects all 73.
  • R4 Test Coverage — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. 22 further occurrence(s) are not listed individually; the score already reflects all 62.
  • X3 Exception handling — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. 113 further occurrence(s) are not listed individually; the score already reflects all 153.
  • X4 Structured logging — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. 1601 further occurrence(s) are not listed individually; the score already reflects all 1641.

Repo exclusion declarations: 4 pattern(s) declared (.gitattributes linguist-generated/vendored, .editorconfig generated_code) excluded 0 source file(s) from code-quality scoring. Declarations are the repo's own visible statement that a tree is machine-written or vendored — auditable in any diff, honored by GitHub the same way.

Limitations & what we did not check

We assess the repository exactly as committed, and only the repository. By design we do not reach outside the source tree: the live cloud account, the running CI/CD pipeline, the host's branch-protection and approval rules, the production configuration, or a restore actually exercised against a backup are all out of scope. That boundary is a feature, not a gap — a repo-relative, deterministic scan re-runs identically on any commit and every finding opens at a real file and line, where a live audit can neither be reproduced nor traced. The visible consequence is that controls which leave no in-repo evidence are reported as "not evidenced" and excluded from the score rather than awarded a number a static scan cannot justify.

Per-dimension blind spots

For each dimension that was measured, what a static, repo-only scan structurally cannot see — the honest edge of the measurement, not a failure of it.

  • D1 Cyclomatic Complexity: Cyclomatic complexity counts branches statically — it cannot tell an essential decision tree from accidental tangle, nor see complexity that lives in data or configuration (large switch-case token tables, DSL lexers/parsers, data-as-code rule tables) rather than control flow: a tokenizer's many single-character cases read as high complexity though each branch is trivial.
  • D2 Cognitive Complexity: Cognitive-complexity heuristics approximate how hard code is to follow; genuine domain difficulty and well-named intent that eases reading are not captured.
  • D3 God Classes: "God class" is sized by members and responsibilities visible in the type — a deliberately broad facade over a coherent subsystem can read the same as an accidental grab-bag. For front-end JS the file-length check is cohesion-aware (a single-responsibility module — one class/IIFE — earns a 3× threshold), but cohesion is approximated from top-level declarations, not true dependency structure.
  • D4 Code Duplication: Duplication is token-similarity — an in-process token-stream comparison over sliding windows, with type-aware normalization — so it finds copy-paste, not semantic duplication expressed differently. Committed machine-written code (scaffolded migrations, designer/codegen output, protobuf/OpenAPI stubs, model snapshots) is EXCLUDED — its repetition is the tool's, not the team's — so the score reflects hand-written duplication only.
  • D5 Coupling: Coupling is measured between projects/assemblies — runtime coupling through DI, reflection, messaging or shared databases is invisible to a static reference graph.
  • D6 Cohesion (LCOM4): LCOM4 cohesion is syntactic — it infers connectivity from which methods touch which fields/methods by name, not from real runtime behaviour or intent.
  • D9 Test Distribution: The test-pyramid shape is inferred from project/folder naming and references, with a single test host bucketed per-file by its path tier and content signals — a suite that names tiers unconventionally and gives no per-file signal can still be mis-bucketed.
  • D10 Test Quality: Assertion density is structural — it cannot tell a meaningful behavioural assertion from a trivial one, only that an assertion is present.
  • D11 Test Reliability: Flakiness is inferred from history/markers — we run the suite once (for coverage), not the repeated runs under varied conditions that reveal nondeterminism, so a flaky test never recorded as failing is invisible here.
  • D12 Dependency Hygiene: Dependency health reads manifests and lockfiles — a vulnerability in a vendored/copied dependency, or risk from how a dependency is actually used, is outside this view.
  • D13 REDACTED Scanning: REDACTED detection is signature- and entropy-based on the current tree — a secret that does not match a known pattern, or one already rotated, will not be flagged (a clean scan is "nothing matched", not "no secrets exist").
  • D15 Churn × Complexity Hotspots: Churn hotspots come from git history — a freshly imported or squashed repository has no churn signal, and recent rewrites can mask a historically risky file.
  • D16 Bus Factor: Bus-factor is a time-decayed model of commit attribution (who has recently, repeatedly worked a file), not comprehension — pairing, review and reading-without-committing spread knowledge it can't see; bot commits and shared accounts still distort it.
  • D17 Explicit Debt: Acknowledged-debt signals (TODO/FIXME, suppressions, dead code) are textual — undocumented debt that nobody marked, and debt that lives in design rather than annotations, is invisible. Committed machine-written code (scaffolded migrations, designer/codegen output, generated stubs) is excluded — it is never the team's dead code to delete.
  • D19 Documentation Quality: Documentation quality publishes two things only: a runnable or packaged unit with no example, and a multi-project root README that maps none of its parts. It does not judge clarity, and its other checks (overview, licence, boilerplate, structure, empty sections, XML-doc coverage) are withheld after adjudication: their candidates are counted in the card's gaps, not shown as rows. A false statement in a document is M4's; units are .NET projects only.
  • D20 ADR Quality: ADR quality checks the structure of the decision records present: it cannot know about decisions made and never recorded, and it does not judge how well a record argues its case. Records in a language the section lexicon does not cover are not evaluated.
  • D24 Comment Value: Comment value is measured as redundancy only: a comment that repeats its code's words is found, but a paraphrase in other words, a vague comment, or one the code contradicts is not, and whether a comment is valuable is not claimed. Comments in other scripts or languages, and outside C#, are not judged.
  • D26 Project Cohesion: Project focus is sized from members/namespaces per project — a project that is broad by deliberate design reads the same as one that has sprawled.
  • D27 Navigability: Indirection/navigability is structural — it measures hops to follow a call, not whether that indirection buys real flexibility or just ceremony.
  • D28 Secrets (history): Secret-history scanning sweeps the git log for known patterns — a secret that predates the available history, or never matched a signature, is not found (clean means "nothing matched in the history we can see").
  • D29 Static Analysis (SAST): SAST findings are pattern-based (semgrep) — it finds classes of bug it has rules for; logic flaws, auth/authorization gaps and issues needing runtime context are out of reach (and clean means "no rule matched").
  • D30 Dependency Vulnerabilities: CVE matching depends on accurate package/version metadata and on the advisory databases — a vulnerability with no published advisory, or in code not declared as a dependency, is not seen. Coverage needs a RESOLVED graph: an unpinned REDACTED, or a pom without a resolved build, yields partial coverage rather than a clean verdict. An ecosystem the analyzer cannot scan is reported as unmeasured, never as clean.
  • D31 IaC & Container Security: IaC scanning checks Dockerfiles/Terraform/Kubernetes against best-practice rules — it cannot see the live cloud account, runtime configuration, or drift between the committed config and what is actually deployed.
  • D34 Knowledge Freshness: Freshness is decayed commit RECENCY, not comprehension — code read often but rarely committed reads as orphaned, and stable code that genuinely needs no changes is penalised the same as forgotten code; bot/squash commits distort it like the bus factor.
  • D35 Change Coupling: Change coupling is co-change in COMMITS — files split across separate commits, or coupled only through a shared config/build step, read as uncoupled, and a sweeping commit (rename/format) is excluded so it doesn't couple everything. It shows that files change together, not WHY: a high coupling can be a healthy cohesive pair as readily as a hidden leak.
  • D43 Malicious Dependencies: Only packages some vulnerability database has already NAMED as malicious are seen — a compromise published in the last hours, or never reported at all, is invisible here, and this dimension reading 10 is not evidence that a dependency is trustworthy. There is no typosquat or dependency-confusion analysis: a package nobody has reported is simply absent from the feeds. Coverage is the dependency scan's: an ecosystem that could not be scanned is disclosed as unmeasured, never as clean.
  • D44 Platform End-of-Life: The support table is FROZEN, so it goes out of date by losing RECALL: a release that ended support after the table was written is missed until the table is refreshed, and this dimension reading 10 is not evidence that a platform is current. Only platforms the repository DECLARES in a place this pass reads are seen — a runtime named only in a REDACTED (D31's subject), in a CI workflow (D29's), or in a file this pass does not parse (go.mod, a Gemfile ruby directive) is invisible here, which is why a repository declaring none of them abstains rather than scoring. Only frameworks with a PUBLISHED support policy are tracked: React, Flask and Express publish none, so their age cannot be judged and their absence from a report is not a statement that they are supported.
  • AC1 Text alternatives: Alt-text is detected structurally — the scan sees that an alternative EXISTS, not whether it meaningfully describes the image, and decorative-vs-missing is judged by attribute shape; runtime-injected images and a non-role=img decorative svg are out of scope. This is accessibility readiness, never a WCAG conformance claim.
  • AC2 Forms & labels: Label association is read from static markup — a label wired up at runtime (JS-set aria-labelledby, framework-injected ids) reads as missing, a present label says nothing about whether its text is correct. A known UI-library field component (e.g. a JSX <TextField>) is now checked conservatively — flagged only when it carries NO label/aria-label/aria-labelledby/id/name — but wrapper/context-labelled libraries (Chakra/Radix FormControl+FormLabel) aren't statically visible (possible false positive) and non-JSX lowercased components are still skipped. A click handler on a plain element is now asked for a name too (it is a control the author declared), but the subtree test that answers it is deliberately generous: any DYNAMIC text expression in the subtree counts as a name, so an icon chosen by a ternary ({cond ? <IconA/> : <IconB/>}) reads as named, and a glyph component from a library the icon-import list does not know still names its parent. A clean result is "no unlabelled control found", not a labelling proof.
  • AC3 Page structure: Page structure is read from the static markup tree — landmarks, headings and lang injected at runtime aren't seen, heading ORDER is checked structurally (not against the rendered visual hierarchy), and lang/title/main fire only on full documents, never partials, and the data-table check sees header-cell presence (a <th> exists), not whether each header correctly associates with its cells. Static readiness, not conformance.
  • AC4 Keyboard semantics: Keyboard semantics are inferred from markup attributes — interactivity wired purely in script, focus managed at runtime, and component-level handlers are invisible. A clean result means "no static keyboard-trap shape", not a keyboard-operability proof.
  • AC5 ARIA correctness: ARIA correctness is checked against the static role/attribute shape — roles/attributes set dynamically aren't seen, a valid role says nothing about whether it matches the element's real behaviour, and required-state checks are suppressed when a JSX spread could supply them. The two-branch toggle check (a control whose state is conveyed only by which of two mutually exclusive branches renders) reads CONDITIONALS THAT ARE ATTRIBUTES — Vue v-if/v-else/v-show and Alpine x-if/x-show — so the same toggle written as a Svelte {#if} block or a JSX ternary is control flow the markup model never projects as a branch and is not seen at all.
  • AC6 Visual & motion safety: Contrast and motion safety are PARTIAL by construction — literal colours (hex/rgb/hsl/named) in inline styles, in-repo <style> blocks, in-repo .css files, var() tokens, Tailwind neutral utilities and CSS-in-JS top-level declarations are read (same-rule/same-element colour+background pairs only); computed/runtime/theme colour, external-CDN stylesheets, CSS-in-JS dynamic (${…}) and nested-selector colours, cross-element pairs and image contrast stay out of reach, so a clean result is bounded by what the static CSS itself shows.
  • AC7 A11y enforcement: Enforcement is scored from in-repo config/CI evidence only — an a11y gate enforced in external tooling with no in-repo trace can't be credited, and a configured linter is presence, not proof the rules actually run or block a merge.
  • AX10 Code composition: Role is inferred from namespace/folder convention, not semantics — a domain concept living in a folder named "Services" reads as application, and the split is lines-of-code, not business value. The business-logic-share score is a SOFT, FLOORED signal: it contributes to the Architecture lens but is floored at the Critical gate, so an infrastructure-heavy design (a gateway, an ETL, a driver) is legitimately low without being nuked to zero.
  • DM6 Domain ↔ infrastructure boundary: Infrastructure reached through a hand-rolled wrapper, a domain-named facade, reflection, or a string-keyed service locator resolves to a non-infra type and isn't seen; the body scan is symbol resolution over syntax, not full dataflow. A clean result means "no resolved infra reference in a domain body", not a proof of purity.
  • M4 Documentation accuracy: Documentation accuracy checks links, versions and artefact counts against the tree: other claims (paths, commands, settings, routes) are read but not checked, and it cannot run the onboarding or measure how long a real new joiner takes.
  • P4 Deployment & Rollback: Approval/branch-protection rules live in repository settings the scan cannot see — only their in-repo evidence (config files, workflows) is checked, so a control enforced purely in the host's settings reads as "not evidenced".
  • P5 DR & Backup: Backup/restore and disaster-recovery readiness is judged from in-repo evidence — a config that exists is not a tested restore, so the absence of positive evidence is reported as "not evidenced", never scored as present.
  • P6 Release Hygiene: Rollback/observability controls are inferred from repo artefacts (pipelines, dashboards-as-code) — controls configured in external tooling, with no in-repo trace, cannot be credited.

Dimensions

D1 · Cyclomatic Complexity4.0 / 10Weak✓ Tool-verified

What it measures: How tangled the control flow is — methods with many branches are hard to test and change.

Method: Cyclomatic complexity per method (1 + decision points), computed exhaustively across production source; test projects separated by convention. Deterministic.

Maturity: Documented → Verified → Prevented · effective 4.0 / 10 · rule-coverage 100% · ceiling Prevented

348 method(s) exceeded the cyclomatic complexity threshold of 15; the worst was index.Home at 97. A further 2 method(s) were over the threshold but excluded as flat dispatchers (a long switch/match over independent cases: many branches, almost no nesting), the largest being reading-position.parsePosition at 18 — they are counted neither in the figure above nor in this dimension's score. 2 files carry no cyclomatic complexity row at all for this reason — every one of their over-threshold methods was excluded, so the exclusion is disclosed nowhere in the file itself: web-astro/src/lib/reading-position.ts (reading-position.parsePosition at 18), chapter4/execution-tools/server.py (server.handle_call_tool at 16). They are named here because the per-file figures other dimensions report are taken BEFORE this exclusion, so such a file can show a high maximum complexity elsewhere in this report and nothing here, with nothing to reconcile the two.

experiment.run_case (cyclomatic 47) · ×4chapter6/astra-async-steering/experiment.py:217
lang-switcher.init::translatePath (cyclomatic 28) · ×4REDACTED:94
experiment.judge (cyclomatic 56) · ×2chapter6/astra-async-steering/experiment.py:97
experiment.judge (cyclomatic 49) · ×2chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:97
main.interactive_mode (cyclomatic 34) · ×2REDACTED:340

+ 311 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Bring the 9 bodies over 60 down to 60 or less in Cyclomatic Complexity — start with index.Home (cyclomatic 97), creator.run_experiment (cyclomatic 91), validate_evidence.validate (cyclomatic 85). — This score is capped by its worst body, so a finding fixed alone moves it by almost nothing — the next one down takes its place. Refactoring these 9 together lifts Cyclomatic Complexity from 4.0 to about 5.1/10, projected with the scoring formula itself and assuming each lands exactly at 60; a cleaner split scores higher.
  2. Enforce Cyclomatic Complexity in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.

Detailed fixes: d1_recommendation.md · top locations in Appendix A, every location in findings.md.

D2 · Cognitive Complexity2.0 / 10Critical✓ Tool-verified

What it measures: How hard the code is for a person to follow, beyond raw branching.

Method: Cognitive complexity per method (Sonar-style nesting-penalized score), computed exhaustively over production code, excluding test projects. Deterministic.

Maturity: Documented → Verified → Prevented · effective 2.0 / 10 · rule-coverage 100% · ceiling Prevented

610 method(s) exceeded the cognitive complexity threshold of 15; the worst was UserMemoryAgent.execute_task at 191.

svg_lib._wrap_line (cognitive 18) · ×6book-ar/svg_lib.py:162
experiment.run_case (cognitive 79) · ×4chapter6/astra-async-steering/experiment.py:217
lang-switcher.init::rewriteSidebar (cognitive 58) · ×4REDACTED:354
demo.main (cognitive 23) · ×3chapter10/voice-werewolf/demo.py:440
main._llm_reply (cognitive 17) · ×3REDACTED:56

+ 563 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Bring the 48 bodies over 60 down to 60 or less in Cognitive Complexity — start with UserMemoryAgent.execute_task (cognitive 191), creator.run_experiment (cognitive 158), main.run_evaluation_mode (cognitive 142). — This score is capped by its worst body, so a finding fixed alone moves it by almost nothing — the next one down takes its place. Refactoring these 48 together lifts Cognitive Complexity from 2.0 to about 3.2/10, projected with the scoring formula itself and assuming each lands exactly at 60; a cleaner split scores higher.
  2. Enforce Cognitive Complexity in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.

Detailed fixes: d2_recommendation.md · top locations in Appendix A, every location in findings.md.

D3 · God Classes8.5 / 10Strong✓ Tool-verified

What it measures: Over-large classes that try to do too much ("god classes").

Method: God-class detection by line and method-count thresholds per logical type (partial classes unified), filtered for generated code and registration/contract false positives. Deterministic.

Maturity: Documented → Verified → Prevented · effective 8.5 / 10 · rule-coverage 100% · ceiling Prevented

104 god class(es) detected.

FileTooLong: user-memory-system-evaluation/experiment.py · ×62chapter7/user-memory-system-evaluation/experiment.py
FunctionTooLong: index.Home · ×41chapter6/live-audio/frontend/pages/index.tsx:65
TooManyMethods: ObjectStorechapter5/permission-embedded-data-objects/pedo/core/store.py:45

What to do

  1. Resolve the 62 FileTooLong finding(s) in God Classes — start with REDACTED (6), svg_lib.py (6), REDACTED (4). — One of this dimension's main actionable groups (62 warning-level).
  2. Resolve the 41 FunctionTooLong finding(s) in God Classes — start with REDACTED (4), REDACTED (4), REDACTED (3). — One of this dimension's main actionable groups (41 warning-level).
  3. Resolve the 1 TooManyMethods finding(s) in God Classes — start with store.py. — One of this dimension's main actionable groups (1 warning-level).
  4. Enforce God Classes in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.

Detailed fixes: d3_recommendation.md · top locations in Appendix A, every location in findings.md.

D4 · Code Duplication8.9 / 10Strong✓ Tool-verified

What it measures: Copy-pasted code that should be shared instead.

Method: Code duplication via token-stream sliding windows with type-aware normalization (locals masked, type names preserved), density-scored per KLoC of production code. Deterministic.

Maturity: Documented → Verified → Prevented · effective 8.9 / 10 · rule-coverage 100% · ceiling Verified

602 duplicated block group(s) detected. A further 63 rows report members as variants of one another; they aggregate block groups already counted above and are not themselves counted. 4 of the 665 are in trees this repository does not ship — vendored, example/demo, project-template, fixture and benchmark code — and are ranked below the shipped groups rather than excluded from them: the duplication there is real and is still counted in this dimension's score. The dimensions that publish a production-file census leave those trees out of theirs, so this count is deliberately drawn over the wider population.

Duplicated block (5 lines × 2) · ×35chapter10/book-translation/agents.py:563
Duplicated block (7 lines × 2) · ×24chapter10/book-translation/run_official_experiment.py:422
Duplicated block (6 lines × 2) · ×22chapter10/autonomous-phone-registration/voice.py:121
Members sharing a duplicated core (6 members, 50+ identical tokens) · ×20book-ar/fit_svg_text.py:34
Duplicated block (10 lines × 2) · ×18chapter1/context/main.py:1004

+ 262 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Resolve the 35 Duplicated block (5 lines × 2) finding(s) in Code Duplication — start with REDACTED (4), demo.py (3), run_campaign.py (2). — One of this dimension's main actionable groups (35 warning-level).
  2. Resolve the 24 Duplicated block (7 lines × 2) finding(s) in Code Duplication — start with REDACTED (4), demo.py (3), REDACTED (2). — One of this dimension's main actionable groups (24 warning-level).
  3. Resolve the 22 Duplicated block (6 lines × 2) finding(s) in Code Duplication — start with REDACTED (3), REDACTED (2), probe_candidates.py (2). — One of this dimension's main actionable groups (22 warning-level).
  4. Enforce Code Duplication in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.

Detailed fixes: d4_recommendation.md · top locations in Appendix A, every location in findings.md.

D5 · Coupling10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether volatile projects sit underneath others that depend on them (so their churn ripples upward), and whether project dependencies form cycles. A widely-depended-on but stable shared/kernel project is healthy, not penalised.

Method: Dependency cycles via elementary-DFS over real .csproj references, plus Martin instability (afferent/efferent) per project. Exhaustive over the reference graph, deterministic.

Coverage: Exhaustive · type-level: afferent/efferent coupling + cycles computed over every production type — the population is all types, not a name convention.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Prevented

13 production modules (npm+Python), 0 dependency cycle(s), 0 unstable depended-on module(s). Read from the build's own module declarations; 0 module(s) off the main sequence, with abstractness counted on 5 of the 13 (the rest declare no modelled class or interface, export only macros, declare types in source no model reads, or have no source directory of their own).

✓ On the Gold path — maintain.

Detailed fixes: d5_recommendation.md.

D6 · Cohesion (LCOM4)10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether a class's methods are focused on a single responsibility.

Method: LCOM4 cohesion per production class with at least two methods: connected components of methods sharing state or calls, computed syntactically. Deterministic, not a proxy.

Coverage: Exhaustive · type-level: LCOM4 cohesion computed over every production class — the population is all types, not a name convention.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Verified

0 of 269 classes have LCOM4 above 3.

✓ On the Gold path — maintain.

Detailed fixes: d6_recommendation.md.

D9 · Test Distribution10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether the test suite has a healthy mix of unit / integration / end-to-end tests.

Method: Test projects classified (Unit/Integration/BDD/E2E) from compiled metadata; test methods counted exhaustively across projects with placement-agnostic disk fallback. Deterministic.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

2956 test methods: 2942 unit, 7 integration, 7 BDD, 0 e2e. The JavaScript/TypeScript suite contributes 220 `it`/`test` case(s) across 40 test file(s) declaring at least one; its tier split is read from package names and paths only. The Python suite contributes 2736 test function(s) across 517 file(s) declaring at least one — every `def test…` in a file pytest or unittest would collect, which is those frameworks' own definition of a case; a parametrize table counts once, so this is a floor. Its tier split is read from file names and paths only.

✓ On the Gold path — maintain.

Detailed fixes: d9_recommendation.md.

D10 · Test Quality9.8 / 10Stronggated by 3 serious findings✓ Tool-verified

What it measures: Whether the tests truly assert behaviour rather than just running the code.

Method: Per-test assertions, skips, and mock references analyzed via Roslyn; structured skip-reason tags (BUG:/ENV:) separate documented deferrals from debt. Deterministic.

Maturity: Documented → Verified → Prevented · effective 9.8 / 10 · rule-coverage 100% · ceiling Prevented

5 skipped (5 with a documented reason), 3 zero-assertion, no mocking-framework packages referenced (hand-written doubles or no mocking) across 220 tests. Measured on the JavaScript/TypeScript suite only — at least 611 test source file(s) (.py) went unread, so its test quality is unmeasured and is not in these counts.

No assertions: should handle streaming via OpenRouter · ×3chapter6/live-audio/backend/tests/test-llm-providers.js:304
Skipped (documented): should work with ${providerName} provider · ×5chapter6/live-audio/backend/tests/provider-tests.js:143

What to do

  1. Resolve the 3 No assertions finding(s) in Test Quality — start with test-llm-providers.js (3). — One of this dimension's main actionable groups (3 warning-level).
  2. Enforce Test Quality in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.

Detailed fixes: d10_recommendation.md · top locations in Appendix A, every location in findings.md.

D11 · Test Reliability10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether the tests pass reliably, with no flakiness.

Method: Suite re-run N times within tiered wall-clock budgets (unit to e2e); tests failing non-deterministically across runs flagged; guarded tests retried when #if guards detected.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Verified

0 flaky across 2 measured tier(s). JavaScript/TypeScript (mocha via `npm ci --ignore-scripts` in chapter6/live-audio/backend/ (8 tests); node:test via `npm ci --ignore-scripts` in web-astro/ (141 tests)): measured (0 flaky); Python (3 distributions): measured (0 flaky).

✓ On the Gold path — maintain.

Detailed fixes: d11_recommendation.md.

D12 · Dependency Hygiene9.4 0.9 / 10Critical✓ Tool-verified

What it measures: Whether dependencies are current, secure, and not bloated.

Method: Manifest scan via dotnet list package across all projects; worst-signal-per-package deduction (saturating for vulnerabilities, capped-linear for deprecation/outdated) per KLoC. Exhaustive, deterministic.

Maturity: Documented → Verified → Prevented · effective 0.9 / 10 · rule-coverage 9% · ceiling Verified

12 outdated, 0 yanked pinned Python distributions. 16 of 169 shipped distributions were graded against pypi.org (1 not published there, 152 declared without an exact pin, which installs the newest release the declaration admits and so cannot be behind one). Only EXACT pins are graded for currency: a floor or a range already installs the newest release it admits, so reporting one would report this repository for being current. Whether a deliberate upper cap has itself gone stale is a different and weaker question, and is not asked. Whether any distribution is UNMAINTAINED is not graded — PyPI publishes no maintenance status, and release age does not stand in for one. Lockfiles are not read (poetry.lock, REDACTED, Pipfile.lock, pdm.lock), so a lock-resolved install is outside this verdict. Known CVEs in this dependency graph are D30's question.

Outdated: colorlog · ×12

What to do

  1. Enforce Dependency Hygiene in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.

Detailed fixes: d12_recommendation.md · top locations in Appendix A, every location in findings.md.

D13 · REDACTED Scanning0.0 / 10Critical✓ Tool-verified

What it measures: Whether any secrets (keys, tokens, passwords) have leaked into the code.

Method: In-process native secret scanner (entropy plus signature patterns) across all tracked files; no external tool. A clean result is a measured 10, not no-data zero. Deterministic.

Maturity: Documented → Verified → Prevented · effective 0.0 / 10 · rule-coverage 100% · ceiling Prevented

6 secret(s) detected.

REDACTED

What to do

  1. Resolve the 9 Leaked secret finding(s) in REDACTED Scanning — start with REDACTED (3), REDACTED (2), REDACTED. — One of this dimension's main actionable groups (9 issue-level).
  2. Enforce REDACTED Scanning in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.

Detailed fixes: d13_recommendation.md · top locations in Appendix A, every location in findings.md.

D15 · Churn × Complexity Hotspots9.9 / 10Stronggated by 110 serious findings✓ Tool-verified

What it measures: Files that change often and are also complex — the riskiest hotspots.

Method: Per production file churn times cyclomatic complexity over a rolling window, computed from git and Roslyn/JS/Razor analysis. Exhaustive, deterministic per commit date.

Maturity: Documented → Verified → Prevented · effective 9.9 / 10 · rule-coverage 100% · ceiling Documented

Top hotspots: REDACTED (27×190=5130); chapter10/voice-werewolf/demo.py (11×84=924); chapter1/context/main.py (18×43=774) Repeated repair below the complexity floor: chapter5/video-edit/video_editor.py (7 of 9 changes were fixes); chapter5/conversational-ui/agent.py (5 of 9 changes were fixes); chapter4/collaboration-tools/src/timer_tools.py (5 of 5 changes were fixes)

Hotspot: REDACTED · ×92REDACTED:27
Repeated repair: chapter5/video-edit/video_editor.py · ×18chapter5/video-edit/video_editor.py:71

What to do

  1. Resolve the 92 Hotspot finding(s) in Churn × Complexity Hotspots — start with demo.py (16), REDACTED (13), REDACTED (7). — One of this dimension's main actionable groups (92 warning-level).
  2. Resolve the 18 Repeated repair finding(s) in Churn × Complexity Hotspots — start with REDACTED (2), video_editor.py, timer_tools.py. — One of this dimension's main actionable groups (18 warning-level).

Detailed fixes: d15_recommendation.md · top locations in Appendix A, every location in findings.md.

D16 · Bus Factor8.0 / 10Strong✓ Tool-verified

What it measures: Whether knowledge is concentrated in too few people (the "bus factor").

Method: Living knowledge per author via time-decayed commit attribution (6-month half-life, focus weighting) across largest source files. Deterministic, avoids blame's mechanical-refactor false positives.

Maturity: Documented → Verified → Prevented · effective 8.0 / 10 · rule-coverage 100% · ceiling Documented

166 source file(s) have their living knowledge concentrated in one author (≥90% of recent, decayed contribution). The largest is chapter7/android-world/run_controlled_experiment.py. Counted over 834 of the 1026 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.

Off-boarding risk: anonymized user #1 · ×3
Further sole-owners (lower concentration)

What to do

  1. Resolve the 3 Off-boarding risk finding(s) in Bus Factor. — One of this dimension's main actionable groups (3 recommendation-level).
  2. Resolve the 1 Further sole-owners (lower concentration) finding(s) in Bus Factor. — One of this dimension's main actionable groups (1 recommendation-level).

Detailed fixes: d16_recommendation.md · top locations in Appendix A, every location in findings.md.

D17 · Explicit Debt10.0 / 10Stronggated by 16 serious findings✓ Tool-verified

What it measures: Acknowledged debt left in the code — TODOs, dead code, suppressed warnings.

Method: Roslyn syntactic debt markers (suppressions/TODO/FIXME/HACK/empty-catch/commented-code/Obsolete) plus SymbolFinder dead-code analysis; weighted-debt-per-KLoC density deducted 2.0x per unit. Deterministic, exhaustive.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Prevented

16 deducted task-comment markers across 267236 LoC (0.0/KLoC) → score 10.0. Task comments only: this repository's language is read without a compiler, so D17's suppression, dead-code and commented-out-code arms did not run and this score counts fewer marker kinds than a .NET repository's would.

TodoComment · ×16REDACTED:394

What to do

  1. Resolve the 16 TodoComment finding(s) in Explicit Debt — start with REDACTED (6), quickstart.py (2), test_basic.py (2). — One of this dimension's main actionable groups (16 warning-level).
  2. Enforce Explicit Debt in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.

Detailed fixes: d17_recommendation.md · top locations in Appendix A, every location in findings.md.

D19 · Documentation Quality10.0 / 10Exemplary○ Nothing flagged

What it measures: Whether the project's documentation is clear, complete, and useful.

Method: Every README, docs/ document and root guide parsed by its markup and measured in Unicode letters. Published: a runnable or packaged .NET project whose README (or a document it links, or a root guide) shows no example, and a root README naming none of three or more projects. Overview, licence, boilerplate, wall-of-text, empty-section and XML-doc rows are measured and withheld (counted in gaps) after adjudication. Deterministic, exhaustive, advisory.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

2 of 2 documentation facets pass in full. 350 document(s) read across 11 unit(s).

✓ On the Gold path — maintain.

Detailed fixes: d19_recommendation.md.

D20 · ADR Quality0.0 / 10Critical✓ Tool-verified

What it measures: Whether architecture decisions are recorded well (context, decision, consequences).

Method: Every ADR read by its section structure: nine located rules (a missing Decision, Context or Consequences section, a stale status, two records deciding the same question, a dangling supersede link, a number-only title, a single option, no named cost, no status where the log uses one, no enforcement field where the log adopted one), each a fixed deduction from 10; the score is the mean over evaluated records. Deterministic, no model. Advisory.

Maturity: Documented → Verified → Prevented · effective 0.0 / 10 · rule-coverage 100% · ceiling Documented

No architecture decision records were found.

No ADRs found

What to do

  1. Resolve the 1 No ADRs found finding(s) in ADR Quality. — One of this dimension's main actionable groups (1 recommendation-level).

Detailed fixes: d20_recommendation.md · top locations in Appendix A, every location in findings.md.

D24 · Comment Value6.2 6.0 / 10Adequate✓ Tool-verified

What it measures: Whether comments are worth it — explaining WHY (valuable) rather than WHAT (redundant).

Method: Every inline C# comment compared word by word with the identifiers, literals and constructs of the code it annotates (taken from the syntax); a comment whose words that code already contains is redundant, as are closing-brace labels and generator template text. Comments giving a reason or a reference are kept; other scripts and languages are not judged. Deterministic, exhaustive, advisory.

Maturity: Documented → Verified → Prevented · effective 6.0 / 10 · rule-coverage 95% · ceiling Documented

20 of 534 judged comments only repeat the code they sit on (3.7 %). 34 comment(s) in another language or script were not judged.

redundant comment · ×10chapter6/live-audio/backend/server.js:65
doc comments repeat the nameschapter6/live-audio/backend/utils/providers/asrProviders.js:7

What to do

  1. Resolve the 10 redundant comment finding(s) in Comment Value — start with textProcessor.js (3), vad.js (2), index.tsx (2). — One of this dimension's main actionable groups (10 recommendation-level).

Detailed fixes: d24_recommendation.md · top locations in Appendix A, every location in findings.md.

D26 · Project Cohesion9.8 / 10Exemplary✓ Tool-verified

What it measures: Whether each project is a focused, coherent unit rather than an oversized grab-bag.

Method: Project size overshoot penalties (LoC / public-type count / namespace count, 2-of-3 flag) weighted by log magnitude. Exhaustive across projects, deterministic.

Maturity: Documented → Verified → Prevented · effective 9.8 / 10 · rule-coverage 100% · ceiling Documented

1 of 103 build units (Python, npm) flagged as possibly oversized/incoherent.

Projects may be oversized for their cohesion

✓ On the Gold path — maintain.

Detailed fixes: d26_recommendation.md · top locations in Appendix A, every location in findings.md.

D27 · Navigability10.0 / 10Exemplary✓ Tool-verified

What it measures: How far you must trace to follow a call — low indirection and co-located slices read easier.

Method: Call indirection (interface hops, cross-namespace calls, slice-locality scaled) over a sampled set of method invocations, size-aware baseline. Sampled; confidence discounted by symbol-resolution gaps. C# also names each pass-through layer (a class whose every public method only forwards its own parameters to one collaborator) as a located finding; the score is not affected.

Coverage: Slice locality from the first namespace segments, SAMPLED (≤400 methods) — not exhaustive.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

87 % of calls cross a namespace and 0 % go through an interface, but 100 % of collaborators are co-located — so a call's collaborators sit together and tracing stays easy. Baseline: small — navigation cost is tolerated.

✓ On the Gold path — maintain.

Detailed fixes: d27_recommendation.md.

D28 · Secrets (history)0.0 / 10Critical✓ Tool-verified

What it measures: Whether any secrets were ever committed — scanned across the full git history, not just now.

Method: REDACTED scan via TWO gitleaks detect passes in an isolated checkout — the full git history, then a second --no-git pass over the working tree as it stands — merged and de-duplicated by (rule, file, line); each match flagged High. Both invocations are recorded in the audit trail. Exhaustive; when the tool is absent, or when its output cannot be parsed into the expected shape, the dimension is WITHHELD as an explicit measurement gap on our side — unscored and excluded from the lens, never a hedged middling score.

Maturity: Documented → Verified → Prevented · effective 0.0 / 10 · rule-coverage 100% · ceiling Documented

60 finding(s): 0 critical, 60 high, 0 medium, 0 low. Remediation for historically-committed secrets is credential rotation — they remain in history regardless of later deletion.

REDACTED
REDACTED
REDACTED

What to do

  1. Resolve the 43 REDACTED finding(s) in Secrets (history) — start with REDACTED (12), REDACTED (8), REDACTED (8). — One of this dimension's main actionable groups (43 issue-level).
  2. Resolve the 17 High secret finding(s) in Secrets (history) — start with REDACTED (8), REDACTED (8), REDACTED. — One of this dimension's main actionable groups (17 issue-level).
  3. Resolve the 1 Rotate the exposed credentials finding(s) in Secrets (history). — One of this dimension's main actionable groups (1 recommendation-level).

Detailed fixes: d28_recommendation.md · top locations in Appendix A, every location in findings.md.

D29 · Static Analysis (SAST)0.0 / 10Critical✓ Tool-verified

What it measures: Real static-analysis (SAST) findings — likely security bugs in the code, any language.

Method: Polyglot static analysis via semgrep across the repo using the pinned, image-baked p/security-audit + p/owasp-top-ten rulesets (no scan-time registry fetch); severity rules (ERROR/WARNING/INFO) map to a full-band severity-weighted score. Exhaustive, deterministic; degrades on parse failure.

Coverage: semgrep pattern rules over all files — exhaustive for the rule set, blind to classes of bug without a rule (clean = no rule matched).

Maturity: Documented → Verified → Prevented · effective 0.0 / 10 · rule-coverage 100% · ceiling Documented

172 finding(s): 0 critical, 59 high, 75 medium, 38 low. 21 unpinned-GitHub-Actions row(s) are reported here but scored by D36 (supply-chain provenance), which measures that posture as `pinned_actions` — one pinning decision is charged once, not once per lens. semgrep hit a parse error in 46 file(s) — `chapter10/book-translation/validation/real_20260730T050000Z_v2/orchestration_checkpoint.json`, `chapter10/book-translation/validation/real_20260730T053000Z_v3/orchestration_checkpoint.json`, `chapter10/book-translation/validation/real_20260730T061500Z_v4/orchestration_checkpoint.json`, `chapter10/multi-role-transfer/validation/runs/exp10-1-kimi-k2.5-tavily-receipts-20260730-v3/moonshot_receipts.json`, `chapter2/prompt-engineering/tau_bench/envs/retail/tasks_train.py`, … (+41 more) — so no absence of findings in the named regions is evidence of anything; rows reported elsewhere in those files are real. Fix the syntax error (or exclude the file deliberately) and re-scan to cover them. Separately, one or more rules could not re-parse an embedded snippet in 2 file(s) (e.g. a workflow `run:` block read as shell). Those files WERE scanned and their other rows are unaffected; only those rules' view of those snippets is missing.

REDACTED
REDACTED
REDACTED
REDACTED
REDACTED

+ 15 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Resolve the 30 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (3), REDACTED (3), REDACTED (3). — One of this dimension's main actionable groups (30 issue-level).
  2. Resolve the 4 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED, REDACTED, REDACTED. — One of this dimension's main actionable groups (4 issue-level).
  3. No action in Static Analysis (SAST) — all 21 REDACTED finding(s) are reported here at file:line but scored by D36 (supply-chain provenance), so none is charged to this dimension. — One of this dimension's main actionable groups (21 issue-level, 0 of them charged here).

Detailed fixes: d29_recommendation.md · top locations in Appendix A, every location in findings.md.

D30 · Dependency Vulnerabilities0.0 / 10Critical✓ Tool-verified

What it measures: Whether any dependency has a known published vulnerability (CVE), direct or transitive, in ANY ecosystem the repository declares — Dart pub, Elixir and Erlang via Hex, Go modules, Java and Kotlin via Maven/Gradle, JavaScript/npm, .NET/NuGet, PHP/Composer, Python/PyPI, RubyGems, Rust/Cargo and Swift.

Method: Dependency-CVE scan across every ecosystem the repository declares, scored ONCE. Three sources are unioned and deduplicated by advisory identity (rule id + alias closure, CVE<->GHSA) scoped to package+version, keeping the worst severity: `osv-scanner --recursive` over osv.dev for Dart pub, Elixir/Hex (and Erlang, whose `rebar.lock` syft first converts to a CycloneDX SBOM the scanner reads, with rows attributed back to the lock), Go, Java and Kotlin via Maven/Gradle (and Scala, whose sbt build's pinned direct declarations are written into a CycloneDX SBOM the scanner reads, with rows attributed back to the build file), npm, PHP/Composer, Python/PyPI, RubyGems, Rust/Cargo and Swift; `trivy fs --scanners vuln` for npm lockfiles; and `dotnet list package --vulnerable --include-transitive` for NuGet (with per-advisory collapse of the project x target-framework fan-out), plus a DECLARED-dependency arm that resolves a published gem's gemspec against rubygems.org where no Gemfile.lock is committed. `SeverityScore(c,h,m,l, normalizer 8.0)`. NotApplicable only when NO ecosystem is readable; if any applicable ecosystem could not be scanned the findings are REPORTED and the score is withheld. Supersedes the npm and OSV arms, retired 2026-09-05.

Maturity: Documented → Verified → Prevented · effective 0.0 / 10 · rule-coverage 100% · ceiling Documented

210 finding(s): 17 critical, 110 high, 76 medium, 7 low.

REDACTED
REDACTED
REDACTED
REDACTED
REDACTED

+ 3 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Resolve the 105 High CVE finding(s) in Dependency Vulnerabilities — start with REDACTED (82), REDACTED (13), REDACTED (10). — One of this dimension's main actionable groups (105 issue-level).
  2. Resolve the 14 Critical CVE finding(s) in Dependency Vulnerabilities — start with REDACTED (5), REDACTED (5), REDACTED (4). — One of this dimension's main actionable groups (14 issue-level).
  3. Resolve the 5 High vulnerability finding(s) in Dependency Vulnerabilities — start with REDACTED (3), REDACTED, REDACTED. — One of this dimension's main actionable groups (5 issue-level).

Detailed fixes: d30_recommendation.md · top locations in Appendix A, every location in findings.md.

D31 · IaC & Container Security2.2 2.0 / 10Critical✓ Tool-verified

What it measures: Whether Dockerfiles / Terraform / Kubernetes config follow security best practices.

Method: IaC/container misconfiguration scan via trivy config (REDACTED/Terraform/K8s/Helm/CloudFormation); severity rules to 0-10 moderate normalizer. NotApplicable without manifests. Exhaustive, deterministic.

Maturity: Documented → Verified → Prevented · effective 2.0 / 10 · rule-coverage 91% · ceiling Documented

42 finding(s): 1 critical, 14 high, 24 medium, 3 low.

REDACTED
REDACTED
REDACTED
REDACTED

What to do

  1. Resolve the 24 Medium IaC finding(s) in IaC & Container Security — start with REDACTED (22), REDACTED (2). — One of this dimension's main actionable groups (24 warning-level).
  2. Resolve the 14 High IaC finding(s) in IaC & Container Security — start with REDACTED (14). — One of this dimension's main actionable groups (14 issue-level).
  3. Resolve the 1 Critical IaC finding(s) in IaC & Container Security — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).

Detailed fixes: d31_recommendation.md · top locations in Appendix A, every location in findings.md.

D34 · Knowledge Freshness10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether anyone still has living knowledge of each file, or it has been orphaned — last understood long ago by someone now gone quiet. The sibling of the bus factor: D16 asks who owns it, D34 asks whether anyone still knows it.

Method: File orphaning as total living-knowledge decay below one focused-commit's worth within a year, computed per-file from the D16 decay model. Exhaustive, deterministic over fixed history.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

Every significant source file has living knowledge — recently and meaningfully worked. Counted over 834 of the 1026 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.

✓ On the Gold path — maintain.

Detailed fixes: d34_recommendation.md.

D35 · Change Coupling10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether files that change together actually belong together — pairs that repeatedly co-change in git history despite having no explicit code dependency, surfacing the hidden/logical coupling (and boundaries in the wrong place) a static scan can't see.

Method: Pairwise co-occurrence over the per-commit file sets in git history (production source only — tests and generated dropped): Degree-of-Coupling = shared ÷ min individual revisions, reported above noise floors (each file ≥10 revisions, ≥5 shared commits, ≥50% strength); sweeping commits excluded. Deterministic over fixed history.

Coverage: Population: PRODUCTION source files only — test and generated files are dropped before pairing, so a class co-changing with its own test (trivially ~100%) can't drown the real production↔production coupling. Pairs ranked by Degree-of-Coupling. A non-source file is never a coupling PARTICIPANT either: documentation, schemas, config and data files are dropped with the rest, so a code↔docs pair — a command and the reference page that restates it — is not reported however strongly the two co-change; nor is coupling that runs THROUGH a build step or config file.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

No strong hidden change-coupling between production files.

✓ On the Gold path — maintain.

Detailed fixes: d35_recommendation.md.

D36 · Supply-chain Provenance & Signing0.0 / 10Critical✓ Tool-verified

What it measures: Whether the build pipeline provides supply-chain integrity — generated provenance/attestation, signed artifacts (cosign/sigstore), an SBOM, and pinned build actions. Presence of the configuration, not a runtime guarantee.

Method: Supply-chain provenance/signing read deterministically from CI/build config (.github/workflows, .gitlab-ci.yml, azure-pipelines, Jenkinsfile, .circleci) + the release surface: four signals — generated provenance/attestation (SLSA/in-toto/actions-attest), artifact signing (cosign/sigstore/gitsign), an SBOM (syft/sbom-action/*.spdx.json/*.cdx.json), and SHA-pinned build actions — scored 10·present/denom. NotApplicable without a build pipeline. Detects configuration presence, not runtime enforcement.

Maturity: Documented → Verified → Prevented · effective 0.0 / 10 · rule-coverage 100% · ceiling Documented

0/4 supply-chain integrity signals present (provenance, signing, SBOM, pinned actions).

REDACTED
REDACTED
REDACTED
REDACTED
REDACTED

+ 3 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Resolve the 1 REDACTED finding(s) in Supply-chain Provenance & Signing. — One of this dimension's main actionable groups (1 warning-level).
  2. Resolve the 1 REDACTED finding(s) in Supply-chain Provenance & Signing. — One of this dimension's main actionable groups (1 warning-level).
  3. Resolve the 1 REDACTED finding(s) in Supply-chain Provenance & Signing — start with REDACTED. — One of this dimension's main actionable groups (1 warning-level).

Detailed fixes: d36_recommendation.md · top locations in Appendix A, every location in findings.md.

D43 · Malicious Dependencies10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether any dependency the repository declares is published as MALICIOUS rather than merely vulnerable — a package that is an attacker's work, in any ecosystem osv-scanner reads. Scored apart from D30 because the answer is binary: there is no safe version to upgrade to, and the fix is to remove the package and rotate every credential it could have read.

Method: The same dependency scan D30 reads, partitioned on the scanner's own classification rather than rescanned: a row is MALICIOUS when its id is in the `MAL-` space (the ossf/malicious-packages feed) OR its `database_specific.cwe_ids` carries `CWE-506` ("Embedded Malicious Code"). Both channels are structural; the summary text is deliberately NOT read, because a malicious-package record whose summary says only "Critical severity vulnerability" is a real shape ([GHSA redacted]) and a text matcher misses it. Scored BINARY: any surviving row is 0, whatever its severity and however many CVEs sit beside it — a hostile dependency is not a quantity. Applicability and degradation are D30's: NotApplicable only when no ecosystem is readable, and an unscannable ecosystem degrades rather than reading clean. SCORED, not informational.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

No dependency in any ecosystem this repository declares is published as malicious.

✓ On the Gold path — maintain.

Detailed fixes: d43_recommendation.md.

D44 · Platform End-of-Life10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether anyone still ships security patches for the platform this repository RUNS ON — the runtime it pins and the framework majors its own constraints hold it to. Separate from D12 because the question differs: a current Django on an end-of-life Python is perfectly up to date and completely unsupported, and the fix is a migration rather than a version bump. What the repository says it merely SUPPORTS is never charged.

Method: End-of-life PLATFORM read from the repository's own declarations and graded against a FROZEN, dated table of vendor support dates — no network, no feed, no API, so this dimension answers identically inside a closed scan fence. Two subjects: a RUNTIME the project pins (a single or all-end-of-life TargetFramework, a .nvmrc or .python-version, a requires-python CAP) and a FRAMEWORK major a dependency constraint cannot move off (a caret, tilde or exact version; `vue@^2.7.16` pins Vue 2). A FLOOR is deliberately never charged — `requires-python = ">=3.8"` states what a package SUPPORTS, not what it runs on — and a multi-target project is charged only when EVERY target is out of support. Runtime 4.0/product capped 8.0, framework 1.5 capped 4.5. The table is safe to freeze because a statement about support that ended in the past cannot become false: it loses recall as it ages, never precision, and a test asserts every entry predates the freeze date. Disjoint from D31 (a container image's OS layer) and D29 (the toolchain a CI workflow installs). Abstains when the repository declares no platform this pass reads — never scores it clean.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

0 end-of-life runtime(s) and 0 end-of-life framework(s), read from 1 platform declaration(s) and 169 dependency declaration(s). This dimension reads what the repository says about ITSELF — a pinned target framework, a version file, a capped requires-python, a Rust toolchain pin, a framework major a constraint cannot move off. A FLOOR is deliberately never charged: `requires-python = ">=3.8"` states what the package SUPPORTS, not what it runs on, and a well-maintained library declares exactly that while running its own CI on a current release. The end-of-life facts are FROZEN and dated, so this dimension needs no network and answers identically inside a closed scan fence; as the table ages it loses recall and never precision, because a statement about support that ended in the past cannot become false. The OS layer of a container image is D31's question and the toolchain a CI workflow installs is D29's; this row is neither.

✓ On the Gold path — maintain.

Detailed fixes: d44_recommendation.md.

Frontend & cross-cutting dimensions

R = React/JS · M = Maturity · P = Readiness.

AC1 · Text alternatives1.7 / 10Critical✓ Tool-verified

Other · Accessibility — Whether non-text content carries a text alternative — img/area/input[type=image] have alt, a meaningful svg has a title or aria-label, video has a captions track, and object/embed/canvas have a name or fallback content. Static markup readiness, not a WCAG conformance claim.

Method: Static markup-model scan: every img/area/input[type=image] checked for alt, svg[role=img] for a title/aria-label, video for a captions <track>. Components skipped, spreads suppressed. Deterministic, hard fact per element.

Coverage: Population: image/media elements — img, area, input[type=image], svg, video, object, embed, canvas — across the PARSED MARKUP files only (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx); components, hidden subtrees and dynamic-attribute elements are skipped. Markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is NOT read by any producer, so it contributes no element to this population; where such a frontend is present the card discloses it as an analyzer gap rather than scoring around it.

  • An image with no alt (and no aria-label/aria-labelledby) is unreadable to assistive tech. Add alt — alt="" if it's purely decorative. (×5) — chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/01-cover.html:27, chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/04-architecture.html:37, chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/05-attention.html:41, …
  • A <canvas> with no aria-label/title and no inner fallback content can't be described by assistive tech. Add a name or fallback content. — chapter2/attention_visualization/frontend/components/AttentionModal.tsx:452

What to do

  • Add a text alternative — alt on images (alt="" for purely decorative ones), a title or aria-label on meaningful svg, an aria-label or inner fallback content on canvas, and a captions <track> on video.
AC2 · Forms & labels5.3 / 10Adequate✓ Tool-verified

Other · Accessibility — Whether form controls have a programmatic label (an associated label, aria-label or aria-labelledby), buttons have text, links have an accessible name, a click handler on a plain element names the control it declares, fieldsets have a non-empty legend, known UI-library field components carry a label prop, and a placeholder isn't used as the only label. Static markup readiness, not a WCAG conformance claim.

Method: Static markup-model scan: inputs/selects/textareas checked for an associated label[for]/wrapping label/aria-label/aria-labelledby (per document), buttons for accessible text, fieldsets for a legend; placeholder-only labelling flagged. Deterministic, hard fact per control.

Coverage: Population: form controls, buttons, links, fieldsets and known UI-library field components in the PARSED MARKUP files only (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx); components, hidden subtrees and spread/dynamic-attribute elements are skipped, so a control whose label arrives through a spread or a runtime expression is deliberately not judged. Markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is not read at all.

  • This <label> has no htmlFor and wraps no form control, so it names nothing: assistive tech never announces it, and clicking the caption focuses no field. Note that an id on the label is not an association — it is the TARGET of one, so a control still has to point at it. Give the label htmlFor="<the control's id>", move the control inside the label, or point the control's aria-labelledby at this label's id. (×4) — chapter2/attention_visualization/frontend/components/AttentionModal.tsx:407, chapter2/attention_visualization/frontend/pages/index.tsx:265, chapter2/attention_visualization/frontend/pages/index.tsx:273, …
  • This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label htmlFor>, a wrapping <label>, or aria-label. (×5) — chapter5/conversational-ui/baseline/src/App.jsx:65, chapter5/conversational-ui/frontend/src/App.jsx:65, chapter5/conversational-ui/validation/runs/20260729T212616Z-5_11-hmr/app/frontend/src/App.jsx:65, …
  • This <label> has no for and wraps no form control, so it names nothing: assistive tech never announces it, and clicking the caption focuses no field. Note that an id on the label is not an association — it is the TARGET of one, so a control still has to point at it. Give the label for="<the control's id>", move the control inside the label, or point the control's aria-labelledby at this label's id. (×2) — chapter5/dynamic-form/validation/runs/20260729T212542Z-5_9-live-browser/generated_form.html:18, chapter7/elo-leaderboard/validation/runs/exp7-7-arena-20260731-v1/leaderboard_animation.html:146
  • This control has no associated label. Add a <label for> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it. (×3) — chapter5/dynamic-form/validation/runs/20260729T212542Z-5_9-live-browser/generated_form.html:19, chapter5/dynamic-form/validation/runs/20260729T212542Z-5_9-live-browser/generated_form.html:20, chapter7/elo-leaderboard/validation/runs/exp7-7-arena-20260731-v1/leaderboard_animation.html:147

What to do

  • Give every control a programmatic label (a <label for> / wrapping <label> / aria-label) and every button text — a placeholder is not a label.
AC3 · Page structure4.6 / 10Weak✓ Tool-verified

Other · Accessibility — Whether pages declare a language (well-formed BCP-47) and a non-empty title, expose exactly one main landmark and a sane heading order with non-empty headings, keep zoom enabled, title their iframes, give data tables header cells, and avoid meta-refresh. Static markup readiness, not a WCAG conformance claim.

Method: Static markup-model scan: html lang, document <title>, a main landmark and heading order on full documents only, plus zoom-disabling viewports, untitled iframes and meta-refresh anywhere. Deterministic, per structural checkpoint.

Coverage: Population: the PARSED MARKUP documents (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx). The page-level checks — lang, title, single main landmark — fire ONCE PER FULL DOCUMENT (an <html> root) and never on a partial or component fragment, so a repo of fragments is assessed only on the per-element checks (heading order, table headers, iframe titles, meta-refresh, zoom). Markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is not read at all.

  • The page declares no language, so assistive tech can't pick the right pronunciation. Add lang (e.g. lang="en"). (×13) — chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/01-cover.html:2, chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/02-problem.html:2, chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/03-keyidea.html:2, …
  • A page with no <title> gives no name in the tab, history or screen-reader page list. Add a descriptive <title> in <head>. (×13) — chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/01-cover.html:2, chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/02-problem.html:2, chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/03-keyidea.html:2, …
  • No <main> (or role="main") means no "skip to content" target and a weaker landmark map. Wrap the primary content in <main>. (×13) — chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/01-cover.html:2, chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/02-problem.html:2, chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/03-keyidea.html:2, …
  • Skipping heading levels breaks the document outline assistive tech relies on. Don't jump levels — increase by at most one. — chapter2/attention_visualization/frontend/pages/index.tsx:262

What to do

  • Declare <html lang>, a document <title> and a <main> landmark, keep headings in order, leave zoom enabled, title iframes and drop meta-refresh.
AC4 · Keyboard semantics3.5 / 10Weak✓ Tool-verified

Other · Accessibility — Whether interactive behaviour is keyboard-reachable — no click handler on a non-interactive element lacking a role, tabindex and key handler, no element the repo's own CSS styles `cursor: pointer` without giving it any of the three, no unfocusable element whose only binding is a mouse enter/leave pair or a double-click, no positive tabindex, no href-less anchor, no placeholder-href (#/javascript) link acting as a button. Static markup readiness, not a WCAG conformance claim.

Method: Static markup-model scan: click handlers on non-interactive elements lacking role+tabindex+key handler, positive tabindex values, and href-less anchors. Components skipped, spreads suppressed. Deterministic, hard fact per element.

Coverage: Population: elements that pose a keyboard-semantics question, in the PARSED MARKUP files only (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx) — a non-natively-interactive element carrying a click handler, a double-click or hover enter/leave binding, a pointer-only gesture on a tabindex="0" element, or `cursor: pointer` from the repo's own CSS; an href-less or placeholder-href (#, javascript:) anchor; and any element with a positive tabindex. Natively interactive elements used correctly (<button>, <a href>, form controls) are NOT in the population — there is nothing to judge — so a page of nothing but correct controls gives AC4 nothing to measure. Keyboard reachability is judged from the markup, never from a rendered page. ★ An interactive element declared in a tagged-template (html`…`) or hyperscript frontend is NOT in this population — no producer reads either — so an empty population is reported as an analyzer gap, never as "this repository has no interactive elements".

  • An <a> with no href, role or tabindex isn't focusable or keyboard-activatable. Give it a real href, or use a <button> for an action. — web-astro/src/components/Reader.astro:326

What to do

  • Make custom controls keyboard-operable (role + tabindex + key handler), drop positive tabindex, and give anchors a real href.
AC5 · ARIA correctness10.0 / 10Exemplary○ Nothing flagged

Other · Accessibility — Whether ARIA is used correctly — valid non-abstract roles, the ARIA state a role requires, valid (non-misspelled) aria-* attribute names, in-enum values for token-typed aria-* attributes, and no aria-hidden on (or wrapping) a focusable element. Static markup readiness, not a WCAG conformance claim.

Method: Static markup-model scan: role values checked against the WAI-ARIA role set (abstract/invalid flagged), required ARIA state for a role, and aria-hidden on a focusable element. Deterministic, role/attribute level.

Coverage: Population: elements in the PARSED MARKUP files (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx) that carry a role or an aria-* attribute; roles and token values are checked against the ARIA enums exhaustively within that set. An expression-valued (dynamic) role or aria-* value is skipped rather than guessed, and markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is not read at all.

AC6 · Visual & motion safety5.0 / 10Weak✓ Tool-verified

Other · Accessibility — Whether focus outlines aren't removed without a replacement, motion respects prefers-reduced-motion, and literal CSS colour pairs meet contrast — PARTIAL: inline styles, in-repo <style> blocks, in-repo .css files, var() tokens, Tailwind neutral utilities and CSS-in-JS literals are read (hex/rgb/hsl/named), never computed/runtime/external-CDN colour. Static markup readiness, not a WCAG conformance claim.

Method: Static markup/CSS scan: inline outline:none/0, literal inline colour/background contrast against the 4.5:1 AA floor, and <style>-block animation without a prefers-reduced-motion guard. Deterministic but PARTIAL — only inline styles and in-repo CSS literals are visible.

Coverage: Population: styled elements in the PARSED MARKUP files (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx), plus in-repo <style> blocks, in-repo .css files and CSS-in-JS literals. Colour contrast is computed from LITERAL colour pairs only (hex/rgb/hsl/named, including var() tokens and Tailwind neutral utilities) — computed, runtime-themed and external-CDN colour is never resolved, so this is a partial read of contrast by construction. Markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is not read at all.

  • <div> moves — its `animate-spin` utility runs with no motion-safe:/motion-reduce: variant — and nothing reads prefers-reduced-motion for it, so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Gate it on @media (prefers-reduced-motion: no-preference) or motion-safe:. — chapter2/attention_visualization/frontend/pages/index.tsx:169
  • This element's Tailwind text/background colour utilities fall below the 4.5:1 WCAG AA minimum for normal text. Pick a darker or lighter shade. — chapter6/live-audio/frontend/pages/index.tsx:650
  • `#progress` moves (`transition: width 0.5s`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — chapter7/elo-leaderboard/validation/runs/exp7-7-arena-20260731-v1/leaderboard_animation.html:109
  • `button` sets color: white on background-color: #4CAF50 — 2.8:1, below the 4.5:1 WCAG AA minimum for normal text. Darken or lighten one of them. — chapter7/elo-leaderboard/validation/runs/exp7-7-arena-20260731-v1/leaderboard_animation.html:75
  • `.toolbar .progress > i` moves (`transition: width .25s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — extras/agent-lab/agent-trajectory.js:116
  • `.error` sets color: #9a6700 on background-color: #1c2128 — 3.3:1, below the 4.5:1 WCAG AA minimum for normal text. Darken or lighten one of them. — extras/agent-lab/agent-trajectory.js:222
  • `.send-button` sets color: #ffffff on background-color: #16a34a — 3.3:1, below the 4.5:1 WCAG AA minimum for normal text. Darken or lighten one of them. (×2) — chapter5/conversational-ui/frontend/src/theme.css:96, chapter5/conversational-ui/baseline/src/theme.css:96
  • `.input` sets the outline to none/0 and no visible :focus / :focus-visible style for that element replaces it in this stylesheet, so a keyboard user cannot see where focus is. Draw a focus ring (outline, box-shadow or border) under :focus-visible. — chapter2/attention_visualization/frontend/styles/globals.css:25
  • `.sidebar-toggle svg` moves (`transition: transform 0.15s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. — extras/book-theme.css:116

What to do

  • Keep a visible focus style (don't remove the outline without a replacement), guard animation with prefers-reduced-motion, and raise low-contrast colour pairs to at least 4.5:1.
AC7 · A11y enforcement4.0 / 10Weak✓ Tool-verified

Other · Accessibility — Whether accessibility is ENFORCED in the toolchain — an accessibility checker configured over the markup (an a11y lint rule set, e.g. eslint-plugin-jsx-a11y or vuejs-accessibility where the project lints JavaScript) and an automated accessibility assertion wired into tests or CI (axe/pa11y/Lighthouse or an equivalent) — on the Documented→Verified→Prevented ladder.

Method: Repo config/CI scan: an accessibility checker configured over the markup (an a11y lint rule set such as eslint-plugin-jsx-a11y / vuejs-accessibility where JavaScript is linted) and an automated accessibility assertion in tests or CI (axe/pa11y/Lighthouse or equivalent), graded on the Documented→Verified→Prevented rungs. Deterministic, presence/rung detection.

Coverage: Population: the repository's own tooling configuration — lint config, test and CI files — NOT the markup. It is read for a configured accessibility checker and an automated accessibility assertion (axe/pa11y/Lighthouse, or a native-toolkit equivalent), and it credits an INVOCATION, never a mention: a licence filename, an import comment or a doc reference earns no rung. Enforcement configured entirely outside the repository leaves no evidence here and cannot be credited.

  • No accessibility enforcement found — no a11y linter (eslint-plugin-jsx-a11y) and no axe/pa11y/Lighthouse in tests or CI. Start with the linter to catch issues at author time. What was searched, so you can tell an absence from a miss: the 60 markup file(s) this pass actually assessed, the linter configuration checked in beside them, and this repository's test and CI files — matched by name against the accessibility checkers this dimension carries. An audit run outside the repository, a hosted scanner, or a check whose name is not one of those, is not seen here. — web-astro/package.json:27

What to do

  • Enforce accessibility in the toolchain: add eslint-plugin-jsx-a11y, then assert with your test runner's axe binding (jest-axe, vitest-axe, cypress-axe or @axe-core/playwright) in tests, then gate axe/pa11y/Lighthouse in CI.
AX10 · Code composition9.8 / 10Exemplary✓ Tool-verified

Other · Architecture — How the codebase splits by code ROLE — domain, application, infrastructure, test, generated. The significance map behind the knowledge/coupling weighting, and a DDD signal in its own right: a thin domain core under fat infrastructure is the anemic-domain smell, quantified. How each file's role is decided, because the split is only as good as that: a generated name or a build-output tree makes it Generated, a test project makes it Test, and otherwise the file's NAMESPACE and PATH words are matched against fixed vocabularies in a fixed ORDER — domain, then infrastructure, then application — so a file whose words hit two layers is counted under the earlier one. A production file matching none of them counts as application, so that share reads 'application or unclassified' rather than a measured application layer. Roles come from naming convention, never from what the code does. On this repository the split was taken from the source tree on disk rather than from a loaded .NET workspace, so a file's role is decided by its PATH segments alone — no declared namespace was available to add to the evidence — and generated output is excluded from the census entirely rather than counted as a generated share.

Method: Roslyn line-count by code ROLE: every source file classified Domain/Application/Infrastructure/Test/Generated by namespace + path convention (the shared CodeRoleClassifier), then significant lines summed per role. Deterministic; the advisory score is the business-logic (domain+application) share of production code.

Coverage: Population: ALL source files, each bucketed into ONE of five roles (Domain/Application/Infrastructure/Test/Generated) by namespace + path convention — a file whose layer isn't named in the convention falls to Application (the neutral default), and the split is line-count, not semantic depth or business value.

What to do

  • The domain core is a small share of production code, but most of the rest matched no layer vocabulary at all — so this is not yet an anemic-domain finding. The namespace/path convention could not place that code, which makes the composition above a statement about the naming, not about the design. Name the layers (or check that the repository's conventions differ from the ones this check knows) before reading a thin domain into it.
AX2 · Stateful singletons10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether singleton services avoid mutable shared instance state that concurrent callers would race on.

Method: Roslyn scan: singleton field mutations unguarded by lock or Interlocked, per type; syntax-based guard detection. Deterministic, traceable per field.

AX3 · Project dependency cycles10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether the project-reference graph is acyclic (cycles block independent build/deploy and signal eroding boundaries).

Method: Project reference cycles via elementary-DFS over real .csproj references, using the engine shared with D5/D7; cyclic versus acyclic. Exhaustive, deterministic.

AX4 · Dependency direction10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether dependencies point inward (Domain ← Application ← Infrastructure/Web) — the clean-architecture dependency rule, checked across the project graph.

Method: Layer violations by name-segment inference (Domain/Core to Application to Infrastructure/Web) over the project-reference graph. Exhaustive over all projects, deterministic.

C2 · Access Controls10.0 / 10Exemplary○ Nothing flagged

Other · Security — Whether access is authorized by default — a framework authorization attribute/decorator or policy, or imperative guard methods (throw-on-violation) called from handlers.

Method: Roslyn scan: [Authorize] usage and authorization policies, plus imperative throw-on-violation guard methods detected via syntax. Deterministic.

DM6 · Domain ↔ infrastructure boundary10.0 / 10Exemplary✓ Tool-verified

Other · Domain Modelling — Whether the domain layer stays free of infrastructure dependencies — a domain aggregate fused to a persistence ORM (Django/SQLAlchemy) on its own declaration (active-record) couples the domain to infrastructure. The clean-architecture dependency rule.

Method: Roslyn (DDD-gated): domain-layer types scanned for infrastructure usage in member SIGNATURES and inside method/accessor BODIES — resolved calls and object-creations into EF/Marten/HTTP/Mongo/Redis/message-bus types (not just a namespace allowlist). Deterministic, symbol-resolved, exhaustive over domain-layer bodies, DDD-native.

Coverage: Domain layer identified by NAMESPACE heuristic; infrastructure then resolved by symbol in member SIGNATURES and method/accessor BODIES — rename the layer and the check evaporates.

M1 · Documentation (README)8.0 / 10Strong✓ Tool-verified

Maturity · Maturity — Whether the repo and its projects have a README, and whether it's substantive and current.

Method: Filesystem scan: README presence, word count, and headings for depth; git history for staleness. Exhaustive across root and project dirs, deterministic.

What to do

  • Explain in the README how to run the tests. Add a section called Testing to the README in the repository's top folder, saying how to run the test suite.
  • Add a README to the 8 of 12 project(s) that lack one — worth up to 1.3 pts.
M2 · Architecture documentation5.0 / 10Adequate✓ Tool-verified

Maturity · Maturity — Whether key decisions (ADRs) and the high-level shape (C4/diagrams) are written down.

Method: Filesystem scan: ADR folder/naming conventions or content, plus Mermaid/PlantUML/C4/architecture.md discovery. Exhaustive, deterministic.

  • No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.

What to do

  • Record your significant design decisions. Write one short document per decision, giving its date, the situation, the decision and its consequences, and keep them together with your other design documents. A docs/adr folder with each file named by number and title is the easiest place to find them.
M3 · Folder & project structure8.0 / 10Strong✓ Tool-verified

Maturity · Maturity — Whether the repo is organised deliberately — src/test separation and consistent project naming.

Method: Filesystem scan: src/test folder separation and namespace-prefix consistency (majority RootNamespace agreement). Exhaustive across projects, deterministic.

  • Production code isn't grouped under a src/ folder — it's spread across several top-level directories, so there's no one place that says 'this is the product'.

What to do

  • Group production code under src/ (or split deliberately, e.g. backend/ + frontend/) so production and tooling code aren't mixed at the root.
M4 · Documentation accuracy10.0 / 10Exemplary○ Nothing flagged

Maturity · Maturity — Whether the project's current-state documentation describes the code that exists.

Method: Every current-state document's checkable claims looked up in the tree (links, versions, and artefact counts an order of magnitude off), plus two README checks: an advertised infrastructure product with no footprint, and a module the CHANGELOG records as removed. Deterministic, no model. Advisory.

P1 · CI/CD gates10.0 / 10Exemplary○ Nothing flagged

Readiness · Readiness — Whether an automated pipeline builds and tests every change.

Method: Filesystem scan: CI workflow files (.github/workflows, .gitlab-ci.yml, etc.) for build and test stages. Exhaustive, deterministic.

P10 · Library API & versioning10.0 / 10Exemplary○ Nothing flagged

Readiness · Readiness — For a library: a deliberate (small) public API surface and explicit semantic versioning so consumers can depend on it safely.

Method: Roslyn scan: public API surface area and semantic-versioning markers (SemVer attributes, changelog entries) for libraries; off .NET, a library is the ecosystem's publication act (an npm package that is not private and names an entry point, a PyPI distribution with a build system, a Rust library crate, a Maven/Gradle module that publishes, a Go module with no package main, a gemspec, a Composer library, a SwiftPM library product, a pub.dev or Hex package), its surface is the share of types the language's code model records as public (Rust, Swift, Java, Kotlin, Go, Dart; not measured where the model records no type visibility or, as in TypeScript, only module-level export), and its version is read from the manifest, a semver CHANGELOG, release tooling or semver git tags. Exhaustive, deterministic.

P2 · Observability5.9 / 10Adequate✓ Tool-verified

Readiness · Readiness — Whether the code is diagnosable in production — structured logging, tracing/metrics, health checks.

Method: Filesystem/Roslyn scan: structured-logging frameworks (Serilog, NLog), OpenTelemetry, and health-check endpoint patterns. Exhaustive, deterministic.

  • Only 28/96 runnable modules use logging (modules with no entry point or server are excluded — they are libraries a runnable module hosts). Silent: `chapter1/image-gen-workflow`, `chapter1/learning-from-experience`, `chapter10/autonomous-phone-registration`, `chapter10/book-translation`, `chapter10/generative-agents` and 63 more.

What to do

  • Extend structured logging to the remaining runnable modules so everything you run is diagnosable in production.
  • Add OpenTelemetry tracing/metrics (opentelemetry-sdk) so requests are traceable across the system, not just health-probable.
P3 · Security & performance tooling0.0 / 10Critical✓ Tool-verified

Readiness · Readiness — Whether SAST, secret/dependency scanning and performance benchmarking are wired in (presence, not runtime).

Method: Filesystem scan: SAST configuration, dependency-update automation, secret scanning, and a benchmark harness or benchmark step — in this repository's own ecosystem. Exhaustive, deterministic.

  • No static application security testing detected. For this repository's stack, add bandit, `semgrep --config=p/python`, or CodeQL's python pack as a CI step. What was searched, so you can tell an absence from a miss: the 26840 CI workflow file(s) in this repository, and the scanner and linter configuration checked in beside them. A scan that runs outside CI, one configured in your forge's web UI rather than in a committed file, or a tool whose name is none of those this check carries, is not seen — if that is your case the row is wrong, and saying so is more useful than adding a second scanner. — REDACTED:4
  • `chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/package.json` declares packages, and nothing in the repository keeps them current: no Dependabot or Renovate configuration that schedules updates, and no dependency-review gate on pull requests. A pinned dependency stays at the version it was added at until someone notices — including after an advisory is published against it. Add a `.github/dependabot.yml` with one `package-ecosystem` entry per ecosystem the tree uses (or an enabled `renovate.json`), and gate pull requests with `actions/dependency-review-action`. — chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/package.json:13

What to do

  • Add a SAST step to CI running what this repository's stack ships: bandit, `semgrep --config=p/python`, or CodeQL's python pack — so a security regression fails the build instead of landing.
  • Enable Dependabot/Renovate or a dependency-review gate.
  • Add gitleaks/trufflehog in CI to block PRs that introduce committed secrets.
P4 · Deployment & Rollback8.0 / 10Strong✓ Tool-verified

Readiness · Readiness — Whether releases are automated and safely reversible (probes, rolling updates, approval gates) — from manifests/pipeline files, not the live environment.

Method: Filesystem scan: deployment manifests/IaC (K8s YAML, Helm, Terraform) for rolling updates, probes, approval gates, migration hooks. Exhaustive, deterministic.

What to do

  • The pipeline declares a deployment environment, but whether required reviewers / protection rules are attached to it lives in repository settings we cannot read — confirm the gate is enforced before production promotion.
P5 · DR & Backup0.0 / 10Critical✓ Tool-verified

Readiness · Readiness — Whether disaster recovery is planned and codified — backups, geo-recovery, RTO/RPO, persistence guarantees — from IaC + container manifests + docs, never the live cloud.

Method: Filesystem scan: disaster recovery, backup, geo-recovery, RTO/RPO, persistence guarantees from IaC, manifests, and docs. Exhaustive, deterministic, never a live environment.

  • A persistence guard (data volume / purge-protection) was found, but no backup, geo-recovery or RTO/RPO controls were evidenced — a volume that survives a container recreate is not a tested restore from catastrophic loss.

What to do

  • Codify backups + geo-recovery in IaC and document RTO/RPO and the restore procedure — a persistence guard alone is not disaster recovery.
P6 · Release Hygiene8.0 / 10Strong✓ Tool-verified

Readiness · Readiness — Whether releases are traceable — a maintained changelog and explicit version stamping.

Method: Filesystem scan: changelog file presence and version tags in csproj or git tags. Exhaustive, deterministic.

  • The changelog this check read carries 0 versioned entries, against a bar of 3. Counted as either the distinct `x.y.z` versions it names (a link's target is not counted) or its version-shaped section headings (`## [1.2.0]`, `## V14.x.x`, `## Updates in 8.0.x`), whichever is the larger — so a log sectioned by minor series counts its sections, not its individual patch numbers. Entries recorded somewhere this check does not read — release notes generated at tag time from a generator config it did not recognise, or a log kept outside the repository — are not counted here, and this row is about what is re-findable in the tree rather than about how often you release.

What to do

  • Keep the changelog current — add a versioned entry (Keep-a-Changelog ## [x.y.z]) for each release so the history isn't a stub.
P7 · Outbound HTTP resilience3.0 / 10Weak✓ Tool-verified

Readiness · Readiness — Whether outbound HTTP calls are wrapped in resilience (retry/timeout/circuit-breaker) so a failing dependency doesn't cascade.

Method: Source scan: outbound HTTP clients and what bounds them — resilience handlers (Polly, AddStandardResilienceHandler) on .NET; on Go, the JVM, Python, JavaScript/TypeScript, Ruby, PHP, Rust, Elixir, Swift, Dart and Erlang, a timeout, deadline, retry or breaker beside each call, or a process-wide client default (a framework-wide deadline such as Drupal core's, Laravel's or actix's awc counts). Exhaustive, deterministic.

  • `requests.get(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout. (×2) — chapter2/local_llm_serving/server.py:116, chapter7/elo-leaderboard/data_loader.py:33
  • `requests.post(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout. (×3) — chapter2/prompt-engineering/tau_bench/model_utils/model/vllm_utils.py:24, chapter3/agentic-rag-for-user-memory/indexer.py:316, chapter3/contextual-retrieval-for-user-memory/indexer.py:215
  • `httpx.AsyncClient(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout. (×6) — chapter4/collaboration-tools/src/notification_tools.py:243, chapter4/collaboration-tools/src/notification_tools.py:300, chapter4/collaboration-tools/src/notification_tools.py:350, …
  • `httpx.get(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout. — chapter4/multimodal-agent/agent.py:81
  • `axios.post(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout. (×3) — chapter6/live-audio/backend/utils/providers/llmProviders.js:69, chapter6/live-audio/backend/utils/providers/llmProviders.js:121, chapter6/live-audio/backend/utils/providers/llmProviders.js:183
  • `urllib.request.urlopen(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout. — REDACTED:996

What to do

  • Pass `timeout=` on every `requests`/`httpx` call (requests has no default and will wait forever), mount an `HTTPAdapter(max_retries=Retry(...))` on shared sessions, and wrap calls to flaky dependencies in `tenacity` retries or a `pybreaker` circuit breaker.
  • Bound every outbound call: pass `signal: AbortSignal.timeout(ms)` to `fetch`, set `timeout` on the axios instance (`axios.create({ timeout })`), and add retries with back-off (`axios-retry`, `p-retry`) and a breaker (`opossum`, `cockatiel`) around dependencies that fail.
PF3 · Async & latency hygiene6.0 / 10Adequate✓ Tool-verified

Readiness · Performance — Whether asynchronous code stays responsive — it avoids sync-over-async blocking (a .NET .Wait()/.GetAwaiter().GetResult(), a time.sleep or blocking HTTP call inside a Python coroutine, a *Sync call inside an async JavaScript function, block_on inside a Rust async fn, runBlocking inside a Kotlin suspend function, block() inside a Reactor publisher) that stalls a thread or event loop and risks deadlock, and, where the code is a reusable library on .NET, awaits with ConfigureAwait(false) so it never captures and stalls its caller's context.

Method: Production-source scan: sync-over-async blocking counted everywhere — .Wait()/.GetAwaiter().GetResult() in .NET; off .NET, read from each language's code model, a blocking call inside an async function (Python, TS/JS, Rust, Kotlin, Swift, Dart) or inside a Java method returning a Reactor Mono/Flux or a Scala method returning a Future or effect — and, for a .NET library with ≥5 awaits, the share of awaits using ConfigureAwait(false). Deterministic, syntax/text detection.

  • `virtual_terminal` is async and calls subprocess.run — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs. — chapter4/execution-tools/execution_tools.py:195
  • `excel_create_with_formula_and_screenshot` is async and calls subprocess.run — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs. — REDACTED:36
  • `virtual_desktop_execute` is async and calls time.sleep, subprocess.run — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs. — REDACTED:139
  • `virtual_mobile_execute` is async and calls subprocess.run — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs. — REDACTED:289
  • `environment_capabilities` is async and calls subprocess.run — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs. — REDACTED:359
  • `execute_command` is async and calls subprocess.run — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs. — REDACTED:39
  • `google_search_api` is async and calls requests.get — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs. — chapter4/perception-tools/src/google_search_enhanced.py:22
  • `_fallback_google_search` is async and calls requests.post — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs. — chapter4/perception-tools/src/google_search_enhanced.py:92
  • `read_webpage_content` is async and calls requests.get — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs. — chapter4/perception-tools/src/google_search_enhanced.py:141
  • `extract_audio_metadata` is async and calls subprocess.run — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs. — chapter4/perception-tools/src/media_processing_tools.py:217
  • `trim_audio` is async and calls subprocess.run — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs. — chapter4/perception-tools/src/media_processing_tools.py:688
  • `read_webpage` is async and calls requests.get — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs. — chapter4/perception-tools/src/multimodal_tools.py:24
  • `get_weather` is async and calls requests.get — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs. — REDACTED:24
  • `get_stock_price` is async and calls requests.get — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs. — REDACTED:149
  • `convert_currency` is async and calls requests.get — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs. — REDACTED:228
  • `search_wayback` is async and calls requests.get — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs. — REDACTED:461
  • `get_crypto_price` is async and calls requests.get — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs. — REDACTED:551
  • `search_location` is async and calls requests.get — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs. — REDACTED:660
  • `search_poi` is async and calls requests.post — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs. — REDACTED:761
  • `search_web` is async and calls requests.post — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs. — chapter4/perception-tools/src/search_tools.py:45
  • `get_archived_content` is async and calls requests.get — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs. — chapter4/perception-tools/src/wayback_enhanced.py:21
  • `get_article_history` is async and calls requests.get — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs. — chapter4/perception-tools/src/wiki_enhanced.py:180
  • `fs.writeFileSync` in `data.on("end")` blocks the event loop until it finishes — a blocking call inside async code stalls the event loop — every other request waits for as long as it runs. — chapter6/live-audio/backend/server.js:869
  • `fs.readFileSync` in `data.on("end")` blocks the event loop until it finishes — a blocking call inside async code stalls the event loop — every other request waits for as long as it runs. — chapter6/live-audio/backend/server.js:889
  • `fs.unlinkSync` in `data.on("end")` blocks the event loop until it finishes — a blocking call inside async code stalls the event loop — every other request waits for as long as it runs. (×2) — chapter6/live-audio/backend/server.js:892, chapter6/live-audio/backend/server.js:893
  • `fs.existsSync` in `it("should transcribe test audio")` blocks the event loop until it finishes — a blocking call inside async code stalls the event loop — every other request waits for as long as it runs. — chapter6/live-audio/backend/tests/provider-tests.js:120
  • `fs.mkdirSync` in `it("should transcribe test audio")` blocks the event loop until it finishes — a blocking call inside async code stalls the event loop — every other request waits for as long as it runs. — chapter6/live-audio/backend/tests/provider-tests.js:121
  • `fs.existsSync` in `anonymous function` blocks the event loop until it finishes — a blocking call inside async code stalls the event loop — every other request waits for as long as it runs. — chapter6/live-audio/backend/tests/provider-tests.js:302
  • `fs.mkdirSync` in `anonymous function` blocks the event loop until it finishes — a blocking call inside async code stalls the event loop — every other request waits for as long as it runs. — chapter6/live-audio/backend/tests/provider-tests.js:303
  • `fs.writeFileSync` in `it("should synthesize simple text to speech")` blocks the event loop until it finishes — a blocking call inside async code stalls the event loop — every other request waits for as long as it runs. — chapter6/live-audio/backend/tests/test-tts-providers.js:160
  • `fs.writeFileSync` in `it("should handle multilingual text")` blocks the event loop until it finishes — a blocking call inside async code stalls the event loop — every other request waits for as long as it runs. — chapter6/live-audio/backend/tests/test-tts-providers.js:188
  • `fs.writeFileSync` in `it("should handle different audio formats and settings")` blocks the event loop until it finishes — a blocking call inside async code stalls the event loop — every other request waits for as long as it runs. — chapter6/live-audio/backend/tests/test-tts-providers.js:224
  • `fs.writeFileSync` in `it("should handle longer text synthesis")` blocks the event loop until it finishes — a blocking call inside async code stalls the event loop — every other request waits for as long as it runs. — chapter6/live-audio/backend/tests/test-tts-providers.js:285
  • `fs.writeFileSync` in `transcribe` blocks the event loop until it finishes — a blocking call inside async code stalls the event loop — every other request waits for as long as it runs. (×2) — chapter6/live-audio/backend/utils/providers/asrProviders.js:78, chapter6/live-audio/backend/utils/providers/asrProviders.js:168
  • `fs.unlinkSync` in `transcribe` blocks the event loop until it finishes — a blocking call inside async code stalls the event loop — every other request waits for as long as it runs. (×2) — chapter6/live-audio/backend/utils/providers/asrProviders.js:130, chapter6/live-audio/backend/utils/providers/asrProviders.js:224
  • `fs.existsSync` in `initializeSileroVAD` blocks the event loop until it finishes — a blocking call inside async code stalls the event loop — every other request waits for as long as it runs. — chapter6/live-audio/backend/utils/vad.js:48

What to do

  • Python: await the async equivalent (asyncio.sleep, an async HTTP client such as httpx.AsyncClient or aiohttp, asyncio.create_subprocess_exec), or move the blocking call off the loop with `await asyncio.to_thread(...)`; never call asyncio.run inside a coroutine — await the coroutine.
  • TypeScript/JavaScript: use the promise APIs (fs/promises, a promisified child_process.execFile, the async zlib/crypto functions) and await them instead of the *Sync variants.
R1 · Type Safety1.7 / 10Critical✓ Tool-verified

React / JS · Code Health — How much of the frontend is typed TypeScript vs untyped JavaScript.

Method: Frontend file inventory: the share of typed TypeScript vs untyped JavaScript across the source tree. Deterministic, exhaustive over frontend files.

  • 26 typed · 126 plain JS — the untyped files are chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/build.js, chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/make-assets.js, chapter4/execution-tools/validation/experiment_4_4/real_mcp_20260730T062500Z/workspace/valid.js, chapter4/execution-tools/validation/experiment_4_4/real_mcp_20260730T070500Z/workspace/valid.js, chapter4/execution-tools/validation/experiment_4_4/real_mcp_gui_20260802T093348Z/workspace/valid.js, chapter4/execution-tools/validation/experiment_4_4/real_mcp_gui_20260802T093657Z/workspace/valid.js (+120 more).

What to do

  • Migrate the remaining .js/.jsx files to TypeScript.
R10 · Code Duplication8.8 / 10Strong✓ Tool-verified

React / JS · Code Health — Near-exact copy-pasted blocks of substantial extent across the frontend (the D4 clone algorithm over JS/TS tokens, D-386): a block is reported only where its copies still agree on most of their own identifiers and literals, or were renamed as they were pasted but kept most of their constants, and where the copies carry enough code to stand on their own or the copied extent reaches 30 lines — so a re-implementation sharing neither names nor values, and a small pasted declaration, are both found and deliberately not reported, and a clean R10 is not a claim that nothing was copied.

Method: Near-exact copy-pasted blocks of substantial extent across the frontend (the D4 clone algorithm run over JS/TS tokens). Masking finds the candidates; a block is reported when its copies still agree on most of their own identifiers and literals, or when a renamed copy still agrees on most of its constants, AND the copies carry enough code to stand on their own — or when the copied extent reaches 30 lines. So a re-implementation sharing neither names nor values, and a small pasted declaration, are deliberately not counted. Deterministic.

  • chapter5/conversational-ui/validation/runs/20260729T212616Z-5_11-hmr/app/ and chapter5/conversational-ui/validation/runs/20260729T212727Z-5_11-hmr/app/ are near-verbatim copies of each other: 6 files are byte-identical under the same relative paths (~2136 lines; the trees hold 8 and 8 files). That is one structural fact, not 6 local ones: every edit made to one tree and not the other drifts silently, which is the failure whole-tree forks guarantee. Pick one tree as the single source and produce the other from it (generated, copied at build or release time, or re-exported) — or, if the copy is a stale snapshot nothing produces any more, delete it. Check first whether the copy is a deliberately published deliverable (a template consumers copy verbatim, a released sample frozen at a version); where it is, keep it produced from the source tree rather than edited in place. — REDACTED:1
  • chapter5/conversational-ui/validation/runs/20260729T212616Z-5_11-hmr/app/ and chapter5/conversational-ui/validation/runs/20260729T212933Z-5_11-hmr/app/ are near-verbatim copies of each other: 5 files are byte-identical under the same relative paths (~2058 lines; the trees hold 8 and 8 files). That is one structural fact, not 5 local ones: every edit made to one tree and not the other drifts silently, which is the failure whole-tree forks guarantee. Pick one tree as the single source and produce the other from it (generated, copied at build or release time, or re-exported) — or, if the copy is a stale snapshot nothing produces any more, delete it. Check first whether the copy is a deliberately published deliverable (a template consumers copy verbatim, a released sample frozen at a version); where it is, keep it produced from the source tree rather than edited in place. — REDACTED:1
  • chapter5/conversational-ui/validation/runs/20260729T212727Z-5_11-hmr/app/ and chapter5/conversational-ui/validation/runs/20260729T212933Z-5_11-hmr/app/ are near-verbatim copies of each other: 5 files are byte-identical under the same relative paths (~2058 lines; the trees hold 8 and 8 files). That is one structural fact, not 5 local ones: every edit made to one tree and not the other drifts silently, which is the failure whole-tree forks guarantee. Pick one tree as the single source and produce the other from it (generated, copied at build or release time, or re-exported) — or, if the copy is a stale snapshot nothing produces any more, delete it. Check first whether the copy is a deliberately published deliverable (a template consumers copy verbatim, a released sample frozen at a version); where it is, keep it produced from the source tree rather than edited in place. — REDACTED:1
  • chapter5/conversational-ui/baseline/src/App.jsx:1 · chapter5/conversational-ui/frontend/src/App.jsx:1 · chapter5/conversational-ui/validation/runs/20260729T212616Z-5_11-hmr/app/frontend/src/App.jsx:1 · chapter5/conversational-ui/validation/runs/20260729T212727Z-5_11-hmr/app/frontend/src/App.jsx:1 — these 4 files are line-for-line copies of one another — 54 lines are identical, in the same order, in every one of them — so this is one fact about the file set, not a block to extract. An edit made to one file and not the others changes behaviour silently, which is the failure a wholesale copy guarantees. Pick one file as the single source and derive the others from it (re-export it, spread it into the local overrides each variant genuinely needs, or generate the copies at build time) — the few lines that differ between the files are exactly the part each variant should still own. Check first whether the copies are deliberately standalone deliverables (a translation file seeded from its sibling and waiting to be translated); where they are, the duplication is the design, and the honest move is to mark the seeded file as untranslated rather than to let it pass as done. — chapter5/conversational-ui/baseline/src/App.jsx:1
  • chapter6/live-audio/backend/utils/providers/asrProviders.js:88 · chapter6/live-audio/backend/utils/providers/asrProviders.js:182 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — chapter6/live-audio/backend/utils/providers/asrProviders.js:88
  • web-astro/scripts/collaboration-manager-figures.mjs:6 · web-astro/scripts/evolution-methods-figures.mjs:7 — the 2 copies sit in sibling files in one directory, so check first whether one of them (or an existing module there) already owns this behaviour and the others should call it; otherwise extract it into one module in that directory and have each site call it. — web-astro/scripts/collaboration-manager-figures.mjs:6
  • web-astro/scripts/evolution-flow-figures.mjs:7 · web-astro/scripts/training-sequences-figures.mjs:7 — the two spans are one implementation copied and then locally edited — 319 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one. — web-astro/scripts/evolution-flow-figures.mjs:7
  • chapter2/attention_visualization/frontend/components/PromptDisplay.tsx:15 · chapter2/attention_visualization/frontend/components/ResponseDisplay.tsx:11 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — chapter2/attention_visualization/frontend/components/PromptDisplay.tsx:15
  • chapter6/live-audio/backend/utils/providers/llmProviders.js:58 · chapter6/live-audio/backend/utils/providers/llmProviders.js:110 · chapter6/live-audio/backend/utils/providers/llmProviders.js:172 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. — chapter6/live-audio/backend/utils/providers/llmProviders.js:58
  • REDACTED:163 · REDACTED:493 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — REDACTED:163
  • web-astro/scripts/collaboration-society-figures.mjs:26 · web-astro/scripts/evolution-methods-figures.mjs:45 · web-astro/scripts/training-sequences-figures.mjs:20 — the 3 copies are spread across 3 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — web-astro/scripts/collaboration-society-figures.mjs:26
  • extras/auto-translate.js:357 · REDACTED:533 — the two spans are one implementation copied and then locally edited — 215 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one. — extras/auto-translate.js:357
  • REDACTED:37 · REDACTED:36 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — REDACTED:37
  • web-astro/scripts/training-foundations-figures.mjs:5 · web-astro/scripts/training-systems-figures.mjs:4 — the 2 copies sit in sibling files in one directory, so check first whether one of them (or an existing module there) already owns this behaviour and the others should call it; otherwise extract it into one module in that directory and have each site call it. — web-astro/scripts/training-foundations-figures.mjs:5
  • REDACTED:15 · REDACTED:289 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — REDACTED:15
  • web-astro/scripts/evolution-methods-figures.mjs:45 · web-astro/scripts/training-foundations-figures.mjs:16 · web-astro/scripts/training-sequences-figures.mjs:20 · web-astro/scripts/training-systems-figures.mjs:15 — the 4 copies are spread across 4 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — web-astro/scripts/evolution-methods-figures.mjs:45
  • REDACTED:87 · REDACTED:67 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — REDACTED:87
  • chapter6/live-audio/backend/utils/providers/llmProviders.js:30 · chapter6/live-audio/backend/utils/providers/llmProviders.js:153 — the two spans are one implementation copied and then locally edited — 112 tokens are still identical, in the same order in both spans, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one. — chapter6/live-audio/backend/utils/providers/llmProviders.js:30
  • REDACTED:400 · REDACTED:479 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — REDACTED:400
  • chapter6/live-audio/backend/utils/providers/asrProviders.js:237 · chapter6/live-audio/backend/utils/providers/llmProviders.js:204 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — chapter6/live-audio/backend/utils/providers/asrProviders.js:237
  • extras/auto-translate.js:197 · web-astro/src/scripts/machine-translation.ts:136 — the two spans are one implementation copied and then locally edited — 129 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one. — extras/auto-translate.js:197
  • web-astro/scripts/collaboration-context-figures.mjs:6 · web-astro/scripts/collaboration-society-figures.mjs:7 — the 2 copies sit in sibling files in one directory, so check first whether one of them (or an existing module there) already owns this behaviour and the others should call it; otherwise extract it into one module in that directory and have each site call it. — web-astro/scripts/collaboration-context-figures.mjs:6
  • REDACTED:23 · REDACTED:51 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — REDACTED:23
  • REDACTED:387 · REDACTED:537 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — REDACTED:387
  • web-astro/scripts/evolution-flow-figures.mjs:28 · web-astro/scripts/training-workflows-figures.mjs:15 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — web-astro/scripts/evolution-flow-figures.mjs:28
  • chapter6/live-audio/frontend/pages/index.tsx:624 · chapter6/live-audio/frontend/pages/index.tsx:681 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — chapter6/live-audio/frontend/pages/index.tsx:624
  • REDACTED:178 · REDACTED:554 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — REDACTED:178
  • REDACTED:255 · REDACTED:591 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — REDACTED:255
  • web-astro/scripts/collaboration-society-figures.mjs:151 · web-astro/scripts/collaboration-society-figures.mjs:274 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — web-astro/scripts/collaboration-society-figures.mjs:151
  • web-astro/src/lib/highlight-store.ts:51 · web-astro/src/lib/highlight-store.ts:96 — the two spans are one implementation copied and then locally edited — 111 tokens are still identical, in the same order in both spans, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one. — web-astro/src/lib/highlight-store.ts:51
  • REDACTED:122 · REDACTED:142 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — REDACTED:122
  • web-astro/scripts/collaboration-society-figures.mjs:215 · web-astro/scripts/collaboration-society-figures.mjs:236 · web-astro/scripts/collaboration-society-figures.mjs:395 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. — web-astro/scripts/collaboration-society-figures.mjs:215
  • web-astro/scripts/computer-use-layout.mjs:14 · web-astro/scripts/evaluation-layout-kit.mjs:37 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — web-astro/scripts/computer-use-layout.mjs:14
  • web-astro/scripts/chapter3-figure-kit.mjs:7 · REDACTED:36 — the two spans are one implementation copied and then locally edited — 68 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one. — web-astro/scripts/chapter3-figure-kit.mjs:7
  • web-astro/scripts/evaluation-spectrum-figures.mjs:24 · REDACTED:20 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — web-astro/scripts/evaluation-spectrum-figures.mjs:24
  • REDACTED:79 · REDACTED:78 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — REDACTED:79
  • REDACTED:552 · REDACTED:821 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — REDACTED:552
  • REDACTED:138 · REDACTED:298 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — REDACTED:138
  • web-astro/scripts/collaboration-society-figures.mjs:73 · web-astro/scripts/collaboration-society-figures.mjs:166 · web-astro/scripts/collaboration-society-figures.mjs:291 — all 3 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — web-astro/scripts/collaboration-society-figures.mjs:73
  • REDACTED:342 · REDACTED:356 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — REDACTED:342

What to do

  • Act on each finding's own remediation rather than one rule: the move depends on what recurs. Where the copies are executable blocks, give the shared part one home and call it from each site; where they are declarations, a listing, a specialisation already delegating to its base, or one shape repeated per entity, there is no call site and the move is a shared type, a generated set or a factory — sometimes there is nothing to extract.
R11 · Import Boundaries9.3 / 10Exemplary✓ Tool-verified

React / JS · Architecture — Conformance to the detected frontend architecture layout (feature-sliced / layered src) plus cross-package deep-import rules (D-386).

Method: Conformance to the detected frontend layout (feature-sliced / layered src) plus cross-package deep-import rules, over the module graph. Deterministic.

  • chapter6/live-audio/frontend/pages/index.tsx:8 imports react-syntax-highlighter/dist/cjs/styles/prism, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead. — chapter6/live-audio/frontend/pages/index.tsx:8

What to do

  • Fix the listed violations: import through public entries (package exports / slice index), never reach into another layer or package's internals.
R2 · Cyclomatic Complexity6.5 / 10Adequate✓ Tool-verified

React / JS · Code Health — Per-function cyclomatic/cognitive complexity from the token-level function scanner (D-386) — real branching, not a regex heuristic.

Method: Per-function cyclomatic/cognitive complexity from a token-level function scanner (real branching, not a regex heuristic), computed over every frontend function. Deterministic.

  • walk has cyclomatic complexity 65 and cognitive complexity 57; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — REDACTED:15
  • (anonymous) has cyclomatic complexity 55 and cognitive complexity 127; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — web-astro/scripts/build.test.mjs:489
  • main has cyclomatic complexity 54 and cognitive complexity 97; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — slides/review.mjs:96
  • validateExperimentEvidence has cyclomatic complexity 50 and cognitive complexity 25; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — chapter6/live-audio/backend/experiment_validation.js:19
  • onmessage has cyclomatic complexity 39 and cognitive complexity 64; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — chapter6/live-audio/frontend/pages/index.tsx:139
  • translatePath has cyclomatic complexity 28 and cognitive complexity 34; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — REDACTED:94
  • validateLesson has cyclomatic complexity 28 and cognitive complexity 33; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — slides/generate.mjs:344
  • (anonymous) has cyclomatic complexity 27 and cognitive complexity 13; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — web-astro/src/lib/annotations.ts:57
  • rewriteSidebar has cyclomatic complexity 24 and cognitive complexity 58; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — REDACTED:354
  • Home has cyclomatic complexity 24 and cognitive complexity 20; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — chapter2/attention_visualization/frontend/pages/index.tsx:56
  • main has cyclomatic complexity 23 and cognitive complexity 28; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — slides/generate.mjs:476
  • (anonymous) has cyclomatic complexity 22 and cognitive complexity 29; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — REDACTED:616
  • (anonymous) has cyclomatic complexity 21 and cognitive complexity 50; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — web-astro/scripts/retrieval-workflow-layout.test.mjs:10
  • runLlm has cyclomatic complexity 21 and cognitive complexity 28; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — chapter6/live-audio/backend/run_real_validation.js:222
  • color has cyclomatic complexity 21 and cognitive complexity 27; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — web-astro/scripts/figure-style.mjs:33
  • detectLang has cyclomatic complexity 20 and cognitive complexity 26; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — REDACTED:31
  • isCompleteSentence has cyclomatic complexity 20 and cognitive complexity 22; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — chapter6/live-audio/backend/server.js:535
  • (anonymous) has cyclomatic complexity 20 and cognitive complexity 15; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — web-astro/src/scripts/highlights.ts:338
  • slugForPath has cyclomatic complexity 17 and cognitive complexity 24; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — extras/search-index-router.js:32

What to do

  • Break down the listed branch-heavy functions; aim P95 cyclomatic ≤ 5.
R3 · Large Files6.1 / 10Adequate✓ Tool-verified

React / JS · Code Health — How many source files exceed the large-file threshold.

Method: Components/modules exceeding the large-file threshold, counted exhaustively across the frontend source tree. Deterministic.

  • chapter6/live-audio/backend/server.js has 884 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — chapter6/live-audio/backend/server.js:1
  • slides/chapter1-pilot.mjs has 708 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — slides/chapter1-pilot.mjs:1
  • chapter6/live-audio/frontend/pages/index.tsx has 667 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — chapter6/live-audio/frontend/pages/index.tsx:1
  • REDACTED has 641 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — REDACTED:1
  • web-astro/src/scripts/highlights.ts has 529 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — web-astro/src/scripts/highlights.ts:1
  • slides/generate.mjs has 507 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — slides/generate.mjs:1
  • chapter2/attention_visualization/frontend/components/AttentionModal.tsx has 420 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — chapter2/attention_visualization/frontend/components/AttentionModal.tsx:1
  • chapter6/live-audio/backend/run_real_validation.js has 420 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — chapter6/live-audio/backend/run_real_validation.js:1
  • extras/agent-lab/agent-trajectory.js has 419 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — extras/agent-lab/agent-trajectory.js:1
  • extras/auto-translate.js has 410 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — extras/auto-translate.js:1

What to do

  • Split each oversized file along the responsibilities already in it, into smaller focused modules in the same package.
R4 · Test Coverage4.3 / 10Weak✓ Tool-verified

React / JS · Readiness — Static test reachability (D-386): the share of production files reachable from any test via the import graph — measured without running anything.

Method: Static test reachability: the share of production files reachable from any test via the import graph — measured without running anything. Deterministic.

  • No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one. (×40) — chapter6/live-audio/backend/server.js:1, slides/chapter1-pilot.mjs:1, chapter6/live-audio/frontend/pages/index.tsx:1, …

What to do

  • Add tests that import the unreached modules (directly or through their public entry).
R5 · Dependency Freshness9.8 / 10Exemplary✓ Tool-verified

React / JS · Readiness — How outdated the npm dependencies are (a maturity signal). JS/npm CVEs are scored separately in D30 (JS/npm Dependency Vulnerabilities).

Method: npm dependency staleness from manifest/registry metadata (a maturity signal; JS/npm CVEs are scored separately in D30, which answers dependency vulnerabilities for every ecosystem). Deterministic.

What to do

  • Bump outdated dependencies to current versions to limit upgrade debt.
R6 · Tooling10.0 / 10Exemplary✓ Tool-verified

React / JS · Readiness — Whether the project wires up test, lint and typecheck — detected from each REDACTED script's COMMAND (eslint / tsc / vitest / jest / playwright), not just its name, and corroborated against CI-workflow invocations so a tool run only in CI still counts.

Method: REDACTED scanned for test/lint/typecheck script wiring. Deterministic presence check.

R7 · Dead Code7.8 / 10Strong✓ Tool-verified

React / JS · Code Health — Files unreachable from every application/tooling/test entry point, and exports nothing imports (module-graph reachability, D-386).

Method: Dead code: files unreachable from every application/tooling/test entry point plus exports nothing imports, via module-graph reachability. Deterministic, exhaustive over the import graph.

  • 2 file(s) (~100 LoC) were excluded from dead-code analysis. This package DOES declare main/module/exports — but every declared target is missing from the scanned tree, which is what a build-output entry (dist/, lib/, out/) looks like before the package is built. Point a declared target at the source entry, or build the package before scanning, so reachability can follow it. — chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace
  • Unreachable from the 20 application, 15 tooling and 40 test entry point(s) detected in this repo. Gate removals on `npm run build` — an undetected custom entry would make these reachable.
  • no import path from any entry point (20 application, 15 tooling, 40 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make (×22) — REDACTED, web-astro/src/scripts/highlights.ts, extras/auto-translate.js, …
  • no import path from any entry point (20 application, 15 tooling, 40 test roots considered), but 1 in-repo import(s) from 1 other file(s) do name it (web-astro/src/scripts/highlights.ts) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it — web-astro/src/scripts/note-editor.ts
  • no import path from any entry point (20 application, 15 tooling, 40 test roots considered), but 2 in-repo import(s) from 2 other file(s) do name it (web-astro/src/scripts/highlights.ts, web-astro/src/scripts/note-editor.ts) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it — web-astro/src/lib/highlight-store.ts
  • no import path from any entry point (20 application, 15 tooling, 40 test roots considered), but 3 in-repo import(s) from 3 other file(s) do name it (web-astro/src/lib/book.ts, web-astro/src/scripts/highlights.ts, web-astro/src/scripts/note-editor.ts) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it — web-astro/src/lib/i18n.ts
  • Nothing imports this binding — it is safe to review for removal. — web-astro/src/scripts/reader-navigation.ts:119
  • This top-level declaration is not exported and its name occurs nowhere else in its module — not called, read, typed against, re-exported or named by a string. Nothing outside the module can reach a non-exported binding, so this is the whole search: remove it, or use it. — slides/chapter1-pilot.mjs:1

What to do

  • Delete the dead files and unused exports — every line is maintenance cost and rebuild-estimate inflation with zero runtime value.
R8 · Dependency Hygiene0.0 / 10Critical✓ Tool-verified

React / JS · Readiness — npm dependency truthfulness (D-386): unused dependencies, imports not declared anywhere, and type-/test-only packages shipped as production deps.

Method: npm dependency truthfulness: unused dependencies, imports declared nowhere, and type-/test-only packages shipped as production deps — from the manifest + import graph. Deterministic.

  • Imported but not declared in any reachable REDACTED — installs work only by hoisting accident. (×5) — web-astro/scripts/build.test.mjs:490, web-astro/scripts/book-math.test.mjs:10, web-astro/scripts/book-math.test.mjs:6, …
  • Declared in REDACTED but never imported anywhere in that package or its workspace members — no static import reaches it. Usually that is dead weight and attack surface, but two shapes are indistinguishable from source and are NOT dead: an optional or native peer that another dependency loads dynamically at runtime, and a package a build, docs or test step installs and invokes separately. Confirm which of the three this is before removing it. (×2)
  • Declared in chapter5/paper-to-ppt/package.json but never imported anywhere in that package or its workspace members — no static import reaches it. Usually that is dead weight and attack surface, but two shapes are indistinguishable from source and are NOT dead: an optional or native peer that another dependency loads dynamically at runtime, and a package a build, docs or test step installs and invokes separately. Confirm which of the three this is before removing it.

What to do

  • Remove unused dependencies, declare unlisted imports explicitly, and demote type-/test-only packages to devDependencies.
R9 · Circular Imports10.0 / 10Exemplary✓ Tool-verified

React / JS · Architecture — Import cycles in the module graph (D-386) — files that can only be understood and changed together.

Method: Import cycles in the module graph, detected exhaustively over JS/TS imports (the same cycle detection as the .NET coupling dimension). Deterministic.

S1 · Web-Security Posture8.0 / 10Strong✓ Tool-verified

Other · Security — Only what this repository's own non-C# files could be read for was assessed — markup this repository SHIPS is scored for third-party script integrity whether or not the repository serves it itself, since a page handed to a consumer runs in that consumer’s origin. Nothing else in this dimension was assessed: the transport, cookie, input-validation and crypto controls are read from a source model that was not loaded for this repository’s language, so their absence here is not a finding about this repository.

Method: Roslyn plus filesystem scan: HSTS/security headers, secure cookies, input validation, middleware order, weak crypto (MD5/SHA1/DES); HTTPS-metadata context-aware. On a repository with no .NET source it reads JavaScript/TypeScript, Dart, Ruby, Scala, Rust or Elixir source itself (test, vendored, generated and minified paths not) for the arms that hold whether or not the code serves HTTP: a weak hash or cipher, key material fixed in the source, a TLS client that accepts any certificate, and (JavaScript/TypeScript, Ruby, Scala, Rust and Elixir) an obsolete TLS version; the server controls are not assessed there, and a Dart, Ruby, Scala, Rust or Elixir repository that serves no HTTP of its own is N/A on them. Deterministic.

  • `https://d3js.org/d3.v7.min.js` is executed by this page with no Subresource Integrity. Whoever can answer that request — the CDN, anyone who compromises it, anyone on the network path — runs arbitrary script in this page's origin, with its session. The URL also names no version, so it resolves to whatever that origin serves at fetch time — the executed bytes can change with nobody touching this repository. — chapter7/elo-leaderboard/validation/runs/exp7-7-arena-20260731-v1/leaderboard_animation.html:7

What to do

  • Pin third-party scripts and verify them: name an exact version in the URL and add an `integrity="sha384-…"` hash alongside `crossorigin="anonymous"` (both are required — an integrity hash on a cross-origin script without `crossorigin` is not evaluated, it blocks the script). Where the vendor ships a continuously-updated loader and publishes no stable hash (tag managers, analytics, chat widgets), Subresource Integrity is not available: constrain it instead with a `Content-Security-Policy` that names the exact origins allowed to execute, and drop the script from the pages that do not need it. Where the page is shipped inside a package that others host, prefer vendoring the asset and serving it from the app’s own origin, so no consumer inherits a third-party dependency they did not choose.
X1 · Async correctness7.7 / 10Strong✓ Tool-verified

Other · Code Health — Whether the code avoids sync-over-async (deadlock-prone blocking on tasks) and async void.

Method: Roslyn syntax scan: async methods scanned for .Wait()/.GetAwaiter().GetResult() and async-void outside event handlers. Deterministic, hard fact per invocation.

  • The task this creates is not kept anywhere. The event loop holds only a weak reference to its tasks, so a task nobody references can be garbage-collected before it finishes (Python's documentation for `asyncio.create_task`: save a reference to the result); and nothing ever awaits it, so an exception it raises is never handled — it surfaces, if at all, as "Task exception was never retrieved" in a log. Keep the task: `await` it, gather it, start it in an `asyncio.TaskGroup` (`async with asyncio.TaskGroup() as tg: tg.create_task(…)`), or, for genuine fire-and-forget, add it to a set and `task.add_done_callback(tasks.discard)` with a callback that also reads its exception. (×9) — chapter9/browser-use-rpa/browser-use/browser_use/tokens/service.py:335, chapter9/browser-use-rpa/browser-use/browser_use/browser/session.py:1433, chapter9/browser-use-rpa/browser-use/browser_use/browser/session.py:1447, …
  • This `async def` runs on the event loop's thread, and `time.sleep` blocks that thread: for the whole delay no other coroutine, request or callback on the loop makes progress — the Python form of blocking on a task. Use `await asyncio.sleep(…)`, which suspends only this coroutine. Where the blocking work is not a sleep but a synchronous call that cannot be made async, move it off the loop with `await asyncio.to_thread(…)` (or `loop.run_in_executor(…)`). (×3) — REDACTED:193, REDACTED:216, REDACTED:247

What to do

  • Task from `asyncio.create_task` is not kept
X12 · Unreachable branch10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether any branch is dead by construction — a switch arm whose label can never equal a case-normalised subject, or an `else if` whose predicate the arm above has already swallowed.

Method: Roslyn syntax + semantics: switch labels compared against the subject's own case normaliser, and if/else-if chains checked for a literal an earlier arm's containment test already swallows. Deterministic, provable per finding. Advisory.

X13 · Undrained process stream10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a child process that has BOTH standard streams redirected drains both — reading one to the end while the other is never read deadlocks once the child fills the unread pipe.

Method: Roslyn syntax + semantics: ProcessStartInfo launches with both streams redirected, checked for a drain of each stream across the enclosing type. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `spawn` imported from `child_process` whose stdout and stderr are both pipes (no options, no `stdio`, or `stdio` of `'pipe'`), bound to a local that never leaves its scope, where exactly one of the two streams is read, the other never, and the child’s `close`/`exit` (or the read stream’s end) is awaited; a shell redirect in the call’s arguments or a `kill` of the child suppresses it. The same rule reads Python’s `subprocess.Popen`, Dart’s `Process.start`, Ruby’s `Open3.popen3`, and Scala’s JDK process starts (`new ProcessBuilder(…).start()` with no `redirectErrorStream`/`redirectError`/`redirectOutput`/`inheritIO`, `Runtime.getRuntime.exec`) where one of `getInputStream`/`getErrorStream` is read and the other never while `waitFor()` is called or the read stream is read to its end. Deterministic, provable per finding. Advisory.

X14 · Bypassable address classification10.0 / 10Exemplary○ Nothing flagged

Other · Security — Whether a hand-rolled public/private IP check can be walked past — a method that unwraps IPv4-mapped IPv6 but returns the opposite verdict for the same host written as IPv4-compatible, 6to4 or NAT64.

Method: Roslyn syntax + semantics: methods that unwrap IPv4-mapped IPv6 and hand-roll IPv4 range carve-outs, checked for whether the IPv6 branch also accounts for the IPv4-compatible, 6to4 and NAT64 embeddings. Deterministic, provable per finding. Advisory.

X15 · Unvalidated length from an untrusted reader10.0 / 10Exemplary○ Nothing flagged

Other · Security — Whether a length read out of the stream being parsed is bounded before it is allocated or read — an unchecked count taken from the input lets the input choose the allocation.

Method: Roslyn syntax + semantics: integer lengths read from a BinaryReader and spent on a bulk read or an array allocation, checked for any comparison or bounding call on the value anywhere in the method. Deterministic, provable per finding. Advisory.

X16 · Unfloored truncation loop10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a loop that shortens a string until it fits a length budget has a floor — one with none grinds the value down to the empty string, or past it into a negative-length `Substring`.

Method: Roslyn syntax + semantics: while/do loops whose body's only effect on a string is to drop its last character, checked for whether anything — a direct comparison on the length, a body guard, a break — bounds that length below. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `while`/`do` loop whose body’s one assignment to a value is `x = x.slice(0, -1)` or `x = x.slice|substring|substr(0, x.length - 1)`, driven by a condition that reads `x.length` only as a term of a larger expression — never compared directly, never tested for truthiness, and with no other read of `x` — and whose body has no `break`, `return`, `throw` or `if` naming `x`. Deterministic, provable per finding. Advisory.

X17 · Uncapped recursion over a caller-supplied document1.8 / 10Critical✓ Tool-verified

Other · Security — Whether a walk that recurses through a JSON/XML tree handed in by its caller bounds how deep it will go — an uncapped walk lets the document's nesting choose the stack depth, and the resulting StackOverflowException cannot be caught.

Method: Roslyn syntax + semantics: methods that take a JSON/XML document node and call themselves with a child of it, reachable from an externally-callable member of the same type that accepts a document, checked for any depth parameter, descent counter or threaded arithmetic anywhere in the walk. On a repository with no .NET source it reads TypeScript off the engine’s own token stream (test, vendored, generated and minified paths and `.d.ts` not) with the same rule: a function or method with a parameter typed as a document value — `unknown`, `any`, `object`, `Record<string, unknown|any>`, a JSON alias (`JsonValue`, `JSONObject`, …) or a DOM node global the file does not rebind — that calls itself (bare, or through `this` for a method, or hands itself to a call over the value as in `value.map(walk)`) with something it took out of that value and never through an ancestor accessor such as `closest()` or `parentElement`, that is exported or reached from an exported function (a public method of the same exported class) taking such a value, and that names no depth, level, nesting, recursion, remaining or budget anywhere and threads no `+`/`-` arithmetic through a self-call. Plain JavaScript is not read: with no annotation nothing tells a parsed document from a tree the code built itself. Deterministic, provable per finding. Advisory.

  • `record_completion` is public, takes a document from its caller (line 139) and hands it to `_jsonable`, which calls itself at line 61 (`_jsonable`) with a piece of `value` (and at line 63, line 65) — and nowhere in `_jsonable` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `_jsonable` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — chapter9/prompt-auto-optimization/config.py:61
  • `inspect_path_traversal` is public, takes a document from its caller (line 194) and hands it to `_extract_string_values`, which calls itself at line 188 (`self._extract_string_values`) with a piece of `obj` (and at line 191) — and nowhere in `_extract_string_values` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `_extract_string_values` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — chapter9/harness-safety-gate/safety_policy_gate.py:188
  • `expand_env` is public and takes `value: Any` from its caller, and it calls itself at line 45 (`expand_env`) with a piece of `value` (and at line 47) — and nowhere in `expand_env` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `expand_env` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — chapter7/model-benchmark/campaign.py:45
  • `scrub_value` is public and takes `value: Any` from its caller, and it calls itself at line 69 (`scrub_value`) with a piece of `value` (and at line 71) — and nowhere in `scrub_value` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `scrub_value` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — chapter6/computer-use-open-model/main.py:69
  • `json_safe` is public and takes `value: Any` from its caller, and it calls itself at line 52 (`json_safe`) with a piece of `value` (and at line 54, line 56) — and nowhere in `json_safe` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `json_safe` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — chapter6/claude-computer-use-native/run_weather_task.py:52
  • `redacted` is public and takes `value: Any` from its caller, and it calls itself at line 91 (`redacted`) with a piece of `value` (and at line 94) — and nowhere in `redacted` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `redacted` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — chapter6/agent-with-event-trigger/unipile_mailbox_experiment.py:91
  • `account_email` is public and takes `account: dict[str, Any]` from its caller, and it calls itself at line 273 (`account_email`) with a piece of `account` — and nowhere in `account_email` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `account_email` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — chapter6/agent-with-event-trigger/unipile_mailbox_experiment.py:273
  • `jsonable` is public and takes `value: Any` from its caller, and it calls itself at line 73 (`jsonable`) with a piece of `value` (and at line 75) — and nowhere in `jsonable` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `jsonable` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — chapter5/erp-agent/campaign_postgres.py:73
  • `convert_expression` is public and takes `node: Any` from its caller, and it calls itself at line 63 (`convert_expression`) with a piece of `node` (and at line 68, line 69) — and nowhere in `convert_expression` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `convert_expression` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — REDACTED:63
  • `redact_material` is public and takes `value: Any` from its caller, and it calls itself at line 160 (`redact_material`) with a piece of `value` (and at line 162) — and nowhere in `redact_material` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `redact_material` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — chapter4/collaboration-tools/run_experiment_4_5.py:160
  • `parse_value` is public and takes `value: Any` from its caller, and it calls itself at line 198 (`parse_value`) with a piece of `value` — and nowhere in `parse_value` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `parse_value` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — chapter4/collaboration-tools/run_experiment_4_5.py:198
  • `jsonable` is public and takes `value: Any` from its caller, and it calls itself at line 53 (`jsonable`) with a piece of `value` (and at line 55, line 57, line 59) — and nowhere in `jsonable` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `jsonable` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — chapter3/experiment_utils.py:53
  • `hash_item` is public and takes `item: Any` from its caller, and it calls itself at line 52 (`hash_item`) with a piece of `item` (and at line 56, line 60, line 63, line 70) — and nowhere in `hash_item` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `hash_item` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — chapter2/prompt-engineering/tau_bench/model_utils/api/cache.py:52
  • `dict_equal` is public and takes `d1: dict` from its caller, and it calls itself at line 35 (`dict_equal`) with a piece of `d1` — and nowhere in `dict_equal` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `dict_equal` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — chapter2/prompt-engineering/tau_bench/model_utils/api/datapoint.py:35
  • `prep_for_json_serialization` is public and takes `obj: Any` from its caller, and it calls itself at line 20 (`prep_for_json_serialization`) with a piece of `obj` (and at line 22, line 24, line 26, line 28) — and nowhere in `prep_for_json_serialization` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `prep_for_json_serialization` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — chapter2/prompt-engineering/tau_bench/model_utils/api/logging.py:20
  • `iter_values` is public and takes `value: Any` from its caller, and it calls itself at line 31 (`iter_values`) with a piece of `value` (and at line 34) — and nowhere in `iter_values` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `iter_values` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — chapter2/agent-skills-ppt/validate_official_run.py:31

What to do

  • Each finding names the externally-callable member that accepts the document and the self-call that descends, and states that no depth parameter or counter exists anywhere in the walk. Confirm from the two, then thread a depth argument through the walk and reject documents past a fixed maximum, or rewrite it with an explicit stack.
X18 · Disposal-pattern correctness10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a type's disposal matches what it OWNS — releasing what it created, leaving alone what it was handed, and not declaring a finalizer for state that has nothing unmanaged to finalize.

Method: Roslyn syntax + semantics: every assignment to a disposable field is read to decide whether the type CREATED the value or was handed it, and the type's disposal is checked against that answer — an injected interface it disposes, a value it constructed and never releases, a finalizer on a type holding nothing unmanaged, and a disposable local whose every reference is a plain member read. A value handed to a container that disposes its contents (a parent control's `Controls` collection, a component `IContainer`) is released by that container and is not reported; generated code is out of population. On a repository with no .NET source the same ownership questions are read in JavaScript/TypeScript off the engine’s own token stream (test, vendored, generated and minified paths not): a class declaring `dispose()`, `[Symbol.dispose]()` or `[Symbol.asyncDispose]()` that disposes a field it was handed through a constructor parameter typed as a repository interface or resolved by a dependency-injection container; that assigns a field only ever from `new X(…)` of a disposable class and neither releases it anywhere in the class nor names it in its disposal member or a method that member calls, nor hands it to anything else; and a `const`/`let` local built from literals only whose every reference opens a statement operating on a non-release member of it. A class is disposable when every repository declaration of its name declares or inherits a disposal member, or when it is a documented library disposable (`vscode` EventEmitter, CancellationTokenSource and Disposable; three.js geometries, materials, textures, render targets, renderers, controls and composers). The finalizer arm has no JavaScript counterpart: a class cannot declare one. Dart is read for the owned-and-never-released arm: a Flutter `State` (or a class declaring `dispose()`/`close()`) whose library-private field is written only with direct creations of a framework controller, `FocusNode`, `StreamController` or periodic `Timer` (or a `.listen(…)` into a field declared `StreamSubscription`), which nothing in the class or its library releases (`dispose`/`close`/`cancel`) and which is never handed on except as a named argument. Ruby is read for the owned-and-never-released arm and the abandoned-local arm: a class declaring an instance `close`, `dispose`, `shutdown`, `stop`, `disconnect` or `terminate` whose instance variable is written only with a blockless core descriptor creation (`File.open`/`new`, `Tempfile`, `Dir.open`, `IO.popen`, the `socket` and `openssl` socket classes) that no method of the class closes and that is never handed on (passed, returned, stored, exposed by `attr_reader`, delegated) — a class whose superclass or mixin lies outside the repository is not judged — and a blockless creation read through and dropped (`File.open(path).read`) or held in a local that is never closed, returned, passed or stored (a `&:read` block-pass, an `autoclose: false` borrow and a `fileno` hand-over are not abandonment). PHP is read for the same two arms: a class (not a trait, and not one using a trait) declaring an instance `close`, `dispose`, `shutdown`, `stop`, `disconnect` or `terminate` whose `private` property (or a `final` class's `protected` one) is written only with a direct core `fopen`, `tmpfile`, `popen`, `proc_open`, `fsockopen`, `stream_socket_client`/`server` or `opendir` that nothing in the class closes (`fclose`, `pclose`, `closedir`, `unset`, a reset to `null`) and that is never handed on, and a handle held in a function's local, or read through as the argument of a reader, that is never closed, returned, passed, captured or stored; a `php://` stream, `curl_init`, `SplFileObject`, `PDO` and a function the repository declares under the core name are not read. Deterministic, provable per finding. Advisory.

X19 · Unrestored process-global state10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a method that temporarily changes state belonging to the whole process — the working directory, an environment variable — puts it back on EVERY path: a restore reached only when nothing throws leaks the change to the rest of the process.

Method: Roslyn syntax + semantics: method bodies that write the process working directory or an environment variable and write it back in the same body, checked for whether that restore sits in a `finally`/`catch` or only on the straight-line path. On a repository with no .NET source the same rule reads production JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not): `process.chdir`, `process.env.NAME =`/`["NAME"] =` and `delete process.env.NAME`, and Deno’s `Deno.chdir`/`Deno.env.set`/`Deno.env.delete`, paired per function body (a nested function or arrow is its own body, and module top-level code is none), where the last write puts back a local the body captured from the same global or deletes a variable the first write set, with at least one statement between them; a write in a `catch`/`finally` of that body silences it. Deterministic, provable per finding. Advisory.

X2 · Cancellation propagation6.7 / 10Adequate✓ Tool-verified

Other · Code Health — Whether async functions that make a cancellable request accept or pass on an AbortSignal (adoption curve).

Method: Roslyn scan: every async method (excluding framework-fixed overrides/Blazor handlers) checked for CancellationToken parameter presence. Deterministic, adoption percentage. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same question: every named async function that itself makes a request an AbortSignal can cancel (global `fetch`, axios and its file-local instances, ky, ofetch) counts, and it is compliant when its parameters or body name a signal or it hands one of its own parameters to the request as options; signatures a framework fixes (JSX event handlers, route and lifecycle exports, request-first handlers, `override`, `'use server'` modules, TanStack `mutationFn`) are exempt unless they take a signal. Deterministic, adoption percentage.

  • Only 5/11 async functions that make a cancellable request (fetch, axios, ky, ofetch, got, undici, node:http) accept an AbortSignal or pass one on, so a request keeps running after whatever wanted it has given up — a page navigated away from, an unmounted component, a timed-out job. Take a `signal` (or an options object that carries one) and hand it to the request; where nothing could ever cancel the call, omitting it is a deliberate choice — judge against how the function is used.
  • `_load` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`. — extras/agent-lab/agent-trajectory.js:298
  • `startCall` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`. — chapter6/phone-agent/static/app.js:130
  • `runTts` awaits `axios.post(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axios.post(url, { signal })`. — chapter6/live-audio/backend/run_real_validation.js:315
  • `transcribe` awaits `axios(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axios(url, { signal })`. (×2) — chapter6/live-audio/backend/utils/providers/asrProviders.js:64, chapter6/live-audio/backend/utils/providers/asrProviders.js:154
  • `loadTrajectories` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`. — chapter2/attention_visualization/frontend/pages/index.tsx:68

What to do

  • Thread an AbortSignal through async functions that make requests, so the work stops when its caller gives up.
X21 · Side-effecting pattern guard10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a `when` guard is free of side effects — a guard that increments a counter or assigns while deciding whether its arm matches applies that change during PATTERN MATCHING, on an arm that may not be selected, and skips it entirely when a short-circuit to its left answers first.

Method: Roslyn syntax: `when` guards on case labels and switch-expression arms, read for a mutation (`++`/`--`/assignment) sitting in a position the guard's own `&&`/`||`/`??`/`?:`/`?.` can skip. Deterministic, provable per finding. Advisory.

X22 · Contradicted release guard10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a method that TAKES a lock or semaphore and gives it back from a flag-guarded `finally` returns the value that flag implies — reporting success while the guard hands the primitive back admits a second caller the exclusion was there to keep out, and reporting failure while the guard keeps it leaves nothing to ever give it back. Also whether a `finally` that gives the primitive back unconditionally can run in a state where the method does not hold it: after a timed wait whose result was discarded, after an acquire inside the `try` that can fail, after the body already released it, or never, because a `return` left between the acquire and the `try`.

Method: Roslyn syntax: `try` statements whose `finally` releases a synchronisation primitive under a bare local-bool guard, where the method also TOOK that same primitive before the `try`, checked for a `return` of a bool literal whose value disagrees with the flag state the method's own straight-line assignments put it in. Deterministic, provable per finding. Advisory.

X23 · Unguarded diagnostic materialisation7.8 / 10Strong✓ Tool-verified

Other · Code Health — Whether the work a diagnostic log line costs is paid only when that line is wanted — C# evaluates a call's arguments BEFORE the call, so a trace/debug message joined or projected out of a collection is built in full on every pass, and then discarded by a sink the shipped configuration leaves switched off.

Method: Roslyn syntax: log calls at a diagnostic level (a `Log`-prefixed method naming Trace/Debug/Verbose, or a bare `Debug`/`Trace`/`Verbose` on a receiver named for a logger), whose argument list is read for a call whose cost scales with a sequence — a LINQ operator, a materialisation, `string.Join`, a serializer — with no enclosing level check or conditional-compilation region. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `debug`/`trace`/`verbose` call on a receiver named for a logger, or a `log`-prefixed method naming the level, whose argument calls an array operator (`map`/`filter`/`reduce`/`sort`/…), `Array.from`, `Object.keys/values/entries`, `JSON.stringify`/`util.inspect` over anything but a literal, or an array `join` — outside any arrow or function passed as an argument, which the logger calls only when the level is on — with no enclosing `if`, `&&` or `?:` whose condition names a level, a level string, or the `NODE_ENV`/`__DEV__`/`DEV` build switch. Deterministic, provable per finding. Advisory.

  • `debug` at line 921 is called with an argument built by `"…".join(loaded_extension_names)` (line 921), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on. — REDACTED:921
  • `debug` at line 336 is called with an argument built by `[f.name for f in files_before]` (line 336), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on. — chapter9/browser-use-rpa/browser-use/browser_use/browser/watchdogs/downloads_watchdog.py:336
  • `debug` at line 2042 is called with an argument built by `[t.name for t in threads]` (line 2042), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on. — REDACTED:2042
  • `debug` at line 240 is called with an argument built by `"…".join(changes)` (line 240), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on. — chapter3/retrieval-pipeline/reranker.py:240
  • `debug` at line 72 is called with an argument built by `list(metadata.keys())` (line 72), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on. — chapter3/dense-embedding/document_store.py:72

What to do

  • In Python, put the construction behind the logger's own check (`if logger.isEnabledFor(logging.DEBUG):`), or pass the collection itself with a `%s` placeholder (`logger.debug("Items %s", items)`) so the logging module renders it only when the record is emitted. The placeholder alone is not the fix when the argument is still built first: it defers the formatting, not a `json.dumps`, a `join` or a comprehension in the argument, and an f-string defers nothing at all.
X24 · Document value interpolated into markup unescaped10.0 / 10Exemplary○ Nothing flagged

Other · Security — Whether text read out of the document being converted is escaped before it is written into generated markup — a value the document's author chose, interpolated into an attribute the surrounding literal delimits, can close that attribute and open another.

Method: Roslyn semantic model over the whole compilation: a string-typed `Value`/`InnerText`/`InnerXml`/`Text` member declared inside `DocumentFormat.OpenXml` or `System.Xml` is a taint SOURCE, propagated through assignments, returns, arguments, tuple elements and string composition to its transitive closure, then read at interpolated-string holes that sit in a markup position the surrounding literal itself delimits. Escaper/encoder calls and enclosing validator conditions cut the flow. Flow- and container-insensitive by construction. A second arm needs no provenance at all and reports a type that CONTRADICTS ITSELF — the same expression escaped at one delimited markup hole and interpolated raw at another hole in the same markup position of the same type, which the type's own escaping proves is a defect without knowing where the value came from. On a repository with no .NET source it reads JavaScript/TypeScript off the token stream with the same rule: a DOM read of raw document text (`getAttribute`, `textContent`, `innerText`, `nodeValue`) is the source, propagated through local bindings and string composition, and judged at template-literal and concatenation holes in the same two delimited markup positions; escapers and validating conditions cut it, and documentation-site, test, vendored and minified scripts are not read. Deterministic, provable per finding. Advisory.

X25 · Inert configuration knob10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a value the caller is invited to supply is the value the type actually uses — a constructor parameter stored in a private field that nothing ever reads while the default it was given is spelled out a second time at the site that should have read it, a keyed lookup that falls back to a different setting than the one its key names while the same type falls back to the matching one for that same key, or a culture-sensitive parse given no format provider by a type that feeds its own settable culture to the same kind of parse elsewhere, or a number an entry point writes to standard output under the host's culture while the same entry point formats with the invariant culture elsewhere. Either way, every caller who supplies a value silently gets something else.

Method: Roslyn syntax: private instance fields of a non-partial type assigned in a constructor from one of its own parameters with a `??` fallback, checked for whether anything in the type body reads the field and whether that same fallback expression is spelled out again outside the constructor; and `??` fallbacks onto a member access from a lookup call carrying exactly one string literal, grouped by that key across the type and checked for a fallback member whose folded name disagrees with the key while a sibling site for the same key agrees with it. On a repository with no .NET source the first two arms read JavaScript/TypeScript off the engine’s own token stream (tests included, bundles and vendored paths not): a `#x`, `private` or `private` parameter-property instance field filled in the constructor from a parameter (or one member of one) through `??`/`||` or a parameter default, never read anywhere in the file by name, whose constructed default is spelled again in the class body; and `lookup("key") ?? s.member` grouped by key per class, or per module outside every class. The culture arm has no JavaScript counterpart: its parses take no locale. Deterministic, provable per finding. Advisory.

X26 · Unsynchronised callback handoff10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a value handed from a callback to the body that waits on it crosses on something built to be crossed — a `Queue<T>`/`List<T>`/`Dictionary<K,V>` written inside an event handler and read back outside it is mutated by two flows at once, and the semaphore or completion source beside it orders how MANY items exist while leaving the collection's own head, tail and backing array unprotected.

Method: Roslyn syntax: method, accessor, local-function and lambda bodies that declare BOTH a non-thread-safe generic collection (`Queue`/`Stack`/`List`/`Dictionary`/`HashSet`/`Sorted*`/`LinkedList`) and a synchronisation primitive (`SemaphoreSlim`/`TaskCompletionSource`/`ManualResetEvent(Slim)`/`AutoResetEvent`/`CountdownEvent`) as locals, then read for a `+=`-registered lambda that raises that primitive while the body outside every lambda waits on it — and, in that scope, a mutating call on the collection inside the lambda paired with a mention of it outside. Any `lock` in the scope abstains it. On a repository with no .NET source the same handoff is read in Java off the engine’s own token stream (test source sets, vendored and demonstration paths not): an `ArrayList`/`LinkedList`/`ArrayDeque`/`PriorityQueue`/`Hash*`/`LinkedHash*`/`Tree*` local and a `CountDownLatch`/`Semaphore`/`CompletableFuture` local, a lambda or anonymous class that raises the primitive and mutates the collection, and a wait outside it; any `synchronized` or `lock()` abstains the body. Because each of those primitives orders what the callback wrote before raising it, only a touch that provably overlaps the callback is convicted: one after the registration and before the next wait, or one in a loop registered-before, waiting on every pass and not declaring the collection. Deterministic, provable per finding. Advisory.

X27 · Collection changed while being enumerated10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a `for` loop leaves the `dict`, `set` or `deque` it is walking alone — CPython's iterators over those check that the collection has not changed size since the loop began, so a body that removes from (or empties) the very collection the loop is walking makes the next step raise `RuntimeError: dictionary changed size during iteration` and the remaining items are never seen.

Method: Roslyn syntax + semantics: `foreach` statements whose body calls a structural mutator (`Add`/`Remove`/`Clear`/`Insert`/…) on the very expression the loop is enumerating. Two arms. ARM A — the source is a concrete fragile BCL collection, or a live `Keys`/`Values` view over one, and the mutator resolves to that same collection's own member; concurrent and immutable collections and arrays are outside the population by construction, since their enumerators survive a structural change. ARM B — the source is an argument-less accessor CALL on a receiver whose body is in source: the accessor must return a stored field VERBATIM and a sibling member must structurally change that same field, both read off the implementations rather than from the members' names. A mutation the loop provably exits immediately after (`break`/`return`/`throw`/`goto`), or one written inside a nested loop or a lambda, is counted and never reported. Deterministic, provable per finding. Advisory.

X28 · Index access outside its own emptiness guard10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a condition that tests a value for emptiness indexes that same value only where the test holds — an `||` written one parenthesis too far to the left leaves an index access outside the guard beside it, so the empty case the guard exists to anticipate reaches the index and throws.

Method: Roslyn syntax only, no semantic model: the OUTERMOST `&&`/`||` of every boolean condition, read for a symbol the condition tests for emptiness (`string.IsNullOrEmpty`/`IsNullOrWhiteSpace`, a `Length`/`Count` comparison against a literal, `Any()`, a `Length`/`Count` pattern, or a comparison against `""`) and ALSO indexes. Each `symbol[...]` access is placed by a boolean-reachability walk from the access up to the outermost connective: an access is COVERED when some enclosing step has it in the right operand and the left operand, under the truth value that step forces, proves the symbol non-empty — a recursion over `&&`/`||` whose true- and false-directions are asymmetric. A finding needs BOTH an uncovered access and a covered one on the same symbol in the same condition, which is the agreeing twin that separates a misplaced parenthesis from an unrelated length test. Bare index accesses with no emptiness test in the condition are neither counted nor reported; a non-identifier receiver and a lambda nested inside the condition are outside the population. Deterministic, provable per finding. Advisory.

X29 · Per-element action decided by a fixed element10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a decision taken once per element is taken ABOUT that element — a test inside a counted loop that reads a fixed subscript of the very collection its guarded statement indexes by the loop variable applies element zero's answer to all of them, so the elements that differ from it are all handled wrongly, and in the same direction.

Method: Roslyn syntax only, no semantic model: every `for` statement declaring exactly ONE loop variable, and every `if` inside its body that is not under a nested loop or a lambda. A site enters the population when the `if`’s condition never mentions the loop variable while the statement it guards indexes some collection by that variable ALONE (`c[i]`; `c[i + 1]` and `c[i, j]` are outside it). A finding additionally needs the AGREEING TWIN at the same-collection grain: the condition must read THAT SAME collection at a subscript that does not move — written into the condition, or reached through a local declared BEFORE the loop, so an alias bound inside the body is not followed. Both collection expressions must be simple identifiers. On a repository with no .NET source the same rule reads JavaScript/TypeScript off the engine’s own token stream (tests included, bundles and vendored paths not): a `for (let|var|const x = …; …; …)` with one declarator and a braced body, an alias followed only when it is declared before the loop in a block that encloses it and never assigned inside the loop. Deterministic, provable per finding. Advisory.

X3 · Exception handling6.2 / 10Adequate✓ Tool-verified

Other · Code Health — Whether exceptions are handled rather than silently swallowed or rethrown with lost stack traces.

Method: Roslyn syntax scan: every catch clause counted; empty catches and bare rethrows flagged. Population is all catch clauses, not estimated. Deterministic, hard fact.

  • An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it. (×19) — web-astro/src/scripts/reading-position.ts:61, scripts/gen_star_history.py:92, extras/auto-translate.js:55, …
  • `.catch(() => {})` handles the rejection by doing nothing — the failure is discarded with no log and no rethrow, and the chain carries on as if the work succeeded. Log it through whatever this codebase already uses to report problems, hand it to a caller that can (`next(error)`, a returned rejection), or don't catch it. — web-astro/src/scripts/reading-position.ts:75
  • `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter. (×18) — chapter9/self-modifying-agent/evolution.py:224, REDACTED:49, REDACTED:100, …
  • `except (Exception, SystemExit)` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter. — REDACTED:154
  • An empty catch block silently discards the error — failures vanish with no log and no rethrow. On a teardown path letting it propagate is not an option (throwing out of `close()` masks the failure already in flight and abandons the rest of the cleanup), so make the swallow deliberate instead: narrow the catch to the exception this release can actually raise, and record it through whatever this codebase already uses to report problems — or, if it truly cannot matter, say why in a comment on the catch. — chapter9/browser-use-rpa/browser-use/browser_use/logging_config.py:279

What to do

  • Swallowed exception (empty catch)
X30 · Support guard that admits what it rejects10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a guard written as a NEGATED `||` says what its author meant — `!(a || b || x != k)` is `!a && !b && x == k` by De Morgan, so a bail-out that mixes capabilities the code needs with a fault it refuses turns inside out: it fires only where the capabilities are ABSENT, and lets every value the fault term names walk straight into the body that cannot handle it.

Method: Roslyn syntax only, no semantic model: every logical-not whose operand is a parenthesised `||` chain of two or more disjuncts, flattened (a left-nested `a || b || c` read once would see `(a || b)` as one disjunct). A site enters the population on that shape alone. A finding additionally needs the disjuncts to DISAGREE in polarity: at least one bare boolean read — an identifier or member access, never an invocation, which is a predicate rather than a capability flag — and at least one `x != <constant>`, the only form that negates into an exact-value pin (`== null` negates into a looser requirement and is outside the fault set). Consistently-polarised disjunctions, all-fault or all-capability, are counted and never reported; a negated `&&` is outside the population entirely. No same-receiver gate: it was measured to cost a real defect and remove no false positive. Deterministic, provable per finding. Advisory.

X4 · Structured logging2.5 / 10Weak✓ Tool-verified

Other · Code Health — Whether log calls use message templates (queryable) rather than interpolated strings.

Method: Roslyn syntax scan: every log call-site counted; interpolated-string first-argument violations flagged. Population is all log calls, not estimated. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `trace`/`debug`/`info`/`warn`/`error`/`fatal`/`verbose`/`silly`/`http`/`log` call on a receiver named for a logger, in a package whose own or an enclosing `REDACTED` declares a logger that carries values as fields (pino, pino-http, nestjs-pino, Fastify, winston, bunyan, tslog, LogTape, roarr), whose first deciding argument is a template literal with substitutions; an object-literal fields argument is stepped over, a plain string message clears the call. Python is read the same way: a `debug`/`info`/`warning`/`error`/`exception`/`critical`/`log` call on a logger in a file that imports the standard library’s `logging` or structlog (loguru, which formats at the call, is not judged), whose message is a whole f-string with a non-constant field; a `%`-formatted, `.format()`-ed or concatenated message is not convicted, as in C#. PHP is read the same way: a PSR-3 level call (`emergency`…`debug`, `log`) on a logger (`$logger`, `$this->logger`, Laravel’s `Log::`, `logger()`, `\Drupal::logger()`) in a package whose `composer.json` requires a PSR-3 logger or a framework that hands one out (psr/log, Monolog, Laravel, Symfony, Drupal, CakePHP), or a file that imports one, whose message is a double-quoted string interpolating a variable; a single-quoted message clears the call, and `sprintf` or `.` concatenation is not convicted, as in C#. Dart is read the same way: a `trace`/`debug`/`info`/`warn`/`error`/`fatal` call on Sentry’s structured logger (`Sentry.logger`) whose message is a whole string literal interpolating a value (`$name`, `${…}`); the `Sentry.logger.fmt` template API clears the call. Dart that logs only through loggers with one message and no fields (package:logging, package:logger, talker, dart:developer) is not applicable rather than a reach gap. Ruby is read the same way: a `trace`/`debug`/`info`/`warn`/`error`/`fatal` call on the console gem’s `Console` (declared by a Gemfile, gemspec or Gemfile.lock, or required) or, where SemanticLogger, Ougai or dry-logger is declared or required, on a receiver named for a logger (`logger`, `@logger`, `Rails.logger`, `log`), whose first deciding argument is, as the whole argument, a double-quoted string interpolating a non-constant value (`#{…}`, `#@ivar`); a plain literal clears the call, keyword arguments are the fields, and a block, `%`-format or `+` concatenation is not convicted. Ruby that logs only through the standard Logger (Rails.logger) is not applicable rather than a reach gap. Deterministic.

  • `debug` at line 142 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.debug("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.debug("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/learning_agent/agent.py:142
  • `error` at line 145 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/learning_agent/agent.py:145
  • `error` at line 245 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/learning_agent/agent.py:245
  • `error` at line 279 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/learning_agent/agent.py:279
  • `info` at line 301 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/learning_agent/agent.py:301
  • `info` at line 303 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/learning_agent/agent.py:303
  • `info` at line 343 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/learning_agent/agent.py:343
  • `info` at line 344 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/learning_agent/agent.py:344
  • `info` at line 346 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/learning_agent/agent.py:346
  • `info` at line 347 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/learning_agent/agent.py:347
  • `info` at line 376 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/learning_agent/agent.py:376
  • `error` at line 563 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/learning_agent/agent.py:563
  • `info` at line 90 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/learning_agent/knowledge_base.py:90
  • `error` at line 144 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/learning_agent/knowledge_base.py:144
  • `info` at line 146 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/learning_agent/knowledge_base.py:146
  • `info` at line 299 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/learning_agent/knowledge_base.py:299
  • `info` at line 115 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/learning_agent/replay.py:115
  • `info` at line 121 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/learning_agent/replay.py:121
  • `error` at line 152 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/learning_agent/replay.py:152
  • `info` at line 160 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/learning_agent/replay.py:160
  • `warning` at line 247 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.warning("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.warning("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/learning_agent/replay.py:247
  • `debug` at line 271 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.debug("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.debug("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/learning_agent/replay.py:271
  • `debug` at line 281 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.debug("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.debug("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/learning_agent/replay.py:281
  • `debug` at line 304 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.debug("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.debug("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/learning_agent/replay.py:304
  • `debug` at line 319 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.debug("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.debug("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/learning_agent/replay.py:319
  • `error` at line 582 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/browser-use/browser_use/cli.py:582
  • `debug` at line 591 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.debug("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.debug("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/browser-use/browser_use/cli.py:591
  • `error` at line 595 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/browser-use/browser_use/cli.py:595
  • `error` at line 605 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/browser-use/browser_use/cli.py:605
  • `error` at line 616 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/browser-use/browser_use/cli.py:616
  • `error` at line 742 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/browser-use/browser_use/cli.py:742
  • `debug` at line 759 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.debug("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.debug("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/browser-use/browser_use/cli.py:759
  • `debug` at line 761 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.debug("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.debug("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/browser-use/browser_use/cli.py:761
  • `debug` at line 802 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.debug("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.debug("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/browser-use/browser_use/cli.py:802
  • `error` at line 1091 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/browser-use/browser_use/cli.py:1091
  • `info` at line 1504 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/browser-use/browser_use/cli.py:1504
  • `debug` at line 1525 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.debug("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.debug("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/browser-use/browser_use/cli.py:1525
  • `debug` at line 1527 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.debug("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.debug("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/browser-use/browser_use/cli.py:1527
  • `error` at line 1531 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/browser-use/browser_use/cli.py:1531
  • `error` at line 1540 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog. — chapter9/browser-use-rpa/browser-use/browser_use/cli.py:1540

What to do

  • Interpolated log message defeats structured logging
X5 · Nullable reference types4.1 / 10Weak✓ Tool-verified

Other · Code Health — Whether strict null checking is enabled and not undermined by heavy `!` assertion — TypeScript's `strictNullChecks` (which `strict` turns on) is what makes `string` exclude `null` and `undefined`, and the postfix `!` is the operator that silences it.

Method: Roslyn compiler-options scan: NullableContextOptions per project; null-forgiving (!) suppression density per 1k syntax nodes. Deterministic, adoption plus suppression penalty.

  • 1/2 of this repository's type-checking configuration(s) turn on strict null checking (`"strict": true`, or `"strictNullChecks": true`). A configuration that states neither is counted as OFF, because off is tsc's own default; a solution-style one whose `"files"` is empty and whose `"references"` point at other projects is in neither number, because it checks no source itself. Where it is off, `string` admits `null` and `undefined`: passing a value that is null compiles silently and throws on the first property access.
  • ~8.0 `!` null assertions per 1k TypeScript source lines — 34 assertion(s) across the 4240 source line(s) of the 25 TypeScript file(s) read, which is the only code the operator asserts anything in (a `!` in a `.js` file is not this operator and was not counted, and one in a file whose null checking is off silences nothing). Densest: web-astro/src/scripts/reading-position.ts (23), web-astro/src/scripts/highlights.ts (8), web-astro/src/scripts/figure-viewer.ts (2). Each one tells the compiler to trust the author about null, suppressing the very diagnostic `strictNullChecks` exists to produce.

What to do

  • The findings name the configuration each number was taken from and, for the assertions, the files that hold them. Turn null checking on where it is off — `"strict": true` in the base tsconfig that the others extend switches `strictNullChecks` on with the rest of the family — and then resolve the assertions rather than adding to them. A `!` on a value the checker could show to be null is a promise the author cannot check from where they are standing, and each one is a `TypeError: Cannot read properties of null` waiting for the path that makes it true; where the value genuinely cannot be null, say something the checker can see instead (narrow it with a test, make the property required, drop the `?`).

WCAG coverage — what static analysis assessed

Statically assessed 15 of 55 WCAG 2.2 Level A/AA success criteria (27%; ≈30% of the 50 WCAG 2.1 AA criteria for EN 301 549). The other 40 require runtime or manual evaluation. Partial signal only (a clean result is necessary, not sufficient; static analysis fully verifies none). This is accessibility readiness, not a conformance claim — a WCAG conformance claim requires manual evaluation (WCAG-EM 1.0).

DimensionWCAG 2.2 A/AA criteriaCoverage
AC1 · Text alternatives1.1.1, 1.2.2, 1.2.5Partial signal
AC2 · Forms & labels1.3.1, 3.3.2, 4.1.2Partial signal
AC3 · Page structure1.4.4, 2.2.1, 2.4.1, 2.4.2, 3.1.1, 4.1.2Partial signal
AC4 · Keyboard semantics2.1.1, 2.4.3Partial signal
AC5 · ARIA correctness4.1.2Partial signal
AC6 · Visual & motion safety1.4.3, 2.4.7Partial — literal CSS only
AC7 · A11y enforcementenforcement — no page criterionEnforcement posture (process)

Not statically assessed — these 40 Level A/AA criteria need runtime or manual evaluation (WCAG-EM): 1.2.1, 1.2.3, 1.2.4, 1.3.2, 1.3.3, 1.3.4, 1.3.5, 1.4.1, 1.4.2, 1.4.5, 1.4.10, 1.4.11, 1.4.12, 1.4.13, 2.1.2, 2.1.4, 2.2.2, 2.3.1, 2.4.4, 2.4.5, 2.4.6, 2.4.11, 2.5.1, 2.5.2, 2.5.3, 2.5.4, 2.5.7, 2.5.8, 3.1.2, 3.2.1, 3.2.2, 3.2.3, 3.2.4, 3.2.6, 3.3.1, 3.3.3, 3.3.4, 3.3.7, 3.3.8, 4.1.3.

Reference — by lens

The score is the rank-weighted fold of these lenses (worst-heaviest), each including its meta-dimensions; a lens with a Critical contributor is capped at Fair (its band reads "gated by …") and is never the strongest area however high its average.

LensScoreRatingImpact
Code Health42%Weak — gated by D2, R1, X4Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Architecture97%ExemplarySolid.
Maturity74%StrongSolid.
Readiness14%Critical — gated by D12, D13, R8, P3, P5, P7Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Security64%Adequate — gated by D28, D29, D30, D31, D36Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Domain Modelling100%ExemplaryStrongest area.
Accessibility38%Weak — gated by AC1, AC4Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Performance60%AdequateAcceptable, with room to improve.
Unscored — 3 check(s) recorded observations but carry no score

These checks ran and found something, but they do not carry a score — either by design (an advisory check reports evidence rather than grading it) or because they could not be scored here. They are excluded from the score for that reason, not because there was nothing to see.

  • X10 Duplicated predicate — 25 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
  • X6 Hand-rolled structured-format parsing — 8 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
  • X7 Silent fallback defaults — 24 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
Not included — 40 check(s) not relevant to this codebase

These checks had nothing to measure here (no tests, no git history, the codebase is small, or the architecture style doesn't apply), so they're omitted above rather than scored low.

  • AX1 Captive dependencies — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • AX5 Architecture & structure — not assessed — architecture style/structure is computed from a project graph (projects, types, module namespaces) that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • AX6 Interface segregation — no exported interface declares behaviour
  • AX7 Slice cohesion — not applicable — not a vertical-slice architecture
  • AX8 Test isolation — no test/production split to check
  • AX9 CQS / query purity — no CQRS query handlers detected — query purity is not applicable to this codebase
  • AXB2 Runtime readiness — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
  • AXR1 Runtime accessibility — compose up failed (exit 17 — an image could not be built) — failed to solve: process "/bin/sh -c apt-get update && apt-get install -y curl wget git build-essential software-properties-common ca-certificates libgl1-mesa-glx libglib2.0-0 poppler-utils tesseract-ocr tesseract-ocr-eng tesseract-ocr-chi-sim && rm -rf /var/lib/apt/lists/*" did not complete successfully: exit code: 100; runtime evidence skipped This is a statement about this run, not a statement about your application: nothing here says the surface is inaccessible, only that it was never rendered.
  • C1 Data Protection — Not assessed: these personal data controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks personal data controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
  • C3 Audit Trail — No personal data detected in a persisted data model — no PII-named field (email, first_name, date_of_birth, phone, …) or stored credential in a Django, SQLAlchemy, SQLModel, Peewee, Tortoise or MongoEngine model, a migration or a SQL schema — and no database or data-store client (Django ORM, SQLAlchemy, psycopg, PyMongo, …) in the source either, so this repository keeps no sensitive data whose changes an audit trail would record. If it does (through a store configured outside this repository, for instance), the trail belongs to wherever that data is stored.
  • C4 Data Retention — No personal data detected in a persisted data model — no PII-named field (email, first_name, date_of_birth, phone, …) or stored credential on a Django, SQLAlchemy, SQLModel, Peewee, Tortoise or mongoengine model, in a migration or in a SQL schema — and no database or data-store client (django.db, sqlalchemy, psycopg2, pymongo, sqlite3, …) imported either, so this repository keeps no personal data whose lifetime a retention limit would bound.
  • C5 Data-Subject Rights — No personal data detected in a persisted data model — no PII-named field (email, first_name, date_of_birth, phone, …) or stored credential on a Django, SQLAlchemy, SQLModel, Peewee, Tortoise or mongoengine model, in a migration or in a SQL schema — and no database or data-store client (django.db, sqlalchemy, psycopg2, pymongo, sqlite3, …) imported either, so this repository keeps no personal data for a data subject to erase, export or consent over.
  • D14 License Compliance — Python dependency closure larger than the licence pass walks
  • D18 Solution Shape — D18 scores the shape of a .NET solution; this repository has no .NET solution or project files, so the dimension does not apply.
  • D21 Naming Consistency — Naming consistency is measured on C# and TypeScript only; JavaScript, Python, html not measured.
  • D22 Internal API Consistency — The exposed public-API surface could not be collected — no C#/VB projects loaded.
  • D23 Boundary Type-Coupling — No bounded-context organisation was detected either — neither a context-shaped layout, nor 2+ sibling source directories each declaring an aggregate root, nor 2+ sibling projects each declaring an entity of their own or taking another project's integration events. Aggregate roots were found in only one source directory (chapter2), which is a layered codebase, not two contexts. Declaring this codebase's bounded contexts (≥2) would let cross-boundary type coupling be assessed. Declare them in `.codehealth/config.yaml` at the repository root (create it if absent), mapping each context name to the module-path or namespace prefixes that belong to it — e.g. `architecture:` → `contexts:` → `Billing: ["src/billing", "Acme.Billing"]`, `Catalog: ["src/catalog", "Acme.Catalog"]`.
  • D25 ADR Conformance — no ADRs to check
  • D32 Data Compliance (PII/GDPR) — 6 file(s) were not parsed by semgrep — the PII/GDPR ruleset never ran over them
  • D37 Vulnerability-disclosure Policy — No vulnerability-disclosure policy file found (SECURITY.md/.markdown/.rst/.txt at root or under .github/.forgejo/.gitea/docs, .well-known/security.txt). A coordinated-disclosure policy may live off-repo, so this is not evidenced rather than failed.
  • D39 IL Efficiency — D39 measures the IL emitted by a .NET build; this repository has no .NET solution or project files, so the dimension does not apply.
  • D40 Network Egress Confinement — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.
  • D41 Kernel & Syscall Confinement — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.
  • D42 Runtime Threat Enforcement — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.
  • D7 Architectural Integrity — no checkable ADRs, and no project-reference graph for the cycle pass to read — so this dimension makes no claim about dependency cycles in either direction (where this repository's language has an import-cycle lens, cycles are reported there). Architectural integrity not assessed
  • D8 Code Coverage — Coverage not measured — polyglot repository, one half has no runner
  • ED1 Event-Driven — not scored — this repository shows none of the 3 signals this lens looks for
  • ED5 Idempotency — no mutating command handlers or message consumers detected — idempotency check not applicable
  • ES1 Event Sourcing — not scored — this repository shows none of the 3 signals this lens looks for
  • GD1 Unfinished & placeholder code — no source files were read — this check reads C#, F#, JavaScript/TypeScript, Dart, Ruby and Scala, and none was read for this repository's product. That is a limit of the analyzer, not a finding about your code.
  • IC1 Incompleteness & stubs — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • P12 CI test-gate honesty — Reported, not scored — and nothing was matched here. The coverage check applies to any stack, and the automatic-re-run check to any GitHub-Actions workflow, but the checks for excluded tests, skipped tests and sleep-based synchronisation currently recognise only some ecosystems' test-runner idioms, so on a repository built with another stack the zeros below mean 'not checked', not 'clean'.
  • P8 Schema migrations — no ORM, schema-migration tool or schema auto-create was found in this repository's dependency manifests or source, so there is no database schema for this check to judge
  • P9 Domain vs controller coverage — coverage data present for 76 file(s), but no domain-layer files were identified: no covered file's path contains any of the markers this check keys on (/domain/, /aggregates/, /valueobjects/, /domainmodel/, .domain/, /entities/), which are matched case-insensitively anywhere in the path. With no domain partition there is nothing to compare the web/controller layer against — if this repository keeps its business rules under a folder named none of those, that naming is what the check cannot see, not the domain logic.
  • PF1 Benchmark discipline — Not applicable: no benchmark suite was found. This check searched for a pytest-benchmark or pytest-codspeed dependency with tests taking the `benchmark` fixture, an asv.conf.json with its `time_`/`mem_`/`peakmem_` benchmarks, or a pyperf Runner, and for a `*benchmark*` script that this repository's CI runs. Benchmarks are credited as a bonus, so their absence is neither scored nor deducted.
  • PF2 Allocation hygiene — Not applicable: Python and TypeScript/JavaScript runs on a garbage-collected runtime that gives a program no allocation-control idiom to choose on a hot path — no pools, stack allocation or value types — so allocation awareness is not something this code can be rated on.
  • SC1 Supply-chain hygiene — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
  • X20 Mistyped argument guard — This check asks whether an argument guard reports an EMPTY value as a NULL one, which needs a language that throws a null-specific argument exception — .NET's ArgumentNullException, the JVM's NullPointerException, Dart's ArgumentError.notNull. This repository contains none of those languages: the ones it is written in have a single exception for a bad argument, so there is no pair of exceptions to confuse and nothing here for it to assess. Not a gap in the analyzer and not a finding about your code.
  • X32 Type resolved by simple name across every loaded assembly — This check is about how a .NET program searches the assemblies loaded into its process for a type, and this repository contains no .NET source, so there is nothing here for it to assess. Not a gap in the analyzer and not a finding about your code.
  • X9 Subsumed condition operand — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.

Appendix A — Findings (grouped)

The findings behind the scores, grouped by severity, then by dimension and kind. The high-severity issues are enumerated in full below; items per group are capped at 25 with any overflow stated explicitly per group, never silently truncated. The complete machine-readable list of every finding (all severities) is the companion findings.md in this report's bundle.

Critical — 320 finding(s)
D30 · Dependency Vulnerabilities · High CVE · ×105
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • + 80 more in this group — see findings.md.
D28 · Secrets (history) · REDACTED · ×43
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • + 18 more in this group — see findings.md.
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • + 5 more in this group — see findings.md.
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D28 · Secrets (history) · High secret · ×17
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D30 · Dependency Vulnerabilities · Critical CVE · ×14
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D31 · IaC & Container Security · High IaC · ×14
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
AC3 · Page structure · <html> without a lang · ×13
  • <html> without a lang chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/01-cover.html:2 — The page declares no language, so assistive tech can't pick the right pronunciation. Add lang (e.g. lang="en").
  • <html> without a lang chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/02-problem.html:2 — The page declares no language, so assistive tech can't pick the right pronunciation. Add lang (e.g. lang="en").
  • <html> without a lang chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/03-keyidea.html:2 — The page declares no language, so assistive tech can't pick the right pronunciation. Add lang (e.g. lang="en").
  • <html> without a lang chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/04-architecture.html:2 — The page declares no language, so assistive tech can't pick the right pronunciation. Add lang (e.g. lang="en").
  • <html> without a lang chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/05-attention.html:2 — The page declares no language, so assistive tech can't pick the right pronunciation. Add lang (e.g. lang="en").
  • <html> without a lang chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/06-building-blocks.html:2 — The page declares no language, so assistive tech can't pick the right pronunciation. Add lang (e.g. lang="en").
  • <html> without a lang chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/07-why-self-attention.html:2 — The page declares no language, so assistive tech can't pick the right pronunciation. Add lang (e.g. lang="en").
  • <html> without a lang chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/08-training.html:2 — The page declares no language, so assistive tech can't pick the right pronunciation. Add lang (e.g. lang="en").
  • <html> without a lang chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/09-results.html:2 — The page declares no language, so assistive tech can't pick the right pronunciation. Add lang (e.g. lang="en").
  • <html> without a lang chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/10-chart.html:2 — The page declares no language, so assistive tech can't pick the right pronunciation. Add lang (e.g. lang="en").
  • <html> without a lang chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/11-generalization.html:2 — The page declares no language, so assistive tech can't pick the right pronunciation. Add lang (e.g. lang="en").
  • <html> without a lang chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/12-interpretability.html:2 — The page declares no language, so assistive tech can't pick the right pronunciation. Add lang (e.g. lang="en").
  • <html> without a lang chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/13-conclusion.html:2 — The page declares no language, so assistive tech can't pick the right pronunciation. Add lang (e.g. lang="en").
AC3 · Page structure · Document without a <title> · ×13
  • Document without a <title> chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/01-cover.html:2 — A page with no <title> gives no name in the tab, history or screen-reader page list. Add a descriptive <title> in <head>.
  • Document without a <title> chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/02-problem.html:2 — A page with no <title> gives no name in the tab, history or screen-reader page list. Add a descriptive <title> in <head>.
  • Document without a <title> chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/03-keyidea.html:2 — A page with no <title> gives no name in the tab, history or screen-reader page list. Add a descriptive <title> in <head>.
  • Document without a <title> chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/04-architecture.html:2 — A page with no <title> gives no name in the tab, history or screen-reader page list. Add a descriptive <title> in <head>.
  • Document without a <title> chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/05-attention.html:2 — A page with no <title> gives no name in the tab, history or screen-reader page list. Add a descriptive <title> in <head>.
  • Document without a <title> chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/06-building-blocks.html:2 — A page with no <title> gives no name in the tab, history or screen-reader page list. Add a descriptive <title> in <head>.
  • Document without a <title> chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/07-why-self-attention.html:2 — A page with no <title> gives no name in the tab, history or screen-reader page list. Add a descriptive <title> in <head>.
  • Document without a <title> chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/08-training.html:2 — A page with no <title> gives no name in the tab, history or screen-reader page list. Add a descriptive <title> in <head>.
  • Document without a <title> chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/09-results.html:2 — A page with no <title> gives no name in the tab, history or screen-reader page list. Add a descriptive <title> in <head>.
  • Document without a <title> chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/10-chart.html:2 — A page with no <title> gives no name in the tab, history or screen-reader page list. Add a descriptive <title> in <head>.
  • Document without a <title> chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/11-generalization.html:2 — A page with no <title> gives no name in the tab, history or screen-reader page list. Add a descriptive <title> in <head>.
  • Document without a <title> chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/12-interpretability.html:2 — A page with no <title> gives no name in the tab, history or screen-reader page list. Add a descriptive <title> in <head>.
  • Document without a <title> chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/13-conclusion.html:2 — A page with no <title> gives no name in the tab, history or screen-reader page list. Add a descriptive <title> in <head>.
D13 · REDACTED Scanning · Leaked secret · ×9
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
AC2 · Forms & labels · <input> without a programmatic label · ×8
  • <input> without a programmatic label chapter5/conversational-ui/baseline/src/App.jsx:65 — This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label htmlFor>, a wrapping <label>, or aria-label.
  • <input> without a programmatic label chapter5/conversational-ui/frontend/src/App.jsx:65 — This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label htmlFor>, a wrapping <label>, or aria-label.
  • <input> without a programmatic label chapter5/conversational-ui/validation/runs/20260729T212616Z-5_11-hmr/app/frontend/src/App.jsx:65 — This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label htmlFor>, a wrapping <label>, or aria-label.
  • <input> without a programmatic label chapter5/conversational-ui/validation/runs/20260729T212727Z-5_11-hmr/app/frontend/src/App.jsx:65 — This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label htmlFor>, a wrapping <label>, or aria-label.
  • <input> without a programmatic label chapter5/conversational-ui/validation/runs/20260729T212933Z-5_11-hmr/app/frontend/src/App.jsx:65 — This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label htmlFor>, a wrapping <label>, or aria-label.
  • <input> without a programmatic label chapter5/dynamic-form/validation/runs/20260729T212542Z-5_9-live-browser/generated_form.html:19 — This control has no associated label. Add a <label for> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
  • <input> without a programmatic label chapter5/dynamic-form/validation/runs/20260729T212542Z-5_9-live-browser/generated_form.html:20 — This control has no associated label. Add a <label for> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
  • <input> without a programmatic label chapter7/elo-leaderboard/validation/runs/exp7-7-arena-20260731-v1/leaderboard_animation.html:147 — This control has no associated label. Add a <label for> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
AC2 · Forms & labels · <label> that labels no control · ×6
  • <label> that labels no control chapter2/attention_visualization/frontend/components/AttentionModal.tsx:407 — This <label> has no htmlFor and wraps no form control, so it names nothing: assistive tech never announces it, and clicking the caption focuses no field. Note that an id on the label is not an association — it is the TARGET of one, so a control still has to point at it. Give the label htmlFor="<the control's id>", move the control inside the label, or point the control's aria-labelledby at this label's id.
  • <label> that labels no control chapter2/attention_visualization/frontend/pages/index.tsx:265 — This <label> has no htmlFor and wraps no form control, so it names nothing: assistive tech never announces it, and clicking the caption focuses no field. Note that an id on the label is not an association — it is the TARGET of one, so a control still has to point at it. Give the label htmlFor="<the control's id>", move the control inside the label, or point the control's aria-labelledby at this label's id.
  • <label> that labels no control chapter2/attention_visualization/frontend/pages/index.tsx:273 — This <label> has no htmlFor and wraps no form control, so it names nothing: assistive tech never announces it, and clicking the caption focuses no field. Note that an id on the label is not an association — it is the TARGET of one, so a control still has to point at it. Give the label htmlFor="<the control's id>", move the control inside the label, or point the control's aria-labelledby at this label's id.
  • <label> that labels no control chapter2/attention_visualization/frontend/pages/index.tsx:277 — This <label> has no htmlFor and wraps no form control, so it names nothing: assistive tech never announces it, and clicking the caption focuses no field. Note that an id on the label is not an association — it is the TARGET of one, so a control still has to point at it. Give the label htmlFor="<the control's id>", move the control inside the label, or point the control's aria-labelledby at this label's id.
  • <label> that labels no control chapter5/dynamic-form/validation/runs/20260729T212542Z-5_9-live-browser/generated_form.html:18 — This <label> has no for and wraps no form control, so it names nothing: assistive tech never announces it, and clicking the caption focuses no field. Note that an id on the label is not an association — it is the TARGET of one, so a control still has to point at it. Give the label for="<the control's id>", move the control inside the label, or point the control's aria-labelledby at this label's id.
  • <label> that labels no control chapter7/elo-leaderboard/validation/runs/exp7-7-arena-20260731-v1/leaderboard_animation.html:146 — This <label> has no for and wraps no form control, so it names nothing: assistive tech never announces it, and clicking the caption focuses no field. Note that an id on the label is not an association — it is the TARGET of one, so a control still has to point at it. Give the label for="<the control's id>", move the control inside the label, or point the control's aria-labelledby at this label's id.
AC1 · Text alternatives · <img> without a text alternative · ×5
  • <img> without a text alternative chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/01-cover.html:27 — An image with no alt (and no aria-label/aria-labelledby) is unreadable to assistive tech. Add alt — alt="" if it's purely decorative.
  • <img> without a text alternative chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/04-architecture.html:37 — An image with no alt (and no aria-label/aria-labelledby) is unreadable to assistive tech. Add alt — alt="" if it's purely decorative.
  • <img> without a text alternative chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/05-attention.html:41 — An image with no alt (and no aria-label/aria-labelledby) is unreadable to assistive tech. Add alt — alt="" if it's purely decorative.
  • <img> without a text alternative chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/09-results.html:31 — An image with no alt (and no aria-label/aria-labelledby) is unreadable to assistive tech. Add alt — alt="" if it's purely decorative.
  • <img> without a text alternative chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/12-interpretability.html:40 — An image with no alt (and no aria-label/aria-labelledby) is unreadable to assistive tech. Add alt — alt="" if it's purely decorative.
D30 · Dependency Vulnerabilities · High vulnerability · ×5
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D30 · Dependency Vulnerabilities · Critical vulnerability · ×3
  • REDACTED
  • REDACTED
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
D31 · IaC & Container Security · Critical IaC · ×1
  • REDACTED
R8 · Dependency Hygiene · Unlisted import 'mdast-util-from-markdown' · ×1
  • Unlisted import 'mdast-util-from-markdown' web-astro/scripts/build.test.mjs:490 — Imported but not declared in any reachable REDACTED — installs work only by hoisting accident.
R8 · Dependency Hygiene · Unlisted import 'rehype-stringify' · ×1
  • Unlisted import 'rehype-stringify' web-astro/scripts/book-math.test.mjs:10 — Imported but not declared in any reachable REDACTED — installs work only by hoisting accident.
R8 · Dependency Hygiene · Unlisted import 'remark-parse' · ×1
  • Unlisted import 'remark-parse' web-astro/scripts/book-math.test.mjs:6 — Imported but not declared in any reachable REDACTED — installs work only by hoisting accident.
R8 · Dependency Hygiene · Unlisted import 'remark-rehype' · ×1
  • Unlisted import 'remark-rehype' web-astro/scripts/book-math.test.mjs:8 — Imported but not declared in any reachable REDACTED — installs work only by hoisting accident.
R8 · Dependency Hygiene · Unlisted import 'unified' · ×1
  • Unlisted import 'unified' web-astro/scripts/book-math.test.mjs:5 — Imported but not declared in any reachable REDACTED — installs work only by hoisting accident.
Serious — 2300 finding(s)
D15 · Churn × Complexity Hotspots · Hotspot · ×92
  • Hotspot: REDACTED REDACTED:27 — REDACTED changed 27 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 190 in lang-switcher.init at line 27. 13 of those changes were fix/bug commits, and the other 14 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- REDACTED`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: chapter10/voice-werewolf/demo.py chapter10/voice-werewolf/demo.py:225 — chapter10/voice-werewolf/demo.py changed 11 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 84 in demo.run_game at line 225. 2 of those changes were fix/bug commits, and the other 9 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter10/voice-werewolf/demo.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: chapter1/context/main.py chapter1/context/main.py:907 — chapter1/context/main.py changed 18 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 43 in main.interactive_mode at line 907. 9 of those changes were fix/bug commits, and the other 9 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter1/context/main.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: REDACTED REDACTED:701 — REDACTED changed 24 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 28 in ContextAwareAgent.execute_task at line 701. 10 of those changes were fix/bug commits, and the other 14 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- REDACTED`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: chapter3/user-memory/agent.py chapter3/user-memory/agent.py:614 — chapter3/user-memory/agent.py changed 10 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 58 in UserMemoryAgent.execute_task at line 614. 4 of those changes were fix/bug commits, and the other 6 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter3/user-memory/agent.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: REDACTED REDACTED:825 — REDACTED changed 15 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 34 in SystemHintAgent.execute_task at line 825. 6 of those changes were fix/bug commits, and the other 9 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- REDACTED`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: chapter5/code-for-math/demo.py chapter5/code-for-math/demo.py:543 — chapter5/code-for-math/demo.py changed 11 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 43 in demo.main at line 543. 4 of those changes were fix/bug commits, and the other 7 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter5/code-for-math/demo.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: chapter2/kv-cache/agent.py chapter2/kv-cache/agent.py:622 — chapter2/kv-cache/agent.py changed 11 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 35 in KVCacheAgent.execute_task at line 622. 5 of those changes were fix/bug commits, and the other 6 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter2/kv-cache/agent.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: chapter5/paper-to-ppt/demo.py chapter5/paper-to-ppt/demo.py:410 — chapter5/paper-to-ppt/demo.py changed 10 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 36 in demo.main at line 410. 3 of those changes were fix/bug commits, and the other 7 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter5/paper-to-ppt/demo.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: chapter10/book-translation/agents.py chapter10/book-translation/agents.py:461 — chapter10/book-translation/agents.py changed 13 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 23 in agents.run_orchestration at line 461. 6 of those changes were fix/bug commits, and the other 7 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter10/book-translation/agents.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: chapter10/multi-role-transfer/orchestrator.py chapter10/multi-role-transfer/orchestrator.py:108 — chapter10/multi-role-transfer/orchestrator.py changed 12 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 24 in MultiRoleOrchestrator._run_one_llm_turn at line 108. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter10/multi-role-transfer/orchestrator.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: REDACTED REDACTED:1059 — REDACTED changed 8 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 36 in EventTriggeredAgent.handle_event at line 1059. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- REDACTED`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: chapter2/prompt-engineering/run_ablation.py chapter2/prompt-engineering/run_ablation.py:554 — chapter2/prompt-engineering/run_ablation.py changed 8 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 33 in run_ablation.run_full_suite at line 554. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter2/prompt-engineering/run_ablation.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: chapter2/context-compression/agent.py chapter2/context-compression/agent.py:353 — chapter2/context-compression/agent.py changed 11 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 24 in ResearchAgent._stream_response at line 353. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter2/context-compression/agent.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: chapter8/Intuitor/evaluate_from_cache.py chapter8/Intuitor/evaluate_from_cache.py:198 — chapter8/Intuitor/evaluate_from_cache.py changed 10 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 25 in evaluate_from_cache.evaluate_from_parquet at line 198. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter8/Intuitor/evaluate_from_cache.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: chapter3/log-sanitization/agent.py chapter3/log-sanitization/agent.py:139 — chapter3/log-sanitization/agent.py changed 10 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 24 in LogSanitizationAgent.detect_pii at line 139. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter3/log-sanitization/agent.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: chapter10/autonomous-phone-registration/demo.py chapter10/autonomous-phone-registration/demo.py:126 — chapter10/autonomous-phone-registration/demo.py changed 4 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 58 in demo.main at line 126. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter10/autonomous-phone-registration/demo.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: REDACTED REDACTED:676 — REDACTED changed 12 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 19 in pipeline.judge_gemini_audio at line 676. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- REDACTED`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: chapter9/self-evolution-eval/harness.py chapter9/self-evolution-eval/harness.py:24 — chapter9/self-evolution-eval/harness.py changed 9 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 25 in LongitudinalEvaluator.run at line 24. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter9/self-evolution-eval/harness.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: chapter5/code-for-logic/demo.py chapter5/code-for-logic/demo.py:489 — chapter5/code-for-logic/demo.py changed 9 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 25 in demo.main at line 489. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter5/code-for-logic/demo.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: chapter3/user-memory/conversational_agent.py chapter3/user-memory/conversational_agent.py:47 — chapter3/user-memory/conversational_agent.py changed 10 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 20 in ConversationalAgent.__init__ at line 47. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter3/user-memory/conversational_agent.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: chapter1/web-search-agent/agent.py chapter1/web-search-agent/agent.py:364 — chapter1/web-search-agent/agent.py changed 10 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 19 in WebSearchAgent.search_and_answer at line 364. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter1/web-search-agent/agent.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: chapter7/tts-quality-eval/demo.py chapter7/tts-quality-eval/demo.py:214 — chapter7/tts-quality-eval/demo.py changed 6 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 31 in demo.main at line 214. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter7/tts-quality-eval/demo.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: chapter10/multi-role-transfer/demo.py chapter10/multi-role-transfer/demo.py:190 — chapter10/multi-role-transfer/demo.py changed 10 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 18 in demo.save_evidence at line 190. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter10/multi-role-transfer/demo.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: chapter2/local_llm_serving/agent.py chapter2/local_llm_serving/agent.py:340 — chapter2/local_llm_serving/agent.py changed 5 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 35 in VLLMToolAgent.chat_stream at line 340. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter2/local_llm_serving/agent.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • + 67 more in this group — see findings.md.
D30 · Dependency Vulnerabilities · Medium CVE · ×70
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • + 45 more in this group — see findings.md.
D3 · God Classes · FileTooLong · ×62
  • FileTooLong: user-memory-system-evaluation/experiment.py chapter7/user-memory-system-evaluation/experiment.py — FileTooLong — 1634 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1134 over it, 3.27× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: android-world/run_controlled_experiment.py chapter7/android-world/run_controlled_experiment.py — FileTooLong — 1490 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 990 over it, 2.98× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: exp7-7-arena-20260731-v1/leaderboard_animation.html chapter7/elo-leaderboard/validation/runs/exp7-7-arena-20260731-v1/leaderboard_animation.html — FileTooLong — 1442 significant lines (blank, comment-only and punctuation-only lines excluded), about 92% of them inside a single declaration: data (159-2053). The bar is 500 significant lines; this is 942 over it, 2.88× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: active-tool-discovery/run_exact_experiment.py chapter4/active-tool-discovery/run_exact_experiment.py — FileTooLong — 907 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 407 over it, 1.81× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: REDACTED REDACTED — FileTooLong — 880 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 380 over it, 1.76× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: model-benchmark/campaign.py chapter7/model-benchmark/campaign.py — FileTooLong — 851 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 351 over it, 1.70× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: src/expanded_catalog.py chapter4/perception-tools/src/expanded_catalog.py — FileTooLong — 840 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 340 over it, 1.68× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: REDACTED REDACTED — FileTooLong — 792 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 292 over it, 1.58× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: system-hint/run_experiment_2_8.py chapter2/system-hint/run_experiment_2_8.py — FileTooLong — 782 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 282 over it, 1.56× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: permission-embedded-data-objects/run_live_security_eval.py chapter5/permission-embedded-data-objects/run_live_security_eval.py — FileTooLong — 748 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 248 over it, 1.50× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: REDACTED REDACTED — FileTooLong — 746 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 246 over it, 1.49× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: multimodal-agent/agent.py chapter4/multimodal-agent/agent.py — FileTooLong — 742 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 242 over it, 1.48× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: REDACTED REDACTED — FileTooLong — 734 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 234 over it, 1.47× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: model-benchmark/analysis.py chapter7/model-benchmark/analysis.py — FileTooLong — 727 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 227 over it, 1.45× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: REDACTED REDACTED — FileTooLong — 700 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 200 over it, 1.40× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: book-translation/run_official_experiment.py chapter10/book-translation/run_official_experiment.py — FileTooLong — 686 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 186 over it, 1.37× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: REDACTED REDACTED — FileTooLong — 670 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 170 over it, 1.34× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: REDACTED REDACTED — FileTooLong — 656 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 156 over it, 1.31× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: user-memory/main.py chapter3/user-memory/main.py — FileTooLong — 645 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 145 over it, 1.29× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: dataguardbench/prompts.py chapter5/permission-embedded-data-objects/pedo/eval/dataguardbench/prompts.py — FileTooLong — 644 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 144 over it, 1.29× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: openvla-robotwin2-eval/experiment.py chapter7/openvla-robotwin2-eval/experiment.py — FileTooLong — 644 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 144 over it, 1.29× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: agent-creator/creator.py chapter5/agent-creator/creator.py — FileTooLong — 638 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 138 over it, 1.28× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: context/main.py chapter1/context/main.py — FileTooLong — 634 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 134 over it, 1.27× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: agent-with-event-trigger/unipile_mailbox_experiment.py chapter6/agent-with-event-trigger/unipile_mailbox_experiment.py — FileTooLong — 630 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 130 over it, 1.26× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: REDACTED REDACTED — FileTooLong — 618 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 118 over it, 1.24× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • + 37 more in this group — see findings.md.
D3 · God Classes · FunctionTooLong · ×41
  • FunctionTooLong: index.Home chapter6/live-audio/frontend/pages/index.tsx:65 — FunctionTooLong — Home runs 471 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 371 over it, 4.71× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: highlights.initHighlights web-astro/src/scripts/highlights.ts:18 — FunctionTooLong — initHighlights runs 428 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 328 over it, 4.28× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: lang-switcher.init REDACTED:27 — FunctionTooLong — init runs 416 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 316 over it, 4.16× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: AttentionModal.AttentionModal chapter2/attention_visualization/frontend/components/AttentionModal.tsx:11 — FunctionTooLong — AttentionModal runs 317 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 217 over it, 3.17× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: index.Home chapter2/attention_visualization/frontend/pages/index.tsx:56 — FunctionTooLong — Home runs 308 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 208 over it, 3.08× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: evaluation-overview-figures.layoutEmbodiedEvaluation REDACTED:624 — FunctionTooLong — layoutEmbodiedEvaluation runs 280 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 180 over it, 2.80× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: retrieval-workflow-layout.layoutRetrievalWorkflow web-astro/scripts/retrieval-workflow-layout.mjs:17 — FunctionTooLong — layoutRetrievalWorkflow runs 267 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 167 over it, 2.67× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: evaluation-overview-figures.layoutEvaluationOverview REDACTED:160 — FunctionTooLong — layoutEvaluationOverview runs 213 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 113 over it, 2.13× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: book-markdown.bookMarkdown REDACTED:9 — FunctionTooLong — bookMarkdown runs 191 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 91 over it, 1.91× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: book-markdown.bookMarkdown.<returned closure> REDACTED:10 — FunctionTooLong — bookMarkdown.<returned closure> runs 190 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 90 over it, 1.90× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: coding-production-layout.layoutReviewLoop REDACTED:111 — FunctionTooLong — layoutReviewLoop runs 186 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 86 over it, 1.86× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: evaluation-overview-figures.layoutDualControl REDACTED:413 — FunctionTooLong — layoutDualControl runs 181 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 81 over it, 1.81× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: async-architecture-layout.layoutSchedulingPatterns REDACTED:303 — FunctionTooLong — layoutSchedulingPatterns runs 176 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 76 over it, 1.76× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: pairwise-figure.layoutPairwise REDACTED:39 — FunctionTooLong — layoutPairwise runs 166 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 66 over it, 1.66× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: note-editor.createNoteEditor web-astro/src/scripts/note-editor.ts:5 — FunctionTooLong — createNoteEditor runs 153 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 53 over it, 1.53× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: tool-cache-layout.layoutTrajectory web-astro/scripts/tool-cache-layout.mjs:219 — FunctionTooLong — layoutTrajectory runs 151 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 51 over it, 1.51× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: coding-application-layout.layoutBootstrapping REDACTED:515 — FunctionTooLong — layoutBootstrapping runs 149 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 49 over it, 1.49× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: voice-architecture-layout.layoutParallelThinking REDACTED:603 — FunctionTooLong — layoutParallelThinking runs 146 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 46 over it, 1.46× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: generate.renderLesson slides/generate.mjs:148 — FunctionTooLong — renderLesson runs 144 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 44 over it, 1.44× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: tool-cache-layout.layoutComparison web-astro/scripts/tool-cache-layout.mjs:38 — FunctionTooLong — layoutComparison runs 144 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 44 over it, 1.44× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: async-architecture-layout.layoutEventArchitecture REDACTED:127 — FunctionTooLong — layoutEventArchitecture runs 139 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 39 over it, 1.39× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: async-architecture-layout.layoutRuntimeArchitecture REDACTED:522 — FunctionTooLong — layoutRuntimeArchitecture runs 139 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 39 over it, 1.39× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: coding-application-layout.layoutArtifactFlow REDACTED:351 — FunctionTooLong — layoutArtifactFlow runs 133 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 33 over it, 1.33× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: AttentionStats.AttentionStats chapter2/attention_visualization/frontend/components/AttentionStats.tsx:13 — FunctionTooLong — AttentionStats runs 127 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 27 over it, 1.27× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: voice-architecture-layout.layoutRealtimeComparison REDACTED:449 — FunctionTooLong — layoutRealtimeComparison runs 127 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 27 over it, 1.27× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • + 16 more in this group — see findings.md.
R4 · Test Coverage · No test reaches this file · ×40
  • No test reaches this file chapter6/live-audio/backend/server.js:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file slides/chapter1-pilot.mjs:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file chapter6/live-audio/frontend/pages/index.tsx:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file REDACTED:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file slides/generate.mjs:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file web-astro/src/scripts/highlights.ts:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file chapter2/attention_visualization/frontend/components/AttentionModal.tsx:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file extras/agent-lab/agent-trajectory.js:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file chapter6/live-audio/backend/run_real_validation.js:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file chapter2/attention_visualization/frontend/pages/index.tsx:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file web-astro/scripts/prepare-assets.mjs:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file chapter6/live-audio/backend/utils/vad.js:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file chapter6/phone-agent/static/app.js:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file slides/review.mjs:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file chapter6/live-audio/backend/utils/textProcessor.js:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file web-astro/src/scripts/note-editor.ts:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file extras/nav-collapse.js:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file web-astro/src/scripts/machine-translation.ts:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file chapter2/attention_visualization/frontend/components/AttentionStats.tsx:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file REDACTED:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file chapter2/attention_visualization/frontend/components/AttentionPreview.tsx:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file chapter6/live-audio/frontend/public/audioWorklet.js:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file web-astro/src/scripts/reading-position.ts:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file chapter2/attention_visualization/frontend/components/AttentionHeatmap.tsx:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file web-astro/src/lib/highlight-store.ts:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • + 15 more in this group — see findings.md.
PF3 · Async & latency hygiene · Sync-over-async blocking · ×39
  • Sync-over-async blocking chapter4/execution-tools/execution_tools.py:195 — `virtual_terminal` is async and calls subprocess.run — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs.
  • Sync-over-async blocking REDACTED:36 — `excel_create_with_formula_and_screenshot` is async and calls subprocess.run — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs.
  • Sync-over-async blocking REDACTED:139 — `virtual_desktop_execute` is async and calls time.sleep, subprocess.run — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs.
  • Sync-over-async blocking REDACTED:289 — `virtual_mobile_execute` is async and calls subprocess.run — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs.
  • Sync-over-async blocking REDACTED:359 — `environment_capabilities` is async and calls subprocess.run — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs.
  • Sync-over-async blocking REDACTED:39 — `execute_command` is async and calls subprocess.run — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs.
  • Sync-over-async blocking chapter4/perception-tools/src/google_search_enhanced.py:22 — `google_search_api` is async and calls requests.get — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs.
  • Sync-over-async blocking chapter4/perception-tools/src/google_search_enhanced.py:92 — `_fallback_google_search` is async and calls requests.post — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs.
  • Sync-over-async blocking chapter4/perception-tools/src/google_search_enhanced.py:141 — `read_webpage_content` is async and calls requests.get — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs.
  • Sync-over-async blocking chapter4/perception-tools/src/media_processing_tools.py:217 — `extract_audio_metadata` is async and calls subprocess.run — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs.
  • Sync-over-async blocking chapter4/perception-tools/src/media_processing_tools.py:688 — `trim_audio` is async and calls subprocess.run — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs.
  • Sync-over-async blocking chapter4/perception-tools/src/multimodal_tools.py:24 — `read_webpage` is async and calls requests.get — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs.
  • Sync-over-async blocking REDACTED:24 — `get_weather` is async and calls requests.get — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs.
  • Sync-over-async blocking REDACTED:149 — `get_stock_price` is async and calls requests.get — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs.
  • Sync-over-async blocking REDACTED:228 — `convert_currency` is async and calls requests.get — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs.
  • Sync-over-async blocking REDACTED:461 — `search_wayback` is async and calls requests.get — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs.
  • Sync-over-async blocking REDACTED:551 — `get_crypto_price` is async and calls requests.get — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs.
  • Sync-over-async blocking REDACTED:660 — `search_location` is async and calls requests.get — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs.
  • Sync-over-async blocking REDACTED:761 — `search_poi` is async and calls requests.post — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs.
  • Sync-over-async blocking chapter4/perception-tools/src/search_tools.py:45 — `search_web` is async and calls requests.post — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs.
  • Sync-over-async blocking chapter4/perception-tools/src/wayback_enhanced.py:21 — `get_archived_content` is async and calls requests.get — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs.
  • Sync-over-async blocking chapter4/perception-tools/src/wiki_enhanced.py:180 — `get_article_history` is async and calls requests.get — a blocking call inside async code stalls the event loop — every other task on it waits for as long as it runs.
  • Sync-over-async blocking chapter6/live-audio/backend/server.js:869 — `fs.writeFileSync` in `data.on("end")` blocks the event loop until it finishes — a blocking call inside async code stalls the event loop — every other request waits for as long as it runs.
  • Sync-over-async blocking chapter6/live-audio/backend/server.js:889 — `fs.readFileSync` in `data.on("end")` blocks the event loop until it finishes — a blocking call inside async code stalls the event loop — every other request waits for as long as it runs.
  • Sync-over-async blocking chapter6/live-audio/backend/server.js:892 — `fs.unlinkSync` in `data.on("end")` blocks the event loop until it finishes — a blocking call inside async code stalls the event loop — every other request waits for as long as it runs.
  • + 14 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (5 lines × 2) · ×35
  • Duplicated block (5 lines × 2) chapter10/book-translation/agents.py:563 — chapter10/book-translation/agents.py:563-569 | chapter10/book-translation/agents.py:640-644 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter10/book-translation/agents.py:563` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) chapter2/context-compression/run_all_strategies.py:326 — chapter2/context-compression/run_all_strategies.py:326-330 | chapter2/context-compression/run_all_strategies.py:332-336 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `chapter2/context-compression/run_all_strategies.py:337` calls `max` and `chapter2/context-compression/run_all_strategies.py:331` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 2) chapter2/prompt-injection/run_campaign.py:313 — chapter2/prompt-injection/run_campaign.py:313-317 | chapter5/paper-to-video/campaign.py:331-336 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (5 lines × 2) chapter2/prompt-injection/run_campaign.py:318 — chapter2/prompt-injection/run_campaign.py:318-322 | chapter5/paper-to-video/campaign.py:337-341 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (5 lines × 2) REDACTED:961 — REDACTED:961-965 | REDACTED:1195-1199 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:961` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) chapter3/agentic-rag/campaign.py:312 — chapter3/agentic-rag/campaign.py:312-316 | chapter3/memory_rag_campaign.py:515-519 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (5 lines × 2) chapter3/retrieval-pipeline/evaluate.py:359 — chapter3/retrieval-pipeline/evaluate.py:359-363 | chapter3/retrieval-pipeline/stage_evaluator.py:204-208 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Note first that the copies are not typed on the same thing: the declarations holding them bind `ranked_ids` to `List[str]` in one and `list[str]` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (5 lines × 2) chapter3/structured-index/hybrid_retriever.py:189 — chapter3/structured-index/hybrid_retriever.py:189-193 | chapter3/structured-index/hybrid_retriever.py:250-254 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (5 lines × 2) chapter3/structured-knowledge-extraction/generate_data.py:58 — chapter3/structured-knowledge-extraction/generate_data.py:58-62 | chapter3/structured-knowledge-extraction/generate_data.py:142-146 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter3/structured-knowledge-extraction/generate_data.py:58` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) chapter4/collaboration-tools/main.py:308 — chapter4/collaboration-tools/main.py:308-312 | chapter4/collaboration-tools/main.py:354-358 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (5 lines × 2) chapter5/code-for-logic/demo.py:358 — chapter5/code-for-logic/demo.py:358-362 | chapter5/code-for-math/demo.py:427-431 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (5 lines × 2) chapter5/paper-to-ppt/make_figures.py:19 — chapter5/paper-to-ppt/make_figures.py:19-23 | chapter5/paper-to-ppt/make_figures.py:38-42 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (5 lines × 2) REDACTED:229 — REDACTED:229-234 | REDACTED:182-186 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:229` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) REDACTED:708 — REDACTED:708-712 | REDACTED:724-728 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (5 lines × 2) chapter6/agent-with-event-trigger/unipile_mailbox_experiment.py:623 — chapter6/agent-with-event-trigger/unipile_mailbox_experiment.py:623-627 | chapter6/async-agent/run_real_experiment.py:379-383 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `chapter6/agent-with-event-trigger/unipile_mailbox_experiment.py:623` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:336 — chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:336-340 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:336-340 — before extracting anything, compare `chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py` and `chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 250 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (5 lines × 2) chapter6/gemini-xlerobot-navigation/desktop_planner.py:230 — chapter6/gemini-xlerobot-navigation/desktop_planner.py:230-234 | chapter6/rgb-sim2real-grasping/pipeline.py:151-155 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `chapter6/gemini-xlerobot-navigation/desktop_planner.py:236` calls `split` and `chapter6/rgb-sim2real-grasping/pipeline.py:157` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 2) REDACTED:311 — REDACTED:311-315 | REDACTED:263-267 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (5 lines × 2) REDACTED:49 — REDACTED:49-53 | chapter9/prompt-auto-optimization/config.py:62-66 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (5 lines × 2) chapter5/coding-agent/agent.py:64 — chapter5/coding-agent/agent.py:64-68 | chapter5/coding-agent/agent_new.py:51-55 — before extracting anything, compare `chapter5/coding-agent/agent.py` and `chapter5/coding-agent/agent_new.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 198 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (5 lines × 2) chapter6/streaming-speech/run_official_experiment.py:56 — chapter6/streaming-speech/run_official_experiment.py:56-60 | chapter7/elo-leaderboard/validation/validate_evidence.py:12-16 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (5 lines × 2) chapter9/harness-safety-gate/validation/real_20260807T160109Z/candidates/deterministic/confirmation_gate.py:53 — chapter9/harness-safety-gate/validation/real_20260807T160109Z/candidates/deterministic/confirmation_gate.py:53-57 | chapter9/harness-safety-gate/validation/real_20260807T160109Z/candidates/rejected_control/confirmation_gate.py:54-58 — `chapter9/harness-safety-gate/validation/real_20260807T160109Z/candidates/deterministic/confirmation_gate.py` and `chapter9/harness-safety-gate/validation/real_20260807T160109Z/candidates/rejected_control/confirmation_gate.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 31 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (5 lines × 2) chapter3/agentic-rag/campaign.py:294 — chapter3/agentic-rag/campaign.py:294-298 | chapter3/memory_rag_campaign.py:493-497 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (5 lines × 2) chapter3/agentic-rag/campaign.py:300 — chapter3/agentic-rag/campaign.py:300-304 | chapter8/prompt-distillation/run_experiment_8_8.py:728-732 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (5 lines × 2) chapter3/dense-embedding/indexing.py:70 — chapter3/dense-embedding/indexing.py:70-74 | chapter3/dense-embedding/indexing.py:274-278 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `chapter3/dense-embedding/indexing.py:279` calls `debug` and `chapter3/dense-embedding/indexing.py:76` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • + 10 more in this group — see findings.md.
D31 · IaC & Container Security · Medium IaC · ×24
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Duplicated block (7 lines × 2) · ×24
  • Duplicated block (7 lines × 2) chapter10/book-translation/run_official_experiment.py:422 — chapter10/book-translation/run_official_experiment.py:422-428 | REDACTED:315-321 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (7 lines × 2) chapter10/multi-role-transfer/orchestrator.py:220 — chapter10/multi-role-transfer/orchestrator.py:220-229 | chapter10/multi-role-transfer/skill_orchestrator.py:258-264 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (7 lines × 2) chapter10/voice-werewolf/demo.py:187 — chapter10/voice-werewolf/demo.py:187-193 | chapter8/continued-pretraining/continued-pretrain.py:44-52 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `chapter10/voice-werewolf/demo.py:187` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) REDACTED:521 — REDACTED:521-527 | REDACTED:531-537 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) chapter3/agentic-rag-for-user-memory/main.py:200 — chapter3/agentic-rag-for-user-memory/main.py:200-206 | chapter3/contextual-retrieval-for-user-memory/main.py:700-706 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (7 lines × 2) chapter3/agentic-rag-for-user-memory/main.py:632 — chapter3/agentic-rag-for-user-memory/main.py:632-649 | chapter3/mem0/main.py:352-358 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `chapter3/agentic-rag-for-user-memory/main.py:632` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (7 lines × 2) REDACTED:242 — REDACTED:242-248 | REDACTED:242-248 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 13 separate duplicated blocks between them, totalling at least 349 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (7 lines × 2) REDACTED:459 — REDACTED:459-465 | chapter3/contextual-retrieval/index_local_laws_contextual.py:540-546 — `REDACTED` and `chapter3/contextual-retrieval/index_local_laws_contextual.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 7 separate duplicated blocks between them, totalling at least 122 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (7 lines × 2) chapter3/retrieval-pipeline/retrieval_client.py:40 — chapter3/retrieval-pipeline/retrieval_client.py:40-46 | chapter3/retrieval-pipeline/retrieval_client.py:60-66 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (7 lines × 2) REDACTED:407 — REDACTED:407-413 | REDACTED:433-439 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) chapter3/structured-knowledge-extraction/generate_data.py:59 — chapter3/structured-knowledge-extraction/generate_data.py:59-65 | chapter3/structured-knowledge-extraction/generate_data.py:100-106 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) chapter3/user-memory/main.py:210 — chapter3/user-memory/main.py:210-216 | chapter3/user-memory/main.py:341-347 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) chapter5/code-for-logic/build_puzzles.py:179 — chapter5/code-for-logic/build_puzzles.py:179-185 | chapter5/code-for-logic/demo.py:509-515 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `chapter5/code-for-logic/build_puzzles.py:179` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) REDACTED:104 — REDACTED:104-110 | chapter5/video-edit/campaign.py:124-130 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (7 lines × 2) chapter5/permission-embedded-data-objects/demo.py:20 — chapter5/permission-embedded-data-objects/demo.py:20-27 | REDACTED:242-248 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (7 lines × 2) chapter5/permission-embedded-data-objects/pedo/core/store.py:249 — chapter5/permission-embedded-data-objects/pedo/core/store.py:249-255 | chapter5/permission-embedded-data-objects/pedo/core/store.py:298-304 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) REDACTED:347 — REDACTED:347-353 | REDACTED:356-362 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) REDACTED:530 — REDACTED:530-536 | REDACTED:539-545 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) REDACTED:380 — REDACTED:380-386 | chapter5/permission-embedded-data-objects/pedo/eval/benchmark_spec_errors.py:337-346 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (7 lines × 2) chapter5/permission-embedded-data-objects/pedo/eval/dataguardbench/agentspec_wrap.py:67 — chapter5/permission-embedded-data-objects/pedo/eval/dataguardbench/agentspec_wrap.py:67-74 | chapter5/permission-embedded-data-objects/pedo/eval/dataguardbench/agentspec_wrap.py:76-82 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter5/permission-embedded-data-objects/pedo/eval/dataguardbench/agentspec_wrap.py:67` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) chapter6/gemini-xlerobot-navigation/validate_evidence.py:53 — chapter6/gemini-xlerobot-navigation/validate_evidence.py:53-59 | chapter6/rgb-sim2real-grasping/validate_evidence.py:48-54 — `chapter6/gemini-xlerobot-navigation/validate_evidence.py` and `chapter6/rgb-sim2real-grasping/validate_evidence.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 38 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (7 lines × 2) chapter7/user-memory-system-evaluation/probe_backends.py:46 — chapter7/user-memory-system-evaluation/probe_backends.py:46-59 | chapter7/user-memory-system-evaluation/probe_backends.py:67-73 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) chapter9/harness-safety-gate/demo.py:56 — chapter9/harness-safety-gate/demo.py:56-62 | chapter9/self-modifying-agent/demo.py:40-46 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (7 lines × 2) chapter9/harness-safety-gate/run_experiment_9_7.py:223 — chapter9/harness-safety-gate/run_experiment_9_7.py:223-232 | chapter9/self-evolution-eval/run_experiment_9_9.py:219-225 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
D4 · Code Duplication · Duplicated block (6 lines × 2) · ×22
  • Duplicated block (6 lines × 2) chapter10/autonomous-phone-registration/voice.py:121 — chapter10/autonomous-phone-registration/voice.py:121-126 | chapter10/voice-werewolf/werewolf/human.py:87-92 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (6 lines × 2) chapter10/voice-werewolf/validate_simulator_run.py:59 — chapter10/voice-werewolf/validate_simulator_run.py:59-64 | chapter10/voice-werewolf/validate_simulator_run.py:100-105 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (6 lines × 2) chapter3/agentic-rag/campaign.py:186 — chapter3/agentic-rag/campaign.py:186-191 | chapter3/memory_rag_campaign.py:266-271 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `chapter3/agentic-rag/campaign.py:186` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) chapter3/memobase/main.py:194 — chapter3/memobase/main.py:194-199 | chapter3/memobase/quickstart.py:103-108 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `chapter3/memobase/main.py:202` calls `run_single_task` and `chapter3/memobase/quickstart.py:111` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 2) chapter3/structured-index/main.py:123 — chapter3/structured-index/main.py:123-128 | chapter3/structured-index/main.py:130-137 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter3/structured-index/main.py:130` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) chapter3/user-memory/main.py:218 — chapter3/user-memory/main.py:218-223 | chapter3/user-memory/main.py:349-354 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (6 lines × 2) chapter4/execution-tools/multilang_executor.py:418 — chapter4/execution-tools/multilang_executor.py:418-423 | chapter4/execution-tools/multilang_executor.py:606-611 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (6 lines × 2) chapter5/adaptive-log-parser/campaign.py:198 — chapter5/adaptive-log-parser/campaign.py:198-203 | chapter5/erp-agent/campaign_postgres.py:254-259 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (6 lines × 2) chapter5/code-for-logic/demo.py:373 — chapter5/code-for-logic/demo.py:373-378 | chapter5/small-model-codified-rules/demo.py:164-170 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (6 lines × 2) REDACTED:441 — REDACTED:441-446 | REDACTED:450-455 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (6 lines × 2) REDACTED:350 — REDACTED:350-355 | REDACTED:405-410 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `REDACTED:404` calls `close` and `REDACTED:349` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 2) chapter7/user-memory-system-evaluation/probe_candidates.py:37 — chapter7/user-memory-system-evaluation/probe_candidates.py:37-42 | chapter7/user-memory-system-evaluation/probe_candidates.py:56-61 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (6 lines × 2) chapter8/MiniMind-pretrain/validation/validate_evidence.py:75 — chapter8/MiniMind-pretrain/validation/validate_evidence.py:75-80 | chapter8/continued-pretraining/validation/validate_evidence.py:65-70 — before extracting anything, compare `chapter8/MiniMind-pretrain/validation/validate_evidence.py` and `chapter8/continued-pretraining/validation/validate_evidence.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 69 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (6 lines × 2) chapter8/MiniMind-pretrain/validation/validate_evidence.py:304 — chapter8/MiniMind-pretrain/validation/validate_evidence.py:304-309 | chapter8/continued-pretraining/validation/validate_evidence.py:203-208 — before extracting anything, compare `chapter8/MiniMind-pretrain/validation/validate_evidence.py` and `chapter8/continued-pretraining/validation/validate_evidence.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 69 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (6 lines × 2) chapter8/continued-pretraining/compare_models.py:129 — chapter8/continued-pretraining/compare_models.py:129-135 | chapter8/continued-pretraining/continued-pretrain.py:76-81 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `chapter8/continued-pretraining/compare_models.py:129` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) chapter8/speech-sft-experiment/run_orpheus.py:268 — chapter8/speech-sft-experiment/run_orpheus.py:268-273 | chapter8/speech-sft-experiment/run_sesame.py:268-273 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `chapter8/speech-sft-experiment/run_orpheus.py:268` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) chapter3/agentic-rag/tools.py:51 — chapter3/agentic-rag/tools.py:51-56 | chapter3/contextual-retrieval/tools.py:50-55 — `chapter3/agentic-rag/tools.py` and `chapter3/contextual-retrieval/tools.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 14 separate duplicated blocks between them, totalling at least 341 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (6 lines × 2) chapter3/agentic-rag-for-user-memory/offline_demo.py:108 — chapter3/agentic-rag-for-user-memory/offline_demo.py:108-113 | chapter3/agentic-rag-for-user-memory/offline_demo.py:125-130 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (6 lines × 2) chapter3/memory_rag_campaign.py:502 — chapter3/memory_rag_campaign.py:502-507 | chapter3/structured-knowledge-extraction/campaign.py:536-541 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (6 lines × 2) chapter7/user-memory-system-evaluation/probe_candidates.py:47 — chapter7/user-memory-system-evaluation/probe_candidates.py:47-52 | chapter7/user-memory-system-evaluation/probe_candidates.py:68-73 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter7/user-memory-system-evaluation/probe_candidates.py:47` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (6 lines × 2) REDACTED:532 — REDACTED:532-537 | chapter9/prompt-auto-optimization/run_experiment_9_3.py:21-26 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (6 lines × 2) chapter9/tau2-escalation-experience/analyze.py:34 — chapter9/tau2-escalation-experience/analyze.py:34-39 | chapter9/tau2-escalation-experience/build_evidence.py:39-44 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
D29 · Static Analysis (SAST) · REDACTED · ×21
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
X3 · Exception handling · Swallowed exception (empty catch) · ×21
  • Swallowed exception (empty catch) web-astro/src/scripts/reading-position.ts:61 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) web-astro/src/scripts/reading-position.ts:75 — `.catch(() => {})` handles the rejection by doing nothing — the failure is discarded with no log and no rethrow, and the chain carries on as if the work succeeded. Log it through whatever this codebase already uses to report problems, hand it to a caller that can (`next(error)`, a returned rejection), or don't catch it.
  • Swallowed exception (empty catch) scripts/gen_star_history.py:92 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) extras/auto-translate.js:55 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) REDACTED:68 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) REDACTED:77 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) REDACTED:341 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) REDACTED:403 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) extras/nav-collapse.js:115 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) extras/search-index-router.js:67 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) chapter9/harness-safety-gate/safety_policy_gate.py:236 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) chapter9/browser-use-rpa/browser-use/browser_use/cli.py:1169 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) chapter9/browser-use-rpa/browser-use/browser_use/config.py:25 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) chapter9/browser-use-rpa/browser-use/browser_use/config.py:34 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) chapter9/browser-use-rpa/browser-use/browser_use/config.py:41 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) chapter9/browser-use-rpa/browser-use/browser_use/logging_config.py:271 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) chapter9/browser-use-rpa/browser-use/browser_use/logging_config.py:279 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. On a teardown path letting it propagate is not an option (throwing out of `close()` masks the failure already in flight and abandons the rest of the cleanup), so make the swallow deliberate instead: narrow the catch to the exception this release can actually raise, and record it through whatever this codebase already uses to report problems — or, if it truly cannot matter, say why in a comment on the catch.
  • Swallowed exception (empty catch) chapter9/browser-use-rpa/browser-use/browser_use/utils.py:318 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) chapter9/browser-use-rpa/browser-use/browser_use/tools/registry/service.py:344 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) chapter9/browser-use-rpa/browser-use/browser_use/tokens/service.py:102 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) chapter9/browser-use-rpa/browser-use/browser_use/tokens/service.py:559 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
D4 · Code Duplication · Members sharing a duplicated core (6 members, 50+ identical tokens) · ×20
  • Members sharing a duplicated core (6 members, 50+ identical tokens) book-ar/fit_svg_text.py:34 — book-ar/fit_svg_text.py:34-40 | book-en/fit_svg_text.py:34-40 | book-es/fit_svg_text.py:37-43 | book-id/fit_svg_text.py:37-43 | book-ru/fit_svg_text.py:34-40 | book-tr/fit_svg_text.py:37-43 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) book-ar/svg_lib.py:91 — book-ar/svg_lib.py:91-107 | book-en/svg_lib.py:87-103 | book-es/svg_lib.py:87-103 | book-id/svg_lib.py:87-103 | book-ru/svg_lib.py:87-103 | book-tr/svg_lib.py:87-103 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) book-ar/svg_lib.py:142 — book-ar/svg_lib.py:142-159 | book-en/svg_lib.py:126-143 | book-es/svg_lib.py:126-143 | book-id/svg_lib.py:126-143 | book-ru/svg_lib.py:126-143 | book-tr/svg_lib.py:126-143 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) book-ar/svg_lib.py:163 — book-ar/svg_lib.py:163-180 | book-en/svg_lib.py:147-164 | book-es/svg_lib.py:147-164 | book-id/svg_lib.py:147-164 | book-ru/svg_lib.py:147-164 | book-tr/svg_lib.py:147-164 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) book-ar/svg_lib.py:315 — book-ar/svg_lib.py:315-321 | book-en/svg_lib.py:289-295 | book-es/svg_lib.py:289-295 | book-id/svg_lib.py:289-295 | book-ru/svg_lib.py:289-295 | book-tr/svg_lib.py:289-295 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) book-ar/svg_lib.py:324 — book-ar/svg_lib.py:324-364 | book-en/svg_lib.py:298-338 | book-es/svg_lib.py:298-338 | book-id/svg_lib.py:298-338 | book-ru/svg_lib.py:298-338 | book-tr/svg_lib.py:298-338 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) book-ar/svg_lib.py:370 — book-ar/svg_lib.py:370-380 | book-en/svg_lib.py:344-354 | book-es/svg_lib.py:344-354 | book-id/svg_lib.py:344-354 | book-ru/svg_lib.py:344-354 | book-tr/svg_lib.py:344-354 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) book-ar/svg_lib.py:383 — book-ar/svg_lib.py:383-391 | book-en/svg_lib.py:357-365 | book-es/svg_lib.py:357-365 | book-id/svg_lib.py:357-365 | book-ru/svg_lib.py:357-365 | book-tr/svg_lib.py:357-365 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) book-ar/svg_lib.py:394 — book-ar/svg_lib.py:394-406 | book-en/svg_lib.py:368-380 | book-es/svg_lib.py:368-380 | book-id/svg_lib.py:368-380 | book-ru/svg_lib.py:368-380 | book-tr/svg_lib.py:368-380 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) book-ar/svg_lib.py:418 — book-ar/svg_lib.py:418-448 | book-en/svg_lib.py:392-422 | book-es/svg_lib.py:392-422 | book-id/svg_lib.py:392-422 | book-ru/svg_lib.py:392-422 | book-tr/svg_lib.py:392-422 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) book-ar/svg_lib.py:451 — book-ar/svg_lib.py:451-463 | book-en/svg_lib.py:425-437 | book-es/svg_lib.py:425-437 | book-id/svg_lib.py:425-437 | book-ru/svg_lib.py:425-437 | book-tr/svg_lib.py:425-437 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) book-ar/svg_lib.py:523 — book-ar/svg_lib.py:523-530 | book-en/svg_lib.py:497-504 | book-es/svg_lib.py:497-504 | book-id/svg_lib.py:497-504 | book-ru/svg_lib.py:497-504 | book-tr/svg_lib.py:497-504 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) book-ar/svg_lib.py:539 — book-ar/svg_lib.py:539-546 | book-en/svg_lib.py:513-520 | book-es/svg_lib.py:513-520 | book-id/svg_lib.py:513-520 | book-ru/svg_lib.py:513-520 | book-tr/svg_lib.py:513-520 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) book-ar/svg_lib.py:549 — book-ar/svg_lib.py:549-564 | book-en/svg_lib.py:523-538 | book-es/svg_lib.py:523-538 | book-id/svg_lib.py:523-538 | book-ru/svg_lib.py:523-538 | book-tr/svg_lib.py:523-538 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) book-ar/svg_lib.py:614 — book-ar/svg_lib.py:614-632 | book-en/svg_lib.py:588-606 | book-es/svg_lib.py:588-606 | book-id/svg_lib.py:588-606 | book-ru/svg_lib.py:588-606 | book-tr/svg_lib.py:588-606 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) book-ar/svg_lib.py:636 — book-ar/svg_lib.py:636-645 | book-en/svg_lib.py:610-619 | book-es/svg_lib.py:610-619 | book-id/svg_lib.py:610-619 | book-ru/svg_lib.py:610-619 | book-tr/svg_lib.py:610-619 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) book-ar/svg_lib.py:668 — book-ar/svg_lib.py:668-692 | book-en/svg_lib.py:642-666 | book-es/svg_lib.py:642-666 | book-id/svg_lib.py:642-666 | book-ru/svg_lib.py:642-666 | book-tr/svg_lib.py:642-666 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) book-en/strip_titles.py:38 — book-en/strip_titles.py:38-91 | book-id/strip_titles.py:37-90 | book-ta/strip_titles.py:38-91 | book-tr/strip_titles.py:37-90 | book-zhtw/strip_titles.py:37-90 | book/strip_titles.py:37-90 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) book-en/strip_titles.py:95 — book-en/strip_titles.py:95-108 | book-id/strip_titles.py:94-107 | book-ta/strip_titles.py:95-108 | book-tr/strip_titles.py:94-107 | book-zhtw/strip_titles.py:94-107 | book/strip_titles.py:94-107 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) chapter5/adaptive-log-parser/agent.py:78 — chapter5/adaptive-log-parser/agent.py:78-92 | chapter5/code-for-logic/demo.py:66-80 | chapter5/dynamic-form/demo.py:62-76 | chapter5/log-diagnosis/diagnoser.py:24-38 | chapter5/small-model-codified-rules/agent.py:32-46 | chapter5/video-edit/agents.py:29-43 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
X3 · Exception handling · Swallowed exception (caught, then discarded) · ×19
  • Swallowed exception (caught, then discarded) chapter9/self-modifying-agent/evolution.py:224 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) REDACTED:49 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) REDACTED:100 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) REDACTED:114 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) REDACTED:154 — `except (Exception, SystemExit)` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) chapter9/self-evolving-tools/tool_manager.py:140 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) chapter9/self-evolving-tools/tool_manager.py:151 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) chapter9/hermes-self-evolution/run_downstream_ablation.py:195 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) REDACTED:419 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) REDACTED:439 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) REDACTED:465 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) chapter9/harness-safety-gate/safety_policy_gate.py:136 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) chapter9/browser-use-rpa/browser-use/browser_use/tools/service.py:498 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) chapter9/browser-use-rpa/browser-use/browser_use/tools/registry/service.py:366 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) chapter9/browser-use-rpa/browser-use/browser_use/tokens/service.py:106 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) chapter9/browser-use-rpa/browser-use/browser_use/tokens/service.py:122 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) chapter9/browser-use-rpa/browser-use/browser_use/telemetry/service.py:110 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) chapter9/browser-use-rpa/browser-use/browser_use/llm/openai/chat.py:261 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) chapter9/browser-use-rpa/browser-use/browser_use/filesystem/file_system.py:262 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
D15 · Churn × Complexity Hotspots · Repeated repair · ×18
  • Repeated repair: chapter5/video-edit/video_editor.py chapter5/video-edit/video_editor.py:71 — chapter5/video-edit/video_editor.py changed 9 times in last 90 days and 7 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 12 (its worst body is video_editor._apply_edit_ffmpeg at line 71), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(video-edit): revert drive-by regressions and keep atempo scaling for factor=0.5”; “fix(video-edit): drop unrelated atempo/makedirs drive-bys”; “fix(video-edit): skip slowmo when factor is null”; “fix(video): skip slowmo when factor is not positive (#314)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter5/video-edit/video_editor.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: chapter5/conversational-ui/agent.py chapter5/conversational-ui/agent.py:128 — chapter5/conversational-ui/agent.py changed 9 times in last 90 days and 5 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 11 (its worst body is agent.customize at line 128), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(conversational-ui): drop apply_edits file items missing a string content (#459)”; “fix(conversational-ui): skip non-dict apply_edits file entries (#406)”; “fix(conversational-ui): tolerate malformed apply_edits JSON (#401)”; “fix(chapter5): LLM-JSON robustness, bare output paths, ffprobe N/A”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter5/conversational-ui/agent.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: chapter4/collaboration-tools/src/timer_tools.py chapter4/collaboration-tools/src/timer_tools.py:345 — chapter4/collaboration-tools/src/timer_tools.py changed 5 times in last 90 days and 5 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 12 (its worst body is timer_tools._run_recurring_timer at line 345), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(timer-tools): handle timezone-aware expiry_time in status and loading (#743)”; “fix(timer-tools): trigger callback and persist state when active timer expires on load (#702)”; “fix(cron): reject non-positive recurring timer intervals (#388)”; “fix(collaboration-tools): honor max_occurrences=0 for recurring timers (#355)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter4/collaboration-tools/src/timer_tools.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: chapter5/coding-agent/tools/bash_tool.py chapter5/coding-agent/tools/bash_tool.py:18 — chapter5/coding-agent/tools/bash_tool.py changed 5 times in last 90 days and 5 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 6 (its worst body is BashTool._execute_impl at line 18), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(coding-agent): support shell commands on Windows (#413)”; “fix(bash): treat timeout_ms 0 like omit (#310)”; “fix(bash): honor sub-second timeouts (#172)”; “fix(coding_agent): repair background output, timeout, and binary detection”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter5/coding-agent/tools/bash_tool.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: REDACTED REDACTED:466 — REDACTED changed 7 times in last 90 days and 4 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 14 (its worst body is GraphRAGIndexer.multi_hop_search at line 466), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(structured-index): return empty list for non-positive top_k in GraphRAGIndexer.search (#510)”; “fix(chapter3): don't mutate self.communities while iterating it (#127)”; “fix(chapter3): treat GraphRAG chunk_overlap as a word budget, not a sentence count”; “Revert "Merge pull request #12 from nsdevaraj/main"”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- REDACTED`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: chapter4/execution-tools/multilang_executor.py chapter4/execution-tools/multilang_executor.py:166 — chapter4/execution-tools/multilang_executor.py changed 6 times in last 90 days and 4 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 12 (its worst body is LanguageExecutor._run_command at line 166), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(ch4): make execution-tools run on Windows via Git Bash / WSL instead of dying on /bin/bash (#1116)”; “fix(chapter4): drain subprocess pipes concurrently with the wait (#112)”; “fix(multilang): default null language to python (#44)”; “fix(multilang_executor): read full stdout/stderr after process exit”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter4/execution-tools/multilang_executor.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: chapter5/coding-agent/tools/read_tool.py chapter5/coding-agent/tools/read_tool.py:56 — chapter5/coding-agent/tools/read_tool.py changed 4 times in last 90 days and 4 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 12 (its worst body is ReadTool._read_text at line 56), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(read): do not report nonempty file as empty when limit is 0 (#364)”; “fix(read): treat negative limit as read-to-EOF (#317)”; “fix(coding_agent): repair background output, timeout, and binary detection”; “fix(coding_agent): default null Read offset and limit (#37)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter5/coding-agent/tools/read_tool.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: chapter3/user-memory/conversation_history.py chapter3/user-memory/conversation_history.py:145 — chapter3/user-memory/conversation_history.py changed 5 times in last 90 days and 3 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 8 (its worst body is ConversationHistory.search_history at line 145), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(user-memory): honor limit=0 in search_history (#656)”; “fix(user-memory): return empty recent turns for limit=0 (#398)”; “fix(chapter3): robust memory paths, tool args, empty-input guards”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter3/user-memory/conversation_history.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: chapter5/video-edit/agents.py chapter5/video-edit/agents.py:53 — chapter5/video-edit/agents.py changed 5 times in last 90 days and 3 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 11 (its worst body is agents.client at line 53), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(video-edit): parse first JSON object when extras follow (#366)”; “fix(chapter5): LLM-JSON robustness, bare output paths, ffprobe N/A”; “Revert "Merge pull request #12 from nsdevaraj/main"”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter5/video-edit/agents.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: scripts/gen_star_history.py scripts/gen_star_history.py:447 — scripts/gen_star_history.py changed 4 times in last 90 days and 3 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 12 (its worst body is gen_star_history.pick_xticks at line 447), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(star-history): 改用 GraphQL 增量拉取,修复超过 4 万星标后的 CI 失败 (#964)”; “fix(scripts): support various ISO 8601 formats in gen_star_history (#790)”; “fix(star-history): make x-axis adapt to the length of the history (#751)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- scripts/gen_star_history.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: REDACTED REDACTED:173 — REDACTED changed 4 times in last 90 days and 3 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 13 (its worst body is QLearningAgent.train at line 173), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(ch1): guard against empty evaluation windows in RL and LLM learning agents (#900)”; “fix(learning-from-experience): avoid ZeroDivisionError when episode_victories is empty in QLearningAgent”; “fix(chapter1): guard zero-episode divisions in RL/LLM agents”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- REDACTED`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: chapter4/active-tool-selection/semantic_router.py chapter4/active-tool-selection/semantic_router.py:261 — chapter4/active-tool-selection/semantic_router.py changed 4 times in last 90 days and 3 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 8 (its worst body is StructuredRequestParser.parse_request at line 261), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(ch4): handle stop-words queries in SemanticRouter (#795)”; “fix(active-tool-selection): search for closing tag after opening tag in parse_request (#700)”; “chapter4: 工具四件套补齐统一 CLI + 离线演示 + 真实 bug 修复”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter4/active-tool-selection/semantic_router.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: chapter4/active-tool-selection/agent.py chapter4/active-tool-selection/agent.py:137 — chapter4/active-tool-selection/agent.py changed 4 times in last 90 days and 3 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 5 (its worst body is ActiveToolAgent._call_llm at line 137), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(chapter4): null usage, zero num_frames, malformed env vars”; “Revert "Merge pull request #12 from nsdevaraj/main"”; “chapter4: 工具四件套补齐统一 CLI + 离线演示 + 真实 bug 修复”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter4/active-tool-selection/agent.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: scripts/site_source_paths.py scripts/site_source_paths.py:65 — scripts/site_source_paths.py changed 3 times in last 90 days and 3 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 6 (its worst body is site_source_paths.git_commit_range at line 65), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(site): 修复章节页「编辑此页」「查看源代码」按钮 404 (#1024)”; “fix(scripts): normalize leading slash in source_path_for_page URIs (#712)”; “fix(site): filter ignored_commits when determining creation date (#655)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- scripts/site_source_paths.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: chapter4/execution-tools/file_tools.py chapter4/execution-tools/file_tools.py:34 — chapter4/execution-tools/file_tools.py changed 3 times in last 90 days and 3 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 11 (its worst body is FileTools.write_file at line 34), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix: replace bare except clauses and add encoding=utf-8 across all chapter code (#805)”; “fix(file-tools): reject empty search in edit_file (#389)”; “Fix file_tools.py: use zip_longest in _generate_diff to show all diff lines”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter4/execution-tools/file_tools.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: scripts/mkdocs_pandoc_strip.py scripts/mkdocs_pandoc_strip.py:18 — scripts/mkdocs_pandoc_strip.py changed 3 times in last 90 days and 3 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 5 (its worst body is mkdocs_pandoc_strip.on_page_markdown at line 18), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(mkdocs): handle None or empty markdown input in pandoc strip hook (#781)”; “fix(docs): protect code blocks and support combined Pandoc attributes in mkdocs_pandoc_strip (#646)”; “Fix up GitHub Pages site from PR #65”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- scripts/mkdocs_pandoc_strip.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: chapter5/coding-agent/tools/bash_output_tool.py chapter5/coding-agent/tools/bash_output_tool.py:19 — chapter5/coding-agent/tools/bash_output_tool.py changed 3 times in last 90 days and 3 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 6 (its worst body is BashOutputTool._execute_impl at line 19), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(coding-agent): support shell commands on Windows (#413)”; “fix(chapter5): make BashOutput return only new output, as documented (#141)”; “fix(coding_agent): repair background output, timeout, and binary detection”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter5/coding-agent/tools/bash_output_tool.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: chapter4/perception-tools/src/document_processing_tools.py chapter4/perception-tools/src/document_processing_tools.py:175 — chapter4/perception-tools/src/document_processing_tools.py changed 3 times in last 90 days and 3 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 7 (its worst body is document_processing_tools.extract_pptx_content at line 175), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(perception-tools): skip empty segments in parse_page_range (#353)”; “fix(chapter4): clamp the lower bound of a PDF page range (#152)”; “fix(csv): honor max_rows in extract_csv_content data (#129)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 03:03:28 +00:00' --until='2026-09-30 03:03:28 +00:00' --full-history --no-merges -- chapter4/perception-tools/src/document_processing_tools.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
D4 · Code Duplication · Duplicated block (10 lines × 2) · ×18
  • Duplicated block (10 lines × 2) chapter1/context/main.py:1004 — chapter1/context/main.py:1004-1013 | chapter1/context/main.py:1139-1148 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10 lines × 2) REDACTED:34 — REDACTED:34-43 | REDACTED:163-172 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (10 lines × 2) chapter10/multi-role-transfer/run_comparison.py:95 — chapter10/multi-role-transfer/run_comparison.py:95-104 | chapter7/openvla-robotwin2-eval/experiment.py:451-460 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (10 lines × 2) chapter10/voice-werewolf/werewolf/game.py:303 — chapter10/voice-werewolf/werewolf/game.py:303-312 | chapter10/voice-werewolf/werewolf/game.py:325-334 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10 lines × 2) REDACTED:976 — REDACTED:976-985 | REDACTED:1208-1217 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:976` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (10 lines × 2) chapter3/agentic-rag-for-user-memory/main.py:87 — chapter3/agentic-rag-for-user-memory/main.py:87-96 | chapter3/contextual-retrieval-for-user-memory/main.py:90-99 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (10 lines × 2) REDACTED:128 — REDACTED:128-137 | chapter3/contextual-retrieval/index_local_laws_contextual.py:142-151 — `REDACTED` and `chapter3/contextual-retrieval/index_local_laws_contextual.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 7 separate duplicated blocks between them, totalling at least 122 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (10 lines × 2) chapter5/adaptive-log-parser/agent.py:97 — chapter5/adaptive-log-parser/agent.py:97-106 | chapter5/dynamic-form/demo.py:83-92 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (10 lines × 2) chapter5/permission-embedded-data-objects/pedo/core/store.py:237 — chapter5/permission-embedded-data-objects/pedo/core/store.py:237-246 | chapter5/permission-embedded-data-objects/pedo/core/store.py:287-296 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10 lines × 2) chapter5/permission-embedded-data-objects/pedo/core/store.py:524 — chapter5/permission-embedded-data-objects/pedo/core/store.py:524-533 | chapter5/permission-embedded-data-objects/pedo/core/store.py:545-554 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `chapter5/permission-embedded-data-objects/pedo/core/store.py:534` calls `error` and `chapter5/permission-embedded-data-objects/pedo/core/store.py:555` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 2) chapter5/permission-embedded-data-objects/pedo/eval/benchmark_overhead.py:104 — chapter5/permission-embedded-data-objects/pedo/eval/benchmark_overhead.py:104-113 | chapter5/permission-embedded-data-objects/pedo/eval/benchmark_overhead.py:155-164 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10 lines × 2) REDACTED:407 — REDACTED:407-416 | REDACTED:458-467 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:407` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `REDACTED:403` calls `except` and `REDACTED:455` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 2) chapter8/premature-completion-dpo/build_preference_data.py:66 — chapter8/premature-completion-dpo/build_preference_data.py:66-75 | chapter8/premature-completion-dpo/evaluate.py:146-155 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `chapter8/premature-completion-dpo/build_preference_data.py:66` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (10 lines × 2) chapter8/speech-sft-experiment/run_orpheus.py:194 — chapter8/speech-sft-experiment/run_orpheus.py:194-203 | chapter8/speech-sft-experiment/run_sesame.py:185-194 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (10 lines × 2) chapter9/harness-safety-gate/run_experiment_9_7.py:110 — chapter9/harness-safety-gate/run_experiment_9_7.py:110-119 | chapter9/self-modifying-agent/run_experiment_9_6.py:105-114 — before extracting anything, compare `chapter9/harness-safety-gate/run_experiment_9_7.py` and `chapter9/self-modifying-agent/run_experiment_9_6.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 40 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (10 lines × 2) chapter3/agentic-rag-for-user-memory/agent.py:373 — chapter3/agentic-rag-for-user-memory/agent.py:373-382 | chapter3/contextual-retrieval-for-user-memory/agent.py:369-378 — `chapter3/agentic-rag-for-user-memory/agent.py` and `chapter3/contextual-retrieval-for-user-memory/agent.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 278 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (10 lines × 2) REDACTED:94 — REDACTED:94-103 | REDACTED:94-103 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 271 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (10 lines × 2) chapter4/collaboration-tools/src/config.py:15 — chapter4/collaboration-tools/src/config.py:15-24 | chapter4/execution-tools/config.py:14-23 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (8 lines × 2) · ×18
  • Duplicated block (8 lines × 2) chapter10/book-translation/run_official_experiment.py:199 — chapter10/book-translation/run_official_experiment.py:199-206 | REDACTED:155-162 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (8 lines × 2) chapter10/parallel-web-research/llm.py:62 — chapter10/parallel-web-research/llm.py:62-69 | chapter10/voice-werewolf/werewolf/strategy_audit.py:115-122 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (8 lines × 2) chapter2/agent-skills-ppt/skills/pptx/scripts/generate_pptx.py:50 — chapter2/agent-skills-ppt/skills/pptx/scripts/generate_pptx.py:50-57 | chapter2/agent-skills-ppt/skills/pptx/scripts/generate_pptx.py:63-70 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (8 lines × 2) REDACTED:384 — REDACTED:384-391 | REDACTED:384-391 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 13 separate duplicated blocks between them, totalling at least 349 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (8 lines × 2) chapter3/agentic-rag/tools.py:72 — chapter3/agentic-rag/tools.py:72-79 | chapter3/contextual-retrieval/tools.py:71-78 — `chapter3/agentic-rag/tools.py` and `chapter3/contextual-retrieval/tools.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 14 separate duplicated blocks between them, totalling at least 341 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (8 lines × 2) chapter3/sparse-embedding/demo.py:115 — chapter3/sparse-embedding/demo.py:115-122 | chapter3/sparse-embedding/demo.py:184-191 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `chapter3/sparse-embedding/demo.py:194` calls `info` and `chapter3/sparse-embedding/demo.py:123` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 2) chapter3/user-memory/memory_manager.py:426 — chapter3/user-memory/memory_manager.py:426-433 | chapter3/user-memory/memory_manager.py:454-461 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `chapter3/user-memory/memory_manager.py:463` calls `str` and `chapter3/user-memory/memory_manager.py:435` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 2) REDACTED:113 — REDACTED:113-120 | REDACTED:128-135 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (8 lines × 2) REDACTED:713 — REDACTED:713-720 | REDACTED:733-740 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (8 lines × 2) chapter5/permission-embedded-data-objects/pedo/eval/dataguardbench/agentspec_wrap.py:52 — chapter5/permission-embedded-data-objects/pedo/eval/dataguardbench/agentspec_wrap.py:52-59 | chapter5/permission-embedded-data-objects/pedo/eval/dataguardbench/agentspec_wrap.py:62-69 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter5/permission-embedded-data-objects/pedo/eval/dataguardbench/agentspec_wrap.py:52` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) chapter5/permission-embedded-data-objects/pedo/eval/dataguardbench/agentspec_wrap.py:103 — chapter5/permission-embedded-data-objects/pedo/eval/dataguardbench/agentspec_wrap.py:103-111 | chapter5/permission-embedded-data-objects/pedo/eval/dataguardbench/agentspec_wrap.py:122-129 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter5/permission-embedded-data-objects/pedo/eval/dataguardbench/agentspec_wrap.py:103` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) chapter5/permission-embedded-data-objects/pedo/eval/dataguardbench/agentspec_wrap.py:208 — chapter5/permission-embedded-data-objects/pedo/eval/dataguardbench/agentspec_wrap.py:208-215 | chapter5/permission-embedded-data-objects/pedo/eval/dataguardbench/agentspec_wrap.py:231-238 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (8 lines × 2) chapter7/model-benchmark/campaign.py:329 — chapter7/model-benchmark/campaign.py:329-336 | chapter7/model-benchmark/campaign.py:339-355 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (8 lines × 2) chapter7/model-benchmark/campaign.py:693 — chapter7/model-benchmark/campaign.py:693-700 | chapter7/model-benchmark/campaign.py:783-790 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter7/model-benchmark/campaign.py:693` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (8 lines × 2) REDACTED:292 — REDACTED:292-299 | REDACTED:244-251 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (8 lines × 2) chapter8/MiniMind-pretrain/validation/validate_evidence.py:84 — chapter8/MiniMind-pretrain/validation/validate_evidence.py:84-91 | chapter8/continued-pretraining/validation/validate_evidence.py:47-54 — before extracting anything, compare `chapter8/MiniMind-pretrain/validation/validate_evidence.py` and `chapter8/continued-pretraining/validation/validate_evidence.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 69 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (8 lines × 2) chapter5/permission-embedded-data-objects/pedo/scenarios/hiring.py:97 — chapter5/permission-embedded-data-objects/pedo/scenarios/hiring.py:97-105 | chapter5/permission-embedded-data-objects/pedo/scenarios/project_mgmt.py:86-93 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (8 lines × 2) chapter9/harness-safety-gate/run_experiment_9_7.py:212 — chapter9/harness-safety-gate/run_experiment_9_7.py:212-219 | chapter9/self-modifying-agent/run_experiment_9_6.py:117-124 — before extracting anything, compare `chapter9/harness-safety-gate/run_experiment_9_7.py` and `chapter9/self-modifying-agent/run_experiment_9_6.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 40 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) · ×17
  • Members sharing a duplicated core (4 members, 50+ identical tokens) chapter1/learning-from-experience/experiment.py:498 — chapter1/learning-from-experience/experiment.py:498-650 | chapter3/agentic-rag-for-user-memory/offline_demo.py:260-282 | chapter5/code-for-logic/build_puzzles.py:171-200 | chapter5/code-for-logic/demo.py:490-636 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) chapter3/agentic-rag-for-user-memory/agent.py:202 — chapter3/agentic-rag-for-user-memory/agent.py:202-358 | chapter3/agentic-rag/agent.py:232-363 | chapter3/contextual-retrieval-for-user-memory/agent.py:198-354 | chapter3/contextual-retrieval/agent.py:173-288 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) REDACTED:313 — REDACTED:313-349 | chapter3/agentic-rag-for-user-memory/indexer.py:518-573 | REDACTED:313-349 | chapter3/contextual-retrieval-for-user-memory/indexer.py:402-457 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) chapter3/agentic-rag/evaluation/evaluate.py:301 — chapter3/agentic-rag/evaluation/evaluate.py:301-338 | chapter3/agentic-rag/evaluation/evaluate.py:341-368 | chapter3/contextual-retrieval/evaluation/evaluate.py:293-330 | chapter3/contextual-retrieval/evaluation/evaluate.py:333-360 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) chapter3/agentic-rag/tools.py:333 — chapter3/agentic-rag/tools.py:333-347 | chapter3/agentic-rag/tools.py:350-373 | chapter3/contextual-retrieval/tools.py:338-352 | chapter3/contextual-retrieval/tools.py:355-378 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) chapter3/agentic-rag/tools.py:376 — chapter3/agentic-rag/tools.py:376-410 | chapter3/agentic-rag/tools.py:413-463 | chapter3/contextual-retrieval/tools.py:381-415 | chapter3/contextual-retrieval/tools.py:418-468 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) chapter4/multimodal-agent/demo.py:32 — chapter4/multimodal-agent/demo.py:32-135 | chapter4/multimodal-agent/demo.py:139-196 | chapter4/multimodal-agent/main.py:37-92 | chapter4/multimodal-agent/main.py:96-236 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) chapter5/adaptive-log-parser/campaign.py:249 — chapter5/adaptive-log-parser/campaign.py:249-324 | REDACTED:222-383 | chapter5/dynamic-form/campaign.py:192-335 | chapter5/erp-agent/campaign_postgres.py:268-402 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) REDACTED:57 — REDACTED:57-98 | REDACTED:57-96 | REDACTED:57-96 | REDACTED:57-96 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) REDACTED:125 — REDACTED:125-174 | REDACTED:123-172 | REDACTED:123-172 | REDACTED:123-172 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) REDACTED:178 — REDACTED:178-217 | REDACTED:176-215 | REDACTED:176-215 | REDACTED:176-215 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) REDACTED:198 — REDACTED:198-236 | REDACTED:191-243 | REDACTED:375-432 | REDACTED:242-285 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) REDACTED:46 — REDACTED:46-81 | REDACTED:235-339 | REDACTED:402-548 | chapter5/permission-embedded-data-objects/pedo/eval/benchmark_reactions.py:31-120 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:57 — chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:57-164 | chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:236-300 | chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:351-422 | chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:481-560 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) chapter6/astra-async-steering/experiment.py:69 — chapter6/astra-async-steering/experiment.py:69-79 | chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:69-79 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:69-79 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:69-79 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) chapter6/astra-async-steering/experiment.py:89 — chapter6/astra-async-steering/experiment.py:89-94 | chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:89-94 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:89-94 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:89-94 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) chapter8/prompt-distillation/compare.py:265 — chapter8/prompt-distillation/compare.py:265-351 | chapter8/prompt-distillation/create_data.py:371-440 | chapter8/prompt-distillation/evaluate.py:334-535 | chapter8/prompt-distillation/train_sft_trl.py:301-485 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D17 · Explicit Debt · TodoComment · ×16
  • TodoComment REDACTED:394 — ## TODO List Management Rules: — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment REDACTED:157 — ## TODO List Management Rules: — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment REDACTED:678 — # Always add TODO management tools if enabled — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment chapter5/coding-agent/example_complex_task.py:70 — # Show TODO updates — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment chapter5/coding-agent/example_with_system_hints.py:86 — # Show TODO updates — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment chapter5/coding-agent/system_state.py:45 — # TODO list — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment chapter4/perception-tools/src/filesystem_tools.py:528 — # TODO: Integrate with LLM API for better summarization — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment REDACTED:86 — # TODO: Update centroid embedding — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment REDACTED:411 — # Add TODO management tools if enabled — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment REDACTED:794 — # Update TODO list — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment chapter2/system-hint/main.py:400 — # --- 案例 3:TODO 列表管理 ------------------------------------------- — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment chapter2/system-hint/quickstart.py:117 — # TODO list summary — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment chapter2/system-hint/quickstart.py:123 — # Show first few TODO items — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment chapter2/system-hint/test_basic.py:72 — # Test TODO list operations — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment chapter2/system-hint/test_basic.py:89 — # Verify TODO list state — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment chapter2/system-hint/view_trajectory.py:53 — # Show TODO list if present — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
P7 · Outbound HTTP resilience · Outbound HTTP without resilience · ×16
  • Outbound HTTP without resilience chapter2/local_llm_serving/server.py:116 — `requests.get(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience chapter2/prompt-engineering/tau_bench/model_utils/model/vllm_utils.py:24 — `requests.post(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience chapter3/agentic-rag-for-user-memory/indexer.py:316 — `requests.post(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience chapter3/contextual-retrieval-for-user-memory/indexer.py:215 — `requests.post(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience chapter4/collaboration-tools/src/notification_tools.py:243 — `httpx.AsyncClient(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience chapter4/collaboration-tools/src/notification_tools.py:300 — `httpx.AsyncClient(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience chapter4/collaboration-tools/src/notification_tools.py:350 — `httpx.AsyncClient(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience chapter4/multimodal-agent/agent.py:81 — `httpx.get(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience chapter6/live-audio/backend/utils/providers/llmProviders.js:69 — `axios.post(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience chapter6/live-audio/backend/utils/providers/llmProviders.js:121 — `axios.post(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience chapter6/live-audio/backend/utils/providers/llmProviders.js:183 — `axios.post(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience chapter7/elo-leaderboard/data_loader.py:33 — `requests.get(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience REDACTED:996 — `urllib.request.urlopen(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience chapter9/browser-use-rpa/browser-use/browser_use/llm/azure/chat.py:85 — `httpx.AsyncClient(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience chapter9/browser-use-rpa/browser-use/browser_use/sync/auth.py:144 — `httpx.AsyncClient(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience chapter9/browser-use-rpa/browser-use/browser_use/sync/auth.py:222 — `httpx.AsyncClient(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
X17 · Uncapped recursion over a caller-supplied document · Recursive walk over a caller-supplied document has no depth cap · ×16
  • Recursive walk over a caller-supplied document has no depth cap chapter9/prompt-auto-optimization/config.py:61 — `record_completion` is public, takes a document from its caller (line 139) and hands it to `_jsonable`, which calls itself at line 61 (`_jsonable`) with a piece of `value` (and at line 63, line 65) — and nowhere in `_jsonable` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `_jsonable` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
  • Recursive walk over a caller-supplied document has no depth cap chapter9/harness-safety-gate/safety_policy_gate.py:188 — `inspect_path_traversal` is public, takes a document from its caller (line 194) and hands it to `_extract_string_values`, which calls itself at line 188 (`self._extract_string_values`) with a piece of `obj` (and at line 191) — and nowhere in `_extract_string_values` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `_extract_string_values` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
  • Recursive walk over a caller-supplied document has no depth cap chapter7/model-benchmark/campaign.py:45 — `expand_env` is public and takes `value: Any` from its caller, and it calls itself at line 45 (`expand_env`) with a piece of `value` (and at line 47) — and nowhere in `expand_env` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `expand_env` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
  • Recursive walk over a caller-supplied document has no depth cap chapter6/computer-use-open-model/main.py:69 — `scrub_value` is public and takes `value: Any` from its caller, and it calls itself at line 69 (`scrub_value`) with a piece of `value` (and at line 71) — and nowhere in `scrub_value` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `scrub_value` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
  • Recursive walk over a caller-supplied document has no depth cap chapter6/claude-computer-use-native/run_weather_task.py:52 — `json_safe` is public and takes `value: Any` from its caller, and it calls itself at line 52 (`json_safe`) with a piece of `value` (and at line 54, line 56) — and nowhere in `json_safe` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `json_safe` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
  • Recursive walk over a caller-supplied document has no depth cap chapter6/agent-with-event-trigger/unipile_mailbox_experiment.py:91 — `redacted` is public and takes `value: Any` from its caller, and it calls itself at line 91 (`redacted`) with a piece of `value` (and at line 94) — and nowhere in `redacted` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `redacted` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
  • Recursive walk over a caller-supplied document has no depth cap chapter6/agent-with-event-trigger/unipile_mailbox_experiment.py:273 — `account_email` is public and takes `account: dict[str, Any]` from its caller, and it calls itself at line 273 (`account_email`) with a piece of `account` — and nowhere in `account_email` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `account_email` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
  • Recursive walk over a caller-supplied document has no depth cap chapter5/erp-agent/campaign_postgres.py:73 — `jsonable` is public and takes `value: Any` from its caller, and it calls itself at line 73 (`jsonable`) with a piece of `value` (and at line 75) — and nowhere in `jsonable` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `jsonable` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
  • Recursive walk over a caller-supplied document has no depth cap REDACTED:63 — `convert_expression` is public and takes `node: Any` from its caller, and it calls itself at line 63 (`convert_expression`) with a piece of `node` (and at line 68, line 69) — and nowhere in `convert_expression` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `convert_expression` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
  • Recursive walk over a caller-supplied document has no depth cap chapter4/collaboration-tools/run_experiment_4_5.py:160 — `redact_material` is public and takes `value: Any` from its caller, and it calls itself at line 160 (`redact_material`) with a piece of `value` (and at line 162) — and nowhere in `redact_material` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `redact_material` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
  • Recursive walk over a caller-supplied document has no depth cap chapter4/collaboration-tools/run_experiment_4_5.py:198 — `parse_value` is public and takes `value: Any` from its caller, and it calls itself at line 198 (`parse_value`) with a piece of `value` — and nowhere in `parse_value` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `parse_value` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
  • Recursive walk over a caller-supplied document has no depth cap chapter3/experiment_utils.py:53 — `jsonable` is public and takes `value: Any` from its caller, and it calls itself at line 53 (`jsonable`) with a piece of `value` (and at line 55, line 57, line 59) — and nowhere in `jsonable` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `jsonable` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
  • Recursive walk over a caller-supplied document has no depth cap chapter2/prompt-engineering/tau_bench/model_utils/api/cache.py:52 — `hash_item` is public and takes `item: Any` from its caller, and it calls itself at line 52 (`hash_item`) with a piece of `item` (and at line 56, line 60, line 63, line 70) — and nowhere in `hash_item` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `hash_item` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
  • Recursive walk over a caller-supplied document has no depth cap chapter2/prompt-engineering/tau_bench/model_utils/api/datapoint.py:35 — `dict_equal` is public and takes `d1: dict` from its caller, and it calls itself at line 35 (`dict_equal`) with a piece of `d1` — and nowhere in `dict_equal` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `dict_equal` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
  • Recursive walk over a caller-supplied document has no depth cap chapter2/prompt-engineering/tau_bench/model_utils/api/logging.py:20 — `prep_for_json_serialization` is public and takes `obj: Any` from its caller, and it calls itself at line 20 (`prep_for_json_serialization`) with a piece of `obj` (and at line 22, line 24, line 26, line 28) — and nowhere in `prep_for_json_serialization` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `prep_for_json_serialization` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
  • Recursive walk over a caller-supplied document has no depth cap chapter2/agent-skills-ppt/validate_official_run.py:31 — `iter_values` is public and takes `value: Any` from its caller, and it calls itself at line 31 (`iter_values`) with a piece of `value` (and at line 34) — and nowhere in `iter_values` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `iter_values` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
D29 · Static Analysis (SAST) · REDACTED · ×15
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Duplicated block (16 lines × 2) · ×15
  • Duplicated block (16 lines × 2) REDACTED:129 — REDACTED:129-144 | REDACTED:318-333 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:129` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `REDACTED:336` calls `now`, `MCPServerManager` and `REDACTED:147` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (16 lines × 2) REDACTED:284 — REDACTED:284-299 | REDACTED:529-544 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (16 lines × 2) chapter3/agentic-rag-for-user-memory/main.py:307 — chapter3/agentic-rag-for-user-memory/main.py:307-322 | chapter3/contextual-retrieval-for-user-memory/main.py:552-567 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (16 lines × 2) chapter3/agentic-rag/agent.py:55 — chapter3/agentic-rag/agent.py:55-70 | chapter3/contextual-retrieval/agent.py:40-55 — `chapter3/agentic-rag/agent.py` and `chapter3/contextual-retrieval/agent.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 6 separate duplicated blocks between them, totalling at least 111 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (16 lines × 2) chapter3/agentic-rag/agent.py:214 — chapter3/agentic-rag/agent.py:214-229 | chapter3/contextual-retrieval/agent.py:155-170 — `chapter3/agentic-rag/agent.py` and `chapter3/contextual-retrieval/agent.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 6 separate duplicated blocks between them, totalling at least 111 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (16 lines × 2) chapter3/agentic-rag/agent.py:348 — chapter3/agentic-rag/agent.py:348-363 | chapter3/contextual-retrieval/agent.py:273-288 — `chapter3/agentic-rag/agent.py` and `chapter3/contextual-retrieval/agent.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 6 separate duplicated blocks between them, totalling at least 111 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (16 lines × 2) chapter3/agentic-rag/evaluation/evaluate.py:82 — chapter3/agentic-rag/evaluation/evaluate.py:82-97 | chapter3/contextual-retrieval/evaluation/evaluate.py:74-89 — before extracting anything, compare `chapter3/agentic-rag/evaluation/evaluate.py` and `chapter3/contextual-retrieval/evaluation/evaluate.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 369 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (16 lines × 2) chapter3/agentic-rag/main.py:299 — chapter3/agentic-rag/main.py:299-314 | chapter3/contextual-retrieval/main.py:273-288 — `chapter3/agentic-rag/main.py` and `chapter3/contextual-retrieval/main.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 9 separate duplicated blocks between them, totalling at least 254 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (16 lines × 2) chapter3/dense-embedding/cli.py:146 — chapter3/dense-embedding/cli.py:146-161 | chapter3/sparse-embedding/cli.py:73-88 — `chapter3/dense-embedding/cli.py` and `chapter3/sparse-embedding/cli.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 39 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (16 lines × 2) chapter4/perception-tools/src/search_tools.py:174 — chapter4/perception-tools/src/search_tools.py:174-189 | chapter4/perception-tools/src/search_tools.py:197-212 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter4/perception-tools/src/search_tools.py:174` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:367 — chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:367-382 | chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:493-508 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:367` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) chapter6/agent-with-event-trigger/server.py:246 — chapter6/agent-with-event-trigger/server.py:246-261 | chapter6/agent-with-event-trigger/server_fastapi.py:240-255 — before extracting anything, compare `chapter6/agent-with-event-trigger/server.py` and `chapter6/agent-with-event-trigger/server_fastapi.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 189 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (16 lines × 2) chapter9/hermes-self-evolution/run_acceptance_review.py:59 — chapter9/hermes-self-evolution/run_acceptance_review.py:59-74 | chapter9/hermes-self-evolution/run_review_pass.py:48-63 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (16 lines × 2) chapter6/agent-with-event-trigger/server.py:354 — chapter6/agent-with-event-trigger/server.py:354-369 | chapter6/agent-with-event-trigger/server_fastapi.py:348-363 — before extracting anything, compare `chapter6/agent-with-event-trigger/server.py` and `chapter6/agent-with-event-trigger/server_fastapi.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 189 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (16 lines × 2) chapter6/agent-with-event-trigger/server.py:374 — chapter6/agent-with-event-trigger/server.py:374-389 | chapter6/agent-with-event-trigger/server_fastapi.py:368-383 — before extracting anything, compare `chapter6/agent-with-event-trigger/server.py` and `chapter6/agent-with-event-trigger/server_fastapi.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 189 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
AC3 · Page structure · Page without a main landmark · ×13
  • Page without a main landmark chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/01-cover.html:2 — No <main> (or role="main") means no "skip to content" target and a weaker landmark map. Wrap the primary content in <main>.
  • Page without a main landmark chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/02-problem.html:2 — No <main> (or role="main") means no "skip to content" target and a weaker landmark map. Wrap the primary content in <main>.
  • Page without a main landmark chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/03-keyidea.html:2 — No <main> (or role="main") means no "skip to content" target and a weaker landmark map. Wrap the primary content in <main>.
  • Page without a main landmark chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/04-architecture.html:2 — No <main> (or role="main") means no "skip to content" target and a weaker landmark map. Wrap the primary content in <main>.
  • Page without a main landmark chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/05-attention.html:2 — No <main> (or role="main") means no "skip to content" target and a weaker landmark map. Wrap the primary content in <main>.
  • Page without a main landmark chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/06-building-blocks.html:2 — No <main> (or role="main") means no "skip to content" target and a weaker landmark map. Wrap the primary content in <main>.
  • Page without a main landmark chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/07-why-self-attention.html:2 — No <main> (or role="main") means no "skip to content" target and a weaker landmark map. Wrap the primary content in <main>.
  • Page without a main landmark chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/08-training.html:2 — No <main> (or role="main") means no "skip to content" target and a weaker landmark map. Wrap the primary content in <main>.
  • Page without a main landmark chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/09-results.html:2 — No <main> (or role="main") means no "skip to content" target and a weaker landmark map. Wrap the primary content in <main>.
  • Page without a main landmark chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/10-chart.html:2 — No <main> (or role="main") means no "skip to content" target and a weaker landmark map. Wrap the primary content in <main>.
  • Page without a main landmark chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/11-generalization.html:2 — No <main> (or role="main") means no "skip to content" target and a weaker landmark map. Wrap the primary content in <main>.
  • Page without a main landmark chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/12-interpretability.html:2 — No <main> (or role="main") means no "skip to content" target and a weaker landmark map. Wrap the primary content in <main>.
  • Page without a main landmark chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/slides/13-conclusion.html:2 — No <main> (or role="main") means no "skip to content" target and a weaker landmark map. Wrap the primary content in <main>.
D29 · Static Analysis (SAST) · REDACTED · ×13
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED · ×13
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Duplicated block (11 lines × 2) · ×13
  • Duplicated block (11 lines × 2) REDACTED:298 — REDACTED:298-308 | REDACTED:298-308 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 271 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (11 lines × 2) REDACTED:149 — REDACTED:149-159 | REDACTED:109-119 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 73 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (11 lines × 2) chapter3/contextual-retrieval-for-user-memory/contextual_indexer.py:115 — chapter3/contextual-retrieval-for-user-memory/contextual_indexer.py:115-125 | chapter3/contextual-retrieval-for-user-memory/indexer.py:71-81 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (11 lines × 2) chapter3/dense-embedding/cli.py:240 — chapter3/dense-embedding/cli.py:240-250 | chapter3/sparse-embedding/cli.py:196-206 — `chapter3/dense-embedding/cli.py` and `chapter3/sparse-embedding/cli.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 39 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `chapter3/dense-embedding/cli.py:240` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) chapter4/perception-tools/src/expanded_catalog.py:538 — chapter4/perception-tools/src/expanded_catalog.py:538-548 | chapter4/perception-tools/src/expanded_catalog.py:612-622 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (11 lines × 2) chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:141 — chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:141-151 | chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:396-406 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (11 lines × 2) chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:384 — chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:384-394 | chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:396-406 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (11 lines × 2) chapter6/astra-async-steering/experiment.py:171 — chapter6/astra-async-steering/experiment.py:171-181 | chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:171-181 — before extracting anything, compare `chapter6/astra-async-steering/experiment.py` and `chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 251 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (11 lines × 2) chapter8/sesame/batch_inference.py:151 — chapter8/sesame/batch_inference.py:151-161 | chapter8/sesame/inference.py:135-145 — before extracting anything, compare `chapter8/sesame/batch_inference.py` and `chapter8/sesame/inference.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 80 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (11 lines × 2) chapter9/harness-safety-gate/safety_policy_gate.py:334 — chapter9/harness-safety-gate/safety_policy_gate.py:334-344 | chapter9/harness-safety-gate/safety_policy_gate.py:348-358 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (11 lines × 2) chapter2/prompt-injection/demo.py:184 — chapter2/prompt-injection/demo.py:184-199 | chapter5/erp-agent/demo.py:215-225 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (11 lines × 2) chapter3/agentic-rag-for-user-memory/demo_agent_logging.py:127 — chapter3/agentic-rag-for-user-memory/demo_agent_logging.py:127-137 | chapter3/contextual-retrieval-for-user-memory/demo_agent_logging.py:127-137 — `chapter3/agentic-rag-for-user-memory/demo_agent_logging.py` and `chapter3/contextual-retrieval-for-user-memory/demo_agent_logging.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 106 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (11 lines × 2) chapter5/coding-agent/agent.py:94 — chapter5/coding-agent/agent.py:94-104 | chapter5/coding-agent/agent_new.py:80-90 — before extracting anything, compare `chapter5/coding-agent/agent.py` and `chapter5/coding-agent/agent_new.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 198 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (14 lines × 2) · ×12
  • Duplicated block (14 lines × 2) chapter1/context/main.py:927 — chapter1/context/main.py:927-940 | chapter3/user-memory/main.py:780-796 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (14 lines × 2) chapter1/learning-from-experience/demo.py:120 — chapter1/learning-from-experience/demo.py:120-133 | chapter1/learning-from-experience/quick_demo.py:48-61 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (14 lines × 2) chapter3/agentic-rag/tools.py:333 — chapter3/agentic-rag/tools.py:333-346 | chapter3/contextual-retrieval/tools.py:338-351 — `chapter3/agentic-rag/tools.py` and `chapter3/contextual-retrieval/tools.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 14 separate duplicated blocks between them, totalling at least 341 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (14 lines × 2) chapter3/contextual-retrieval-for-user-memory/contextual_indexer.py:470 — chapter3/contextual-retrieval-for-user-memory/contextual_indexer.py:470-483 | chapter3/contextual-retrieval-for-user-memory/contextual_indexer.py:515-528 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (14 lines × 2) chapter3/user-memory/background_memory_processor.py:217 — chapter3/user-memory/background_memory_processor.py:217-230 | chapter3/user-memory/background_memory_processor.py:292-305 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter3/user-memory/background_memory_processor.py:217` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (14 lines × 2) chapter3/user-memory/quickstart.py:92 — chapter3/user-memory/quickstart.py:92-105 | chapter3/user-memory/quickstart.py:147-160 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter3/user-memory/quickstart.py:92` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:123 — chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:123-136 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:123-136 — before extracting anything, compare `chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py` and `chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 250 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:123` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (14 lines × 2) chapter7/android-world/experiment_core.py:149 — chapter7/android-world/experiment_core.py:149-162 | chapter7/android-world/experiment_core.py:244-257 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `chapter7/android-world/experiment_core.py:258` calls `sum` and `chapter7/android-world/experiment_core.py:163` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 2) REDACTED:331 — REDACTED:331-344 | REDACTED:461-474 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (14 lines × 2) chapter8/MiniMind-pretrain/validation/validate_evidence.py:181 — chapter8/MiniMind-pretrain/validation/validate_evidence.py:181-194 | chapter8/continued-pretraining/validation/validate_evidence.py:110-123 — before extracting anything, compare `chapter8/MiniMind-pretrain/validation/validate_evidence.py` and `chapter8/continued-pretraining/validation/validate_evidence.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 69 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `chapter8/MiniMind-pretrain/validation/validate_evidence.py:179` calls `AssertionError`, `get` and `chapter8/continued-pretraining/validation/validate_evidence.py:109` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 2) REDACTED:734 — REDACTED:734-747 | chapter5/permission-embedded-data-objects/pedo/eval/benchmark_spec_errors.py:425-440 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (14 lines × 2) chapter6/agent-with-event-trigger/server.py:266 — chapter6/agent-with-event-trigger/server.py:266-279 | chapter6/agent-with-event-trigger/server_fastapi.py:260-273 — before extracting anything, compare `chapter6/agent-with-event-trigger/server.py` and `chapter6/agent-with-event-trigger/server_fastapi.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 189 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (5 lines × 3) · ×12
  • Duplicated block (5 lines × 3) chapter3/agentic-rag-for-user-memory/evaluator.py:571 — chapter3/agentic-rag-for-user-memory/evaluator.py:571-575 | chapter3/contextual-retrieval-for-user-memory/contextual_evaluator.py:697-701 | chapter3/contextual-retrieval-for-user-memory/evaluator.py:571-575 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
  • Duplicated block (5 lines × 3) chapter3/agentic-rag-for-user-memory/indexer.py:508 — chapter3/agentic-rag-for-user-memory/indexer.py:508-512 | chapter3/contextual-retrieval-for-user-memory/contextual_indexer.py:592-598 | chapter3/contextual-retrieval-for-user-memory/indexer.py:392-396 — `chapter3/agentic-rag-for-user-memory/indexer.py` and `chapter3/contextual-retrieval-for-user-memory/indexer.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 10 separate duplicated blocks between them, totalling at least 347 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (5 lines × 3) REDACTED:407 — REDACTED:407-411 | REDACTED:433-437 | REDACTED:231-236 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (5 lines × 3) chapter3/structured-knowledge-extraction/generate_data.py:51 — chapter3/structured-knowledge-extraction/generate_data.py:51-55 | chapter3/structured-knowledge-extraction/generate_data.py:91-95 | chapter3/structured-knowledge-extraction/generate_data.py:132-136 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (5 lines × 3) chapter4/collaboration-tools/main.py:290 — chapter4/collaboration-tools/main.py:290-294 | chapter4/collaboration-tools/main.py:322-326 | chapter4/collaboration-tools/main.py:349-353 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (5 lines × 3) chapter5/adaptive-log-parser/agent.py:98 — chapter5/adaptive-log-parser/agent.py:98-103 | chapter5/dynamic-form/demo.py:84-89 | chapter5/log-diagnosis/diagnoser.py:51-55 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Note first that the copies are not typed on the same thing: the declarations holding them bind `model` to `Optional[str] = None` in one and `str = MODEL` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (5 lines × 3) chapter5/adaptive-log-parser/campaign.py:310 — chapter5/adaptive-log-parser/campaign.py:310-322 | REDACTED:359-380 | chapter5/erp-agent/campaign_postgres.py:395-399 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `chapter5/erp-agent/campaign_postgres.py:395` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 3) chapter5/log-diagnosis/http_service.py:90 — chapter5/log-diagnosis/http_service.py:90-94 | chapter5/log-diagnosis/validation/runs/exp5-8-live-http-mcp-20260730-053056/http_service.py:90-94 | chapter5/log-diagnosis/validation/runs/exp5-8-live-http-mcp-20260730-053403/http_service.py:90-94 — before extracting anything, compare `chapter5/log-diagnosis/http_service.py` and `chapter5/log-diagnosis/validation/runs/exp5-8-live-http-mcp-20260730-053056/http_service.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 50 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (5 lines × 3) REDACTED:521 — REDACTED:521-525 | REDACTED:353-357 | REDACTED:322-326 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once.
  • Duplicated block (5 lines × 3) REDACTED:249 — REDACTED:249-253 | REDACTED:276-280 | REDACTED:305-309 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (5 lines × 3) chapter5/log-diagnosis/http_service.py:47 — chapter5/log-diagnosis/http_service.py:47-51 | chapter5/log-diagnosis/validation/runs/exp5-8-live-http-mcp-20260730-053056/http_service.py:47-51 | chapter5/log-diagnosis/validation/runs/exp5-8-live-http-mcp-20260730-053403/http_service.py:47-51 — before extracting anything, compare `chapter5/log-diagnosis/http_service.py` and `chapter5/log-diagnosis/validation/runs/exp5-8-live-http-mcp-20260730-053056/http_service.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 50 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (5 lines × 3) chapter5/code-for-logic/demo.py:632 — chapter5/code-for-logic/demo.py:632-636 | chapter5/code-for-math/demo.py:732-736 | chapter5/small-model-codified-rules/demo.py:532-536 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
D4 · Code Duplication · Duplicated block (15 lines × 2) · ×10
  • Duplicated block (15 lines × 2) chapter10/book-translation/consistency_auditor.py:395 — chapter10/book-translation/consistency_auditor.py:395-409 | chapter10/book-translation/consistency_auditor.py:441-455 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (15 lines × 2) chapter2/context-compression/experiment.py:330 — chapter2/context-compression/experiment.py:330-344 | chapter2/context-compression/run_all_strategies.py:400-414 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (15 lines × 2) chapter3/agentic-rag-for-user-memory/config.py:227 — chapter3/agentic-rag-for-user-memory/config.py:227-241 | chapter3/contextual-retrieval-for-user-memory/config.py:222-236 — `chapter3/agentic-rag-for-user-memory/config.py` and `chapter3/contextual-retrieval-for-user-memory/config.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 5 separate duplicated blocks between them, totalling at least 98 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (15 lines × 2) chapter3/structured-index/config.py:97 — chapter3/structured-index/config.py:97-111 | chapter3/structured-index/config.py:135-149 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (15 lines × 2) chapter4/active-tool-discovery/agent.py:92 — chapter4/active-tool-discovery/agent.py:92-106 | REDACTED:125-139 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `chapter4/active-tool-discovery/agent.py:90` calls `strip` and `REDACTED:124` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (15 lines × 2) chapter4/multimodal-agent/agent.py:483 — chapter4/multimodal-agent/agent.py:483-497 | chapter4/multimodal-agent/agent.py:916-930 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (15 lines × 2) REDACTED:624 — REDACTED:624-638 | REDACTED:747-761 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:624` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) REDACTED:695 — REDACTED:695-710 | REDACTED:711-725 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (15 lines × 2) REDACTED:511 — REDACTED:511-527 | REDACTED:793-807 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (15 lines × 2) chapter5/coding-agent/example_complex_task.py:11 — chapter5/coding-agent/example_complex_task.py:11-26 | chapter5/coding-agent/example_with_system_hints.py:11-25 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
D4 · Code Duplication · Duplicated block (13 lines × 2) · ×10
  • Duplicated block (13 lines × 2) chapter2/local_llm_serving/agent.py:115 — chapter2/local_llm_serving/agent.py:115-127 | chapter2/local_llm_serving/agent.py:163-175 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (13 lines × 2) REDACTED:946 — REDACTED:946-958 | REDACTED:1180-1192 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (13 lines × 2) chapter3/agentic-rag-for-user-memory/evaluator.py:604 — chapter3/agentic-rag-for-user-memory/evaluator.py:604-616 | chapter3/contextual-retrieval-for-user-memory/evaluator.py:604-616 — `chapter3/agentic-rag-for-user-memory/evaluator.py` and `chapter3/contextual-retrieval-for-user-memory/evaluator.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 15 separate duplicated blocks between them, totalling at least 555 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (13 lines × 2) chapter3/agentic-rag/evaluation/evaluate.py:67 — chapter3/agentic-rag/evaluation/evaluate.py:67-79 | chapter3/contextual-retrieval/evaluation/evaluate.py:59-71 — before extracting anything, compare `chapter3/agentic-rag/evaluation/evaluate.py` and `chapter3/contextual-retrieval/evaluation/evaluate.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 369 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (13 lines × 2) chapter4/execution-tools/file_tools.py:80 — chapter4/execution-tools/file_tools.py:80-92 | chapter4/execution-tools/file_tools.py:171-183 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (13 lines × 2) chapter5/adaptive-log-parser/campaign.py:310 — chapter5/adaptive-log-parser/campaign.py:310-322 | REDACTED:359-380 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (13 lines × 2) chapter7/android-world/run_controlled_experiment.py:1743 — chapter7/android-world/run_controlled_experiment.py:1743-1755 | chapter7/android-world/run_controlled_experiment.py:1775-1787 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (13 lines × 2) chapter9/harness-safety-gate/validation/real_20260807T160109Z/candidates/deterministic/confirmation_gate.py:32 — chapter9/harness-safety-gate/validation/real_20260807T160109Z/candidates/deterministic/confirmation_gate.py:32-44 | chapter9/harness-safety-gate/validation/real_20260807T160109Z/candidates/rejected_control/confirmation_gate.py:33-45 — `chapter9/harness-safety-gate/validation/real_20260807T160109Z/candidates/deterministic/confirmation_gate.py` and `chapter9/harness-safety-gate/validation/real_20260807T160109Z/candidates/rejected_control/confirmation_gate.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 31 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (13 lines × 2) chapter9/harness-safety-gate/validation/real_20260807T160109Z/candidates/deterministic/confirmation_gate.py:61 — chapter9/harness-safety-gate/validation/real_20260807T160109Z/candidates/deterministic/confirmation_gate.py:61-73 | chapter9/harness-safety-gate/validation/real_20260807T160109Z/candidates/rejected_control/confirmation_gate.py:62-74 — `chapter9/harness-safety-gate/validation/real_20260807T160109Z/candidates/deterministic/confirmation_gate.py` and `chapter9/harness-safety-gate/validation/real_20260807T160109Z/candidates/rejected_control/confirmation_gate.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 31 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (13 lines × 2) chapter10/staged-system-prompt/runs/staged-system-prompt-kimi-k3-20260730-v1/workspace/organize_downloads.py:65 — chapter10/staged-system-prompt/runs/staged-system-prompt-kimi-k3-20260730-v1/workspace/organize_downloads.py:65-77 | chapter10/staged-system-prompt/runs/staged-system-prompt-kimi-k3-20260730-v3/workspace/organize_downloads.py:41-56 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (12 lines × 2) · ×10
  • Duplicated block (12 lines × 2) chapter3/agentic-rag/config.py:248 — chapter3/agentic-rag/config.py:248-259 | chapter3/contextual-retrieval/config.py:248-259 — `chapter3/agentic-rag/config.py` and `chapter3/contextual-retrieval/config.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 2 separate duplicated blocks between them, totalling at least 33 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (12 lines × 2) chapter3/agentic-rag/tools.py:319 — chapter3/agentic-rag/tools.py:319-330 | chapter3/contextual-retrieval/tools.py:324-335 — `chapter3/agentic-rag/tools.py` and `chapter3/contextual-retrieval/tools.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 14 separate duplicated blocks between them, totalling at least 341 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `chapter3/agentic-rag/tools.py:317` calls `_get_offline_retriever`, `get_document` and `chapter3/contextual-retrieval/tools.py:321` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12 lines × 2) chapter3/dense-embedding/cli.py:204 — chapter3/dense-embedding/cli.py:204-215 | chapter3/sparse-embedding/cli.py:162-173 — `chapter3/dense-embedding/cli.py` and `chapter3/sparse-embedding/cli.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 39 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (12 lines × 2) chapter3/user-memory/background_memory_processor.py:187 — chapter3/user-memory/background_memory_processor.py:187-198 | chapter3/user-memory/background_memory_processor.py:275-286 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter3/user-memory/background_memory_processor.py:187` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) chapter3/user-memory/quickstart.py:107 — chapter3/user-memory/quickstart.py:107-118 | chapter3/user-memory/quickstart.py:165-176 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter3/user-memory/quickstart.py:107` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) chapter4/execution-tools/multilang_executor.py:397 — chapter4/execution-tools/multilang_executor.py:397-408 | chapter4/execution-tools/multilang_executor.py:660-671 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (12 lines × 2) chapter4/perception-tools/src/pubchem_tools.py:255 — chapter4/perception-tools/src/pubchem_tools.py:255-266 | chapter4/perception-tools/src/search_tools.py:236-247 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (12 lines × 2) chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:98 — chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:98-109 | chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:140-151 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:98` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) chapter8/MiniMind-pretrain/validation/validate_evidence.py:115 — chapter8/MiniMind-pretrain/validation/validate_evidence.py:115-126 | chapter8/continued-pretraining/validation/validate_evidence.py:74-85 — before extracting anything, compare `chapter8/MiniMind-pretrain/validation/validate_evidence.py` and `chapter8/continued-pretraining/validation/validate_evidence.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 69 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (12 lines × 2) chapter5/permission-embedded-data-objects/pedo/eval/benchmark_spec_errors.py:134 — chapter5/permission-embedded-data-objects/pedo/eval/benchmark_spec_errors.py:134-147 | chapter5/permission-embedded-data-objects/pedo/eval/benchmark_spec_errors.py:185-196 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (9 lines × 2) · ×10
  • Duplicated block (9 lines × 2) REDACTED:147 — REDACTED:147-155 | REDACTED:126-134 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 6 separate duplicated blocks between them, totalling at least 324 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (9 lines × 2) chapter4/perception-tools/cli.py:274 — chapter4/perception-tools/cli.py:274-282 | chapter4/perception-tools/cli.py:303-311 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (9 lines × 2) chapter4/perception-tools/src/yahoo_finance_tools.py:89 — chapter4/perception-tools/src/yahoo_finance_tools.py:89-97 | chapter4/perception-tools/src/yahoo_finance_tools.py:281-289 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (9 lines × 2) chapter5/adaptive-log-parser/agent.py:125 — chapter5/adaptive-log-parser/agent.py:125-133 | chapter5/erp-agent/agent.py:65-74 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `chapter5/adaptive-log-parser/agent.py:125` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) chapter5/coding-agent/agent.py:71 — chapter5/coding-agent/agent.py:71-79 | chapter5/coding-agent/agent_new.py:58-66 — before extracting anything, compare `chapter5/coding-agent/agent.py` and `chapter5/coding-agent/agent_new.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 198 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `chapter5/coding-agent/agent.py:80` calls `replace`, `_get_git_status` and `chapter5/coding-agent/agent_new.py:67` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 2) REDACTED:316 — REDACTED:316-324 | REDACTED:407-415 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `REDACTED:327` calls `connect` and `REDACTED:417` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 2) REDACTED:105 — REDACTED:105-113 | REDACTED:42-50 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:105` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) chapter6/astra-async-steering/experiment.py:133 — chapter6/astra-async-steering/experiment.py:133-141 | chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:133-141 — before extracting anything, compare `chapter6/astra-async-steering/experiment.py` and `chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 251 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `chapter6/astra-async-steering/experiment.py:133` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (9 lines × 2) chapter8/cot-distillation/sft_data_auditor.py:584 — chapter8/cot-distillation/sft_data_auditor.py:584-592 | chapter8/cot-distillation/sft_data_auditor.py:596-604 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (9 lines × 2) chapter6/agent-with-event-trigger/server.py:22 — chapter6/agent-with-event-trigger/server.py:22-30 | chapter6/agent-with-event-trigger/server_fastapi.py:21-29 — before extracting anything, compare `chapter6/agent-with-event-trigger/server.py` and `chapter6/agent-with-event-trigger/server_fastapi.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 189 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
X1 · Async correctness · Task from `asyncio.create_task` is not kept · ×9
  • Task from `asyncio.create_task` is not kept chapter9/browser-use-rpa/browser-use/browser_use/tokens/service.py:335 — The task this creates is not kept anywhere. The event loop holds only a weak reference to its tasks, so a task nobody references can be garbage-collected before it finishes (Python's documentation for `asyncio.create_task`: save a reference to the result); and nothing ever awaits it, so an exception it raises is never handled — it surfaces, if at all, as "Task exception was never retrieved" in a log. Keep the task: `await` it, gather it, start it in an `asyncio.TaskGroup` (`async with asyncio.TaskGroup() as tg: tg.create_task(…)`), or, for genuine fire-and-forget, add it to a set and `task.add_done_callback(tasks.discard)` with a callback that also reads its exception.
  • Task from `asyncio.create_task` is not kept chapter9/browser-use-rpa/browser-use/browser_use/browser/session.py:1433 — The task this creates is not kept anywhere. The event loop holds only a weak reference to its tasks, so a task nobody references can be garbage-collected before it finishes (Python's documentation for `asyncio.create_task`: save a reference to the result); and nothing ever awaits it, so an exception it raises is never handled — it surfaces, if at all, as "Task exception was never retrieved" in a log. Keep the task: `await` it, gather it, start it in an `asyncio.TaskGroup` (`async with asyncio.TaskGroup() as tg: tg.create_task(…)`), or, for genuine fire-and-forget, add it to a set and `task.add_done_callback(tasks.discard)` with a callback that also reads its exception.
  • Task from `asyncio.create_task` is not kept chapter9/browser-use-rpa/browser-use/browser_use/browser/session.py:1447 — The task this creates is not kept anywhere. The event loop holds only a weak reference to its tasks, so a task nobody references can be garbage-collected before it finishes (Python's documentation for `asyncio.create_task`: save a reference to the result); and nothing ever awaits it, so an exception it raises is never handled — it surfaces, if at all, as "Task exception was never retrieved" in a log. Keep the task: `await` it, gather it, start it in an `asyncio.TaskGroup` (`async with asyncio.TaskGroup() as tg: tg.create_task(…)`), or, for genuine fire-and-forget, add it to a set and `task.add_done_callback(tasks.discard)` with a callback that also reads its exception.
  • Task from `asyncio.create_task` is not kept chapter9/browser-use-rpa/browser-use/browser_use/browser/session.py:1465 — The task this creates is not kept anywhere. The event loop holds only a weak reference to its tasks, so a task nobody references can be garbage-collected before it finishes (Python's documentation for `asyncio.create_task`: save a reference to the result); and nothing ever awaits it, so an exception it raises is never handled — it surfaces, if at all, as "Task exception was never retrieved" in a log. Keep the task: `await` it, gather it, start it in an `asyncio.TaskGroup` (`async with asyncio.TaskGroup() as tg: tg.create_task(…)`), or, for genuine fire-and-forget, add it to a set and `task.add_done_callback(tasks.discard)` with a callback that also reads its exception.
  • Task from `asyncio.create_task` is not kept chapter9/browser-use-rpa/browser-use/browser_use/browser/session.py:1495 — The task this creates is not kept anywhere. The event loop holds only a weak reference to its tasks, so a task nobody references can be garbage-collected before it finishes (Python's documentation for `asyncio.create_task`: save a reference to the result); and nothing ever awaits it, so an exception it raises is never handled — it surfaces, if at all, as "Task exception was never retrieved" in a log. Keep the task: `await` it, gather it, start it in an `asyncio.TaskGroup` (`async with asyncio.TaskGroup() as tg: tg.create_task(…)`), or, for genuine fire-and-forget, add it to a set and `task.add_done_callback(tasks.discard)` with a callback that also reads its exception.
  • Task from `asyncio.create_task` is not kept chapter9/browser-use-rpa/browser-use/browser_use/browser/watchdogs/crash_watchdog.py:62 — The task this creates is not kept anywhere. The event loop holds only a weak reference to its tasks, so a task nobody references can be garbage-collected before it finishes (Python's documentation for `asyncio.create_task`: save a reference to the result); and nothing ever awaits it, so an exception it raises is never handled — it surfaces, if at all, as "Task exception was never retrieved" in a log. Keep the task: `await` it, gather it, start it in an `asyncio.TaskGroup` (`async with asyncio.TaskGroup() as tg: tg.create_task(…)`), or, for genuine fire-and-forget, add it to a set and `task.add_done_callback(tasks.discard)` with a callback that also reads its exception.
  • Task from `asyncio.create_task` is not kept chapter9/browser-use-rpa/browser-use/browser_use/browser/watchdogs/recording_watchdog.py:103 — The task this creates is not kept anywhere. The event loop holds only a weak reference to its tasks, so a task nobody references can be garbage-collected before it finishes (Python's documentation for `asyncio.create_task`: save a reference to the result); and nothing ever awaits it, so an exception it raises is never handled — it surfaces, if at all, as "Task exception was never retrieved" in a log. Keep the task: `await` it, gather it, start it in an `asyncio.TaskGroup` (`async with asyncio.TaskGroup() as tg: tg.create_task(…)`), or, for genuine fire-and-forget, add it to a set and `task.add_done_callback(tasks.discard)` with a callback that also reads its exception.
  • Task from `asyncio.create_task` is not kept chapter6/phone-agent/webrtc_app.py:610 — The task this creates is not kept anywhere. The event loop holds only a weak reference to its tasks, so a task nobody references can be garbage-collected before it finishes (Python's documentation for `asyncio.create_task`: save a reference to the result); and nothing ever awaits it, so an exception it raises is never handled — it surfaces, if at all, as "Task exception was never retrieved" in a log. Keep the task: `await` it, gather it, start it in an `asyncio.TaskGroup` (`async with asyncio.TaskGroup() as tg: tg.create_task(…)`), or, for genuine fire-and-forget, add it to a set and `task.add_done_callback(tasks.discard)` with a callback that also reads its exception.
  • Task from `asyncio.create_task` is not kept chapter6/phone-agent/webrtc_app.py:618 — The task this creates is not kept anywhere. The event loop holds only a weak reference to its tasks, so a task nobody references can be garbage-collected before it finishes (Python's documentation for `asyncio.create_task`: save a reference to the result); and nothing ever awaits it, so an exception it raises is never handled — it surfaces, if at all, as "Task exception was never retrieved" in a log. Keep the task: `await` it, gather it, start it in an `asyncio.TaskGroup` (`async with asyncio.TaskGroup() as tg: tg.create_task(…)`), or, for genuine fire-and-forget, add it to a set and `task.add_done_callback(tasks.discard)` with a callback that also reads its exception.
D4 · Code Duplication · Duplicated block (35 lines × 2) · ×7
  • Duplicated block (35 lines × 2) REDACTED:261 — REDACTED:261-295 | REDACTED:261-295 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 271 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (35 lines × 2) chapter3/agentic-rag-for-user-memory/evaluator.py:158 — chapter3/agentic-rag-for-user-memory/evaluator.py:158-192 | chapter3/contextual-retrieval-for-user-memory/evaluator.py:158-192 — `chapter3/agentic-rag-for-user-memory/evaluator.py` and `chapter3/contextual-retrieval-for-user-memory/evaluator.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 15 separate duplicated blocks between them, totalling at least 555 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (35 lines × 2) chapter3/agentic-rag-for-user-memory/evaluator.py:565 — chapter3/agentic-rag-for-user-memory/evaluator.py:565-599 | chapter3/contextual-retrieval-for-user-memory/evaluator.py:565-599 — `chapter3/agentic-rag-for-user-memory/evaluator.py` and `chapter3/contextual-retrieval-for-user-memory/evaluator.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 15 separate duplicated blocks between them, totalling at least 555 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (35 lines × 2) REDACTED:167 — REDACTED:167-201 | REDACTED:167-201 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 13 separate duplicated blocks between them, totalling at least 349 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (35 lines × 2) REDACTED:251 — REDACTED:251-285 | REDACTED:251-285 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 13 separate duplicated blocks between them, totalling at least 349 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (35 lines × 2) chapter3/agentic-rag/evaluation/evaluate.py:100 — chapter3/agentic-rag/evaluation/evaluate.py:100-134 | chapter3/contextual-retrieval/evaluation/evaluate.py:92-126 — before extracting anything, compare `chapter3/agentic-rag/evaluation/evaluate.py` and `chapter3/contextual-retrieval/evaluation/evaluate.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 369 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (35 lines × 2) chapter3/agentic-rag/tools.py:376 — chapter3/agentic-rag/tools.py:376-410 | chapter3/contextual-retrieval/tools.py:381-415 — `chapter3/agentic-rag/tools.py` and `chapter3/contextual-retrieval/tools.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 14 separate duplicated blocks between them, totalling at least 341 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (10 lines × 3) · ×7
  • Duplicated block (10 lines × 3) chapter1/learning-from-experience/demo.py:123 — chapter1/learning-from-experience/demo.py:123-132 | chapter1/learning-from-experience/experiment.py:173-182 | chapter1/learning-from-experience/quick_demo.py:51-60 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once.
  • Duplicated block (10 lines × 3) chapter3/agentic-rag/tools.py:140 — chapter3/agentic-rag/tools.py:140-149 | chapter3/agentic-rag/tools.py:190-199 | chapter3/contextual-retrieval/tools.py:197-206 — `chapter3/agentic-rag/tools.py` and `chapter3/contextual-retrieval/tools.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 14 separate duplicated blocks between them, totalling at least 341 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `chapter3/agentic-rag/tools.py:140` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `chapter3/agentic-rag/tools.py:188` calls `get` and `chapter3/agentic-rag/tools.py:139` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 3) chapter5/log-diagnosis/http_service.py:35 — chapter5/log-diagnosis/http_service.py:35-44 | chapter5/log-diagnosis/validation/runs/exp5-8-live-http-mcp-20260730-053056/http_service.py:35-44 | chapter5/log-diagnosis/validation/runs/exp5-8-live-http-mcp-20260730-053403/http_service.py:35-44 — before extracting anything, compare `chapter5/log-diagnosis/http_service.py` and `chapter5/log-diagnosis/validation/runs/exp5-8-live-http-mcp-20260730-053056/http_service.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 50 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (10 lines × 3) chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:255 — chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:255-264 | chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:275-290 | chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:519-528 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (10 lines × 3) chapter6/gemini-xlerobot-navigation/validate_evidence.py:25 — chapter6/gemini-xlerobot-navigation/validate_evidence.py:25-34 | chapter6/rgb-sim2real-grasping/validate_evidence.py:23-32 | chapter6/xlerobot-teleoperation/validate_evidence.py:23-32 — `chapter6/gemini-xlerobot-navigation/validate_evidence.py` and `chapter6/rgb-sim2real-grasping/validate_evidence.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 38 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (10 lines × 3) REDACTED:659 — REDACTED:659-668 | REDACTED:811-820 | REDACTED:687-696 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `REDACTED:809` calls `add_argument`, `getenv` and `REDACTED:657` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 3) chapter4/active-tool-discovery/demo.py:33 — chapter4/active-tool-discovery/demo.py:33-42 | chapter9/prompt-auto-optimization/config.py:74-83 | chapter9/self-evolving-tools/agent.py:43-52 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D2 · Cognitive Complexity · svg_lib._wrap_line (cognitive 18) · ×6
  • svg_lib._wrap_line (cognitive 18) book-ar/svg_lib.py:162 — svg_lib._wrap_line has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (8 pts), ternaries 2 (6 pts), boolean chains 3, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • svg_lib._wrap_line (cognitive 18) book-en/svg_lib.py:146 — svg_lib._wrap_line has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (8 pts), ternaries 2 (6 pts), boolean chains 3, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • svg_lib._wrap_line (cognitive 18) book-es/svg_lib.py:146 — svg_lib._wrap_line has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (8 pts), ternaries 2 (6 pts), boolean chains 3, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • svg_lib._wrap_line (cognitive 18) book-id/svg_lib.py:146 — svg_lib._wrap_line has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (8 pts), ternaries 2 (6 pts), boolean chains 3, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • svg_lib._wrap_line (cognitive 18) book-ru/svg_lib.py:146 — svg_lib._wrap_line has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (8 pts), ternaries 2 (6 pts), boolean chains 3, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • svg_lib._wrap_line (cognitive 18) book-tr/svg_lib.py:146 — svg_lib._wrap_line has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (8 pts), ternaries 2 (6 pts), boolean chains 3, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D30 · Dependency Vulnerabilities · Medium vulnerability · ×6
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Duplicated block (27 lines × 2) · ×6
  • Duplicated block (27 lines × 2) chapter3/agentic-rag-for-user-memory/evaluator.py:619 — chapter3/agentic-rag-for-user-memory/evaluator.py:619-645 | chapter3/contextual-retrieval-for-user-memory/evaluator.py:619-645 — `chapter3/agentic-rag-for-user-memory/evaluator.py` and `chapter3/contextual-retrieval-for-user-memory/evaluator.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 15 separate duplicated blocks between them, totalling at least 555 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (27 lines × 2) chapter3/agentic-rag/agent.py:270 — chapter3/agentic-rag/agent.py:270-296 | chapter3/contextual-retrieval/agent.py:209-235 — `chapter3/agentic-rag/agent.py` and `chapter3/contextual-retrieval/agent.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 6 separate duplicated blocks between them, totalling at least 111 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `chapter3/agentic-rag/agent.py:270` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (27 lines × 2) REDACTED:393 — REDACTED:393-419 | REDACTED:393-419 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 13 separate duplicated blocks between them, totalling at least 349 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (27 lines × 2) REDACTED:338 — REDACTED:338-364 | REDACTED:510-536 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 73 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (27 lines × 2) chapter5/permission-embedded-data-objects/pedo/scenarios/banking.py:86 — chapter5/permission-embedded-data-objects/pedo/scenarios/banking.py:86-112 | chapter5/permission-embedded-data-objects/pedo/scenarios/healthcare.py:64-90 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `chapter5/permission-embedded-data-objects/pedo/scenarios/banking.py:86` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (27 lines × 2) chapter9/browser-use-rpa/demo_email.py:96 — chapter9/browser-use-rpa/demo_email.py:96-122 | chapter9/browser-use-rpa/demo_email.py:152-178 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (21 lines × 2) · ×6
  • Duplicated block (21 lines × 2) chapter3/agentic-rag-for-user-memory/agent.py:72 — chapter3/agentic-rag-for-user-memory/agent.py:72-92 | chapter3/contextual-retrieval-for-user-memory/agent.py:72-92 — `chapter3/agentic-rag-for-user-memory/agent.py` and `chapter3/contextual-retrieval-for-user-memory/agent.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 278 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (21 lines × 2) REDACTED:320 — REDACTED:320-340 | chapter3/contextual-retrieval/index_local_laws_contextual.py:355-375 — `REDACTED` and `chapter3/contextual-retrieval/index_local_laws_contextual.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 7 separate duplicated blocks between them, totalling at least 122 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `chapter3/contextual-retrieval/index_local_laws_contextual.py:376` calls `info` and `REDACTED:343` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (21 lines × 2) chapter4/multimodal-agent/demo.py:32 — chapter4/multimodal-agent/demo.py:32-52 | chapter4/multimodal-agent/demo.py:139-159 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `chapter4/multimodal-agent/demo.py:161` calls `MultimodalContent` and `chapter4/multimodal-agent/demo.py:55` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (21 lines × 2) chapter5/permission-embedded-data-objects/pedo/core/store.py:143 — chapter5/permission-embedded-data-objects/pedo/core/store.py:143-163 | chapter5/permission-embedded-data-objects/pedo/core/store.py:170-190 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `type_name` to `Optional[str] = None` in one and `str` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (21 lines × 2) chapter9/browser-use-rpa/demo_weather.py:33 — chapter9/browser-use-rpa/demo_weather.py:33-53 | chapter9/browser-use-rpa/demo_weather.py:60-80 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (21 lines × 2) chapter3/mem0/agent.py:483 — chapter3/mem0/agent.py:483-503 | chapter3/memobase/locomo_benchmark.py:567-596 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Note first that the copies are not typed on the same thing: the declarations holding them bind `filepath` to `str` in one and `Path` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (18 lines × 2) · ×6
  • Duplicated block (18 lines × 2) chapter3/agentic-rag/evaluation/evaluate.py:47 — chapter3/agentic-rag/evaluation/evaluate.py:47-64 | chapter3/contextual-retrieval/evaluation/evaluate.py:39-56 — before extracting anything, compare `chapter3/agentic-rag/evaluation/evaluate.py` and `chapter3/contextual-retrieval/evaluation/evaluate.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 369 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (18 lines × 2) chapter3/mem0/quickstart.py:160 — chapter3/mem0/quickstart.py:160-177 | chapter3/mem0/quickstart.py:182-199 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (18 lines × 2) REDACTED:563 — REDACTED:563-580 | REDACTED:587-604 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (18 lines × 2) chapter7/android-world/run_controlled_experiment.py:623 — chapter7/android-world/run_controlled_experiment.py:623-640 | chapter7/experiment-7-2-human-benchmark/run_android_human.py:18-35 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `chapter7/android-world/run_controlled_experiment.py:623` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) chapter8/MiniMind-pretrain/validation/validate_evidence.py:283 — chapter8/MiniMind-pretrain/validation/validate_evidence.py:283-300 | chapter8/continued-pretraining/validation/validate_evidence.py:182-199 — before extracting anything, compare `chapter8/MiniMind-pretrain/validation/validate_evidence.py` and `chapter8/continued-pretraining/validation/validate_evidence.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 69 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (18 lines × 2) chapter6/agent-with-event-trigger/server.py:69 — chapter6/agent-with-event-trigger/server.py:69-86 | chapter6/agent-with-event-trigger/server_fastapi.py:68-85 — before extracting anything, compare `chapter6/agent-with-event-trigger/server.py` and `chapter6/agent-with-event-trigger/server_fastapi.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 189 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
X2 · Cancellation propagation · Async function without AbortSignal · ×6
  • Async function without AbortSignal: _load extras/agent-lab/agent-trajectory.js:298 — `_load` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`.
  • Async function without AbortSignal: startCall chapter6/phone-agent/static/app.js:130 — `startCall` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`.
  • Async function without AbortSignal: runTts chapter6/live-audio/backend/run_real_validation.js:315 — `runTts` awaits `axios.post(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axios.post(url, { signal })`.
  • Async function without AbortSignal: transcribe chapter6/live-audio/backend/utils/providers/asrProviders.js:64 — `transcribe` awaits `axios(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axios(url, { signal })`.
  • Async function without AbortSignal: transcribe chapter6/live-audio/backend/utils/providers/asrProviders.js:154 — `transcribe` awaits `axios(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `axios(url, { signal })`.
  • Async function without AbortSignal: loadTrajectories chapter2/attention_visualization/frontend/pages/index.tsx:68 — `loadTrajectories` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`.
D4 · Code Duplication · Members sharing a duplicated core (5 members, 50+ identical tokens) · ×5
  • Members sharing a duplicated core (5 members, 50+ identical tokens) chapter1/context/main.py:908 — chapter1/context/main.py:908-1153 | chapter3/agentic-rag/quickstart.py:122-141 | chapter3/user-memory/main.py:722-768 | chapter3/user-memory/main.py:772-828 | chapter3/user-memory/quickstart.py:22-195 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) chapter3/agentic-rag-for-user-memory/agent.py:95 — chapter3/agentic-rag-for-user-memory/agent.py:95-108 | chapter3/agentic-rag/agent.py:73-86 | chapter3/contextual-retrieval-for-user-memory/agent.py:95-108 | chapter3/contextual-retrieval-for-user-memory/contextual_agent.py:109-122 | chapter3/contextual-retrieval/agent.py:58-71 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) chapter4/perception-tools/src/arxiv_enhanced.py:94 — chapter4/perception-tools/src/arxiv_enhanced.py:94-172 | chapter4/perception-tools/src/google_search_enhanced.py:93-138 | chapter4/perception-tools/src/wiki_enhanced.py:87-128 | chapter4/perception-tools/src/wiki_enhanced.py:135-177 | chapter4/perception-tools/src/wiki_enhanced.py:185-269 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) chapter5/permission-embedded-data-objects/pedo/scenarios/enterprise_agents.py:67 — chapter5/permission-embedded-data-objects/pedo/scenarios/enterprise_agents.py:67-81 | chapter5/permission-embedded-data-objects/pedo/scenarios/forum.py:58-73 | chapter5/permission-embedded-data-objects/pedo/scenarios/healthcare.py:40-57 | chapter5/permission-embedded-data-objects/pedo/scenarios/hiring.py:110-124 | chapter5/permission-embedded-data-objects/pedo/scenarios/project_mgmt.py:106-120 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) chapter6/astra-async-steering/experiment.py:351 — chapter6/astra-async-steering/experiment.py:351-368 | chapter6/astra-async-steering/summarize.py:13-54 | chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:351-368 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:336-347 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:336-347 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication · Duplicated block (33 lines × 2) · ×5
  • Duplicated block (33 lines × 2) chapter3/agentic-rag-for-user-memory/demo_ui_improvements.py:58 — chapter3/agentic-rag-for-user-memory/demo_ui_improvements.py:58-90 | chapter3/contextual-retrieval-for-user-memory/demo_ui_improvements.py:58-90 — `chapter3/agentic-rag-for-user-memory/demo_ui_improvements.py` and `chapter3/contextual-retrieval-for-user-memory/demo_ui_improvements.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 121 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (33 lines × 2) chapter3/agentic-rag-for-user-memory/evaluator.py:123 — chapter3/agentic-rag-for-user-memory/evaluator.py:123-155 | chapter3/contextual-retrieval-for-user-memory/evaluator.py:123-155 — `chapter3/agentic-rag-for-user-memory/evaluator.py` and `chapter3/contextual-retrieval-for-user-memory/evaluator.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 15 separate duplicated blocks between them, totalling at least 555 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (33 lines × 2) chapter3/agentic-rag/evaluation/evaluate.py:266 — chapter3/agentic-rag/evaluation/evaluate.py:266-298 | chapter3/contextual-retrieval/evaluation/evaluate.py:258-290 — before extracting anything, compare `chapter3/agentic-rag/evaluation/evaluate.py` and `chapter3/contextual-retrieval/evaluation/evaluate.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 369 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (33 lines × 2) chapter6/agent-with-event-trigger/server.py:141 — chapter6/agent-with-event-trigger/server.py:141-173 | chapter6/agent-with-event-trigger/server_fastapi.py:135-167 — before extracting anything, compare `chapter6/agent-with-event-trigger/server.py` and `chapter6/agent-with-event-trigger/server_fastapi.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 189 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (33 lines × 2) chapter6/agent-with-event-trigger/server.py:284 — chapter6/agent-with-event-trigger/server.py:284-316 | chapter6/agent-with-event-trigger/server_fastapi.py:278-310 — before extracting anything, compare `chapter6/agent-with-event-trigger/server.py` and `chapter6/agent-with-event-trigger/server_fastapi.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 189 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (24 lines × 2) · ×5
  • Duplicated block (24 lines × 2) REDACTED:530 — REDACTED:530-553 | REDACTED:810-833 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (24 lines × 2) chapter3/agentic-rag-for-user-memory/demo_ui_improvements.py:94 — chapter3/agentic-rag-for-user-memory/demo_ui_improvements.py:94-117 | chapter3/contextual-retrieval-for-user-memory/demo_ui_improvements.py:94-117 — `chapter3/agentic-rag-for-user-memory/demo_ui_improvements.py` and `chapter3/contextual-retrieval-for-user-memory/demo_ui_improvements.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 121 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (24 lines × 2) REDACTED:99 — REDACTED:99-122 | chapter3/contextual-retrieval/index_local_laws_contextual.py:113-136 — `REDACTED` and `chapter3/contextual-retrieval/index_local_laws_contextual.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 7 separate duplicated blocks between them, totalling at least 122 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (24 lines × 2) REDACTED:114 — REDACTED:114-137 | REDACTED:236-259 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:114` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (24 lines × 2) chapter5/permission-embedded-data-objects/pedo/scenarios/banking.py:89 — chapter5/permission-embedded-data-objects/pedo/scenarios/banking.py:89-112 | chapter5/permission-embedded-data-objects/pedo/scenarios/project_mgmt.py:130-155 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `chapter5/permission-embedded-data-objects/pedo/scenarios/banking.py:89` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (20 lines × 2) · ×5
  • Duplicated block (20 lines × 2) chapter2/system-hint/main.py:62 — chapter2/system-hint/main.py:62-81 | chapter3/user-memory/main.py:61-80 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (20 lines × 2) chapter3/agentic-rag-for-user-memory/indexer.py:494 — chapter3/agentic-rag-for-user-memory/indexer.py:494-513 | chapter3/contextual-retrieval-for-user-memory/indexer.py:378-397 — `chapter3/agentic-rag-for-user-memory/indexer.py` and `chapter3/contextual-retrieval-for-user-memory/indexer.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 10 separate duplicated blocks between them, totalling at least 347 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (20 lines × 2) chapter5/paper-to-ppt/agents.py:376 — chapter5/paper-to-ppt/agents.py:376-395 | chapter5/paper-to-ppt/agents.py:455-474 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (20 lines × 2) chapter7/elo-leaderboard/visualization.py:197 — chapter7/elo-leaderboard/visualization.py:197-216 | chapter7/elo-leaderboard/visualization.py:248-267 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter7/elo-leaderboard/visualization.py:197` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20 lines × 2) chapter9/harness-safety-gate/demo.py:32 — chapter9/harness-safety-gate/demo.py:32-51 | chapter9/self-modifying-agent/demo.py:20-39 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `chapter9/harness-safety-gate/demo.py:30` calls `loads`, `read_text` and `chapter9/self-modifying-agent/demo.py:19` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (19 lines × 2) · ×5
  • Duplicated block (19 lines × 2) REDACTED:302 — REDACTED:302-320 | REDACTED:547-565 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (19 lines × 2) REDACTED:805 — REDACTED:805-823 | REDACTED:1039-1057 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (19 lines × 2) chapter4/perception-tools/src/filesystem_tools.py:390 — chapter4/perception-tools/src/filesystem_tools.py:390-411 | chapter4/perception-tools/src/search_tools.py:348-366 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (19 lines × 2) chapter5/permission-embedded-data-objects/pedo/scenarios/enterprise_agents.py:204 — chapter5/permission-embedded-data-objects/pedo/scenarios/enterprise_agents.py:204-222 | chapter5/permission-embedded-data-objects/pedo/scenarios/healthcare.py:129-147 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `chapter5/permission-embedded-data-objects/pedo/scenarios/enterprise_agents.py:204` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (19 lines × 2) REDACTED:25 — REDACTED:25-43 | REDACTED:25-43 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 13 separate duplicated blocks between them, totalling at least 349 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (8 lines × 4) · ×5
  • Duplicated block (8 lines × 4) chapter4/multimodal-agent/demo.py:42 — chapter4/multimodal-agent/demo.py:42-50 | chapter4/multimodal-agent/demo.py:149-157 | chapter4/multimodal-agent/main.py:45-52 | chapter4/multimodal-agent/main.py:144-151 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (8 lines × 4) REDACTED:205 — REDACTED:205-212 | REDACTED:496-503 | REDACTED:505-512 | REDACTED:514-521 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `REDACTED:213` calls `execute` and `REDACTED:504` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 4) REDACTED:364 — REDACTED:364-371 | REDACTED:386-393 | REDACTED:500-507 | REDACTED:518-525 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (8 lines × 4) chapter6/astra-async-steering/experiment.py:181 — chapter6/astra-async-steering/experiment.py:181-188 | chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:181-188 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:167-174 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:167-174 — before extracting anything, compare `chapter6/astra-async-steering/experiment.py` and `chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 251 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `chapter6/astra-async-steering/experiment.py:181` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 4) chapter6/astra-async-steering/experiment.py:162 — chapter6/astra-async-steering/experiment.py:162-169 | chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:162-169 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:154-161 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:154-161 — before extracting anything, compare `chapter6/astra-async-steering/experiment.py` and `chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 251 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (5 lines × 4) · ×5
  • Duplicated block (5 lines × 4) chapter3/agentic-rag/evaluation/evaluate.py:377 — chapter3/agentic-rag/evaluation/evaluate.py:377-381 | chapter3/agentic-rag/main.py:208-213 | chapter3/contextual-retrieval/evaluation/evaluate.py:369-373 | chapter3/contextual-retrieval/main.py:196-201 — before extracting anything, compare `chapter3/agentic-rag/evaluation/evaluate.py` and `chapter3/contextual-retrieval/evaluation/evaluate.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 369 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `chapter3/agentic-rag/evaluation/evaluate.py:377` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 4) chapter6/astra-async-steering/experiment.py:90 — chapter6/astra-async-steering/experiment.py:90-94 | chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:90-94 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:90-94 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:90-94 — before extracting anything, compare `chapter6/astra-async-steering/experiment.py` and `chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 251 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `chapter6/astra-async-steering/experiment.py:90` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (5 lines × 4) chapter6/astra-async-steering/experiment.py:152 — chapter6/astra-async-steering/experiment.py:152-156 | chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:152-156 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:147-151 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:147-151 — before extracting anything, compare `chapter6/astra-async-steering/experiment.py` and `chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 251 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `chapter6/astra-async-steering/experiment.py:152` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 4) chapter6/astra-async-steering/experiment.py:373 — chapter6/astra-async-steering/experiment.py:373-377 | chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:373-377 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:352-356 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:352-356 — before extracting anything, compare `chapter6/astra-async-steering/experiment.py` and `chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 251 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (5 lines × 4) chapter6/astra-async-steering/experiment.py:61 — chapter6/astra-async-steering/experiment.py:61-65 | chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:61-65 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:61-65 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:61-65 — before extracting anything, compare `chapter6/astra-async-steering/experiment.py` and `chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 251 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
AC6 · Visual & motion safety · Animation without a prefers-reduced-motion guard · ×4
  • Animation without a prefers-reduced-motion guard chapter2/attention_visualization/frontend/pages/index.tsx:169 — <div> moves — its `animate-spin` utility runs with no motion-safe:/motion-reduce: variant — and nothing reads prefers-reduced-motion for it, so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Gate it on @media (prefers-reduced-motion: no-preference) or motion-safe:.
  • Animation without a prefers-reduced-motion guard chapter7/elo-leaderboard/validation/runs/exp7-7-arena-20260731-v1/leaderboard_animation.html:109 — `#progress` moves (`transition: width 0.5s`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce.
  • Animation without a prefers-reduced-motion guard extras/agent-lab/agent-trajectory.js:116 — `.toolbar .progress > i` moves (`transition: width .25s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce.
  • Animation without a prefers-reduced-motion guard extras/book-theme.css:116 — `.sidebar-toggle svg` moves (`transition: transform 0.15s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce.
D1 · Cyclomatic Complexity · experiment.run_case (cyclomatic 47) · ×4
  • experiment.run_case (cyclomatic 47) chapter6/astra-async-steering/experiment.py:217 — experiment.run_case has cyclomatic complexity 47 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • experiment.run_case (cyclomatic 47) chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:217 — experiment.run_case has cyclomatic complexity 47 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • experiment.run_case (cyclomatic 47) chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:202 — experiment.run_case has cyclomatic complexity 47 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • experiment.run_case (cyclomatic 47) chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:202 — experiment.run_case has cyclomatic complexity 47 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · lang-switcher.init · ×4
  • lang-switcher.init::translatePath (cyclomatic 28) REDACTED:94 — lang-switcher.init::translatePath has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: 3 other methods here (lang-switcher.init::detectLang, lang-switcher.init::rewriteSidebar, lang-switcher.init::render) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
  • lang-switcher.init::rewriteSidebar (cyclomatic 24) REDACTED:354 — lang-switcher.init::rewriteSidebar has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: 3 other methods here (lang-switcher.init::detectLang, lang-switcher.init::translatePath, lang-switcher.init::render) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
  • lang-switcher.init::detectLang (cyclomatic 20) REDACTED:31 — lang-switcher.init::detectLang has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: 3 other methods here (lang-switcher.init::translatePath, lang-switcher.init::rewriteSidebar, lang-switcher.init::render) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
  • lang-switcher.init::render (cyclomatic 16) REDACTED:503 — lang-switcher.init::render has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This shape REPEATS in the file: 3 other methods here (lang-switcher.init::detectLang, lang-switcher.init::translatePath, lang-switcher.init::rewriteSidebar) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · experiment.run_case (cognitive 79) · ×4
  • experiment.run_case (cognitive 79) chapter6/astra-async-steering/experiment.py:217 — experiment.run_case has cognitive complexity 79 (threshold 15). Drivers by points: if/else 18 (55 pts), boolean chains 17, ternaries 4, loops 2, error handling 1 (nesting depth added 37). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • experiment.run_case (cognitive 79) chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:217 — experiment.run_case has cognitive complexity 79 (threshold 15). Drivers by points: if/else 18 (55 pts), boolean chains 17, ternaries 4, loops 2, error handling 1 (nesting depth added 37). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • experiment.run_case (cognitive 79) chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:202 — experiment.run_case has cognitive complexity 79 (threshold 15). Drivers by points: if/else 18 (55 pts), boolean chains 17, ternaries 4, loops 2, error handling 1 (nesting depth added 37). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • experiment.run_case (cognitive 79) chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:202 — experiment.run_case has cognitive complexity 79 (threshold 15). Drivers by points: if/else 18 (55 pts), boolean chains 17, ternaries 4, loops 2, error handling 1 (nesting depth added 37). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · lang-switcher.init · ×4
  • lang-switcher.init::rewriteSidebar (cognitive 58) REDACTED:354 — lang-switcher.init::rewriteSidebar has cognitive complexity 58 (threshold 15). Drivers by points: if/else 12 (43 pts), boolean chains 5, loops 4 (5 pts), error handling 1 (3 pts), ternaries 1 (2 pts) (nesting depth added 35). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function. This shape REPEATS in the file: 3 other methods here (lang-switcher.init::detectLang, lang-switcher.init::translatePath, lang-switcher.init::render) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
  • lang-switcher.init::translatePath (cognitive 34) REDACTED:94 — lang-switcher.init::translatePath has cognitive complexity 34 (threshold 15). Drivers by points: if/else 15 (22 pts), boolean chains 12 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: 3 other methods here (lang-switcher.init::detectLang, lang-switcher.init::rewriteSidebar, lang-switcher.init::render) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
  • lang-switcher.init::detectLang (cognitive 26) REDACTED:31 — lang-switcher.init::detectLang has cognitive complexity 26 (threshold 15). Drivers by points: if/else 8 (14 pts), loops 4 (6 pts), boolean chains 5, error handling 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: 3 other methods here (lang-switcher.init::translatePath, lang-switcher.init::rewriteSidebar, lang-switcher.init::render) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
  • lang-switcher.init::render (cognitive 24) REDACTED:503 — lang-switcher.init::render has cognitive complexity 24 (threshold 15). Drivers by points: ternaries 4 (10 pts), if/else 6 (8 pts), loops 3 (4 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: 3 other methods here (lang-switcher.init::detectLang, lang-switcher.init::translatePath, lang-switcher.init::rewriteSidebar) have the same decision points, in the same order, at the same nesting depths — so this is one pattern written 4 times rather than 4 independent problems. Splitting this body alone leaves the other 3 exactly as they are. Where these are variations on one operation, the change that clears all 4 is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D29 · Static Analysis (SAST) · REDACTED · ×4
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Duplicated block (31 lines × 2) · ×4
  • Duplicated block (31 lines × 2) chapter3/agentic-rag-for-user-memory/config.py:131 — chapter3/agentic-rag-for-user-memory/config.py:131-161 | chapter3/contextual-retrieval-for-user-memory/config.py:131-161 — `chapter3/agentic-rag-for-user-memory/config.py` and `chapter3/contextual-retrieval-for-user-memory/config.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 5 separate duplicated blocks between them, totalling at least 98 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (31 lines × 2) chapter3/agentic-rag-for-user-memory/indexer.py:217 — chapter3/agentic-rag-for-user-memory/indexer.py:217-247 | chapter3/contextual-retrieval-for-user-memory/indexer.py:125-155 — `chapter3/agentic-rag-for-user-memory/indexer.py` and `chapter3/contextual-retrieval-for-user-memory/indexer.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 10 separate duplicated blocks between them, totalling at least 347 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (31 lines × 2) REDACTED:74 — REDACTED:74-104 | REDACTED:74-104 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 13 separate duplicated blocks between them, totalling at least 349 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (31 lines × 2) chapter4/execution-tools/multilang_executor.py:453 — chapter4/execution-tools/multilang_executor.py:453-483 | chapter4/execution-tools/multilang_executor.py:609-639 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (29 lines × 2) · ×4
  • Duplicated block (29 lines × 2) chapter2/local_llm_serving/benchmark.py:376 — chapter2/local_llm_serving/benchmark.py:376-404 | chapter8/prompt-distillation/train_sft_trl.py:352-380 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `chapter2/local_llm_serving/benchmark.py:376` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (29 lines × 2) REDACTED:352 — REDACTED:352-380 | REDACTED:352-380 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 13 separate duplicated blocks between them, totalling at least 349 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (29 lines × 2) chapter3/agentic-rag/evaluation/evaluate.py:372 — chapter3/agentic-rag/evaluation/evaluate.py:372-400 | chapter3/contextual-retrieval/evaluation/evaluate.py:364-392 — before extracting anything, compare `chapter3/agentic-rag/evaluation/evaluate.py` and `chapter3/contextual-retrieval/evaluation/evaluate.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 369 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (29 lines × 2) chapter6/agent-with-event-trigger/server.py:177 — chapter6/agent-with-event-trigger/server.py:177-205 | chapter6/agent-with-event-trigger/server_fastapi.py:171-199 — before extracting anything, compare `chapter6/agent-with-event-trigger/server.py` and `chapter6/agent-with-event-trigger/server_fastapi.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 189 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (26 lines × 2) · ×4
  • Duplicated block (26 lines × 2) chapter3/agentic-rag-for-user-memory/config.py:293 — chapter3/agentic-rag-for-user-memory/config.py:293-318 | chapter3/contextual-retrieval-for-user-memory/config.py:282-307 — `chapter3/agentic-rag-for-user-memory/config.py` and `chapter3/contextual-retrieval-for-user-memory/config.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 5 separate duplicated blocks between them, totalling at least 98 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (26 lines × 2) chapter3/agentic-rag-for-user-memory/demo_ui_improvements.py:121 — chapter3/agentic-rag-for-user-memory/demo_ui_improvements.py:121-146 | chapter3/contextual-retrieval-for-user-memory/demo_ui_improvements.py:121-146 — `chapter3/agentic-rag-for-user-memory/demo_ui_improvements.py` and `chapter3/contextual-retrieval-for-user-memory/demo_ui_improvements.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 121 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (26 lines × 2) chapter3/agentic-rag-for-user-memory/indexer.py:346 — chapter3/agentic-rag-for-user-memory/indexer.py:346-371 | chapter3/contextual-retrieval-for-user-memory/indexer.py:245-270 — `chapter3/agentic-rag-for-user-memory/indexer.py` and `chapter3/contextual-retrieval-for-user-memory/indexer.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 10 separate duplicated blocks between them, totalling at least 347 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (26 lines × 2) REDACTED:46 — REDACTED:46-71 | REDACTED:46-71 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 13 separate duplicated blocks between them, totalling at least 349 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (23 lines × 2) · ×4
  • Duplicated block (23 lines × 2) chapter3/agentic-rag/main.py:162 — chapter3/agentic-rag/main.py:162-184 | chapter3/contextual-retrieval/main.py:160-182 — `chapter3/agentic-rag/main.py` and `chapter3/contextual-retrieval/main.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 9 separate duplicated blocks between them, totalling at least 254 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (23 lines × 2) chapter3/agentic-rag/tools.py:350 — chapter3/agentic-rag/tools.py:350-372 | chapter3/contextual-retrieval/tools.py:355-377 — `chapter3/agentic-rag/tools.py` and `chapter3/contextual-retrieval/tools.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 14 separate duplicated blocks between them, totalling at least 341 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (23 lines × 2) chapter5/coding-agent/agent.py:496 — chapter5/coding-agent/agent.py:496-518 | chapter5/coding-agent/agent_new.py:275-297 — before extracting anything, compare `chapter5/coding-agent/agent.py` and `chapter5/coding-agent/agent_new.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 198 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (23 lines × 2) chapter8/sesame/batch_inference.py:167 — chapter8/sesame/batch_inference.py:167-189 | chapter8/sesame/inference.py:150-172 — before extracting anything, compare `chapter8/sesame/batch_inference.py` and `chapter8/sesame/inference.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 80 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `chapter8/sesame/batch_inference.py:167` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (22 lines × 2) · ×4
  • Duplicated block (22 lines × 2) chapter2/local_llm_serving/benchmark.py:342 — chapter2/local_llm_serving/benchmark.py:342-363 | chapter3/user-memory-evaluation/main.py:353-374 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `chapter2/local_llm_serving/benchmark.py:342` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (22 lines × 2) chapter3/agentic-rag/agent.py:390 — chapter3/agentic-rag/agent.py:390-411 | chapter3/contextual-retrieval/agent.py:321-342 — `chapter3/agentic-rag/agent.py` and `chapter3/contextual-retrieval/agent.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 6 separate duplicated blocks between them, totalling at least 111 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (22 lines × 2) chapter3/user-memory/locomo_benchmark.py:321 — chapter3/user-memory/locomo_benchmark.py:321-342 | chapter3/user-memory/locomo_benchmark.py:402-423 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (22 lines × 2) chapter4/collaboration-tools/src/chess_tools.py:227 — chapter4/collaboration-tools/src/chess_tools.py:227-248 | chapter4/collaboration-tools/src/chess_tools.py:387-408 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (15 lines × 3) · ×4
  • Duplicated block (15 lines × 3) chapter3/user-memory/agent.py:122 — chapter3/user-memory/agent.py:122-136 | chapter3/user-memory/conversational_agent.py:113-127 | REDACTED:304-318 — before extracting anything, compare `chapter3/user-memory/agent.py` and `chapter3/user-memory/conversational_agent.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 76 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `chapter3/user-memory/agent.py:122` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 3) chapter3/user-memory/memory_manager.py:143 — chapter3/user-memory/memory_manager.py:143-157 | chapter3/user-memory/memory_manager.py:388-402 | chapter3/user-memory/memory_manager.py:570-584 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (15 lines × 3) chapter4/multimodal-agent/agent.py:515 — chapter4/multimodal-agent/agent.py:515-529 | chapter4/multimodal-agent/agent.py:764-778 | chapter4/multimodal-agent/agent.py:810-824 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter4/multimodal-agent/agent.py:515` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (15 lines × 3) REDACTED:741 — REDACTED:741-755 | REDACTED:848-862 | REDACTED:903-917 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:741` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (8–9 lines × 2) · ×4
  • Duplicated block (8–9 lines × 2) chapter3/agentic-rag-for-user-memory/main.py:184 — chapter3/agentic-rag-for-user-memory/main.py:184-191 | chapter3/contextual-retrieval-for-user-memory/main.py:534-542 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `chapter3/agentic-rag-for-user-memory/main.py:184` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8–9 lines × 2) REDACTED:394 — REDACTED:394-401 | chapter3/contextual-retrieval/index_local_laws_contextual.py:458-466 — `REDACTED` and `chapter3/contextual-retrieval/index_local_laws_contextual.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 7 separate duplicated blocks between them, totalling at least 122 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (8–9 lines × 2) REDACTED:349 — REDACTED:349-357 | REDACTED:319-326 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (8–9 lines × 2) chapter5/permission-embedded-data-objects/pedo/eval/dataguardbench/agentspec_wrap.py:119 — chapter5/permission-embedded-data-objects/pedo/eval/dataguardbench/agentspec_wrap.py:119-126 | chapter5/permission-embedded-data-objects/pedo/eval/dataguardbench/agentspec_wrap.py:127-135 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter5/permission-embedded-data-objects/pedo/eval/dataguardbench/agentspec_wrap.py:119` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (7 lines × 6) · ×4
  • Duplicated block (7 lines × 6) book-ar/fit_svg_text.py:34 — book-ar/fit_svg_text.py:34-40 | book-en/fit_svg_text.py:34-40 | book-es/fit_svg_text.py:37-43 | book-id/fit_svg_text.py:37-43 | book-ru/fit_svg_text.py:34-40 | book-tr/fit_svg_text.py:37-43 — `book-ar/fit_svg_text.py` and `book-en/fit_svg_text.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 2 separate duplicated blocks between them, totalling at least 15 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (7 lines × 6) book-ar/svg_lib.py:315 — book-ar/svg_lib.py:315-321 | book-en/svg_lib.py:289-295 | book-es/svg_lib.py:289-295 | book-id/svg_lib.py:289-295 | book-ru/svg_lib.py:289-295 | book-tr/svg_lib.py:289-295 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (7 lines × 6) book-ar/svg_lib.py:539 — book-ar/svg_lib.py:539-545 | book-en/svg_lib.py:513-519 | book-es/svg_lib.py:513-519 | book-id/svg_lib.py:513-519 | book-ru/svg_lib.py:513-519 | book-tr/svg_lib.py:513-519 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `book-ar/svg_lib.py:539` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 6) book-ar/svg_lib.py:658 — book-ar/svg_lib.py:658-664 | book-en/svg_lib.py:632-638 | book-es/svg_lib.py:632-638 | book-id/svg_lib.py:632-638 | book-ru/svg_lib.py:632-638 | book-tr/svg_lib.py:632-638 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
R10 · Code Duplication · Duplicated block (16 lines × 2 locations) · ×4
  • Duplicated block (16 lines × 2 locations) chapter6/live-audio/frontend/pages/index.tsx:624 — chapter6/live-audio/frontend/pages/index.tsx:624 · chapter6/live-audio/frontend/pages/index.tsx:681 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (16 lines × 2 locations) REDACTED:178 — REDACTED:178 · REDACTED:554 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
  • Duplicated block (16 lines × 2 locations) REDACTED:255 — REDACTED:255 · REDACTED:591 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (16 lines × 2 locations) web-astro/scripts/collaboration-society-figures.mjs:151 — web-astro/scripts/collaboration-society-figures.mjs:151 · web-astro/scripts/collaboration-society-figures.mjs:274 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
R10 · Code Duplication · Duplicated block (12 lines × 2 locations) · ×4
  • Duplicated block (12 lines × 2 locations) REDACTED:79 — REDACTED:79 · REDACTED:78 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
  • Duplicated block (12 lines × 2 locations) REDACTED:552 — REDACTED:552 · REDACTED:821 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
  • Duplicated block (12 lines × 2 locations) REDACTED:138 — REDACTED:138 · REDACTED:298 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
  • Duplicated block (12 lines × 2 locations) REDACTED:342 — REDACTED:342 · REDACTED:356 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
R7 · Dead Code · Dead file (~2 LoC) · ×4
  • Dead file (~2 LoC) chapter4/execution-tools/validation/experiment_4_4/real_mcp_20260730T062500Z/workspace/valid.js — no import path from any entry point (20 application, 15 tooling, 40 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
  • Dead file (~2 LoC) chapter4/execution-tools/validation/experiment_4_4/real_mcp_20260730T070500Z/workspace/valid.js — no import path from any entry point (20 application, 15 tooling, 40 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
  • Dead file (~2 LoC) chapter4/execution-tools/validation/experiment_4_4/real_mcp_gui_20260802T093348Z/workspace/valid.js — no import path from any entry point (20 application, 15 tooling, 40 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
  • Dead file (~2 LoC) chapter4/execution-tools/validation/experiment_4_4/real_mcp_gui_20260802T093657Z/workspace/valid.js — no import path from any entry point (20 application, 15 tooling, 40 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
AC6 · Visual & motion safety · Low contrast colour pair in CSS (3.3 · ×3
  • Low contrast colour pair in CSS (3.3:1) extras/agent-lab/agent-trajectory.js:222 — `.error` sets color: #9a6700 on background-color: #1c2128 — 3.3:1, below the 4.5:1 WCAG AA minimum for normal text. Darken or lighten one of them.
  • Low contrast colour pair in CSS (3.3:1) chapter5/conversational-ui/frontend/src/theme.css:96 — `.send-button` sets color: #ffffff on background-color: #16a34a — 3.3:1, below the 4.5:1 WCAG AA minimum for normal text. Darken or lighten one of them.
  • Low contrast colour pair in CSS (3.3:1) chapter5/conversational-ui/baseline/src/theme.css:96 — `.send-button` sets color: #ffffff on background-color: #16a34a — 3.3:1, below the 4.5:1 WCAG AA minimum for normal text. Darken or lighten one of them.
D10 · Test Quality · No assertions · ×3
  • No assertions: should handle streaming via OpenRouter chapter6/live-audio/backend/tests/test-llm-providers.js:304 — This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: should handle creative tasks with Gemini chapter6/live-audio/backend/tests/test-llm-providers.js:390 — This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
  • No assertions: should handle Chinese language tasks chapter6/live-audio/backend/tests/test-llm-providers.js:465 — This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
D2 · Cognitive Complexity · demo.main (cognitive 23) · ×3
  • demo.main (cognitive 23) chapter10/voice-werewolf/demo.py:440 — demo.main has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (10 pts), boolean chains 6, ternaries 3 (6 pts), error handling 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • demo.main (cognitive 23) chapter5/conversational-ui/demo.py:163 — demo.main has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (12 pts), ternaries 5 (8 pts), loops 2 (3 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • demo.main (cognitive 23) chapter5/small-model-codified-rules/demo.py:428 — demo.main has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11 (18 pts), boolean chains 2, loops 2, ternaries 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · main._llm_reply (cognitive 17) · ×3
  • main._llm_reply (cognitive 17) REDACTED:56 — main._llm_reply has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 6, if/else 4 (5 pts), ternaries 2 (4 pts), error handling 2 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • main._llm_reply (cognitive 17) REDACTED:56 — main._llm_reply has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 6, if/else 4 (5 pts), ternaries 2 (4 pts), error handling 2 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • main._llm_reply (cognitive 17) REDACTED:56 — main._llm_reply has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 6, if/else 4 (5 pts), ternaries 2 (4 pts), error handling 2 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D29 · Static Analysis (SAST) · REDACTED · ×3
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Duplicated block (56 lines × 2) · ×3
  • Duplicated block (56 lines × 2) REDACTED:110 — REDACTED:110-165 | REDACTED:110-165 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 271 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (56 lines × 2) chapter3/agentic-rag-for-user-memory/indexer.py:518 — chapter3/agentic-rag-for-user-memory/indexer.py:518-573 | chapter3/contextual-retrieval-for-user-memory/indexer.py:402-457 — `chapter3/agentic-rag-for-user-memory/indexer.py` and `chapter3/contextual-retrieval-for-user-memory/indexer.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 10 separate duplicated blocks between them, totalling at least 347 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (56 lines × 2) chapter3/user-memory/agent.py:82 — chapter3/user-memory/agent.py:82-137 | chapter3/user-memory/conversational_agent.py:73-128 — before extracting anything, compare `chapter3/user-memory/agent.py` and `chapter3/user-memory/conversational_agent.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 76 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (41 lines × 2) · ×3
  • Duplicated block (41 lines × 2) chapter3/agentic-rag/tools.py:202 — chapter3/agentic-rag/tools.py:202-242 | chapter3/contextual-retrieval/tools.py:209-249 — `chapter3/agentic-rag/tools.py` and `chapter3/contextual-retrieval/tools.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 14 separate duplicated blocks between them, totalling at least 341 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (41 lines × 2) REDACTED:369 — REDACTED:369-409 | REDACTED:413-453 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (41 lines × 2) REDACTED:484 — REDACTED:484-526 | chapter9/self-modifying-agent/evolution.py:276-316 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (38 lines × 2) · ×3
  • Duplicated block (38 lines × 2) REDACTED:349 — REDACTED:349-386 | REDACTED:332-369 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 6 separate duplicated blocks between them, totalling at least 324 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (38 lines × 2) chapter3/agentic-rag-for-user-memory/demo_ui_improvements.py:17 — chapter3/agentic-rag-for-user-memory/demo_ui_improvements.py:17-54 | chapter3/contextual-retrieval-for-user-memory/demo_ui_improvements.py:17-54 — `chapter3/agentic-rag-for-user-memory/demo_ui_improvements.py` and `chapter3/contextual-retrieval-for-user-memory/demo_ui_improvements.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 121 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (38 lines × 2) chapter3/agentic-rag/evaluation/evaluate.py:301 — chapter3/agentic-rag/evaluation/evaluate.py:301-338 | chapter3/contextual-retrieval/evaluation/evaluate.py:293-330 — before extracting anything, compare `chapter3/agentic-rag/evaluation/evaluate.py` and `chapter3/contextual-retrieval/evaluation/evaluate.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 369 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (37 lines × 2) · ×3
  • Duplicated block (37 lines × 2) REDACTED:313 — REDACTED:313-349 | REDACTED:313-349 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 271 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (37 lines × 2) chapter3/agentic-rag/main.py:254 — chapter3/agentic-rag/main.py:254-290 | chapter3/contextual-retrieval/main.py:231-267 — `chapter3/agentic-rag/main.py` and `chapter3/contextual-retrieval/main.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 9 separate duplicated blocks between them, totalling at least 254 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (37 lines × 2) chapter3/agentic-rag-for-user-memory/demo_agent_logging.py:26 — chapter3/agentic-rag-for-user-memory/demo_agent_logging.py:26-62 | chapter3/contextual-retrieval-for-user-memory/demo_agent_logging.py:26-62 — `chapter3/agentic-rag-for-user-memory/demo_agent_logging.py` and `chapter3/contextual-retrieval-for-user-memory/demo_agent_logging.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 106 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (34 lines × 3) · ×3
  • Duplicated block (34 lines × 3) chapter4/multimodal-agent/agent.py:199 — chapter4/multimodal-agent/agent.py:199-232 | chapter4/multimodal-agent/agent.py:253-286 | chapter4/multimodal-agent/agent.py:627-660 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (34 lines × 3) REDACTED:57 — REDACTED:57-90 | REDACTED:57-90 | REDACTED:57-90 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 148 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:57` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (34 lines × 3) REDACTED:46 — REDACTED:46-80 | REDACTED:235-268 | chapter5/permission-embedded-data-objects/pedo/eval/benchmark_reactions.py:31-118 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:46` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (32–33 lines × 2) · ×3
  • Duplicated block (32–33 lines × 2) chapter1/web-search-agent/agent.py:197 — chapter1/web-search-agent/agent.py:197-228 | chapter1/web-search-agent/agent.py:262-294 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter1/web-search-agent/agent.py:197` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (32–33 lines × 2) chapter2/attention_visualization/agent.py:304 — chapter2/attention_visualization/agent.py:304-336 | chapter2/attention_visualization/main.py:591-622 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `chapter2/attention_visualization/agent.py:304` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (32–33 lines × 2) chapter3/agentic-rag-for-user-memory/quickstart.py:18 — chapter3/agentic-rag-for-user-memory/quickstart.py:18-49 | chapter3/contextual-retrieval-for-user-memory/quickstart.py:18-50 — `chapter3/agentic-rag-for-user-memory/quickstart.py` and `chapter3/contextual-retrieval-for-user-memory/quickstart.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 134 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (30 lines × 2) · ×3
  • Duplicated block (30 lines × 2) chapter3/agentic-rag-for-user-memory/quickstart.py:128 — chapter3/agentic-rag-for-user-memory/quickstart.py:128-157 | chapter3/contextual-retrieval-for-user-memory/quickstart.py:129-158 — `chapter3/agentic-rag-for-user-memory/quickstart.py` and `chapter3/contextual-retrieval-for-user-memory/quickstart.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 134 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (30 lines × 2) REDACTED:67 — REDACTED:67-96 | chapter3/contextual-retrieval/index_local_laws_contextual.py:81-110 — `REDACTED` and `chapter3/contextual-retrieval/index_local_laws_contextual.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 7 separate duplicated blocks between them, totalling at least 122 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `chapter3/contextual-retrieval/index_local_laws_contextual.py:76` calls `info` and `REDACTED:61` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (30 lines × 2) REDACTED:117 — REDACTED:117-146 | REDACTED:77-106 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 73 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (21–22 lines × 2) · ×3
  • Duplicated block (21–22 lines × 2) chapter2/system-hint/main.py:31 — chapter2/system-hint/main.py:31-51 | chapter3/user-memory/main.py:41-62 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (21–22 lines × 2) chapter5/permission-embedded-data-objects/run_live_security_eval.py:595 — chapter5/permission-embedded-data-objects/run_live_security_eval.py:595-615 | chapter5/permission-embedded-data-objects/run_live_security_eval.py:656-677 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (21–22 lines × 2) REDACTED:256 — REDACTED:256-276 | REDACTED:284-305 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (19–20 lines × 2) · ×3
  • Duplicated block (19–20 lines × 2) REDACTED:273 — REDACTED:273-292 | REDACTED:352-370 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (19–20 lines × 2) chapter4/perception-tools/src/yahoo_finance_tools.py:177 — chapter4/perception-tools/src/yahoo_finance_tools.py:177-196 | chapter4/perception-tools/src/yahoo_finance_tools.py:384-402 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (19–20 lines × 2) chapter6/rgb-sim2real-grasping/preflight.py:71 — chapter6/rgb-sim2real-grasping/preflight.py:71-90 | REDACTED:54-72 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
D4 · Code Duplication · Duplicated block (16–18 lines × 2) · ×3
  • Duplicated block (16–18 lines × 2) REDACTED:671 — REDACTED:671-688 | REDACTED:922-937 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (16–18 lines × 2) chapter4/perception-tools/src/google_search_enhanced.py:194 — chapter4/perception-tools/src/google_search_enhanced.py:194-209 | chapter4/perception-tools/src/wayback_enhanced.py:66-83 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `chapter4/perception-tools/src/wayback_enhanced.py:66` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `chapter4/perception-tools/src/google_search_enhanced.py:192` calls `info`, `TextContent` and `chapter4/perception-tools/src/wayback_enhanced.py:66` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (16–18 lines × 2) REDACTED:281 — REDACTED:281-298 | REDACTED:372-387 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (17 lines × 3) · ×3
  • Duplicated block (17 lines × 3) chapter3/agentic-rag/quickstart.py:122 — chapter3/agentic-rag/quickstart.py:122-138 | chapter3/user-memory/main.py:722-743 | chapter3/user-memory/main.py:772-793 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (17 lines × 3) REDACTED:375 — REDACTED:375-391 | REDACTED:419-435 | REDACTED:462-478 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:375` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 3) chapter5/permission-embedded-data-objects/pedo/scenarios/hiring.py:141 — chapter5/permission-embedded-data-objects/pedo/scenarios/hiring.py:141-159 | chapter5/permission-embedded-data-objects/pedo/scenarios/hiring.py:228-244 | chapter5/permission-embedded-data-objects/pedo/scenarios/project_mgmt.py:224-240 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `chapter5/permission-embedded-data-objects/pedo/scenarios/hiring.py:141` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (17 lines × 2) · ×3
  • Duplicated block (17 lines × 2) chapter3/retrieval-pipeline/retrieval_pipeline.py:204 — chapter3/retrieval-pipeline/retrieval_pipeline.py:204-220 | chapter3/retrieval-pipeline/retrieval_pipeline.py:223-239 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (17 lines × 2) chapter4/perception-tools/src/filesystem_tools.py:168 — chapter4/perception-tools/src/filesystem_tools.py:168-184 | chapter4/perception-tools/src/filesystem_tools.py:223-239 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (17 lines × 2) REDACTED:132 — REDACTED:132-148 | chapter9/prompt-auto-optimization/config.py:189-205 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (16 lines × 3) · ×3
  • Duplicated block (16 lines × 3) chapter4/perception-tools/src/filesystem_tools.py:480 — chapter4/perception-tools/src/filesystem_tools.py:480-496 | chapter4/perception-tools/src/search_tools.py:314-331 | chapter4/perception-tools/src/search_tools.py:407-422 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `chapter4/perception-tools/src/filesystem_tools.py:480` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (16 lines × 3) chapter5/permission-embedded-data-objects/pedo/scenarios/banking.py:86 — chapter5/permission-embedded-data-objects/pedo/scenarios/banking.py:86-103 | chapter5/permission-embedded-data-objects/pedo/scenarios/ecommerce.py:101-116 | chapter5/permission-embedded-data-objects/pedo/scenarios/healthcare.py:64-81 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `chapter5/permission-embedded-data-objects/pedo/scenarios/banking.py:86` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 3) chapter6/gemini-xlerobot-navigation/validate_evidence.py:77 — chapter6/gemini-xlerobot-navigation/validate_evidence.py:77-92 | chapter6/rgb-sim2real-grasping/validate_evidence.py:62-77 | chapter6/xlerobot-teleoperation/validate_evidence.py:57-72 — `chapter6/gemini-xlerobot-navigation/validate_evidence.py` and `chapter6/rgb-sim2real-grasping/validate_evidence.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 38 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (15–16 lines × 2) · ×3
  • Duplicated block (15–16 lines × 2) REDACTED:390 — REDACTED:390-404 | REDACTED:412-427 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 6 separate duplicated blocks between them, totalling at least 324 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (15–16 lines × 2) chapter2/context-compression/experiment.py:294 — chapter2/context-compression/experiment.py:294-309 | chapter2/context-compression/run_all_strategies.py:369-383 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `chapter2/context-compression/experiment.py:294` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15–16 lines × 2) chapter2/system-hint/main.py:308 — chapter2/system-hint/main.py:308-323 | chapter2/system-hint/main.py:330-344 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter2/system-hint/main.py:308` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (14–15 lines × 2) · ×3
  • Duplicated block (14–15 lines × 2) REDACTED:480 — REDACTED:480-493 | REDACTED:764-778 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (14–15 lines × 2) chapter5/paper-to-ppt/agents.py:355 — chapter5/paper-to-ppt/agents.py:355-369 | chapter5/paper-to-ppt/agents.py:432-445 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (14–15 lines × 2) REDACTED:694 — REDACTED:694-708 | REDACTED:851-864 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (14 lines × 3) · ×3
  • Duplicated block (14 lines × 3) chapter3/agentic-rag-for-user-memory/evaluator.py:575 — chapter3/agentic-rag-for-user-memory/evaluator.py:575-588 | chapter3/contextual-retrieval-for-user-memory/contextual_evaluator.py:670-683 | chapter3/contextual-retrieval-for-user-memory/evaluator.py:575-588 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `chapter3/contextual-retrieval-for-user-memory/contextual_evaluator.py:668` calls `sum`, `values` and `chapter3/agentic-rag-for-user-memory/evaluator.py:573` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 3) chapter4/multimodal-agent/agent.py:453 — chapter4/multimodal-agent/agent.py:453-466 | chapter4/multimodal-agent/agent.py:536-552 | chapter4/multimodal-agent/agent.py:572-588 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (14 lines × 3) chapter4/perception-tools/src/multimodal_tools.py:90 — chapter4/perception-tools/src/multimodal_tools.py:90-103 | chapter4/perception-tools/src/multimodal_tools.py:568-581 | chapter4/perception-tools/src/search_tools.py:325-338 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `chapter4/perception-tools/src/multimodal_tools.py:90` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (11–14 lines × 2) · ×3
  • Duplicated block (11–14 lines × 2) chapter3/agentic-rag-for-user-memory/agent.py:137 — chapter3/agentic-rag-for-user-memory/agent.py:137-150 | chapter3/contextual-retrieval-for-user-memory/agent.py:137-147 — `chapter3/agentic-rag-for-user-memory/agent.py` and `chapter3/contextual-retrieval-for-user-memory/agent.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 278 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `chapter3/agentic-rag-for-user-memory/agent.py:137` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (11–14 lines × 2) REDACTED:201 — REDACTED:201-211 | REDACTED:384-397 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:201` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11–14 lines × 2) chapter3/user-memory-evaluation/generate_test_cases.py:293 — chapter3/user-memory-evaluation/generate_test_cases.py:293-306 | chapter3/user-memory-evaluation/generate_test_cases.py:310-320 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (11 lines × 6) · ×3
  • Duplicated block (11 lines × 6) book-ar/svg_lib.py:370 — book-ar/svg_lib.py:370-380 | book-en/svg_lib.py:344-354 | book-es/svg_lib.py:344-354 | book-id/svg_lib.py:344-354 | book-ru/svg_lib.py:344-354 | book-tr/svg_lib.py:344-354 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (11 lines × 6) book-ar/svg_lib.py:451 — book-ar/svg_lib.py:451-461 | book-en/svg_lib.py:425-435 | book-es/svg_lib.py:425-435 | book-id/svg_lib.py:425-435 | book-ru/svg_lib.py:425-435 | book-tr/svg_lib.py:425-435 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `book-ar/svg_lib.py:451` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 6) chapter9/self-modifying-agent/validation/real_20260729T171050Z/candidates/deterministic/retry_policy.py:10 — chapter9/self-modifying-agent/validation/real_20260729T171050Z/candidates/deterministic/retry_policy.py:10-20 | chapter9/self-modifying-agent/validation/real_20260729T171050Z/candidates/real_llm/retry_policy.py:8-18 | chapter9/self-modifying-agent/validation/real_20260729T171118Z/candidates/deterministic/retry_policy.py:10-20 | chapter9/self-modifying-agent/validation/real_20260729T171118Z/candidates/real_llm/retry_policy.py:8-18 | chapter9/self-modifying-agent/validation/real_20260802T043954Z/candidates/deterministic/retry_policy.py:10-20 | chapter9/self-modifying-agent/validation/real_20260802T043954Z/candidates/real_llm/retry_policy.py:10-20 — `chapter9/self-modifying-agent/validation/real_20260729T171050Z/candidates/deterministic/retry_policy.py` and `chapter9/self-modifying-agent/validation/real_20260729T171050Z/candidates/real_llm/retry_policy.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 1 separate duplicated blocks between them, totalling at least 11 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (11 lines × 4) · ×3
  • Duplicated block (11 lines × 4) REDACTED:335 — REDACTED:335-345 | chapter3/agentic-rag-for-user-memory/indexer.py:542-552 | REDACTED:335-345 | chapter3/contextual-retrieval-for-user-memory/indexer.py:426-436 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 271 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:335` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 4) chapter3/agentic-rag/tools.py:337 — chapter3/agentic-rag/tools.py:337-347 | chapter3/agentic-rag/tools.py:363-373 | chapter3/contextual-retrieval/tools.py:342-352 | chapter3/contextual-retrieval/tools.py:368-378 — `chapter3/agentic-rag/tools.py` and `chapter3/contextual-retrieval/tools.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 14 separate duplicated blocks between them, totalling at least 341 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `chapter3/agentic-rag/tools.py:337` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (11 lines × 4) chapter6/astra-async-steering/experiment.py:69 — chapter6/astra-async-steering/experiment.py:69-79 | chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:69-79 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:69-79 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:69-79 — before extracting anything, compare `chapter6/astra-async-steering/experiment.py` and `chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 251 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (11 lines × 3) · ×3
  • Duplicated block (11 lines × 3) chapter3/agentic-rag-for-user-memory/evaluator.py:381 — chapter3/agentic-rag-for-user-memory/evaluator.py:381-391 | chapter3/contextual-retrieval-for-user-memory/contextual_evaluator.py:401-411 | chapter3/contextual-retrieval-for-user-memory/evaluator.py:381-391 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `chapter3/agentic-rag-for-user-memory/evaluator.py:381` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 3) chapter5/log-diagnosis/http_service.py:75 — chapter5/log-diagnosis/http_service.py:75-85 | chapter5/log-diagnosis/validation/runs/exp5-8-live-http-mcp-20260730-053056/http_service.py:75-85 | chapter5/log-diagnosis/validation/runs/exp5-8-live-http-mcp-20260730-053403/http_service.py:75-85 — before extracting anything, compare `chapter5/log-diagnosis/http_service.py` and `chapter5/log-diagnosis/validation/runs/exp5-8-live-http-mcp-20260730-053056/http_service.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 50 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (11 lines × 3) chapter7/user-memory-system-evaluation/experiment.py:1131 — chapter7/user-memory-system-evaluation/experiment.py:1131-1141 | chapter7/user-memory-system-evaluation/experiment.py:1146-1156 | chapter7/user-memory-system-evaluation/experiment.py:1173-1183 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (9 lines × 6) · ×3
  • Duplicated block (9 lines × 6) book-ar/svg_lib.py:383 — book-ar/svg_lib.py:383-391 | book-en/svg_lib.py:357-365 | book-es/svg_lib.py:357-365 | book-id/svg_lib.py:357-365 | book-ru/svg_lib.py:357-365 | book-tr/svg_lib.py:357-365 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (9 lines × 6) book-ar/svg_lib.py:495 — book-ar/svg_lib.py:495-503 | book-en/svg_lib.py:469-477 | book-es/svg_lib.py:469-477 | book-id/svg_lib.py:469-477 | book-ru/svg_lib.py:469-477 | book-tr/svg_lib.py:469-477 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `book-ar/svg_lib.py:495` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 6) book-ar/svg_lib.py:595 — book-ar/svg_lib.py:595-603 | book-en/svg_lib.py:569-577 | book-es/svg_lib.py:569-577 | book-id/svg_lib.py:569-577 | book-ru/svg_lib.py:569-577 | book-tr/svg_lib.py:569-577 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (9 lines × 4) · ×3
  • Duplicated block (9 lines × 4) chapter6/astra-async-steering/experiment.py:200 — chapter6/astra-async-steering/experiment.py:200-208 | chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:200-208 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:185-193 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:185-193 — before extracting anything, compare `chapter6/astra-async-steering/experiment.py` and `chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 251 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `chapter6/astra-async-steering/experiment.py:197` calls `get` and `chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:182` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 4) chapter6/astra-async-steering/experiment.py:218 — chapter6/astra-async-steering/experiment.py:218-226 | chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:218-226 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:203-211 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:203-211 — before extracting anything, compare `chapter6/astra-async-steering/experiment.py` and `chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 251 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `chapter6/astra-async-steering/experiment.py:218` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 4) REDACTED:109 — REDACTED:109-117 | REDACTED:107-115 | REDACTED:107-115 | REDACTED:107-115 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 114 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (8 lines × 6) · ×3
  • Duplicated block (8 lines × 6) book-ar/svg_lib.py:257 — book-ar/svg_lib.py:257-264 | book-en/svg_lib.py:231-238 | book-es/svg_lib.py:231-238 | book-id/svg_lib.py:231-238 | book-ru/svg_lib.py:231-238 | book-tr/svg_lib.py:231-238 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `book-ar/svg_lib.py:257` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 6) book-ar/svg_lib.py:649 — book-ar/svg_lib.py:649-656 | book-en/svg_lib.py:623-630 | book-es/svg_lib.py:623-630 | book-id/svg_lib.py:623-630 | book-ru/svg_lib.py:623-630 | book-tr/svg_lib.py:623-630 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (8 lines × 6) book-ar/fit_svg_text.py:23 — book-ar/fit_svg_text.py:23-30 | book-en/fit_svg_text.py:23-30 | book-es/fit_svg_text.py:26-33 | book-id/fit_svg_text.py:26-33 | book-ru/fit_svg_text.py:23-30 | book-tr/fit_svg_text.py:26-33 — `book-ar/fit_svg_text.py` and `book-en/fit_svg_text.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 2 separate duplicated blocks between them, totalling at least 15 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (8 lines × 3) · ×3
  • Duplicated block (8 lines × 3) chapter2/context-compression/experiment.py:303 — chapter2/context-compression/experiment.py:303-310 | chapter2/context-compression/main.py:193-200 | chapter2/context-compression/run_all_strategies.py:377-384 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `chapter2/context-compression/experiment.py:303` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (8 lines × 3) chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:98 — chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:98-105 | chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:140-147 | chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:551-558 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:98` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 3) REDACTED:101 — REDACTED:101-108 | chapter9/harness-safety-gate/llm_generator.py:23-30 | chapter9/self-modifying-agent/llm_generator.py:18-25 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
D4 · Code Duplication · Duplicated block (7 lines × 4) · ×3
  • Duplicated block (7 lines × 4) REDACTED:198 — REDACTED:198-204 | REDACTED:191-197 | REDACTED:375-381 | REDACTED:242-248 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times.
  • Duplicated block (7 lines × 4) chapter1/learning-from-experience/run_experiment_8_2.py:41 — chapter1/learning-from-experience/run_experiment_8_2.py:41-50 | chapter10/multi-role-transfer/run_official_experiment.py:70-79 | chapter10/parallel-web-research/run_official_experiment.py:74-83 | chapter6/streaming-speech/run_official_experiment.py:68-74 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (7 lines × 4) chapter6/astra-async-steering/experiment.py:395 — chapter6/astra-async-steering/experiment.py:395-401 | chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:395-401 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:373-379 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:373-379 — before extracting anything, compare `chapter6/astra-async-steering/experiment.py` and `chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 251 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (6 lines × 3) · ×3
  • Duplicated block (6 lines × 3) chapter1/context/main.py:628 — chapter1/context/main.py:628-633 | chapter1/context/main.py:1004-1009 | chapter1/context/main.py:1139-1144 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (6 lines × 3) chapter3/agentic-rag/campaign.py:40 — chapter3/agentic-rag/campaign.py:40-45 | chapter3/memory_rag_campaign.py:45-50 | chapter3/structured-knowledge-extraction/campaign.py:45-50 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `chapter3/agentic-rag/campaign.py:36` calls `compile` and `chapter3/memory_rag_campaign.py:41` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 3) chapter1/context/run_experiment_1_1.py:62 — chapter1/context/run_experiment_1_1.py:62-67 | chapter1/search-codegen/run_experiment_1_3.py:94-99 | chapter1/web-search-agent/run_experiment_1_2.py:29-34 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (6 lines × 6) · ×3
  • Duplicated block (6 lines × 6) book-ar/svg_lib.py:192 — book-ar/svg_lib.py:192-197 | book-en/svg_lib.py:176-181 | book-es/svg_lib.py:176-181 | book-id/svg_lib.py:176-181 | book-ru/svg_lib.py:176-181 | book-tr/svg_lib.py:176-181 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (6 lines × 6) book-ar/svg_lib.py:409 — book-ar/svg_lib.py:409-414 | book-en/svg_lib.py:383-388 | book-es/svg_lib.py:383-388 | book-id/svg_lib.py:383-388 | book-ru/svg_lib.py:383-388 | book-tr/svg_lib.py:383-388 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (6 lines × 6) book-ar/svg_lib.py:487 — book-ar/svg_lib.py:487-492 | book-en/svg_lib.py:461-466 | book-es/svg_lib.py:461-466 | book-id/svg_lib.py:461-466 | book-ru/svg_lib.py:461-466 | book-tr/svg_lib.py:461-466 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
X1 · Async correctness · Blocking `time.sleep` inside an `async def` · ×3
  • Blocking `time.sleep` inside an `async def` REDACTED:193 — This `async def` runs on the event loop's thread, and `time.sleep` blocks that thread: for the whole delay no other coroutine, request or callback on the loop makes progress — the Python form of blocking on a task. Use `await asyncio.sleep(…)`, which suspends only this coroutine. Where the blocking work is not a sleep but a synchronous call that cannot be made async, move it off the loop with `await asyncio.to_thread(…)` (or `loop.run_in_executor(…)`).
  • Blocking `time.sleep` inside an `async def` REDACTED:216 — This `async def` runs on the event loop's thread, and `time.sleep` blocks that thread: for the whole delay no other coroutine, request or callback on the loop makes progress — the Python form of blocking on a task. Use `await asyncio.sleep(…)`, which suspends only this coroutine. Where the blocking work is not a sleep but a synchronous call that cannot be made async, move it off the loop with `await asyncio.to_thread(…)` (or `loop.run_in_executor(…)`).
  • Blocking `time.sleep` inside an `async def` REDACTED:247 — This `async def` runs on the event loop's thread, and `time.sleep` blocks that thread: for the whole delay no other coroutine, request or callback on the loop makes progress — the Python form of blocking on a task. Use `await asyncio.sleep(…)`, which suspends only this coroutine. Where the blocking work is not a sleep but a synchronous call that cannot be made async, move it off the loop with `await asyncio.to_thread(…)` (or `loop.run_in_executor(…)`).
D1 · Cyclomatic Complexity · experiment.judge (cyclomatic 56) · ×2
  • experiment.judge (cyclomatic 56) chapter6/astra-async-steering/experiment.py:97 — experiment.judge has cyclomatic complexity 56 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • experiment.judge (cyclomatic 56) chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:97 — experiment.judge has cyclomatic complexity 56 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · experiment.judge (cyclomatic 49) · ×2
  • experiment.judge (cyclomatic 49) chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:97 — experiment.judge has cyclomatic complexity 49 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • experiment.judge (cyclomatic 49) chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:97 — experiment.judge has cyclomatic complexity 49 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · main.interactive_mode (cyclomatic 34) · ×2
  • main.interactive_mode (cyclomatic 34) REDACTED:340 — main.interactive_mode has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • main.interactive_mode (cyclomatic 34) chapter3/user-memory/main.py:92 — main.interactive_mode has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · UserMemoryEvaluator.evaluate_test_case (cyclomatic 28) · ×2
  • UserMemoryEvaluator.evaluate_test_case (cyclomatic 28) chapter3/agentic-rag-for-user-memory/evaluator.py:290 — UserMemoryEvaluator.evaluate_test_case has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • UserMemoryEvaluator.evaluate_test_case (cyclomatic 28) chapter3/contextual-retrieval-for-user-memory/evaluator.py:290 — UserMemoryEvaluator.evaluate_test_case has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · demo.main (cyclomatic 20) · ×2
  • demo.main (cyclomatic 20) chapter10/voice-werewolf/demo.py:440 — demo.main has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • demo.main (cyclomatic 20) chapter4/active-tool-discovery/demo.py:127 — demo.main has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · UserMemoryEvaluator.generate_report (cyclomatic 20) · ×2
  • UserMemoryEvaluator.generate_report (cyclomatic 20) chapter3/agentic-rag-for-user-memory/evaluator.py:521 — UserMemoryEvaluator.generate_report has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • UserMemoryEvaluator.generate_report (cyclomatic 20) chapter3/contextual-retrieval-for-user-memory/evaluator.py:521 — UserMemoryEvaluator.generate_report has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RAGEvaluator.compute_aggregate_metrics (cyclomatic 19) · ×2
  • RAGEvaluator.compute_aggregate_metrics (cyclomatic 19) chapter3/agentic-rag/evaluation/evaluate.py:206 — RAGEvaluator.compute_aggregate_metrics has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • RAGEvaluator.compute_aggregate_metrics (cyclomatic 19) chapter3/contextual-retrieval/evaluation/evaluate.py:198 — RAGEvaluator.compute_aggregate_metrics has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ConversationChunker._chunk_fixed_rounds (cyclomatic 18) · ×2
  • ConversationChunker._chunk_fixed_rounds (cyclomatic 18) REDACTED:167 — ConversationChunker._chunk_fixed_rounds has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ConversationChunker._chunk_fixed_rounds (cyclomatic 18) REDACTED:167 — ConversationChunker._chunk_fixed_rounds has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · demo.main (cyclomatic 18) · ×2
  • demo.main (cyclomatic 18) chapter3/retrieval-pipeline/demo.py:44 — demo.main has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • demo.main (cyclomatic 18) chapter5/paper-to-video/demo.py:415 — demo.main has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · demo.main (cyclomatic 17) · ×2
  • demo.main (cyclomatic 17) chapter5/dynamic-form/demo.py:631 — demo.main has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • demo.main (cyclomatic 17) chapter5/small-model-codified-rules/demo.py:428 — demo.main has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · main.main (cyclomatic 16) · ×2
  • main.main (cyclomatic 16) chapter3/agentic-rag-for-user-memory/main.py:606 — main.main has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • main.main (cyclomatic 16) chapter3/contextual-retrieval/main.py:185 — main.main has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · experiment.judge (cognitive 95) · ×2
  • experiment.judge (cognitive 95) chapter6/astra-async-steering/experiment.py:97 — experiment.judge has cognitive complexity 95 (threshold 15). Drivers by points: if/else 30 (59 pts), boolean chains 21, ternaries 7 (15 pts) (nesting depth added 37). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • experiment.judge (cognitive 95) chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:97 — experiment.judge has cognitive complexity 95 (threshold 15). Drivers by points: if/else 30 (59 pts), boolean chains 21, ternaries 7 (15 pts) (nesting depth added 37). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · experiment.judge (cognitive 82) · ×2
  • experiment.judge (cognitive 82) chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:97 — experiment.judge has cognitive complexity 82 (threshold 15). Drivers by points: if/else 27 (50 pts), boolean chains 17, ternaries 7 (15 pts) (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • experiment.judge (cognitive 82) chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:97 — experiment.judge has cognitive complexity 82 (threshold 15). Drivers by points: if/else 27 (50 pts), boolean chains 17, ternaries 7 (15 pts) (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConversationChunker._chunk_fixed_rounds (cognitive 55) · ×2
  • ConversationChunker._chunk_fixed_rounds (cognitive 55) REDACTED:167 — ConversationChunker._chunk_fixed_rounds has cognitive complexity 55 (threshold 15). Drivers by points: if/else 9 (32 pts), loops 6 (21 pts), boolean chains 2 (nesting depth added 38). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ConversationChunker._chunk_fixed_rounds (cognitive 55) REDACTED:167 — ConversationChunker._chunk_fixed_rounds has cognitive complexity 55 (threshold 15). Drivers by points: if/else 9 (32 pts), loops 6 (21 pts), boolean chains 2 (nesting depth added 38). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · UserMemoryEvaluator.evaluate_test_case (cognitive 52) · ×2
  • UserMemoryEvaluator.evaluate_test_case (cognitive 52) chapter3/agentic-rag-for-user-memory/evaluator.py:290 — UserMemoryEvaluator.evaluate_test_case has cognitive complexity 52 (threshold 15). Drivers by points: if/else 14 (21 pts), ternaries 8 (17 pts), loops 3 (8 pts), boolean chains 4, error handling 1 (2 pts) (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • UserMemoryEvaluator.evaluate_test_case (cognitive 52) chapter3/contextual-retrieval-for-user-memory/evaluator.py:290 — UserMemoryEvaluator.evaluate_test_case has cognitive complexity 52 (threshold 15). Drivers by points: if/else 14 (21 pts), ternaries 8 (17 pts), loops 3 (8 pts), boolean chains 4, error handling 1 (2 pts) (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DocumentChunker._chunk_by_paragraphs (cognitive 33) · ×2
  • DocumentChunker._chunk_by_paragraphs (cognitive 33) REDACTED:45 — DocumentChunker._chunk_by_paragraphs has cognitive complexity 33 (threshold 15). Drivers by points: if/else 11 (22 pts), loops 3 (9 pts), boolean chains 2 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • DocumentChunker._chunk_by_paragraphs (cognitive 33) REDACTED:45 — DocumentChunker._chunk_by_paragraphs has cognitive complexity 33 (threshold 15). Drivers by points: if/else 11 (22 pts), loops 3 (9 pts), boolean chains 2 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · UserMemoryRAGAgent.answer_question (cognitive 30) · ×2
  • UserMemoryRAGAgent.answer_question (cognitive 30) chapter3/agentic-rag-for-user-memory/agent.py:198 — UserMemoryRAGAgent.answer_question has cognitive complexity 30 (threshold 15). Drivers by points: if/else 7 (13 pts), error handling 2 (6 pts), loops 2 (4 pts), ternaries 2 (4 pts), boolean chains 3 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • UserMemoryRAGAgent.answer_question (cognitive 30) chapter3/contextual-retrieval-for-user-memory/agent.py:194 — UserMemoryRAGAgent.answer_question has cognitive complexity 30 (threshold 15). Drivers by points: if/else 7 (13 pts), error handling 2 (6 pts), loops 2 (4 pts), ternaries 2 (4 pts), boolean chains 3 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RAGEvaluator.compute_aggregate_metrics (cognitive 30) · ×2
  • RAGEvaluator.compute_aggregate_metrics (cognitive 30) chapter3/agentic-rag/evaluation/evaluate.py:206 — RAGEvaluator.compute_aggregate_metrics has cognitive complexity 30 (threshold 15). Drivers by points: if/else 16 (27 pts), ternaries 1 (2 pts), loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • RAGEvaluator.compute_aggregate_metrics (cognitive 30) chapter3/contextual-retrieval/evaluation/evaluate.py:198 — RAGEvaluator.compute_aggregate_metrics has cognitive complexity 30 (threshold 15). Drivers by points: if/else 16 (27 pts), ternaries 1 (2 pts), loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · UserMemoryEvaluator.generate_report (cognitive 28) · ×2
  • UserMemoryEvaluator.generate_report (cognitive 28) chapter3/agentic-rag-for-user-memory/evaluator.py:521 — UserMemoryEvaluator.generate_report has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (18 pts), ternaries 2 (4 pts), boolean chains 3, loops 3 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • UserMemoryEvaluator.generate_report (cognitive 28) chapter3/contextual-retrieval-for-user-memory/evaluator.py:521 — UserMemoryEvaluator.generate_report has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (18 pts), ternaries 2 (4 pts), boolean chains 3, loops 3 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · main.print_result (cognitive 22) · ×2
  • main.print_result (cognitive 22) chapter2/system-hint/main.py:30 — main.print_result has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (16 pts), loops 3 (6 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • main.print_result (cognitive 22) chapter3/user-memory/main.py:40 — main.print_result has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (18 pts), loops 2 (4 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · main.main (cognitive 21) · ×2
  • main.main (cognitive 21) chapter3/agentic-rag/main.py:187 — main.main has cognitive complexity 21 (threshold 15). Drivers by points: if/else 14 (16 pts), ternaries 2 (4 pts), boolean chains 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • main.main (cognitive 21) chapter7/elo-leaderboard/main.py:54 — main.main has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (12 pts), loops 2 (4 pts), ternaries 1 (3 pts), boolean chains 1, error handling 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · demo.main (cognitive 21) · ×2
  • demo.main (cognitive 21) chapter5/dynamic-form/demo.py:631 — demo.main has cognitive complexity 21 (threshold 15). Drivers by points: if/else 12, boolean chains 3, loops 2 (3 pts), ternaries 2 (3 pts) (nesting depth added 2). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • demo.main (cognitive 21) chapter5/paper-to-video/demo.py:415 — demo.main has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 5, ternaries 3, loops 2, error handling 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D29 · Static Analysis (SAST) · REDACTED · ×2
  • REDACTED
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED · ×2
  • REDACTED
  • REDACTED
D4 · Code Duplication · Members sharing a duplicated core (12 members, 50+ identical tokens) · ×2
  • Members sharing a duplicated core (12 members, 50+ identical tokens) book-ar/svg_lib.py:495 — book-ar/svg_lib.py:495-506 | book-ar/svg_lib.py:509-520 | book-en/svg_lib.py:469-480 | book-en/svg_lib.py:483-494 | book-es/svg_lib.py:469-480 | book-es/svg_lib.py:483-494 | book-id/svg_lib.py:469-480 | book-id/svg_lib.py:483-494 | book-ru/svg_lib.py:469-480 | book-ru/svg_lib.py:483-494 | book-tr/svg_lib.py:469-480 | book-tr/svg_lib.py:483-494 — These 12 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 12 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 12 times.
  • Members sharing a duplicated core (12 members, 50+ identical tokens) book-ar/svg_lib.py:573 — book-ar/svg_lib.py:573-591 | book-ar/svg_lib.py:595-610 | book-en/svg_lib.py:547-565 | book-en/svg_lib.py:569-584 | book-es/svg_lib.py:547-565 | book-es/svg_lib.py:569-584 | book-id/svg_lib.py:547-565 | book-id/svg_lib.py:569-584 | book-ru/svg_lib.py:547-565 | book-ru/svg_lib.py:569-584 | book-tr/svg_lib.py:547-565 | book-tr/svg_lib.py:569-584 — These 12 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 12 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 12 times.
D4 · Code Duplication · Duplicated block (58 lines × 2) · ×2
  • Duplicated block (58 lines × 2) chapter3/agentic-rag-for-user-memory/demo_agent_logging.py:66 — chapter3/agentic-rag-for-user-memory/demo_agent_logging.py:66-123 | chapter3/contextual-retrieval-for-user-memory/demo_agent_logging.py:66-123 — `chapter3/agentic-rag-for-user-memory/demo_agent_logging.py` and `chapter3/contextual-retrieval-for-user-memory/demo_agent_logging.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 106 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (58 lines × 2) chapter3/agentic-rag-for-user-memory/tools.py:191 — chapter3/agentic-rag-for-user-memory/tools.py:191-248 | chapter3/contextual-retrieval-for-user-memory/tools.py:191-248 — `chapter3/agentic-rag-for-user-memory/tools.py` and `chapter3/contextual-retrieval-for-user-memory/tools.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 191 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (43 lines × 2) · ×2
  • Duplicated block (43 lines × 2) chapter3/agentic-rag-for-user-memory/evaluator.py:195 — chapter3/agentic-rag-for-user-memory/evaluator.py:195-237 | chapter3/contextual-retrieval-for-user-memory/evaluator.py:195-237 — `chapter3/agentic-rag-for-user-memory/evaluator.py` and `chapter3/contextual-retrieval-for-user-memory/evaluator.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 15 separate duplicated blocks between them, totalling at least 555 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (43 lines × 2) chapter5/coding-agent/agent.py:259 — chapter5/coding-agent/agent.py:259-301 | chapter5/coding-agent/agent_new.py:218-260 — before extracting anything, compare `chapter5/coding-agent/agent.py` and `chapter5/coding-agent/agent_new.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 198 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (42 lines × 2) · ×2
  • Duplicated block (42 lines × 2) chapter3/agentic-rag-for-user-memory/evaluator.py:522 — chapter3/agentic-rag-for-user-memory/evaluator.py:522-563 | chapter3/contextual-retrieval-for-user-memory/evaluator.py:522-563 — `chapter3/agentic-rag-for-user-memory/evaluator.py` and `chapter3/contextual-retrieval-for-user-memory/evaluator.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 15 separate duplicated blocks between them, totalling at least 555 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (42 lines × 2) chapter3/agentic-rag-for-user-memory/indexer.py:250 — chapter3/agentic-rag-for-user-memory/indexer.py:250-291 | chapter3/contextual-retrieval-for-user-memory/indexer.py:158-199 — `chapter3/agentic-rag-for-user-memory/indexer.py` and `chapter3/contextual-retrieval-for-user-memory/indexer.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 10 separate duplicated blocks between them, totalling at least 347 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (40 lines × 2) · ×2
  • Duplicated block (40 lines × 2) chapter3/agentic-rag-for-user-memory/indexer.py:304 — chapter3/agentic-rag-for-user-memory/indexer.py:304-343 | chapter3/contextual-retrieval-for-user-memory/indexer.py:203-242 — `chapter3/agentic-rag-for-user-memory/indexer.py` and `chapter3/contextual-retrieval-for-user-memory/indexer.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 10 separate duplicated blocks between them, totalling at least 347 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (40 lines × 2) chapter3/agentic-rag/main.py:119 — chapter3/agentic-rag/main.py:119-158 | chapter3/contextual-retrieval/main.py:117-156 — `chapter3/agentic-rag/main.py` and `chapter3/contextual-retrieval/main.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 9 separate duplicated blocks between them, totalling at least 254 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (39 lines × 2) · ×2
  • Duplicated block (39 lines × 2) chapter3/agentic-rag-for-user-memory/indexer.py:176 — chapter3/agentic-rag-for-user-memory/indexer.py:176-214 | chapter3/contextual-retrieval-for-user-memory/indexer.py:84-122 — `chapter3/agentic-rag-for-user-memory/indexer.py` and `chapter3/contextual-retrieval-for-user-memory/indexer.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 10 separate duplicated blocks between them, totalling at least 347 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (39 lines × 2) chapter3/agentic-rag/main.py:18 — chapter3/agentic-rag/main.py:18-56 | chapter3/contextual-retrieval/main.py:18-56 — `chapter3/agentic-rag/main.py` and `chapter3/contextual-retrieval/main.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 9 separate duplicated blocks between them, totalling at least 254 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (34 lines × 2) · ×2
  • Duplicated block (34 lines × 2) chapter3/user-memory/locomo_benchmark.py:285 — chapter3/user-memory/locomo_benchmark.py:285-318 | chapter3/user-memory/locomo_benchmark.py:378-411 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (34 lines × 2) chapter5/coding-agent/agent.py:123 — chapter5/coding-agent/agent.py:123-156 | chapter5/coding-agent/agent_new.py:109-142 — before extracting anything, compare `chapter5/coding-agent/agent.py` and `chapter5/coding-agent/agent_new.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 198 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (28–29 lines × 2) · ×2
  • Duplicated block (28–29 lines × 2) chapter2/local_llm_serving/agent.py:225 — chapter2/local_llm_serving/agent.py:225-253 | chapter2/local_llm_serving/agent.py:356-383 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter2/local_llm_serving/agent.py:225` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (28–29 lines × 2) chapter4/collaboration-tools/src/subagent_tools.py:91 — chapter4/collaboration-tools/src/subagent_tools.py:91-118 | chapter4/execution-tools/llm_helper.py:63-91 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `request` to `Dict[str, Any]` in one and `dict` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (28 lines × 2) · ×2
  • Duplicated block (28 lines × 2) chapter3/agentic-rag/evaluation/evaluate.py:341 — chapter3/agentic-rag/evaluation/evaluate.py:341-368 | chapter3/contextual-retrieval/evaluation/evaluate.py:333-360 — before extracting anything, compare `chapter3/agentic-rag/evaluation/evaluate.py` and `chapter3/contextual-retrieval/evaluation/evaluate.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 369 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (28 lines × 2) REDACTED:729 — REDACTED:729-756 | REDACTED:891-918 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (23–26 lines × 2) · ×2
  • Duplicated block (23–26 lines × 2) REDACTED:777 — REDACTED:777-802 | REDACTED:1014-1036 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (23–26 lines × 2) chapter4/perception-tools/src/filesystem_tools.py:469 — chapter4/perception-tools/src/filesystem_tools.py:469-494 | chapter4/perception-tools/src/search_tools.py:398-420 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `chapter4/perception-tools/src/search_tools.py:395` calls `sort`, `max` and `chapter4/perception-tools/src/filesystem_tools.py:467` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (25 lines × 6) · ×2
  • Duplicated block (25 lines × 6) book-ar/svg_lib.py:266 — book-ar/svg_lib.py:266-290 | book-en/svg_lib.py:240-264 | book-es/svg_lib.py:240-264 | book-id/svg_lib.py:240-264 | book-ru/svg_lib.py:240-264 | book-tr/svg_lib.py:240-264 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (25 lines × 6) book-ar/svg_lib.py:668 — book-ar/svg_lib.py:668-692 | book-en/svg_lib.py:642-666 | book-es/svg_lib.py:642-666 | book-id/svg_lib.py:642-666 | book-ru/svg_lib.py:642-666 | book-tr/svg_lib.py:642-666 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (25 lines × 2) · ×2
  • Duplicated block (25 lines × 2) REDACTED:63 — REDACTED:63-87 | REDACTED:63-87 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 271 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (25 lines × 2) chapter4/multimodal-agent/agent.py:625 — chapter4/multimodal-agent/agent.py:625-649 | chapter4/multimodal-agent/agent.py:744-768 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (22–24 lines × 2) · ×2
  • Duplicated block (22–24 lines × 2) chapter4/multimodal-agent/agent.py:535 — chapter4/multimodal-agent/agent.py:535-556 | chapter4/multimodal-agent/agent.py:569-592 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter4/multimodal-agent/agent.py:535` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (22–24 lines × 2) REDACTED:114 — REDACTED:114-137 | REDACTED:123-144 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:114` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `REDACTED:111` calls `_check_salary_range` and `REDACTED:120` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (19 lines × 6) · ×2
  • Duplicated block (19 lines × 6) book-ar/svg_lib.py:614 — book-ar/svg_lib.py:614-632 | book-en/svg_lib.py:588-606 | book-es/svg_lib.py:588-606 | book-id/svg_lib.py:588-606 | book-ru/svg_lib.py:588-606 | book-tr/svg_lib.py:588-606 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `book-ar/svg_lib.py:614` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (19 lines × 6) book-en/strip_titles.py:73 — book-en/strip_titles.py:73-91 | book-id/strip_titles.py:72-90 | book-ta/strip_titles.py:73-91 | book-tr/strip_titles.py:72-90 | book-zhtw/strip_titles.py:72-90 | book/strip_titles.py:72-90 — `book-en/strip_titles.py` and `book-id/strip_titles.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 68 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (19 lines × 3) · ×2
  • Duplicated block (19 lines × 3) chapter4/perception-tools/src/arxiv_enhanced.py:151 — chapter4/perception-tools/src/arxiv_enhanced.py:151-169 | chapter4/perception-tools/src/wiki_enhanced.py:107-125 | chapter4/perception-tools/src/wiki_enhanced.py:156-174 — before extracting anything, compare `chapter4/perception-tools/src/arxiv_enhanced.py` and `chapter4/perception-tools/src/wiki_enhanced.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 90 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `chapter4/perception-tools/src/arxiv_enhanced.py:151` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (19 lines × 3) chapter5/log-diagnosis/http_service.py:54 — chapter5/log-diagnosis/http_service.py:54-72 | chapter5/log-diagnosis/validation/runs/exp5-8-live-http-mcp-20260730-053056/http_service.py:54-72 | chapter5/log-diagnosis/validation/runs/exp5-8-live-http-mcp-20260730-053403/http_service.py:54-72 — before extracting anything, compare `chapter5/log-diagnosis/http_service.py` and `chapter5/log-diagnosis/validation/runs/exp5-8-live-http-mcp-20260730-053056/http_service.py` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 50 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (18 lines × 6) · ×2
  • Duplicated block (18 lines × 6) book-ar/svg_lib.py:142 — book-ar/svg_lib.py:142-159 | book-en/svg_lib.py:126-143 | book-es/svg_lib.py:126-143 | book-id/svg_lib.py:126-143 | book-ru/svg_lib.py:126-143 | book-tr/svg_lib.py:126-143 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (18 lines × 6) book-ar/svg_lib.py:163 — book-ar/svg_lib.py:163-180 | book-en/svg_lib.py:147-164 | book-es/svg_lib.py:147-164 | book-id/svg_lib.py:147-164 | book-ru/svg_lib.py:147-164 | book-tr/svg_lib.py:147-164 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (16 lines × 4) · ×2
  • Duplicated block (16 lines × 4) chapter4/perception-tools/src/document_processing_tools.py:84 — chapter4/perception-tools/src/document_processing_tools.py:84-99 | chapter4/perception-tools/src/filesystem_tools.py:566-581 | chapter4/perception-tools/src/media_processing_tools.py:345-360 | chapter4/perception-tools/src/multimodal_tools.py:230-245 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `chapter4/perception-tools/src/document_processing_tools.py:84` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (16 lines × 4) chapter4/perception-tools/src/pubchem_tools.py:347 — chapter4/perception-tools/src/pubchem_tools.py:347-362 | chapter4/perception-tools/src/pubchem_tools.py:423-438 | chapter4/perception-tools/src/pubchem_tools.py:516-531 | chapter4/perception-tools/src/yahoo_finance_tools.py:196-211 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `chapter4/perception-tools/src/pubchem_tools.py:347` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (15 lines × 4) · ×2
  • Duplicated block (15 lines × 4) chapter3/agentic-rag/tools.py:381 — chapter3/agentic-rag/tools.py:381-395 | chapter3/agentic-rag/tools.py:418-433 | chapter3/contextual-retrieval/tools.py:386-400 | chapter3/contextual-retrieval/tools.py:423-438 — `chapter3/agentic-rag/tools.py` and `chapter3/contextual-retrieval/tools.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 14 separate duplicated blocks between them, totalling at least 341 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `chapter3/agentic-rag/tools.py:381` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (15 lines × 4) REDACTED:84 — REDACTED:84-98 | REDACTED:82-96 | REDACTED:82-96 | REDACTED:82-96 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 114 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (12–13 lines × 3) · ×2
  • Duplicated block (12–13 lines × 3) chapter10/multi-role-transfer/run_official_experiment.py:105 — chapter10/multi-role-transfer/run_official_experiment.py:105-116 | chapter10/parallel-web-research/run_official_experiment.py:195-207 | chapter6/streaming-speech/run_official_experiment.py:78-89 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `chapter6/streaming-speech/run_official_experiment.py:92` calls `bool_gate` and `chapter10/multi-role-transfer/run_official_experiment.py:119` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12–13 lines × 3) chapter5/permission-embedded-data-objects/pedo/core/store.py:141 — chapter5/permission-embedded-data-objects/pedo/core/store.py:141-153 | chapter5/permission-embedded-data-objects/pedo/core/store.py:168-180 | chapter5/permission-embedded-data-objects/pedo/core/store.py:702-713 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Note first that the copies are not typed on the same thing: the declarations holding them bind `type_name` to `Optional[str] = None` in one and `str` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `chapter5/permission-embedded-data-objects/pedo/core/store.py:155` calls `_check_permission` and `chapter5/permission-embedded-data-objects/pedo/core/store.py:714` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (13 lines × 3) · ×2
  • Duplicated block (13 lines × 3) chapter3/agentic-rag-for-user-memory/agent.py:236 — chapter3/agentic-rag-for-user-memory/agent.py:236-248 | chapter3/contextual-retrieval-for-user-memory/agent.py:232-244 | chapter3/contextual-retrieval/agent.py:200-212 — `chapter3/agentic-rag-for-user-memory/agent.py` and `chapter3/contextual-retrieval-for-user-memory/agent.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 278 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Note first that the copies are not typed on the same thing: the declarations holding them bind `stream` to `bool = False` in one and `bool = None` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (13 lines × 3) chapter5/adaptive-log-parser/campaign.py:76 — chapter5/adaptive-log-parser/campaign.py:76-88 | REDACTED:85-97 | chapter5/erp-agent/campaign_postgres.py:89-101 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (8–13 lines × 3) · ×2
  • Duplicated block (8–13 lines × 3) REDACTED:215 — REDACTED:215-226 | REDACTED:402-414 | REDACTED:264-271 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:215` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (8–13 lines × 3) chapter5/permission-embedded-data-objects/pedo/eval/benchmark_reactions.py:163 — chapter5/permission-embedded-data-objects/pedo/eval/benchmark_reactions.py:163-176 | chapter5/permission-embedded-data-objects/pedo/eval/benchmark_reactions.py:177-189 | chapter5/permission-embedded-data-objects/pedo/eval/benchmark_reactions.py:190-197 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (12–13 lines × 2) · ×2
  • Duplicated block (12–13 lines × 2) chapter10/multi-role-transfer/tools.py:121 — chapter10/multi-role-transfer/tools.py:121-133 | chapter10/staged-system-prompt/tools.py:188-199 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (12–13 lines × 2) chapter3/user-memory/background_memory_processor.py:248 — chapter3/user-memory/background_memory_processor.py:248-260 | chapter3/user-memory/background_memory_processor.py:320-331 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (11–13 lines × 2) · ×2
  • Duplicated block (11–13 lines × 2) chapter3/agentic-rag/tools.py:132 — chapter3/agentic-rag/tools.py:132-142 | chapter3/contextual-retrieval/tools.py:130-142 — `chapter3/agentic-rag/tools.py` and `chapter3/contextual-retrieval/tools.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 14 separate duplicated blocks between them, totalling at least 341 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (11–13 lines × 2) chapter3/structured-index/document_processor.py:68 — chapter3/structured-index/document_processor.py:68-80 | chapter3/structured-index/document_processor.py:99-109 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (12 lines × 4) · ×2
  • Duplicated block (12 lines × 4) chapter6/astra-async-steering/experiment.py:117 — chapter6/astra-async-steering/experiment.py:117-128 | chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:117-128 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:117-128 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:117-128 — before extracting anything, compare `chapter6/astra-async-steering/experiment.py` and `chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 251 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `chapter6/astra-async-steering/experiment.py:117` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 4) chapter6/astra-async-steering/experiment.py:380 — chapter6/astra-async-steering/experiment.py:380-391 | chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:380-391 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:359-370 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:359-370 — before extracting anything, compare `chapter6/astra-async-steering/experiment.py` and `chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 251 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `chapter6/astra-async-steering/experiment.py:380` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (10–11 lines × 2) · ×2
  • Duplicated block (10–11 lines × 2) REDACTED:361 — REDACTED:361-370 | REDACTED:243-253 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:243` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10–11 lines × 2) REDACTED:271 — REDACTED:271-281 | REDACTED:517-526 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:271` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (10 lines × 6) · ×2
  • Duplicated block (10 lines × 6) book-ar/svg_lib.py:394 — book-ar/svg_lib.py:394-403 | book-en/svg_lib.py:368-377 | book-es/svg_lib.py:368-377 | book-id/svg_lib.py:368-377 | book-ru/svg_lib.py:368-377 | book-tr/svg_lib.py:368-377 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (10 lines × 6) book-ar/svg_lib.py:636 — book-ar/svg_lib.py:636-645 | book-en/svg_lib.py:610-619 | book-es/svg_lib.py:610-619 | book-id/svg_lib.py:610-619 | book-ru/svg_lib.py:610-619 | book-tr/svg_lib.py:610-619 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (9–10 lines × 4) · ×2
  • Duplicated block (9–10 lines × 4) chapter3/agentic-rag/evaluation/evaluate.py:326 — chapter3/agentic-rag/evaluation/evaluate.py:326-334 | chapter3/agentic-rag/evaluation/evaluate.py:353-362 | chapter3/contextual-retrieval/evaluation/evaluate.py:318-326 | chapter3/contextual-retrieval/evaluation/evaluate.py:345-354 — before extracting anything, compare `chapter3/agentic-rag/evaluation/evaluate.py` and `chapter3/contextual-retrieval/evaluation/evaluate.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 369 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (9–10 lines × 4) chapter4/multimodal-agent/agent.py:225 — chapter4/multimodal-agent/agent.py:225-233 | chapter4/multimodal-agent/agent.py:279-287 | chapter4/multimodal-agent/agent.py:653-661 | chapter4/multimodal-agent/agent.py:956-965 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (9 lines × 3) · ×2
  • Duplicated block (9 lines × 3) chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:156 — chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:156-164 | chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:292-300 | chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:414-422 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (9 lines × 3) chapter4/active-tool-selection/config.py:23 — chapter4/active-tool-selection/config.py:23-35 | chapter4/perception-tools/src/media_processing_tools.py:27-35 | chapter6/async-agent/demo.py:52-66 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (7–9 lines × 2) · ×2
  • Duplicated block (7–9 lines × 2) chapter4/collaboration-tools/run_experiment_4_5.py:269 — chapter4/collaboration-tools/run_experiment_4_5.py:269-275 | chapter4/execution-tools/run_experiment_4_4.py:99-107 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `chapter4/execution-tools/run_experiment_4_4.py:99` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7–9 lines × 2) chapter8/MultilingualReasoning/gpt_oss_20b_sft.py:194 — chapter8/MultilingualReasoning/gpt_oss_20b_sft.py:194-202 | chapter8/prompt-distillation/train_sft_trl.py:134-140 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (8 lines × 5) · ×2
  • Duplicated block (8 lines × 5) REDACTED:151 — REDACTED:151-158 | REDACTED:173-180 | REDACTED:189-196 | REDACTED:206-213 | REDACTED:408-415 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `REDACTED:181` calls `execute` and `REDACTED:214` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 5) chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:265 — chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:265-272 | chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:291-298 | chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:413-420 | chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:509-516 | chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:537-544 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D4 · Code Duplication · Duplicated block (6–7 lines × 3) · ×2
  • Duplicated block (6–7 lines × 3) chapter3/agentic-rag/evaluation/evaluate.py:376 — chapter3/agentic-rag/evaluation/evaluate.py:376-381 | chapter3/contextual-retrieval/evaluation/evaluate.py:368-373 | chapter3/mem0/main.py:349-355 — before extracting anything, compare `chapter3/agentic-rag/evaluation/evaluate.py` and `chapter3/contextual-retrieval/evaluation/evaluate.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 369 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (6–7 lines × 3) chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:63 — chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:63-69 | chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:241-246 | chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:358-363 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D4 · Code Duplication · Duplicated block (6–7 lines × 2) · ×2
  • Duplicated block (6–7 lines × 2) chapter5/permission-embedded-data-objects/pedo/eval/benchmark_overhead.py:77 — chapter5/permission-embedded-data-objects/pedo/eval/benchmark_overhead.py:77-83 | chapter5/permission-embedded-data-objects/pedo/eval/benchmark_overhead.py:127-132 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter5/permission-embedded-data-objects/pedo/eval/benchmark_overhead.py:77` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `chapter5/permission-embedded-data-objects/pedo/eval/benchmark_overhead.py:132` calls `cursor`, `execute` and `chapter5/permission-embedded-data-objects/pedo/eval/benchmark_overhead.py:83` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6–7 lines × 2) REDACTED:478 — REDACTED:478-483 | REDACTED:314-320 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
D4 · Code Duplication · Duplicated block (6 lines × 4) · ×2
  • Duplicated block (6 lines × 4) chapter1/learning-from-experience/experiment.py:513 — chapter1/learning-from-experience/experiment.py:513-526 | chapter3/agentic-rag-for-user-memory/offline_demo.py:270-275 | chapter5/code-for-logic/build_puzzles.py:178-183 | chapter5/code-for-logic/demo.py:507-513 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `chapter1/learning-from-experience/experiment.py:513` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (6 lines × 4) chapter7/model-benchmark/campaign.py:520 — chapter7/model-benchmark/campaign.py:520-532 | chapter7/model-benchmark/campaign.py:554-566 | chapter7/model-benchmark/campaign.py:674-679 | chapter7/model-benchmark/campaign.py:765-770 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter7/model-benchmark/campaign.py:520` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (5 lines × 6) · ×2
  • Duplicated block (5 lines × 6) book-ar/svg_lib.py:466 — book-ar/svg_lib.py:466-470 | book-en/svg_lib.py:440-444 | book-es/svg_lib.py:440-444 | book-id/svg_lib.py:440-444 | book-ru/svg_lib.py:440-444 | book-tr/svg_lib.py:440-444 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (5 lines × 6) book-ar/svg_lib.py:526 — book-ar/svg_lib.py:526-530 | book-en/svg_lib.py:500-504 | book-es/svg_lib.py:500-504 | book-id/svg_lib.py:500-504 | book-ru/svg_lib.py:500-504 | book-tr/svg_lib.py:500-504 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
R10 · Code Duplication · Forked directory tree (5 identical files, ~2058 lines × 2 trees) · ×2
  • Forked directory tree (5 identical files, ~2058 lines × 2 trees) REDACTED:1 — chapter5/conversational-ui/validation/runs/20260729T212616Z-5_11-hmr/app/ and chapter5/conversational-ui/validation/runs/20260729T212933Z-5_11-hmr/app/ are near-verbatim copies of each other: 5 files are byte-identical under the same relative paths (~2058 lines; the trees hold 8 and 8 files). That is one structural fact, not 5 local ones: every edit made to one tree and not the other drifts silently, which is the failure whole-tree forks guarantee. Pick one tree as the single source and produce the other from it (generated, copied at build or release time, or re-exported) — or, if the copy is a stale snapshot nothing produces any more, delete it. Check first whether the copy is a deliberately published deliverable (a template consumers copy verbatim, a released sample frozen at a version); where it is, keep it produced from the source tree rather than edited in place.
  • Forked directory tree (5 identical files, ~2058 lines × 2 trees) REDACTED:1 — chapter5/conversational-ui/validation/runs/20260729T212727Z-5_11-hmr/app/ and chapter5/conversational-ui/validation/runs/20260729T212933Z-5_11-hmr/app/ are near-verbatim copies of each other: 5 files are byte-identical under the same relative paths (~2058 lines; the trees hold 8 and 8 files). That is one structural fact, not 5 local ones: every edit made to one tree and not the other drifts silently, which is the failure whole-tree forks guarantee. Pick one tree as the single source and produce the other from it (generated, copied at build or release time, or re-exported) — or, if the copy is a stale snapshot nothing produces any more, delete it. Check first whether the copy is a deliberately published deliverable (a template consumers copy verbatim, a released sample frozen at a version); where it is, keep it produced from the source tree rather than edited in place.
R10 · Code Duplication · Duplicated block (20 lines × 2 locations) · ×2
  • Duplicated block (20 lines × 2 locations) chapter6/live-audio/backend/utils/providers/asrProviders.js:237 — chapter6/live-audio/backend/utils/providers/asrProviders.js:237 · chapter6/live-audio/backend/utils/providers/llmProviders.js:204 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
  • Duplicated block (20 lines × 2 locations) web-astro/scripts/collaboration-context-figures.mjs:6 — web-astro/scripts/collaboration-context-figures.mjs:6 · web-astro/scripts/collaboration-society-figures.mjs:7 — the 2 copies sit in sibling files in one directory, so check first whether one of them (or an existing module there) already owns this behaviour and the others should call it; otherwise extract it into one module in that directory and have each site call it.
R10 · Code Duplication · Duplicated block (17 lines × 2 locations) · ×2
  • Duplicated block (17 lines × 2 locations) REDACTED:387 — REDACTED:387 · REDACTED:537 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (17 lines × 2 locations) web-astro/scripts/evolution-flow-figures.mjs:28 — web-astro/scripts/evolution-flow-figures.mjs:28 · web-astro/scripts/training-workflows-figures.mjs:15 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
R10 · Code Duplication · Duplicated block (15 lines × 2 locations) · ×2
  • Duplicated block (15 lines × 2 locations) REDACTED:122 — REDACTED:122 · REDACTED:142 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
  • Duplicated block (15 lines × 2 locations) web-astro/scripts/computer-use-layout.mjs:14 — web-astro/scripts/computer-use-layout.mjs:14 · web-astro/scripts/evaluation-layout-kit.mjs:37 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
AC1 · Text alternatives · <canvas> without a text alternative · ×1
  • <canvas> without a text alternative chapter2/attention_visualization/frontend/components/AttentionModal.tsx:452 — A <canvas> with no aria-label/title and no inner fallback content can't be described by assistive tech. Add a name or fallback content.
AC3 · Page structure · Heading level jumps from h1 to h3 · ×1
  • Heading level jumps from h1 to h3 chapter2/attention_visualization/frontend/pages/index.tsx:262 — Skipping heading levels breaks the document outline assistive tech relies on. Don't jump levels — increase by at most one.
AC4 · Keyboard semantics · Anchor without href · ×1
  • Anchor without href web-astro/src/components/Reader.astro:326 — An <a> with no href, role or tabindex isn't focusable or keyboard-activatable. Give it a real href, or use a <button> for an action.
AC6 · Visual & motion safety · Low contrast Tailwind colour pair (3.3 · ×1
  • Low contrast Tailwind colour pair (3.3:1) chapter6/live-audio/frontend/pages/index.tsx:650 — This element's Tailwind text/background colour utilities fall below the 4.5:1 WCAG AA minimum for normal text. Pick a darker or lighter shade.
AC6 · Visual & motion safety · Low contrast colour pair in CSS (2.8 · ×1
  • Low contrast colour pair in CSS (2.8:1) chapter7/elo-leaderboard/validation/runs/exp7-7-arena-20260731-v1/leaderboard_animation.html:75 — `button` sets color: white on background-color: #4CAF50 — 2.8:1, below the 4.5:1 WCAG AA minimum for normal text. Darken or lighten one of them.
AC6 · Visual & motion safety · Focus outline removed in CSS without a · ×1
  • Focus outline removed in CSS without a :focus replacement chapter2/attention_visualization/frontend/styles/globals.css:25 — `.input` sets the outline to none/0 and no visible :focus / :focus-visible style for that element replaces it in this stylesheet, so a keyboard user cannot see where focus is. Draw a focus ring (outline, box-shadow or border) under :focus-visible.
AC7 · A11y enforcement · Accessibility enforcement below the top rung · ×1
  • Accessibility enforcement below the top rung web-astro/package.json:27 — No accessibility enforcement found — no a11y linter (eslint-plugin-jsx-a11y) and no axe/pa11y/Lighthouse in tests or CI. Start with the linter to catch issues at author time. What was searched, so you can tell an absence from a miss: the 60 markup file(s) this pass actually assessed, the linter configuration checked in beside them, and this repository's test and CI files — matched by name against the accessibility checkers this dimension carries. An audit run outside the repository, a hosted scanner, or a check whose name is not one of those, is not seen here.
D1 · Cyclomatic Complexity · index.Home (cyclomatic 97) · ×1
  • index.Home (cyclomatic 97) chapter6/live-audio/frontend/pages/index.tsx:65 — index.Home has cyclomatic complexity 97 (threshold 15). Most of this is not in the body itself: 7 of the 97 points are its own statements and the rest belongs to 16 function items inside it that branch (a function literal at line 139, startRecording, setupWebSocket, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
D1 · Cyclomatic Complexity · creator.run_experiment (cyclomatic 91) · ×1
  • creator.run_experiment (cyclomatic 91) chapter5/agent-creator/creator.py:1530 — creator.run_experiment has cyclomatic complexity 91 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · validate_evidence.validate (cyclomatic 85) · ×1
  • validate_evidence.validate (cyclomatic 85) chapter8/MiniMind-pretrain/validation/validate_evidence.py:114 — validate_evidence.validate has cyclomatic complexity 85 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · demo.run_game (cyclomatic 84) · ×1
  • demo.run_game (cyclomatic 84) chapter10/voice-werewolf/demo.py:225 — demo.run_game has cyclomatic complexity 84 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · analysis.completion_audit (cyclomatic 83) · ×1
  • analysis.completion_audit (cyclomatic 83) chapter7/model-benchmark/analysis.py:331 — analysis.completion_audit has cyclomatic complexity 83 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_controlled_experiment.main (cyclomatic 71) · ×1
  • run_controlled_experiment.main (cyclomatic 71) chapter7/android-world/run_controlled_experiment.py:1392 — run_controlled_experiment.main has cyclomatic complexity 71 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · book-markdown.bookMarkdown.<returned closure> · ×1
  • book-markdown.bookMarkdown.<returned closure>::walk (cyclomatic 67) REDACTED:15 — book-markdown.bookMarkdown.<returned closure>::walk has cyclomatic complexity 67 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · bookMarkdown · ×1
  • bookMarkdown::(anonymous)::walk (cyclomatic 65) REDACTED:15 — bookMarkdown::(anonymous)::walk has cyclomatic complexity 65 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · verify_acceptance.check_arm (cyclomatic 62) · ×1
  • verify_acceptance.check_arm (cyclomatic 62) chapter6/phone-agent/verify_acceptance.py:145 — verify_acceptance.check_arm has cyclomatic complexity 62 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · demo.main (cyclomatic 58) · ×1
  • demo.main (cyclomatic 58) chapter10/autonomous-phone-registration/demo.py:126 — demo.main has cyclomatic complexity 58 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · UserMemoryAgent.execute_task (cyclomatic 58) · ×1
  • UserMemoryAgent.execute_task (cyclomatic 58) chapter3/user-memory/agent.py:614 — UserMemoryAgent.execute_task has cyclomatic complexity 58 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · AttentionModal.AttentionModal (cyclomatic 58) · ×1
  • AttentionModal.AttentionModal (cyclomatic 58) chapter2/attention_visualization/frontend/components/AttentionModal.tsx:11 — AttentionModal.AttentionModal has cyclomatic complexity 58 (threshold 15). Most of this is not in the body itself: 5 of the 58 points are its own statements and the rest belongs to 9 function items inside it that branch (a function literal at line 99, handleMouseMove, a function literal at line 42, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
D1 · Cyclomatic Complexity · validate_simulator_run.validate (cyclomatic 54) · ×1
  • validate_simulator_run.validate (cyclomatic 54) chapter10/voice-werewolf/validate_simulator_run.py:15 — validate_simulator_run.validate has cyclomatic complexity 54 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · main.run_evaluation_mode (cyclomatic 54) · ×1
  • main.run_evaluation_mode (cyclomatic 54) chapter3/user-memory/main.py:373 — main.run_evaluation_mode has cyclomatic complexity 54 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · experiment.analyze (cyclomatic 54) · ×1
  • experiment.analyze (cyclomatic 54) chapter7/openvla-robotwin2-eval/experiment.py:527 — experiment.analyze has cyclomatic complexity 54 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · review.main (cyclomatic 54) · ×1
  • review.main (cyclomatic 54) slides/review.mjs:96 — review.main has cyclomatic complexity 54 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · campaign.main (cyclomatic 53) · ×1
  • campaign.main (cyclomatic 53) chapter3/structured-knowledge-extraction/campaign.py:524 — campaign.main has cyclomatic complexity 53 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · experiment_validation.validateExperimentEvidence (cyclomatic 50) · ×1
  • experiment_validation.validateExperimentEvidence (cyclomatic 50) chapter6/live-audio/backend/experiment_validation.js:19 — experiment_validation.validateExperimentEvidence has cyclomatic complexity 50 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · validate_evidence.validate (cyclomatic 49) · ×1
  • validate_evidence.validate (cyclomatic 49) chapter8/continued-pretraining/validation/validate_evidence.py:73 — validate_evidence.validate has cyclomatic complexity 49 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_experiment_4_2.substantive_observation (cyclomatic 47) · ×1
  • run_experiment_4_2.substantive_observation (cyclomatic 47) chapter4/perception-tools/run_experiment_4_2.py:326 — run_experiment_4_2.substantive_observation has cyclomatic complexity 47 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · DuplexInterruptionManager.calculate_energy (cyclomatic 45) · ×1
  • DuplexInterruptionManager.calculate_energy (cyclomatic 45) chapter6/streaming-speech/interruption_manager.py:101 — DuplexInterruptionManager.calculate_energy has cyclomatic complexity 45 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · validate_vlm_evidence.validate_receipts (cyclomatic 45) · ×1
  • validate_vlm_evidence.validate_receipts (cyclomatic 45) chapter8/MiniMind-pretrain/validation/validate_vlm_evidence.py:99 — validate_vlm_evidence.validate_receipts has cyclomatic complexity 45 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · AgentCreator._generate_scratch_files (cyclomatic 44) · ×1
  • AgentCreator._generate_scratch_files (cyclomatic 44) chapter5/agent-creator/creator.py:815 — AgentCreator._generate_scratch_files has cyclomatic complexity 44 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · benchmark_safety_final.call_generated_func (cyclomatic 44) · ×1
  • benchmark_safety_final.call_generated_func (cyclomatic 44) REDACTED:264 — benchmark_safety_final.call_generated_func has cyclomatic complexity 44 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · main.interactive_mode (cyclomatic 43) · ×1
  • main.interactive_mode (cyclomatic 43) chapter1/context/main.py:907 — main.interactive_mode has cyclomatic complexity 43 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · demo.main (cyclomatic 43) · ×1
  • demo.main (cyclomatic 43) chapter5/code-for-math/demo.py:543 — demo.main has cyclomatic complexity 43 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · index.Home (cyclomatic 43) · ×1
  • index.Home (cyclomatic 43) chapter2/attention_visualization/frontend/pages/index.tsx:56 — index.Home has cyclomatic complexity 43 (threshold 15). Of this number, 27 points are the body's own statements and 16 belong to 3 function items inside it that branch. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · validate_official_run.validate (cyclomatic 40) · ×1
  • validate_official_run.validate (cyclomatic 40) chapter2/agent-skills-ppt/validate_official_run.py:130 — validate_official_run.validate has cyclomatic complexity 40 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · merge_candidate_shards.main (cyclomatic 40) · ×1
  • merge_candidate_shards.main (cyclomatic 40) chapter7/android-world/merge_candidate_shards.py:56 — merge_candidate_shards.main has cyclomatic complexity 40 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_experiment_2_8.run_one (cyclomatic 39) · ×1
  • run_experiment_2_8.run_one (cyclomatic 39) chapter2/system-hint/run_experiment_2_8.py:468 — run_experiment_2_8.run_one has cyclomatic complexity 39 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · validator._structural_check (cyclomatic 38) · ×1
  • validator._structural_check (cyclomatic 38) chapter5/agent-creator/validator.py:81 — validator._structural_check has cyclomatic complexity 38 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · site_i18n.build_catalog (cyclomatic 37) · ×1
  • site_i18n.build_catalog (cyclomatic 37) scripts/site_i18n.py:168 — site_i18n.build_catalog has cyclomatic complexity 37 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · demo.main (cyclomatic 36) · ×1
  • demo.main (cyclomatic 36) chapter5/paper-to-ppt/demo.py:410 — demo.main has cyclomatic complexity 36 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · EventTriggeredAgent.handle_event (cyclomatic 36) · ×1
  • EventTriggeredAgent.handle_event (cyclomatic 36) REDACTED:1059 — EventTriggeredAgent.handle_event has cyclomatic complexity 36 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ConnectionHandler.processTTSQueue (cyclomatic 36) · ×1
  • ConnectionHandler.processTTSQueue (cyclomatic 36) chapter6/live-audio/backend/server.js:715 — ConnectionHandler.processTTSQueue has cyclomatic complexity 36 (threshold 15). Most of this is not in the body itself: 11 of the 36 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 776, 861). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
D1 · Cyclomatic Complexity · validate_campaign.main (cyclomatic 35) · ×1
  • validate_campaign.main (cyclomatic 35) chapter10/generative-agents/validate_campaign.py:93 — validate_campaign.main has cyclomatic complexity 35 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · KVCacheAgent.execute_task (cyclomatic 35) · ×1
  • KVCacheAgent.execute_task (cyclomatic 35) chapter2/kv-cache/agent.py:622 — KVCacheAgent.execute_task has cyclomatic complexity 35 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · VLLMToolAgent.chat_stream (cyclomatic 35) · ×1
  • VLLMToolAgent.chat_stream (cyclomatic 35) chapter2/local_llm_serving/agent.py:340 — VLLMToolAgent.chat_stream has cyclomatic complexity 35 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · BackgroundMemoryProcessor.apply_memory_updates (cyclomatic 35) · ×1
  • BackgroundMemoryProcessor.apply_memory_updates (cyclomatic 35) chapter3/user-memory/background_memory_processor.py:163 — BackgroundMemoryProcessor.apply_memory_updates has cyclomatic complexity 35 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_experiment_4_5.run (cyclomatic 35) · ×1
  • run_experiment_4_5.run (cyclomatic 35) chapter4/collaboration-tools/run_experiment_4_5.py:218 — run_experiment_4_5.run has cyclomatic complexity 35 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · SystemHintAgent.execute_task (cyclomatic 34) · ×1
  • SystemHintAgent.execute_task (cyclomatic 34) REDACTED:825 — SystemHintAgent.execute_task has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_exact_experiment.derive_acceptance (cyclomatic 34) · ×1
  • run_exact_experiment.derive_acceptance (cyclomatic 34) chapter4/active-tool-discovery/run_exact_experiment.py:897 — run_exact_experiment.derive_acceptance has cyclomatic complexity 34 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · streaming._absorb (cyclomatic 34) · ×1
  • streaming._absorb (cyclomatic 34) chapter5/provider-failover/streaming.py:116 — streaming._absorb has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · evaluate_audio_quality.judge_once (cyclomatic 34) · ×1
  • evaluate_audio_quality.judge_once (cyclomatic 34) REDACTED:200 — evaluate_audio_quality.judge_once has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · verify_acceptance.main (cyclomatic 34) · ×1
  • verify_acceptance.main (cyclomatic 34) chapter6/phone-agent/verify_acceptance.py:279 — verify_acceptance.main has cyclomatic complexity 34 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · validate_vlm_evidence.validate_run (cyclomatic 34) · ×1
  • validate_vlm_evidence.validate_run (cyclomatic 34) chapter8/MiniMind-pretrain/validation/validate_vlm_evidence.py:225 — validate_vlm_evidence.validate_run has cyclomatic complexity 34 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · experiment.completion_assessment (cyclomatic 32) · ×1
  • experiment.completion_assessment (cyclomatic 32) chapter7/user-memory-system-evaluation/experiment.py:1587 — experiment.completion_assessment has cyclomatic complexity 32 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · context-flow-figures.layoutContextFlow (cyclomatic 32) · ×1
  • context-flow-figures.layoutContextFlow (cyclomatic 32) REDACTED:11 — context-flow-figures.layoutContextFlow has cyclomatic complexity 32 (threshold 15). Most of this is not in the body itself: 9 of the 32 points are its own statements and the rest belongs to 11 function items inside it that branch (a function literal at line 151, a function literal at line 31, a function literal at line 47, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
D1 · Cyclomatic Complexity · annotations.parseBackup (cyclomatic 32) · ×1
  • annotations.parseBackup (cyclomatic 32) web-astro/src/lib/annotations.ts:40 — annotations.parseBackup has cyclomatic complexity 32 (threshold 15). Most of this is not in the body itself: 6 of the 32 points are its own statements and the rest belongs to one function literal inside it that branches (line 57). The decisions are inside the literal, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literal's work into a named function or method at the enclosing scope and have the literal call it, then reduce whichever part then reads as the largest.
D1 · Cyclomatic Complexity · run_official_experiment.main (cyclomatic 31) · ×1
  • run_official_experiment.main (cyclomatic 31) chapter10/book-translation/run_official_experiment.py:505 — run_official_experiment.main has cyclomatic complexity 31 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · run_comparison.main (cyclomatic 31) · ×1
  • run_comparison.main (cyclomatic 31) chapter10/multi-role-transfer/run_comparison.py:456 — run_comparison.main has cyclomatic complexity 31 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ContextualMemoryEvaluator.evaluate_test_case (cyclomatic 31) · ×1
  • ContextualMemoryEvaluator.evaluate_test_case (cyclomatic 31) chapter3/contextual-retrieval-for-user-memory/contextual_evaluator.py:269 — ContextualMemoryEvaluator.evaluate_test_case has cyclomatic complexity 31 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · memory_rag_campaign.main (cyclomatic 31) · ×1
  • memory_rag_campaign.main (cyclomatic 31) chapter3/memory_rag_campaign.py:492 — memory_rag_campaign.main has cyclomatic complexity 31 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · main.interactive_chat (cyclomatic 31) · ×1
  • main.interactive_chat (cyclomatic 31) chapter4/multimodal-agent/main.py:95 — main.interactive_chat has cyclomatic complexity 31 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · demo.main (cyclomatic 31) · ×1
  • demo.main (cyclomatic 31) chapter7/tts-quality-eval/demo.py:214 — demo.main has cyclomatic complexity 31 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · DownstreamAblationEngine.run_ablation_campaign (cyclomatic 31) · ×1
  • DownstreamAblationEngine.run_ablation_campaign (cyclomatic 31) chapter9/hermes-self-evolution/run_downstream_ablation.py:224 — DownstreamAblationEngine.run_ablation_campaign has cyclomatic complexity 31 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · OllamaNativeAgent.chat_stream (cyclomatic 30) · ×1
  • OllamaNativeAgent.chat_stream (cyclomatic 30) chapter2/local_llm_serving/ollama_native.py:213 — OllamaNativeAgent.chat_stream has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · providers.capture (cyclomatic 30) · ×1
  • providers.capture (cyclomatic 30) chapter5/provider-failover/providers.py:88 — providers.capture has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · InteractiveContextualRAG.evaluate_specific_test_case (cyclomatic 29) · ×1
  • InteractiveContextualRAG.evaluate_specific_test_case (cyclomatic 29) chapter3/contextual-retrieval-for-user-memory/main.py:454 — InteractiveContextualRAG.evaluate_specific_test_case has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · campaign.run (cyclomatic 29) · ×1
  • campaign.run (cyclomatic 29) REDACTED:415 — campaign.run has cyclomatic complexity 29 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · verify_acceptance.check_llm_receipt (cyclomatic 29) · ×1
  • verify_acceptance.check_llm_receipt (cyclomatic 29) chapter6/phone-agent/verify_acceptance.py:100 — verify_acceptance.check_llm_receipt has cyclomatic complexity 29 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · webrtc_app._acceptance (cyclomatic 29) · ×1
  • webrtc_app._acceptance (cyclomatic 29) chapter6/phone-agent/webrtc_app.py:201 — webrtc_app._acceptance has cyclomatic complexity 29 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · ContextAwareAgent.execute_task (cyclomatic 28) · ×1
  • ContextAwareAgent.execute_task (cyclomatic 28) REDACTED:701 — ContextAwareAgent.execute_task has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ExtendedTools.virtual_desktop_execute (cyclomatic 28) · ×1
  • ExtendedTools.virtual_desktop_execute (cyclomatic 28) REDACTED:139 — ExtendedTools.virtual_desktop_execute has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · campaign.main (cyclomatic 28) · ×1
  • campaign.main (cyclomatic 28) chapter5/paper-to-video/campaign.py:320 — campaign.main has cyclomatic complexity 28 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · benchmark_harness_focused.run_focused_harness_eval (cyclomatic 28) · ×1
  • benchmark_harness_focused.run_focused_harness_eval (cyclomatic 28) REDACTED:129 — benchmark_harness_focused.run_focused_harness_eval has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · PEDOSecurityEvaluator.evaluate_row_level_security (cyclomatic 28) · ×1
  • PEDOSecurityEvaluator.evaluate_row_level_security (cyclomatic 28) chapter5/permission-embedded-data-objects/run_live_security_eval.py:438 — PEDOSecurityEvaluator.evaluate_row_level_security has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · PEDOSecurityEvaluator.evaluate_field_visibility (cyclomatic 28) · ×1
  • PEDOSecurityEvaluator.evaluate_field_visibility (cyclomatic 28) chapter5/permission-embedded-data-objects/run_live_security_eval.py:561 — PEDOSecurityEvaluator.evaluate_field_visibility has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · experiment.preflight (cyclomatic 28) · ×1
  • experiment.preflight (cyclomatic 28) chapter7/openvla-robotwin2-eval/experiment.py:99 — experiment.preflight has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · generate.validateLesson (cyclomatic 28) · ×1
  • generate.validateLesson (cyclomatic 28) slides/generate.mjs:344 — generate.validateLesson has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · benchmark_safety.print_results (cyclomatic 27) · ×1
  • benchmark_safety.print_results (cyclomatic 27) REDACTED:645 — benchmark_safety.print_results has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · validate_run.main (cyclomatic 27) · ×1
  • validate_run.main (cyclomatic 27) chapter6/computer-use-open-model/validate_run.py:61 — validate_run.main has cyclomatic complexity 27 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · preflight.main (cyclomatic 27) · ×1
  • preflight.main (cyclomatic 27) chapter6/rgb-sim2real-grasping/preflight.py:32 — preflight.main has cyclomatic complexity 27 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · run_experiment_9_5.campaign (cyclomatic 27) · ×1
  • run_experiment_9_5.campaign (cyclomatic 27) REDACTED:334 — run_experiment_9_5.campaign has cyclomatic complexity 27 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · ReActAttentionAgent.execute_react_loop (cyclomatic 26) · ×1
  • ReActAttentionAgent.execute_react_loop (cyclomatic 26) chapter2/attention_visualization/main.py:305 — ReActAttentionAgent.execute_react_loop has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · NotificationDispatcher.dispatch_and_wait (cyclomatic 26) · ×1
  • NotificationDispatcher.dispatch_and_wait (cyclomatic 26) chapter4/collaboration-tools/src/notification_dispatcher.py:437 — NotificationDispatcher.dispatch_and_wait has cyclomatic complexity 26 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · search_tools.search_web (cyclomatic 26) · ×1
  • search_tools.search_web (cyclomatic 26) chapter4/perception-tools/src/search_tools.py:45 — search_tools.search_web has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · validator.validate_agent (cyclomatic 26) · ×1
  • validator.validate_agent (cyclomatic 26) chapter5/agent-creator/validator.py:331 — validator.validate_agent has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RateRampBenchmark.run (cyclomatic 26) · ×1
  • RateRampBenchmark.run (cyclomatic 26) chapter7/model-benchmark/rate_ramp_benchmark.py:213 — RateRampBenchmark.run has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ConnectionHandler.generateAIResponse (cyclomatic 26) · ×1
  • ConnectionHandler.generateAIResponse (cyclomatic 26) chapter6/live-audio/backend/server.js:352 — ConnectionHandler.generateAIResponse has cyclomatic complexity 26 (threshold 15). Most of this is not in the body itself: 6 of the 26 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 423, 488). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
D1 · Cyclomatic Complexity · LLMAgent.choose_action (cyclomatic 25) · ×1
  • LLMAgent.choose_action (cyclomatic 25) chapter1/learning-from-experience/llm_agent.py:215 — LLMAgent.choose_action has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · evaluate_audio_run.evaluate (cyclomatic 25) · ×1
  • evaluate_audio_run.evaluate (cyclomatic 25) chapter10/voice-werewolf/evaluate_audio_run.py:47 — evaluate_audio_run.evaluate has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_experiment_2_8.execute_tool (cyclomatic 25) · ×1
  • run_experiment_2_8.execute_tool (cyclomatic 25) chapter2/system-hint/run_experiment_2_8.py:298 — run_experiment_2_8.execute_tool has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_experiment_4_4.run (cyclomatic 25) · ×1
  • run_experiment_4_4.run (cyclomatic 25) chapter4/execution-tools/run_experiment_4_4.py:55 — run_experiment_4_4.run has cyclomatic complexity 25 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · MultimodalAgent._stream_gemini_response (cyclomatic 25) · ×1
  • MultimodalAgent._stream_gemini_response (cyclomatic 25) chapter4/multimodal-agent/agent.py:887 — MultimodalAgent._stream_gemini_response has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · demo.main (cyclomatic 25) · ×1
  • demo.main (cyclomatic 25) chapter5/code-for-logic/demo.py:489 — demo.main has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · benchmark_application.print_application_results (cyclomatic 25) · ×1
  • benchmark_application.print_application_results (cyclomatic 25) REDACTED:455 — benchmark_application.print_application_results has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · evaluate_audio_quality.main (cyclomatic 25) · ×1
  • evaluate_audio_quality.main (cyclomatic 25) REDACTED:378 — evaluate_audio_quality.main has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · evaluate_from_cache.evaluate_from_parquet (cyclomatic 25) · ×1
  • evaluate_from_cache.evaluate_from_parquet (cyclomatic 25) chapter8/Intuitor/evaluate_from_cache.py:198 — evaluate_from_cache.evaluate_from_parquet has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · LongitudinalEvaluator.run (cyclomatic 25) · ×1
  • LongitudinalEvaluator.run (cyclomatic 25) chapter9/self-evolution-eval/harness.py:24 — LongitudinalEvaluator.run has cyclomatic complexity 25 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · check_i18n_consistency.main (cyclomatic 25) · ×1
  • check_i18n_consistency.main (cyclomatic 25) scripts/check_i18n_consistency.py:96 — check_i18n_consistency.main has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · machine-translation.initMachineTranslation (cyclomatic 25) · ×1
  • machine-translation.initMachineTranslation (cyclomatic 25) web-astro/src/scripts/machine-translation.ts:30 — machine-translation.initMachineTranslation has cyclomatic complexity 25 (threshold 15). Most of this is not in the body itself: 6 of the 25 points are its own statements and the rest belongs to 6 function items inside it that branch (setState, a function literal at line 67, a function literal at line 138, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
D1 · Cyclomatic Complexity · FieldSpec.validate (cyclomatic 24) · ×1
  • FieldSpec.validate (cyclomatic 24) chapter10/autonomous-phone-registration/models.py:31 — FieldSpec.validate has cyclomatic complexity 24 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · MultiRoleOrchestrator._run_one_llm_turn (cyclomatic 24) · ×1
  • MultiRoleOrchestrator._run_one_llm_turn (cyclomatic 24) chapter10/multi-role-transfer/orchestrator.py:108 — MultiRoleOrchestrator._run_one_llm_turn has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · demo.verify_simulator_trace (cyclomatic 24) · ×1
  • demo.verify_simulator_trace (cyclomatic 24) chapter10/voice-werewolf/demo.py:131 — demo.verify_simulator_trace has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ResearchAgent._stream_response (cyclomatic 24) · ×1
  • ResearchAgent._stream_response (cyclomatic 24) chapter2/context-compression/agent.py:353 — ResearchAgent._stream_response has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ContextualUserMemoryAgent.answer_question (cyclomatic 24) · ×1
  • ContextualUserMemoryAgent.answer_question (cyclomatic 24) chapter3/contextual-retrieval-for-user-memory/contextual_agent.py:268 — ContextualUserMemoryAgent.answer_question has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · LogSanitizationAgent.detect_pii (cyclomatic 24) · ×1
  • LogSanitizationAgent.detect_pii (cyclomatic 24) chapter3/log-sanitization/agent.py:139 — LogSanitizationAgent.detect_pii has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · campaign_browser.main (cyclomatic 24) · ×1
  • campaign_browser.main (cyclomatic 24) REDACTED:221 — campaign_browser.main has cyclomatic complexity 24 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · benchmark_application.run_pedo_workflow (cyclomatic 24) · ×1
  • benchmark_application.run_pedo_workflow (cyclomatic 24) REDACTED:239 — benchmark_application.run_pedo_workflow has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · StrengthenedOracle.check_violations (cyclomatic 24) · ×1
  • StrengthenedOracle.check_violations (cyclomatic 24) REDACTED:101 — StrengthenedOracle.check_violations has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · analysis.availability_summary (cyclomatic 24) · ×1
  • analysis.availability_summary (cyclomatic 24) chapter7/model-benchmark/analysis.py:124 — analysis.availability_summary has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_full.main (cyclomatic 24) · ×1
  • run_full.main (cyclomatic 24) chapter7/user-memory-system-evaluation/run_full.py:145 — run_full.main has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MultilingualReasoningEvaluator._parse_model_output (cyclomatic 24) · ×1
  • MultilingualReasoningEvaluator._parse_model_output (cyclomatic 24) chapter8/MultilingualReasoning/evaluate_multilingual.py:320 — MultilingualReasoningEvaluator._parse_model_output has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · reading-position.initReadingPosition (cyclomatic 24) · ×1
  • reading-position.initReadingPosition (cyclomatic 24) web-astro/src/scripts/reading-position.ts:9 — reading-position.initReadingPosition has cyclomatic complexity 24 (threshold 15). Most of this is not in the body itself: 9 of the 24 points are its own statements and the rest belongs to 5 function items inside it that branch (restore, capture, save, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
D1 · Cyclomatic Complexity · main (cyclomatic 24) · ×1
  • main (cyclomatic 24) slides/generate.mjs:476 — main has cyclomatic complexity 24 (threshold 15). Of this number, 23 points are the body's own statements and 1 belongs to 10 function literals inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · agents.run_orchestration (cyclomatic 23) · ×1
  • agents.run_orchestration (cyclomatic 23) chapter10/book-translation/agents.py:461 — agents.run_orchestration has cyclomatic complexity 23 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · evaluation.evaluate_task (cyclomatic 23) · ×1
  • evaluation.evaluate_task (cyclomatic 23) chapter10/multi-role-transfer/evaluation.py:148 — evaluation.evaluate_task has cyclomatic complexity 23 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · run_campaign.summarize (cyclomatic 23) · ×1
  • run_campaign.summarize (cyclomatic 23) chapter2/prompt-injection/run_campaign.py:217 — run_campaign.summarize has cyclomatic complexity 23 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · campaign.main (cyclomatic 23) · ×1
  • campaign.main (cyclomatic 23) chapter3/structured-index/campaign.py:400 — campaign.main has cyclomatic complexity 23 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · CodingAgentCLI.run_agent (cyclomatic 23) · ×1
  • CodingAgentCLI.run_agent (cyclomatic 23) chapter5/coding-agent/main.py:206 — CodingAgentCLI.run_agent has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · benchmark_application.run_raw_workflow (cyclomatic 23) · ×1
  • benchmark_application.run_raw_workflow (cyclomatic 23) REDACTED:334 — benchmark_application.run_raw_workflow has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_controlled_experiment._parse_args (cyclomatic 23) · ×1
  • run_controlled_experiment._parse_args (cyclomatic 23) chapter7/android-world/run_controlled_experiment.py:933 — run_controlled_experiment._parse_args has cyclomatic complexity 23 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · campaign.measure_stream (cyclomatic 23) · ×1
  • campaign.measure_stream (cyclomatic 23) chapter7/model-benchmark/campaign.py:432 — campaign.measure_stream has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · LearningAgent._save_learned_workflow (cyclomatic 23) · ×1
  • LearningAgent._save_learned_workflow (cyclomatic 23) chapter9/browser-use-rpa/learning_agent/agent.py:437 — LearningAgent._save_learned_workflow has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · TrajectoryConsistencyChecker.check_trajectory (cyclomatic 23) · ×1
  • TrajectoryConsistencyChecker.check_trajectory (cyclomatic 23) chapter9/trajectory-verifier/consistency_checker.py:153 — TrajectoryConsistencyChecker.check_trajectory has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · evidence.validate_manifest (cyclomatic 22) · ×1
  • evidence.validate_manifest (cyclomatic 22) chapter1/image-gen-workflow/evidence.py:83 — evidence.validate_manifest has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_experiment_1_2.validate (cyclomatic 22) · ×1
  • run_experiment_1_2.validate (cyclomatic 22) chapter1/web-search-agent/run_experiment_1_2.py:91 — run_experiment_1_2.validate has cyclomatic complexity 22 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · run_official_experiment.validate_judge_response (cyclomatic 22) · ×1
  • run_official_experiment.validate_judge_response (cyclomatic 22) chapter10/book-translation/run_official_experiment.py:179 — run_official_experiment.validate_judge_response has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · validate_campaign.main (cyclomatic 22) · ×1
  • validate_campaign.main (cyclomatic 22) chapter10/talkact-reproduction/validate_campaign.py:40 — validate_campaign.main has cyclomatic complexity 22 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · demo.verify_isolation (cyclomatic 22) · ×1
  • demo.verify_isolation (cyclomatic 22) chapter10/voice-werewolf/demo.py:59 — demo.verify_isolation has cyclomatic complexity 22 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · campaign.main (cyclomatic 22) · ×1
  • campaign.main (cyclomatic 22) chapter3/contextual-retrieval/campaign.py:163 — campaign.main has cyclomatic complexity 22 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · GrepTool._search_content (cyclomatic 22) · ×1
  • GrepTool._search_content (cyclomatic 22) chapter5/coding-agent/tools/grep_tool.py:262 — GrepTool._search_content has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · campaign_postgres.main (cyclomatic 22) · ×1
  • campaign_postgres.main (cyclomatic 22) chapter5/erp-agent/campaign_postgres.py:267 — campaign_postgres.main has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · benchmark_comparisons.run_all_comparisons (cyclomatic 22) · ×1
  • benchmark_comparisons.run_all_comparisons (cyclomatic 22) REDACTED:693 — benchmark_comparisons.run_all_comparisons has cyclomatic complexity 22 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D1 · Cyclomatic Complexity · benchmark_safety_v2.print_safety_v2_results (cyclomatic 22) · ×1
  • benchmark_safety_v2.print_safety_v2_results (cyclomatic 22) REDACTED:379 — benchmark_safety_v2.print_safety_v2_results has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · validate_weather_run.main (cyclomatic 22) · ×1
  • validate_weather_run.main (cyclomatic 22) chapter6/claude-computer-use-native/validate_weather_run.py:28 — validate_weather_run.main has cyclomatic complexity 22 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · markup.parse (cyclomatic 22) · ×1
  • markup.parse (cyclomatic 22) chapter6/controllable-tts/markup.py:56 — markup.parse has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · create_data.generate_distillation_data (cyclomatic 22) · ×1
  • create_data.generate_distillation_data (cyclomatic 22) chapter8/prompt-distillation/create_data.py:146 — create_data.generate_distillation_data has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · DownstreamAblationEngine.evaluate_code_quality (cyclomatic 22) · ×1
  • DownstreamAblationEngine.evaluate_code_quality (cyclomatic 22) chapter9/hermes-self-evolution/run_downstream_ablation.py:89 — DownstreamAblationEngine.evaluate_code_quality has cyclomatic complexity 22 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · OpenAIQualityJudge.evaluate (cyclomatic 22) · ×1
  • OpenAIQualityJudge.evaluate (cyclomatic 22) chapter9/trajectory-verifier/llm_judge.py:41 — OpenAIQualityJudge.evaluate has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ResearchAgent.execute_research (cyclomatic 21) · ×1
  • ResearchAgent.execute_research (cyclomatic 21) chapter2/context-compression/agent.py:511 — ResearchAgent.execute_research has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_experiment_2_8.component_scores (cyclomatic 21) · ×1
  • run_experiment_2_8.component_scores (cyclomatic 21) chapter2/system-hint/run_experiment_2_8.py:390 — run_experiment_2_8.component_scores has cyclomatic complexity 21 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · run_experiment_2_8.summarize (cyclomatic 21) · ×1
  • run_experiment_2_8.summarize (cyclomatic 21) chapter2/system-hint/run_experiment_2_8.py:675 — run_experiment_2_8.summarize has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · InteractiveRAGEvaluator.evaluate_single_test (cyclomatic 21) · ×1
  • InteractiveRAGEvaluator.evaluate_single_test (cyclomatic 21) chapter3/agentic-rag-for-user-memory/main.py:255 — InteractiveRAGEvaluator.evaluate_single_test has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RetrievalStageEvaluator.evaluate_pipeline (cyclomatic 21) · ×1
  • RetrievalStageEvaluator.evaluate_pipeline (cyclomatic 21) chapter3/retrieval-pipeline/stage_evaluator.py:255 — RetrievalStageEvaluator.evaluate_pipeline has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · HybridStructuredRetriever.index_graphrag_data (cyclomatic 21) · ×1
  • HybridStructuredRetriever.index_graphrag_data (cyclomatic 21) chapter3/structured-index/hybrid_retriever.py:219 — HybridStructuredRetriever.index_graphrag_data has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · HybridStructuredRetriever._compute_scores (cyclomatic 21) · ×1
  • HybridStructuredRetriever._compute_scores (cyclomatic 21) chapter3/structured-index/hybrid_retriever.py:289 — HybridStructuredRetriever._compute_scores has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · BatchEvaluator.generate_report (cyclomatic 21) · ×1
  • BatchEvaluator.generate_report (cyclomatic 21) chapter3/user-memory-evaluation/evaluator.py:373 — BatchEvaluator.generate_report has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · UserMemoryEvaluationFramework._load_single_test_case (cyclomatic 21) · ×1
  • UserMemoryEvaluationFramework._load_single_test_case (cyclomatic 21) chapter3/user-memory-evaluation/framework.py:66 — UserMemoryEvaluationFramework._load_single_test_case has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_exact_experiment.substantive_payload (cyclomatic 21) · ×1
  • run_exact_experiment.substantive_payload (cyclomatic 21) chapter4/active-tool-discovery/run_exact_experiment.py:363 — run_exact_experiment.substantive_payload has cyclomatic complexity 21 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · run_exact_experiment.run (cyclomatic 21) · ×1
  • run_exact_experiment.run (cyclomatic 21) chapter4/active-tool-discovery/run_exact_experiment.py:1060 — run_exact_experiment.run has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · example_with_system_hints.demo_system_hints (cyclomatic 21) · ×1
  • example_with_system_hints.demo_system_hints (cyclomatic 21) chapter5/coding-agent/example_with_system_hints.py:10 — example_with_system_hints.demo_system_hints has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · campaign.run (cyclomatic 21) · ×1
  • campaign.run (cyclomatic 21) chapter5/video-edit/campaign.py:473 — campaign.run has cyclomatic complexity 21 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · demo.main (cyclomatic 21) · ×1
  • demo.main (cyclomatic 21) chapter5/video-edit/demo.py:139 — demo.main has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · experiment_core.render_report (cyclomatic 21) · ×1
  • experiment_core.render_report (cyclomatic 21) chapter7/android-world/experiment_core.py:394 — experiment_core.render_report has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · analysis.cost_summary (cyclomatic 21) · ×1
  • analysis.cost_summary (cyclomatic 21) chapter7/model-benchmark/analysis.py:219 — analysis.cost_summary has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_real_validation.runLlm (cyclomatic 21) · ×1
  • run_real_validation.runLlm (cyclomatic 21) chapter6/live-audio/backend/run_real_validation.js:222 — run_real_validation.runLlm has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · figure-style.color (cyclomatic 21) · ×1
  • figure-style.color (cyclomatic 21) web-astro/scripts/figure-style.mjs:33 — figure-style.color has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_experiment_1_1.evaluate_context_contract (cyclomatic 20) · ×1
  • run_experiment_1_1.evaluate_context_contract (cyclomatic 20) chapter1/context/run_experiment_1_1.py:155 — run_experiment_1_1.evaluate_context_contract has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · run_experiment_8_2.main (cyclomatic 20) · ×1
  • run_experiment_8_2.main (cyclomatic 20) chapter1/learning-from-experience/run_experiment_8_2.py:69 — run_experiment_8_2.main has cyclomatic complexity 20 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · supervise_campaigns.main (cyclomatic 20) · ×1
  • supervise_campaigns.main (cyclomatic 20) REDACTED:90 — supervise_campaigns.main has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · package_comparison.main (cyclomatic 20) · ×1
  • package_comparison.main (cyclomatic 20) chapter10/multi-role-transfer/package_comparison.py:75 — package_comparison.main has cyclomatic complexity 20 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · ReActAttentionAgent.save_react_trajectory (cyclomatic 20) · ×1
  • ReActAttentionAgent.save_react_trajectory (cyclomatic 20) chapter2/attention_visualization/main.py:483 — ReActAttentionAgent.save_react_trajectory has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MemoryIndexer.search (cyclomatic 20) · ×1
  • MemoryIndexer.search (cyclomatic 20) chapter3/agentic-rag-for-user-memory/indexer.py:373 — MemoryIndexer.search has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · AgenticRAG.query (cyclomatic 20) · ×1
  • AgenticRAG.query (cyclomatic 20) chapter3/agentic-rag/agent.py:231 — AgenticRAG.query has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · UserMemoryAgent.__init__ (cyclomatic 20) · ×1
  • UserMemoryAgent.__init__ (cyclomatic 20) chapter3/user-memory/agent.py:59 — UserMemoryAgent.__init__ has cyclomatic complexity 20 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · ConversationalAgent.__init__ (cyclomatic 20) · ×1
  • ConversationalAgent.__init__ (cyclomatic 20) chapter3/user-memory/conversational_agent.py:47 — ConversationalAgent.__init__ has cyclomatic complexity 20 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · run_exact_experiment._call_real_tool (cyclomatic 20) · ×1
  • run_exact_experiment._call_real_tool (cyclomatic 20) chapter4/active-tool-discovery/run_exact_experiment.py:525 — run_exact_experiment._call_real_tool has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · cli._demo (cyclomatic 20) · ×1
  • cli._demo (cyclomatic 20) chapter4/perception-tools/cli.py:337 — cli._demo has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · run_experiment_4_2.derive_acceptance (cyclomatic 20) · ×1
  • run_experiment_4_2.derive_acceptance (cyclomatic 20) chapter4/perception-tools/run_experiment_4_2.py:459 — run_experiment_4_2.derive_acceptance has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · expanded_catalog._specific_contract (cyclomatic 20) · ×1
  • expanded_catalog._specific_contract (cyclomatic 20) chapter4/perception-tools/src/expanded_catalog.py:322 — expanded_catalog._specific_contract has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · campaign.main (cyclomatic 20) · ×1
  • campaign.main (cyclomatic 20) chapter5/adaptive-log-parser/campaign.py:248 — campaign.main has cyclomatic complexity 20 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · AgentCreator._ask (cyclomatic 20) · ×1
  • AgentCreator._ask (cyclomatic 20) chapter5/agent-creator/creator.py:208 — AgentCreator._ask has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · CodingAgent.run (cyclomatic 20) · ×1
  • CodingAgent.run (cyclomatic 20) chapter5/coding-agent/agent_new.py:108 — CodingAgent.run has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · PEDOSecurityEvaluator._execute_agent_query (cyclomatic 20) · ×1
  • PEDOSecurityEvaluator._execute_agent_query (cyclomatic 20) chapter5/permission-embedded-data-objects/run_live_security_eval.py:267 — PEDOSecurityEvaluator._execute_agent_query has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_targeted_eval.run_single (cyclomatic 20) · ×1
  • run_targeted_eval.run_single (cyclomatic 20) REDACTED:303 — run_targeted_eval.run_single has cyclomatic complexity 20 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · main.run (cyclomatic 20) · ×1
  • main.run (cyclomatic 20) chapter6/computer-use-open-model/main.py:90 — main.run has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · validate_artifacts.main (cyclomatic 20) · ×1
  • validate_artifacts.main (cyclomatic 20) chapter6/controllable-tts/validate_artifacts.py:34 — validate_artifacts.main has cyclomatic complexity 20 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · experiment.interaction_analysis (cyclomatic 20) · ×1
  • experiment.interaction_analysis (cyclomatic 20) chapter7/user-memory-system-evaluation/experiment.py:1301 — experiment.interaction_analysis has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_full.valid_checkpoint (cyclomatic 20) · ×1
  • run_full.valid_checkpoint (cyclomatic 20) chapter7/user-memory-system-evaluation/run_full.py:34 — run_full.valid_checkpoint has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · train_student.main (cyclomatic 20) · ×1
  • train_student.main (cyclomatic 20) chapter8/cot-distillation/train_student.py:135 — train_student.main has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ConnectionHandler.isCompleteSentence (cyclomatic 20) · ×1
  • ConnectionHandler.isCompleteSentence (cyclomatic 20) chapter6/live-audio/backend/server.js:535 — ConnectionHandler.isCompleteSentence has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · calc_sandbox._check (cyclomatic 19) · ×1
  • calc_sandbox._check (cyclomatic 19) REDACTED:49 — calc_sandbox._check has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · GPT5NativeAgent._citations (cyclomatic 19) · ×1
  • GPT5NativeAgent._citations (cyclomatic 19) chapter1/search-codegen/agent.py:148 — GPT5NativeAgent._citations has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · WebSearchAgent.search_and_answer (cyclomatic 19) · ×1
  • WebSearchAgent.search_and_answer (cyclomatic 19) chapter1/web-search-agent/agent.py:364 — WebSearchAgent.search_and_answer has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · AttentionVisualizationAgent._capture_attention_hook (cyclomatic 19) · ×1
  • AttentionVisualizationAgent._capture_attention_hook (cyclomatic 19) chapter2/attention_visualization/agent.py:216 — AttentionVisualizationAgent._capture_attention_hook has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ReActAttentionAgent.generate_with_streaming (cyclomatic 19) · ×1
  • ReActAttentionAgent.generate_with_streaming (cyclomatic 19) chapter2/attention_visualization/main.py:85 — ReActAttentionAgent.generate_with_streaming has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · main.main (cyclomatic 19) · ×1
  • main.main (cyclomatic 19) chapter3/agentic-rag/main.py:187 — main.main has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · MockChatClient._respond (cyclomatic 19) · ×1
  • MockChatClient._respond (cyclomatic 19) REDACTED:158 — MockChatClient._respond has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · campaign.main (cyclomatic 19) · ×1
  • campaign.main (cyclomatic 19) chapter4/multimodal-agent/campaign.py:239 — campaign.main has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · demo.solve (cyclomatic 19) · ×1
  • demo.solve (cyclomatic 19) chapter5/code-for-math/demo.py:168 — demo.solve has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · CodingAgent._run_anthropic_iteration (cyclomatic 19) · ×1
  • CodingAgent._run_anthropic_iteration (cyclomatic 19) chapter5/coding-agent/agent.py:181 — CodingAgent._run_anthropic_iteration has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · NotebookEditTool._execute_impl (cyclomatic 19) · ×1
  • NotebookEditTool._execute_impl (cyclomatic 19) chapter5/coding-agent/tools/notebook_edit_tool.py:18 — NotebookEditTool._execute_impl has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · campaign_browser.customize (cyclomatic 19) · ×1
  • campaign_browser.customize (cyclomatic 19) REDACTED:100 — campaign_browser.customize has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · seed.generate (cyclomatic 19) · ×1
  • seed.generate (cyclomatic 19) chapter5/erp-agent/seed.py:44 — seed.generate has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · replay._eval_assertion (cyclomatic 19) · ×1
  • replay._eval_assertion (cyclomatic 19) chapter5/log-diagnosis/replay.py:52 — replay._eval_assertion has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · benchmark_final_comprehensive.check_violations (cyclomatic 19) · ×1
  • benchmark_final_comprehensive.check_violations (cyclomatic 19) REDACTED:162 — benchmark_final_comprehensive.check_violations has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · benchmark_safety_final.print_final_results (cyclomatic 19) · ×1
  • benchmark_safety_final.print_final_results (cyclomatic 19) REDACTED:464 — benchmark_safety_final.print_final_results has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · pipeline.judge_gemini_audio (cyclomatic 19) · ×1
  • pipeline.judge_gemini_audio (cyclomatic 19) REDACTED:676 — pipeline.judge_gemini_audio has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · build_73_evidence.main (cyclomatic 19) · ×1
  • build_73_evidence.main (cyclomatic 19) chapter7/user-memory-system-evaluation/build_73_evidence.py:30 — build_73_evidence.main has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ChatBackend.complete (cyclomatic 19) · ×1
  • ChatBackend.complete (cyclomatic 19) chapter7/user-memory-system-evaluation/experiment.py:245 — ChatBackend.complete has cyclomatic complexity 19 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · MultilingualReasoningEvaluator.evaluate_cot_fidelity (cyclomatic 19) · ×1
  • MultilingualReasoningEvaluator.evaluate_cot_fidelity (cyclomatic 19) chapter8/MultilingualReasoning/evaluate_multilingual.py:174 — MultilingualReasoningEvaluator.evaluate_cot_fidelity has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · generate_data.main (cyclomatic 19) · ×1
  • generate_data.main (cyclomatic 19) chapter8/cot-distillation/generate_data.py:206 — generate_data.main has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · evaluate.main (cyclomatic 19) · ×1
  • evaluate.main (cyclomatic 19) chapter8/prompt-distillation/evaluate.py:333 — evaluate.main has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · LearningAgent._extract_action_data (cyclomatic 19) · ×1
  • LearningAgent._extract_action_data (cyclomatic 19) chapter9/browser-use-rpa/learning_agent/agent.py:147 — LearningAgent._extract_action_data has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · SafetyPolicyGate.inspect_path_traversal (cyclomatic 19) · ×1
  • SafetyPolicyGate.inspect_path_traversal (cyclomatic 19) chapter9/harness-safety-gate/safety_policy_gate.py:194 — SafetyPolicyGate.inspect_path_traversal has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · demo.main (cyclomatic 19) · ×1
  • demo.main (cyclomatic 19) chapter9/prompt-auto-optimization/demo.py:82 — demo.main has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · fix_svg_text_layout.reflow_wrapped_shapes (cyclomatic 18) · ×1
  • fix_svg_text_layout.reflow_wrapped_shapes (cyclomatic 18) REDACTED:434 — fix_svg_text_layout.reflow_wrapped_shapes has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · finalize_experiment_8_2.main (cyclomatic 18) · ×1
  • finalize_experiment_8_2.main (cyclomatic 18) chapter1/learning-from-experience/finalize_experiment_8_2.py:16 — finalize_experiment_8_2.main has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · decision.decide_orchestration (cyclomatic 18) · ×1
  • decision.decide_orchestration (cyclomatic 18) chapter10/autonomous-phone-registration/decision.py:72 — decision.decide_orchestration has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · judge_plausibility.main (cyclomatic 18) · ×1
  • judge_plausibility.main (cyclomatic 18) chapter10/generative-agents/judge_plausibility.py:221 — judge_plausibility.main has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · demo.save_evidence (cyclomatic 18) · ×1
  • demo.save_evidence (cyclomatic 18) chapter10/multi-role-transfer/demo.py:190 — demo.save_evidence has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · evaluation._custom_task_score (cyclomatic 18) · ×1
  • evaluation._custom_task_score (cyclomatic 18) chapter10/multi-role-transfer/evaluation.py:67 — evaluation._custom_task_score has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · main.run_demo (cyclomatic 18) · ×1
  • main.run_demo (cyclomatic 18) chapter2/context-compression/main.py:65 — main.run_demo has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · main.main (cyclomatic 18) · ×1
  • main.main (cyclomatic 18) REDACTED:516 — main.main has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_campaign.run_trial (cyclomatic 18) · ×1
  • run_campaign.run_trial (cyclomatic 18) chapter2/prompt-injection/run_campaign.py:107 — run_campaign.run_trial has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · main.run_memory_op (cyclomatic 18) · ×1
  • main.run_memory_op (cyclomatic 18) chapter3/mem0/main.py:242 — main.run_memory_op has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · NotesMemoryManager.consolidate_memories (cyclomatic 18) · ×1
  • NotesMemoryManager.consolidate_memories (cyclomatic 18) chapter3/user-memory/memory_manager.py:269 — NotesMemoryManager.consolidate_memories has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · AgentCreator.repair_after_live_failure (cyclomatic 18) · ×1
  • AgentCreator.repair_after_live_failure (cyclomatic 18) chapter5/agent-creator/creator.py:1289 — AgentCreator.repair_after_live_failure has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · demo.self_check (cyclomatic 18) · ×1
  • demo.self_check (cyclomatic 18) chapter5/paper-to-video/demo.py:382 — demo.self_check has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · judging.judge (cyclomatic 18) · ×1
  • judging.judge (cyclomatic 18) chapter5/provider-failover/judging.py:19 — judging.judge has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_handoff.run_pair (cyclomatic 18) · ×1
  • run_handoff.run_pair (cyclomatic 18) chapter5/provider-failover/run_handoff.py:46 — run_handoff.run_pair has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · summarize.continuation_summary (cyclomatic 18) · ×1
  • summarize.continuation_summary (cyclomatic 18) chapter5/provider-failover/summarize.py:67 — summarize.continuation_summary has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · unipile_mailbox_experiment.run (cyclomatic 18) · ×1
  • unipile_mailbox_experiment.run (cyclomatic 18) chapter6/agent-with-event-trigger/unipile_mailbox_experiment.py:652 — unipile_mailbox_experiment.run has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_weather_task.main (cyclomatic 18) · ×1
  • run_weather_task.main (cyclomatic 18) chapter6/claude-computer-use-native/run_weather_task.py:60 — run_weather_task.main has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · desktop_planner.run_episode (cyclomatic 18) · ×1
  • desktop_planner.run_episode (cyclomatic 18) chapter6/gemini-xlerobot-navigation/desktop_planner.py:197 — desktop_planner.run_episode has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_acceptance.main (cyclomatic 18) · ×1
  • run_acceptance.main (cyclomatic 18) REDACTED:206 — run_acceptance.main has cyclomatic complexity 18 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · bradley_terry.compute_mle_elo (cyclomatic 18) · ×1
  • bradley_terry.compute_mle_elo (cyclomatic 18) chapter7/elo-leaderboard/bradley_terry.py:12 — bradley_terry.compute_mle_elo has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · campaign.measure_anthropic (cyclomatic 18) · ×1
  • campaign.measure_anthropic (cyclomatic 18) chapter7/model-benchmark/campaign.py:615 — campaign.measure_anthropic has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · campaign.measure_gemini (cyclomatic 18) · ×1
  • campaign.measure_gemini (cyclomatic 18) chapter7/model-benchmark/campaign.py:703 — campaign.measure_gemini has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ExperimentRunner.run_611 (cyclomatic 18) · ×1
  • ExperimentRunner.run_611 (cyclomatic 18) chapter7/user-memory-system-evaluation/experiment.py:1119 — ExperimentRunner.run_611 has cyclomatic complexity 18 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D1 · Cyclomatic Complexity · MultilingualReasoningEvaluator.evaluate_accuracy (cyclomatic 18) · ×1
  • MultilingualReasoningEvaluator.evaluate_accuracy (cyclomatic 18) chapter8/MultilingualReasoning/evaluate_multilingual.py:236 — MultilingualReasoningEvaluator.evaluate_accuracy has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_report_audit.parse_retained_outputs (cyclomatic 18) · ×1
  • run_report_audit.parse_retained_outputs (cyclomatic 18) REDACTED:100 — run_report_audit.parse_retained_outputs has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_experiment_9_7.main (cyclomatic 18) · ×1
  • run_experiment_9_7.main (cyclomatic 18) chapter9/harness-safety-gate/run_experiment_9_7.py:47 — run_experiment_9_7.main has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · highlights.initHighlights · ×1
  • highlights.initHighlights::render (cyclomatic 18) web-astro/src/scripts/highlights.ts:90 — highlights.initHighlights::render has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · TreasureHuntGame.execute_action (cyclomatic 17) · ×1
  • TreasureHuntGame.execute_action (cyclomatic 17) chapter1/learning-from-experience/game_environment.py:204 — TreasureHuntGame.execute_action has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · quick_demo.run_llm_demo (cyclomatic 17) · ×1
  • quick_demo.run_llm_demo (cyclomatic 17) chapter1/learning-from-experience/quick_demo.py:47 — quick_demo.run_llm_demo has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · GPT5NativeAgent.process_request (cyclomatic 17) · ×1
  • GPT5NativeAgent.process_request (cyclomatic 17) chapter1/search-codegen/agent.py:233 — GPT5NativeAgent.process_request has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · PhoneAgent._run_dialogue (cyclomatic 17) · ×1
  • PhoneAgent._run_dialogue (cyclomatic 17) chapter10/autonomous-phone-registration/orchestration.py:166 — PhoneAgent._run_dialogue has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_official_experiment.judge_chapter (cyclomatic 17) · ×1
  • run_official_experiment.judge_chapter (cyclomatic 17) chapter10/book-translation/run_official_experiment.py:256 — run_official_experiment.judge_chapter has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Coordinator.run (cyclomatic 17) · ×1
  • Coordinator.run (cyclomatic 17) chapter10/parallel-web-research/agents.py:259 — Coordinator.run has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_official_experiment.main (cyclomatic 17) · ×1
  • run_official_experiment.main (cyclomatic 17) chapter10/parallel-web-research/run_official_experiment.py:219 — run_official_experiment.main has cyclomatic complexity 17 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · run_official_experiment.validate_manifest (cyclomatic 17) · ×1
  • run_official_experiment.validate_manifest (cyclomatic 17) chapter10/staged-system-prompt/run_official_experiment.py:53 — run_official_experiment.validate_manifest has cyclomatic complexity 17 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · LocalFileTools.grep (cyclomatic 17) · ×1
  • LocalFileTools.grep (cyclomatic 17) chapter2/kv-cache/agent.py:257 — LocalFileTools.grep has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · VLLMToolAgent.chat (cyclomatic 17) · ×1
  • VLLMToolAgent.chat (cyclomatic 17) chapter2/local_llm_serving/agent.py:182 — VLLMToolAgent.chat has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ContextualMemoryIndexer._generate_summary_cards (cyclomatic 17) · ×1
  • ContextualMemoryIndexer._generate_summary_cards (cyclomatic 17) chapter3/contextual-retrieval-for-user-memory/contextual_indexer.py:246 — ContextualMemoryIndexer._generate_summary_cards has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MemoryIndexer.search (cyclomatic 17) · ×1
  • MemoryIndexer.search (cyclomatic 17) chapter3/contextual-retrieval-for-user-memory/indexer.py:272 — MemoryIndexer.search has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · InteractiveSession.run (cyclomatic 17) · ×1
  • InteractiveSession.run (cyclomatic 17) chapter3/mem0/main.py:105 — InteractiveSession.run has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Reranker.rerank (cyclomatic 17) · ×1
  • Reranker.rerank (cyclomatic 17) chapter3/retrieval-pipeline/reranker.py:124 — Reranker.rerank has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · campaign.build_graph (cyclomatic 17) · ×1
  • campaign.build_graph (cyclomatic 17) chapter3/structured-index/campaign.py:236 — campaign.build_graph has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · validate_experiment_4_5.main (cyclomatic 17) · ×1
  • validate_experiment_4_5.main (cyclomatic 17) chapter4/collaboration-tools/validate_experiment_4_5.py:43 — validate_experiment_4_5.main has cyclomatic complexity 17 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · CodingAgent._run_openai_iteration (cyclomatic 17) · ×1
  • CodingAgent._run_openai_iteration (cyclomatic 17) chapter5/coding-agent/agent.py:304 — CodingAgent._run_openai_iteration has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · CodeSandboxEvaluator._recommendations_for (cyclomatic 17) · ×1
  • CodeSandboxEvaluator._recommendations_for (cyclomatic 17) chapter5/coding-agent/sandbox_evaluator.py:264 — CodeSandboxEvaluator._recommendations_for has cyclomatic complexity 17 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · GrepTool._execute_impl (cyclomatic 17) · ×1
  • GrepTool._execute_impl (cyclomatic 17) chapter5/coding-agent/tools/grep_tool.py:21 — GrepTool._execute_impl has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · MultiEditTool._execute_impl (cyclomatic 17) · ×1
  • MultiEditTool._execute_impl (cyclomatic 17) chapter5/coding-agent/tools/multi_edit_tool.py:18 — MultiEditTool._execute_impl has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · benchmark_safety_final.run_final_evaluation (cyclomatic 17) · ×1
  • benchmark_safety_final.run_final_evaluation (cyclomatic 17) REDACTED:345 — benchmark_safety_final.run_final_evaluation has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · CostEfficiencyAnalyzer.analyze_trajectory (cyclomatic 17) · ×1
  • CostEfficiencyAnalyzer.analyze_trajectory (cyclomatic 17) chapter7/agent-cost-analysis/cost_efficiency_analyzer.py:276 — CostEfficiencyAnalyzer.analyze_trajectory has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · experiment_core.choose_decision (cyclomatic 17) · ×1
  • experiment_core.choose_decision (cyclomatic 17) chapter7/android-world/experiment_core.py:141 — experiment_core.choose_decision has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · validate_evidence.main (cyclomatic 17) · ×1
  • validate_evidence.main (cyclomatic 17) chapter7/elo-leaderboard/validation/validate_evidence.py:19 — validate_evidence.main has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MultilingualReasoningEvaluator.evaluate (cyclomatic 17) · ×1
  • MultilingualReasoningEvaluator.evaluate (cyclomatic 17) chapter8/MultilingualReasoning/evaluate_multilingual.py:461 — MultilingualReasoningEvaluator.evaluate has cyclomatic complexity 17 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · WorkflowReplayer._get_element (cyclomatic 17) · ×1
  • WorkflowReplayer._get_element (cyclomatic 17) chapter9/browser-use-rpa/learning_agent/replay.py:249 — WorkflowReplayer._get_element has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · calibration.calibration_report (cyclomatic 17) · ×1
  • calibration.calibration_report (cyclomatic 17) chapter9/trajectory-verifier/calibration.py:10 — calibration.calibration_report has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · search-index-router.slugForPath (cyclomatic 17) · ×1
  • search-index-router.slugForPath (cyclomatic 17) extras/search-index-router.js:32 — search-index-router.slugForPath has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · coding-application-layout.artifactGroups (cyclomatic 17) · ×1
  • coding-application-layout.artifactGroups (cyclomatic 17) REDACTED:285 — coding-application-layout.artifactGroups has cyclomatic complexity 17 (threshold 15). Of this number, 13 points are the body's own statements and 4 belong to 2 function literals inside it that branch. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · resolution.resolve_backend (cyclomatic 16) · ×1
  • resolution.resolve_backend (cyclomatic 16) agentbook/providers/resolution.py:127 — resolution.resolve_backend has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ExperimentRunner.compare_learning_curves (cyclomatic 16) · ×1
  • ExperimentRunner.compare_learning_curves (cyclomatic 16) chapter1/learning-from-experience/experiment.py:265 — ExperimentRunner.compare_learning_curves has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · agents.get_client (cyclomatic 16) · ×1
  • agents.get_client (cyclomatic 16) chapter10/book-translation/agents.py:56 — agents.get_client has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · SkillOrchestrator._handle_tool (cyclomatic 16) · ×1
  • SkillOrchestrator._handle_tool (cyclomatic 16) chapter10/multi-role-transfer/skill_orchestrator.py:218 — SkillOrchestrator._handle_tool has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · main.interactive_mode (cyclomatic 16) · ×1
  • main.interactive_mode (cyclomatic 16) chapter2/system-hint/main.py:130 — main.interactive_mode has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · quickstart.main (cyclomatic 16) · ×1
  • quickstart.main (cyclomatic 16) chapter2/system-hint/quickstart.py:14 — quickstart.main has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · offline_demo.run_demo (cyclomatic 16) · ×1
  • offline_demo.run_demo (cyclomatic 16) chapter3/agentic-rag-for-user-memory/offline_demo.py:135 — offline_demo.run_demo has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · AgenticRAG.query (cyclomatic 16) · ×1
  • AgenticRAG.query (cyclomatic 16) chapter3/contextual-retrieval/agent.py:172 — AgenticRAG.query has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · compare_retrieval.main (cyclomatic 16) · ×1
  • compare_retrieval.main (cyclomatic 16) chapter3/contextual-retrieval/compare_retrieval.py:277 — compare_retrieval.main has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ContextualAgenticRAG._execute_tool (cyclomatic 16) · ×1
  • ContextualAgenticRAG._execute_tool (cyclomatic 16) chapter3/contextual-retrieval/contextual_agent.py:98 — ContextualAgenticRAG._execute_tool has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · BackgroundMemoryProcessor.process_recent_conversations (cyclomatic 16) · ×1
  • BackgroundMemoryProcessor.process_recent_conversations (cyclomatic 16) chapter3/user-memory/background_memory_processor.py:364 — BackgroundMemoryProcessor.process_recent_conversations has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · demo_conversation_processing.demonstrate_conversation_processing (cyclomatic 16) · ×1
  • demo_conversation_processing.demonstrate_conversation_processing (cyclomatic 16) chapter3/user-memory/demo_conversation_processing.py:19 — demo_conversation_processing.demonstrate_conversation_processing has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · quickstart.quickstart (cyclomatic 16) · ×1
  • quickstart.quickstart (cyclomatic 16) chapter3/user-memory/quickstart.py:21 — quickstart.quickstart has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_exact_experiment.run_agent_task (cyclomatic 16) · ×1
  • run_exact_experiment.run_agent_task (cyclomatic 16) chapter4/active-tool-discovery/run_exact_experiment.py:629 — run_exact_experiment.run_agent_task has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ExecutionTools.code_interpreter (cyclomatic 16) · ×1
  • ExecutionTools.code_interpreter (cyclomatic 16) chapter4/execution-tools/execution_tools.py:78 — ExecutionTools.code_interpreter has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · quickstart.test_tools (cyclomatic 16) · ×1
  • quickstart.test_tools (cyclomatic 16) chapter4/perception-tools/quickstart.py:22 — quickstart.test_tools has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · expanded_catalog._filesystem (cyclomatic 16) · ×1
  • expanded_catalog._filesystem (cyclomatic 16) chapter4/perception-tools/src/expanded_catalog.py:696 — expanded_catalog._filesystem has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · yahoo_finance_tools.get_financial_statements (cyclomatic 16) · ×1
  • yahoo_finance_tools.get_financial_statements (cyclomatic 16) chapter4/perception-tools/src/yahoo_finance_tools.py:327 — yahoo_finance_tools.get_financial_statements has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · demo.main (cyclomatic 16) · ×1
  • demo.main (cyclomatic 16) chapter5/adaptive-log-parser/demo.py:176 — demo.main has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · AgentCreator._validate_template_spec (cyclomatic 16) · ×1
  • AgentCreator._validate_template_spec (cyclomatic 16) chapter5/agent-creator/creator.py:431 — AgentCreator._validate_template_spec has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · creator.resolve_client (cyclomatic 16) · ×1
  • creator.resolve_client (cyclomatic 16) chapter5/agent-creator/creator.py:71 — creator.resolve_client has cyclomatic complexity 16 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · GrepTool._get_files_to_search (cyclomatic 16) · ×1
  • GrepTool._get_files_to_search (cyclomatic 16) chapter5/coding-agent/tools/grep_tool.py:120 — GrepTool._get_files_to_search has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ShellSession._parse_protocol_output (cyclomatic 16) · ×1
  • ShellSession._parse_protocol_output (cyclomatic 16) chapter5/coding-agent/tools/shell_session.py:183 — ShellSession._parse_protocol_output has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · PermissionRule._evaluate_condition (cyclomatic 16) · ×1
  • PermissionRule._evaluate_condition (cyclomatic 16) chapter5/permission-embedded-data-objects/pedo/core/models.py:54 — PermissionRule._evaluate_condition has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · oracle.run_secret_storage_oracle (cyclomatic 16) · ×1
  • oracle.run_secret_storage_oracle (cyclomatic 16) REDACTED:59 — oracle.run_secret_storage_oracle has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · benchmark_comparisons.test_rls_violations (cyclomatic 16) · ×1
  • benchmark_comparisons.test_rls_violations (cyclomatic 16) REDACTED:84 — benchmark_comparisons.test_rls_violations has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · evaluate_audio_quality.validate_response (cyclomatic 16) · ×1
  • evaluate_audio_quality.validate_response (cyclomatic 16) REDACTED:149 — evaluate_audio_quality.validate_response has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · pipeline.main (cyclomatic 16) · ×1
  • pipeline.main (cyclomatic 16) chapter6/rgb-sim2real-grasping/pipeline.py:146 — pipeline.main has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · qwen2_streaming.parse_response (cyclomatic 16) · ×1
  • qwen2_streaming.parse_response (cyclomatic 16) chapter6/streaming-speech/qwen2_streaming.py:36 — qwen2_streaming.parse_response has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · preflight.main (cyclomatic 16) · ×1
  • preflight.main (cyclomatic 16) REDACTED:28 — preflight.main has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · experiment.run_cell (cyclomatic 16) · ×1
  • experiment.run_cell (cyclomatic 16) chapter7/model-action-threshold/experiment.py:375 — experiment.run_cell has cyclomatic complexity 16 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · experiment.main (cyclomatic 16) · ×1
  • experiment.main (cyclomatic 16) chapter7/model-action-threshold/experiment.py:637 — experiment.main has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · experiment.validate_readiness (cyclomatic 16) · ×1
  • experiment.validate_readiness (cyclomatic 16) chapter7/user-memory-system-evaluation/experiment.py:1916 — experiment.validate_readiness has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_report_audit.validate_judgment (cyclomatic 16) · ×1
  • run_report_audit.validate_judgment (cyclomatic 16) REDACTED:254 — run_report_audit.validate_judgment has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · train_sft_trl.train_model (cyclomatic 16) · ×1
  • train_sft_trl.train_model (cyclomatic 16) chapter8/prompt-distillation/train_sft_trl.py:145 — train_sft_trl.train_model has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · analyze_campaign.sesame_analysis (cyclomatic 16) · ×1
  • analyze_campaign.sesame_analysis (cyclomatic 16) chapter8/speech-sft-experiment/analyze_campaign.py:95 — analyze_campaign.sesame_analysis has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · evaluate.evaluate_rules (cyclomatic 16) · ×1
  • evaluate.evaluate_rules (cyclomatic 16) chapter9/ai-style-skill/evaluate.py:32 — evaluate.evaluate_rules has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · SafetyPolicyGate.inspect_resource_limits (cyclomatic 16) · ×1
  • SafetyPolicyGate.inspect_resource_limits (cyclomatic 16) chapter9/harness-safety-gate/safety_policy_gate.py:262 — SafetyPolicyGate.inspect_resource_limits has cyclomatic complexity 16 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · run_experiment_9_9.main (cyclomatic 16) · ×1
  • run_experiment_9_9.main (cyclomatic 16) chapter9/self-evolution-eval/run_experiment_9_9.py:79 — run_experiment_9_9.main has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · candidate_sandbox.run_in_sandbox (cyclomatic 16) · ×1
  • candidate_sandbox.run_in_sandbox (cyclomatic 16) chapter9/self-modifying-agent/candidate_sandbox.py:121 — candidate_sandbox.run_in_sandbox has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · build_evidence.arm_stats (cyclomatic 16) · ×1
  • build_evidence.arm_stats (cyclomatic 16) chapter9/tau2-escalation-experience/build_evidence.py:23 — build_evidence.arm_stats has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_experiment_9_1.build_evidence (cyclomatic 16) · ×1
  • run_experiment_9_1.build_evidence (cyclomatic 16) chapter9/trajectory-verifier/run_experiment_9_1.py:37 — run_experiment_9_1.build_evidence has cyclomatic complexity 16 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · flatten_epub_toc.flatten_nav (cyclomatic 16) · ×1
  • flatten_epub_toc.flatten_nav (cyclomatic 16) REDACTED:32 — flatten_epub_toc.flatten_nav has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · AttentionStats.AttentionStats (cyclomatic 16) · ×1
  • AttentionStats.AttentionStats (cyclomatic 16) chapter2/attention_visualization/frontend/components/AttentionStats.tsx:13 — AttentionStats.AttentionStats has cyclomatic complexity 16 (threshold 15). Most of this is not in the body itself: 5 of the 16 points are its own statements and the rest belongs to 5 function items inside it that branch (a function literal at line 52, a function literal at line 105, calculateStats, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
D1 · Cyclomatic Complexity · EchoProcessor.process (cyclomatic 16) · ×1
  • EchoProcessor.process (cyclomatic 16) chapter6/live-audio/frontend/public/audioWorklet.js:103 — EchoProcessor.process has cyclomatic complexity 16 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · auto-translate.hookLifecycle (cyclomatic 16) · ×1
  • auto-translate.hookLifecycle (cyclomatic 16) extras/auto-translate.js:184 — auto-translate.hookLifecycle has cyclomatic complexity 16 (threshold 15). Most of this is not in the body itself: 6 of the 16 points are its own statements and the rest belongs to 3 function literals inside it that branch (lines 200, 212, 226). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
D1 · Cyclomatic Complexity · evolution-flow-figures.layoutEvolutionDeployment (cyclomatic 16) · ×1
  • evolution-flow-figures.layoutEvolutionDeployment (cyclomatic 16) web-astro/scripts/evolution-flow-figures.mjs:326 — evolution-flow-figures.layoutEvolutionDeployment has cyclomatic complexity 16 (threshold 15). Most of this is not in the body itself: 1 of the 16 points is its own statement and the rest belongs to 2 function literals inside it that branch (lines 337, 429). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
D1 · Cyclomatic Complexity · figure-viewer.initFigureViewer (cyclomatic 16) · ×1
  • figure-viewer.initFigureViewer (cyclomatic 16) web-astro/src/scripts/figure-viewer.ts:1 — figure-viewer.initFigureViewer has cyclomatic complexity 16 (threshold 15). Most of this is not in the body itself: 2 of the 16 points are its own statements and the rest belongs to 5 function items inside it that branch (applyZoom, fit, a function literal at line 75, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
D2 · Cognitive Complexity · UserMemoryAgent.execute_task (cognitive 191) · ×1
  • UserMemoryAgent.execute_task (cognitive 191) chapter3/user-memory/agent.py:614 — UserMemoryAgent.execute_task has cognitive complexity 191 (threshold 15). Drivers by points: if/else 35 (145 pts), loops 5 (18 pts), boolean chains 14, ternaries 3 (8 pts), error handling 2 (6 pts) (nesting depth added 132). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · creator.run_experiment (cognitive 158) · ×1
  • creator.run_experiment (cognitive 158) chapter5/agent-creator/creator.py:1530 — creator.run_experiment has cognitive complexity 158 (threshold 15). Drivers by points: if/else 22 (53 pts), ternaries 19 (44 pts), boolean chains 43, error handling 3 (9 pts), loops 4 (9 pts) (nesting depth added 67). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · main.run_evaluation_mode (cognitive 142) · ×1
  • main.run_evaluation_mode (cognitive 142) chapter3/user-memory/main.py:373 — main.run_evaluation_mode has cognitive complexity 142 (threshold 15). Drivers by points: if/else 34 (97 pts), loops 8 (18 pts), ternaries 5 (18 pts), error handling 2 (5 pts), boolean chains 4 (nesting depth added 89). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_controlled_experiment.main (cognitive 135) · ×1
  • run_controlled_experiment.main (cognitive 135) chapter7/android-world/run_controlled_experiment.py:1392 — run_controlled_experiment.main has cognitive complexity 135 (threshold 15). Drivers by points: if/else 44 (99 pts), boolean chains 17, loops 5 (12 pts), ternaries 4, error handling 2 (3 pts) (nesting depth added 63). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · VLLMToolAgent.chat_stream (cognitive 118) · ×1
  • VLLMToolAgent.chat_stream (cognitive 118) chapter2/local_llm_serving/agent.py:340 — VLLMToolAgent.chat_stream has cognitive complexity 118 (threshold 15). Drivers by points: if/else 22 (81 pts), loops 7 (24 pts), boolean chains 6, error handling 1 (4 pts), ternaries 2 (3 pts) (nesting depth added 80). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · analysis.completion_audit (cognitive 118) · ×1
  • analysis.completion_audit (cognitive 118) chapter7/model-benchmark/analysis.py:331 — analysis.completion_audit has cognitive complexity 118 (threshold 15). Drivers by points: if/else 35 (64 pts), boolean chains 32, loops 13 (22 pts) (nesting depth added 38). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OllamaNativeAgent.chat_stream (cognitive 114) · ×1
  • OllamaNativeAgent.chat_stream (cognitive 114) chapter2/local_llm_serving/ollama_native.py:213 — OllamaNativeAgent.chat_stream has cognitive complexity 114 (threshold 15). Drivers by points: if/else 20 (69 pts), loops 8 (35 pts), error handling 2 (8 pts), boolean chains 1, ternaries 1 (nesting depth added 82). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · validate_evidence.validate (cognitive 111) · ×1
  • validate_evidence.validate (cognitive 111) chapter8/MiniMind-pretrain/validation/validate_evidence.py:114 — validate_evidence.validate has cognitive complexity 111 (threshold 15). Drivers by points: if/else 49 (72 pts), boolean chains 24, loops 9 (11 pts), error handling 2 (4 pts) (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KVCacheAgent.execute_task (cognitive 107) · ×1
  • KVCacheAgent.execute_task (cognitive 107) chapter2/kv-cache/agent.py:622 — KVCacheAgent.execute_task has cognitive complexity 107 (threshold 15). Drivers by points: if/else 26 (79 pts), ternaries 3 (14 pts), error handling 2 (6 pts), boolean chains 4, loops 2 (4 pts) (nesting depth added 70). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · BackgroundMemoryProcessor.apply_memory_updates (cognitive 101) · ×1
  • BackgroundMemoryProcessor.apply_memory_updates (cognitive 101) chapter3/user-memory/background_memory_processor.py:163 — BackgroundMemoryProcessor.apply_memory_updates has cognitive complexity 101 (threshold 15). Drivers by points: if/else 30 (74 pts), error handling 5 (18 pts), boolean chains 4, ternaries 1 (4 pts), loops 1 (nesting depth added 60). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · experiment.analyze (cognitive 100) · ×1
  • experiment.analyze (cognitive 100) chapter7/openvla-robotwin2-eval/experiment.py:527 — experiment.analyze has cognitive complexity 100 (threshold 15). Drivers by points: if/else 32 (65 pts), ternaries 9 (15 pts), loops 8 (11 pts), boolean chains 9 (nesting depth added 42). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · EventTriggeredAgent.handle_event (cognitive 99) · ×1
  • EventTriggeredAgent.handle_event (cognitive 99) REDACTED:1059 — EventTriggeredAgent.handle_event has cognitive complexity 99 (threshold 15). Drivers by points: if/else 28 (73 pts), ternaries 4 (12 pts), error handling 2 (6 pts), boolean chains 4, loops 2 (4 pts) (nesting depth added 59). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · main.interactive_mode (cognitive 97) · ×1
  • main.interactive_mode (cognitive 97) chapter1/context/main.py:907 — main.interactive_mode has cognitive complexity 97 (threshold 15). Drivers by points: if/else 20 (53 pts), ternaries 4 (17 pts), error handling 5 (14 pts), loops 4 (10 pts), boolean chains 3 (nesting depth added 61). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · review.main (cognitive 97) · ×1
  • review.main (cognitive 97) slides/review.mjs:96 — review.main has cognitive complexity 97 (threshold 15). Drivers by points: if/else 28 (61 pts), boolean chains 13, ternaries 5 (12 pts), loops 6 (11 pts) (nesting depth added 45). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SystemHintAgent.execute_task (cognitive 96) · ×1
  • SystemHintAgent.execute_task (cognitive 96) REDACTED:825 — SystemHintAgent.execute_task has cognitive complexity 96 (threshold 15). Drivers by points: if/else 24 (69 pts), ternaries 4 (12 pts), error handling 2 (6 pts), boolean chains 5, loops 2 (4 pts) (nesting depth added 59). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · processTTSQueue (cognitive 94) · ×1
  • processTTSQueue (cognitive 94) chapter6/live-audio/backend/server.js:715 — processTTSQueue has cognitive complexity 94 (threshold 15). Drivers by points: if/else 22 (57 pts), loops 5 (19 pts), boolean chains 8, ternaries 2 (6 pts), error handling 2 (4 pts) (nesting depth added 55). Of this number, 17 points are the body's own statements and 77 belong to 9 function literals inside it that branch. To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · validate_simulator_run.validate (cognitive 91) · ×1
  • validate_simulator_run.validate (cognitive 91) chapter10/voice-werewolf/validate_simulator_run.py:15 — validate_simulator_run.validate has cognitive complexity 91 (threshold 15). Drivers by points: if/else 32 (68 pts), boolean chains 14, loops 3 (4 pts), error handling 1 (3 pts), ternaries 2 (nesting depth added 39). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · demo.run_game (cognitive 83) · ×1
  • demo.run_game (cognitive 83) chapter10/voice-werewolf/demo.py:225 — demo.run_game has cognitive complexity 83 (threshold 15). Drivers by points: ternaries 43, boolean chains 19, if/else 19, error handling 1 (2 pts) (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · site_i18n.build_catalog (cognitive 76) · ×1
  • site_i18n.build_catalog (cognitive 76) scripts/site_i18n.py:168 — site_i18n.build_catalog has cognitive complexity 76 (threshold 15). Drivers by points: if/else 25 (54 pts), loops 8 (18 pts), boolean chains 2, error handling 1 (2 pts) (nesting depth added 40). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AgentCreator._generate_scratch_files (cognitive 75) · ×1
  • AgentCreator._generate_scratch_files (cognitive 75) chapter5/agent-creator/creator.py:815 — AgentCreator._generate_scratch_files has cognitive complexity 75 (threshold 15). Drivers by points: if/else 21 (38 pts), loops 7 (15 pts), boolean chains 11, error handling 4 (11 pts) (nesting depth added 32). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · demo.main (cognitive 75) · ×1
  • demo.main (cognitive 75) chapter5/code-for-math/demo.py:543 — demo.main has cognitive complexity 75 (threshold 15). Drivers by points: ternaries 15 (31 pts), if/else 16 (27 pts), error handling 2 (8 pts), boolean chains 7, loops 2 (nesting depth added 33). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DuplexInterruptionManager.calculate_energy (cognitive 74) · ×1
  • DuplexInterruptionManager.calculate_energy (cognitive 74) chapter6/streaming-speech/interruption_manager.py:101 — DuplexInterruptionManager.calculate_energy has cognitive complexity 74 (threshold 15). Drivers by points: if/else 27 (53 pts), ternaries 4 (14 pts), boolean chains 7 (nesting depth added 36). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · merge_candidate_shards.main (cognitive 70) · ×1
  • merge_candidate_shards.main (cognitive 70) chapter7/android-world/merge_candidate_shards.py:56 — merge_candidate_shards.main has cognitive complexity 70 (threshold 15). Drivers by points: if/else 32 (54 pts), loops 6 (11 pts), boolean chains 4, ternaries 1 (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · main.interactive_chat (cognitive 68) · ×1
  • main.interactive_chat (cognitive 68) chapter4/multimodal-agent/main.py:95 — main.interactive_chat has cognitive complexity 68 (threshold 15). Drivers by points: if/else 16 (45 pts), ternaries 3 (10 pts), loops 3 (7 pts), error handling 3 (6 pts) (nesting depth added 43). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · validate_vlm_evidence.validate_receipts (cognitive 67) · ×1
  • validate_vlm_evidence.validate_receipts (cognitive 67) chapter8/MiniMind-pretrain/validation/validate_vlm_evidence.py:99 — validate_vlm_evidence.validate_receipts has cognitive complexity 67 (threshold 15). Drivers by points: if/else 25 (46 pts), boolean chains 16, error handling 2 (4 pts), loops 1 (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ReActAttentionAgent.execute_react_loop (cognitive 66) · ×1
  • ReActAttentionAgent.execute_react_loop (cognitive 66) chapter2/attention_visualization/main.py:305 — ReActAttentionAgent.execute_react_loop has cognitive complexity 66 (threshold 15). Drivers by points: if/else 17 (43 pts), ternaries 4 (14 pts), loops 3 (7 pts), boolean chains 2 (nesting depth added 40). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ResearchAgent._stream_response (cognitive 66) · ×1
  • ResearchAgent._stream_response (cognitive 66) chapter2/context-compression/agent.py:353 — ResearchAgent._stream_response has cognitive complexity 66 (threshold 15). Drivers by points: if/else 11 (43 pts), loops 3 (11 pts), ternaries 4 (7 pts), boolean chains 4, error handling 1 (nesting depth added 43). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · ContextualUserMemoryAgent.answer_question (cognitive 66) · ×1
  • ContextualUserMemoryAgent.answer_question (cognitive 66) chapter3/contextual-retrieval-for-user-memory/contextual_agent.py:268 — ContextualUserMemoryAgent.answer_question has cognitive complexity 66 (threshold 15). Drivers by points: if/else 14 (38 pts), loops 5 (16 pts), error handling 2 (6 pts), boolean chains 3, ternaries 1 (3 pts) (nesting depth added 41). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · campaign.main (cognitive 66) · ×1
  • campaign.main (cognitive 66) chapter3/structured-knowledge-extraction/campaign.py:524 — campaign.main has cognitive complexity 66 (threshold 15). Drivers by points: boolean chains 19, if/else 16 (18 pts), loops 9 (12 pts), error handling 5 (11 pts), ternaries 5 (6 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · main.interactive_mode (cognitive 66) · ×1
  • main.interactive_mode (cognitive 66) chapter3/user-memory/main.py:92 — main.interactive_mode has cognitive complexity 66 (threshold 15). Drivers by points: if/else 18 (39 pts), ternaries 5 (16 pts), loops 2 (6 pts), error handling 2 (4 pts), boolean chains 1 (nesting depth added 38). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · verify_acceptance.check_arm (cognitive 66) · ×1
  • verify_acceptance.check_arm (cognitive 66) chapter6/phone-agent/verify_acceptance.py:145 — verify_acceptance.check_arm has cognitive complexity 66 (threshold 15). Drivers by points: if/else 27 (32 pts), boolean chains 28, loops 5, ternaries 1 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · main.interactive_mode (cognitive 65) · ×1
  • main.interactive_mode (cognitive 65) REDACTED:340 — main.interactive_mode has cognitive complexity 65 (threshold 15). Drivers by points: if/else 13 (41 pts), loops 5 (11 pts), error handling 3 (7 pts), ternaries 2 (4 pts), boolean chains 2 (nesting depth added 40). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · benchmark_application.run_pedo_workflow (cognitive 64) · ×1
  • benchmark_application.run_pedo_workflow (cognitive 64) REDACTED:239 — benchmark_application.run_pedo_workflow has cognitive complexity 64 (threshold 15). Drivers by points: if/else 10 (34 pts), loops 5 (17 pts), error handling 3 (6 pts), boolean chains 5, ternaries 1 (2 pts) (nesting depth added 40). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · validate_evidence.validate (cognitive 64) · ×1
  • validate_evidence.validate (cognitive 64) chapter8/continued-pretraining/validation/validate_evidence.py:73 — validate_evidence.validate has cognitive complexity 64 (threshold 15). Drivers by points: if/else 29 (43 pts), boolean chains 12, loops 6 (7 pts), error handling 1 (2 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · benchmark_application.run_raw_workflow (cognitive 63) · ×1
  • benchmark_application.run_raw_workflow (cognitive 63) REDACTED:334 — benchmark_application.run_raw_workflow has cognitive complexity 63 (threshold 15). Drivers by points: if/else 10 (34 pts), loops 5 (17 pts), error handling 3 (6 pts), boolean chains 4, ternaries 1 (2 pts) (nesting depth added 40). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · HybridStructuredRetriever.index_graphrag_data (cognitive 62) · ×1
  • HybridStructuredRetriever.index_graphrag_data (cognitive 62) chapter3/structured-index/hybrid_retriever.py:219 — HybridStructuredRetriever.index_graphrag_data has cognitive complexity 62 (threshold 15). Drivers by points: if/else 16 (40 pts), ternaries 4 (16 pts), loops 3 (6 pts) (nesting depth added 39). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · validator._structural_check (cognitive 62) · ×1
  • validator._structural_check (cognitive 62) chapter5/agent-creator/validator.py:81 — validator._structural_check has cognitive complexity 62 (threshold 15). Drivers by points: if/else 20 (39 pts), boolean chains 10, loops 5 (8 pts), error handling 2 (5 pts) (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExperimentRunner.run_611 (cognitive 62) · ×1
  • ExperimentRunner.run_611 (cognitive 62) chapter7/user-memory-system-evaluation/experiment.py:1119 — ExperimentRunner.run_611 has cognitive complexity 62 (threshold 15). Drivers by points: loops 10 (36 pts), error handling 4 (14 pts), if/else 3 (12 pts) (nesting depth added 45). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · index.Home (cognitive 59) · ×1
  • index.Home (cognitive 59) chapter6/live-audio/frontend/pages/index.tsx:65 — index.Home has cognitive complexity 59 (threshold 15). Drivers by points: if/else 22 (23 pts), ternaries 14 (18 pts), boolean chains 14, error handling 4 (nesting depth added 5). Most of this is not in the body itself: 6 of the 59 points are its own statements and the rest belongs to 16 function items inside it that branch (startRecording, setupWebSocket, stopRecording, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
D2 · Cognitive Complexity · demo.main (cognitive 58) · ×1
  • demo.main (cognitive 58) chapter10/autonomous-phone-registration/demo.py:126 — demo.main has cognitive complexity 58 (threshold 15). Drivers by points: ternaries 23 (24 pts), boolean chains 21, if/else 11, error handling 1 (2 pts) (nesting depth added 2). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · run_experiment_2_8.run_one (cognitive 57) · ×1
  • run_experiment_2_8.run_one (cognitive 57) chapter2/system-hint/run_experiment_2_8.py:468 — run_experiment_2_8.run_one has cognitive complexity 57 (threshold 15). Drivers by points: if/else 19 (32 pts), boolean chains 11, loops 6 (9 pts), error handling 2 (5 pts) (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · book-markdown.bookMarkdown.<returned closure> · ×1
  • book-markdown.bookMarkdown.<returned closure>::walk (cognitive 57) REDACTED:15 — book-markdown.bookMarkdown.<returned closure>::walk has cognitive complexity 57 (threshold 15). Drivers by points: if/else 24 (30 pts), boolean chains 25, ternaries 1 (2 pts) (nesting depth added 7). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · bookMarkdown · ×1
  • bookMarkdown::(anonymous)::walk (cognitive 57) REDACTED:15 — bookMarkdown::(anonymous)::walk has cognitive complexity 57 (threshold 15). Drivers by points: if/else 24 (30 pts), boolean chains 23, other 2, ternaries 1 (2 pts) (nesting depth added 7). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · CodingAgentCLI.run_agent (cognitive 56) · ×1
  • CodingAgentCLI.run_agent (cognitive 56) chapter5/coding-agent/main.py:206 — CodingAgentCLI.run_agent has cognitive complexity 56 (threshold 15). Drivers by points: if/else 14 (46 pts), loops 2 (7 pts), error handling 2, boolean chains 1 (nesting depth added 37). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · benchmark_harness_focused.run_focused_harness_eval (cognitive 56) · ×1
  • benchmark_harness_focused.run_focused_harness_eval (cognitive 56) REDACTED:129 — benchmark_harness_focused.run_focused_harness_eval has cognitive complexity 56 (threshold 15). Drivers by points: if/else 9 (21 pts), error handling 4 (14 pts), ternaries 4 (11 pts), loops 5 (7 pts), boolean chains 3 (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · benchmark_safety.print_results (cognitive 56) · ×1
  • benchmark_safety.print_results (cognitive 56) REDACTED:645 — benchmark_safety.print_results has cognitive complexity 56 (threshold 15). Drivers by points: if/else 13 (31 pts), loops 10 (18 pts), ternaries 3 (6 pts), boolean chains 1 (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PEDOSecurityEvaluator.evaluate_field_visibility (cognitive 56) · ×1
  • PEDOSecurityEvaluator.evaluate_field_visibility (cognitive 56) chapter5/permission-embedded-data-objects/run_live_security_eval.py:561 — PEDOSecurityEvaluator.evaluate_field_visibility has cognitive complexity 56 (threshold 15). Drivers by points: if/else 23 (47 pts), boolean chains 6, error handling 1 (3 pts) (nesting depth added 26). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · evidence.validate_manifest (cognitive 55) · ×1
  • evidence.validate_manifest (cognitive 55) chapter1/image-gen-workflow/evidence.py:83 — evidence.validate_manifest has cognitive complexity 55 (threshold 15). Drivers by points: if/else 12 (33 pts), loops 7 (17 pts), ternaries 1 (3 pts), boolean chains 2 (nesting depth added 33). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_comparison.main (cognitive 55) · ×1
  • run_comparison.main (cognitive 55) chapter10/multi-role-transfer/run_comparison.py:456 — run_comparison.main has cognitive complexity 55 (threshold 15). Drivers by points: if/else 15 (28 pts), loops 6 (13 pts), boolean chains 7, ternaries 3 (7 pts) (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AgenticRAG.query (cognitive 55) · ×1
  • AgenticRAG.query (cognitive 55) chapter3/agentic-rag/agent.py:231 — AgenticRAG.query has cognitive complexity 55 (threshold 15). Drivers by points: if/else 16 (36 pts), loops 3 (10 pts), error handling 2 (6 pts), boolean chains 3 (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ContextAwareAgent.execute_task (cognitive 54) · ×1
  • ContextAwareAgent.execute_task (cognitive 54) REDACTED:701 — ContextAwareAgent.execute_task has cognitive complexity 54 (threshold 15). Drivers by points: if/else 12 (24 pts), ternaries 5 (12 pts), error handling 4 (9 pts), boolean chains 6, loops 2 (3 pts) (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GrepTool._search_content (cognitive 52) · ×1
  • GrepTool._search_content (cognitive 52) chapter5/coding-agent/tools/grep_tool.py:262 — GrepTool._search_content has cognitive complexity 52 (threshold 15). Drivers by points: if/else 12 (26 pts), loops 5 (11 pts), ternaries 3 (10 pts), boolean chains 3, error handling 1 (2 pts) (nesting depth added 28). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InteractiveContextualRAG.evaluate_specific_test_case (cognitive 51) · ×1
  • InteractiveContextualRAG.evaluate_specific_test_case (cognitive 51) chapter3/contextual-retrieval-for-user-memory/main.py:454 — InteractiveContextualRAG.evaluate_specific_test_case has cognitive complexity 51 (threshold 15). Drivers by points: if/else 13 (20 pts), ternaries 9 (19 pts), loops 5 (9 pts), boolean chains 2, error handling 1 (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · analysis.availability_summary (cognitive 51) · ×1
  • analysis.availability_summary (cognitive 51) chapter7/model-benchmark/analysis.py:124 — analysis.availability_summary has cognitive complexity 51 (threshold 15). Drivers by points: if/else 11 (32 pts), ternaries 5 (10 pts), boolean chains 6, loops 2 (3 pts) (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · check_i18n_consistency.main (cognitive 51) · ×1
  • check_i18n_consistency.main (cognitive 51) scripts/check_i18n_consistency.py:96 — check_i18n_consistency.main has cognitive complexity 51 (threshold 15). Drivers by points: if/else 21 (37 pts), loops 10 (14 pts) (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ContextualMemoryEvaluator.evaluate_test_case (cognitive 50) · ×1
  • ContextualMemoryEvaluator.evaluate_test_case (cognitive 50) chapter3/contextual-retrieval-for-user-memory/contextual_evaluator.py:269 — ContextualMemoryEvaluator.evaluate_test_case has cognitive complexity 50 (threshold 15). Drivers by points: ternaries 10 (23 pts), loops 7 (13 pts), if/else 7 (8 pts), boolean chains 3, error handling 2 (3 pts) (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MultimodalAgent._stream_gemini_response (cognitive 50) · ×1
  • MultimodalAgent._stream_gemini_response (cognitive 50) chapter4/multimodal-agent/agent.py:887 — MultimodalAgent._stream_gemini_response has cognitive complexity 50 (threshold 15). Drivers by points: if/else 14 (41 pts), loops 3 (5 pts), boolean chains 4 (nesting depth added 29). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · validate_official_run.validate (cognitive 49) · ×1
  • validate_official_run.validate (cognitive 49) chapter2/agent-skills-ppt/validate_official_run.py:130 — validate_official_run.validate has cognitive complexity 49 (threshold 15). Drivers by points: if/else 13 (18 pts), boolean chains 16, ternaries 9 (11 pts), loops 3 (4 pts) (nesting depth added 8). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · evaluate_audio_quality.judge_once (cognitive 49) · ×1
  • evaluate_audio_quality.judge_once (cognitive 49) REDACTED:200 — evaluate_audio_quality.judge_once has cognitive complexity 49 (threshold 15). Drivers by points: if/else 14 (22 pts), boolean chains 14, ternaries 4 (7 pts), loops 4 (6 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · validate_campaign.main (cognitive 48) · ×1
  • validate_campaign.main (cognitive 48) chapter10/generative-agents/validate_campaign.py:93 — validate_campaign.main has cognitive complexity 48 (threshold 15). Drivers by points: if/else 12 (25 pts), boolean chains 18, loops 3 (4 pts), ternaries 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_experiment_4_2.substantive_observation (cognitive 48) · ×1
  • run_experiment_4_2.substantive_observation (cognitive 48) chapter4/perception-tools/run_experiment_4_2.py:326 — run_experiment_4_2.substantive_observation has cognitive complexity 48 (threshold 15). Drivers by points: if/else 23 (24 pts), boolean chains 22, ternaries 1 (2 pts) (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · GrepTool._get_files_to_search (cognitive 48) · ×1
  • GrepTool._get_files_to_search (cognitive 48) chapter5/coding-agent/tools/grep_tool.py:120 — GrepTool._get_files_to_search has cognitive complexity 48 (threshold 15). Drivers by points: if/else 12 (37 pts), error handling 1 (5 pts), loops 2 (5 pts), boolean chains 1 (nesting depth added 32). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StrengthenedOracle.check_violations (cognitive 48) · ×1
  • StrengthenedOracle.check_violations (cognitive 48) REDACTED:101 — StrengthenedOracle.check_violations has cognitive complexity 48 (threshold 15). Drivers by points: if/else 13 (35 pts), loops 5, boolean chains 4, ternaries 1 (4 pts) (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · evaluate_from_cache.evaluate_from_parquet (cognitive 48) · ×1
  • evaluate_from_cache.evaluate_from_parquet (cognitive 48) chapter8/Intuitor/evaluate_from_cache.py:198 — evaluate_from_cache.evaluate_from_parquet has cognitive complexity 48 (threshold 15). Drivers by points: if/else 12 (21 pts), ternaries 8 (19 pts), boolean chains 3, loops 2 (3 pts), error handling 1 (2 pts) (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TreasureHuntGame._try_crafting (cognitive 47) · ×1
  • TreasureHuntGame._try_crafting (cognitive 47) chapter1/learning-from-experience/game_environment.py:423 — TreasureHuntGame._try_crafting has cognitive complexity 47 (threshold 15). Drivers by points: if/else 9 (26 pts), loops 5 (21 pts) (nesting depth added 33). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · run_experiment_4_5.run (cognitive 47) · ×1
  • run_experiment_4_5.run (cognitive 47) chapter4/collaboration-tools/run_experiment_4_5.py:218 — run_experiment_4_5.run has cognitive complexity 47 (threshold 15). Drivers by points: if/else 15 (23 pts), ternaries 10 (12 pts), boolean chains 8, error handling 1 (3 pts), loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · search_tools.search_web (cognitive 47) · ×1
  • search_tools.search_web (cognitive 47) chapter4/perception-tools/src/search_tools.py:45 — search_tools.search_web has cognitive complexity 47 (threshold 15). Drivers by points: if/else 11 (19 pts), error handling 6 (12 pts), loops 4 (9 pts), ternaries 2 (5 pts), boolean chains 2 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · benchmark_safety_v2.print_safety_v2_results (cognitive 47) · ×1
  • benchmark_safety_v2.print_safety_v2_results (cognitive 47) REDACTED:379 — benchmark_safety_v2.print_safety_v2_results has cognitive complexity 47 (threshold 15). Drivers by points: loops 11 (23 pts), if/else 7 (17 pts), ternaries 3 (7 pts) (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · NotebookEditTool._execute_impl (cognitive 46) · ×1
  • NotebookEditTool._execute_impl (cognitive 46) chapter5/coding-agent/tools/notebook_edit_tool.py:18 — NotebookEditTool._execute_impl has cognitive complexity 46 (threshold 15). Drivers by points: if/else 16 (35 pts), loops 3 (9 pts), error handling 2 (nesting depth added 25). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · markup.parse (cognitive 46) · ×1
  • markup.parse (cognitive 46) chapter6/controllable-tts/markup.py:56 — markup.parse has cognitive complexity 46 (threshold 15). Drivers by points: if/else 17 (33 pts), ternaries 2 (8 pts), error handling 1 (4 pts), loops 1 (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · fix_svg_text_layout.reflow_wrapped_shapes (cognitive 45) · ×1
  • fix_svg_text_layout.reflow_wrapped_shapes (cognitive 45) REDACTED:434 — fix_svg_text_layout.reflow_wrapped_shapes has cognitive complexity 45 (threshold 15). Drivers by points: if/else 8 (21 pts), loops 8 (20 pts), ternaries 1 (4 pts) (nesting depth added 28). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GPT5NativeAgent._citations (cognitive 45) · ×1
  • GPT5NativeAgent._citations (cognitive 45) chapter1/search-codegen/agent.py:148 — GPT5NativeAgent._citations has cognitive complexity 45 (threshold 15). Drivers by points: if/else 7 (20 pts), loops 4 (10 pts), ternaries 2 (10 pts), boolean chains 5 (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ResearchAgent.execute_research (cognitive 45) · ×1
  • ResearchAgent.execute_research (cognitive 45) chapter2/context-compression/agent.py:511 — ResearchAgent.execute_research has cognitive complexity 45 (threshold 15). Drivers by points: if/else 13 (33 pts), error handling 2 (6 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LLMAgent.choose_action (cognitive 44) · ×1
  • LLMAgent.choose_action (cognitive 44) chapter1/learning-from-experience/llm_agent.py:215 — LLMAgent.choose_action has cognitive complexity 44 (threshold 15). Drivers by points: if/else 15 (30 pts), loops 5 (10 pts), boolean chains 3, error handling 1 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · main.main (cognitive 44) · ×1
  • main.main (cognitive 44) REDACTED:516 — main.main has cognitive complexity 44 (threshold 15). Drivers by points: if/else 12 (21 pts), ternaries 4 (11 pts), error handling 5 (9 pts), loops 1 (3 pts) (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · UserMemoryEvaluationFramework._load_single_test_case (cognitive 44) · ×1
  • UserMemoryEvaluationFramework._load_single_test_case (cognitive 44) chapter3/user-memory-evaluation/framework.py:66 — UserMemoryEvaluationFramework._load_single_test_case has cognitive complexity 44 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 6 (16 pts), ternaries 1 (6 pts), boolean chains 4 (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · benchmark_safety_final.run_final_evaluation (cognitive 44) · ×1
  • benchmark_safety_final.run_final_evaluation (cognitive 44) REDACTED:345 — benchmark_safety_final.run_final_evaluation has cognitive complexity 44 (threshold 15). Drivers by points: if/else 9 (32 pts), error handling 2 (6 pts), loops 2 (3 pts), ternaries 1 (3 pts) (nesting depth added 30). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PEDOSecurityEvaluator.evaluate_row_level_security (cognitive 44) · ×1
  • PEDOSecurityEvaluator.evaluate_row_level_security (cognitive 44) chapter5/permission-embedded-data-objects/run_live_security_eval.py:438 — PEDOSecurityEvaluator.evaluate_row_level_security has cognitive complexity 44 (threshold 15). Drivers by points: if/else 10 (17 pts), ternaries 6 (10 pts), boolean chains 9, error handling 2 (8 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · demo.main (cognitive 44) · ×1
  • demo.main (cognitive 44) chapter7/tts-quality-eval/demo.py:214 — demo.main has cognitive complexity 44 (threshold 15). Drivers by points: if/else 17 (24 pts), ternaries 5 (8 pts), boolean chains 7, loops 3 (5 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SafetyPolicyGate.inspect_path_traversal (cognitive 44) · ×1
  • SafetyPolicyGate.inspect_path_traversal (cognitive 44) chapter9/harness-safety-gate/safety_policy_gate.py:194 — SafetyPolicyGate.inspect_path_traversal has cognitive complexity 44 (threshold 15). Drivers by points: if/else 8 (23 pts), loops 7 (16 pts), error handling 1 (3 pts), boolean chains 2 (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · streaming._absorb (cognitive 43) · ×1
  • streaming._absorb (cognitive 43) chapter5/provider-failover/streaming.py:116 — streaming._absorb has cognitive complexity 43 (threshold 15). Drivers by points: if/else 9 (21 pts), boolean chains 19, loops 2 (3 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MultiRoleOrchestrator._run_one_llm_turn (cognitive 42) · ×1
  • MultiRoleOrchestrator._run_one_llm_turn (cognitive 42) chapter10/multi-role-transfer/orchestrator.py:108 — MultiRoleOrchestrator._run_one_llm_turn has cognitive complexity 42 (threshold 15). Drivers by points: if/else 15 (27 pts), error handling 3 (7 pts), boolean chains 6, loops 1, ternaries 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LogSanitizationAgent.detect_pii (cognitive 42) · ×1
  • LogSanitizationAgent.detect_pii (cognitive 42) chapter3/log-sanitization/agent.py:139 — LogSanitizationAgent.detect_pii has cognitive complexity 42 (threshold 15). Drivers by points: if/else 11 (27 pts), loops 3 (6 pts), boolean chains 4, ternaries 3, error handling 2 (nesting depth added 19). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · run_exact_experiment.derive_acceptance (cognitive 42) · ×1
  • run_exact_experiment.derive_acceptance (cognitive 42) chapter4/active-tool-discovery/run_exact_experiment.py:897 — run_exact_experiment.derive_acceptance has cognitive complexity 42 (threshold 15). Drivers by points: boolean chains 21, if/else 9 (17 pts), loops 2 (3 pts), ternaries 1 (nesting depth added 9). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · TrajectoryConsistencyChecker.check_trajectory (cognitive 42) · ×1
  • TrajectoryConsistencyChecker.check_trajectory (cognitive 42) chapter9/trajectory-verifier/consistency_checker.py:153 — TrajectoryConsistencyChecker.check_trajectory has cognitive complexity 42 (threshold 15). Drivers by points: if/else 15 (31 pts), boolean chains 4, ternaries 4, loops 2 (3 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · evaluate_audio_run.evaluate (cognitive 41) · ×1
  • evaluate_audio_run.evaluate (cognitive 41) chapter10/voice-werewolf/evaluate_audio_run.py:47 — evaluate_audio_run.evaluate has cognitive complexity 41 (threshold 15). Drivers by points: if/else 13 (28 pts), boolean chains 7, loops 2 (3 pts), ternaries 2 (3 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · example_with_system_hints.demo_system_hints (cognitive 41) · ×1
  • example_with_system_hints.demo_system_hints (cognitive 41) chapter5/coding-agent/example_with_system_hints.py:10 — example_with_system_hints.demo_system_hints has cognitive complexity 41 (threshold 15). Drivers by points: if/else 10 (32 pts), loops 3 (9 pts) (nesting depth added 28). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · KVCacheAgent._format_messages (cognitive 40) · ×1
  • KVCacheAgent._format_messages (cognitive 40) chapter2/kv-cache/agent.py:513 — KVCacheAgent._format_messages has cognitive complexity 40 (threshold 15). Drivers by points: if/else 10 (27 pts), loops 3 (12 pts), boolean chains 1 (nesting depth added 26). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · CodingAgent.run (cognitive 40) · ×1
  • CodingAgent.run (cognitive 40) chapter5/coding-agent/agent_new.py:108 — CodingAgent.run has cognitive complexity 40 (threshold 15). Drivers by points: if/else 7 (24 pts), error handling 3 (10 pts), loops 3 (5 pts), boolean chains 1 (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · benchmark_application.print_application_results (cognitive 40) · ×1
  • benchmark_application.print_application_results (cognitive 40) REDACTED:455 — benchmark_application.print_application_results has cognitive complexity 40 (threshold 15). Drivers by points: if/else 9 (17 pts), ternaries 5 (12 pts), loops 5 (6 pts), boolean chains 5 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · benchmark_safety_final.print_final_results (cognitive 40) · ×1
  • benchmark_safety_final.print_final_results (cognitive 40) REDACTED:464 — benchmark_safety_final.print_final_results has cognitive complexity 40 (threshold 15). Drivers by points: if/else 10 (22 pts), loops 10 (18 pts) (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LearningAgent._save_learned_workflow (cognitive 40) · ×1
  • LearningAgent._save_learned_workflow (cognitive 40) chapter9/browser-use-rpa/learning_agent/agent.py:437 — LearningAgent._save_learned_workflow has cognitive complexity 40 (threshold 15). Drivers by points: if/else 10 (19 pts), loops 5 (12 pts), boolean chains 4, ternaries 3 (4 pts), error handling 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · demo_conversation_processing.demonstrate_conversation_processing (cognitive 39) · ×1
  • demo_conversation_processing.demonstrate_conversation_processing (cognitive 39) chapter3/user-memory/demo_conversation_processing.py:19 — demo_conversation_processing.demonstrate_conversation_processing has cognitive complexity 39 (threshold 15). Drivers by points: if/else 12 (29 pts), loops 3 (6 pts), boolean chains 2, ternaries 1 (2 pts) (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · demo.main (cognitive 39) · ×1
  • demo.main (cognitive 39) chapter4/active-tool-discovery/demo.py:127 — demo.main has cognitive complexity 39 (threshold 15). Drivers by points: if/else 16 (29 pts), loops 3 (7 pts), error handling 1 (2 pts), ternaries 1 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · providers.capture (cognitive 39) · ×1
  • providers.capture (cognitive 39) chapter5/provider-failover/providers.py:88 — providers.capture has cognitive complexity 39 (threshold 15). Drivers by points: if/else 13 (23 pts), boolean chains 16 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LocalFileTools.grep (cognitive 38) · ×1
  • LocalFileTools.grep (cognitive 38) chapter2/kv-cache/agent.py:257 — LocalFileTools.grep has cognitive complexity 38 (threshold 15). Drivers by points: if/else 10 (27 pts), loops 4 (8 pts), error handling 2 (3 pts) (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · demo.main (cognitive 38) · ×1
  • demo.main (cognitive 38) chapter5/paper-to-ppt/demo.py:410 — demo.main has cognitive complexity 38 (threshold 15). Drivers by points: boolean chains 16, if/else 15, ternaries 5 (6 pts), loops 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · benchmark_comparisons.run_multi_model_test (cognitive 38) · ×1
  • benchmark_comparisons.run_multi_model_test (cognitive 38) REDACTED:509 — benchmark_comparisons.run_multi_model_test has cognitive complexity 38 (threshold 15). Drivers by points: if/else 4 (14 pts), error handling 3 (12 pts), loops 3 (6 pts), ternaries 1 (5 pts), boolean chains 1 (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · validate_vlm_evidence.validate_run (cognitive 38) · ×1
  • validate_vlm_evidence.validate_run (cognitive 38) chapter8/MiniMind-pretrain/validation/validate_vlm_evidence.py:225 — validate_vlm_evidence.validate_run has cognitive complexity 38 (threshold 15). Drivers by points: if/else 21 (26 pts), boolean chains 11, loops 1 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · ReActAttentionAgent.generate_with_streaming (cognitive 37) · ×1
  • ReActAttentionAgent.generate_with_streaming (cognitive 37) chapter2/attention_visualization/main.py:85 — ReActAttentionAgent.generate_with_streaming has cognitive complexity 37 (threshold 15). Drivers by points: if/else 14 (29 pts), loops 2 (3 pts), ternaries 2 (3 pts), boolean chains 2 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AgenticRAG.query (cognitive 37) · ×1
  • AgenticRAG.query (cognitive 37) chapter3/contextual-retrieval/agent.py:172 — AgenticRAG.query has cognitive complexity 37 (threshold 15). Drivers by points: if/else 13 (25 pts), error handling 2 (6 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · demo.main (cognitive 37) · ×1
  • demo.main (cognitive 37) chapter3/retrieval-pipeline/demo.py:44 — demo.main has cognitive complexity 37 (threshold 15). Drivers by points: if/else 7 (18 pts), ternaries 3 (10 pts), loops 4 (7 pts), boolean chains 2 (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RetrievalStageEvaluator.evaluate_pipeline (cognitive 37) · ×1
  • RetrievalStageEvaluator.evaluate_pipeline (cognitive 37) chapter3/retrieval-pipeline/stage_evaluator.py:255 — RetrievalStageEvaluator.evaluate_pipeline has cognitive complexity 37 (threshold 15). Drivers by points: if/else 10 (20 pts), loops 12 (17 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · verify_acceptance.main (cognitive 37) · ×1
  • verify_acceptance.main (cognitive 37) chapter6/phone-agent/verify_acceptance.py:279 — verify_acceptance.main has cognitive complexity 37 (threshold 15). Drivers by points: if/else 19 (23 pts), boolean chains 8, loops 4, error handling 1, ternaries 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · DownstreamAblationEngine.run_ablation_campaign (cognitive 37) · ×1
  • DownstreamAblationEngine.run_ablation_campaign (cognitive 37) chapter9/hermes-self-evolution/run_downstream_ablation.py:224 — DownstreamAblationEngine.run_ablation_campaign has cognitive complexity 37 (threshold 15). Drivers by points: if/else 12 (18 pts), ternaries 11, boolean chains 4, loops 3 (4 pts) (nesting depth added 7). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · ConnectionHandler.generateAIResponse (cognitive 37) · ×1
  • ConnectionHandler.generateAIResponse (cognitive 37) chapter6/live-audio/backend/server.js:352 — ConnectionHandler.generateAIResponse has cognitive complexity 37 (threshold 15). Drivers by points: if/else 14 (26 pts), boolean chains 5, error handling 4 (5 pts), loops 1 (nesting depth added 13). Most of this is not in the body itself: 7 of the 37 points are its own statements and the rest belongs to 2 function literals inside it that branch (lines 423, 488). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
D2 · Cognitive Complexity · PhoneAgent._run_dialogue (cognitive 36) · ×1
  • PhoneAgent._run_dialogue (cognitive 36) chapter10/autonomous-phone-registration/orchestration.py:166 — PhoneAgent._run_dialogue has cognitive complexity 36 (threshold 15). Drivers by points: if/else 10 (24 pts), error handling 2 (4 pts), loops 2 (3 pts), ternaries 1 (3 pts), boolean chains 2 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_official_experiment.split_translation_units (cognitive 36) · ×1
  • run_official_experiment.split_translation_units (cognitive 36) chapter10/book-translation/run_official_experiment.py:78 — run_official_experiment.split_translation_units has cognitive complexity 36 (threshold 15). Drivers by points: if/else 8 (25 pts), loops 4 (9 pts), boolean chains 2 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · supervise_campaigns.main (cognitive 36) · ×1
  • supervise_campaigns.main (cognitive 36) REDACTED:90 — supervise_campaigns.main has cognitive complexity 36 (threshold 15). Drivers by points: if/else 9 (22 pts), loops 5 (9 pts), boolean chains 4, ternaries 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LocalLegalIndexer.chunk_document_smart (cognitive 36) · ×1
  • LocalLegalIndexer.chunk_document_smart (cognitive 36) REDACTED:139 — LocalLegalIndexer.chunk_document_smart has cognitive complexity 36 (threshold 15). Drivers by points: if/else 12 (29 pts), loops 2 (4 pts), ternaries 1 (2 pts), boolean chains 1 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BatchEvaluator.generate_report (cognitive 36) · ×1
  • BatchEvaluator.generate_report (cognitive 36) chapter3/user-memory-evaluation/evaluator.py:373 — BatchEvaluator.generate_report has cognitive complexity 36 (threshold 15). Drivers by points: if/else 8 (18 pts), ternaries 6 (12 pts), loops 4 (6 pts) (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_exact_experiment.run (cognitive 36) · ×1
  • run_exact_experiment.run (cognitive 36) chapter4/active-tool-discovery/run_exact_experiment.py:1060 — run_exact_experiment.run has cognitive complexity 36 (threshold 15). Drivers by points: if/else 19 (32 pts), boolean chains 4 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · NotificationDispatcher.dispatch_and_wait (cognitive 36) · ×1
  • NotificationDispatcher.dispatch_and_wait (cognitive 36) chapter4/collaboration-tools/src/notification_dispatcher.py:437 — NotificationDispatcher.dispatch_and_wait has cognitive complexity 36 (threshold 15). Drivers by points: if/else 18 (24 pts), boolean chains 6, error handling 3 (5 pts), ternaries 1 (nesting depth added 8). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · AgentCreator._ask (cognitive 36) · ×1
  • AgentCreator._ask (cognitive 36) chapter5/agent-creator/creator.py:208 — AgentCreator._ask has cognitive complexity 36 (threshold 15). Drivers by points: if/else 5 (15 pts), ternaries 4 (7 pts), boolean chains 6, error handling 2 (5 pts), loops 2 (3 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · validator.validate_agent (cognitive 36) · ×1
  • validator.validate_agent (cognitive 36) chapter5/agent-creator/validator.py:331 — validator.validate_agent has cognitive complexity 36 (threshold 15). Drivers by points: if/else 9 (18 pts), boolean chains 7, ternaries 6, error handling 1 (3 pts), loops 1 (2 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · campaign.run (cognitive 36) · ×1
  • campaign.run (cognitive 36) REDACTED:415 — campaign.run has cognitive complexity 36 (threshold 15). Drivers by points: if/else 11 (13 pts), boolean chains 7, error handling 3 (6 pts), loops 5 (6 pts), ternaries 2 (4 pts) (nesting depth added 8). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · run_targeted_eval.run_single (cognitive 36) · ×1
  • run_targeted_eval.run_single (cognitive 36) REDACTED:303 — run_targeted_eval.run_single has cognitive complexity 36 (threshold 15). Drivers by points: error handling 10 (21 pts), if/else 9 (11 pts), ternaries 2 (4 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · desktop_planner.run_episode (cognitive 36) · ×1
  • desktop_planner.run_episode (cognitive 36) chapter6/gemini-xlerobot-navigation/desktop_planner.py:197 — desktop_planner.run_episode has cognitive complexity 36 (threshold 15). Drivers by points: if/else 10 (25 pts), boolean chains 7, loops 2 (4 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MultilingualReasoningEvaluator._parse_model_output (cognitive 36) · ×1
  • MultilingualReasoningEvaluator._parse_model_output (cognitive 36) chapter8/MultilingualReasoning/evaluate_multilingual.py:320 — MultilingualReasoningEvaluator._parse_model_output has cognitive complexity 36 (threshold 15). Drivers by points: if/else 11 (20 pts), boolean chains 8, loops 4 (8 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · quick_demo.run_llm_demo (cognitive 35) · ×1
  • quick_demo.run_llm_demo (cognitive 35) chapter1/learning-from-experience/quick_demo.py:47 — quick_demo.run_llm_demo has cognitive complexity 35 (threshold 15). Drivers by points: if/else 10 (21 pts), loops 3 (9 pts), ternaries 2 (3 pts), boolean chains 2 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_official_experiment.validate_judge_response (cognitive 35) · ×1
  • run_official_experiment.validate_judge_response (cognitive 35) chapter10/book-translation/run_official_experiment.py:179 — run_official_experiment.validate_judge_response has cognitive complexity 35 (threshold 15). Drivers by points: if/else 11 (22 pts), boolean chains 7, loops 3 (6 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_official_experiment.main (cognitive 35) · ×1
  • run_official_experiment.main (cognitive 35) chapter10/book-translation/run_official_experiment.py:505 — run_official_experiment.main has cognitive complexity 35 (threshold 15). Drivers by points: boolean chains 12, ternaries 9 (10 pts), if/else 7 (8 pts), loops 4 (5 pts) (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · VLLMToolAgent.chat (cognitive 35) · ×1
  • VLLMToolAgent.chat (cognitive 35) chapter2/local_llm_serving/agent.py:182 — VLLMToolAgent.chat has cognitive complexity 35 (threshold 15). Drivers by points: if/else 9 (12 pts), ternaries 4 (10 pts), loops 3 (7 pts), error handling 1 (4 pts), boolean chains 2 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InteractiveRAGEvaluator.evaluate_single_test (cognitive 35) · ×1
  • InteractiveRAGEvaluator.evaluate_single_test (cognitive 35) chapter3/agentic-rag-for-user-memory/main.py:255 — InteractiveRAGEvaluator.evaluate_single_test has cognitive complexity 35 (threshold 15). Drivers by points: if/else 9 (13 pts), ternaries 7 (13 pts), loops 4 (7 pts), boolean chains 1, error handling 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · campaign.measure_stream (cognitive 35) · ×1
  • campaign.measure_stream (cognitive 35) chapter7/model-benchmark/campaign.py:432 — campaign.measure_stream has cognitive complexity 35 (threshold 15). Drivers by points: if/else 9 (17 pts), ternaries 5 (9 pts), boolean chains 5, loops 2 (3 pts), error handling 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · campaign.measure_gemini (cognitive 35) · ×1
  • campaign.measure_gemini (cognitive 35) chapter7/model-benchmark/campaign.py:703 — campaign.measure_gemini has cognitive complexity 35 (threshold 15). Drivers by points: if/else 7 (21 pts), boolean chains 6, loops 3 (6 pts), error handling 1, ternaries 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RateRampBenchmark.run (cognitive 35) · ×1
  • RateRampBenchmark.run (cognitive 35) chapter7/model-benchmark/rate_ramp_benchmark.py:213 — RateRampBenchmark.run has cognitive complexity 35 (threshold 15). Drivers by points: if/else 12 (19 pts), boolean chains 11, loops 2 (3 pts), ternaries 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · experiment.completion_assessment (cognitive 35) · ×1
  • experiment.completion_assessment (cognitive 35) chapter7/user-memory-system-evaluation/experiment.py:1587 — experiment.completion_assessment has cognitive complexity 35 (threshold 15). Drivers by points: if/else 17 (21 pts), boolean chains 10, loops 2, ternaries 1 (2 pts) (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · create_data.generate_distillation_data (cognitive 35) · ×1
  • create_data.generate_distillation_data (cognitive 35) chapter8/prompt-distillation/create_data.py:146 — create_data.generate_distillation_data has cognitive complexity 35 (threshold 15). Drivers by points: if/else 15 (23 pts), loops 8 (12 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · demo.verify_simulator_trace (cognitive 34) · ×1
  • demo.verify_simulator_trace (cognitive 34) chapter10/voice-werewolf/demo.py:131 — demo.verify_simulator_trace has cognitive complexity 34 (threshold 15). Drivers by points: if/else 11 (21 pts), boolean chains 10, loops 2 (3 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · cli._demo (cognitive 34) · ×1
  • cli._demo (cognitive 34) chapter4/perception-tools/cli.py:337 — cli._demo has cognitive complexity 34 (threshold 15). Drivers by points: if/else 15 (19 pts), error handling 4 (8 pts), loops 3 (5 pts), boolean chains 1, ternaries 1 (nesting depth added 10). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · demo.solve (cognitive 34) · ×1
  • demo.solve (cognitive 34) chapter5/code-for-math/demo.py:168 — demo.solve has cognitive complexity 34 (threshold 15). Drivers by points: ternaries 6 (12 pts), if/else 3 (8 pts), boolean chains 6, error handling 1 (4 pts), loops 2 (4 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · main.run_demo (cognitive 33) · ×1
  • main.run_demo (cognitive 33) chapter2/context-compression/main.py:65 — main.run_demo has cognitive complexity 33 (threshold 15). Drivers by points: if/else 14 (26 pts), loops 1 (3 pts), error handling 2, boolean chains 1, ternaries 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_experiment_2_8.execute_tool (cognitive 33) · ×1
  • run_experiment_2_8.execute_tool (cognitive 33) chapter2/system-hint/run_experiment_2_8.py:298 — run_experiment_2_8.execute_tool has cognitive complexity 33 (threshold 15). Drivers by points: if/else 18 (27 pts), boolean chains 2, loops 1 (2 pts), ternaries 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ContextualChunker._chunk_by_paragraphs (cognitive 33) · ×1
  • ContextualChunker._chunk_by_paragraphs (cognitive 33) REDACTED:190 — ContextualChunker._chunk_by_paragraphs has cognitive complexity 33 (threshold 15). Drivers by points: if/else 11 (22 pts), loops 3 (9 pts), boolean chains 2 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · quickstart.quickstart (cognitive 33) · ×1
  • quickstart.quickstart (cognitive 33) chapter3/user-memory/quickstart.py:21 — quickstart.quickstart has cognitive complexity 33 (threshold 15). Drivers by points: if/else 10 (18 pts), loops 4 (8 pts), ternaries 3 (6 pts), boolean chains 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExtendedTools.virtual_desktop_execute (cognitive 33) · ×1
  • ExtendedTools.virtual_desktop_execute (cognitive 33) REDACTED:139 — ExtendedTools.virtual_desktop_execute has cognitive complexity 33 (threshold 15). Drivers by points: if/else 13 (19 pts), boolean chains 9, loops 4, ternaries 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CodingAgent._run_openai_iteration (cognitive 33) · ×1
  • CodingAgent._run_openai_iteration (cognitive 33) chapter5/coding-agent/agent.py:304 — CodingAgent._run_openai_iteration has cognitive complexity 33 (threshold 15). Drivers by points: if/else 8 (20 pts), error handling 3 (5 pts), loops 3 (5 pts), ternaries 1 (2 pts), boolean chains 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · regeneration_robustness.run (cognitive 33) · ×1
  • regeneration_robustness.run (cognitive 33) REDACTED:250 — regeneration_robustness.run has cognitive complexity 33 (threshold 15). Drivers by points: if/else 6 (18 pts), error handling 2 (8 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_handoff.run_pair (cognitive 33) · ×1
  • run_handoff.run_pair (cognitive 33) chapter5/provider-failover/run_handoff.py:46 — run_handoff.run_pair has cognitive complexity 33 (threshold 15). Drivers by points: if/else 7 (18 pts), loops 3 (6 pts), boolean chains 5, error handling 2 (4 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · flatten_epub_toc.flatten_nav (cognitive 33) · ×1
  • flatten_epub_toc.flatten_nav (cognitive 33) REDACTED:32 — flatten_epub_toc.flatten_nav has cognitive complexity 33 (threshold 15). Drivers by points: if/else 9 (22 pts), loops 5 (9 pts), boolean chains 2 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · validateLesson (cognitive 33) · ×1
  • validateLesson (cognitive 33) slides/generate.mjs:344 — validateLesson has cognitive complexity 33 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 9, loops 5 (6 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · WebSearchAgent.search_and_answer (cognitive 32) · ×1
  • WebSearchAgent.search_and_answer (cognitive 32) chapter1/web-search-agent/agent.py:364 — WebSearchAgent.search_and_answer has cognitive complexity 32 (threshold 15). Drivers by points: if/else 5 (10 pts), ternaries 2 (7 pts), boolean chains 6, error handling 2 (5 pts), loops 2 (4 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · UserMemoryEvaluationFramework.display_test_case_summary (cognitive 32) · ×1
  • UserMemoryEvaluationFramework.display_test_case_summary (cognitive 32) chapter3/user-memory-evaluation/framework.py:299 — UserMemoryEvaluationFramework.display_test_case_summary has cognitive complexity 32 (threshold 15). Drivers by points: if/else 6 (12 pts), ternaries 3 (12 pts), loops 3 (8 pts) (nesting depth added 20). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · NotesMemoryManager.consolidate_memories (cognitive 32) · ×1
  • NotesMemoryManager.consolidate_memories (cognitive 32) chapter3/user-memory/memory_manager.py:269 — NotesMemoryManager.consolidate_memories has cognitive complexity 32 (threshold 15). Drivers by points: if/else 9 (17 pts), loops 4 (7 pts), ternaries 2 (5 pts), boolean chains 3 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · demo.main (cognitive 32) · ×1
  • demo.main (cognitive 32) chapter5/code-for-logic/demo.py:489 — demo.main has cognitive complexity 32 (threshold 15). Drivers by points: if/else 17 (23 pts), boolean chains 5, loops 2 (3 pts), ternaries 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · campaign_postgres.main (cognitive 32) · ×1
  • campaign_postgres.main (cognitive 32) chapter5/erp-agent/campaign_postgres.py:267 — campaign_postgres.main has cognitive complexity 32 (threshold 15). Drivers by points: if/else 7 (11 pts), boolean chains 10, error handling 1 (4 pts), ternaries 2 (4 pts), loops 2 (3 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · experiment.preflight (cognitive 32) · ×1
  • experiment.preflight (cognitive 32) chapter7/openvla-robotwin2-eval/experiment.py:99 — experiment.preflight has cognitive complexity 32 (threshold 15). Drivers by points: boolean chains 14, if/else 6 (10 pts), ternaries 6, loops 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_full.main (cognitive 32) · ×1
  • run_full.main (cognitive 32) chapter7/user-memory-system-evaluation/run_full.py:145 — run_full.main has cognitive complexity 32 (threshold 15). Drivers by points: if/else 16 (23 pts), ternaries 4, loops 3, boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_report_audit.parse_retained_outputs (cognitive 32) · ×1
  • run_report_audit.parse_retained_outputs (cognitive 32) REDACTED:100 — run_report_audit.parse_retained_outputs has cognitive complexity 32 (threshold 15). Drivers by points: if/else 14 (30 pts), loops 2 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · evaluate.print_confusion_matrix (cognitive 32) · ×1
  • evaluate.print_confusion_matrix (cognitive 32) chapter8/prompt-distillation/evaluate.py:264 — evaluate.print_confusion_matrix has cognitive complexity 32 (threshold 15). Drivers by points: ternaries 5 (12 pts), if/else 5 (11 pts), loops 6 (9 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · process (cognitive 32) · ×1
  • process (cognitive 32) chapter6/live-audio/frontend/public/audioWorklet.js:103 — process has cognitive complexity 32 (threshold 15). Drivers by points: loops 5 (14 pts), if/else 7 (13 pts), boolean chains 5 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AttentionVisualizationAgent._capture_attention_hook (cognitive 31) · ×1
  • AttentionVisualizationAgent._capture_attention_hook (cognitive 31) chapter2/attention_visualization/agent.py:216 — AttentionVisualizationAgent._capture_attention_hook has cognitive complexity 31 (threshold 15). Drivers by points: if/else 12 (23 pts), boolean chains 5, loops 1 (2 pts), error handling 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · memory_rag_campaign.main (cognitive 31) · ×1
  • memory_rag_campaign.main (cognitive 31) chapter3/memory_rag_campaign.py:492 — memory_rag_campaign.main has cognitive complexity 31 (threshold 15). Drivers by points: boolean chains 19, ternaries 5, if/else 4, error handling 1 (2 pts), loops 1 (nesting depth added 1). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · replay._eval_assertion (cognitive 31) · ×1
  • replay._eval_assertion (cognitive 31) chapter5/log-diagnosis/replay.py:52 — replay._eval_assertion has cognitive complexity 31 (threshold 15). Drivers by points: if/else 9 (15 pts), ternaries 3 (6 pts), error handling 2 (5 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · benchmark_comparisons.run_all_comparisons (cognitive 31) · ×1
  • benchmark_comparisons.run_all_comparisons (cognitive 31) REDACTED:693 — benchmark_comparisons.run_all_comparisons has cognitive complexity 31 (threshold 15). Drivers by points: loops 16 (20 pts), if/else 4 (8 pts), ternaries 1 (3 pts) (nesting depth added 10). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · evaluate_audio_quality.main (cognitive 31) · ×1
  • evaluate_audio_quality.main (cognitive 31) REDACTED:378 — evaluate_audio_quality.main has cognitive complexity 31 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 11, error handling 2 (4 pts), loops 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · analysis.cost_summary (cognitive 31) · ×1
  • analysis.cost_summary (cognitive 31) chapter7/model-benchmark/analysis.py:219 — analysis.cost_summary has cognitive complexity 31 (threshold 15). Drivers by points: ternaries 8 (16 pts), boolean chains 7, if/else 2 (5 pts), loops 2 (3 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_full.valid_checkpoint (cognitive 31) · ×1
  • run_full.valid_checkpoint (cognitive 31) chapter7/user-memory-system-evaluation/run_full.py:34 — run_full.valid_checkpoint has cognitive complexity 31 (threshold 15). Drivers by points: if/else 12 (22 pts), boolean chains 5, error handling 2 (3 pts), loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_official_experiment.judge_chapter (cognitive 30) · ×1
  • run_official_experiment.judge_chapter (cognitive 30) chapter10/book-translation/run_official_experiment.py:256 — run_official_experiment.judge_chapter has cognitive complexity 30 (threshold 15). Drivers by points: if/else 7 (15 pts), error handling 3 (7 pts), ternaries 2 (4 pts), boolean chains 3, loops 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · quickstart.main (cognitive 30) · ×1
  • quickstart.main (cognitive 30) chapter2/system-hint/quickstart.py:14 — quickstart.main has cognitive complexity 30 (threshold 15). Drivers by points: if/else 12 (20 pts), loops 3 (6 pts), ternaries 1 (3 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Campaign.answer_agentic (cognitive 30) · ×1
  • Campaign.answer_agentic (cognitive 30) chapter3/agentic-rag/campaign.py:143 — Campaign.answer_agentic has cognitive complexity 30 (threshold 15). Drivers by points: if/else 5 (9 pts), loops 3 (7 pts), ternaries 2 (6 pts), boolean chains 4, error handling 1 (4 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LOCOMOBenchmark._run_single_session_test (cognitive 30) · ×1
  • LOCOMOBenchmark._run_single_session_test (cognitive 30) chapter3/user-memory/locomo_benchmark.py:271 — LOCOMOBenchmark._run_single_session_test has cognitive complexity 30 (threshold 15). Drivers by points: ternaries 4 (13 pts), loops 4 (10 pts), if/else 4 (7 pts) (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · campaign_browser.customize (cognitive 30) · ×1
  • campaign_browser.customize (cognitive 30) REDACTED:100 — campaign_browser.customize has cognitive complexity 30 (threshold 15). Drivers by points: if/else 5 (11 pts), ternaries 4 (8 pts), boolean chains 6, loops 2 (3 pts), error handling 1 (2 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · preflight.main (cognitive 30) · ×1
  • preflight.main (cognitive 30) chapter6/rgb-sim2real-grasping/preflight.py:32 — preflight.main has cognitive complexity 30 (threshold 15). Drivers by points: boolean chains 15, ternaries 6 (8 pts), if/else 3 (4 pts), loops 3 (nesting depth added 3). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · WorkflowReplayer._get_element (cognitive 30) · ×1
  • WorkflowReplayer._get_element (cognitive 30) chapter9/browser-use-rpa/learning_agent/replay.py:249 — WorkflowReplayer._get_element has cognitive complexity 30 (threshold 15). Drivers by points: if/else 11 (20 pts), error handling 3 (7 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · judge_comparison.main (cognitive 29) · ×1
  • judge_comparison.main (cognitive 29) chapter10/multi-role-transfer/judge_comparison.py:57 — judge_comparison.main has cognitive complexity 29 (threshold 15). Drivers by points: if/else 5 (11 pts), ternaries 2 (7 pts), loops 4 (6 pts), error handling 1 (3 pts), boolean chains 2 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_campaign.summarize (cognitive 29) · ×1
  • run_campaign.summarize (cognitive 29) chapter2/prompt-injection/run_campaign.py:217 — run_campaign.summarize has cognitive complexity 29 (threshold 15). Drivers by points: if/else 7 (10 pts), loops 6 (10 pts), boolean chains 8, ternaries 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AgenticRAG._execute_tool (cognitive 29) · ×1
  • AgenticRAG._execute_tool (cognitive 29) chapter3/agentic-rag/agent.py:116 — AgenticRAG._execute_tool has cognitive complexity 29 (threshold 15). Drivers by points: if/else 12 (26 pts), loops 1 (2 pts), error handling 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ContextualAgenticRAG._execute_tool (cognitive 29) · ×1
  • ContextualAgenticRAG._execute_tool (cognitive 29) chapter3/contextual-retrieval/contextual_agent.py:98 — ContextualAgenticRAG._execute_tool has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (21 pts), boolean chains 3, loops 1 (2 pts), ternaries 1 (2 pts), error handling 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RetrievalPipeline._combine_results (cognitive 29) · ×1
  • RetrievalPipeline._combine_results (cognitive 29) chapter3/retrieval-pipeline/retrieval_pipeline.py:189 — RetrievalPipeline._combine_results has cognitive complexity 29 (threshold 15). Drivers by points: ternaries 5 (14 pts), if/else 7 (11 pts), loops 4 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · quickstart.main (cognitive 29) · ×1
  • quickstart.main (cognitive 29) chapter3/sparse-embedding/quickstart.py:18 — quickstart.main has cognitive complexity 29 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 5 (9 pts), error handling 2 (4 pts), ternaries 1 (4 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · campaign.build_graph (cognitive 29) · ×1
  • campaign.build_graph (cognitive 29) chapter3/structured-index/campaign.py:236 — campaign.build_graph has cognitive complexity 29 (threshold 15). Drivers by points: if/else 5 (14 pts), loops 7 (11 pts), boolean chains 3, ternaries 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · campaign.main (cognitive 29) · ×1
  • campaign.main (cognitive 29) chapter3/structured-index/campaign.py:400 — campaign.main has cognitive complexity 29 (threshold 15). Drivers by points: if/else 6 (10 pts), boolean chains 9, loops 5 (7 pts), ternaries 3 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · main.main (cognitive 29) · ×1
  • main.main (cognitive 29) chapter3/structured-index/main.py:114 — main.main has cognitive complexity 29 (threshold 15). Drivers by points: if/else 6 (15 pts), loops 4 (14 pts) (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LOCOMOBenchmark._run_multi_session_test (cognitive 29) · ×1
  • LOCOMOBenchmark._run_multi_session_test (cognitive 29) chapter3/user-memory/locomo_benchmark.py:358 — LOCOMOBenchmark._run_multi_session_test has cognitive complexity 29 (threshold 15). Drivers by points: loops 4 (11 pts), ternaries 3 (11 pts), if/else 3 (7 pts) (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MockChatClient._respond (cognitive 29) · ×1
  • MockChatClient._respond (cognitive 29) REDACTED:158 — MockChatClient._respond has cognitive complexity 29 (threshold 15). Drivers by points: if/else 12 (22 pts), boolean chains 4, loops 2, ternaries 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_exact_experiment.run_agent_task (cognitive 29) · ×1
  • run_exact_experiment.run_agent_task (cognitive 29) chapter4/active-tool-discovery/run_exact_experiment.py:629 — run_exact_experiment.run_agent_task has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (21 pts), ternaries 2 (4 pts), boolean chains 3, loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MultimodalAgent._stream_openai_response (cognitive 29) · ×1
  • MultimodalAgent._stream_openai_response (cognitive 29) chapter4/multimodal-agent/agent.py:993 — MultimodalAgent._stream_openai_response has cognitive complexity 29 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 4 (8 pts), boolean chains 2 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ShellSession._parse_protocol_output (cognitive 29) · ×1
  • ShellSession._parse_protocol_output (cognitive 29) chapter5/coding-agent/tools/shell_session.py:183 — ShellSession._parse_protocol_output has cognitive complexity 29 (threshold 15). Drivers by points: if/else 8 (20 pts), boolean chains 5, loops 2 (4 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_continuation.main (cognitive 29) · ×1
  • run_continuation.main (cognitive 29) chapter5/provider-failover/run_continuation.py:147 — run_continuation.main has cognitive complexity 29 (threshold 15). Drivers by points: loops 4 (10 pts), error handling 2 (9 pts), ternaries 1 (5 pts), if/else 1 (4 pts), boolean chains 1 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · build_evidence.arm_stats (cognitive 29) · ×1
  • build_evidence.arm_stats (cognitive 29) chapter9/tau2-escalation-experience/build_evidence.py:23 — build_evidence.arm_stats has cognitive complexity 29 (threshold 15). Drivers by points: if/else 5 (16 pts), loops 3 (6 pts), boolean chains 5, ternaries 2 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · main (cognitive 29) · ×1
  • main (cognitive 29) slides/generate.mjs:476 — main has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (15 pts), boolean chains 5, loops 4 (5 pts), ternaries 3, other 1 (nesting depth added 6). Of this number, 28 points are the body's own statements and 1 belongs to 10 function literals inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · main.main (cognitive 28) · ×1
  • main.main (cognitive 28) chapter1/context/main.py:1156 — main.main has cognitive complexity 28 (threshold 15). Drivers by points: if/else 10 (18 pts), error handling 2 (4 pts), boolean chains 3, loops 1 (3 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LLMAgent.play_episode (cognitive 28) · ×1
  • LLMAgent.play_episode (cognitive 28) chapter1/learning-from-experience/llm_agent.py:407 — LLMAgent.play_episode has cognitive complexity 28 (threshold 15). Drivers by points: if/else 12 (22 pts), loops 2 (4 pts), ternaries 1 (2 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · agents.run_orchestration (cognitive 28) · ×1
  • agents.run_orchestration (cognitive 28) chapter10/book-translation/agents.py:461 — agents.run_orchestration has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (15 pts), boolean chains 6, loops 5, ternaries 2 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · judge_plausibility.main (cognitive 28) · ×1
  • judge_plausibility.main (cognitive 28) chapter10/generative-agents/judge_plausibility.py:221 — judge_plausibility.main has cognitive complexity 28 (threshold 15). Drivers by points: if/else 7 (11 pts), ternaries 5 (10 pts), loops 3 (4 pts), error handling 1 (2 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ReActAttentionAgent.save_react_trajectory (cognitive 28) · ×1
  • ReActAttentionAgent.save_react_trajectory (cognitive 28) chapter2/attention_visualization/main.py:483 — ReActAttentionAgent.save_react_trajectory has cognitive complexity 28 (threshold 15). Drivers by points: if/else 6 (12 pts), ternaries 7 (8 pts), loops 3 (5 pts), error handling 1 (2 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ResearchAgent._handle_windowed_compression (cognitive 28) · ×1
  • ResearchAgent._handle_windowed_compression (cognitive 28) chapter2/context-compression/agent.py:251 — ResearchAgent._handle_windowed_compression has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (21 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MemoryIndexer.search (cognitive 28) · ×1
  • MemoryIndexer.search (cognitive 28) chapter3/agentic-rag-for-user-memory/indexer.py:373 — MemoryIndexer.search has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (17 pts), boolean chains 7, loops 2 (3 pts), error handling 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · expanded_catalog._specific_contract (cognitive 28) · ×1
  • expanded_catalog._specific_contract (cognitive 28) chapter4/perception-tools/src/expanded_catalog.py:322 — expanded_catalog._specific_contract has cognitive complexity 28 (threshold 15). Drivers by points: ternaries 8 (16 pts), if/else 11 (12 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MultiEditTool._execute_impl (cognitive 28) · ×1
  • MultiEditTool._execute_impl (cognitive 28) chapter5/coding-agent/tools/multi_edit_tool.py:18 — MultiEditTool._execute_impl has cognitive complexity 28 (threshold 15). Drivers by points: if/else 13 (20 pts), error handling 2 (4 pts), boolean chains 3, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · campaign.main (cognitive 28) · ×1
  • campaign.main (cognitive 28) chapter5/paper-to-video/campaign.py:320 — campaign.main has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (13 pts), boolean chains 10, loops 3, ternaries 2 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · benchmark_safety_final.call_generated_func (cognitive 28) · ×1
  • benchmark_safety_final.call_generated_func (cognitive 28) REDACTED:264 — benchmark_safety_final.call_generated_func has cognitive complexity 28 (threshold 15). Drivers by points: boolean chains 10, error handling 5 (9 pts), if/else 7 (9 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · judging.judge (cognitive 28) · ×1
  • judging.judge (cognitive 28) chapter5/provider-failover/judging.py:19 — judging.judge has cognitive complexity 28 (threshold 15). Drivers by points: if/else 6 (10 pts), boolean chains 8, ternaries 2 (5 pts), error handling 1 (4 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · validate_run.main (cognitive 28) · ×1
  • validate_run.main (cognitive 28) chapter6/computer-use-open-model/validate_run.py:61 — validate_run.main has cognitive complexity 28 (threshold 15). Drivers by points: boolean chains 13, if/else 6, ternaries 5 (6 pts), loops 2 (3 pts) (nesting depth added 2). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · verify_acceptance.check_llm_receipt (cognitive 28) · ×1
  • verify_acceptance.check_llm_receipt (cognitive 28) chapter6/phone-agent/verify_acceptance.py:100 — verify_acceptance.check_llm_receipt has cognitive complexity 28 (threshold 15). Drivers by points: boolean chains 14, if/else 13, ternaries 1. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · webrtc_app._acceptance (cognitive 28) · ×1
  • webrtc_app._acceptance (cognitive 28) chapter6/phone-agent/webrtc_app.py:201 — webrtc_app._acceptance has cognitive complexity 28 (threshold 15). Drivers by points: boolean chains 25, if/else 3. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · experiment_core.render_report (cognitive 28) · ×1
  • experiment_core.render_report (cognitive 28) chapter7/android-world/experiment_core.py:394 — experiment_core.render_report has cognitive complexity 28 (threshold 15). Drivers by points: if/else 12 (15 pts), loops 6 (9 pts), boolean chains 3, ternaries 1 (nesting depth added 6). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · bradley_terry.compute_mle_elo (cognitive 28) · ×1
  • bradley_terry.compute_mle_elo (cognitive 28) chapter7/elo-leaderboard/bradley_terry.py:12 — bradley_terry.compute_mle_elo has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (17 pts), loops 3 (5 pts), boolean chains 4, ternaries 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · train_student.main (cognitive 28) · ×1
  • train_student.main (cognitive 28) chapter8/cot-distillation/train_student.py:135 — train_student.main has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (13 pts), ternaries 4 (7 pts), error handling 4 (6 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · evaluate.evaluate_model (cognitive 28) · ×1
  • evaluate.evaluate_model (cognitive 28) chapter8/prompt-distillation/evaluate.py:78 — evaluate.evaluate_model has cognitive complexity 28 (threshold 15). Drivers by points: ternaries 6 (16 pts), if/else 6 (9 pts), boolean chains 2, loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · evaluate.main (cognitive 28) · ×1
  • evaluate.main (cognitive 28) chapter8/prompt-distillation/evaluate.py:333 — evaluate.main has cognitive complexity 28 (threshold 15). Drivers by points: if/else 13 (22 pts), loops 2 (4 pts), boolean chains 1, ternaries 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_real_validation.runLlm (cognitive 28) · ×1
  • run_real_validation.runLlm (cognitive 28) chapter6/live-audio/backend/run_real_validation.js:222 — run_real_validation.runLlm has cognitive complexity 28 (threshold 15). Drivers by points: if/else 8 (16 pts), boolean chains 7, loops 2 (3 pts), ternaries 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · figure-style.color (cognitive 28) · ×1
  • figure-style.color (cognitive 28) web-astro/scripts/figure-style.mjs:33 — figure-style.color has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (15 pts), ternaries 5 (10 pts), boolean chains 3 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · highlights.initHighlights · ×1
  • highlights.initHighlights::render (cognitive 28) web-astro/src/scripts/highlights.ts:90 — highlights.initHighlights::render has cognitive complexity 28 (threshold 15). Drivers by points: if/else 8 (20 pts), boolean chains 4, loops 3 (4 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FieldSpec.validate (cognitive 27) · ×1
  • FieldSpec.validate (cognitive 27) chapter10/autonomous-phone-registration/models.py:31 — FieldSpec.validate has cognitive complexity 27 (threshold 15). Drivers by points: if/else 10 (12 pts), boolean chains 10, error handling 2 (4 pts), ternaries 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · main.run_single_task (cognitive 27) · ×1
  • main.run_single_task (cognitive 27) REDACTED:259 — main.run_single_task has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (23 pts), loops 1 (2 pts), boolean chains 1, error handling 1 (nesting depth added 16). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · main.interactive_mode (cognitive 27) · ×1
  • main.interactive_mode (cognitive 27) chapter2/system-hint/main.py:130 — main.interactive_mode has cognitive complexity 27 (threshold 15). Drivers by points: ternaries 5 (15 pts), if/else 4 (6 pts), error handling 2 (4 pts), boolean chains 1, loops 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · main.run_interactive_mode (cognitive 27) · ×1
  • main.run_interactive_mode (cognitive 27) chapter3/agentic-rag/main.py:59 — main.run_interactive_mode has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (14 pts), ternaries 3 (5 pts), error handling 2 (4 pts), loops 2 (4 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ContextualLegalIndexer.compare_retrieval_methods (cognitive 27) · ×1
  • ContextualLegalIndexer.compare_retrieval_methods (cognitive 27) chapter3/contextual-retrieval/index_local_laws_contextual.py:472 — ContextualLegalIndexer.compare_retrieval_methods has cognitive complexity 27 (threshold 15). Drivers by points: if/else 7 (18 pts), loops 2 (5 pts), error handling 1 (2 pts), boolean chains 1, ternaries 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · memory_rag_campaign.live_search_plan (cognitive 27) · ×1
  • memory_rag_campaign.live_search_plan (cognitive 27) chapter3/memory_rag_campaign.py:241 — memory_rag_campaign.live_search_plan has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (16 pts), error handling 1 (4 pts), loops 2 (3 pts), boolean chains 2, ternaries 1 (2 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InvertedIndex.add_document (cognitive 27) · ×1
  • InvertedIndex.add_document (cognitive 27) chapter3/sparse-embedding/bm25_engine.py:146 — InvertedIndex.add_document has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (21 pts), loops 2 (3 pts), boolean chains 2, ternaries 1 (nesting depth added 14). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · GraphRAGIndexer.search (cognitive 27) · ×1
  • GraphRAGIndexer.search (cognitive 27) REDACTED:389 — GraphRAGIndexer.search has cognitive complexity 27 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 5 (11 pts), ternaries 1 (3 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · archetypes.fit (cognitive 27) · ×1
  • archetypes.fit (cognitive 27) chapter3/structured-knowledge-extraction/archetypes.py:98 — archetypes.fit has cognitive complexity 27 (threshold 15). Drivers by points: if/else 7 (17 pts), loops 3 (5 pts), ternaries 2 (4 pts), boolean chains 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_experiment_4_4.run (cognitive 27) · ×1
  • run_experiment_4_4.run (cognitive 27) chapter4/execution-tools/run_experiment_4_4.py:55 — run_experiment_4_4.run has cognitive complexity 27 (threshold 15). Drivers by points: boolean chains 14, if/else 7 (8 pts), ternaries 4, loops 1 (nesting depth added 1). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · CodingAgent._run_anthropic_iteration (cognitive 27) · ×1
  • CodingAgent._run_anthropic_iteration (cognitive 27) chapter5/coding-agent/agent.py:181 — CodingAgent._run_anthropic_iteration has cognitive complexity 27 (threshold 15). Drivers by points: if/else 7 (17 pts), error handling 3 (7 pts), loops 2, boolean chains 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ReadTool._read_notebook (cognitive 27) · ×1
  • ReadTool._read_notebook (cognitive 27) chapter5/coding-agent/tools/read_tool.py:138 — ReadTool._read_notebook has cognitive complexity 27 (threshold 15). Drivers by points: if/else 6 (19 pts), loops 2 (5 pts), error handling 2, boolean chains 1 (nesting depth added 16). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · campaign_browser.main (cognitive 27) · ×1
  • campaign_browser.main (cognitive 27) REDACTED:221 — campaign_browser.main has cognitive complexity 27 (threshold 15). Drivers by points: boolean chains 11, if/else 5 (7 pts), loops 6 (7 pts), error handling 1 (2 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · benchmark_final_comprehensive.run_safety_eval (cognitive 27) · ×1
  • benchmark_final_comprehensive.run_safety_eval (cognitive 27) REDACTED:247 — benchmark_final_comprehensive.run_safety_eval has cognitive complexity 27 (threshold 15). Drivers by points: if/else 5 (12 pts), ternaries 4 (12 pts), loops 2 (3 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · build_73_evidence.main (cognitive 27) · ×1
  • build_73_evidence.main (cognitive 27) chapter7/user-memory-system-evaluation/build_73_evidence.py:30 — build_73_evidence.main has cognitive complexity 27 (threshold 15). Drivers by points: if/else 7 (15 pts), boolean chains 6, loops 2 (3 pts), ternaries 3 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LongitudinalEvaluator.run (cognitive 27) · ×1
  • LongitudinalEvaluator.run (cognitive 27) chapter9/self-evolution-eval/harness.py:24 — LongitudinalEvaluator.run has cognitive complexity 27 (threshold 15). Drivers by points: if/else 11 (13 pts), ternaries 9 (10 pts), boolean chains 2, loops 2 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · OpenAIQualityJudge.evaluate (cognitive 27) · ×1
  • OpenAIQualityJudge.evaluate (cognitive 27) chapter9/trajectory-verifier/llm_judge.py:41 — OpenAIQualityJudge.evaluate has cognitive complexity 27 (threshold 15). Drivers by points: if/else 11 (13 pts), ternaries 4 (8 pts), boolean chains 5, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AttentionModal.AttentionModal (cognitive 27) · ×1
  • AttentionModal.AttentionModal (cognitive 27) chapter2/attention_visualization/frontend/components/AttentionModal.tsx:11 — AttentionModal.AttentionModal has cognitive complexity 27 (threshold 15). Drivers by points: boolean chains 13, if/else 9 (10 pts), ternaries 2 (3 pts), match/switch 1 (nesting depth added 2). Most of this is not in the body itself: 4 of the 27 points are its own statements and the rest belongs to 9 function items inside it that branch (a function literal at line 99, handleMouseMove, a function literal at line 91, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
D2 · Cognitive Complexity · demo.save_evidence (cognitive 26) · ×1
  • demo.save_evidence (cognitive 26) chapter10/multi-role-transfer/demo.py:190 — demo.save_evidence has cognitive complexity 26 (threshold 15). Drivers by points: if/else 5 (11 pts), boolean chains 5, loops 3 (4 pts), error handling 1 (3 pts), ternaries 3 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · demo.verify_isolation (cognitive 26) · ×1
  • demo.verify_isolation (cognitive 26) chapter10/voice-werewolf/demo.py:59 — demo.verify_isolation has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (10 pts), ternaries 6 (7 pts), loops 3 (6 pts), boolean chains 3 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · main.main (cognitive 26) · ×1
  • main.main (cognitive 26) chapter3/agentic-rag-for-user-memory/main.py:606 — main.main has cognitive complexity 26 (threshold 15). Drivers by points: if/else 13 (22 pts), ternaries 1 (3 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ContextualMemoryIndexer._generate_summary_cards (cognitive 26) · ×1
  • ContextualMemoryIndexer._generate_summary_cards (cognitive 26) chapter3/contextual-retrieval-for-user-memory/contextual_indexer.py:246 — ContextualMemoryIndexer._generate_summary_cards has cognitive complexity 26 (threshold 15). Drivers by points: if/else 12 (18 pts), ternaries 2 (4 pts), error handling 2 (3 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · main.run_interactive_mode (cognitive 26) · ×1
  • main.run_interactive_mode (cognitive 26) chapter3/contextual-retrieval/main.py:59 — main.run_interactive_mode has cognitive complexity 26 (threshold 15). Drivers by points: if/else 8 (14 pts), error handling 2 (4 pts), loops 2 (4 pts), ternaries 2 (4 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Reranker.rerank (cognitive 26) · ×1
  • Reranker.rerank (cognitive 26) chapter3/retrieval-pipeline/reranker.py:124 — Reranker.rerank has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (17 pts), loops 4 (5 pts), ternaries 1 (2 pts), boolean chains 1, error handling 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · UserMemoryAgent._tool_add_memory (cognitive 26) · ×1
  • UserMemoryAgent._tool_add_memory (cognitive 26) chapter3/user-memory/agent.py:428 — UserMemoryAgent._tool_add_memory has cognitive complexity 26 (threshold 15). Drivers by points: if/else 11 (19 pts), error handling 2 (6 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · campaign._trajectory (cognitive 26) · ×1
  • campaign._trajectory (cognitive 26) REDACTED:209 — campaign._trajectory has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (22 pts), ternaries 2 (3 pts), boolean chains 1 (nesting depth added 13). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · PEDOSecurityEvaluator._execute_agent_query (cognitive 26) · ×1
  • PEDOSecurityEvaluator._execute_agent_query (cognitive 26) chapter5/permission-embedded-data-objects/run_live_security_eval.py:267 — PEDOSecurityEvaluator._execute_agent_query has cognitive complexity 26 (threshold 15). Drivers by points: if/else 8 (11 pts), error handling 4 (8 pts), ternaries 2 (6 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_targeted_eval.main (cognitive 26) · ×1
  • run_targeted_eval.main (cognitive 26) REDACTED:447 — run_targeted_eval.main has cognitive complexity 26 (threshold 15). Drivers by points: loops 8 (19 pts), if/else 2 (6 pts), boolean chains 1 (nesting depth added 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · qwen2_streaming.parse_response (cognitive 26) · ×1
  • qwen2_streaming.parse_response (cognitive 26) chapter6/streaming-speech/qwen2_streaming.py:36 — qwen2_streaming.parse_response has cognitive complexity 26 (threshold 15). Drivers by points: if/else 8 (14 pts), error handling 3 (8 pts), boolean chains 2, loops 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_controlled_experiment._parse_args (cognitive 26) · ×1
  • run_controlled_experiment._parse_args (cognitive 26) chapter7/android-world/run_controlled_experiment.py:933 — run_controlled_experiment._parse_args has cognitive complexity 26 (threshold 15). Drivers by points: if/else 12 (14 pts), boolean chains 10, error handling 1 (2 pts) (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · experiment.main (cognitive 26) · ×1
  • experiment.main (cognitive 26) chapter7/model-action-threshold/experiment.py:637 — experiment.main has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (15 pts), loops 4 (8 pts), ternaries 2 (3 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CardBuilder.build (cognitive 26) · ×1
  • CardBuilder.build (cognitive 26) chapter7/user-memory-system-evaluation/experiment.py:557 — CardBuilder.build has cognitive complexity 26 (threshold 15). Drivers by points: if/else 6 (17 pts), loops 3 (4 pts), error handling 1 (2 pts), ternaries 1 (2 pts), boolean chains 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · analyze_campaign.sesame_analysis (cognitive 26) · ×1
  • analyze_campaign.sesame_analysis (cognitive 26) chapter8/speech-sft-experiment/analyze_campaign.py:95 — analyze_campaign.sesame_analysis has cognitive complexity 26 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 4 (5 pts), boolean chains 4, ternaries 2 (4 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Workflow.parameterize (cognitive 26) · ×1
  • Workflow.parameterize (cognitive 26) chapter9/browser-use-rpa/learning_agent/workflow.py:227 — Workflow.parameterize has cognitive complexity 26 (threshold 15). Drivers by points: loops 6 (12 pts), if/else 3 (11 pts), boolean chains 3 (nesting depth added 14). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · run_experiment_9_5.campaign (cognitive 26) · ×1
  • run_experiment_9_5.campaign (cognitive 26) REDACTED:334 — run_experiment_9_5.campaign has cognitive complexity 26 (threshold 15). Drivers by points: boolean chains 19, if/else 4, ternaries 2, loops 1. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · DownstreamAblationEngine.evaluate_code_quality (cognitive 26) · ×1
  • DownstreamAblationEngine.evaluate_code_quality (cognitive 26) chapter9/hermes-self-evolution/run_downstream_ablation.py:89 — DownstreamAblationEngine.evaluate_code_quality has cognitive complexity 26 (threshold 15). Drivers by points: if/else 15 (19 pts), boolean chains 3, error handling 2 (3 pts), loops 1 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · analyze.stats (cognitive 26) · ×1
  • analyze.stats (cognitive 26) chapter9/tau2-escalation-experience/analyze.py:18 — analyze.stats has cognitive complexity 26 (threshold 15). Drivers by points: if/else 5 (14 pts), boolean chains 6, loops 3 (6 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · fix_svg_text_layout.same_row_regions (cognitive 25) · ×1
  • fix_svg_text_layout.same_row_regions (cognitive 25) REDACTED:241 — fix_svg_text_layout.same_row_regions has cognitive complexity 25 (threshold 15). Drivers by points: ternaries 4 (14 pts), if/else 3 (7 pts), loops 3 (4 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StrategyRunner.generate_summary (cognitive 25) · ×1
  • StrategyRunner.generate_summary (cognitive 25) chapter2/context-compression/run_all_strategies.py:288 — StrategyRunner.generate_summary has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (14 pts), ternaries 5 (10 pts), loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · campaign.main (cognitive 25) · ×1
  • campaign.main (cognitive 25) chapter3/contextual-retrieval/campaign.py:163 — campaign.main has cognitive complexity 25 (threshold 15). Drivers by points: boolean chains 11, loops 3 (6 pts), if/else 3, ternaries 3, error handling 1 (2 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RetrievalPipeline._calculate_statistics (cognitive 25) · ×1
  • RetrievalPipeline._calculate_statistics (cognitive 25) chapter3/retrieval-pipeline/retrieval_pipeline.py:322 — RetrievalPipeline._calculate_statistics has cognitive complexity 25 (threshold 15). Drivers by points: if/else 7 (17 pts), loops 3 (4 pts), boolean chains 2, ternaries 1 (2 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GraphRAGIndexer.multi_hop_search (cognitive 25) · ×1
  • GraphRAGIndexer.multi_hop_search (cognitive 25) REDACTED:466 — GraphRAGIndexer.multi_hop_search has cognitive complexity 25 (threshold 15). Drivers by points: ternaries 3 (10 pts), if/else 4 (8 pts), loops 3 (4 pts), boolean chains 3 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · HybridStructuredRetriever._compute_scores (cognitive 25) · ×1
  • HybridStructuredRetriever._compute_scores (cognitive 25) chapter3/structured-index/hybrid_retriever.py:289 — HybridStructuredRetriever._compute_scores has cognitive complexity 25 (threshold 15). Drivers by points: if/else 13 (18 pts), boolean chains 2, error handling 1 (2 pts), ternaries 2, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MultimodalTools._analyze_with_gemini_audio (cognitive 25) · ×1
  • MultimodalTools._analyze_with_gemini_audio (cognitive 25) chapter4/multimodal-agent/agent.py:195 — MultimodalTools._analyze_with_gemini_audio has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (22 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 15). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function. This shape REPEATS in the file: one other method here (MultimodalTools._analyze_with_gemini_pdf) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · MultimodalTools._analyze_with_gemini_pdf (cognitive 25) · ×1
  • MultimodalTools._analyze_with_gemini_pdf (cognitive 25) chapter4/multimodal-agent/agent.py:248 — MultimodalTools._analyze_with_gemini_pdf has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (22 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 15). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function. This shape REPEATS in the file: one other method here (MultimodalTools._analyze_with_gemini_audio) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · benchmark_final_comprehensive.run_all (cognitive 25) · ×1
  • benchmark_final_comprehensive.run_all (cognitive 25) REDACTED:595 — benchmark_final_comprehensive.run_all has cognitive complexity 25 (threshold 15). Drivers by points: loops 11 (18 pts), if/else 4 (7 pts) (nesting depth added 10). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · demo.main (cognitive 25) · ×1
  • demo.main (cognitive 25) chapter5/video-edit/demo.py:139 — demo.main has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (13 pts), ternaries 6 (7 pts), boolean chains 4, loops 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · summarize.summarize (cognitive 25) · ×1
  • summarize.summarize (cognitive 25) chapter6/astra-async-steering/summarize.py:12 — summarize.summarize has cognitive complexity 25 (threshold 15). Drivers by points: if/else 7 (17 pts), ternaries 2 (4 pts), boolean chains 2, loops 2 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_weather_task.main (cognitive 25) · ×1
  • run_weather_task.main (cognitive 25) chapter6/claude-computer-use-native/run_weather_task.py:60 — run_weather_task.main has cognitive complexity 25 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 4 (6 pts), ternaries 3, boolean chains 2, error handling 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OpenAICompatibleLlm.predict (cognitive 25) · ×1
  • OpenAICompatibleLlm.predict (cognitive 25) chapter7/android-world/run_controlled_experiment.py:770 — OpenAICompatibleLlm.predict has cognitive complexity 25 (threshold 15). Drivers by points: if/else 7 (19 pts), boolean chains 3, error handling 1 (2 pts), loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExperimentRunner.run_64 (cognitive 25) · ×1
  • ExperimentRunner.run_64 (cognitive 25) chapter7/user-memory-system-evaluation/experiment.py:1014 — ExperimentRunner.run_64 has cognitive complexity 25 (threshold 15). Drivers by points: error handling 5 (13 pts), if/else 6 (9 pts), boolean chains 2, loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MultilingualReasoningEvaluator.evaluate_cot_fidelity (cognitive 25) · ×1
  • MultilingualReasoningEvaluator.evaluate_cot_fidelity (cognitive 25) chapter8/MultilingualReasoning/evaluate_multilingual.py:174 — MultilingualReasoningEvaluator.evaluate_cot_fidelity has cognitive complexity 25 (threshold 15). Drivers by points: if/else 15 (21 pts), boolean chains 2, ternaries 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MultilingualReasoningEvaluator.evaluate_accuracy (cognitive 25) · ×1
  • MultilingualReasoningEvaluator.evaluate_accuracy (cognitive 25) chapter8/MultilingualReasoning/evaluate_multilingual.py:236 — MultilingualReasoningEvaluator.evaluate_accuracy has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (16 pts), boolean chains 4, ternaries 3, error handling 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · calibration.calibration_report (cognitive 25) · ×1
  • calibration.calibration_report (cognitive 25) chapter9/trajectory-verifier/calibration.py:10 — calibration.calibration_report has cognitive complexity 25 (threshold 15). Drivers by points: ternaries 6 (12 pts), boolean chains 7, if/else 1 (3 pts), loops 2 (3 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · reading-position.initReadingPosition (cognitive 25) · ×1
  • reading-position.initReadingPosition (cognitive 25) web-astro/src/scripts/reading-position.ts:9 — reading-position.initReadingPosition has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (12 pts), boolean chains 6, ternaries 5, error handling 1 (2 pts) (nesting depth added 2). Most of this is not in the body itself: 9 of the 25 points are its own statements and the rest belongs to 5 function items inside it that branch (save, restore, capture, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
D2 · Cognitive Complexity · validateExperimentEvidence (cognitive 25) · ×1
  • validateExperimentEvidence (cognitive 25) chapter6/live-audio/backend/experiment_validation.js:19 — validateExperimentEvidence has cognitive complexity 25 (threshold 15). Drivers by points: boolean chains 22, ternaries 3. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · demo_streaming.demo_unified_streaming (cognitive 24) · ×1
  • demo_streaming.demo_unified_streaming (cognitive 24) chapter2/local_llm_serving/demo_streaming.py:120 — demo_streaming.demo_unified_streaming has cognitive complexity 24 (threshold 15). Drivers by points: if/else 6 (21 pts), loops 2 (3 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_campaign.run_trial (cognitive 24) · ×1
  • run_campaign.run_trial (cognitive 24) chapter2/prompt-injection/run_campaign.py:107 — run_campaign.run_trial has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (11 pts), ternaries 5 (7 pts), boolean chains 6 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AdvancedMemoryManager.get_context_string (cognitive 24) · ×1
  • AdvancedMemoryManager.get_context_string (cognitive 24) chapter3/contextual-retrieval-for-user-memory/advanced_memory_manager.py:269 — AdvancedMemoryManager.get_context_string has cognitive complexity 24 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 4 (11 pts), boolean chains 2 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · regex_sanitizer.sanitize (cognitive 24) · ×1
  • regex_sanitizer.sanitize (cognitive 24) chapter3/log-sanitization/regex_sanitizer.py:186 — regex_sanitizer.sanitize has cognitive complexity 24 (threshold 15). Drivers by points: if/else 4 (12 pts), loops 5 (8 pts), boolean chains 2, ternaries 1 (2 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · main.run_memory_op (cognitive 24) · ×1
  • main.run_memory_op (cognitive 24) chapter3/mem0/main.py:242 — main.run_memory_op has cognitive complexity 24 (threshold 15). Drivers by points: if/else 9 (14 pts), loops 4 (9 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · extractor._normalize (cognitive 24) · ×1
  • extractor._normalize (cognitive 24) chapter3/structured-knowledge-extraction/extractor.py:85 — extractor._normalize has cognitive complexity 24 (threshold 15). Drivers by points: if/else 5 (11 pts), ternaries 2 (7 pts), error handling 1 (4 pts), boolean chains 1, loops 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InteractiveEvaluator.run_single_test (cognitive 24) · ×1
  • InteractiveEvaluator.run_single_test (cognitive 24) chapter3/user-memory-evaluation/main.py:71 — InteractiveEvaluator.run_single_test has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (11 pts), loops 4 (7 pts), ternaries 1 (4 pts), boolean chains 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · agent._run_loop (cognitive 24) · ×1
  • agent._run_loop (cognitive 24) chapter4/active-tool-discovery/agent.py:109 — agent._run_loop has cognitive complexity 24 (threshold 15). Drivers by points: if/else 6 (12 pts), ternaries 2 (5 pts), boolean chains 4, error handling 1 (2 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MultimodalAgent._extract_pdf_to_text (cognitive 24) · ×1
  • MultimodalAgent._extract_pdf_to_text (cognitive 24) chapter4/multimodal-agent/agent.py:622 — MultimodalAgent._extract_pdf_to_text has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (21 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 15). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · campaign.main (cognitive 24) · ×1
  • campaign.main (cognitive 24) chapter5/adaptive-log-parser/campaign.py:248 — campaign.main has cognitive complexity 24 (threshold 15). Drivers by points: boolean chains 10, if/else 5 (7 pts), loops 3 (4 pts), error handling 1 (3 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · agents._slide_contract_issues (cognitive 24) · ×1
  • agents._slide_contract_issues (cognitive 24) chapter5/paper-to-ppt/agents.py:213 — agents._slide_contract_issues has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (17 pts), boolean chains 3, ternaries 1 (3 pts), loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · benchmark_comparisons.run_improved_harness_test (cognitive 24) · ×1
  • benchmark_comparisons.run_improved_harness_test (cognitive 24) REDACTED:603 — benchmark_comparisons.run_improved_harness_test has cognitive complexity 24 (threshold 15). Drivers by points: error handling 5 (15 pts), if/else 2 (6 pts), loops 2 (3 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · benchmark_final_comprehensive.check_violations (cognitive 24) · ×1
  • benchmark_final_comprehensive.check_violations (cognitive 24) REDACTED:162 — benchmark_final_comprehensive.check_violations has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 6, loops 4, error handling 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PEDOSecurityEvaluator.evaluate_scenarios (cognitive 24) · ×1
  • PEDOSecurityEvaluator.evaluate_scenarios (cognitive 24) chapter5/permission-embedded-data-objects/run_live_security_eval.py:801 — PEDOSecurityEvaluator.evaluate_scenarios has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (17 pts), ternaries 5, boolean chains 1, loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · main.run (cognitive 24) · ×1
  • main.run (cognitive 24) chapter6/computer-use-open-model/main.py:90 — main.run has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 4, error handling 4, ternaries 3 (4 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CostEfficiencyAnalyzer.analyze_trajectory (cognitive 24) · ×1
  • CostEfficiencyAnalyzer.analyze_trajectory (cognitive 24) chapter7/agent-cost-analysis/cost_efficiency_analyzer.py:276 — CostEfficiencyAnalyzer.analyze_trajectory has cognitive complexity 24 (threshold 15). Drivers by points: if/else 9 (13 pts), loops 2 (4 pts), ternaries 3 (4 pts), boolean chains 3 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RepositoryHarness.execute (cognitive 24) · ×1
  • RepositoryHarness.execute (cognitive 24) chapter7/model-action-threshold/experiment.py:287 — RepositoryHarness.execute has cognitive complexity 24 (threshold 15). Drivers by points: if/else 9 (15 pts), loops 2 (5 pts), error handling 2 (4 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · campaign.measure_anthropic (cognitive 24) · ×1
  • campaign.measure_anthropic (cognitive 24) chapter7/model-benchmark/campaign.py:615 — campaign.measure_anthropic has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (14 pts), boolean chains 6, loops 2, error handling 1, ternaries 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · customer_service_env._derive_claims_and_promises (cognitive 24) · ×1
  • customer_service_env._derive_claims_and_promises (cognitive 24) chapter9/trajectory-verifier/customer_service_env.py:184 — customer_service_env._derive_claims_and_promises has cognitive complexity 24 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 3 (5 pts), ternaries 1 (4 pts), boolean chains 2 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · gen_star_history.pick_xticks (cognitive 24) · ×1
  • gen_star_history.pick_xticks (cognitive 24) scripts/gen_star_history.py:447 — gen_star_history.pick_xticks has cognitive complexity 24 (threshold 15). Drivers by points: loops 6 (13 pts), ternaries 2 (6 pts), if/else 3 (5 pts) (nesting depth added 13). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · search-index-router.slugForPath (cognitive 24) · ×1
  • search-index-router.slugForPath (cognitive 24) extras/search-index-router.js:32 — search-index-router.slugForPath has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (15 pts), boolean chains 4, loops 3 (4 pts), error handling 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TreasureHuntGame._attack (cognitive 23) · ×1
  • TreasureHuntGame._attack (cognitive 23) chapter1/learning-from-experience/game_environment.py:378 — TreasureHuntGame._attack has cognitive complexity 23 (threshold 15). Drivers by points: if/else 12 (21 pts), boolean chains 1, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_campaign.run_arm (cognitive 23) · ×1
  • run_campaign.run_arm (cognitive 23) chapter10/generative-agents/run_campaign.py:468 — run_campaign.run_arm has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (18 pts), boolean chains 2, ternaries 1 (2 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SimulatedVoiceSession.__init__ (cognitive 23) · ×1
  • SimulatedVoiceSession.__init__ (cognitive 23) REDACTED:53 — SimulatedVoiceSession.__init__ has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 4, ternaries 2 (4 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · visualization.create_token_attention_summary (cognitive 23) · ×1
  • visualization.create_token_attention_summary (cognitive 23) chapter2/attention_visualization/visualization.py:219 — visualization.create_token_attention_summary has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 4 (8 pts), ternaries 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · demo._parse_selection (cognitive 23) · ×1
  • demo._parse_selection (cognitive 23) chapter2/prompt-injection/demo.py:32 — demo._parse_selection has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (21 pts), boolean chains 1, loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DocumentStore.add_document (cognitive 23) · ×1
  • DocumentStore.add_document (cognitive 23) chapter3/retrieval-pipeline/document_store.py:16 — DocumentStore.add_document has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (17 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 12). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · main.main (cognitive 23) · ×1
  • main.main (cognitive 23) chapter3/user-memory-evaluation/main.py:345 — main.main has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (16 pts), loops 1 (3 pts), ternaries 1 (3 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · quickstart.test_tools (cognitive 23) · ×1
  • quickstart.test_tools (cognitive 23) chapter4/perception-tools/quickstart.py:22 — quickstart.test_tools has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (14 pts), error handling 6, loops 1 (3 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · expanded_catalog._filesystem (cognitive 23) · ×1
  • expanded_catalog._filesystem (cognitive 23) chapter4/perception-tools/src/expanded_catalog.py:696 — expanded_catalog._filesystem has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (11 pts), ternaries 4 (8 pts), loops 2 (4 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · filesystem_tools.grep_search (cognitive 23) · ×1
  • filesystem_tools.grep_search (cognitive 23) chapter4/perception-tools/src/filesystem_tools.py:382 — filesystem_tools.grep_search has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (16 pts), error handling 2 (3 pts), loops 2 (3 pts), ternaries 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · seed.generate (cognitive 23) · ×1
  • seed.generate (cognitive 23) chapter5/erp-agent/seed.py:44 — seed.generate has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (9 pts), loops 7 (9 pts), boolean chains 3, ternaries 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · demo.self_check (cognitive 23) · ×1
  • demo.self_check (cognitive 23) chapter5/paper-to-video/demo.py:382 — demo.self_check has cognitive complexity 23 (threshold 15). Drivers by points: ternaries 8 (13 pts), boolean chains 6, if/else 3, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PermissionRule._evaluate_condition (cognitive 23) · ×1
  • PermissionRule._evaluate_condition (cognitive 23) chapter5/permission-embedded-data-objects/pedo/core/models.py:54 — PermissionRule._evaluate_condition has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (21 pts), boolean chains 1, loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ObjectStore._handle_delete_cascades (cognitive 23) · ×1
  • ObjectStore._handle_delete_cascades (cognitive 23) chapter5/permission-embedded-data-objects/pedo/core/store.py:427 — ObjectStore._handle_delete_cascades has cognitive complexity 23 (threshold 15). Drivers by points: loops 5 (14 pts), if/else 3 (9 pts) (nesting depth added 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · evaluate_audio_quality.validate_response (cognitive 23) · ×1
  • evaluate_audio_quality.validate_response (cognitive 23) REDACTED:149 — evaluate_audio_quality.validate_response has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (14 pts), boolean chains 6, loops 2 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · pipeline.judge_gemini_audio (cognitive 23) · ×1
  • pipeline.judge_gemini_audio (cognitive 23) REDACTED:676 — pipeline.judge_gemini_audio has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (15 pts), boolean chains 7, error handling 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · experiment.interaction_analysis (cognitive 23) · ×1
  • experiment.interaction_analysis (cognitive 23) chapter7/user-memory-system-evaluation/experiment.py:1301 — experiment.interaction_analysis has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (11 pts), boolean chains 7, loops 3, ternaries 2 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SFTDataQualityAuditor.find_duplicates (cognitive 23) · ×1
  • SFTDataQualityAuditor.find_duplicates (cognitive 23) chapter8/cot-distillation/sft_data_auditor.py:357 — SFTDataQualityAuditor.find_duplicates has cognitive complexity 23 (threshold 15). Drivers by points: loops 7 (12 pts), if/else 5 (11 pts) (nesting depth added 11). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · index.Home (cognitive 23) · ×1
  • index.Home (cognitive 23) chapter2/attention_visualization/frontend/pages/index.tsx:56 — index.Home has cognitive complexity 23 (threshold 15). Drivers by points: boolean chains 20, if/else 7 (9 pts), ternaries 3 (6 pts), error handling 3 (5 pts), loops 1 (nesting depth added 7). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators. This shape REPEATS in the file: one other method here (index.Home::loadTrajectories) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · fix_svg_text_layout.apply_figure_overrides (cognitive 22) · ×1
  • fix_svg_text_layout.apply_figure_overrides (cognitive 22) REDACTED:347 — fix_svg_text_layout.apply_figure_overrides has cognitive complexity 22 (threshold 15). Drivers by points: if/else 5 (14 pts), boolean chains 3, ternaries 1 (3 pts), loops 1 (2 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · calc_sandbox._check (cognitive 22) · ×1
  • calc_sandbox._check (cognitive 22) REDACTED:49 — calc_sandbox._check has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (11 pts), loops 5 (10 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RegistrationBrowser.fill (cognitive 22) · ×1
  • RegistrationBrowser.fill (cognitive 22) chapter10/autonomous-phone-registration/browser.py:87 — RegistrationBrowser.fill has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (15 pts), error handling 3 (4 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · decision.decide_orchestration (cognitive 22) · ×1
  • decision.decide_orchestration (cognitive 22) chapter10/autonomous-phone-registration/decision.py:72 — decision.decide_orchestration has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (8 pts), boolean chains 5, loops 3 (5 pts), error handling 1 (2 pts), ternaries 2 (nesting depth added 5). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · BilingualConsistencyAuditor._audit_terminology (cognitive 22) · ×1
  • BilingualConsistencyAuditor._audit_terminology (cognitive 22) chapter10/book-translation/consistency_auditor.py:181 — BilingualConsistencyAuditor._audit_terminology has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 3 (6 pts), boolean chains 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · evaluation.evaluate_task (cognitive 22) · ×1
  • evaluation.evaluate_task (cognitive 22) chapter10/multi-role-transfer/evaluation.py:148 — evaluation.evaluate_task has cognitive complexity 22 (threshold 15). Drivers by points: boolean chains 17, if/else 5. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · run_comparison._aggregate (cognitive 22) · ×1
  • run_comparison._aggregate (cognitive 22) chapter10/multi-role-transfer/run_comparison.py:347 — run_comparison._aggregate has cognitive complexity 22 (threshold 15). Drivers by points: ternaries 8 (16 pts), if/else 2 (4 pts), loops 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · validate_campaign.main (cognitive 22) · ×1
  • validate_campaign.main (cognitive 22) chapter10/talkact-reproduction/validate_campaign.py:40 — validate_campaign.main has cognitive complexity 22 (threshold 15). Drivers by points: boolean chains 9, if/else 8 (9 pts), ternaries 3, loops 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · ContextualMemoryIndexer.search_with_context (cognitive 22) · ×1
  • ContextualMemoryIndexer.search_with_context (cognitive 22) chapter3/contextual-retrieval-for-user-memory/contextual_indexer.py:422 — ContextualMemoryIndexer.search_with_context has cognitive complexity 22 (threshold 15). Drivers by points: loops 6 (11 pts), if/else 5 (8 pts), boolean chains 2, error handling 1 (nesting depth added 8). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · MemoryIndexer.search (cognitive 22) · ×1
  • MemoryIndexer.search (cognitive 22) chapter3/contextual-retrieval-for-user-memory/indexer.py:272 — MemoryIndexer.search has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 7, error handling 1, loops 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · campaign.build_sample (cognitive 22) · ×1
  • campaign.build_sample (cognitive 22) chapter3/structured-knowledge-extraction/campaign.py:82 — campaign.build_sample has cognitive complexity 22 (threshold 15). Drivers by points: if/else 5 (9 pts), boolean chains 4, loops 3 (4 pts), ternaries 1 (3 pts), error handling 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · NotesMemoryManager.update_memory (cognitive 22) · ×1
  • NotesMemoryManager.update_memory (cognitive 22) chapter3/user-memory/memory_manager.py:193 — NotesMemoryManager.update_memory has cognitive complexity 22 (threshold 15). Drivers by points: if/else 5 (13 pts), ternaries 2 (8 pts), loops 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · timer_tools._load_timers (cognitive 22) · ×1
  • timer_tools._load_timers (cognitive 22) chapter4/collaboration-tools/src/timer_tools.py:419 — timer_tools._load_timers has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (16 pts), ternaries 1 (3 pts), boolean chains 1, error handling 1, loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_experiment_4_2.derive_acceptance (cognitive 22) · ×1
  • run_experiment_4_2.derive_acceptance (cognitive 22) chapter4/perception-tools/run_experiment_4_2.py:459 — run_experiment_4_2.derive_acceptance has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 8, loops 1, ternaries 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · yahoo_finance_tools.get_financial_statements (cognitive 22) · ×1
  • yahoo_finance_tools.get_financial_statements (cognitive 22) chapter4/perception-tools/src/yahoo_finance_tools.py:327 — yahoo_finance_tools.get_financial_statements has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (9 pts), ternaries 3 (6 pts), error handling 2 (4 pts), boolean chains 2, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · demo.main (cognitive 22) · ×1
  • demo.main (cognitive 22) chapter5/adaptive-log-parser/demo.py:176 — demo.main has cognitive complexity 22 (threshold 15). Drivers by points: if/else 12 (14 pts), ternaries 4 (5 pts), loops 2 (3 pts) (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · benchmark_safety_final.check_db_violations (cognitive 22) · ×1
  • benchmark_safety_final.check_db_violations (cognitive 22) REDACTED:190 — benchmark_safety_final.check_db_violations has cognitive complexity 22 (threshold 15). Drivers by points: if/else 4 (8 pts), ternaries 3 (6 pts), loops 4, boolean chains 2, error handling 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · harness.check_hiring_violations (cognitive 22) · ×1
  • harness.check_hiring_violations (cognitive 22) REDACTED:374 — harness.check_hiring_violations has cognitive complexity 22 (threshold 15). Drivers by points: if/else 4 (8 pts), ternaries 3 (6 pts), loops 4, boolean chains 2, error handling 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · summarize.continuation_summary (cognitive 22) · ×1
  • summarize.continuation_summary (cognitive 22) chapter5/provider-failover/summarize.py:67 — summarize.continuation_summary has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 5, loops 3, ternaries 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · validate_weather_run.main (cognitive 22) · ×1
  • validate_weather_run.main (cognitive 22) chapter6/claude-computer-use-native/validate_weather_run.py:28 — validate_weather_run.main has cognitive complexity 22 (threshold 15). Drivers by points: boolean chains 14, if/else 5 (6 pts), loops 1, ternaries 1 (nesting depth added 1). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · pipeline.main (cognitive 22) · ×1
  • pipeline.main (cognitive 22) chapter6/rgb-sim2real-grasping/pipeline.py:146 — pipeline.main has cognitive complexity 22 (threshold 15). Drivers by points: if/else 5 (10 pts), loops 4 (6 pts), boolean chains 3, error handling 2, ternaries 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_controlled_experiment._validate_resume_evidence (cognitive 22) · ×1
  • run_controlled_experiment._validate_resume_evidence (cognitive 22) chapter7/android-world/run_controlled_experiment.py:1270 — run_controlled_experiment._validate_resume_evidence has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (16 pts), error handling 2 (5 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · validate_evidence.main (cognitive 22) · ×1
  • validate_evidence.main (cognitive 22) chapter7/elo-leaderboard/validation/validate_evidence.py:19 — validate_evidence.main has cognitive complexity 22 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 2, loops 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · experiment.selected_pricing_manifest (cognitive 22) · ×1
  • experiment.selected_pricing_manifest (cognitive 22) chapter7/user-memory-system-evaluation/experiment.py:1453 — experiment.selected_pricing_manifest has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (13 pts), loops 4, error handling 1 (3 pts), boolean chains 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · create_data.parse_final_answer (cognitive 22) · ×1
  • create_data.parse_final_answer (cognitive 22) chapter8/prompt-distillation/create_data.py:88 — create_data.parse_final_answer has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (18 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · evaluate.evaluate_rules (cognitive 22) · ×1
  • evaluate.evaluate_rules (cognitive 22) chapter9/ai-style-skill/evaluate.py:32 — evaluate.evaluate_rules has cognitive complexity 22 (threshold 15). Drivers by points: loops 5 (8 pts), if/else 3 (7 pts), ternaries 4 (6 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConnectionHandler.isCompleteSentence (cognitive 22) · ×1
  • ConnectionHandler.isCompleteSentence (cognitive 22) chapter6/live-audio/backend/server.js:535 — ConnectionHandler.isCompleteSentence has cognitive complexity 22 (threshold 15). Drivers by points: if/else 13 (17 pts), boolean chains 5 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · run_experiment_1_2.validate (cognitive 21) · ×1
  • run_experiment_1_2.validate (cognitive 21) chapter1/web-search-agent/run_experiment_1_2.py:91 — run_experiment_1_2.validate has cognitive complexity 21 (threshold 15). Drivers by points: boolean chains 17, if/else 4. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · agents.get_client (cognitive 21) · ×1
  • agents.get_client (cognitive 21) chapter10/book-translation/agents.py:56 — agents.get_client has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (15 pts), boolean chains 4, ternaries 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SkillOrchestrator._handle_tool (cognitive 21) · ×1
  • SkillOrchestrator._handle_tool (cognitive 21) chapter10/multi-role-transfer/skill_orchestrator.py:218 — SkillOrchestrator._handle_tool has cognitive complexity 21 (threshold 15). Drivers by points: if/else 11 (15 pts), boolean chains 5, error handling 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StagedAgent._run_one_model_turn (cognitive 21) · ×1
  • StagedAgent._run_one_model_turn (cognitive 21) chapter10/staged-system-prompt/agent.py:300 — StagedAgent._run_one_model_turn has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 3, error handling 2 (3 pts), loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Agent.execute_tool (cognitive 21) · ×1
  • Agent.execute_tool (cognitive 21) REDACTED:239 — Agent.execute_tool has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (14 pts), ternaries 2 (6 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SystemHintAgent._tool_read_file (cognitive 21) · ×1
  • SystemHintAgent._tool_read_file (cognitive 21) REDACTED:556 — SystemHintAgent._tool_read_file has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (14 pts), error handling 3, boolean chains 2, ternaries 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_experiment_2_8.component_scores (cognitive 21) · ×1
  • run_experiment_2_8.component_scores (cognitive 21) chapter2/system-hint/run_experiment_2_8.py:390 — run_experiment_2_8.component_scores has cognitive complexity 21 (threshold 15). Drivers by points: boolean chains 12, if/else 7 (8 pts), ternaries 1 (nesting depth added 1). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · ContextualMemoryEvaluator.generate_report (cognitive 21) · ×1
  • ContextualMemoryEvaluator.generate_report (cognitive 21) chapter3/contextual-retrieval-for-user-memory/contextual_evaluator.py:655 — ContextualMemoryEvaluator.generate_report has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (14 pts), ternaries 2 (4 pts), loops 3 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · campaign.normalize_schema (cognitive 21) · ×1
  • campaign.normalize_schema (cognitive 21) chapter3/structured-knowledge-extraction/campaign.py:205 — campaign.normalize_schema has cognitive complexity 21 (threshold 15). Drivers by points: boolean chains 9, ternaries 2 (6 pts), if/else 1 (3 pts), loops 2 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InteractiveEvaluator._display_result (cognitive 21) · ×1
  • InteractiveEvaluator._display_result (cognitive 21) chapter3/user-memory-evaluation/main.py:221 — InteractiveEvaluator._display_result has cognitive complexity 21 (threshold 15). Drivers by points: ternaries 7 (13 pts), if/else 4, loops 2 (4 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BackgroundMemoryProcessor.process_recent_conversations (cognitive 21) · ×1
  • BackgroundMemoryProcessor.process_recent_conversations (cognitive 21) chapter3/user-memory/background_memory_processor.py:364 — BackgroundMemoryProcessor.process_recent_conversations has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (15 pts), boolean chains 3, loops 3 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_exact_experiment.substantive_payload (cognitive 21) · ×1
  • run_exact_experiment.substantive_payload (cognitive 21) chapter4/active-tool-discovery/run_exact_experiment.py:363 — run_exact_experiment.substantive_payload has cognitive complexity 21 (threshold 15). Drivers by points: boolean chains 11, if/else 9 (10 pts) (nesting depth added 1). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · run_exact_experiment.run_group (cognitive 21) · ×1
  • run_exact_experiment.run_group (cognitive 21) chapter4/active-tool-discovery/run_exact_experiment.py:791 — run_exact_experiment.run_group has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (15 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · example_complex_task.run_complex_task (cognitive 21) · ×1
  • example_complex_task.run_complex_task (cognitive 21) chapter5/coding-agent/example_complex_task.py:10 — example_complex_task.run_complex_task has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (20 pts), loops 1 (nesting depth added 13). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · campaign.run (cognitive 21) · ×1
  • campaign.run (cognitive 21) chapter5/video-edit/campaign.py:473 — campaign.run has cognitive complexity 21 (threshold 15). Drivers by points: boolean chains 11, if/else 8 (9 pts), loops 1 (nesting depth added 1). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · unipile_mailbox_experiment.run (cognitive 21) · ×1
  • unipile_mailbox_experiment.run (cognitive 21) chapter6/agent-with-event-trigger/unipile_mailbox_experiment.py:652 — unipile_mailbox_experiment.run has cognitive complexity 21 (threshold 15). Drivers by points: ternaries 6 (9 pts), boolean chains 6, if/else 4 (5 pts), error handling 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · validate_evidence.validate (cognitive 21) · ×1
  • validate_evidence.validate (cognitive 21) chapter6/gemini-xlerobot-navigation/validate_evidence.py:24 — validate_evidence.validate has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (11 pts), error handling 1 (5 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · experiment.run_cell (cognitive 21) · ×1
  • experiment.run_cell (cognitive 21) chapter7/model-action-threshold/experiment.py:375 — experiment.run_cell has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (7 pts), boolean chains 6, error handling 2 (5 pts), loops 2 (3 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · experiment.failure_boundary_analysis (cognitive 21) · ×1
  • experiment.failure_boundary_analysis (cognitive 21) chapter7/user-memory-system-evaluation/experiment.py:1395 — experiment.failure_boundary_analysis has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 4 (5 pts), boolean chains 4 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_report_audit.validate_judgment (cognitive 21) · ×1
  • run_report_audit.validate_judgment (cognitive 21) REDACTED:254 — run_report_audit.validate_judgment has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (13 pts), boolean chains 5, loops 2 (3 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · quality_audit.check_row (cognitive 21) · ×1
  • quality_audit.check_row (cognitive 21) chapter8/curly-quote-sft/quality_audit.py:24 — quality_audit.check_row has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 1 (3 pts), ternaries 1 (3 pts), boolean chains 1 (nesting depth added 12). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · compare.compare (cognitive 21) · ×1
  • compare.compare (cognitive 21) chapter8/prompt-distillation/compare.py:110 — compare.compare has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (9 pts), ternaries 4 (8 pts), boolean chains 2, loops 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · fix_svg_text_layout.css_font_sizes (cognitive 20) · ×1
  • fix_svg_text_layout.css_font_sizes (cognitive 20) REDACTED:122 — fix_svg_text_layout.css_font_sizes has cognitive complexity 20 (threshold 15). Drivers by points: if/else 4 (14 pts), loops 3 (6 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · fix_svg_text_layout.validate_file (cognitive 20) · ×1
  • fix_svg_text_layout.validate_file (cognitive 20) REDACTED:503 — fix_svg_text_layout.validate_file has cognitive complexity 20 (threshold 15). Drivers by points: if/else 4 (9 pts), ternaries 2 (5 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AblationTestSuite.analyze_results (cognitive 20) · ×1
  • AblationTestSuite.analyze_results (cognitive 20) chapter1/context/main.py:291 — AblationTestSuite.analyze_results has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (18 pts), loops 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExperimentRunner.compare_learning_curves (cognitive 20) · ×1
  • ExperimentRunner.compare_learning_curves (cognitive 20) chapter1/learning-from-experience/experiment.py:265 — ExperimentRunner.compare_learning_curves has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (9 pts), loops 5 (6 pts), ternaries 3 (4 pts), boolean chains 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · GPT5NativeAgent.process_request (cognitive 20) · ×1
  • GPT5NativeAgent.process_request (cognitive 20) chapter1/search-codegen/agent.py:233 — GPT5NativeAgent.process_request has cognitive complexity 20 (threshold 15). Drivers by points: boolean chains 8, ternaries 4 (8 pts), if/else 3, error handling 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ComputerAgent.run (cognitive 20) · ×1
  • ComputerAgent.run (cognitive 20) chapter10/autonomous-phone-registration/orchestration.py:306 — ComputerAgent.run has cognitive complexity 20 (threshold 15). Drivers by points: if/else 5 (11 pts), error handling 2 (6 pts), loops 2, boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · evaluation._custom_task_score (cognitive 20) · ×1
  • evaluation._custom_task_score (cognitive 20) chapter10/multi-role-transfer/evaluation.py:67 — evaluation._custom_task_score has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (10 pts), boolean chains 8, loops 1 (2 pts) (nesting depth added 3). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · Judge._witch_act (cognitive 20) · ×1
  • Judge._witch_act (cognitive 20) chapter10/voice-werewolf/werewolf/game.py:279 — Judge._witch_act has cognitive complexity 20 (threshold 15). Drivers by points: if/else 11 (16 pts), boolean chains 4 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Judge.day (cognitive 20) · ×1
  • Judge.day (cognitive 20) chapter10/voice-werewolf/werewolf/game.py:340 — Judge.day has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (17 pts), boolean chains 2, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LocalFileTools.find (cognitive 20) · ×1
  • LocalFileTools.find (cognitive 20) chapter2/kv-cache/agent.py:181 — LocalFileTools.find has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (14 pts), loops 2 (3 pts), boolean chains 2, error handling 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · demo.run_matrix (cognitive 20) · ×1
  • demo.run_matrix (cognitive 20) chapter2/prompt-injection/demo.py:93 — demo.run_matrix has cognitive complexity 20 (threshold 15). Drivers by points: if/else 2 (8 pts), loops 3 (6 pts), ternaries 2 (6 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_experiment_2_8.summarize (cognitive 20) · ×1
  • run_experiment_2_8.summarize (cognitive 20) chapter2/system-hint/run_experiment_2_8.py:675 — run_experiment_2_8.summarize has cognitive complexity 20 (threshold 15). Drivers by points: boolean chains 9, if/else 6 (8 pts), loops 2, ternaries 1 (nesting depth added 2). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · view_trajectory.view_trajectory (cognitive 20) · ×1
  • view_trajectory.view_trajectory (cognitive 20) chapter2/system-hint/view_trajectory.py:20 — view_trajectory.view_trajectory has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (10 pts), loops 4 (7 pts), error handling 3 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InteractiveContextualRAG.manage_memory_cards (cognitive 20) · ×1
  • InteractiveContextualRAG.manage_memory_cards (cognitive 20) chapter3/contextual-retrieval-for-user-memory/main.py:304 — InteractiveContextualRAG.manage_memory_cards has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (14 pts), loops 3 (6 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · main.main (cognitive 20) · ×1
  • main.main (cognitive 20) chapter3/contextual-retrieval-for-user-memory/main.py:731 — main.main has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (11 pts), error handling 1 (3 pts), ternaries 1 (3 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · memory_rag_campaign.fixed_window_chunks (cognitive 20) · ×1
  • memory_rag_campaign.fixed_window_chunks (cognitive 20) chapter3/memory_rag_campaign.py:73 — memory_rag_campaign.fixed_window_chunks has cognitive complexity 20 (threshold 15). Drivers by points: if/else 5 (14 pts), loops 3 (5 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExecutionTools.code_interpreter (cognitive 20) · ×1
  • ExecutionTools.code_interpreter (cognitive 20) chapter4/execution-tools/execution_tools.py:78 — ExecutionTools.code_interpreter has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (15 pts), boolean chains 3, error handling 1, ternaries 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExecutionTools.virtual_terminal (cognitive 20) · ×1
  • ExecutionTools.virtual_terminal (cognitive 20) chapter4/execution-tools/execution_tools.py:195 — ExecutionTools.virtual_terminal has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (18 pts), error handling 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · campaign.main (cognitive 20) · ×1
  • campaign.main (cognitive 20) chapter4/multimodal-agent/campaign.py:239 — campaign.main has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (8 pts), boolean chains 5, loops 4 (5 pts), ternaries 2 (nesting depth added 2). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · validator._protocol_is_valid (cognitive 20) · ×1
  • validator._protocol_is_valid (cognitive 20) chapter5/agent-creator/validator.py:235 — validator._protocol_is_valid has cognitive complexity 20 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 2 (4 pts), boolean chains 3 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · validate_manifest.validate_manifest (cognitive 20) · ×1
  • validate_manifest.validate_manifest (cognitive 20) chapter5/cad-vs-diffusion/validate_manifest.py:34 — validate_manifest.validate_manifest has cognitive complexity 20 (threshold 15). Drivers by points: loops 10 (17 pts), if/else 1 (2 pts), boolean chains 1 (nesting depth added 8). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · demo.call_model (cognitive 20) · ×1
  • demo.call_model (cognitive 20) chapter5/code-for-logic/demo.py:227 — demo.call_model has cognitive complexity 20 (threshold 15). Drivers by points: ternaries 2 (5 pts), error handling 1 (4 pts), if/else 2 (4 pts), loops 2 (4 pts), boolean chains 3 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · benchmark_safety.run_safety_evaluation (cognitive 20) · ×1
  • benchmark_safety.run_safety_evaluation (cognitive 20) REDACTED:509 — benchmark_safety.run_safety_evaluation has cognitive complexity 20 (threshold 15). Drivers by points: if/else 4 (14 pts), error handling 1 (3 pts), loops 2 (3 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · agent.run_agent (cognitive 20) · ×1
  • agent.run_agent (cognitive 20) chapter5/small-model-codified-rules/agent.py:190 — agent.run_agent has cognitive complexity 20 (threshold 15). Drivers by points: if/else 4 (8 pts), boolean chains 4, error handling 1 (4 pts), loops 2 (4 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TaskManager._run (cognitive 20) · ×1
  • TaskManager._run (cognitive 20) chapter6/async-agent/tasks.py:138 — TaskManager._run has cognitive complexity 20 (threshold 15). Drivers by points: if/else 5 (9 pts), error handling 3 (5 pts), ternaries 2 (3 pts), boolean chains 2, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · validate_artifacts.main (cognitive 20) · ×1
  • validate_artifacts.main (cognitive 20) chapter6/controllable-tts/validate_artifacts.py:34 — validate_artifacts.main has cognitive complexity 20 (threshold 15). Drivers by points: boolean chains 10, ternaries 4, error handling 1 (2 pts), if/else 2, loops 2 (nesting depth added 1). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · desktop_planner.main (cognitive 20) · ×1
  • desktop_planner.main (cognitive 20) chapter6/gemini-xlerobot-navigation/desktop_planner.py:226 — desktop_planner.main has cognitive complexity 20 (threshold 15). Drivers by points: loops 4 (10 pts), ternaries 2 (5 pts), boolean chains 2, error handling 2, if/else 1 (nesting depth added 9). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · runner.run (cognitive 20) · ×1
  • runner.run (cognitive 20) chapter7/user-memory-policy-eval/runner.py:202 — runner.run has cognitive complexity 20 (threshold 15). Drivers by points: if/else 4 (8 pts), ternaries 4 (5 pts), loops 3 (4 pts), error handling 1 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MemoryAgent.rag (cognitive 20) · ×1
  • MemoryAgent.rag (cognitive 20) chapter7/user-memory-system-evaluation/experiment.py:647 — MemoryAgent.rag has cognitive complexity 20 (threshold 15). Drivers by points: if/else 4 (8 pts), loops 3 (6 pts), ternaries 3 (4 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · experiment.validate_readiness (cognitive 20) · ×1
  • experiment.validate_readiness (cognitive 20) chapter7/user-memory-system-evaluation/experiment.py:1916 — experiment.validate_readiness has cognitive complexity 20 (threshold 15). Drivers by points: if/else 11 (15 pts), boolean chains 4, loops 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · evaluate_from_cache.normalize_number (cognitive 20) · ×1
  • evaluate_from_cache.normalize_number (cognitive 20) chapter8/Intuitor/evaluate_from_cache.py:71 — evaluate_from_cache.normalize_number has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (11 pts), error handling 3 (6 pts), ternaries 1 (2 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_vlm_training_report_audit.validate_judgment (cognitive 20) · ×1
  • run_vlm_training_report_audit.validate_judgment (cognitive 20) REDACTED:417 — run_vlm_training_report_audit.validate_judgment has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (13 pts), boolean chains 4, loops 2 (3 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · analyze_data.main (cognitive 20) · ×1
  • analyze_data.main (cognitive 20) chapter8/cot-distillation/analyze_data.py:8 — analyze_data.main has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (12 pts), ternaries 2 (4 pts), loops 2, boolean chains 1, error handling 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_experiment_9_7.main (cognitive 20) · ×1
  • run_experiment_9_7.main (cognitive 20) chapter9/harness-safety-gate/run_experiment_9_7.py:47 — run_experiment_9_7.main has cognitive complexity 20 (threshold 15). Drivers by points: ternaries 7 (9 pts), boolean chains 4, loops 3 (4 pts), if/else 3 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · context-flow-figures.layoutContextFlow (cognitive 20) · ×1
  • context-flow-figures.layoutContextFlow (cognitive 20) REDACTED:11 — context-flow-figures.layoutContextFlow has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (13 pts), ternaries 4 (6 pts), boolean chains 1 (nesting depth added 5). Most of this is not in the body itself: 8 of the 20 points are its own statements and the rest belongs to 11 function items inside it that branch (a function literal at line 55, caption, a function literal at line 140, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
D2 · Cognitive Complexity · run_experiment_1_1.evaluate_context_contract (cognitive 19) · ×1
  • run_experiment_1_1.evaluate_context_contract (cognitive 19) chapter1/context/run_experiment_1_1.py:155 — run_experiment_1_1.evaluate_context_contract has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 9 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · pipeline.generate_image_gemini (cognitive 19) · ×1
  • pipeline.generate_image_gemini (cognitive 19) chapter1/image-gen-workflow/pipeline.py:235 — pipeline.generate_image_gemini has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (7 pts), boolean chains 4, ternaries 1 (4 pts), loops 2 (3 pts), error handling 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LLMAgent.train (cognitive 19) · ×1
  • LLMAgent.train (cognitive 19) chapter1/learning-from-experience/llm_agent.py:511 — LLMAgent.train has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (11 pts), ternaries 2 (4 pts), boolean chains 3, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · QLearningAgent.train (cognitive 19) · ×1
  • QLearningAgent.train (cognitive 19) REDACTED:173 — QLearningAgent.train has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (10 pts), ternaries 3 (5 pts), boolean chains 3, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_experiment_8_2.main (cognitive 19) · ×1
  • run_experiment_8_2.main (cognitive 19) chapter1/learning-from-experience/run_experiment_8_2.py:69 — run_experiment_8_2.main has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 10, if/else 5, ternaries 4. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · consistency.analyze (cognitive 19) · ×1
  • consistency.analyze (cognitive 19) chapter10/book-translation/consistency.py:97 — consistency.analyze has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (12 pts), loops 3 (6 pts), ternaries 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · package_comparison.main (cognitive 19) · ×1
  • package_comparison.main (cognitive 19) chapter10/multi-role-transfer/package_comparison.py:75 — package_comparison.main has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 13, if/else 3, ternaries 2, loops 1. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · llm.extract_profile (cognitive 19) · ×1
  • llm.extract_profile (cognitive 19) chapter10/parallel-web-research/llm.py:32 — llm.extract_profile has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (10 pts), boolean chains 3, ternaries 1 (3 pts), error handling 1 (2 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · offline_demo.run_demo (cognitive 19) · ×1
  • offline_demo.run_demo (cognitive 19) chapter3/agentic-rag-for-user-memory/offline_demo.py:135 — offline_demo.run_demo has cognitive complexity 19 (threshold 15). Drivers by points: ternaries 5 (9 pts), if/else 6, loops 3, boolean chains 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ComparisonRunner.generate_report (cognitive 19) · ×1
  • ComparisonRunner.generate_report (cognitive 19) chapter3/user-memory-evaluation/comparison.py:155 — ComparisonRunner.generate_report has cognitive complexity 19 (threshold 15). Drivers by points: loops 5 (7 pts), if/else 3 (6 pts), ternaries 3 (6 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Campaign.run_one (cognitive 19) · ×1
  • Campaign.run_one (cognitive 19) chapter3/user-memory/run_evaluation.py:245 — Campaign.run_one has cognitive complexity 19 (threshold 15). Drivers by points: if/else 11 (14 pts), boolean chains 3, loops 1, ternaries 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · expanded_catalog._web (cognitive 19) · ×1
  • expanded_catalog._web (cognitive 19) chapter4/perception-tools/src/expanded_catalog.py:586 — expanded_catalog._web has cognitive complexity 19 (threshold 15). Drivers by points: if/else 12 (16 pts), ternaries 1 (2 pts), loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · filesystem_tools._fingerprint (cognitive 19) · ×1
  • filesystem_tools._fingerprint (cognitive 19) chapter4/perception-tools/src/filesystem_tools.py:118 — filesystem_tools._fingerprint has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (8 pts), loops 3 (8 pts), ternaries 1 (3 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · filesystem_tools.copy_path (cognitive 19) · ×1
  • filesystem_tools.copy_path (cognitive 19) chapter4/perception-tools/src/filesystem_tools.py:218 — filesystem_tools.copy_path has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10 (15 pts), error handling 2, boolean chains 1, ternaries 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AgentCreator.repair_after_live_failure (cognitive 19) · ×1
  • AgentCreator.repair_after_live_failure (cognitive 19) chapter5/agent-creator/creator.py:1289 — AgentCreator.repair_after_live_failure has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 6, if/else 5 (6 pts), ternaries 3 (4 pts), error handling 1 (2 pts), loops 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · creator.resolve_client (cognitive 19) · ×1
  • creator.resolve_client (cognitive 19) chapter5/agent-creator/creator.py:71 — creator.resolve_client has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 9, if/else 4 (8 pts), loops 1, ternaries 1 (nesting depth added 4). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · GeneratedAgent.run (cognitive 19) · ×1
  • GeneratedAgent.run (cognitive 19) chapter5/agent-creator/reference_agent/agent.py:61 — GeneratedAgent.run has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 8, if/else 3 (5 pts), error handling 1 (3 pts), loops 2 (3 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CodingAgent._convert_to_openai_format (cognitive 19) · ×1
  • CodingAgent._convert_to_openai_format (cognitive 19) chapter5/coding-agent/agent.py:421 — CodingAgent._convert_to_openai_format has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (13 pts), loops 2 (5 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LSTool._execute_impl (cognitive 19) · ×1
  • LSTool._execute_impl (cognitive 19) chapter5/coding-agent/tools/ls_tool.py:19 — LSTool._execute_impl has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (10 pts), ternaries 2 (4 pts), loops 2 (3 pts), error handling 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · oracle.run_shopping_cart_oracle (cognitive 19) · ×1
  • oracle.run_shopping_cart_oracle (cognitive 19) REDACTED:184 — oracle.run_shopping_cart_oracle has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (10 pts), error handling 4, loops 2 (3 pts), boolean chains 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · benchmark_comparisons.test_rls_violations (cognitive 19) · ×1
  • benchmark_comparisons.test_rls_violations (cognitive 19) REDACTED:84 — benchmark_comparisons.test_rls_violations has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10, error handling 7, boolean chains 2. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · AgentRuntime.run_llm_turn (cognitive 19) · ×1
  • AgentRuntime.run_llm_turn (cognitive 19) chapter6/async-agent/runtime.py:265 — AgentRuntime.run_llm_turn has cognitive complexity 19 (threshold 15). Drivers by points: if/else 3 (6 pts), ternaries 2 (4 pts), boolean chains 3, error handling 1 (3 pts), loops 2 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · analysis.summarize_workloads (cognitive 19) · ×1
  • analysis.summarize_workloads (cognitive 19) chapter7/model-benchmark/analysis.py:71 — analysis.summarize_workloads has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (10 pts), boolean chains 6, ternaries 1 (2 pts), loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · generate_data.main (cognitive 19) · ×1
  • generate_data.main (cognitive 19) chapter8/cot-distillation/generate_data.py:206 — generate_data.main has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10 (11 pts), boolean chains 5, ternaries 2, loops 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · SFTDataQualityAuditor.check_format (cognitive 19) · ×1
  • SFTDataQualityAuditor.check_format (cognitive 19) chapter8/cot-distillation/sft_data_auditor.py:193 — SFTDataQualityAuditor.check_format has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (13 pts), ternaries 1 (3 pts), boolean chains 2, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · train_sft_trl.train_model (cognitive 19) · ×1
  • train_sft_trl.train_model (cognitive 19) chapter8/prompt-distillation/train_sft_trl.py:145 — train_sft_trl.train_model has cognitive complexity 19 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 2, ternaries 2 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · WorkflowReplayer.replay_workflow (cognitive 19) · ×1
  • WorkflowReplayer.replay_workflow (cognitive 19) chapter9/browser-use-rpa/learning_agent/replay.py:77 — WorkflowReplayer.replay_workflow has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (14 pts), error handling 2 (3 pts), boolean chains 1, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · WorkflowReplayer._evaluate_predicate (cognitive 19) · ×1
  • WorkflowReplayer._evaluate_predicate (cognitive 19) chapter9/browser-use-rpa/learning_agent/replay.py:180 — WorkflowReplayer._evaluate_predicate has cognitive complexity 19 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · demo.main (cognitive 19) · ×1
  • demo.main (cognitive 19) chapter9/prompt-auto-optimization/demo.py:82 — demo.main has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 6, if/else 6, ternaries 4 (5 pts), loops 2 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · OpenAILongitudinalAgent.observe (cognitive 19) · ×1
  • OpenAILongitudinalAgent.observe (cognitive 19) chapter9/self-evolution-eval/agent.py:264 — OpenAILongitudinalAgent.observe has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (10 pts), boolean chains 4, loops 1 (3 pts), ternaries 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SelfEvolvingAgent._dispatch (cognitive 19) · ×1
  • SelfEvolvingAgent._dispatch (cognitive 19) chapter9/self-evolving-tools/agent.py:251 — SelfEvolvingAgent._dispatch has cognitive complexity 19 (threshold 15). Drivers by points: if/else 11 (16 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · base_tools._parse_ddg (cognitive 19) · ×1
  • base_tools._parse_ddg (cognitive 19) chapter9/self-evolving-tools/base_tools.py:77 — base_tools._parse_ddg has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 2 (4 pts), ternaries 1 (3 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · analyze.main (cognitive 19) · ×1
  • analyze.main (cognitive 19) chapter9/tau2-escalation-experience/analyze.py:45 — analyze.main has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (10 pts), loops 3 (5 pts), boolean chains 4 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TrajectoryConsistencyChecker.find_contradictions (cognitive 19) · ×1
  • TrajectoryConsistencyChecker.find_contradictions (cognitive 19) chapter9/trajectory-verifier/consistency_checker.py:310 — TrajectoryConsistencyChecker.find_contradictions has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (14 pts), loops 3 (4 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · orchestration._extract_value (cognitive 18) · ×1
  • orchestration._extract_value (cognitive 18) chapter10/autonomous-phone-registration/orchestration.py:29 — orchestration._extract_value has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (10 pts), boolean chains 3, error handling 1 (2 pts), ternaries 1 (2 pts), loops 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · agents.llm_chat (cognitive 18) · ×1
  • agents.llm_chat (cognitive 18) chapter10/book-translation/agents.py:242 — agents.llm_chat has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (12 pts), boolean chains 3, error handling 1 (2 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · WorkerAgent.run (cognitive 18) · ×1
  • WorkerAgent.run (cognitive 18) chapter10/parallel-web-research/agents.py:119 — WorkerAgent.run has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (11 pts), error handling 3 (4 pts), ternaries 1 (2 pts), loops 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · validate_official_run.collect_tool_calls (cognitive 18) · ×1
  • validate_official_run.collect_tool_calls (cognitive 18) chapter2/agent-skills-ppt/validate_official_run.py:50 — validate_official_run.collect_tool_calls has cognitive complexity 18 (threshold 15). Drivers by points: if/else 3 (8 pts), loops 3 (7 pts), boolean chains 3 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StrategyRunner.run_strategy (cognitive 18) · ×1
  • StrategyRunner.run_strategy (cognitive 18) chapter2/context-compression/run_all_strategies.py:96 — StrategyRunner.run_strategy has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 2 (4 pts), error handling 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MemoryIndexer._index_documents (cognitive 18) · ×1
  • MemoryIndexer._index_documents (cognitive 18) chapter3/agentic-rag-for-user-memory/indexer.py:293 — MemoryIndexer._index_documents has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (11 pts), error handling 2 (3 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InteractiveRAGEvaluator.view_test_cases (cognitive 18) · ×1
  • InteractiveRAGEvaluator.view_test_cases (cognitive 18) chapter3/agentic-rag-for-user-memory/main.py:134 — InteractiveRAGEvaluator.view_test_cases has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (12 pts), ternaries 2 (5 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RAGEvaluator.evaluate_response (cognitive 18) · ×1
  • RAGEvaluator.evaluate_response (cognitive 18) chapter3/agentic-rag/evaluation/evaluate.py:44 — RAGEvaluator.evaluate_response has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (10 pts), loops 2 (4 pts), ternaries 2 (4 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · compare_retrieval.main (cognitive 18) · ×1
  • compare_retrieval.main (cognitive 18) chapter3/contextual-retrieval/compare_retrieval.py:277 — compare_retrieval.main has cognitive complexity 18 (threshold 15). Drivers by points: if/else 11 (13 pts), ternaries 2 (3 pts), boolean chains 2 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · InteractiveSession.run (cognitive 18) · ×1
  • InteractiveSession.run (cognitive 18) chapter3/mem0/main.py:105 — InteractiveSession.run has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (13 pts), error handling 2 (4 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · main.run_interactive_mode (cognitive 18) · ×1
  • main.run_interactive_mode (cognitive 18) chapter3/memobase/main.py:25 — main.run_interactive_mode has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (9 pts), loops 2 (5 pts), error handling 2 (4 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · api_service.build_index (cognitive 18) · ×1
  • api_service.build_index (cognitive 18) chapter3/structured-index/api_service.py:121 — api_service.build_index has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (17 pts), error handling 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GraphRAGIndexer.hierarchical_summarization (cognitive 18) · ×1
  • GraphRAGIndexer.hierarchical_summarization (cognitive 18) REDACTED:311 — GraphRAGIndexer.hierarchical_summarization has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (8 pts), loops 3 (6 pts), error handling 1 (3 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · UserMemoryAgent._tool_update_memory (cognitive 18) · ×1
  • UserMemoryAgent._tool_update_memory (cognitive 18) chapter3/user-memory/agent.py:510 — UserMemoryAgent._tool_update_memory has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (14 pts), error handling 1 (3 pts), ternaries 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_exact_experiment.parse_action (cognitive 18) · ×1
  • run_exact_experiment.parse_action (cognitive 18) chapter4/active-tool-discovery/run_exact_experiment.py:300 — run_exact_experiment.parse_action has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (11 pts), ternaries 2 (5 pts), boolean chains 1, error handling 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MultimodalAgent._answer_with_context (cognitive 18) · ×1
  • MultimodalAgent._answer_with_context (cognitive 18) chapter4/multimodal-agent/agent.py:780 — MultimodalAgent._answer_with_context has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (13 pts), loops 1 (3 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · multimodal_tools.extract_youtube_transcript (cognitive 18) · ×1
  • multimodal_tools.extract_youtube_transcript (cognitive 18) chapter4/perception-tools/src/multimodal_tools.py:473 — multimodal_tools.extract_youtube_transcript has cognitive complexity 18 (threshold 15). Drivers by points: ternaries 4 (6 pts), error handling 3 (5 pts), if/else 4 (5 pts), boolean chains 1, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · campaign.main (cognitive 18) · ×1
  • campaign.main (cognitive 18) chapter5/dynamic-form/campaign.py:191 — campaign.main has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (7 pts), boolean chains 6, error handling 1 (3 pts), loops 1, ternaries 1 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · case_studies.banking_pedo_run (cognitive 18) · ×1
  • case_studies.banking_pedo_run (cognitive 18) chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:56 — case_studies.banking_pedo_run has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (13 pts), error handling 5 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · EventTriggeredAgent._tool_read_file (cognitive 18) · ×1
  • EventTriggeredAgent._tool_read_file (cognitive 18) REDACTED:836 — EventTriggeredAgent._tool_read_file has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (12 pts), error handling 3, ternaries 1 (2 pts), boolean chains 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · unipile_mailbox_experiment.poll_campaign_emails (cognitive 18) · ×1
  • unipile_mailbox_experiment.poll_campaign_emails (cognitive 18) chapter6/agent-with-event-trigger/unipile_mailbox_experiment.py:499 — unipile_mailbox_experiment.poll_campaign_emails has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · preflight.main (cognitive 18) · ×1
  • preflight.main (cognitive 18) REDACTED:28 — preflight.main has cognitive complexity 18 (threshold 15). Drivers by points: ternaries 6 (8 pts), boolean chains 4, if/else 3, loops 3 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · CostEfficiencyAnalyzer._recommendations (cognitive 18) · ×1
  • CostEfficiencyAnalyzer._recommendations (cognitive 18) chapter7/agent-cost-analysis/cost_efficiency_analyzer.py:359 — CostEfficiencyAnalyzer._recommendations has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (16 pts), loops 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RateRampBenchmark.calculate_backoff_curves (cognitive 18) · ×1
  • RateRampBenchmark.calculate_backoff_curves (cognitive 18) chapter7/model-benchmark/rate_ramp_benchmark.py:154 — RateRampBenchmark.calculate_backoff_curves has cognitive complexity 18 (threshold 15). Drivers by points: if/else 3 (6 pts), boolean chains 5, ternaries 3 (5 pts), loops 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · demo.summarize (cognitive 18) · ×1
  • demo.summarize (cognitive 18) chapter7/tts-quality-eval/demo.py:147 — demo.summarize has cognitive complexity 18 (threshold 15). Drivers by points: if/else 3 (7 pts), ternaries 2 (6 pts), loops 3 (5 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ChatBackend.complete (cognitive 18) · ×1
  • ChatBackend.complete (cognitive 18) chapter7/user-memory-system-evaluation/experiment.py:245 — ChatBackend.complete has cognitive complexity 18 (threshold 15). Drivers by points: boolean chains 9, if/else 5, error handling 2 (3 pts), loops 1 (nesting depth added 1). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · experiment.reprice_legacy_64_records (cognitive 18) · ×1
  • experiment.reprice_legacy_64_records (cognitive 18) chapter7/user-memory-system-evaluation/experiment.py:1706 — experiment.reprice_legacy_64_records has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_training_report_audit.validate_judgment (cognitive 18) · ×1
  • run_training_report_audit.validate_judgment (cognitive 18) REDACTED:302 — run_training_report_audit.validate_judgment has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · validate_vlm_evidence.verify_records (cognitive 18) · ×1
  • validate_vlm_evidence.verify_records (cognitive 18) chapter8/MiniMind-pretrain/validation/validate_vlm_evidence.py:63 — validate_vlm_evidence.verify_records has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (14 pts), boolean chains 3, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MultilingualReasoningEvaluator.compute_token_usage (cognitive 18) · ×1
  • MultilingualReasoningEvaluator.compute_token_usage (cognitive 18) chapter8/MultilingualReasoning/evaluate_multilingual.py:279 — MultilingualReasoningEvaluator.compute_token_usage has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (8 pts), ternaries 4 (8 pts), boolean chains 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MultilingualReasoningEvaluator.evaluate (cognitive 18) · ×1
  • MultilingualReasoningEvaluator.evaluate (cognitive 18) chapter8/MultilingualReasoning/evaluate_multilingual.py:461 — MultilingualReasoningEvaluator.evaluate has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (7 pts), boolean chains 4, loops 4, error handling 1 (2 pts), ternaries 1 (nesting depth added 2). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · analyze_campaign.orpheus_analysis (cognitive 18) · ×1
  • analyze_campaign.orpheus_analysis (cognitive 18) chapter8/speech-sft-experiment/analyze_campaign.py:48 — analyze_campaign.orpheus_analysis has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (11 pts), loops 3 (5 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · evolution.diagnose (cognitive 18) · ×1
  • evolution.diagnose (cognitive 18) REDACTED:90 — evolution.diagnose has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 3 (4 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · coding_agent.optimize_prompt (cognitive 18) · ×1
  • coding_agent.optimize_prompt (cognitive 18) chapter9/prompt-auto-optimization/coding_agent.py:82 — coding_agent.optimize_prompt has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (13 pts), error handling 1 (2 pts), boolean chains 1, loops 1, ternaries 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · clean_site_files.linked_json_files (cognitive 18) · ×1
  • clean_site_files.linked_json_files (cognitive 18) scripts/clean_site_files.py:60 — clean_site_files.linked_json_files has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (11 pts), loops 2 (3 pts), ternaries 1 (3 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · index.Home · ×1
  • index.Home::loadTrajectories (cognitive 18) chapter2/attention_visualization/frontend/pages/index.tsx:68 — index.Home::loadTrajectories has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (7 pts), error handling 3 (5 pts), ternaries 1 (3 pts), boolean chains 2, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (index.Home) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · VoiceActivityDetector.processAudioChunk (cognitive 18) · ×1
  • VoiceActivityDetector.processAudioChunk (cognitive 18) chapter6/live-audio/backend/utils/vad.js:138 — VoiceActivityDetector.processAudioChunk has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (15 pts), error handling 1 (2 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · evolution-flow-figures.layoutEvolutionDeployment (cognitive 18) · ×1
  • evolution-flow-figures.layoutEvolutionDeployment (cognitive 18) web-astro/scripts/evolution-flow-figures.mjs:326 — evolution-flow-figures.layoutEvolutionDeployment has cognitive complexity 18 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 2, ternaries 1 (nesting depth added 3). None of this is in the body itself: all 18 points belong to 2 function literals inside it that branch (lines 337, 429). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
D2 · Cognitive Complexity · main.run_ablation_study (cognitive 17) · ×1
  • main.run_ablation_study (cognitive 17) chapter1/context/main.py:812 — main.run_ablation_study has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (10 pts), loops 2 (3 pts), boolean chains 2, error handling 1, ternaries 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · finalize_experiment_8_2.main (cognitive 17) · ×1
  • finalize_experiment_8_2.main (cognitive 17) chapter1/learning-from-experience/finalize_experiment_8_2.py:16 — finalize_experiment_8_2.main has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 6, ternaries 6, if/else 5. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · LLMAgent._build_context (cognitive 17) · ×1
  • LLMAgent._build_context (cognitive 17) chapter1/learning-from-experience/llm_agent.py:144 — LLMAgent._build_context has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (9 pts), loops 3 (8 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · consistency.check_adherence (cognitive 17) · ×1
  • consistency.check_adherence (cognitive 17) chapter10/book-translation/consistency.py:48 — consistency.check_adherence has cognitive complexity 17 (threshold 15). Drivers by points: if/else 3 (9 pts), ternaries 2 (4 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ReceiptRecorder.record (cognitive 17) · ×1
  • ReceiptRecorder.record (cognitive 17) chapter10/generative-agents/provider_adapter.py:72 — ReceiptRecorder.record has cognitive complexity 17 (threshold 15). Drivers by points: ternaries 5 (11 pts), boolean chains 2, if/else 2, loops 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Coordinator.run (cognitive 17) · ×1
  • Coordinator.run (cognitive 17) chapter10/parallel-web-research/agents.py:259 — Coordinator.run has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (9 pts), loops 3, boolean chains 2, error handling 1 (2 pts), ternaries 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_official_experiment.validate_manifest (cognitive 17) · ×1
  • run_official_experiment.validate_manifest (cognitive 17) chapter10/staged-system-prompt/run_official_experiment.py:53 — run_official_experiment.validate_manifest has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 11, if/else 4 (5 pts), loops 1 (nesting depth added 1). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · benchmark.stream_once (cognitive 17) · ×1
  • benchmark.stream_once (cognitive 17) chapter2/local_llm_serving/benchmark.py:86 — benchmark.stream_once has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (10 pts), error handling 1 (3 pts), ternaries 2, boolean chains 1, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ContextualLegalIndexer.process_all_documents (cognitive 17) · ×1
  • ContextualLegalIndexer.process_all_documents (cognitive 17) chapter3/contextual-retrieval/index_local_laws_contextual.py:351 — ContextualLegalIndexer.process_all_documents has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (14 pts), error handling 1 (2 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · main.main (cognitive 17) · ×1
  • main.main (cognitive 17) chapter3/contextual-retrieval/main.py:185 — main.main has cognitive complexity 17 (threshold 15). Drivers by points: if/else 12 (14 pts), ternaries 1 (2 pts), boolean chains 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · api_service.query_index (cognitive 17) · ×1
  • api_service.query_index (cognitive 17) chapter3/structured-index/api_service.py:224 — api_service.query_index has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (9 pts), loops 2 (6 pts), error handling 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · HybridStructuredRetriever.retrieve (cognitive 17) · ×1
  • HybridStructuredRetriever.retrieve (cognitive 17) chapter3/structured-index/hybrid_retriever.py:433 — HybridStructuredRetriever.retrieve has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (8 pts), boolean chains 3, loops 3, error handling 1 (2 pts), ternaries 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · archetypes.vectorize (cognitive 17) · ×1
  • archetypes.vectorize (cognitive 17) chapter3/structured-knowledge-extraction/archetypes.py:57 — archetypes.vectorize has cognitive complexity 17 (threshold 15). Drivers by points: ternaries 4 (12 pts), if/else 2 (3 pts), boolean chains 1, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · campaign.vectorize (cognitive 17) · ×1
  • campaign.vectorize (cognitive 17) chapter3/structured-knowledge-extraction/campaign.py:374 — campaign.vectorize has cognitive complexity 17 (threshold 15). Drivers by points: ternaries 4 (12 pts), if/else 2 (3 pts), boolean chains 1, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BackgroundMemoryProcessor._background_processing_loop (cognitive 17) · ×1
  • BackgroundMemoryProcessor._background_processing_loop (cognitive 17) chapter3/user-memory/background_memory_processor.py:505 — BackgroundMemoryProcessor._background_processing_loop has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (13 pts), error handling 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · cli.cmd_list (cognitive 17) · ×1
  • cli.cmd_list (cognitive 17) chapter4/perception-tools/cli.py:251 — cli.cmd_list has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (10 pts), ternaries 2 (4 pts), loops 2 (3 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · multimodal_tools.read_document (cognitive 17) · ×1
  • multimodal_tools.read_document (cognitive 17) chapter4/perception-tools/src/multimodal_tools.py:133 — multimodal_tools.read_document has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (8 pts), loops 3 (7 pts), boolean chains 1, error handling 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PubChemClient.make_request (cognitive 17) · ×1
  • PubChemClient.make_request (cognitive 17) chapter4/perception-tools/src/pubchem_tools.py:102 — PubChemClient.make_request has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (8 pts), ternaries 3 (5 pts), boolean chains 2, error handling 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AgentCreator._validate_template_spec (cognitive 17) · ×1
  • AgentCreator._validate_template_spec (cognitive 17) chapter5/agent-creator/creator.py:431 — AgentCreator._validate_template_spec has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (9 pts), boolean chains 6, loops 2 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · AgentCreator._stats_from_calls (cognitive 17) · ×1
  • AgentCreator._stats_from_calls (cognitive 17) chapter5/agent-creator/creator.py:753 — AgentCreator._stats_from_calls has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (11 pts), boolean chains 5, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KillBashTool._execute_impl (cognitive 17) · ×1
  • KillBashTool._execute_impl (cognitive 17) chapter5/coding-agent/tools/kill_bash_tool.py:16 — KillBashTool._execute_impl has cognitive complexity 17 (threshold 15). Drivers by points: error handling 3 (9 pts), if/else 4 (7 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · demo._render_field_html (cognitive 17) · ×1
  • demo._render_field_html (cognitive 17) chapter5/dynamic-form/demo.py:244 — demo._render_field_html has cognitive complexity 17 (threshold 15). Drivers by points: ternaries 6 (11 pts), loops 2 (4 pts), if/else 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · demo._replay_and_issues (cognitive 17) · ×1
  • demo._replay_and_issues (cognitive 17) chapter5/log-diagnosis/demo.py:82 — demo._replay_and_issues has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (9 pts), ternaries 2 (4 pts), boolean chains 2, loops 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · sut.run_task (cognitive 17) · ×1
  • sut.run_task (cognitive 17) chapter5/log-diagnosis/sut.py:21 — sut.run_task has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (9 pts), boolean chains 4, loops 1 (3 pts), ternaries 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · oracle.run_secret_storage_oracle (cognitive 17) · ×1
  • oracle.run_secret_storage_oracle (cognitive 17) REDACTED:59 — oracle.run_secret_storage_oracle has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (9 pts), error handling 6, boolean chains 2 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · BenchmarkResults.coverage_by_cwe (cognitive 17) · ×1
  • BenchmarkResults.coverage_by_cwe (cognitive 17) chapter5/permission-embedded-data-objects/pedo/eval/dataguardbench/metrics.py:127 — BenchmarkResults.coverage_by_cwe has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (9 pts), loops 4 (6 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · renderers._gemini_parts (cognitive 17) · ×1
  • renderers._gemini_parts (cognitive 17) chapter5/provider-failover/renderers.py:176 — renderers._gemini_parts has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 7, if/else 5 (7 pts), loops 2 (3 pts) (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · campaign._render_model_script (cognitive 17) · ×1
  • campaign._render_model_script (cognitive 17) chapter5/video-edit/campaign.py:265 — campaign._render_model_script has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (8 pts), ternaries 2 (4 pts), boolean chains 2, error handling 1 (2 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · video_editor._apply_edit_ffmpeg (cognitive 17) · ×1
  • video_editor._apply_edit_ffmpeg (cognitive 17) chapter5/video-edit/video_editor.py:71 — video_editor._apply_edit_ffmpeg has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 1, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · client.interactive_mode (cognitive 17) · ×1
  • client.interactive_mode (cognitive 17) chapter6/agent-with-event-trigger/client.py:250 — client.interactive_mode has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (8 pts), error handling 3 (7 pts), loops 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_real_experiment.derive_acceptance (cognitive 17) · ×1
  • run_real_experiment.derive_acceptance (cognitive 17) chapter6/async-agent/run_real_experiment.py:269 — run_real_experiment.derive_acceptance has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 8, if/else 3 (4 pts), ternaries 2 (3 pts), loops 2 (nesting depth added 2). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · run_acceptance.main (cognitive 17) · ×1
  • run_acceptance.main (cognitive 17) REDACTED:206 — run_acceptance.main has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 7, if/else 5, loops 3, error handling 1, ternaries 1. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · demo.evaluate_one (cognitive 17) · ×1
  • demo.evaluate_one (cognitive 17) chapter7/tts-quality-eval/demo.py:55 — demo.evaluate_one has cognitive complexity 17 (threshold 15). Drivers by points: ternaries 7 (8 pts), if/else 4 (5 pts), boolean chains 3, error handling 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · run_vlm_training_report_audit.main (cognitive 17) · ×1
  • run_vlm_training_report_audit.main (cognitive 17) REDACTED:823 — run_vlm_training_report_audit.main has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 2, loops 1, ternaries 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · train_sft_trl.prepare_model_and_tokenizer (cognitive 17) · ×1
  • train_sft_trl.prepare_model_and_tokenizer (cognitive 17) chapter8/prompt-distillation/train_sft_trl.py:59 — train_sft_trl.prepare_model_and_tokenizer has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (14 pts), ternaries 1 (2 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SafetyPolicyGate.is_high_risk_operation (cognitive 17) · ×1
  • SafetyPolicyGate.is_high_risk_operation (cognitive 17) chapter9/harness-safety-gate/safety_policy_gate.py:294 — SafetyPolicyGate.is_high_risk_operation has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_experiment_9_8.main (cognitive 17) · ×1
  • run_experiment_9_8.main (cognitive 17) chapter9/hermes-self-evolution/run_experiment_9_8.py:75 — run_experiment_9_8.main has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (13 pts), boolean chains 3, loops 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · airline_env.run_agent (cognitive 17) · ×1
  • airline_env.run_agent (cognitive 17) chapter9/prompt-auto-optimization/airline_env.py:158 — airline_env.run_agent has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (8 pts), boolean chains 3, error handling 1 (3 pts), loops 2 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · homepage_index.read_headings (cognitive 17) · ×1
  • homepage_index.read_headings (cognitive 17) scripts/homepage_index.py:30 — homepage_index.read_headings has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (13 pts), boolean chains 3, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · review.splitSlides (cognitive 17) · ×1
  • review.splitSlides (cognitive 17) slides/review.mjs:46 — review.splitSlides has cognitive complexity 17 (threshold 15). Drivers by points: loops 4 (8 pts), if/else 3 (5 pts), boolean chains 4 (nesting depth added 6). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · resolution.resolve_backend (cognitive 16) · ×1
  • resolution.resolve_backend (cognitive 16) agentbook/providers/resolution.py:127 — resolution.resolve_backend has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 8, if/else 5, ternaries 2 (3 pts) (nesting depth added 1). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · ContextAwareAgent._build_context (cognitive 16) · ×1
  • ContextAwareAgent._build_context (cognitive 16) REDACTED:570 — ContextAwareAgent._build_context has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (8 pts), loops 2 (4 pts), boolean chains 3, ternaries 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · vis_validation.render_arm_section (cognitive 16) · ×1
  • vis_validation.render_arm_section (cognitive 16) chapter1/context/vis_validation.py:40 — vis_validation.render_arm_section has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (9 pts), loops 2 (4 pts), boolean chains 2, ternaries 1 (nesting depth added 4). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · TreasureHuntGame.execute_action (cognitive 16) · ×1
  • TreasureHuntGame.execute_action (cognitive 16) chapter1/learning-from-experience/game_environment.py:204 — TreasureHuntGame.execute_action has cognitive complexity 16 (threshold 15). Drivers by points: if/else 11 (15 pts), boolean chains 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GPT5NativeAgent._post_responses (cognitive 16) · ×1
  • GPT5NativeAgent._post_responses (cognitive 16) chapter1/search-codegen/agent.py:177 — GPT5NativeAgent._post_responses has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (9 pts), error handling 2 (4 pts), boolean chains 2, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · main.run_interactive_mode (cognitive 16) · ×1
  • main.run_interactive_mode (cognitive 16) chapter1/web-search-agent/main.py:32 — main.run_interactive_mode has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (8 pts), error handling 2 (4 pts), ternaries 1 (3 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BilingualConsistencyAuditor._load_content (cognitive 16) · ×1
  • BilingualConsistencyAuditor._load_content (cognitive 16) chapter10/book-translation/consistency_auditor.py:149 — BilingualConsistencyAuditor._load_content has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (11 pts), boolean chains 3, error handling 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_official_experiment.main (cognitive 16) · ×1
  • run_official_experiment.main (cognitive 16) chapter10/parallel-web-research/run_official_experiment.py:219 — run_official_experiment.main has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 12, ternaries 3, if/else 1. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · StagedAgent._dispatch_tool (cognitive 16) · ×1
  • StagedAgent._dispatch_tool (cognitive 16) chapter10/staged-system-prompt/agent.py:192 — StagedAgent._dispatch_tool has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (11 pts), boolean chains 5 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · demo.run_agent (cognitive 16) · ×1
  • demo.run_agent (cognitive 16) chapter2/agent-skills-ppt/demo.py:269 — demo.run_agent has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (7 pts), boolean chains 3, error handling 1 (3 pts), loops 2 (3 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AttentionVisualizationAgent._process_generation_attentions (cognitive 16) · ×1
  • AttentionVisualizationAgent._process_generation_attentions (cognitive 16) chapter2/attention_visualization/agent.py:454 — AttentionVisualizationAgent._process_generation_attentions has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (10 pts), boolean chains 4, error handling 1, loops 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · visualization.visualize_results (cognitive 16) · ×1
  • visualization.visualize_results (cognitive 16) chapter2/attention_visualization/visualization.py:348 — visualization.visualize_results has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (10 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ContextCompressor._non_context_aware_individual_summary (cognitive 16) · ×1
  • ContextCompressor._non_context_aware_individual_summary (cognitive 16) chapter2/context-compression/compression_strategies.py:260 — ContextCompressor._non_context_aware_individual_summary has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (9 pts), loops 2 (4 pts), error handling 1 (2 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExperimentRunner.run_single_strategy (cognitive 16) · ×1
  • ExperimentRunner.run_single_strategy (cognitive 16) chapter2/context-compression/experiment.py:68 — ExperimentRunner.run_single_strategy has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (7 pts), ternaries 4, boolean chains 2, loops 1 (2 pts), error handling 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · main.run_comparison (cognitive 16) · ×1
  • main.run_comparison (cognitive 16) REDACTED:371 — main.run_comparison has cognitive complexity 16 (threshold 15). Drivers by points: ternaries 4 (8 pts), if/else 3 (5 pts), loops 2, boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Agent.run (cognitive 16) · ×1
  • Agent.run (cognitive 16) REDACTED:312 — Agent.run has cognitive complexity 16 (threshold 15). Drivers by points: loops 3 (6 pts), error handling 2 (5 pts), if/else 1 (3 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · main.preview_status_bar (cognitive 16) · ×1
  • main.preview_status_bar (cognitive 16) chapter2/system-hint/main.py:347 — main.preview_status_bar has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (9 pts), loops 3 (6 pts), ternaries 1 (nesting depth added 4). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · ContextualConversationChunker.contextualize_chunks (cognitive 16) · ×1
  • ContextualConversationChunker.contextualize_chunks (cognitive 16) REDACTED:161 — ContextualConversationChunker.contextualize_chunks has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (9 pts), error handling 1 (3 pts), ternaries 1 (3 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InteractiveContextualRAG.test_query (cognitive 16) · ×1
  • InteractiveContextualRAG.test_query (cognitive 16) chapter3/contextual-retrieval-for-user-memory/main.py:389 — InteractiveContextualRAG.test_query has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (10 pts), loops 2 (5 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · cli.compare_ann (cognitive 16) · ×1
  • cli.compare_ann (cognitive 16) chapter3/dense-embedding/cli.py:280 — cli.compare_ann has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (6 pts), loops 3 (5 pts), ternaries 2 (4 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DocumentStore.delete_document (cognitive 16) · ×1
  • DocumentStore.delete_document (cognitive 16) chapter3/retrieval-pipeline/document_store.py:57 — DocumentStore.delete_document has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (12 pts), loops 1 (3 pts), boolean chains 1 (nesting depth added 10). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · extractor.extract_dataset (cognitive 16) · ×1
  • extractor.extract_dataset (cognitive 16) chapter3/structured-knowledge-extraction/extractor.py:113 — extractor.extract_dataset has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (11 pts), loops 3 (4 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ComparisonRunner.run (cognitive 16) · ×1
  • ComparisonRunner.run (cognitive 16) chapter3/user-memory-evaluation/comparison.py:68 — ComparisonRunner.run has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (11 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LLMEvaluator._parse_evaluation_response (cognitive 16) · ×1
  • LLMEvaluator._parse_evaluation_response (cognitive 16) chapter3/user-memory-evaluation/evaluator.py:236 — LLMEvaluator._parse_evaluation_response has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (9 pts), boolean chains 3, ternaries 1 (2 pts), error handling 1, loops 1 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · UserMemoryAgent.__init__ (cognitive 16) · ×1
  • UserMemoryAgent.__init__ (cognitive 16) chapter3/user-memory/agent.py:59 — UserMemoryAgent.__init__ has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 11, if/else 4, ternaries 1. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · ConversationalAgent.__init__ (cognitive 16) · ×1
  • ConversationalAgent.__init__ (cognitive 16) chapter3/user-memory/conversational_agent.py:47 — ConversationalAgent.__init__ has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 11, if/else 4, ternaries 1. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · run_exact_experiment._call_real_tool (cognitive 16) · ×1
  • run_exact_experiment._call_real_tool (cognitive 16) chapter4/active-tool-discovery/run_exact_experiment.py:525 — run_exact_experiment._call_real_tool has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (9 pts), boolean chains 3, loops 1 (2 pts), ternaries 1 (2 pts) (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · hitl_tools._notify_admin_of_request (cognitive 16) · ×1
  • hitl_tools._notify_admin_of_request (cognitive 16) chapter4/collaboration-tools/src/hitl_tools.py:76 — hitl_tools._notify_admin_of_request has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (12 pts), error handling 2 (3 pts), ternaries 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · validate_experiment_4_5.main (cognitive 16) · ×1
  • validate_experiment_4_5.main (cognitive 16) chapter4/collaboration-tools/validate_experiment_4_5.py:43 — validate_experiment_4_5.main has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 12, if/else 3, ternaries 1. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · private_data_tools.search_notion (cognitive 16) · ×1
  • private_data_tools.search_notion (cognitive 16) REDACTED:151 — private_data_tools.search_notion has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (9 pts), loops 2 (4 pts), error handling 2, boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AgentCreator._safe_files (cognitive 16) · ×1
  • AgentCreator._safe_files (cognitive 16) chapter5/agent-creator/creator.py:373 — AgentCreator._safe_files has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 3, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · csp_solver.eval_stmt (cognitive 16) · ×1
  • csp_solver.eval_stmt (cognitive 16) chapter5/code-for-logic/csp_solver.py:31 — csp_solver.eval_stmt has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (11 pts), boolean chains 3, ternaries 1 (2 pts) (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · demo.parse_answer (cognitive 16) · ×1
  • demo.parse_answer (cognitive 16) chapter5/code-for-logic/demo.py:189 — demo.parse_answer has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (8 pts), error handling 2 (5 pts), loops 2 (3 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · demo.run_mode (cognitive 16) · ×1
  • demo.run_mode (cognitive 16) chapter5/code-for-logic/demo.py:277 — demo.run_mode has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (6 pts), boolean chains 3, error handling 1 (3 pts), ternaries 2 (3 pts), loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CodeSandboxEvaluator._recommendations_for (cognitive 16) · ×1
  • CodeSandboxEvaluator._recommendations_for (cognitive 16) chapter5/coding-agent/sandbox_evaluator.py:264 — CodeSandboxEvaluator._recommendations_for has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 8, if/else 8. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · GrepTool._execute_impl (cognitive 16) · ×1
  • GrepTool._execute_impl (cognitive 16) chapter5/coding-agent/tools/grep_tool.py:21 — GrepTool._execute_impl has cognitive complexity 16 (threshold 15). Drivers by points: if/else 13, boolean chains 1, error handling 1, ternaries 1. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · demo.run_questions (cognitive 16) · ×1
  • demo.run_questions (cognitive 16) chapter5/erp-agent/demo.py:101 — demo.run_questions has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (7 pts), error handling 2 (4 pts), loops 2 (4 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · campaign.process_page (cognitive 16) · ×1
  • campaign.process_page (cognitive 16) chapter5/paper-to-video/campaign.py:209 — campaign.process_page has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (9 pts), boolean chains 6, loops 1 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ObjectStore._check_permission (cognitive 16) · ×1
  • ObjectStore._check_permission (cognitive 16) chapter5/permission-embedded-data-objects/pedo/core/store.py:322 — ObjectStore._check_permission has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (13 pts), boolean chains 1, loops 1, ternaries 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · IntegrityOracle._check_salary_range (cognitive 16) · ×1
  • IntegrityOracle._check_salary_range (cognitive 16) REDACTED:111 — IntegrityOracle._check_salary_range has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (9 pts), ternaries 1 (4 pts), boolean chains 2, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · demo.print_interception_example (cognitive 16) · ×1
  • demo.print_interception_example (cognitive 16) chapter5/small-model-codified-rules/demo.py:222 — demo.print_interception_example has cognitive complexity 16 (threshold 15). Drivers by points: if/else 2 (8 pts), loops 3 (7 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · campaign._script_is_safe (cognitive 16) · ×1
  • campaign._script_is_safe (cognitive 16) chapter5/video-edit/campaign.py:234 — campaign._script_is_safe has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 1, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · demo.main (cognitive 16) · ×1
  • demo.main (cognitive 16) chapter6/streaming-speech/demo.py:107 — demo.main has cognitive complexity 16 (threshold 15). Drivers by points: ternaries 6 (9 pts), if/else 3, boolean chains 2, loops 2 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · benchmark.measure_once (cognitive 16) · ×1
  • benchmark.measure_once (cognitive 16) chapter7/model-benchmark/benchmark.py:142 — benchmark.measure_once has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (12 pts), ternaries 2, error handling 1, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · annotate_timeouts.build_annotations (cognitive 16) · ×1
  • annotate_timeouts.build_annotations (cognitive 16) chapter7/openvla-robotwin2-eval/annotate_timeouts.py:52 — annotate_timeouts.build_annotations has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (11 pts), loops 3 (5 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · experiment.conversation_chunks (cognitive 16) · ×1
  • experiment.conversation_chunks (cognitive 16) chapter7/user-memory-system-evaluation/experiment.py:461 — experiment.conversation_chunks has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (11 pts), loops 3 (5 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · verify_full_matrix_20260731.main (cognitive 16) · ×1
  • verify_full_matrix_20260731.main (cognitive 16) chapter7/user-memory-system-evaluation/validation/verify_full_matrix_20260731.py:31 — verify_full_matrix_20260731.main has cognitive complexity 16 (threshold 15). Drivers by points: loops 6 (7 pts), if/else 4 (5 pts), boolean chains 4 (nesting depth added 2). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · evaluate.build_confusion_matrix (cognitive 16) · ×1
  • evaluate.build_confusion_matrix (cognitive 16) chapter8/prompt-distillation/evaluate.py:183 — evaluate.build_confusion_matrix has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (11 pts), loops 4 (5 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LearningAgent._extract_action_data (cognitive 16) · ×1
  • LearningAgent._extract_action_data (cognitive 16) chapter9/browser-use-rpa/learning_agent/agent.py:147 — LearningAgent._extract_action_data has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (10 pts), boolean chains 4, error handling 1, ternaries 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_experiment_9_9.main (cognitive 16) · ×1
  • run_experiment_9_9.main (cognitive 16) chapter9/self-evolution-eval/run_experiment_9_9.py:79 — run_experiment_9_9.main has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (6 pts), boolean chains 5, ternaries 3, loops 2 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · base_tools.web_search (cognitive 16) · ×1
  • base_tools.web_search (cognitive 16) chapter9/self-evolving-tools/base_tools.py:31 — base_tools.web_search has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (7 pts), error handling 2 (4 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · candidate_sandbox.run_in_sandbox (cognitive 16) · ×1
  • candidate_sandbox.run_in_sandbox (cognitive 16) chapter9/self-modifying-agent/candidate_sandbox.py:121 — candidate_sandbox.run_in_sandbox has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (9 pts), error handling 4, boolean chains 3 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · generate.renderLesson (cognitive 16) · ×1
  • generate.renderLesson (cognitive 16) slides/generate.mjs:148 — generate.renderLesson has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7, ternaries 3 (6 pts), boolean chains 3 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · bookFootnotes (cognitive 16) · ×1
  • bookFootnotes (cognitive 16) REDACTED:279 — bookFootnotes has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (9 pts), boolean chains 5, other 2 (nesting depth added 3). None of this is in the body itself: all 16 points belong to 2 function items inside it that branch ((anonymous)::walk, a function literal at line 280). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
D29 · Static Analysis (SAST) · REDACTED · ×1
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED · ×1
  • REDACTED
D3 · God Classes · TooManyMethods · ×1
  • TooManyMethods: ObjectStore chapter5/permission-embedded-data-objects/pedo/core/store.py:45 — TooManyMethods — 36 methods. The bar is 30 methods; this is 6 over it, 1.20× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D4 · Code Duplication · Near-duplicate member family (6 members, 55 shared lines) · ×1
  • Near-duplicate member family (6 members, 55 shared lines) book-ar/svg_lib.py:216 — book-ar/svg_lib.py:216-290 | book-en/svg_lib.py:200-264 | book-es/svg_lib.py:200-264 | book-id/svg_lib.py:200-264 | book-ru/svg_lib.py:200-264 | book-tr/svg_lib.py:200-264 — These 6 members are variants of one another: a block of 55 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
D4 · Code Duplication · Near-duplicate member family (6 members, 17 shared lines) · ×1
  • Near-duplicate member family (6 members, 17 shared lines) book-ar/svg_lib.py:466 — book-ar/svg_lib.py:466-484 | book-en/svg_lib.py:440-458 | book-es/svg_lib.py:440-458 | book-id/svg_lib.py:440-458 | book-ru/svg_lib.py:440-458 | book-tr/svg_lib.py:440-458 — These 6 members are variants of one another: a block of 17 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
D4 · Code Duplication · Near-duplicate member family (6 members, 15 shared lines) · ×1
  • Near-duplicate member family (6 members, 15 shared lines) book-ar/svg_lib.py:649 — book-ar/svg_lib.py:649-664 | book-en/svg_lib.py:623-638 | book-es/svg_lib.py:623-638 | book-id/svg_lib.py:623-638 | book-ru/svg_lib.py:623-638 | book-tr/svg_lib.py:623-638 — These 6 members are variants of one another: a block of 15 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 127 shared lines) · ×1
  • Near-duplicate member family (4 members, 127 shared lines) chapter6/astra-async-steering/experiment.py:218 — chapter6/astra-async-steering/experiment.py:218-347 | chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:218-347 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:203-332 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:203-332 — These 4 members are variants of one another: a block of 127 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 42 shared lines) · ×1
  • Near-duplicate member family (4 members, 42 shared lines) chapter6/astra-async-steering/experiment.py:98 — chapter6/astra-async-steering/experiment.py:98-214 | chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:98-214 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:98-199 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:98-199 — These 4 members are variants of one another: a block of 42 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 24 shared lines) · ×1
  • Near-duplicate member family (4 members, 24 shared lines) chapter6/astra-async-steering/experiment.py:372 — chapter6/astra-async-steering/experiment.py:372-401 | chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:372-401 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:351-379 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:351-379 — These 4 members are variants of one another: a block of 24 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 21 shared lines) · ×1
  • Near-duplicate member family (4 members, 21 shared lines) chapter4/perception-tools/src/document_processing_tools.py:105 — chapter4/perception-tools/src/document_processing_tools.py:105-172 | chapter4/perception-tools/src/filesystem_tools.py:320-379 | chapter4/perception-tools/src/media_processing_tools.py:465-546 | chapter4/perception-tools/src/media_processing_tools.py:554-685 — These 4 members are variants of one another: a block of 21 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 3 shared lines) · ×1
  • Near-duplicate member family (4 members, 3 shared lines) REDACTED:169 — REDACTED:169-185 | REDACTED:315-376 | REDACTED:294-313 | REDACTED:227-238 — These 4 members are variants of one another: a block of 3 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member pair (145 shared lines) · ×1
  • Near-duplicate member pair (145 shared lines) REDACTED:826 — REDACTED:826-1049 | REDACTED:1060-1283 — These two members are variants of one another: 145 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (91 shared lines) · ×1
  • Near-duplicate member pair (91 shared lines) chapter3/agentic-rag/main.py:188 — chapter3/agentic-rag/main.py:188-314 | chapter3/contextual-retrieval/main.py:186-288 — These two members are variants of one another: 91 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (90 shared lines) · ×1
  • Near-duplicate member pair (90 shared lines) chapter3/agentic-rag-for-user-memory/evaluator.py:522 — chapter3/agentic-rag-for-user-memory/evaluator.py:522-616 | chapter3/contextual-retrieval-for-user-memory/evaluator.py:522-616 — These two members are variants of one another: 90 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (58 shared lines) · ×1
  • Near-duplicate member pair (58 shared lines) REDACTED:672 — REDACTED:672-756 | REDACTED:824-918 — These two members are variants of one another: 58 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (44 shared lines) · ×1
  • Near-duplicate member pair (44 shared lines) chapter8/MiniMind-pretrain/validation/validate_evidence.py:115 — chapter8/MiniMind-pretrain/validation/validate_evidence.py:115-300 | chapter8/continued-pretraining/validation/validate_evidence.py:74-199 — These two members are variants of one another: 44 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (30 shared lines) · ×1
  • Near-duplicate member pair (30 shared lines) REDACTED:240 — REDACTED:240-331 | REDACTED:335-419 — These two members are variants of one another: 30 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Edited copy of a member (16 corresponding lines) · ×1
  • Edited copy of a member (16 corresponding lines) REDACTED:262 — REDACTED:262-290 | REDACTED:208-223 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (52 corresponding lines) · ×1
  • Edited copy of a member (52 corresponding lines) REDACTED:665 — REDACTED:665-758 | REDACTED:768-862 — These two members are one piece of code written twice and then edited apart: 52 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (38 corresponding lines) · ×1
  • Edited copy of a member (38 corresponding lines) REDACTED:373 — REDACTED:373-458 | REDACTED:466-548 — These two members are one piece of code written twice and then edited apart: 38 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (27 corresponding lines) · ×1
  • Edited copy of a member (27 corresponding lines) chapter4/perception-tools/src/media_processing_tools.py:367 — chapter4/perception-tools/src/media_processing_tools.py:367-458 | chapter4/perception-tools/src/multimodal_tools.py:327-397 — These two members are one piece of code written twice and then edited apart: 27 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Members sharing a duplicated core (10 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (10 members, 50+ identical tokens) chapter3/agentic-rag-for-user-memory/config.py:22 — chapter3/agentic-rag-for-user-memory/config.py:22-42 | chapter3/agentic-rag/config.py:13-33 | chapter3/contextual-retrieval-for-user-memory/config.py:22-42 | chapter3/contextual-retrieval/config.py:13-33 | chapter3/mem0/config.py:22-42 | chapter3/memobase/config.py:14-32 | chapter3/structured-index/config.py:16-34 | chapter3/structured-knowledge-extraction/config.py:20-38 | chapter3/user-memory-evaluation/config.py:12-30 | chapter3/user-memory/config.py:23-43 — These 10 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 10 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 10 times.
D4 · Code Duplication · Duplicated block (157 lines × 2) · ×1
  • Duplicated block (157 lines × 2) chapter3/agentic-rag-for-user-memory/agent.py:202 — chapter3/agentic-rag-for-user-memory/agent.py:202-358 | chapter3/contextual-retrieval-for-user-memory/agent.py:198-354 — `chapter3/agentic-rag-for-user-memory/agent.py` and `chapter3/contextual-retrieval-for-user-memory/agent.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 278 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (118 lines × 2) · ×1
  • Duplicated block (118 lines × 2) chapter3/agentic-rag-for-user-memory/evaluator.py:291 — chapter3/agentic-rag-for-user-memory/evaluator.py:291-408 | chapter3/contextual-retrieval-for-user-memory/evaluator.py:291-408 — `chapter3/agentic-rag-for-user-memory/evaluator.py` and `chapter3/contextual-retrieval-for-user-memory/evaluator.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 15 separate duplicated blocks between them, totalling at least 555 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (117 lines × 2) · ×1
  • Duplicated block (117 lines × 2) REDACTED:160 — REDACTED:160-276 | REDACTED:139-255 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 6 separate duplicated blocks between them, totalling at least 324 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (98 lines × 4) · ×1
  • Duplicated block (98 lines × 4) chapter6/astra-async-steering/experiment.py:250 — chapter6/astra-async-steering/experiment.py:250-347 | chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:250-347 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:235-332 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:235-332 — before extracting anything, compare `chapter6/astra-async-steering/experiment.py` and `chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 251 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (35–89 lines × 2) · ×1
  • Duplicated block (35–89 lines × 2) REDACTED:47 — REDACTED:47-81 | chapter5/permission-embedded-data-objects/pedo/eval/benchmark_reactions.py:32-120 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:47` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (86 lines × 2) · ×1
  • Duplicated block (86 lines × 2) REDACTED:172 — REDACTED:172-257 | REDACTED:172-257 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 271 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (80 lines × 2) · ×1
  • Duplicated block (80 lines × 2) chapter3/agentic-rag-for-user-memory/tools.py:107 — chapter3/agentic-rag-for-user-memory/tools.py:107-186 | chapter3/contextual-retrieval-for-user-memory/tools.py:107-186 — `chapter3/agentic-rag-for-user-memory/tools.py` and `chapter3/contextual-retrieval-for-user-memory/tools.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 191 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (78 lines × 2) · ×1
  • Duplicated block (78 lines × 2) REDACTED:23 — REDACTED:23-100 | REDACTED:24-101 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 6 separate duplicated blocks between them, totalling at least 324 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (75 lines × 2) · ×1
  • Duplicated block (75 lines × 2) chapter3/agentic-rag-for-user-memory/indexer.py:417 — chapter3/agentic-rag-for-user-memory/indexer.py:417-491 | chapter3/contextual-retrieval-for-user-memory/indexer.py:301-375 — `chapter3/agentic-rag-for-user-memory/indexer.py` and `chapter3/contextual-retrieval-for-user-memory/indexer.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 10 separate duplicated blocks between them, totalling at least 347 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (73 lines × 2) · ×1
  • Duplicated block (73 lines × 2) chapter5/coding-agent/agent.py:183 — chapter5/coding-agent/agent.py:183-255 | chapter5/coding-agent/agent_new.py:142-214 — before extracting anything, compare `chapter5/coding-agent/agent.py` and `chapter5/coding-agent/agent_new.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 198 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (68 lines × 2) · ×1
  • Duplicated block (68 lines × 2) chapter3/agentic-rag/evaluation/evaluate.py:137 — chapter3/agentic-rag/evaluation/evaluate.py:137-204 | chapter3/contextual-retrieval/evaluation/evaluate.py:129-196 — before extracting anything, compare `chapter3/agentic-rag/evaluation/evaluate.py` and `chapter3/contextual-retrieval/evaluation/evaluate.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 369 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (40–66 lines × 2) · ×1
  • Duplicated block (40–66 lines × 2) REDACTED:280 — REDACTED:280-345 | REDACTED:289-328 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 6 separate duplicated blocks between them, totalling at least 324 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:289` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (4–62 lines × 3) · ×1
  • Duplicated block (4–62 lines × 3) chapter3/agentic-rag-for-user-memory/main.py:574 — chapter3/agentic-rag-for-user-memory/main.py:574-577 | chapter3/agentic-rag-for-user-memory/quickstart.py:53-114 | chapter3/contextual-retrieval-for-user-memory/quickstart.py:54-115 — `chapter3/agentic-rag-for-user-memory/quickstart.py` and `chapter3/contextual-retrieval-for-user-memory/quickstart.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 134 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (62 lines × 2) · ×1
  • Duplicated block (62 lines × 2) REDACTED:288 — REDACTED:288-349 | REDACTED:288-349 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 13 separate duplicated blocks between them, totalling at least 349 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (53–61 lines × 2) · ×1
  • Duplicated block (53–61 lines × 2) REDACTED:123 — REDACTED:123-183 | REDACTED:193-245 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:123` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (60 lines × 2) · ×1
  • Duplicated block (60 lines × 2) chapter3/agentic-rag-for-user-memory/evaluator.py:411 — chapter3/agentic-rag-for-user-memory/evaluator.py:411-470 | chapter3/contextual-retrieval-for-user-memory/evaluator.py:411-470 — `chapter3/agentic-rag-for-user-memory/evaluator.py` and `chapter3/contextual-retrieval-for-user-memory/evaluator.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 15 separate duplicated blocks between them, totalling at least 555 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (57 lines × 2) · ×1
  • Duplicated block (57 lines × 2) chapter3/agentic-rag/evaluation/evaluate.py:207 — chapter3/agentic-rag/evaluation/evaluate.py:207-263 | chapter3/contextual-retrieval/evaluation/evaluate.py:199-255 — before extracting anything, compare `chapter3/agentic-rag/evaluation/evaluate.py` and `chapter3/contextual-retrieval/evaluation/evaluate.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 369 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (52–56 lines × 2) · ×1
  • Duplicated block (52–56 lines × 2) chapter5/coding-agent/tools/edit_tool.py:86 — chapter5/coding-agent/tools/edit_tool.py:86-137 | chapter5/coding-agent/tools/write_tool.py:55-110 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (53–55 lines × 2) · ×1
  • Duplicated block (53–55 lines × 2) REDACTED:268 — REDACTED:268-322 | REDACTED:447-499 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (55 lines × 2) · ×1
  • Duplicated block (55 lines × 2) chapter3/agentic-rag/tools.py:245 — chapter3/agentic-rag/tools.py:245-299 | chapter3/contextual-retrieval/tools.py:252-306 — `chapter3/agentic-rag/tools.py` and `chapter3/contextual-retrieval/tools.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 14 separate duplicated blocks between them, totalling at least 341 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (53 lines × 2) · ×1
  • Duplicated block (53 lines × 2) chapter3/agentic-rag-for-user-memory/tools.py:50 — chapter3/agentic-rag-for-user-memory/tools.py:50-102 | chapter3/contextual-retrieval-for-user-memory/tools.py:50-102 — `chapter3/agentic-rag-for-user-memory/tools.py` and `chapter3/contextual-retrieval-for-user-memory/tools.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 191 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (51 lines × 2) · ×1
  • Duplicated block (51 lines × 2) chapter3/agentic-rag/tools.py:413 — chapter3/agentic-rag/tools.py:413-463 | chapter3/contextual-retrieval/tools.py:418-468 — `chapter3/agentic-rag/tools.py` and `chapter3/contextual-retrieval/tools.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 14 separate duplicated blocks between them, totalling at least 341 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (38–51 lines × 2) · ×1
  • Duplicated block (38–51 lines × 2) chapter3/contextual-retrieval/demo.py:173 — chapter3/contextual-retrieval/demo.py:173-210 | chapter3/contextual-retrieval/demo.py:296-346 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (50 lines × 4) · ×1
  • Duplicated block (50 lines × 4) REDACTED:125 — REDACTED:125-174 | REDACTED:123-172 | REDACTED:123-172 | REDACTED:123-172 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 114 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (50 lines × 2) · ×1
  • Duplicated block (50 lines × 2) chapter3/agentic-rag/main.py:66 — chapter3/agentic-rag/main.py:66-115 | chapter3/contextual-retrieval/main.py:64-113 — `chapter3/agentic-rag/main.py` and `chapter3/contextual-retrieval/main.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 9 separate duplicated blocks between them, totalling at least 254 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (49 lines × 2) · ×1
  • Duplicated block (49 lines × 2) chapter3/agentic-rag-for-user-memory/evaluator.py:240 — chapter3/agentic-rag-for-user-memory/evaluator.py:240-288 | chapter3/contextual-retrieval-for-user-memory/evaluator.py:240-288 — `chapter3/agentic-rag-for-user-memory/evaluator.py` and `chapter3/contextual-retrieval-for-user-memory/evaluator.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 15 separate duplicated blocks between them, totalling at least 555 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (42–48 lines × 2) · ×1
  • Duplicated block (42–48 lines × 2) REDACTED:986 — REDACTED:986-1033 | REDACTED:1216-1257 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:986` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (42–47 lines × 2) · ×1
  • Duplicated block (42–47 lines × 2) chapter10/multi-role-transfer/run_official_experiment.py:233 — chapter10/multi-role-transfer/run_official_experiment.py:233-274 | chapter6/streaming-speech/run_official_experiment.py:261-307 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `chapter10/multi-role-transfer/run_official_experiment.py:233` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (41–46 lines × 2) · ×1
  • Duplicated block (41–46 lines × 2) REDACTED:621 — REDACTED:621-666 | REDACTED:877-917 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (46 lines × 2) · ×1
  • Duplicated block (46 lines × 2) chapter3/agentic-rag/tools.py:152 — chapter3/agentic-rag/tools.py:152-197 | chapter3/contextual-retrieval/tools.py:159-204 — `chapter3/agentic-rag/tools.py` and `chapter3/contextual-retrieval/tools.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 14 separate duplicated blocks between them, totalling at least 341 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (45 lines × 2) · ×1
  • Duplicated block (45 lines × 2) chapter3/agentic-rag-for-user-memory/evaluator.py:475 — chapter3/agentic-rag-for-user-memory/evaluator.py:475-519 | chapter3/contextual-retrieval-for-user-memory/evaluator.py:475-519 — `chapter3/agentic-rag-for-user-memory/evaluator.py` and `chapter3/contextual-retrieval-for-user-memory/evaluator.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 15 separate duplicated blocks between them, totalling at least 555 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (41–44 lines × 2) · ×1
  • Duplicated block (41–44 lines × 2) chapter3/agentic-rag-for-user-memory/agent.py:153 — chapter3/agentic-rag-for-user-memory/agent.py:153-196 | chapter3/contextual-retrieval-for-user-memory/agent.py:152-192 — `chapter3/agentic-rag-for-user-memory/agent.py` and `chapter3/contextual-retrieval-for-user-memory/agent.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 278 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `chapter3/agentic-rag-for-user-memory/agent.py:153` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (40–42 lines × 2) · ×1
  • Duplicated block (40–42 lines × 2) REDACTED:875 — REDACTED:875-916 | REDACTED:1118-1157 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:875` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (37–42 lines × 2) · ×1
  • Duplicated block (37–42 lines × 2) chapter4/active-tool-selection/agent.py:215 — chapter4/active-tool-selection/agent.py:215-256 | chapter4/active-tool-selection/agent.py:495-531 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (41 lines × 6) · ×1
  • Duplicated block (41 lines × 6) book-ar/svg_lib.py:324 — book-ar/svg_lib.py:324-364 | book-en/svg_lib.py:298-338 | book-es/svg_lib.py:298-338 | book-id/svg_lib.py:298-338 | book-ru/svg_lib.py:298-338 | book-tr/svg_lib.py:298-338 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (40 lines × 4) · ×1
  • Duplicated block (40 lines × 4) REDACTED:178 — REDACTED:178-217 | REDACTED:176-215 | REDACTED:176-215 | REDACTED:176-215 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 114 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (19–40 lines × 2) · ×1
  • Duplicated block (19–40 lines × 2) chapter1/learning-from-experience/experiment.py:550 — chapter1/learning-from-experience/experiment.py:550-568 | chapter2/system-hint/main.py:527-566 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `chapter1/learning-from-experience/experiment.py:550` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (39–40 lines × 2) · ×1
  • Duplicated block (39–40 lines × 2) REDACTED:707 — REDACTED:707-746 | REDACTED:812-850 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (35–39 lines × 2) · ×1
  • Duplicated block (35–39 lines × 2) chapter10/talkact-reproduction/validate_campaign.py:155 — chapter10/talkact-reproduction/validate_campaign.py:155-193 | chapter6/claude-computer-use-native/validate_weather_run.py:120-154 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `chapter10/talkact-reproduction/validate_campaign.py:155` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (36 lines × 2) · ×1
  • Duplicated block (36 lines × 2) REDACTED:204 — REDACTED:204-239 | REDACTED:204-239 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 13 separate duplicated blocks between them, totalling at least 349 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (35 lines × 6) · ×1
  • Duplicated block (35 lines × 6) book-en/strip_titles.py:38 — book-en/strip_titles.py:38-72 | book-id/strip_titles.py:37-71 | book-ta/strip_titles.py:38-72 | book-tr/strip_titles.py:37-71 | book-zhtw/strip_titles.py:37-71 | book/strip_titles.py:37-71 — `book-en/strip_titles.py` and `book-id/strip_titles.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 68 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (34–35 lines × 2) · ×1
  • Duplicated block (34–35 lines × 2) chapter4/perception-tools/src/wiki_enhanced.py:87 — chapter4/perception-tools/src/wiki_enhanced.py:87-120 | chapter4/perception-tools/src/wiki_enhanced.py:135-169 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter4/perception-tools/src/wiki_enhanced.py:87` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (18–35 lines × 2) · ×1
  • Duplicated block (18–35 lines × 2) REDACTED:236 — REDACTED:236-270 | REDACTED:404-421 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:236` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (33–34 lines × 2) · ×1
  • Duplicated block (33–34 lines × 2) REDACTED:739 — REDACTED:739-772 | REDACTED:977-1009 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (30–33 lines × 2) · ×1
  • Duplicated block (30–33 lines × 2) chapter1/context/create_sample_pdf.py:95 — chapter1/context/create_sample_pdf.py:95-127 | chapter1/context/create_sample_pdf.py:141-170 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter1/context/create_sample_pdf.py:95` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (26–33 lines × 2) · ×1
  • Duplicated block (26–33 lines × 2) chapter3/user-memory/main.py:729 — chapter3/user-memory/main.py:729-754 | chapter3/user-memory/main.py:779-811 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (32 lines × 2) · ×1
  • Duplicated block (32 lines × 2) chapter4/execution-tools/filesystem_enhanced.py:443 — chapter4/execution-tools/filesystem_enhanced.py:443-474 | chapter4/execution-tools/filesystem_enhanced.py:504-535 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (30 lines × 6) · ×1
  • Duplicated block (30 lines × 6) book-ar/svg_lib.py:418 — book-ar/svg_lib.py:418-447 | book-en/svg_lib.py:392-421 | book-es/svg_lib.py:392-421 | book-id/svg_lib.py:392-421 | book-ru/svg_lib.py:392-421 | book-tr/svg_lib.py:392-421 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (24–30 lines × 4) · ×1
  • Duplicated block (24–30 lines × 4) chapter8/prompt-distillation/compare.py:265 — chapter8/prompt-distillation/compare.py:265-288 | chapter8/prompt-distillation/create_data.py:371-394 | chapter8/prompt-distillation/evaluate.py:334-357 | chapter8/prompt-distillation/train_sft_trl.py:301-330 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `chapter8/prompt-distillation/compare.py:265` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (22–30 lines × 3) · ×1
  • Duplicated block (22–30 lines × 3) REDACTED:68 — REDACTED:68-97 | chapter9/harness-safety-gate/llm_generator.py:34-55 | chapter9/self-modifying-agent/llm_generator.py:29-50 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (28–30 lines × 2) · ×1
  • Duplicated block (28–30 lines × 2) chapter8/orpheus/inference.py:222 — chapter8/orpheus/inference.py:222-251 | chapter8/orpheus/orpheus_sft_unsloth.py:432-459 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `chapter8/orpheus/inference.py:222` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (26–29 lines × 2) · ×1
  • Duplicated block (26–29 lines × 2) chapter1/context/create_sample_pdf.py:83 — chapter1/context/create_sample_pdf.py:83-111 | chapter1/context/create_sample_pdf.py:171-196 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (28 lines × 4) · ×1
  • Duplicated block (28 lines × 4) chapter4/perception-tools/src/yahoo_finance_tools.py:105 — chapter4/perception-tools/src/yahoo_finance_tools.py:105-132 | chapter4/perception-tools/src/yahoo_finance_tools.py:204-231 | chapter4/perception-tools/src/yahoo_finance_tools.py:297-324 | chapter4/perception-tools/src/yahoo_finance_tools.py:410-437 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter4/perception-tools/src/yahoo_finance_tools.py:105` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (20–28 lines × 2) · ×1
  • Duplicated block (20–28 lines × 2) REDACTED:558 — REDACTED:558-585 | REDACTED:838-857 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (24–28 lines × 2) · ×1
  • Duplicated block (24–28 lines × 2) chapter4/perception-tools/src/expanded_catalog.py:375 — chapter4/perception-tools/src/expanded_catalog.py:375-402 | chapter4/perception-tools/src/expanded_catalog.py:417-440 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter4/perception-tools/src/expanded_catalog.py:375` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (25–28 lines × 2) · ×1
  • Duplicated block (25–28 lines × 2) chapter6/streaming-speech/interruption_manager.py:138 — chapter6/streaming-speech/interruption_manager.py:138-165 | chapter6/streaming-speech/interruption_manager.py:172-196 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter6/streaming-speech/interruption_manager.py:138` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (24–27 lines × 3) · ×1
  • Duplicated block (24–27 lines × 3) chapter1/context/create_sample_pdf.py:86 — chapter1/context/create_sample_pdf.py:86-112 | chapter1/context/create_sample_pdf.py:133-156 | chapter1/context/create_sample_pdf.py:174-197 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D4 · Code Duplication · Duplicated block (26–27 lines × 3) · ×1
  • Duplicated block (26–27 lines × 3) chapter4/execution-tools/multilang_executor.py:459 — chapter4/execution-tools/multilang_executor.py:459-485 | chapter4/execution-tools/multilang_executor.py:571-596 | chapter4/execution-tools/multilang_executor.py:615-641 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter4/execution-tools/multilang_executor.py:459` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (25–27 lines × 3) · ×1
  • Duplicated block (25–27 lines × 3) chapter4/perception-tools/src/pubchem_tools.py:336 — chapter4/perception-tools/src/pubchem_tools.py:336-360 | chapter4/perception-tools/src/pubchem_tools.py:411-436 | chapter4/perception-tools/src/pubchem_tools.py:503-529 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (22–27 lines × 2) · ×1
  • Duplicated block (22–27 lines × 2) chapter1/context/create_sample_pdf.py:47 — chapter1/context/create_sample_pdf.py:47-68 | chapter1/context/create_sample_pdf.py:156-182 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (23–27 lines × 2) · ×1
  • Duplicated block (23–27 lines × 2) chapter1/search-codegen/quickstart.py:13 — chapter1/search-codegen/quickstart.py:13-35 | chapter1/search-codegen/quickstart.py:38-64 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (26–27 lines × 2) · ×1
  • Duplicated block (26–27 lines × 2) chapter3/agentic-rag/main.py:219 — chapter3/agentic-rag/main.py:219-245 | chapter3/contextual-retrieval/main.py:203-228 — `chapter3/agentic-rag/main.py` and `chapter3/contextual-retrieval/main.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 9 separate duplicated blocks between them, totalling at least 254 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `chapter3/agentic-rag/main.py:219` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (23–26 lines × 3) · ×1
  • Duplicated block (23–26 lines × 3) REDACTED:94 — REDACTED:94-119 | REDACTED:418-443 | REDACTED:511-533 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (24–26 lines × 2) · ×1
  • Duplicated block (24–26 lines × 2) chapter2/local_llm_serving/demo_streaming.py:31 — chapter2/local_llm_serving/demo_streaming.py:31-56 | chapter2/local_llm_serving/demo_streaming.py:94-117 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter2/local_llm_serving/demo_streaming.py:31` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (22–26 lines × 2) · ×1
  • Duplicated block (22–26 lines × 2) REDACTED:693 — REDACTED:693-718 | REDACTED:942-963 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (20–26 lines × 2) · ×1
  • Duplicated block (20–26 lines × 2) chapter4/active-tool-selection/agent.py:138 — chapter4/active-tool-selection/agent.py:138-163 | chapter4/active-tool-selection/agent.py:340-359 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (21–26 lines × 2) · ×1
  • Duplicated block (21–26 lines × 2) chapter8/prompt-distillation/create_data.py:396 — chapter8/prompt-distillation/create_data.py:396-416 | chapter8/prompt-distillation/train_sft_trl.py:333-358 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `chapter8/prompt-distillation/create_data.py:396` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (25 lines × 3) · ×1
  • Duplicated block (25 lines × 3) chapter3/agentic-rag-for-user-memory/evaluator.py:393 — chapter3/agentic-rag-for-user-memory/evaluator.py:393-417 | chapter3/contextual-retrieval-for-user-memory/contextual_evaluator.py:413-437 | chapter3/contextual-retrieval-for-user-memory/evaluator.py:393-417 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `chapter3/agentic-rag-for-user-memory/evaluator.py:393` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `chapter3/agentic-rag-for-user-memory/evaluator.py:420` calls `info` and `chapter3/contextual-retrieval-for-user-memory/contextual_evaluator.py:438` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (19–25 lines × 2) · ×1
  • Duplicated block (19–25 lines × 2) chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:266 — chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:266-290 | chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:510-528 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (22–25 lines × 2) · ×1
  • Duplicated block (22–25 lines × 2) REDACTED:350 — REDACTED:350-374 | REDACTED:316-337 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (15–25 lines × 2) · ×1
  • Duplicated block (15–25 lines × 2) chapter8/sesame/batch_inference.py:23 — chapter8/sesame/batch_inference.py:23-37 | chapter8/sesame/inference.py:20-44 — before extracting anything, compare `chapter8/sesame/batch_inference.py` and `chapter8/sesame/inference.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 80 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (21–24 lines × 3) · ×1
  • Duplicated block (21–24 lines × 3) chapter4/perception-tools/src/filesystem_tools.py:192 — chapter4/perception-tools/src/filesystem_tools.py:192-215 | chapter4/perception-tools/src/filesystem_tools.py:255-278 | chapter4/perception-tools/src/filesystem_tools.py:292-312 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (23 lines × 5) · ×1
  • Duplicated block (23 lines × 5) book-en/svg_lib.py:216 — book-en/svg_lib.py:216-238 | book-es/svg_lib.py:216-238 | book-id/svg_lib.py:216-238 | book-ru/svg_lib.py:216-238 | book-tr/svg_lib.py:216-238 — `book-en/svg_lib.py` and `book-es/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 33 separate duplicated blocks between them, totalling at least 435 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `book-en/svg_lib.py:216` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (21–23 lines × 3) · ×1
  • Duplicated block (21–23 lines × 3) chapter4/perception-tools/src/filesystem_tools.py:345 — chapter4/perception-tools/src/filesystem_tools.py:345-366 | chapter4/perception-tools/src/media_processing_tools.py:511-533 | chapter4/perception-tools/src/media_processing_tools.py:646-666 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (20–23 lines × 2) · ×1
  • Duplicated block (20–23 lines × 2) REDACTED:918 — REDACTED:918-940 | REDACTED:1159-1178 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:918` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (21–23 lines × 2) · ×1
  • Duplicated block (21–23 lines × 2) chapter2/system-hint/main.py:154 — chapter2/system-hint/main.py:154-176 | chapter6/agent-with-event-trigger/client.py:258-278 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `chapter2/system-hint/main.py:154` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (22 lines × 6) · ×1
  • Duplicated block (22 lines × 6) book-ar/svg_lib.py:216 — book-ar/svg_lib.py:216-237 | book-en/svg_lib.py:200-221 | book-es/svg_lib.py:200-221 | book-id/svg_lib.py:200-221 | book-ru/svg_lib.py:200-221 | book-tr/svg_lib.py:200-221 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `book-ar/svg_lib.py:238` calls `_ATTR` and `book-en/svg_lib.py:222` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (21–22 lines × 3) · ×1
  • Duplicated block (21–22 lines × 3) REDACTED:119 — REDACTED:119-140 | REDACTED:119-140 | REDACTED:261-281 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 13 separate duplicated blocks between them, totalling at least 349 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (20–22 lines × 2) · ×1
  • Duplicated block (20–22 lines × 2) chapter9/harness-safety-gate/run_experiment_9_7.py:225 — chapter9/harness-safety-gate/run_experiment_9_7.py:225-244 | chapter9/self-modifying-agent/run_experiment_9_6.py:222-243 — before extracting anything, compare `chapter9/harness-safety-gate/run_experiment_9_7.py` and `chapter9/self-modifying-agent/run_experiment_9_6.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 40 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `chapter9/harness-safety-gate/run_experiment_9_7.py:225` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (19–21 lines × 10) · ×1
  • Duplicated block (19–21 lines × 10) chapter3/agentic-rag-for-user-memory/config.py:22 — chapter3/agentic-rag-for-user-memory/config.py:22-42 | chapter3/agentic-rag/config.py:13-33 | chapter3/contextual-retrieval-for-user-memory/config.py:22-42 | chapter3/contextual-retrieval/config.py:13-33 | chapter3/mem0/config.py:22-42 | chapter3/memobase/config.py:14-32 | chapter3/structured-index/config.py:16-34 | chapter3/structured-knowledge-extraction/config.py:20-38 | chapter3/user-memory-evaluation/config.py:12-30 | chapter3/user-memory/config.py:23-43 — `chapter3/agentic-rag-for-user-memory/config.py` and `chapter3/contextual-retrieval-for-user-memory/config.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 5 separate duplicated blocks between them, totalling at least 98 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (21 lines × 3) · ×1
  • Duplicated block (21 lines × 3) REDACTED:385 — REDACTED:385-405 | chapter8/sesame/batch_inference.py:186-206 | chapter8/sesame/inference.py:175-195 — before extracting anything, compare `chapter8/sesame/batch_inference.py` and `chapter8/sesame/inference.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 80 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:385` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (18–21 lines × 3) · ×1
  • Duplicated block (18–21 lines × 3) chapter5/coding-agent/tools/edit_tool.py:65 — chapter5/coding-agent/tools/edit_tool.py:65-83 | chapter5/coding-agent/tools/multi_edit_tool.py:97-117 | chapter5/coding-agent/tools/write_tool.py:35-52 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (17–21 lines × 2) · ×1
  • Duplicated block (17–21 lines × 2) REDACTED:842 — REDACTED:842-862 | REDACTED:1093-1109 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (19–21 lines × 2) · ×1
  • Duplicated block (19–21 lines × 2) REDACTED:422 — REDACTED:422-440 | chapter3/contextual-retrieval/index_local_laws_contextual.py:488-508 — `REDACTED` and `chapter3/contextual-retrieval/index_local_laws_contextual.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 7 separate duplicated blocks between them, totalling at least 122 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (6–21 lines × 2) · ×1
  • Duplicated block (6–21 lines × 2) REDACTED:605 — REDACTED:605-625 | chapter5/video-edit/campaign.py:739-744 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `chapter5/video-edit/campaign.py:739` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `REDACTED:625` calls `_write_json`, `RuntimeError` and `chapter5/video-edit/campaign.py:744` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (9–21 lines × 2) · ×1
  • Duplicated block (9–21 lines × 2) chapter8/continued-pretraining/continued-pretrain.py:38 — chapter8/continued-pretraining/continued-pretrain.py:38-46 | chapter8/sesame/inference.py:176-196 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `chapter8/continued-pretraining/continued-pretrain.py:38` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (14–20 lines × 4) · ×1
  • Duplicated block (14–20 lines × 4) chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:258 — chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:258-271 | chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:278-297 | chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:502-515 | chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:530-543 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D4 · Code Duplication · Duplicated block (20 lines × 4) · ×1
  • Duplicated block (20 lines × 4) chapter6/astra-async-steering/experiment.py:230 — chapter6/astra-async-steering/experiment.py:230-249 | chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:230-249 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:215-234 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:215-234 — before extracting anything, compare `chapter6/astra-async-steering/experiment.py` and `chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 251 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (14–19 lines × 2) · ×1
  • Duplicated block (14–19 lines × 2) chapter5/code-for-math/demo.py:382 — chapter5/code-for-math/demo.py:382-400 | chapter9/browser-use-rpa/demo_email.py:328-341 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `chapter5/code-for-math/demo.py:382` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (16–19 lines × 2) · ×1
  • Duplicated block (16–19 lines × 2) REDACTED:358 — REDACTED:358-376 | REDACTED:383-398 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `REDACTED:399` calls `execute` and `REDACTED:377` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (13–19 lines × 2) · ×1
  • Duplicated block (13–19 lines × 2) REDACTED:494 — REDACTED:494-512 | REDACTED:515-527 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (17–19 lines × 2) · ×1
  • Duplicated block (17–19 lines × 2) chapter5/video-edit/agents.py:136 — chapter5/video-edit/agents.py:136-154 | chapter5/video-edit/agents.py:301-317 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter5/video-edit/agents.py:136` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (12–19 lines × 2) · ×1
  • Duplicated block (12–19 lines × 2) chapter8/cot-distillation/train_student.py:64 — chapter8/cot-distillation/train_student.py:64-82 | chapter8/prompt-distillation/run_experiment_8_8.py:341-352 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (18 lines × 5) · ×1
  • Duplicated block (18 lines × 5) chapter4/perception-tools/src/arxiv_enhanced.py:155 — chapter4/perception-tools/src/arxiv_enhanced.py:155-172 | chapter4/perception-tools/src/google_search_enhanced.py:121-138 | chapter4/perception-tools/src/wiki_enhanced.py:111-128 | chapter4/perception-tools/src/wiki_enhanced.py:160-177 | chapter4/perception-tools/src/wiki_enhanced.py:252-269 — before extracting anything, compare `chapter4/perception-tools/src/arxiv_enhanced.py` and `chapter4/perception-tools/src/wiki_enhanced.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 90 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `chapter4/perception-tools/src/arxiv_enhanced.py:155` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (7–18 lines × 3) · ×1
  • Duplicated block (7–18 lines × 3) chapter1/learning-from-experience/experiment.py:512 — chapter1/learning-from-experience/experiment.py:512-529 | chapter3/agentic-rag-for-user-memory/offline_demo.py:269-275 | chapter5/code-for-logic/build_puzzles.py:177-183 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `chapter1/learning-from-experience/experiment.py:512` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (18 lines × 3) · ×1
  • Duplicated block (18 lines × 3) chapter5/permission-embedded-data-objects/pedo/scenarios/forum.py:117 — chapter5/permission-embedded-data-objects/pedo/scenarios/forum.py:117-134 | chapter5/permission-embedded-data-objects/pedo/scenarios/hiring.py:225-244 | chapter5/permission-embedded-data-objects/pedo/scenarios/project_mgmt.py:221-240 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `chapter5/permission-embedded-data-objects/pedo/scenarios/forum.py:117` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (17–18 lines × 2) · ×1
  • Duplicated block (17–18 lines × 2) chapter2/context-compression/compression_strategies.py:349 — chapter2/context-compression/compression_strategies.py:349-365 | chapter2/context-compression/compression_strategies.py:460-477 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter2/context-compression/compression_strategies.py:349` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (17 lines × 7) · ×1
  • Duplicated block (17 lines × 7) chapter4/perception-tools/src/media_processing_tools.py:276 — chapter4/perception-tools/src/media_processing_tools.py:276-292 | chapter4/perception-tools/src/media_processing_tools.py:842-858 | chapter4/perception-tools/src/pubchem_tools.py:280-296 | chapter4/perception-tools/src/pubchem_tools.py:359-375 | chapter4/perception-tools/src/pubchem_tools.py:435-451 | chapter4/perception-tools/src/pubchem_tools.py:528-544 | chapter4/perception-tools/src/search_tools.py:246-262 — there are 7 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 7 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `chapter4/perception-tools/src/media_processing_tools.py:276` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (17 lines × 6) · ×1
  • Duplicated block (17 lines × 6) book-ar/svg_lib.py:91 — book-ar/svg_lib.py:91-107 | book-en/svg_lib.py:87-103 | book-es/svg_lib.py:87-103 | book-id/svg_lib.py:87-103 | book-ru/svg_lib.py:87-103 | book-tr/svg_lib.py:87-103 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `book-ar/svg_lib.py:91` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `book-ar/svg_lib.py:111` calls `category` and `book-en/svg_lib.py:107` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (9–17 lines × 3) · ×1
  • Duplicated block (9–17 lines × 3) chapter7/model-benchmark/campaign.py:520 — chapter7/model-benchmark/campaign.py:520-536 | chapter7/model-benchmark/campaign.py:674-682 | chapter7/model-benchmark/campaign.py:765-773 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter7/model-benchmark/campaign.py:520` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (16–17 lines × 2) · ×1
  • Duplicated block (16–17 lines × 2) chapter2/context-compression/agent.py:400 — chapter2/context-compression/agent.py:400-415 | chapter3/user-memory/agent.py:696-712 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
D4 · Code Duplication · Duplicated block (14–17 lines × 2) · ×1
  • Duplicated block (14–17 lines × 2) chapter3/agentic-rag-for-user-memory/main.py:168 — chapter3/agentic-rag-for-user-memory/main.py:168-181 | chapter3/agentic-rag-for-user-memory/main.py:282-298 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (16 lines × 27) · ×1
  • Duplicated block (16 lines × 27) chapter4/perception-tools/src/arxiv_enhanced.py:72 — chapter4/perception-tools/src/arxiv_enhanced.py:72-87 | chapter4/perception-tools/src/document_processing_tools.py:157-172 | chapter4/perception-tools/src/document_processing_tools.py:231-246 | chapter4/perception-tools/src/document_processing_tools.py:293-308 | chapter4/perception-tools/src/filesystem_tools.py:364-379 | chapter4/perception-tools/src/filesystem_tools.py:490-505 | chapter4/perception-tools/src/media_processing_tools.py:199-214 | chapter4/perception-tools/src/media_processing_tools.py:443-458 | chapter4/perception-tools/src/media_processing_tools.py:531-546 | chapter4/perception-tools/src/media_processing_tools.py:664-679 | chapter4/perception-tools/src/media_processing_tools.py:750-765 | chapter4/perception-tools/src/multimodal_tools.py:304-319 | chapter4/perception-tools/src/multimodal_tools.py:382-397 | chapter4/perception-tools/src/multimodal_tools.py:455-470 | REDACTED:133-148 | REDACTED:255-270 | REDACTED:131-146 | REDACTED:210-225 | REDACTED:281-296 | REDACTED:350-365 | REDACTED:443-458 | REDACTED:533-548 | REDACTED:642-657 | REDACTED:743-758 | REDACTED:847-862 | chapter4/perception-tools/src/search_tools.py:416-431 | chapter4/perception-tools/src/wiki_enhanced.py:65-80 — there are 27 copies across 9 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 27 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `chapter4/perception-tools/src/arxiv_enhanced.py:72` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (16 lines × 6) · ×1
  • Duplicated block (16 lines × 6) book-ar/svg_lib.py:549 — book-ar/svg_lib.py:549-564 | book-en/svg_lib.py:523-538 | book-es/svg_lib.py:523-538 | book-id/svg_lib.py:523-538 | book-ru/svg_lib.py:523-538 | book-tr/svg_lib.py:523-538 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (11–16 lines × 3) · ×1
  • Duplicated block (11–16 lines × 3) chapter4/active-tool-selection/agent.py:150 — chapter4/active-tool-selection/agent.py:150-165 | chapter4/active-tool-selection/agent.py:350-360 | chapter4/active-tool-selection/agent.py:478-492 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (14–16 lines × 3) · ×1
  • Duplicated block (14–16 lines × 3) chapter4/multimodal-agent/agent.py:226 — chapter4/multimodal-agent/agent.py:226-239 | chapter4/multimodal-agent/agent.py:280-293 | chapter4/multimodal-agent/agent.py:957-972 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (12–16 lines × 2) · ×1
  • Duplicated block (12–16 lines × 2) chapter3/agentic-rag/main.py:198 — chapter3/agentic-rag/main.py:198-213 | chapter3/contextual-retrieval/main.py:190-201 — `chapter3/agentic-rag/main.py` and `chapter3/contextual-retrieval/main.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 9 separate duplicated blocks between them, totalling at least 254 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `chapter3/agentic-rag/main.py:198` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (15 lines × 6) · ×1
  • Duplicated block (15 lines × 6) chapter5/adaptive-log-parser/agent.py:78 — chapter5/adaptive-log-parser/agent.py:78-92 | chapter5/code-for-logic/demo.py:66-80 | chapter5/dynamic-form/demo.py:62-76 | chapter5/log-diagnosis/diagnoser.py:24-38 | chapter5/small-model-codified-rules/agent.py:32-46 | chapter5/video-edit/agents.py:29-43 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 6 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 6 times. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (15 lines × 5) · ×1
  • Duplicated block (15 lines × 5) chapter5/permission-embedded-data-objects/pedo/scenarios/enterprise_agents.py:67 — chapter5/permission-embedded-data-objects/pedo/scenarios/enterprise_agents.py:67-81 | chapter5/permission-embedded-data-objects/pedo/scenarios/forum.py:58-73 | chapter5/permission-embedded-data-objects/pedo/scenarios/healthcare.py:40-57 | chapter5/permission-embedded-data-objects/pedo/scenarios/hiring.py:110-124 | chapter5/permission-embedded-data-objects/pedo/scenarios/project_mgmt.py:106-120 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 5 call sites, so a change lands once.
D4 · Code Duplication · Duplicated block (11–15 lines × 2) · ×1
  • Duplicated block (11–15 lines × 2) REDACTED:674 — REDACTED:674-688 | REDACTED:826-836 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
D4 · Code Duplication · Duplicated block (12–14 lines × 35) · ×1
  • Duplicated block (12–14 lines × 35) chapter4/perception-tools/src/arxiv_enhanced.py:67 — chapter4/perception-tools/src/arxiv_enhanced.py:67-80 | chapter4/perception-tools/src/document_processing_tools.py:152-165 | chapter4/perception-tools/src/document_processing_tools.py:226-239 | chapter4/perception-tools/src/document_processing_tools.py:288-301 | chapter4/perception-tools/src/filesystem_tools.py:359-372 | chapter4/perception-tools/src/filesystem_tools.py:485-498 | chapter4/perception-tools/src/media_processing_tools.py:194-207 | chapter4/perception-tools/src/media_processing_tools.py:274-285 | chapter4/perception-tools/src/media_processing_tools.py:438-451 | chapter4/perception-tools/src/media_processing_tools.py:526-539 | chapter4/perception-tools/src/media_processing_tools.py:659-672 | chapter4/perception-tools/src/media_processing_tools.py:745-758 | chapter4/perception-tools/src/media_processing_tools.py:838-851 | chapter4/perception-tools/src/multimodal_tools.py:299-312 | chapter4/perception-tools/src/multimodal_tools.py:377-390 | chapter4/perception-tools/src/multimodal_tools.py:452-463 | REDACTED:128-141 | REDACTED:250-263 | chapter4/perception-tools/src/pubchem_tools.py:276-289 | chapter4/perception-tools/src/pubchem_tools.py:355-368 | chapter4/perception-tools/src/pubchem_tools.py:431-444 | chapter4/perception-tools/src/pubchem_tools.py:524-537 | REDACTED:126-139 | REDACTED:205-218 | REDACTED:276-289 | REDACTED:345-358 | REDACTED:438-451 | REDACTED:528-541 | REDACTED:637-650 | REDACTED:738-751 | REDACTED:842-855 | chapter4/perception-tools/src/search_tools.py:242-255 | chapter4/perception-tools/src/search_tools.py:320-333 | chapter4/perception-tools/src/search_tools.py:411-424 | chapter4/perception-tools/src/wiki_enhanced.py:60-73 — there are 35 copies across 10 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 35 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `chapter4/perception-tools/src/arxiv_enhanced.py:67` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `chapter4/perception-tools/src/multimodal_tools.py:450` calls `ImportError`, `TextContent` and `chapter4/perception-tools/src/arxiv_enhanced.py:67` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (14 lines × 31) · ×1
  • Duplicated block (14 lines × 31) chapter4/perception-tools/src/arxiv_enhanced.py:72 — chapter4/perception-tools/src/arxiv_enhanced.py:72-85 | chapter4/perception-tools/src/document_processing_tools.py:84-97 | chapter4/perception-tools/src/document_processing_tools.py:157-170 | chapter4/perception-tools/src/document_processing_tools.py:231-244 | chapter4/perception-tools/src/document_processing_tools.py:293-306 | chapter4/perception-tools/src/filesystem_tools.py:364-377 | chapter4/perception-tools/src/filesystem_tools.py:490-503 | chapter4/perception-tools/src/filesystem_tools.py:566-579 | chapter4/perception-tools/src/media_processing_tools.py:199-212 | chapter4/perception-tools/src/media_processing_tools.py:345-358 | chapter4/perception-tools/src/media_processing_tools.py:443-456 | chapter4/perception-tools/src/media_processing_tools.py:531-544 | chapter4/perception-tools/src/media_processing_tools.py:664-677 | chapter4/perception-tools/src/media_processing_tools.py:750-763 | chapter4/perception-tools/src/multimodal_tools.py:230-243 | chapter4/perception-tools/src/multimodal_tools.py:304-317 | chapter4/perception-tools/src/multimodal_tools.py:382-395 | chapter4/perception-tools/src/multimodal_tools.py:455-468 | REDACTED:133-146 | REDACTED:255-268 | REDACTED:131-144 | REDACTED:210-223 | REDACTED:281-294 | REDACTED:350-363 | REDACTED:443-456 | REDACTED:533-546 | REDACTED:642-655 | REDACTED:743-756 | REDACTED:847-860 | chapter4/perception-tools/src/search_tools.py:416-429 | chapter4/perception-tools/src/wiki_enhanced.py:65-78 — there are 31 copies across 9 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 31 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `chapter4/perception-tools/src/arxiv_enhanced.py:72` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (14 lines × 8) · ×1
  • Duplicated block (14 lines × 8) chapter4/perception-tools/src/pubchem_tools.py:351 — chapter4/perception-tools/src/pubchem_tools.py:351-364 | chapter4/perception-tools/src/pubchem_tools.py:427-440 | chapter4/perception-tools/src/pubchem_tools.py:520-533 | chapter4/perception-tools/src/search_tools.py:238-251 | chapter4/perception-tools/src/yahoo_finance_tools.py:101-114 | chapter4/perception-tools/src/yahoo_finance_tools.py:200-213 | chapter4/perception-tools/src/yahoo_finance_tools.py:293-306 | chapter4/perception-tools/src/yahoo_finance_tools.py:406-419 — there are 8 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 8 sites; resolving a subset leaves the remainder to drift apart. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (14 lines × 6) · ×1
  • Duplicated block (14 lines × 6) book-en/strip_titles.py:95 — book-en/strip_titles.py:95-108 | book-id/strip_titles.py:94-107 | book-ta/strip_titles.py:95-108 | book-tr/strip_titles.py:94-107 | book-zhtw/strip_titles.py:94-107 | book/strip_titles.py:94-107 — `book-en/strip_titles.py` and `book-id/strip_titles.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 68 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (12–14 lines × 6) · ×1
  • Duplicated block (12–14 lines × 6) chapter4/perception-tools/src/document_processing_tools.py:79 — chapter4/perception-tools/src/document_processing_tools.py:79-92 | chapter4/perception-tools/src/filesystem_tools.py:561-574 | chapter4/perception-tools/src/media_processing_tools.py:342-353 | chapter4/perception-tools/src/multimodal_tools.py:85-98 | chapter4/perception-tools/src/multimodal_tools.py:225-238 | chapter4/perception-tools/src/multimodal_tools.py:563-576 — there are 6 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `chapter4/perception-tools/src/document_processing_tools.py:79` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (14 lines × 5) · ×1
  • Duplicated block (14 lines × 5) chapter3/agentic-rag-for-user-memory/agent.py:95 — chapter3/agentic-rag-for-user-memory/agent.py:95-108 | chapter3/agentic-rag/agent.py:73-86 | chapter3/contextual-retrieval-for-user-memory/agent.py:95-108 | chapter3/contextual-retrieval-for-user-memory/contextual_agent.py:109-122 | chapter3/contextual-retrieval/agent.py:58-71 — `chapter3/agentic-rag-for-user-memory/agent.py` and `chapter3/contextual-retrieval-for-user-memory/agent.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 278 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (14 lines × 4) · ×1
  • Duplicated block (14 lines × 4) chapter3/agentic-rag/quickstart.py:123 — chapter3/agentic-rag/quickstart.py:123-138 | chapter3/user-memory/main.py:728-743 | chapter3/user-memory/main.py:778-793 | chapter3/user-memory/quickstart.py:181-194 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart.
D4 · Code Duplication · Duplicated block (12–14 lines × 2) · ×1
  • Duplicated block (12–14 lines × 2) chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:99 — chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:99-112 | chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:538-549 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:99` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (13 lines × 6) · ×1
  • Duplicated block (13 lines × 6) book-ar/svg_lib.py:573 — book-ar/svg_lib.py:573-585 | book-en/svg_lib.py:547-559 | book-es/svg_lib.py:547-559 | book-id/svg_lib.py:547-559 | book-ru/svg_lib.py:547-559 | book-tr/svg_lib.py:547-559 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `book-ar/svg_lib.py:573` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (11–13 lines × 3) · ×1
  • Duplicated block (11–13 lines × 3) REDACTED:842 — REDACTED:842-852 | REDACTED:902-912 | REDACTED:1143-1155 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (10–13 lines × 2) · ×1
  • Duplicated block (10–13 lines × 2) REDACTED:596 — REDACTED:596-608 | REDACTED:867-876 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (12 lines × 6) · ×1
  • Duplicated block (12 lines × 6) book-ar/svg_lib.py:471 — book-ar/svg_lib.py:471-482 | book-en/svg_lib.py:445-456 | book-es/svg_lib.py:445-456 | book-id/svg_lib.py:445-456 | book-ru/svg_lib.py:445-456 | book-tr/svg_lib.py:445-456 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (12 lines × 3) · ×1
  • Duplicated block (12 lines × 3) REDACTED:89 — REDACTED:89-100 | REDACTED:89-100 | REDACTED:231-242 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 13 separate duplicated blocks between them, totalling at least 349 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (10–12 lines × 2) · ×1
  • Duplicated block (10–12 lines × 2) chapter7/elo-leaderboard/benchmark.py:25 — chapter7/elo-leaderboard/benchmark.py:25-34 | chapter7/elo-leaderboard/benchmark.py:50-61 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `chapter7/elo-leaderboard/benchmark.py:50` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (9–11 lines × 4) · ×1
  • Duplicated block (9–11 lines × 4) chapter3/agentic-rag/evaluation/evaluate.py:56 — chapter3/agentic-rag/evaluation/evaluate.py:56-64 | chapter3/agentic-rag/evaluation/evaluate.py:71-79 | chapter3/contextual-retrieval/evaluation/evaluate.py:48-58 | chapter3/contextual-retrieval/evaluation/evaluate.py:63-73 — before extracting anything, compare `chapter3/agentic-rag/evaluation/evaluate.py` and `chapter3/contextual-retrieval/evaluation/evaluate.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 369 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (9–11 lines × 2) · ×1
  • Duplicated block (9–11 lines × 2) chapter1/learning-from-experience/run_experiment_8_2.py:74 — chapter1/learning-from-experience/run_experiment_8_2.py:74-82 | chapter2/prompt-engineering/run_ablation.py:119-129 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `chapter2/prompt-engineering/run_ablation.py:119` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (10 lines × 4) · ×1
  • Duplicated block (10 lines × 4) REDACTED:150 — REDACTED:150-159 | REDACTED:172-181 | REDACTED:188-197 | REDACTED:407-416 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:150` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (8–10 lines × 3) · ×1
  • Duplicated block (8–10 lines × 3) REDACTED:672 — REDACTED:672-681 | REDACTED:824-831 | REDACTED:700-708 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (7–10 lines × 2) · ×1
  • Duplicated block (7–10 lines × 2) chapter10/parallel-web-research/run_official_experiment.py:220 — chapter10/parallel-web-research/run_official_experiment.py:220-229 | chapter6/streaming-speech/run_official_experiment.py:104-110 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (9–10 lines × 2) · ×1
  • Duplicated block (9–10 lines × 2) REDACTED:185 — REDACTED:185-194 | REDACTED:48-56 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:185` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (4–10 lines × 4) · ×1
  • Duplicated block (4–10 lines × 4) chapter6/astra-async-steering/experiment.py:359 — chapter6/astra-async-steering/experiment.py:359-368 | chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:359-368 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:342-345 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:342-345 — before extracting anything, compare `chapter6/astra-async-steering/experiment.py` and `chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 251 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (9 lines × 34) · ×1
  • Duplicated block (9 lines × 34) chapter4/perception-tools/src/arxiv_enhanced.py:72 — chapter4/perception-tools/src/arxiv_enhanced.py:72-80 | chapter4/perception-tools/src/document_processing_tools.py:84-92 | chapter4/perception-tools/src/document_processing_tools.py:157-165 | chapter4/perception-tools/src/document_processing_tools.py:231-239 | chapter4/perception-tools/src/document_processing_tools.py:293-301 | chapter4/perception-tools/src/filesystem_tools.py:364-372 | chapter4/perception-tools/src/filesystem_tools.py:490-498 | chapter4/perception-tools/src/filesystem_tools.py:566-574 | chapter4/perception-tools/src/media_processing_tools.py:199-207 | chapter4/perception-tools/src/media_processing_tools.py:345-353 | chapter4/perception-tools/src/media_processing_tools.py:443-451 | chapter4/perception-tools/src/media_processing_tools.py:531-539 | chapter4/perception-tools/src/media_processing_tools.py:664-672 | chapter4/perception-tools/src/media_processing_tools.py:750-758 | chapter4/perception-tools/src/multimodal_tools.py:90-98 | chapter4/perception-tools/src/multimodal_tools.py:230-238 | chapter4/perception-tools/src/multimodal_tools.py:304-312 | chapter4/perception-tools/src/multimodal_tools.py:382-390 | chapter4/perception-tools/src/multimodal_tools.py:455-463 | chapter4/perception-tools/src/multimodal_tools.py:568-576 | REDACTED:133-141 | REDACTED:255-263 | REDACTED:131-139 | REDACTED:210-218 | REDACTED:281-289 | REDACTED:350-358 | REDACTED:443-451 | REDACTED:533-541 | REDACTED:642-650 | REDACTED:743-751 | REDACTED:847-855 | chapter4/perception-tools/src/search_tools.py:325-333 | chapter4/perception-tools/src/search_tools.py:416-424 | chapter4/perception-tools/src/wiki_enhanced.py:65-73 — there are 34 copies across 9 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 34 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `chapter4/perception-tools/src/arxiv_enhanced.py:72` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (4–9 lines × 3) · ×1
  • Duplicated block (4–9 lines × 3) chapter3/agentic-rag-for-user-memory/main.py:345 — chapter3/agentic-rag-for-user-memory/main.py:345-348 | chapter3/agentic-rag-for-user-memory/quickstart.py:116-124 | chapter3/contextual-retrieval-for-user-memory/quickstart.py:117-125 — `chapter3/agentic-rag-for-user-memory/quickstart.py` and `chapter3/contextual-retrieval-for-user-memory/quickstart.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 134 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (6–9 lines × 2) · ×1
  • Duplicated block (6–9 lines × 2) chapter3/structured-index/document_processor.py:209 — chapter3/structured-index/document_processor.py:209-217 | chapter4/perception-tools/src/multimodal_tools.py:59-64 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
D4 · Code Duplication · Duplicated block (8 lines × 12) · ×1
  • Duplicated block (8 lines × 12) book-ar/svg_lib.py:499 — book-ar/svg_lib.py:499-506 | book-ar/svg_lib.py:513-520 | book-en/svg_lib.py:473-480 | book-en/svg_lib.py:487-494 | book-es/svg_lib.py:473-480 | book-es/svg_lib.py:487-494 | book-id/svg_lib.py:473-480 | book-id/svg_lib.py:487-494 | book-ru/svg_lib.py:473-480 | book-ru/svg_lib.py:487-494 | book-tr/svg_lib.py:473-480 | book-tr/svg_lib.py:487-494 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `book-ar/svg_lib.py:499` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (7–8 lines × 4) · ×1
  • Duplicated block (7–8 lines × 4) chapter5/adaptive-log-parser/campaign.py:252 — chapter5/adaptive-log-parser/campaign.py:252-258 | REDACTED:225-232 | chapter5/dynamic-form/campaign.py:197-204 | chapter5/erp-agent/campaign_postgres.py:272-279 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `chapter5/erp-agent/campaign_postgres.py:271` calls `add_argument`, `getenv` and `chapter5/adaptive-log-parser/campaign.py:251` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (7–8 lines × 2) · ×1
  • Duplicated block (7–8 lines × 2) chapter4/collaboration-tools/run_experiment_4_5.py:258 — chapter4/collaboration-tools/run_experiment_4_5.py:258-264 | chapter4/execution-tools/run_experiment_4_4.py:88-95 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `chapter4/collaboration-tools/run_experiment_4_5.py:258` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (7 lines × 3) · ×1
  • Duplicated block (7 lines × 3) REDACTED:271 — REDACTED:271-278 | chapter3/user-memory/agent.py:580-609 | REDACTED:517-523 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:271` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (2–7 lines × 5) · ×1
  • Duplicated block (2–7 lines × 5) chapter6/astra-async-steering/experiment.py:351 — chapter6/astra-async-steering/experiment.py:351-357 | chapter6/astra-async-steering/summarize.py:16-19 | chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:351-357 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:341-342 | chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py:341-342 — before extracting anything, compare `chapter6/astra-async-steering/experiment.py` and `chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 251 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `chapter6/astra-async-steering/experiment.py:357` calls `loads`, `read_text`, `splitlines` and `chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py:342` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (3–7 lines × 4) · ×1
  • Duplicated block (3–7 lines × 4) chapter3/agentic-rag/compare_offline.py:149 — chapter3/agentic-rag/compare_offline.py:149-155 | chapter8/MultilingualReasoning/gpt_oss_20b_sft.py:470-475 | chapter8/continued-pretraining/compare_models.py:131-137 | chapter8/cot-distillation/generate_data.py:237-239 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `chapter3/agentic-rag/compare_offline.py:149` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `chapter8/continued-pretraining/compare_models.py:130` calls `add_argument` and `chapter3/agentic-rag/compare_offline.py:149` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (3–6 lines × 6) · ×1
  • Duplicated block (3–6 lines × 6) REDACTED:141 — REDACTED:141-146 | REDACTED:150-152 | REDACTED:262-267 | REDACTED:271-273 | REDACTED:208-211 | REDACTED:214-216 — there are 6 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:141` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `REDACTED:146` calls `execute` and `REDACTED:152` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (3–5 lines × 12) · ×1
  • Duplicated block (3–5 lines × 12) book-ar/svg_lib.py:587 — book-ar/svg_lib.py:587-591 | book-ar/svg_lib.py:604-606 | book-en/svg_lib.py:561-565 | book-en/svg_lib.py:578-580 | book-es/svg_lib.py:561-565 | book-es/svg_lib.py:578-580 | book-id/svg_lib.py:561-565 | book-id/svg_lib.py:578-580 | book-ru/svg_lib.py:561-565 | book-ru/svg_lib.py:578-580 | book-tr/svg_lib.py:561-565 | book-tr/svg_lib.py:578-580 — `book-ar/svg_lib.py` and `book-en/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 31 separate duplicated blocks between them, totalling at least 403 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (2–5 lines × 6) · ×1
  • Duplicated block (2–5 lines × 6) chapter5/permission-embedded-data-objects/demo.py:23 — chapter5/permission-embedded-data-objects/demo.py:23-31 | chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:62-66 | chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:357-361 | chapter5/permission-embedded-data-objects/pedo/eval/case_studies.py:487-491 | REDACTED:351-355 | chapter5/permission-embedded-data-objects/pedo/eval/enterprise_agent_scenarios.py:67-68 — there are 6 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `chapter5/permission-embedded-data-objects/demo.py:23` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (5 lines × 5) · ×1
  • Duplicated block (5 lines × 5) REDACTED:150 — REDACTED:150-154 | REDACTED:172-176 | REDACTED:188-192 | REDACTED:221-225 | REDACTED:407-411 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:150` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (3–5 lines × 3) · ×1
  • Duplicated block (3–5 lines × 3) chapter3/structured-index/structured_vs_flat_demo.py:189 — chapter3/structured-index/structured_vs_flat_demo.py:189-193 | chapter3/structured-index/structured_vs_flat_demo.py:211-215 | chapter3/structured-index/structured_vs_flat_demo.py:225-227 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. Note first that the copies are not typed on the same thing: the declarations holding them bind `i` to `"-- 扁平检索(按词面相似度返回独立片段)--") for` in one and `"-- 扁平检索 --") for` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `chapter3/structured-index/structured_vs_flat_demo.py:188` calls `enumerate`, `search` and `chapter3/structured-index/structured_vs_flat_demo.py:225` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (1–5 lines × 5) · ×1
  • Duplicated block (1–5 lines × 5) REDACTED:169 — REDACTED:169-173 | REDACTED:348-349 | REDACTED:350-350 | REDACTED:294-298 | REDACTED:227-229 — there are 5 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:169` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (284 lines × 2) · ×1
  • Duplicated block (284 lines × 2) chapter3/agentic-rag/evaluation/dataset_builder.py:17 — chapter3/agentic-rag/evaluation/dataset_builder.py:17-300 | chapter3/contextual-retrieval/evaluation/dataset_builder.py:17-300 — before extracting anything, compare `chapter3/agentic-rag/evaluation/dataset_builder.py` and `chapter3/contextual-retrieval/evaluation/dataset_builder.py` as WHOLE FILES: 100% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (9 lines × 5) · ×1
  • Duplicated block (9 lines × 5) book-en/svg_lib.py:107 — book-en/svg_lib.py:107-115 | book-es/svg_lib.py:107-115 | book-id/svg_lib.py:107-115 | book-ru/svg_lib.py:107-115 | book-tr/svg_lib.py:107-115 — `book-en/svg_lib.py` and `book-es/svg_lib.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 33 separate duplicated blocks between them, totalling at least 435 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (5 lines × 27) · ×1
  • Duplicated block (5 lines × 27) REDACTED:27 — REDACTED:27-31 | chapter1/context/config.py:14-18 | chapter1/learning-from-experience/llm_agent.py:20-24 | chapter1/web-search-agent/agent.py:21-25 | chapter2/context-compression/agent.py:23-27 | chapter2/context-compression/compression_strategies.py:17-21 | REDACTED:29-33 | chapter3/agentic-rag-for-user-memory/agent.py:20-24 | chapter3/agentic-rag-for-user-memory/config.py:14-18 | chapter3/contextual-retrieval-for-user-memory/agent.py:20-24 | chapter3/contextual-retrieval-for-user-memory/config.py:14-18 | chapter3/contextual-retrieval-for-user-memory/contextual_agent.py:23-27 | REDACTED:22-26 | chapter3/contextual-retrieval-for-user-memory/contextual_evaluator.py:27-31 | chapter3/contextual-retrieval-for-user-memory/contextual_indexer.py:25-29 | chapter3/contextual-retrieval/agent.py:15-19 | REDACTED:23-27 | chapter3/mem0/agent.py:23-27 | chapter3/mem0/config.py:14-18 | REDACTED:28-32 | chapter3/user-memory/agent.py:21-25 | chapter3/user-memory/config.py:15-19 | chapter3/user-memory/conversational_agent.py:20-24 | chapter4/execution-tools/llm_helper.py:15-19 | REDACTED:38-42 | chapter6/agent-with-event-trigger/server.py:34-38 | chapter6/agent-with-event-trigger/server_fastapi.py:33-37 — before extracting anything, compare `REDACTED` and `REDACTED` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `REDACTED:22` calls `basicConfig`, `getLogger` and `chapter1/learning-from-experience/llm_agent.py:16` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (5 lines × 34) · ×1
  • Duplicated block (5 lines × 34) chapter1/learning-from-experience/run_experiment_8_2.py:33 — chapter1/learning-from-experience/run_experiment_8_2.py:33-37 | chapter10/generative-agents/package_evidence.py:27-31 | chapter10/generative-agents/validate_campaign.py:28-32 | chapter10/talkact-reproduction/validate_campaign.py:29-33 | chapter5/adaptive-log-parser/campaign.py:61-65 | REDACTED:47-51 | chapter5/dynamic-form/campaign.py:41-45 | chapter5/erp-agent/campaign_postgres.py:60-64 | REDACTED:63-67 | chapter6/async-agent/tasks.py:70-74 | chapter6/claude-computer-use-native/validate_weather_run.py:21-25 | chapter6/computer-use-open-model/evidence.py:14-18 | chapter6/gemini-xlerobot-navigation/validate_evidence.py:17-21 | chapter6/phone-agent/speech.py:24-28 | chapter6/phone-agent/verify_acceptance.py:77-81 | chapter6/rgb-sim2real-grasping/validate_evidence.py:15-19 | chapter6/robotics_lab_common.py:57-61 | chapter6/xlerobot-teleoperation/validate_evidence.py:15-19 | chapter7/model-action-threshold/experiment.py:145-149 | chapter7/openvla-robotwin2-eval/finalize_evidence.py:31-35 | chapter7/package_evidence.py:15-19 | chapter7/user-memory-system-evaluation/build_73_evidence.py:23-27 | REDACTED:97-101 | REDACTED:217-221 | chapter8/MiniMind-pretrain/validation/validate_evidence.py:53-57 | chapter8/MiniMind-pretrain/validation/validate_vlm_evidence.py:42-46 | REDACTED:81-85 | chapter8/continued-pretraining/validation/validate_evidence.py:32-36 | chapter8/cot-distillation/train_student.py:27-31 | chapter8/prompt-distillation/run_experiment_8_8.py:90-94 | chapter8/speech-sft-experiment/analyze_campaign.py:23-27 | chapter8/speech-sft-experiment/run_orpheus.py:48-52 | chapter8/speech-sft-experiment/run_sesame.py:45-49 | chapter9/hermes-self-evolution/run_experiment_9_8.py:52-56 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 34 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 34 times. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `chapter10/talkact-reproduction/validate_campaign.py:36` calls `positive_usage`, `sum`, `values` and `chapter6/claude-computer-use-native/validate_weather_run.py:28` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (8 lines × 7) · ×1
  • Duplicated block (8 lines × 7) chapter10/book-translation/agents.py:46 — chapter10/book-translation/agents.py:46-53 | chapter10/multi-role-transfer/demo.py:36-43 | chapter10/staged-system-prompt/config.py:20-27 | chapter10/voice-werewolf/werewolf/agent.py:32-39 | chapter7/agent-cost-analysis/config.py:35-43 | chapter7/model-benchmark/benchmark.py:43-51 | REDACTED:60-68 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 7 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 7 times. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (6 lines × 5) · ×1
  • Duplicated block (6 lines × 5) chapter3/agentic-rag/campaign.py:72 — chapter3/agentic-rag/campaign.py:72-77 | chapter3/contextual-retrieval/campaign.py:155-160 | chapter3/memory_rag_campaign.py:484-489 | chapter3/structured-knowledge-extraction/campaign.py:516-521 | chapter3/user-memory/run_evaluation.py:408-413 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 5 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 5 times. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note first that the copies are not typed on the same thing: the declarations holding them bind `receipts` to `List[Dict[str, Any]]` in one and `Iterable[Dict[str, Any]]` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `chapter3/structured-knowledge-extraction/campaign.py:526` calls `add_argument`, `str` and `chapter3/memory_rag_campaign.py:494` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
P5 · DR & Backup · No DR/backup evidence · ×1
  • No DR/backup evidence — A persistence guard (data volume / purge-protection) was found, but no backup, geo-recovery or RTO/RPO controls were evidenced — a volume that survives a container recreate is not a tested restore from catastrophic loss.
R1 · Type Safety · Type Safety · ×1
  • Type Safety — 26 typed · 126 plain JS — the untyped files are chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/build.js, chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/make-assets.js, chapter4/execution-tools/validation/experiment_4_4/real_mcp_20260730T062500Z/workspace/valid.js, chapter4/execution-tools/validation/experiment_4_4/real_mcp_20260730T070500Z/workspace/valid.js, chapter4/execution-tools/validation/experiment_4_4/real_mcp_gui_20260802T093348Z/workspace/valid.js, chapter4/execution-tools/validation/experiment_4_4/real_mcp_gui_20260802T093657Z/workspace/valid.js (+120 more).
R10 · Code Duplication · Forked directory tree (6 identical files, ~2136 lines × 2 trees) · ×1
  • Forked directory tree (6 identical files, ~2136 lines × 2 trees) REDACTED:1 — chapter5/conversational-ui/validation/runs/20260729T212616Z-5_11-hmr/app/ and chapter5/conversational-ui/validation/runs/20260729T212727Z-5_11-hmr/app/ are near-verbatim copies of each other: 6 files are byte-identical under the same relative paths (~2136 lines; the trees hold 8 and 8 files). That is one structural fact, not 6 local ones: every edit made to one tree and not the other drifts silently, which is the failure whole-tree forks guarantee. Pick one tree as the single source and produce the other from it (generated, copied at build or release time, or re-exported) — or, if the copy is a stale snapshot nothing produces any more, delete it. Check first whether the copy is a deliberately published deliverable (a template consumers copy verbatim, a released sample frozen at a version); where it is, keep it produced from the source tree rather than edited in place.
R10 · Code Duplication · Wholesale file copy (54 identical lines × 4 files) · ×1
  • Wholesale file copy (54 identical lines × 4 files) chapter5/conversational-ui/baseline/src/App.jsx:1 — chapter5/conversational-ui/baseline/src/App.jsx:1 · chapter5/conversational-ui/frontend/src/App.jsx:1 · chapter5/conversational-ui/validation/runs/20260729T212616Z-5_11-hmr/app/frontend/src/App.jsx:1 · chapter5/conversational-ui/validation/runs/20260729T212727Z-5_11-hmr/app/frontend/src/App.jsx:1 — these 4 files are line-for-line copies of one another — 54 lines are identical, in the same order, in every one of them — so this is one fact about the file set, not a block to extract. An edit made to one file and not the others changes behaviour silently, which is the failure a wholesale copy guarantees. Pick one file as the single source and derive the others from it (re-export it, spread it into the local overrides each variant genuinely needs, or generate the copies at build time) — the few lines that differ between the files are exactly the part each variant should still own. Check first whether the copies are deliberately standalone deliverables (a translation file seeded from its sibling and waiting to be translated); where they are, the duplication is the design, and the honest move is to mark the seeded file as untranslated rather than to let it pass as done.
R10 · Code Duplication · Duplicated block (52 lines × 2 locations) · ×1
  • Duplicated block (52 lines × 2 locations) chapter6/live-audio/backend/utils/providers/asrProviders.js:88 — chapter6/live-audio/backend/utils/providers/asrProviders.js:88 · chapter6/live-audio/backend/utils/providers/asrProviders.js:182 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
R10 · Code Duplication · Duplicated block (51 lines × 2 locations) · ×1
  • Duplicated block (51 lines × 2 locations) web-astro/scripts/collaboration-manager-figures.mjs:6 — web-astro/scripts/collaboration-manager-figures.mjs:6 · web-astro/scripts/evolution-methods-figures.mjs:7 — the 2 copies sit in sibling files in one directory, so check first whether one of them (or an existing module there) already owns this behaviour and the others should call it; otherwise extract it into one module in that directory and have each site call it.
R10 · Code Duplication · Duplicated block with local edits (47 matched lines × 2 locations) · ×1
  • Duplicated block with local edits (47 matched lines × 2 locations) web-astro/scripts/evolution-flow-figures.mjs:7 — web-astro/scripts/evolution-flow-figures.mjs:7 · web-astro/scripts/training-sequences-figures.mjs:7 — the two spans are one implementation copied and then locally edited — 319 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
R10 · Code Duplication · Duplicated block (39 lines × 2 locations) · ×1
  • Duplicated block (39 lines × 2 locations) chapter2/attention_visualization/frontend/components/PromptDisplay.tsx:15 — chapter2/attention_visualization/frontend/components/PromptDisplay.tsx:15 · chapter2/attention_visualization/frontend/components/ResponseDisplay.tsx:11 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
R10 · Code Duplication · Duplicated block (37 lines × 3 locations) · ×1
  • Duplicated block (37 lines × 3 locations) chapter6/live-audio/backend/utils/providers/llmProviders.js:58 — chapter6/live-audio/backend/utils/providers/llmProviders.js:58 · chapter6/live-audio/backend/utils/providers/llmProviders.js:110 · chapter6/live-audio/backend/utils/providers/llmProviders.js:172 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
R10 · Code Duplication · Duplicated block (36 lines × 2 locations) · ×1
  • Duplicated block (36 lines × 2 locations) REDACTED:163 — REDACTED:163 · REDACTED:493 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
R10 · Code Duplication · Duplicated block (35 lines × 3 locations) · ×1
  • Duplicated block (35 lines × 3 locations) web-astro/scripts/collaboration-society-figures.mjs:26 — web-astro/scripts/collaboration-society-figures.mjs:26 · web-astro/scripts/evolution-methods-figures.mjs:45 · web-astro/scripts/training-sequences-figures.mjs:20 — the 3 copies are spread across 3 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
R10 · Code Duplication · Duplicated block with local edits (31 matched lines × 2 locations) · ×1
  • Duplicated block with local edits (31 matched lines × 2 locations) extras/auto-translate.js:357 — extras/auto-translate.js:357 · REDACTED:533 — the two spans are one implementation copied and then locally edited — 215 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
R10 · Code Duplication · Duplicated block (31 lines × 2 locations) · ×1
  • Duplicated block (31 lines × 2 locations) REDACTED:37 — REDACTED:37 · REDACTED:36 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
R10 · Code Duplication · Duplicated block (29 lines × 2 locations) · ×1
  • Duplicated block (29 lines × 2 locations) web-astro/scripts/training-foundations-figures.mjs:5 — web-astro/scripts/training-foundations-figures.mjs:5 · web-astro/scripts/training-systems-figures.mjs:4 — the 2 copies sit in sibling files in one directory, so check first whether one of them (or an existing module there) already owns this behaviour and the others should call it; otherwise extract it into one module in that directory and have each site call it.
R10 · Code Duplication · Duplicated block (28 lines × 2 locations) · ×1
  • Duplicated block (28 lines × 2 locations) REDACTED:15 — REDACTED:15 · REDACTED:289 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
R10 · Code Duplication · Duplicated block (26 lines × 4 locations) · ×1
  • Duplicated block (26 lines × 4 locations) web-astro/scripts/evolution-methods-figures.mjs:45 — web-astro/scripts/evolution-methods-figures.mjs:45 · web-astro/scripts/training-foundations-figures.mjs:16 · web-astro/scripts/training-sequences-figures.mjs:20 · web-astro/scripts/training-systems-figures.mjs:15 — the 4 copies are spread across 4 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
R10 · Code Duplication · Duplicated block (22 lines × 2 locations) · ×1
  • Duplicated block (22 lines × 2 locations) REDACTED:87 — REDACTED:87 · REDACTED:67 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
R10 · Code Duplication · Duplicated block with local edits (21 matched lines × 2 locations) · ×1
  • Duplicated block with local edits (21 matched lines × 2 locations) chapter6/live-audio/backend/utils/providers/llmProviders.js:30 — chapter6/live-audio/backend/utils/providers/llmProviders.js:30 · chapter6/live-audio/backend/utils/providers/llmProviders.js:153 — the two spans are one implementation copied and then locally edited — 112 tokens are still identical, in the same order in both spans, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
R10 · Code Duplication · Duplicated block (21 lines × 2 locations) · ×1
  • Duplicated block (21 lines × 2 locations) REDACTED:400 — REDACTED:400 · REDACTED:479 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
R10 · Code Duplication · Duplicated block with local edits (20 matched lines × 2 locations) · ×1
  • Duplicated block with local edits (20 matched lines × 2 locations) extras/auto-translate.js:197 — extras/auto-translate.js:197 · web-astro/src/scripts/machine-translation.ts:136 — the two spans are one implementation copied and then locally edited — 129 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
R10 · Code Duplication · Duplicated block (18 lines × 2 locations) · ×1
  • Duplicated block (18 lines × 2 locations) REDACTED:23 — REDACTED:23 · REDACTED:51 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
R10 · Code Duplication · Duplicated block with local edits (16 matched lines × 2 locations) · ×1
  • Duplicated block with local edits (16 matched lines × 2 locations) web-astro/src/lib/highlight-store.ts:51 — web-astro/src/lib/highlight-store.ts:51 · web-astro/src/lib/highlight-store.ts:96 — the two spans are one implementation copied and then locally edited — 111 tokens are still identical, in the same order in both spans, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
R10 · Code Duplication · Duplicated block (15 lines × 3 locations) · ×1
  • Duplicated block (15 lines × 3 locations) web-astro/scripts/collaboration-society-figures.mjs:215 — web-astro/scripts/collaboration-society-figures.mjs:215 · web-astro/scripts/collaboration-society-figures.mjs:236 · web-astro/scripts/collaboration-society-figures.mjs:395 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
R10 · Code Duplication · Duplicated block with local edits (14 matched lines × 2 locations) · ×1
  • Duplicated block with local edits (14 matched lines × 2 locations) web-astro/scripts/chapter3-figure-kit.mjs:7 — web-astro/scripts/chapter3-figure-kit.mjs:7 · REDACTED:36 — the two spans are one implementation copied and then locally edited — 68 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
R10 · Code Duplication · Duplicated block (14 lines × 2 locations) · ×1
  • Duplicated block (14 lines × 2 locations) web-astro/scripts/evaluation-spectrum-figures.mjs:24 — web-astro/scripts/evaluation-spectrum-figures.mjs:24 · REDACTED:20 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
R10 · Code Duplication · Duplicated block (12 lines × 3 locations) · ×1
  • Duplicated block (12 lines × 3 locations) web-astro/scripts/collaboration-society-figures.mjs:73 — web-astro/scripts/collaboration-society-figures.mjs:73 · web-astro/scripts/collaboration-society-figures.mjs:166 · web-astro/scripts/collaboration-society-figures.mjs:291 — all 3 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
R11 · Import Boundaries · Boundary violation [package · ×1
  • Boundary violation [package:third-party-deep-import] chapter6/live-audio/frontend/pages/index.tsx:8 — chapter6/live-audio/frontend/pages/index.tsx:8 imports react-syntax-highlighter/dist/cjs/styles/prism, reaching past a declared dependency's public entry into its build output — that path is the package's toolchain layout, not its API, and a minor version bump can relocate it with no semver signal. Import from the package's documented entry point instead.
R2 · Cyclomatic Complexity · Complex function walk (cyclomatic 65, cognitive 57) · ×1
  • Complex function walk (cyclomatic 65, cognitive 57) REDACTED:15 — walk has cyclomatic complexity 65 and cognitive complexity 57; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R2 · Cyclomatic Complexity · Complex function (anonymous) (cyclomatic 55, cognitive 127) · ×1
  • Complex function (anonymous) (cyclomatic 55, cognitive 127) web-astro/scripts/build.test.mjs:489 — (anonymous) has cyclomatic complexity 55 and cognitive complexity 127; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R2 · Cyclomatic Complexity · Complex function main (cyclomatic 54, cognitive 97) · ×1
  • Complex function main (cyclomatic 54, cognitive 97) slides/review.mjs:96 — main has cyclomatic complexity 54 and cognitive complexity 97; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R2 · Cyclomatic Complexity · Complex function validateExperimentEvidence (cyclomatic 50, cognitive 25) · ×1
  • Complex function validateExperimentEvidence (cyclomatic 50, cognitive 25) chapter6/live-audio/backend/experiment_validation.js:19 — validateExperimentEvidence has cyclomatic complexity 50 and cognitive complexity 25; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R2 · Cyclomatic Complexity · Complex function onmessage (cyclomatic 39, cognitive 64) · ×1
  • Complex function onmessage (cyclomatic 39, cognitive 64) chapter6/live-audio/frontend/pages/index.tsx:139 — onmessage has cyclomatic complexity 39 and cognitive complexity 64; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R2 · Cyclomatic Complexity · Complex function translatePath (cyclomatic 28, cognitive 34) · ×1
  • Complex function translatePath (cyclomatic 28, cognitive 34) REDACTED:94 — translatePath has cyclomatic complexity 28 and cognitive complexity 34; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R2 · Cyclomatic Complexity · Complex function validateLesson (cyclomatic 28, cognitive 33) · ×1
  • Complex function validateLesson (cyclomatic 28, cognitive 33) slides/generate.mjs:344 — validateLesson has cyclomatic complexity 28 and cognitive complexity 33; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R2 · Cyclomatic Complexity · Complex function (anonymous) (cyclomatic 27, cognitive 13) · ×1
  • Complex function (anonymous) (cyclomatic 27, cognitive 13) web-astro/src/lib/annotations.ts:57 — (anonymous) has cyclomatic complexity 27 and cognitive complexity 13; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R2 · Cyclomatic Complexity · Complex function rewriteSidebar (cyclomatic 24, cognitive 58) · ×1
  • Complex function rewriteSidebar (cyclomatic 24, cognitive 58) REDACTED:354 — rewriteSidebar has cyclomatic complexity 24 and cognitive complexity 58; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R2 · Cyclomatic Complexity · Complex function Home (cyclomatic 24, cognitive 20) · ×1
  • Complex function Home (cyclomatic 24, cognitive 20) chapter2/attention_visualization/frontend/pages/index.tsx:56 — Home has cyclomatic complexity 24 and cognitive complexity 20; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R2 · Cyclomatic Complexity · Complex function main (cyclomatic 23, cognitive 28) · ×1
  • Complex function main (cyclomatic 23, cognitive 28) slides/generate.mjs:476 — main has cyclomatic complexity 23 and cognitive complexity 28; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R2 · Cyclomatic Complexity · Complex function (anonymous) (cyclomatic 22, cognitive 29) · ×1
  • Complex function (anonymous) (cyclomatic 22, cognitive 29) REDACTED:616 — (anonymous) has cyclomatic complexity 22 and cognitive complexity 29; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R2 · Cyclomatic Complexity · Complex function (anonymous) (cyclomatic 21, cognitive 50) · ×1
  • Complex function (anonymous) (cyclomatic 21, cognitive 50) web-astro/scripts/retrieval-workflow-layout.test.mjs:10 — (anonymous) has cyclomatic complexity 21 and cognitive complexity 50; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R2 · Cyclomatic Complexity · Complex function runLlm (cyclomatic 21, cognitive 28) · ×1
  • Complex function runLlm (cyclomatic 21, cognitive 28) chapter6/live-audio/backend/run_real_validation.js:222 — runLlm has cyclomatic complexity 21 and cognitive complexity 28; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R2 · Cyclomatic Complexity · Complex function color (cyclomatic 21, cognitive 27) · ×1
  • Complex function color (cyclomatic 21, cognitive 27) web-astro/scripts/figure-style.mjs:33 — color has cyclomatic complexity 21 and cognitive complexity 27; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R2 · Cyclomatic Complexity · Complex function detectLang (cyclomatic 20, cognitive 26) · ×1
  • Complex function detectLang (cyclomatic 20, cognitive 26) REDACTED:31 — detectLang has cyclomatic complexity 20 and cognitive complexity 26; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R2 · Cyclomatic Complexity · Complex function isCompleteSentence (cyclomatic 20, cognitive 22) · ×1
  • Complex function isCompleteSentence (cyclomatic 20, cognitive 22) chapter6/live-audio/backend/server.js:535 — isCompleteSentence has cyclomatic complexity 20 and cognitive complexity 22; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R2 · Cyclomatic Complexity · Complex function (anonymous) (cyclomatic 20, cognitive 15) · ×1
  • Complex function (anonymous) (cyclomatic 20, cognitive 15) web-astro/src/scripts/highlights.ts:338 — (anonymous) has cyclomatic complexity 20 and cognitive complexity 15; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R2 · Cyclomatic Complexity · Complex function slugForPath (cyclomatic 17, cognitive 24) · ×1
  • Complex function slugForPath (cyclomatic 17, cognitive 24) extras/search-index-router.js:32 — slugForPath has cyclomatic complexity 17 and cognitive complexity 24; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R3 · Large Files · chapter6/live-audio/backend/server.js · ×1
  • chapter6/live-audio/backend/server.js: 884 lines of code chapter6/live-audio/backend/server.js:1 — chapter6/live-audio/backend/server.js has 884 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files · slides/chapter1-pilot.mjs · ×1
  • slides/chapter1-pilot.mjs: 708 lines of code slides/chapter1-pilot.mjs:1 — slides/chapter1-pilot.mjs has 708 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files · chapter6/live-audio/frontend/pages/index.tsx · ×1
  • chapter6/live-audio/frontend/pages/index.tsx: 667 lines of code chapter6/live-audio/frontend/pages/index.tsx:1 — chapter6/live-audio/frontend/pages/index.tsx has 667 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files · REDACTED · ×1
  • REDACTED: 641 lines of code REDACTED:1 — REDACTED has 641 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files · web-astro/src/scripts/highlights.ts · ×1
  • web-astro/src/scripts/highlights.ts: 529 lines of code web-astro/src/scripts/highlights.ts:1 — web-astro/src/scripts/highlights.ts has 529 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files · slides/generate.mjs · ×1
  • slides/generate.mjs: 507 lines of code slides/generate.mjs:1 — slides/generate.mjs has 507 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files · chapter2/attention_visualization/frontend/components/AttentionModal.tsx · ×1
  • chapter2/attention_visualization/frontend/components/AttentionModal.tsx: 420 lines of code chapter2/attention_visualization/frontend/components/AttentionModal.tsx:1 — chapter2/attention_visualization/frontend/components/AttentionModal.tsx has 420 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files · chapter6/live-audio/backend/run_real_validation.js · ×1
  • chapter6/live-audio/backend/run_real_validation.js: 420 lines of code chapter6/live-audio/backend/run_real_validation.js:1 — chapter6/live-audio/backend/run_real_validation.js has 420 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files · extras/agent-lab/agent-trajectory.js · ×1
  • extras/agent-lab/agent-trajectory.js: 419 lines of code extras/agent-lab/agent-trajectory.js:1 — extras/agent-lab/agent-trajectory.js has 419 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files · extras/auto-translate.js · ×1
  • extras/auto-translate.js: 410 lines of code extras/auto-translate.js:1 — extras/auto-translate.js has 410 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R7 · Dead Code · Dead file (~706 LoC) · ×1
  • Dead file (~706 LoC) REDACTED — no import path from any entry point (20 application, 15 tooling, 40 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
R7 · Dead Code · Dead file (~531 LoC) · ×1
  • Dead file (~531 LoC) web-astro/src/scripts/highlights.ts — no import path from any entry point (20 application, 15 tooling, 40 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
R7 · Dead Code · Dead file (~472 LoC) · ×1
  • Dead file (~472 LoC) extras/auto-translate.js — no import path from any entry point (20 application, 15 tooling, 40 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
R7 · Dead Code · Dead file (~453 LoC) · ×1
  • Dead file (~453 LoC) extras/agent-lab/agent-trajectory.js — no import path from any entry point (20 application, 15 tooling, 40 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
R7 · Dead Code · Dead file (~194 LoC) · ×1
  • Dead file (~194 LoC) web-astro/src/scripts/note-editor.ts — no import path from any entry point (20 application, 15 tooling, 40 test roots considered), but 1 in-repo import(s) from 1 other file(s) do name it (web-astro/src/scripts/highlights.ts) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it
R7 · Dead Code · Dead file (~176 LoC) · ×1
  • Dead file (~176 LoC) extras/nav-collapse.js — no import path from any entry point (20 application, 15 tooling, 40 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
R7 · Dead Code · Dead file (~174 LoC) · ×1
  • Dead file (~174 LoC) web-astro/src/scripts/machine-translation.ts — no import path from any entry point (20 application, 15 tooling, 40 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
R7 · Dead Code · Dead file (~161 LoC) · ×1
  • Dead file (~161 LoC) web-astro/src/scripts/reading-position.ts — no import path from any entry point (20 application, 15 tooling, 40 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
R7 · Dead Code · Dead file (~158 LoC) · ×1
  • Dead file (~158 LoC) chapter2/attention_visualization/frontend/components/AttentionHeatmap.tsx — no import path from any entry point (20 application, 15 tooling, 40 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
R7 · Dead Code · Dead file (~120 LoC) · ×1
  • Dead file (~120 LoC) web-astro/src/lib/highlight-store.ts — no import path from any entry point (20 application, 15 tooling, 40 test roots considered), but 2 in-repo import(s) from 2 other file(s) do name it (web-astro/src/scripts/highlights.ts, web-astro/src/scripts/note-editor.ts) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it
R7 · Dead Code · Dead file (~115 LoC) · ×1
  • Dead file (~115 LoC) web-astro/src/scripts/figure-viewer.ts — no import path from any entry point (20 application, 15 tooling, 40 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
R7 · Dead Code · Dead file (~89 LoC) · ×1
  • Dead file (~89 LoC) extras/search-index-router.js — no import path from any entry point (20 application, 15 tooling, 40 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
R7 · Dead Code · Dead file (~83 LoC) · ×1
  • Dead file (~83 LoC) chapter6/live-audio/backend/test_llm.js — no import path from any entry point (20 application, 15 tooling, 40 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
R7 · Dead Code · Dead file (~78 LoC) · ×1
  • Dead file (~78 LoC) chapter5/conversational-ui/baseline/src/App.jsx — no import path from any entry point (20 application, 15 tooling, 40 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
R7 · Dead Code · Dead file (~72 LoC) · ×1
  • Dead file (~72 LoC) chapter2/attention_visualization/frontend/components/TestCaseSelector.tsx — no import path from any entry point (20 application, 15 tooling, 40 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
R7 · Dead Code · Dead file (~63 LoC) · ×1
  • Dead file (~63 LoC) web-astro/src/lib/book.ts — no import path from any entry point (20 application, 15 tooling, 40 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
R7 · Dead Code · Dead file (~41 LoC) · ×1
  • Dead file (~41 LoC) extras/mermaid-init.js — no import path from any entry point (20 application, 15 tooling, 40 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
R7 · Dead Code · Dead file (~40 LoC) · ×1
  • Dead file (~40 LoC) web-astro/src/lib/i18n.ts — no import path from any entry point (20 application, 15 tooling, 40 test roots considered), but 3 in-repo import(s) from 3 other file(s) do name it (web-astro/src/lib/book.ts, web-astro/src/scripts/highlights.ts, web-astro/src/scripts/note-editor.ts) — every one of those referrers is itself unreachable, so this file is dead only as a member of that cluster: if any referrer is in fact alive, this row falls with it
R7 · Dead Code · Dead file (~37 LoC) · ×1
  • Dead file (~37 LoC) extras/mathjax.js — no import path from any entry point (20 application, 15 tooling, 40 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
R7 · Dead Code · Dead file (~13 LoC) · ×1
  • Dead file (~13 LoC) chapter6/live-audio/backend/utils/test_number_to_words.js — no import path from any entry point (20 application, 15 tooling, 40 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
R7 · Dead Code · Dead file (~12 LoC) · ×1
  • Dead file (~12 LoC) chapter6/live-audio/backend/utils/test_markdown_snake_case.js — no import path from any entry point (20 application, 15 tooling, 40 test roots considered), and no other file in the scanned tree imports it — nothing in-repo names this module at all, which is the strongest form of this claim the import graph can make
R8 · Dependency Hygiene · Unused dependency 'clsx' · ×1
  • Unused dependency 'clsx' — Declared in REDACTED but never imported anywhere in that package or its workspace members — no static import reaches it. Usually that is dead weight and attack surface, but two shapes are indistinguishable from source and are NOT dead: an optional or native peer that another dependency loads dynamically at runtime, and a package a build, docs or test step installs and invokes separately. Confirm which of the three this is before removing it.
R8 · Dependency Hygiene · Unused dependency 'tailwind-merge' · ×1
  • Unused dependency 'tailwind-merge' — Declared in REDACTED but never imported anywhere in that package or its workspace members — no static import reaches it. Usually that is dead weight and attack surface, but two shapes are indistinguishable from source and are NOT dead: an optional or native peer that another dependency loads dynamically at runtime, and a package a build, docs or test step installs and invokes separately. Confirm which of the three this is before removing it.
R8 · Dependency Hygiene · Unused dependency '@slidev/cli' · ×1
  • Unused dependency '@slidev/cli' — Declared in chapter5/paper-to-ppt/package.json but never imported anywhere in that package or its workspace members — no static import reaches it. Usually that is dead weight and attack surface, but two shapes are indistinguishable from source and are NOT dead: an optional or native peer that another dependency loads dynamically at runtime, and a package a build, docs or test step installs and invokes separately. Confirm which of the three this is before removing it.
S1 · Web-Security Posture · Third-party script without Subresource Integrity · ×1
  • Third-party script without Subresource Integrity chapter7/elo-leaderboard/validation/runs/exp7-7-arena-20260731-v1/leaderboard_animation.html:7 — `https://d3js.org/d3.v7.min.js` is executed by this page with no Subresource Integrity. Whoever can answer that request — the CDN, anyone who compromises it, anyone on the network path — runs arbitrary script in this page's origin, with its session. The URL also names no version, so it resolves to whatever that origin serves at fetch time — the executed bytes can change with nobody touching this repository.
Minor — 183 finding(s)
X4 · Structured logging · Interpolated log message defeats structured logging · ×40
  • Interpolated log message defeats structured logging chapter9/browser-use-rpa/learning_agent/agent.py:142 — `debug` at line 142 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.debug("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.debug("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging chapter9/browser-use-rpa/learning_agent/agent.py:145 — `error` at line 145 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging chapter9/browser-use-rpa/learning_agent/agent.py:245 — `error` at line 245 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging chapter9/browser-use-rpa/learning_agent/agent.py:279 — `error` at line 279 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging chapter9/browser-use-rpa/learning_agent/agent.py:301 — `info` at line 301 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging chapter9/browser-use-rpa/learning_agent/agent.py:303 — `info` at line 303 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging chapter9/browser-use-rpa/learning_agent/agent.py:343 — `info` at line 343 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging chapter9/browser-use-rpa/learning_agent/agent.py:344 — `info` at line 344 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging chapter9/browser-use-rpa/learning_agent/agent.py:346 — `info` at line 346 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging chapter9/browser-use-rpa/learning_agent/agent.py:347 — `info` at line 347 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging chapter9/browser-use-rpa/learning_agent/agent.py:376 — `info` at line 376 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging chapter9/browser-use-rpa/learning_agent/agent.py:563 — `error` at line 563 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging chapter9/browser-use-rpa/learning_agent/knowledge_base.py:90 — `info` at line 90 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging chapter9/browser-use-rpa/learning_agent/knowledge_base.py:144 — `error` at line 144 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging chapter9/browser-use-rpa/learning_agent/knowledge_base.py:146 — `info` at line 146 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging chapter9/browser-use-rpa/learning_agent/knowledge_base.py:299 — `info` at line 299 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging chapter9/browser-use-rpa/learning_agent/replay.py:115 — `info` at line 115 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging chapter9/browser-use-rpa/learning_agent/replay.py:121 — `info` at line 121 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging chapter9/browser-use-rpa/learning_agent/replay.py:152 — `error` at line 152 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.error("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.error("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging chapter9/browser-use-rpa/learning_agent/replay.py:160 — `info` at line 160 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.info("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.info("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging chapter9/browser-use-rpa/learning_agent/replay.py:247 — `warning` at line 247 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.warning("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.warning("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging chapter9/browser-use-rpa/learning_agent/replay.py:271 — `debug` at line 271 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.debug("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.debug("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging chapter9/browser-use-rpa/learning_agent/replay.py:281 — `debug` at line 281 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.debug("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.debug("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging chapter9/browser-use-rpa/learning_agent/replay.py:304 — `debug` at line 304 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.debug("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.debug("order moved", order_id=order_id, status=status)` with structlog.
  • Interpolated log message defeats structured logging chapter9/browser-use-rpa/learning_agent/replay.py:319 — `debug` at line 319 is handed an f-string as its message, so the logger receives one finished string — the values in it cannot be queried, filtered or aggregated as fields, every occurrence reads as a different message, and the string is built even when the record is filtered out. Pass the values beside a constant message instead: `logger.debug("order %s moved to %s", order_id, status)` with the standard library's `logging`, which keeps the message and its arguments apart on the record, or `log.debug("order moved", order_id=order_id, status=status)` with structlog.
  • + 15 more in this group — see findings.md.
D29 · Static Analysis (SAST) · REDACTED · ×25
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
X10 · Duplicated predicate · Duplicated predicate · ×25
  • Duplicated predicate chapter6/live-audio/backend/server.js:437 — `jsonData.choices[0]?.delta?.content || ''` appears character-identically in 2 files — chapter6/live-audio/backend/server.js, chapter6/live-audio/backend/test_llm.js. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate slides/generate.mjs:360 — `lesson.experiments.length < 1 || lesson.experiments.length > 3` appears character-identically in 2 files — slides/generate.mjs, slides/review.mjs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate chapter6/live-audio/backend/run_real_validation.js:347 — `response.headers?.['x-request-id'] || response.headers?.['request-id'] || null` appears character-identically in 2 files — chapter6/live-audio/backend/run_real_validation.js, chapter6/live-audio/backend/utils/providers/asrProviders.js. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate chapter3/agentic-rag/evaluation/evaluate.py:288 — `"average_analysis_recall" in agentic_metrics and "average_analysis_recall" in non_agentic_metrics` appears character-identically in 2 files — chapter3/agentic-rag/evaluation/evaluate.py, chapter3/contextual-retrieval/evaluation/evaluate.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate chapter3/agentic-rag/evaluation/evaluate.py:284 — `"average_keyword_recall" in agentic_metrics and "average_keyword_recall" in non_agentic_metrics` appears character-identically in 2 files — chapter3/agentic-rag/evaluation/evaluate.py, chapter3/contextual-retrieval/evaluation/evaluate.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate chapter3/agentic-rag/evaluation/evaluate.py:274 — `"average_time" in agentic_metrics and "average_time" in non_agentic_metrics` appears character-identically in 2 files — chapter3/agentic-rag/evaluation/evaluate.py, chapter3/contextual-retrieval/evaluation/evaluate.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate chapter3/agentic-rag/evaluation/evaluate.py:279 — `"cases_with_citations" in agentic_metrics and "cases_with_citations" in non_agentic_metrics` appears character-identically in 2 files — chapter3/agentic-rag/evaluation/evaluate.py, chapter3/contextual-retrieval/evaluation/evaluate.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate REDACTED:549 — `"import" in error_str or exception_type == "ImportError"` appears character-identically in 2 files — REDACTED, REDACTED. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate REDACTED:539 — `"not found" in error_str or "no such file" in error_str or exception_type == "FileNotFoundError"` appears character-identically in 2 files — REDACTED, REDACTED. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate REDACTED:536 — `"permission" in error_str or exception_type == "PermissionError"` appears character-identically in 2 files — REDACTED, REDACTED. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate chapter3/contextual-retrieval/campaign.py:245 — `"request" in call and "response" in call` appears character-identically in 3 files — chapter3/contextual-retrieval/campaign.py, chapter3/memory_rag_campaign.py, chapter3/structured-knowledge-extraction/campaign.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate REDACTED:543 — `"syntax" in error_str or exception_type == "SyntaxError"` appears character-identically in 2 files — REDACTED, REDACTED. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate chapter8/curly-quote-sft/train_sft.py:80 — `(step + 1) % args.grad_accum == 0 or step == len(loader) - 1` appears character-identically in 2 files — chapter8/curly-quote-sft/train_sft.py, chapter8/exact-copy-sft/train_sft.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate book-ar/svg_lib.py:95 — `0x1100 <= o <= 0x115F or 0x2460 <= o <= 0x24FF or 0x2500 <= o <= 0x257F or 0x25A0 <= o <= 0x25FF or 0x2600 <= o <= 0x27BF or 0x2E80 <= o <= …` appears character-identically in 6 files — book-ar/svg_lib.py, book-en/svg_lib.py, book-es/svg_lib.py, book-id/svg_lib.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate book-ar/svg_lib.py:370 — `OMIT_TITLE and size == FS_TITLE and len(str(content).strip()) >= TITLE_MIN_LEN` appears character-identically in 6 files — book-ar/svg_lib.py, book-en/svg_lib.py, book-es/svg_lib.py, book-id/svg_lib.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate REDACTED:83 — `_DELETE_FROM.search(query) and not _HAS_WHERE.search(query)` appears character-identically in 3 files — REDACTED, chapter9/harness-safety-gate/validation/real_20260807T160109Z/candidates/deterministic/confirmation_gate.py, chapter9/harness-safety-gate/validation/real_20260807T160109Z/candidates/rejected_control/confirmation_gate.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate chapter10/multi-role-transfer/package_comparison.py:134 — `all(response_ids) and len(set(response_ids)) == len(response_ids)` appears character-identically in 2 files — chapter10/multi-role-transfer/package_comparison.py, chapter10/multi-role-transfer/run_official_experiment.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate chapter3/user-memory/agent.py:88 — `api_key or Config.get_api_key(self.provider)` appears character-identically in 2 files — chapter3/user-memory/agent.py, chapter3/user-memory/conversational_agent.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate chapter8/premature-completion-dpo/build_preference_data.py:166 — `args.model or default_model(args.provider)` appears character-identically in 2 files — chapter8/premature-completion-dpo/build_preference_data.py, chapter9/ai-style-skill/evaluate.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py:374 — `args.out or Path(__file__).parent / "validation" / "runs" / datetime.now(timezone.utc).strftime("exp6-14-%Y%m%dT%H%M%SZ")` appears character-identically in 3 files — chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py, chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py, chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate chapter1/context/run_experiment_1_1.py:625 — `args.output_dir or Path("validation") / f"real_{stamp}"` appears character-identically in 2 files — chapter1/context/run_experiment_1_1.py, chapter1/web-search-agent/run_experiment_1_2.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate REDACTED:337 — `args.output_dir or ROOT / "validation" / stamp` appears character-identically in 6 files — REDACTED, chapter9/harness-safety-gate/run_experiment_9_7.py, chapter9/prompt-auto-optimization/run_experiment_9_3.py, chapter9/self-evolution-eval/run_experiment_9_9.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate chapter6/astra-async-steering/experiment.py:418 — `args.repeats < 1 or args.tool_delay <= 0 or args.timeout <= 0` appears character-identically in 4 files — chapter6/astra-async-steering/experiment.py, chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py, chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py, chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate book-ar/fit_svg_text.py:34 — `argv[1:] or sorted(glob.glob(os.path.join(IMG, '*.svg')))` appears character-identically in 6 files — book-ar/fit_svg_text.py, book-en/fit_svg_text.py, book-es/fit_svg_text.py, book-id/fit_svg_text.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate chapter6/astra-async-steering/experiment.py:304 — `arm == "async_steer" and not steer_target` appears character-identically in 4 files — chapter6/astra-async-steering/experiment.py, chapter6/astra-async-steering/validation/runs/exp6-14-20260905-formal/source/experiment.py, chapter6/astra-async-steering/validation/runs/pilot-20260905-v1/source/experiment.py, chapter6/astra-async-steering/validation/runs/pilot-20260905-v2/source/experiment.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
X7 · Silent fallback defaults · Silent fallback default in catch · ×15
  • Silent fallback default in catch chapter1/image-gen-workflow/evidence.py:73 — `_git` (in `repo_info`) swallows every exception into `return ''` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default in catch chapter5/coding-agent/agent.py:90 — `_get_git_branch` swallows every exception into `return 'unknown'` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default in catch chapter5/coding-agent/agent.py:103 — `_get_main_branch` swallows every exception into `return 'main'` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default in catch chapter5/coding-agent/agent.py:111 — `_get_git_status` swallows every exception into `return 'Not a git repository'` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default in catch chapter5/coding-agent/agent.py:119 — `_get_recent_commits` swallows every exception into `return 'Not a git repository'` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default in catch chapter5/coding-agent/agent_new.py:76 — `_get_git_branch` swallows every exception into `return 'unknown'` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default in catch chapter5/coding-agent/agent_new.py:89 — `_get_main_branch` swallows every exception into `return 'main'` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default in catch chapter5/coding-agent/agent_new.py:97 — `_get_git_status` swallows every exception into `return 'Not a git repository'` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default in catch chapter5/coding-agent/agent_new.py:105 — `_get_recent_commits` swallows every exception into `return 'Not a git repository'` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default in catch REDACTED:63 — `_llm_reply` swallows every exception into `return '(未安装 openai 依赖,无法启用 LLM 模式;已回退占位回复)'` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default in catch REDACTED:63 — `_llm_reply` swallows every exception into `return '(未安装 openai 依赖,无法启用 LLM 模式;已回退占位回复)'` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default in catch REDACTED:63 — `_llm_reply` swallows every exception into `return '(未安装 openai 依赖,无法启用 LLM 模式;已回退占位回复)'` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default in catch REDACTED:63 — `_llm_reply` swallows every exception into `return '(未安装 openai 依赖,无法启用 LLM 模式;已回退占位回复)'` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default in catch REDACTED:184 — `load_seen_hashes` swallows every exception into `return set()` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default in catch REDACTED:154 — `main` swallows every exception into `return 1` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
D24 · Comment Value · redundant comment · ×10
  • redundant comment chapter6/live-audio/backend/server.js:65 — 7 comments in this file only repeat the code they sit on (lines 65, 156, 374, 409, 547, 868, 895), for example "Initialize LLM provider". Delete it, or replace it with what the code cannot say (why it is done here, a constraint, or a consequence).
  • redundant comment chapter6/live-audio/backend/utils/providers/asrProviders.js:66 — 5 comments in this file only repeat the code they sit on (lines 66, 81, 156, 171, 254), for example "Create WAV buffer". Delete it, or replace it with what the code cannot say (why it is done here, a constraint, or a consequence).
  • redundant comment chapter6/live-audio/backend/utils/providers/llmProviders.js:221 — "Get API key from global config" repeats the code it sits on: 4 of its 5 words (api, key, global, config) are already in `const apiKey = globalConfig[providerConfig.apiKey];`. Delete it, or replace it with what the code cannot say (why it is done here, a constraint, or a consequence).
  • redundant comment chapter6/live-audio/backend/utils/textProcessor.js:3 — "Remove emoji from the sentence" repeats the code it sits on: 3 of its 3 words (remove, emoji, sentence) are already in `function removeEmoji(sentence)`. Delete it, or replace it with what the code cannot say (why it is done here, a constraint, or a consequence).
  • redundant comment chapter6/live-audio/backend/utils/textProcessor.js:88 — "Pronounce special characters" repeats the code it sits on: 3 of its 3 words (pronounce, special, characters) are already in `function pronounceSpecialCharacters(text, isCodeBlock = false)`. Delete it, or replace it with what the code cannot say (why it is done here, a constraint, or a consequence).
  • redundant comment chapter6/live-audio/backend/utils/textProcessor.js:145 — "Pronounce numbers in text" repeats the code it sits on: 3 of its 3 words (pronounce, numbers, text) are already in `function pronounceNumbers(text, language)`. Delete it, or replace it with what the code cannot say (why it is done here, a constraint, or a consequence).
  • redundant comment chapter6/live-audio/backend/utils/vad.js:34 — "Initialize the Silero VAD" repeats the code it sits on: 3 of its 3 words (initialize, silero, vad) are already in `this.initializationPromise = this.initializeSileroVAD();`. Delete it, or replace it with what the code cannot say (why it is done here, a constraint, or a consequence).
  • redundant comment chapter6/live-audio/backend/utils/vad.js:107 — "Create input tensor" repeats the code it sits on: 3 of its 3 words (create, input, tensor) are already in `const inputTensor = new ort.Tensor('float32', audioSamples, [1, audioSamples.length]);`. Delete it, or replace it with what the code cannot say (why it is done here, a constraint, or a consequence).
  • redundant comment chapter6/live-audio/frontend/pages/index.tsx:346 — "Create AudioContext with specific sample rate" repeats the code it sits on: 5 of its 6 words (create, audio, context, sample, rate) are already in `audioContextRef.current = new AudioContextClass({`. Delete it, or replace it with what the code cannot say (why it is done here, a constraint, or a consequence).
  • redundant comment chapter6/live-audio/frontend/pages/index.tsx:382 — "Check if getUserMedia is supported" repeats the code it sits on: 4 of its 5 words (check, get, user, media) are already in `if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia)`. Delete it, or replace it with what the code cannot say (why it is done here, a constraint, or a consequence).
X6 · Hand-rolled structured-format parsing · Hand-rolled JSON/XML parsing via regex · ×8
  • Hand-rolled JSON/XML parsing via regex scripts/site_i18n.py:138 — A regex whose pattern encodes JSON/XML syntax is parsing a structured format by hand — malformed or differently-typed content (e.g. `"amount": "5"` as a string) silently mis-parses instead of failing validation. This Python code already uses a real parser in the same package; use it here too.
  • Hand-rolled JSON/XML parsing via regex REDACTED:165 — A regex whose pattern encodes JSON/XML syntax is parsing a structured format by hand — malformed or differently-typed content (e.g. `"amount": "5"` as a string) silently mis-parses instead of failing validation. This Python code already uses a real parser in the same package; use it here too.
  • Hand-rolled JSON/XML parsing via regex book-zhtw/strip_titles.py:23 — A regex whose pattern encodes JSON/XML syntax is parsing a structured format by hand — malformed or differently-typed content (e.g. `"amount": "5"` as a string) silently mis-parses instead of failing validation. This Python code already uses a real parser in the same package; use it here too.
  • Hand-rolled JSON/XML parsing via regex book-tr/strip_titles.py:23 — A regex whose pattern encodes JSON/XML syntax is parsing a structured format by hand — malformed or differently-typed content (e.g. `"amount": "5"` as a string) silently mis-parses instead of failing validation. This Python code already uses a real parser in the same package; use it here too.
  • Hand-rolled JSON/XML parsing via regex book-ta/strip_titles.py:24 — A regex whose pattern encodes JSON/XML syntax is parsing a structured format by hand — malformed or differently-typed content (e.g. `"amount": "5"` as a string) silently mis-parses instead of failing validation. This Python code already uses a real parser in the same package; use it here too.
  • Hand-rolled JSON/XML parsing via regex book-id/strip_titles.py:23 — A regex whose pattern encodes JSON/XML syntax is parsing a structured format by hand — malformed or differently-typed content (e.g. `"amount": "5"` as a string) silently mis-parses instead of failing validation. This Python code already uses a real parser in the same package; use it here too.
  • Hand-rolled JSON/XML parsing via regex book-en/strip_titles.py:24 — A regex whose pattern encodes JSON/XML syntax is parsing a structured format by hand — malformed or differently-typed content (e.g. `"amount": "5"` as a string) silently mis-parses instead of failing validation. This Python code already uses a real parser in the same package; use it here too.
  • Hand-rolled JSON/XML parsing via regex book/strip_titles.py:23 — A regex whose pattern encodes JSON/XML syntax is parsing a structured format by hand — malformed or differently-typed content (e.g. `"amount": "5"` as a string) silently mis-parses instead of failing validation. This Python code already uses a real parser in the same package; use it here too.
D29 · Static Analysis (SAST) · REDACTED · ×6
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D30 · Dependency Vulnerabilities · Low CVE · ×5
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
X23 · Unguarded diagnostic materialisation · Diagnostic log message is built whether or not it is wanted · ×5
  • Diagnostic log message is built whether or not it is wanted REDACTED:921 — `debug` at line 921 is called with an argument built by `"…".join(loaded_extension_names)` (line 921), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on.
  • Diagnostic log message is built whether or not it is wanted chapter9/browser-use-rpa/browser-use/browser_use/browser/watchdogs/downloads_watchdog.py:336 — `debug` at line 336 is called with an argument built by `[f.name for f in files_before]` (line 336), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on.
  • Diagnostic log message is built whether or not it is wanted REDACTED:2042 — `debug` at line 2042 is called with an argument built by `[t.name for t in threads]` (line 2042), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on.
  • Diagnostic log message is built whether or not it is wanted chapter3/retrieval-pipeline/reranker.py:240 — `debug` at line 240 is called with an argument built by `"…".join(changes)` (line 240), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on.
  • Diagnostic log message is built whether or not it is wanted chapter3/dense-embedding/document_store.py:72 — `debug` at line 72 is called with an argument built by `list(metadata.keys())` (line 72), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on.
X7 · Silent fallback defaults · Silent fallback default on parse failure · ×5
  • Silent fallback default on parse failure REDACTED:160 — `_load_memories` returns `[]` when `(OSError, json.JSONDecodeError)` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default on parse failure chapter3/structured-knowledge-extraction/discovery.py:60 — `_chat_json` returns `{}` when `json.JSONDecodeError` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default on parse failure chapter4/multimodal-agent/campaign.py:230 — `judge_answers` returns `[]` when `json.JSONDecodeError` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default on parse failure chapter7/agent-cost-analysis/cost_efficiency_analyzer.py:145 — `_coerce_int` returns `0` when `(TypeError, ValueError)` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default on parse failure chapter7/agent-cost-analysis/cost_efficiency_analyzer.py:154 — `_coerce_float` returns `0.0` when `(TypeError, ValueError)` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
D29 · Static Analysis (SAST) · REDACTED · ×4
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
X7 · Silent fallback defaults · Pending state with no failure state · ×4
  • Pending state with no failure state chapter5/conversational-ui/validation/runs/20260729T212727Z-5_11-hmr/app/frontend/src/App.jsx:61 — The view draws `思考中…` under `loading`, but `loading` is settled by a load that can fail and the component draws no failure state, so a failed load is shown as "not yet" for ever, or as the loaded state over its initial value. Give the component a failure state and draw it.
  • Pending state with no failure state chapter5/conversational-ui/validation/runs/20260729T212616Z-5_11-hmr/app/frontend/src/App.jsx:61 — The view draws `思考中…` under `loading`, but `loading` is settled by a load that can fail and the component draws no failure state, so a failed load is shown as "not yet" for ever, or as the loaded state over its initial value. Give the component a failure state and draw it.
  • Pending state with no failure state chapter5/conversational-ui/frontend/src/App.jsx:61 — The view draws `思考中…` under `loading`, but `loading` is settled by a load that can fail and the component draws no failure state, so a failed load is shown as "not yet" for ever, or as the loaded state over its initial value. Give the component a failure state and draw it.
  • Pending state with no failure state chapter5/conversational-ui/baseline/src/App.jsx:61 — The view draws `思考中…` under `loading`, but `loading` is settled by a load that can fail and the component draws no failure state, so a failed load is shown as "not yet" for ever, or as the loaded state over its initial value. Give the component a failure state and draw it.
D16 · Bus Factor · Off-boarding risk · ×3
  • Off-boarding risk: anonymized user #1 — If anonymized user #1 becomes unavailable, 123 significant file(s) lose their only recent owner: chapter7/android-world/run_controlled_experiment.py, chapter4/active-tool-discovery/run_exact_experiment.py, chapter3/contextual-retrieval-for-user-memory/main.py, chapter2/prompt-engineering/run_ablation.py, REDACTED, REDACTED, chapter1/context/run_experiment_1_1.py, chapter10/multi-role-transfer/run_comparison.py (+115 more). Pair on, review, or document these before any departure.
  • Off-boarding risk: anonymized user #2 — If anonymized user #2 becomes unavailable, 31 significant file(s) lose their only recent owner: chapter5/permission-embedded-data-objects/run_live_security_eval.py, chapter4/collaboration-tools/src/notification_dispatcher.py, chapter9/hermes-self-evolution/run_downstream_ablation.py, chapter8/MultilingualReasoning/evaluate_multilingual.py, chapter3/structured-index/hybrid_retriever.py, chapter9/harness-safety-gate/safety_policy_gate.py, chapter4/perception-tools/src/filesystem_tools.py, chapter10/book-translation/consistency_auditor.py (+23 more). Pair on, review, or document these before any departure.
  • Off-boarding risk: anonymized user #3 — If anonymized user #3 becomes unavailable, 7 significant file(s) lose their only recent owner: chapter6/live-audio/frontend/pages/index.tsx, chapter9/browser-use-rpa/learning_agent/agent.py, chapter1/learning-from-experience/game_environment.py, chapter3/dense-embedding/indexing.py, chapter3/retrieval-pipeline/reranker.py, chapter2/attention_visualization/frontend/components/AttentionStats.tsx, chapter4/perception-tools/src/base.py. Pair on, review, or document these before any departure.
D31 · IaC & Container Security · Low IaC · ×3
  • REDACTED
  • REDACTED
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED · ×2
  • REDACTED
  • REDACTED
D30 · Dependency Vulnerabilities · Low vulnerability · ×2
  • REDACTED
  • REDACTED
D16 · Bus Factor · Further sole-owners (lower concentration) · ×1
  • Further sole-owners (lower concentration) — 5 other contributor(s) are each the sole owner of a small amount of code below the off-boarding threshold — folded into the bus-factor score and metrics (166 single-owned of 834 analysed files in total, counted over production source files of roughly 2,400 bytes or more, excluding vendored, generated, example/demo and scaffolding-template trees and test files identified by path convention, largest first; 834 of the 1026 production source files in this repository met that bar). They are anonymized user #4 (1 file(s)), anonymized user #5 (1 file(s)), anonymized user #6 (1 file(s)), anonymized user #7 (1 file(s)), anonymized user #8 (1 file(s)) — spread or document their files in the same way, at lower priority than the named off-boarding risks above. The files folded here: REDACTED, chapter1/context/vis_validation.py, chapter4/perception-tools/src/xquik_tools.py, REDACTED, agentbook/providers/models.py.
D20 · ADR Quality · No ADRs found · ×1
  • No ADRs found — No ADRs found. No recognised ADR directory (`docs/adr/`, `docs/decisions/`, `adr/`, `docs/rfcs/`, an `ADR0001/` folder, or their siblings) exists anywhere in this tree. What was searched, so you can tell an empty log from a search that missed one: every directory under the tree (build output, dependencies and VCS metadata excepted), for a document that is either any non-index page inside a recognised ADR directory, whatever its name and however deeply nested (`docs/adr/use-postgres.md`, `docs/adr/2024/0001-x.md`); or a file anywhere whose name is ADR-shaped (`0001-use-postgres.md`, `adr-012-caching.md`); or, when neither turned anything up, a document carrying the decision-record signature (an "Architecture Decision Record" heading, or Status / Context / Decision / Consequences as section headings). A decision log that clears none of these — unnumbered files outside any recognised directory, without those headings — is not seen by this check and this row is then wrong. If that is your case, say so rather than renaming anything; otherwise, consider recording architectural decisions in `docs/adr/`.
D26 · Project Cohesion · Projects may be oversized for their cohesion · ×1
  • Projects may be oversized for their cohesion — 1 of 103 project(s) overshoot their size bounds, lowering Project Cohesion to 9.8/10. The most over is `(repository root)` (18522 LoC, 137 module-visible types across 37 directories). Review these for cohesion — draw the boundary inside the module first (group each responsibility into its own package or directory and keep the cross-boundary members non-public), since splitting a published package moves types between packages and breaks consumers.
D28 · Secrets (history) · Rotate the exposed credentials · ×1
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
M2 · Architecture documentation · No ADRs · ×1
  • No ADRs — No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.
M3 · Folder & project structure · No src/ separation · ×1
  • No src/ separation — Production code isn't grouped under a src/ folder — it's spread across several top-level directories, so there's no one place that says 'this is the product'.
P2 · Observability · Logging is not universal · ×1
  • Logging is not universal — Only 28/96 runnable modules use logging (modules with no entry point or server are excluded — they are libraries a runnable module hosts). Silent: `chapter1/image-gen-workflow`, `chapter1/learning-from-experience`, `chapter10/autonomous-phone-registration`, `chapter10/book-translation`, `chapter10/generative-agents` and 63 more.
P3 · Security & performance tooling · No SAST · ×1
  • No SAST REDACTED:4 — No static application security testing detected. For this repository's stack, add bandit, `semgrep --config=p/python`, or CodeQL's python pack as a CI step. What was searched, so you can tell an absence from a miss: the 26840 CI workflow file(s) in this repository, and the scanner and linter configuration checked in beside them. A scan that runs outside CI, one configured in your forge's web UI rather than in a committed file, or a tool whose name is none of those this check carries, is not seen — if that is your case the row is wrong, and saying so is more useful than adding a second scanner.
P3 · Security & performance tooling · No dependency-update automation · ×1
  • No dependency-update automation chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/package.json:13 — `chapter2/agent-skills-ppt/runs/exp2-6-kimi-pptx-20260731-v1/workspace/package.json` declares packages, and nothing in the repository keeps them current: no Dependabot or Renovate configuration that schedules updates, and no dependency-review gate on pull requests. A pinned dependency stays at the version it was added at until someone notices — including after an advisory is published against it. Add a `.github/dependabot.yml` with one `package-ecosystem` entry per ecosystem the tree uses (or an enabled `renovate.json`), and gate pull requests with `actions/dependency-review-action`.
P6 · Release Hygiene · Changelog looks stale/thin · ×1
  • Changelog looks stale/thin — The changelog this check read carries 0 versioned entries, against a bar of 3. Counted as either the distinct `x.y.z` versions it names (a link's target is not counted) or its version-shaped section headings (`## [1.2.0]`, `## V14.x.x`, `## Updates in 8.0.x`), whichever is the larger — so a log sectioned by minor series counts its sections, not its individual patch numbers. Entries recorded somewhere this check does not read — release notes generated at tag time from a generator config it did not recognise, or a log kept outside the repository — are not counted here, and this row is about what is re-findable in the tree rather than about how often you release.
R7 · Dead Code · Unused export 'initReaderNavigation' · ×1
  • Unused export 'initReaderNavigation' web-astro/src/scripts/reader-navigation.ts:119 — Nothing imports this binding — it is safe to review for removal.
R7 · Dead Code · Unused module-local declaration 'escapeHtml' · ×1
  • Unused module-local declaration 'escapeHtml' slides/chapter1-pilot.mjs:1 — This top-level declaration is not exported and its name occurs nowhere else in its module — not called, read, typed against, re-exported or named by a string. Nothing outside the module can reach a non-exported binding, so this is the whole search: remove it, or use it.
X2 · Cancellation propagation · Not all async functions that make a request accept an AbortSignal · ×1
  • Not all async functions that make a request accept an AbortSignal — Only 5/11 async functions that make a cancellable request (fetch, axios, ky, ofetch, got, undici, node:http) accept an AbortSignal or pass one on, so a request keeps running after whatever wanted it has given up — a page navigated away from, an unmounted component, a timed-out job. Take a `signal` (or an options object that carries one) and hand it to the request; where nothing could ever cancel the call, omitting it is a deliberate choice — judge against how the function is used.
X5 · Nullable reference types · Strict null checking is not enabled everywhere the repository type-checks · ×1
  • Strict null checking is not enabled everywhere the repository type-checks — 1/2 of this repository's type-checking configuration(s) turn on strict null checking (`"strict": true`, or `"strictNullChecks": true`). A configuration that states neither is counted as OFF, because off is tsc's own default; a solution-style one whose `"files"` is empty and whose `"references"` point at other projects is in neither number, because it checks no source itself. Where it is off, `string` admits `null` and `undefined`: passing a value that is null compiles silently and throws on the first property access.
X5 · Nullable reference types · Null assertions (`!`) reduce the strict null checking score · ×1
  • Null assertions (`!`) reduce the strict null checking score — ~8.0 `!` null assertions per 1k TypeScript source lines — 34 assertion(s) across the 4240 source line(s) of the 25 TypeScript file(s) read, which is the only code the operator asserts anything in (a `!` in a `.js` file is not this operator and was not counted, and one in a file whose null checking is off silences nothing). Densest: web-astro/src/scripts/reading-position.ts (23), web-astro/src/scripts/highlights.ts (8), web-astro/src/scripts/figure-viewer.ts (2). Each one tells the compiler to trust the author about null, suppressing the very diagnostic `strictNullChecks` exists to produce.
Minor — 18 finding(s)
D12 · Dependency Hygiene · Outdated · ×12
  • Outdated: colorlog — `colorlog` is pinned to 6.8.0, but 6.12.0 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 6.8.0 until the declaration is edited.
  • Outdated: flagembedding — `flagembedding` is pinned to 1.2.11, but 1.4.2 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 1.2.11 until the declaration is edited.
  • Outdated: huggingface-hub — `huggingface-hub` is pinned to 0.20.3, but 2.4.0 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 0.20.3 until the declaration is edited. This crosses a major version, so it is a migration rather than a bump.
  • Outdated: nltk — `nltk` is pinned to 3.6.5, but 3.10.4 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 3.6.5 until the declaration is edited.
  • Outdated: openai-whisper — `openai-whisper` is pinned to 20231106, but 20250625 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 20231106 until the declaration is edited. This crosses a major version, so it is a migration rather than a bump.
  • Outdated: scikit-learn — `scikit-learn` is pinned to 1.3.0, but 1.9.1 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 1.3.0 until the declaration is edited.
  • Outdated: scipy — `scipy` is pinned to 1.11.1, but 1.18.1 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 1.11.1 until the declaration is edited.
  • Outdated: selenium — `selenium` is pinned to 4.8.2, but 4.52.0 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 4.8.2 until the declaration is edited.
  • Outdated: sentence-transformers — `sentence-transformers` is pinned to 2.2.2, but 6.2.0 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 2.2.2 until the declaration is edited. This crosses a major version, so it is a migration rather than a bump.
  • Outdated: typing-extensions — `typing-extensions` is pinned to 4.9.0, but 4.16.0 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 4.9.0 until the declaration is edited.
  • Outdated: unsloth — `unsloth` is pinned to 2026.8.2, but 2026.11.1 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 2026.8.2 until the declaration is edited.
  • Outdated: websockets — `websockets` is pinned to 15.0.1, but 17.4 is the current stable release on PyPI. An exact pin never moves on its own, so this repository installs 15.0.1 until the declaration is edited. This crosses a major version, so it is a migration rather than a bump.
D10 · Test Quality · Skipped (documented) · ×5
  • Skipped (documented): should work with ${providerName} provider chapter6/live-audio/backend/tests/provider-tests.js:143 — Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a this.skip()/t.skip() call
  • Skipped (documented): should work with ${combination.description} chapter6/live-audio/backend/tests/provider-tests.js:285 — Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a this.skip()/t.skip() call
  • Skipped (documented): should compare provider performance chapter6/live-audio/backend/tests/test-asr-providers.js:232 — Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a this.skip()/t.skip() call
  • Skipped (documented): should compare provider response times chapter6/live-audio/backend/tests/test-llm-providers.js:491 — Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a this.skip()/t.skip() call
  • Skipped (documented): should integrate with live audio system chapter6/live-audio/backend/tests/test-tts-providers.js:373 — Skipped with a documented reason — a deferral, not lazy debt: skipped at run time by a this.skip()/t.skip() call
D24 · Comment Value · doc comments repeat the names · ×1
  • doc comments repeat the names chapter6/live-audio/backend/utils/providers/asrProviders.js:7 — 0 of 15 documented parameters and 4 of 30 summaries in `livechat-backend` only repeat the member or parameter name (e.g. "Base ASR Provider class" for `BaseASRProvider`). Delete the restating tags, or add what the name does not say.

Appendix B — Reproduction & audit trail

Every external tool invocation behind a deep-scan dimension — the tool, its captured version, the exact command, how many findings it yielded, and a link to the retained raw output. To reproduce any finding: check out the same commit and run the command shown (repo-relative — never an absolute scratch path). The complete raw scanner output is retained verbatim under artifacts/raw/ (indexed in artifacts/raw/index.json); per-invocation exit codes and wall-clock durations are in sidecar.json — kept out of this table so the rendered report stays byte-identical across runs of the same commit.

DimensionToolVersionCommandFindingsRaw output
D28 · Secrets (history)gitleaks—gitleaks detect --no-banner --config /opt/gitleaks-rules/canine-gitleaks.toml --report-format json --report-path /tmp/watchdog-gitleaks-ed07a75aac42416aae1a3797c9a73531/history.json --exit-code 0 --source .77artifacts/raw/gitleaks-history.json
D28 · Secrets (history)gitleaks—gitleaks detect --no-git --no-banner --config /opt/gitleaks-rules/canine-gitleaks.toml --report-format json --report-path /tmp/watchdog-gitleaks-ed07a75aac42416aae1a3797c9a73531/tree.json --exit-code 0 --source .72artifacts/raw/gitleaks-tree.json
D29 · Static Analysis (SAST)semgrep—semgrep --config /opt/semgrep-rules/security-audit.yml --config /opt/semgrep-rules/owasp-top-ten.yml --config /opt/semgrep-rules/canine-sast.yml --json --quiet --timeout 10 --timeout-threshold 3 --metrics off --exclude *.arrow --exclude *.avro --exclude *.csv --exclude *.dat --exclude *.db --exclude *.feather --exclude *.geojson --exclude *.h5 --exclude *.hdf5 --exclude *.jsonl --exclude *.log --exclude *.ndjson --exclude *.npy --exclude *.npz --exclude *.orc --exclude *.parquet --exclude *.pickle --exclude *.pkl --exclude *.psv --exclude *.sqlite --exclude *.sqlite3 --exclude *.tfrecord --exclude *.tsv --exclude *.txt --exclude chapter5/conversational-ui/validation/runs/20260729T212933Z-5_11-hmr/app/frontend .172artifacts/raw/semgrep.json
D30 · Dependency Vulnerabilitiestrivy—trivy fs --scanners vuln --format json --quiet --severity CRITICAL,HIGH,MEDIUM,LOW --skip-dirs **/bin/** --skip-dirs **/obj/** . --skip-db-update210artifacts/raw/trivy-fs.json
D31 · IaC & Container Securitytrivy—trivy config --format json --quiet .42artifacts/raw/trivy-config.json
D32 · Data Compliance (PII/GDPR)semgrep—semgrep: not applicable — No personal data was found crossing a boundary the PII/GDPR ruleset checks — nothing written to a log or console sink, placed in a URL or query string, or persisted to browser storage. That is a clean result for the LEAK surface only: this ruleset detects personal data escaping, it does not inventory the personal data a repository holds, so it is not evidence that this repository has no personal-data surface. The personal-data map (Appendix C) and the C1-C5 compliance cards are what speak to that. semgrep could not parse 6 file(s) — `chapter5/video-edit/validation/runs/exp5-6-real-blender-20260730-055102/scripts/corrected-final-attempt-3.py`, `slides/review.mjs`, `web-astro/scripts/check-deployment.mjs`, `web-astro/scripts/prepare-assets.mjs`, `web-astro/src/lib/edition-source.mjs`, … (+1 more) — so the PII/GDPR sweep did not cover the unparsed regions of them; rows reported elsewhere in those files are real.0—
D37 · Vulnerability-disclosure Policydisclosure—disclosure: not applicable — No vulnerability-disclosure policy file found (SECURITY.md/.markdown/.rst/.txt at root or under .github/.forgejo/.gitea/docs, .well-known/security.txt). A coordinated-disclosure policy may live off-repo, so this is not evidenced rather than failed.0—
D40 · Network Egress Confinementruntime-hardening—runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.0—
D41 · Kernel & Syscall Confinementruntime-hardening—runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.0—
D42 · Runtime Threat Enforcementruntime-hardening—runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.0—
D43 · Malicious Dependenciestrivy—trivy fs --scanners vuln --format json --quiet --severity CRITICAL,HIGH,MEDIUM,LOW --skip-dirs **/bin/** --skip-dirs **/obj/** . --skip-db-update0artifacts/raw/trivy-fs.json

Run 01a1a2b2-393b-7533-bac6-f677191c661a · every finding is also locatable in findings.md, and the complete scoring record (with exit codes + durations) in sidecar.json.

Downloadable artifacts

Machine-readable and reproducible from this commit + frozen rubric — drop them straight into a contract appendix, a CRA dossier, or a downstream SCA / VEX tool.

⬇ Findings, MITRE CWE-tagged .sarif⬇ Health changelog .md