Public report of Miosa-osa/OSA, published 17 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, 17 November 2026, 01:13 UTC · Survey ID cd_0740b24151e945dd969aedca415f045c

Miosa-osa/OSA

Measured 17 November 2026, 01:12 UTC, at code version 047b7b7

First survey, so nothing to compare with yet Code coverage: not measuredTest reliability: not measured

Code coverage is not measured: Suite not runnable in-image.

Test reliability is not measured: No test run produced results.

CAI score 64.3out of 100 At risk

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: 419,914 lines of product code in 7 projects, tests not counted · Estimated rebuild effort: about 4.8 person-years · Weakest lens: Performance, 60.0

Findings by how serious they are

88 critical 1798 serious 109 minor

12 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
17 November 2026, 01:12 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 ▸

49of 49 dimensions measured by tools.
1978of 1995 findings point to an exact file and line, so you can open each one in the code. The other 17 concern the repository as a whole, such as missing documentation.
49dimensions across 8 lenses, read from 419,914 lines of product code in 7 projects.
Chapters

Executive summary

Miosa-osa/OSA is rated At risk because critical security findings are open, most of them in the build pipeline. It scores 64.3 out of 100, which the At risk rating leaves unchanged.

Performance, at 60.0, is the weakest lens by a small margin, and the weakest lens counts most in the score. The best first step for the work it takes is replacing the two exposed passwords or keys and switching the old ones off, worth about 2.7 points. Removing the blocking calls would lift Performance itself, worth about 3.8 points.

Forty pipeline tools are referenced by a changeable name, so the build pipeline can be tampered with. Eighteen pipeline steps run downloads nobody checks, and fourteen known security holes in the packages the code depends on can be used by attackers. Pinning each tool to an exact version, checking each download against a checksum and updating the vulnerable packages would close these risks. The four unsafe settings in infrastructure or container files need changing to safe values. The two passwords or keys in the code and the password or key in the code's history need replacing, with the old ones switched off. The four errors that are caught and ignored need handling or logging instead of being ignored.

The product code is 419,914 lines, about €690,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.
Performance 60.0 · counts for 45%Security and Compliance 60.5 · counts for 25%Production Readiness 61.0 · counts for 14%Code Health 73.9 · counts for 8%Maturity 94.3 · counts for 4%Architecture 96.3 · counts for 2%Event-Driven 100.0 · counts for 1%Event Sourcing 100.0 · counts for 1%

The weakest lenses score close to each other, so improving any of them moves the score.

Code composition: what the lines of code are
Business logic 0%Supporting code 0%Tests 100%
Rebuild cost: about €690,000 · Estimate
Cost to rebuild€230,000 to €1,200,000, for 3,841 to 12,188 hours of work, about 4.8 person-years for 2 to 10 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.9 at a score of 64. 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: 419,914 lines of product code
Comment linesThe estimate prices 419,872 lines. Comment lines count towards the size of 419,914 lines but aren't priced as work.
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.

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 2 Leaked secret finding(s) in REDACTED Scanning — start with REDACTED (2).
Raises the score by about 2.7 points · Low effort · REDACTED Scanning
2
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.
Raises the score by about 3.8 points · Medium effort · Async & latency hygiene
3
Resolve the 4 EmptyCatchBlock finding(s) in Explicit Debt — start with Program.cs (2), VncServer.cs (2).
Raises the score by about 1.7 points · Low effort · Explicit Debt

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 €690,000 to build again, about 4.8 person-years of work. Its weakest lens is Performance, at 60.0 (Adequate). Performance is about whether the code is written and measured with speed in mind. Because the weakest lens counts most in the score, work on Performance also moves the score most.
Based on: the rebuild estimate · the Performance grade · how much each lens counts
What to do: Start with the Performance actions in Top priorities.
If you do one thing first · First action
Resolve the 2 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 2.7 points for low effort, because it clears the 2 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.6 out of 10. Code at that level is slower to change than clean code, and we estimate the extra work at 4% to 8% on every change. The history of the code shows how much it changes: about 798,867 lines over the last 90 days, which is about 3,239,850 lines a year. At that pace, the extra work comes to an estimated 291.8 to 1750.6 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.

384 modules, with 344 dependencies between them. One loop runs through 2 of the modules, marked above the diagonal.

The table shows the 40 modules with the most connections; 344 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 (global)2 OptimalSystemAgent.Tools3 osa_tui.client.types4 osa_tui.components.measure5 osa_tui.config.cli6 osa_tui.dialogs7 osa_tui.event8 osa_tui.style9 osa_tui.tools10 osa_tui.components11 osa_tui.components.agents.entry12 osa_tui.components.chat.message13 osa_tui.components.chat.thinking_box14 osa_tui.components.completion_panel15 osa_tui.components.input.mentions16 osa_tui.components.task_checklist17 osa_tui.dialogs.claude_login18 osa_tui.dialogs.config_editor19 osa_tui.dialogs.onboarding20 osa_tui.dialogs.permissions21 osa_tui.dialogs.plan_review22 osa_tui.dialogs.skills_browser23 osa_tui.dialogs.survey24 osa_tui.app.attachment25 osa_tui.app.handle_actions26 osa_tui.components.activity27 osa_tui.components.agents28 osa_tui.components.chat29 osa_tui.components.header30 osa_tui.components.sidebar31 osa_tui.components.status_bar32 osa_tui.components.tasks33 osa_tui.components.toast34 osa_tui.dialogs.hooks_viewer35 osa_tui.dialogs.model_picker36 osa_tui.dialogs.transcript_viewer37 osa_tui.app.assistant_stream38 osa_tui.app.event_loop39 osa_tui.components.input40 osa_tui.app
1 (global)
2 OptimalSystemAgent.Tools
3 osa_tui.client.types
4 osa_tui.components.measure
5 osa_tui.config.cli
6 osa_tui.dialogs
7 osa_tui.event
8 osa_tui.style
9 osa_tui.tools
10 osa_tui.components11
11 osa_tui.components.agents.entry1
12 osa_tui.components.chat.message112
13 osa_tui.components.chat.thinking_box111
14 osa_tui.components.completion_panel12
15 osa_tui.components.input.mentions1
16 osa_tui.components.task_checklist111
17 osa_tui.dialogs.claude_login121
18 osa_tui.dialogs.config_editor1
19 osa_tui.dialogs.onboarding221
20 osa_tui.dialogs.permissions111
21 osa_tui.dialogs.plan_review111
22 osa_tui.dialogs.skills_browser2
23 osa_tui.dialogs.survey111
24 osa_tui.app.attachment1
25 osa_tui.app.handle_actions11
26 osa_tui.components.activity11112
27 osa_tui.components.agents11129
28 osa_tui.components.chat111122
29 osa_tui.components.header112
30 osa_tui.components.sidebar112
31 osa_tui.components.status_bar11122
32 osa_tui.components.tasks112
33 osa_tui.components.toast1112
34 osa_tui.dialogs.hooks_viewer221
35 osa_tui.dialogs.model_picker11212
36 osa_tui.dialogs.transcript_viewer121
37 osa_tui.app.assistant_stream11
38 osa_tui.app.event_loop11111
39 osa_tui.components.input111231
40 osa_tui.app141211121211112111111211122121
Uses a module listed above itPart of a loopThe module itself
1 (global)2 OptimalSystemAgent.Tools3 osa_tui.client.types4 osa_tui.components.measure5 osa_tui.config.cli6 osa_tui.dialogs7 osa_tui.event8 osa_tui.style9 osa_tui.tools10 osa_tui.components11 osa_tui.components.agents.entry12 osa_tui.components.chat.message13 osa_tui.components.chat.thinking_box14 osa_tui.components.completion_panel15 osa_tui.components.input.mentions16 osa_tui.components.task_checklist17 osa_tui.dialogs.claude_login18 osa_tui.dialogs.config_editor19 osa_tui.dialogs.onboarding20 osa_tui.dialogs.permissions21 osa_tui.dialogs.plan_review22 osa_tui.dialogs.skills_browser23 osa_tui.dialogs.survey24 osa_tui.app.attachment25 osa_tui.app.handle_actions26 osa_tui.components.activity27 osa_tui.components.agents28 osa_tui.components.chat29 osa_tui.components.header30 osa_tui.components.sidebar31 osa_tui.components.status_bar32 osa_tui.components.tasks33 osa_tui.components.toast34 osa_tui.dialogs.hooks_viewer35 osa_tui.dialogs.model_picker36 osa_tui.dialogs.transcript_viewer37 osa_tui.app.assistant_stream38 osa_tui.app.event_loop39 osa_tui.components.input40 osa_tui.app(global)1OptimalSystemAgent.Tools2osa_tui.client.types3osa_tui.components.measure4osa_tui.config.cli5osa_tui.dialogs6osa_tui.event7osa_tui.style8osa_tui.tools9osa_tui.components10osa_tui.components.agents.entry11osa_tui.components.chat.message12osa_tui.components.chat.thinking_box13osa_tui.components.completion_panel14osa_tui.components.input.mentions15osa_tui.components.task_checklist16osa_tui.dialogs.claude_login17osa_tui.dialogs.config_editor18osa_tui.dialogs.onboarding19osa_tui.dialogs.permissions20osa_tui.dialogs.plan_review21osa_tui.dialogs.skills_browser22osa_tui.dialogs.survey23osa_tui.app.attachment24osa_tui.app.handle_actions25osa_tui.components.activity26osa_tui.components.agents27osa_tui.components.chat28osa_tui.components.header29osa_tui.components.sidebar30osa_tui.components.status_bar31osa_tui.components.tasks32osa_tui.components.toast33osa_tui.dialogs.hooks_viewer34osa_tui.dialogs.model_picker35osa_tui.dialogs.transcript_viewer36osa_tui.app.assistant_stream37osa_tui.app.event_loop38osa_tui.components.input39osa_tui.app40111112111121111121122111111121111111111211129111122112112111221121112221112121211111111111231141211121211112111111211122121+344 more modules (most-connected shown)

At a glance — Code Health · 73.9 · Strong ·

At a glance — Architecture · 96.3 · Exemplary ·

At a glance — Maturity · 94.3 · Exemplary ·

At a glance — Readiness · 61.0 · Adequate · gated by P8 ·

At a glance — Security · 60.5 · Adequate · gated by D29, D36 ·

At a glance — Event-Driven · 100.0 · Exemplary ·

At a glance — Event Sourcing · 100.0 · Exemplary ·

At a glance — Performance · 60.0 · 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
A05:2025 — Injection71High / Critical
A03:2025 — Software Supply Chain Failures64High / Critical
A02:2025 — Security Misconfiguration13High / Critical
A07:2025 — Authentication Failures4High / Critical
A01:2025 — Broken Access Control1Medium

Roadmap

Top priorities: 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; Resolve the 2 Leaked secret finding(s) in REDACTED Scanning — start with REDACTED (2); Name the access rules — give each one a named predicate/policy object your guards consult, so the rule set can be reviewed and unit-tested independently of the call sites that enforce it.

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

Do thisHelpsEffortDimension
Resolve the 2 Leaked secret finding(s) in REDACTED Scanning — start with REDACTED (2).+2.7 ptsLowREDACTED Scanning
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.+3.8 ptsMediumAsync & latency hygiene
Resolve the 4 EmptyCatchBlock finding(s) in Explicit Debt — start with Program.cs (2), VncServer.cs (2).+1.7 ptsLowExplicit Debt
Name the access rules — give each one a named predicate/policy object your guards consult, so the rule set can be reviewed and unit-tested independently of the call sites that enforce it.+1.8 ptsMediumAccess Controls
Resolve the 1 Unbounded dependency requirement finding(s) in Dependency Hygiene.+0.9 ptsLowDependency Hygiene
Turn off runtime CREATE TABLE in production and let the versioned migrations own the schema.+1.7 ptsMediumSchema migrations
Resolve the 4 REDACTED finding(s) in Supply-chain Provenance & Signing — start with REDACTED, REDACTED, REDACTED.+0.7 ptsLowSupply-chain Provenance & Signing
Resolve the 1 End-of-life runtime finding(s) in Platform End-of-Life — start with .tool-versions.+0.7 ptsLowPlatform End-of-Life

File quality

Per-file score 0–10 — a quality signature. Of 561 files carrying findings, judged against the Production bar: 1% slop · 54% mixed · 45% near-clean.

FileScoreBandWorst signal
REDACTED0.4SlopDependency Vulnerabilities: High CVE: REDACTED
REDACTED0.6SlopDependency Vulnerabilities: High CVE: REDACTED
REDACTED0.9SlopDependency Vulnerabilities: Critical CVE: REDACTED
REDACTED0.9SlopIaC & Container Security: High IaC: REDACTED
REDACTED2.3SlopStatic Analysis (SAST): High: REDACTED
REDACTED2.3SlopStatic Analysis (SAST): High: REDACTED
REDACTED2.4SlopStatic Analysis (SAST): High: REDACTED
REDACTED3.0SlopStatic Analysis (SAST): High: REDACTED
REDACTED4.1MixedStatic Analysis (SAST): High: REDACTED
REDACTED4.3MixedSecrets (history): REDACTED: REDACTED
REDACTED4.4MixedStatic Analysis (SAST): High: REDACTED
priv/rust/tui/src/app/handle_actions.rs4.8MixedCyclomatic Complexity: App::handle_agent_response (cyclomatic 24)
REDACTED4.8MixedStatic Analysis (SAST): High: REDACTED
priv/rust/tui/src/app/handle_backend.rs4.8MixedCyclomatic Complexity: App::handle_backend_event (cyclomatic 421)
lib/optimal_system_agent/events/tui_forwarder.ex5.0MixedChange Coupling: Boundary-crossing change coupling: tui_forwarder.ex ↔ handle_backend.rs
REDACTED5.1MixedStatic Analysis (SAST): High: REDACTED
REDACTED5.1MixedStatic Analysis (SAST): High: REDACTED
REDACTED5.8MixedREDACTED Scanning: Leaked secret: REDACTED
REDACTED5.8MixedStatic Analysis (SAST): High: REDACTED
REDACTED5.8MixedStatic 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 — 88

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 — 1798

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 — 109

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

Could not be resolved — 12

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 49 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 — 49 dimensions across the health lenses
D1D2D3D4D5D6D7D12D13D14D15D17D19D20D26D27D28D29D30D31D32D34D35D36D43D44AX10AX3AX4AX5AX8AX9C2ED3ES2GD1M1M2M3M4P1P2P3P4P5P6P8PF3X5

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, 1978 of 1995 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 01a1e710-104d-7264-9600-0ed367e16e91.

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: the test suite could not be built/run in-image (commonly external-service dependencies — a database, a broker — we won't provision). To have it measured, make the suite runnable without them. For context only, test code is ≈ 42% of production LoC (174,731 test / 419,653 production) — a rough proxy, NOT a coverage measurement, so it is excluded from the score. You can widen what we reach: optional: make the suite runnable without a database, broker or other service we do not provision, and real coverage is measured on the next scan.
  • D11 Test Reliability — 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. Test reliability NOT MEASURED: the test run produced no results for any test tier, so no test ever ran and flakiness could not be exercised. The cause could not be attributed, so it is excluded from the score rather than read as an absence of tests.
  • D14 License Compliance — 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 repository declares an Elixir mix.exs/REDACTED (Hex), but the licence verdict published here was taken over its crate dependencies. Nothing was read about its Mix dependencies' licensing in either direction, and a clean score on this card must not be read as covering them.
  • D16 Bus Factor — not measured this run — This is a true statement about the repository that carries nothing for its owner to act on, so it is reported here rather than as a defect in their code. Single-maintainer repository — bus factor is not applicable (8 contributor(s) across 1004 commit(s) sampled, automation and bot accounts excluded). One of them holds 92% of the history; the other 7 hold 1.1% each on average, below the 5% at which there is somebody to hand the work to. That is a single maintainer with drive-by contributors, not a team whose knowledge has concentrated — so the bus factor is not applicable and there is nothing here for the owner to act on.
  • D17 Explicit Debt — 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 4 deducted marker(s) and the 1.4/KLoC density on this row were taken over this repository's .NET projects ALONE: .ex (268,039 lines, 65% of production source), .rs (115,862 lines, 28% of production source) went unread, because every marker collector on this path is reached through a C# workspace. A read-only sweep of that source finds at least 3 task marker(s) (TODO/FIXME/HACK/XXX) across 3 file(s) that this score does not count — a floor, since only line comments are read there and D17's other eight marker kinds (suppressions, NoWarn, editorconfig severities, empty catches, commented-out code, Obsolete, dead code, preprocessor branches) need a compiler we do not have for that language. The debt in that source is UNMEASURED — its absence from the score above is a gap in this analyzer's language coverage, not a finding that the code carries none.
  • 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. PREREGISTRATION version 20's fallback (adjudication D21-sample3-v3): this rule kind was adjudicated below the 95 % precision gate, so its candidates are counted here and not published, and the score covers only the acronym-spelling and awaitable-suffix rules. The kind returns as rows only after it shows a measured precision; this says nothing about whether these names are consistent.
  • D22 Internal API Consistency — not measured this run — This is a true statement about the repository that carries nothing for its owner to act on, so it is reported here rather than as a defect in their code. The loaded project set declares no packable project and no `.Contracts` project, so there is no intentionally-exposed surface for API consistency to be judged over.
  • D24 Comment Value — 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. 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.
  • D25 ADR Conformance — 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. The code index reads C#, Razor, TypeScript, JavaScript and Vue. A rule whose scope holds production code in another language is not called honoured, because its uses could sit in that code.
  • D27 Navigability — 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. Tracing effort is measured over resolved call sites, and all 382 sampled here came from .ex/.exs files. This repository's .rs source is a material share of its production lines and contributed none, so the score above is a verdict about the part that was read. Not a finding that the unread half navigates well — it is unmeasured.
  • D32 Data Compliance (PII/GDPR) — 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. `native/macos/ScreenShare/Sources/ScreenShare/VncServer.swift`, `native/windows/ScreenShare/RfbConnection.cs` 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.
  • AX6 Interface segregation — 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's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
  • 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 (REDACTED). compose up failed (exit 14 — a file the compose project references is missing) — env file .env not found: stat .env: no such file or directory; runtime evidence skipped.
  • 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's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
  • 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.
  • X1 Async correctness — 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's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
  • X10 Duplicated predicate — 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. 72 further occurrence(s) are not listed individually; the score already reflects all 112.
  • X12 Unreachable branch — 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's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
  • X16 Unfloored truncation loop — 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's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
  • X18 Disposal-pattern correctness — 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's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
  • X2 Cancellation propagation — 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's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
  • X27 Collection changed while being enumerated — 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's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
  • X29 Per-element action decided by a fixed element — 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's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
  • X3 Exception handling — 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's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
  • X7 Silent fallback defaults — 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. 879 further occurrence(s) are not listed individually; the score already reflects all 919.

Repo exclusion declarations (.gitattributes linguist-generated/vendored, .editorconfig generated_code): none declared — every source file was scored.

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.
  • D7 Architectural Integrity: Layering is checked against detected/declared rules — an architecture whose boundaries live in convention or in code review, not in a rule a scanner can read, is not enforced 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").
  • D14 License Compliance: License compatibility is checked against declared package metadata and a policy — mislabelled or missing license metadata, and obligations that depend on how you distribute, are not resolved here.
  • 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.
  • 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.
  • 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 requirements.txt, 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.
  • D32 Data Compliance (PII/GDPR): PII/GDPR signals are heuristic pattern matches in code — they flag likely handling concerns, not legal compliance, and cannot trace where data actually flows at runtime.
  • 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.
  • 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.
  • AX9 CQS / query purity: Handlers are found by interface/name convention — a query handler using neither is not seen. Mutation is a resolved write/publish invocation (SaveChanges/repository/bus), so a write hidden behind a hand-rolled wrapper, reflection, or a string-keyed service locator resolves to a non-persistence type and isn't flagged; it detects that a query writes state, not whether the write is a legitimate read-side cache update. Clean means "no resolved write/publish in a query body", not a proof of CQS 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.5 / 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.5 / 10 · rule-coverage 100% · ceiling Prevented

93 method(s) exceeded the cyclomatic complexity threshold of 15; the worst was App::handle_backend_event at 421. A further 26 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 osa_tui::render::latex::macro_glyph at 135 — they are counted neither in the figure above nor in this dimension's score. 14 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: priv/rust/tui/src/render/latex.rs (osa_tui::render::latex::macro_glyph at 135), lib/optimal_system_agent/tools/builtins/security_intel.ex (SecurityIntel.execute at 40), lib/optimal_system_agent/shell/pty/keys.ex (Keys.named at 34), priv/rust/tui/src/app/state.rs (AppState::fmt at 33), lib/optimal_system_agent/providers/error_catalog.ex (ErrorCatalog.classify_string at 30), and 9 more not listed here. 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.

App::handle_backend_event (cyclomatic 421) · ×14priv/rust/tui/src/app/handle_backend.rs:141
osa_tui::client::sse::parse_system_event (cyclomatic 118) · ×13priv/rust/tui/src/client/sse.rs:1142
ModelPicker::draw_local_detail (cyclomatic 18) · ×4priv/rust/tui/src/dialogs/model_picker/local.rs:622
Agents::draw_tree (cyclomatic 91) · ×2priv/rust/tui/src/components/agents/render.rs:19
InputComponent::handle_event (cyclomatic 83) · ×2priv/rust/tui/src/components/input/mod.rs:2293

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

What to do

  1. Bring the 2 bodies over 120 down to 120 or less in Cyclomatic Complexity — start with App::handle_backend_event (cyclomatic 421), App::handle_command (cyclomatic 124). — 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 2 together lifts Cyclomatic Complexity from 4.5 to about 5.8/10, projected with the scoring formula itself and assuming each lands exactly at 120; a cleaner split scores higher.

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

D2 · Cognitive Complexity4.1 / 10Weak✓ 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 4.1 / 10 · rule-coverage 100% · ceiling Prevented

211 method(s) exceeded the cognitive complexity threshold of 15; the worst was App::handle_backend_event at 629.

osa_tui::render::markdown::parse_inline (cognitive 341) · ×36priv/rust/tui/src/render/markdown.rs:2005
App::handle_backend_event (cognitive 629) · ×18priv/rust/tui/src/app/handle_backend.rs:141
ModelPicker::draw_local_catalog (cognitive 34) · ×6priv/rust/tui/src/dialogs/model_picker/local.rs:493
InputComponent::draw (cognitive 131) · ×5priv/rust/tui/src/components/input/mod.rs:2747
OnboardingWizard::handle_step_channels (cognitive 17) · ×4priv/rust/tui/src/dialogs/onboarding.rs:863

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

What to do

  1. Bring the 2 bodies over 240 down to 240 or less in Cognitive Complexity — start with App::handle_backend_event (cognitive 629), osa_tui::render::markdown::parse_inline (cognitive 341). — 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 2 together lifts Cognitive Complexity from 4.1 to about 5.1/10, projected with the scoring formula itself and assuming each lands exactly at 240; a cleaner split scores higher.

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

D3 · God Classes8.2 / 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.2 / 10 · rule-coverage 100% · ceiling Prevented

198 god class(es) detected.

FileTooLong: cli/commands.ex · ×73lib/optimal_system_agent/channels/cli/commands.ex
TooManyFunctions: Settings · ×50lib/optimal_system_agent/settings.ex:1
MethodTooLong: App.handle_backend_event · ×39priv/rust/tui/src/app/handle_backend.rs:141
ClassTooLong: InputComponent · ×12priv/rust/tui/src/components/input/mod.rs:82
FunctionTooLong: osa_tui::client::sse::parse_system_event · ×9priv/rust/tui/src/client/sse.rs:1142

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

What to do

  1. Resolve the 73 FileTooLong finding(s) in God Classes — start with mod.rs (4), registry.ex (2), handler.ex (2). — One of this dimension's main actionable groups (73 warning-level).
  2. Resolve the 50 TooManyFunctions finding(s) in God Classes — start with handler.ex (2), settings.ex, tasks.ex. — One of this dimension's main actionable groups (50 warning-level).
  3. Resolve the 39 MethodTooLong finding(s) in God Classes — start with mod.rs (3), render.rs (2), event_loop.rs (2). — One of this dimension's main actionable groups (39 warning-level).

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

D4 · Code Duplication7.7 / 10Strong✓ Tool-verified

What it measures: How much of the production code is copy-pasted: the share of production lines inside a reported copy (every copy of a duplicated block or of an edited member, each line once), 10 at none and 0 at a quarter of the lines.

Method: Code duplication via token-stream sliding windows with type-aware normalization (locals masked, type names preserved), scored on the share of production lines inside a reported copy (each line once; 10 at none, 0 at a quarter). Deterministic.

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

511 duplicated block group(s) detected. 5.9 % of the production lines (24,587 of 419,653) are in a reported copy. A further 617 rows report members as variants of one another; the share counts each copied line once, however many rows cite it. 59 of the 1128 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.

Edited copy of a member (4 corresponding lines) · ×54lib/optimal_system_agent/open_computers/executor/direct/compose.ex:541
Edited copy of a member (9 corresponding lines) · ×36lib/optimal_system_agent/agent/task_tracker.ex:143
Duplicated block (8 lines × 2) · ×33canopy/backend/lib/canopy_web/controllers/activity_controller.ex:9
Duplicated block (9 lines × 2) · ×32canopy/backend/lib/canopy/workspaces.ex:94
Edited copy of a member (3 corresponding lines) · ×29lib/optimal_system_agent/security/notes_store.ex:198

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

What to do

  1. Resolve the 54 Edited copy of a member (4 corresponding lines) finding(s) in Code Duplication — start with claude_cli.ex (3), episodic_store.ex (2), xai_models.ex (2). — One of this dimension's main actionable groups (54 warning-level).
  2. Resolve the 36 Edited copy of a member (9 corresponding lines) finding(s) in Code Duplication — start with handler.ex (3), task_tracker.ex (2), tool_executor.ex (2). — One of this dimension's main actionable groups (36 warning-level).
  3. Resolve the 33 Duplicated block (8 lines × 2) finding(s) in Code Duplication — start with workflow.ex (2), claude_cli.ex (2), mod.rs (2). — One of this dimension's main actionable groups (33 warning-level).

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

7 production modules (Cargo+npm+SwiftPM+OTP), 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 7 (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 126 classes have LCOM4 above 3.

✓ On the Gold path — maintain.

Detailed fixes: d6_recommendation.md.

D7 · Architectural Integrity6.0 / 10Adequate✓ Tool-verified

What it measures: Whether the code respects its intended layering / architecture rules.

Method: Enforcement rung (Prevented/Verified/Documented) per checkable ADR via Roslyn, plus dependency cycles via the engine shared with D5/AX3. Deterministic, exact.

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

No mechanizable ADR was identified, so enforcement is not measured. Cycles found: 0.

Detailed fixes: d7_recommendation.md.

D12 · Dependency Hygiene9.4 / 10Stronggated by 1 serious finding✓ Tool-verified

What it measures: Whether dependencies are current, not deprecated, and not bloated. Known vulnerabilities are D30's.

Method: Manifest scan via dotnet list package across all projects; worst-signal-per-package deduction (capped-linear for deprecation, prerelease and outdated) per KLoC. Known-vulnerable packages are D30's and are not charged here (rubric-2026.11.2). Exhaustive.

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

8 outdated, 0 retired direct Hex dependencies, 1 pinning defect(s). Whether any of these packages is UNMAINTAINED is not graded — hex.pm publishes no maintenance status, and release age does not stand in for one. Whether any is UNUSED is not graded either: a Hex app name does not determine the modules it provides (`ecto_sql` provides Ecto.Adapters.SQL), and a large idiomatic class of BEAM dependencies — runtime adapters, codec plugins, protocol implementations and OTP applications the release starts — is correctly declared and never referenced in source, so absence of a reference is not evidence of an unused dependency. Known CVEs in this dependency graph are D30's question, read from REDACTED there.

Unbounded dependency requirement: postgrex
Outdated: bandit · ×8

What to do

  1. Resolve the 1 Unbounded dependency requirement finding(s) in Dependency Hygiene. — One of this dimension's main actionable groups (1 warning-level).

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

D13 · REDACTED Scanning5.0 / 10Adequate✓ 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 5.0 / 10 · rule-coverage 100% · ceiling Prevented

1 secret(s) detected. 4 detection(s) were excluded as holding no minted credential in material that runs: a name, reference or comparison rather than a value, a readable phrase or pattern, a value that declares itself fake, or development, test, example, mock or demo material.

REDACTED

What to do

  1. Resolve the 2 Leaked secret finding(s) in REDACTED Scanning — start with REDACTED (2). — One of this dimension's main actionable groups (2 issue-level).

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

D14 · License Compliance10.0 / 10Exemplary○ Nothing flagged

What it measures: Whether the licenses of third-party packages are compatible with your policy.

Method: Third-party package licenses resolved from declared package metadata and checked against the configured policy (allow/deny/copyleft). Deterministic; clean = no incompatible license found at metadata depth.

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

0 of 38 shipped crate(s) use a banned license. Licences were resolved from crates.io over the crates a consumer compiles — this repository's REDACTED closed over its manifests' `[dependencies]` and `[build-dependencies]`. Crates it asks for ONLY under `[dev-dependencies]` are excluded: they are not compiled by anything that depends on this repository. ★ COVERAGE OF THIS VERDICT: it grades this repository's crate dependencies and nothing else. The repository also declares an Elixir mix.exs/REDACTED (Hex), and the licences of those dependencies were NOT read by this pass — a gap in this engine's coverage, not a statement about them. So this result says the graded closure carries no banned licence; it does NOT say this repository's licensing is clear.

✓ On the Gold path — maintain.

Detailed fixes: d14_recommendation.md.

D15 · Churn × Complexity Hotspots8.4 / 10Strong✓ 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 8.4 / 10 · rule-coverage 100% · ceiling Documented

Top hotspots: priv/rust/tui/src/app/handle_backend.rs (104×421=43784); priv/rust/tui/src/app/commands.rs (48×124=5952); priv/rust/tui/src/app/event_loop.rs (88×67=5896) Repeated repair below the complexity floor: priv/rust/tui/src/main.rs (15 of 29 changes were fixes); priv/rust/tui/src/components/chat/welcome.rs (8 of 15 changes were fixes); lib/optimal_system_agent/providers/error_catalog.ex (8 of 14 changes were fixes)

Hotspot: priv/rust/tui/src/app/handle_backend.rs · ×51priv/rust/tui/src/app/handle_backend.rs:141
Repeated repair: priv/rust/tui/src/main.rs · ×44priv/rust/tui/src/main.rs:165

What to do

  1. Resolve the 51 Hotspot finding(s) in Churn × Complexity Hotspots — start with REDACTED (3), report.py (2), handle_backend.rs. — One of this dimension's main actionable groups (51 warning-level).
  2. Resolve the 44 Repeated repair finding(s) in Churn × Complexity Hotspots — start with handler.ex (4), main.rs, welcome.rs. — One of this dimension's main actionable groups (44 warning-level).

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

D17 · Explicit Debt7.2 / 10Adequategated by 4 critical 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 7.2 / 10 · rule-coverage 100% · ceiling Prevented

4 deducted debt markers + 0 dead symbols across 810 LoC in the .NET projects (1.4/KLoC) → score 7.2. Measured on the .NET source only: .ex, .rs (93% of production source) was not read, and carries at least 3 uncounted task marker(s) in 3 file(s).

EmptyCatchBlock · ×4native/windows/ScreenShare/Program.cs:52

What to do

  1. Resolve the 4 EmptyCatchBlock finding(s) in Explicit Debt — start with Program.cs (2), VncServer.cs (2). — One of this dimension's main actionable groups (4 issue-level).

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

1 of 1 documentation facets pass in full. 350 document(s) read across 3 unit(s).

✓ On the Gold path — maintain.

Detailed fixes: d19_recommendation.md.

D20 · ADR Quality10.0 / 10Exemplary○ Nothing flagged

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 10.0 / 10 · rule-coverage 100% · ceiling Documented

0 of 6 evaluated ADRs have a defect readable from the log itself (a missing or empty section, no title, a single option, consequences with no cost, no status, a missing enforcement field, a status the log contradicts, a dangling link, an unlinked second decision on one question, a date that is no calendar day). How well each record argues its case is not measured.

✓ On the Gold path — maintain.

Detailed fixes: d20_recommendation.md.

D26 · Project Cohesion10.0 / 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 10.0 / 10 · rule-coverage 100% · ceiling Documented

0 of 2 projects flagged as possibly oversized/incoherent.

✓ On the Gold path — maintain.

Detailed fixes: d26_recommendation.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

30 % 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. Measured over the .ex/.exs source only — this repository's .rs was not sampled for call sites, so this score covers part of the tree, not all of it.

✓ On the Gold path — maintain.

Detailed fixes: d27_recommendation.md.

D28 · Secrets (history)9.0 / 10Adequategated by 1 critical finding✓ 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 9.0 / 10 · rule-coverage 100% · ceiling Documented

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

REDACTED
REDACTED

What to do

  1. Resolve the 1 REDACTED finding(s) in Secrets (history) — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).
  2. 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.2 / 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.2 / 10 · rule-coverage 100% · ceiling Documented

71 finding(s): 0 critical, 60 high, 4 medium, 7 low. 40 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 9 file(s) — `bin/osa` (line 148, line 521, line 615, …), `bin/osa-update` (line 201, line 384, line 517), `native/linux/ScreenShare/build.sh` (line 16), `native/linux/ScreenShare/stage.sh` (line 6), `native/linux/ScreenShare/verify-package.sh` (line 6), … (+4 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. In 1 of those file(s) — `native/windows/ScreenShare/RfbConnection.cs` — the break is a C# primary constructor, which semgrep's grammar cannot parse and which hides the type from every rule scoped to it; those files were re-scanned from a shadow copy with the constructor's parameter list blanked (line and column preserving), which restores the type to the rules, and 0 additional row(s) came from that pass. Only the header's own parameter list is unread in them. Separately, one or more rules could not re-parse an embedded snippet in 3 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

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

What to do

  1. Resolve the 13 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (9), REDACTED (4). — One of this dimension's main actionable groups (13 issue-level).
  2. Resolve the 5 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (3), REDACTED (2). — One of this dimension's main actionable groups (5 issue-level).
  3. No action in Static Analysis (SAST) — all 40 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 (40 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. Advisory since rubric-2026.11.2 (CAI decision 0006): every row is a match against a vulnerability database that changes daily, so the reading is shown and never moves a scored dimension, lens or the headline.

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

54 finding(s): 1 critical, 13 high, 40 medium, 0 low.

REDACTED
REDACTED
REDACTED
REDACTED
REDACTED

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

What to do

  1. Resolve the 18 Medium advisory (unsound) finding(s) in Dependency Vulnerabilities — start with REDACTED (18). — One of this dimension's main actionable groups (18 warning-level).
  2. Resolve the 13 High CVE finding(s) in Dependency Vulnerabilities — start with REDACTED (11), REDACTED (2). — One of this dimension's main actionable groups (13 issue-level).
  3. Resolve the 1 Critical CVE finding(s) in Dependency Vulnerabilities — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).

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

D31 · IaC & Container Security7.8 / 10Adequategated by 4 critical findings✓ 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 7.8 / 10 · rule-coverage 100% · ceiling Documented

13 finding(s): 0 critical, 4 high, 9 medium, 0 low.

REDACTED
REDACTED

What to do

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

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

D32 · Data Compliance (PII/GDPR)9.0 / 10Stronggated by 1 serious finding✓ Tool-verified

What it measures: Likely personal-data (PII / GDPR) handling concerns — logging or storing data without safeguards.

Method: Heuristic PII/GDPR LEAK scan via semgrep across the repo, using our own ruleset: personal data crossing a boundary it should not — reaching a log/console sink, a URL or query string, or unprotected browser storage. Matches map to severity and a 0-10 wide normalizer. A clean sweep is unscored rather than an unearned 10, and is a statement about the leak paths checked only — this dimension does not inventory the personal data a repository holds (the personal-data map and the C1-C5 compliance cards do that), so it never reports that a repository has no personal-data surface. Reported LOUDLY as a measurement gap if the ruleset is missing from the analyzer image. Exhaustive over the leak paths, advisory-leaning; degrades on parse failure.

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

1 finding(s): 0 critical, 0 high, 1 medium, 0 low. semgrep could not parse 2 file(s) — `native/macos/ScreenShare/Sources/ScreenShare/VncServer.swift`, `native/windows/ScreenShare/RfbConnection.cs` — so the PII/GDPR sweep did not cover the unparsed regions of them; rows reported elsewhere in those files are real.

REDACTED

What to do

  1. Resolve the 1 REDACTED finding(s) in Data Compliance (PII/GDPR) — start with REDACTED. — One of this dimension's main actionable groups (1 warning-level).

Detailed fixes: d32_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 1193 of the 1654 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 Coupling9.9 / 10Adequategated by 3 critical findings✓ 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 9.9 / 10 · rule-coverage 100% · ceiling Documented

Strongest change-coupling: tui_forwarder.ex↔handle_backend.rs 73%; tui_forwarder.ex↔sse.rs 73%; tui_forwarder.ex↔backend.rs 73%

Boundary-crossing change coupling: tui_forwarder.ex ↔ handle_backend.rs · ×3lib/optimal_system_agent/events/tui_forwarder.ex:1
Change coupling: handle_actions.rs ↔ http.rs · ×4priv/rust/tui/src/app/handle_actions.rs:1

What to do

  1. Resolve the 3 Boundary-crossing change coupling finding(s) in Change Coupling — start with tui_forwarder.ex (3). — One of this dimension's main actionable groups (3 issue-level).
  2. Resolve the 4 Change coupling finding(s) in Change Coupling — start with handle_actions.rs (2), handle_backend.rs (2). — One of this dimension's main actionable groups (4 warning-level).

Detailed fixes: d35_recommendation.md · top locations in Appendix A, every location in findings.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

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

What to do

  1. Resolve the 4 REDACTED finding(s) in Supply-chain Provenance & Signing — start with REDACTED, REDACTED, REDACTED. — One of this dimension's main actionable groups (4 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. Reported 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. Advisory since rubric-2026.11.2 (CAI decision 0006): the malicious-package feed is a database that changes daily, so the reading is shown and never moves a scored dimension, lens or the headline.

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-Life6.0 / 10Adequate✓ 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 6.0 / 10 · rule-coverage 100% · ceiling Documented

1 end-of-life runtime(s) and 0 end-of-life framework(s), read from 5 platform declaration(s) and 0 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.

End-of-life runtime: Erlang/OTP 26.tool-versions:1

What to do

  1. Resolve the 1 End-of-life runtime finding(s) in Platform End-of-Life — start with .tool-versions. — One of this dimension's main actionable groups (1 warning-level).

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

Frontend & cross-cutting dimensions

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

AX10 · Code composition9.3 / 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.

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.

AX5 · Architecture & structure10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether the codebase has a recognisable, scale-appropriate structure (a named architectural style, or modular enough for its size) rather than being an ad-hoc ball of mud.

Method: Roslyn plus csproj analysis: architecture style detection (DDD, clean, vertical-slice, CQRS) and structure fitness for repo size. Deterministic.

AX8 · Test isolation10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether production projects stay free of references to test projects — tests may depend on production, never the reverse.

Method: Csproj graph: each production project checked for references to test projects (identified by test-framework presence, not name). Zero violations is clean. Deterministic.

AX9 · CQS / query purity10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether read (query) handlers stay side-effect-free — a query that writes persistent state or raises events breaks CQS and makes reads unsafe to retry, cache, or route to a read replica.

Method: Roslyn scan: CQRS handlers classified query-vs-command by interface (IQueryHandler/ICommandHandler/IRequestHandler<TQuery,TResult>) and name convention (*Query/Get*/Find* vs *Command); each query handler's body checked for persistent-state writes (SaveChanges/repository Add-Update) or event publishes by resolved invocation. Deterministic, type-level, exhaustive over the detected handlers.

Coverage: Population: CQRS handlers identified by IQueryHandler/ICommandHandler/IRequestHandler interface + *Query/Get*/Find*/*Command NAME convention; query purity then checked exhaustively within that set — a query handler using neither convention is invisible, and mutation is a resolved persistence/publish CALL, not full dataflow.

C2 · Access Controls7.0 / 10Strong✓ Tool-verified

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.

  • Authorization IS enforced here (by imperative guard methods that throw on violation) — this is NOT a claim that the code is unprotected. What's missing is a NAMED rule set: the guards encode the access rules inline, so the rules can't be listed, reviewed or tested apart from the call sites that apply them. Recommendation, not a defect.

What to do

  • Name the access rules — give each one a named predicate/policy object your guards consult, so the rule set can be reviewed and unit-tested independently of the call sites that enforce it.
ED3 · Event naming10.0 / 10Exemplary✓ Tool-verified

Other · Event-Driven — Whether persisted/published domain events are named in the past tense (facts that happened) rather than imperatively.

Method: Roslyn scan (event-driven gated): domain and integration events checked for past-tense naming (-ed/-en suffix or irregular set). Naming nudge, low-weight advisory.

  • `CancelTimeout` is an imperative name inside a domain-event set whose siblings are past-tense facts — it reads as an intent, not something that happened. Name new events for the fact that occurred (e.g. `ItemAdded`). Do not rename this one if it is already stored or published: its type name is written with every event recorded under it, so a rename can break replay of the stored stream and every subscriber that reads it, and a clearer name does not pay for that. If it has never been written or sent, renaming it now is safe. — priv/rust/tui/src/event/backend.rs:15

What to do

  • Name new events in the past tense: they record facts that already happened. Do not rename an event that is already stored or published: its type name is written with every event recorded under it, so a rename can break replay of the stored stream and every subscriber that reads it.
ES2 · Immutable events10.0 / 10Exemplary✓ Tool-verified

Other · Event Sourcing — Whether domain events stay immutable (private fields, set once) rather than carrying mutable state.

Method: Roslyn scan (event-sourcing gated): persisted events checked for public setters; immutability verified per property/field. Deterministic, hard fact.

GD1 · Unfinished & placeholder code10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Unreviewed-generation residue: shipped members still throwing NotImplementedException, and placeholder string literals left in non-test, non-generated code. Scored as a quality signature, never as a claim about authorship.

Method: Roslyn syntax scan: NotImplementedException throws and placeholder string literals in non-test, non-generated shipped code. Deterministic, code-shape signature.

M1 · Documentation (README)10.0 / 10Exemplary✓ Tool-verified

Maturity · Maturity — Whether the repository and its projects have a README, and whether it is substantive.

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

M2 · Architecture documentation10.0 / 10Exemplary✓ 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.

M3 · Folder & project structure10.0 / 10Exemplary✓ Tool-verified

Maturity · Maturity — Whether the repository is organised deliberately: production code and tests are set apart in a way its ecosystem or the repository itself declares.

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

M4 · Documentation accuracy8.9 / 10Strong✓ Tool-verified

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.

  • docs/foundation-core/README.md links to `../architecture/`, but `docs/architecture` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/foundation-core/README.md:135
  • docs/operations/README.md links to `debugging-journal.md`, but `docs/operations/debugging-journal.md` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/operations/README.md:8
  • docs/backend/channels/README.md links to `../../architecture/README.md`, but `docs/architecture/README.md` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — docs/backend/channels/README.md:48

What to do

  • Reconcile the README with reality: docs/foundation-core/README.md links to `../architecture/`, but `docs/architecture` does not exist; docs/operations/README.md links to `debugging-journal.md`, but `docs/operations/debugging-journal.md` does not exist; docs/backend/channels/README.md links to `../../architecture/README.md`, but `docs/architecture/README.md` does not exist.
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.

P2 · Observability8.3 / 10Strong✓ 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 3/7 runnable modules use logging (modules with no entry point or server are excluded — they are libraries a runnable module hosts). Silent: `.`, `.`, `native/linux/ScreenShare`, `native/macos/ScreenShare`.

What to do

  • Extend structured logging to the remaining runnable modules so everything you run is diagnosable in production.
P3 · Security & performance tooling4.0 / 10Weak✓ 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.

  • `scripts/whatsapp-bridge/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`. — scripts/whatsapp-bridge/package.json:11

What to do

  • 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.

  • Deployment is automated and no gate that pauses it for a human is DECLARED IN THIS REPOSITORY'S PIPELINE FILES. What was read: every file under `.github/workflows/`, `.forgejo/workflows/`, `.gitea/workflows/`, `.azuredevops/` and `.azure-pipelines/`, plus `.gitlab-ci*` and `azure-pipelines*` — with comment text stripped, so documenting a gate is not declaring one. What would have counted: GitLab's `when: manual`, CircleCI's `type: approval`, an Azure `ManualValidation@` task or an `approvals:` block, a Jenkins `input` step, a `uses:` step naming an approval action, an `environment:` paired with `reviewers` / `required_reviewers` / `protection` / `wait-timer` / `deployment_branch_policy`, a draft-release step, a `workflow_dispatch` promotion, or a release-event gate. ★ What this cannot see, because none of it is a file: a GitHub environment whose required reviewers are configured in repo SETTINGS, a branch protection rule, or an organisation deployment policy — all of them real, enforced gates that live outside the repository. If yours is one of those, this row is wrong and nothing in the tree could have told us. Otherwise: whatever reaches the release trigger goes to production unreviewed, so a mistaken merge or tag is live before anyone can stop it. — REDACTED:452

What to do

  • Add an approval/environment gate (required reviewers / protection rules) before production promotion.
P5 · DR & Backup10.0 / 10Exemplary✓ 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.

P6 · Release Hygiene10.0 / 10Exemplary✓ 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.

P8 · Schema migrations3.0 / 10Weak✓ Tool-verified

Readiness · Readiness — Whether database schema changes go through versioned migrations rather than being auto-created from the model at startup.

Method: Roslyn scan: EF Core DbContext for a versioned migrations directory versus bare EnsureCreated usage; off .NET, a file scan of dependency manifests, migration histories (Flyway, Liquibase, Alembic, Django, Rails, Prisma, TypeORM, Knex/Sequelize, golang-migrate, goose, Laravel, Doctrine, Diesel/sqlx) and schema auto-create in production source or config. Exhaustive, deterministic.

  • This repository versions its schema (Ecto migrations), but runtime CREATE TABLE here builds or alters the schema from the model as well, outside that history — the two paths can disagree about the shape, and a change made this way is never a reviewed migration. Turn it off and let Ecto migrations own the schema. — lib/optimal_system_agent/security/defense_lab.ex:246

What to do

  • Turn off runtime CREATE TABLE in production and let the versioned migrations own the schema.
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.

  • `writeFileSync` in `ev.on("messages.upsert")` 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. (×3) — REDACTED:168, REDACTED:177, REDACTED:188
  • `existsSync` in `app.post("/send-media")` 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. — REDACTED:251
  • `readFileSync` in `app.post("/send-media")` 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. — REDACTED:254

What to do

  • 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.
X5 · Nullable reference types10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether nullable reference types are enabled and not undermined by heavy `!` suppression.

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

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 Health73.9StrongSolid.
Architecture96.3ExemplarySolid.
Maturity94.3ExemplarySolid.
Readiness61.0Adequate — gated by P8Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Security60.5Adequate — gated by D29, D36Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Event-Driven100.0ExemplaryStrongest area.
Event Sourcing100.0ExemplarySolid.
Performance60.0AdequateLargest drag on the score — prioritise here.
Unscored — 4 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.

  • SC1 Supply-chain hygiene — 1 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
  • X10 Duplicated predicate — 40 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
  • X7 Silent fallback defaults — 40 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
  • X9 Subsumed condition operand — 1 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
Not included — 67 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.

  • AC1 Text alternatives — No web markup found — accessibility is not applicable to this repository.
  • AC2 Forms & labels — No web markup found — accessibility is not applicable to this repository.
  • AC3 Page structure — No web markup found — accessibility is not applicable to this repository.
  • AC4 Keyboard semantics — No web markup found — accessibility is not applicable to this repository.
  • AC5 ARIA correctness — No web markup found — accessibility is not applicable to this repository.
  • AC6 Visual & motion safety — No web markup found — accessibility is not applicable to this repository.
  • AX1 Captive dependencies — no DI registrations detected
  • AX2 Stateful singletons — no singleton implementations detected
  • AX6 Interface segregation — AX6 reached only 6% of this repository's production lines — elixir (277,341 lines), rust (115,862 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
  • AX7 Slice cohesion — not applicable — not a vertical-slice architecture
  • 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 14 — a file the compose project references is missing) — env file .env not found: stat .env: no such file or directory; 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 — No personal data detected in the analyzed source — no PII-typed entity/column names (Email, FirstName, DateOfBirth, …), no ASP.NET Identity / user-account model, and no stored user credentials. GDPR data-protection controls are therefore N/A here. If this is intentional, record the no-PII posture in an ADR; if the app does process personal data, name those fields conventionally so this dimension activates.
  • C3 Audit Trail — No personal data detected in the analyzed source — no PII-typed entity/column names (Email, FirstName, DateOfBirth, …), no ASP.NET Identity / user-account model, and no stored user credentials. GDPR data-protection controls are therefore N/A here. If this is intentional, record the no-PII posture in an ADR; if the app does process personal data, name those fields conventionally so this dimension activates.
  • C4 Data Retention — No personal data detected in the analyzed source — no PII-typed entity/column names (Email, FirstName, DateOfBirth, …), no ASP.NET Identity / user-account model, and no stored user credentials. GDPR data-protection controls are therefore N/A here. If this is intentional, record the no-PII posture in an ADR; if the app does process personal data, name those fields conventionally so this dimension activates.
  • C5 Data-Subject Rights — No personal data detected in the analyzed source — no PII-typed entity/column names (Email, FirstName, DateOfBirth, …), no ASP.NET Identity / user-account model, and no stored user credentials. GDPR data-protection controls are therefore N/A here. If this is intentional, record the no-PII posture in an ADR; if the app does process personal data, name those fields conventionally so this dimension activates.
  • D10 Test Quality — ~174731 lines of test source are present (.py, .exs, .ex, .rb) but no test cases reached the test census for this repository — no test root we could resolve declared them, or the files we read declare no cases in a test framework we recognise — so skipped/assertion-free tests couldn't be counted. Not scored — this is a gap in the analyzer, not a finding about this repository.
  • D11 Test Reliability — Test reliability not measured — no test run produced results
  • D16 Bus Factor — single-maintainer repository — bus factor is not applicable
  • D18 Solution Shape — D18 scores the shape of a .NET solution, but this repository's production source is mostly .ex, .exs, .py, .rb, .rs, .swift — the .NET project files present are an immaterial minority — so the dimension does not apply.
  • D21 Naming Consistency — D21 withholds its case and prefix conventions rows: 1 candidate(s) found and not reported.
  • D22 Internal API Consistency — No intentionally-exposed public API to evaluate for consistency.
  • D23 Boundary Type-Coupling — single shared-core project — no cross-context coupling to assess
  • D24 Comment Value — D24 reads C#, Visual Basic, TypeScript and JavaScript comments only; comments in this repository's .ex, .exs, .py, .rb, .rs, .swift source were not judged.
  • D25 ADR Conformance — 1 binding ADR(s) rule out an element in code we do not index (.ex, .exs, .py, .rb, .rs, .swift); their rules were neither confirmed nor broken.
  • 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.
  • 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.
  • D8 Code Coverage — Coverage not measured
  • DM1 Domain Modelling — applicable but not scored (2 of 3 signals for this style — below the bar we score at): 39 value object(s); 4 domain event(s); its domain events are published by services or handlers — no domain entity raises one
  • ED2 Event/command shape — not scored — deciding whether a command has more than one competing handler requires resolving the call graph, and this analysis resolves a call's owner only where the receiver's type is written down in the source. Reported as guidance rather than measured
  • ED2 Event/command shape — not scored — deciding whether a command has more than one competing handler requires resolving the call graph, and a call made through an inferred or generic receiver has no resolvable owner in the source. Reported as guidance rather than measured
  • ED5 Idempotency — no mutating command handlers or message consumers detected — idempotency check not applicable
  • ES1 Fold determinism — not applicable — the code was read and holds no event-replay fold, so there is nothing for this check to judge
  • IC1 Incompleteness & stubs — IC1 reached only 0% of this repository's production lines — elixir (277,341 lines), rust (115,862 lines), python (23,742 lines), swift (1,693 lines), javascript (261 lines), ruby (205 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
  • 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'.
  • P7 Outbound HTTP resilience — not applicable — this isn't a service/API/worker
  • P9 Domain vs controller coverage — coverage not measured: this check compares the coverage of the analyzer's own test run across the domain and web layers, and that run measured none here — Test coverage (D8) says why
  • PF1 Benchmark discipline — Performance is assessed only for perf-relevant repos — a packaged library, one that ships benchmarks, or one already using allocation-aware APIs. This repo isn't one, so the Performance lens is not applicable and is excluded from the score.
  • PF2 Allocation hygiene — Not scored: this check counted allocation-aware idioms (Span, pools, stackalloc) per line, which describes what kind of code a repository is rather than whether it has an allocation problem, so it was withdrawn. Nothing here is a finding about your code.
  • S1 Web-Security Posture — No web surface detected in the analyzed source — no HTTP API or web-UI project (no controllers/minimal-API endpoints, no Razor/Blazor views) and no web middleware (HTTPS redirection, HSTS, security headers, cookies). Transport security, security headers, secure cookies, CSRF/input-validation and middleware-order controls are therefore N/A here — this is a library/CLI/worker, not a web app. Crypto hygiene was still checked and found nothing to flag. If this codebase becomes web-facing, the dimension reactivates automatically.
  • X1 Async correctness — X1 reached only 0% of this repository's production lines — elixir (277,341 lines), rust (115,862 lines), python (23,742 lines), swift (1,693 lines), javascript (261 lines), ruby (205 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
  • X12 Unreachable branch — X12 reached only 0% of this repository's production lines — elixir (277,341 lines), rust (115,862 lines), python (23,742 lines), swift (1,693 lines), javascript (261 lines), ruby (205 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
  • X13 Undrained process stream — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X14 Bypassable address classification — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X15 Unvalidated length from an untrusted reader — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X16 Unfloored truncation loop — X16 reached only 0% of this repository's production lines — elixir (277,341 lines), rust (115,862 lines), python (23,742 lines), swift (1,693 lines), javascript (261 lines), ruby (205 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
  • X17 Uncapped recursion over a caller-supplied document — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X18 Disposal-pattern correctness — X18 reached only 0% of this repository's production lines — elixir (277,341 lines), rust (115,862 lines), python (23,742 lines), swift (1,693 lines), javascript (261 lines), ruby (205 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
  • X19 Unrestored process-global state — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X2 Cancellation propagation — X2 reached only 0% of this repository's production lines — elixir (277,341 lines), rust (115,862 lines), python (23,742 lines), swift (1,693 lines), javascript (261 lines), ruby (205 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
  • X20 Mistyped argument guard — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X21 Side-effecting pattern guard — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X22 Contradicted release guard — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X23 Unguarded diagnostic materialisation — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X24 Document value interpolated into markup unescaped — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X25 Inert configuration knob — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X26 Unsynchronised callback handoff — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X27 Collection changed while being enumerated — X27 reached only 0% of this repository's production lines — elixir (277,341 lines), rust (115,862 lines), python (23,742 lines), swift (1,693 lines), javascript (261 lines), ruby (205 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
  • X28 Index access outside its own emptiness guard — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X29 Per-element action decided by a fixed element — X29 reached only 0% of this repository's production lines — elixir (277,341 lines), rust (115,862 lines), python (23,742 lines), swift (1,693 lines), javascript (261 lines), ruby (205 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
  • X3 Exception handling — X3 reached only 0% of this repository's production lines — elixir (277,341 lines), rust (115,862 lines), python (23,742 lines), swift (1,693 lines), javascript (261 lines), ruby (205 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
  • X30 Support guard that admits what it rejects — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X32 Type resolved by simple name across every loaded assembly — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X4 Structured logging — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X6 Hand-rolled structured-format parsing — 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 — 88 finding(s)
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
  • + 15 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
D30 · Dependency Vulnerabilities · High CVE · ×13
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D17 · Explicit Debt · EmptyCatchBlock · ×4
  • EmptyCatchBlock native/windows/ScreenShare/Program.cs:52 — empty catch block — the error is discarded with nothing recorded, so a failure here leaves no trace anywhere. Record it through whatever this codebase already uses to report problems, or let it propagate. Where swallowing one specific failure really is correct — as it often is on a teardown/dispose path where throwing would mask the original failure — catch exactly that exception type and write down WHY in a comment on the catch. Both are needed: a comment on a catch-all still swallows every failure nobody anticipated, and a note that only restates the swallow ("ignored", "do nothing") is read as no explanation at all.
  • EmptyCatchBlock native/windows/ScreenShare/Program.cs:53 — empty catch block — the error is discarded with nothing recorded, so a failure here leaves no trace anywhere. Record it through whatever this codebase already uses to report problems, or let it propagate. Where swallowing one specific failure really is correct — as it often is on a teardown/dispose path where throwing would mask the original failure — catch exactly that exception type and write down WHY in a comment on the catch. Both are needed: a comment on a catch-all still swallows every failure nobody anticipated, and a note that only restates the swallow ("ignored", "do nothing") is read as no explanation at all.
  • EmptyCatchBlock native/windows/ScreenShare/VncServer.cs:55 — empty catch block — the error is discarded with nothing recorded, so a failure here leaves no trace anywhere. Record it through whatever this codebase already uses to report problems, or let it propagate. Where swallowing one specific failure really is correct — as it often is on a teardown/dispose path where throwing would mask the original failure — catch exactly that exception type and write down WHY in a comment on the catch. Both are needed: a comment on a catch-all still swallows every failure nobody anticipated, and a note that only restates the swallow ("ignored", "do nothing") is read as no explanation at all.
  • EmptyCatchBlock native/windows/ScreenShare/VncServer.cs:56 — empty catch block — the error is discarded with nothing recorded, so a failure here leaves no trace anywhere. Record it through whatever this codebase already uses to report problems, or let it propagate. Where swallowing one specific failure really is correct — as it often is on a teardown/dispose path where throwing would mask the original failure — catch exactly that exception type and write down WHY in a comment on the catch. Both are needed: a comment on a catch-all still swallows every failure nobody anticipated, and a note that only restates the swallow ("ignored", "do nothing") is read as no explanation at all.
D31 · IaC & Container Security · High IaC · ×4
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D35 · Change Coupling · Boundary-crossing change coupling · ×3
  • Boundary-crossing change coupling: tui_forwarder.ex ↔ handle_backend.rs lib/optimal_system_agent/events/tui_forwarder.ex:1 — `lib/optimal_system_agent/events/tui_forwarder.ex` (context optimal_system_agent) and `priv/rust/tui/src/app/handle_backend.rs` (context priv) sit in DIFFERENT parts of the tree yet change together 73% of the time (8 of the 11 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) — the bounded-context boundary may be in the wrong place, or one context is leaking into the other. This is the behavioural boundary violation a static scan can't see. You can check this without leaving the row: of the 8 shared commits counted here, the most recent 3 are `36515858` v1.0.156: interrupt stops losing your work + ripgrep-fast search + ph…; `4103e389` Fix persistent goal controls and wrapped CLI input (#113); `da7ae273` feat(ask_user): the agent stopped a six-hour run to ask a question no… — run `git show` on any of them.
  • Boundary-crossing change coupling: tui_forwarder.ex ↔ sse.rs lib/optimal_system_agent/events/tui_forwarder.ex:1 — `lib/optimal_system_agent/events/tui_forwarder.ex` (context optimal_system_agent) and `priv/rust/tui/src/client/sse.rs` (context priv) sit in DIFFERENT parts of the tree yet change together 73% of the time (8 of the 11 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) — the bounded-context boundary may be in the wrong place, or one context is leaking into the other. This is the behavioural boundary violation a static scan can't see. You can check this without leaving the row: of the 8 shared commits counted here, the most recent 3 are `36515858` v1.0.156: interrupt stops losing your work + ripgrep-fast search + ph…; `4103e389` Fix persistent goal controls and wrapped CLI input (#113); `da7ae273` feat(ask_user): the agent stopped a six-hour run to ask a question no… — run `git show` on any of them.
  • Boundary-crossing change coupling: tui_forwarder.ex ↔ backend.rs lib/optimal_system_agent/events/tui_forwarder.ex:1 — `lib/optimal_system_agent/events/tui_forwarder.ex` (context optimal_system_agent) and `priv/rust/tui/src/event/backend.rs` (context priv) sit in DIFFERENT parts of the tree yet change together 73% of the time (8 of the 11 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) — the bounded-context boundary may be in the wrong place, or one context is leaking into the other. This is the behavioural boundary violation a static scan can't see. You can check this without leaving the row: of the 8 shared commits counted here, the most recent 3 are `36515858` v1.0.156: interrupt stops losing your work + ripgrep-fast search + ph…; `4103e389` Fix persistent goal controls and wrapped CLI input (#113); `da7ae273` feat(ask_user): the agent stopped a six-hour run to ask a question no… — run `git show` on any of them.
D13 · REDACTED Scanning · Leaked secret · ×2
  • REDACTED
  • REDACTED
D28 · Secrets (history) · REDACTED · ×1
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED · ×1
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED · ×1
  • REDACTED
D30 · Dependency Vulnerabilities · Critical CVE · ×1
  • REDACTED
Serious — 1798 finding(s)
D3 · God Classes · FileTooLong · ×73
  • FileTooLong: cli/commands.ex lib/optimal_system_agent/channels/cli/commands.ex — FileTooLong — 3896 significant lines (blank, comment-only and punctuation-only lines excluded), declaring 212 functions. The bar is 500 significant lines; this is 3396 over it, 7.79× 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: app/handle_backend.rs priv/rust/tui/src/app/handle_backend.rs — FileTooLong — 2441 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 96% of them inside a single declaration: App (2 blocks, 8-4148). The bar is 500 significant lines; this is 1941 over it, 4.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: loop/react_loop.ex lib/optimal_system_agent/agent/loop/react_loop.ex — FileTooLong — 2170 significant lines (blank, comment-only and punctuation-only lines excluded), declaring 84 functions. The bar is 500 significant lines; this is 1670 over it, 4.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: optimal_system_agent/orchestrator.ex lib/optimal_system_agent/orchestrator.ex — FileTooLong — 2130 significant lines (blank, comment-only and punctuation-only lines excluded), declaring 102 functions. The bar is 500 significant lines; this is 1630 over it, 4.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: optimal_system_agent/onboarding.ex lib/optimal_system_agent/onboarding.ex — FileTooLong — 2030 significant lines (blank, comment-only and punctuation-only lines excluded), declaring 104 functions. The bar is 500 significant lines; this is 1530 over it, 4.06× 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: input/mod.rs priv/rust/tui/src/components/input/mod.rs — FileTooLong — 1896 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 90% of them inside a single declaration: InputComponent (3 blocks, 82-3155). The bar is 500 significant lines; this is 1396 over it, 3.79× 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: client/sse.rs priv/rust/tui/src/client/sse.rs — FileTooLong — 1713 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 1213 over it, 3.43× 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/loop.ex lib/optimal_system_agent/agent/loop.ex — FileTooLong — 1698 significant lines (blank, comment-only and punctuation-only lines excluded), declaring 99 functions. The bar is 500 significant lines; this is 1198 over it, 3.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: dialogs/model_picker.rs priv/rust/tui/src/dialogs/model_picker.rs — FileTooLong — 1534 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 89% of them inside a single declaration: ModelPicker (2 blocks, 239-2543). The bar is 500 significant lines; this is 1034 over it, 3.07× 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: app/handle_actions.rs priv/rust/tui/src/app/handle_actions.rs — FileTooLong — 1459 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 87% of them inside a single declaration: App (2 blocks, 10-3779). The bar is 500 significant lines; this is 959 over it, 2.92× 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: providers/registry.ex lib/optimal_system_agent/providers/registry.ex — FileTooLong — 1415 significant lines (blank, comment-only and punctuation-only lines excluded), declaring 114 functions. The bar is 500 significant lines; this is 915 over it, 2.83× 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: loop/goal_verifier.ex lib/optimal_system_agent/agent/loop/goal_verifier.ex — FileTooLong — 1409 significant lines (blank, comment-only and punctuation-only lines excluded), declaring 102 functions. The bar is 500 significant lines; this is 909 over it, 2.82× 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/compactor.ex lib/optimal_system_agent/agent/compactor.ex — FileTooLong — 1407 significant lines (blank, comment-only and punctuation-only lines excluded), declaring 94 functions. The bar is 500 significant lines; this is 907 over it, 2.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: render/markdown.rs priv/rust/tui/src/render/markdown.rs — FileTooLong — 1399 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 46 free functions. The bar is 500 significant lines; this is 899 over it, 2.80× 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: app/event_loop.rs priv/rust/tui/src/app/event_loop.rs — FileTooLong — 1295 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 33 free functions. The bar is 500 significant lines; this is 795 over it, 2.59× 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: providers/openai_compat.ex lib/optimal_system_agent/providers/openai_compat.ex — FileTooLong — 1288 significant lines (blank, comment-only and punctuation-only lines excluded), declaring 93 functions. The bar is 500 significant lines; this is 788 over it, 2.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: components/activity.rs priv/rust/tui/src/components/activity.rs — FileTooLong — 1235 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 77% of them inside a single declaration: Activity (3 blocks, 514-2799). The bar is 500 significant lines; this is 735 over it, 2.47× 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: dialogs/onboarding.rs priv/rust/tui/src/dialogs/onboarding.rs — FileTooLong — 1234 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 95% of them inside a single declaration: OnboardingWizard (2 blocks, 92-1918). The bar is 500 significant lines; this is 734 over it, 2.47× 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: loop/tool_executor.ex lib/optimal_system_agent/agent/loop/tool_executor.ex — FileTooLong — 1227 significant lines (blank, comment-only and punctuation-only lines excluded), declaring 75 functions. The bar is 500 significant lines; this is 727 over it, 2.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: agent/context.ex lib/optimal_system_agent/agent/context.ex — FileTooLong — 1204 significant lines (blank, comment-only and punctuation-only lines excluded), declaring 84 functions. The bar is 500 significant lines; this is 704 over it, 2.41× 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: loop/goal_tracker.ex lib/optimal_system_agent/agent/loop/goal_tracker.ex — FileTooLong — 1139 significant lines (blank, comment-only and punctuation-only lines excluded), declaring 95 functions. The bar is 500 significant lines; this is 639 over it, 2.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: providers/anthropic.ex lib/optimal_system_agent/providers/anthropic.ex — FileTooLong — 1125 significant lines (blank, comment-only and punctuation-only lines excluded), declaring 69 functions. The bar is 500 significant lines; this is 625 over it, 2.25× 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: api/session_routes.ex lib/optimal_system_agent/channels/http/api/session_routes.ex — FileTooLong — 1086 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 586 over it, 2.17× 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: providers/ollama.ex lib/optimal_system_agent/providers/ollama.ex — FileTooLong — 1014 significant lines (blank, comment-only and punctuation-only lines excluded), declaring 72 functions. The bar is 500 significant lines; this is 514 over it, 2.03× 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: components/status_bar.rs priv/rust/tui/src/components/status_bar.rs — FileTooLong — 995 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 77% of them inside a single declaration: StatusBar (3 blocks, 510-1982). The bar is 500 significant lines; this is 495 over it, 1.99× 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.
  • + 48 more in this group — see findings.md.
D4 · Code Duplication · Edited copy of a member (4 corresponding lines) · ×54
  • Edited copy of a member (4 corresponding lines) lib/optimal_system_agent/open_computers/executor/direct/compose.ex:541 — lib/optimal_system_agent/open_computers/executor/direct/compose.ex:541-544 | lib/optimal_system_agent/open_computers/executor/direct/container.ex:668-671 — These two members are one piece of code written twice and then edited apart: 4 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.
  • Edited copy of a member (4 corresponding lines) lib/optimal_system_agent/tools/builtins/file_transform/balance.ex:197 — lib/optimal_system_agent/tools/builtins/file_transform/balance.ex:197-200 | lib/optimal_system_agent/tools/builtins/file_transform/balance.ex:204-207 — These two members are one piece of code written twice and then edited apart: 4 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.
  • Edited copy of a member (4 corresponding lines) lib/optimal_system_agent/channels/matrix.ex:205 — lib/optimal_system_agent/channels/matrix.ex:205-211 | lib/optimal_system_agent/channels/whatsapp.ex:246-249 — These two members are one piece of code written twice and then edited apart: 4 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.
  • Edited copy of a member (4 corresponding lines) lib/optimal_system_agent/mcp/plugin_manifest.ex:399 — lib/optimal_system_agent/mcp/plugin_manifest.ex:399-402 | lib/optimal_system_agent/mcp/plugin_manifest.ex:414-417 — These two members are one piece of code written twice and then edited apart: 4 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.
  • Edited copy of a member (4 corresponding lines) lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex:195 — lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex:195-198 | lib/optimal_system_agent/open_computers/executor/direct/cluster/mlx_distributed.ex:223-226 — These two members are one piece of code written twice and then edited apart: 4 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.
  • Edited copy of a member (4 corresponding lines) lib/optimal_system_agent/agent/loop/durable_log.ex:259 — lib/optimal_system_agent/agent/loop/durable_log.ex:259-265 | lib/optimal_system_agent/auth/aws_sigv4.ex:193-196 — These two members are one piece of code written twice and then edited apart: 4 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.
  • Edited copy of a member (4 corresponding lines) lib/optimal_system_agent/agent/memory/episodic_store.ex:338 — lib/optimal_system_agent/agent/memory/episodic_store.ex:338-341 | lib/optimal_system_agent/store/skill_library.ex:238-241 — These two members are one piece of code written twice and then edited apart: 4 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.
  • Edited copy of a member (4 corresponding lines) lib/optimal_system_agent/conversations/strategies/facilitator.ex:197 — lib/optimal_system_agent/conversations/strategies/facilitator.ex:197-200 | lib/optimal_system_agent/conversations/weaver.ex:292-295 — These two members are one piece of code written twice and then edited apart: 4 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.
  • Edited copy of a member (4 corresponding lines) lib/optimal_system_agent/agent/memory/episodic_store.ex:327 — lib/optimal_system_agent/agent/memory/episodic_store.ex:327-332 | lib/optimal_system_agent/skills/ranker.ex:212-215 — These two members are one piece of code written twice and then edited apart: 4 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.
  • Edited copy of a member (4 corresponding lines) lib/optimal_system_agent/providers/xai_models.ex:263 — lib/optimal_system_agent/providers/xai_models.ex:263-266 | lib/optimal_system_agent/providers/zai_models.ex:382-385 — These two members are one piece of code written twice and then edited apart: 4 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.
  • Edited copy of a member (4 corresponding lines) lib/optimal_system_agent/agents/registry.ex:371 — lib/optimal_system_agent/agents/registry.ex:371-378 | lib/optimal_system_agent/security/ci_scan.ex:278-281 — These two members are one piece of code written twice and then edited apart: 4 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.
  • Edited copy of a member (4 corresponding lines) lib/optimal_system_agent/cli/doctor.ex:590 — lib/optimal_system_agent/cli/doctor.ex:590-597 | lib/optimal_system_agent/cli/doctor/inspection.ex:1014-1017 — These two members are one piece of code written twice and then edited apart: 4 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.
  • Edited copy of a member (4 corresponding lines) lib/optimal_system_agent/plugins/loader.ex:565 — lib/optimal_system_agent/plugins/loader.ex:565-568 | lib/optimal_system_agent/providers/cache_attribution.ex:102-106 — These two members are one piece of code written twice and then edited apart: 4 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.
  • Edited copy of a member (4 corresponding lines) lib/optimal_system_agent/healing/orchestrator.ex:648 — lib/optimal_system_agent/healing/orchestrator.ex:648-651 | lib/optimal_system_agent/open_computers/executor/direct/tunnel.ex:114-121 — These two members are one piece of code written twice and then edited apart: 4 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.
  • Edited copy of a member (4 corresponding lines) lib/optimal_system_agent/providers/bedrock.ex:884 — lib/optimal_system_agent/providers/bedrock.ex:884-890 | lib/optimal_system_agent/providers/openai_responses.ex:336-339 — These two members are one piece of code written twice and then edited apart: 4 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.
  • Edited copy of a member (4 corresponding lines) lib/optimal_system_agent/monitor/watch_manager.ex:66 — lib/optimal_system_agent/monitor/watch_manager.ex:66-69 | lib/optimal_system_agent/shell/background_manager.ex:205-208 — These two members are one piece of code written twice and then edited apart: 4 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.
  • Edited copy of a member (4 corresponding lines) lib/optimal_system_agent/protocol/context_refs.ex:62 — lib/optimal_system_agent/protocol/context_refs.ex:62-65 | lib/optimal_system_agent/providers/registry.ex:1225-1228 — These two members are one piece of code written twice and then edited apart: 4 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.
  • Edited copy of a member (4 corresponding lines) lib/optimal_system_agent/providers/claude_cli.ex:123 — lib/optimal_system_agent/providers/claude_cli.ex:123-129 | lib/optimal_system_agent/providers/copilot_cli.ex:125-128 — These two members are one piece of code written twice and then edited apart: 4 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.
  • Edited copy of a member (4 corresponding lines) lib/optimal_system_agent/providers/claude_cli.ex:469 — lib/optimal_system_agent/providers/claude_cli.ex:469-475 | lib/optimal_system_agent/providers/copilot_cli.ex:496-499 — These two members are one piece of code written twice and then edited apart: 4 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.
  • Edited copy of a member (4 corresponding lines) lib/optimal_system_agent/agent/loop/tool_executor.ex:955 — lib/optimal_system_agent/agent/loop/tool_executor.ex:955-958 | lib/optimal_system_agent/permissions/ask_flow.ex:212-215 — These two members are one piece of code written twice and then edited apart: 4 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.
  • Edited copy of a member (4 corresponding lines) lib/optimal_system_agent/settings.ex:652 — lib/optimal_system_agent/settings.ex:652-655 | lib/optimal_system_agent/tools/file_state.ex:529-532 — These two members are one piece of code written twice and then edited apart: 4 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.
  • Edited copy of a member (4 corresponding lines) lib/optimal_system_agent/providers/claude_cli.ex:574 — lib/optimal_system_agent/providers/claude_cli.ex:574-578 | lib/optimal_system_agent/providers/copilot_cli.ex:455-458 — These two members are one piece of code written twice and then edited apart: 4 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.
  • Edited copy of a member (4 corresponding lines) lib/optimal_system_agent/security/attack_path.ex:109 — lib/optimal_system_agent/security/attack_path.ex:109-112 | lib/optimal_system_agent/security/traffic_ingest.ex:15-18 — These two members are one piece of code written twice and then edited apart: 4 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.
  • Edited copy of a member (4 corresponding lines) lib/optimal_system_agent/tools/builtins/computer_use/adapters/macos.ex:648 — lib/optimal_system_agent/tools/builtins/computer_use/adapters/macos.ex:648-651 | lib/optimal_system_agent/tools/builtins/file_grep/backend.ex:245-248 — These two members are one piece of code written twice and then edited apart: 4 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.
  • Edited copy of a member (4 corresponding lines) lib/optimal_system_agent/tools/builtins/push_notification/handler.ex:266 — lib/optimal_system_agent/tools/builtins/push_notification/handler.ex:266-269 | lib/optimal_system_agent/tools/builtins/web_fetch/handler.ex:113-116 — These two members are one piece of code written twice and then edited apart: 4 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.
  • + 29 more in this group — see findings.md.
D15 · Churn × Complexity Hotspots · Hotspot · ×51
  • Hotspot: priv/rust/tui/src/app/handle_backend.rs priv/rust/tui/src/app/handle_backend.rs:141 — priv/rust/tui/src/app/handle_backend.rs changed 104 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 421 in App::handle_backend_event at line 141. 38 of those changes were fix/bug commits, and the other 66 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- priv/rust/tui/src/app/handle_backend.rs`: 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: priv/rust/tui/src/app/commands.rs priv/rust/tui/src/app/commands.rs:128 — priv/rust/tui/src/app/commands.rs changed 48 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 124 in App::handle_command at line 128. 14 of those changes were fix/bug commits, and the other 34 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- priv/rust/tui/src/app/commands.rs`: 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: priv/rust/tui/src/app/event_loop.rs priv/rust/tui/src/app/event_loop.rs:826 — priv/rust/tui/src/app/event_loop.rs changed 88 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 67 in App::run at line 826. 41 of those changes were fix/bug commits, and the other 47 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- priv/rust/tui/src/app/event_loop.rs`: 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: priv/rust/tui/src/client/sse.rs priv/rust/tui/src/client/sse.rs:1142 — priv/rust/tui/src/client/sse.rs changed 42 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 118 in osa_tui::client::sse::parse_system_event at line 1142. 16 of those changes were fix/bug commits, and the other 26 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- priv/rust/tui/src/client/sse.rs`: 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: priv/rust/tui/src/app/update.rs priv/rust/tui/src/app/update.rs:239 — priv/rust/tui/src/app/update.rs changed 71 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 54 in App::handle_key at line 239. 30 of those changes were fix/bug commits, and the other 41 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- priv/rust/tui/src/app/update.rs`: 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: priv/rust/tui/src/components/input/mod.rs priv/rust/tui/src/components/input/mod.rs:2293 — priv/rust/tui/src/components/input/mod.rs changed 39 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 83 in InputComponent::handle_event at line 2293. 19 of those changes were fix/bug commits, and the other 20 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- priv/rust/tui/src/components/input/mod.rs`: 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: priv/rust/tui/src/components/status_bar.rs priv/rust/tui/src/components/status_bar.rs:1295 — priv/rust/tui/src/components/status_bar.rs changed 45 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 64 in StatusBar::draw at line 1295. 12 of those changes were fix/bug commits, and the other 33 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- priv/rust/tui/src/components/status_bar.rs`: 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: lib/optimal_system_agent/agent/loop/react_loop.ex lib/optimal_system_agent/agent/loop/react_loop.ex:1767 — lib/optimal_system_agent/agent/loop/react_loop.ex changed 73 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 32 in ReactLoop.handle_result at line 1767. 31 of those changes were fix/bug commits, and the other 42 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/agent/loop/react_loop.ex`: 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: priv/rust/tui/src/components/activity.rs priv/rust/tui/src/components/activity.rs:2240 — priv/rust/tui/src/components/activity.rs changed 43 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 52 in Activity::draw at line 2240. 16 of those changes were fix/bug commits, and the other 27 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- priv/rust/tui/src/components/activity.rs`: 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: priv/rust/tui/src/components/agents/render.rs priv/rust/tui/src/components/agents/render.rs:19 — priv/rust/tui/src/components/agents/render.rs changed 23 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 91 in Agents::draw_tree at line 19. 8 of those changes were fix/bug commits, and the other 15 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- priv/rust/tui/src/components/agents/render.rs`: 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: priv/rust/tui/src/render/markdown.rs priv/rust/tui/src/render/markdown.rs:2005 — priv/rust/tui/src/render/markdown.rs changed 17 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 97 in osa_tui::render::markdown::parse_inline at line 2005. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- priv/rust/tui/src/render/markdown.rs`: 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: lib/optimal_system_agent/orchestrator.ex lib/optimal_system_agent/orchestrator.ex:289 — lib/optimal_system_agent/orchestrator.ex changed 41 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 40 in Orchestrator.run_fresh_subagent at line 289. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/orchestrator.ex`: 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: priv/rust/tui/src/app/handle_actions.rs priv/rust/tui/src/app/handle_actions.rs:239 — priv/rust/tui/src/app/handle_actions.rs changed 67 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 24 in App::handle_agent_response at line 239. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- priv/rust/tui/src/app/handle_actions.rs`: 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: lib/optimal_system_agent/agent/loop.ex lib/optimal_system_agent/agent/loop.ex:1283 — lib/optimal_system_agent/agent/loop.ex changed 73 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 21 in Loop.init at line 1283. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/agent/loop.ex`: 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: lib/optimal_system_agent/onboarding.ex lib/optimal_system_agent/onboarding.ex:2877 — lib/optimal_system_agent/onboarding.ex changed 33 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 34 in Onboarding.build_health_check_request at line 2877. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/onboarding.ex`: 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: lib/optimal_system_agent/channels/cli/commands.ex lib/optimal_system_agent/channels/cli/commands.ex:3014 — lib/optimal_system_agent/channels/cli/commands.ex changed 51 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 21 in Commands.cmd_goal at line 3014. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/channels/cli/commands.ex`: 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: lib/optimal_system_agent/tools/builtins/delegate/handler.ex lib/optimal_system_agent/tools/builtins/delegate/handler.ex:175 — lib/optimal_system_agent/tools/builtins/delegate/handler.ex changed 25 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 38 in Handler.build_config at line 175. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/tools/builtins/delegate/handler.ex`: 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: lib/optimal_system_agent/agent/loop/llm_client.ex lib/optimal_system_agent/agent/loop/llm_client.ex:785 — lib/optimal_system_agent/agent/loop/llm_client.ex changed 31 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 25 in LLMClient.llm_chat_stream at line 785. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/agent/loop/llm_client.ex`: 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: lib/optimal_system_agent/providers/anthropic.ex lib/optimal_system_agent/providers/anthropic.ex:1039 — lib/optimal_system_agent/providers/anthropic.ex changed 32 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 23 in Anthropic.format_messages at line 1039. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/providers/anthropic.ex`: 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: lib/optimal_system_agent/providers/ollama.ex lib/optimal_system_agent/providers/ollama.ex:473 — lib/optimal_system_agent/providers/ollama.ex changed 34 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 21 in Ollama.cloud_stream_loop at line 473. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/providers/ollama.ex`: 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:308 — REDACTED changed 11 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 62 in run_bench.main at line 308. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04: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: bench/terminalbench/report.py bench/terminalbench/report.py:804 — bench/terminalbench/report.py changed 8 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 49 in report.build at line 804. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- bench/terminalbench/report.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: priv/rust/tui/src/render/markdown_stream.rs priv/rust/tui/src/render/markdown_stream.rs:277 — priv/rust/tui/src/render/markdown_stream.rs changed 8 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 35 in osa_tui::render::markdown_stream::inline_preview at line 277. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- priv/rust/tui/src/render/markdown_stream.rs`: 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: priv/rust/tui/src/dialogs/model_picker.rs priv/rust/tui/src/dialogs/model_picker.rs:668 — priv/rust/tui/src/dialogs/model_picker.rs changed 15 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 18 in ModelPicker::handle_providers_key at line 668. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- priv/rust/tui/src/dialogs/model_picker.rs`: 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: priv/rust/tui/src/tools/collapse.rs priv/rust/tui/src/tools/collapse.rs:127 — priv/rust/tui/src/tools/collapse.rs changed 11 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 23 in ToolKind::noun at line 127. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- priv/rust/tui/src/tools/collapse.rs`: 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.
  • + 26 more in this group — see findings.md.
D3 · God Classes · TooManyFunctions · ×50
  • TooManyFunctions: Settings lib/optimal_system_agent/settings.ex:1 — TooManyFunctions — 54 functions. The bar is 30 functions; this is 24 over it, 1.80× the bar. The counted members are a module's functions — a module holds no instance state, so there is no shared data to group them by and no type to move them onto. To reduce it, extract each cohesive family of functions into a new module of its own and have this one delegate to it, so no single module carries every responsibility.
  • TooManyFunctions: Handler lib/optimal_system_agent/tools/builtins/file_read/handler.ex:1 — TooManyFunctions — 47 functions. The bar is 30 functions; this is 17 over it, 1.57× the bar. The counted members are a module's functions — a module holds no instance state, so there is no shared data to group them by and no type to move them onto. To reduce it, extract each cohesive family of functions into a new module of its own and have this one delegate to it, so no single module carries every responsibility.
  • TooManyFunctions: Tasks lib/optimal_system_agent/agent/tasks.ex:1 — TooManyFunctions — 45 functions. The bar is 30 functions; this is 15 over it, 1.50× the bar. The counted members are a module's functions — a module holds no instance state, so there is no shared data to group them by and no type to move them onto. To reduce it, extract each cohesive family of functions into a new module of its own and have this one delegate to it, so no single module carries every responsibility.
  • TooManyFunctions: Soul lib/optimal_system_agent/soul.ex:1 — TooManyFunctions — 45 functions. The bar is 30 functions; this is 15 over it, 1.50× the bar. The counted members are a module's functions — a module holds no instance state, so there is no shared data to group them by and no type to move them onto. To reduce it, extract each cohesive family of functions into a new module of its own and have this one delegate to it, so no single module carries every responsibility.
  • TooManyFunctions: ConfigFile lib/optimal_system_agent/config_file.ex:1 — TooManyFunctions — 43 functions. The bar is 30 functions; this is 13 over it, 1.43× the bar. The counted members are a module's functions — a module holds no instance state, so there is no shared data to group them by and no type to move them onto. To reduce it, extract each cohesive family of functions into a new module of its own and have this one delegate to it, so no single module carries every responsibility.
  • TooManyFunctions: CacheAttribution lib/optimal_system_agent/providers/cache_attribution.ex:1 — TooManyFunctions — 42 functions. The bar is 30 functions; this is 12 over it, 1.40× the bar. The counted members are a module's functions — a module holds no instance state, so there is no shared data to group them by and no type to move them onto. To reduce it, extract each cohesive family of functions into a new module of its own and have this one delegate to it, so no single module carries every responsibility.
  • TooManyFunctions: LinuxX11 lib/optimal_system_agent/tools/builtins/computer_use/adapters/linux_x11.ex:1 — TooManyFunctions — 42 functions. The bar is 30 functions; this is 12 over it, 1.40× the bar. The counted members are a module's functions — a module holds no instance state, so there is no shared data to group them by and no type to move them onto. To reduce it, extract each cohesive family of functions into a new module of its own and have this one delegate to it, so no single module carries every responsibility.
  • TooManyFunctions: SkillLoader lib/optimal_system_agent/tools/registry/skill_loader.ex:1 — TooManyFunctions — 41 functions. The bar is 30 functions; this is 11 over it, 1.37× the bar. The counted members are a module's functions — a module holds no instance state, so there is no shared data to group them by and no type to move them onto. To reduce it, extract each cohesive family of functions into a new module of its own and have this one delegate to it, so no single module carries every responsibility.
  • TooManyFunctions: Doctor lib/optimal_system_agent/cli/doctor.ex:1 — TooManyFunctions — 40 functions. The bar is 30 functions; this is 10 over it, 1.33× the bar. The counted members are a module's functions — a module holds no instance state, so there is no shared data to group them by and no type to move them onto. To reduce it, extract each cohesive family of functions into a new module of its own and have this one delegate to it, so no single module carries every responsibility.
  • TooManyFunctions: Miosa lib/optimal_system_agent/tools/builtins/computer_use/adapters/miosa.ex:1 — TooManyFunctions — 40 functions. The bar is 30 functions; this is 10 over it, 1.33× the bar. The counted members are a module's functions — a module holds no instance state, so there is no shared data to group them by and no type to move them onto. To reduce it, extract each cohesive family of functions into a new module of its own and have this one delegate to it, so no single module carries every responsibility.
  • TooManyFunctions: Pricing lib/optimal_system_agent/agent/pricing.ex:1 — TooManyFunctions — 39 functions. The bar is 30 functions; this is 9 over it, 1.30× the bar. The counted members are a module's functions — a module holds no instance state, so there is no shared data to group them by and no type to move them onto. To reduce it, extract each cohesive family of functions into a new module of its own and have this one delegate to it, so no single module carries every responsibility.
  • TooManyFunctions: Reminders lib/optimal_system_agent/agent/reminders.ex:1 — TooManyFunctions — 39 functions. The bar is 30 functions; this is 9 over it, 1.30× the bar. The counted members are a module's functions — a module holds no instance state, so there is no shared data to group them by and no type to move them onto. To reduce it, extract each cohesive family of functions into a new module of its own and have this one delegate to it, so no single module carries every responsibility.
  • TooManyFunctions: OpenAIResponses lib/optimal_system_agent/providers/openai_responses.ex:1 — TooManyFunctions — 39 functions. The bar is 30 functions; this is 9 over it, 1.30× the bar. The counted members are a module's functions — a module holds no instance state, so there is no shared data to group them by and no type to move them onto. To reduce it, extract each cohesive family of functions into a new module of its own and have this one delegate to it, so no single module carries every responsibility.
  • TooManyFunctions: Checkpoint lib/optimal_system_agent/agent/loop/checkpoint.ex:1 — TooManyFunctions — 38 functions. The bar is 30 functions; this is 8 over it, 1.27× the bar. The counted members are a module's functions — a module holds no instance state, so there is no shared data to group them by and no type to move them onto. To reduce it, extract each cohesive family of functions into a new module of its own and have this one delegate to it, so no single module carries every responsibility.
  • TooManyFunctions: ToolOrchestrator lib/optimal_system_agent/agent/loop/tool_orchestrator.ex:1 — TooManyFunctions — 38 functions. The bar is 30 functions; this is 8 over it, 1.27× the bar. The counted members are a module's functions — a module holds no instance state, so there is no shared data to group them by and no type to move them onto. To reduce it, extract each cohesive family of functions into a new module of its own and have this one delegate to it, so no single module carries every responsibility.
  • TooManyFunctions: Dream lib/optimal_system_agent/memory/dream.ex:1 — TooManyFunctions — 38 functions. The bar is 30 functions; this is 8 over it, 1.27× the bar. The counted members are a module's functions — a module holds no instance state, so there is no shared data to group them by and no type to move them onto. To reduce it, extract each cohesive family of functions into a new module of its own and have this one delegate to it, so no single module carries every responsibility.
  • TooManyFunctions: RepoMap lib/optimal_system_agent/repo_map.ex:1 — TooManyFunctions — 38 functions. The bar is 30 functions; this is 8 over it, 1.27× the bar. The counted members are a module's functions — a module holds no instance state, so there is no shared data to group them by and no type to move them onto. To reduce it, extract each cohesive family of functions into a new module of its own and have this one delegate to it, so no single module carries every responsibility.
  • TooManyFunctions: Topology lib/optimal_system_agent/workspace/topology.ex:1 — TooManyFunctions — 38 functions. The bar is 30 functions; this is 8 over it, 1.27× the bar. The counted members are a module's functions — a module holds no instance state, so there is no shared data to group them by and no type to move them onto. To reduce it, extract each cohesive family of functions into a new module of its own and have this one delegate to it, so no single module carries every responsibility.
  • TooManyFunctions: Session lib/optimal_system_agent/shell/pty/session.ex:1 — TooManyFunctions — 37 functions. The bar is 30 functions; this is 7 over it, 1.23× the bar. The counted members are a module's functions — a module holds no instance state, so there is no shared data to group them by and no type to move them onto. To reduce it, extract each cohesive family of functions into a new module of its own and have this one delegate to it, so no single module carries every responsibility.
  • TooManyFunctions: CopilotCli lib/optimal_system_agent/providers/copilot_cli.ex:1 — TooManyFunctions — 36 functions. The bar is 30 functions; this is 6 over it, 1.20× the bar. The counted members are a module's functions — a module holds no instance state, so there is no shared data to group them by and no type to move them onto. To reduce it, extract each cohesive family of functions into a new module of its own and have this one delegate to it, so no single module carries every responsibility.
  • TooManyFunctions: Google lib/optimal_system_agent/providers/google.ex:1 — TooManyFunctions — 36 functions. The bar is 30 functions; this is 6 over it, 1.20× the bar. The counted members are a module's functions — a module holds no instance state, so there is no shared data to group them by and no type to move them onto. To reduce it, extract each cohesive family of functions into a new module of its own and have this one delegate to it, so no single module carries every responsibility.
  • TooManyFunctions: Client lib/optimal_system_agent/remote/client.ex:1 — TooManyFunctions — 35 functions. The bar is 30 functions; this is 5 over it, 1.17× the bar. The counted members are a module's functions — a module holds no instance state, so there is no shared data to group them by and no type to move them onto. To reduce it, extract each cohesive family of functions into a new module of its own and have this one delegate to it, so no single module carries every responsibility.
  • TooManyFunctions: CallChainAnalyzer lib/optimal_system_agent/security/call_chain_analyzer.ex:1 — TooManyFunctions — 35 functions. The bar is 30 functions; this is 5 over it, 1.17× the bar. The counted members are a module's functions — a module holds no instance state, so there is no shared data to group them by and no type to move them onto. To reduce it, extract each cohesive family of functions into a new module of its own and have this one delegate to it, so no single module carries every responsibility.
  • TooManyFunctions: VerificationGate lib/optimal_system_agent/agent/loop/verification_gate.ex:1 — TooManyFunctions — 34 functions. The bar is 30 functions; this is 4 over it, 1.13× the bar. The counted members are a module's functions — a module holds no instance state, so there is no shared data to group them by and no type to move them onto. To reduce it, extract each cohesive family of functions into a new module of its own and have this one delegate to it, so no single module carries every responsibility.
  • TooManyFunctions: Tier lib/optimal_system_agent/agent/tier.ex:1 — TooManyFunctions — 34 functions. The bar is 30 functions; this is 4 over it, 1.13× the bar. The counted members are a module's functions — a module holds no instance state, so there is no shared data to group them by and no type to move them onto. To reduce it, extract each cohesive family of functions into a new module of its own and have this one delegate to it, so no single module carries every responsibility.
  • + 25 more in this group — see findings.md.
D15 · Churn × Complexity Hotspots · Repeated repair · ×44
  • Repeated repair: priv/rust/tui/src/main.rs priv/rust/tui/src/main.rs:165 — priv/rust/tui/src/main.rs changed 29 times in last 90 days and 15 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 osa_tui::run at line 165), AT OR 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: “v1.0.203: stream integrity, self-healing transcripts, safer deletes, send-now, background tasks, resize crash fix (#283)”; “Release v1.0.191: fix the tmux chrome-fossil bug (the real one) (#265)”; “release: v1.0.87 - fix chunked streaming, measured off a real wire trace”; “wip: checkpoint the in-flight audit and fix work”. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- priv/rust/tui/src/main.rs`: 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: priv/rust/tui/src/components/chat/welcome.rs priv/rust/tui/src/components/chat/welcome.rs:33 — priv/rust/tui/src/components/chat/welcome.rs changed 15 times in last 90 days and 8 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 osa_tui::components::chat::welcome::welcome_lines at line 33), AT OR 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(tui,runtime): resize stranded a copy of the interface per step; the live region now fits any terminal; banner named a model OSA was not running; v1.0.57”; “fix(tui): audit sweep — 14 rendering defects across 3 root causes; v1.0.40”; “fix(tui): crash + reconnect fixes, @-file flow, and no-key onboarding guidance”; “fix(tui): stop the slash/resize render crash; fix duplicated welcome; grow composer; declutter startup”. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- priv/rust/tui/src/components/chat/welcome.rs`: 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: lib/optimal_system_agent/providers/error_catalog.ex lib/optimal_system_agent/providers/error_catalog.ex:411 — lib/optimal_system_agent/providers/error_catalog.ex changed 14 times in last 90 days and 8 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 ErrorCatalog.harness_error? at line 411), AT OR 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: “v1.0.203: stream integrity, self-healing transcripts, safer deletes, send-now, background tasks, resize crash fix (#283)”; “Fix v1.0.182: retry transient empty/5xx provider responses instead of halting (#254)”; “release: v1.0.69 - fix an error, without leaving the session”; “fix(providers): stop compacted tool-call arguments from poisoning every provider”. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/providers/error_catalog.ex`: 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: lib/optimal_system_agent/agent/loop/verification_gate.ex lib/optimal_system_agent/agent/loop/verification_gate.ex:451 — lib/optimal_system_agent/agent/loop/verification_gate.ex changed 14 times in last 90 days and 8 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 VerificationGate.triaged at line 451), AT OR 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: “Ship v1.0.172: image-paste crash fix, full model pricing, background-marker strip (#231)”; “fix(loop): a teammate you were waiting for did not count as work in flight”; “fix(verification): a compiler object file was passing as a discriminating test”; “fix(verification): our own test policy was destroying the deliverable”. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/agent/loop/verification_gate.ex`: 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: lib/optimal_system_agent/agent/pricing.ex lib/optimal_system_agent/agent/pricing.ex:900 — lib/optimal_system_agent/agent/pricing.ex changed 13 times in last 90 days and 8 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 9 (its worst body is Pricing.confidence at line 900), AT OR 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: “v1.0.201: Opus 5.5 + GPT-6 Sol/Luna, faster replies, lean-prompt setting, sticky default model, Ollama 401 fix (#281)”; “fix(pricing): a vendor's dated rate card reached through the reseller's namespace”; “fix(pricing): a reselling gateway billed at its upstream's list price”; “fix(pricing): bill the hour and the published cache rate, not one number each”. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/agent/pricing.ex`: 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: lib/optimal_system_agent/tools/builtins/file_grep/handler.ex lib/optimal_system_agent/tools/builtins/file_grep/handler.ex:321 — lib/optimal_system_agent/tools/builtins/file_grep/handler.ex changed 13 times in last 90 days and 8 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 9 (its worst body is Handler.try_ripgrep at line 321), AT OR 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: make the full suite green — 58 failures to 2 (1 environmental by design)”; “fix: OSA could not read /tmp on macOS (#126)”; “fix(tools): the deadline freed the turn and leaked the process”; “fix(loop): a working session said it did not exist”. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/tools/builtins/file_grep/handler.ex`: 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: lib/optimal_system_agent/agent/loop/streaming_tool_executor.ex lib/optimal_system_agent/agent/loop/streaming_tool_executor.ex:413 — lib/optimal_system_agent/agent/loop/streaming_tool_executor.ex changed 12 times in last 90 days and 8 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 StreamingToolExecutor.drain_to_messages at line 413), AT OR 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: “v1.0.203: stream integrity, self-healing transcripts, safer deletes, send-now, background tasks, resize crash fix (#283)”; “fix(loop): nobody could say whether a human was there to answer”; “fix(loop): the Anthropic streaming path ran two edits to one file at once”; “fix(permissions): the session workspace was not an allowed path anywhere”. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/agent/loop/streaming_tool_executor.ex`: 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: lib/optimal_system_agent/agent/loop/guardrails.ex lib/optimal_system_agent/agent/loop/guardrails.ex:501 — lib/optimal_system_agent/agent/loop/guardrails.ex changed 11 times in last 90 days and 6 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 Guardrails.bug_report? at line 501), AT OR 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(loop): the announcement backstop read the whole chat as one turn”; “fix(loop): the announcement backstop matched a vocabulary, not a shape”; “fix(loop): the announcement backstop had no word for "I'll examine"”; “fix(loop): the backstop for "let me write it now" could not see turn 1”. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/agent/loop/guardrails.ex`: 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: lib/optimal_system_agent/providers/anthropic_models.ex lib/optimal_system_agent/providers/anthropic_models.ex:632 — lib/optimal_system_agent/providers/anthropic_models.ex changed 7 times in last 90 days and 6 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 AnthropicModels.ladder_value at line 632), AT OR 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: “v1.0.203: stream integrity, self-healing transcripts, safer deletes, send-now, background tasks, resize crash fix (#283)”; “v1.0.201: Opus 5.5 + GPT-6 Sol/Luna, faster replies, lean-prompt setting, sticky default model, Ollama 401 fix (#281)”; “fix: a Fable session no longer opens at 36% context (#127)”; “fix(pricing): rates carry their own expiry date, and reach it by themselves”. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/providers/anthropic_models.ex`: 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: lib/mix/tasks/osa.run.ex lib/mix/tasks/osa.run.ex:21 — lib/mix/tasks/osa.run.ex changed 7 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 1 (its worst body is Run.run at line 21), AT OR 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: three capability decisions that a proxy was answering for them”; “fix(cli): --effort documented the wrong ladder and swallowed its own rejection”; “fix(security): the escape-sequence fix covered the loud paths, not the quiet ones”; “fix(telemetry): the machine-readable output format streamed no tool calls at all”. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/mix/tasks/osa.run.ex`: 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: lib/optimal_system_agent/store/session_transcript.ex lib/optimal_system_agent/store/session_transcript.ex:35 — lib/optimal_system_agent/store/session_transcript.ex changed 6 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 3 (its worst body is SessionTranscript.save_turn at line 35), AT OR 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 persistent goal controls and wrapped CLI input (#113)”; “fix(sessions): /clear left the discarded conversation as the newest one”; “fix(tools,providers,context,security): broken web fetch, wrong-provider /model, premature compaction; v1.0.48”; “fix: @-mentions attach, transcript persistence, bounded context, turn recap (audit wave)”. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/store/session_transcript.ex`: 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: lib/optimal_system_agent/agent/loop/compaction_thresholds.ex lib/optimal_system_agent/agent/loop/compaction_thresholds.ex:77 — lib/optimal_system_agent/agent/loop/compaction_thresholds.ex 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 3 (its worst body is CompactionThresholds.configured_ceiling at line 77), AT OR 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: “v1.0.205: live reasoning watchdog, honest compaction, glued-word and double-answer fixes (#285)”; “v1.0.201: Opus 5.5 + GPT-6 Sol/Luna, faster replies, lean-prompt setting, sticky default model, Ollama 401 fix (#281)”; “fix(compaction): the compact point is the model's window, not a constant”; “fix(compaction): three defects that each failed silently”. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/agent/loop/compaction_thresholds.ex`: 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: lib/optimal_system_agent/agent/task_notifications.ex lib/optimal_system_agent/agent/task_notifications.ex:257 — lib/optimal_system_agent/agent/task_notifications.ex 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 5 (its worst body is TaskNotifications.await_claim at line 257), AT OR 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: “v1.0.203: stream integrity, self-healing transcripts, safer deletes, send-now, background tasks, resize crash fix (#283)”; “fix(loop): a result that came back while the turn was ending was never read”; “wip: checkpoint the in-flight audit and fix work”; “fix(tools,providers,context,security): broken web fetch, wrong-provider /model, premature compaction; v1.0.48”. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/agent/task_notifications.ex`: 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: lib/optimal_system_agent/agent/fast_path.ex lib/optimal_system_agent/agent/fast_path.ex:77 — lib/optimal_system_agent/agent/fast_path.ex 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 7 (its worst body is FastPath.select_tools at line 77), AT OR 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: “Ship v1.0.172: image-paste crash fix, full model pricing, background-marker strip (#231)”; “Fix TUI resize recovery and add native skills (#109)”; “fix(providers): the capabilities that reported a plausible zero”; “fix(security,update): harden git against hostile repo config; verified updates; v1.0.46”. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/agent/fast_path.ex`: 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: lib/optimal_system_agent/agent/loop/verification_evidence.ex lib/optimal_system_agent/agent/loop/verification_evidence.ex:190 — lib/optimal_system_agent/agent/loop/verification_evidence.ex 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 6 (its worst body is VerificationEvidence.covered_after? at line 190), AT OR 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(verification): a compiler object file was passing as a discriminating test”; “fix(verification): our own test policy was destroying the deliverable”; “fix(verification): the gate charged a one-line fix the price of authoring a module”; “fix(agent): the verification gate was satisfiable without evidence”. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/agent/loop/verification_evidence.ex`: 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: lib/optimal_system_agent/cli/doctor/inspection.ex lib/optimal_system_agent/cli/doctor/inspection.ex:146 — lib/optimal_system_agent/cli/doctor/inspection.ex 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 7 (its worst body is Inspection.prompt_override_rows at line 146), AT OR 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(doctor): report the fail-closed pin, not the mode it overrides”; “fix(harness): stop first-meet loops and explorer nests”; “fix(security): a hostile repo only had to rename its settings file”; “fix: osa doctor walked the entire checkout; subagents ignored the model”. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/cli/doctor/inspection.ex`: 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: lib/optimal_system_agent/mcp/transport/stdio.ex lib/optimal_system_agent/mcp/transport/stdio.ex:398 — lib/optimal_system_agent/mcp/transport/stdio.ex 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 5 (its worst body is Stdio.check_memory at line 398), AT OR 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: a leaking MCP server and a wedged tool call can no longer take a machine or a turn down in silence (#125)”; “fix(mcp): quiet the boot into one summary line instead of a wall of warnings”; “fix(mcp): match owner pid in stdio EXIT handler (was reaping live child on pgid probe)”; “harden(round2): untouched-surface fixes + copy polish + 2 real bugs from de-flaking”. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/mcp/transport/stdio.ex`: 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: lib/optimal_system_agent/security/threat_intel.ex lib/optimal_system_agent/security/threat_intel.ex:70 — lib/optimal_system_agent/security/threat_intel.ex 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 8 (its worst body is ThreatIntel.enrich at line 70), AT OR 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(security): repair main's compile errors + port fix203 contract fixes”; “fix(threat_intel): remove space in if expression to fix Elixir syntax”; “fix(threat_intel): use int_max in days_between call site”; “fix(threat_intel): rename max to int_max to avoid Kernel.max/2 conflict”. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/security/threat_intel.ex`: 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: lib/optimal_system_agent/tools/file_state.ex lib/optimal_system_agent/tools/file_state.ex:321 — lib/optimal_system_agent/tools/file_state.ex 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 10 (its worst body is FileState.read_status at line 321), AT OR 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 v1.0.179: backlog cleanup — base URL, unicode ledger, linger race, latent crashes, test flakiness (#250)”; “fix: make the full suite green — 58 failures to 2 (1 environmental by design)”; “fix(doom-loop): the 43.5% duplicate rate was a 60-char display field”; “wip: checkpoint the in-flight audit and fix work”. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/tools/file_state.ex`: 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: lib/optimal_system_agent/memory/store.ex lib/optimal_system_agent/memory/store.ex:698 — lib/optimal_system_agent/memory/store.ex 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 8 (its worst body is Store.index_entry at line 698), AT OR 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(tools,providers,context,security): broken web fetch, wrong-provider /model, premature compaction; v1.0.48”; “fix(boot): stop two more boot-time crashes found chasing the Bus fix live”; “fix: memory/mcp/permissions correctness + curate toolset (80 -> 72)”; “fix: @-mentions attach, transcript persistence, bounded context, turn recap (audit wave)”. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/memory/store.ex`: 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: lib/optimal_system_agent/utils/mojibake.ex lib/optimal_system_agent/utils/mojibake.ex:106 — lib/optimal_system_agent/utils/mojibake.ex changed 5 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 8 (its worst body is Mojibake.incomplete_tail_start at line 106), AT OR 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 v1.0.175: repair Windows-1252 mojibake (glm/z.ai em-dashes, quotes, bullets) (#234)”; “fix(loop): recover reasoning models that stall after thinking; +2 follow-up bugs (#185)”; “fix: double-encoded mojibake + mid-turn steer immediate & visible (#184)”; “fix(streaming): repair UTF-8-as-Latin-1 mojibake split across deltas (#167)”. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/utils/mojibake.ex`: 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: lib/optimal_system_agent/agent/safety/dangerous_commands.ex lib/optimal_system_agent/agent/safety/dangerous_commands.ex:452 — lib/optimal_system_agent/agent/safety/dangerous_commands.ex 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 DangerousCommands.check_variant at line 452), AT OR 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: “v1.0.203: stream integrity, self-healing transcripts, safer deletes, send-now, background tasks, resize crash fix (#283)”; “fix(safety): the circuit breaker could be stalled by padding, not just fooled”; “fix(runtime): boot as root, split the circuit breaker, scope session settings”. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/agent/safety/dangerous_commands.ex`: 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: lib/optimal_system_agent/providers/catalog.ex lib/optimal_system_agent/providers/catalog.ex:449 — lib/optimal_system_agent/providers/catalog.ex 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 5 (its worst body is Catalog.cache_fresh? at line 449), AT OR 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: “Release v1.0.188: /goal clear ghost fix + measured est-tok/s in model picker (#262)”; “fix(tools,providers,context,security): broken web fetch, wrong-provider /model, premature compaction; v1.0.48”; “fix(backend): command fail-fast (no stdin, reject dangling operators, 120s cap); glm-5.2 context window 200k; billing token/usd_pricing fields”. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/providers/catalog.ex`: 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: lib/optimal_system_agent/cli.ex lib/optimal_system_agent/cli.ex:113 — lib/optimal_system_agent/cli.ex 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 10 (its worst body is CLI.update at line 113), AT OR 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(runtime): boot as root, split the circuit breaker, scope session settings”; “fix(agent): three bugs the benchmarks found”; “fix(security,update): harden git against hostile repo config; verified updates; v1.0.46”. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/cli.ex`: 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: lib/optimal_system_agent/workspace/fast_worktree.ex lib/optimal_system_agent/workspace/fast_worktree.ex:402 — lib/optimal_system_agent/workspace/fast_worktree.ex 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 FastWorktree.sweep at line 402), AT OR 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(tools,providers,context,security): broken web fetch, wrong-provider /model, premature compaction; v1.0.48”; “fix(security,update): harden git against hostile repo config; verified updates; v1.0.46”; “fix(install): resolve ~/.osa at runtime everywhere (prebuilt-release correctness)”. 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-11..2026-10-09, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-11 01:18:43 -04:00' --until='2026-10-09 01:18:43 -04:00' --full-history --no-merges -- lib/optimal_system_agent/workspace/fast_worktree.ex`: 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.
  • + 19 more in this group — see findings.md.
D3 · God Classes · MethodTooLong · ×39
  • MethodTooLong: App.handle_backend_event priv/rust/tui/src/app/handle_backend.rs:141 — MethodTooLong — handle_backend_event runs 2271 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 2171 over it, 22.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.
  • MethodTooLong: App.handle_command priv/rust/tui/src/app/commands.rs:128 — MethodTooLong — handle_command runs 419 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 319 over it, 4.19× 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.
  • MethodTooLong: Agents.draw_tree priv/rust/tui/src/components/agents/render.rs:19 — MethodTooLong — draw_tree runs 404 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 304 over it, 4.04× 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.
  • MethodTooLong: StatusBar.draw priv/rust/tui/src/components/status_bar.rs:1295 — MethodTooLong — draw runs 398 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 298 over it, 3.98× 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.
  • MethodTooLong: App.run priv/rust/tui/src/app/event_loop.rs:826 — MethodTooLong — run runs 270 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 170 over it, 2.70× 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.
  • MethodTooLong: Activity.draw priv/rust/tui/src/components/activity.rs:2240 — MethodTooLong — draw runs 264 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 164 over it, 2.64× 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.
  • MethodTooLong: InputComponent.draw priv/rust/tui/src/components/input/mod.rs:2747 — MethodTooLong — draw runs 246 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 146 over it, 2.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.
  • MethodTooLong: InputComponent.handle_event priv/rust/tui/src/components/input/mod.rs:2293 — MethodTooLong — handle_event runs 237 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 137 over it, 2.37× 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.
  • MethodTooLong: Agents.draw_dashboard priv/rust/tui/src/components/agents/render.rs:878 — MethodTooLong — draw_dashboard runs 193 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 93 over it, 1.93× 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.
  • MethodTooLong: App.new priv/rust/tui/src/app/mod.rs:661 — MethodTooLong — new runs 190 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) 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.
  • MethodTooLong: SkillsBrowser.draw priv/rust/tui/src/dialogs/skills_browser.rs:251 — MethodTooLong — draw runs 170 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 70 over it, 1.70× 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.
  • MethodTooLong: PermissionsManager.draw priv/rust/tui/src/dialogs/permissions_manager.rs:195 — MethodTooLong — draw runs 159 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 59 over it, 1.59× 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.
  • MethodTooLong: PersonaPicker.draw priv/rust/tui/src/dialogs/persona_picker.rs:179 — MethodTooLong — draw runs 153 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) 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.
  • MethodTooLong: DoctorPanel.draw priv/rust/tui/src/dialogs/doctor_panel.rs:183 — MethodTooLong — draw runs 150 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 50 over it, 1.50× 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.
  • MethodTooLong: ToolsBrowser.draw priv/rust/tui/src/dialogs/tools_browser.rs:227 — MethodTooLong — draw runs 150 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 50 over it, 1.50× 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.
  • MethodTooLong: MemoryBrowser.draw priv/rust/tui/src/dialogs/memory_browser.rs:153 — MethodTooLong — draw runs 147 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 47 over it, 1.47× 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.
  • MethodTooLong: SandboxPicker.draw priv/rust/tui/src/dialogs/sandbox_picker.rs:116 — MethodTooLong — draw runs 145 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 45 over it, 1.45× 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.
  • MethodTooLong: App.handle_key priv/rust/tui/src/app/update.rs:239 — MethodTooLong — handle_key runs 143 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 43 over it, 1.43× 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.
  • MethodTooLong: SessionBrowser.draw priv/rust/tui/src/dialogs/sessions.rs:248 — MethodTooLong — draw runs 142 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 42 over it, 1.42× 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.
  • MethodTooLong: TasksPanel.draw priv/rust/tui/src/dialogs/tasks_panel.rs:206 — MethodTooLong — draw runs 138 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 38 over it, 1.38× 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.
  • MethodTooLong: Permissions.draw_inline priv/rust/tui/src/dialogs/permissions.rs:376 — MethodTooLong — draw_inline runs 131 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 31 over it, 1.31× 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.
  • MethodTooLong: App.draw priv/rust/tui/src/app/event_loop.rs:1839 — MethodTooLong — draw runs 129 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 29 over it, 1.29× 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.
  • MethodTooLong: ModelPicker.draw_providers priv/rust/tui/src/dialogs/model_picker.rs:1605 — MethodTooLong — draw_providers runs 128 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 28 over it, 1.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.
  • MethodTooLong: ChannelsPanel.draw priv/rust/tui/src/dialogs/channels_panel.rs:127 — MethodTooLong — draw runs 124 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 24 over it, 1.24× 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.
  • MethodTooLong: SurveyDialog.draw_inline priv/rust/tui/src/dialogs/survey.rs:681 — MethodTooLong — draw_inline runs 123 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 23 over it, 1.23× 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.
  • + 14 more in this group — see findings.md.
D2 · Cognitive Complexity · osa_tui · ×36
  • osa_tui::render::markdown::parse_inline (cognitive 341) priv/rust/tui/src/render/markdown.rs:2005 — osa_tui::render::markdown::parse_inline has cognitive complexity 341 (threshold 15). Drivers by points: if/else 78 (257 pts), loops 14 (53 pts), boolean chains 16, match/switch 4 (15 pts) (nesting depth added 229). 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.
  • osa_tui::render::markdown::render_markdown (cognitive 163) priv/rust/tui/src/render/markdown.rs:34 — osa_tui::render::markdown::render_markdown has cognitive complexity 163 (threshold 15). Drivers by points: if/else 56 (135 pts), loops 7 (21 pts), boolean chains 7 (nesting depth added 93). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • osa_tui::client::sse::parse_system_event (cognitive 78) priv/rust/tui/src/client/sse.rs:1142 — osa_tui::client::sse::parse_system_event has cognitive complexity 78 (threshold 15). Drivers by points: match/switch 40 (45 pts), if/else 20 (31 pts), boolean chains 2 (nesting depth added 16). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • osa_tui::render::markdown::wrap_spans_inner (cognitive 64) priv/rust/tui/src/render/markdown.rs:1739 — osa_tui::render::markdown::wrap_spans_inner has cognitive complexity 64 (threshold 15). Drivers by points: if/else 16 (42 pts), loops 8 (18 pts), boolean chains 4 (nesting depth added 36). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • osa_tui::render::markdown_stream::inline_preview (cognitive 61) priv/rust/tui/src/render/markdown_stream.rs:277 — osa_tui::render::markdown_stream::inline_preview has cognitive complexity 61 (threshold 15). Drivers by points: if/else 25 (42 pts), loops 5 (11 pts), boolean chains 5, match/switch 1 (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.
  • osa_tui::client::sse::parse_sse_event (cognitive 38) priv/rust/tui/src/client/sse.rs:388 — osa_tui::client::sse::parse_sse_event has cognitive complexity 38 (threshold 15). Drivers by points: match/switch 27 (30 pts), if/else 4 (8 pts) (nesting depth added 7). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • osa_tui::dialogs::transcript_viewer::wrap_plain (cognitive 34) priv/rust/tui/src/dialogs/transcript_viewer.rs:806 — osa_tui::dialogs::transcript_viewer::wrap_plain has cognitive complexity 34 (threshold 15). Drivers by points: if/else 9 (26 pts), loops 3 (7 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.
  • osa_tui::app::settle_guard::common_prefix_modulo_whitespace (cognitive 33) priv/rust/tui/src/app/settle_guard.rs:134 — osa_tui::app::settle_guard::common_prefix_modulo_whitespace has cognitive complexity 33 (threshold 15). Drivers by points: if/else 8 (16 pts), loops 4 (8 pts), boolean chains 6, match/switch 1 (3 pts) (nesting depth added 14). Of this number, 26 points are the body's own statements and 7 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • osa_tui::render::cells::render_lines (cognitive 32) priv/rust/tui/src/render/cells.rs:94 — osa_tui::render::cells::render_lines has cognitive complexity 32 (threshold 15). Drivers by points: if/else 7 (21 pts), loops 4 (10 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.
  • osa_tui::components::chat::wrap_count::rows_for_line (cognitive 31) priv/rust/tui/src/components/chat/wrap_count.rs:49 — osa_tui::components::chat::wrap_count::rows_for_line has cognitive complexity 31 (threshold 15). Drivers by points: if/else 11 (20 pts), boolean chains 7, loops 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.
  • osa_tui::view::onboarding_flow::completed_step_summary (cognitive 29) priv/rust/tui/src/view/onboarding_flow.rs:202 — osa_tui::view::onboarding_flow::completed_step_summary has cognitive complexity 29 (threshold 15). Drivers by points: if/else 15 (25 pts), match/switch 2 (3 pts), boolean chains 1 (nesting depth added 11). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • osa_tui::components::input::strip_ansi (cognitive 28) priv/rust/tui/src/components/input/mod.rs:3389 — osa_tui::components::input::strip_ansi has cognitive complexity 28 (threshold 15). Drivers by points: if/else 5 (19 pts), loops 3 (7 pts), match/switch 1 (2 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.
  • osa_tui::render::markdown::render_table (cognitive 28) priv/rust/tui/src/render/markdown.rs:876 — osa_tui::render::markdown::render_table has cognitive complexity 28 (threshold 15). Drivers by points: loops 9 (15 pts), if/else 9 (11 pts), boolean chains 1, match/switch 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.
  • osa_tui::render::markdown::strip_escapes (cognitive 28) priv/rust/tui/src/render/markdown.rs:1629 — osa_tui::render::markdown::strip_escapes has cognitive complexity 28 (threshold 15). Drivers by points: if/else 5 (19 pts), loops 3 (7 pts), match/switch 1 (2 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.
  • osa_tui::render::markdown::wrap_text (cognitive 27) priv/rust/tui/src/render/markdown.rs:1904 — osa_tui::render::markdown::wrap_text has cognitive complexity 27 (threshold 15). Drivers by points: if/else 10 (19 pts), boolean chains 4, loops 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.
  • osa_tui::client::error_text::strip_request_ids (cognitive 26) priv/rust/tui/src/client/error_text.rs:104 — osa_tui::client::error_text::strip_request_ids has cognitive complexity 26 (threshold 15). Drivers by points: loops 5 (13 pts), if/else 3 (7 pts), boolean chains 6 (nesting depth added 12). 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.
  • osa_tui::util::fuzzy::score (cognitive 25) priv/rust/tui/src/util/fuzzy.rs:36 — osa_tui::util::fuzzy::score has cognitive complexity 25 (threshold 15). Drivers by points: if/else 12 (22 pts), boolean chains 2, 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.
  • osa_tui::components::chat::welcome::welcome_lines (cognitive 23) priv/rust/tui/src/components/chat/welcome.rs:33 — osa_tui::components::chat::welcome::welcome_lines has cognitive complexity 23 (threshold 15). Drivers by points: if/else 15 (16 pts), loops 2 (5 pts), boolean chains 2 (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.
  • osa_tui::tools::collapse::classify_shell_command (cognitive 23) priv/rust/tui/src/tools/collapse.rs:297 — osa_tui::tools::collapse::classify_shell_command has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (12 pts), match/switch 3 (6 pts), loops 2 (3 pts), boolean chains 2 (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.
  • osa_tui::tools::generic::args_summary (cognitive 23) priv/rust/tui/src/tools/generic.rs:52 — osa_tui::tools::generic::args_summary has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (19 pts), loops 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.
  • osa_tui::view::onboarding_flow::push_channels (cognitive 23) priv/rust/tui/src/view/onboarding_flow.rs:650 — osa_tui::view::onboarding_flow::push_channels has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11 (18 pts), loops 2 (4 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.
  • osa_tui::app::event_loop::replay_scrollback (cognitive 22) priv/rust/tui/src/app/event_loop.rs:3239 — osa_tui::app::event_loop::replay_scrollback has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (15 pts), loops 3 (4 pts), match/switch 2, 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.
  • osa_tui::render::markdown::allocate_col_widths (cognitive 21) priv/rust/tui/src/render/markdown.rs:1186 — osa_tui::render::markdown::allocate_col_widths has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (12 pts), match/switch 2 (5 pts), loops 3 (4 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.
  • osa_tui::components::osc8::supports_hyperlinks_with (cognitive 20) priv/rust/tui/src/components/osc8.rs:191 — osa_tui::components::osc8::supports_hyperlinks_with has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (14 pts), match/switch 2 (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.
  • osa_tui::render::diff::overlay_syntax_fg (cognitive 20) priv/rust/tui/src/render/diff.rs:240 — osa_tui::render::diff::overlay_syntax_fg has cognitive complexity 20 (threshold 15). Drivers by points: if/else 4 (8 pts), loops 4 (6 pts), match/switch 2 (6 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.
  • + 11 more in this group — see findings.md.
D4 · Code Duplication · Edited copy of a member (9 corresponding lines) · ×36
  • Edited copy of a member (9 corresponding lines) lib/optimal_system_agent/agent/task_tracker.ex:143 — lib/optimal_system_agent/agent/task_tracker.ex:143-151 | lib/optimal_system_agent/agent/tasks/tracker.ex:517-525 — These two members are one piece of code written twice and then edited apart: 9 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.
  • Edited copy of a member (9 corresponding lines) canopy/backend/lib/canopy_web/controllers/alert_controller.ex:9 — canopy/backend/lib/canopy_web/controllers/alert_controller.ex:9-17 | canopy/backend/lib/canopy_web/controllers/goal_controller.ex:9-25 — These two members are one piece of code written twice and then edited apart: 9 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.
  • Edited copy of a member (9 corresponding lines) lib/optimal_system_agent/channels/cli/commands.ex:849 — lib/optimal_system_agent/channels/cli/commands.ex:849-857 | lib/optimal_system_agent/channels/cli/commands.ex:956-964 — These two members are one piece of code written twice and then edited apart: 9 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.
  • Edited copy of a member (9 corresponding lines) lib/optimal_system_agent/scratchpad.ex:125 — lib/optimal_system_agent/scratchpad.ex:125-133 | lib/optimal_system_agent/scratchpad.ex:139-147 — These two members are one piece of code written twice and then edited apart: 9 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.
  • Edited copy of a member (9 corresponding lines) lib/optimal_system_agent/agent/memory/coordinator.ex:253 — lib/optimal_system_agent/agent/memory/coordinator.ex:253-262 | lib/optimal_system_agent/agent/memory/coordinator.ex:268-276 — These two members are one piece of code written twice and then edited apart: 9 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.
  • Edited copy of a member (9 corresponding lines) lib/optimal_system_agent/agent/memory/episodic.ex:224 — lib/optimal_system_agent/agent/memory/episodic.ex:224-232 | lib/optimal_system_agent/learning/pain_sink.ex:111-119 — These two members are one piece of code written twice and then edited apart: 9 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.
  • Edited copy of a member (9 corresponding lines) lib/optimal_system_agent/agent/tasks/check.ex:150 — lib/optimal_system_agent/agent/tasks/check.ex:150-158 | lib/optimal_system_agent/sandbox/miosa_cli.ex:422-437 — These two members are one piece of code written twice and then edited apart: 9 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.
  • Edited copy of a member (9 corresponding lines) lib/optimal_system_agent/agent/loop/tool_executor.ex:1076 — lib/optimal_system_agent/agent/loop/tool_executor.ex:1076-1084 | lib/optimal_system_agent/permissions/ask_flow.ex:305-313 — These two members are one piece of code written twice and then edited apart: 9 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.
  • Edited copy of a member (9 corresponding lines) lib/optimal_system_agent/channels/http/api/tool_routes.ex:362 — lib/optimal_system_agent/channels/http/api/tool_routes.ex:362-370 | lib/optimal_system_agent/channels/http/api/tool_routes.ex:374-388 — These two members are one piece of code written twice and then edited apart: 9 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.
  • Edited copy of a member (9 corresponding lines) lib/optimal_system_agent/monitor/watch_manager.ex:48 — lib/optimal_system_agent/monitor/watch_manager.ex:48-56 | lib/optimal_system_agent/shell/background_manager.ex:175-183 — These two members are one piece of code written twice and then edited apart: 9 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.
  • Edited copy of a member (9 corresponding lines) priv/skills/email-security/scripts/headers.py:28 — priv/skills/email-security/scripts/headers.py:28-36 | priv/skills/log-analysis/scripts/summarize_jsonl.py:41-50 — These two members are one piece of code written twice and then edited apart: 9 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.
  • Edited copy of a member (9 corresponding lines) lib/optimal_system_agent/agent/fast_path.ex:295 — lib/optimal_system_agent/agent/fast_path.ex:295-303 | lib/optimal_system_agent/memory/synthesis.ex:151-166 — These two members are one piece of code written twice and then edited apart: 9 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.
  • Edited copy of a member (9 corresponding lines) lib/optimal_system_agent/providers/bedrock.ex:812 — lib/optimal_system_agent/providers/bedrock.ex:812-820 | lib/optimal_system_agent/providers/bedrock.ex:824-832 — These two members are one piece of code written twice and then edited apart: 9 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.
  • Edited copy of a member (9 corresponding lines) priv/rust/tui/src/components/input/mod.rs:2220 — priv/rust/tui/src/components/input/mod.rs:2220-2228 | priv/rust/tui/src/components/input/mod.rs:2231-2239 — These two members are one piece of code written twice and then edited apart: 9 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.
  • Edited copy of a member (9 corresponding lines) priv/rust/tui/src/dialogs/permissions.rs:210 — priv/rust/tui/src/dialogs/permissions.rs:210-218 | priv/rust/tui/src/tools/file.rs:640-649 — These two members are one piece of code written twice and then edited apart: 9 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.
  • Edited copy of a member (9 corresponding lines) lib/optimal_system_agent/providers/google.ex:421 — lib/optimal_system_agent/providers/google.ex:421-429 | lib/optimal_system_agent/providers/openai_compat.ex:1334-1343 — These two members are one piece of code written twice and then edited apart: 9 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.
  • Edited copy of a member (9 corresponding lines) canopy/backend/lib/canopy/adapters/claude_code.ex:128 — canopy/backend/lib/canopy/adapters/claude_code.ex:128-141 | lib/optimal_system_agent/providers/openai_compat.ex:691-699 — These two members are one piece of code written twice and then edited apart: 9 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.
  • Edited copy of a member (9 corresponding lines) lib/optimal_system_agent/agent/pricing.ex:621 — lib/optimal_system_agent/agent/pricing.ex:621-629 | lib/optimal_system_agent/agent/pricing.ex:757-767 — These two members are one piece of code written twice and then edited apart: 9 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.
  • Edited copy of a member (9 corresponding lines) lib/optimal_system_agent/providers/anthropic.ex:797 — lib/optimal_system_agent/providers/anthropic.ex:797-807 | lib/optimal_system_agent/providers/registry.ex:374-382 — These two members are one piece of code written twice and then edited apart: 9 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.
  • Edited copy of a member (9 corresponding lines) lib/optimal_system_agent/security/code_fix_pr.ex:191 — lib/optimal_system_agent/security/code_fix_pr.ex:191-199 | lib/optimal_system_agent/security/fix_verify.ex:166-176 — These two members are one piece of code written twice and then edited apart: 9 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.
  • Edited copy of a member (9 corresponding lines) lib/optimal_system_agent/agent/loop/tool_executor.ex:1036 — lib/optimal_system_agent/agent/loop/tool_executor.ex:1036-1051 | lib/optimal_system_agent/permissions.ex:1135-1143 — These two members are one piece of code written twice and then edited apart: 9 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.
  • Edited copy of a member (9 corresponding lines) lib/optimal_system_agent/channels/http/api/provider_routes.ex:282 — lib/optimal_system_agent/channels/http/api/provider_routes.ex:282-293 | lib/optimal_system_agent/onboarding.ex:1267-1275 — These two members are one piece of code written twice and then edited apart: 9 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.
  • Edited copy of a member (9 corresponding lines) lib/optimal_system_agent/providers/anthropic.ex:1834 — lib/optimal_system_agent/providers/anthropic.ex:1834-1842 | lib/optimal_system_agent/providers/google.ex:595-605 — These two members are one piece of code written twice and then edited apart: 9 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.
  • Edited copy of a member (9 corresponding lines) lib/optimal_system_agent/agent/task_tracker.ex:430 — lib/optimal_system_agent/agent/task_tracker.ex:430-438 | lib/optimal_system_agent/agent/tasks/tracker.ex:455-463 — These two members are one piece of code written twice and then edited apart: 9 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.
  • Edited copy of a member (9 corresponding lines) lib/optimal_system_agent/agent/tasks/persistence.ex:20 — lib/optimal_system_agent/agent/tasks/persistence.ex:20-31 | lib/optimal_system_agent/agent/workflow.ex:672-680 — These two members are one piece of code written twice and then edited apart: 9 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.
  • + 11 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (8 lines × 2) · ×33
  • Duplicated block (8 lines × 2) canopy/backend/lib/canopy_web/controllers/activity_controller.ex:9 — canopy/backend/lib/canopy_web/controllers/activity_controller.ex:9-16 | canopy/backend/lib/canopy_web/controllers/audit_controller.ex:11-18 — 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 lines × 2) lib/optimal_system_agent/agent/delegation_policy.ex:145 — lib/optimal_system_agent/agent/delegation_policy.ex:145-152 | lib/optimal_system_agent/channels/cli/commands.ex:5277-5284 — 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) lib/optimal_system_agent/agent/scheduler.ex:307 — lib/optimal_system_agent/agent/scheduler.ex:307-314 | lib/optimal_system_agent/agent/scheduler.ex:389-396 — 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 `lib/optimal_system_agent/agent/scheduler.ex:307` 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) lib/optimal_system_agent/agent/tasks/workflow.ex:182 — lib/optimal_system_agent/agent/tasks/workflow.ex:182-189 | lib/optimal_system_agent/agent/tasks/workflow.ex:201-208 — 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) lib/optimal_system_agent/agent/workflow.ex:329 — lib/optimal_system_agent/agent/workflow.ex:329-336 | lib/optimal_system_agent/agent/workflow.ex:347-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 (8 lines × 2) lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex:204 — lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex:204-211 | lib/optimal_system_agent/open_computers/executor/direct/cluster/mlx_distributed.ex:231-238 — before extracting anything, compare `lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex` and `lib/optimal_system_agent/open_computers/executor/direct/cluster/mlx_distributed.ex` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 66 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, `lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex:213` calls `to_charlist` and `lib/optimal_system_agent/open_computers/executor/direct/cluster/mlx_distributed.ex:240` 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 × 2) lib/optimal_system_agent/providers/anthropic.ex:1071 — lib/optimal_system_agent/providers/anthropic.ex:1071-1078 | lib/optimal_system_agent/providers/anthropic.ex:1142-1149 — 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 before the matched lines, `lib/optimal_system_agent/providers/anthropic.ex:1069` calls `get`, `is_list` and `lib/optimal_system_agent/providers/anthropic.ex:1141` 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) lib/optimal_system_agent/providers/catalog.ex:609 — lib/optimal_system_agent/providers/catalog.ex:609-616 | lib/optimal_system_agent/providers/catalog.ex:708-715 — 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 `lib/optimal_system_agent/providers/catalog.ex:609` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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) lib/optimal_system_agent/tools/builtins/security_intel.ex:164 — lib/optimal_system_agent/tools/builtins/security_intel.ex:164-172 | lib/optimal_system_agent/tools/builtins/security_intel.ex:209-216 — 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 `lib/optimal_system_agent/tools/builtins/security_intel.ex:164` 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) lib/optimal_system_agent/open_computers/executor/direct/desktop/macos.ex:141 — lib/optimal_system_agent/open_computers/executor/direct/desktop/macos.ex:141-148 | lib/optimal_system_agent/open_computers/executor/direct/desktop/windows.ex:143-150 — before extracting anything, compare `lib/optimal_system_agent/open_computers/executor/direct/desktop/macos.ex` and `lib/optimal_system_agent/open_computers/executor/direct/desktop/windows.ex` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 66 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 (8 lines × 2) lib/optimal_system_agent/agent/jailbreak.ex:196 — lib/optimal_system_agent/agent/jailbreak.ex:196-203 | lib/optimal_system_agent/agent/voice.ex:211-218 — 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 lines × 2) lib/optimal_system_agent/providers/claude_cli.ex:135 — lib/optimal_system_agent/providers/claude_cli.ex:135-142 | lib/optimal_system_agent/providers/copilot_cli.ex:134-141 — before extracting anything, compare `lib/optimal_system_agent/providers/claude_cli.ex` and `lib/optimal_system_agent/providers/copilot_cli.ex` as WHOLE FILES: this scan already matched 7 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. 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 `lib/optimal_system_agent/providers/claude_cli.ex:135` 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) lib/optimal_system_agent/auth/providers/claude_cli.ex:111 — lib/optimal_system_agent/auth/providers/claude_cli.ex:111-118 | lib/optimal_system_agent/auth/providers/copilot_cli.ex:107-114 — 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 `lib/optimal_system_agent/auth/providers/claude_cli.ex:111` 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) lib/optimal_system_agent/agent/task_tracker.ex:144 — lib/optimal_system_agent/agent/task_tracker.ex:144-151 | lib/optimal_system_agent/agent/tasks/tracker.ex:518-525 — before extracting anything, compare `lib/optimal_system_agent/agent/task_tracker.ex` and `lib/optimal_system_agent/agent/tasks/tracker.ex` as WHOLE FILES: this scan already matched 7 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. 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) priv/rust/tui/src/app/event_loop.rs:1784 — priv/rust/tui/src/app/event_loop.rs:1784-1792 | priv/rust/tui/src/app/event_loop.rs:1814-1821 — 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 `priv/rust/tui/src/app/event_loop.rs:1784` 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 × 2) priv/rust/tui/src/app/handle_actions.rs:2149 — priv/rust/tui/src/app/handle_actions.rs:2149-2156 | priv/rust/tui/src/app/handle_actions.rs:2161-2168 — 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 `priv/rust/tui/src/app/handle_actions.rs:2149` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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) priv/rust/tui/src/app/handle_dialogs.rs:1099 — priv/rust/tui/src/app/handle_dialogs.rs:1099-1106 | priv/rust/tui/src/app/handle_dialogs.rs:1119-1126 — 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 `priv/rust/tui/src/app/handle_dialogs.rs:1119` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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 first that the copies are not typed on the same thing: the declarations holding them bind `self` to `super) fn handle_survey_key(&mut` in one and `crate) fn decline_survey(&mut` 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 (8 lines × 2) priv/rust/tui/src/components/input/mod.rs:1752 — priv/rust/tui/src/components/input/mod.rs:1752-1759 | priv/rust/tui/src/components/input/mod.rs:1821-1828 — 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 `priv/rust/tui/src/components/input/mod.rs:1752` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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) priv/rust/tui/src/dialogs/command_palette.rs:296 — priv/rust/tui/src/dialogs/command_palette.rs:296-303 | priv/rust/tui/src/dialogs/config_editor.rs:463-470 — 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 `priv/rust/tui/src/dialogs/command_palette.rs:296` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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) priv/rust/tui/src/dialogs/file_picker.rs:381 — priv/rust/tui/src/dialogs/file_picker.rs:381-388 | priv/rust/tui/src/dialogs/reasoning.rs:244-251 — before extracting anything, compare `priv/rust/tui/src/dialogs/file_picker.rs` and `priv/rust/tui/src/dialogs/reasoning.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 61 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 `priv/rust/tui/src/dialogs/file_picker.rs:381` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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) priv/rust/tui/src/dialogs/onboarding.rs:1284 — priv/rust/tui/src/dialogs/onboarding.rs:1284-1291 | priv/rust/tui/src/dialogs/onboarding.rs:1468-1475 — 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) priv/rust/tui/src/tools/mod.rs:846 — priv/rust/tui/src/tools/mod.rs:846-853 | priv/rust/tui/src/tools/mod.rs:900-907 — 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 `priv/rust/tui/src/tools/mod.rs:846` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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) priv/rust/tui/src/components/agents/render.rs:719 — priv/rust/tui/src/components/agents/render.rs:719-726 | priv/rust/tui/src/components/agents/render.rs:751-758 — 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 `priv/rust/tui/src/components/agents/render.rs:719` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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) priv/rust/tui/src/components/completion_panel.rs:277 — priv/rust/tui/src/components/completion_panel.rs:277-284 | priv/rust/tui/src/dialogs/cost_dashboard.rs:216-223 — before extracting anything, compare `priv/rust/tui/src/components/completion_panel.rs` and `priv/rust/tui/src/dialogs/cost_dashboard.rs` 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 `priv/rust/tui/src/components/completion_panel.rs:277` 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) priv/rust/tui/src/render/markdown.rs:2359 — priv/rust/tui/src/render/markdown.rs:2359-2366 | priv/rust/tui/src/render/markdown.rs:2369-2376 — 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.
  • + 8 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (9 lines × 2) · ×32
  • Duplicated block (9 lines × 2) canopy/backend/lib/canopy/workspaces.ex:94 — canopy/backend/lib/canopy/workspaces.ex:94-102 | canopy/backend/lib/canopy_web/controllers/workspace_controller.ex:173-181 — 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 (9 lines × 2) lib/optimal_system_agent/agent/safety/model_classifier.ex:171 — lib/optimal_system_agent/agent/safety/model_classifier.ex:171-179 | lib/optimal_system_agent/permissions/auto_classifier.ex:229-237 — before extracting anything, compare `lib/optimal_system_agent/agent/safety/model_classifier.ex` and `lib/optimal_system_agent/permissions/auto_classifier.ex` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 33 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 `lib/optimal_system_agent/agent/safety/model_classifier.ex:171` 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 × 2) lib/optimal_system_agent/agent/task_queue.ex:506 — lib/optimal_system_agent/agent/task_queue.ex:506-514 | lib/optimal_system_agent/agent/tasks/queue.ex:299-307 — before extracting anything, compare `lib/optimal_system_agent/agent/task_queue.ex` and `lib/optimal_system_agent/agent/tasks/queue.ex` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 149 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 `lib/optimal_system_agent/agent/task_queue.ex:506` 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 × 2) lib/optimal_system_agent/channels/http/api/cost_routes.ex:227 — lib/optimal_system_agent/channels/http/api/cost_routes.ex:227-235 | lib/optimal_system_agent/channels/http/api/settings_routes.ex:90-98 — 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 (9 lines × 2) lib/optimal_system_agent/channels/http/api/webhook_verify.ex:31 — lib/optimal_system_agent/channels/http/api/webhook_verify.ex:31-39 | lib/optimal_system_agent/channels/http/api/webhook_verify.ex:70-78 — 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) lib/optimal_system_agent/open_computers/executor/direct/container.ex:742 — lib/optimal_system_agent/open_computers/executor/direct/container.ex:742-750 | lib/optimal_system_agent/open_computers/executor/direct/container.ex:775-783 — 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) lib/optimal_system_agent/open_computers/executor/direct/container.ex:745 — lib/optimal_system_agent/open_computers/executor/direct/container.ex:745-753 | lib/optimal_system_agent/open_computers/executor/direct/container.ex:790-798 — 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) lib/optimal_system_agent/open_computers/executor/direct/fs.ex:190 — lib/optimal_system_agent/open_computers/executor/direct/fs.ex:190-198 | lib/optimal_system_agent/open_computers/executor/direct/fs.ex:219-227 — 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) lib/optimal_system_agent/open_computers/executor/direct/wg_mesh.ex:241 — lib/optimal_system_agent/open_computers/executor/direct/wg_mesh.ex:241-249 | lib/optimal_system_agent/open_computers/executor/direct/wg_mesh.ex:252-260 — 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) lib/optimal_system_agent/skills/lint.ex:112 — lib/optimal_system_agent/skills/lint.ex:112-120 | lib/optimal_system_agent/tools/registry/skill_loader.ex:349-357 — 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 (9 lines × 2) lib/optimal_system_agent/tools/builtins/file_edit/fuzzy_matcher.ex:415 — lib/optimal_system_agent/tools/builtins/file_edit/fuzzy_matcher.ex:415-423 | lib/optimal_system_agent/tools/builtins/file_edit/fuzzy_matcher.ex:463-471 — 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) lib/optimal_system_agent/tools/builtins/github.ex:191 — lib/optimal_system_agent/tools/builtins/github.ex:191-199 | lib/optimal_system_agent/tools/builtins/github.ex:252-260 — 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, `lib/optimal_system_agent/tools/builtins/github.ex:200` calls `maybe_flag` and `lib/optimal_system_agent/tools/builtins/github.ex:261` 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) lib/optimal_system_agent/tools/builtins/skill_manager.ex:56 — lib/optimal_system_agent/tools/builtins/skill_manager.ex:56-69 | lib/optimal_system_agent/tools/builtins/vault_sleep.ex:25-33 — 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 `lib/optimal_system_agent/tools/builtins/skill_manager.ex:56` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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) lib/optimal_system_agent/tools/registry.ex:324 — lib/optimal_system_agent/tools/registry.ex:324-332 | lib/optimal_system_agent/tools/registry.ex:1278-1286 — 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) lib/optimal_system_agent/auth/providers/claude_cli.ex:146 — lib/optimal_system_agent/auth/providers/claude_cli.ex:146-154 | lib/optimal_system_agent/auth/providers/copilot_cli.ex:134-142 — 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 (9 lines × 2) lib/optimal_system_agent/open_computers/session.ex:323 — lib/optimal_system_agent/open_computers/session.ex:323-331 | lib/optimal_system_agent/remote/client.ex:339-347 — 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 (9 lines × 2) lib/optimal_system_agent/agent/loop/streaming_tool_executor.ex:321 — lib/optimal_system_agent/agent/loop/streaming_tool_executor.ex:321-329 | lib/optimal_system_agent/agent/loop/tool_orchestrator.ex:608-616 — 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 `lib/optimal_system_agent/agent/loop/streaming_tool_executor.ex:321` 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 × 2) REDACTED:186 — REDACTED:186-194 | lib/optimal_system_agent/auth/providers/xai.ex:168-176 — before extracting anything, compare `REDACTED` and `lib/optimal_system_agent/auth/providers/xai.ex` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 82 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 (9 lines × 2) lib/optimal_system_agent/channels/http/api/approval_routes.ex:159 — lib/optimal_system_agent/channels/http/api/approval_routes.ex:159-167 | lib/optimal_system_agent/channels/http/api/issue_routes.ex:214-222 — 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 (9 lines × 2) canopy/backend/lib/canopy_web/controllers/project_controller.ex:102 — canopy/backend/lib/canopy_web/controllers/project_controller.ex:102-110 | canopy/backend/lib/canopy_web/controllers/workspace_controller.ex:188-196 — before extracting anything, compare `canopy/backend/lib/canopy_web/controllers/project_controller.ex` and `canopy/backend/lib/canopy_web/controllers/workspace_controller.ex` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 34 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 (9 lines × 2) priv/rust/tui/src/components/chat/message.rs:1088 — priv/rust/tui/src/components/chat/message.rs:1088-1096 | priv/rust/tui/src/components/chat/message.rs:1099-1107 — 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) priv/rust/tui/src/components/input/mod.rs:1567 — priv/rust/tui/src/components/input/mod.rs:1567-1575 | priv/rust/tui/src/components/input/mod.rs:2511-2519 — 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) priv/rust/tui/src/components/input/mod.rs:1739 — priv/rust/tui/src/components/input/mod.rs:1739-1747 | priv/rust/tui/src/components/input/mod.rs:1769-1777 — 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 `priv/rust/tui/src/components/input/mod.rs:1739` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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) priv/rust/tui/src/dialogs/claude_login.rs:436 — priv/rust/tui/src/dialogs/claude_login.rs:436-444 | priv/rust/tui/src/dialogs/claude_login.rs:504-514 — 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 `priv/rust/tui/src/dialogs/claude_login.rs:436` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `priv/rust/tui/src/dialogs/claude_login.rs:446` calls `set`, `max` and `priv/rust/tui/src/dialogs/claude_login.rs:515` 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) priv/rust/tui/src/dialogs/command_palette.rs:309 — priv/rust/tui/src/dialogs/command_palette.rs:309-317 | priv/rust/tui/src/dialogs/picker.rs:307-315 — before extracting anything, compare `priv/rust/tui/src/dialogs/command_palette.rs` and `priv/rust/tui/src/dialogs/picker.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 67 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 `priv/rust/tui/src/dialogs/command_palette.rs:309` 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 after the matched lines, `priv/rust/tui/src/dialogs/command_palette.rs:320` calls `to_lowercase`, `contains` and `priv/rust/tui/src/dialogs/picker.rs:318` 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.
  • + 7 more in this group — see findings.md.
D4 · Code Duplication · Edited copy of a member (3 corresponding lines) · ×29
  • Edited copy of a member (3 corresponding lines) lib/optimal_system_agent/security/notes_store.ex:198 — lib/optimal_system_agent/security/notes_store.ex:198-200 | lib/optimal_system_agent/security/notes_store.ex:205-211 — These two members are one piece of code written twice and then edited apart: 3 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.
  • Edited copy of a member (3 corresponding lines) lib/optimal_system_agent/mcp/transport/stdio.ex:365 — lib/optimal_system_agent/mcp/transport/stdio.ex:365-367 | lib/optimal_system_agent/os/process_group.ex:288-290 — These two members are one piece of code written twice and then edited apart: 3 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.
  • Edited copy of a member (3 corresponding lines) canopy/backend/lib/canopy/agents.ex:9 — canopy/backend/lib/canopy/agents.ex:9-11 | canopy/backend/lib/canopy/work.ex:111-113 — These two members are one piece of code written twice and then edited apart: 3 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.
  • Edited copy of a member (3 corresponding lines) lib/optimal_system_agent/agents/registry.ex:198 — lib/optimal_system_agent/agents/registry.ex:198-200 | lib/optimal_system_agent/tools/builtins/browser/server.ex:151-157 — These two members are one piece of code written twice and then edited apart: 3 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.
  • Edited copy of a member (3 corresponding lines) lib/optimal_system_agent/providers/ollama.ex:1614 — lib/optimal_system_agent/providers/ollama.ex:1614-1616 | lib/optimal_system_agent/providers/openai_compat.ex:685-687 — These two members are one piece of code written twice and then edited apart: 3 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.
  • Edited copy of a member (3 corresponding lines) lib/optimal_system_agent/tools.ex:41 — lib/optimal_system_agent/tools.ex:41-43 | lib/optimal_system_agent/tools/builtins/notebook_edit/handler.ex:308-313 — These two members are one piece of code written twice and then edited apart: 3 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.
  • Edited copy of a member (3 corresponding lines) lib/optimal_system_agent/fs_checkpoint/server.ex:622 — lib/optimal_system_agent/fs_checkpoint/server.ex:622-628 | lib/optimal_system_agent/security/ci_scan.ex:269-271 — These two members are one piece of code written twice and then edited apart: 3 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.
  • Edited copy of a member (3 corresponding lines) lib/optimal_system_agent/providers/anthropic.ex:983 — lib/optimal_system_agent/providers/anthropic.ex:983-985 | lib/optimal_system_agent/providers/cache_attribution.ex:653-656 — These two members are one piece of code written twice and then edited apart: 3 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.
  • Edited copy of a member (3 corresponding lines) lib/optimal_system_agent/channels/http/api/agent_routes.ex:90 — lib/optimal_system_agent/channels/http/api/agent_routes.ex:90-92 | lib/optimal_system_agent/channels/http/api/session_routes.ex:620-622 — These two members are one piece of code written twice and then edited apart: 3 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.
  • Edited copy of a member (3 corresponding lines) lib/optimal_system_agent/conversations/strategies/facilitator.ex:82 — lib/optimal_system_agent/conversations/strategies/facilitator.ex:82-84 | lib/optimal_system_agent/conversations/strategies/round_robin.ex:51-53 — These two members are one piece of code written twice and then edited apart: 3 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.
  • Edited copy of a member (3 corresponding lines) lib/optimal_system_agent/conversations/strategies/facilitator.ex:204 — lib/optimal_system_agent/conversations/strategies/facilitator.ex:204-206 | lib/optimal_system_agent/conversations/strategies/round_robin.ex:24-26 — These two members are one piece of code written twice and then edited apart: 3 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.
  • Edited copy of a member (3 corresponding lines) lib/optimal_system_agent/auth/login_broker.ex:332 — lib/optimal_system_agent/auth/login_broker.ex:332-334 | lib/optimal_system_agent/channels/http.ex:754-756 — These two members are one piece of code written twice and then edited apart: 3 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.
  • Edited copy of a member (3 corresponding lines) lib/optimal_system_agent/os/process_group.ex:258 — lib/optimal_system_agent/os/process_group.ex:258-260 | lib/optimal_system_agent/system/erlexec.ex:96-98 — These two members are one piece of code written twice and then edited apart: 3 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.
  • Edited copy of a member (3 corresponding lines) lib/optimal_system_agent/agent/attendance.ex:317 — lib/optimal_system_agent/agent/attendance.ex:317-319 | lib/optimal_system_agent/tools/builtins/send_message/handler.ex:196-200 — These two members are one piece of code written twice and then edited apart: 3 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.
  • Edited copy of a member (3 corresponding lines) lib/optimal_system_agent/agent/session_persistence.ex:538 — lib/optimal_system_agent/agent/session_persistence.ex:538-540 | lib/optimal_system_agent/channels/http/api/mcp_routes.ex:206-208 — These two members are one piece of code written twice and then edited apart: 3 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.
  • Edited copy of a member (3 corresponding lines) lib/optimal_system_agent/agent/worktree.ex:155 — lib/optimal_system_agent/agent/worktree.ex:155-157 | lib/optimal_system_agent/tools/builtins/enter_worktree/handler.ex:153-158 — These two members are one piece of code written twice and then edited apart: 3 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.
  • Edited copy of a member (3 corresponding lines) lib/optimal_system_agent/mcp/plugin_manifest.ex:455 — lib/optimal_system_agent/mcp/plugin_manifest.ex:455-457 | lib/optimal_system_agent/tools/registry/skill_loader.ex:172-176 — These two members are one piece of code written twice and then edited apart: 3 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.
  • Edited copy of a member (3 corresponding lines) lib/optimal_system_agent/providers/claude_cli.ex:500 — lib/optimal_system_agent/providers/claude_cli.ex:500-502 | lib/optimal_system_agent/providers/copilot_cli.ex:515-517 — These two members are one piece of code written twice and then edited apart: 3 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.
  • Edited copy of a member (3 corresponding lines) lib/optimal_system_agent/tools/builtins/multi_file_edit/ui.ex:38 — lib/optimal_system_agent/tools/builtins/multi_file_edit/ui.ex:38-45 | lib/optimal_system_agent/tools/builtins/structural_edit/ui.ex:33-35 — These two members are one piece of code written twice and then edited apart: 3 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.
  • Edited copy of a member (3 corresponding lines) lib/optimal_system_agent/agent/loop.ex:1155 — lib/optimal_system_agent/agent/loop.ex:1155-1157 | lib/optimal_system_agent/agent/subagent_cloud_policy.ex:56-59 — These two members are one piece of code written twice and then edited apart: 3 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.
  • Edited copy of a member (3 corresponding lines) lib/optimal_system_agent/agent/loop/checkpoint.ex:738 — lib/optimal_system_agent/agent/loop/checkpoint.ex:738-740 | lib/optimal_system_agent/scratchpad.ex:246-252 — These two members are one piece of code written twice and then edited apart: 3 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.
  • Edited copy of a member (3 corresponding lines) lib/optimal_system_agent/orchestrator.ex:2030 — lib/optimal_system_agent/orchestrator.ex:2030-2034 | lib/optimal_system_agent/tools/builtins/send_message/discipline.ex:174-176 — These two members are one piece of code written twice and then edited apart: 3 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.
  • Edited copy of a member (3 corresponding lines) lib/optimal_system_agent/agent/loop/checkpoint.ex:732 — lib/optimal_system_agent/agent/loop/checkpoint.ex:732-734 | lib/optimal_system_agent/agent/rewind.ex:318-320 — These two members are one piece of code written twice and then edited apart: 3 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.
  • Edited copy of a member (3 corresponding lines) lib/optimal_system_agent/channels/cli/commands.ex:2049 — lib/optimal_system_agent/channels/cli/commands.ex:2049-2051 | lib/optimal_system_agent/tools/builtins/send_message/discipline.ex:185-189 — These two members are one piece of code written twice and then edited apart: 3 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.
  • Edited copy of a member (3 corresponding lines) lib/optimal_system_agent/providers/bedrock.ex:916 — lib/optimal_system_agent/providers/bedrock.ex:916-918 | lib/optimal_system_agent/providers/google.ex:587-589 — These two members are one piece of code written twice and then edited apart: 3 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.
  • + 4 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (7 lines × 2) · ×29
  • Duplicated block (7 lines × 2) canopy/backend/lib/canopy_web/controllers/integration_controller.ex:73 — canopy/backend/lib/canopy_web/controllers/integration_controller.ex:73-79 | canopy/backend/lib/canopy_web/controllers/integration_controller.ex:98-104 — 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) lib/optimal_system_agent/agent/loop/doom_loop/identical_call.ex:273 — lib/optimal_system_agent/agent/loop/doom_loop/identical_call.ex:273-279 | lib/optimal_system_agent/agent/loop/regulation/signals.ex:123-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.
  • Duplicated block (7 lines × 2) lib/optimal_system_agent/agent/loop/message_handler.ex:392 — lib/optimal_system_agent/agent/loop/message_handler.ex:392-398 | lib/optimal_system_agent/tools/builtins/exit_plan_mode/handler.ex:156-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 (7 lines × 2) lib/optimal_system_agent/agent/scheduler.ex:294 — lib/optimal_system_agent/agent/scheduler.ex:294-300 | lib/optimal_system_agent/agent/scheduler.ex:376-382 — 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) lib/optimal_system_agent/agent/memory/coordinator.ex:256 — lib/optimal_system_agent/agent/memory/coordinator.ex:256-262 | lib/optimal_system_agent/agent/memory/coordinator.ex:270-276 — 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 `lib/optimal_system_agent/agent/memory/coordinator.ex:256` 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) lib/optimal_system_agent/security/surface_map.ex:351 — lib/optimal_system_agent/security/surface_map.ex:351-357 | lib/optimal_system_agent/security/surface_map.ex:498-504 — 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 `lib/optimal_system_agent/security/surface_map.ex:351` 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 × 2) lib/miosa/shims.ex:1167 — lib/miosa/shims.ex:1167-1173 | lib/optimal_system_agent/signal/signal.ex:63-69 — 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, `lib/optimal_system_agent/signal/signal.ex:61` calls `to_cloud_event`, `t` and `lib/miosa/shims.ex:1164` 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 (7 lines × 2) lib/optimal_system_agent/agent/fleet.ex:1397 — lib/optimal_system_agent/agent/fleet.ex:1397-1403 | lib/optimal_system_agent/orchestrator.ex:3591-3597 — 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, `lib/optimal_system_agent/agent/fleet.ex:1394` calls `completion_summary` and `lib/optimal_system_agent/orchestrator.ex:3586` 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 (7 lines × 2) lib/optimal_system_agent/open_computers/executor/direct/desktop/macos.ex:102 — lib/optimal_system_agent/open_computers/executor/direct/desktop/macos.ex:102-108 | lib/optimal_system_agent/open_computers/executor/direct/desktop/windows.ex:99-105 — before extracting anything, compare `lib/optimal_system_agent/open_computers/executor/direct/desktop/macos.ex` and `lib/optimal_system_agent/open_computers/executor/direct/desktop/windows.ex` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 66 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 `lib/optimal_system_agent/open_computers/executor/direct/desktop/macos.ex:102` 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) lib/optimal_system_agent/providers/anthropic.ex:857 — lib/optimal_system_agent/providers/anthropic.ex:857-863 | lib/optimal_system_agent/providers/openai_compat.ex:1060-1066 — 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) lib/optimal_system_agent/providers/anthropic.ex:1664 — lib/optimal_system_agent/providers/anthropic.ex:1664-1670 | lib/optimal_system_agent/providers/google.ex:577-583 — 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) lib/optimal_system_agent/providers/claude_cli.ex:445 — lib/optimal_system_agent/providers/claude_cli.ex:445-451 | lib/optimal_system_agent/providers/copilot_cli.ex:380-386 — before extracting anything, compare `lib/optimal_system_agent/providers/claude_cli.ex` and `lib/optimal_system_agent/providers/copilot_cli.ex` as WHOLE FILES: this scan already matched 7 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. 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 (7 lines × 2) lib/optimal_system_agent/security/code_fix_store.ex:75 — lib/optimal_system_agent/security/code_fix_store.ex:75-81 | lib/optimal_system_agent/security/notes_store.ex:137-143 — 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) lib/optimal_system_agent/security/oob.ex:466 — lib/optimal_system_agent/security/oob.ex:466-472 | lib/optimal_system_agent/skills/validator.ex:619-625 — 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) lib/optimal_system_agent/agent/loop/goal_tracker.ex:1726 — lib/optimal_system_agent/agent/loop/goal_tracker.ex:1726-1732 | lib/optimal_system_agent/agent/loop/goal_verifier.ex:2031-2037 — 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) priv/rust/tui/src/app/commands.rs:1181 — priv/rust/tui/src/app/commands.rs:1181-1187 | priv/rust/tui/src/app/handle_actions.rs:1392-1398 — 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 `priv/rust/tui/src/app/commands.rs:1181` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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) priv/rust/tui/src/app/event_loop.rs:1352 — priv/rust/tui/src/app/event_loop.rs:1352-1358 | priv/rust/tui/src/app/event_loop.rs:1409-1418 — 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) priv/rust/tui/src/app/handle_actions.rs:1681 — priv/rust/tui/src/app/handle_actions.rs:1681-1687 | priv/rust/tui/src/app/handle_actions.rs:1696-1702 — 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 `priv/rust/tui/src/app/handle_actions.rs:1681` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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) priv/rust/tui/src/app/handle_actions.rs:1750 — priv/rust/tui/src/app/handle_actions.rs:1750-1756 | priv/rust/tui/src/app/handle_actions.rs:1966-1972 — 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 `priv/rust/tui/src/app/handle_actions.rs:1750` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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) priv/rust/tui/src/app/handle_dialogs.rs:1212 — priv/rust/tui/src/app/handle_dialogs.rs:1212-1218 | priv/rust/tui/src/app/keymap_dispatch.rs:279-285 — 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 `priv/rust/tui/src/app/handle_dialogs.rs:1212` 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 first that the copies are not typed on the same thing: the declarations holding them bind `self` to `super) fn cancel_selected_agent(&mut` in one and `crate) fn kill_all_agents(&mut` 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 (7 lines × 2) priv/rust/tui/src/components/input/mod.rs:3390 — priv/rust/tui/src/components/input/mod.rs:3390-3396 | priv/rust/tui/src/render/markdown.rs:1630-1636 — 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 `priv/rust/tui/src/components/input/mod.rs:3390` 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 (7 lines × 2) priv/rust/tui/src/dialogs/command_palette.rs:153 — priv/rust/tui/src/dialogs/command_palette.rs:153-159 | priv/rust/tui/src/dialogs/picker.rs:154-160 — before extracting anything, compare `priv/rust/tui/src/dialogs/command_palette.rs` and `priv/rust/tui/src/dialogs/picker.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 67 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 `priv/rust/tui/src/dialogs/picker.rs:154` 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 (7 lines × 2) priv/rust/tui/src/dialogs/context_breakdown.rs:316 — priv/rust/tui/src/dialogs/context_breakdown.rs:316-322 | priv/rust/tui/src/dialogs/status_dashboard.rs:272-278 — before extracting anything, compare `priv/rust/tui/src/dialogs/context_breakdown.rs` and `priv/rust/tui/src/dialogs/status_dashboard.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 43 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 `priv/rust/tui/src/dialogs/context_breakdown.rs:316` 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) priv/rust/tui/src/dialogs/sandbox_picker.rs:173 — priv/rust/tui/src/dialogs/sandbox_picker.rs:173-179 | priv/rust/tui/src/dialogs/theme_picker.rs:141-147 — before extracting anything, compare `priv/rust/tui/src/dialogs/sandbox_picker.rs` and `priv/rust/tui/src/dialogs/theme_picker.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 54 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 (7 lines × 2) priv/rust/tui/src/dialogs/model_picker.rs:1953 — priv/rust/tui/src/dialogs/model_picker.rs:1953-1959 | priv/rust/tui/src/dialogs/model_picker.rs:1990-1996 — 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.
  • + 4 more in this group — see findings.md.
D4 · Code Duplication · Edited copy of a member (12 corresponding lines) · ×28
  • Edited copy of a member (12 corresponding lines) priv/rust/tui/src/app/handle_dialogs.rs:551 — priv/rust/tui/src/app/handle_dialogs.rs:551-564 | priv/rust/tui/src/app/handle_dialogs.rs:738-749 — These two members are one piece of code written twice and then edited apart: 12 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.
  • Edited copy of a member (12 corresponding lines) lib/optimal_system_agent/agent/scheduler/persistence.ex:96 — lib/optimal_system_agent/agent/scheduler/persistence.ex:96-110 | lib/optimal_system_agent/agent/scheduler/persistence.ex:121-132 — These two members are one piece of code written twice and then edited apart: 12 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.
  • Edited copy of a member (12 corresponding lines) lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex:202 — lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex:202-217 | lib/optimal_system_agent/open_computers/executor/direct/cluster/mlx_distributed.ex:230-241 — These two members are one piece of code written twice and then edited apart: 12 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.
  • Edited copy of a member (12 corresponding lines) lib/optimal_system_agent/open_computers/remote/client.ex:70 — lib/optimal_system_agent/open_computers/remote/client.ex:70-81 | lib/optimal_system_agent/remote/client.ex:336-347 — These two members are one piece of code written twice and then edited apart: 12 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.
  • Edited copy of a member (12 corresponding lines) priv/rust/tui/src/app/commands.rs:1175 — priv/rust/tui/src/app/commands.rs:1175-1187 | priv/rust/tui/src/app/handle_actions.rs:1387-1398 — These two members are one piece of code written twice and then edited apart: 12 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.
  • Edited copy of a member (12 corresponding lines) REDACTED:164 — REDACTED:164-182 | lib/optimal_system_agent/auth/providers/xai.ex:153-164 — These two members are one piece of code written twice and then edited apart: 12 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.
  • Edited copy of a member (12 corresponding lines) priv/rust/tui/src/app/handle_actions.rs:1676 — priv/rust/tui/src/app/handle_actions.rs:1676-1687 | priv/rust/tui/src/app/handle_actions.rs:1691-1702 — These two members are one piece of code written twice and then edited apart: 12 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.
  • Edited copy of a member (12 corresponding lines) priv/rust/tui/src/app/commands.rs:1115 — priv/rust/tui/src/app/commands.rs:1115-1126 | priv/rust/tui/src/app/handle_actions.rs:1953-1972 — These two members are one piece of code written twice and then edited apart: 12 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.
  • Edited copy of a member (12 corresponding lines) priv/rust/tui/src/components/input/mod.rs:532 — priv/rust/tui/src/components/input/mod.rs:532-543 | priv/rust/tui/src/components/input/mod.rs:685-696 — These two members are one piece of code written twice and then edited apart: 12 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.
  • Edited copy of a member (12 corresponding lines) lib/optimal_system_agent/tools/builtins/task_write/handler.ex:135 — lib/optimal_system_agent/tools/builtins/task_write/handler.ex:135-146 | lib/optimal_system_agent/tools/builtins/task_write/handler.ex:235-246 — These two members are one piece of code written twice and then edited apart: 12 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.
  • Edited copy of a member (12 corresponding lines) priv/rust/tui/src/app/terminal_probe.rs:112 — priv/rust/tui/src/app/terminal_probe.rs:112-126 | priv/rust/tui/src/app/terminal_probe.rs:131-142 — These two members are one piece of code written twice and then edited apart: 12 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.
  • Edited copy of a member (12 corresponding lines) lib/miosa/shims.ex:858 — lib/miosa/shims.ex:858-869 | lib/optimal_system_agent/budget/budget.ex:246-262 — These two members are one piece of code written twice and then edited apart: 12 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.
  • Edited copy of a member (12 corresponding lines) canopy/backend/lib/canopy/costs.ex:42 — canopy/backend/lib/canopy/costs.ex:42-53 | canopy/backend/lib/canopy_web/controllers/cost_controller.ex:65-79 — These two members are one piece of code written twice and then edited apart: 12 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.
  • Edited copy of a member (12 corresponding lines) priv/rust/tui/src/client/http.rs:76 — priv/rust/tui/src/client/http.rs:76-87 | priv/rust/tui/src/client/http.rs:1395-1408 — These two members are one piece of code written twice and then edited apart: 12 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.
  • Edited copy of a member (12 corresponding lines) canopy/backend/lib/canopy_web/controllers/agent_controller.ex:227 — canopy/backend/lib/canopy_web/controllers/agent_controller.ex:227-239 | canopy/backend/lib/canopy_web/controllers/spawn_controller.ex:57-68 — These two members are one piece of code written twice and then edited apart: 12 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.
  • Edited copy of a member (12 corresponding lines) lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex:254 — lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex:254-265 | lib/optimal_system_agent/open_computers/executor/direct/cluster/mlx_distributed.ex:48-60 — These two members are one piece of code written twice and then edited apart: 12 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.
  • Edited copy of a member (12 corresponding lines) lib/optimal_system_agent/shell/pty/screen.ex:294 — lib/optimal_system_agent/shell/pty/screen.ex:294-305 | lib/optimal_system_agent/shell/pty/screen.ex:310-321 — These two members are one piece of code written twice and then edited apart: 12 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.
  • Edited copy of a member (12 corresponding lines) lib/optimal_system_agent/providers/fallback_chain.ex:275 — lib/optimal_system_agent/providers/fallback_chain.ex:275-288 | lib/optimal_system_agent/providers/fallback_chain.ex:297-308 — These two members are one piece of code written twice and then edited apart: 12 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.
  • Edited copy of a member (12 corresponding lines) lib/optimal_system_agent/skills/validator.ex:185 — lib/optimal_system_agent/skills/validator.ex:185-196 | lib/optimal_system_agent/tools/registry/skill_loader.ex:406-419 — These two members are one piece of code written twice and then edited apart: 12 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.
  • Edited copy of a member (12 corresponding lines) lib/optimal_system_agent/agent/session_persistence/jsonl.ex:231 — lib/optimal_system_agent/agent/session_persistence/jsonl.ex:231-242 | lib/optimal_system_agent/agent/session_persistence/record_lock.ex:96-107 — These two members are one piece of code written twice and then edited apart: 12 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.
  • Edited copy of a member (12 corresponding lines) priv/rust/tui/src/style/mod.rs:627 — priv/rust/tui/src/style/mod.rs:627-638 | priv/rust/tui/src/style/mod.rs:644-655 — These two members are one piece of code written twice and then edited apart: 12 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.
  • Edited copy of a member (12 corresponding lines) lib/optimal_system_agent/agent/task_tracker.ex:593 — lib/optimal_system_agent/agent/task_tracker.ex:593-605 | lib/optimal_system_agent/security/threat_intel.ex:221-232 — These two members are one piece of code written twice and then edited apart: 12 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.
  • Edited copy of a member (12 corresponding lines) lib/optimal_system_agent/teams/nervous_system.ex:74 — lib/optimal_system_agent/teams/nervous_system.ex:74-90 | lib/optimal_system_agent/teams/supervisor.ex:93-104 — These two members are one piece of code written twice and then edited apart: 12 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.
  • Edited copy of a member (12 corresponding lines) lib/optimal_system_agent/tools/builtins/skill_manager.ex:115 — lib/optimal_system_agent/tools/builtins/skill_manager.ex:115-126 | lib/optimal_system_agent/tools/builtins/team_tasks/handler.ex:102-114 — These two members are one piece of code written twice and then edited apart: 12 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.
  • Edited copy of a member (12 corresponding lines) lib/optimal_system_agent/providers/anthropic.ex:1624 — lib/optimal_system_agent/providers/anthropic.ex:1624-1635 | lib/optimal_system_agent/providers/openai_compat.ex:1657-1669 — These two members are one piece of code written twice and then edited apart: 12 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.
  • + 3 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (5 lines × 2) · ×28
  • Duplicated block (5 lines × 2) lib/optimal_system_agent/agent/loop/tool_executor.ex:1481 — lib/optimal_system_agent/agent/loop/tool_executor.ex:1481-1485 | lib/optimal_system_agent/agent/loop/tool_executor.ex:1493-1497 — 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) lib/optimal_system_agent/channels/http/auth.ex:54 — lib/optimal_system_agent/channels/http/auth.ex:54-58 | lib/optimal_system_agent/channels/http/auth.ex:74-78 — 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) lib/optimal_system_agent/open_computers/executor/direct/desktop/macos.ex:52 — lib/optimal_system_agent/open_computers/executor/direct/desktop/macos.ex:52-56 | lib/optimal_system_agent/open_computers/executor/direct/desktop/windows.ex:49-53 — before extracting anything, compare `lib/optimal_system_agent/open_computers/executor/direct/desktop/macos.ex` and `lib/optimal_system_agent/open_computers/executor/direct/desktop/windows.ex` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 66 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 (5 lines × 2) lib/optimal_system_agent/tools/builtins/diff.ex:95 — lib/optimal_system_agent/tools/builtins/diff.ex:95-101 | lib/optimal_system_agent/tools/builtins/diff.ex:123-127 — 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 `lib/optimal_system_agent/tools/builtins/diff.ex: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.
  • Duplicated block (5 lines × 2) canopy/backend/lib/canopy/costs.ex:144 — canopy/backend/lib/canopy/costs.ex:144-148 | canopy/backend/lib/canopy_web/controllers/cost_controller.ex:131-135 — before extracting anything, compare `canopy/backend/lib/canopy/costs.ex` and `canopy/backend/lib/canopy_web/controllers/cost_controller.ex` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 78 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) lib/miosa/shims.ex:934 — lib/miosa/shims.ex:934-938 | lib/optimal_system_agent/budget/treasury.ex:289-293 — 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) lib/miosa/shims.ex:942 — lib/miosa/shims.ex:942-946 | lib/optimal_system_agent/budget/treasury.ex:297-301 — 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) lib/optimal_system_agent/cli/opencomputers.ex:589 — lib/optimal_system_agent/cli/opencomputers.ex:589-593 | lib/optimal_system_agent/open_computers/config.ex:131-135 — 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) lib/optimal_system_agent/security/chain_summary.ex:237 — lib/optimal_system_agent/security/chain_summary.ex:237-242 | lib/optimal_system_agent/security/sarif_report.ex:247-251 — 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 (5 lines × 2) lib/optimal_system_agent/tools/builtins/code_symbols/handler.ex:59 — lib/optimal_system_agent/tools/builtins/code_symbols/handler.ex:59-63 | lib/optimal_system_agent/tools/builtins/file_glob/handler.ex:23-27 — 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 `lib/optimal_system_agent/tools/builtins/code_symbols/handler.ex:59` 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) lib/optimal_system_agent/agent/plan_store.ex:71 — lib/optimal_system_agent/agent/plan_store.ex:71-75 | lib/optimal_system_agent/agent/progress_ledger.ex:97-101 — 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 `lib/optimal_system_agent/agent/plan_store.ex:71` 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) lib/optimal_system_agent/tools/bounded_cmd.ex:377 — lib/optimal_system_agent/tools/bounded_cmd.ex:377-381 | lib/optimal_system_agent/tools/builtins/file_grep/constants.ex:66-70 — 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 `lib/optimal_system_agent/tools/bounded_cmd.ex: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 × 2) lib/optimal_system_agent/agent/loop/checkpoint.ex:119 — lib/optimal_system_agent/agent/loop/checkpoint.ex:119-123 | lib/optimal_system_agent/agent/loop/checkpoint.ex:712-716 — 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) lib/optimal_system_agent/channels/cli/commands.ex:849 — lib/optimal_system_agent/channels/cli/commands.ex:849-853 | lib/optimal_system_agent/channels/cli/commands.ex:956-960 — 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 `lib/optimal_system_agent/channels/cli/commands.ex:849` 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) lib/optimal_system_agent/providers/ollama.ex:1746 — lib/optimal_system_agent/providers/ollama.ex:1746-1750 | lib/optimal_system_agent/providers/openai_compat.ex:905-909 — 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 `lib/optimal_system_agent/providers/ollama.ex:1746` 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) lib/optimal_system_agent/telemetry/metrics.ex:210 — lib/optimal_system_agent/telemetry/metrics.ex:210-214 | lib/optimal_system_agent/telemetry/metrics.ex:218-222 — 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 `lib/optimal_system_agent/telemetry/metrics.ex:210` 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) priv/rust/tui/src/app/commands.rs:1006 — priv/rust/tui/src/app/commands.rs:1006-1010 | priv/rust/tui/src/app/handle_dialogs.rs:739-743 — 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 `priv/rust/tui/src/app/commands.rs:1006` 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) priv/rust/tui/src/dialogs/file_picker.rs:234 — priv/rust/tui/src/dialogs/file_picker.rs:234-238 | priv/rust/tui/src/dialogs/sessions.rs:249-253 — before extracting anything, compare `priv/rust/tui/src/dialogs/file_picker.rs` and `priv/rust/tui/src/dialogs/sessions.rs` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 97 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 (5 lines × 2) priv/rust/tui/src/dialogs/onboarding.rs:1182 — priv/rust/tui/src/dialogs/onboarding.rs:1182-1186 | priv/rust/tui/src/dialogs/onboarding.rs:1211-1215 — 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 `priv/rust/tui/src/dialogs/onboarding.rs:1182` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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) priv/rust/tui/src/dialogs/skills_browser.rs:154 — priv/rust/tui/src/dialogs/skills_browser.rs:154-158 | priv/rust/tui/src/dialogs/tools_browser.rs:144-148 — before extracting anything, compare `priv/rust/tui/src/dialogs/skills_browser.rs` and `priv/rust/tui/src/dialogs/tools_browser.rs` as WHOLE FILES: this scan already matched 22 separate duplicated blocks between them, totalling at least 301 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 (5 lines × 2) priv/rust/tui/src/dialogs/onboarding.rs:1192 — priv/rust/tui/src/dialogs/onboarding.rs:1192-1196 | priv/rust/tui/src/dialogs/onboarding.rs:1201-1206 — 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 `priv/rust/tui/src/dialogs/onboarding.rs:1192` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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 (5 lines × 2) priv/rust/tui/src/components/input/mod.rs:1170 — priv/rust/tui/src/components/input/mod.rs:1170-1175 | priv/rust/tui/src/components/input/mod.rs:2458-2462 — 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) priv/rust/tui/src/dialogs/onboarding.rs:1175 — priv/rust/tui/src/dialogs/onboarding.rs:1175-1179 | priv/rust/tui/src/dialogs/onboarding.rs:1212-1216 — 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 `priv/rust/tui/src/dialogs/onboarding.rs:1175` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (5 lines × 2) priv/rust/tui/src/config/cli.rs:7 — priv/rust/tui/src/config/cli.rs:7-11 | priv/rust/tui/src/config/mod.rs:155-159 — 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. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (5 lines × 2) bench/swebench/run_bench.py:302 — bench/swebench/run_bench.py:302-306 | bench/swebenchpro/run_bench.py:118-122 — `bench/swebench/run_bench.py` and `bench/swebenchpro/run_bench.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 202 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.
  • + 3 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (10 lines × 2) · ×26
  • Duplicated block (10 lines × 2) canopy/backend/lib/canopy_web/controllers/alert_controller.ex:127 — canopy/backend/lib/canopy_web/controllers/alert_controller.ex:127-136 | canopy/backend/lib/canopy_web/controllers/skill_controller.ex:16-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.
  • Duplicated block (10 lines × 2) lib/optimal_system_agent/agent/jailbreak.ex:183 — lib/optimal_system_agent/agent/jailbreak.ex:183-192 | lib/optimal_system_agent/agent/voice.ex:198-207 — 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) lib/optimal_system_agent/agent/loop/goal_verifier.ex:790 — lib/optimal_system_agent/agent/loop/goal_verifier.ex:790-799 | lib/optimal_system_agent/agent/loop/spot_check_auditor.ex:417-429 — 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 `lib/optimal_system_agent/agent/loop/spot_check_auditor.ex:417` 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 lines × 2) lib/optimal_system_agent/agent/task_tracker.ex:618 — lib/optimal_system_agent/agent/task_tracker.ex:618-627 | lib/optimal_system_agent/agent/tasks/tracker.ex:534-543 — before extracting anything, compare `lib/optimal_system_agent/agent/task_tracker.ex` and `lib/optimal_system_agent/agent/tasks/tracker.ex` as WHOLE FILES: this scan already matched 7 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. 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 `lib/optimal_system_agent/agent/task_tracker.ex:618` 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 (10 lines × 2) lib/optimal_system_agent/healing/orchestrator.ex:317 — lib/optimal_system_agent/healing/orchestrator.ex:317-326 | lib/optimal_system_agent/healing/orchestrator.ex:362-371 — 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 `lib/optimal_system_agent/healing/orchestrator.ex:317` 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 lines × 2) lib/optimal_system_agent/open_computers/executor/direct/clipboard.ex:96 — lib/optimal_system_agent/open_computers/executor/direct/clipboard.ex:96-105 | lib/optimal_system_agent/open_computers/executor/direct/clipboard.ex:126-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 (10 lines × 2) lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex:69 — lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex:69-78 | lib/optimal_system_agent/open_computers/executor/direct/cluster/mlx_distributed.ex:92-101 — before extracting anything, compare `lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex` and `lib/optimal_system_agent/open_computers/executor/direct/cluster/mlx_distributed.ex` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 66 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 `lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex:69` 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 lines × 2) lib/optimal_system_agent/providers/catalog.ex:604 — lib/optimal_system_agent/providers/catalog.ex:604-613 | lib/optimal_system_agent/providers/catalog.ex:638-647 — 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 `lib/optimal_system_agent/providers/catalog.ex:604` 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 (10 lines × 2) lib/optimal_system_agent/providers/claude_cli.ex:857 — lib/optimal_system_agent/providers/claude_cli.ex:857-866 | lib/optimal_system_agent/providers/copilot_cli.ex:530-539 — before extracting anything, compare `lib/optimal_system_agent/providers/claude_cli.ex` and `lib/optimal_system_agent/providers/copilot_cli.ex` as WHOLE FILES: this scan already matched 7 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. 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 (10 lines × 2) lib/optimal_system_agent/providers/registry.ex:177 — lib/optimal_system_agent/providers/registry.ex:177-186 | lib/optimal_system_agent/providers/registry.ex:333-342 — 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) lib/optimal_system_agent/tools/ablation/runner.ex:326 — lib/optimal_system_agent/tools/ablation/runner.ex:326-335 | lib/optimal_system_agent/tools/ablation/runner.ex:439-448 — 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 `lib/optimal_system_agent/tools/ablation/runner.ex:326` 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 (10 lines × 2) lib/optimal_system_agent/tools/registry.ex:335 — lib/optimal_system_agent/tools/registry.ex:335-344 | lib/optimal_system_agent/tools/registry.ex:1033-1042 — 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) lib/optimal_system_agent/agent/tasks.ex:201 — lib/optimal_system_agent/agent/tasks.ex:201-210 | lib/optimal_system_agent/agent/tasks/tracker.ex:653-662 — 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 `lib/optimal_system_agent/agent/tasks.ex: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 (10 lines × 2) lib/optimal_system_agent/tools/builtins/computer_use/adapters/linux_wayland.ex:175 — lib/optimal_system_agent/tools/builtins/computer_use/adapters/linux_wayland.ex:175-184 | lib/optimal_system_agent/tools/builtins/computer_use/adapters/linux_x11.ex:222-232 — 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) lib/optimal_system_agent/tools/builtins/task_output/tool.ex:48 — lib/optimal_system_agent/tools/builtins/task_output/tool.ex:48-57 | lib/optimal_system_agent/tools/builtins/task_stop/tool.ex:49-58 — 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) lib/optimal_system_agent/agent/session_persistence/jsonl.ex:246 — lib/optimal_system_agent/agent/session_persistence/jsonl.ex:246-255 | lib/optimal_system_agent/agent/session_persistence/record_lock.ex:111-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 `lib/optimal_system_agent/agent/session_persistence/jsonl.ex:246` 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 lines × 2) lib/optimal_system_agent/fs_checkpoint/server.ex:123 — lib/optimal_system_agent/fs_checkpoint/server.ex:123-132 | lib/optimal_system_agent/providers/catalog.ex:906-915 — 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 `lib/optimal_system_agent/fs_checkpoint/server.ex: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.
  • Duplicated block (10 lines × 2) priv/rust/tui/src/app/handle_actions.rs:196 — priv/rust/tui/src/app/handle_actions.rs:196-205 | priv/rust/tui/src/app/handle_actions.rs:217-226 — 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 `priv/rust/tui/src/app/handle_actions.rs:196` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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 lines × 2) priv/rust/tui/src/dialogs/config_editor.rs:432 — priv/rust/tui/src/dialogs/config_editor.rs:432-441 | priv/rust/tui/src/dialogs/reasoning.rs:228-238 — before extracting anything, compare `priv/rust/tui/src/dialogs/config_editor.rs` and `priv/rust/tui/src/dialogs/reasoning.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 64 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 `priv/rust/tui/src/dialogs/config_editor.rs:432` 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 lines × 2) priv/rust/tui/src/dialogs/context_breakdown.rs:249 — priv/rust/tui/src/dialogs/context_breakdown.rs:249-258 | priv/rust/tui/src/dialogs/context_breakdown.rs:302-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. Read the line range as the matched WINDOW rather than a finished unit: at `priv/rust/tui/src/dialogs/context_breakdown.rs:249` 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 lines × 2) priv/rust/tui/src/dialogs/onboarding.rs:1354 — priv/rust/tui/src/dialogs/onboarding.rs:1354-1363 | priv/rust/tui/src/dialogs/onboarding.rs:1390-1399 — 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) priv/rust/tui/src/render/markdown.rs:2535 — priv/rust/tui/src/render/markdown.rs:2535-2544 | priv/rust/tui/src/render/markdown.rs:2545-2554 — 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) priv/rust/tui/src/view/onboarding_flow.rs:260 — priv/rust/tui/src/view/onboarding_flow.rs:260-269 | priv/rust/tui/src/view/onboarding_flow.rs:904-913 — 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 `priv/rust/tui/src/view/onboarding_flow.rs:260` 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 (10 lines × 2) priv/rust/tui/src/voice/transcribe.rs:568 — priv/rust/tui/src/voice/transcribe.rs:568-577 | priv/rust/tui/src/voice/transcribe.rs:632-641 — 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 `priv/rust/tui/src/voice/transcribe.rs:568` 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 lines × 2) bench/headtohead/attribution.py:396 — bench/headtohead/attribution.py:396-405 | bench/terminalbench/report.py:598-607 — 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.
  • + 1 more in this group — see findings.md.
D4 · Code Duplication · Edited copy of a member (8 corresponding lines) · ×25
  • Edited copy of a member (8 corresponding lines) lib/optimal_system_agent/conversations/weaver.ex:40 — lib/optimal_system_agent/conversations/weaver.ex:40-55 | lib/optimal_system_agent/conversations/weaver.ex:69-76 — These two members are one piece of code written twice and then edited apart: 8 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.
  • Edited copy of a member (8 corresponding lines) priv/rust/tui/src/dialogs/file_picker.rs:127 — priv/rust/tui/src/dialogs/file_picker.rs:127-134 | priv/rust/tui/src/dialogs/sessions.rs:91-103 — These two members are one piece of code written twice and then edited apart: 8 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.
  • Edited copy of a member (8 corresponding lines) native/macos/AccessibilityHelper/main.swift:107 — native/macos/AccessibilityHelper/main.swift:107-114 | native/macos/AccessibilityHelper/main.swift:116-123 — These two members are one piece of code written twice and then edited apart: 8 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.
  • Edited copy of a member (8 corresponding lines) priv/rust/tui/src/client/http.rs:1037 — priv/rust/tui/src/client/http.rs:1037-1047 | priv/rust/tui/src/client/http.rs:1443-1450 — These two members are one piece of code written twice and then edited apart: 8 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.
  • Edited copy of a member (8 corresponding lines) lib/optimal_system_agent/action_authority.ex:65 — lib/optimal_system_agent/action_authority.ex:65-73 | lib/optimal_system_agent/system/updater.ex:471-478 — These two members are one piece of code written twice and then edited apart: 8 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.
  • Edited copy of a member (8 corresponding lines) lib/optimal_system_agent/channels/cli/computer_use_dispatch.ex:191 — lib/optimal_system_agent/channels/cli/computer_use_dispatch.ex:191-198 | lib/optimal_system_agent/tools/builtins/computer_use/executor.ex:227-246 — These two members are one piece of code written twice and then edited apart: 8 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.
  • Edited copy of a member (8 corresponding lines) lib/optimal_system_agent/agent/safety/model_classifier.ex:331 — lib/optimal_system_agent/agent/safety/model_classifier.ex:331-338 | lib/optimal_system_agent/events/classifier.ex:85-94 — These two members are one piece of code written twice and then edited apart: 8 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.
  • Edited copy of a member (8 corresponding lines) lib/optimal_system_agent/shell/background_manager.ex:135 — lib/optimal_system_agent/shell/background_manager.ex:135-142 | lib/optimal_system_agent/shell/background_manager.ex:154-163 — These two members are one piece of code written twice and then edited apart: 8 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.
  • Edited copy of a member (8 corresponding lines) lib/optimal_system_agent/channels/http/api/workspace_routes.ex:272 — lib/optimal_system_agent/channels/http/api/workspace_routes.ex:272-279 | lib/optimal_system_agent/workspace/topology.ex:454-465 — These two members are one piece of code written twice and then edited apart: 8 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.
  • Edited copy of a member (8 corresponding lines) lib/optimal_system_agent/channels/line.ex:188 — lib/optimal_system_agent/channels/line.ex:188-196 | lib/optimal_system_agent/channels/whatsapp.ex:196-203 — These two members are one piece of code written twice and then edited apart: 8 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.
  • Edited copy of a member (8 corresponding lines) lib/optimal_system_agent/providers/mistral_models.ex:174 — lib/optimal_system_agent/providers/mistral_models.ex:174-181 | lib/optimal_system_agent/providers/mistral_models.ex:197-207 — These two members are one piece of code written twice and then edited apart: 8 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.
  • Edited copy of a member (8 corresponding lines) canopy/backend/lib/canopy/agents.ex:56 — canopy/backend/lib/canopy/agents.ex:56-69 | canopy/backend/lib/canopy/work.ex:73-80 — These two members are one piece of code written twice and then edited apart: 8 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.
  • Edited copy of a member (8 corresponding lines) lib/optimal_system_agent/skin/engine.ex:54 — lib/optimal_system_agent/skin/engine.ex:54-66 | lib/optimal_system_agent/skin/engine.ex:89-96 — These two members are one piece of code written twice and then edited apart: 8 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.
  • Edited copy of a member (8 corresponding lines) priv/rust/tui/src/dialogs/file_picker.rs:155 — priv/rust/tui/src/dialogs/file_picker.rs:155-162 | priv/rust/tui/src/dialogs/sessions.rs:124-131 — These two members are one piece of code written twice and then edited apart: 8 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.
  • Edited copy of a member (8 corresponding lines) lib/optimal_system_agent/shell/background_tracker.ex:111 — lib/optimal_system_agent/shell/background_tracker.ex:111-118 | lib/optimal_system_agent/shell/background_tracker.ex:124-131 — These two members are one piece of code written twice and then edited apart: 8 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.
  • Edited copy of a member (8 corresponding lines) lib/optimal_system_agent/security/code_fix_pr.ex:348 — lib/optimal_system_agent/security/code_fix_pr.ex:348-355 | lib/optimal_system_agent/skills/validator.ex:643-651 — These two members are one piece of code written twice and then edited apart: 8 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.
  • Edited copy of a member (8 corresponding lines) priv/rust/tui/src/client/http.rs:299 — priv/rust/tui/src/client/http.rs:299-306 | priv/rust/tui/src/client/http.rs:472-482 — These two members are one piece of code written twice and then edited apart: 8 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.
  • Edited copy of a member (8 corresponding lines) lib/optimal_system_agent/memory/scoring.ex:166 — lib/optimal_system_agent/memory/scoring.ex:166-174 | lib/optimal_system_agent/memory/store.ex:1007-1014 — These two members are one piece of code written twice and then edited apart: 8 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.
  • Edited copy of a member (8 corresponding lines) lib/optimal_system_agent/channels/cli/commands.ex:2677 — lib/optimal_system_agent/channels/cli/commands.ex:2677-2684 | lib/optimal_system_agent/channels/cli/renderer.ex:205-215 — These two members are one piece of code written twice and then edited apart: 8 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.
  • Edited copy of a member (8 corresponding lines) lib/optimal_system_agent/security/code_fix_store.ex:95 — lib/optimal_system_agent/security/code_fix_store.ex:95-102 | lib/optimal_system_agent/security/notes_store.ex:164-171 — These two members are one piece of code written twice and then edited apart: 8 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.
  • Edited copy of a member (8 corresponding lines) lib/optimal_system_agent/channels/http/api/webhook_verify.ex:47 — lib/optimal_system_agent/channels/http/api/webhook_verify.ex:47-54 | lib/optimal_system_agent/channels/slack.ex:148-156 — These two members are one piece of code written twice and then edited apart: 8 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.
  • Edited copy of a member (8 corresponding lines) lib/optimal_system_agent/agent/voice.ex:183 — lib/optimal_system_agent/agent/voice.ex:183-190 | lib/optimal_system_agent/cli/doctor.ex:666-673 — These two members are one piece of code written twice and then edited apart: 8 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.
  • Edited copy of a member (8 corresponding lines) lib/optimal_system_agent/store/decision_edge.ex:39 — lib/optimal_system_agent/store/decision_edge.ex:39-46 | lib/optimal_system_agent/store/decision_node.ex:53-61 — These two members are one piece of code written twice and then edited apart: 8 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.
  • Edited copy of a member (8 corresponding lines) lib/optimal_system_agent/agent/loop.ex:255 — lib/optimal_system_agent/agent/loop.ex:255-263 | lib/optimal_system_agent/workspace/workspace.ex:59-66 — These two members are one piece of code written twice and then edited apart: 8 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.
  • Edited copy of a member (8 corresponding lines) lib/optimal_system_agent/protocol/context_refs.ex:76 — lib/optimal_system_agent/protocol/context_refs.ex:76-84 | lib/optimal_system_agent/tools/builtins/task_resume/handler.ex:89-96 — These two members are one piece of code written twice and then edited apart: 8 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 (5 corresponding lines) · ×25
  • Edited copy of a member (5 corresponding lines) lib/optimal_system_agent/context_mesh/keeper.ex:451 — lib/optimal_system_agent/context_mesh/keeper.ex:451-461 | lib/optimal_system_agent/memory/consolidator.ex:257-261 — These two members are one piece of code written twice and then edited apart: 5 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.
  • Edited copy of a member (5 corresponding lines) lib/optimal_system_agent/workspace/fast_worktree/populate.ex:107 — lib/optimal_system_agent/workspace/fast_worktree/populate.ex:107-111 | lib/optimal_system_agent/workspace/fast_worktree/populate.ex:125-129 — These two members are one piece of code written twice and then edited apart: 5 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.
  • Edited copy of a member (5 corresponding lines) lib/optimal_system_agent/agent/loop/verification_evidence.ex:293 — lib/optimal_system_agent/agent/loop/verification_evidence.ex:293-297 | lib/optimal_system_agent/agent/loop/verification_evidence.ex:1021-1031 — These two members are one piece of code written twice and then edited apart: 5 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.
  • Edited copy of a member (5 corresponding lines) lib/optimal_system_agent/memory/scoring.ex:108 — lib/optimal_system_agent/memory/scoring.ex:108-114 | lib/optimal_system_agent/memory/store.ex:985-989 — These two members are one piece of code written twice and then edited apart: 5 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.
  • Edited copy of a member (5 corresponding lines) lib/optimal_system_agent/mcp/config.ex:526 — lib/optimal_system_agent/mcp/config.ex:526-530 | lib/optimal_system_agent/memory/skill_generator.ex:206-210 — These two members are one piece of code written twice and then edited apart: 5 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.
  • Edited copy of a member (5 corresponding lines) lib/optimal_system_agent/agent/tasks/persistence.ex:131 — lib/optimal_system_agent/agent/tasks/persistence.ex:131-135 | lib/optimal_system_agent/agent/workflow.ex:714-720 — These two members are one piece of code written twice and then edited apart: 5 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.
  • Edited copy of a member (5 corresponding lines) lib/optimal_system_agent/agent/loop/verification_evidence.ex:361 — lib/optimal_system_agent/agent/loop/verification_evidence.ex:361-365 | lib/optimal_system_agent/providers/retry_classifier.ex:423-429 — These two members are one piece of code written twice and then edited apart: 5 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.
  • Edited copy of a member (5 corresponding lines) lib/optimal_system_agent/security/eval_harness.ex:113 — lib/optimal_system_agent/security/eval_harness.ex:113-118 | lib/optimal_system_agent/security/oob.ex:287-291 — These two members are one piece of code written twice and then edited apart: 5 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.
  • Edited copy of a member (5 corresponding lines) lib/optimal_system_agent/agent/task_queue.ex:468 — lib/optimal_system_agent/agent/task_queue.ex:468-476 | lib/optimal_system_agent/agent/tasks/queue.ex:253-257 — These two members are one piece of code written twice and then edited apart: 5 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.
  • Edited copy of a member (5 corresponding lines) lib/optimal_system_agent/agent/tasks/workflow.ex:612 — lib/optimal_system_agent/agent/tasks/workflow.ex:612-616 | lib/optimal_system_agent/agent/workflow.ex:819-825 — These two members are one piece of code written twice and then edited apart: 5 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.
  • Edited copy of a member (5 corresponding lines) lib/optimal_system_agent/agent/loop/goal_tracker.ex:1946 — lib/optimal_system_agent/agent/loop/goal_tracker.ex:1946-1950 | lib/optimal_system_agent/workspace/trust.ex:365-370 — These two members are one piece of code written twice and then edited apart: 5 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.
  • Edited copy of a member (5 corresponding lines) lib/optimal_system_agent/agent/session_persistence.ex:1481 — lib/optimal_system_agent/agent/session_persistence.ex:1481-1485 | lib/optimal_system_agent/memory/session_titler.ex:236-241 — These two members are one piece of code written twice and then edited apart: 5 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.
  • Edited copy of a member (5 corresponding lines) lib/optimal_system_agent/tools/builtins/message_agent/ui.ex:13 — lib/optimal_system_agent/tools/builtins/message_agent/ui.ex:13-18 | lib/optimal_system_agent/tools/builtins/team_tasks/ui.ex:13-17 — These two members are one piece of code written twice and then edited apart: 5 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.
  • Edited copy of a member (5 corresponding lines) lib/optimal_system_agent/agent/session_persistence.ex:1608 — lib/optimal_system_agent/agent/session_persistence.ex:1608-1612 | lib/optimal_system_agent/workspace/fast_worktree/metadata.ex:147-152 — These two members are one piece of code written twice and then edited apart: 5 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.
  • Edited copy of a member (5 corresponding lines) priv/rust/tui/src/dialogs/persona_picker.rs:79 — priv/rust/tui/src/dialogs/persona_picker.rs:79-83 | priv/rust/tui/src/dialogs/tools_browser.rs:83-89 — These two members are one piece of code written twice and then edited apart: 5 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.
  • Edited copy of a member (5 corresponding lines) lib/optimal_system_agent/tools/builtins/send_user_file/tool.ex:102 — lib/optimal_system_agent/tools/builtins/send_user_file/tool.ex:102-106 | lib/optimal_system_agent/tools/builtins/send_user_file/ui.ex:5-10 — These two members are one piece of code written twice and then edited apart: 5 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.
  • Edited copy of a member (5 corresponding lines) lib/optimal_system_agent/agent/security_context.ex:196 — lib/optimal_system_agent/agent/security_context.ex:196-203 | lib/optimal_system_agent/channels/http/api/canopy_routes.ex:398-402 — These two members are one piece of code written twice and then edited apart: 5 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.
  • Edited copy of a member (5 corresponding lines) lib/optimal_system_agent/local_models/catalog.ex:79 — lib/optimal_system_agent/local_models/catalog.ex:79-83 | lib/optimal_system_agent/local_models/hugging_face.ex:166-171 — These two members are one piece of code written twice and then edited apart: 5 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.
  • Edited copy of a member (5 corresponding lines) lib/optimal_system_agent/providers/cohere.ex:136 — lib/optimal_system_agent/providers/cohere.ex:136-140 | lib/optimal_system_agent/providers/google.ex:569-573 — These two members are one piece of code written twice and then edited apart: 5 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.
  • Edited copy of a member (5 corresponding lines) priv/rust/tui/src/components/task_checklist.rs:125 — priv/rust/tui/src/components/task_checklist.rs:125-129 | priv/rust/tui/src/components/tasks.rs:38-42 — These two members are one piece of code written twice and then edited apart: 5 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.
  • Edited copy of a member (5 corresponding lines) lib/optimal_system_agent/teams/agent_state.ex:87 — lib/optimal_system_agent/teams/agent_state.ex:87-91 | lib/optimal_system_agent/teams/manager.ex:474-478 — These two members are one piece of code written twice and then edited apart: 5 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.
  • Edited copy of a member (5 corresponding lines) lib/optimal_system_agent/providers/openai_compat.ex:1049 — lib/optimal_system_agent/providers/openai_compat.ex:1049-1053 | lib/optimal_system_agent/providers/openai_responses.ex:537-541 — These two members are one piece of code written twice and then edited apart: 5 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.
  • Edited copy of a member (5 corresponding lines) lib/optimal_system_agent/agent/loop/permission_broker.ex:187 — lib/optimal_system_agent/agent/loop/permission_broker.ex:187-191 | lib/optimal_system_agent/permissions/ask_flow.ex:76-80 — These two members are one piece of code written twice and then edited apart: 5 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.
  • Edited copy of a member (5 corresponding lines) lib/optimal_system_agent/sandbox/miosa.ex:158 — lib/optimal_system_agent/sandbox/miosa.ex:158-162 | lib/optimal_system_agent/sandbox/miosa.ex:167-171 — These two members are one piece of code written twice and then edited apart: 5 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.
  • Edited copy of a member (5 corresponding lines) bench/swebench/run_bench.py:49 — bench/swebench/run_bench.py:49-53 | bench/swebenchpro/dataset.py:52-59 — These two members are one piece of code written twice and then edited apart: 5 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 (6 corresponding lines) · ×25
  • Edited copy of a member (6 corresponding lines) lib/optimal_system_agent/security/code_fix_pr.ex:285 — lib/optimal_system_agent/security/code_fix_pr.ex:285-290 | lib/optimal_system_agent/security/code_fix_pr.ex:297-302 — These two members are one piece of code written twice and then edited apart: 6 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.
  • Edited copy of a member (6 corresponding lines) lib/optimal_system_agent/security/symbol_resolver.ex:153 — lib/optimal_system_agent/security/symbol_resolver.ex:153-158 | lib/optimal_system_agent/security/symbol_resolver.ex:162-169 — These two members are one piece of code written twice and then edited apart: 6 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.
  • Edited copy of a member (6 corresponding lines) lib/optimal_system_agent/verify/post_edit.ex:168 — lib/optimal_system_agent/verify/post_edit.ex:168-173 | lib/optimal_system_agent/verify/post_edit.ex:227-232 — These two members are one piece of code written twice and then edited apart: 6 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.
  • Edited copy of a member (6 corresponding lines) lib/optimal_system_agent/channels/cli/computer_use_dispatch.ex:205 — lib/optimal_system_agent/channels/cli/computer_use_dispatch.ex:205-210 | lib/optimal_system_agent/tools/builtins/computer_use/executor.ex:253-258 — These two members are one piece of code written twice and then edited apart: 6 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.
  • Edited copy of a member (6 corresponding lines) lib/optimal_system_agent/security/anomaly_queue.ex:111 — lib/optimal_system_agent/security/anomaly_queue.ex:111-119 | lib/optimal_system_agent/security/evidence.ex:54-59 — These two members are one piece of code written twice and then edited apart: 6 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.
  • Edited copy of a member (6 corresponding lines) lib/optimal_system_agent/tools/builtins/tool_search/handler.ex:44 — lib/optimal_system_agent/tools/builtins/tool_search/handler.ex:44-50 | lib/optimal_system_agent/tools/builtins/tool_search/handler.ex:74-79 — These two members are one piece of code written twice and then edited apart: 6 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.
  • Edited copy of a member (6 corresponding lines) lib/optimal_system_agent/cli/setup.ex:867 — lib/optimal_system_agent/cli/setup.ex:867-874 | lib/optimal_system_agent/cli/setup.ex:886-891 — These two members are one piece of code written twice and then edited apart: 6 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.
  • Edited copy of a member (6 corresponding lines) lib/optimal_system_agent/agent/safety/classifier.ex:64 — lib/optimal_system_agent/agent/safety/classifier.ex:64-71 | lib/optimal_system_agent/agent/safety/dangerous_commands.ex:351-356 — These two members are one piece of code written twice and then edited apart: 6 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.
  • Edited copy of a member (6 corresponding lines) lib/optimal_system_agent/agent/tasks/workflow.ex:278 — lib/optimal_system_agent/agent/tasks/workflow.ex:278-283 | lib/optimal_system_agent/agent/workflow.ex:213-219 — These two members are one piece of code written twice and then edited apart: 6 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.
  • Edited copy of a member (6 corresponding lines) lib/optimal_system_agent/config_file.ex:358 — lib/optimal_system_agent/config_file.ex:358-363 | lib/optimal_system_agent/security/validation_result.ex:208-213 — These two members are one piece of code written twice and then edited apart: 6 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.
  • Edited copy of a member (6 corresponding lines) lib/optimal_system_agent/agent/compactor.ex:464 — lib/optimal_system_agent/agent/compactor.ex:464-469 | lib/optimal_system_agent/tools/conflict_scope.ex:356-361 — These two members are one piece of code written twice and then edited apart: 6 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.
  • Edited copy of a member (6 corresponding lines) lib/optimal_system_agent/agent/fleet.ex:874 — lib/optimal_system_agent/agent/fleet.ex:874-879 | lib/optimal_system_agent/orchestrator.ex:3441-3446 — These two members are one piece of code written twice and then edited apart: 6 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.
  • Edited copy of a member (6 corresponding lines) lib/optimal_system_agent/providers/anthropic.ex:1864 — lib/optimal_system_agent/providers/anthropic.ex:1864-1869 | lib/optimal_system_agent/providers/bedrock.ex:962-967 — These two members are one piece of code written twice and then edited apart: 6 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.
  • Edited copy of a member (6 corresponding lines) lib/optimal_system_agent/agent/loop.ex:2114 — lib/optimal_system_agent/agent/loop.ex:2114-2123 | lib/optimal_system_agent/agent/loop/react_loop.ex:3559-3564 — These two members are one piece of code written twice and then edited apart: 6 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.
  • Edited copy of a member (6 corresponding lines) lib/optimal_system_agent/providers/catalog.ex:303 — lib/optimal_system_agent/providers/catalog.ex:303-309 | lib/optimal_system_agent/providers/model_limits.ex:122-127 — These two members are one piece of code written twice and then edited apart: 6 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.
  • Edited copy of a member (6 corresponding lines) lib/optimal_system_agent/bench/workspace.ex:156 — lib/optimal_system_agent/bench/workspace.ex:156-161 | lib/optimal_system_agent/security/code_fix_pr.ex:210-217 — These two members are one piece of code written twice and then edited apart: 6 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.
  • Edited copy of a member (6 corresponding lines) lib/optimal_system_agent/cli/auth.ex:147 — lib/optimal_system_agent/cli/auth.ex:147-152 | lib/optimal_system_agent/usage.ex:506-512 — These two members are one piece of code written twice and then edited apart: 6 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.
  • Edited copy of a member (6 corresponding lines) lib/optimal_system_agent/providers/catalog.ex:957 — lib/optimal_system_agent/providers/catalog.ex:957-963 | lib/optimal_system_agent/workspace/trust.ex:488-493 — These two members are one piece of code written twice and then edited apart: 6 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.
  • Edited copy of a member (6 corresponding lines) priv/rust/tui/src/app/commands.rs:1189 — priv/rust/tui/src/app/commands.rs:1189-1194 | priv/rust/tui/src/app/handle_actions.rs:1597-1602 — These two members are one piece of code written twice and then edited apart: 6 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.
  • Edited copy of a member (6 corresponding lines) lib/optimal_system_agent/agent/permission_mode.ex:74 — lib/optimal_system_agent/agent/permission_mode.ex:74-80 | lib/optimal_system_agent/verification/upstream_verifier.ex:139-144 — These two members are one piece of code written twice and then edited apart: 6 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.
  • Edited copy of a member (6 corresponding lines) lib/optimal_system_agent/agent/run_store.ex:461 — lib/optimal_system_agent/agent/run_store.ex:461-466 | lib/optimal_system_agent/security/shadow_graph.ex:72-77 — These two members are one piece of code written twice and then edited apart: 6 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.
  • Edited copy of a member (6 corresponding lines) bench/headtohead/report_h2h.py:584 — bench/headtohead/report_h2h.py:584-589 | bench/swebench/report.py:753-758 — These two members are one piece of code written twice and then edited apart: 6 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.
  • Edited copy of a member (6 corresponding lines) lib/optimal_system_agent/sandbox/miosa.ex:202 — lib/optimal_system_agent/sandbox/miosa.ex:202-207 | lib/optimal_system_agent/sandbox/miosa_cli.ex:215-222 — These two members are one piece of code written twice and then edited apart: 6 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.
  • Edited copy of a member (6 corresponding lines) bench/scaffold/paired.py:64 — bench/scaffold/paired.py:64-69 | bench/swebenchpro/ablation.py:53-61 — These two members are one piece of code written twice and then edited apart: 6 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.
  • Edited copy of a member (6 corresponding lines) bench/headtohead/attribution.py:209 — bench/headtohead/attribution.py:209-214 | bench/terminalbench/report.py:116-125 — These two members are one piece of code written twice and then edited apart: 6 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 · Duplicated block (6 lines × 2) · ×24
  • Duplicated block (6 lines × 2) lib/optimal_system_agent/agent/scheduler/persistence.ex:156 — lib/optimal_system_agent/agent/scheduler/persistence.ex:156-161 | lib/optimal_system_agent/agent/scheduler/persistence.ex:182-188 — 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:260 — REDACTED:260-265 | lib/optimal_system_agent/auth/providers/xai.ex:203-208 — before extracting anything, compare `REDACTED` and `lib/optimal_system_agent/auth/providers/xai.ex` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 82 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 before the matched lines, `REDACTED:254` calls `normalize` and `lib/optimal_system_agent/auth/providers/xai.ex:197` 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) lib/optimal_system_agent/agent/attendance.ex:345 — lib/optimal_system_agent/agent/attendance.ex:345-350 | lib/optimal_system_agent/agent/fleet/settings_coverage.ex:182-187 — 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 `lib/optimal_system_agent/agent/attendance.ex:345` 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) lib/optimal_system_agent/agent/loop.ex:2349 — lib/optimal_system_agent/agent/loop.ex:2349-2354 | lib/optimal_system_agent/agent/loop/react_loop.ex:4407-4412 — 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) lib/optimal_system_agent/agent/tasks/workflow.ex:562 — lib/optimal_system_agent/agent/tasks/workflow.ex:562-567 | lib/optimal_system_agent/agent/workflow.ex:797-802 — before extracting anything, compare `lib/optimal_system_agent/agent/tasks/workflow.ex` and `lib/optimal_system_agent/agent/workflow.ex` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 285 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) lib/optimal_system_agent/agent/tasks/workflow.ex:571 — lib/optimal_system_agent/agent/tasks/workflow.ex:571-576 | lib/optimal_system_agent/agent/workflow.ex:806-811 — before extracting anything, compare `lib/optimal_system_agent/agent/tasks/workflow.ex` and `lib/optimal_system_agent/agent/workflow.ex` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 285 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) lib/optimal_system_agent/git.ex:226 — lib/optimal_system_agent/git.ex:226-231 | lib/optimal_system_agent/workspace/topology.ex:714-719 — 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 `lib/optimal_system_agent/git.ex:226` 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) lib/optimal_system_agent/open_computers/executor/direct/desktop/macos.ex:116 — lib/optimal_system_agent/open_computers/executor/direct/desktop/macos.ex:116-121 | lib/optimal_system_agent/open_computers/executor/direct/desktop/windows.ex:113-118 — before extracting anything, compare `lib/optimal_system_agent/open_computers/executor/direct/desktop/macos.ex` and `lib/optimal_system_agent/open_computers/executor/direct/desktop/windows.ex` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 66 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 `lib/optimal_system_agent/open_computers/executor/direct/desktop/macos.ex:116` 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) lib/optimal_system_agent/local_models.ex:620 — lib/optimal_system_agent/local_models.ex:620-625 | lib/optimal_system_agent/miosa/platform.ex:79-84 — 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) lib/optimal_system_agent/tools/builtins/task_write/handler.ex:23 — lib/optimal_system_agent/tools/builtins/task_write/handler.ex:23-28 | lib/optimal_system_agent/tools/builtins/team_tasks/handler.ex:20-25 — 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) lib/miosa/shims.ex:1157 — lib/miosa/shims.ex:1157-1162 | lib/optimal_system_agent/signal/signal.ex:51-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.
  • Duplicated block (6 lines × 2) priv/rust/tui/src/app/handle_actions.rs:1003 — priv/rust/tui/src/app/handle_actions.rs:1003-1009 | priv/rust/tui/src/app/handle_dialogs.rs:363-368 — 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 `priv/rust/tui/src/app/handle_actions.rs:1003` 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) priv/rust/tui/src/clipboard.rs:233 — priv/rust/tui/src/clipboard.rs:233-238 | priv/rust/tui/src/components/osc8.rs:229-236 — 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 `priv/rust/tui/src/clipboard.rs: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.
  • Duplicated block (6 lines × 2) priv/rust/tui/src/dialogs/model_picker.rs:1619 — priv/rust/tui/src/dialogs/model_picker.rs:1619-1624 | priv/rust/tui/src/dialogs/model_picker.rs:2003-2008 — 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 `priv/rust/tui/src/dialogs/model_picker.rs:1619` 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) priv/rust/tui/src/dialogs/model_picker.rs:2551 — priv/rust/tui/src/dialogs/model_picker.rs:2551-2556 | priv/rust/tui/src/dialogs/onboarding.rs:614-621 — 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 `priv/rust/tui/src/dialogs/model_picker.rs:2551` 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) priv/rust/tui/src/dialogs/skills_browser.rs:178 — priv/rust/tui/src/dialogs/skills_browser.rs:178-183 | priv/rust/tui/src/dialogs/tools_browser.rs:168-173 — before extracting anything, compare `priv/rust/tui/src/dialogs/skills_browser.rs` and `priv/rust/tui/src/dialogs/tools_browser.rs` as WHOLE FILES: this scan already matched 22 separate duplicated blocks between them, totalling at least 301 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 `priv/rust/tui/src/dialogs/skills_browser.rs:178` 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) priv/rust/tui/src/dialogs/file_picker.rs:148 — priv/rust/tui/src/dialogs/file_picker.rs:148-153 | priv/rust/tui/src/dialogs/sessions.rs:117-122 — before extracting anything, compare `priv/rust/tui/src/dialogs/file_picker.rs` and `priv/rust/tui/src/dialogs/sessions.rs` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 97 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 (6 lines × 2) priv/rust/tui/src/voice/transcribe.rs:581 — priv/rust/tui/src/voice/transcribe.rs:581-586 | priv/rust/tui/src/voice/transcribe.rs:645-650 — 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 `priv/rust/tui/src/voice/transcribe.rs:581` 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) priv/rust/tui/src/app/update.rs:697 — priv/rust/tui/src/app/update.rs:697-702 | priv/rust/tui/src/app/update.rs:776-781 — 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 `priv/rust/tui/src/app/update.rs:697` 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) priv/rust/tui/src/components/completion_panel.rs:177 — priv/rust/tui/src/components/completion_panel.rs:177-182 | priv/rust/tui/src/components/completion_panel.rs:197-202 — 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 `priv/rust/tui/src/components/completion_panel.rs:177` 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) bench/bus_bench.exs:16 — bench/bus_bench.exs:16-21 | bench/goldrush_bench.exs:17-22 — 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 (6 lines × 2) bench/swebench/run_bench.py:293 — bench/swebench/run_bench.py:293-298 | bench/swebenchpro/run_bench.py:106-113 — `bench/swebench/run_bench.py` and `bench/swebenchpro/run_bench.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 202 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) bench/recoverybench/delta_report.py:620 — bench/recoverybench/delta_report.py:620-625 | bench/terminalbench/report.py:1362-1367 — 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 (6 lines × 2) bench/swebench/run_bench.py:541 — bench/swebench/run_bench.py:541-546 | bench/swebenchpro/run_bench.py:404-409 — `bench/swebench/run_bench.py` and `bench/swebenchpro/run_bench.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 202 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 `bench/swebench/run_bench.py:541` 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, `bench/swebench/run_bench.py:547` calls `log` and `bench/swebenchpro/run_bench.py:410` 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 · Edited copy of a member (13 corresponding lines) · ×23
  • Edited copy of a member (13 corresponding lines) canopy/backend/lib/canopy/work.ex:11 — canopy/backend/lib/canopy/work.ex:11-23 | canopy/backend/lib/canopy_web/controllers/issue_controller.ex:9-45 — These two members are one piece of code written twice and then edited apart: 13 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.
  • Edited copy of a member (13 corresponding lines) lib/optimal_system_agent/agent/task_tracker.ex:635 — lib/optimal_system_agent/agent/task_tracker.ex:635-647 | lib/optimal_system_agent/agent/tasks/tracker.ex:553-566 — These two members are one piece of code written twice and then edited apart: 13 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.
  • Edited copy of a member (13 corresponding lines) lib/optimal_system_agent/security/shadow_graph.ex:359 — lib/optimal_system_agent/security/shadow_graph.ex:359-371 | lib/optimal_system_agent/security/shadow_graph.ex:375-387 — These two members are one piece of code written twice and then edited apart: 13 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.
  • Edited copy of a member (13 corresponding lines) priv/rust/tui/src/tools/diagnostics.rs:170 — priv/rust/tui/src/tools/diagnostics.rs:170-182 | priv/rust/tui/src/tools/todos.rs:175-197 — These two members are one piece of code written twice and then edited apart: 13 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.
  • Edited copy of a member (13 corresponding lines) canopy/backend/lib/canopy/costs.ex:57 — canopy/backend/lib/canopy/costs.ex:57-69 | canopy/backend/lib/canopy_web/controllers/cost_controller.ex:83-98 — These two members are one piece of code written twice and then edited apart: 13 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.
  • Edited copy of a member (13 corresponding lines) lib/optimal_system_agent/providers/image_budget.ex:450 — lib/optimal_system_agent/providers/image_budget.ex:450-462 | lib/optimal_system_agent/providers/image_budget.ex:889-904 — These two members are one piece of code written twice and then edited apart: 13 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.
  • Edited copy of a member (13 corresponding lines) lib/optimal_system_agent/tools/builtins/github.ex:191 — lib/optimal_system_agent/tools/builtins/github.ex:191-204 | lib/optimal_system_agent/tools/builtins/github.ex:252-264 — These two members are one piece of code written twice and then edited apart: 13 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.
  • Edited copy of a member (13 corresponding lines) priv/rust/tui/src/tools/mod.rs:248 — priv/rust/tui/src/tools/mod.rs:248-265 | priv/rust/tui/src/tools/mod.rs:596-608 — These two members are one piece of code written twice and then edited apart: 13 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.
  • Edited copy of a member (13 corresponding lines) lib/optimal_system_agent/agent/tasks/persistence.ex:46 — lib/optimal_system_agent/agent/tasks/persistence.ex:46-58 | lib/optimal_system_agent/agent/workflow.ex:688-705 — These two members are one piece of code written twice and then edited apart: 13 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.
  • Edited copy of a member (13 corresponding lines) lib/optimal_system_agent/providers/registry.ex:177 — lib/optimal_system_agent/providers/registry.ex:177-189 | lib/optimal_system_agent/providers/registry.ex:333-348 — These two members are one piece of code written twice and then edited apart: 13 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.
  • Edited copy of a member (13 corresponding lines) lib/optimal_system_agent/shell/background_tracker.ex:77 — lib/optimal_system_agent/shell/background_tracker.ex:77-90 | lib/optimal_system_agent/shell/background_tracker.ex:137-149 — These two members are one piece of code written twice and then edited apart: 13 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.
  • Edited copy of a member (13 corresponding lines) lib/optimal_system_agent/tools/builtins/ask_user/tool.ex:37 — lib/optimal_system_agent/tools/builtins/ask_user/tool.ex:37-55 | lib/optimal_system_agent/tools/builtins/vault_sleep.ex:21-33 — These two members are one piece of code written twice and then edited apart: 13 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.
  • Edited copy of a member (13 corresponding lines) lib/optimal_system_agent/skin/loader.ex:17 — lib/optimal_system_agent/skin/loader.ex:17-33 | lib/optimal_system_agent/tools/registry/command_loader.ex:46-58 — These two members are one piece of code written twice and then edited apart: 13 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.
  • Edited copy of a member (13 corresponding lines) canopy/backend/lib/canopy/agents.ex:82 — canopy/backend/lib/canopy/agents.ex:82-94 | canopy/backend/lib/canopy_web/controllers/agent_controller.ex:203-218 — These two members are one piece of code written twice and then edited apart: 13 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.
  • Edited copy of a member (13 corresponding lines) lib/optimal_system_agent/auth/providers/copilot.ex:210 — lib/optimal_system_agent/auth/providers/copilot.ex:210-222 | lib/optimal_system_agent/auth/providers/openai_codex.ex:282-294 — These two members are one piece of code written twice and then edited apart: 13 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.
  • Edited copy of a member (13 corresponding lines) lib/optimal_system_agent/prompt_loader.ex:192 — lib/optimal_system_agent/prompt_loader.ex:192-204 | lib/optimal_system_agent/soul.ex:762-776 — These two members are one piece of code written twice and then edited apart: 13 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.
  • Edited copy of a member (13 corresponding lines) priv/rust/tui/src/app/update.rs:617 — priv/rust/tui/src/app/update.rs:617-629 | priv/rust/tui/src/app/update.rs:633-645 — These two members are one piece of code written twice and then edited apart: 13 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.
  • Edited copy of a member (13 corresponding lines) lib/optimal_system_agent/tools/builtins/computer_use/adapters/windows.ex:253 — lib/optimal_system_agent/tools/builtins/computer_use/adapters/windows.ex:253-265 | lib/optimal_system_agent/tools/builtins/computer_use/adapters/windows.ex:269-281 — These two members are one piece of code written twice and then edited apart: 13 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.
  • Edited copy of a member (13 corresponding lines) lib/optimal_system_agent/events/tui_forwarder.ex:116 — lib/optimal_system_agent/events/tui_forwarder.ex:116-128 | lib/optimal_system_agent/orchestrator.ex:3786-3800 — These two members are one piece of code written twice and then edited apart: 13 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.
  • Edited copy of a member (13 corresponding lines) priv/rust/tui/src/dialogs/permissions_manager.rs:97 — priv/rust/tui/src/dialogs/permissions_manager.rs:97-110 | priv/rust/tui/src/tools/diagnostics.rs:156-168 — These two members are one piece of code written twice and then edited apart: 13 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.
  • Edited copy of a member (13 corresponding lines) lib/optimal_system_agent/security/login_session.ex:129 — lib/optimal_system_agent/security/login_session.ex:129-141 | lib/optimal_system_agent/security/login_session.ex:286-298 — These two members are one piece of code written twice and then edited apart: 13 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.
  • Edited copy of a member (13 corresponding lines) lib/optimal_system_agent/tools/builtins/delegate/handler.ex:53 — lib/optimal_system_agent/tools/builtins/delegate/handler.ex:53-67 | lib/optimal_system_agent/tools/builtins/fleet/handler.ex:72-84 — These two members are one piece of code written twice and then edited apart: 13 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.
  • Edited copy of a member (13 corresponding lines) bench/terminalbench/failure_shape.py:112 — bench/terminalbench/failure_shape.py:112-124 | scripts/engagement_replay.py:143-155 — These two members are one piece of code written twice and then edited apart: 13 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 (7 corresponding lines) · ×22
  • Edited copy of a member (7 corresponding lines) lib/optimal_system_agent/agent/loop/goal_tracker.ex:1187 — lib/optimal_system_agent/agent/loop/goal_tracker.ex:1187-1193 | lib/optimal_system_agent/agent/loop/spot_check_auditor.ex:251-257 — These two members are one piece of code written twice and then edited apart: 7 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.
  • Edited copy of a member (7 corresponding lines) lib/optimal_system_agent/providers/image_budget.ex:620 — lib/optimal_system_agent/providers/image_budget.ex:620-626 | lib/optimal_system_agent/providers/image_budget.ex:640-646 — These two members are one piece of code written twice and then edited apart: 7 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.
  • Edited copy of a member (7 corresponding lines) priv/rust/tui/src/client/http.rs:320 — priv/rust/tui/src/client/http.rs:320-326 | priv/rust/tui/src/client/http.rs:564-572 — These two members are one piece of code written twice and then edited apart: 7 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.
  • Edited copy of a member (7 corresponding lines) priv/rust/tui/src/client/http.rs:285 — priv/rust/tui/src/client/http.rs:285-291 | priv/rust/tui/src/client/http.rs:310-316 — These two members are one piece of code written twice and then edited apart: 7 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.
  • Edited copy of a member (7 corresponding lines) lib/optimal_system_agent/agent/execution_control.ex:178 — lib/optimal_system_agent/agent/execution_control.ex:178-187 | lib/optimal_system_agent/agent/execution_control.ex:191-197 — These two members are one piece of code written twice and then edited apart: 7 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.
  • Edited copy of a member (7 corresponding lines) priv/rust/tui/src/components/agents/mod.rs:562 — priv/rust/tui/src/components/agents/mod.rs:562-568 | priv/rust/tui/src/components/agents/mod.rs:572-581 — These two members are one piece of code written twice and then edited apart: 7 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.
  • Edited copy of a member (7 corresponding lines) lib/optimal_system_agent/agent/step_snapshot.ex:496 — lib/optimal_system_agent/agent/step_snapshot.ex:496-502 | lib/optimal_system_agent/security/ci_scan.ex:255-262 — These two members are one piece of code written twice and then edited apart: 7 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.
  • Edited copy of a member (7 corresponding lines) lib/optimal_system_agent/agent/compactor.ex:2174 — lib/optimal_system_agent/agent/compactor.ex:2174-2180 | lib/optimal_system_agent/store/session_transcript.ex:280-288 — These two members are one piece of code written twice and then edited apart: 7 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.
  • Edited copy of a member (7 corresponding lines) lib/optimal_system_agent/agent/run_store.ex:605 — lib/optimal_system_agent/agent/run_store.ex:605-615 | lib/optimal_system_agent/scratchpad.ex:153-159 — These two members are one piece of code written twice and then edited apart: 7 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.
  • Edited copy of a member (7 corresponding lines) lib/optimal_system_agent/providers/openai_compat.ex:475 — lib/optimal_system_agent/providers/openai_compat.ex:475-481 | lib/optimal_system_agent/providers/openai_responses.ex:162-169 — These two members are one piece of code written twice and then edited apart: 7 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.
  • Edited copy of a member (7 corresponding lines) lib/optimal_system_agent/agent/workflow.ex:410 — lib/optimal_system_agent/agent/workflow.ex:410-424 | lib/optimal_system_agent/agent/tasks/workflow.ex:216-222 — These two members are one piece of code written twice and then edited apart: 7 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.
  • Edited copy of a member (7 corresponding lines) lib/optimal_system_agent/agent/task_tracker.ex:556 — lib/optimal_system_agent/agent/task_tracker.ex:556-563 | lib/optimal_system_agent/agent/tasks/tracker.ex:624-630 — These two members are one piece of code written twice and then edited apart: 7 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.
  • Edited copy of a member (7 corresponding lines) lib/optimal_system_agent/providers/claude_cli.ex:254 — lib/optimal_system_agent/providers/claude_cli.ex:254-262 | lib/optimal_system_agent/providers/copilot_cli.ex:216-222 — These two members are one piece of code written twice and then edited apart: 7 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.
  • Edited copy of a member (7 corresponding lines) lib/optimal_system_agent/tools/builtins/code_symbols/handler.ex:547 — lib/optimal_system_agent/tools/builtins/code_symbols/handler.ex:547-553 | lib/optimal_system_agent/tools/builtins/repo_map.ex:198-204 — These two members are one piece of code written twice and then edited apart: 7 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.
  • Edited copy of a member (7 corresponding lines) lib/optimal_system_agent/agent/loop/proactive_compaction.ex:1017 — lib/optimal_system_agent/agent/loop/proactive_compaction.ex:1017-1023 | lib/optimal_system_agent/memory/flush.ex:581-587 — These two members are one piece of code written twice and then edited apart: 7 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.
  • Edited copy of a member (7 corresponding lines) lib/optimal_system_agent/agent/loop/tool_arg_metrics.ex:193 — lib/optimal_system_agent/agent/loop/tool_arg_metrics.ex:193-199 | lib/optimal_system_agent/agent/loop/verification_gate.ex:652-658 — These two members are one piece of code written twice and then edited apart: 7 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.
  • Edited copy of a member (7 corresponding lines) lib/optimal_system_agent/providers/ollama.ex:1906 — lib/optimal_system_agent/providers/ollama.ex:1906-1912 | lib/optimal_system_agent/providers/registry.ex:2609-2615 — These two members are one piece of code written twice and then edited apart: 7 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.
  • Edited copy of a member (7 corresponding lines) canopy/backend/lib/canopy_web/controllers/comment_controller.ex:43 — canopy/backend/lib/canopy_web/controllers/comment_controller.ex:43-50 | canopy/backend/lib/canopy_web/controllers/issue_controller.ex:189-195 — These two members are one piece of code written twice and then edited apart: 7 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.
  • Edited copy of a member (7 corresponding lines) lib/miosa/shims.ex:74 — lib/miosa/shims.ex:74-80 | lib/optimal_system_agent/tools/instruction.ex:34-40 — These two members are one piece of code written twice and then edited apart: 7 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.
  • Edited copy of a member (7 corresponding lines) lib/optimal_system_agent/agent/scheduler/sqlite_store.ex:23 — lib/optimal_system_agent/agent/scheduler/sqlite_store.ex:23-29 | lib/optimal_system_agent/system/erlexec.ex:117-128 — These two members are one piece of code written twice and then edited apart: 7 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.
  • Edited copy of a member (7 corresponding lines) lib/optimal_system_agent/tools/builtins/security_intel.ex:604 — lib/optimal_system_agent/tools/builtins/security_intel.ex:604-610 | lib/optimal_system_agent/tools/builtins/wallet_ops.ex:53-59 — These two members are one piece of code written twice and then edited apart: 7 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.
  • Edited copy of a member (7 corresponding lines) bench/recoverybench/run_bench.py:93 — bench/recoverybench/run_bench.py:93-99 | REDACTED:162-168 — These two members are one piece of code written twice and then edited apart: 7 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 (14 corresponding lines) · ×19
  • Edited copy of a member (14 corresponding lines) lib/optimal_system_agent/tools/builtins/codebase_explore.ex:224 — lib/optimal_system_agent/tools/builtins/codebase_explore.ex:224-237 | lib/optimal_system_agent/tools/registry/search.ex:167-182 — These two members are one piece of code written twice and then edited apart: 14 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.
  • Edited copy of a member (14 corresponding lines) lib/optimal_system_agent/agent/task_tracker.ex:618 — lib/optimal_system_agent/agent/task_tracker.ex:618-631 | lib/optimal_system_agent/agent/tasks/tracker.ex:534-548 — These two members are one piece of code written twice and then edited apart: 14 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.
  • Edited copy of a member (14 corresponding lines) lib/optimal_system_agent/workspace/topology.ex:555 — lib/optimal_system_agent/workspace/topology.ex:555-573 | lib/optimal_system_agent/workspace/topology.ex:597-610 — These two members are one piece of code written twice and then edited apart: 14 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.
  • Edited copy of a member (14 corresponding lines) lib/optimal_system_agent/agent/workflow.ex:323 — lib/optimal_system_agent/agent/workflow.ex:323-336 | lib/optimal_system_agent/agent/workflow.ex:341-354 — These two members are one piece of code written twice and then edited apart: 14 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.
  • Edited copy of a member (14 corresponding lines) lib/optimal_system_agent/tools/pipeline.ex:56 — lib/optimal_system_agent/tools/pipeline.ex:56-71 | lib/optimal_system_agent/tools/pipeline.ex:80-93 — These two members are one piece of code written twice and then edited apart: 14 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.
  • Edited copy of a member (14 corresponding lines) lib/optimal_system_agent/channels/cli/commands.ex:1753 — lib/optimal_system_agent/channels/cli/commands.ex:1753-1766 | lib/optimal_system_agent/channels/cli/commands.ex:1883-1913 — These two members are one piece of code written twice and then edited apart: 14 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.
  • Edited copy of a member (14 corresponding lines) lib/optimal_system_agent/tools/builtins/file_grep/handler.ex:303 — lib/optimal_system_agent/tools/builtins/file_grep/handler.ex:303-316 | lib/optimal_system_agent/tools/builtins/tool_search/handler.ex:230-247 — These two members are one piece of code written twice and then edited apart: 14 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.
  • Edited copy of a member (14 corresponding lines) lib/optimal_system_agent/agent/tasks/workflow.ex:176 — lib/optimal_system_agent/agent/tasks/workflow.ex:176-189 | lib/optimal_system_agent/agent/tasks/workflow.ex:195-208 — These two members are one piece of code written twice and then edited apart: 14 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.
  • Edited copy of a member (14 corresponding lines) canopy/backend/lib/canopy_web/controllers/goal_controller.ex:43 — canopy/backend/lib/canopy_web/controllers/goal_controller.ex:43-57 | canopy/backend/lib/canopy_web/controllers/workspace_controller.ex:54-67 — These two members are one piece of code written twice and then edited apart: 14 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.
  • Edited copy of a member (14 corresponding lines) lib/optimal_system_agent/workspace/store.ex:74 — lib/optimal_system_agent/workspace/store.ex:74-91 | lib/optimal_system_agent/workspace/store.ex:183-196 — These two members are one piece of code written twice and then edited apart: 14 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.
  • Edited copy of a member (14 corresponding lines) lib/optimal_system_agent/tools/builtins/message_agent/handler.ex:21 — lib/optimal_system_agent/tools/builtins/message_agent/handler.ex:21-34 | lib/optimal_system_agent/tools/builtins/scratchpad/handler.ex:53-66 — These two members are one piece of code written twice and then edited apart: 14 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.
  • Edited copy of a member (14 corresponding lines) lib/optimal_system_agent/miosa/mcp.ex:87 — lib/optimal_system_agent/miosa/mcp.ex:87-100 | lib/optimal_system_agent/tools/builtins/notebook_edit/handler.ex:257-270 — These two members are one piece of code written twice and then edited apart: 14 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.
  • Edited copy of a member (14 corresponding lines) lib/optimal_system_agent/channels/http/api/protocol_routes.ex:80 — lib/optimal_system_agent/channels/http/api/protocol_routes.ex:80-93 | lib/optimal_system_agent/channels/http/api/protocol_routes.ex:97-111 — These two members are one piece of code written twice and then edited apart: 14 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.
  • Edited copy of a member (14 corresponding lines) canopy/backend/lib/canopy_web/controllers/agent_controller.ex:250 — canopy/backend/lib/canopy_web/controllers/agent_controller.ex:250-266 | canopy/backend/lib/canopy_web/controllers/workspace_controller.ex:200-213 — These two members are one piece of code written twice and then edited apart: 14 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.
  • Edited copy of a member (14 corresponding lines) canopy/backend/lib/canopy/agents.ex:18 — canopy/backend/lib/canopy/agents.ex:18-31 | canopy/backend/lib/canopy/work.ex:31-44 — These two members are one piece of code written twice and then edited apart: 14 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.
  • Edited copy of a member (14 corresponding lines) priv/rust/tui/src/components/chat/message.rs:238 — priv/rust/tui/src/components/chat/message.rs:238-251 | priv/rust/tui/src/components/chat/mod.rs:565-578 — These two members are one piece of code written twice and then edited apart: 14 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.
  • Edited copy of a member (14 corresponding lines) lib/optimal_system_agent/providers/deepseek_models.ex:331 — lib/optimal_system_agent/providers/deepseek_models.ex:331-344 | lib/optimal_system_agent/providers/zai_models.ex:490-503 — These two members are one piece of code written twice and then edited apart: 14 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.
  • Edited copy of a member (14 corresponding lines) lib/optimal_system_agent/agent/fleet.ex:755 — lib/optimal_system_agent/agent/fleet.ex:755-768 | lib/optimal_system_agent/agent/fleet.ex:795-816 — These two members are one piece of code written twice and then edited apart: 14 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.
  • Edited copy of a member (14 corresponding lines) lib/optimal_system_agent/file_locking/intent_broadcaster.ex:65 — lib/optimal_system_agent/file_locking/intent_broadcaster.ex:65-82 | lib/optimal_system_agent/team.ex:233-246 — These two members are one piece of code written twice and then edited apart: 14 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.
D2 · Cognitive Complexity · App · ×18
  • App::handle_backend_event (cognitive 629) priv/rust/tui/src/app/handle_backend.rs:141 — App::handle_backend_event has cognitive complexity 629 (threshold 15). Drivers by points: if/else 210 (452 pts), match/switch 70 (154 pts), boolean chains 15, loops 3 (8 pts) (nesting depth added 331). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • App::handle_command (cognitive 146) priv/rust/tui/src/app/commands.rs:128 — App::handle_command has cognitive complexity 146 (threshold 15). Drivers by points: if/else 76 (118 pts), match/switch 9 (16 pts), boolean chains 6, loops 2 (6 pts) (nesting depth added 53). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • App::run (cognitive 145) priv/rust/tui/src/app/event_loop.rs:826 — App::run has cognitive complexity 145 (threshold 15). Drivers by points: if/else 44 (98 pts), match/switch 5 (17 pts), boolean chains 15, loops 6 (15 pts) (nesting depth added 75). Of this number, 139 points are the body's own statements and 6 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • App::draw (cognitive 139) priv/rust/tui/src/app/event_loop.rs:1839 — App::draw has cognitive complexity 139 (threshold 15). Drivers by points: if/else 33 (130 pts), match/switch 3 (9 pts) (nesting depth added 103). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • App::handle_tick (cognitive 53) priv/rust/tui/src/app/update.rs:1610 — App::handle_tick has cognitive complexity 53 (threshold 15). Drivers by points: if/else 19 (52 pts), boolean chains 1 (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.
  • App::handle_agent_response (cognitive 37) priv/rust/tui/src/app/handle_actions.rs:239 — App::handle_agent_response has cognitive complexity 37 (threshold 15). Drivers by points: if/else 21 (31 pts), boolean chains 3, match/switch 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.
  • App::handle_command_result (cognitive 36) priv/rust/tui/src/app/handle_actions.rs:543 — App::handle_command_result has cognitive complexity 36 (threshold 15). Drivers by points: if/else 13 (33 pts), match/switch 2 (3 pts) (nesting depth added 21). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • App::handle_idle_key (cognitive 32) priv/rust/tui/src/app/update.rs:1026 — App::handle_idle_key has cognitive complexity 32 (threshold 15). Drivers by points: if/else 16 (25 pts), boolean chains 4, match/switch 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.
  • App::dispatch_event (cognitive 30) priv/rust/tui/src/app/event_loop.rs:1676 — App::dispatch_event has cognitive complexity 30 (threshold 15). Drivers by points: if/else 11 (25 pts), loops 1 (4 pts), boolean chains 1 (nesting depth added 17). 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.
  • App::handle_onboarding_key (cognitive 29) priv/rust/tui/src/app/handle_dialogs.rs:225 — App::handle_onboarding_key has cognitive complexity 29 (threshold 15). Drivers by points: if/else 7 (17 pts), match/switch 3 (12 pts) (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.
  • App::handle_key (cognitive 29) priv/rust/tui/src/app/update.rs:239 — App::handle_key has cognitive complexity 29 (threshold 15). Drivers by points: if/else 11 (20 pts), match/switch 5 (9 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.
  • App::handle_voice_event (cognitive 27) priv/rust/tui/src/app/update.rs:1507 — App::handle_voice_event has cognitive complexity 27 (threshold 15). Drivers by points: if/else 15 (24 pts), boolean chains 2, match/switch 1 (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • App::handle_processing_key (cognitive 26) priv/rust/tui/src/app/update.rs:1242 — App::handle_processing_key has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 7, match/switch 3 (5 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.
  • App::dispatch_action (cognitive 25) priv/rust/tui/src/app/keymap_dispatch.rs:106 — App::dispatch_action has cognitive complexity 25 (threshold 15). Drivers by points: if/else 16 (24 pts), match/switch 1 (nesting depth added 8). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • App::handle_health_result (cognitive 20) priv/rust/tui/src/app/handle_actions.rs:11 — App::handle_health_result has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (19 pts), match/switch 1 (nesting depth added 10). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • App::draw_inline (cognitive 19) priv/rust/tui/src/app/event_loop.rs:2395 — App::draw_inline has cognitive complexity 19 (threshold 15). Drivers by points: if/else 13 (17 pts), boolean chains 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.
  • App::measure_bands (cognitive 18) priv/rust/tui/src/app/event_loop.rs:2289 — App::measure_bands has cognitive complexity 18 (threshold 15). Drivers by points: if/else 11 (12 pts), boolean chains 5, match/switch 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.
  • App::sync_chrome (cognitive 17) priv/rust/tui/src/app/mod.rs:1326 — App::sync_chrome has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (14 pts), match/switch 1 (2 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.
D30 · Dependency Vulnerabilities · Medium advisory (unsound) · ×18
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Edited copy of a member (15 corresponding lines) · ×18
  • Edited copy of a member (15 corresponding lines) lib/optimal_system_agent/agent/scheduler.ex:285 — lib/optimal_system_agent/agent/scheduler.ex:285-300 | lib/optimal_system_agent/agent/scheduler.ex:368-382 — These two members are one piece of code written twice and then edited apart: 15 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.
  • Edited copy of a member (15 corresponding lines) lib/optimal_system_agent/conversations/server.ex:246 — lib/optimal_system_agent/conversations/server.ex:246-260 | lib/optimal_system_agent/conversations/strategies/facilitator.ex:94-115 — These two members are one piece of code written twice and then edited apart: 15 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.
  • Edited copy of a member (15 corresponding lines) lib/optimal_system_agent/agent/tasks/workflow.ex:258 — lib/optimal_system_agent/agent/tasks/workflow.ex:258-272 | lib/optimal_system_agent/agent/workflow.ex:388-405 — These two members are one piece of code written twice and then edited apart: 15 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.
  • Edited copy of a member (15 corresponding lines) lib/optimal_system_agent/agent/budget.ex:326 — lib/optimal_system_agent/agent/budget.ex:326-340 | lib/optimal_system_agent/budget/budget.ex:267-298 — These two members are one piece of code written twice and then edited apart: 15 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.
  • Edited copy of a member (15 corresponding lines) priv/rust/tui/src/notification/inhibit.rs:54 — priv/rust/tui/src/notification/inhibit.rs:54-68 | priv/rust/tui/src/notification/sound.rs:49-63 — These two members are one piece of code written twice and then edited apart: 15 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.
  • Edited copy of a member (15 corresponding lines) canopy/backend/lib/canopy_web/controllers/session_controller.ex:150 — canopy/backend/lib/canopy_web/controllers/session_controller.ex:150-164 | lib/optimal_system_agent/event_stream.ex:115-129 — These two members are one piece of code written twice and then edited apart: 15 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.
  • Edited copy of a member (15 corresponding lines) lib/optimal_system_agent/open_computers/executor/direct/container.ex:161 — lib/optimal_system_agent/open_computers/executor/direct/container.ex:161-175 | lib/optimal_system_agent/open_computers/executor/direct/container.ex:182-196 — These two members are one piece of code written twice and then edited apart: 15 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.
  • Edited copy of a member (15 corresponding lines) lib/optimal_system_agent/agent/persisted_result.ex:76 — lib/optimal_system_agent/agent/persisted_result.ex:76-90 | lib/optimal_system_agent/mcp/config.ex:435-450 — These two members are one piece of code written twice and then edited apart: 15 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.
  • Edited copy of a member (15 corresponding lines) lib/optimal_system_agent/tools/builtins/multi_file_edit/handler.ex:365 — lib/optimal_system_agent/tools/builtins/multi_file_edit/handler.ex:365-380 | lib/optimal_system_agent/tools/builtins/structural_edit/handler.ex:464-478 — These two members are one piece of code written twice and then edited apart: 15 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.
  • Edited copy of a member (15 corresponding lines) lib/optimal_system_agent/agent/session_persistence/record_lock.ex:47 — lib/optimal_system_agent/agent/session_persistence/record_lock.ex:47-66 | lib/optimal_system_agent/agent/session_persistence/record_lock.ex:72-86 — These two members are one piece of code written twice and then edited apart: 15 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.
  • Edited copy of a member (15 corresponding lines) lib/mix/tasks/osa.setup.wizard.ex:347 — lib/mix/tasks/osa.setup.wizard.ex:347-362 | lib/mix/tasks/osa.setup.wizard.ex:386-400 — These two members are one piece of code written twice and then edited apart: 15 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.
  • Edited copy of a member (15 corresponding lines) lib/optimal_system_agent/channels/cli/session.ex:108 — lib/optimal_system_agent/channels/cli/session.ex:108-122 | lib/optimal_system_agent/channels/cli/session.ex:126-145 — These two members are one piece of code written twice and then edited apart: 15 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.
  • Edited copy of a member (15 corresponding lines) lib/optimal_system_agent/tools/builtins/brief/tool.ex:33 — lib/optimal_system_agent/tools/builtins/brief/tool.ex:33-51 | lib/optimal_system_agent/tools/builtins/vault_context.ex:18-32 — These two members are one piece of code written twice and then edited apart: 15 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.
  • Edited copy of a member (15 corresponding lines) lib/optimal_system_agent/agent/memory/episodic_store.ex:240 — lib/optimal_system_agent/agent/memory/episodic_store.ex:240-254 | lib/optimal_system_agent/store/skill_library.ex:181-196 — These two members are one piece of code written twice and then edited apart: 15 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.
  • Edited copy of a member (15 corresponding lines) lib/optimal_system_agent/agent/loop/llm_client.ex:392 — lib/optimal_system_agent/agent/loop/llm_client.ex:392-412 | lib/optimal_system_agent/agent/loop/llm_client.ex:750-764 — These two members are one piece of code written twice and then edited apart: 15 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.
  • Edited copy of a member (15 corresponding lines) lib/optimal_system_agent/tools/builtins/enter_plan_mode/handler.ex:34 — lib/optimal_system_agent/tools/builtins/enter_plan_mode/handler.ex:34-53 | lib/optimal_system_agent/tools/builtins/task_write/handler.ex:175-189 — These two members are one piece of code written twice and then edited apart: 15 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.
  • Edited copy of a member (15 corresponding lines) lib/optimal_system_agent/tools/builtins/create_agent/prompt.ex:11 — lib/optimal_system_agent/tools/builtins/create_agent/prompt.ex:11-25 | lib/optimal_system_agent/tools/builtins/list_agents/prompt.ex:11-25 — These two members are one piece of code written twice and then edited apart: 15 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.
  • Edited copy of a member (15 corresponding lines) lib/optimal_system_agent/tools/builtins/peer_claim_region/prompt.ex:13 — lib/optimal_system_agent/tools/builtins/peer_claim_region/prompt.ex:13-27 | lib/optimal_system_agent/tools/builtins/peer_negotiate_task/prompt.ex:11-25 — These two members are one piece of code written twice and then edited apart: 15 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 · Duplicated block (13 lines × 2) · ×18
  • Duplicated block (13 lines × 2) lib/optimal_system_agent/agent/loop/llm_client.ex:509 — lib/optimal_system_agent/agent/loop/llm_client.ex:509-521 | lib/optimal_system_agent/agent/loop/llm_client.ex:750-762 — 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) lib/optimal_system_agent/agent/session_persistence/record_lock.ex:47 — lib/optimal_system_agent/agent/session_persistence/record_lock.ex:47-59 | lib/optimal_system_agent/agent/session_persistence/record_lock.ex:72-84 — 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) lib/optimal_system_agent/agent/task_tracker.ex:172 — lib/optimal_system_agent/agent/task_tracker.ex:172-185 | lib/optimal_system_agent/agent/tasks/tracker.ex:53-65 — before extracting anything, compare `lib/optimal_system_agent/agent/task_tracker.ex` and `lib/optimal_system_agent/agent/tasks/tracker.ex` as WHOLE FILES: this scan already matched 7 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. 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 `lib/optimal_system_agent/agent/task_tracker.ex:172` 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 (13 lines × 2) lib/optimal_system_agent/prompt_loader.ex:192 — lib/optimal_system_agent/prompt_loader.ex:192-204 | lib/optimal_system_agent/soul.ex:764-776 — 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 (13 lines × 2) lib/optimal_system_agent/protocol/tui_schema.ex:257 — lib/optimal_system_agent/protocol/tui_schema.ex:257-269 | lib/optimal_system_agent/protocol/tui_schema.ex:356-368 — 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 `lib/optimal_system_agent/protocol/tui_schema.ex:257` 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 (13 lines × 2) lib/optimal_system_agent/providers/ollama.ex:292 — lib/optimal_system_agent/providers/ollama.ex:292-304 | lib/optimal_system_agent/providers/replicate.ex:117-129 — 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 (13 lines × 2) lib/optimal_system_agent/providers/openai_compat.ex:110 — lib/optimal_system_agent/providers/openai_compat.ex:110-122 | lib/optimal_system_agent/providers/openai_compat.ex:443-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. Read the line range as the matched WINDOW rather than a finished unit: at `lib/optimal_system_agent/providers/openai_compat.ex:110` 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 (13 lines × 2) lib/optimal_system_agent/tools/ablation/runner.ex:484 — lib/optimal_system_agent/tools/ablation/runner.ex:484-496 | lib/optimal_system_agent/tools/ablation/runner.ex: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. Read the line range as the matched WINDOW rather than a finished unit: at `lib/optimal_system_agent/tools/ablation/runner.ex:484` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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 (13 lines × 2) lib/optimal_system_agent/tools/builtins/computer_use/adapters/docker.ex:268 — lib/optimal_system_agent/tools/builtins/computer_use/adapters/docker.ex:268-280 | lib/optimal_system_agent/tools/builtins/computer_use/adapters/remote_ssh.ex:302-315 — 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 (13 lines × 2) lib/optimal_system_agent/tools/builtins/file_grep/tool.ex:46 — lib/optimal_system_agent/tools/builtins/file_grep/tool.ex:46-58 | lib/optimal_system_agent/tools/builtins/security_intel.ex:185-197 — before extracting anything, compare `lib/optimal_system_agent/tools/builtins/file_grep/tool.ex` and `lib/optimal_system_agent/tools/builtins/security_intel.ex` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 64 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 `lib/optimal_system_agent/tools/builtins/file_grep/tool.ex:46` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (13 lines × 2) lib/optimal_system_agent/tools/builtins/multi_file_edit/handler.ex:388 — lib/optimal_system_agent/tools/builtins/multi_file_edit/handler.ex:388-400 | lib/optimal_system_agent/tools/builtins/structural_edit/handler.ex:484-496 — 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) lib/optimal_system_agent/tools/builtins/file_grep/backend.ex:256 — lib/optimal_system_agent/tools/builtins/file_grep/backend.ex:256-269 | lib/optimal_system_agent/tools/legacy_adapter.ex:269-281 — 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 `lib/optimal_system_agent/tools/builtins/file_grep/backend.ex:256` 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 (13 lines × 2) priv/rust/tui/src/app/commands.rs:1133 — priv/rust/tui/src/app/commands.rs:1133-1145 | priv/rust/tui/src/app/commands.rs:1158-1170 — 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 `priv/rust/tui/src/app/commands.rs:1133` 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 first that the copies are not typed on the same thing: the declarations holding them bind `self` to `crate) fn execute_backend_command(&mut` in one and `crate) fn execute_backend_command_quiet(&mut` 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 × 2) priv/rust/tui/src/client/sse.rs:398 — priv/rust/tui/src/client/sse.rs:398-410 | priv/rust/tui/src/client/sse.rs:1569-1581 — 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 `priv/rust/tui/src/client/sse.rs:398` 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 (13 lines × 2) priv/rust/tui/src/components/activity.rs:1489 — priv/rust/tui/src/components/activity.rs:1489-1501 | priv/rust/tui/src/components/activity.rs:1519-1531 — 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 `priv/rust/tui/src/components/activity.rs:1489` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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 (13 lines × 2) priv/rust/tui/src/dialogs/mcp_approval.rs:187 — priv/rust/tui/src/dialogs/mcp_approval.rs:187-199 | priv/rust/tui/src/dialogs/trust.rs:93-105 — before extracting anything, compare `priv/rust/tui/src/dialogs/mcp_approval.rs` and `priv/rust/tui/src/dialogs/trust.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 51 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, `priv/rust/tui/src/dialogs/mcp_approval.rs:202` calls `wrap_two` and `priv/rust/tui/src/dialogs/trust.rs:108` 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 (13 lines × 2) priv/rust/tui/src/client/sse.rs:810 — priv/rust/tui/src/client/sse.rs:810-822 | priv/rust/tui/src/client/sse.rs:844-860 — 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 `priv/rust/tui/src/client/sse.rs:810` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (13 lines × 2) priv/rust/tui/src/tools/monitor.rs:35 — priv/rust/tui/src/tools/monitor.rs:35-47 | priv/rust/tui/src/tools/sleep.rs:34-46 — 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 `priv/rust/tui/src/tools/monitor.rs:35` 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 · Edited copy of a member (16 corresponding lines) · ×17
  • Edited copy of a member (16 corresponding lines) lib/optimal_system_agent/agent/safety/model_classifier.ex:169 — lib/optimal_system_agent/agent/safety/model_classifier.ex:169-187 | lib/optimal_system_agent/permissions/auto_classifier.ex:227-245 — 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.
  • Edited copy of a member (16 corresponding lines) lib/optimal_system_agent/remote/client.ex:358 — lib/optimal_system_agent/remote/client.ex:358-377 | lib/optimal_system_agent/remote/client.ex:389-404 — 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.
  • Edited copy of a member (16 corresponding lines) canopy/backend/lib/canopy/costs.ex:23 — canopy/backend/lib/canopy/costs.ex:23-38 | canopy/backend/lib/canopy_web/controllers/cost_controller.ex:43-61 — 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.
  • Edited copy of a member (16 corresponding lines) lib/optimal_system_agent/channels/http/auth.ex:43 — lib/optimal_system_agent/channels/http/auth.ex:43-58 | lib/optimal_system_agent/channels/http/auth.ex:63-78 — 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.
  • Edited copy of a member (16 corresponding lines) priv/rust/tui/src/app/handle_actions.rs:190 — priv/rust/tui/src/app/handle_actions.rs:190-205 | priv/rust/tui/src/app/handle_actions.rs:209-226 — 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.
  • Edited copy of a member (16 corresponding lines) lib/optimal_system_agent/settings.ex:600 — lib/optimal_system_agent/settings.ex:600-619 | lib/optimal_system_agent/system/json_store.ex:56-71 — 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.
  • Edited copy of a member (16 corresponding lines) lib/optimal_system_agent/shell/background_task.ex:378 — lib/optimal_system_agent/shell/background_task.ex:378-398 | lib/optimal_system_agent/tools/builtins/shell_execute/handler.ex:993-1008 — 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.
  • Edited copy of a member (16 corresponding lines) lib/optimal_system_agent/tools/builtins/scratchpad/handler.ex:85 — lib/optimal_system_agent/tools/builtins/scratchpad/handler.ex:85-102 | lib/optimal_system_agent/tools/builtins/scratchpad/handler.ex:106-121 — 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.
  • Edited copy of a member (16 corresponding lines) lib/optimal_system_agent/shell/task_output.ex:256 — lib/optimal_system_agent/shell/task_output.ex:256-271 | lib/optimal_system_agent/workspace/fast_worktree/metadata.ex:128-143 — 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.
  • Edited copy of a member (16 corresponding lines) lib/optimal_system_agent/tools/builtins/computer_use/executor.ex:354 — lib/optimal_system_agent/tools/builtins/computer_use/executor.ex:354-373 | lib/optimal_system_agent/tools/builtins/computer_use/executor.ex:377-392 — 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.
  • Edited copy of a member (16 corresponding lines) lib/optimal_system_agent/channels/cli/commands.ex:4908 — lib/optimal_system_agent/channels/cli/commands.ex:4908-4925 | lib/optimal_system_agent/channels/cli/commands.ex:4929-4944 — 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.
  • Edited copy of a member (16 corresponding lines) lib/optimal_system_agent/channels/slack.ex:197 — lib/optimal_system_agent/channels/slack.ex:197-212 | lib/optimal_system_agent/channels/telegram.ex:226-243 — 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.
  • Edited copy of a member (16 corresponding lines) lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex:69 — lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex:69-87 | lib/optimal_system_agent/open_computers/executor/direct/cluster/mlx_distributed.ex:92-107 — 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.
  • Edited copy of a member (16 corresponding lines) lib/optimal_system_agent/memory/synthesis.ex:271 — lib/optimal_system_agent/memory/synthesis.ex:271-291 | lib/optimal_system_agent/memory/synthesis.ex:296-311 — 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.
  • Edited copy of a member (16 corresponding lines) lib/optimal_system_agent/tools/builtins/codebase_explore.ex:55 — lib/optimal_system_agent/tools/builtins/codebase_explore.ex:55-75 | lib/optimal_system_agent/tools/builtins/semantic_search.ex:28-43 — 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.
  • Edited copy of a member (16 corresponding lines) lib/optimal_system_agent/agent/loop/turn_pipeline.ex:122 — lib/optimal_system_agent/agent/loop/turn_pipeline.ex:122-140 | lib/optimal_system_agent/channels/http/api/orchestrate_routes.ex:511-526 — 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.
  • Edited copy of a member (16 corresponding lines) bench/recoverybench/delta_report.py:212 — bench/recoverybench/delta_report.py:212-258 | bench/terminalbench/report.py:805-1050 — 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 (11 corresponding lines) · ×17
  • Edited copy of a member (11 corresponding lines) lib/optimal_system_agent/agent/task_tracker.ex:494 — lib/optimal_system_agent/agent/task_tracker.ex:494-504 | lib/optimal_system_agent/agent/tasks/tracker.ex:582-593 — These two members are one piece of code written twice and then edited apart: 11 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.
  • Edited copy of a member (11 corresponding lines) priv/rust/tui/src/components/status_bar.rs:192 — priv/rust/tui/src/components/status_bar.rs:192-202 | priv/rust/tui/src/util.rs:224-242 — These two members are one piece of code written twice and then edited apart: 11 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.
  • Edited copy of a member (11 corresponding lines) priv/rust/tui/src/components/input/mod.rs:1737 — priv/rust/tui/src/components/input/mod.rs:1737-1747 | priv/rust/tui/src/components/input/mod.rs:1764-1777 — These two members are one piece of code written twice and then edited apart: 11 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.
  • Edited copy of a member (11 corresponding lines) lib/optimal_system_agent/cli/prompt.ex:141 — lib/optimal_system_agent/cli/prompt.ex:141-151 | lib/optimal_system_agent/cli/prompt.ex:230-242 — These two members are one piece of code written twice and then edited apart: 11 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.
  • Edited copy of a member (11 corresponding lines) lib/optimal_system_agent/workspace/fast_worktree/populate.ex:138 — lib/optimal_system_agent/workspace/fast_worktree/populate.ex:138-149 | lib/optimal_system_agent/workspace/fast_worktree/populate.ex:405-415 — These two members are one piece of code written twice and then edited apart: 11 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.
  • Edited copy of a member (11 corresponding lines) lib/optimal_system_agent/providers/anthropic.ex:49 — lib/optimal_system_agent/providers/anthropic.ex:49-59 | lib/optimal_system_agent/providers/anthropic.ex:64-74 — These two members are one piece of code written twice and then edited apart: 11 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.
  • Edited copy of a member (11 corresponding lines) priv/rust/tui/src/util.rs:159 — priv/rust/tui/src/util.rs:159-169 | priv/rust/tui/src/util.rs:173-183 — These two members are one piece of code written twice and then edited apart: 11 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.
  • Edited copy of a member (11 corresponding lines) lib/optimal_system_agent/agent/scheduler.ex:270 — lib/optimal_system_agent/agent/scheduler.ex:270-280 | lib/optimal_system_agent/agent/scheduler.ex:425-435 — These two members are one piece of code written twice and then edited apart: 11 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.
  • Edited copy of a member (11 corresponding lines) priv/rust/tui/src/components/agents/mod.rs:1079 — priv/rust/tui/src/components/agents/mod.rs:1079-1089 | priv/rust/tui/src/components/agents/mod.rs:1632-1645 — These two members are one piece of code written twice and then edited apart: 11 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.
  • Edited copy of a member (11 corresponding lines) lib/optimal_system_agent/mcp/transport/stdio.ex:537 — lib/optimal_system_agent/mcp/transport/stdio.ex:537-547 | lib/optimal_system_agent/open_computers/executor/direct/container.ex:567-578 — These two members are one piece of code written twice and then edited apart: 11 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.
  • Edited copy of a member (11 corresponding lines) lib/optimal_system_agent/mcp/transport/http.ex:177 — lib/optimal_system_agent/mcp/transport/http.ex:177-191 | lib/optimal_system_agent/mcp/transport/http.ex:293-303 — These two members are one piece of code written twice and then edited apart: 11 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.
  • Edited copy of a member (11 corresponding lines) canopy/backend/lib/canopy_web/controllers/issue_controller.ex:172 — canopy/backend/lib/canopy_web/controllers/issue_controller.ex:172-185 | canopy/backend/lib/canopy_web/controllers/goal_controller.ex:116-126 — These two members are one piece of code written twice and then edited apart: 11 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.
  • Edited copy of a member (11 corresponding lines) lib/optimal_system_agent/agent/task_tracker.ex:579 — lib/optimal_system_agent/agent/task_tracker.ex:579-589 | lib/optimal_system_agent/agent/tasks/persistence.ex:79-94 — These two members are one piece of code written twice and then edited apart: 11 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.
  • Edited copy of a member (11 corresponding lines) lib/optimal_system_agent/tools/builtins/multi_file_edit/handler.ex:64 — lib/optimal_system_agent/tools/builtins/multi_file_edit/handler.ex:64-80 | lib/optimal_system_agent/tools/builtins/structural_edit/handler.ex:128-138 — These two members are one piece of code written twice and then edited apart: 11 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.
  • Edited copy of a member (11 corresponding lines) priv/rust/tui/src/app/stream_probe.rs:74 — priv/rust/tui/src/app/stream_probe.rs:74-86 | priv/rust/tui/src/app/stream_probe.rs:89-99 — These two members are one piece of code written twice and then edited apart: 11 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.
  • Edited copy of a member (11 corresponding lines) lib/optimal_system_agent/channels/http/api/data_routes.ex:456 — lib/optimal_system_agent/channels/http/api/data_routes.ex:456-466 | lib/optimal_system_agent/channels/http/api/tool_routes.ex:855-865 — These two members are one piece of code written twice and then edited apart: 11 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.
  • Edited copy of a member (11 corresponding lines) lib/optimal_system_agent/sandbox/miosa.ex:212 — lib/optimal_system_agent/sandbox/miosa.ex:212-222 | lib/optimal_system_agent/sandbox/miosa_cli.ex:227-237 — These two members are one piece of code written twice and then edited apart: 11 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 · Duplicated block (12 lines × 2) · ×16
  • Duplicated block (12 lines × 2) canopy/backend/lib/canopy/costs.ex:42 — canopy/backend/lib/canopy/costs.ex:42-53 | canopy/backend/lib/canopy_web/controllers/cost_controller.ex:66-77 — before extracting anything, compare `canopy/backend/lib/canopy/costs.ex` and `canopy/backend/lib/canopy_web/controllers/cost_controller.ex` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 78 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) lib/optimal_system_agent/agent/loop/goal_tracker.ex:929 — lib/optimal_system_agent/agent/loop/goal_tracker.ex:929-940 | lib/optimal_system_agent/agent/loop/goal_tracker.ex:986-998 — 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 `lib/optimal_system_agent/agent/loop/goal_tracker.ex:929` 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 before the matched lines, `lib/optimal_system_agent/agent/loop/goal_tracker.ex:929` calls `join` and `lib/optimal_system_agent/agent/loop/goal_tracker.ex:986` does not — after which the two agree again for 5 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) lib/optimal_system_agent/agent/task_queue.ex:594 — lib/optimal_system_agent/agent/task_queue.ex:594-605 | lib/optimal_system_agent/agent/tasks/queue.ex:361-372 — before extracting anything, compare `lib/optimal_system_agent/agent/task_queue.ex` and `lib/optimal_system_agent/agent/tasks/queue.ex` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 149 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 `lib/optimal_system_agent/agent/task_queue.ex:594` 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 after the matched lines, `lib/optimal_system_agent/agent/task_queue.ex:606` calls `db_error` and `lib/optimal_system_agent/agent/tasks/queue.ex:373` 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) lib/optimal_system_agent/agent/task_tracker.ex:635 — lib/optimal_system_agent/agent/task_tracker.ex:635-646 | lib/optimal_system_agent/agent/tasks/tracker.ex:553-564 — before extracting anything, compare `lib/optimal_system_agent/agent/task_tracker.ex` and `lib/optimal_system_agent/agent/tasks/tracker.ex` as WHOLE FILES: this scan already matched 7 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. 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 `lib/optimal_system_agent/agent/task_tracker.ex:635` 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 (12 lines × 2) lib/optimal_system_agent/agent/tasks/workflow.ex:338 — lib/optimal_system_agent/agent/tasks/workflow.ex:338-349 | lib/optimal_system_agent/agent/workflow.ex:729-740 — before extracting anything, compare `lib/optimal_system_agent/agent/tasks/workflow.ex` and `lib/optimal_system_agent/agent/workflow.ex` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 285 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) lib/optimal_system_agent/agent/tasks/workflow.ex:535 — lib/optimal_system_agent/agent/tasks/workflow.ex:535-546 | lib/optimal_system_agent/agent/workflow.ex:647-658 — before extracting anything, compare `lib/optimal_system_agent/agent/tasks/workflow.ex` and `lib/optimal_system_agent/agent/workflow.ex` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 285 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) lib/optimal_system_agent/cli/opencomputers.ex:566 — lib/optimal_system_agent/cli/opencomputers.ex:566-577 | lib/optimal_system_agent/open_computers/config.ex:108-119 — 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 `lib/optimal_system_agent/cli/opencomputers.ex:566` 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 (12 lines × 2) lib/optimal_system_agent/protocol/tui_schema.ex:275 — lib/optimal_system_agent/protocol/tui_schema.ex:275-286 | lib/optimal_system_agent/protocol/tui_schema.ex:287-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. Read the line range as the matched WINDOW rather than a finished unit: at `lib/optimal_system_agent/protocol/tui_schema.ex:275` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (12 lines × 2) lib/optimal_system_agent/providers/batch.ex:149 — lib/optimal_system_agent/providers/batch.ex:149-160 | lib/optimal_system_agent/providers/batch.ex:174-185 — 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 `lib/optimal_system_agent/providers/batch.ex: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.
  • Duplicated block (12 lines × 2) lib/optimal_system_agent/providers/openai_compat.ex:2012 — lib/optimal_system_agent/providers/openai_compat.ex:2012-2023 | lib/optimal_system_agent/providers/openai_responses.ex:399-410 — 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 `lib/optimal_system_agent/providers/openai_compat.ex:2012` 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) lib/optimal_system_agent/skills/validator.ex:185 — lib/optimal_system_agent/skills/validator.ex:185-196 | lib/optimal_system_agent/tools/registry/skill_loader.ex:406-417 — 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 `lib/optimal_system_agent/skills/validator.ex: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.
  • Duplicated block (12 lines × 2) lib/optimal_system_agent/tools/builtins/create_skill/tool.ex:50 — lib/optimal_system_agent/tools/builtins/create_skill/tool.ex:50-61 | lib/optimal_system_agent/tools/builtins/structural_edit/tool.ex:99-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. Read the line range as the matched WINDOW rather than a finished unit: at `lib/optimal_system_agent/tools/builtins/create_skill/tool.ex:50` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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) lib/optimal_system_agent/speculative/tools/start_speculative/ui.ex:22 — lib/optimal_system_agent/speculative/tools/start_speculative/ui.ex:22-33 | lib/optimal_system_agent/verification/tools/verify_loop/ui.ex:22-33 — 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 (12 lines × 2) priv/rust/tui/src/app/event_loop.rs:3070 — priv/rust/tui/src/app/event_loop.rs:3070-3081 | priv/rust/tui/src/app/event_loop.rs:3199-3210 — 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 `priv/rust/tui/src/app/event_loop.rs:3070` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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) priv/rust/tui/src/dialogs/model_picker.rs:1325 — priv/rust/tui/src/dialogs/model_picker.rs:1325-1336 | priv/rust/tui/src/dialogs/model_picker.rs:1350-1361 — 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. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (12 lines × 2) priv/rust/tui/src/client/sse.rs:2117 — priv/rust/tui/src/client/sse.rs:2117-2128 | priv/rust/tui/src/client/sse.rs:2383-2394 — 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 `priv/rust/tui/src/client/sse.rs:2117` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Edited copy of a member (2 corresponding lines) · ×15
  • Edited copy of a member (2 corresponding lines) lib/optimal_system_agent/memory/consolidator.ex:291 — lib/optimal_system_agent/memory/consolidator.ex:291-292 | lib/optimal_system_agent/memory/store.ex:1088-1092 — These two members are one piece of code written twice and then edited apart: 2 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.
  • Edited copy of a member (2 corresponding lines) lib/optimal_system_agent/agent/loop/goal_verifier.ex:2464 — lib/optimal_system_agent/agent/loop/goal_verifier.ex:2464-2466 | lib/optimal_system_agent/orchestrator.ex:825-826 — These two members are one piece of code written twice and then edited apart: 2 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.
  • Edited copy of a member (2 corresponding lines) lib/optimal_system_agent/channels/dingtalk.ex:62 — lib/optimal_system_agent/channels/dingtalk.ex:62-64 | lib/optimal_system_agent/channels/line.ex:70-71 — These two members are one piece of code written twice and then edited apart: 2 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.
  • Edited copy of a member (2 corresponding lines) lib/optimal_system_agent/tools/builtins/computer_use/adapters/linux_wayland.ex:132 — lib/optimal_system_agent/tools/builtins/computer_use/adapters/linux_wayland.ex:132-133 | lib/optimal_system_agent/tools/builtins/computer_use/adapters/windows.ex:166-167 — These two members are one piece of code written twice and then edited apart: 2 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.
  • Edited copy of a member (2 corresponding lines) bench/osabench/fixtures/acme/lib/acme/slug.ex:5 — bench/osabench/fixtures/acme/lib/acme/slug.ex:5-8 | lib/optimal_system_agent/skills/capture.ex:90-91 — These two members are one piece of code written twice and then edited apart: 2 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.
  • Edited copy of a member (2 corresponding lines) lib/optimal_system_agent/agent/safety/model_classifier.ex:394 — lib/optimal_system_agent/agent/safety/model_classifier.ex:394-395 | lib/optimal_system_agent/permissions/auto_classifier.ex:469-470 — These two members are one piece of code written twice and then edited apart: 2 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.
  • Edited copy of a member (2 corresponding lines) lib/optimal_system_agent/memory.ex:553 — lib/optimal_system_agent/memory.ex:553-554 | lib/optimal_system_agent/memory/store.ex:394-395 — These two members are one piece of code written twice and then edited apart: 2 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.
  • Edited copy of a member (2 corresponding lines) lib/optimal_system_agent/providers/resilience.ex:183 — lib/optimal_system_agent/providers/resilience.ex:183-184 | lib/optimal_system_agent/providers/retry_classifier.ex:453-454 — These two members are one piece of code written twice and then edited apart: 2 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.
  • Edited copy of a member (2 corresponding lines) lib/optimal_system_agent/tools/builtins/multi_file_edit/tool.ex:124 — lib/optimal_system_agent/tools/builtins/multi_file_edit/tool.ex:124-125 | lib/optimal_system_agent/tools/builtins/multi_file_edit/ui.ex:14-20 — These two members are one piece of code written twice and then edited apart: 2 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.
  • Edited copy of a member (2 corresponding lines) lib/optimal_system_agent/agent/compactor.ex:423 — lib/optimal_system_agent/agent/compactor.ex:423-424 | lib/optimal_system_agent/tools/builtins/file_read/spans.ex:157-158 — These two members are one piece of code written twice and then edited apart: 2 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.
  • Edited copy of a member (2 corresponding lines) lib/optimal_system_agent/workspace/project_resource.ex:234 — lib/optimal_system_agent/workspace/project_resource.ex:234-235 | lib/optimal_system_agent/workspace/trust.ex:256-257 — These two members are one piece of code written twice and then edited apart: 2 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.
  • Edited copy of a member (2 corresponding lines) lib/optimal_system_agent/agent/active_skills.ex:214 — lib/optimal_system_agent/agent/active_skills.ex:214-215 | lib/optimal_system_agent/agent/session_health.ex:92-93 — These two members are one piece of code written twice and then edited apart: 2 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.
  • Edited copy of a member (2 corresponding lines) lib/optimal_system_agent/agent/task_tracker.ex:613 — lib/optimal_system_agent/agent/task_tracker.ex:613-614 | lib/optimal_system_agent/agent/tasks/persistence.ex:126-127 — These two members are one piece of code written twice and then edited apart: 2 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.
  • Edited copy of a member (2 corresponding lines) lib/optimal_system_agent/agent/loop/llm_client.ex:771 — lib/optimal_system_agent/agent/loop/llm_client.ex:771-772 | lib/optimal_system_agent/runtime/session_manager.ex:156-157 — These two members are one piece of code written twice and then edited apart: 2 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.
  • Edited copy of a member (2 corresponding lines) lib/optimal_system_agent/providers/reasoning_content.ex:148 — lib/optimal_system_agent/providers/reasoning_content.ex:148-149 | lib/optimal_system_agent/security/proxy_capture.ex:204-205 — These two members are one piece of code written twice and then edited apart: 2 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 · Duplicated block (14 lines × 2) · ×15
  • Duplicated block (14 lines × 2) canopy/backend/lib/canopy/costs.ex:152 — canopy/backend/lib/canopy/costs.ex:152-165 | canopy/backend/lib/canopy_web/controllers/cost_controller.ex:19-32 — before extracting anything, compare `canopy/backend/lib/canopy/costs.ex` and `canopy/backend/lib/canopy_web/controllers/cost_controller.ex` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 78 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 (14 lines × 2) lib/optimal_system_agent/agent/loop/goal_tracker.ex:912 — lib/optimal_system_agent/agent/loop/goal_tracker.ex:912-925 | lib/optimal_system_agent/agent/loop/goal_tracker.ex:970-983 — 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) lib/optimal_system_agent/cli/update.ex:33 — lib/optimal_system_agent/cli/update.ex:33-46 | lib/optimal_system_agent/cli/update.ex:55-68 — 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 before the matched lines, `lib/optimal_system_agent/cli/update.ex:54` calls `puts` and `lib/optimal_system_agent/cli/update.ex:32` 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 (14 lines × 2) lib/optimal_system_agent/decisions/merge.ex:134 — lib/optimal_system_agent/decisions/merge.ex:134-147 | lib/optimal_system_agent/decisions/pivot.ex:157-170 — 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 `lib/optimal_system_agent/decisions/merge.ex:134` 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 (14 lines × 2) lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex:221 — lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex:221-234 | lib/optimal_system_agent/open_computers/executor/direct/cluster/mlx_distributed.ex:245-258 — before extracting anything, compare `lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex` and `lib/optimal_system_agent/open_computers/executor/direct/cluster/mlx_distributed.ex` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 66 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 (14 lines × 2) lib/optimal_system_agent/providers/openai_compat.ex:620 — lib/optimal_system_agent/providers/openai_compat.ex:620-633 | lib/optimal_system_agent/providers/openai_compat.ex:650-663 — 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) lib/optimal_system_agent/settings.ex:606 — lib/optimal_system_agent/settings.ex:606-619 | lib/optimal_system_agent/system/json_store.ex:58-71 — 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 `lib/optimal_system_agent/settings.ex:606` 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 before the matched lines, `lib/optimal_system_agent/settings.ex:604` calls `strip` and `lib/optimal_system_agent/system/json_store.ex:57` 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) lib/optimal_system_agent/tools/builtins/file_edit/fuzzy_matcher.ex:506 — lib/optimal_system_agent/tools/builtins/file_edit/fuzzy_matcher.ex:506-519 | lib/optimal_system_agent/tools/builtins/file_edit/fuzzy_matcher.ex:554-567 — 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 `lib/optimal_system_agent/tools/builtins/file_edit/fuzzy_matcher.ex:554` 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) lib/optimal_system_agent/tools/builtins/memory_recall/tool.ex:37 — lib/optimal_system_agent/tools/builtins/memory_recall/tool.ex:37-50 | lib/optimal_system_agent/tools/builtins/memory_save/tool.ex:37-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 `lib/optimal_system_agent/tools/builtins/memory_recall/tool.ex:37` 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) lib/optimal_system_agent/tools/builtins/scratchpad/tool.ex:41 — lib/optimal_system_agent/tools/builtins/scratchpad/tool.ex:41-54 | lib/optimal_system_agent/tools/builtins/team_tasks/tool.ex:36-49 — 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 `lib/optimal_system_agent/tools/builtins/scratchpad/tool.ex:41` 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) lib/optimal_system_agent/agent/tasks/workflow.ex:259 — lib/optimal_system_agent/agent/tasks/workflow.ex:259-272 | lib/optimal_system_agent/agent/workflow.ex:390-403 — before extracting anything, compare `lib/optimal_system_agent/agent/tasks/workflow.ex` and `lib/optimal_system_agent/agent/workflow.ex` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 285 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 (14 lines × 2) priv/rust/tui/src/dialogs/mcp_approval.rs:234 — priv/rust/tui/src/dialogs/mcp_approval.rs:234-247 | priv/rust/tui/src/dialogs/trust.rs:146-159 — before extracting anything, compare `priv/rust/tui/src/dialogs/mcp_approval.rs` and `priv/rust/tui/src/dialogs/trust.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 51 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 `priv/rust/tui/src/dialogs/mcp_approval.rs:234` 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 (14 lines × 2) priv/rust/tui/src/dialogs/onboarding.rs:1737 — priv/rust/tui/src/dialogs/onboarding.rs:1737-1750 | priv/rust/tui/src/dialogs/onboarding.rs:1769-1782 — 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) priv/rust/tui/src/render/latex.rs:308 — priv/rust/tui/src/render/latex.rs:308-321 | priv/rust/tui/src/render/latex.rs:375-388 — 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 `priv/rust/tui/src/render/latex.rs:308` 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) priv/rust/tui/src/tools/references.rs:148 — priv/rust/tui/src/tools/references.rs:148-161 | priv/rust/tui/src/tools/references.rs:185-198 — 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 `priv/rust/tui/src/tools/references.rs:148` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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 lines × 2) · ×15
  • Duplicated block (11 lines × 2) canopy/backend/lib/canopy/costs.ex:59 — canopy/backend/lib/canopy/costs.ex:59-69 | canopy/backend/lib/canopy_web/controllers/cost_controller.ex:86-96 — before extracting anything, compare `canopy/backend/lib/canopy/costs.ex` and `canopy/backend/lib/canopy_web/controllers/cost_controller.ex` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 78 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) lib/optimal_system_agent/agent/tasks/workflow.ex:580 — lib/optimal_system_agent/agent/tasks/workflow.ex:580-590 | lib/optimal_system_agent/agent/workflow.ex:744-754 — before extracting anything, compare `lib/optimal_system_agent/agent/tasks/workflow.ex` and `lib/optimal_system_agent/agent/workflow.ex` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 285 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) lib/optimal_system_agent/agent/tasks/workflow.ex:594 — lib/optimal_system_agent/agent/tasks/workflow.ex:594-604 | lib/optimal_system_agent/agent/workflow.ex:777-787 — before extracting anything, compare `lib/optimal_system_agent/agent/tasks/workflow.ex` and `lib/optimal_system_agent/agent/workflow.ex` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 285 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) lib/optimal_system_agent/auth/providers/copilot.ex:212 — lib/optimal_system_agent/auth/providers/copilot.ex:212-222 | lib/optimal_system_agent/auth/providers/openai_codex.ex:284-294 — before extracting anything, compare `lib/optimal_system_agent/auth/providers/copilot.ex` and `lib/optimal_system_agent/auth/providers/openai_codex.ex` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 68 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) lib/optimal_system_agent/providers/anthropic.ex:1088 — lib/optimal_system_agent/providers/anthropic.ex:1088-1098 | lib/optimal_system_agent/providers/anthropic.ex:1155-1165 — 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 `lib/optimal_system_agent/providers/anthropic.ex:1088` 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) lib/optimal_system_agent/providers/catalog.ex:673 — lib/optimal_system_agent/providers/catalog.ex:673-683 | lib/optimal_system_agent/providers/catalog.ex:688-698 — 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 `lib/optimal_system_agent/providers/catalog.ex:673` 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 × 2) lib/optimal_system_agent/security/symbol_resolver.ex:272 — lib/optimal_system_agent/security/symbol_resolver.ex:272-282 | lib/optimal_system_agent/security/variant_analysis.ex:123-133 — 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) lib/optimal_system_agent/agent/loop/regulation/pain_channel.ex:179 — lib/optimal_system_agent/agent/loop/regulation/pain_channel.ex:179-189 | lib/optimal_system_agent/local_models/installer.ex:121-131 — 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 `lib/optimal_system_agent/agent/loop/regulation/pain_channel.ex: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 (11 lines × 2) lib/optimal_system_agent/agent/task_tracker.ex:480 — lib/optimal_system_agent/agent/task_tracker.ex:480-490 | lib/optimal_system_agent/agent/tasks/tracker.ex:738-748 — before extracting anything, compare `lib/optimal_system_agent/agent/task_tracker.ex` and `lib/optimal_system_agent/agent/tasks/tracker.ex` as WHOLE FILES: this scan already matched 7 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. 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) priv/rust/tui/src/dialogs/onboarding.rs:875 — priv/rust/tui/src/dialogs/onboarding.rs:875-885 | priv/rust/tui/src/dialogs/onboarding.rs:950-960 — 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 `priv/rust/tui/src/dialogs/onboarding.rs:875` 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 after the matched lines, `priv/rust/tui/src/dialogs/onboarding.rs:886` calls `clear` and `priv/rust/tui/src/dialogs/onboarding.rs:961` 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 (11 lines × 2) priv/rust/tui/src/render/markdown.rs:1430 — priv/rust/tui/src/render/markdown.rs:1430-1440 | priv/rust/tui/src/render/markdown.rs:1880-1890 — 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) priv/rust/tui/src/app/handle_dialogs.rs:1360 — priv/rust/tui/src/app/handle_dialogs.rs:1360-1372 | priv/rust/tui/src/app/handle_dialogs.rs:1403-1413 — 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 `priv/rust/tui/src/app/handle_dialogs.rs:1360` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. 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) priv/rust/tui/src/client/sse.rs:2395 — priv/rust/tui/src/client/sse.rs:2395-2405 | priv/rust/tui/src/client/sse.rs:2496-2506 — 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 `priv/rust/tui/src/client/sse.rs:2395` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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) lib/optimal_system_agent/sandbox/miosa.ex:182 — lib/optimal_system_agent/sandbox/miosa.ex:182-192 | lib/optimal_system_agent/sandbox/miosa_cli.ex:194-204 — 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 `lib/optimal_system_agent/sandbox/miosa.ex:182` 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 × 2) bench/swebench/run_bench.py:146 — bench/swebench/run_bench.py:146-156 | bench/swebenchpro/dataset.py:240-250 — 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `bench/swebench/run_bench.py:157` calls `extend`, `sample` and `bench/swebenchpro/dataset.py:252` 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.
D1 · Cyclomatic Complexity · App · ×14
  • App::handle_backend_event (cyclomatic 421) priv/rust/tui/src/app/handle_backend.rs:141 — App::handle_backend_event has cyclomatic complexity 421 (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.
  • App::handle_command (cyclomatic 124) priv/rust/tui/src/app/commands.rs:128 — App::handle_command has cyclomatic complexity 124 (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.
  • App::run (cyclomatic 67) priv/rust/tui/src/app/event_loop.rs:826 — App::run has cyclomatic complexity 67 (threshold 15). Of this number, 65 points are the body's own statements and 2 belong to one function item inside it that branches. 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.
  • App::draw (cyclomatic 61) priv/rust/tui/src/app/event_loop.rs:1839 — App::draw has cyclomatic complexity 61 (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.
  • App::handle_key (cyclomatic 54) priv/rust/tui/src/app/update.rs:239 — App::handle_key has cyclomatic complexity 54 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • App::dispatch_action (cyclomatic 29) priv/rust/tui/src/app/keymap_dispatch.rs:106 — App::dispatch_action 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.
  • App::handle_processing_key (cyclomatic 26) priv/rust/tui/src/app/update.rs:1242 — App::handle_processing_key has cyclomatic complexity 26 (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.
  • App::handle_idle_key (cyclomatic 25) priv/rust/tui/src/app/update.rs:1026 — App::handle_idle_key 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.
  • App::handle_agent_response (cyclomatic 24) priv/rust/tui/src/app/handle_actions.rs:239 — App::handle_agent_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.
  • App::handle_voice_event (cyclomatic 19) priv/rust/tui/src/app/update.rs:1507 — App::handle_voice_event 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.
  • App::update (cyclomatic 18) priv/rust/tui/src/app/update.rs:119 — App::update has cyclomatic complexity 18 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • App::handle_agents_dashboard_key (cyclomatic 18) priv/rust/tui/src/app/update.rs:671 — App::handle_agents_dashboard_key has cyclomatic complexity 18 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • App::handle_tick (cyclomatic 18) priv/rust/tui/src/app/update.rs:1610 — App::handle_tick 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.
  • App::handle_command_result (cyclomatic 16) priv/rust/tui/src/app/handle_actions.rs:543 — App::handle_command_result 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.
D4 · Code Duplication · Edited copy of a member (22 corresponding lines) · ×14
  • Edited copy of a member (22 corresponding lines) canopy/backend/lib/canopy_web/controllers/activity_controller.ex:9 — canopy/backend/lib/canopy_web/controllers/activity_controller.ex:9-30 | canopy/backend/lib/canopy_web/controllers/audit_controller.ex:9-47 — These two members are one piece of code written twice and then edited apart: 22 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.
  • Edited copy of a member (22 corresponding lines) lib/optimal_system_agent/tools/builtins/code_symbols/handler.ex:286 — lib/optimal_system_agent/tools/builtins/code_symbols/handler.ex:286-307 | lib/optimal_system_agent/tools/builtins/code_symbols/handler.ex:406-427 — These two members are one piece of code written twice and then edited apart: 22 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.
  • Edited copy of a member (22 corresponding lines) lib/optimal_system_agent/agent/tasks/workflow.ex:115 — lib/optimal_system_agent/agent/tasks/workflow.ex:115-136 | lib/optimal_system_agent/agent/workflow.ex:242-272 — These two members are one piece of code written twice and then edited apart: 22 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.
  • Edited copy of a member (22 corresponding lines) priv/rust/tui/src/dialogs/model_picker.rs:2547 — priv/rust/tui/src/dialogs/model_picker.rs:2547-2568 | priv/rust/tui/src/dialogs/onboarding.rs:608-631 — These two members are one piece of code written twice and then edited apart: 22 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.
  • Edited copy of a member (22 corresponding lines) lib/optimal_system_agent/agent/scheduler/persistence.ex:22 — lib/optimal_system_agent/agent/scheduler/persistence.ex:22-43 | lib/optimal_system_agent/agent/scheduler/persistence.ex:53-83 — These two members are one piece of code written twice and then edited apart: 22 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.
  • Edited copy of a member (22 corresponding lines) lib/optimal_system_agent/auth/device_flow.ex:333 — lib/optimal_system_agent/auth/device_flow.ex:333-367 | lib/optimal_system_agent/auth/providers/minimax.ex:552-573 — These two members are one piece of code written twice and then edited apart: 22 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.
  • Edited copy of a member (22 corresponding lines) lib/optimal_system_agent/open_computers/executor/direct/container.ex:742 — lib/optimal_system_agent/open_computers/executor/direct/container.ex:742-763 | lib/optimal_system_agent/open_computers/executor/direct/container.ex:775-802 — These two members are one piece of code written twice and then edited apart: 22 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.
  • Edited copy of a member (22 corresponding lines) priv/rust/tui/src/components/input/mod.rs:1451 — priv/rust/tui/src/components/input/mod.rs:1451-1472 | priv/rust/tui/src/components/input/mod.rs:1475-1496 — These two members are one piece of code written twice and then edited apart: 22 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.
  • Edited copy of a member (22 corresponding lines) lib/optimal_system_agent/cli/opencomputers.ex:462 — lib/optimal_system_agent/cli/opencomputers.ex:462-483 | lib/optimal_system_agent/cli/opencomputers.ex:487-513 — These two members are one piece of code written twice and then edited apart: 22 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.
  • Edited copy of a member (22 corresponding lines) lib/optimal_system_agent/budget/treasury.ex:103 — lib/optimal_system_agent/budget/treasury.ex:103-125 | lib/optimal_system_agent/budget/treasury.ex:151-172 — These two members are one piece of code written twice and then edited apart: 22 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.
  • Edited copy of a member (22 corresponding lines) lib/optimal_system_agent/providers/anthropic.ex:211 — lib/optimal_system_agent/providers/anthropic.ex:211-240 | lib/optimal_system_agent/providers/openai_compat.ex:399-420 — These two members are one piece of code written twice and then edited apart: 22 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.
  • Edited copy of a member (22 corresponding lines) lib/optimal_system_agent/agent/task_tracker.ex:341 — lib/optimal_system_agent/agent/task_tracker.ex:341-362 | lib/optimal_system_agent/agent/task_tracker.ex:404-425 — These two members are one piece of code written twice and then edited apart: 22 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.
  • Edited copy of a member (22 corresponding lines) lib/optimal_system_agent/tools/builtins/download/handler.ex:88 — lib/optimal_system_agent/tools/builtins/download/handler.ex:88-109 | lib/optimal_system_agent/tools/builtins/web_fetch/handler.ex:78-99 — These two members are one piece of code written twice and then edited apart: 22 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.
  • Edited copy of a member (22 corresponding lines) lib/optimal_system_agent/tools/builtins/git/tool.ex:47 — lib/optimal_system_agent/tools/builtins/git/tool.ex:47-68 | lib/optimal_system_agent/tools/builtins/mcts_index.ex:43-68 — These two members are one piece of code written twice and then edited apart: 22 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.
D1 · Cyclomatic Complexity · osa_tui · ×13
  • osa_tui::client::sse::parse_system_event (cyclomatic 118) priv/rust/tui/src/client/sse.rs:1142 — osa_tui::client::sse::parse_system_event has cyclomatic complexity 118 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • osa_tui::render::markdown::parse_inline (cyclomatic 97) priv/rust/tui/src/render/markdown.rs:2005 — osa_tui::render::markdown::parse_inline has cyclomatic complexity 97 (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.
  • osa_tui::render::markdown::render_markdown (cyclomatic 63) priv/rust/tui/src/render/markdown.rs:34 — osa_tui::render::markdown::render_markdown has cyclomatic complexity 63 (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.
  • osa_tui::client::sse::parse_sse_event (cyclomatic 61) priv/rust/tui/src/client/sse.rs:388 — osa_tui::client::sse::parse_sse_event has cyclomatic complexity 61 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • osa_tui::render::markdown_stream::inline_preview (cyclomatic 35) priv/rust/tui/src/render/markdown_stream.rs:277 — osa_tui::render::markdown_stream::inline_preview 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.
  • osa_tui::render::markdown::wrap_spans_inner (cyclomatic 28) priv/rust/tui/src/render/markdown.rs:1739 — osa_tui::render::markdown::wrap_spans_inner 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.
  • osa_tui::config::keybindings::parse_keystroke (cyclomatic 25) priv/rust/tui/src/config/keybindings.rs:92 — osa_tui::config::keybindings::parse_keystroke has cyclomatic complexity 25 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • osa_tui::render::markdown::render_table (cyclomatic 22) priv/rust/tui/src/render/markdown.rs:876 — osa_tui::render::markdown::render_table 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.
  • osa_tui::components::chat::wrap_count::rows_for_line (cyclomatic 20) priv/rust/tui/src/components/chat/wrap_count.rs:49 — osa_tui::components::chat::wrap_count::rows_for_line 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.
  • osa_tui::app::settle_guard::common_prefix_modulo_whitespace (cyclomatic 19) priv/rust/tui/src/app/settle_guard.rs:134 — osa_tui::app::settle_guard::common_prefix_modulo_whitespace has cyclomatic complexity 19 (threshold 15). Of this number, 14 points are the body's own statements and 5 belong to one function item inside it that branches. 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.
  • osa_tui::view::onboarding_flow::completed_step_summary (cyclomatic 19) priv/rust/tui/src/view/onboarding_flow.rs:202 — osa_tui::view::onboarding_flow::completed_step_summary 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.
  • osa_tui::components::osc8::supports_hyperlinks_with (cyclomatic 17) priv/rust/tui/src/components/osc8.rs:191 — osa_tui::components::osc8::supports_hyperlinks_with 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.
  • osa_tui::tools::collapse::classify_shell_command (cyclomatic 16) priv/rust/tui/src/tools/collapse.rs:297 — osa_tui::tools::collapse::classify_shell_command 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.
D4 · Code Duplication · Edited copy of a member (10 corresponding lines) · ×13
  • Edited copy of a member (10 corresponding lines) lib/optimal_system_agent/agent/scheduler.ex:305 — lib/optimal_system_agent/agent/scheduler.ex:305-314 | lib/optimal_system_agent/agent/scheduler.ex:387-396 — These two members are one piece of code written twice and then edited apart: 10 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.
  • Edited copy of a member (10 corresponding lines) lib/optimal_system_agent/channels/http/api/metrics_routes.ex:143 — lib/optimal_system_agent/channels/http/api/metrics_routes.ex:143-154 | lib/optimal_system_agent/channels/http/api/metrics_routes.ex:160-169 — These two members are one piece of code written twice and then edited apart: 10 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.
  • Edited copy of a member (10 corresponding lines) lib/optimal_system_agent/agent/loop/advisor.ex:569 — lib/optimal_system_agent/agent/loop/advisor.ex:569-583 | lib/optimal_system_agent/providers/step_router.ex:399-408 — These two members are one piece of code written twice and then edited apart: 10 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.
  • Edited copy of a member (10 corresponding lines) lib/optimal_system_agent/tools/builtins/file_grep/handler.ex:705 — lib/optimal_system_agent/tools/builtins/file_grep/handler.ex:705-717 | lib/optimal_system_agent/tools/builtins/web_search/handler.ex:192-201 — These two members are one piece of code written twice and then edited apart: 10 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.
  • Edited copy of a member (10 corresponding lines) lib/optimal_system_agent/agent/loop/doom_loop/stall.ex:348 — lib/optimal_system_agent/agent/loop/doom_loop/stall.ex:348-357 | lib/optimal_system_agent/agent/loop/regulation/signals.ex:172-181 — These two members are one piece of code written twice and then edited apart: 10 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.
  • Edited copy of a member (10 corresponding lines) lib/optimal_system_agent/cli/remote.ex:138 — lib/optimal_system_agent/cli/remote.ex:138-147 | lib/optimal_system_agent/cli/remote.ex:151-161 — These two members are one piece of code written twice and then edited apart: 10 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.
  • Edited copy of a member (10 corresponding lines) lib/optimal_system_agent/security/validation_result.ex:221 — lib/optimal_system_agent/security/validation_result.ex:221-230 | lib/optimal_system_agent/security/validation_result.ex:234-243 — These two members are one piece of code written twice and then edited apart: 10 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.
  • Edited copy of a member (10 corresponding lines) lib/optimal_system_agent/agent/defense_context.ex:29 — lib/optimal_system_agent/agent/defense_context.ex:29-55 | lib/optimal_system_agent/agent/security_context.ex:158-167 — These two members are one piece of code written twice and then edited apart: 10 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.
  • Edited copy of a member (10 corresponding lines) lib/optimal_system_agent/local_models/hardware.ex:177 — lib/optimal_system_agent/local_models/hardware.ex:177-186 | lib/optimal_system_agent/local_models/hardware.ex:199-208 — These two members are one piece of code written twice and then edited apart: 10 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.
  • Edited copy of a member (10 corresponding lines) canopy/backend/lib/canopy_web/controllers/inbox_controller.ex:126 — canopy/backend/lib/canopy_web/controllers/inbox_controller.ex:126-136 | canopy/backend/lib/canopy_web/controllers/activity_controller.ex:73-82 — These two members are one piece of code written twice and then edited apart: 10 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.
  • Edited copy of a member (10 corresponding lines) lib/optimal_system_agent/repo_map/git_state.ex:148 — lib/optimal_system_agent/repo_map/git_state.ex:148-157 | lib/optimal_system_agent/workspace/cwd.ex:232-241 — These two members are one piece of code written twice and then edited apart: 10 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.
  • Edited copy of a member (10 corresponding lines) lib/optimal_system_agent/tools/builtins/create_agent/handler.ex:22 — lib/optimal_system_agent/tools/builtins/create_agent/handler.ex:22-31 | lib/optimal_system_agent/tools/builtins/progress_note/handler.ex:29-38 — These two members are one piece of code written twice and then edited apart: 10 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.
  • Edited copy of a member (10 corresponding lines) lib/optimal_system_agent/tools/arg_coercion.ex:176 — lib/optimal_system_agent/tools/arg_coercion.ex:176-187 | lib/optimal_system_agent/tools/builtins/config/handler.ex:107-116 — These two members are one piece of code written twice and then edited apart: 10 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.
D3 · God Classes · ClassTooLong · ×12
  • ClassTooLong: InputComponent priv/rust/tui/src/components/input/mod.rs:82 — ClassTooLong — 1701 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 103 methods, 3 blocks, lines 82-3155. The bar is 400 significant lines; this is 1301 over it, 4.25× 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.
  • ClassTooLong: ModelPicker priv/rust/tui/src/dialogs/model_picker.rs:239 — ClassTooLong — 1363 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 94 methods, 2 blocks, lines 239-2543. The bar is 400 significant lines; this is 963 over it, 3.41× 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.
  • ClassTooLong: OnboardingWizard priv/rust/tui/src/dialogs/onboarding.rs:92 — ClassTooLong — 1177 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 70 methods, 2 blocks, lines 92-1918. The bar is 400 significant lines; this is 777 over it, 2.94× 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.
  • ClassTooLong: Activity priv/rust/tui/src/components/activity.rs:514 — ClassTooLong — 957 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 80 methods, 3 blocks, lines 514-2799. The bar is 400 significant lines; this is 557 over it, 2.39× 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.
  • ClassTooLong: ApiClient priv/rust/tui/src/client/http.rs:89 — ClassTooLong — 828 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 109 methods, 3 blocks, lines 89-2050. The bar is 400 significant lines; this is 428 over it, 2.07× 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.
  • ClassTooLong: StatusBar priv/rust/tui/src/components/status_bar.rs:510 — ClassTooLong — 764 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 66 methods, 3 blocks, lines 510-1982. The bar is 400 significant lines; this is 364 over it, 1.91× 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.
  • ClassTooLong: Agents priv/rust/tui/src/components/agents/mod.rs:27 — ClassTooLong — 705 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 72 methods, 4 blocks, lines 27-1661. The bar is 400 significant lines; this is 305 over it, 1.76× 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.
  • ClassTooLong: App priv/rust/tui/src/app/mod.rs:104 — ClassTooLong — 608 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 226 methods, 2 blocks, lines 104-1524. The bar is 400 significant lines; this is 208 over it, 1.52× 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.
  • ClassTooLong: SurveyDialog priv/rust/tui/src/dialogs/survey.rs:262 — ClassTooLong — 489 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 24 methods, 2 blocks, lines 262-996. The bar is 400 significant lines; this is 89 over it, 1.22× 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.
  • ClassTooLong: BackendEvent priv/rust/tui/src/event/backend.rs:15 — ClassTooLong — 456 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 0 methods. The bar is 400 significant lines; this is 56 over it, 1.14× 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.
  • ClassTooLong: Chat priv/rust/tui/src/components/chat/mod.rs:48 — ClassTooLong — 446 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 50 methods, 3 blocks, lines 48-991. The bar is 400 significant lines; this is 46 over it, 1.12× 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.
  • ClassTooLong: ClaudeLogin priv/rust/tui/src/dialogs/claude_login.rs:84 — ClassTooLong — 414 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 23 methods, 4 blocks, lines 84-717. The bar is 400 significant lines; this is 14 over it, 1.04× 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.
D30 · Dependency Vulnerabilities · Medium CVE · ×11
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D3 · God Classes · FunctionTooLong · ×9
  • FunctionTooLong: osa_tui::client::sse::parse_system_event priv/rust/tui/src/client/sse.rs:1142 — FunctionTooLong — osa_tui::client::sse::parse_system_event runs 1034 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 934 over it, 10.34× 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: osa_tui::client::sse::parse_sse_event priv/rust/tui/src/client/sse.rs:388 — FunctionTooLong — osa_tui::client::sse::parse_sse_event runs 481 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 381 over it, 4.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: osa_tui::render::markdown::parse_inline priv/rust/tui/src/render/markdown.rs:2005 — FunctionTooLong — osa_tui::render::markdown::parse_inline runs 315 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 215 over it, 3.15× 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: osa_tui::render::markdown::render_markdown priv/rust/tui/src/render/markdown.rs:34 — FunctionTooLong — osa_tui::render::markdown::render_markdown runs 231 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 131 over it, 2.31× 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: osa_tui::dialogs::context_breakdown::draw priv/rust/tui/src/dialogs/context_breakdown.rs:128 — FunctionTooLong — osa_tui::dialogs::context_breakdown::draw runs 137 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 37 over it, 1.37× 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: osa_tui::components::chat::welcome::welcome_lines priv/rust/tui/src/components/chat/welcome.rs:33 — FunctionTooLong — osa_tui::components::chat::welcome::welcome_lines runs 132 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 32 over it, 1.32× 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: osa_tui::dialogs::status_dashboard::draw priv/rust/tui/src/dialogs/status_dashboard.rs:92 — FunctionTooLong — osa_tui::dialogs::status_dashboard::draw runs 132 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 32 over it, 1.32× 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: osa_screen_capture_wayland::rfb::serve native/linux/ScreenShare/src/rfb.rs:80 — FunctionTooLong — osa_screen_capture_wayland::rfb::serve runs 119 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 19 over it, 1.19× 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: osa_tui::render::markdown::render_table priv/rust/tui/src/render/markdown.rs:876 — FunctionTooLong — osa_tui::render::markdown::render_table runs 111 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 11 over it, 1.11× 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.
D3 · God Classes · TooManyMethods · ×9
  • TooManyMethods: App priv/rust/tui/src/app/mod.rs:104 — TooManyMethods — 226 methods, declared across 10 files: app/handle_actions.rs (68), app/handle_dialogs.rs (54), app/update.rs (31), app/mod.rs (25), +6 more file(s). The bar is 30 methods; this is 196 over it, 7.53× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. 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.
  • TooManyMethods: ApiClient priv/rust/tui/src/client/http.rs:89 — TooManyMethods — 109 methods. The bar is 30 methods; this is 79 over it, 3.63× 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.
  • TooManyMethods: InputComponent priv/rust/tui/src/components/input/mod.rs:82 — TooManyMethods — 103 methods. The bar is 30 methods; this is 73 over it, 3.43× 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.
  • TooManyMethods: ModelPicker priv/rust/tui/src/dialogs/model_picker.rs:239 — TooManyMethods — 94 methods, declared across 2 files: dialogs/model_picker.rs (69), model_picker/local.rs (25). The bar is 30 methods; this is 64 over it, 3.13× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. 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.
  • TooManyMethods: Activity priv/rust/tui/src/components/activity.rs:514 — TooManyMethods — 80 methods. The bar is 30 methods; this is 50 over it, 2.67× 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.
  • TooManyMethods: Agents priv/rust/tui/src/components/agents/mod.rs:27 — TooManyMethods — 72 methods, declared across 2 files: agents/mod.rs (69), agents/render.rs (3). The bar is 30 methods; this is 42 over it, 2.40× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. 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.
  • TooManyMethods: OnboardingWizard priv/rust/tui/src/dialogs/onboarding.rs:92 — TooManyMethods — 70 methods. The bar is 30 methods; this is 40 over it, 2.33× 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.
  • TooManyMethods: StatusBar priv/rust/tui/src/components/status_bar.rs:510 — TooManyMethods — 66 methods. The bar is 30 methods; this is 36 over it, 2.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.
  • TooManyMethods: Chat priv/rust/tui/src/components/chat/mod.rs:48 — TooManyMethods — 50 methods. The bar is 30 methods; this is 20 over it, 1.67× 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.
D31 · IaC & Container Security · Medium IaC · ×9
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Edited copy of a member (18 corresponding lines) · ×9
  • Edited copy of a member (18 corresponding lines) lib/optimal_system_agent/agent/scheduler.ex:319 — lib/optimal_system_agent/agent/scheduler.ex:319-336 | lib/optimal_system_agent/agent/scheduler.ex:401-420 — These two members are one piece of code written twice and then edited apart: 18 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.
  • Edited copy of a member (18 corresponding lines) canopy/backend/lib/canopy_web/controllers/memory_controller.ex:9 — canopy/backend/lib/canopy_web/controllers/memory_controller.ex:9-26 | canopy/backend/lib/canopy_web/controllers/skill_controller.ex:9-26 — These two members are one piece of code written twice and then edited apart: 18 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.
  • Edited copy of a member (18 corresponding lines) priv/rust/tui/src/app/commands.rs:975 — priv/rust/tui/src/app/commands.rs:975-1002 | priv/rust/tui/src/app/handle_dialogs.rs:362-379 — These two members are one piece of code written twice and then edited apart: 18 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.
  • Edited copy of a member (18 corresponding lines) lib/optimal_system_agent/cli/opencomputers.ex:566 — lib/optimal_system_agent/cli/opencomputers.ex:566-583 | lib/optimal_system_agent/open_computers/config.ex:108-125 — These two members are one piece of code written twice and then edited apart: 18 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.
  • Edited copy of a member (18 corresponding lines) lib/optimal_system_agent/agent/background_notifier.ex:290 — lib/optimal_system_agent/agent/background_notifier.ex:290-311 | lib/optimal_system_agent/agent/background_notifier.ex:321-338 — These two members are one piece of code written twice and then edited apart: 18 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.
  • Edited copy of a member (18 corresponding lines) priv/rust/tui/src/components/input/mod.rs:1007 — priv/rust/tui/src/components/input/mod.rs:1007-1026 | priv/rust/tui/src/components/input/mod.rs:1028-1045 — These two members are one piece of code written twice and then edited apart: 18 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.
  • Edited copy of a member (18 corresponding lines) canopy/backend/lib/canopy_web/controllers/agent_controller.ex:125 — canopy/backend/lib/canopy_web/controllers/agent_controller.ex:125-142 | canopy/backend/lib/canopy_web/controllers/workspace_controller.ex:102-121 — These two members are one piece of code written twice and then edited apart: 18 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.
  • Edited copy of a member (18 corresponding lines) priv/rust/tui/src/components/activity.rs:217 — priv/rust/tui/src/components/activity.rs:217-234 | priv/rust/tui/src/util.rs:29-53 — These two members are one piece of code written twice and then edited apart: 18 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.
  • Edited copy of a member (18 corresponding lines) priv/rust/tui/src/app/exit_dump.rs:190 — priv/rust/tui/src/app/exit_dump.rs:190-207 | priv/rust/tui/src/app/self_update.rs:368-387 — These two members are one piece of code written twice and then edited apart: 18 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 (17 corresponding lines) · ×9
  • Edited copy of a member (17 corresponding lines) priv/rust/tui/src/app/commands.rs:1128 — priv/rust/tui/src/app/commands.rs:1128-1148 | priv/rust/tui/src/app/commands.rs:1157-1173 — These two members are one piece of code written twice and then edited apart: 17 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.
  • Edited copy of a member (17 corresponding lines) lib/optimal_system_agent/open_computers/remote/client.ex:129 — lib/optimal_system_agent/open_computers/remote/client.ex:129-149 | lib/optimal_system_agent/open_computers/session.ex:345-361 — These two members are one piece of code written twice and then edited apart: 17 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.
  • Edited copy of a member (17 corresponding lines) lib/optimal_system_agent/open_computers/executor/direct/desktop/macos.ex:52 — lib/optimal_system_agent/open_computers/executor/direct/desktop/macos.ex:52-69 | lib/optimal_system_agent/open_computers/executor/direct/desktop/windows.ex:49-65 — These two members are one piece of code written twice and then edited apart: 17 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.
  • Edited copy of a member (17 corresponding lines) lib/optimal_system_agent/tools/builtins/computer_use/adapters/linux_wayland.ex:61 — lib/optimal_system_agent/tools/builtins/computer_use/adapters/linux_wayland.ex:61-77 | lib/optimal_system_agent/tools/builtins/computer_use/adapters/windows.ex:60-88 — These two members are one piece of code written twice and then edited apart: 17 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.
  • Edited copy of a member (17 corresponding lines) REDACTED:137 — REDACTED:137-161 | REDACTED:175-191 — These two members are one piece of code written twice and then edited apart: 17 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.
  • Edited copy of a member (17 corresponding lines) lib/optimal_system_agent/auth/providers/claude_cli.ex:408 — lib/optimal_system_agent/auth/providers/claude_cli.ex:408-427 | lib/optimal_system_agent/auth/providers/copilot_cli.ex:246-262 — These two members are one piece of code written twice and then edited apart: 17 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.
  • Edited copy of a member (17 corresponding lines) lib/optimal_system_agent/security/anomaly_queue.ex:40 — lib/optimal_system_agent/security/anomaly_queue.ex:40-59 | lib/optimal_system_agent/security/class_queue.ex:35-51 — These two members are one piece of code written twice and then edited apart: 17 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.
  • Edited copy of a member (17 corresponding lines) lib/optimal_system_agent/cli/update.ex:30 — lib/optimal_system_agent/cli/update.ex:30-46 | lib/optimal_system_agent/cli/update.ex:51-68 — These two members are one piece of code written twice and then edited apart: 17 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.
  • Edited copy of a member (17 corresponding lines) lib/optimal_system_agent/open_computers/executor/direct/compose.ex:107 — lib/optimal_system_agent/open_computers/executor/direct/compose.ex:107-128 | lib/optimal_system_agent/open_computers/executor/direct/compose.ex:134-150 — These two members are one piece of code written twice and then edited apart: 17 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 (20 corresponding lines) · ×9
  • Edited copy of a member (20 corresponding lines) lib/optimal_system_agent/open_computers/executor/direct/clipboard.ex:82 — lib/optimal_system_agent/open_computers/executor/direct/clipboard.ex:82-105 | lib/optimal_system_agent/open_computers/executor/direct/clipboard.ex:116-135 — These two members are one piece of code written twice and then edited apart: 20 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.
  • Edited copy of a member (20 corresponding lines) lib/optimal_system_agent/tools/registry.ex:369 — lib/optimal_system_agent/tools/registry.ex:369-390 | lib/optimal_system_agent/tools/registry.ex:489-508 — These two members are one piece of code written twice and then edited apart: 20 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.
  • Edited copy of a member (20 corresponding lines) priv/rust/tui/src/components/chat/message.rs:826 — priv/rust/tui/src/components/chat/message.rs:826-845 | priv/rust/tui/src/render/markdown.rs:623-643 — These two members are one piece of code written twice and then edited apart: 20 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.
  • Edited copy of a member (20 corresponding lines) lib/optimal_system_agent/agent/persisted_result.ex:96 — lib/optimal_system_agent/agent/persisted_result.ex:96-120 | lib/optimal_system_agent/store/skill_library.ex:130-149 — These two members are one piece of code written twice and then edited apart: 20 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.
  • Edited copy of a member (20 corresponding lines) priv/rust/tui/src/dialogs/claude_login.rs:297 — priv/rust/tui/src/dialogs/claude_login.rs:297-316 | priv/rust/tui/src/dialogs/claude_login.rs:318-339 — These two members are one piece of code written twice and then edited apart: 20 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.
  • Edited copy of a member (20 corresponding lines) lib/optimal_system_agent/store/session_transcript.ex:73 — lib/optimal_system_agent/store/session_transcript.ex:73-92 | lib/optimal_system_agent/store/session_transcript.ex:101-121 — These two members are one piece of code written twice and then edited apart: 20 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.
  • Edited copy of a member (20 corresponding lines) lib/optimal_system_agent/tools/ablation/runner.ex:897 — lib/optimal_system_agent/tools/ablation/runner.ex:897-916 | lib/optimal_system_agent/tools/ablation/runner.ex:923-947 — These two members are one piece of code written twice and then edited apart: 20 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.
  • Edited copy of a member (20 corresponding lines) lib/optimal_system_agent/open_computers/executor/direct/compose.ex:399 — lib/optimal_system_agent/open_computers/executor/direct/compose.ex:399-418 | lib/optimal_system_agent/open_computers/executor/direct/compose.ex:472-491 — These two members are one piece of code written twice and then edited apart: 20 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.
  • Edited copy of a member (20 corresponding lines) lib/optimal_system_agent/budget/budget.ex:330 — lib/optimal_system_agent/budget/budget.ex:330-350 | lib/optimal_system_agent/budget/budget.ex:355-374 — These two members are one piece of code written twice and then edited apart: 20 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 (1 corresponding lines) · ×9
  • Edited copy of a member (1 corresponding lines) lib/optimal_system_agent/tools/builtins/download/handler.ex:121 — lib/optimal_system_agent/tools/builtins/download/handler.ex:121-121 | lib/optimal_system_agent/tools/builtins/web_fetch/handler.ex:135-135 — These two members are one piece of code written twice and then edited apart: 1 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.
  • Edited copy of a member (1 corresponding lines) lib/optimal_system_agent/agent/safety/command_variants.ex:392 — lib/optimal_system_agent/agent/safety/command_variants.ex:392-392 | lib/optimal_system_agent/tools/builtins/shell_execute/parser.ex:583-583 — These two members are one piece of code written twice and then edited apart: 1 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.
  • Edited copy of a member (1 corresponding lines) lib/optimal_system_agent/providers/ollama.ex:1869 — lib/optimal_system_agent/providers/ollama.ex:1869-1869 | lib/optimal_system_agent/providers/openai_compat.ex:1636-1636 — These two members are one piece of code written twice and then edited apart: 1 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.
  • Edited copy of a member (1 corresponding lines) lib/optimal_system_agent/action_authority.ex:76 — lib/optimal_system_agent/action_authority.ex:76-77 | lib/optimal_system_agent/agent/loop/durable_log.ex:268-268 — These two members are one piece of code written twice and then edited apart: 1 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.
  • Edited copy of a member (1 corresponding lines) lib/optimal_system_agent/agent/safety/model_classifier.ex:391 — lib/optimal_system_agent/agent/safety/model_classifier.ex:391-391 | lib/optimal_system_agent/permissions/auto_classifier.ex:466-466 — These two members are one piece of code written twice and then edited apart: 1 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.
  • Edited copy of a member (1 corresponding lines) lib/optimal_system_agent/repo_map.ex:374 — lib/optimal_system_agent/repo_map.ex:374-374 | lib/optimal_system_agent/workspace/fast_worktree/populate.ex:328-328 — These two members are one piece of code written twice and then edited apart: 1 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.
  • Edited copy of a member (1 corresponding lines) lib/optimal_system_agent/agent/loop/message_handler.ex:270 — lib/optimal_system_agent/agent/loop/message_handler.ex:270-270 | lib/optimal_system_agent/tools/builtins/file_read/magic.ex:69-70 — These two members are one piece of code written twice and then edited apart: 1 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.
  • Edited copy of a member (1 corresponding lines) lib/optimal_system_agent/agent/execution_control.ex:228 — lib/optimal_system_agent/agent/execution_control.ex:228-229 | lib/optimal_system_agent/agent/loop/tool_discovery.ex:143-143 — These two members are one piece of code written twice and then edited apart: 1 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.
  • Edited copy of a member (1 corresponding lines) lib/optimal_system_agent/providers/image_budget.ex:657 — lib/optimal_system_agent/providers/image_budget.ex:657-657 | lib/optimal_system_agent/providers/ollama.ex:1203-1204 — These two members are one piece of code written twice and then edited apart: 1 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 (21 corresponding lines) · ×8
  • Edited copy of a member (21 corresponding lines) lib/optimal_system_agent/providers/openai_compat.ex:2353 — lib/optimal_system_agent/providers/openai_compat.ex:2353-2377 | lib/optimal_system_agent/providers/retry_classifier.ex:483-503 — These two members are one piece of code written twice and then edited apart: 21 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.
  • Edited copy of a member (21 corresponding lines) lib/optimal_system_agent/agent/tasks/workflow.ex:289 — lib/optimal_system_agent/agent/tasks/workflow.ex:289-309 | lib/optimal_system_agent/agent/workflow.ex:135-158 — These two members are one piece of code written twice and then edited apart: 21 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.
  • Edited copy of a member (21 corresponding lines) lib/optimal_system_agent/agent/compactor.ex:2002 — lib/optimal_system_agent/agent/compactor.ex:2002-2024 | lib/optimal_system_agent/agent/loop/proactive_compaction.ex:901-921 — These two members are one piece of code written twice and then edited apart: 21 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.
  • Edited copy of a member (21 corresponding lines) priv/rust/tui/src/client/http.rs:1231 — priv/rust/tui/src/client/http.rs:1231-1251 | priv/rust/tui/src/client/http.rs:1263-1289 — These two members are one piece of code written twice and then edited apart: 21 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.
  • Edited copy of a member (21 corresponding lines) lib/optimal_system_agent/agent/loop/goal_verifier.ex:784 — lib/optimal_system_agent/agent/loop/goal_verifier.ex:784-804 | lib/optimal_system_agent/agent/loop/spot_check_auditor.ex:413-434 — These two members are one piece of code written twice and then edited apart: 21 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.
  • Edited copy of a member (21 corresponding lines) lib/optimal_system_agent/channels/cli/commands.ex:825 — lib/optimal_system_agent/channels/cli/commands.ex:825-845 | lib/optimal_system_agent/channels/cli/commands.ex:932-952 — These two members are one piece of code written twice and then edited apart: 21 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.
  • Edited copy of a member (21 corresponding lines) lib/optimal_system_agent/tools/builtins/browser.ex:249 — lib/optimal_system_agent/tools/builtins/browser.ex:249-269 | lib/optimal_system_agent/tools/builtins/browser.ex:273-294 — These two members are one piece of code written twice and then edited apart: 21 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.
  • Edited copy of a member (21 corresponding lines) lib/optimal_system_agent/tools/builtins/computer_use/adapters/remote_ssh.ex:324 — lib/optimal_system_agent/tools/builtins/computer_use/adapters/remote_ssh.ex:324-344 | lib/optimal_system_agent/tools/builtins/computer_use/adapters/remote_ssh.ex:348-374 — These two members are one piece of code written twice and then edited apart: 21 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 · Duplicated block (17 lines × 2) · ×8
  • Duplicated block (17 lines × 2) canopy/backend/lib/canopy/adapters/bash.ex:38 — canopy/backend/lib/canopy/adapters/bash.ex:38-54 | canopy/backend/lib/canopy/adapters/codex.ex:40-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 `canopy/backend/lib/canopy/adapters/bash.ex: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.
  • Duplicated block (17 lines × 2) lib/optimal_system_agent/agent/task_queue.ex:276 — lib/optimal_system_agent/agent/task_queue.ex:276-292 | lib/optimal_system_agent/agent/tasks/queue.ex:174-190 — before extracting anything, compare `lib/optimal_system_agent/agent/task_queue.ex` and `lib/optimal_system_agent/agent/tasks/queue.ex` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 149 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 (17 lines × 2) lib/optimal_system_agent/tools/builtins/browser.ex:41 — lib/optimal_system_agent/tools/builtins/browser.ex:41-57 | lib/optimal_system_agent/tools/builtins/delegate/tool.ex:130-146 — before extracting anything, compare `lib/optimal_system_agent/tools/builtins/browser.ex` and `lib/optimal_system_agent/tools/builtins/delegate/tool.ex` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 85 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 `lib/optimal_system_agent/tools/builtins/browser.ex:41` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (17 lines × 2) lib/optimal_system_agent/tools/builtins/computer_use/tool.ex:62 — lib/optimal_system_agent/tools/builtins/computer_use/tool.ex:62-78 | lib/optimal_system_agent/tools/builtins/pty/pty_wait.ex:53-69 — 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 `lib/optimal_system_agent/tools/builtins/computer_use/tool.ex:62` 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 (17 lines × 2) lib/optimal_system_agent/tools/builtins/computer_use/tool.ex:74 — lib/optimal_system_agent/tools/builtins/computer_use/tool.ex:74-90 | lib/optimal_system_agent/tools/builtins/delegate/tool.ex:84-101 — `lib/optimal_system_agent/tools/builtins/computer_use/tool.ex` and `lib/optimal_system_agent/tools/builtins/delegate/tool.ex` 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 69 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 `lib/optimal_system_agent/tools/builtins/computer_use/tool.ex:74` 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 (17 lines × 2) lib/optimal_system_agent/providers/claude_cli.ex:323 — lib/optimal_system_agent/providers/claude_cli.ex:323-339 | lib/optimal_system_agent/providers/copilot_cli.ex:268-284 — before extracting anything, compare `lib/optimal_system_agent/providers/claude_cli.ex` and `lib/optimal_system_agent/providers/copilot_cli.ex` as WHOLE FILES: this scan already matched 7 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. 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 (17 lines × 2) priv/rust/tui/src/dialogs/claude_login.rs:567 — priv/rust/tui/src/dialogs/claude_login.rs:567-583 | priv/rust/tui/src/dialogs/claude_login.rs:625-641 — 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 `priv/rust/tui/src/dialogs/claude_login.rs:567` 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 (17 lines × 2) priv/rust/tui/src/view/onboarding_flow.rs:359 — priv/rust/tui/src/view/onboarding_flow.rs:359-375 | priv/rust/tui/src/view/onboarding_flow.rs:562-578 — 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 (15 lines × 2) · ×8
  • Duplicated block (15 lines × 2) priv/rust/tui/src/app/commands.rs:937 — priv/rust/tui/src/app/commands.rs:937-951 | priv/rust/tui/src/app/commands.rs:959-973 — 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 `priv/rust/tui/src/app/commands.rs:937` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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) priv/rust/tui/src/app/event_loop.rs:1794 — priv/rust/tui/src/app/event_loop.rs:1794-1808 | priv/rust/tui/src/app/event_loop.rs:1823-1837 — 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 `priv/rust/tui/src/app/event_loop.rs:1794` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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) priv/rust/tui/src/components/chat/message.rs:556 — priv/rust/tui/src/components/chat/message.rs:556-570 | priv/rust/tui/src/components/chat/message.rs:606-620 — 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 `priv/rust/tui/src/components/chat/message.rs:556` 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) priv/rust/tui/src/components/input/mod.rs:3407 — priv/rust/tui/src/components/input/mod.rs:3407-3421 | priv/rust/tui/src/render/markdown.rs:1639-1653 — 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 (15 lines × 2) priv/rust/tui/src/dialogs/file_picker.rs:359 — priv/rust/tui/src/dialogs/file_picker.rs:359-373 | priv/rust/tui/src/dialogs/sessions.rs:400-417 — before extracting anything, compare `priv/rust/tui/src/dialogs/file_picker.rs` and `priv/rust/tui/src/dialogs/sessions.rs` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 97 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 `priv/rust/tui/src/dialogs/file_picker.rs:359` 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) priv/rust/tui/src/dialogs/reasoning.rs:205 — priv/rust/tui/src/dialogs/reasoning.rs:205-219 | priv/rust/tui/src/dialogs/sessions.rs:356-370 — before extracting anything, compare `priv/rust/tui/src/dialogs/reasoning.rs` and `priv/rust/tui/src/dialogs/sessions.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 68 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 (15 lines × 2) priv/rust/tui/src/tools/diagnostics.rs:38 — priv/rust/tui/src/tools/diagnostics.rs:38-52 | priv/rust/tui/src/tools/todos.rs:30-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. Read the line range as the matched WINDOW rather than a finished unit: at `priv/rust/tui/src/tools/diagnostics.rs: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.
  • Duplicated block (15 lines × 2) bench/swebench/run_bench.py:485 — bench/swebench/run_bench.py:485-499 | bench/swebenchpro/run_bench.py:327-341 — `bench/swebench/run_bench.py` and `bench/swebenchpro/run_bench.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 202 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.
D30 · Dependency Vulnerabilities · Medium advisory (unmaintained) · ×7
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Edited copy of a member (26 corresponding lines) · ×7
  • Edited copy of a member (26 corresponding lines) lib/optimal_system_agent/telemetry/metrics.ex:127 — lib/optimal_system_agent/telemetry/metrics.ex:127-152 | lib/optimal_system_agent/telemetry/metrics.ex:157-182 — These two members are one piece of code written twice and then edited apart: 26 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.
  • Edited copy of a member (26 corresponding lines) priv/rust/tui/src/components/chat/mod.rs:607 — priv/rust/tui/src/components/chat/mod.rs:607-642 | priv/rust/tui/src/components/chat/mod.rs:646-671 — These two members are one piece of code written twice and then edited apart: 26 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.
  • Edited copy of a member (26 corresponding lines) lib/optimal_system_agent/onboarding.ex:1287 — lib/optimal_system_agent/onboarding.ex:1287-1312 | lib/optimal_system_agent/onboarding.ex:3061-3092 — These two members are one piece of code written twice and then edited apart: 26 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.
  • Edited copy of a member (26 corresponding lines) lib/optimal_system_agent/decisions/graph.ex:232 — lib/optimal_system_agent/decisions/graph.ex:232-257 | lib/optimal_system_agent/decisions/graph.ex:270-295 — These two members are one piece of code written twice and then edited apart: 26 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.
  • Edited copy of a member (26 corresponding lines) lib/mix/tasks/osa.setup.wizard.ex:293 — lib/mix/tasks/osa.setup.wizard.ex:293-324 | lib/optimal_system_agent/cli/setup.ex:322-347 — These two members are one piece of code written twice and then edited apart: 26 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.
  • Edited copy of a member (26 corresponding lines) lib/optimal_system_agent/tools/builtins/bash_output/tool.ex:40 — lib/optimal_system_agent/tools/builtins/bash_output/tool.ex:40-65 | lib/optimal_system_agent/tools/builtins/task_wait/tool.ex:54-82 — These two members are one piece of code written twice and then edited apart: 26 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.
  • Edited copy of a member (26 corresponding lines) lib/optimal_system_agent/sandbox/e2b.ex:107 — lib/optimal_system_agent/sandbox/e2b.ex:107-139 | lib/optimal_system_agent/sandbox/vercel.ex:102-127 — These two members are one piece of code written twice and then edited apart: 26 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 (23 corresponding lines) · ×7
  • Edited copy of a member (23 corresponding lines) priv/rust/tui/src/dialogs/sandbox_picker.rs:87 — priv/rust/tui/src/dialogs/sandbox_picker.rs:87-114 | priv/rust/tui/src/dialogs/theme_picker.rs:72-94 — These two members are one piece of code written twice and then edited apart: 23 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.
  • Edited copy of a member (23 corresponding lines) canopy/backend/lib/canopy_web/controllers/activity_controller.ex:47 — canopy/backend/lib/canopy_web/controllers/activity_controller.ex:47-69 | canopy/backend/lib/canopy_web/controllers/log_controller.ex:21-51 — These two members are one piece of code written twice and then edited apart: 23 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.
  • Edited copy of a member (23 corresponding lines) canopy/backend/lib/canopy/costs.ex:73 — canopy/backend/lib/canopy/costs.ex:73-95 | canopy/backend/lib/canopy_web/controllers/cost_controller.ex:102-127 — These two members are one piece of code written twice and then edited apart: 23 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.
  • Edited copy of a member (23 corresponding lines) lib/optimal_system_agent/tools/builtins/file_read.ex:116 — lib/optimal_system_agent/tools/builtins/file_read.ex:116-138 | lib/optimal_system_agent/tools/builtins/file_read/handler.ex:785-811 — These two members are one piece of code written twice and then edited apart: 23 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.
  • Edited copy of a member (23 corresponding lines) lib/optimal_system_agent/agent/tasks/tracker.ex:166 — lib/optimal_system_agent/agent/tasks/tracker.ex:166-194 | lib/optimal_system_agent/agent/tasks/tracker.ex:236-258 — These two members are one piece of code written twice and then edited apart: 23 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.
  • Edited copy of a member (23 corresponding lines) priv/rust/tui/src/components/input/vim.rs:94 — priv/rust/tui/src/components/input/vim.rs:94-116 | priv/rust/tui/src/components/input/vim.rs:144-172 — These two members are one piece of code written twice and then edited apart: 23 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.
  • Edited copy of a member (23 corresponding lines) lib/optimal_system_agent/tools/builtins/code_sandbox.ex:73 — lib/optimal_system_agent/tools/builtins/code_sandbox.ex:73-95 | lib/optimal_system_agent/tools/builtins/pty/pty_wait.ex:50-72 — These two members are one piece of code written twice and then edited apart: 23 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 · Duplicated block (16 lines × 2) · ×7
  • Duplicated block (16 lines × 2) canopy/backend/lib/canopy/budget_enforcer.ex:154 — canopy/backend/lib/canopy/budget_enforcer.ex:154-169 | canopy/backend/lib/canopy/budget_enforcer.ex:204-219 — 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 `canopy/backend/lib/canopy/budget_enforcer.ex:154` 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 × 2) canopy/backend/lib/canopy/costs.ex:23 — canopy/backend/lib/canopy/costs.ex:23-38 | canopy/backend/lib/canopy_web/controllers/cost_controller.ex:44-59 — before extracting anything, compare `canopy/backend/lib/canopy/costs.ex` and `canopy/backend/lib/canopy_web/controllers/cost_controller.ex` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 78 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 (16 lines × 2) lib/optimal_system_agent/agent/safety/model_classifier.ex:250 — lib/optimal_system_agent/agent/safety/model_classifier.ex:250-265 | lib/optimal_system_agent/permissions/auto_classifier.ex:301-316 — before extracting anything, compare `lib/optimal_system_agent/agent/safety/model_classifier.ex` and `lib/optimal_system_agent/permissions/auto_classifier.ex` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 33 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 `lib/optimal_system_agent/agent/safety/model_classifier.ex:250` 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) lib/optimal_system_agent/agent/tasks/workflow.ex:516 — lib/optimal_system_agent/agent/tasks/workflow.ex:516-531 | lib/optimal_system_agent/agent/workflow.ex:628-643 — before extracting anything, compare `lib/optimal_system_agent/agent/tasks/workflow.ex` and `lib/optimal_system_agent/agent/workflow.ex` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 285 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 (16 lines × 2) lib/optimal_system_agent/tools/builtins/rollback/tool.ex:44 — lib/optimal_system_agent/tools/builtins/rollback/tool.ex:44-60 | lib/optimal_system_agent/tools/builtins/workspace_map.ex:74-89 — 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 `lib/optimal_system_agent/tools/builtins/workspace_map.ex:74` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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) lib/optimal_system_agent/tools/builtins/multi_file_edit/prompt.ex:8 — lib/optimal_system_agent/tools/builtins/multi_file_edit/prompt.ex:8-23 | lib/optimal_system_agent/tools/builtins/task_write/prompt.ex:24-57 — 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 (16 lines × 2) priv/rust/tui/src/components/chat/message.rs:618 — priv/rust/tui/src/components/chat/message.rs:618-633 | priv/rust/tui/src/components/chat/message.rs:659-674 — 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, `priv/rust/tui/src/components/chat/message.rs:634` calls `saturating_sub` and `priv/rust/tui/src/components/chat/message.rs:677` 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 (9 lines × 3) · ×7
  • Duplicated block (9 lines × 3) canopy/backend/lib/canopy_web/controllers/agent_controller.ex:26 — canopy/backend/lib/canopy_web/controllers/agent_controller.ex:26-34 | canopy/backend/lib/canopy_web/controllers/skill_controller.ex:98-106 | canopy/backend/lib/canopy_web/controllers/webhook_controller.ex:33-41 — 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 `canopy/backend/lib/canopy_web/controllers/agent_controller.ex:26` 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 × 3) lib/optimal_system_agent/tools/builtins/code_symbols/handler.ex:286 — lib/optimal_system_agent/tools/builtins/code_symbols/handler.ex:286-294 | lib/optimal_system_agent/tools/builtins/code_symbols/handler.ex:311-319 | lib/optimal_system_agent/tools/builtins/code_symbols/handler.ex:406-414 — 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 `lib/optimal_system_agent/tools/builtins/code_symbols/handler.ex:286` 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 × 3) lib/optimal_system_agent/channels/http/api/approval_routes.ex:142 — lib/optimal_system_agent/channels/http/api/approval_routes.ex:142-150 | lib/optimal_system_agent/channels/http/api/issue_routes.ex:197-205 | lib/optimal_system_agent/channels/http/api/project_routes.ex:327-335 — 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 (9 lines × 3) priv/rust/tui/src/components/notify.rs:74 — priv/rust/tui/src/components/notify.rs:74-82 | priv/rust/tui/src/notification/kitty.rs:56-64 | priv/rust/tui/src/notification/progress.rs:73-81 — 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. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (9 lines × 3) priv/rust/tui/src/dialogs/mcp_approval.rs:186 — priv/rust/tui/src/dialogs/mcp_approval.rs:186-194 | priv/rust/tui/src/dialogs/onboarding.rs:1065-1073 | priv/rust/tui/src/dialogs/trust.rs:92-100 — before extracting anything, compare `priv/rust/tui/src/dialogs/mcp_approval.rs` and `priv/rust/tui/src/dialogs/trust.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 51 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 `priv/rust/tui/src/dialogs/mcp_approval.rs: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 (9 lines × 3) priv/rust/tui/src/tools/search.rs:56 — priv/rust/tui/src/tools/search.rs:56-64 | priv/rust/tui/src/tools/search.rs:117-125 | priv/rust/tui/src/tools/search.rs:205-213 — 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 `priv/rust/tui/src/tools/search.rs:56` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (9 lines × 3) priv/rust/tui/src/client/http.rs:1478 — priv/rust/tui/src/client/http.rs:1478-1486 | priv/rust/tui/src/client/http.rs:1494-1502 | priv/rust/tui/src/client/http.rs:1510-1518 — 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.
D2 · Cognitive Complexity · ModelPicker · ×6
  • ModelPicker::draw_local_catalog (cognitive 34) priv/rust/tui/src/dialogs/model_picker/local.rs:493 — ModelPicker::draw_local_catalog has cognitive complexity 34 (threshold 15). Drivers by points: if/else 13 (27 pts), match/switch 2 (5 pts), boolean chains 1, loops 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.
  • ModelPicker::draw_local_detail (cognitive 33) priv/rust/tui/src/dialogs/model_picker/local.rs:622 — ModelPicker::draw_local_detail has cognitive complexity 33 (threshold 15). Drivers by points: if/else 22 (30 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.
  • ModelPicker::draw_models (cognitive 33) priv/rust/tui/src/dialogs/model_picker.rs:1989 — ModelPicker::draw_models has cognitive complexity 33 (threshold 15). Drivers by points: if/else 19 (31 pts), boolean chains 1, 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.
  • ModelPicker::draw_key_entry (cognitive 26) priv/rust/tui/src/dialogs/model_picker.rs:2386 — ModelPicker::draw_key_entry has cognitive complexity 26 (threshold 15). Drivers by points: if/else 11 (17 pts), match/switch 5 (7 pts), loops 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.
  • ModelPicker::draw_providers (cognitive 25) priv/rust/tui/src/dialogs/model_picker.rs:1605 — ModelPicker::draw_providers has cognitive complexity 25 (threshold 15). Drivers by points: if/else 13 (20 pts), loops 2, match/switch 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.
  • ModelPicker::handle_local_detail_key (cognitive 16) priv/rust/tui/src/dialogs/model_picker/local.rs:281 — ModelPicker::handle_local_detail_key has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (15 pts), match/switch 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.
D3 · God Classes · TooManyFields · ×6
  • TooManyFields: App priv/rust/tui/src/app/mod.rs:104 — TooManyFields — 136 stored fields beside 226 methods. The bar is 30 stored fields; this is 106 over it, 4.53× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: Activity priv/rust/tui/src/components/activity.rs:514 — TooManyFields — 53 stored fields beside 80 methods. The bar is 30 stored fields; this is 23 over it, 1.77× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: StatusBar priv/rust/tui/src/components/status_bar.rs:510 — TooManyFields — 48 stored fields beside 66 methods. The bar is 30 stored fields; this is 18 over it, 1.60× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: InputComponent priv/rust/tui/src/components/input/mod.rs:82 — TooManyFields — 41 stored fields beside 103 methods. The bar is 30 stored fields; this is 11 over it, 1.37× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: ModelPicker priv/rust/tui/src/dialogs/model_picker.rs:239 — TooManyFields — 33 stored fields beside 94 methods. The bar is 30 stored fields; this is 3 over it, 1.10× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: ThemeColors priv/rust/tui/src/style/mod.rs:11 — TooManyFields — 31 stored fields. The bar is 30 stored fields; this is 1 over it, 1.03× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
D4 · Code Duplication · Edited copy of a member (24 corresponding lines) · ×6
  • Edited copy of a member (24 corresponding lines) priv/rust/tui/src/components/input/mod.rs:1557 — priv/rust/tui/src/components/input/mod.rs:1557-1581 | priv/rust/tui/src/components/input/mod.rs:1584-1607 — These two members are one piece of code written twice and then edited apart: 24 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.
  • Edited copy of a member (24 corresponding lines) priv/rust/tui/src/dialogs/command_palette.rs:308 — priv/rust/tui/src/dialogs/command_palette.rs:308-331 | priv/rust/tui/src/dialogs/picker.rs:306-330 — These two members are one piece of code written twice and then edited apart: 24 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.
  • Edited copy of a member (24 corresponding lines) lib/optimal_system_agent/open_computers/executor/direct/fs.ex:103 — lib/optimal_system_agent/open_computers/executor/direct/fs.ex:103-126 | lib/optimal_system_agent/open_computers/executor/direct/fs.ex:134-164 — These two members are one piece of code written twice and then edited apart: 24 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.
  • Edited copy of a member (24 corresponding lines) lib/optimal_system_agent/agent/loop/goal_tracker.ex:1692 — lib/optimal_system_agent/agent/loop/goal_tracker.ex:1692-1715 | lib/optimal_system_agent/agent/loop/goal_verifier.ex:1988-2017 — These two members are one piece of code written twice and then edited apart: 24 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.
  • Edited copy of a member (24 corresponding lines) lib/optimal_system_agent/peer/discovery.ex:138 — lib/optimal_system_agent/peer/discovery.ex:138-164 | lib/optimal_system_agent/peer/review.ex:100-123 — These two members are one piece of code written twice and then edited apart: 24 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.
  • Edited copy of a member (24 corresponding lines) lib/optimal_system_agent/tools/builtins/browser.ex:35 — lib/optimal_system_agent/tools/builtins/browser.ex:35-65 | lib/optimal_system_agent/tools/builtins/goal/create_tool.ex:41-64 — These two members are one piece of code written twice and then edited apart: 24 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 copies of one member (3 members, 4+ corresponding lines) · ×6
  • Edited copies of one member (3 members, 4+ corresponding lines) lib/optimal_system_agent/security/shadow_graph.ex:150 — lib/optimal_system_agent/security/shadow_graph.ex:150-153 | lib/optimal_system_agent/security/shadow_graph.ex:159-162 | lib/optimal_system_agent/security/shadow_graph.ex:168-171 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 4 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 4+ corresponding lines) lib/optimal_system_agent/tools/builtins/computer_use/adapters/linux_wayland.ex:276 — lib/optimal_system_agent/tools/builtins/computer_use/adapters/linux_wayland.ex:276-279 | lib/optimal_system_agent/tools/builtins/computer_use/adapters/linux_x11.ex:394-397 | lib/optimal_system_agent/tools/builtins/computer_use/adapters/macos.ex:883-886 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 4 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 4+ corresponding lines) lib/optimal_system_agent/agent/loop/context_collapse.ex:244 — lib/optimal_system_agent/agent/loop/context_collapse.ex:244-247 | lib/optimal_system_agent/agent/loop/tool_result_storage.ex:444-447 | lib/optimal_system_agent/agent/session_id.ex:141-144 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 4 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 4+ corresponding lines) lib/optimal_system_agent/agent/loop/message_handler.ex:233 — lib/optimal_system_agent/agent/loop/message_handler.ex:233-236 | lib/optimal_system_agent/agent/loop/tool_result_storage.ex:488-492 | lib/optimal_system_agent/bench/workspace.ex:165-168 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 4 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 4+ corresponding lines) lib/optimal_system_agent/auth/providers/minimax.ex:363 — lib/optimal_system_agent/auth/providers/minimax.ex:363-366 | REDACTED:322-325 | lib/optimal_system_agent/auth/providers/xai.ex:116-119 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 4 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 4+ corresponding lines) lib/optimal_system_agent/open_computers/executor/direct/desktop/macos.ex:164 — lib/optimal_system_agent/open_computers/executor/direct/desktop/macos.ex:164-167 | lib/optimal_system_agent/open_computers/executor/direct/desktop/windows.ex:166-169 | lib/optimal_system_agent/open_computers/executor/direct/desktop/x11vnc.ex:189-192 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 4 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Duplicated block (8 lines × 3) · ×6
  • Duplicated block (8 lines × 3) canopy/backend/lib/canopy_web/controllers/alert_controller.ex:129 — canopy/backend/lib/canopy_web/controllers/alert_controller.ex:129-136 | canopy/backend/lib/canopy_web/controllers/budget_controller.ex:60-67 | canopy/backend/lib/canopy_web/controllers/skill_controller.ex:18-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 all 3 call sites, so a change lands once.
  • Duplicated block (8 lines × 3) lib/optimal_system_agent/agent/safety/model_classifier.ex:251 — lib/optimal_system_agent/agent/safety/model_classifier.ex:251-258 | lib/optimal_system_agent/auth/providers/claude_cli.ex:216-223 | lib/optimal_system_agent/permissions/auto_classifier.ex:302-309 — before extracting anything, compare `lib/optimal_system_agent/agent/safety/model_classifier.ex` and `lib/optimal_system_agent/permissions/auto_classifier.ex` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 33 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 × 3) lib/optimal_system_agent/agent/compact_restore.ex:30 — lib/optimal_system_agent/agent/compact_restore.ex:30-37 | lib/optimal_system_agent/agent/loop/proactive_compaction.ex:664-671 | lib/optimal_system_agent/memory/flush.ex:559-566 — 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 `lib/optimal_system_agent/agent/compact_restore.ex:30` 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) Formula/miosa.rb:48 — Formula/miosa.rb:48-55 | Formula/osa.rb:67-74 | Formula/osagent.rb:48-55 — 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 (8 lines × 3) priv/rust/tui/src/app/commands.rs:1141 — priv/rust/tui/src/app/commands.rs:1141-1148 | priv/rust/tui/src/app/commands.rs:1166-1173 | priv/rust/tui/src/app/handle_actions.rs:1014-1021 — 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 `priv/rust/tui/src/app/commands.rs:1141` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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) priv/rust/tui/src/dialogs/mcp_approval.rs:239 — priv/rust/tui/src/dialogs/mcp_approval.rs:239-246 | priv/rust/tui/src/dialogs/onboarding.rs:1321-1328 | priv/rust/tui/src/dialogs/trust.rs:151-158 — before extracting anything, compare `priv/rust/tui/src/dialogs/mcp_approval.rs` and `priv/rust/tui/src/dialogs/trust.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 51 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 `priv/rust/tui/src/dialogs/mcp_approval.rs:239` 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 × 3) · ×6
  • Duplicated block (7 lines × 3) lib/miosa/shims.ex:956 — lib/miosa/shims.ex:956-962 | lib/optimal_system_agent/budget/budget.ex:473-479 | lib/optimal_system_agent/budget/treasury.ex:311-317 — 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 (7 lines × 3) lib/optimal_system_agent/conversations/strategies/weighted.ex:155 — lib/optimal_system_agent/conversations/strategies/weighted.ex:155-161 | lib/optimal_system_agent/memory/scoring.ex:84-90 | lib/optimal_system_agent/memory/store.ex:805-811 — 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 (7 lines × 3) lib/optimal_system_agent/tools/builtins/file_glob/ui.ex:22 — lib/optimal_system_agent/tools/builtins/file_glob/ui.ex:22-28 | lib/optimal_system_agent/tools/builtins/file_grep/ui.ex:29-35 | lib/optimal_system_agent/tools/builtins/file_read/ui.ex:28-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.
  • Duplicated block (7 lines × 3) priv/rust/tui/src/app/handle_actions.rs:2150 — priv/rust/tui/src/app/handle_actions.rs:2150-2156 | priv/rust/tui/src/app/handle_actions.rs:2162-2168 | priv/rust/tui/src/app/handle_actions.rs:2173-2179 — 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 `priv/rust/tui/src/app/handle_actions.rs:2150` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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 × 3) priv/rust/tui/src/client/sse.rs:2122 — priv/rust/tui/src/client/sse.rs:2122-2128 | priv/rust/tui/src/client/sse.rs:2388-2394 | priv/rust/tui/src/client/sse.rs:2489-2495 — 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 `priv/rust/tui/src/client/sse.rs:2122` 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 × 3) priv/rust/tui/src/dialogs/file_picker.rs:264 — priv/rust/tui/src/dialogs/file_picker.rs:264-270 | priv/rust/tui/src/dialogs/reasoning.rs:180-186 | priv/rust/tui/src/dialogs/rewind.rs:164-170 — before extracting anything, compare `priv/rust/tui/src/dialogs/file_picker.rs` and `priv/rust/tui/src/dialogs/reasoning.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 61 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.
D2 · Cognitive Complexity · InputComponent · ×5
  • InputComponent::draw (cognitive 131) priv/rust/tui/src/components/input/mod.rs:2747 — InputComponent::draw has cognitive complexity 131 (threshold 15). Drivers by points: if/else 72 (116 pts), boolean chains 9, loops 1 (3 pts), match/switch 1 (3 pts) (nesting depth added 48). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • InputComponent::handle_event (cognitive 107) priv/rust/tui/src/components/input/mod.rs:2293 — InputComponent::handle_event has cognitive complexity 107 (threshold 15). Drivers by points: if/else 30 (79 pts), boolean chains 15, match/switch 5 (13 pts) (nesting depth added 57). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • InputComponent::top_level_candidates (cognitive 20) priv/rust/tui/src/components/input/mod.rs:1312 — InputComponent::top_level_candidates has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 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.
  • InputComponent::delete_char (cognitive 17) priv/rust/tui/src/components/input/mod.rs:954 — InputComponent::delete_char has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 5 (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.
  • InputComponent::walk_dir (cognitive 16) priv/rust/tui/src/components/input/mod.rs:1345 — InputComponent::walk_dir has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (11 pts), boolean chains 3, loops 1, match/switch 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.
D4 · Code Duplication · Edited copy of a member (38 corresponding lines) · ×5
  • Edited copy of a member (38 corresponding lines) priv/rust/tui/src/render/latex.rs:307 — priv/rust/tui/src/render/latex.rs:307-372 | priv/rust/tui/src/render/latex.rs:374-411 — 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.
  • Edited copy of a member (38 corresponding lines) priv/rust/tui/src/app/update.rs:671 — priv/rust/tui/src/app/update.rs:671-708 | priv/rust/tui/src/app/update.rs:737-787 — 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.
  • Edited copy of a member (38 corresponding lines) priv/rust/tui/src/app/handle_actions.rs:1298 — priv/rust/tui/src/app/handle_actions.rs:1298-1342 | priv/rust/tui/src/app/handle_dialogs.rs:1353-1390 — 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.
  • Edited copy of a member (38 corresponding lines) lib/optimal_system_agent/channels/cli/session.ex:298 — lib/optimal_system_agent/channels/cli/session.ex:298-335 | lib/optimal_system_agent/channels/cli/session.ex:453-490 — 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.
  • Edited copy of a member (38 corresponding lines) lib/optimal_system_agent/providers/cohere.ex:60 — lib/optimal_system_agent/providers/cohere.ex:60-108 | lib/optimal_system_agent/providers/google.ex:152-189 — 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 copies of one member (3 members, 11+ corresponding lines) · ×5
  • Edited copies of one member (3 members, 11+ corresponding lines) priv/rust/tui/src/app/handle_actions.rs:1437 — priv/rust/tui/src/app/handle_actions.rs:1437-1447 | priv/rust/tui/src/app/handle_actions.rs:1484-1494 | priv/rust/tui/src/app/handle_actions.rs:1774-1784 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 11 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 11+ corresponding lines) priv/rust/tui/src/components/input/mod.rs:1986 — priv/rust/tui/src/components/input/mod.rs:1986-1997 | priv/rust/tui/src/components/input/mod.rs:2097-2107 | priv/rust/tui/src/components/input/mod.rs:2124-2134 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 11 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 11+ corresponding lines) lib/optimal_system_agent/channels/dingtalk.ex:69 — lib/optimal_system_agent/channels/dingtalk.ex:69-79 | lib/optimal_system_agent/channels/line.ex:76-86 | lib/optimal_system_agent/channels/wecom.ex:64-79 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 11 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 11+ corresponding lines) lib/optimal_system_agent/providers/deepseek_models.ex:224 — lib/optimal_system_agent/providers/deepseek_models.ex:224-234 | lib/optimal_system_agent/providers/google_models.ex:267-277 | lib/optimal_system_agent/providers/openai_models.ex:212-222 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 11 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 11+ corresponding lines) lib/optimal_system_agent/tools/builtins/task_resume/prompt.ex:11 — lib/optimal_system_agent/tools/builtins/task_resume/prompt.ex:11-25 | lib/optimal_system_agent/tools/builtins/task_stop/prompt.ex:11-25 | lib/optimal_system_agent/tools/builtins/task_wait/prompt.ex:11-21 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 11 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 7+ corresponding lines) · ×5
  • Edited copies of one member (3 members, 7+ corresponding lines) priv/rust/tui/src/dialogs/skills_browser.rs:162 — priv/rust/tui/src/dialogs/skills_browser.rs:162-168 | priv/rust/tui/src/dialogs/tasks_panel.rs:136-142 | priv/rust/tui/src/dialogs/tools_browser.rs:152-158 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 7 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 7+ corresponding lines) lib/optimal_system_agent/tools/builtins/file_write/ui.ex:36 — lib/optimal_system_agent/tools/builtins/file_write/ui.ex:36-45 | lib/optimal_system_agent/tools/builtins/memory_recall/ui.ex:23-33 | lib/optimal_system_agent/tools/builtins/tool_search/ui.ex:21-27 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 7 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 7+ corresponding lines) lib/optimal_system_agent/tools/builtins/file_transform/prompt.ex:34 — lib/optimal_system_agent/tools/builtins/file_transform/prompt.ex:34-40 | lib/optimal_system_agent/tools/builtins/file_write/prompt.ex:17-27 | lib/optimal_system_agent/tools/builtins/structural_edit/prompt.ex:13-23 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 7 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 7+ corresponding lines) lib/optimal_system_agent/agent/loop/react_loop.ex:130 — lib/optimal_system_agent/agent/loop/react_loop.ex:130-136 | lib/optimal_system_agent/mcp/discovery.ex:105-111 | lib/optimal_system_agent/soul.ex:452-458 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 7 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 7+ corresponding lines) bench/modelsweep/paired.py:40 — bench/modelsweep/paired.py:40-48 | bench/terminalbench/paired_report.py:46-54 | bench/terminalbench/reprice.py:131-137 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 7 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Duplicated block (20 lines × 2) · ×5
  • Duplicated block (20 lines × 2) canopy/backend/lib/canopy/costs.ex:76 — canopy/backend/lib/canopy/costs.ex:76-95 | canopy/backend/lib/canopy_web/controllers/cost_controller.ex:106-125 — before extracting anything, compare `canopy/backend/lib/canopy/costs.ex` and `canopy/backend/lib/canopy_web/controllers/cost_controller.ex` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 78 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 (20 lines × 2) lib/optimal_system_agent/agent/task_queue.ex:606 — lib/optimal_system_agent/agent/task_queue.ex:606-625 | lib/optimal_system_agent/agent/task_queue.ex:757-776 — 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 `lib/optimal_system_agent/agent/task_queue.ex:606` 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 (20 lines × 2) lib/optimal_system_agent/channels/cli/session.ex:538 — lib/optimal_system_agent/channels/cli/session.ex:538-557 | lib/optimal_system_agent/channels/cli/session.ex:590-609 — 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) lib/optimal_system_agent/tools/builtins/computer_use/adapters/linux_wayland.ex:242 — lib/optimal_system_agent/tools/builtins/computer_use/adapters/linux_wayland.ex:242-261 | lib/optimal_system_agent/tools/builtins/computer_use/adapters/linux_x11.ex:279-298 — 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 (20 lines × 2) bench/swebench/run_bench.py:230 — bench/swebench/run_bench.py:230-249 | bench/swebenchpro/run_bench.py:81-100 — `bench/swebench/run_bench.py` and `bench/swebenchpro/run_bench.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 202 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 `bench/swebench/run_bench.py:230` 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 (19 lines × 2) · ×5
  • Duplicated block (19 lines × 2) lib/optimal_system_agent/providers/claude_cli.ex:413 — lib/optimal_system_agent/providers/claude_cli.ex:413-431 | lib/optimal_system_agent/providers/copilot_cli.ex:352-370 — before extracting anything, compare `lib/optimal_system_agent/providers/claude_cli.ex` and `lib/optimal_system_agent/providers/copilot_cli.ex` as WHOLE FILES: this scan already matched 7 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. 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 (19 lines × 2) lib/optimal_system_agent/tools/builtins/github.ex:343 — lib/optimal_system_agent/tools/builtins/github.ex:343-361 | lib/optimal_system_agent/tools/builtins/github.ex:389-407 — 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 lines × 2) lib/optimal_system_agent/tools/registry.ex:369 — lib/optimal_system_agent/tools/registry.ex:369-387 | lib/optimal_system_agent/tools/registry.ex:489-507 — 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 lines × 2) priv/rust/tui/src/dialogs/file_picker.rs:312 — priv/rust/tui/src/dialogs/file_picker.rs:312-330 | priv/rust/tui/src/dialogs/sessions.rs:331-349 — before extracting anything, compare `priv/rust/tui/src/dialogs/file_picker.rs` and `priv/rust/tui/src/dialogs/sessions.rs` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 97 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 `priv/rust/tui/src/dialogs/file_picker.rs:312` 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 (19 lines × 2) priv/rust/tui/src/dialogs/skills_browser.rs:133 — priv/rust/tui/src/dialogs/skills_browser.rs:133-151 | priv/rust/tui/src/dialogs/tools_browser.rs:123-141 — before extracting anything, compare `priv/rust/tui/src/dialogs/skills_browser.rs` and `priv/rust/tui/src/dialogs/tools_browser.rs` as WHOLE FILES: this scan already matched 22 separate duplicated blocks between them, totalling at least 301 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 (18 lines × 2) · ×5
  • Duplicated block (18 lines × 2) lib/optimal_system_agent/agent/task_tracker.ex:242 — lib/optimal_system_agent/agent/task_tracker.ex:242-259 | lib/optimal_system_agent/agent/task_tracker.ex:280-297 — 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 `lib/optimal_system_agent/agent/task_tracker.ex:242` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (18 lines × 2) lib/optimal_system_agent/channels/cli/session.ex:567 — lib/optimal_system_agent/channels/cli/session.ex:567-584 | lib/optimal_system_agent/channels/cli/session.ex:603-620 — 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 `lib/optimal_system_agent/channels/cli/session.ex:567` 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 (18 lines × 2) lib/optimal_system_agent/tools/builtins/download/handler.ex:65 — lib/optimal_system_agent/tools/builtins/download/handler.ex:65-82 | lib/optimal_system_agent/tools/builtins/web_fetch/handler.ex:53-70 — 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 (18 lines × 2) lib/optimal_system_agent/tools/builtins/enter_worktree/tool.ex:34 — lib/optimal_system_agent/tools/builtins/enter_worktree/tool.ex:34-51 | lib/optimal_system_agent/tools/builtins/file_write/tool.ex:37-58 — 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 `lib/optimal_system_agent/tools/builtins/enter_worktree/tool.ex:34` 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) lib/optimal_system_agent/tools/builtins/knowledge.ex:21 — lib/optimal_system_agent/tools/builtins/knowledge.ex:21-38 | lib/optimal_system_agent/tools/builtins/skill_manager.ex:38-55 — before extracting anything, compare `lib/optimal_system_agent/tools/builtins/knowledge.ex` and `lib/optimal_system_agent/tools/builtins/skill_manager.ex` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 85 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 `lib/optimal_system_agent/tools/builtins/knowledge.ex:21` 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–12 lines × 2) · ×5
  • Duplicated block (11–12 lines × 2) lib/optimal_system_agent/agent/task_queue.ex:400 — lib/optimal_system_agent/agent/task_queue.ex:400-411 | lib/optimal_system_agent/agent/tasks/queue.ex:69-79 — before extracting anything, compare `lib/optimal_system_agent/agent/task_queue.ex` and `lib/optimal_system_agent/agent/tasks/queue.ex` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 149 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–12 lines × 2) lib/optimal_system_agent/agent/tasks/workflow.ex:239 — lib/optimal_system_agent/agent/tasks/workflow.ex:239-250 | lib/optimal_system_agent/agent/workflow.ex:370-380 — before extracting anything, compare `lib/optimal_system_agent/agent/tasks/workflow.ex` and `lib/optimal_system_agent/agent/workflow.ex` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 285 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 `lib/optimal_system_agent/agent/tasks/workflow.ex:239` 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–12 lines × 2) lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex:254 — lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex:254-265 | lib/optimal_system_agent/open_computers/executor/direct/cluster/mlx_distributed.ex:48-58 — before extracting anything, compare `lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex` and `lib/optimal_system_agent/open_computers/executor/direct/cluster/mlx_distributed.ex` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 66 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–12 lines × 2) lib/optimal_system_agent/tools/builtins/computer_use/adapters/docker.ex:233 — lib/optimal_system_agent/tools/builtins/computer_use/adapters/docker.ex:233-244 | lib/optimal_system_agent/tools/builtins/computer_use/adapters/remote_ssh.ex:271-281 — 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 `lib/optimal_system_agent/tools/builtins/computer_use/adapters/docker.ex: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.
  • Duplicated block (11–12 lines × 2) bench/swebench/run_bench.py:335 — bench/swebench/run_bench.py:335-346 | bench/swebenchpro/run_bench.py:158-168 — `bench/swebench/run_bench.py` and `bench/swebenchpro/run_bench.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 202 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 `bench/swebench/run_bench.py: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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `bench/swebenchpro/run_bench.py:157` calls `add_argument` and `bench/swebench/run_bench.py:335` 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 (6 lines × 3) · ×5
  • Duplicated block (6 lines × 3) lib/optimal_system_agent/agent/loop/doom_loop/stall.ex:322 — lib/optimal_system_agent/agent/loop/doom_loop/stall.ex:322-327 | lib/optimal_system_agent/agent/loop/regulation/signals.ex:156-161 | lib/optimal_system_agent/agent/loop/regulation/surprise.ex:91-96 — 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 (6 lines × 3) lib/optimal_system_agent/channels/dingtalk.ex:149 — lib/optimal_system_agent/channels/dingtalk.ex:149-154 | lib/optimal_system_agent/channels/feishu.ex:182-187 | lib/optimal_system_agent/channels/wecom.ex:137-142 — 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 (6 lines × 3) priv/rust/tui/src/dialogs/channels_panel.rs:247 — priv/rust/tui/src/dialogs/channels_panel.rs:247-252 | priv/rust/tui/src/dialogs/doctor_panel.rs:306-312 | priv/rust/tui/src/dialogs/tools_browser.rs:360-365 — before extracting anything, compare `priv/rust/tui/src/dialogs/channels_panel.rs` and `priv/rust/tui/src/dialogs/doctor_panel.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 137 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 `priv/rust/tui/src/dialogs/channels_panel.rs:247` 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 × 3) priv/rust/tui/src/dialogs/skills_browser.rs:163 — priv/rust/tui/src/dialogs/skills_browser.rs:163-168 | priv/rust/tui/src/dialogs/tasks_panel.rs:137-142 | priv/rust/tui/src/dialogs/tools_browser.rs:153-158 — before extracting anything, compare `priv/rust/tui/src/dialogs/skills_browser.rs` and `priv/rust/tui/src/dialogs/tasks_panel.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 133 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. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (6 lines × 3) bench/recoverybench/run_bench.py:103 — bench/recoverybench/run_bench.py:103-108 | bench/terminalbench/controls.py:83-88 | REDACTED:172-177 — 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.
PF3 · Async & latency hygiene · Sync-over-async blocking · ×5
  • Sync-over-async blocking REDACTED:168 — `writeFileSync` in `ev.on("messages.upsert")` 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 REDACTED:177 — `writeFileSync` in `ev.on("messages.upsert")` 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 REDACTED:188 — `writeFileSync` in `ev.on("messages.upsert")` 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 REDACTED:251 — `existsSync` in `app.post("/send-media")` 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 REDACTED:254 — `readFileSync` in `app.post("/send-media")` 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.
D1 · Cyclomatic Complexity · ModelPicker · ×4
  • ModelPicker::draw_local_detail (cyclomatic 18) priv/rust/tui/src/dialogs/model_picker/local.rs:622 — ModelPicker::draw_local_detail 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.
  • ModelPicker::handle_providers_key (cyclomatic 18) priv/rust/tui/src/dialogs/model_picker.rs:668 — ModelPicker::handle_providers_key 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.
  • ModelPicker::draw_key_entry (cyclomatic 18) priv/rust/tui/src/dialogs/model_picker.rs:2386 — ModelPicker::draw_key_entry 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.
  • ModelPicker::draw_models (cyclomatic 17) priv/rust/tui/src/dialogs/model_picker.rs:1989 — ModelPicker::draw_models 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.
D2 · Cognitive Complexity · OnboardingWizard · ×4
  • OnboardingWizard::handle_step_channels (cognitive 17) priv/rust/tui/src/dialogs/onboarding.rs:863 — OnboardingWizard::handle_step_channels has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 1, match/switch 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.
  • OnboardingWizard::draw_step_provider (cognitive 16) priv/rust/tui/src/dialogs/onboarding.rs:1228 — OnboardingWizard::draw_step_provider has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (10 pts), match/switch 1 (3 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.
  • OnboardingWizard::draw_step_channels (cognitive 16) priv/rust/tui/src/dialogs/onboarding.rs:1551 — OnboardingWizard::draw_step_channels has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 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.
  • OnboardingWizard::draw_step_confirm (cognitive 16) priv/rust/tui/src/dialogs/onboarding.rs:1792 — OnboardingWizard::draw_step_confirm has cognitive complexity 16 (threshold 15). Drivers by points: if/else 14 (15 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.
D30 · Dependency Vulnerabilities · Medium vulnerability · ×4
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D35 · Change Coupling · Change coupling · ×4
  • Change coupling: handle_actions.rs ↔ http.rs priv/rust/tui/src/app/handle_actions.rs:1 — `priv/rust/tui/src/app/handle_actions.rs` and `priv/rust/tui/src/client/http.rs` change together 59% of the time (10 of the 17 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 10 shared commits counted here, the most recent 3 are `90175864` v1.0.155: kill the stalls - live waiting indicator, no file_glob hang…; `ddf265eb` feat: harden runtime intelligence and visibility; `7bc3673b` fix(tui): /model now switches the live session, not just global defaults — run `git show` on any of them.
  • Change coupling: handle_backend.rs ↔ render.rs priv/rust/tui/src/app/handle_backend.rs:1 — `priv/rust/tui/src/app/handle_backend.rs` and `priv/rust/tui/src/components/agents/render.rs` change together 58% of the time (7 of the 12 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 7 shared commits counted here, the most recent 3 are `66651e35` feat(dashboard): show live per-agent context % instead of a misleadin…; `9b79514f` fix(tui+agents): stop long multi-agent turns looking frozen; fix task…; `7c5c8cee` fix(subagents): "no recent signal" described our ignorance; nothing d… — run `git show` on any of them.
  • Change coupling: handle_backend.rs ↔ mod.rs priv/rust/tui/src/app/handle_backend.rs:1 — `priv/rust/tui/src/app/handle_backend.rs` and `priv/rust/tui/src/components/input/mod.rs` change together 54% of the time (15 of the 28 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 15 shared commits counted here, the most recent 3 are `9b79514f` fix(tui+agents): stop long multi-agent turns looking frozen; fix task…; `34828317` feat(tui): alt+enter sends a queued message into the running turn; `72a96882` fix(tui,runtime): resize stranded a copy of the interface per step; t… — run `git show` on any of them.
  • Change coupling: handle_actions.rs ↔ status_bar.rs priv/rust/tui/src/app/handle_actions.rs:1 — `priv/rust/tui/src/app/handle_actions.rs` and `priv/rust/tui/src/components/status_bar.rs` change together 50% of the time (17 of the 34 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 17 shared commits counted here, the most recent 3 are `4f74f734` feat(jailbreak): inject override at the TOP of the system prompt + an…; `ddf265eb` feat: harden runtime intelligence and visibility; `18470e24` fix(tui): responsive status and Claude thinking (#115) — run `git show` on any of them.
D36 · Supply-chain Provenance & Signing · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Edited copy of a member (29 corresponding lines) · ×4
  • Edited copy of a member (29 corresponding lines) lib/optimal_system_agent/agent/tasks/workflow.ex:142 — lib/optimal_system_agent/agent/tasks/workflow.ex:142-170 | lib/optimal_system_agent/agent/workflow.ex:277-318 — These two members are one piece of code written twice and then edited apart: 29 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.
  • Edited copy of a member (29 corresponding lines) lib/optimal_system_agent/agent/tasks/workflow.ex:48 — lib/optimal_system_agent/agent/tasks/workflow.ex:48-76 | lib/optimal_system_agent/agent/workflow.ex:178-208 — These two members are one piece of code written twice and then edited apart: 29 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.
  • Edited copy of a member (29 corresponding lines) lib/optimal_system_agent/channels/http/api/agent_routes.ex:102 — lib/optimal_system_agent/channels/http/api/agent_routes.ex:102-136 | lib/optimal_system_agent/channels/http/api/command_center_routes.ex:495-523 — These two members are one piece of code written twice and then edited apart: 29 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.
  • Edited copy of a member (29 corresponding lines) lib/optimal_system_agent/channels/discord.ex:82 — lib/optimal_system_agent/channels/discord.ex:82-112 | lib/optimal_system_agent/channels/telegram.ex:89-117 — These two members are one piece of code written twice and then edited apart: 29 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 copies of one member (3 members, 13+ corresponding lines) · ×4
  • Edited copies of one member (3 members, 13+ corresponding lines) priv/rust/tui/src/components/agents/mod.rs:1358 — priv/rust/tui/src/components/agents/mod.rs:1358-1371 | priv/rust/tui/src/components/agents/mod.rs:1389-1401 | priv/rust/tui/src/components/agents/mod.rs:1413-1426 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 13 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 13+ corresponding lines) priv/rust/tui/src/dialogs/memory_browser.rs:58 — priv/rust/tui/src/dialogs/memory_browser.rs:58-70 | priv/rust/tui/src/dialogs/permissions_manager.rs:79-94 | priv/rust/tui/src/dialogs/persona_picker.rs:86-98 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 13 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 13+ corresponding lines) lib/optimal_system_agent/context_refs/resolvers/diff.ex:6 — lib/optimal_system_agent/context_refs/resolvers/diff.ex:6-22 | lib/optimal_system_agent/context_refs/resolvers/git_log.ex:6-18 | lib/optimal_system_agent/context_refs/resolvers/staged.ex:6-22 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 13 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 13+ corresponding lines) lib/optimal_system_agent/tools/builtins/cross_team_query/handler.ex:50 — lib/optimal_system_agent/tools/builtins/cross_team_query/handler.ex:50-62 | lib/optimal_system_agent/tools/builtins/peer_negotiate_task/handler.ex:55-67 | lib/optimal_system_agent/tools/builtins/peer_review/handler.ex:42-54 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 13 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 8+ corresponding lines) · ×4
  • Edited copies of one member (3 members, 8+ corresponding lines) lib/optimal_system_agent/monitor/watch_manager.ex:31 — lib/optimal_system_agent/monitor/watch_manager.ex:31-38 | lib/optimal_system_agent/shell/background_manager.ex:35-44 | lib/optimal_system_agent/shell/background_manager.ex:61-69 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 8 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 8+ corresponding lines) lib/optimal_system_agent/cli/setup.ex:697 — lib/optimal_system_agent/cli/setup.ex:697-704 | lib/optimal_system_agent/cli/setup.ex:721-728 | lib/optimal_system_agent/cli/setup.ex:732-741 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 8 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 8+ corresponding lines) lib/optimal_system_agent/mcp/client/server_session.ex:226 — lib/optimal_system_agent/mcp/client/server_session.ex:226-233 | lib/optimal_system_agent/open_computers/executor/direct/tunnel.ex:182-190 | lib/optimal_system_agent/shell/pty/session.ex:302-309 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 8 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 8+ corresponding lines) canopy/backend/lib/canopy_web/controllers/comment_controller.ex:9 — canopy/backend/lib/canopy_web/controllers/comment_controller.ex:9-16 | canopy/backend/lib/canopy_web/controllers/project_controller.ex:84-91 | canopy/backend/lib/canopy_web/controllers/workspace_controller.ex:125-132 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 8 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 4+ corresponding lines) · ×4
  • Edited copies of one member (4 members, 4+ corresponding lines) lib/optimal_system_agent/tools/builtins/file_edit/handler.ex:416 — lib/optimal_system_agent/tools/builtins/file_edit/handler.ex:416-419 | lib/optimal_system_agent/tools/builtins/multi_file_edit/handler.ex:325-328 | lib/optimal_system_agent/tools/builtins/structural_edit/handler.ex:545-548 | lib/optimal_system_agent/workspace/topology.ex:700-703 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 4 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
  • Edited copies of one member (4 members, 4+ corresponding lines) lib/optimal_system_agent/agent/loop.ex:2724 — lib/optimal_system_agent/agent/loop.ex:2724-2727 | lib/optimal_system_agent/agent/loop/checkpoint.ex:722-725 | lib/optimal_system_agent/agent/tasks/tracker.ex:721-724 | lib/optimal_system_agent/learning/pain_event.ex:95-100 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 4 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
  • Edited copies of one member (4 members, 4+ corresponding lines) lib/optimal_system_agent/agent/step_snapshot.ex:346 — lib/optimal_system_agent/agent/step_snapshot.ex:346-349 | lib/optimal_system_agent/command_center.ex:206-211 | lib/optimal_system_agent/healing/orchestrator.ex:95-98 | lib/optimal_system_agent/security/login_session.ex:79-84 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 4 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
  • Edited copies of one member (4 members, 4+ corresponding lines) lib/optimal_system_agent/security/http_replay.ex:242 — lib/optimal_system_agent/security/http_replay.ex:242-245 | lib/optimal_system_agent/security/recon_ingest.ex:274-277 | lib/optimal_system_agent/security/roe_guard.ex:227-230 | lib/optimal_system_agent/security/traffic_ingest.ex:103-106 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 4 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 3+ corresponding lines) · ×4
  • Edited copies of one member (3 members, 3+ corresponding lines) lib/optimal_system_agent/context_mesh/registry.ex:109 — lib/optimal_system_agent/context_mesh/registry.ex:109-111 | lib/optimal_system_agent/file_locking/intent_broadcaster.ex:166-168 | lib/optimal_system_agent/team.ex:126-128 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 3 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 3+ corresponding lines) lib/optimal_system_agent/speculative/executor.ex:147 — lib/optimal_system_agent/speculative/executor.ex:147-149 | lib/optimal_system_agent/team.ex:256-258 | lib/optimal_system_agent/workspace/session.ex:116-118 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 3 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 3+ corresponding lines) lib/miosa/shims.ex:950 — lib/miosa/shims.ex:950-952 | lib/optimal_system_agent/budget/budget.ex:467-469 | lib/optimal_system_agent/budget/treasury.ex:305-307 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 3 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 3+ corresponding lines) lib/optimal_system_agent/observability.ex:192 — lib/optimal_system_agent/observability.ex:192-194 | lib/optimal_system_agent/tools/builtins/delegate/handler.ex:740-743 | lib/optimal_system_agent/tools/builtins/fleet/handler.ex:313-316 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 3 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 2+ corresponding lines) · ×4
  • Edited copies of one member (3 members, 2+ corresponding lines) lib/optimal_system_agent/agent/active_skills.ex:218 — lib/optimal_system_agent/agent/active_skills.ex:218-219 | lib/optimal_system_agent/agent/run_store.ex:1283-1284 | lib/optimal_system_agent/agent/session_persistence.ex:548-549 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 2 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 2+ corresponding lines) lib/optimal_system_agent/conversations/tools/spawn_conversation/handler.ex:25 — lib/optimal_system_agent/conversations/tools/spawn_conversation/handler.ex:25-26 | lib/optimal_system_agent/tools/builtins/create_skill/handler.ex:23-24 | lib/optimal_system_agent/tools/builtins/file_edit/handler.ex:39-40 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 2 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 2+ corresponding lines) lib/optimal_system_agent/channels/http/api/agent_state_routes.ex:64 — lib/optimal_system_agent/channels/http/api/agent_state_routes.ex:64-65 | lib/optimal_system_agent/channels/http/api/dashboard_routes.ex:69-70 | lib/optimal_system_agent/events/tui_forwarder.ex:137-138 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 2 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 2+ corresponding lines) bench/headtohead/report_h2h.py:56 — bench/headtohead/report_h2h.py:56-57 | bench/swebench/report.py:227-228 | bench/terminalbench/report.py:106-107 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 2 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (5 members, 4+ corresponding lines) · ×4
  • Edited copies of one member (5 members, 4+ corresponding lines) lib/optimal_system_agent/providers/cache_attribution.ex:633 — lib/optimal_system_agent/providers/cache_attribution.ex:633-636 | lib/optimal_system_agent/security/action_reviewer.ex:233-236 | lib/optimal_system_agent/security/exploit_oracle.ex:267-270 | lib/optimal_system_agent/security/finding_skeptic.ex:167-170 | lib/optimal_system_agent/security/validation_result.ex:307-310 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 4 lines, 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 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. Left alone, the next edit has to be made 5 times and the copies will drift further apart.
  • Edited copies of one member (5 members, 4+ corresponding lines) lib/optimal_system_agent/agent/step_snapshot.ex:475 — lib/optimal_system_agent/agent/step_snapshot.ex:475-478 | lib/optimal_system_agent/providers/batch.ex:353-356 | lib/optimal_system_agent/security/anomaly_queue.ex:174-177 | lib/optimal_system_agent/security/class_queue.ex:181-184 | lib/optimal_system_agent/tools/builtins/computer_use/adapters/miosa.ex:172-175 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 4 lines, 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 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. Left alone, the next edit has to be made 5 times and the copies will drift further apart.
  • Edited copies of one member (5 members, 4+ corresponding lines) lib/optimal_system_agent/channels/email_channel.ex:404 — lib/optimal_system_agent/channels/email_channel.ex:404-408 | lib/optimal_system_agent/mcp/config.ex:307-311 | lib/optimal_system_agent/mcp/protocol/messages.ex:362-365 | lib/optimal_system_agent/providers/reasoning_content.ex:115-118 | lib/optimal_system_agent/utils.ex:278-281 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 4 lines, 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 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. Left alone, the next edit has to be made 5 times and the copies will drift further apart.
  • Edited copies of one member (5 members, 4+ corresponding lines) lib/optimal_system_agent/auth/providers/copilot.ex:346 — lib/optimal_system_agent/auth/providers/copilot.ex:346-349 | lib/optimal_system_agent/auth/providers/minimax.ex:379-382 | lib/optimal_system_agent/auth/providers/openai_codex.ex:487-490 | REDACTED:338-341 | lib/optimal_system_agent/auth/providers/xai.ex:263-266 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 4 lines, 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 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. Left alone, the next edit has to be made 5 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 1+ corresponding lines) · ×4
  • Edited copies of one member (4 members, 1+ corresponding lines) lib/optimal_system_agent/agent/fleet/journal.ex:74 — lib/optimal_system_agent/agent/fleet/journal.ex:74-74 | lib/optimal_system_agent/agent/loop/goal_tracker.ex:1881-1881 | lib/optimal_system_agent/agent/memory/episodic_store.ex:392-392 | lib/optimal_system_agent/workspace/fast_worktree.ex:555-555 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 1 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
  • Edited copies of one member (4 members, 1+ corresponding lines) lib/optimal_system_agent/channels/http/api/memory_routes.ex:97 — lib/optimal_system_agent/channels/http/api/memory_routes.ex:97-97 | lib/optimal_system_agent/events/tui_forwarder.ex:197-197 | lib/optimal_system_agent/observability/otel.ex:103-103 | lib/optimal_system_agent/skills/advisor.ex:116-117 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 1 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
  • Edited copies of one member (4 members, 1+ corresponding lines) lib/optimal_system_agent/agent/context.ex:1170 — lib/optimal_system_agent/agent/context.ex:1170-1170 | lib/optimal_system_agent/agent/loop/regulation/homeostat.ex:200-201 | lib/optimal_system_agent/permissions/auto_classifier.ex:454-455 | lib/optimal_system_agent/providers/history_sanitizer.ex:264-264 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 1 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
  • Edited copies of one member (4 members, 1+ corresponding lines) lib/optimal_system_agent/agent/durable_inbox.ex:189 — lib/optimal_system_agent/agent/durable_inbox.ex:189-189 | lib/optimal_system_agent/agent/memory/episodic_store.ex:350-350 | lib/optimal_system_agent/agent/session_persistence.ex:1043-1043 | lib/optimal_system_agent/bench/script.ex:89-89 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 1 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Duplicated block (17–18 lines × 2) · ×4
  • Duplicated block (17–18 lines × 2) lib/optimal_system_agent/agent/loop/react_loop.ex:1928 — lib/optimal_system_agent/agent/loop/react_loop.ex:1928-1944 | lib/optimal_system_agent/agent/loop/react_loop.ex:1954-1971 — 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 `lib/optimal_system_agent/agent/loop/react_loop.ex:1928` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with 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.
  • Duplicated block (17–18 lines × 2) lib/optimal_system_agent/providers/openai_responses.ex:62 — lib/optimal_system_agent/providers/openai_responses.ex:62-79 | lib/optimal_system_agent/providers/openai_responses.ex:121-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.
  • Duplicated block (17–18 lines × 2) lib/optimal_system_agent/tools/builtins/delegate/tool.ex:142 — lib/optimal_system_agent/tools/builtins/delegate/tool.ex:142-158 | lib/optimal_system_agent/tools/builtins/delegate/tool.ex:162-179 — 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 `lib/optimal_system_agent/tools/builtins/delegate/tool.ex:142` 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 (17–18 lines × 2) bench/swebench/run_bench.py:206 — bench/swebench/run_bench.py:206-223 | bench/swebenchpro/run_bench.py:58-74 — `bench/swebench/run_bench.py` and `bench/swebenchpro/run_bench.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 202 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 (13–14 lines × 2) · ×4
  • Duplicated block (13–14 lines × 2) lib/optimal_system_agent/agent/workflow.ex:242 — lib/optimal_system_agent/agent/workflow.ex:242-254 | lib/optimal_system_agent/agent/workflow.ex:277-290 — 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 `lib/optimal_system_agent/agent/workflow.ex:242` 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 (13–14 lines × 2) lib/optimal_system_agent/agent/loop/verification_evidence.ex:224 — lib/optimal_system_agent/agent/loop/verification_evidence.ex:224-236 | lib/optimal_system_agent/agent/loop/verification_evidence.ex:309-322 — 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–14 lines × 2) priv/rust/tui/src/render/markdown.rs:368 — priv/rust/tui/src/render/markdown.rs:368-381 | priv/rust/tui/src/render/markdown.rs:409-421 — 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 `priv/rust/tui/src/render/markdown.rs:368` 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 (13–14 lines × 2) bench/swebench/run_bench.py:637 — bench/swebench/run_bench.py:637-650 | bench/swebenchpro/run_bench.py:562-574 — `bench/swebench/run_bench.py` and `bench/swebenchpro/run_bench.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 202 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 `bench/swebench/run_bench.py:637` 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 (8–9 lines × 2) · ×4
  • Duplicated block (8–9 lines × 2) lib/optimal_system_agent/tools/builtins/multi_file_edit/handler.ex:276 — lib/optimal_system_agent/tools/builtins/multi_file_edit/handler.ex:276-283 | lib/optimal_system_agent/tools/builtins/structural_edit/handler.ex:296-304 — 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 `lib/optimal_system_agent/tools/builtins/multi_file_edit/handler.ex: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.
  • Duplicated block (8–9 lines × 2) lib/optimal_system_agent/channels/cli/commands.ex:2755 — lib/optimal_system_agent/channels/cli/commands.ex:2755-2763 | lib/optimal_system_agent/channels/cli/commands.ex:2822-2829 — 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–9 lines × 2) priv/rust/tui/src/dialogs/file_picker.rs:302 — priv/rust/tui/src/dialogs/file_picker.rs:302-310 | priv/rust/tui/src/dialogs/model_picker.rs:1634-1641 — before extracting anything, compare `priv/rust/tui/src/dialogs/file_picker.rs` and `priv/rust/tui/src/dialogs/model_picker.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 54 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 `priv/rust/tui/src/dialogs/file_picker.rs:302` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (8–9 lines × 2) priv/rust/tui/src/tools/file.rs:65 — priv/rust/tui/src/tools/file.rs:65-73 | priv/rust/tui/src/tools/file.rs:213-220 — 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 `priv/rust/tui/src/tools/file.rs:65` 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, `priv/rust/tui/src/tools/file.rs:212` calls `default`, `fg` and `priv/rust/tui/src/tools/file.rs:62` 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.
D2 · Cognitive Complexity · Activity · ×3
  • Activity::draw (cognitive 82) priv/rust/tui/src/components/activity.rs:2240 — Activity::draw has cognitive complexity 82 (threshold 15). Drivers by points: if/else 51 (64 pts), boolean chains 8, match/switch 4 (8 pts), loops 1 (2 pts) (nesting depth added 18). 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.
  • Activity::a11y_status (cognitive 24) priv/rust/tui/src/components/activity.rs:1343 — Activity::a11y_status has cognitive complexity 24 (threshold 15). Drivers by points: if/else 14 (21 pts), match/switch 1 (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.
  • Activity::wrapped_details_lines (cognitive 20) priv/rust/tui/src/components/activity.rs:1703 — Activity::wrapped_details_lines has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (16 pts), loops 2 (3 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.
D4 · Code Duplication · Edited copy of a member (27 corresponding lines) · ×3
  • Edited copy of a member (27 corresponding lines) lib/optimal_system_agent/tools/builtins/knowledge.ex:21 — lib/optimal_system_agent/tools/builtins/knowledge.ex:21-51 | lib/optimal_system_agent/tools/builtins/skill_manager.ex:38-69 — 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.
  • Edited copy of a member (27 corresponding lines) lib/optimal_system_agent/providers/fallback_chain.ex:335 — lib/optimal_system_agent/providers/fallback_chain.ex:335-361 | lib/optimal_system_agent/providers/fallback_chain.ex:411-445 — 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.
  • Edited copy of a member (27 corresponding lines) lib/optimal_system_agent/fs_checkpoint/server.ex:515 — lib/optimal_system_agent/fs_checkpoint/server.ex:515-541 | lib/optimal_system_agent/fs_checkpoint/server.ex:580-616 — 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 (5 members, 50+ identical tokens) · ×3
  • Members sharing a duplicated core (5 members, 50+ identical tokens) canopy/backend/lib/canopy_web/controllers/goal_controller.ex:29 — canopy/backend/lib/canopy_web/controllers/goal_controller.ex:29-39 | canopy/backend/lib/canopy_web/controllers/project_controller.ex:23-33 | canopy/backend/lib/canopy_web/controllers/schedule_controller.ex:42-52 | canopy/backend/lib/canopy_web/controllers/template_controller.ex:20-31 | canopy/backend/lib/canopy_web/controllers/user_controller.ex:26-36 — 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) lib/optimal_system_agent/auth/providers/copilot.ex:313 — lib/optimal_system_agent/auth/providers/copilot.ex:313-328 | lib/optimal_system_agent/auth/providers/minimax.ex:338-352 | lib/optimal_system_agent/auth/providers/openai_codex.ex:463-478 | REDACTED:295-310 | lib/optimal_system_agent/auth/providers/xai.ex:238-254 — 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) lib/optimal_system_agent/tools/builtins/file_read.ex:35 — lib/optimal_system_agent/tools/builtins/file_read.ex:35-49 | lib/optimal_system_agent/tools/builtins/find_skill.ex:46-64 | lib/optimal_system_agent/tools/builtins/multi_file_edit/tool.ex:46-77 | lib/optimal_system_agent/tools/builtins/send_user_file/tool.ex:39-56 | lib/optimal_system_agent/tools/builtins/structural_edit/tool.ex:61-123 — 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 · Members sharing a duplicated core (4 members, 50+ identical tokens) · ×3
  • Members sharing a duplicated core (4 members, 50+ identical tokens) lib/optimal_system_agent/agent/tasks/workflow.ex:228 — lib/optimal_system_agent/agent/tasks/workflow.ex:228-252 | lib/optimal_system_agent/agent/tasks/workflow.ex:483-512 | lib/optimal_system_agent/agent/workflow.ex:359-383 | lib/optimal_system_agent/agent/workflow.ex:591-624 — 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) priv/rust/tui/src/app/commands.rs:931 — priv/rust/tui/src/app/commands.rs:931-951 | priv/rust/tui/src/app/commands.rs:953-973 | priv/rust/tui/src/app/commands.rs:1005-1040 | priv/rust/tui/src/app/commands.rs:1090-1110 — 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) priv/rust/tui/src/client/http.rs:1383 — priv/rust/tui/src/client/http.rs:1383-1392 | priv/rust/tui/src/client/http.rs:1472-1488 | priv/rust/tui/src/client/http.rs:1491-1504 | priv/rust/tui/src/client/http.rs:1507-1520 — 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.
D4 · Code Duplication · Edited copy of a member (33 corresponding lines) · ×3
  • Edited copy of a member (33 corresponding lines) lib/optimal_system_agent/agent/task_queue.ex:506 — lib/optimal_system_agent/agent/task_queue.ex:506-540 | lib/optimal_system_agent/agent/tasks/queue.ex:299-331 — These two members are one piece of code written twice and then edited apart: 33 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.
  • Edited copy of a member (33 corresponding lines) lib/optimal_system_agent/agent/loop/goal_tracker.ex:912 — lib/optimal_system_agent/agent/loop/goal_tracker.ex:912-944 | lib/optimal_system_agent/agent/loop/goal_tracker.ex:970-1002 — These two members are one piece of code written twice and then edited apart: 33 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.
  • Edited copy of a member (33 corresponding lines) lib/optimal_system_agent/agent/pricing.ex:287 — lib/optimal_system_agent/agent/pricing.ex:287-319 | lib/optimal_system_agent/agent/pricing.ex:901-934 — These two members are one piece of code written twice and then edited apart: 33 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 (32 corresponding lines) · ×3
  • Edited copy of a member (32 corresponding lines) lib/optimal_system_agent/agent/tasks/tracker.ex:47 — lib/optimal_system_agent/agent/tasks/tracker.ex:47-81 | lib/optimal_system_agent/agent/tasks/tracker.ex:87-118 — These two members are one piece of code written twice and then edited apart: 32 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.
  • Edited copy of a member (32 corresponding lines) lib/optimal_system_agent/agent/task_queue.ex:169 — lib/optimal_system_agent/agent/task_queue.ex:169-201 | lib/optimal_system_agent/agent/task_queue.ex:364-395 — These two members are one piece of code written twice and then edited apart: 32 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.
  • Edited copy of a member (32 corresponding lines) lib/optimal_system_agent/providers/anthropic.ex:1271 — lib/optimal_system_agent/providers/anthropic.ex:1271-1302 | lib/optimal_system_agent/providers/anthropic.ex:1761-1799 — These two members are one piece of code written twice and then edited apart: 32 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 (25 corresponding lines) · ×3
  • Edited copy of a member (25 corresponding lines) priv/rust/tui/src/app/event_loop.rs:1783 — priv/rust/tui/src/app/event_loop.rs:1783-1808 | priv/rust/tui/src/app/event_loop.rs:1813-1837 — These two members are one piece of code written twice and then edited apart: 25 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.
  • Edited copy of a member (25 corresponding lines) lib/optimal_system_agent/agent/task_tracker.ex:166 — lib/optimal_system_agent/agent/task_tracker.ex:166-190 | lib/optimal_system_agent/agent/task_tracker.ex:195-221 — These two members are one piece of code written twice and then edited apart: 25 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.
  • Edited copy of a member (25 corresponding lines) lib/optimal_system_agent/tools/ablation/runner.ex:757 — lib/optimal_system_agent/tools/ablation/runner.ex:757-781 | lib/optimal_system_agent/tools/ablation/runner.ex:858-889 — These two members are one piece of code written twice and then edited apart: 25 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 (19 corresponding lines) · ×3
  • Edited copy of a member (19 corresponding lines) lib/optimal_system_agent/agent/loop/verification_evidence.ex:224 — lib/optimal_system_agent/agent/loop/verification_evidence.ex:224-247 | lib/optimal_system_agent/agent/loop/verification_evidence.ex:309-327 — These two members are one piece of code written twice and then edited apart: 19 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.
  • Edited copy of a member (19 corresponding lines) lib/optimal_system_agent/onboarding.ex:2827 — lib/optimal_system_agent/onboarding.ex:2827-2847 | lib/optimal_system_agent/onboarding.ex:2854-2872 — These two members are one piece of code written twice and then edited apart: 19 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.
  • Edited copy of a member (19 corresponding lines) lib/optimal_system_agent/application.ex:568 — lib/optimal_system_agent/application.ex:568-586 | lib/optimal_system_agent/cli/setup.ex:175-193 — These two members are one piece of code written twice and then edited apart: 19 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 copies of one member (3 members, 14+ corresponding lines) · ×3
  • Edited copies of one member (3 members, 14+ corresponding lines) lib/optimal_system_agent/security/surface_map.ex:244 — lib/optimal_system_agent/security/surface_map.ex:244-257 | lib/optimal_system_agent/security/surface_map.ex:351-369 | lib/optimal_system_agent/security/surface_map.ex:498-511 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 14 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 14+ corresponding lines) lib/optimal_system_agent/providers/catalog.ex:637 — lib/optimal_system_agent/providers/catalog.ex:637-651 | lib/optimal_system_agent/providers/catalog.ex:655-668 | lib/optimal_system_agent/providers/catalog.ex:702-715 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 14 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 14+ corresponding lines) lib/optimal_system_agent/auth/providers/claude_cli.ex:486 — lib/optimal_system_agent/auth/providers/claude_cli.ex:486-501 | lib/optimal_system_agent/auth/providers/copilot_cli.ex:314-327 | lib/optimal_system_agent/auth/providers/ollama_account.ex:315-329 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 14 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 15+ corresponding lines) · ×3
  • Edited copies of one member (3 members, 15+ corresponding lines) canopy/backend/lib/canopy_web/controllers/document_controller.ex:41 — canopy/backend/lib/canopy_web/controllers/document_controller.ex:41-61 | canopy/backend/lib/canopy_web/controllers/document_controller.ex:65-79 | canopy/backend/lib/canopy_web/controllers/document_controller.ex:101-117 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 15 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 15+ corresponding lines) lib/optimal_system_agent/channels/discord.ex:200 — lib/optimal_system_agent/channels/discord.ex:200-214 | lib/optimal_system_agent/channels/slack.ex:218-232 | lib/optimal_system_agent/channels/telegram.ex:250-267 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 15 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 15+ corresponding lines) lib/optimal_system_agent/tools/builtins/security_intel.ex:379 — lib/optimal_system_agent/tools/builtins/security_intel.ex:379-399 | lib/optimal_system_agent/tools/builtins/security_intel.ex:403-417 | lib/optimal_system_agent/tools/builtins/security_intel.ex:421-439 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 15 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Duplicated block (21–22 lines × 2) · ×3
  • Duplicated block (21–22 lines × 2) lib/optimal_system_agent/tools/builtins/file_read/tool.ex:52 — lib/optimal_system_agent/tools/builtins/file_read/tool.ex:52-72 | lib/optimal_system_agent/tools/builtins/scratchpad/tool.ex:48-69 — 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 `lib/optimal_system_agent/tools/builtins/file_read/tool.ex:52` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (21–22 lines × 2) lib/optimal_system_agent/tools/builtins/github.ex:35 — lib/optimal_system_agent/tools/builtins/github.ex:35-55 | lib/optimal_system_agent/tools/builtins/shell_execute/tool.ex:57-78 — 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 `lib/optimal_system_agent/tools/builtins/github.ex:35` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (21–22 lines × 2) lib/optimal_system_agent/tools/builtins/multi_file_edit/tool.ex:53 — lib/optimal_system_agent/tools/builtins/multi_file_edit/tool.ex:53-74 | lib/optimal_system_agent/tools/builtins/structural_edit/tool.ex:67-87 — 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 `lib/optimal_system_agent/tools/builtins/multi_file_edit/tool.ex:53` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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) lib/optimal_system_agent/agent/task_tracker.ex:201 — lib/optimal_system_agent/agent/task_tracker.ex:201-215 | lib/optimal_system_agent/agent/tasks/tracker.ex:93-106 — before extracting anything, compare `lib/optimal_system_agent/agent/task_tracker.ex` and `lib/optimal_system_agent/agent/tasks/tracker.ex` as WHOLE FILES: this scan already matched 7 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. 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 `lib/optimal_system_agent/agent/task_tracker.ex: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 (14–15 lines × 2) lib/optimal_system_agent/tools/builtins/config/tool.ex:44 — lib/optimal_system_agent/tools/builtins/config/tool.ex:44-58 | lib/optimal_system_agent/tools/builtins/file_grep/tool.ex:47-60 — 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 `lib/optimal_system_agent/tools/builtins/config/tool.ex:44` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with 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.
  • Duplicated block (14–15 lines × 2) lib/optimal_system_agent/tools/builtins/repl/tool.ex:45 — lib/optimal_system_agent/tools/builtins/repl/tool.ex:45-58 | lib/optimal_system_agent/tools/builtins/workspace_map.ex:68-82 — 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 `lib/optimal_system_agent/tools/builtins/repl/tool.ex:45` 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 × 5) · ×3
  • Duplicated block (13 lines × 5) lib/optimal_system_agent/tools/builtins/browser.ex:43 — lib/optimal_system_agent/tools/builtins/browser.ex:43-58 | lib/optimal_system_agent/tools/builtins/delegate/tool.ex:132-147 | lib/optimal_system_agent/tools/builtins/file_transform/tool.ex:65-77 | lib/optimal_system_agent/tools/builtins/task_write/tool.ex:64-80 | lib/optimal_system_agent/tools/builtins/team_tasks/tool.ex:44-59 — before extracting anything, compare `lib/optimal_system_agent/tools/builtins/browser.ex` and `lib/optimal_system_agent/tools/builtins/delegate/tool.ex` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 85 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 `lib/optimal_system_agent/tools/builtins/browser.ex:43` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (13 lines × 5) lib/optimal_system_agent/tools/builtins/exit_plan_mode/ui.ex:5 — lib/optimal_system_agent/tools/builtins/exit_plan_mode/ui.ex:5-17 | lib/optimal_system_agent/tools/builtins/progress_note/ui.ex:18-30 | lib/optimal_system_agent/tools/builtins/task_output/ui.ex:18-36 | lib/optimal_system_agent/tools/builtins/task_resume/ui.ex:18-36 | lib/optimal_system_agent/tools/builtins/task_stop/ui.ex:18-36 — 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.
  • Duplicated block (13 lines × 5) priv/rust/tui/src/dialogs/memory_browser.rs:319 — priv/rust/tui/src/dialogs/memory_browser.rs:319-331 | priv/rust/tui/src/dialogs/permissions_manager.rs:395-407 | priv/rust/tui/src/dialogs/persona_picker.rs:372-384 | priv/rust/tui/src/dialogs/skills_browser.rs:471-483 | priv/rust/tui/src/dialogs/tools_browser.rs:417-429 — before extracting anything, compare `priv/rust/tui/src/dialogs/memory_browser.rs` and `priv/rust/tui/src/dialogs/permissions_manager.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 223 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 `priv/rust/tui/src/dialogs/memory_browser.rs:319` 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 (12–13 lines × 2) · ×3
  • Duplicated block (12–13 lines × 2) lib/optimal_system_agent/context_mesh/keeper.ex:272 — lib/optimal_system_agent/context_mesh/keeper.ex:272-283 | lib/optimal_system_agent/context_mesh/keeper.ex:336-348 — 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 `lib/optimal_system_agent/context_mesh/keeper.ex:272` 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–13 lines × 2) bench/swebench/run_bench.py:658 — bench/swebench/run_bench.py:658-670 | bench/swebenchpro/run_bench.py:579-590 — `bench/swebench/run_bench.py` and `bench/swebenchpro/run_bench.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 202 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 (12–13 lines × 2) bench/terminalbench/probeset.py:507 — bench/terminalbench/probeset.py:507-519 | bench/terminalbench/reprice.py:65-76 — 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 (9–11 lines × 2) · ×3
  • Duplicated block (9–11 lines × 2) lib/optimal_system_agent/agent/task_queue.ex:658 — lib/optimal_system_agent/agent/task_queue.ex:658-668 | lib/optimal_system_agent/agent/tasks/queue.ex:199-207 — before extracting anything, compare `lib/optimal_system_agent/agent/task_queue.ex` and `lib/optimal_system_agent/agent/tasks/queue.ex` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 149 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–11 lines × 2) priv/rust/tui/src/components/input/mod.rs:1590 — priv/rust/tui/src/components/input/mod.rs:1590-1598 | priv/rust/tui/src/components/input/mod.rs:2525-2535 — 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–11 lines × 2) priv/rust/tui/src/dialogs/sandbox_picker.rs:95 — priv/rust/tui/src/dialogs/sandbox_picker.rs:95-105 | priv/rust/tui/src/dialogs/theme_picker.rs:81-89 — before extracting anything, compare `priv/rust/tui/src/dialogs/sandbox_picker.rs` and `priv/rust/tui/src/dialogs/theme_picker.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 54 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 `priv/rust/tui/src/dialogs/sandbox_picker.rs:95` 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 (7–8 lines × 2) · ×3
  • Duplicated block (7–8 lines × 2) lib/optimal_system_agent/providers/catalog.ex:743 — lib/optimal_system_agent/providers/catalog.ex:743-749 | lib/optimal_system_agent/providers/catalog.ex:751-758 — 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 `lib/optimal_system_agent/providers/catalog.ex:743` 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 (7–8 lines × 2) lib/optimal_system_agent/tools/builtins/security_intel.ex:143 — lib/optimal_system_agent/tools/builtins/security_intel.ex:143-149 | lib/optimal_system_agent/tools/builtins/security_intel.ex:161-168 — 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.
  • Duplicated block (7–8 lines × 2) priv/rust/tui/src/app/commands.rs:274 — priv/rust/tui/src/app/commands.rs:274-280 | priv/rust/tui/src/app/handle_dialogs.rs:988-995 — 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 `priv/rust/tui/src/app/handle_dialogs.rs:988` 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 (11 lines × 3) · ×3
  • Duplicated block (11 lines × 3) lib/optimal_system_agent/agent/batch_cadence.ex:283 — lib/optimal_system_agent/agent/batch_cadence.ex:283-293 | lib/optimal_system_agent/tools/builtins/file_edit/drift_guard.ex:217-227 | lib/optimal_system_agent/tools/file_state.ex:583-593 — 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 `lib/optimal_system_agent/agent/batch_cadence.ex:283` 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) lib/optimal_system_agent/auth/providers/bedrock.ex:334 — lib/optimal_system_agent/auth/providers/bedrock.ex:334-344 | lib/optimal_system_agent/auth/providers/claude_cli.ex:612-622 | lib/optimal_system_agent/auth/providers/copilot_cli.ex:400-410 — 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 (11 lines × 3) lib/optimal_system_agent/tools/builtins/download/tool.ex:42 — lib/optimal_system_agent/tools/builtins/download/tool.ex:42-56 | lib/optimal_system_agent/tools/builtins/pty/pty_send.ex:38-48 | lib/optimal_system_agent/tools/builtins/use_skill.ex:51-64 — 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 (10 lines × 3) · ×3
  • Duplicated block (10 lines × 3) lib/optimal_system_agent/providers/cohere.ex:145 — lib/optimal_system_agent/providers/cohere.ex:145-154 | lib/optimal_system_agent/providers/ollama.ex:1554-1563 | lib/optimal_system_agent/providers/openai_compat.ex:1380-1389 — 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `lib/optimal_system_agent/providers/openai_compat.ex:1376` calls `encode_text_preserving_cache`, `encode_text` and `lib/optimal_system_agent/providers/cohere.ex:141` 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) lib/optimal_system_agent/tools/builtins/dir_list/tool.ex:37 — lib/optimal_system_agent/tools/builtins/dir_list/tool.ex:37-46 | lib/optimal_system_agent/tools/builtins/enter_plan_mode/tool.ex:29-38 | lib/optimal_system_agent/tools/builtins/exit_plan_mode/tool.ex:28-37 — 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 (10 lines × 3) priv/rust/tui/src/components/agents/mod.rs:1362 — priv/rust/tui/src/components/agents/mod.rs:1362-1371 | priv/rust/tui/src/components/agents/mod.rs:1392-1401 | priv/rust/tui/src/components/agents/mod.rs:1417-1426 — 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 `priv/rust/tui/src/components/agents/mod.rs:1362` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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, `priv/rust/tui/src/components/agents/mod.rs:1361` calls `into` and `priv/rust/tui/src/components/agents/mod.rs:1391` 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 lines × 4) · ×3
  • Duplicated block (7 lines × 4) priv/rust/tui/src/client/http.rs:1386 — priv/rust/tui/src/client/http.rs:1386-1392 | priv/rust/tui/src/client/http.rs:1482-1488 | priv/rust/tui/src/client/http.rs:1498-1504 | priv/rust/tui/src/client/http.rs:1514-1520 — 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 `priv/rust/tui/src/client/http.rs:1386` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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 × 4) priv/rust/tui/src/render/markdown.rs:2170 — priv/rust/tui/src/render/markdown.rs:2170-2176 | priv/rust/tui/src/render/markdown.rs:2202-2208 | priv/rust/tui/src/render/markdown.rs:2256-2262 | priv/rust/tui/src/render/markdown.rs:2325-2331 — 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 `priv/rust/tui/src/render/markdown.rs:2170` 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 after the matched lines, `priv/rust/tui/src/render/markdown.rs:2177` calls `peek`, `Some`, `next` and `priv/rust/tui/src/render/markdown.rs:2209` 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 (7 lines × 4) priv/rust/tui/src/dialogs/onboarding.rs:1538 — priv/rust/tui/src/dialogs/onboarding.rs:1538-1544 | priv/rust/tui/src/dialogs/onboarding.rs:1572-1578 | priv/rust/tui/src/dialogs/onboarding.rs:1779-1787 | priv/rust/tui/src/dialogs/onboarding.rs:1883-1890 — 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 `priv/rust/tui/src/dialogs/onboarding.rs:1538` 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.
D1 · Cyclomatic Complexity · Agents · ×2
  • Agents::draw_tree (cyclomatic 91) priv/rust/tui/src/components/agents/render.rs:19 — Agents::draw_tree 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.
  • Agents::draw_dashboard (cyclomatic 34) priv/rust/tui/src/components/agents/render.rs:878 — Agents::draw_dashboard 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 · InputComponent · ×2
  • InputComponent::handle_event (cyclomatic 83) priv/rust/tui/src/components/input/mod.rs:2293 — InputComponent::handle_event 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.
  • InputComponent::draw (cyclomatic 63) priv/rust/tui/src/components/input/mod.rs:2747 — InputComponent::draw has cyclomatic complexity 63 (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 · Activity · ×2
  • Activity::draw (cyclomatic 52) priv/rust/tui/src/components/activity.rs:2240 — Activity::draw has cyclomatic complexity 52 (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.
  • Activity::a11y_status (cyclomatic 16) priv/rust/tui/src/components/activity.rs:1343 — Activity::a11y_status 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 is NOT this file's highest cyclomatic complexity: osa_tui::components::activity::tool_display (cyclomatic 20) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · SurveyDialog · ×2
  • SurveyDialog::handle_key_option_list (cyclomatic 25) priv/rust/tui/src/dialogs/survey.rs:505 — SurveyDialog::handle_key_option_list 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.
  • SurveyDialog::draw_inline (cyclomatic 22) priv/rust/tui/src/dialogs/survey.rs:681 — SurveyDialog::draw_inline 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 · Permissions · ×2
  • Permissions::draw_inline (cyclomatic 24) priv/rust/tui/src/dialogs/permissions.rs:376 — Permissions::draw_inline 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.
  • Permissions::handle_key (cyclomatic 23) priv/rust/tui/src/dialogs/permissions.rs:247 — Permissions::handle_key has cyclomatic complexity 23 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · ToolKind · ×2
  • ToolKind::noun (cyclomatic 23) priv/rust/tui/src/tools/collapse.rs:127 — ToolKind::noun 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.
  • ToolKind::verb (cyclomatic 17) priv/rust/tui/src/tools/collapse.rs:58 — ToolKind::verb 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 · SessionBrowser · ×2
  • SessionBrowser::draw (cyclomatic 21) priv/rust/tui/src/dialogs/sessions.rs:248 — SessionBrowser::draw 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.
  • SessionBrowser::handle_browse (cyclomatic 16) priv/rust/tui/src/dialogs/sessions.rs:155 — SessionBrowser::handle_browse 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.
D2 · Cognitive Complexity · Agents · ×2
  • Agents::draw_tree (cognitive 210) priv/rust/tui/src/components/agents/render.rs:19 — Agents::draw_tree has cognitive complexity 210 (threshold 15). Drivers by points: if/else 72 (143 pts), match/switch 11 (45 pts), loops 6 (13 pts), boolean chains 9 (nesting depth added 112). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Agents::draw_dashboard (cognitive 71) priv/rust/tui/src/components/agents/render.rs:878 — Agents::draw_dashboard has cognitive complexity 71 (threshold 15). Drivers by points: if/else 35 (59 pts), loops 3 (5 pts), match/switch 3 (5 pts), boolean chains 2 (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 · SkillsBrowser · ×2
  • SkillsBrowser::draw (cognitive 53) priv/rust/tui/src/dialogs/skills_browser.rs:251 — SkillsBrowser::draw has cognitive complexity 53 (threshold 15). Drivers by points: if/else 19 (45 pts), boolean chains 3, match/switch 1 (3 pts), loops 1 (2 pts) (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.
  • SkillsBrowser::ordered (cognitive 16) priv/rust/tui/src/dialogs/skills_browser.rs:103 — SkillsBrowser::ordered has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (9 pts), loops 3 (7 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 · SurveyDialog · ×2
  • SurveyDialog::handle_key_option_list (cognitive 36) priv/rust/tui/src/dialogs/survey.rs:505 — SurveyDialog::handle_key_option_list has cognitive complexity 36 (threshold 15). Drivers by points: if/else 17 (34 pts), boolean chains 1, match/switch 1 (nesting depth added 17). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • SurveyDialog::draw_inline (cognitive 31) priv/rust/tui/src/dialogs/survey.rs:681 — SurveyDialog::draw_inline has cognitive complexity 31 (threshold 15). Drivers by points: if/else 16 (22 pts), boolean chains 6, 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 · ToolKind · ×2
  • ToolKind::noun (cognitive 34) priv/rust/tui/src/tools/collapse.rs:127 — ToolKind::noun has cognitive complexity 34 (threshold 15). Drivers by points: if/else 22 (33 pts), match/switch 1 (nesting depth added 11). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • ToolKind::verb (cognitive 25) priv/rust/tui/src/tools/collapse.rs:58 — ToolKind::verb has cognitive complexity 25 (threshold 15). Drivers by points: if/else 16 (24 pts), match/switch 1 (nesting depth added 8). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · SseClient · ×2
  • SseClient::connect_once (cognitive 32) priv/rust/tui/src/client/sse.rs:241 — SseClient::connect_once has cognitive complexity 32 (threshold 15). Drivers by points: if/else 11 (25 pts), match/switch 2 (5 pts), boolean chains 1, loops 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.
  • SseClient::run_with_reconnect (cognitive 25) priv/rust/tui/src/client/sse.rs:106 — SseClient::run_with_reconnect has cognitive complexity 25 (threshold 15). Drivers by points: if/else 5 (15 pts), match/switch 3 (9 pts), loops 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 · ToolsBrowser · ×2
  • ToolsBrowser::draw (cognitive 30) priv/rust/tui/src/dialogs/tools_browser.rs:227 — ToolsBrowser::draw has cognitive complexity 30 (threshold 15). Drivers by points: if/else 13 (23 pts), match/switch 1 (3 pts), boolean chains 2, 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.
  • ToolsBrowser::ordered (cognitive 16) priv/rust/tui/src/dialogs/tools_browser.rs:93 — ToolsBrowser::ordered has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (9 pts), loops 3 (7 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 · PtyPane · ×2
  • PtyPane::draw (cognitive 24) priv/rust/tui/src/dialogs/pty_pane.rs:299 — PtyPane::draw has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (16 pts), match/switch 2 (4 pts), loops 2 (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.
  • PtyPane::spawn (cognitive 17) priv/rust/tui/src/dialogs/pty_pane.rs:89 — PtyPane::spawn has cognitive complexity 17 (threshold 15). Drivers by points: match/switch 5 (8 pts), if/else 2 (5 pts), loops 3 (4 pts) (nesting depth added 7). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D29 · Static Analysis (SAST) · REDACTED · ×2
  • REDACTED
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED · ×2
  • REDACTED
  • REDACTED
D4 · Code Duplication · Edited copy of a member (40 corresponding lines) · ×2
  • Edited copy of a member (40 corresponding lines) priv/rust/tui/src/app/handle_actions.rs:1537 — priv/rust/tui/src/app/handle_actions.rs:1537-1592 | priv/rust/tui/src/app/handle_actions.rs:3726-3765 — These two members are one piece of code written twice and then edited apart: 40 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.
  • Edited copy of a member (40 corresponding lines) lib/optimal_system_agent/providers/openai_compat_provider.ex:370 — lib/optimal_system_agent/providers/openai_compat_provider.ex:370-411 | lib/optimal_system_agent/providers/openai_compat_provider.ex:416-455 — These two members are one piece of code written twice and then edited apart: 40 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 (47 corresponding lines) · ×2
  • Edited copy of a member (47 corresponding lines) canopy/backend/lib/canopy/adapters/bash.ex:30 — canopy/backend/lib/canopy/adapters/bash.ex:30-76 | canopy/backend/lib/canopy/adapters/codex.ex:30-77 — These two members are one piece of code written twice and then edited apart: 47 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.
  • Edited copy of a member (47 corresponding lines) bench/swebench/run_bench.py:203 — bench/swebench/run_bench.py:203-251 | bench/swebenchpro/run_bench.py:56-102 — These two members are one piece of code written twice and then edited apart: 47 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 (30 corresponding lines) · ×2
  • Edited copy of a member (30 corresponding lines) lib/optimal_system_agent/agent/task_queue.ex:782 — lib/optimal_system_agent/agent/task_queue.ex:782-818 | lib/optimal_system_agent/agent/tasks/queue.ex:396-425 — These two members are one piece of code written twice and then edited apart: 30 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.
  • Edited copy of a member (30 corresponding lines) lib/optimal_system_agent/agent/worktree.ex:165 — lib/optimal_system_agent/agent/worktree.ex:165-194 | lib/optimal_system_agent/tools/builtins/exit_worktree/handler.ex:119-154 — These two members are one piece of code written twice and then edited apart: 30 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 (28 corresponding lines) · ×2
  • Edited copy of a member (28 corresponding lines) priv/rust/tui/src/client/http.rs:166 — priv/rust/tui/src/client/http.rs:166-193 | priv/rust/tui/src/client/http.rs:196-226 — These two members are one piece of code written twice and then edited apart: 28 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.
  • Edited copy of a member (28 corresponding lines) lib/optimal_system_agent/agent/task_tracker.ex:367 — lib/optimal_system_agent/agent/task_tracker.ex:367-399 | lib/optimal_system_agent/agent/tasks/tracker.ex:378-405 — These two members are one piece of code written twice and then edited apart: 28 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 (42 corresponding lines) · ×2
  • Edited copy of a member (42 corresponding lines) lib/optimal_system_agent/agent/loop/react_loop.ex:4303 — lib/optimal_system_agent/agent/loop/react_loop.ex:4303-4344 | lib/optimal_system_agent/agent/loop/react_loop.ex:4353-4400 — These two members are one piece of code written twice and then edited apart: 42 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.
  • Edited copy of a member (42 corresponding lines) lib/optimal_system_agent/tools/builtins/github.ex:28 — lib/optimal_system_agent/tools/builtins/github.ex:28-69 | lib/optimal_system_agent/tools/builtins/goal/update_tool.ex:54-95 — These two members are one piece of code written twice and then edited apart: 42 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 copies of one member (3 members, 34+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 34+ corresponding lines) lib/optimal_system_agent/agent/task_tracker.ex:226 — lib/optimal_system_agent/agent/task_tracker.ex:226-259 | lib/optimal_system_agent/agent/task_tracker.ex:264-297 | lib/optimal_system_agent/agent/task_tracker.ex:302-336 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 34 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 34+ corresponding lines) lib/optimal_system_agent/tools/builtins/monitor/tool.ex:36 — lib/optimal_system_agent/tools/builtins/monitor/tool.ex:36-80 | lib/optimal_system_agent/tools/builtins/notebook_edit/tool.ex:51-84 | lib/optimal_system_agent/tools/builtins/peer_review/tool.ex:32-65 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 34 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 22+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 22+ corresponding lines) priv/rust/tui/src/components/completion_panel.rs:264 — priv/rust/tui/src/components/completion_panel.rs:264-286 | priv/rust/tui/src/dialogs/cost_dashboard.rs:204-225 | priv/rust/tui/src/dialogs/keybindings_viewer.rs:76-97 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 22 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 22+ corresponding lines) lib/optimal_system_agent/tools/ablation/runner.ex:288 — lib/optimal_system_agent/tools/ablation/runner.ex:288-313 | lib/optimal_system_agent/tools/ablation/runner.ex:475-496 | lib/optimal_system_agent/tools/ablation/runner.ex:503-527 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 22 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 10+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 10+ corresponding lines) lib/optimal_system_agent/channels/dingtalk.ex:145 — lib/optimal_system_agent/channels/dingtalk.ex:145-154 | lib/optimal_system_agent/channels/feishu.ex:170-187 | lib/optimal_system_agent/channels/wecom.ex:132-142 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 10 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 10+ corresponding lines) canopy/backend/lib/canopy_web/controllers/activity_controller.ex:34 — canopy/backend/lib/canopy_web/controllers/activity_controller.ex:34-43 | canopy/backend/lib/canopy_web/controllers/log_controller.ex:5-17 | canopy/backend/lib/canopy_web/controllers/session_controller.ex:137-146 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 10 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copy of a member (31 corresponding lines) · ×2
  • Edited copy of a member (31 corresponding lines) lib/optimal_system_agent/onboarding.ex:1455 — lib/optimal_system_agent/onboarding.ex:1455-1494 | lib/optimal_system_agent/onboarding.ex:1766-1796 — These two members are one piece of code written twice and then edited apart: 31 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.
  • Edited copy of a member (31 corresponding lines) lib/optimal_system_agent/agent/task_queue.ex:746 — lib/optimal_system_agent/agent/task_queue.ex:746-776 | lib/optimal_system_agent/agent/tasks/queue.ex:361-392 — These two members are one piece of code written twice and then edited apart: 31 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 copies of one member (3 members, 9+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 9+ corresponding lines) lib/optimal_system_agent/remote/client.ex:206 — lib/optimal_system_agent/remote/client.ex:206-214 | lib/optimal_system_agent/remote/client.ex:218-232 | lib/optimal_system_agent/remote/client.ex:245-257 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 9 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 9+ corresponding lines) lib/optimal_system_agent/providers/deepseek_models.ex:349 — lib/optimal_system_agent/providers/deepseek_models.ex:349-358 | lib/optimal_system_agent/providers/xai_models.ex:411-419 | lib/optimal_system_agent/providers/zai_models.ex:507-515 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 9 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 17+ corresponding lines) · ×2
  • Edited copies of one member (4 members, 17+ corresponding lines) canopy/backend/lib/canopy_web/controllers/budget_controller.ex:72 — canopy/backend/lib/canopy_web/controllers/budget_controller.ex:72-88 | canopy/backend/lib/canopy_web/controllers/issue_controller.ex:126-144 | canopy/backend/lib/canopy_web/controllers/session_controller.ex:70-86 | canopy/backend/lib/canopy_web/controllers/skill_controller.ex:37-53 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 17 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
  • Edited copies of one member (4 members, 17+ corresponding lines) lib/optimal_system_agent/auth/providers/minimax.ex:309 — lib/optimal_system_agent/auth/providers/minimax.ex:309-330 | lib/optimal_system_agent/auth/providers/openai_codex.ex:396-418 | REDACTED:198-215 | lib/optimal_system_agent/auth/providers/xai.ex:180-196 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 17 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 24+ corresponding lines) · ×2
  • Edited copies of one member (4 members, 24+ corresponding lines) lib/optimal_system_agent/tools/builtins/create_agent/tool.ex:36 — lib/optimal_system_agent/tools/builtins/create_agent/tool.ex:36-65 | lib/optimal_system_agent/tools/builtins/peer_claim_region/tool.ex:32-59 | lib/optimal_system_agent/tools/builtins/peer_negotiate_task/tool.ex:32-55 | lib/optimal_system_agent/tools/builtins/team_create/tool.ex:36-64 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 24 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
  • Edited copies of one member (4 members, 24+ corresponding lines) lib/optimal_system_agent/tools/builtins/claims_board.ex:55 — lib/optimal_system_agent/tools/builtins/claims_board.ex:55-86 | lib/optimal_system_agent/tools/builtins/config/tool.ex:37-60 | lib/optimal_system_agent/tools/builtins/repo_map.ex:60-84 | lib/optimal_system_agent/tools/builtins/workspace_map.ex:66-91 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 24 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 21+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 21+ corresponding lines) lib/optimal_system_agent/tools/builtins/dir_list/messages.ex:69 — lib/optimal_system_agent/tools/builtins/dir_list/messages.ex:69-90 | lib/optimal_system_agent/tools/builtins/file_glob/messages.ex:37-57 | lib/optimal_system_agent/tools/builtins/file_read/messages.ex:95-118 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 21 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 21+ corresponding lines) lib/optimal_system_agent/auth/providers/bedrock.ex:186 — lib/optimal_system_agent/auth/providers/bedrock.ex:186-206 | lib/optimal_system_agent/auth/providers/claude_cli.ex:518-546 | lib/optimal_system_agent/auth/providers/ollama_account.ex:345-365 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 21 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 12+ corresponding lines) · ×2
  • Edited copies of one member (4 members, 12+ corresponding lines) lib/optimal_system_agent/channels/discord.ex:218 — lib/optimal_system_agent/channels/discord.ex:218-229 | lib/optimal_system_agent/channels/slack.ex:236-247 | lib/optimal_system_agent/channels/telegram.ex:271-287 | lib/optimal_system_agent/channels/whatsapp.ex:222-238 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 12 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
  • Edited copies of one member (4 members, 12+ corresponding lines) lib/mix/tasks/osa.setup.wizard.ex:240 — lib/mix/tasks/osa.setup.wizard.ex:240-255 | lib/mix/tasks/osa.setup.wizard.ex:278-289 | lib/optimal_system_agent/cli/setup.ex:245-261 | lib/optimal_system_agent/cli/setup.ex:299-311 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 12 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (5 members, 8+ corresponding lines) · ×2
  • Edited copies of one member (5 members, 8+ corresponding lines) priv/rust/tui/src/clipboard.rs:251 — priv/rust/tui/src/clipboard.rs:251-258 | priv/rust/tui/src/components/input/history.rs:30-39 | priv/rust/tui/src/components/jailbreak.rs:26-34 | priv/rust/tui/src/config/cli.rs:3-11 | priv/rust/tui/src/config/mod.rs:149-159 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 8 lines, 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 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. Left alone, the next edit has to be made 5 times and the copies will drift further apart.
  • Edited copies of one member (5 members, 8+ corresponding lines) lib/optimal_system_agent/channels/dingtalk.ex:171 — lib/optimal_system_agent/channels/dingtalk.ex:171-178 | lib/optimal_system_agent/channels/feishu.ex:253-260 | lib/optimal_system_agent/channels/line.ex:252-259 | lib/optimal_system_agent/channels/matrix.ex:244-251 | lib/optimal_system_agent/channels/wecom.ex:159-166 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 8 lines, 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 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. Left alone, the next edit has to be made 5 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (6 members, 3+ corresponding lines) · ×2
  • Edited copies of one member (6 members, 3+ corresponding lines) lib/optimal_system_agent/tools/builtins/download/handler.ex:136 — lib/optimal_system_agent/tools/builtins/download/handler.ex:136-138 | lib/optimal_system_agent/tools/builtins/file_transform/handler.ex:327-329 | lib/optimal_system_agent/tools/builtins/file_write/handler.ex:250-252 | lib/optimal_system_agent/tools/builtins/multi_file_edit/handler.ex:472-474 | lib/optimal_system_agent/tools/builtins/structural_edit/handler.ex:563-565 | lib/optimal_system_agent/tools/conflict_scope.ex:404-406 — These 6 members are one piece of code written 6 times and then edited apart: every two of them correspond over at least 3 lines, 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 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. Left alone, the next edit has to be made 6 times and the copies will drift further apart.
  • Edited copies of one member (6 members, 3+ corresponding lines) lib/optimal_system_agent/repo_map.ex:561 — lib/optimal_system_agent/repo_map.ex:561-563 | lib/optimal_system_agent/security/http_replay.ex:326-328 | lib/optimal_system_agent/security/proxy_capture.ex:281-283 | lib/optimal_system_agent/security/shadow_graph.ex:111-114 | lib/optimal_system_agent/security/threat_intel.ex:210-217 | lib/optimal_system_agent/verification/upstream_verifier.ex:360-364 — These 6 members are one piece of code written 6 times and then edited apart: every two of them correspond over at least 3 lines, 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 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. Left alone, the next edit has to be made 6 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 6+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 6+ corresponding lines) priv/rust/tui/src/components/notify.rs:87 — priv/rust/tui/src/components/notify.rs:87-93 | priv/rust/tui/src/notification/kitty.rs:67-72 | priv/rust/tui/src/notification/progress.rs:84-89 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 6 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 6+ corresponding lines) lib/optimal_system_agent/agent/loop/context_collapse.ex:22 — lib/optimal_system_agent/agent/loop/context_collapse.ex:22-36 | lib/optimal_system_agent/providers/fallback_chain.ex:584-606 | lib/optimal_system_agent/sandbox/miosa_cli.ex:269-274 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 6 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 5+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 5+ corresponding lines) lib/optimal_system_agent/agent/loop/doom_loop/stall.ex:381 — lib/optimal_system_agent/agent/loop/doom_loop/stall.ex:381-386 | lib/optimal_system_agent/agent/loop/regulation/signals.ex:200-204 | lib/optimal_system_agent/providers/ollama.ex:1544-1550 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 5 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 5+ corresponding lines) bench/osabench/fixtures/acme/lib/acme/accounts.ex:5 — bench/osabench/fixtures/acme/lib/acme/accounts.ex:5-9 | bench/osabench/fixtures/acme/lib/acme/newsletter.ex:5-9 | bench/osabench/fixtures/acme/lib/acme/users.ex:5-10 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 5 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 3+ corresponding lines) · ×2
  • Edited copies of one member (4 members, 3+ corresponding lines) lib/optimal_system_agent/agent/loop/reasoning_watchdog.ex:292 — lib/optimal_system_agent/agent/loop/reasoning_watchdog.ex:292-294 | lib/optimal_system_agent/agent/loop/regulation/pain.ex:365-367 | lib/optimal_system_agent/channels/cli/format.ex:37-39 | lib/optimal_system_agent/providers/error_catalog.ex:726-728 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 3 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
  • Edited copies of one member (4 members, 3+ corresponding lines) lib/optimal_system_agent/peer/negotiation.ex:372 — lib/optimal_system_agent/peer/negotiation.ex:372-374 | lib/optimal_system_agent/security/http_replay.ex:107-112 | lib/optimal_system_agent/speculative/executor.ex:136-138 | lib/optimal_system_agent/workspace/session.ex:126-128 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 3 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Duplicated block (27 lines × 2) · ×2
  • Duplicated block (27 lines × 2) lib/optimal_system_agent/auth/providers/copilot.ex:437 — lib/optimal_system_agent/auth/providers/copilot.ex:437-463 | lib/optimal_system_agent/auth/providers/openai_codex.ex:595-623 — before extracting anything, compare `lib/optimal_system_agent/auth/providers/copilot.ex` and `lib/optimal_system_agent/auth/providers/openai_codex.ex` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 68 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 `lib/optimal_system_agent/auth/providers/copilot.ex:437` 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) lib/optimal_system_agent/channels/cli/commands.ex:694 — lib/optimal_system_agent/channels/cli/commands.ex:694-720 | lib/optimal_system_agent/channels/cli/commands.ex:1707-1733 — 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 (26 lines × 2) · ×2
  • Duplicated block (26 lines × 2) lib/optimal_system_agent/agent/tasks/workflow.ex:380 — lib/optimal_system_agent/agent/tasks/workflow.ex:380-405 | lib/optimal_system_agent/agent/workflow.ex:485-510 — before extracting anything, compare `lib/optimal_system_agent/agent/tasks/workflow.ex` and `lib/optimal_system_agent/agent/workflow.ex` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 285 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 (26 lines × 2) lib/optimal_system_agent/tools/builtins/vault_checkpoint.ex:5 — lib/optimal_system_agent/tools/builtins/vault_checkpoint.ex:5-38 | lib/optimal_system_agent/tools/builtins/vault_wake.ex:5-30 — 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 (23–25 lines × 2) · ×2
  • Duplicated block (23–25 lines × 2) lib/optimal_system_agent/open_computers/remote.ex:34 — lib/optimal_system_agent/open_computers/remote.ex:34-56 | lib/optimal_system_agent/open_computers/remote.ex:63-87 — 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 `lib/optimal_system_agent/open_computers/remote.ex:34` 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 (23–25 lines × 2) lib/optimal_system_agent/tools/builtins/exit_worktree/tool.ex:34 — lib/optimal_system_agent/tools/builtins/exit_worktree/tool.ex:34-58 | lib/optimal_system_agent/tools/builtins/file_read/tool.ex:38-60 — 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 `lib/optimal_system_agent/tools/builtins/exit_worktree/tool.ex:34` 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 (22–23 lines × 2) · ×2
  • Duplicated block (22–23 lines × 2) lib/optimal_system_agent/agent/task_queue.ex:250 — lib/optimal_system_agent/agent/task_queue.ex:250-272 | lib/optimal_system_agent/agent/tasks/queue.ex:149-170 — before extracting anything, compare `lib/optimal_system_agent/agent/task_queue.ex` and `lib/optimal_system_agent/agent/tasks/queue.ex` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 149 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 (22–23 lines × 2) priv/rust/tui/src/components/completion_panel.rs:353 — priv/rust/tui/src/components/completion_panel.rs:353-374 | priv/rust/tui/src/dialogs/cost_dashboard.rs:280-302 — before extracting anything, compare `priv/rust/tui/src/components/completion_panel.rs` and `priv/rust/tui/src/dialogs/cost_dashboard.rs` 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 `priv/rust/tui/src/components/completion_panel.rs:353` 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 lines × 2) · ×2
  • Duplicated block (23 lines × 2) lib/optimal_system_agent/agent/task_queue.ex:518 — lib/optimal_system_agent/agent/task_queue.ex:518-540 | lib/optimal_system_agent/agent/tasks/queue.ex:309-331 — before extracting anything, compare `lib/optimal_system_agent/agent/task_queue.ex` and `lib/optimal_system_agent/agent/tasks/queue.ex` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 149 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 `lib/optimal_system_agent/agent/task_queue.ex:518` 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, `lib/optimal_system_agent/agent/task_queue.ex:548` calls `put` and `lib/optimal_system_agent/agent/tasks/queue.ex:335` 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 (23 lines × 2) priv/rust/tui/src/dialogs/persona_picker.rs:317 — priv/rust/tui/src/dialogs/persona_picker.rs:317-339 | priv/rust/tui/src/dialogs/tools_browser.rs:367-389 — before extracting anything, compare `priv/rust/tui/src/dialogs/persona_picker.rs` and `priv/rust/tui/src/dialogs/tools_browser.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 229 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 `priv/rust/tui/src/dialogs/persona_picker.rs:317` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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) · ×2
  • Duplicated block (22 lines × 2) lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex:152 — lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex:152-173 | lib/optimal_system_agent/open_computers/executor/direct/cluster/mlx_distributed.ex:181-202 — before extracting anything, compare `lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex` and `lib/optimal_system_agent/open_computers/executor/direct/cluster/mlx_distributed.ex` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 66 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 `lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex: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 (22 lines × 2) lib/optimal_system_agent/telemetry/metrics.ex:129 — lib/optimal_system_agent/telemetry/metrics.ex:129-150 | lib/optimal_system_agent/telemetry/metrics.ex:159-180 — 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 `lib/optimal_system_agent/telemetry/metrics.ex:129` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (16–20 lines × 2) · ×2
  • Duplicated block (16–20 lines × 2) lib/optimal_system_agent/agent/loop/goal_tracker.ex:1692 — lib/optimal_system_agent/agent/loop/goal_tracker.ex:1692-1707 | lib/optimal_system_agent/agent/loop/goal_verifier.ex:1990-2009 — 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–20 lines × 2) lib/optimal_system_agent/tools/builtins/file_transform/tool.ex:61 — lib/optimal_system_agent/tools/builtins/file_transform/tool.ex:61-76 | lib/optimal_system_agent/tools/builtins/task_write/tool.ex:60-79 — `lib/optimal_system_agent/tools/builtins/file_transform/tool.ex` and `lib/optimal_system_agent/tools/builtins/task_write/tool.ex` 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. Read the line range as the matched WINDOW rather than a finished unit: at `lib/optimal_system_agent/tools/builtins/file_transform/tool.ex:61` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (16–18 lines × 2) · ×2
  • Duplicated block (16–18 lines × 2) lib/optimal_system_agent/agent/scheduler.ex:321 — lib/optimal_system_agent/agent/scheduler.ex:321-336 | lib/optimal_system_agent/agent/scheduler.ex:403-420 — 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 `lib/optimal_system_agent/agent/scheduler.ex:321` 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–18 lines × 2) priv/rust/tui/src/app/event_loop.rs:2991 — priv/rust/tui/src/app/event_loop.rs:2991-3006 | priv/rust/tui/src/app/event_loop.rs:3131-3148 — 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 `priv/rust/tui/src/app/event_loop.rs:2991` 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 (16–17 lines × 3) · ×2
  • Duplicated block (16–17 lines × 3) lib/optimal_system_agent/tools/builtins/bash_output/tool.ex:44 — lib/optimal_system_agent/tools/builtins/bash_output/tool.ex:44-59 | lib/optimal_system_agent/tools/builtins/file_transform/tool.ex:73-89 | lib/optimal_system_agent/tools/builtins/task_write/tool.ex:102-117 — `lib/optimal_system_agent/tools/builtins/file_transform/tool.ex` and `lib/optimal_system_agent/tools/builtins/task_write/tool.ex` 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. Read the line range as the matched WINDOW rather than a finished unit: at `lib/optimal_system_agent/tools/builtins/bash_output/tool.ex:44` 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–17 lines × 3) lib/optimal_system_agent/tools/builtins/code_symbols/tool.ex:40 — lib/optimal_system_agent/tools/builtins/code_symbols/tool.ex:40-56 | lib/optimal_system_agent/tools/builtins/exit_worktree/tool.ex:33-49 | lib/optimal_system_agent/tools/builtins/file_read/tool.ex:37-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. Read the line range as the matched WINDOW rather than a finished unit: at `lib/optimal_system_agent/tools/builtins/code_symbols/tool.ex:40` 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 (17 lines × 3) · ×2
  • Duplicated block (17 lines × 3) lib/optimal_system_agent/tools/builtins/cross_team_query/tool.ex:47 — lib/optimal_system_agent/tools/builtins/cross_team_query/tool.ex:47-63 | lib/optimal_system_agent/tools/builtins/peer_claim_region/tool.ex:43-59 | lib/optimal_system_agent/tools/builtins/team_tasks/tool.ex:48-64 — `lib/optimal_system_agent/tools/builtins/cross_team_query/tool.ex` and `lib/optimal_system_agent/tools/builtins/peer_claim_region/tool.ex` 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 119 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 `lib/optimal_system_agent/tools/builtins/cross_team_query/tool.ex:47` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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) canopy/backend/lib/canopy/adapters/cursor.ex:33 — canopy/backend/lib/canopy/adapters/cursor.ex:33-49 | canopy/backend/lib/canopy/adapters/gemini.ex:33-49 | canopy/backend/lib/canopy/adapters/openclaw.ex:33-49 — 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.
D4 · Code Duplication · Duplicated block (13–17 lines × 2) · ×2
  • Duplicated block (13–17 lines × 2) lib/mix/tasks/osa.setup.wizard.ex:303 — lib/mix/tasks/osa.setup.wizard.ex:303-319 | lib/optimal_system_agent/cli/setup.ex:330-342 — 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 `lib/mix/tasks/osa.setup.wizard.ex: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.
  • Duplicated block (13–17 lines × 2) lib/optimal_system_agent/tools/builtins/config/tool.ex:40 — lib/optimal_system_agent/tools/builtins/config/tool.ex:40-52 | lib/optimal_system_agent/tools/builtins/rollback/tool.ex:43-59 — 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 `lib/optimal_system_agent/tools/builtins/config/tool.ex:40` 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 (15–17 lines × 2) · ×2
  • Duplicated block (15–17 lines × 2) lib/optimal_system_agent/agent/compactor.ex:1797 — lib/optimal_system_agent/agent/compactor.ex:1797-1813 | lib/optimal_system_agent/agent/compactor.ex:2192-2206 — 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 `lib/optimal_system_agent/agent/compactor.ex:2192` 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 (15–17 lines × 2) lib/optimal_system_agent/providers/registry.ex:1297 — lib/optimal_system_agent/providers/registry.ex:1297-1311 | lib/optimal_system_agent/providers/registry.ex:1331-1347 — 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 (16–17 lines × 2) · ×2
  • Duplicated block (16–17 lines × 2) lib/optimal_system_agent/tools/builtins/save_skill.ex:53 — lib/optimal_system_agent/tools/builtins/save_skill.ex:53-68 | lib/optimal_system_agent/tools/builtins/task_write/tool.ex:71-87 — before extracting anything, compare `lib/optimal_system_agent/tools/builtins/save_skill.ex` and `lib/optimal_system_agent/tools/builtins/task_write/tool.ex` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 84 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 `lib/optimal_system_agent/tools/builtins/save_skill.ex:53` 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–17 lines × 2) priv/rust/tui/src/client/http.rs:173 — priv/rust/tui/src/client/http.rs:173-189 | priv/rust/tui/src/client/http.rs:207-222 — 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 `priv/rust/tui/src/client/http.rs:173` 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–16 lines × 2) · ×2
  • Duplicated block (15–16 lines × 2) lib/optimal_system_agent/tools/builtins/file_read.ex:118 — lib/optimal_system_agent/tools/builtins/file_read.ex:118-133 | lib/optimal_system_agent/tools/builtins/file_read/handler.ex:789-803 — 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 (15–16 lines × 2) priv/rust/tui/src/app/handle_actions.rs:2700 — priv/rust/tui/src/app/handle_actions.rs:2700-2714 | priv/rust/tui/src/components/chat/welcome.rs:253-268 — 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. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (14 lines × 3) · ×2
  • Duplicated block (14 lines × 3) lib/optimal_system_agent/providers/anthropic.ex:168 — lib/optimal_system_agent/providers/anthropic.ex:168-181 | lib/optimal_system_agent/providers/cohere.ex:95-108 | lib/optimal_system_agent/providers/google.ex:176-189 — 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 (14 lines × 3) priv/rust/tui/src/dialogs/skills_browser.rs:350 — priv/rust/tui/src/dialogs/skills_browser.rs:350-363 | priv/rust/tui/src/dialogs/tasks_panel.rs:285-298 | priv/rust/tui/src/dialogs/tools_browser.rs:326-339 — before extracting anything, compare `priv/rust/tui/src/dialogs/skills_browser.rs` and `priv/rust/tui/src/dialogs/tasks_panel.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 133 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 `priv/rust/tui/src/dialogs/skills_browser.rs:350` 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 (12–14 lines × 3) · ×2
  • Duplicated block (12–14 lines × 3) lib/optimal_system_agent/tools/builtins/delegate/tool.ex:112 — lib/optimal_system_agent/tools/builtins/delegate/tool.ex:112-123 | lib/optimal_system_agent/tools/builtins/repo_map.ex:63-76 | lib/optimal_system_agent/tools/builtins/security_intel.ex:171-182 — before extracting anything, compare `lib/optimal_system_agent/tools/builtins/delegate/tool.ex` and `lib/optimal_system_agent/tools/builtins/security_intel.ex` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 65 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 `lib/optimal_system_agent/tools/builtins/delegate/tool.ex:112` 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 (12–14 lines × 3) priv/rust/tui/src/dialogs/doctor_panel.rs:329 — priv/rust/tui/src/dialogs/doctor_panel.rs:329-342 | priv/rust/tui/src/dialogs/memory_browser.rs:285-296 | priv/rust/tui/src/dialogs/persona_picker.rs:329-342 — before extracting anything, compare `priv/rust/tui/src/dialogs/doctor_panel.rs` and `priv/rust/tui/src/dialogs/memory_browser.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 145 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 `priv/rust/tui/src/dialogs/doctor_panel.rs:329` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (11–13 lines × 2) · ×2
  • Duplicated block (11–13 lines × 2) lib/optimal_system_agent/agent/tasks/workflow.ex:123 — lib/optimal_system_agent/agent/tasks/workflow.ex:123-133 | lib/optimal_system_agent/agent/workflow.ex:255-267 — before extracting anything, compare `lib/optimal_system_agent/agent/tasks/workflow.ex` and `lib/optimal_system_agent/agent/workflow.ex` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 285 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–13 lines × 2) bench/recoverybench/delta_report.py:214 — bench/recoverybench/delta_report.py:214-224 | bench/terminalbench/report.py:809-821 — 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 (10–13 lines × 2) · ×2
  • Duplicated block (10–13 lines × 2) lib/optimal_system_agent/providers/claude_cli.ex:349 — lib/optimal_system_agent/providers/claude_cli.ex:349-361 | lib/optimal_system_agent/providers/copilot_cli.ex:294-303 — before extracting anything, compare `lib/optimal_system_agent/providers/claude_cli.ex` and `lib/optimal_system_agent/providers/copilot_cli.ex` as WHOLE FILES: this scan already matched 7 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. 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 `lib/optimal_system_agent/providers/claude_cli.ex:349` 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–13 lines × 2) priv/rust/tui/src/components/chat/thinking_box.rs:290 — priv/rust/tui/src/components/chat/thinking_box.rs:290-302 | priv/rust/tui/src/components/chat/thinking_box.rs:352-361 — 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 `priv/rust/tui/src/components/chat/thinking_box.rs:290` 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–12 lines × 2) · ×2
  • Duplicated block (10–12 lines × 2) canopy/backend/lib/canopy_web/controllers/document_controller.ex:50 — canopy/backend/lib/canopy_web/controllers/document_controller.ex:50-61 | canopy/backend/lib/canopy_web/controllers/document_controller.ex:108-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 `canopy/backend/lib/canopy_web/controllers/document_controller.ex: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.
  • Duplicated block (10–12 lines × 2) priv/rust/tui/src/components/agents/mod.rs:1200 — priv/rust/tui/src/components/agents/mod.rs:1200-1211 | priv/rust/tui/src/components/agents/mod.rs:1495-1504 — 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 `priv/rust/tui/src/components/agents/mod.rs:1200` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (5 lines × 3) · ×2
  • Duplicated block (5 lines × 3) canopy/backend/lib/canopy_web/controllers/activity_controller.ex:18 — canopy/backend/lib/canopy_web/controllers/activity_controller.ex:18-22 | canopy/backend/lib/canopy_web/controllers/audit_controller.ex:20-24 | canopy/backend/lib/canopy_web/controllers/memory_controller.ex:17-21 — 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `canopy/backend/lib/canopy_web/controllers/audit_controller.ex:25` calls `where`, `ilike` and `canopy/backend/lib/canopy_web/controllers/activity_controller.ex:23` 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 × 3) lib/optimal_system_agent/sandbox/docker.ex:151 — lib/optimal_system_agent/sandbox/docker.ex:151-155 | lib/optimal_system_agent/sandbox/host.ex:28-32 | lib/optimal_system_agent/sandbox/vercel.ex:169-173 — 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.
D4 · Code Duplication · Duplicated block (6 lines × 6) · ×2
  • Duplicated block (6 lines × 6) lib/optimal_system_agent/agent/ask_user_mode.ex:228 — lib/optimal_system_agent/agent/ask_user_mode.ex:228-233 | lib/optimal_system_agent/agent/coordinator_mode.ex:71-76 | lib/optimal_system_agent/agent/loop/goal_tracker.ex:2100-2105 | lib/optimal_system_agent/agent/plan_store.ex:181-186 | lib/optimal_system_agent/tools/builtins/task_wait/depth.ex:112-117 | lib/optimal_system_agent/tools/builtins/task_wait/rewait_guard.ex:84-89 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `lib/optimal_system_agent/agent/ask_user_mode.ex:228` 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 before the matched lines, `lib/optimal_system_agent/agent/plan_store.ex:178` calls `clear` and `lib/optimal_system_agent/tools/builtins/task_wait/rewait_guard.ex:81` 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 × 6) priv/rust/tui/src/dialogs/command_palette.rs:153 — priv/rust/tui/src/dialogs/command_palette.rs:153-159 | priv/rust/tui/src/dialogs/file_picker.rs:239-244 | priv/rust/tui/src/dialogs/model_picker.rs:1511-1516 | priv/rust/tui/src/dialogs/picker.rs:154-159 | priv/rust/tui/src/dialogs/reasoning.rs:155-160 | priv/rust/tui/src/dialogs/rewind.rs:139-144 — before extracting anything, compare `priv/rust/tui/src/dialogs/command_palette.rs` and `priv/rust/tui/src/dialogs/picker.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 67 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, `priv/rust/tui/src/dialogs/command_palette.rs:160` calls `title`, `styled`, `modal_title` and `priv/rust/tui/src/dialogs/file_picker.rs:245` 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 (11 lines × 5) · ×2
  • Duplicated block (11 lines × 5) lib/optimal_system_agent/auth/providers/copilot.ex:359 — lib/optimal_system_agent/auth/providers/copilot.ex:359-369 | lib/optimal_system_agent/auth/providers/minimax.ex:392-402 | lib/optimal_system_agent/auth/providers/openai_codex.ex:499-509 | REDACTED:350-360 | lib/optimal_system_agent/auth/providers/xai.ex:275-285 — before extracting anything, compare `lib/optimal_system_agent/auth/providers/copilot.ex` and `lib/optimal_system_agent/auth/providers/openai_codex.ex` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 68 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 `lib/optimal_system_agent/auth/providers/copilot.ex:359` 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 before the matched lines, `lib/optimal_system_agent/auth/providers/copilot.ex:357` calls `access_token`, `t`, `term` and `lib/optimal_system_agent/auth/providers/openai_codex.ex:497` 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 (11 lines × 5) priv/rust/tui/src/dialogs/channels_panel.rs:266 — priv/rust/tui/src/dialogs/channels_panel.rs:266-278 | priv/rust/tui/src/dialogs/doctor_panel.rs:332-344 | priv/rust/tui/src/dialogs/memory_browser.rs:288-298 | priv/rust/tui/src/dialogs/permissions_manager.rs:362-374 | priv/rust/tui/src/dialogs/persona_picker.rs:332-344 — before extracting anything, compare `priv/rust/tui/src/dialogs/channels_panel.rs` and `priv/rust/tui/src/dialogs/doctor_panel.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 137 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 `priv/rust/tui/src/dialogs/channels_panel.rs:266` 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–18 lines × 2) · ×2
  • Duplicated block (15–18 lines × 2) priv/rust/tui/src/dialogs/overdrive_confirm.rs:30 — priv/rust/tui/src/dialogs/overdrive_confirm.rs:30-44 | priv/rust/tui/src/dialogs/quit_confirm.rs:50-67 — 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 `priv/rust/tui/src/dialogs/overdrive_confirm.rs:30` 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, `priv/rust/tui/src/dialogs/quit_confirm.rs:45` calls `Char`, `contains`, `Some` and `priv/rust/tui/src/dialogs/overdrive_confirm.rs:28` 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–18 lines × 2) bench/swebench/report.py:722 — bench/swebench/report.py:722-736 | bench/terminalbench/report.py:1323-1340 — 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 `bench/swebench/report.py:722` 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 (11 lines × 6) · ×2
  • Duplicated block (11 lines × 6) priv/rust/tui/src/dialogs/config_editor.rs:348 — priv/rust/tui/src/dialogs/config_editor.rs:348-358 | priv/rust/tui/src/dialogs/file_picker.rs:251-261 | priv/rust/tui/src/dialogs/onboarding.rs:1068-1078 | priv/rust/tui/src/dialogs/reasoning.rs:167-177 | priv/rust/tui/src/dialogs/rewind.rs:151-161 | priv/rust/tui/src/dialogs/sessions.rs:271-281 — before extracting anything, compare `priv/rust/tui/src/dialogs/config_editor.rs` and `priv/rust/tui/src/dialogs/file_picker.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 30 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 × 6) priv/rust/tui/src/dialogs/doctor_panel.rs:275 — priv/rust/tui/src/dialogs/doctor_panel.rs:275-285 | priv/rust/tui/src/dialogs/memory_browser.rs:232-242 | priv/rust/tui/src/dialogs/permissions_manager.rs:294-304 | priv/rust/tui/src/dialogs/persona_picker.rs:271-281 | priv/rust/tui/src/dialogs/skills_browser.rs:343-353 | priv/rust/tui/src/dialogs/tools_browser.rs:319-329 — before extracting anything, compare `priv/rust/tui/src/dialogs/doctor_panel.rs` and `priv/rust/tui/src/dialogs/memory_browser.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 145 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 `priv/rust/tui/src/dialogs/doctor_panel.rs:275` 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–11 lines × 2) · ×2
  • Duplicated block (8–11 lines × 2) priv/rust/tui/src/dialogs/picker.rs:241 — priv/rust/tui/src/dialogs/picker.rs:241-251 | priv/rust/tui/src/dialogs/reasoning.rs:213-220 — 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 `priv/rust/tui/src/dialogs/picker.rs:241` 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–11 lines × 2) bench/swebench/runners.py:210 — bench/swebench/runners.py:210-220 | bench/swebenchpro/runners.py:152-159 — 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 (10 lines × 5) · ×2
  • Duplicated block (10 lines × 5) priv/rust/tui/src/dialogs/memory_browser.rs:194 — priv/rust/tui/src/dialogs/memory_browser.rs:194-203 | priv/rust/tui/src/dialogs/persona_picker.rs:226-235 | priv/rust/tui/src/dialogs/skills_browser.rs:298-307 | priv/rust/tui/src/dialogs/tasks_panel.rs:252-261 | priv/rust/tui/src/dialogs/tools_browser.rs:274-283 — before extracting anything, compare `priv/rust/tui/src/dialogs/memory_browser.rs` and `priv/rust/tui/src/dialogs/persona_picker.rs` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 245 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 `priv/rust/tui/src/dialogs/memory_browser.rs:194` 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 lines × 5) priv/rust/tui/src/dialogs/memory_browser.rs:296 — priv/rust/tui/src/dialogs/memory_browser.rs:296-305 | priv/rust/tui/src/dialogs/permissions_manager.rs:372-381 | priv/rust/tui/src/dialogs/persona_picker.rs:342-351 | priv/rust/tui/src/dialogs/skills_browser.rs:448-457 | priv/rust/tui/src/dialogs/tools_browser.rs:394-403 — before extracting anything, compare `priv/rust/tui/src/dialogs/memory_browser.rs` and `priv/rust/tui/src/dialogs/permissions_manager.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 223 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 `priv/rust/tui/src/dialogs/memory_browser.rs:296` 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 lines × 4) · ×2
  • Duplicated block (10 lines × 4) priv/rust/tui/src/dialogs/channels_panel.rs:276 — priv/rust/tui/src/dialogs/channels_panel.rs:276-285 | priv/rust/tui/src/dialogs/doctor_panel.rs:342-351 | priv/rust/tui/src/dialogs/mcp_servers.rs:226-235 | priv/rust/tui/src/dialogs/tasks_panel.rs:370-379 — before extracting anything, compare `priv/rust/tui/src/dialogs/channels_panel.rs` and `priv/rust/tui/src/dialogs/doctor_panel.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 137 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 `priv/rust/tui/src/dialogs/channels_panel.rs:276` 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 (10 lines × 4) priv/rust/tui/src/app/commands.rs:942 — priv/rust/tui/src/app/commands.rs:942-951 | priv/rust/tui/src/app/commands.rs:964-973 | priv/rust/tui/src/app/commands.rs:1031-1040 | priv/rust/tui/src/app/commands.rs:1101-1110 — 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 `priv/rust/tui/src/app/commands.rs:942` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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 (9–10 lines × 3) · ×2
  • Duplicated block (9–10 lines × 3) priv/rust/tui/src/dialogs/file_picker.rs:309 — priv/rust/tui/src/dialogs/file_picker.rs:309-318 | priv/rust/tui/src/dialogs/model_picker.rs:2011-2019 | priv/rust/tui/src/dialogs/sessions.rs:328-337 — before extracting anything, compare `priv/rust/tui/src/dialogs/file_picker.rs` and `priv/rust/tui/src/dialogs/model_picker.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 54 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 `priv/rust/tui/src/dialogs/file_picker.rs:309` 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–10 lines × 3) priv/rust/tui/src/render/markdown.rs:2166 — priv/rust/tui/src/render/markdown.rs:2166-2175 | priv/rust/tui/src/render/markdown.rs:2252-2261 | priv/rust/tui/src/render/markdown.rs:2322-2330 — 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 `priv/rust/tui/src/render/markdown.rs:2166` 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 (9 lines × 4) · ×2
  • Duplicated block (9 lines × 4) priv/rust/tui/src/dialogs/file_picker.rs:239 — priv/rust/tui/src/dialogs/file_picker.rs:239-247 | priv/rust/tui/src/dialogs/model_picker.rs:1511-1519 | priv/rust/tui/src/dialogs/reasoning.rs:155-163 | priv/rust/tui/src/dialogs/rewind.rs:139-147 — before extracting anything, compare `priv/rust/tui/src/dialogs/file_picker.rs` and `priv/rust/tui/src/dialogs/model_picker.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 54 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 (9 lines × 4) priv/rust/tui/src/dialogs/memory_browser.rs:42 — priv/rust/tui/src/dialogs/memory_browser.rs:42-50 | priv/rust/tui/src/dialogs/permissions_manager.rs:67-75 | priv/rust/tui/src/dialogs/skills_browser.rs:74-82 | priv/rust/tui/src/dialogs/tools_browser.rs:68-76 — before extracting anything, compare `priv/rust/tui/src/dialogs/memory_browser.rs` and `priv/rust/tui/src/dialogs/permissions_manager.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 223 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 (7–9 lines × 2) · ×2
  • Duplicated block (7–9 lines × 2) priv/rust/tui/src/components/input/mod.rs:1296 — priv/rust/tui/src/components/input/mod.rs:1296-1302 | priv/rust/tui/src/util/fuzzy.rs:112-120 — 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 `priv/rust/tui/src/components/input/mod.rs:1296` 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) priv/rust/tui/src/dialogs/permissions.rs:212 — priv/rust/tui/src/dialogs/permissions.rs:212-218 | priv/rust/tui/src/tools/file.rs:641-649 — 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 `priv/rust/tui/src/dialogs/permissions.rs:212` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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 (6–8 lines × 3) · ×2
  • Duplicated block (6–8 lines × 3) priv/rust/tui/src/components/chat/message.rs:1088 — priv/rust/tui/src/components/chat/message.rs:1088-1093 | priv/rust/tui/src/components/chat/message.rs:1099-1104 | priv/rust/tui/src/components/chat/message.rs:1110-1117 — 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.
  • Duplicated block (6–8 lines × 3) priv/rust/tui/src/render/markdown.rs:224 — priv/rust/tui/src/render/markdown.rs:224-231 | priv/rust/tui/src/render/markdown.rs:233-240 | priv/rust/tui/src/render/markdown.rs:241-246 — 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 `priv/rust/tui/src/render/markdown.rs:224` 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. 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.
D1 · Cyclomatic Complexity · KeyMap.Map (cyclomatic 64) · ×1
  • KeyMap.Map (cyclomatic 64) native/windows/ScreenShare/DesktopInput.cs:111 — KeyMap.Map has cyclomatic complexity 64 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · StatusBar · ×1
  • StatusBar::draw (cyclomatic 64) priv/rust/tui/src/components/status_bar.rs:1295 — StatusBar::draw has cyclomatic complexity 64 (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 · Orchestrator.run_fresh_subagent (cyclomatic 40) · ×1
  • Orchestrator.run_fresh_subagent (cyclomatic 40) lib/optimal_system_agent/orchestrator.ex:289 — Orchestrator.run_fresh_subagent has cyclomatic complexity 40 (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 · Handler.build_config (cyclomatic 38) · ×1
  • Handler.build_config (cyclomatic 38) lib/optimal_system_agent/tools/builtins/delegate/handler.ex:175 — Handler.build_config has cyclomatic complexity 38 (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 · Onboarding.build_health_check_request (cyclomatic 34) · ×1
  • Onboarding.build_health_check_request (cyclomatic 34) lib/optimal_system_agent/onboarding.ex:2877 — Onboarding.build_health_check_request has cyclomatic complexity 34 (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 · ReactLoop.handle_result (cyclomatic 32) · ×1
  • ReactLoop.handle_result (cyclomatic 32) lib/optimal_system_agent/agent/loop/react_loop.ex:1767 — ReactLoop.handle_result has cyclomatic complexity 32 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · Onboarding.apply_env_vars (cyclomatic 27) · ×1
  • Onboarding.apply_env_vars (cyclomatic 27) lib/optimal_system_agent/onboarding.ex:2603 — Onboarding.apply_env_vars 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 · LLMClient.llm_chat_stream (cyclomatic 25) · ×1
  • LLMClient.llm_chat_stream (cyclomatic 25) lib/optimal_system_agent/agent/loop/llm_client.ex:785 — LLMClient.llm_chat_stream 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 · ReactLoop.do_iteration (cyclomatic 25) · ×1
  • ReactLoop.do_iteration (cyclomatic 25) lib/optimal_system_agent/agent/loop/react_loop.ex:545 — ReactLoop.do_iteration 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 · Lifetime.start (cyclomatic 24) · ×1
  • Lifetime.start (cyclomatic 24) native/macos/ScreenShare/Sources/ScreenShare/Lifetime.swift:26 — Lifetime.start 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 · Commands.models_info (cyclomatic 23) · ×1
  • Commands.models_info (cyclomatic 23) lib/optimal_system_agent/channels/cli/commands.ex:1239 — Commands.models_info 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 · Anthropic.format_messages (cyclomatic 23) · ×1
  • Anthropic.format_messages (cyclomatic 23) lib/optimal_system_agent/providers/anthropic.ex:1039 — Anthropic.format_messages 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 · VMHelper.main (cyclomatic 22) · ×1
  • VMHelper.main (cyclomatic 22) native/macos/OpenComputersVM/Sources/Main.swift:5 — VMHelper.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 · Completions · ×1
  • Completions::draw_in (cyclomatic 22) priv/rust/tui/src/components/input/completions.rs:161 — Completions::draw_in 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 · Loop.init (cyclomatic 21) · ×1
  • Loop.init (cyclomatic 21) lib/optimal_system_agent/agent/loop.ex:1283 — Loop.init 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 · Commands.cmd_goal (cyclomatic 21) · ×1
  • Commands.cmd_goal (cyclomatic 21) lib/optimal_system_agent/channels/cli/commands.ex:3014 — Commands.cmd_goal has cyclomatic complexity 21 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · Ollama.cloud_stream_loop (cyclomatic 21) · ×1
  • Ollama.cloud_stream_loop (cyclomatic 21) lib/optimal_system_agent/providers/ollama.ex:473 — Ollama.cloud_stream_loop has cyclomatic complexity 21 (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 · MacOS.perform_element (cyclomatic 21) · ×1
  • MacOS.perform_element (cyclomatic 21) lib/optimal_system_agent/tools/builtins/computer_use/adapters/macos.ex:220 — MacOS.perform_element has cyclomatic complexity 21 (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.swift.pointer (cyclomatic 21) · ×1
  • main.swift.pointer (cyclomatic 21) native/macos/AccessibilityHelper/main.swift:292 — main.swift.pointer 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 · DesktopInput.pointer (cyclomatic 21) · ×1
  • DesktopInput.pointer (cyclomatic 21) native/macos/ScreenShare/Sources/ScreenShare/DesktopInput.swift:49 — DesktopInput.pointer 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 · WebSearchRenderer · ×1
  • WebSearchRenderer::render (cyclomatic 21) priv/rust/tui/src/tools/web.rs:358 — WebSearchRenderer::render 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 · Onboarding.model_list (cyclomatic 20) · ×1
  • Onboarding.model_list (cyclomatic 20) lib/optimal_system_agent/onboarding.ex:1023 — Onboarding.model_list has cyclomatic complexity 20 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · Config.parse (cyclomatic 20) · ×1
  • Config.parse (cyclomatic 20) native/macos/ScreenShare/Sources/ScreenShare/Config.swift:14 — Config.parse 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 · Cli · ×1
  • Cli::parse_from (cyclomatic 20) priv/rust/tui/src/config/cli.rs:108 — Cli::parse_from has cyclomatic complexity 20 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · SandboxPicker · ×1
  • SandboxPicker::draw (cyclomatic 20) priv/rust/tui/src/dialogs/sandbox_picker.rs:116 — SandboxPicker::draw 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 · SkillsBrowser · ×1
  • SkillsBrowser::draw (cyclomatic 20) priv/rust/tui/src/dialogs/skills_browser.rs:251 — SkillsBrowser::draw 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 · DesktopInput.Pointer (cyclomatic 19) · ×1
  • DesktopInput.Pointer (cyclomatic 19) native/windows/ScreenShare/DesktopInput.cs:62 — DesktopInput.Pointer 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 · Orchestrator.do_run_background (cyclomatic 19) · ×1
  • Orchestrator.do_run_background (cyclomatic 19) lib/optimal_system_agent/orchestrator.ex:1296 — Orchestrator.do_run_background has cyclomatic complexity 19 (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 · Commands.cmd_resume (cyclomatic 18) · ×1
  • Commands.cmd_resume (cyclomatic 18) lib/optimal_system_agent/channels/cli/commands.ex:4253 — Commands.cmd_resume 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 · LocalModels.overview (cyclomatic 18) · ×1
  • LocalModels.overview (cyclomatic 18) lib/optimal_system_agent/local_models.ex:60 — LocalModels.overview has cyclomatic complexity 18 (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 · Observability.current_reasoning (cyclomatic 18) · ×1
  • Observability.current_reasoning (cyclomatic 18) lib/optimal_system_agent/observability.ex:304 — Observability.current_reasoning has cyclomatic complexity 18 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · CompletionPanel · ×1
  • CompletionPanel::build_lines (cyclomatic 18) priv/rust/tui/src/components/completion_panel.rs:140 — CompletionPanel::build_lines 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 · RfbConnection.RunAsync (cyclomatic 17) · ×1
  • RfbConnection.RunAsync (cyclomatic 17) native/windows/ScreenShare/RfbConnection.cs:10 — RfbConnection.RunAsync 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 · SessionGrant.accept (cyclomatic 17) · ×1
  • SessionGrant.accept (cyclomatic 17) lib/optimal_system_agent/open_computers/executor/direct/desktop/session_grant.ex:9 — SessionGrant.accept 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 · Ollama.process_ndjson_line (cyclomatic 17) · ×1
  • Ollama.process_ndjson_line (cyclomatic 17) lib/optimal_system_agent/providers/ollama.ex:1766 — Ollama.process_ndjson_line 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 · SseClient · ×1
  • SseClient::connect_once (cyclomatic 17) priv/rust/tui/src/client/sse.rs:241 — SseClient::connect_once 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 · Sidebar · ×1
  • Sidebar::draw (cyclomatic 17) priv/rust/tui/src/components/sidebar.rs:366 — Sidebar::draw 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 · RewindDialog · ×1
  • RewindDialog::draw (cyclomatic 17) priv/rust/tui/src/dialogs/rewind.rs:133 — RewindDialog::draw 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 · Loop.cancel (cyclomatic 16) · ×1
  • Loop.cancel (cyclomatic 16) lib/optimal_system_agent/agent/loop.ex:950 — Loop.cancel 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 · Events.register_orchestrator_handler (cyclomatic 16) · ×1
  • Events.register_orchestrator_handler (cyclomatic 16) lib/optimal_system_agent/channels/cli/events.ex:43 — Events.register_orchestrator_handler has cyclomatic complexity 16 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · SkillGenerator.do_generate_from_pattern (cyclomatic 16) · ×1
  • SkillGenerator.do_generate_from_pattern (cyclomatic 16) lib/optimal_system_agent/memory/skill_generator.ex:72 — SkillGenerator.do_generate_from_pattern 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 · Onboarding.write_setup (cyclomatic 16) · ×1
  • Onboarding.write_setup (cyclomatic 16) lib/optimal_system_agent/onboarding.ex:2057 — Onboarding.write_setup 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 · ChainSummary.render (cyclomatic 16) · ×1
  • ChainSummary.render (cyclomatic 16) lib/optimal_system_agent/security/chain_summary.ex:94 — ChainSummary.render 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 · Task.from_map (cyclomatic 16) · ×1
  • Task.from_map (cyclomatic 16) lib/optimal_system_agent/store/task.ex:74 — Task.from_map 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 · verify_package.verify (cyclomatic 16) · ×1
  • verify_package.verify (cyclomatic 16) native/linux/ScreenShare/verify_package.py:12 — verify_package.verify 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 · atspi_tree.walk (cyclomatic 16) · ×1
  • atspi_tree.walk (cyclomatic 16) priv/scripts/atspi_tree.py:36 — atspi_tree.walk 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 · OwnedStore.init (cyclomatic 16) · ×1
  • OwnedStore.init (cyclomatic 16) native/macos/OpenComputersVM/Sources/OwnedStore.swift:12 — OwnedStore.init 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 · ThemePicker · ×1
  • ThemePicker::draw (cyclomatic 16) priv/rust/tui/src/dialogs/theme_picker.rs:96 — ThemePicker::draw 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.
D12 · Dependency Hygiene · Unbounded dependency requirement · ×1
  • Unbounded dependency requirement: postgrex — Runtime dependency `:postgrex` is declared `">= 0.0.0"` in canopy/backend/mix.exs, which has no upper bound — every future MAJOR release of `:postgrex` satisfies it, so the next unlocked resolve can pull a breaking change. Use `~>` (e.g. `"~> 1.0"`) to bound the requirement to a compatible range.
D2 · Cognitive Complexity · StatusBar · ×1
  • StatusBar::draw (cognitive 120) priv/rust/tui/src/components/status_bar.rs:1295 — StatusBar::draw has cognitive complexity 120 (threshold 15). Drivers by points: if/else 80 (118 pts), match/switch 1 (2 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 · Permissions · ×1
  • Permissions::draw_inline (cognitive 52) priv/rust/tui/src/dialogs/permissions.rs:376 — Permissions::draw_inline has cognitive complexity 52 (threshold 15). Drivers by points: if/else 25 (42 pts), loops 3 (7 pts), match/switch 1 (2 pts), boolean chains 1 (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 · WebSearchRenderer · ×1
  • WebSearchRenderer::render (cognitive 48) priv/rust/tui/src/tools/web.rs:358 — WebSearchRenderer::render has cognitive complexity 48 (threshold 15). Drivers by points: if/else 22 (41 pts), loops 3 (6 pts), boolean chains 1 (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 · Commands.models_info (cognitive 47) · ×1
  • Commands.models_info (cognitive 47) lib/optimal_system_agent/channels/cli/commands.ex:1239 — Commands.models_info has cognitive complexity 47 (threshold 15). Drivers by points: if/else 20 (38 pts), boolean chains 5, match/switch 2 (4 pts) (nesting depth added 20). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · Orchestrator.run_fresh_subagent (cognitive 46) · ×1
  • Orchestrator.run_fresh_subagent (cognitive 46) lib/optimal_system_agent/orchestrator.ex:289 — Orchestrator.run_fresh_subagent has cognitive complexity 46 (threshold 15). Drivers by points: if/else 14 (16 pts), boolean chains 14, match/switch 7 (10 pts), error handling 4 (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 · Onboarding.build_health_check_request (cognitive 44) · ×1
  • Onboarding.build_health_check_request (cognitive 44) lib/optimal_system_agent/onboarding.ex:2877 — Onboarding.build_health_check_request has cognitive complexity 44 (threshold 15). Drivers by points: boolean chains 19, match/switch 5 (15 pts), if/else 7 (10 pts) (nesting depth added 13). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · LLMClient.llm_chat_stream (cognitive 38) · ×1
  • LLMClient.llm_chat_stream (cognitive 38) lib/optimal_system_agent/agent/loop/llm_client.ex:785 — LLMClient.llm_chat_stream has cognitive complexity 38 (threshold 15). Drivers by points: if/else 18 (24 pts), match/switch 4 (6 pts), boolean chains 5, error handling 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 · SandboxPicker · ×1
  • SandboxPicker::draw (cognitive 38) priv/rust/tui/src/dialogs/sandbox_picker.rs:116 — SandboxPicker::draw has cognitive complexity 38 (threshold 15). Drivers by points: if/else 24 (35 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 · Handler.build_config (cognitive 37) · ×1
  • Handler.build_config (cognitive 37) lib/optimal_system_agent/tools/builtins/delegate/handler.ex:175 — Handler.build_config has cognitive complexity 37 (threshold 15). Drivers by points: boolean chains 30, if/else 5, match/switch 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 · ReactLoop.do_iteration (cognitive 36) · ×1
  • ReactLoop.do_iteration (cognitive 36) lib/optimal_system_agent/agent/loop/react_loop.ex:545 — ReactLoop.do_iteration has cognitive complexity 36 (threshold 15). Drivers by points: if/else 19 (21 pts), match/switch 6 (8 pts), boolean chains 5, error handling 1 (2 pts) (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 · Commands.cmd_resume (cognitive 36) · ×1
  • Commands.cmd_resume (cognitive 36) lib/optimal_system_agent/channels/cli/commands.ex:4253 — Commands.cmd_resume has cognitive complexity 36 (threshold 15). Drivers by points: if/else 9 (18 pts), match/switch 3 (7 pts), error handling 2 (6 pts), boolean chains 5 (nesting depth added 17). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · Sidebar · ×1
  • Sidebar::draw (cognitive 35) priv/rust/tui/src/components/sidebar.rs:366 — Sidebar::draw has cognitive complexity 35 (threshold 15). Drivers by points: if/else 13 (27 pts), loops 3 (5 pts), boolean chains 3 (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 · TasksPanel · ×1
  • TasksPanel::draw (cognitive 35) priv/rust/tui/src/dialogs/tasks_panel.rs:206 — TasksPanel::draw has cognitive complexity 35 (threshold 15). Drivers by points: if/else 12 (28 pts), match/switch 1 (3 pts), boolean chains 2, loops 1 (2 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 · PersonaPicker · ×1
  • PersonaPicker::draw (cognitive 34) priv/rust/tui/src/dialogs/persona_picker.rs:179 — PersonaPicker::draw has cognitive complexity 34 (threshold 15). Drivers by points: if/else 17 (30 pts), boolean chains 2, loops 1 (2 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 · SessionBrowser · ×1
  • SessionBrowser::draw (cognitive 34) priv/rust/tui/src/dialogs/sessions.rs:248 — SessionBrowser::draw has cognitive complexity 34 (threshold 15). Drivers by points: if/else 18 (26 pts), match/switch 5 (6 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 · VMHelper.main (cognitive 33) · ×1
  • VMHelper.main (cognitive 33) native/macos/OpenComputersVM/Sources/Main.swift:5 — VMHelper.main has cognitive complexity 33 (threshold 15). Drivers by points: if/else 6 (15 pts), boolean chains 12, error handling 2 (4 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 · Config.parse (cognitive 33) · ×1
  • Config.parse (cognitive 33) native/macos/ScreenShare/Sources/ScreenShare/Config.swift:14 — Config.parse has cognitive complexity 33 (threshold 15). Drivers by points: if/else 9 (24 pts), match/switch 2 (5 pts), boolean chains 3, loops 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 · CompletionPanel · ×1
  • CompletionPanel::build_lines (cognitive 33) priv/rust/tui/src/components/completion_panel.rs:140 — CompletionPanel::build_lines has cognitive complexity 33 (threshold 15). Drivers by points: if/else 12 (18 pts), loops 6 (14 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 · RewindDialog · ×1
  • RewindDialog::draw (cognitive 33) priv/rust/tui/src/dialogs/rewind.rs:133 — RewindDialog::draw has cognitive complexity 33 (threshold 15). Drivers by points: if/else 19 (28 pts), loops 2 (3 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 · ReactLoop.handle_result (cognitive 32) · ×1
  • ReactLoop.handle_result (cognitive 32) lib/optimal_system_agent/agent/loop/react_loop.ex:2719 — ReactLoop.handle_result has cognitive complexity 32 (threshold 15). Drivers by points: if/else 14 (25 pts), match/switch 2 (5 pts), boolean chains 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 · Completions · ×1
  • Completions::draw_in (cognitive 32) priv/rust/tui/src/components/input/completions.rs:161 — Completions::draw_in has cognitive complexity 32 (threshold 15). Drivers by points: if/else 13 (20 pts), boolean chains 7, match/switch 2 (4 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 · Onboarding.apply_env_vars (cognitive 31) · ×1
  • Onboarding.apply_env_vars (cognitive 31) lib/optimal_system_agent/onboarding.ex:2603 — Onboarding.apply_env_vars has cognitive complexity 31 (threshold 15). Drivers by points: if/else 14 (26 pts), match/switch 3, 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 · CodeFixPr.apply_and_open (cognitive 29) · ×1
  • CodeFixPr.apply_and_open (cognitive 29) lib/optimal_system_agent/security/code_fix_pr.ex:89 — CodeFixPr.apply_and_open has cognitive complexity 29 (threshold 15). Drivers by points: if/else 7 (18 pts), match/switch 3 (8 pts), boolean chains 3 (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 · McpApprovalDialog · ×1
  • McpApprovalDialog::draw (cognitive 29) priv/rust/tui/src/dialogs/mcp_approval.rs:153 — McpApprovalDialog::draw has cognitive complexity 29 (threshold 15). Drivers by points: if/else 16 (23 pts), loops 3 (5 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 · MemoryBrowser · ×1
  • MemoryBrowser::draw (cognitive 29) priv/rust/tui/src/dialogs/memory_browser.rs:153 — MemoryBrowser::draw has cognitive complexity 29 (threshold 15). Drivers by points: if/else 15 (26 pts), loops 1 (2 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 · ProactiveCompaction.compact (cognitive 28) · ×1
  • ProactiveCompaction.compact (cognitive 28) lib/optimal_system_agent/agent/loop/proactive_compaction.ex:273 — ProactiveCompaction.compact has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (16 pts), match/switch 5 (12 pts) (nesting depth added 14). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · TurnTrace.format (cognitive 27) · ×1
  • TurnTrace.format (cognitive 27) lib/optimal_system_agent/agent/turn_trace.ex:493 — TurnTrace.format has cognitive complexity 27 (threshold 15). Drivers by points: if/else 22 (25 pts), match/switch 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 · Lifetime.start (cognitive 27) · ×1
  • Lifetime.start (cognitive 27) native/macos/ScreenShare/Sources/ScreenShare/Lifetime.swift:26 — Lifetime.start has cognitive complexity 27 (threshold 15). Drivers by points: if/else 11 (15 pts), boolean chains 9, loops 3 (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 · ChannelsPanel · ×1
  • ChannelsPanel::draw (cognitive 27) priv/rust/tui/src/dialogs/channels_panel.rs:127 — ChannelsPanel::draw has cognitive complexity 27 (threshold 15). Drivers by points: if/else 11 (23 pts), boolean chains 2, 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 · ThemePicker · ×1
  • ThemePicker::draw (cognitive 27) priv/rust/tui/src/dialogs/theme_picker.rs:96 — ThemePicker::draw has cognitive complexity 27 (threshold 15). Drivers by points: if/else 14 (19 pts), loops 2 (4 pts), boolean chains 2, match/switch 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 · AgentRenderer · ×1
  • AgentRenderer::render (cognitive 27) priv/rust/tui/src/tools/agent.rs:14 — AgentRenderer::render has cognitive complexity 27 (threshold 15). Drivers by points: if/else 16 (24 pts), boolean chains 1, loops 1, match/switch 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 · Compactor.run_pipeline (cognitive 26) · ×1
  • Compactor.run_pipeline (cognitive 26) lib/optimal_system_agent/agent/compactor.ex:663 — Compactor.run_pipeline has cognitive complexity 26 (threshold 15). Drivers by points: if/else 12 (13 pts), match/switch 4 (9 pts), error handling 3 (4 pts) (nesting depth added 7). 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 · CodebaseExplore.explore (cognitive 26) · ×1
  • CodebaseExplore.explore (cognitive 26) lib/optimal_system_agent/tools/builtins/codebase_explore.ex:110 — CodebaseExplore.explore has cognitive complexity 26 (threshold 15). Drivers by points: if/else 16 (26 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 · main.swift.pointer (cognitive 26) · ×1
  • main.swift.pointer (cognitive 26) native/macos/AccessibilityHelper/main.swift:292 — main.swift.pointer has cognitive complexity 26 (threshold 15). Drivers by points: if/else 8 (12 pts), ternaries 3 (6 pts), boolean chains 5, loops 1 (2 pts), match/switch 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 · DesktopInput.Pointer (cognitive 25) · ×1
  • DesktopInput.Pointer (cognitive 25) native/windows/ScreenShare/DesktopInput.cs:62 — DesktopInput.Pointer has cognitive complexity 25 (threshold 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 · Heartbeat.run_heartbeat_tasks (cognitive 25) · ×1
  • Heartbeat.run_heartbeat_tasks (cognitive 25) lib/optimal_system_agent/agent/scheduler/heartbeat.ex:78 — Heartbeat.run_heartbeat_tasks has cognitive complexity 25 (threshold 15). Drivers by points: match/switch 3 (13 pts), if/else 7 (12 pts) (nesting depth added 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · PromptLoader.scan_command_dir (cognitive 25) · ×1
  • PromptLoader.scan_command_dir (cognitive 25) lib/optimal_system_agent/prompt_loader.ex:145 — PromptLoader.scan_command_dir has cognitive complexity 25 (threshold 15). Drivers by points: match/switch 5 (18 pts), if/else 7 (nesting depth added 13). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · Anthropic.format_messages (cognitive 25) · ×1
  • Anthropic.format_messages (cognitive 25) lib/optimal_system_agent/providers/anthropic.ex:1039 — Anthropic.format_messages has cognitive complexity 25 (threshold 15). Drivers by points: boolean chains 19, if/else 5, match/switch 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 · Playbook.advance (cognitive 25) · ×1
  • Playbook.advance (cognitive 25) lib/optimal_system_agent/security/playbook.ex:313 — Playbook.advance has cognitive complexity 25 (threshold 15). Drivers by points: if/else 5 (14 pts), match/switch 4 (11 pts) (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 · Handler.validate_edit (cognitive 25) · ×1
  • Handler.validate_edit (cognitive 25) lib/optimal_system_agent/tools/builtins/multi_file_edit/handler.ex:245 — Handler.validate_edit has cognitive complexity 25 (threshold 15). Drivers by points: if/else 5 (14 pts), match/switch 4 (10 pts), boolean chains 1 (nesting depth added 15). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · FileWriteRenderer · ×1
  • FileWriteRenderer::render (cognitive 25) priv/rust/tui/src/tools/file.rs:91 — FileWriteRenderer::render has cognitive complexity 25 (threshold 15). Drivers by points: if/else 17 (20 pts), loops 2 (5 pts) (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 · ReactLoop.handle_result (cognitive 24) · ×1
  • ReactLoop.handle_result (cognitive 24) lib/optimal_system_agent/agent/loop/react_loop.ex:1767 — ReactLoop.handle_result has cognitive complexity 24 (threshold 15). Drivers by points: if/else 12 (13 pts), boolean chains 8, match/switch 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.
D2 · Cognitive Complexity · Orchestrator.do_run_background (cognitive 24) · ×1
  • Orchestrator.do_run_background (cognitive 24) lib/optimal_system_agent/orchestrator.ex:1296 — Orchestrator.do_run_background has cognitive complexity 24 (threshold 15). Drivers by points: boolean chains 10, match/switch 3 (7 pts), if/else 5, error handling 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 · SarifReport.generate (cognitive 24) · ×1
  • SarifReport.generate (cognitive 24) lib/optimal_system_agent/security/sarif_report.ex:52 — SarifReport.generate has cognitive complexity 24 (threshold 15). Drivers by points: if/else 6 (14 pts), match/switch 4 (9 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 · LiveCommandOutput · ×1
  • LiveCommandOutput::push_truncated_str (cognitive 24) priv/rust/tui/src/components/live_output.rs:80 — LiveCommandOutput::push_truncated_str has cognitive complexity 24 (threshold 15). Drivers by points: if/else 9 (20 pts), boolean chains 3, 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 · DoctorPanel · ×1
  • DoctorPanel::draw (cognitive 24) priv/rust/tui/src/dialogs/doctor_panel.rs:183 — DoctorPanel::draw has cognitive complexity 24 (threshold 15). Drivers by points: if/else 12 (20 pts), boolean chains 2, loops 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 · Loop.init (cognitive 23) · ×1
  • Loop.init (cognitive 23) lib/optimal_system_agent/agent/loop.ex:1283 — Loop.init has cognitive complexity 23 (threshold 15). Drivers by points: boolean chains 15, if/else 5 (6 pts), match/switch 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 · Commands.print_goal_status (cognitive 23) · ×1
  • Commands.print_goal_status (cognitive 23) lib/optimal_system_agent/channels/cli/commands.ex:3261 — Commands.print_goal_status has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11 (18 pts), match/switch 3 (5 pts) (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · Onboarding.model_list (cognitive 23) · ×1
  • Onboarding.model_list (cognitive 23) lib/optimal_system_agent/onboarding.ex:1023 — Onboarding.model_list has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (10 pts), match/switch 5 (9 pts), boolean chains 4 (nesting depth added 6). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · Controller.start_session (cognitive 23) · ×1
  • Controller.start_session (cognitive 23) lib/optimal_system_agent/open_computers/executor/direct/desktop/controller.ex:318 — Controller.start_session has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (14 pts), match/switch 3 (7 pts), error handling 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 · ChainSummary.render (cognitive 23) · ×1
  • ChainSummary.render (cognitive 23) lib/optimal_system_agent/security/chain_summary.ex:94 — ChainSummary.render has cognitive complexity 23 (threshold 15). Drivers by points: if/else 14 (15 pts), boolean chains 8 (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 · DesktopInput.pointer (cognitive 23) · ×1
  • DesktopInput.pointer (cognitive 23) native/macos/ScreenShare/Sources/ScreenShare/DesktopInput.swift:49 — DesktopInput.pointer has cognitive complexity 23 (threshold 15). Drivers by points: boolean chains 8, if/else 7 (8 pts), ternaries 5 (6 pts), loops 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 · ReferencesRenderer · ×1
  • ReferencesRenderer::render (cognitive 23) priv/rust/tui/src/tools/references.rs:11 — ReferencesRenderer::render has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11 (16 pts), loops 3 (7 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 · RfbConnection.RunAsync (cognitive 22) · ×1
  • RfbConnection.RunAsync (cognitive 22) native/windows/ScreenShare/RfbConnection.cs:10 — RfbConnection.RunAsync has cognitive complexity 22 (threshold 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 · GoalTracker.request_decision (cognitive 22) · ×1
  • GoalTracker.request_decision (cognitive 22) lib/optimal_system_agent/agent/loop/goal_tracker.ex:1392 — GoalTracker.request_decision has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (12 pts), match/switch 2 (6 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 · CronEngine.parse_single (cognitive 22) · ×1
  • CronEngine.parse_single (cognitive 22) lib/optimal_system_agent/agent/scheduler/cron_engine.ex:91 — CronEngine.parse_single has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (12 pts), match/switch 4 (8 pts), boolean chains 2 (nesting depth added 10). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · Application.start (cognitive 22) · ×1
  • Application.start (cognitive 22) lib/optimal_system_agent/application.ex:26 — Application.start has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (9 pts), error handling 2 (6 pts), boolean chains 4, match/switch 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 · CLI.loop (cognitive 22) · ×1
  • CLI.loop (cognitive 22) lib/optimal_system_agent/channels/cli.ex:114 — CLI.loop has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (17 pts), match/switch 3 (5 pts) (nesting depth added 11). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · Fs.write (cognitive 22) · ×1
  • Fs.write (cognitive 22) lib/optimal_system_agent/open_computers/executor/direct/fs.ex:130 — Fs.write has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (17 pts), match/switch 2 (5 pts) (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 · OpenAICompat.do_finalize_sse_stream (cognitive 22) · ×1
  • OpenAICompat.do_finalize_sse_stream (cognitive 22) lib/optimal_system_agent/providers/openai_compat.ex:901 — OpenAICompat.do_finalize_sse_stream has cognitive complexity 22 (threshold 15). Drivers by points: if/else 13 (17 pts), match/switch 3 (4 pts), boolean chains 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 · RetryClassifier.parse_http_date (cognitive 22) · ×1
  • RetryClassifier.parse_http_date (cognitive 22) lib/optimal_system_agent/providers/retry_classifier.ex:482 — RetryClassifier.parse_http_date has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (19 pts), match/switch 2 (3 pts) (nesting depth added 10). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · osa_screen_capture_wayland · ×1
  • osa_screen_capture_wayland::rfb::serve (cognitive 22) native/linux/ScreenShare/src/rfb.rs:80 — osa_screen_capture_wayland::rfb::serve has cognitive complexity 22 (threshold 15). Drivers by points: loops 4 (11 pts), if/else 3 (7 pts), boolean chains 2, match/switch 1 (2 pts) (nesting depth added 12). 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 · Message · ×1
  • Message::height_uncached (cognitive 22) priv/rust/tui/src/components/chat/message.rs:386 — Message::height_uncached has cognitive complexity 22 (threshold 15). Drivers by points: if/else 14 (21 pts), match/switch 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 · Picker · ×1
  • Picker::draw (cognitive 22) priv/rust/tui/src/dialogs/picker.rs:144 — Picker::draw has cognitive complexity 22 (threshold 15). Drivers by points: if/else 14 (21 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 · Commands.cmd_goal (cognitive 21) · ×1
  • Commands.cmd_goal (cognitive 21) lib/optimal_system_agent/channels/cli/commands.ex:3014 — Commands.cmd_goal has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (10 pts), match/switch 3 (6 pts), boolean chains 5 (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 · Orchestrator.resume_subagent (cognitive 21) · ×1
  • Orchestrator.resume_subagent (cognitive 21) lib/optimal_system_agent/orchestrator.ex:1767 — Orchestrator.resume_subagent has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (10 pts), match/switch 4 (8 pts), boolean chains 3 (nesting depth added 7). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · CodebaseExplore.detect_patterns (cognitive 21) · ×1
  • CodebaseExplore.detect_patterns (cognitive 21) lib/optimal_system_agent/tools/builtins/codebase_explore.ex:344 — CodebaseExplore.detect_patterns has cognitive complexity 21 (threshold 15). Drivers by points: if/else 16, boolean chains 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 · Loop.cancel (cognitive 20) · ×1
  • Loop.cancel (cognitive 20) lib/optimal_system_agent/agent/loop.ex:950 — Loop.cancel has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (8 pts), boolean chains 6, error handling 4, match/switch 1 (2 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 · Commands.models_install (cognitive 20) · ×1
  • Commands.models_install (cognitive 20) lib/optimal_system_agent/channels/cli/commands.ex:1374 — Commands.models_install has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (15 pts), match/switch 3 (4 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 · Ollama.process_ndjson_line (cognitive 20) · ×1
  • Ollama.process_ndjson_line (cognitive 20) lib/optimal_system_agent/providers/ollama.ex:1766 — Ollama.process_ndjson_line has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (9 pts), boolean chains 6, match/switch 3 (5 pts) (nesting depth added 4). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · atspi_tree.walk (cognitive 20) · ×1
  • atspi_tree.walk (cognitive 20) priv/scripts/atspi_tree.py:36 — atspi_tree.walk has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 8, 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 · ConfigEditor · ×1
  • ConfigEditor::draw (cognitive 20) priv/rust/tui/src/dialogs/config_editor.rs:337 — ConfigEditor::draw has cognitive complexity 20 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 1, 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 · FilePicker · ×1
  • FilePicker::draw (cognitive 20) priv/rust/tui/src/dialogs/file_picker.rs:233 — FilePicker::draw has cognitive complexity 20 (threshold 15). Drivers by points: if/else 14 (19 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 · Handlers.read_before_write (cognitive 19) · ×1
  • Handlers.read_before_write (cognitive 19) lib/optimal_system_agent/agent/hooks/handlers.ex:382 — Handlers.read_before_write has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (10 pts), error handling 2 (5 pts), match/switch 1 (3 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 · Renderer.print_banner (cognitive 19) · ×1
  • Renderer.print_banner (cognitive 19) lib/optimal_system_agent/channels/cli/renderer.ex:22 — Renderer.print_banner has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10 (11 pts), error handling 7, boolean chains 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 · CiScan.run (cognitive 19) · ×1
  • CiScan.run (cognitive 19) lib/optimal_system_agent/security/ci_scan.ex:66 — CiScan.run has cognitive complexity 19 (threshold 15). Drivers by points: match/switch 4 (13 pts), if/else 5, boolean chains 1 (nesting depth added 9). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · FileState.read_status (cognitive 19) · ×1
  • FileState.read_status (cognitive 19) lib/optimal_system_agent/tools/file_state.ex:321 — FileState.read_status has cognitive complexity 19 (threshold 15). Drivers by points: match/switch 4 (14 pts), if/else 5 (nesting depth added 10). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · TranscriptViewer · ×1
  • TranscriptViewer::handle_mouse (cognitive 19) priv/rust/tui/src/dialogs/transcript_viewer.rs:340 — TranscriptViewer::handle_mouse has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (18 pts), match/switch 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 · Context.build (cognitive 18) · ×1
  • Context.build (cognitive 18) lib/optimal_system_agent/agent/context.ex:103 — Context.build has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7, boolean chains 6, match/switch 4 (5 pts) (nesting depth added 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 · Onboarding.write_setup (cognitive 18) · ×1
  • Onboarding.write_setup (cognitive 18) lib/optimal_system_agent/onboarding.ex:2057 — Onboarding.write_setup has cognitive complexity 18 (threshold 15). Drivers by points: boolean chains 9, if/else 3 (6 pts), error handling 1 (2 pts), match/switch 1 (nesting depth added 4). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · OpenAICompat.parse_http_date (cognitive 18) · ×1
  • OpenAICompat.parse_http_date (cognitive 18) lib/optimal_system_agent/providers/openai_compat.ex:2352 — OpenAICompat.parse_http_date has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (15 pts), match/switch 2 (3 pts) (nesting depth added 8). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · VulnDeduplication.check_dependency (cognitive 18) · ×1
  • VulnDeduplication.check_dependency (cognitive 18) lib/optimal_system_agent/security/vuln_deduplication.ex:87 — VulnDeduplication.check_dependency has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (13 pts), boolean chains 3, match/switch 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 · Registry.execute_direct_unguarded (cognitive 18) · ×1
  • Registry.execute_direct_unguarded (cognitive 18) lib/optimal_system_agent/tools/registry.ex:368 — Registry.execute_direct_unguarded has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (9 pts), match/switch 4 (8 pts), boolean chains 1 (nesting depth added 8). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident. This shape REPEATS in the file: one other method here (Registry.execute_unguarded) 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 · Registry.execute_unguarded (cognitive 18) · ×1
  • Registry.execute_unguarded (cognitive 18) lib/optimal_system_agent/tools/registry.ex:488 — Registry.execute_unguarded has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (9 pts), match/switch 4 (8 pts), boolean chains 1 (nesting depth added 8). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident. This shape REPEATS in the file: one other method here (Registry.execute_direct_unguarded) 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 · Cli · ×1
  • Cli::parse_from (cognitive 18) priv/rust/tui/src/config/cli.rs:108 — Cli::parse_from has cognitive complexity 18 (threshold 15). Drivers by points: match/switch 5 (12 pts), if/else 2 (4 pts), boolean chains 1, loops 1 (nesting depth added 9). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · Keybindings · ×1
  • Keybindings::apply_user (cognitive 18) priv/rust/tui/src/config/keybindings.rs:400 — Keybindings::apply_user has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 2 (3 pts), match/switch 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 · CommandPalette · ×1
  • CommandPalette::draw (cognitive 18) priv/rust/tui/src/dialogs/command_palette.rs:136 — CommandPalette::draw has cognitive complexity 18 (threshold 15). Drivers by points: if/else 12 (16 pts), boolean chains 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 · PermissionsManager · ×1
  • PermissionsManager::draw (cognitive 18) priv/rust/tui/src/dialogs/permissions_manager.rs:195 — PermissionsManager::draw has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (15 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 · McpRenderer · ×1
  • McpRenderer::render (cognitive 18) priv/rust/tui/src/tools/mcp.rs:11 — McpRenderer::render has cognitive complexity 18 (threshold 15). Drivers by points: if/else 14 (16 pts), 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, 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 · Config.Parse (cognitive 17) · ×1
  • Config.Parse (cognitive 17) native/windows/ScreenShare/Config.cs:5 — Config.Parse has cognitive complexity 17 (threshold 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 · Bench.bench (cognitive 17) · ×1
  • Bench.bench (cognitive 17) lib/mix/tasks/osa.bench.ex:122 — Bench.bench has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8, boolean chains 7, match/switch 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 · RunStore.rehydrate_file (cognitive 17) · ×1
  • RunStore.rehydrate_file (cognitive 17) lib/optimal_system_agent/agent/run_store.ex:1430 — RunStore.rehydrate_file has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (7 pts), match/switch 4 (6 pts), boolean chains 4 (nesting depth added 3). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · CLI.process_input (cognitive 17) · ×1
  • CLI.process_input (cognitive 17) lib/optimal_system_agent/channels/cli.ex:216 — CLI.process_input has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (12 pts), match/switch 1 (4 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 · Update.set_update_enabled (cognitive 17) · ×1
  • Update.set_update_enabled (cognitive 17) lib/optimal_system_agent/cli/update.ex:165 — Update.set_update_enabled has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (14 pts), boolean chains 2, match/switch 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 · LocalModels.overview (cognitive 17) · ×1
  • LocalModels.overview (cognitive 17) lib/optimal_system_agent/local_models.ex:60 — LocalModels.overview has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 11, match/switch 4, if/else 2. The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · Store.reweave_links (cognitive 17) · ×1
  • Store.reweave_links (cognitive 17) lib/optimal_system_agent/memory/store.ex:279 — Store.reweave_links has cognitive complexity 17 (threshold 15). Drivers by points: match/switch 3 (9 pts), if/else 4 (6 pts), boolean chains 1, error handling 1 (nesting depth added 8). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · SessionGrant.accept (cognitive 17) · ×1
  • SessionGrant.accept (cognitive 17) lib/optimal_system_agent/open_computers/executor/direct/desktop/session_grant.ex:9 — SessionGrant.accept has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 15, if/else 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 · Desktop.start_session (cognitive 17) · ×1
  • Desktop.start_session (cognitive 17) lib/optimal_system_agent/open_computers/executor/direct/desktop.ex:138 — Desktop.start_session has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (9 pts), match/switch 2 (4 pts), boolean chains 2, error handling 1 (2 pts) (nesting depth added 8). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · AutoClassifier.json_verdict (cognitive 17) · ×1
  • AutoClassifier.json_verdict (cognitive 17) lib/optimal_system_agent/permissions/auto_classifier.ex:287 — AutoClassifier.json_verdict has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (14 pts), match/switch 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 · Ollama.cloud_stream_loop (cognitive 17) · ×1
  • Ollama.cloud_stream_loop (cognitive 17) lib/optimal_system_agent/providers/ollama.ex:473 — Ollama.cloud_stream_loop has cognitive complexity 17 (threshold 15). Drivers by points: boolean chains 10, if/else 4 (6 pts), match/switch 1 (nesting depth added 2). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · OpenAICompat.do_chat (cognitive 17) · ×1
  • OpenAICompat.do_chat (cognitive 17) lib/optimal_system_agent/providers/openai_compat.ex:105 — OpenAICompat.do_chat has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (9 pts), match/switch 2 (5 pts), boolean chains 2, 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 · DefenseLab.execute (cognitive 17) · ×1
  • DefenseLab.execute (cognitive 17) lib/optimal_system_agent/security/defense_lab.ex:49 — DefenseLab.execute has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (7 pts), match/switch 3 (6 pts), error handling 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 · FuzzyMatcher.block_anchor (cognitive 17) · ×1
  • FuzzyMatcher.block_anchor (cognitive 17) lib/optimal_system_agent/tools/builtins/file_edit/fuzzy_matcher.ex:299 — FuzzyMatcher.block_anchor has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), match/switch 2 (5 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 · Handler.read_with_range_inner (cognitive 17) · ×1
  • Handler.read_with_range_inner (cognitive 17) lib/optimal_system_agent/tools/builtins/file_read/handler.ex:578 — Handler.read_with_range_inner has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10, boolean chains 5, match/switch 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 · FileRead.read_with_range (cognitive 17) · ×1
  • FileRead.read_with_range (cognitive 17) lib/optimal_system_agent/tools/builtins/file_read.ex:84 — FileRead.read_with_range has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 3 (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 · FileState.held_lines (cognitive 17) · ×1
  • FileState.held_lines (cognitive 17) lib/optimal_system_agent/tools/file_state.ex:263 — FileState.held_lines has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (12 pts), match/switch 2 (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 · ThinkingBox · ×1
  • ThinkingBox::draw (cognitive 17) priv/rust/tui/src/components/chat/thinking_box.rs:234 — ThinkingBox::draw has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (11 pts), boolean chains 3, loops 2 (3 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 · DiagnosticsRenderer · ×1
  • DiagnosticsRenderer::render (cognitive 17) priv/rust/tui/src/tools/diagnostics.rs:9 — DiagnosticsRenderer::render has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10, loops 2 (4 pts), match/switch 1 (3 pts) (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 · ToolExecutor.maybe_ask (cognitive 16) · ×1
  • ToolExecutor.maybe_ask (cognitive 16) lib/optimal_system_agent/agent/loop/tool_executor.ex:727 — ToolExecutor.maybe_ask has cognitive complexity 16 (threshold 15). Drivers by points: match/switch 3 (9 pts), if/else 5, boolean chains 2 (nesting depth added 6). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · Commands.cmd_permissions (cognitive 16) · ×1
  • Commands.cmd_permissions (cognitive 16) lib/optimal_system_agent/channels/cli/commands.ex:4481 — Commands.cmd_permissions has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (13 pts), match/switch 2 (3 pts) (nesting depth added 6). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · Commands.mcp_add (cognitive 16) · ×1
  • Commands.mcp_add (cognitive 16) lib/optimal_system_agent/channels/cli/commands.ex:4966 — Commands.mcp_add has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (8 pts), match/switch 3 (5 pts), boolean chains 3 (nesting depth added 5). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · Commands.cmd_map (cognitive 16) · ×1
  • Commands.cmd_map (cognitive 16) lib/optimal_system_agent/channels/cli/commands.ex:5298 — Commands.cmd_map has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7, match/switch 3 (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 · DataRoutes.handle_list_models (cognitive 16) · ×1
  • DataRoutes.handle_list_models (cognitive 16) lib/optimal_system_agent/channels/http/api/data_routes.ex:321 — DataRoutes.handle_list_models has cognitive complexity 16 (threshold 15). Drivers by points: error handling 4 (8 pts), match/switch 2 (4 pts), boolean chains 2, if/else 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 · SkillGenerator.do_generate_from_pattern (cognitive 16) · ×1
  • SkillGenerator.do_generate_from_pattern (cognitive 16) lib/optimal_system_agent/memory/skill_generator.ex:72 — SkillGenerator.do_generate_from_pattern has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 12, if/else 3, match/switch 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 · Observability.current_reasoning (cognitive 16) · ×1
  • Observability.current_reasoning (cognitive 16) lib/optimal_system_agent/observability.ex:304 — Observability.current_reasoning has cognitive complexity 16 (threshold 15). Drivers by points: match/switch 6 (12 pts), if/else 3 (4 pts) (nesting depth added 7). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · Pty.open_unix_pty (cognitive 16) · ×1
  • Pty.open_unix_pty (cognitive 16) lib/optimal_system_agent/open_computers/executor/direct/pty.ex:248 — Pty.open_unix_pty has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (7 pts), error handling 2 (4 pts), match/switch 2 (4 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 · OpenAICompat.process_delta (cognitive 16) · ×1
  • OpenAICompat.process_delta (cognitive 16) lib/optimal_system_agent/providers/openai_compat.ex:754 — OpenAICompat.process_delta has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (12 pts), match/switch 3, boolean chains 1 (nesting depth added 5). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · MacOS.perform_element (cognitive 16) · ×1
  • MacOS.perform_element (cognitive 16) lib/optimal_system_agent/tools/builtins/computer_use/adapters/macos.ex:220 — MacOS.perform_element has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 10, if/else 4, match/switch 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 · Handler.scan (cognitive 16) · ×1
  • Handler.scan (cognitive 16) lib/optimal_system_agent/tools/builtins/file_grep/handler.ex:514 — Handler.scan has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (10 pts), match/switch 3 (5 pts), boolean chains 1 (nesting depth added 6). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · verify_package.verify (cognitive 16) · ×1
  • verify_package.verify (cognitive 16) native/linux/ScreenShare/verify_package.py:12 — verify_package.verify has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (11 pts), boolean chains 4, 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 · OwnedStore.init (cognitive 16) · ×1
  • OwnedStore.init (cognitive 16) native/macos/OpenComputersVM/Sources/OwnedStore.swift:12 — OwnedStore.init has cognitive complexity 16 (threshold 15). Drivers by points: boolean chains 9, if/else 5 (6 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 · VirtualMachines.handle (cognitive 16) · ×1
  • VirtualMachines.handle (cognitive 16) native/macos/OpenComputersVM/Sources/VirtualMachines.swift:26 — VirtualMachines.handle has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (13 pts), match/switch 1 (2 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 · Chat · ×1
  • Chat::draw_live (cognitive 16) priv/rust/tui/src/components/chat/mod.rs:902 — Chat::draw_live 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 · KeybindingsViewer · ×1
  • KeybindingsViewer::draw (cognitive 16) priv/rust/tui/src/dialogs/keybindings_viewer.rs:99 — KeybindingsViewer::draw has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (9 pts), loops 2 (3 pts), boolean chains 2, match/switch 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 · ReasoningSelector · ×1
  • ReasoningSelector::draw (cognitive 16) priv/rust/tui/src/dialogs/reasoning.rs:149 — ReasoningSelector::draw has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (15 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.
D32 · Data Compliance (PII/GDPR) · 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 pair (60 shared lines) · ×1
  • Near-duplicate member pair (60 shared lines) priv/rust/tui/src/app/event_loop.rs:2946 — priv/rust/tui/src/app/event_loop.rs:2946-3081 | priv/rust/tui/src/app/event_loop.rs:3130-3210 — These two members are variants of one another: 60 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 (33 shared lines) · ×1
  • Near-duplicate member pair (33 shared lines) lib/optimal_system_agent/tools/builtins/computer_use/tool.ex:47 — lib/optimal_system_agent/tools/builtins/computer_use/tool.ex:47-148 | lib/optimal_system_agent/tools/builtins/security_intel.ex:84-239 — These two members are variants of one another: 33 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 (25 shared lines) · ×1
  • Near-duplicate member pair (25 shared lines) priv/rust/tui/src/voice/transcribe.rs:547 — priv/rust/tui/src/voice/transcribe.rs:547-589 | priv/rust/tui/src/voice/transcribe.rs:611-653 — These two members are variants of one another: 25 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 · Members sharing a duplicated core (19 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (19 members, 50+ identical tokens) priv/rust/tui/src/dialogs/channels_panel.rs:127 — priv/rust/tui/src/dialogs/channels_panel.rs:127-297 | priv/rust/tui/src/dialogs/context_breakdown.rs:128-322 | priv/rust/tui/src/dialogs/cost_dashboard.rs:227-308 | priv/rust/tui/src/dialogs/doctor_panel.rs:183-384 | priv/rust/tui/src/dialogs/hooks_viewer.rs:154-268 | priv/rust/tui/src/dialogs/keybindings_viewer.rs:99-261 | priv/rust/tui/src/dialogs/mcp_approval.rs:153-284 | priv/rust/tui/src/dialogs/mcp_servers.rs:116-254 | priv/rust/tui/src/dialogs/memory_browser.rs:153-331 | priv/rust/tui/src/dialogs/metrics_dashboard.rs:168-333 | priv/rust/tui/src/dialogs/permissions_manager.rs:195-407 | priv/rust/tui/src/dialogs/persona_picker.rs:179-384 | priv/rust/tui/src/dialogs/sandbox_picker.rs:116-318 | priv/rust/tui/src/dialogs/skills_browser.rs:251-483 | priv/rust/tui/src/dialogs/status_dashboard.rs:92-278 | priv/rust/tui/src/dialogs/tasks_panel.rs:206-391 | priv/rust/tui/src/dialogs/theme_picker.rs:96-264 | priv/rust/tui/src/dialogs/tools_browser.rs:227-429 | priv/rust/tui/src/dialogs/trust.rs:69-194 — These 19 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 19 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 19 times.
D4 · Code Duplication · Members sharing a duplicated core (18 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (18 members, 50+ identical tokens) priv/rust/tui/src/components/completion_panel.rs:291 — priv/rust/tui/src/components/completion_panel.rs:291-379 | priv/rust/tui/src/dialogs/channels_panel.rs:127-297 | priv/rust/tui/src/dialogs/context_breakdown.rs:128-322 | priv/rust/tui/src/dialogs/cost_dashboard.rs:227-308 | priv/rust/tui/src/dialogs/doctor_panel.rs:183-384 | priv/rust/tui/src/dialogs/hooks_viewer.rs:154-268 | priv/rust/tui/src/dialogs/keybindings_viewer.rs:99-261 | priv/rust/tui/src/dialogs/mcp_servers.rs:116-254 | priv/rust/tui/src/dialogs/memory_browser.rs:153-331 | priv/rust/tui/src/dialogs/metrics_dashboard.rs:168-333 | priv/rust/tui/src/dialogs/permissions_manager.rs:195-407 | priv/rust/tui/src/dialogs/persona_picker.rs:179-384 | priv/rust/tui/src/dialogs/sandbox_picker.rs:116-318 | priv/rust/tui/src/dialogs/skills_browser.rs:251-483 | priv/rust/tui/src/dialogs/status_dashboard.rs:92-278 | priv/rust/tui/src/dialogs/tasks_panel.rs:206-391 | priv/rust/tui/src/dialogs/theme_picker.rs:96-264 | priv/rust/tui/src/dialogs/tools_browser.rs:227-429 — These 18 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 18 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 18 times.
D4 · Code Duplication · Members sharing a duplicated core (14 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (14 members, 50+ identical tokens) priv/rust/tui/src/dialogs/channels_panel.rs:127 — priv/rust/tui/src/dialogs/channels_panel.rs:127-297 | priv/rust/tui/src/dialogs/cost_dashboard.rs:227-308 | priv/rust/tui/src/dialogs/doctor_panel.rs:183-384 | priv/rust/tui/src/dialogs/hooks_viewer.rs:154-268 | priv/rust/tui/src/dialogs/mcp_servers.rs:116-254 | priv/rust/tui/src/dialogs/memory_browser.rs:153-331 | priv/rust/tui/src/dialogs/metrics_dashboard.rs:168-333 | priv/rust/tui/src/dialogs/onboarding.rs:1038-1120 | priv/rust/tui/src/dialogs/permissions_manager.rs:195-407 | priv/rust/tui/src/dialogs/persona_picker.rs:179-384 | priv/rust/tui/src/dialogs/reasoning.rs:149-251 | priv/rust/tui/src/dialogs/skills_browser.rs:251-483 | priv/rust/tui/src/dialogs/tasks_panel.rs:206-391 | priv/rust/tui/src/dialogs/tools_browser.rs:227-429 — These 14 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 14 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 14 times.
D4 · Code Duplication · Members sharing a duplicated core (12 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (12 members, 50+ identical tokens) priv/rust/tui/src/dialogs/config_editor.rs:337 — priv/rust/tui/src/dialogs/config_editor.rs:337-470 | priv/rust/tui/src/dialogs/file_picker.rs:233-388 | priv/rust/tui/src/dialogs/mcp_approval.rs:153-284 | priv/rust/tui/src/dialogs/model_picker.rs:1487-1552 | priv/rust/tui/src/dialogs/onboarding.rs:1038-1120 | priv/rust/tui/src/dialogs/overdrive_confirm.rs:53-126 | priv/rust/tui/src/dialogs/plan_review.rs:115-193 | priv/rust/tui/src/dialogs/quit_confirm.rs:85-159 | priv/rust/tui/src/dialogs/reasoning.rs:149-251 | priv/rust/tui/src/dialogs/rewind.rs:133-287 | priv/rust/tui/src/dialogs/sessions.rs:248-451 | priv/rust/tui/src/dialogs/trust.rs:69-194 — 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 · Members sharing a duplicated core (10 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (10 members, 50+ identical tokens) priv/rust/tui/src/dialogs/channels_panel.rs:86 — priv/rust/tui/src/dialogs/channels_panel.rs:86-125 | priv/rust/tui/src/dialogs/doctor_panel.rs:128-181 | priv/rust/tui/src/dialogs/hooks_viewer.rs:113-152 | priv/rust/tui/src/dialogs/memory_browser.rs:77-140 | priv/rust/tui/src/dialogs/metrics_dashboard.rs:127-166 | priv/rust/tui/src/dialogs/permissions_manager.rs:129-193 | priv/rust/tui/src/dialogs/persona_picker.rs:107-177 | priv/rust/tui/src/dialogs/skills_browser.rs:170-235 | priv/rust/tui/src/dialogs/tasks_panel.rs:144-183 | priv/rust/tui/src/dialogs/tools_browser.rs:160-225 — 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 · Members sharing a duplicated core (8 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (8 members, 50+ identical tokens) priv/rust/tui/src/dialogs/config_editor.rs:337 — priv/rust/tui/src/dialogs/config_editor.rs:337-470 | priv/rust/tui/src/dialogs/file_picker.rs:233-388 | priv/rust/tui/src/dialogs/model_picker.rs:1605-1810 | priv/rust/tui/src/dialogs/model_picker.rs:1952-1987 | priv/rust/tui/src/dialogs/model_picker.rs:1989-2119 | priv/rust/tui/src/dialogs/reasoning.rs:149-251 | priv/rust/tui/src/dialogs/rewind.rs:133-287 | priv/rust/tui/src/dialogs/sessions.rs:248-451 — These 8 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 8 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 8 times.
D4 · Code Duplication · Members sharing a duplicated core (7 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (7 members, 50+ identical tokens) canopy/backend/lib/canopy_web/controllers/agent_controller.ex:82 — canopy/backend/lib/canopy_web/controllers/agent_controller.ex:82-98 | canopy/backend/lib/canopy_web/controllers/goal_controller.ex:61-77 | canopy/backend/lib/canopy_web/controllers/project_controller.ex:53-69 | canopy/backend/lib/canopy_web/controllers/schedule_controller.ex:63-79 | canopy/backend/lib/canopy_web/controllers/user_controller.ex:40-56 | canopy/backend/lib/canopy_web/controllers/webhook_controller.ex:45-61 | canopy/backend/lib/canopy_web/controllers/workspace_controller.ex:71-87 — These 7 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 7 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 7 times.
D4 · Code Duplication · Members sharing a duplicated core (6 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (6 members, 50+ identical tokens) priv/rust/tui/src/dialogs/command_palette.rs:136 — priv/rust/tui/src/dialogs/command_palette.rs:136-304 | priv/rust/tui/src/dialogs/file_picker.rs:233-388 | priv/rust/tui/src/dialogs/model_picker.rs:1487-1552 | priv/rust/tui/src/dialogs/picker.rs:144-302 | priv/rust/tui/src/dialogs/reasoning.rs:149-251 | priv/rust/tui/src/dialogs/rewind.rs:133-287 — 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.
D4 · Code Duplication · Edited copy of a member (48 corresponding lines) · ×1
  • Edited copy of a member (48 corresponding lines) priv/rust/tui/src/tools/search.rs:46 — priv/rust/tui/src/tools/search.rs:46-93 | priv/rust/tui/src/tools/search.rs:107-156 — These two members are one piece of code written twice and then edited apart: 48 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 (54 corresponding lines) · ×1
  • Edited copy of a member (54 corresponding lines) priv/rust/tui/src/voice/transcribe.rs:157 — priv/rust/tui/src/voice/transcribe.rs:157-219 | priv/rust/tui/src/voice/transcribe.rs:288-341 — These two members are one piece of code written twice and then edited apart: 54 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 copies of one member (4 members, 40+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 40+ corresponding lines) priv/rust/tui/src/style/themes.rs:18 — priv/rust/tui/src/style/themes.rs:18-58 | priv/rust/tui/src/style/themes.rs:60-99 | priv/rust/tui/src/style/themes.rs:101-140 | priv/rust/tui/src/style/themes.rs:142-181 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 40 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 26+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 26+ corresponding lines) lib/optimal_system_agent/tools/builtins/code_symbols/handler.ex:254 — lib/optimal_system_agent/tools/builtins/code_symbols/handler.ex:254-282 | lib/optimal_system_agent/tools/builtins/code_symbols/handler.ex:311-340 | lib/optimal_system_agent/tools/builtins/code_symbols/handler.ex:344-369 | lib/optimal_system_agent/tools/builtins/code_symbols/handler.ex:373-402 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 26 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copy of a member (53 corresponding lines) · ×1
  • Edited copy of a member (53 corresponding lines) priv/rust/tui/src/dialogs/command_palette.rs:81 — priv/rust/tui/src/dialogs/command_palette.rs:81-133 | priv/rust/tui/src/dialogs/picker.rs:85-141 — These two members are one piece of code written twice and then edited apart: 53 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 (35 corresponding lines) · ×1
  • Edited copy of a member (35 corresponding lines) lib/optimal_system_agent/agent/task_queue.ex:400 — lib/optimal_system_agent/agent/task_queue.ex:400-463 | lib/optimal_system_agent/agent/tasks/queue.ex:69-103 — These two members are one piece of code written twice and then edited apart: 35 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 (65 corresponding lines) · ×1
  • Edited copy of a member (65 corresponding lines) lib/optimal_system_agent/tools/builtins/file_transform/tool.ex:41 — lib/optimal_system_agent/tools/builtins/file_transform/tool.ex:41-105 | lib/optimal_system_agent/tools/builtins/fleet/tool.ex:61-135 — These two members are one piece of code written twice and then edited apart: 65 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 copies of one member (3 members, 45+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 45+ corresponding lines) lib/optimal_system_agent/agent/compactor.ex:1792 — lib/optimal_system_agent/agent/compactor.ex:1792-1836 | lib/optimal_system_agent/agent/compactor.ex:1883-1952 | lib/optimal_system_agent/agent/compactor.ex:2187-2235 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 45 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copy of a member (34 corresponding lines) · ×1
  • Edited copy of a member (34 corresponding lines) lib/optimal_system_agent/healing/orchestrator.ex:309 — lib/optimal_system_agent/healing/orchestrator.ex:309-342 | lib/optimal_system_agent/healing/orchestrator.ex:346-387 — These two members are one piece of code written twice and then edited apart: 34 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 (44 corresponding lines) · ×1
  • Edited copy of a member (44 corresponding lines) canopy/backend/lib/canopy/budget_enforcer.ex:154 — canopy/backend/lib/canopy/budget_enforcer.ex:154-200 | canopy/backend/lib/canopy/budget_enforcer.ex:204-247 — These two members are one piece of code written twice and then edited apart: 44 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 (51 corresponding lines) · ×1
  • Edited copy of a member (51 corresponding lines) lib/optimal_system_agent/agent/task_queue.ex:245 — lib/optimal_system_agent/agent/task_queue.ex:245-304 | lib/optimal_system_agent/agent/tasks/queue.ex:143-193 — These two members are one piece of code written twice and then edited apart: 51 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 copies of one member (3 members, 41+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 41+ corresponding lines) lib/optimal_system_agent/auth/providers/copilot.ex:409 — lib/optimal_system_agent/auth/providers/copilot.ex:409-467 | REDACTED:386-431 | lib/optimal_system_agent/auth/providers/xai.ex:313-353 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 41 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copy of a member (43 corresponding lines) · ×1
  • Edited copy of a member (43 corresponding lines) lib/optimal_system_agent/tools/builtins/shell_execute/handler.ex:668 — lib/optimal_system_agent/tools/builtins/shell_execute/handler.ex:668-713 | lib/optimal_system_agent/tools/builtins/shell_execute/handler.ex:730-772 — These two members are one piece of code written twice and then edited apart: 43 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 (39 corresponding lines) · ×1
  • Edited copy of a member (39 corresponding lines) lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex:152 — lib/optimal_system_agent/open_computers/executor/direct/cluster/exo.ex:152-191 | lib/optimal_system_agent/open_computers/executor/direct/cluster/mlx_distributed.ex:181-219 — These two members are one piece of code written twice and then edited apart: 39 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 copies of one member (3 members, 17+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 17+ corresponding lines) lib/optimal_system_agent/providers/tool_call_parsers.ex:111 — lib/optimal_system_agent/providers/tool_call_parsers.ex:111-127 | lib/optimal_system_agent/providers/tool_call_parsers.ex:183-207 | lib/optimal_system_agent/providers/tool_call_parsers.ex:214-232 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 17 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copy of a member (36 corresponding lines) · ×1
  • Edited copy of a member (36 corresponding lines) lib/optimal_system_agent/agent/loop/tool_executor.ex:1241 — lib/optimal_system_agent/agent/loop/tool_executor.ex:1241-1280 | lib/optimal_system_agent/permissions/ask_flow.ex:149-184 — These two members are one piece of code written twice and then edited apart: 36 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 copies of one member (3 members, 16+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 16+ corresponding lines) lib/optimal_system_agent/tools/builtins/file_edit/fuzzy_matcher.ex:460 — lib/optimal_system_agent/tools/builtins/file_edit/fuzzy_matcher.ex:460-475 | lib/optimal_system_agent/tools/builtins/file_edit/fuzzy_matcher.ex:505-525 | lib/optimal_system_agent/tools/builtins/file_edit/fuzzy_matcher.ex:548-574 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 16 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 27+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 27+ corresponding lines) lib/optimal_system_agent/peer/negotiation.ex:180 — lib/optimal_system_agent/peer/negotiation.ex:180-219 | lib/optimal_system_agent/peer/negotiation.ex:233-265 | lib/optimal_system_agent/peer/negotiation.ex:276-302 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 27 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (7 members, 16+ corresponding lines) · ×1
  • Edited copies of one member (7 members, 16+ corresponding lines) canopy/backend/lib/canopy_web/controllers/agent_controller.ex:19 — canopy/backend/lib/canopy_web/controllers/agent_controller.ex:19-34 | canopy/backend/lib/canopy_web/controllers/alert_controller.ex:28-43 | canopy/backend/lib/canopy_web/controllers/gateway_controller.ex:14-29 | canopy/backend/lib/canopy_web/controllers/issue_controller.ex:49-64 | canopy/backend/lib/canopy_web/controllers/memory_controller.ex:37-52 | canopy/backend/lib/canopy_web/controllers/skill_controller.ex:91-106 | canopy/backend/lib/canopy_web/controllers/webhook_controller.ex:26-41 — These 7 members are one piece of code written 7 times and then edited apart: every two of them correspond over at least 16 lines, 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 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. Left alone, the next edit has to be made 7 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (6 members, 12+ corresponding lines) · ×1
  • Edited copies of one member (6 members, 12+ corresponding lines) priv/rust/tui/src/app/handle_dialogs.rs:567 — priv/rust/tui/src/app/handle_dialogs.rs:567-578 | priv/rust/tui/src/app/handle_dialogs.rs:611-623 | priv/rust/tui/src/app/handle_dialogs.rs:628-639 | priv/rust/tui/src/app/handle_dialogs.rs:654-665 | priv/rust/tui/src/app/handle_dialogs.rs:723-734 | priv/rust/tui/src/app/handle_dialogs.rs:755-768 — These 6 members are one piece of code written 6 times and then edited apart: every two of them correspond over at least 12 lines, 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 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. Left alone, the next edit has to be made 6 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 28+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 28+ corresponding lines) lib/optimal_system_agent/security/js_secrets.ex:315 — lib/optimal_system_agent/security/js_secrets.ex:315-343 | lib/optimal_system_agent/security/symbol_resolver.ex:267-296 | lib/optimal_system_agent/security/variant_analysis.ex:120-147 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 28 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 18+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 18+ corresponding lines) lib/optimal_system_agent/providers/batch.ex:138 — lib/optimal_system_agent/providers/batch.ex:138-160 | lib/optimal_system_agent/providers/batch.ex:164-185 | lib/optimal_system_agent/providers/batch.ex:189-206 | lib/optimal_system_agent/providers/batch.ex:210-227 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 18 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 26+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 26+ corresponding lines) lib/optimal_system_agent/tools/builtins/computer_use/adapters/docker.ex:255 — lib/optimal_system_agent/tools/builtins/computer_use/adapters/docker.ex:255-280 | lib/optimal_system_agent/tools/builtins/computer_use/adapters/remote_ssh.ex:255-281 | lib/optimal_system_agent/tools/builtins/computer_use/adapters/remote_ssh.ex:290-315 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 26 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copy of a member (45 corresponding lines) · ×1
  • Edited copy of a member (45 corresponding lines) lib/optimal_system_agent/skills/validator.ex:360 — lib/optimal_system_agent/skills/validator.ex:360-405 | lib/optimal_system_agent/skills/validator.ex:409-453 — These two members are one piece of code written twice and then edited apart: 45 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 copies of one member (3 members, 25+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 25+ corresponding lines) lib/optimal_system_agent/agent/tasks/tracker.ex:124 — lib/optimal_system_agent/agent/tasks/tracker.ex:124-150 | lib/optimal_system_agent/agent/tasks/tracker.ex:198-222 | lib/optimal_system_agent/agent/tasks/tracker.ex:289-316 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 25 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 25+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 25+ corresponding lines) lib/optimal_system_agent/speculative/tools/start_speculative/tool.ex:37 — lib/optimal_system_agent/speculative/tools/start_speculative/tool.ex:37-62 | lib/optimal_system_agent/tools/builtins/exit_worktree/tool.ex:33-61 | lib/optimal_system_agent/tools/builtins/expand_output.ex:55-79 | lib/optimal_system_agent/tools/builtins/file_edit/tool.ex:44-72 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 25 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 9+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 9+ corresponding lines) lib/optimal_system_agent/context_mesh/keeper.ex:259 — lib/optimal_system_agent/context_mesh/keeper.ex:259-283 | lib/optimal_system_agent/context_mesh/keeper.ex:329-348 | lib/optimal_system_agent/memory/dream.ex:508-516 | lib/optimal_system_agent/memory/session_titler.ex:454-464 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 9 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 7+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 7+ corresponding lines) canopy/backend/lib/canopy_web/controllers/agent_controller.ex:9 — canopy/backend/lib/canopy_web/controllers/agent_controller.ex:9-15 | canopy/backend/lib/canopy_web/controllers/template_controller.ex:9-15 | canopy/backend/lib/canopy_web/controllers/user_controller.ex:9-15 | canopy/backend/lib/canopy_web/controllers/webhook_controller.ex:9-15 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 7 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 8+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 8+ corresponding lines) priv/rust/tui/src/app/handle_actions.rs:1374 — priv/rust/tui/src/app/handle_actions.rs:1374-1385 | priv/rust/tui/src/app/handle_actions.rs:3702-3709 | priv/rust/tui/src/app/handle_actions.rs:3712-3722 | priv/rust/tui/src/app/handle_actions.rs:3768-3778 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 8 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 14+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 14+ corresponding lines) canopy/backend/lib/canopy_web/controllers/agent_controller.ex:102 — canopy/backend/lib/canopy_web/controllers/agent_controller.ex:102-115 | canopy/backend/lib/canopy_web/controllers/gateway_controller.ex:33-46 | canopy/backend/lib/canopy_web/controllers/memory_controller.ex:81-94 | canopy/backend/lib/canopy_web/controllers/webhook_controller.ex:65-78 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 14 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 19+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 19+ corresponding lines) lib/optimal_system_agent/tools/builtins/memory_recall/tool.ex:37 — lib/optimal_system_agent/tools/builtins/memory_recall/tool.ex:37-55 | lib/optimal_system_agent/tools/builtins/memory_save/tool.ex:37-56 | lib/optimal_system_agent/tools/builtins/orchestrate.ex:50-71 | lib/optimal_system_agent/tools/builtins/vault_remember.ex:22-44 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 19 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (6 members, 9+ corresponding lines) · ×1
  • Edited copies of one member (6 members, 9+ corresponding lines) lib/optimal_system_agent/agent/tasks.ex:445 — lib/optimal_system_agent/agent/tasks.ex:445-453 | lib/optimal_system_agent/agent/tasks.ex:464-472 | lib/optimal_system_agent/agent/tasks.ex:477-485 | lib/optimal_system_agent/agent/tasks.ex:490-498 | lib/optimal_system_agent/agent/tasks.ex:503-511 | lib/optimal_system_agent/agent/tasks.ex:516-524 — These 6 members are one piece of code written 6 times and then edited apart: every two of them correspond over at least 9 lines, 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 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. Left alone, the next edit has to be made 6 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (6 members, 5+ corresponding lines) · ×1
  • Edited copies of one member (6 members, 5+ corresponding lines) lib/optimal_system_agent/tools/builtins/computer_use/adapters/linux_wayland.ex:188 — lib/optimal_system_agent/tools/builtins/computer_use/adapters/linux_wayland.ex:188-204 | lib/optimal_system_agent/tools/builtins/computer_use/adapters/linux_x11.ex:186-192 | lib/optimal_system_agent/tools/builtins/computer_use/adapters/linux_x11.ex:200-209 | lib/optimal_system_agent/tools/builtins/computer_use/adapters/linux_x11.ex:240-252 | lib/optimal_system_agent/tools/builtins/computer_use/adapters/macos.ex:461-465 | lib/optimal_system_agent/tools/builtins/computer_use/adapters/macos.ex:563-567 — These 6 members are one piece of code written 6 times and then edited apart: every two of them correspond over at least 5 lines, 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 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. Left alone, the next edit has to be made 6 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 12+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 12+ corresponding lines) lib/optimal_system_agent/providers/cohere.ex:45 — lib/optimal_system_agent/providers/cohere.ex:45-56 | lib/optimal_system_agent/providers/google.ex:101-112 | lib/optimal_system_agent/providers/replicate.ex:81-92 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 12 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (5 members, 9+ corresponding lines) · ×1
  • Edited copies of one member (5 members, 9+ corresponding lines) lib/optimal_system_agent/channels/http/api/canopy_routes.ex:284 — lib/optimal_system_agent/channels/http/api/canopy_routes.ex:284-293 | lib/optimal_system_agent/channels/http/api/cost_routes.ex:242-251 | lib/optimal_system_agent/channels/http/api/project_routes.ex:344-354 | lib/optimal_system_agent/channels/http/api/settings_routes.ex:105-113 | lib/optimal_system_agent/workspace/trust.ex:374-386 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 9 lines, 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 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. Left alone, the next edit has to be made 5 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 6+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 6+ corresponding lines) lib/optimal_system_agent/mcp/transport/stdio.ex:353 — lib/optimal_system_agent/mcp/transport/stdio.ex:353-358 | lib/optimal_system_agent/os/process_group.ex:70-76 | lib/optimal_system_agent/os/process_group.ex:100-108 | lib/optimal_system_agent/os/process_group.ex:171-177 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 6 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (6 members, 4+ corresponding lines) · ×1
  • Edited copies of one member (6 members, 4+ corresponding lines) canopy/backend/lib/canopy_web/controllers/alert_controller.ex:21 — canopy/backend/lib/canopy_web/controllers/alert_controller.ex:21-24 | canopy/backend/lib/canopy_web/controllers/memory_controller.ex:30-33 | canopy/backend/lib/canopy_web/controllers/schedule_controller.ex:56-59 | canopy/backend/lib/canopy_web/controllers/skill_controller.ex:30-33 | canopy/backend/lib/canopy_web/controllers/user_controller.ex:19-22 | canopy/backend/lib/canopy_web/controllers/webhook_controller.ex:19-22 — These 6 members are one piece of code written 6 times and then edited apart: every two of them correspond over at least 4 lines, 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 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. Left alone, the next edit has to be made 6 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (7 members, 4+ corresponding lines) · ×1
  • Edited copies of one member (7 members, 4+ corresponding lines) priv/rust/tui/src/dialogs/channels_panel.rs:81 — priv/rust/tui/src/dialogs/channels_panel.rs:81-84 | priv/rust/tui/src/dialogs/doctor_panel.rs:123-126 | priv/rust/tui/src/dialogs/hooks_viewer.rs:108-111 | priv/rust/tui/src/dialogs/memory_browser.rs:72-75 | priv/rust/tui/src/dialogs/metrics_dashboard.rs:122-125 | priv/rust/tui/src/dialogs/permissions_manager.rs:124-127 | priv/rust/tui/src/dialogs/persona_picker.rs:102-105 — These 7 members are one piece of code written 7 times and then edited apart: every two of them correspond over at least 4 lines, 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 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. Left alone, the next edit has to be made 7 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (8 members, 4+ corresponding lines) · ×1
  • Edited copies of one member (8 members, 4+ corresponding lines) lib/optimal_system_agent/channels/dingtalk.ex:42 — lib/optimal_system_agent/channels/dingtalk.ex:42-45 | lib/optimal_system_agent/channels/email_channel.ex:48-51 | lib/optimal_system_agent/channels/feishu.ex:53-56 | lib/optimal_system_agent/channels/line.ex:49-52 | lib/optimal_system_agent/channels/matrix.ex:46-49 | REDACTED:65-68 | lib/optimal_system_agent/channels/wecom.ex:44-47 | lib/optimal_system_agent/channels/whatsapp.ex:61-64 — These 8 members are one piece of code written 8 times and then edited apart: every two of them correspond over at least 4 lines, 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 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. Left alone, the next edit has to be made 8 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (7 members, 3+ corresponding lines) · ×1
  • Edited copies of one member (7 members, 3+ corresponding lines) lib/optimal_system_agent/agent/compact_restore.ex:281 — lib/optimal_system_agent/agent/compact_restore.ex:281-283 | lib/optimal_system_agent/agent/context_discovery.ex:152-157 | lib/optimal_system_agent/agent/project_instructions.ex:312-317 | lib/optimal_system_agent/agent/worktree.ex:228-233 | lib/optimal_system_agent/fs_checkpoint/server.ex:560-562 | lib/optimal_system_agent/repo_map/git_state.ex:90-93 | lib/optimal_system_agent/tools/builtins/exit_worktree/handler.ex:253-258 — These 7 members are one piece of code written 7 times and then edited apart: every two of them correspond over at least 3 lines, 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 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. Left alone, the next edit has to be made 7 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 1+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 1+ corresponding lines) lib/optimal_system_agent/agent/pricing.ex:376 — lib/optimal_system_agent/agent/pricing.ex:376-376 | lib/optimal_system_agent/providers/anthropic_models.ex:429-429 | lib/optimal_system_agent/providers/registry.ex:2043-2043 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 1 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (5 members, 3+ corresponding lines) · ×1
  • Edited copies of one member (5 members, 3+ corresponding lines) lib/optimal_system_agent/channels/cli/renderer.ex:342 — lib/optimal_system_agent/channels/cli/renderer.ex:342-344 | lib/optimal_system_agent/cli/doctor.ex:635-637 | lib/optimal_system_agent/open_computers/executor/direct/wg_mesh.ex:219-221 | lib/optimal_system_agent/repo_map/git_state.ex:83-86 | lib/optimal_system_agent/workspace/fast_worktree/capabilities.ex:102-104 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 3 lines, 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 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. Left alone, the next edit has to be made 5 times and the copies will drift further apart.
D4 · Code Duplication · Duplicated block (40 lines × 2) · ×1
  • Duplicated block (40 lines × 2) lib/optimal_system_agent/open_computers/executor/direct/desktop/macos.ex:171 — lib/optimal_system_agent/open_computers/executor/direct/desktop/macos.ex:171-210 | lib/optimal_system_agent/open_computers/executor/direct/desktop/windows.ex:173-212 — before extracting anything, compare `lib/optimal_system_agent/open_computers/executor/direct/desktop/macos.ex` and `lib/optimal_system_agent/open_computers/executor/direct/desktop/windows.ex` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 66 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 (32–40 lines × 2) · ×1
  • Duplicated block (32–40 lines × 2) lib/optimal_system_agent/providers/claude_cli.ex:273 — lib/optimal_system_agent/providers/claude_cli.ex:273-312 | lib/optimal_system_agent/providers/copilot_cli.ex:226-257 — before extracting anything, compare `lib/optimal_system_agent/providers/claude_cli.ex` and `lib/optimal_system_agent/providers/copilot_cli.ex` as WHOLE FILES: this scan already matched 7 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. 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 before the matched lines, `lib/optimal_system_agent/providers/claude_cli.ex:270` calls `S` and `lib/optimal_system_agent/providers/copilot_cli.ex:223` 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 (30–36 lines × 2) · ×1
  • Duplicated block (30–36 lines × 2) lib/miosa/shims.ex:287 — lib/miosa/shims.ex:287-316 | lib/optimal_system_agent/signal/message_classifier.ex:96-131 — 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 (34 lines × 2) · ×1
  • Duplicated block (34 lines × 2) lib/optimal_system_agent/agent/tasks/workflow.ex:409 — lib/optimal_system_agent/agent/tasks/workflow.ex:409-442 | lib/optimal_system_agent/agent/workflow.ex:515-548 — before extracting anything, compare `lib/optimal_system_agent/agent/tasks/workflow.ex` and `lib/optimal_system_agent/agent/workflow.ex` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 285 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 (4–31 lines × 4) · ×1
  • Duplicated block (4–31 lines × 4) lib/optimal_system_agent/agent/scheduler/persistence.ex:24 — lib/optimal_system_agent/agent/scheduler/persistence.ex:24-27 | lib/optimal_system_agent/agent/scheduler/persistence.ex:55-58 | lib/optimal_system_agent/agent/tasks/workflow.ex:446-476 | lib/optimal_system_agent/agent/workflow.ex:552-582 — before extracting anything, compare `lib/optimal_system_agent/agent/tasks/workflow.ex` and `lib/optimal_system_agent/agent/workflow.ex` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 285 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 (25–28 lines × 2) · ×1
  • Duplicated block (25–28 lines × 2) lib/optimal_system_agent/providers/ollama.ex:1567 — lib/optimal_system_agent/providers/ollama.ex:1567-1591 | lib/optimal_system_agent/providers/ollama.ex:1796-1823 — 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–28 lines × 2) · ×1
  • Duplicated block (26–28 lines × 2) lib/optimal_system_agent/providers/openai_compat_provider.ex:370 — lib/optimal_system_agent/providers/openai_compat_provider.ex:370-395 | lib/optimal_system_agent/providers/openai_compat_provider.ex:416-443 — 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `lib/optimal_system_agent/providers/openai_compat_provider.ex:395` calls `maybe_extend_timeout`, `demote_non_leading_system` and `lib/optimal_system_agent/providers/openai_compat_provider.ex:443` 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 (23–27 lines × 2) · ×1
  • Duplicated block (23–27 lines × 2) lib/optimal_system_agent/open_computers/updater.ex:347 — lib/optimal_system_agent/open_computers/updater.ex:347-369 | lib/optimal_system_agent/system/updater.ex:590-616 — 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 (25 lines × 2) · ×1
  • Duplicated block (25 lines × 2) lib/optimal_system_agent/agent/task_queue.ex:169 — lib/optimal_system_agent/agent/task_queue.ex:169-193 | lib/optimal_system_agent/agent/task_queue.ex:364-388 — 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 (20–25 lines × 2) · ×1
  • Duplicated block (20–25 lines × 2) lib/optimal_system_agent/auth/device_flow.ex:333 — lib/optimal_system_agent/auth/device_flow.ex:333-357 | lib/optimal_system_agent/auth/providers/minimax.ex:552-571 — 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 (22–25 lines × 2) · ×1
  • Duplicated block (22–25 lines × 2) lib/optimal_system_agent/shell/background_task.ex:171 — lib/optimal_system_agent/shell/background_task.ex:171-192 | lib/optimal_system_agent/tools/builtins/shell_execute/handler.ex:558-582 — 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 (19–22 lines × 3) · ×1
  • Duplicated block (19–22 lines × 3) lib/optimal_system_agent/auth/providers/minimax.ex:430 — lib/optimal_system_agent/auth/providers/minimax.ex:430-448 | REDACTED:412-431 | lib/optimal_system_agent/auth/providers/xai.ex:332-353 — before extracting anything, compare `lib/optimal_system_agent/auth/providers/minimax.ex` and `REDACTED` as WHOLE FILES: this scan already matched 3 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. 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 `lib/optimal_system_agent/auth/providers/minimax.ex:430` 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–22 lines × 2) · ×1
  • Duplicated block (20–22 lines × 2) lib/optimal_system_agent/agent/task_queue.ex:782 — lib/optimal_system_agent/agent/task_queue.ex:782-803 | lib/optimal_system_agent/agent/tasks/queue.ex:396-415 — before extracting anything, compare `lib/optimal_system_agent/agent/task_queue.ex` and `lib/optimal_system_agent/agent/tasks/queue.ex` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 149 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 (16–22 lines × 2) · ×1
  • Duplicated block (16–22 lines × 2) lib/optimal_system_agent/agent/tasks/workflow.ex:150 — lib/optimal_system_agent/agent/tasks/workflow.ex:150-165 | lib/optimal_system_agent/agent/workflow.ex:290-311 — before extracting anything, compare `lib/optimal_system_agent/agent/tasks/workflow.ex` and `lib/optimal_system_agent/agent/workflow.ex` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 285 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) lib/optimal_system_agent/agent/compactor.ex:1804 — lib/optimal_system_agent/agent/compactor.ex:1804-1822 | lib/optimal_system_agent/agent/compactor.ex:1908-1928 — 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 (18–21 lines × 2) · ×1
  • Duplicated block (18–21 lines × 2) lib/optimal_system_agent/agent/tasks/workflow.ex:292 — lib/optimal_system_agent/agent/tasks/workflow.ex:292-309 | lib/optimal_system_agent/agent/workflow.ex:138-158 — before extracting anything, compare `lib/optimal_system_agent/agent/tasks/workflow.ex` and `lib/optimal_system_agent/agent/workflow.ex` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 285 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 `lib/optimal_system_agent/agent/tasks/workflow.ex:292` 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 (21 lines × 2) · ×1
  • Duplicated block (21 lines × 2) lib/optimal_system_agent/decisions/graph.ex:237 — lib/optimal_system_agent/decisions/graph.ex:237-257 | lib/optimal_system_agent/decisions/graph.ex:275-295 — 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 (14–20 lines × 2) · ×1
  • Duplicated block (14–20 lines × 2) lib/optimal_system_agent/agent/loop/react_loop.ex:870 — lib/optimal_system_agent/agent/loop/react_loop.ex:870-889 | lib/optimal_system_agent/agent/loop/react_loop.ex:1214-1227 — 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 `lib/optimal_system_agent/agent/loop/react_loop.ex:870` 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, `lib/optimal_system_agent/agent/loop/react_loop.ex:866` calls `drain_streaming_tool_blocks`, `get`, `put` and `lib/optimal_system_agent/agent/loop/react_loop.ex:1212` 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 (15–20 lines × 2) · ×1
  • Duplicated block (15–20 lines × 2) lib/optimal_system_agent/agent/task_queue.ex:436 — lib/optimal_system_agent/agent/task_queue.ex:436-455 | lib/optimal_system_agent/agent/tasks/queue.ex:87-101 — before extracting anything, compare `lib/optimal_system_agent/agent/task_queue.ex` and `lib/optimal_system_agent/agent/tasks/queue.ex` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 149 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–20 lines × 2) · ×1
  • Duplicated block (19–20 lines × 2) lib/optimal_system_agent/tools/builtins/security_intel.ex:194 — lib/optimal_system_agent/tools/builtins/security_intel.ex:194-213 | lib/optimal_system_agent/tools/builtins/security_intel.ex:218-236 — 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 `lib/optimal_system_agent/tools/builtins/security_intel.ex:194` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (17–20 lines × 2) · ×1
  • Duplicated block (17–20 lines × 2) lib/optimal_system_agent/tools/builtins/shell_execute/handler.ex:672 — lib/optimal_system_agent/tools/builtins/shell_execute/handler.ex:672-688 | lib/optimal_system_agent/tools/builtins/shell_execute/handler.ex:735-754 — 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–19 lines × 7) · ×1
  • Duplicated block (11–19 lines × 7) lib/optimal_system_agent/tools/builtins/create_skill/tool.ex:37 — lib/optimal_system_agent/tools/builtins/create_skill/tool.ex:37-53 | lib/optimal_system_agent/tools/builtins/diff.ex:37-47 | lib/optimal_system_agent/tools/builtins/expand_output.ex:55-72 | lib/optimal_system_agent/tools/builtins/file_grep/tool.ex:37-50 | lib/optimal_system_agent/tools/builtins/goal/update_tool.ex:54-72 | lib/optimal_system_agent/tools/builtins/pty/pty_start.ex:43-59 | lib/optimal_system_agent/tools/builtins/save_skill.ex:42-58 — `lib/optimal_system_agent/tools/builtins/create_skill/tool.ex` and `lib/optimal_system_agent/tools/builtins/file_grep/tool.ex` 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 70 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 `lib/optimal_system_agent/tools/builtins/create_skill/tool.ex:37` 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 (12–19 lines × 2) · ×1
  • Duplicated block (12–19 lines × 2) lib/optimal_system_agent/tools/builtins/diff.ex:41 — lib/optimal_system_agent/tools/builtins/diff.ex:41-52 | lib/optimal_system_agent/tools/builtins/repo_map.ex:66-84 — 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 `lib/optimal_system_agent/tools/builtins/diff.ex:41` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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–18 lines × 6) · ×1
  • Duplicated block (16–18 lines × 6) lib/optimal_system_agent/tools/builtins/cross_team_query/tool.ex:35 — lib/optimal_system_agent/tools/builtins/cross_team_query/tool.ex:35-51 | lib/optimal_system_agent/tools/builtins/notebook_edit/tool.ex:53-68 | lib/optimal_system_agent/tools/builtins/peer_claim_region/tool.ex:35-51 | lib/optimal_system_agent/tools/builtins/peer_negotiate_task/tool.ex:35-51 | lib/optimal_system_agent/tools/builtins/peer_review/tool.ex:35-52 | lib/optimal_system_agent/tools/builtins/remote_trigger/tool.ex:36-52 — `lib/optimal_system_agent/tools/builtins/cross_team_query/tool.ex` and `lib/optimal_system_agent/tools/builtins/peer_claim_region/tool.ex` 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 119 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 `lib/optimal_system_agent/tools/builtins/cross_team_query/tool.ex:35` 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 (15–17 lines × 5) · ×1
  • Duplicated block (15–17 lines × 5) lib/optimal_system_agent/auth/providers/copilot.ex:313 — lib/optimal_system_agent/auth/providers/copilot.ex:313-328 | lib/optimal_system_agent/auth/providers/minimax.ex:338-352 | lib/optimal_system_agent/auth/providers/openai_codex.ex:463-478 | REDACTED:295-310 | lib/optimal_system_agent/auth/providers/xai.ex:238-254 — before extracting anything, compare `lib/optimal_system_agent/auth/providers/copilot.ex` and `lib/optimal_system_agent/auth/providers/openai_codex.ex` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 68 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 `lib/optimal_system_agent/auth/providers/copilot.ex:313` 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 (13–17 lines × 5) · ×1
  • Duplicated block (13–17 lines × 5) lib/optimal_system_agent/tools/builtins/file_read.ex:35 — lib/optimal_system_agent/tools/builtins/file_read.ex:35-47 | lib/optimal_system_agent/tools/builtins/find_skill.ex:46-62 | lib/optimal_system_agent/tools/builtins/multi_file_edit/tool.ex:57-71 | lib/optimal_system_agent/tools/builtins/send_user_file/tool.ex:39-54 | lib/optimal_system_agent/tools/builtins/structural_edit/tool.ex:71-85 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `lib/optimal_system_agent/tools/builtins/file_read.ex:35` 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 (15–17 lines × 4) · ×1
  • Duplicated block (15–17 lines × 4) lib/optimal_system_agent/tools/builtins/delegate/tool.ex:140 — lib/optimal_system_agent/tools/builtins/delegate/tool.ex:140-155 | lib/optimal_system_agent/tools/builtins/expand_output.ex:59-75 | lib/optimal_system_agent/tools/builtins/file_transform/tool.ex:70-84 | lib/optimal_system_agent/tools/builtins/task_write/tool.ex:99-113 — `lib/optimal_system_agent/tools/builtins/delegate/tool.ex` and `lib/optimal_system_agent/tools/builtins/file_transform/tool.ex` 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 85 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 `lib/optimal_system_agent/tools/builtins/delegate/tool.ex:140` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (14–17 lines × 2) · ×1
  • Duplicated block (14–17 lines × 2) REDACTED:386 — REDACTED:386-402 | lib/optimal_system_agent/auth/providers/xai.ex:313-326 — before extracting anything, compare `REDACTED` and `lib/optimal_system_agent/auth/providers/xai.ex` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 82 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:386` 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 (15–16 lines × 4) · ×1
  • Duplicated block (15–16 lines × 4) lib/optimal_system_agent/tools/builtins/create_skill/tool.ex:45 — lib/optimal_system_agent/tools/builtins/create_skill/tool.ex:45-60 | lib/optimal_system_agent/tools/builtins/save_skill.ex:50-64 | lib/optimal_system_agent/tools/builtins/skill_manager.ex:51-66 | lib/optimal_system_agent/tools/builtins/task_write/tool.ex:68-83 — before extracting anything, compare `lib/optimal_system_agent/tools/builtins/create_skill/tool.ex` and `lib/optimal_system_agent/tools/builtins/save_skill.ex` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 86 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 `lib/optimal_system_agent/tools/builtins/create_skill/tool.ex:45` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with 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 (13–16 lines × 4) · ×1
  • Duplicated block (13–16 lines × 4) lib/optimal_system_agent/tools/builtins/knowledge.ex:27 — lib/optimal_system_agent/tools/builtins/knowledge.ex:27-39 | lib/optimal_system_agent/tools/builtins/repo_map.ex:66-81 | lib/optimal_system_agent/tools/builtins/security_intel.ex:174-186 | lib/optimal_system_agent/tools/builtins/skill_manager.ex:44-56 — before extracting anything, compare `lib/optimal_system_agent/tools/builtins/knowledge.ex` and `lib/optimal_system_agent/tools/builtins/security_intel.ex` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 67 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 `lib/optimal_system_agent/tools/builtins/knowledge.ex:27` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with 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 (15–16 lines × 3) · ×1
  • Duplicated block (15–16 lines × 3) lib/optimal_system_agent/agent/compactor.ex:1815 — lib/optimal_system_agent/agent/compactor.ex:1815-1829 | lib/optimal_system_agent/agent/compactor.ex:1921-1935 | lib/optimal_system_agent/agent/compactor.ex:2208-2223 — 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 `lib/optimal_system_agent/agent/compactor.ex:2208` 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–16 lines × 2) · ×1
  • Duplicated block (14–16 lines × 2) lib/optimal_system_agent/agent/tasks/workflow.ex:354 — lib/optimal_system_agent/agent/tasks/workflow.ex:354-367 | lib/optimal_system_agent/agent/workflow.ex:758-773 — before extracting anything, compare `lib/optimal_system_agent/agent/tasks/workflow.ex` and `lib/optimal_system_agent/agent/workflow.ex` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 285 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 (15 lines × 5) · ×1
  • Duplicated block (15 lines × 5) lib/optimal_system_agent/tools/builtins/cross_team_query/tool.ex:39 — lib/optimal_system_agent/tools/builtins/cross_team_query/tool.ex:39-53 | lib/optimal_system_agent/tools/builtins/monitor/tool.ex:42-58 | lib/optimal_system_agent/tools/builtins/peer_claim_region/tool.ex:39-53 | lib/optimal_system_agent/tools/builtins/peer_review/tool.ex:39-54 | lib/optimal_system_agent/tools/builtins/remote_trigger/tool.ex:40-54 — `lib/optimal_system_agent/tools/builtins/cross_team_query/tool.ex` and `lib/optimal_system_agent/tools/builtins/monitor/tool.ex` 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 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. Read the line range as the matched WINDOW rather than a finished unit: at `lib/optimal_system_agent/tools/builtins/cross_team_query/tool.ex:39` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `lib/optimal_system_agent/tools/builtins/peer_review/tool.ex:57` calls `verdicts` and `lib/optimal_system_agent/tools/builtins/cross_team_query/tool.ex:56` 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 (15 lines × 4) · ×1
  • Duplicated block (15 lines × 4) lib/optimal_system_agent/agent/tasks/workflow.ex:417 — lib/optimal_system_agent/agent/tasks/workflow.ex:417-431 | lib/optimal_system_agent/agent/tasks/workflow.ex:453-467 | lib/optimal_system_agent/agent/workflow.ex:523-537 | lib/optimal_system_agent/agent/workflow.ex:559-573 — before extracting anything, compare `lib/optimal_system_agent/agent/tasks/workflow.ex` and `lib/optimal_system_agent/agent/workflow.ex` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 285 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–15 lines × 3) · ×1
  • Duplicated block (12–15 lines × 3) lib/optimal_system_agent/providers/google_models.ex:421 — lib/optimal_system_agent/providers/google_models.ex:421-435 | lib/optimal_system_agent/providers/google_models.ex:439-453 | lib/optimal_system_agent/providers/xai_models.ex:394-405 — 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 `lib/optimal_system_agent/providers/google_models.ex:421` 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–15 lines × 2) · ×1
  • Duplicated block (8–15 lines × 2) lib/optimal_system_agent/tools/builtins/structural_edit/tool.ex:95 — lib/optimal_system_agent/tools/builtins/structural_edit/tool.ex:95-109 | lib/optimal_system_agent/tools/builtins/vault_sleep.ex:23-30 — 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 `lib/optimal_system_agent/tools/builtins/structural_edit/tool.ex: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 (14 lines × 5) · ×1
  • Duplicated block (14 lines × 5) lib/optimal_system_agent/tools/builtins/browser.ex:49 — lib/optimal_system_agent/tools/builtins/browser.ex:49-65 | lib/optimal_system_agent/tools/builtins/computer_use/tool.ex:133-148 | lib/optimal_system_agent/tools/builtins/knowledge.ex:36-51 | lib/optimal_system_agent/tools/builtins/pty/pty_start.ex:54-67 | lib/optimal_system_agent/tools/builtins/remote_trigger/tool.ex:49-65 — before extracting anything, compare `lib/optimal_system_agent/tools/builtins/browser.ex` and `lib/optimal_system_agent/tools/builtins/computer_use/tool.ex` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 117 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 `lib/optimal_system_agent/tools/builtins/browser.ex:49` 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 lines × 4) · ×1
  • Duplicated block (14 lines × 4) lib/optimal_system_agent/tools/builtins/delegate/tool.ex:88 — lib/optimal_system_agent/tools/builtins/delegate/tool.ex:88-102 | lib/optimal_system_agent/tools/builtins/goal/update_tool.ex:62-77 | lib/optimal_system_agent/tools/builtins/monitor/tool.ex:46-60 | lib/optimal_system_agent/tools/builtins/peer_review/tool.ex:43-56 — before extracting anything, compare `lib/optimal_system_agent/tools/builtins/delegate/tool.ex` and `lib/optimal_system_agent/tools/builtins/goal/update_tool.ex` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 67 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 `lib/optimal_system_agent/tools/builtins/delegate/tool.ex:88` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (13 lines × 6) · ×1
  • Duplicated block (13 lines × 6) lib/optimal_system_agent/tools/builtins/browser.ex:48 — lib/optimal_system_agent/tools/builtins/browser.ex:48-63 | lib/optimal_system_agent/tools/builtins/code_sandbox.ex:79-93 | lib/optimal_system_agent/tools/builtins/computer_use/tool.ex:132-146 | lib/optimal_system_agent/tools/builtins/knowledge.ex:35-49 | lib/optimal_system_agent/tools/builtins/pty/pty_start.ex:53-65 | lib/optimal_system_agent/tools/builtins/remote_trigger/tool.ex:48-63 — before extracting anything, compare `lib/optimal_system_agent/tools/builtins/browser.ex` and `lib/optimal_system_agent/tools/builtins/computer_use/tool.ex` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 117 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 `lib/optimal_system_agent/tools/builtins/browser.ex:48` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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 (13 lines × 3) · ×1
  • Duplicated block (13 lines × 3) lib/optimal_system_agent/channels/discord.ex:202 — lib/optimal_system_agent/channels/discord.ex:202-214 | lib/optimal_system_agent/channels/slack.ex:220-232 | lib/optimal_system_agent/channels/telegram.ex:255-267 — 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.
D4 · Code Duplication · Duplicated block (6–13 lines × 2) · ×1
  • Duplicated block (6–13 lines × 2) lib/optimal_system_agent/providers/ollama.ex:572 — lib/optimal_system_agent/providers/ollama.ex:572-584 | lib/optimal_system_agent/providers/ollama.ex:1774-1779 — 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 × 3) · ×1
  • Duplicated block (12 lines × 3) lib/optimal_system_agent/providers/anthropic_models.ex:718 — lib/optimal_system_agent/providers/anthropic_models.ex:718-729 | lib/optimal_system_agent/providers/google_models.ex:482-493 | lib/optimal_system_agent/providers/openai_models.ex:318-329 — 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.
D4 · Code Duplication · Duplicated block (10–11 lines × 2) · ×1
  • Duplicated block (10–11 lines × 2) canopy/backend/lib/canopy_web/controllers/log_controller.ex:23 — canopy/backend/lib/canopy_web/controllers/log_controller.ex:23-32 | canopy/backend/lib/canopy_web/controllers/log_controller.ex:34-44 — 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 (10 lines × 8) · ×1
  • Duplicated block (10 lines × 8) lib/optimal_system_agent/tools/builtins/browser.ex:48 — lib/optimal_system_agent/tools/builtins/browser.ex:48-63 | lib/optimal_system_agent/tools/builtins/code_sandbox.ex:79-93 | lib/optimal_system_agent/tools/builtins/computer_use/tool.ex:132-146 | lib/optimal_system_agent/tools/builtins/diff.ex:41-50 | lib/optimal_system_agent/tools/builtins/knowledge.ex:35-49 | lib/optimal_system_agent/tools/builtins/pty/pty_start.ex:53-65 | lib/optimal_system_agent/tools/builtins/remote_trigger/tool.ex:48-63 | lib/optimal_system_agent/tools/builtins/repo_map.ex:66-82 — before extracting anything, compare `lib/optimal_system_agent/tools/builtins/browser.ex` and `lib/optimal_system_agent/tools/builtins/computer_use/tool.ex` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 117 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 `lib/optimal_system_agent/tools/builtins/browser.ex:48` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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 × 7) · ×1
  • Duplicated block (10 lines × 7) canopy/backend/lib/canopy_web/controllers/agent_controller.ex:89 — canopy/backend/lib/canopy_web/controllers/agent_controller.ex:89-98 | canopy/backend/lib/canopy_web/controllers/goal_controller.ex:68-77 | canopy/backend/lib/canopy_web/controllers/project_controller.ex:60-69 | canopy/backend/lib/canopy_web/controllers/schedule_controller.ex:70-79 | canopy/backend/lib/canopy_web/controllers/user_controller.ex:47-56 | canopy/backend/lib/canopy_web/controllers/webhook_controller.ex:52-61 | canopy/backend/lib/canopy_web/controllers/workspace_controller.ex:78-87 — before extracting anything, compare `canopy/backend/lib/canopy_web/controllers/goal_controller.ex` and `canopy/backend/lib/canopy_web/controllers/project_controller.ex` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 34 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 `canopy/backend/lib/canopy_web/controllers/agent_controller.ex: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 (9–10 lines × 4) · ×1
  • Duplicated block (9–10 lines × 4) lib/optimal_system_agent/tools/builtins/computer_use/tool.ex:64 — lib/optimal_system_agent/tools/builtins/computer_use/tool.ex:64-73 | lib/optimal_system_agent/tools/builtins/pty/pty_wait.ex:54-62 | lib/optimal_system_agent/tools/builtins/security_intel.ex:199-207 | lib/optimal_system_agent/tools/builtins/security_intel.ex:223-231 — before extracting anything, compare `lib/optimal_system_agent/tools/builtins/computer_use/tool.ex` and `lib/optimal_system_agent/tools/builtins/security_intel.ex` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 61 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 `lib/optimal_system_agent/tools/builtins/computer_use/tool.ex:64` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with 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 (9–10 lines × 2) · ×1
  • Duplicated block (9–10 lines × 2) lib/optimal_system_agent/agent/task_tracker.ex:494 — lib/optimal_system_agent/agent/task_tracker.ex:494-503 | lib/optimal_system_agent/agent/tasks/tracker.ex:582-590 — before extracting anything, compare `lib/optimal_system_agent/agent/task_tracker.ex` and `lib/optimal_system_agent/agent/tasks/tracker.ex` as WHOLE FILES: this scan already matched 7 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. 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 `lib/optimal_system_agent/agent/task_tracker.ex:494` 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 (9 lines × 9) · ×1
  • Duplicated block (9 lines × 9) lib/optimal_system_agent/tools/builtins/browser.ex:47 — lib/optimal_system_agent/tools/builtins/browser.ex:47-62 | lib/optimal_system_agent/tools/builtins/computer_use/tool.ex:131-145 | lib/optimal_system_agent/tools/builtins/cross_team_query/tool.ex:47-62 | lib/optimal_system_agent/tools/builtins/diff.ex:41-49 | lib/optimal_system_agent/tools/builtins/knowledge.ex:34-48 | lib/optimal_system_agent/tools/builtins/peer_claim_region/tool.ex:43-58 | lib/optimal_system_agent/tools/builtins/pty/pty_start.ex:52-64 | lib/optimal_system_agent/tools/builtins/remote_trigger/tool.ex:47-62 | lib/optimal_system_agent/tools/builtins/team_tasks/tool.ex:48-63 — before extracting anything, compare `lib/optimal_system_agent/tools/builtins/browser.ex` and `lib/optimal_system_agent/tools/builtins/computer_use/tool.ex` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 117 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 `lib/optimal_system_agent/tools/builtins/browser.ex:47` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (9 lines × 5) · ×1
  • Duplicated block (9 lines × 5) canopy/backend/lib/canopy_web/controllers/goal_controller.ex:31 — canopy/backend/lib/canopy_web/controllers/goal_controller.ex:31-39 | canopy/backend/lib/canopy_web/controllers/project_controller.ex:25-33 | canopy/backend/lib/canopy_web/controllers/schedule_controller.ex:44-52 | canopy/backend/lib/canopy_web/controllers/template_controller.ex:23-31 | canopy/backend/lib/canopy_web/controllers/user_controller.ex:28-36 — before extracting anything, compare `canopy/backend/lib/canopy_web/controllers/goal_controller.ex` and `canopy/backend/lib/canopy_web/controllers/project_controller.ex` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 34 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 `canopy/backend/lib/canopy_web/controllers/goal_controller.ex: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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `canopy/backend/lib/canopy_web/controllers/template_controller.ex:20` calls `put` and `canopy/backend/lib/canopy_web/controllers/goal_controller.ex: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–9 lines × 3) · ×1
  • Duplicated block (8–9 lines × 3) lib/optimal_system_agent/agent/loop/doom_loop/stall.ex:365 — lib/optimal_system_agent/agent/loop/doom_loop/stall.ex:365-373 | lib/optimal_system_agent/agent/loop/regulation/homeostat.ex:216-223 | lib/optimal_system_agent/agent/loop/regulation/signals.ex:187-194 — 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, `lib/optimal_system_agent/agent/loop/doom_loop/stall.ex:360` calls `find_result` and `lib/optimal_system_agent/agent/loop/regulation/homeostat.ex:213` 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 × 4) · ×1
  • Duplicated block (8 lines × 4) lib/optimal_system_agent/tools/builtins/create_skill/tool.ex:48 — lib/optimal_system_agent/tools/builtins/create_skill/tool.ex:48-61 | lib/optimal_system_agent/tools/builtins/skill_manager.ex:54-67 | lib/optimal_system_agent/tools/builtins/structural_edit/tool.ex:97-110 | lib/optimal_system_agent/tools/builtins/vault_sleep.ex:24-31 — before extracting anything, compare `lib/optimal_system_agent/tools/builtins/create_skill/tool.ex` and `lib/optimal_system_agent/tools/builtins/skill_manager.ex` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 81 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 `lib/optimal_system_agent/tools/builtins/create_skill/tool.ex:48` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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 × 21) · ×1
  • Duplicated block (7 lines × 21) lib/optimal_system_agent/tools/builtins/browser.ex:44 — lib/optimal_system_agent/tools/builtins/browser.ex:44-58 | lib/optimal_system_agent/tools/builtins/computer_use/tool.ex:56-62 | lib/optimal_system_agent/tools/builtins/computer_use/tool.ex:79-94 | lib/optimal_system_agent/tools/builtins/create_skill/tool.ex:43-56 | lib/optimal_system_agent/tools/builtins/cross_team_query/tool.ex:40-54 | lib/optimal_system_agent/tools/builtins/delegate/tool.ex:133-147 | lib/optimal_system_agent/tools/builtins/file_grep/tool.ex:41-53 | lib/optimal_system_agent/tools/builtins/file_transform/tool.ex:66-77 | lib/optimal_system_agent/tools/builtins/goal/update_tool.ex:60-76 | lib/optimal_system_agent/tools/builtins/knowledge.ex:28-41 | lib/optimal_system_agent/tools/builtins/monitor/tool.ex:43-59 | lib/optimal_system_agent/tools/builtins/peer_claim_region/tool.ex:40-54 | lib/optimal_system_agent/tools/builtins/peer_review/tool.ex:40-55 | lib/optimal_system_agent/tools/builtins/pty/pty_start.ex:49-61 | lib/optimal_system_agent/tools/builtins/remote_trigger/tool.ex:41-55 | lib/optimal_system_agent/tools/builtins/save_skill.ex:48-61 | lib/optimal_system_agent/tools/builtins/security_intel.ex:175-188 | lib/optimal_system_agent/tools/builtins/skill_manager.ex:45-58 | lib/optimal_system_agent/tools/builtins/task_write/tool.ex:65-80 | lib/optimal_system_agent/tools/builtins/task_write/tool.ex:97-110 | lib/optimal_system_agent/tools/builtins/team_tasks/tool.ex:45-59 — before extracting anything, compare `lib/optimal_system_agent/tools/builtins/browser.ex` and `lib/optimal_system_agent/tools/builtins/computer_use/tool.ex` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 117 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 `lib/optimal_system_agent/tools/builtins/browser.ex:44` 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, `lib/optimal_system_agent/tools/builtins/peer_review/tool.ex:57` calls `verdicts` and `lib/optimal_system_agent/tools/builtins/computer_use/tool.ex:64` 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 (3–7 lines × 4) · ×1
  • Duplicated block (3–7 lines × 4) lib/optimal_system_agent/agent/tasks/workflow.ex:233 — lib/optimal_system_agent/agent/tasks/workflow.ex:233-235 | lib/optimal_system_agent/agent/tasks/workflow.ex:484-490 | lib/optimal_system_agent/agent/workflow.ex:364-366 | lib/optimal_system_agent/agent/workflow.ex:592-598 — before extracting anything, compare `lib/optimal_system_agent/agent/tasks/workflow.ex` and `lib/optimal_system_agent/agent/workflow.ex` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 285 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, `lib/optimal_system_agent/agent/workflow.ex:599` calls `format_completed_steps`, `format_remaining_steps`, `format_context` and `lib/optimal_system_agent/agent/tasks/workflow.ex:493` 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 (6 lines × 22) · ×1
  • Duplicated block (6 lines × 22) lib/optimal_system_agent/tools/builtins/browser.ex:45 — lib/optimal_system_agent/tools/builtins/browser.ex:45-59 | lib/optimal_system_agent/tools/builtins/computer_use/tool.ex:54-59 | lib/optimal_system_agent/tools/builtins/computer_use/tool.ex:75-91 | lib/optimal_system_agent/tools/builtins/create_skill/tool.ex:43-57 | lib/optimal_system_agent/tools/builtins/cross_team_query/tool.ex:41-55 | lib/optimal_system_agent/tools/builtins/delegate/tool.ex:86-102 | lib/optimal_system_agent/tools/builtins/delegate/tool.ex:134-148 | lib/optimal_system_agent/tools/builtins/file_grep/tool.ex:41-54 | lib/optimal_system_agent/tools/builtins/file_transform/tool.ex:67-78 | lib/optimal_system_agent/tools/builtins/goal/update_tool.ex:60-77 | lib/optimal_system_agent/tools/builtins/knowledge.ex:28-42 | lib/optimal_system_agent/tools/builtins/monitor/tool.ex:44-60 | lib/optimal_system_agent/tools/builtins/peer_claim_region/tool.ex:41-55 | lib/optimal_system_agent/tools/builtins/peer_review/tool.ex:41-56 | lib/optimal_system_agent/tools/builtins/pty/pty_start.ex:50-62 | lib/optimal_system_agent/tools/builtins/remote_trigger/tool.ex:41-56 | lib/optimal_system_agent/tools/builtins/save_skill.ex:48-62 | lib/optimal_system_agent/tools/builtins/security_intel.ex:175-189 | lib/optimal_system_agent/tools/builtins/skill_manager.ex:45-59 | lib/optimal_system_agent/tools/builtins/task_write/tool.ex:66-81 | lib/optimal_system_agent/tools/builtins/task_write/tool.ex:97-111 | lib/optimal_system_agent/tools/builtins/team_tasks/tool.ex:46-60 — before extracting anything, compare `lib/optimal_system_agent/tools/builtins/browser.ex` and `lib/optimal_system_agent/tools/builtins/computer_use/tool.ex` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 117 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 `lib/optimal_system_agent/tools/builtins/browser.ex:45` 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, `lib/optimal_system_agent/tools/builtins/peer_review/tool.ex:57` calls `verdicts` and `lib/optimal_system_agent/tools/builtins/computer_use/tool.ex:60` 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 (5 lines × 24) · ×1
  • Duplicated block (5 lines × 24) lib/optimal_system_agent/tools/builtins/browser.ex:46 — lib/optimal_system_agent/tools/builtins/browser.ex:46-59 | lib/optimal_system_agent/tools/builtins/computer_use/tool.ex:55-59 | lib/optimal_system_agent/tools/builtins/computer_use/tool.ex:76-91 | lib/optimal_system_agent/tools/builtins/create_skill/tool.ex:40-53 | lib/optimal_system_agent/tools/builtins/cross_team_query/tool.ex:42-55 | lib/optimal_system_agent/tools/builtins/delegate/tool.ex:87-102 | lib/optimal_system_agent/tools/builtins/delegate/tool.ex:135-148 | lib/optimal_system_agent/tools/builtins/diff.ex:40-47 | lib/optimal_system_agent/tools/builtins/expand_output.ex:58-72 | lib/optimal_system_agent/tools/builtins/file_grep/tool.ex:40-50 | lib/optimal_system_agent/tools/builtins/file_transform/tool.ex:68-78 | lib/optimal_system_agent/tools/builtins/goal/update_tool.ex:57-72 | lib/optimal_system_agent/tools/builtins/knowledge.ex:29-42 | lib/optimal_system_agent/tools/builtins/monitor/tool.ex:45-60 | lib/optimal_system_agent/tools/builtins/peer_claim_region/tool.ex:42-55 | lib/optimal_system_agent/tools/builtins/peer_review/tool.ex:42-56 | lib/optimal_system_agent/tools/builtins/pty/pty_start.ex:46-59 | lib/optimal_system_agent/tools/builtins/remote_trigger/tool.ex:42-56 | lib/optimal_system_agent/tools/builtins/save_skill.ex:45-58 | lib/optimal_system_agent/tools/builtins/security_intel.ex:176-189 | lib/optimal_system_agent/tools/builtins/skill_manager.ex:46-59 | lib/optimal_system_agent/tools/builtins/task_write/tool.ex:67-81 | lib/optimal_system_agent/tools/builtins/task_write/tool.ex:98-111 | lib/optimal_system_agent/tools/builtins/team_tasks/tool.ex:47-60 — before extracting anything, compare `lib/optimal_system_agent/tools/builtins/browser.ex` and `lib/optimal_system_agent/tools/builtins/computer_use/tool.ex` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 117 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 `lib/optimal_system_agent/tools/builtins/browser.ex: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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `lib/optimal_system_agent/tools/builtins/peer_review/tool.ex:57` calls `verdicts` and `lib/optimal_system_agent/tools/builtins/computer_use/tool.ex:60` 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 × 3) · ×1
  • Duplicated block (3–5 lines × 3) lib/optimal_system_agent/open_computers/remote/client.ex:70 — lib/optimal_system_agent/open_computers/remote/client.ex:70-74 | lib/optimal_system_agent/open_computers/session.ex:320-324 | lib/optimal_system_agent/remote/client.ex:338-340 — 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 `lib/optimal_system_agent/remote/client.ex:338` 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 (19 lines × 3) · ×1
  • Duplicated block (19 lines × 3) lib/optimal_system_agent/tools/builtins/code_symbols/prompt.ex:8 — lib/optimal_system_agent/tools/builtins/code_symbols/prompt.ex:8-30 | lib/optimal_system_agent/tools/builtins/file_glob/prompt.ex:11-29 | lib/optimal_system_agent/tools/builtins/notebook_edit/prompt.ex:18-69 — 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 (83 lines × 4) · ×1
  • Duplicated block (83 lines × 4) lib/optimal_system_agent/tools/builtins/session_search.ex:25 — lib/optimal_system_agent/tools/builtins/session_search.ex:25-107 | lib/optimal_system_agent/tools/builtins/task_output.ex:25-107 | lib/optimal_system_agent/tools/builtins/task_stop.ex:25-107 | lib/optimal_system_agent/tools/builtins/task_write.ex:27-115 — before extracting anything, compare `lib/optimal_system_agent/tools/builtins/session_search.ex` and `lib/optimal_system_agent/tools/builtins/task_output.ex` as WHOLE FILES: 83% 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. 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. 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 × 17) · ×1
  • Duplicated block (5 lines × 17) canopy/backend/lib/canopy_web/controllers/agent_controller.ex:270 — canopy/backend/lib/canopy_web/controllers/agent_controller.ex:270-274 | canopy/backend/lib/canopy_web/controllers/alert_controller.ex:161-165 | canopy/backend/lib/canopy_web/controllers/budget_controller.ex:119-123 | canopy/backend/lib/canopy_web/controllers/comment_controller.ex:54-58 | canopy/backend/lib/canopy_web/controllers/gateway_controller.ex:113-117 | canopy/backend/lib/canopy_web/controllers/goal_controller.ex:130-134 | canopy/backend/lib/canopy_web/controllers/integration_controller.ex:157-161 | canopy/backend/lib/canopy_web/controllers/issue_controller.ex:199-203 | canopy/backend/lib/canopy_web/controllers/memory_controller.ex:132-136 | canopy/backend/lib/canopy_web/controllers/project_controller.ex:127-131 | canopy/backend/lib/canopy_web/controllers/schedule_controller.ex:167-171 | canopy/backend/lib/canopy_web/controllers/skill_controller.ex:139-143 | canopy/backend/lib/canopy_web/controllers/template_controller.ex:50-54 | canopy/backend/lib/canopy_web/controllers/user_controller.ex:84-88 | canopy/backend/lib/canopy_web/controllers/webhook_controller.ex:237-241 | canopy/backend/lib/canopy_web/controllers/workspace_controller.ex:229-233 | lib/optimal_system_agent/channels/http/api/shared.ex:94-100 — before extracting anything, compare `canopy/backend/lib/canopy_web/controllers/goal_controller.ex` and `canopy/backend/lib/canopy_web/controllers/project_controller.ex` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 34 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 (19 lines × 4) · ×1
  • Duplicated block (19 lines × 4) lib/optimal_system_agent/agent/batch_cadence.ex:297 — lib/optimal_system_agent/agent/batch_cadence.ex:297-315 | lib/optimal_system_agent/agent/cost_observations.ex:137-155 | lib/optimal_system_agent/tools/builtins/file_edit/drift_guard.ex:231-249 | lib/optimal_system_agent/tools/file_state.ex:599-617 — 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 `lib/optimal_system_agent/agent/batch_cadence.ex:297` 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 (11 lines × 4) · ×1
  • Duplicated block (11 lines × 4) lib/optimal_system_agent/agent/loop/verification_evidence.ex:1195 — lib/optimal_system_agent/agent/loop/verification_evidence.ex:1195-1205 | lib/optimal_system_agent/security/anomaly_queue.ex:226-236 | lib/optimal_system_agent/security/class_queue.ex:217-227 | lib/optimal_system_agent/security/login_session.ex:389-399 — 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 `lib/optimal_system_agent/agent/loop/verification_evidence.ex:1195` 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 (6 lines × 4) · ×1
  • Duplicated block (6 lines × 4) lib/optimal_system_agent/security/code_fix_store.ex:16 — lib/optimal_system_agent/security/code_fix_store.ex:16-21 | lib/optimal_system_agent/security/notes_store.ex:37-42 | lib/optimal_system_agent/security/playbook_store.ex:22-27 | lib/optimal_system_agent/security/steer_store.ex:17-22 — 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.
D4 · Code Duplication · Duplicated block (14 lines × 7) · ×1
  • Duplicated block (14 lines × 7) lib/optimal_system_agent/tools/builtins/file_glob/tool.ex:36 — lib/optimal_system_agent/tools/builtins/file_glob/tool.ex:36-49 | lib/optimal_system_agent/tools/builtins/session_search/tool.ex:50-63 | lib/optimal_system_agent/tools/builtins/sleep/tool.ex:31-45 | lib/optimal_system_agent/tools/builtins/tool_search/tool.ex:50-63 | lib/optimal_system_agent/tools/builtins/vault_inject.ex:19-32 | lib/optimal_system_agent/tools/builtins/web_fetch/tool.ex:37-50 | lib/optimal_system_agent/tools/builtins/web_search/tool.ex:37-50 — 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.
D4 · Code Duplication · Duplicated block (8 lines × 7) · ×1
  • Duplicated block (8 lines × 7) canopy/backend/lib/canopy_web/controllers/alert_controller.ex:67 — canopy/backend/lib/canopy_web/controllers/alert_controller.ex:67-74 | canopy/backend/lib/canopy_web/controllers/goal_controller.ex:81-88 | canopy/backend/lib/canopy_web/controllers/issue_controller.ex:115-122 | canopy/backend/lib/canopy_web/controllers/project_controller.ex:73-80 | canopy/backend/lib/canopy_web/controllers/schedule_controller.ex:83-90 | canopy/backend/lib/canopy_web/controllers/user_controller.ex:60-67 | canopy/backend/lib/canopy_web/controllers/workspace_controller.ex:91-98 — before extracting anything, compare `canopy/backend/lib/canopy_web/controllers/goal_controller.ex` and `canopy/backend/lib/canopy_web/controllers/project_controller.ex` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 34 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 `canopy/backend/lib/canopy_web/controllers/alert_controller.ex: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.
D4 · Code Duplication · Duplicated block (5 lines × 9) · ×1
  • Duplicated block (5 lines × 9) lib/optimal_system_agent/teams/manager.ex:386 — lib/optimal_system_agent/teams/manager.ex:386-390 | lib/optimal_system_agent/teams/nervous_system.ex:142-146 | lib/optimal_system_agent/teams/nervous_system.ex:174-178 | lib/optimal_system_agent/teams/nervous_system.ex:221-225 | lib/optimal_system_agent/teams/nervous_system.ex:280-284 | lib/optimal_system_agent/teams/nervous_system.ex:392-396 | lib/optimal_system_agent/teams/nervous_system.ex:456-460 | lib/optimal_system_agent/teams/nervous_system.ex:539-543 | lib/optimal_system_agent/teams/nervous_system.ex:649-653 — there are 9 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 9 sites; resolving a subset leaves the remainder to drift apart.
D4 · Code Duplication · Duplicated block (32–44 lines × 2) · ×1
  • Duplicated block (32–44 lines × 2) priv/rust/tui/src/app/event_loop.rs:3031 — priv/rust/tui/src/app/event_loop.rs:3031-3062 | priv/rust/tui/src/app/event_loop.rs:3150-3193 — 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 `priv/rust/tui/src/app/event_loop.rs:3031` 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–44 lines × 3) · ×1
  • Duplicated block (3–44 lines × 3) priv/rust/tui/src/dialogs/command_palette.rs:161 — priv/rust/tui/src/dialogs/command_palette.rs:161-204 | priv/rust/tui/src/dialogs/permissions.rs:464-466 | priv/rust/tui/src/dialogs/picker.rs:164-207 — before extracting anything, compare `priv/rust/tui/src/dialogs/command_palette.rs` and `priv/rust/tui/src/dialogs/picker.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 67 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 `priv/rust/tui/src/dialogs/command_palette.rs:161` 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: `priv/rust/tui/src/dialogs/permissions.rs:464` is reached only past a guard at line 378 that tests `area.width` and leaves the function early, and `priv/rust/tui/src/dialogs/command_palette.rs:161` reads `area.width` with no such check. What separates these copies is not which lines they run but which PRECONDITION they enforce, so one of them is operating on state the other one refuses. Decide which is intended BEFORE unifying them — extract the shared part and whichever copy is missing the check keeps running unchecked, and if the guard is the correct behaviour then that hole is already live.
D4 · Code Duplication · Duplicated block (34–35 lines × 2) · ×1
  • Duplicated block (34–35 lines × 2) priv/rust/tui/src/app/update.rs:1204 — priv/rust/tui/src/app/update.rs:1204-1238 | priv/rust/tui/src/app/update.rs:1450-1483 — 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 `priv/rust/tui/src/app/update.rs:1204` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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 (25–29 lines × 2) · ×1
  • Duplicated block (25–29 lines × 2) priv/rust/tui/src/app/handle_backend.rs:2387 — priv/rust/tui/src/app/handle_backend.rs:2387-2415 | priv/rust/tui/src/app/handle_backend.rs:2448-2472 — 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 `priv/rust/tui/src/app/handle_backend.rs:2387` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with 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 (19–23 lines × 5) · ×1
  • Duplicated block (19–23 lines × 5) priv/rust/tui/src/dialogs/memory_browser.rs:201 — priv/rust/tui/src/dialogs/memory_browser.rs:201-219 | priv/rust/tui/src/dialogs/permissions_manager.rs:254-276 | priv/rust/tui/src/dialogs/persona_picker.rs:233-255 | priv/rust/tui/src/dialogs/skills_browser.rs:305-327 | priv/rust/tui/src/dialogs/tools_browser.rs:281-303 — before extracting anything, compare `priv/rust/tui/src/dialogs/memory_browser.rs` and `priv/rust/tui/src/dialogs/permissions_manager.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 223 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 `priv/rust/tui/src/dialogs/memory_browser.rs:201` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (44 lines × 5) · ×1
  • Duplicated block (44 lines × 5) priv/rust/tui/src/dialogs/memory_browser.rs:95 — priv/rust/tui/src/dialogs/memory_browser.rs:95-138 | priv/rust/tui/src/dialogs/permissions_manager.rs:148-191 | priv/rust/tui/src/dialogs/persona_picker.rs:132-175 | priv/rust/tui/src/dialogs/skills_browser.rs:190-233 | priv/rust/tui/src/dialogs/tools_browser.rs:180-223 — before extracting anything, compare `priv/rust/tui/src/dialogs/memory_browser.rs` and `priv/rust/tui/src/dialogs/permissions_manager.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 223 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 `priv/rust/tui/src/dialogs/memory_browser.rs: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 (18–20 lines × 2) · ×1
  • Duplicated block (18–20 lines × 2) priv/rust/tui/src/tools/mod.rs:822 — priv/rust/tui/src/tools/mod.rs:822-841 | priv/rust/tui/src/tools/mod.rs:870-887 — 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 `priv/rust/tui/src/tools/mod.rs:822` 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 (19 lines × 10) · ×1
  • Duplicated block (19 lines × 10) priv/rust/tui/src/dialogs/channels_panel.rs:103 — priv/rust/tui/src/dialogs/channels_panel.rs:103-121 | priv/rust/tui/src/dialogs/doctor_panel.rs:159-177 | priv/rust/tui/src/dialogs/hooks_viewer.rs:130-148 | priv/rust/tui/src/dialogs/memory_browser.rs:108-126 | priv/rust/tui/src/dialogs/metrics_dashboard.rs:144-162 | priv/rust/tui/src/dialogs/permissions_manager.rs:161-179 | priv/rust/tui/src/dialogs/persona_picker.rs:145-163 | priv/rust/tui/src/dialogs/skills_browser.rs:203-221 | priv/rust/tui/src/dialogs/tasks_panel.rs:161-179 | priv/rust/tui/src/dialogs/tools_browser.rs:193-211 — before extracting anything, compare `priv/rust/tui/src/dialogs/channels_panel.rs` and `priv/rust/tui/src/dialogs/doctor_panel.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 137 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 `priv/rust/tui/src/dialogs/channels_panel.rs:103` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (17–18 lines × 3) · ×1
  • Duplicated block (17–18 lines × 3) priv/rust/tui/src/render/markdown.rs:2203 — priv/rust/tui/src/render/markdown.rs:2203-2220 | priv/rust/tui/src/render/markdown.rs:2257-2273 | priv/rust/tui/src/render/markdown.rs:2326-2343 — 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 `priv/rust/tui/src/render/markdown.rs:2203` 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 (14–18 lines × 2) · ×1
  • Duplicated block (14–18 lines × 2) priv/rust/tui/src/app/handle_actions.rs:1316 — priv/rust/tui/src/app/handle_actions.rs:1316-1333 | priv/rust/tui/src/app/handle_dialogs.rs:1367-1380 — 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 `priv/rust/tui/src/app/handle_actions.rs:1316` 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 first that the copies are not typed on the same thing: the declarations holding them bind `self` to `crate) fn foreground_task(&mut` in one and `&mut` 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, `priv/rust/tui/src/app/handle_dialogs.rs:1381` calls `recompute_layout` and `priv/rust/tui/src/app/handle_actions.rs:1334` 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 (13–17 lines × 9) · ×1
  • Duplicated block (13–17 lines × 9) priv/rust/tui/src/dialogs/channels_panel.rs:180 — priv/rust/tui/src/dialogs/channels_panel.rs:180-196 | priv/rust/tui/src/dialogs/doctor_panel.rs:250-266 | priv/rust/tui/src/dialogs/mcp_servers.rs:182-198 | priv/rust/tui/src/dialogs/memory_browser.rs:213-225 | priv/rust/tui/src/dialogs/permissions_manager.rs:268-284 | priv/rust/tui/src/dialogs/persona_picker.rs:247-263 | priv/rust/tui/src/dialogs/skills_browser.rs:319-335 | priv/rust/tui/src/dialogs/tasks_panel.rs:259-275 | priv/rust/tui/src/dialogs/tools_browser.rs:295-311 — before extracting anything, compare `priv/rust/tui/src/dialogs/channels_panel.rs` and `priv/rust/tui/src/dialogs/doctor_panel.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 137 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 `priv/rust/tui/src/dialogs/channels_panel.rs:180` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (11–16 lines × 3) · ×1
  • Duplicated block (11–16 lines × 3) priv/rust/tui/src/app/update.rs:1009 — priv/rust/tui/src/app/update.rs:1009-1019 | priv/rust/tui/src/app/update.rs:1210-1225 | priv/rust/tui/src/app/update.rs:1456-1471 — 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 `priv/rust/tui/src/app/update.rs:1009` 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 after the matched lines, `priv/rust/tui/src/app/update.rs:1021` calls `prune_orphaned_attachments` and `priv/rust/tui/src/app/update.rs:1226` 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 (10–16 lines × 2) · ×1
  • Duplicated block (10–16 lines × 2) priv/rust/tui/src/app/handle_actions.rs:343 — priv/rust/tui/src/app/handle_actions.rs:343-352 | priv/rust/tui/src/app/handle_actions.rs:376-391 — 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 `priv/rust/tui/src/app/handle_actions.rs:343` 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 (15 lines × 3) · ×1
  • Duplicated block (15 lines × 3) priv/rust/tui/src/dialogs/skills_browser.rs:434 — priv/rust/tui/src/dialogs/skills_browser.rs:434-448 | priv/rust/tui/src/dialogs/tasks_panel.rs:356-370 | priv/rust/tui/src/dialogs/tools_browser.rs:380-394 — before extracting anything, compare `priv/rust/tui/src/dialogs/skills_browser.rs` and `priv/rust/tui/src/dialogs/tasks_panel.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 133 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 `priv/rust/tui/src/dialogs/skills_browser.rs:434` 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–21 lines × 2) · ×1
  • Duplicated block (20–21 lines × 2) priv/rust/tui/src/dialogs/onboarding.rs:1716 — priv/rust/tui/src/dialogs/onboarding.rs:1716-1735 | priv/rust/tui/src/dialogs/onboarding.rs:1747-1767 — 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 `priv/rust/tui/src/dialogs/onboarding.rs:1716` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (12–14 lines × 9) · ×1
  • Duplicated block (12–14 lines × 9) priv/rust/tui/src/dialogs/config_editor.rs:345 — priv/rust/tui/src/dialogs/config_editor.rs:345-356 | priv/rust/tui/src/dialogs/file_picker.rs:248-259 | priv/rust/tui/src/dialogs/model_picker.rs:1520-1531 | priv/rust/tui/src/dialogs/overdrive_confirm.rs:73-84 | priv/rust/tui/src/dialogs/plan_review.rs:128-140 | priv/rust/tui/src/dialogs/quit_confirm.rs:102-115 | priv/rust/tui/src/dialogs/reasoning.rs:164-175 | priv/rust/tui/src/dialogs/rewind.rs:148-159 | priv/rust/tui/src/dialogs/sessions.rs:268-279 — before extracting anything, compare `priv/rust/tui/src/dialogs/config_editor.rs` and `priv/rust/tui/src/dialogs/file_picker.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 30 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 `priv/rust/tui/src/dialogs/config_editor.rs:345` 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) · ×1
  • Duplicated block (11–14 lines × 2) priv/rust/tui/src/components/chat/mod.rs:628 — priv/rust/tui/src/components/chat/mod.rs:628-641 | priv/rust/tui/src/components/chat/mod.rs:661-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. Read the line range as the matched WINDOW rather than a finished unit: at `priv/rust/tui/src/components/chat/mod.rs:628` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, 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–12 lines × 17) · ×1
  • Duplicated block (11–12 lines × 17) priv/rust/tui/src/dialogs/channels_panel.rs:148 — priv/rust/tui/src/dialogs/channels_panel.rs:148-159 | priv/rust/tui/src/dialogs/context_breakdown.rs:175-186 | priv/rust/tui/src/dialogs/cost_dashboard.rs:248-259 | priv/rust/tui/src/dialogs/doctor_panel.rs:204-215 | priv/rust/tui/src/dialogs/hooks_viewer.rs:175-186 | priv/rust/tui/src/dialogs/keybindings_viewer.rs:125-136 | priv/rust/tui/src/dialogs/mcp_servers.rs:137-148 | priv/rust/tui/src/dialogs/memory_browser.rs:172-182 | priv/rust/tui/src/dialogs/metrics_dashboard.rs:189-200 | priv/rust/tui/src/dialogs/permissions_manager.rs:216-227 | priv/rust/tui/src/dialogs/persona_picker.rs:200-211 | priv/rust/tui/src/dialogs/sandbox_picker.rs:140-151 | priv/rust/tui/src/dialogs/skills_browser.rs:272-283 | priv/rust/tui/src/dialogs/status_dashboard.rs:117-128 | priv/rust/tui/src/dialogs/tasks_panel.rs:227-238 | priv/rust/tui/src/dialogs/theme_picker.rs:121-132 | priv/rust/tui/src/dialogs/tools_browser.rs:248-259 — before extracting anything, compare `priv/rust/tui/src/dialogs/channels_panel.rs` and `priv/rust/tui/src/dialogs/context_breakdown.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 36 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 `priv/rust/tui/src/dialogs/channels_panel.rs:148` 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 (11–12 lines × 5) · ×1
  • Duplicated block (11–12 lines × 5) priv/rust/tui/src/dialogs/channels_panel.rs:206 — priv/rust/tui/src/dialogs/channels_panel.rs:206-216 | priv/rust/tui/src/dialogs/doctor_panel.rs:282-292 | priv/rust/tui/src/dialogs/memory_browser.rs:239-249 | priv/rust/tui/src/dialogs/permissions_manager.rs:301-311 | priv/rust/tui/src/dialogs/persona_picker.rs:278-289 — before extracting anything, compare `priv/rust/tui/src/dialogs/channels_panel.rs` and `priv/rust/tui/src/dialogs/doctor_panel.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 137 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 `priv/rust/tui/src/dialogs/channels_panel.rs:206` 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 × 2) · ×1
  • Duplicated block (8–10 lines × 2) priv/rust/tui/src/render/markdown.rs:319 — priv/rust/tui/src/render/markdown.rs:319-326 | priv/rust/tui/src/render/markdown.rs:402-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. Read the line range as the matched WINDOW rather than a finished unit: at `priv/rust/tui/src/render/markdown.rs:319` 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 (9 lines × 18) · ×1
  • Duplicated block (9 lines × 18) priv/rust/tui/src/components/completion_panel.rs:327 — priv/rust/tui/src/components/completion_panel.rs:327-335 | priv/rust/tui/src/dialogs/channels_panel.rs:152-160 | priv/rust/tui/src/dialogs/context_breakdown.rs:179-187 | priv/rust/tui/src/dialogs/cost_dashboard.rs:252-260 | priv/rust/tui/src/dialogs/doctor_panel.rs:208-216 | priv/rust/tui/src/dialogs/hooks_viewer.rs:179-187 | priv/rust/tui/src/dialogs/keybindings_viewer.rs:129-137 | priv/rust/tui/src/dialogs/mcp_servers.rs:141-149 | priv/rust/tui/src/dialogs/memory_browser.rs:175-183 | priv/rust/tui/src/dialogs/metrics_dashboard.rs:193-201 | priv/rust/tui/src/dialogs/permissions_manager.rs:220-228 | priv/rust/tui/src/dialogs/persona_picker.rs:204-212 | priv/rust/tui/src/dialogs/sandbox_picker.rs:144-152 | priv/rust/tui/src/dialogs/skills_browser.rs:276-284 | priv/rust/tui/src/dialogs/status_dashboard.rs:121-129 | priv/rust/tui/src/dialogs/tasks_panel.rs:231-239 | priv/rust/tui/src/dialogs/theme_picker.rs:125-133 | priv/rust/tui/src/dialogs/tools_browser.rs:252-260 — before extracting anything, compare `priv/rust/tui/src/components/completion_panel.rs` and `priv/rust/tui/src/dialogs/cost_dashboard.rs` 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. 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 × 17) · ×1
  • Duplicated block (8 lines × 17) priv/rust/tui/src/dialogs/channels_panel.rs:137 — priv/rust/tui/src/dialogs/channels_panel.rs:137-144 | priv/rust/tui/src/dialogs/context_breakdown.rs:164-171 | priv/rust/tui/src/dialogs/cost_dashboard.rs:237-244 | priv/rust/tui/src/dialogs/doctor_panel.rs:193-200 | priv/rust/tui/src/dialogs/hooks_viewer.rs:164-171 | priv/rust/tui/src/dialogs/keybindings_viewer.rs:114-121 | priv/rust/tui/src/dialogs/mcp_servers.rs:126-133 | priv/rust/tui/src/dialogs/memory_browser.rs:161-168 | priv/rust/tui/src/dialogs/metrics_dashboard.rs:178-185 | priv/rust/tui/src/dialogs/permissions_manager.rs:205-212 | priv/rust/tui/src/dialogs/persona_picker.rs:189-196 | priv/rust/tui/src/dialogs/sandbox_picker.rs:129-136 | priv/rust/tui/src/dialogs/skills_browser.rs:261-268 | priv/rust/tui/src/dialogs/status_dashboard.rs:106-113 | priv/rust/tui/src/dialogs/tasks_panel.rs:216-223 | priv/rust/tui/src/dialogs/theme_picker.rs:110-117 | priv/rust/tui/src/dialogs/tools_browser.rs:237-244 — before extracting anything, compare `priv/rust/tui/src/dialogs/channels_panel.rs` and `priv/rust/tui/src/dialogs/context_breakdown.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 36 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 `priv/rust/tui/src/dialogs/channels_panel.rs: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.
D4 · Code Duplication · Duplicated block (8 lines × 6) · ×1
  • Duplicated block (8 lines × 6) priv/rust/tui/src/dialogs/channels_panel.rs:290 — priv/rust/tui/src/dialogs/channels_panel.rs:290-297 | priv/rust/tui/src/dialogs/hooks_viewer.rs:261-268 | priv/rust/tui/src/dialogs/mcp_servers.rs:247-254 | priv/rust/tui/src/dialogs/metrics_dashboard.rs:326-333 | priv/rust/tui/src/dialogs/tasks_panel.rs:384-391 | priv/rust/tui/src/dialogs/theme_picker.rs:256-263 — before extracting anything, compare `priv/rust/tui/src/dialogs/channels_panel.rs` and `priv/rust/tui/src/dialogs/hooks_viewer.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 73 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 `priv/rust/tui/src/dialogs/channels_panel.rs:290` 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 × 5) · ×1
  • Duplicated block (7–8 lines × 5) priv/rust/tui/src/dialogs/config_editor.rs:374 — priv/rust/tui/src/dialogs/config_editor.rs:374-381 | priv/rust/tui/src/dialogs/model_picker.rs:2006-2012 | priv/rust/tui/src/dialogs/reasoning.rs:184-191 | priv/rust/tui/src/dialogs/rewind.rs:168-174 | priv/rust/tui/src/dialogs/sessions.rs:322-329 — before extracting anything, compare `priv/rust/tui/src/dialogs/config_editor.rs` and `priv/rust/tui/src/dialogs/model_picker.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 42 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 `priv/rust/tui/src/dialogs/config_editor.rs:374` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (8 lines × 5) · ×1
  • Duplicated block (8 lines × 5) priv/rust/tui/src/dialogs/config_editor.rs:398 — priv/rust/tui/src/dialogs/config_editor.rs:398-405 | priv/rust/tui/src/dialogs/model_picker.rs:1715-1722 | priv/rust/tui/src/dialogs/model_picker.rs:2044-2051 | priv/rust/tui/src/dialogs/reasoning.rs:212-219 | priv/rust/tui/src/dialogs/sessions.rs:363-370 — before extracting anything, compare `priv/rust/tui/src/dialogs/config_editor.rs` and `priv/rust/tui/src/dialogs/model_picker.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 42 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 (3–7 lines × 19) · ×1
  • Duplicated block (3–7 lines × 19) priv/rust/tui/src/dialogs/channels_panel.rs:134 — priv/rust/tui/src/dialogs/channels_panel.rs:134-140 | priv/rust/tui/src/dialogs/context_breakdown.rs:161-167 | priv/rust/tui/src/dialogs/cost_dashboard.rs:234-240 | priv/rust/tui/src/dialogs/doctor_panel.rs:190-196 | priv/rust/tui/src/dialogs/hooks_viewer.rs:161-167 | priv/rust/tui/src/dialogs/keybindings_viewer.rs:111-117 | priv/rust/tui/src/dialogs/mcp_approval.rs:170-172 | priv/rust/tui/src/dialogs/mcp_servers.rs:123-129 | priv/rust/tui/src/dialogs/memory_browser.rs:159-164 | priv/rust/tui/src/dialogs/metrics_dashboard.rs:175-181 | priv/rust/tui/src/dialogs/permissions_manager.rs:202-208 | priv/rust/tui/src/dialogs/persona_picker.rs:186-192 | priv/rust/tui/src/dialogs/sandbox_picker.rs:126-132 | priv/rust/tui/src/dialogs/skills_browser.rs:258-264 | priv/rust/tui/src/dialogs/status_dashboard.rs:103-109 | priv/rust/tui/src/dialogs/tasks_panel.rs:213-219 | priv/rust/tui/src/dialogs/theme_picker.rs:107-113 | priv/rust/tui/src/dialogs/tools_browser.rs:234-240 | priv/rust/tui/src/dialogs/trust.rs:83-89 — before extracting anything, compare `priv/rust/tui/src/dialogs/channels_panel.rs` and `priv/rust/tui/src/dialogs/context_breakdown.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 36 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. 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, `priv/rust/tui/src/dialogs/sandbox_picker.rs:125` calls `saturating_sub` and `priv/rust/tui/src/dialogs/mcp_approval.rs:170` 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 (7 lines × 5) · ×1
  • Duplicated block (7 lines × 5) priv/rust/tui/src/dialogs/doctor_panel.rs:302 — priv/rust/tui/src/dialogs/doctor_panel.rs:302-308 | priv/rust/tui/src/dialogs/memory_browser.rs:258-264 | priv/rust/tui/src/dialogs/persona_picker.rs:301-307 | priv/rust/tui/src/dialogs/tasks_panel.rs:337-343 | priv/rust/tui/src/dialogs/tools_browser.rs:356-362 — before extracting anything, compare `priv/rust/tui/src/dialogs/doctor_panel.rs` and `priv/rust/tui/src/dialogs/memory_browser.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 145 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 `priv/rust/tui/src/dialogs/doctor_panel.rs:302` 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, `priv/rust/tui/src/dialogs/tools_browser.rs:363` calls `truncate_chars`, `saturating_sub`, `cols` and `priv/rust/tui/src/dialogs/tasks_panel.rs:344` 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–7 lines × 2) · ×1
  • Duplicated block (5–7 lines × 2) priv/rust/tui/src/dialogs/channels_panel.rs:248 — priv/rust/tui/src/dialogs/channels_panel.rs:248-252 | priv/rust/tui/src/dialogs/doctor_panel.rs:307-313 — before extracting anything, compare `priv/rust/tui/src/dialogs/channels_panel.rs` and `priv/rust/tui/src/dialogs/doctor_panel.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 137 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 `priv/rust/tui/src/dialogs/channels_panel.rs:248` 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 (5 lines × 7) · ×1
  • Duplicated block (5 lines × 7) priv/rust/tui/src/dialogs/config_editor.rs:380 — priv/rust/tui/src/dialogs/config_editor.rs:380-384 | priv/rust/tui/src/dialogs/file_picker.rs:309-313 | priv/rust/tui/src/dialogs/model_picker.rs:1640-1644 | priv/rust/tui/src/dialogs/model_picker.rs:2011-2015 | priv/rust/tui/src/dialogs/reasoning.rs:190-194 | priv/rust/tui/src/dialogs/rewind.rs:173-177 | priv/rust/tui/src/dialogs/sessions.rs:328-332 — before extracting anything, compare `priv/rust/tui/src/dialogs/config_editor.rs` and `priv/rust/tui/src/dialogs/file_picker.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 30 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 (5 lines × 6) · ×1
  • Duplicated block (5 lines × 6) priv/rust/tui/src/dialogs/config_editor.rs:375 — priv/rust/tui/src/dialogs/config_editor.rs:375-381 | priv/rust/tui/src/dialogs/model_picker.rs:1959-1963 | priv/rust/tui/src/dialogs/model_picker.rs:2007-2012 | priv/rust/tui/src/dialogs/reasoning.rs:185-191 | priv/rust/tui/src/dialogs/rewind.rs:169-174 | priv/rust/tui/src/dialogs/sessions.rs:323-329 — before extracting anything, compare `priv/rust/tui/src/dialogs/config_editor.rs` and `priv/rust/tui/src/dialogs/model_picker.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 42 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 `priv/rust/tui/src/dialogs/config_editor.rs:375` 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 (5 lines × 4) · ×1
  • Duplicated block (5 lines × 4) priv/rust/tui/src/dialogs/channels_panel.rs:98 — priv/rust/tui/src/dialogs/channels_panel.rs:98-102 | priv/rust/tui/src/dialogs/hooks_viewer.rs:125-129 | priv/rust/tui/src/dialogs/metrics_dashboard.rs:139-143 | priv/rust/tui/src/dialogs/tasks_panel.rs:156-160 — before extracting anything, compare `priv/rust/tui/src/dialogs/channels_panel.rs` and `priv/rust/tui/src/dialogs/hooks_viewer.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 73 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 `priv/rust/tui/src/dialogs/channels_panel.rs:98` 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 (3–5 lines × 14) · ×1
  • Duplicated block (3–5 lines × 14) priv/rust/tui/src/dialogs/channels_panel.rs:131 — priv/rust/tui/src/dialogs/channels_panel.rs:131-133 | priv/rust/tui/src/dialogs/cost_dashboard.rs:231-233 | priv/rust/tui/src/dialogs/doctor_panel.rs:187-189 | priv/rust/tui/src/dialogs/hooks_viewer.rs:158-160 | priv/rust/tui/src/dialogs/mcp_servers.rs:120-122 | priv/rust/tui/src/dialogs/memory_browser.rs:156-158 | priv/rust/tui/src/dialogs/metrics_dashboard.rs:172-174 | priv/rust/tui/src/dialogs/onboarding.rs:1039-1043 | priv/rust/tui/src/dialogs/permissions_manager.rs:199-201 | priv/rust/tui/src/dialogs/persona_picker.rs:183-185 | priv/rust/tui/src/dialogs/reasoning.rs:150-154 | priv/rust/tui/src/dialogs/skills_browser.rs:255-257 | priv/rust/tui/src/dialogs/tasks_panel.rs:210-212 | priv/rust/tui/src/dialogs/tools_browser.rs:231-233 — before extracting anything, compare `priv/rust/tui/src/dialogs/channels_panel.rs` and `priv/rust/tui/src/dialogs/cost_dashboard.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 41 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 before the matched lines, `priv/rust/tui/src/dialogs/channels_panel.rs:131` calls `min` and `priv/rust/tui/src/dialogs/onboarding.rs:1039` 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 (28 lines × 2) · ×1
  • Duplicated block (28 lines × 2) priv/rust/tui/src/dialogs/skills_browser.rs:103 — priv/rust/tui/src/dialogs/skills_browser.rs:103-130 | priv/rust/tui/src/dialogs/tools_browser.rs:93-120 — before extracting anything, compare `priv/rust/tui/src/dialogs/skills_browser.rs` and `priv/rust/tui/src/dialogs/tools_browser.rs` as WHOLE FILES: this scan already matched 22 separate duplicated blocks between them, totalling at least 301 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 before the matched lines, `priv/rust/tui/src/dialogs/skills_browser.rs:98` calls `iter`, `any`, `to_lowercase` and `priv/rust/tui/src/dialogs/tools_browser.rs:88` 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 (10 lines × 10) · ×1
  • Duplicated block (10 lines × 10) priv/rust/tui/src/dialogs/channels_panel.rs:276 — priv/rust/tui/src/dialogs/channels_panel.rs:276-285 | priv/rust/tui/src/dialogs/doctor_panel.rs:342-351 | priv/rust/tui/src/dialogs/mcp_servers.rs:226-235 | priv/rust/tui/src/dialogs/memory_browser.rs:296-305 | priv/rust/tui/src/dialogs/permissions_manager.rs:372-381 | priv/rust/tui/src/dialogs/persona_picker.rs:342-351 | priv/rust/tui/src/dialogs/sandbox_picker.rs:270-280 | priv/rust/tui/src/dialogs/skills_browser.rs:448-457 | priv/rust/tui/src/dialogs/tasks_panel.rs:370-379 | priv/rust/tui/src/dialogs/tools_browser.rs:394-403 — before extracting anything, compare `priv/rust/tui/src/dialogs/channels_panel.rs` and `priv/rust/tui/src/dialogs/doctor_panel.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 137 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 `priv/rust/tui/src/dialogs/channels_panel.rs:276` 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 lines × 6) · ×1
  • Duplicated block (10 lines × 6) priv/rust/tui/src/dialogs/onboarding.rs:1229 — priv/rust/tui/src/dialogs/onboarding.rs:1229-1238 | priv/rust/tui/src/dialogs/onboarding.rs:1422-1431 | priv/rust/tui/src/dialogs/onboarding.rs:1492-1501 | priv/rust/tui/src/dialogs/onboarding.rs:1557-1566 | priv/rust/tui/src/dialogs/onboarding.rs:1709-1718 | priv/rust/tui/src/dialogs/onboarding.rs:1793-1802 — all 6 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, `priv/rust/tui/src/dialogs/onboarding.rs:1433` calls `is_empty` and `priv/rust/tui/src/dialogs/onboarding.rs:1568` 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 · Near-duplicate member pair (71 shared lines) · ×1
  • Near-duplicate member pair (71 shared lines) bench/swebench/run_bench.py:561 — bench/swebench/run_bench.py:561-672 | bench/swebenchpro/run_bench.py:489-592 — These two members are variants of one another: 71 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 (76 corresponding lines) · ×1
  • Edited copy of a member (76 corresponding lines) bench/swebench/run_bench.py:94 — bench/swebench/run_bench.py:94-184 | bench/swebenchpro/dataset.py:201-276 — These two members are one piece of code written twice and then edited apart: 76 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 · Duplicated block (5–8 lines × 2) · ×1
  • Duplicated block (5–8 lines × 2) lib/optimal_system_agent/bench/report.ex:108 — lib/optimal_system_agent/bench/report.ex:108-115 | lib/optimal_system_agent/bench/report.ex:254-258 — 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 (36–42 lines × 2) · ×1
  • Duplicated block (36–42 lines × 2) bench/swebench/run_bench.py:561 — bench/swebench/run_bench.py:561-602 | bench/swebenchpro/run_bench.py:489-524 — `bench/swebench/run_bench.py` and `bench/swebenchpro/run_bench.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 202 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–43 lines × 2) · ×1
  • Duplicated block (35–43 lines × 2) bench/swebench/run_bench.py:94 — bench/swebench/run_bench.py:94-136 | bench/swebenchpro/dataset.py:201-235 — 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 (19–26 lines × 2) · ×1
  • Duplicated block (19–26 lines × 2) bench/swebench/runners.py:252 — bench/swebench/runners.py:252-277 | bench/swebenchpro/runners.py:188-206 — 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 (17–19 lines × 2) · ×1
  • Duplicated block (17–19 lines × 2) bench/swebench/run_bench.py:520 — bench/swebench/run_bench.py:520-538 | bench/swebenchpro/run_bench.py:386-402 — `bench/swebench/run_bench.py` and `bench/swebenchpro/run_bench.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 202 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 `bench/swebench/run_bench.py:520` 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 (9–12 lines × 2) · ×1
  • Duplicated block (9–12 lines × 2) bench/swebench/airgap.py:610 — bench/swebench/airgap.py:610-621 | bench/swebench/cwd_audit.py:115-123 — 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 (8–10 lines × 3) · ×1
  • Duplicated block (8–10 lines × 3) bench/headtohead/report_h2h.py:85 — bench/headtohead/report_h2h.py:85-92 | bench/recoverybench/delta_report.py:219-226 | bench/terminalbench/report.py:814-823 — 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.
D44 · Platform End-of-Life · End-of-life runtime · ×1
  • End-of-life runtime: Erlang/OTP 26 .tool-versions:1 — .tool-versions declares Erlang/OTP 26 as this project's version file, and Erlang/OTP 26, left support (the last three OTP majors) when OTP 29 shipped on 2026-05-13. An unsupported runtime receives no security patches, so every vulnerability disclosed in it since 2026-05-13 is present and unfixable without moving off it. This is a migration rather than an upgrade: there is no newer release of a runtime that has ended.
P8 · Schema migrations · Schema created by runtime CREATE TABLE outside the migrations · ×1
  • Schema created by runtime CREATE TABLE outside the migrations lib/optimal_system_agent/security/defense_lab.ex:246 — This repository versions its schema (Ecto migrations), but runtime CREATE TABLE here builds or alters the schema from the model as well, outside that history — the two paths can disagree about the shape, and a change made this way is never a reviewed migration. Turn it off and let Ecto migrations own the schema.
SC1 · Supply-chain hygiene · JavaScript dependencies are not locked · ×1
  • JavaScript dependencies are not locked scripts/whatsapp-bridge/package.json:11 — scripts/whatsapp-bridge/package.json declares dependencies that no committed lockfile resolves — there is no package-lock.json / yarn.lock / pnpm-lock.yaml / bun.lock beside it, and no locked workspace above it names it — so its installs aren't reproducible (SSDF PW.4.4). Commit its package manager's lockfile (or add it to the locked workspace) and install from it (`npm ci`, `yarn --immutable`, `pnpm i --frozen-lockfile` or `bun i --frozen-lockfile`). Advisory — never scored.
Minor — 101 finding(s)
X10 · Duplicated predicate · Duplicated predicate · ×40
  • Duplicated predicate lib/mix/tasks/osa.setup.wizard.ex:319 — `:api_key in modes and Prompt.confirm("Use an API key instead?")` appears character-identically in 2 files — lib/mix/tasks/osa.setup.wizard.ex, lib/optimal_system_agent/cli/setup.ex. 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 lib/optimal_system_agent/providers/claude_cli.ex:116 — `Auth.installed?() and Auth.status().connected?` appears character-identically in 2 files — lib/optimal_system_agent/providers/claude_cli.ex, lib/optimal_system_agent/providers/copilot_cli.ex. 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 lib/optimal_system_agent/tools/builtins/ask_user/prompt.ex:33 — `Code.ensure_loaded?(mod) and function_exported?(mod, fun, 0)` appears character-identically in 32 files — lib/optimal_system_agent/tools/builtins/ask_user/prompt.ex, lib/optimal_system_agent/tools/builtins/bash_output/prompt.ex, lib/optimal_system_agent/tools/builtins/code_symbols/prompt.ex, lib/optimal_system_agent/tools/builtins/create_agent/prompt.ex. 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 lib/optimal_system_agent/security/symbol_resolver.ex:285 — `File.regular?(path) and MapSet.member?(exts, Path.extname(path))` appears character-identically in 2 files — lib/optimal_system_agent/security/symbol_resolver.ex, lib/optimal_system_agent/security/variant_analysis.ex. 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 lib/optimal_system_agent/providers/bedrock.ex:133 — `Keyword.get(opts, :model) || default_model()` appears character-identically in 4 files — lib/optimal_system_agent/providers/bedrock.ex, lib/optimal_system_agent/providers/claude_cli.ex, lib/optimal_system_agent/providers/copilot_cli.ex, lib/optimal_system_agent/providers/openai_codex.ex. 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 lib/optimal_system_agent/providers/openai_compat.ex:475 — `Keyword.get(opts, :prompt_cache_key) || Keyword.get(opts, :session_id)` appears character-identically in 2 files — lib/optimal_system_agent/providers/openai_compat.ex, lib/optimal_system_agent/providers/openai_responses.ex. 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 lib/optimal_system_agent/providers/fallback_chain.ex:276 — `Keyword.get(opts, :provider) || Application.get_env(:optimal_system_agent, :default_provider, :ollama)` appears character-identically in 2 files — lib/optimal_system_agent/providers/fallback_chain.ex, lib/optimal_system_agent/teams/manager.ex. 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 lib/optimal_system_agent/providers/anthropic.ex:1398 — `Keyword.get(opts, :reasoning_effort) || Keyword.get(opts, :effort) || current_effort()` appears character-identically in 4 files — lib/optimal_system_agent/providers/anthropic.ex, lib/optimal_system_agent/providers/google.ex, lib/optimal_system_agent/providers/openai_compat.ex, lib/optimal_system_agent/providers/openai_responses.ex. 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 lib/optimal_system_agent/security/oob.ex:69 — `Keyword.get(opts, :runner) || default_runner(opts)` appears character-identically in 2 files — lib/optimal_system_agent/security/oob.ex, lib/optimal_system_agent/security/proxy_capture.ex. 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 lib/optimal_system_agent/agent/fleet.ex:948 — `Keyword.get(opts, :working_dir) || OptimalSystemAgent.Workspace.Cwd.get()` appears character-identically in 2 files — lib/optimal_system_agent/agent/fleet.ex, lib/optimal_system_agent/agent/loop.ex. 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 lib/optimal_system_agent/agent/loop/doom_loop/stall.ex:371 — `Map.get(a, :name) == Map.get(b, :name) and Map.get(a, :arguments) == Map.get(b, :arguments)` appears character-identically in 3 files — lib/optimal_system_agent/agent/loop/doom_loop/stall.ex, lib/optimal_system_agent/agent/loop/regulation/homeostat.ex, lib/optimal_system_agent/agent/loop/regulation/signals.ex. 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 lib/optimal_system_agent/tools/builtins/message_agent/handler.ex:180 — `Map.get(args, "__session_id__") || (ctx && Map.get(ctx, :session_id)) || "unknown"` appears character-identically in 3 files — lib/optimal_system_agent/tools/builtins/message_agent/handler.ex, lib/optimal_system_agent/tools/builtins/scratchpad/handler.ex, lib/optimal_system_agent/tools/builtins/team_tasks/handler.ex. 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 lib/optimal_system_agent/agent/loop/tool_executor.ex:974 — `Map.get(args, "command") || Map.get(args, "code")` appears character-identically in 3 files — lib/optimal_system_agent/agent/loop/tool_executor.ex, lib/optimal_system_agent/agent/loop/verification_evidence.ex, lib/optimal_system_agent/permissions/auto_classifier.ex. 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 lib/optimal_system_agent/agent/loop/regulation/homeostat.ex:201 — `Map.get(args, "command") || Map.get(args, :command)` appears character-identically in 2 files — lib/optimal_system_agent/agent/loop/regulation/homeostat.ex, lib/optimal_system_agent/agent/turn_trace.ex. 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 lib/optimal_system_agent/agent/loop/goal_verifier.ex:1104 — `Map.get(e, :kind) == :write and Map.get(e, :success) == true` appears character-identically in 2 files — lib/optimal_system_agent/agent/loop/goal_verifier.ex, lib/optimal_system_agent/orchestrator.ex. 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 lib/mix/tasks/osa.lessons.ex:65 — `Map.get(entry, :content) || Map.get(entry, "content") || ""` appears character-identically in 2 files — lib/mix/tasks/osa.lessons.ex, lib/optimal_system_agent/memory/flush.ex. 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 lib/optimal_system_agent/security/threat_intel.ex:71 — `Map.get(finding, :cve) || Map.get(finding, "cve")` appears character-identically in 2 files — lib/optimal_system_agent/security/threat_intel.ex, lib/optimal_system_agent/security/weapon_catalog.ex. 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 lib/optimal_system_agent/security/exploit_generator.ex:71 — `Map.get(finding, :target) || Map.get(finding, "target", "unknown")` appears character-identically in 2 files — lib/optimal_system_agent/security/exploit_generator.ex, lib/optimal_system_agent/security/weapon_catalog.ex. 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 lib/optimal_system_agent/agent/loop.ex:3244 — `Map.get(m, :content) || Map.get(m, "content")` appears character-identically in 2 files — lib/optimal_system_agent/agent/loop.ex, lib/optimal_system_agent/orchestrator.ex. 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 lib/optimal_system_agent/channels/http/api/memory_routes.ex:97 — `Map.get(map, key) || Map.get(map, Atom.to_string(key))` appears character-identically in 8 files — lib/optimal_system_agent/channels/http/api/memory_routes.ex, lib/optimal_system_agent/security/anomaly_queue.ex, lib/optimal_system_agent/security/class_queue.ex, lib/optimal_system_agent/security/code_fix_pr.ex. 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 lib/optimal_system_agent/events/tui_forwarder.ex:197 — `Map.get(map, key) || Map.get(map, to_string(key))` appears character-identically in 3 files — lib/optimal_system_agent/events/tui_forwarder.ex, lib/optimal_system_agent/providers/openai_responses.ex, lib/optimal_system_agent/security/http_replay.ex. 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 lib/optimal_system_agent/agent/active_skills.ex:203 — `Map.get(message, :role) || Map.get(message, "role")` appears character-identically in 2 files — lib/optimal_system_agent/agent/active_skills.ex, lib/optimal_system_agent/agent/loop/transient_notes.ex. 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 lib/optimal_system_agent/agent/run_store.ex:1467 — `Map.get(meta, :parent_session_id) || "unknown"` appears character-identically in 2 files — lib/optimal_system_agent/agent/run_store.ex, lib/optimal_system_agent/orchestrator.ex. 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 lib/optimal_system_agent/agent/compaction_safety.ex:405 — `Map.get(msg, :content) || Map.get(msg, "content")` appears character-identically in 9 files — lib/optimal_system_agent/agent/compaction_safety.ex, lib/optimal_system_agent/agent/compactor.ex, lib/optimal_system_agent/agent/delegation_policy.ex, lib/optimal_system_agent/agent/loop/context_collapse.ex. 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 lib/optimal_system_agent/agent/loop/context_collapse.ex:59 — `Map.get(msg, :role) || Map.get(msg, "role")` appears character-identically in 5 files — lib/optimal_system_agent/agent/loop/context_collapse.ex, lib/optimal_system_agent/agent/loop/context_reduce.ex, lib/optimal_system_agent/agent/orchestrator/result_summarizer.ex, lib/optimal_system_agent/providers/history_sanitizer.ex. 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.
  • + 15 more in this group — see findings.md.
X7 · Silent fallback defaults · Silent fallback default in rescue · ×12
  • Silent fallback default in rescue lib/optimal_system_agent/bench.ex:99 — `configured` rescues `_` and answers `nil` — a failure becomes a plausible value and a silent behavior change with no trail. Log the exception or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be produced, say so in a comment at the clause or in the `@doc`, and the row stops firing.
  • Silent fallback default in rescue lib/optimal_system_agent/bench.ex:105 — `configured` rescues `_` and answers `nil` — a failure becomes a plausible value and a silent behavior change with no trail. Log the exception or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be produced, say so in a comment at the clause or in the `@doc`, and the row stops firing.
  • Silent fallback default in rescue lib/optimal_system_agent/bench.ex:132 — `git_sha` rescues `_` and answers `nil` — a failure becomes a plausible value and a silent behavior change with no trail. Log the exception or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be produced, say so in a comment at the clause or in the `@doc`, and the row stops firing.
  • Silent fallback default in rescue lib/optimal_system_agent/command_center.ex:231 — `init` rescues `ArgumentError` and answers `{:ok, %{}}` — a failure becomes a plausible value and a silent behavior change with no trail. Log the exception or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be produced, say so in a comment at the clause or in the `@doc`, and the row stops firing.
  • Silent fallback default in rescue lib/optimal_system_agent/event_stream.ex:76 — `event_history` rescues `ArgumentError` and answers `[]` — a failure becomes a plausible value and a silent behavior change with no trail. Log the exception or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be produced, say so in a comment at the clause or in the `@doc`, and the row stops firing.
  • Silent fallback default in rescue lib/optimal_system_agent/git.ex:173 — `probe_dir` rescues `_` and answers `"."` — a failure becomes a plausible value and a silent behavior change with no trail. Log the exception or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be produced, say so in a comment at the clause or in the `@doc`, and the row stops firing.
  • Silent fallback default in rescue lib/optimal_system_agent/git.ex:218 — `probe_drivers` rescues `_` and answers `[]` — a failure becomes a plausible value and a silent behavior change with no trail. Log the exception or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be produced, say so in a comment at the clause or in the `@doc`, and the row stops firing.
  • Silent fallback default in rescue lib/optimal_system_agent/git.ex:250 — `cached_drivers` rescues `_` and answers `:miss` — a failure becomes a plausible value and a silent behavior change with no trail. Log the exception or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be produced, say so in a comment at the clause or in the `@doc`, and the row stops firing.
  • Silent fallback default in rescue lib/optimal_system_agent/machines.ex:107 — `determine_active_machines` rescues `ArgumentError` and answers `nil` — a failure becomes a plausible value and a silent behavior change with no trail. Log the exception or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be produced, say so in a comment at the clause or in the `@doc`, and the row stops firing.
  • Silent fallback default in rescue lib/optimal_system_agent/onboarding.ex:133 — `live_env` rescues `_` and answers `nil` — a failure becomes a plausible value and a silent behavior change with no trail. Log the exception or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be produced, say so in a comment at the clause or in the `@doc`, and the row stops firing.
  • Silent fallback default in rescue lib/optimal_system_agent/onboarding.ex:200 — `detect_subscriptions` rescues `_` and answers `[]` — a failure becomes a plausible value and a silent behavior change with no trail. Log the exception or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be produced, say so in a comment at the clause or in the `@doc`, and the row stops firing.
  • Silent fallback default in rescue lib/optimal_system_agent/onboarding.ex:664 — `auth_modes` rescues `_` and answers `[:api_key]` — a failure becomes a plausible value and a silent behavior change with no trail. Log the exception or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be produced, say so in a comment at the clause or in the `@doc`, and the row stops firing.
X7 · Silent fallback defaults · Silent fallback default on error · ×10
  • Silent fallback default on error lib/optimal_system_agent/bench.ex:113 — `osa_version` matches `_` and answers `nil` — a failure becomes a plausible value and a silent behavior change with no trail. Log the reason or return the `{:error, reason}` tuple. If that constant is the correct answer rather than a stand-in for a value that could not be produced, say so in a comment at the clause or in the `@doc`, and the row stops firing.
  • Silent fallback default on error lib/optimal_system_agent/config_file.ex:184 — `read_json` matches `_` and answers `%{}` — a failure becomes a plausible value and a silent behavior change with no trail. Log the reason or return the `{:error, reason}` tuple. If that constant is the correct answer rather than a stand-in for a value that could not be produced, say so in a comment at the clause or in the `@doc`, and the row stops firing.
  • Silent fallback default on error lib/optimal_system_agent/config_file.ex:194 — `toml_overlay` matches `false` and answers `%{}` — a failure becomes a plausible value and a silent behavior change with no trail. Log the reason or return the `{:error, reason}` tuple. If that constant is the correct answer rather than a stand-in for a value that could not be produced, say so in a comment at the clause or in the `@doc`, and the row stops firing.
  • Silent fallback default on error lib/optimal_system_agent/config_file.ex:391 — `default_template` matches `_` and answers `"# OSA configuration\n# See docs/configuration.md\n"` — a failure becomes a plausible value and a silent behavior change with no trail. Log the reason or return the `{:error, reason}` tuple. If that constant is the correct answer rather than a stand-in for a value that could not be produced, say so in a comment at the clause or in the `@doc`, and the row stops firing.
  • Silent fallback default on error lib/optimal_system_agent/local_models.ex:355 — `fit_per_quant` matches `_` and answers `[]` — a failure becomes a plausible value and a silent behavior change with no trail. Log the reason or return the `{:error, reason}` tuple. If that constant is the correct answer rather than a stand-in for a value that could not be produced, say so in a comment at the clause or in the `@doc`, and the row stops firing.
  • Silent fallback default on error lib/optimal_system_agent/local_models.ex:396 — `install` matches `_` and answers `nil` — a failure becomes a plausible value and a silent behavior change with no trail. Log the reason or return the `{:error, reason}` tuple. If that constant is the correct answer rather than a stand-in for a value that could not be produced, say so in a comment at the clause or in the `@doc`, and the row stops firing.
  • Silent fallback default on error lib/optimal_system_agent/local_models.ex:527 — `installed_size` matches `_` and answers `0` — a failure becomes a plausible value and a silent behavior change with no trail. Log the reason or return the `{:error, reason}` tuple. If that constant is the correct answer rather than a stand-in for a value that could not be produced, say so in a comment at the clause or in the `@doc`, and the row stops firing.
  • Silent fallback default on error lib/optimal_system_agent/local_models.ex:624 — `read_bench` matches `_` and answers `%{}` — a failure becomes a plausible value and a silent behavior change with no trail. Log the reason or return the `{:error, reason}` tuple. If that constant is the correct answer rather than a stand-in for a value that could not be produced, say so in a comment at the clause or in the `@doc`, and the row stops firing.
  • Silent fallback default on error lib/optimal_system_agent/machines.ex:84 — `load_config` matches `{:error, _}` and answers `%{}` — a failure becomes a plausible value and a silent behavior change with no trail. Log the reason or return the `{:error, reason}` tuple. If that constant is the correct answer rather than a stand-in for a value that could not be produced, say so in a comment at the clause or in the `@doc`, and the row stops firing.
  • Silent fallback default on error lib/optimal_system_agent/memory.ex:456 — `maybe_embed_query` matches `{:error, _reason}` and answers `nil` — a failure becomes a plausible value and a silent behavior change with no trail. Log the reason or return the `{:error, reason}` tuple. If that constant is the correct answer rather than a stand-in for a value that could not be produced, say so in a comment at the clause or in the `@doc`, and the row stops firing.
X7 · Silent fallback defaults · Silent fallback default on parse failure · ×8
  • Silent fallback default on parse failure bench/recoverybench/delta_report.py:198 — `_replay_manifest` 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 bench/recoverybench/delta_report.py:206 — `_trial_meta` 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 bench/swebench/osa_runner.py:161 — `read_spend` returns `{}` when `(json.JSONDecodeError, OSError)` 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 bench/swebench/osa_runner.py:388 — `unseed_permission_modes` returns `0` when `(json.JSONDecodeError, OSError)` 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 bench/swebench/report.py:190 — `_instance_detail` returns `{}` when `(json.JSONDecodeError, OSError)` 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 bench/swebench/workspace.py:111 — `default_test_args` returns `''` when `(json.JSONDecodeError, KeyError, TypeError)` 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 bench/swebenchpro/dataset.py:169 — `_literal_list` returns `[]` when `(ValueError, SyntaxError)` 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 test/headless/stub_provider.py:146 — `_body` 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.
D29 · Static Analysis (SAST) · REDACTED · ×7
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
X7 · Silent fallback defaults · Silent fallback default on Err · ×6
  • Silent fallback default on Err priv/rust/tui/src/app/exit_dump.rs:139 — `render` turns every `Err` into `Vec::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err priv/rust/tui/src/app/handle_actions.rs:2695 — `port_from_base_url` turns every `Err` into `"9089".to_string()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err priv/rust/tui/src/config/mod.rs:271 — `default_base_url` turns every `Err` into `"http://localhost:9089".to_string()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err priv/rust/tui/src/tools/diagnostics.rs:109 — `parse_diagnostics` turns every `Err` into `Vec::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err priv/rust/tui/src/tools/web.rs:312 — `parse_json_hits` turns every `Err` into `Vec::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err priv/rust/tui/src/util.rs:338 — `arg_summary` turns every `Err` into `String::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. 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 arm or in the doc comment, and the row stops firing.
X7 · Silent fallback defaults · Silent fallback default in catch · ×4
  • Silent fallback default in catch bench/recoverybench/run_bench.py:107 — `harbor_version` 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 bench/terminalbench/controls.py:87 — `_harbor_version` 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 REDACTED:176 — `harbor_version` 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 REDACTED:229 — `read_task_meta` 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.
M4 · Documentation accuracy · README/code drift · ×3
  • README/code drift docs/foundation-core/README.md:135 — docs/foundation-core/README.md links to `../architecture/`, but `docs/architecture` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
  • README/code drift docs/operations/README.md:8 — docs/operations/README.md links to `debugging-journal.md`, but `docs/operations/debugging-journal.md` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
  • README/code drift docs/backend/channels/README.md:48 — docs/backend/channels/README.md links to `../../architecture/README.md`, but `docs/architecture/README.md` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
C2 · Access Controls · No named authorization policies · ×1
  • No named authorization policies — Authorization IS enforced here (by imperative guard methods that throw on violation) — this is NOT a claim that the code is unprotected. What's missing is a NAMED rule set: the guards encode the access rules inline, so the rules can't be listed, reviewed or tested apart from the call sites that apply them. Recommendation, not a defect.
D28 · Secrets (history) · Rotate the exposed credentials · ×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
ED3 · Event naming · Event not named in past tense · ×1
  • Event not named in past tense: CancelTimeout priv/rust/tui/src/event/backend.rs:15 — `CancelTimeout` is an imperative name inside a domain-event set whose siblings are past-tense facts — it reads as an intent, not something that happened. Name new events for the fact that occurred (e.g. `ItemAdded`). Do not rename this one if it is already stored or published: its type name is written with every event recorded under it, so a rename can break replay of the stored stream and every subscriber that reads it, and a clearer name does not pay for that. If it has never been written or sent, renaming it now is safe.
P2 · Observability · Logging is not universal · ×1
  • Logging is not universal — Only 3/7 runnable modules use logging (modules with no entry point or server are excluded — they are libraries a runnable module hosts). Silent: `.`, `.`, `native/linux/ScreenShare`, `native/macos/ScreenShare`.
P3 · Security & performance tooling · No dependency-update automation · ×1
  • No dependency-update automation scripts/whatsapp-bridge/package.json:11 — `scripts/whatsapp-bridge/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`.
P4 · Deployment & Rollback · No release approval gate · ×1
  • No release approval gate REDACTED:452 — Deployment is automated and no gate that pauses it for a human is DECLARED IN THIS REPOSITORY'S PIPELINE FILES. What was read: every file under `.github/workflows/`, `.forgejo/workflows/`, `.gitea/workflows/`, `.azuredevops/` and `.azure-pipelines/`, plus `.gitlab-ci*` and `azure-pipelines*` — with comment text stripped, so documenting a gate is not declaring one. What would have counted: GitLab's `when: manual`, CircleCI's `type: approval`, an Azure `ManualValidation@` task or an `approvals:` block, a Jenkins `input` step, a `uses:` step naming an approval action, an `environment:` paired with `reviewers` / `required_reviewers` / `protection` / `wait-timer` / `deployment_branch_policy`, a draft-release step, a `workflow_dispatch` promotion, or a release-event gate. ★ What this cannot see, because none of it is a file: a GitHub environment whose required reviewers are configured in repo SETTINGS, a branch protection rule, or an organisation deployment policy — all of them real, enforced gates that live outside the repository. If yours is one of those, this row is wrong and nothing in the tree could have told us. Otherwise: whatever reaches the release trigger goes to production unreviewed, so a mistaken merge or tag is live before anyone can stop it.
X9 · Subsumed condition operand · Subsumed condition operand · ×1
  • Subsumed condition operand priv/rust/tui/src/render/colors.rs:68 — `term.contains("256color")` can never decide this `||` — every value satisfying `term.contains("256color")` also satisfies `term.contains("256")`, so the `||` chain is already decided by the latter. The expression is equivalent to the chain without it, which means it is wider than it reads. Delete the dead operand, or narrow the surviving one if IT is the accident.
Minor — 8 finding(s)
D12 · Dependency Hygiene · Outdated · ×8
  • Outdated: bandit — `:bandit` is locked at 1.10.3 but 1.15.0 is the current stable release on hex.pm, and it already satisfies the `"~> 1.5"` requirement declared in canopy/backend/mix.exs — so the lockfile is behind this repository's own declared range. Run `mix deps.update bandit` and commit the updated REDACTED.
  • Outdated: ecto_sql — `:ecto_sql` is locked at 3.13.5 but 3.14.0 is the current stable release on hex.pm, and it already satisfies the `"~> 3.13"` requirement declared in canopy/backend/mix.exs — so the lockfile is behind this repository's own declared range. Run `mix deps.update ecto_sql` and commit the updated REDACTED.
  • Outdated: guardian — `:guardian` is locked at 2.4.0 but 2.5.0 is the current stable release on hex.pm, and it already satisfies the `"~> 2.3"` requirement declared in canopy/backend/mix.exs — so the lockfile is behind this repository's own declared range. Run `mix deps.update guardian` and commit the updated REDACTED.
  • Outdated: jason — `:jason` is locked at 1.4.4 but 1.4.5 is the current stable release on hex.pm, and it already satisfies the `"~> 1.2"` requirement declared in canopy/backend/mix.exs — so the lockfile is behind this repository's own declared range. Run `mix deps.update jason` and commit the updated REDACTED.
  • Outdated: phoenix — `:phoenix` is locked at 1.8.5 but 1.8.16 is the current stable release on hex.pm, and it already satisfies the `"~> 1.8.5"` requirement declared in canopy/backend/mix.exs — so the lockfile is behind this repository's own declared range. Run `mix deps.update phoenix` and commit the updated REDACTED.
  • Outdated: postgrex — `:postgrex` is locked at 0.22.0 but 0.22.4 is the current stable release on hex.pm, and it already satisfies the `">= 0.0.0"` requirement declared in canopy/backend/mix.exs — so the lockfile is behind this repository's own declared range. Run `mix deps.update postgrex` and commit the updated REDACTED.
  • Outdated: req — `:req` is locked at 0.5.17 but 0.7.5 is the current stable release on hex.pm, and it already satisfies the `"~> 0.5"` requirement declared in canopy/backend/mix.exs — so the lockfile is behind this repository's own declared range. Run `mix deps.update req` and commit the updated REDACTED.
  • Outdated: telemetry_metrics — `:telemetry_metrics` is locked at 1.1.0 but 1.2.0 is the current stable release on hex.pm, and it already satisfies the `"~> 1.0"` requirement declared in canopy/backend/mix.exs — so the lockfile is behind this repository's own declared range. Run `mix deps.update telemetry_metrics` and commit the updated REDACTED.

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 --log-opts "--full-history --all --skip=0 --max-count=200" --report-format json --report-path /tmp/watchdog-gitleaks-61d7d0ffaa0a4af69bc538333f2db0c4/history.json --exit-code 0 --source .0artifacts/raw/gitleaks-history.json
D28 · Secrets (history)gitleaks—gitleaks detect --no-banner --config /opt/gitleaks-rules/canine-gitleaks.toml --log-opts "--full-history --all --skip=200 --max-count=800" --report-format json --report-path /tmp/watchdog-gitleaks-61d7d0ffaa0a4af69bc538333f2db0c4/history-1.json --exit-code 0 --source .1artifacts/raw/gitleaks-history-1.json
D28 · Secrets (history)gitleaks—gitleaks detect --no-banner --config /opt/gitleaks-rules/canine-gitleaks.toml --log-opts "--full-history --all --skip=1000 --max-count=619" --report-format json --report-path /tmp/watchdog-gitleaks-61d7d0ffaa0a4af69bc538333f2db0c4/history-2.json --exit-code 0 --source .0artifacts/raw/gitleaks-history-2.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-61d7d0ffaa0a4af69bc538333f2db0c4/tree.json --exit-code 0 --source .1artifacts/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 .71artifacts/raw/semgrep.json
D30 · Dependency Vulnerabilitiestrivy—trivy fs --scanners vuln --format json --quiet --severity CRITICAL,HIGH,MEDIUM,LOW --skip-dirs **/bin/** --skip-dirs **/obj/** .54artifacts/raw/trivy-fs.json
D31 · IaC & Container Securitytrivy—trivy config --format json --quiet .13artifacts/raw/trivy-config.json
D32 · Data Compliance (PII/GDPR)semgrep—semgrep --config /opt/semgrep-rules/gdpr.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 .1artifacts/raw/semgrep-gdpr.json
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/** .0artifacts/raw/trivy-fs.json

Run 01a1e710-104d-7264-9600-0ed367e16e91 · 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