Public report of akitaonrails/ai-memory, published 14 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 reportMeasured 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, 14 November 2026, 18:04 UTC · Survey ID cd_5c0f02b1768d4aecabeed3d48baea7f7
akitaonrails/ai-memory
Measured 14 November 2026, 18:03 UTC, at code version 73f6ccd
CAI scoreAt riskUp 3 since the last survey
The score is built from these lenses. Each lens grades one area of the code, such as how easy it is to change or how well it is protected. The weakest lens counts most, so one weak area pulls the score down instead of being averaged away.
A large codebase: 498,897 lines of product code in 19 projects, tests not counted · Estimated rebuild effort: about 5.4 person-years · Weakest lens: Code Health, 64
Findings by how serious they are
21 critical1621 serious100 minor
13 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
Canine Code Analyzer
Producer
Canine Development
Analyzer
Canine Code Analyzer engine 1.0.0
Measured
14 November 2026, 18:03 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 ▸
76of 76 dimensions measured by tools.
1705of 1742 findings point to an exact file and line, so you can open each one in the code. The other 37 concern the repository as a whole, such as missing documentation.
76dimensions across 7 lenses, read from 498,897 lines of product code in 19 projects.
akitaonrails/ai-memory is rated At risk because critical security findings are open, most of them in the build pipeline. It scores 68 out of 100, which the At risk rating leaves unchanged.
Code Health, at 64, is the weakest lens by a small margin, and the weakest lens counts most in the score. The best first step is splitting the oversized files, worth about 3 points. Removing the copied code comes next, worth about 2 points.
Six pipeline steps run downloads nobody checks. Three weaknesses in the code could be used by an attacker, and three settings leave the servers or containers unsafe. Checking each download against a checksum, fixing the weaknesses the scanner points to and correcting the unsafe settings would close these risks. Passing outside input through environment variables would fix the two pipeline steps that put outside input straight into a shell command, and the two pipeline steps that install packages without pinning their versions need the packages they install pinned to exact versions. The label or group of fields with no name needs connecting to its fields or naming.
The product code is 498,897 lines, about €780,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 forThe 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.
The weakest lenses score close to each other, so improving any of them moves the score.
Code composition: what the lines of code are
Product code 79%Tests 21%
New since the last survey: 730 findings
These 730 critical or serious findings weren't in the previous survey, on 27 October 2026. The first 100 are listed here, and the findings file in the download package lists them all.
God Classes · FunctionTooLong: ai_memory_store::ops::merge_project crates/ai-memory-store/src/ops.rs
God Classes · FunctionTooLong: ai_memory_web::features::states crates/ai-memory-web/src/features.rs
God Classes · FunctionTooLong: ai_memory_web::routes::inbox::handler crates/ai-memory-web/src/routes/inbox.rs
God Classes · FunctionTooLong: ai_memory_web::routes::project::render crates/ai-memory-web/src/routes/project.rs
God Classes · MethodTooLong: Consolidator.consolidate_session_multi_in_scope crates/ai-memory-consolidate/src/consolidator.rs
God Classes · FunctionTooLong: ai_memory_cli::commands::session_usage::read_live_calls crates/ai-memory-cli/src/commands/session_usage.rs
God Classes · MethodTooLong: AiMemoryServer.memory_write_pages_batch crates/ai-memory-mcp/src/server.rs
God Classes · FunctionTooLong: ai_memory_web::health::localized_checks crates/ai-memory-web/src/health.rs
God Classes · FileTooLong: src/claude_mem.rs companions/ai-memory-importer/src/claude_mem.rs
God Classes · FunctionTooLong: ai_memory_web::knowledge::view crates/ai-memory-web/src/knowledge.rs
God Classes · FunctionTooLong: ai_memory_cli::dispatch crates/ai-memory-cli/src/lib.rs
God Classes · FunctionTooLong: ai_memory_importer::agentmemory::apply_pages_batched companions/ai-memory-importer/src/agentmemory/mod.rs
God Classes · MethodTooLong: Consolidator.consolidate_session_in_scope crates/ai-memory-consolidate/src/consolidator.rs
God Classes · FunctionTooLong: ai_memory_cli::commands::restore::stage_then_swap crates/ai-memory-cli/src/commands/restore.rs
God Classes · FunctionTooLong: ai_memory_web::operations::usage_panel crates/ai-memory-web/src/operations.rs
God Classes · MethodTooLong: AiMemoryServer.memory_message_send crates/ai-memory-mcp/src/server.rs
We compare every finding with the previous survey's. A finding that has only moved to another line in the same file counts as the same finding, so only new findings appear here. Advisory notes from the AI model are left out, because the model words them afresh in every survey.
Fixed since the last survey: 173 findings
These 173 critical or serious findings were in the previous survey, on 27 October 2026, and are gone from this one. The first 100 are listed here.
€260,000 to €1,300,000, for 4,332 to 13,744 hours of work, about 5.4 person-years for 3 to 11 engineers
Difficulty of the problem
Standard, 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
×1.0 at a score of 68. 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.
Size
Large: 498,897 lines of product code
What it is not
Not a quotation: nobody has offered to build it for that. Not a valuation: it says nothing about what the business is worth. Not a certified figure: no professional has signed it as one.
How the estimate is made: We price the hours a team would need to write this code again, at €60 to €95 an hour. Declarations and boilerplate are priced at a fast rate and logic at a slower one, and the logic is then multiplied by the difficulty of the problem and by the quality factor. The estimate can be about 30% off either way, and it moves most with the hourly rate and the difficulty. For this code, every line is priced as straight logic, which keeps the estimate on the low side.
Top priorities
The three actions that raise the score most for the work they take. The full ranked list is in the Roadmap.
1
Split each oversized file along the responsibilities already in it, into smaller focused modules in the same package.
Raises the score by about 3 points · Medium effort · Large Files
2
Act on each finding's own remediation rather than one rule: the move depends on what recurs.
Where the copies are executable blocks, give the shared part one home and call it from each site; where they are declarations, a listing, a specialisation already delegating to its base, or one shape repeated per entity, there is no call site and the move is a shared type, a generated set or a factory — sometimes there is nothing to extract.
Raises the score by about 2 points · Medium effort · Code Duplication
3
Fix the listed violations: move the shared test helper into a source directory production code may depend on (3 rows).
Raises the score by about 1 point · Medium effort · Import Boundaries
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 €780,000 to build again, about 5.4 person-years of work. Its weakest lens is Code Health, at 64 (Adequate). Code Health is about how easy the code is to read and change safely, and code that is hard to read is slow and risky to change, so every future change costs more than it should. Because the weakest lens counts most in the score, work on Code Health also moves the score most.
Based on: the rebuild estimate · the Code Health grade · how much each lens counts
What to do: Start with the Code Health actions in Top priorities.
If you do one thing first · First action
Split each oversized file along the responsibilities already in it, into smaller focused modules in the same package. Of all the actions in this report, it raises the score most for the work it takes: about 3 points for medium effort. 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.9 out of 10. Code at that level is slower to change than clean code, and we estimate the extra work at 3% to 6% on every change. The history of the code shows how much it changes: about 706,239 lines over the last 90 days, which is about 2,864,192 lines a year. At that pace, the extra work comes to an estimated 188.9 to 1133.1 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 — module dependency graph
Project dependencies, layered top-to-bottom; arrows show direction. Any dashed red edge points upward or sideways, which only happens where the projects form a dependency cycle. A graph without cycles has none.
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.
383 modules, with 1011 dependencies between them. 8 loops run through 21 of the modules, marked above the diagonal.
The table shows the 40 modules with the most connections; 343 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.
ai_memory_core.actor uses ai_memory_core.ids, so a change to ai_memory_core.ids can break ai_memory_core.actor, while a change to ai_memory_core.actor can't break ai_memory_core.ids.
Position
Below the diagonal: ai_memory_core.actor uses a module listed above it, which is the healthy direction.
ai_memory_core.observation uses ai_memory_core.ids, so a change to ai_memory_core.ids can break ai_memory_core.observation, while a change to ai_memory_core.observation can't break ai_memory_core.ids.
Position
Below the diagonal: ai_memory_core.observation uses a module listed above it, which is the healthy direction.
ai_memory_core.page uses ai_memory_core.ids, so a change to ai_memory_core.ids can break ai_memory_core.page, while a change to ai_memory_core.page can't break ai_memory_core.ids.
Position
Below the diagonal: ai_memory_core.page uses a module listed above it, which is the healthy direction.
ai_memory_llm.provider uses ai_memory_llm.types, so a change to ai_memory_llm.types can break ai_memory_llm.provider, while a change to ai_memory_llm.provider can't break ai_memory_llm.types.
Position
Below the diagonal: ai_memory_llm.provider uses a module listed above it, which is the healthy direction.
9→14 ai_memory_llm.provider uses ai_memory_llm.healthpart of a loop✕
Connections
1 pair of types, where a type in ai_memory_llm.provider uses a type in ai_memory_llm.health.
ai_memory_llm.provider uses ai_memory_llm.health, so a change to ai_memory_llm.health can break ai_memory_llm.provider, while a change to ai_memory_llm.provider can't break ai_memory_llm.health.
Position
Above the diagonal, so it is part of a loop. Neither module can be changed, tested or released on its own until one of these dependencies is removed.
ai_memory_store.project_authz uses ai_memory_core.ids, so a change to ai_memory_core.ids can break ai_memory_store.project_authz, while a change to ai_memory_store.project_authz can't break ai_memory_core.ids.
Position
Below the diagonal: ai_memory_store.project_authz uses a module listed above it, which is the healthy direction.
ai_memory_web.templates uses ai_memory_core.i18n, so a change to ai_memory_core.i18n can break ai_memory_web.templates, while a change to ai_memory_web.templates can't break ai_memory_core.i18n.
Position
Below the diagonal: ai_memory_web.templates uses a module listed above it, which is the healthy direction.
ai_memory_web.templates uses ai_memory_core.ids, so a change to ai_memory_core.ids can break ai_memory_web.templates, while a change to ai_memory_web.templates can't break ai_memory_core.ids.
Position
Below the diagonal: ai_memory_web.templates uses a module listed above it, which is the healthy direction.
ai_memory_workstream.harness uses ai_memory_core.ids, so a change to ai_memory_core.ids can break ai_memory_workstream.harness, while a change to ai_memory_workstream.harness can't break ai_memory_core.ids.
Position
Below the diagonal: ai_memory_workstream.harness uses a module listed above it, which is the healthy direction.
ai_memory_core.sanitize uses ai_memory_core.observation, so a change to ai_memory_core.observation can break ai_memory_core.sanitize, while a change to ai_memory_core.sanitize can't break ai_memory_core.observation.
Position
Below the diagonal: ai_memory_core.sanitize uses a module listed above it, which is the healthy direction.
ai_memory_llm.health uses ai_memory_llm.types, so a change to ai_memory_llm.types can break ai_memory_llm.health, while a change to ai_memory_llm.health can't break ai_memory_llm.types.
Position
Below the diagonal: ai_memory_llm.health uses a module listed above it, which is the healthy direction.
ai_memory_llm.health uses ai_memory_llm.provider, so a change to ai_memory_llm.provider can break ai_memory_llm.health, while a change to ai_memory_llm.health can't break ai_memory_llm.provider.
Position
Below the diagonal: ai_memory_llm.health uses a module listed above it, which is the healthy direction.
47 pairs of types, where a type in ai_memory_store.auto_improve uses a type in ai_memory_core.ids. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
ai_memory_store.auto_improve uses ai_memory_core.ids, so a change to ai_memory_core.ids can break ai_memory_store.auto_improve, while a change to ai_memory_store.auto_improve can't break ai_memory_core.ids.
Position
Below the diagonal: ai_memory_store.auto_improve uses a module listed above it, which is the healthy direction.
ai_memory_store.auto_improve uses ai_memory_core.actor, so a change to ai_memory_core.actor can break ai_memory_store.auto_improve, while a change to ai_memory_store.auto_improve can't break ai_memory_core.actor.
Position
Below the diagonal: ai_memory_store.auto_improve uses a module listed above it, which is the healthy direction.
ai_memory_store.auto_improve uses ai_memory_core.page, so a change to ai_memory_core.page can break ai_memory_store.auto_improve, while a change to ai_memory_store.auto_improve can't break ai_memory_core.page.
Position
Below the diagonal: ai_memory_store.auto_improve uses a module listed above it, which is the healthy direction.
ai_memory_store.decay uses ai_memory_core.page, so a change to ai_memory_core.page can break ai_memory_store.decay, while a change to ai_memory_store.decay can't break ai_memory_core.page.
Position
Below the diagonal: ai_memory_store.decay uses a module listed above it, which is the healthy direction.
ai_memory_core.workstream uses ai_memory_core.ids, so a change to ai_memory_core.ids can break ai_memory_core.workstream, while a change to ai_memory_core.workstream can't break ai_memory_core.ids.
Position
Below the diagonal: ai_memory_core.workstream uses a module listed above it, which is the healthy direction.
ai_memory_core.workstream uses ai_memory_core.repository_identity, so a change to ai_memory_core.repository_identity can break ai_memory_core.workstream, while a change to ai_memory_core.workstream can't break ai_memory_core.repository_identity.
Position
Below the diagonal: ai_memory_core.workstream uses a module listed above it, which is the healthy direction.
ai_memory_core.workstream uses ai_memory_core.sanitize, so a change to ai_memory_core.sanitize can break ai_memory_core.workstream, while a change to ai_memory_core.workstream can't break ai_memory_core.sanitize.
Position
Below the diagonal: ai_memory_core.workstream uses a module listed above it, which is the healthy direction.
ai_memory_hooks.payload uses ai_memory_core.ids, so a change to ai_memory_core.ids can break ai_memory_hooks.payload, while a change to ai_memory_hooks.payload can't break ai_memory_core.ids.
Position
Below the diagonal: ai_memory_hooks.payload uses a module listed above it, which is the healthy direction.
ai_memory_hooks.payload uses ai_memory_core.repository_identity, so a change to ai_memory_core.repository_identity can break ai_memory_hooks.payload, while a change to ai_memory_hooks.payload can't break ai_memory_core.repository_identity.
Position
Below the diagonal: ai_memory_hooks.payload uses a module listed above it, which is the healthy direction.
ai_memory_hooks.payload uses ai_memory_core.observation, so a change to ai_memory_core.observation can break ai_memory_hooks.payload, while a change to ai_memory_hooks.payload can't break ai_memory_core.observation.
Position
Below the diagonal: ai_memory_hooks.payload uses a module listed above it, which is the healthy direction.
ai_memory_hooks.payload uses ai_memory_core.sanitize, so a change to ai_memory_core.sanitize can break ai_memory_hooks.payload, while a change to ai_memory_hooks.payload can't break ai_memory_core.sanitize.
Position
Below the diagonal: ai_memory_hooks.payload uses a module listed above it, which is the healthy direction.
34 pairs of types, where a type in ai_memory_store.ops uses a type in ai_memory_core.ids. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
ai_memory_store.ops uses ai_memory_core.ids, so a change to ai_memory_core.ids can break ai_memory_store.ops, while a change to ai_memory_store.ops can't break ai_memory_core.ids.
Position
Below the diagonal: ai_memory_store.ops uses a module listed above it, which is the healthy direction.
ai_memory_store.ops uses ai_memory_core.repository_identity, so a change to ai_memory_core.repository_identity can break ai_memory_store.ops, while a change to ai_memory_store.ops can't break ai_memory_core.repository_identity.
Position
Below the diagonal: ai_memory_store.ops uses a module listed above it, which is the healthy direction.
ai_memory_store.ops uses ai_memory_core.actor, so a change to ai_memory_core.actor can break ai_memory_store.ops, while a change to ai_memory_store.ops can't break ai_memory_core.actor.
Position
Below the diagonal: ai_memory_store.ops uses a module listed above it, which is the healthy direction.
ai_memory_store.ops uses ai_memory_core.observation, so a change to ai_memory_core.observation can break ai_memory_store.ops, while a change to ai_memory_store.ops can't break ai_memory_core.observation.
Position
Below the diagonal: ai_memory_store.ops uses a module listed above it, which is the healthy direction.
ai_memory_store.ops uses ai_memory_core.page, so a change to ai_memory_core.page can break ai_memory_store.ops, while a change to ai_memory_store.ops can't break ai_memory_core.page.
Position
Below the diagonal: ai_memory_store.ops uses a module listed above it, which is the healthy direction.
ai_memory_store.ops uses ai_memory_store.project_authz, so a change to ai_memory_store.project_authz can break ai_memory_store.ops, while a change to ai_memory_store.ops can't break ai_memory_store.project_authz.
Position
Below the diagonal: ai_memory_store.ops uses a module listed above it, which is the healthy direction.
ai_memory_store.ops uses ai_memory_store.decay, so a change to ai_memory_store.decay can break ai_memory_store.ops, while a change to ai_memory_store.ops can't break ai_memory_store.decay.
Position
Below the diagonal: ai_memory_store.ops uses a module listed above it, which is the healthy direction.
42 pairs of types, where a type in ai_memory_store.workstream uses a type in ai_memory_core.ids. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
ai_memory_store.workstream uses ai_memory_core.ids, so a change to ai_memory_core.ids can break ai_memory_store.workstream, while a change to ai_memory_store.workstream can't break ai_memory_core.ids.
Position
Below the diagonal: ai_memory_store.workstream uses a module listed above it, which is the healthy direction.
ai_memory_store.workstream uses ai_memory_core.actor, so a change to ai_memory_core.actor can break ai_memory_store.workstream, while a change to ai_memory_store.workstream can't break ai_memory_core.actor.
Position
Below the diagonal: ai_memory_store.workstream uses a module listed above it, which is the healthy direction.
ai_memory_store.workstream uses ai_memory_store.project_authz, so a change to ai_memory_store.project_authz can break ai_memory_store.workstream, while a change to ai_memory_store.workstream can't break ai_memory_store.project_authz.
Position
Below the diagonal: ai_memory_store.workstream uses a module listed above it, which is the healthy direction.
ai_memory_store.workstream uses ai_memory_core.sanitize, so a change to ai_memory_core.sanitize can break ai_memory_store.workstream, while a change to ai_memory_store.workstream can't break ai_memory_core.sanitize.
Position
Below the diagonal: ai_memory_store.workstream uses a module listed above it, which is the healthy direction.
ai_memory_store.workstream uses ai_memory_core.workstream, so a change to ai_memory_core.workstream can break ai_memory_store.workstream, while a change to ai_memory_store.workstream can't break ai_memory_core.workstream.
Position
Below the diagonal: ai_memory_store.workstream uses a module listed above it, which is the healthy direction.
65 pairs of types, where a type in ai_memory_store.reader uses a type in ai_memory_core.ids. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
ai_memory_store.reader uses ai_memory_core.ids, so a change to ai_memory_core.ids can break ai_memory_store.reader, while a change to ai_memory_store.reader can't break ai_memory_core.ids.
Position
Below the diagonal: ai_memory_store.reader uses a module listed above it, which is the healthy direction.
ai_memory_store.reader uses ai_memory_core.repository_identity, so a change to ai_memory_core.repository_identity can break ai_memory_store.reader, while a change to ai_memory_store.reader can't break ai_memory_core.repository_identity.
Position
Below the diagonal: ai_memory_store.reader uses a module listed above it, which is the healthy direction.
ai_memory_store.reader uses ai_memory_core.actor, so a change to ai_memory_core.actor can break ai_memory_store.reader, while a change to ai_memory_store.reader can't break ai_memory_core.actor.
Position
Below the diagonal: ai_memory_store.reader uses a module listed above it, which is the healthy direction.
ai_memory_store.reader uses ai_memory_core.observation, so a change to ai_memory_core.observation can break ai_memory_store.reader, while a change to ai_memory_store.reader can't break ai_memory_core.observation.
Position
Below the diagonal: ai_memory_store.reader uses a module listed above it, which is the healthy direction.
ai_memory_store.reader uses ai_memory_core.page, so a change to ai_memory_core.page can break ai_memory_store.reader, while a change to ai_memory_store.reader can't break ai_memory_core.page.
Position
Below the diagonal: ai_memory_store.reader uses a module listed above it, which is the healthy direction.
ai_memory_store.reader uses ai_memory_store.project_authz, so a change to ai_memory_store.project_authz can break ai_memory_store.reader, while a change to ai_memory_store.reader can't break ai_memory_store.project_authz.
Position
Below the diagonal: ai_memory_store.reader uses a module listed above it, which is the healthy direction.
ai_memory_store.reader uses ai_memory_core.sanitize, so a change to ai_memory_core.sanitize can break ai_memory_store.reader, while a change to ai_memory_store.reader can't break ai_memory_core.sanitize.
Position
Below the diagonal: ai_memory_store.reader uses a module listed above it, which is the healthy direction.
ai_memory_store.reader uses ai_memory_store.auto_improve, so a change to ai_memory_store.auto_improve can break ai_memory_store.reader, while a change to ai_memory_store.reader can't break ai_memory_store.auto_improve.
Position
Below the diagonal: ai_memory_store.reader uses a module listed above it, which is the healthy direction.
ai_memory_store.reader uses ai_memory_store.workstream, so a change to ai_memory_store.workstream can break ai_memory_store.reader, while a change to ai_memory_store.reader can't break ai_memory_store.workstream.
Position
Below the diagonal: ai_memory_store.reader uses a module listed above it, which is the healthy direction.
ai_memory_store.writer uses ai_memory_core.ids, so a change to ai_memory_core.ids can break ai_memory_store.writer, while a change to ai_memory_store.writer can't break ai_memory_core.ids.
Position
Below the diagonal: ai_memory_store.writer uses a module listed above it, which is the healthy direction.
ai_memory_store.writer uses ai_memory_core.repository_identity, so a change to ai_memory_core.repository_identity can break ai_memory_store.writer, while a change to ai_memory_store.writer can't break ai_memory_core.repository_identity.
Position
Below the diagonal: ai_memory_store.writer uses a module listed above it, which is the healthy direction.
ai_memory_store.writer uses ai_memory_core.actor, so a change to ai_memory_core.actor can break ai_memory_store.writer, while a change to ai_memory_store.writer can't break ai_memory_core.actor.
Position
Below the diagonal: ai_memory_store.writer uses a module listed above it, which is the healthy direction.
ai_memory_store.writer uses ai_memory_core.observation, so a change to ai_memory_core.observation can break ai_memory_store.writer, while a change to ai_memory_store.writer can't break ai_memory_core.observation.
Position
Below the diagonal: ai_memory_store.writer uses a module listed above it, which is the healthy direction.
ai_memory_store.writer uses ai_memory_core.page, so a change to ai_memory_core.page can break ai_memory_store.writer, while a change to ai_memory_store.writer can't break ai_memory_core.page.
Position
Below the diagonal: ai_memory_store.writer uses a module listed above it, which is the healthy direction.
ai_memory_store.writer uses ai_memory_store.project_authz, so a change to ai_memory_store.project_authz can break ai_memory_store.writer, while a change to ai_memory_store.writer can't break ai_memory_store.project_authz.
Position
Below the diagonal: ai_memory_store.writer uses a module listed above it, which is the healthy direction.
ai_memory_store.writer uses ai_memory_core.sanitize, so a change to ai_memory_core.sanitize can break ai_memory_store.writer, while a change to ai_memory_store.writer can't break ai_memory_core.sanitize.
Position
Below the diagonal: ai_memory_store.writer uses a module listed above it, which is the healthy direction.
ai_memory_store.writer uses ai_memory_store.auto_improve, so a change to ai_memory_store.auto_improve can break ai_memory_store.writer, while a change to ai_memory_store.writer can't break ai_memory_store.auto_improve.
Position
Below the diagonal: ai_memory_store.writer uses a module listed above it, which is the healthy direction.
ai_memory_store.writer uses ai_memory_store.decay, so a change to ai_memory_store.decay can break ai_memory_store.writer, while a change to ai_memory_store.writer can't break ai_memory_store.decay.
Position
Below the diagonal: ai_memory_store.writer uses a module listed above it, which is the healthy direction.
ai_memory_store.writer uses ai_memory_store.ops, so a change to ai_memory_store.ops can break ai_memory_store.writer, while a change to ai_memory_store.writer can't break ai_memory_store.ops.
Position
Below the diagonal: ai_memory_store.writer uses a module listed above it, which is the healthy direction.
ai_memory_store.writer uses ai_memory_store.workstream, so a change to ai_memory_store.workstream can break ai_memory_store.writer, while a change to ai_memory_store.writer can't break ai_memory_store.workstream.
Position
Below the diagonal: ai_memory_store.writer uses a module listed above it, which is the healthy direction.
ai_memory_store.scope uses ai_memory_core.ids, so a change to ai_memory_core.ids can break ai_memory_store.scope, while a change to ai_memory_store.scope can't break ai_memory_core.ids.
Position
Below the diagonal: ai_memory_store.scope uses a module listed above it, which is the healthy direction.
ai_memory_store.scope uses ai_memory_store.project_authz, so a change to ai_memory_store.project_authz can break ai_memory_store.scope, while a change to ai_memory_store.scope can't break ai_memory_store.project_authz.
Position
Below the diagonal: ai_memory_store.scope uses a module listed above it, which is the healthy direction.
ai_memory_store.scope uses ai_memory_store.reader, so a change to ai_memory_store.reader can break ai_memory_store.scope, while a change to ai_memory_store.scope can't break ai_memory_store.reader.
Position
Below the diagonal: ai_memory_store.scope uses a module listed above it, which is the healthy direction.
ai_memory_store.scope uses ai_memory_store.writer, so a change to ai_memory_store.writer can break ai_memory_store.scope, while a change to ai_memory_store.scope can't break ai_memory_store.writer.
Position
Below the diagonal: ai_memory_store.scope uses a module listed above it, which is the healthy direction.
ai_memory_wiki.wiki uses ai_memory_core.ids, so a change to ai_memory_core.ids can break ai_memory_wiki.wiki, while a change to ai_memory_wiki.wiki can't break ai_memory_core.ids.
Position
Below the diagonal: ai_memory_wiki.wiki uses a module listed above it, which is the healthy direction.
ai_memory_wiki.wiki uses ai_memory_core.actor, so a change to ai_memory_core.actor can break ai_memory_wiki.wiki, while a change to ai_memory_wiki.wiki can't break ai_memory_core.actor.
Position
Below the diagonal: ai_memory_wiki.wiki uses a module listed above it, which is the healthy direction.
ai_memory_wiki.wiki uses ai_memory_core.page, so a change to ai_memory_core.page can break ai_memory_wiki.wiki, while a change to ai_memory_wiki.wiki can't break ai_memory_core.page.
Position
Below the diagonal: ai_memory_wiki.wiki uses a module listed above it, which is the healthy direction.
ai_memory_wiki.wiki uses ai_memory_core.sanitize, so a change to ai_memory_core.sanitize can break ai_memory_wiki.wiki, while a change to ai_memory_wiki.wiki can't break ai_memory_core.sanitize.
Position
Below the diagonal: ai_memory_wiki.wiki uses a module listed above it, which is the healthy direction.
ai_memory_wiki.wiki uses ai_memory_store.auto_improve, so a change to ai_memory_store.auto_improve can break ai_memory_wiki.wiki, while a change to ai_memory_wiki.wiki can't break ai_memory_store.auto_improve.
Position
Below the diagonal: ai_memory_wiki.wiki uses a module listed above it, which is the healthy direction.
ai_memory_wiki.wiki uses ai_memory_store.ops, so a change to ai_memory_store.ops can break ai_memory_wiki.wiki, while a change to ai_memory_wiki.wiki can't break ai_memory_store.ops.
Position
Below the diagonal: ai_memory_wiki.wiki uses a module listed above it, which is the healthy direction.
ai_memory_wiki.wiki uses ai_memory_store.reader, so a change to ai_memory_store.reader can break ai_memory_wiki.wiki, while a change to ai_memory_wiki.wiki can't break ai_memory_store.reader.
Position
Below the diagonal: ai_memory_wiki.wiki uses a module listed above it, which is the healthy direction.
ai_memory_wiki.wiki uses ai_memory_store.writer, so a change to ai_memory_store.writer can break ai_memory_wiki.wiki, while a change to ai_memory_wiki.wiki can't break ai_memory_store.writer.
Position
Below the diagonal: ai_memory_wiki.wiki uses a module listed above it, which is the healthy direction.
ai_memory_consolidate.consolidator uses ai_memory_core.ids, so a change to ai_memory_core.ids can break ai_memory_consolidate.consolidator, while a change to ai_memory_consolidate.consolidator can't break ai_memory_core.ids.
Position
Below the diagonal: ai_memory_consolidate.consolidator uses a module listed above it, which is the healthy direction.
ai_memory_consolidate.consolidator uses ai_memory_llm.types, so a change to ai_memory_llm.types can break ai_memory_consolidate.consolidator, while a change to ai_memory_consolidate.consolidator can't break ai_memory_llm.types.
Position
Below the diagonal: ai_memory_consolidate.consolidator uses a module listed above it, which is the healthy direction.
ai_memory_consolidate.consolidator uses ai_memory_core.actor, so a change to ai_memory_core.actor can break ai_memory_consolidate.consolidator, while a change to ai_memory_consolidate.consolidator can't break ai_memory_core.actor.
Position
Below the diagonal: ai_memory_consolidate.consolidator uses a module listed above it, which is the healthy direction.
ai_memory_consolidate.consolidator uses ai_memory_core.page, so a change to ai_memory_core.page can break ai_memory_consolidate.consolidator, while a change to ai_memory_consolidate.consolidator can't break ai_memory_core.page.
Position
Below the diagonal: ai_memory_consolidate.consolidator uses a module listed above it, which is the healthy direction.
ai_memory_consolidate.consolidator uses ai_memory_store.reader, so a change to ai_memory_store.reader can break ai_memory_consolidate.consolidator, while a change to ai_memory_consolidate.consolidator can't break ai_memory_store.reader.
Position
Below the diagonal: ai_memory_consolidate.consolidator uses a module listed above it, which is the healthy direction.
ai_memory_consolidate.consolidator uses ai_memory_store.writer, so a change to ai_memory_store.writer can break ai_memory_consolidate.consolidator, while a change to ai_memory_consolidate.consolidator can't break ai_memory_store.writer.
Position
Below the diagonal: ai_memory_consolidate.consolidator uses a module listed above it, which is the healthy direction.
ai_memory_consolidate.consolidator uses ai_memory_wiki.wiki, so a change to ai_memory_wiki.wiki can break ai_memory_consolidate.consolidator, while a change to ai_memory_consolidate.consolidator can't break ai_memory_wiki.wiki.
Position
Below the diagonal: ai_memory_consolidate.consolidator uses a module listed above it, which is the healthy direction.
ai_memory_consolidate.sweep uses ai_memory_core.ids, so a change to ai_memory_core.ids can break ai_memory_consolidate.sweep, while a change to ai_memory_consolidate.sweep can't break ai_memory_core.ids.
Position
Below the diagonal: ai_memory_consolidate.sweep uses a module listed above it, which is the healthy direction.
ai_memory_consolidate.sweep uses ai_memory_store.decay, so a change to ai_memory_store.decay can break ai_memory_consolidate.sweep, while a change to ai_memory_consolidate.sweep can't break ai_memory_store.decay.
Position
Below the diagonal: ai_memory_consolidate.sweep uses a module listed above it, which is the healthy direction.
ai_memory_consolidate.sweep uses ai_memory_store.reader, so a change to ai_memory_store.reader can break ai_memory_consolidate.sweep, while a change to ai_memory_consolidate.sweep can't break ai_memory_store.reader.
Position
Below the diagonal: ai_memory_consolidate.sweep uses a module listed above it, which is the healthy direction.
ai_memory_consolidate.sweep uses ai_memory_store.writer, so a change to ai_memory_store.writer can break ai_memory_consolidate.sweep, while a change to ai_memory_consolidate.sweep can't break ai_memory_store.writer.
Position
Below the diagonal: ai_memory_consolidate.sweep uses a module listed above it, which is the healthy direction.
ai_memory_consolidate.sweep uses ai_memory_wiki.wiki, so a change to ai_memory_wiki.wiki can break ai_memory_consolidate.sweep, while a change to ai_memory_consolidate.sweep can't break ai_memory_wiki.wiki.
Position
Below the diagonal: ai_memory_consolidate.sweep uses a module listed above it, which is the healthy direction.
ai_memory_hooks.workstream uses ai_memory_core.ids, so a change to ai_memory_core.ids can break ai_memory_hooks.workstream, while a change to ai_memory_hooks.workstream can't break ai_memory_core.ids.
Position
Below the diagonal: ai_memory_hooks.workstream uses a module listed above it, which is the healthy direction.
ai_memory_hooks.workstream uses ai_memory_core.repository_identity, so a change to ai_memory_core.repository_identity can break ai_memory_hooks.workstream, while a change to ai_memory_hooks.workstream can't break ai_memory_core.repository_identity.
Position
Below the diagonal: ai_memory_hooks.workstream uses a module listed above it, which is the healthy direction.
ai_memory_hooks.workstream uses ai_memory_core.actor, so a change to ai_memory_core.actor can break ai_memory_hooks.workstream, while a change to ai_memory_hooks.workstream can't break ai_memory_core.actor.
Position
Below the diagonal: ai_memory_hooks.workstream uses a module listed above it, which is the healthy direction.
ai_memory_hooks.workstream uses ai_memory_store.project_authz, so a change to ai_memory_store.project_authz can break ai_memory_hooks.workstream, while a change to ai_memory_hooks.workstream can't break ai_memory_store.project_authz.
Position
Below the diagonal: ai_memory_hooks.workstream uses a module listed above it, which is the healthy direction.
ai_memory_hooks.workstream uses ai_memory_core.sanitize, so a change to ai_memory_core.sanitize can break ai_memory_hooks.workstream, while a change to ai_memory_hooks.workstream can't break ai_memory_core.sanitize.
Position
Below the diagonal: ai_memory_hooks.workstream uses a module listed above it, which is the healthy direction.
ai_memory_hooks.workstream uses ai_memory_core.workstream, so a change to ai_memory_core.workstream can break ai_memory_hooks.workstream, while a change to ai_memory_hooks.workstream can't break ai_memory_core.workstream.
Position
Below the diagonal: ai_memory_hooks.workstream uses a module listed above it, which is the healthy direction.
ai_memory_hooks.workstream uses ai_memory_store.reader, so a change to ai_memory_store.reader can break ai_memory_hooks.workstream, while a change to ai_memory_hooks.workstream can't break ai_memory_store.reader.
Position
Below the diagonal: ai_memory_hooks.workstream uses a module listed above it, which is the healthy direction.
ai_memory_hooks.workstream uses ai_memory_store.writer, so a change to ai_memory_store.writer can break ai_memory_hooks.workstream, while a change to ai_memory_hooks.workstream can't break ai_memory_store.writer.
Position
Below the diagonal: ai_memory_hooks.workstream uses a module listed above it, which is the healthy direction.
ai_memory_hooks.workstream uses ai_memory_store.scope, so a change to ai_memory_store.scope can break ai_memory_hooks.workstream, while a change to ai_memory_hooks.workstream can't break ai_memory_store.scope.
Position
Below the diagonal: ai_memory_hooks.workstream uses a module listed above it, which is the healthy direction.
ai_memory_hooks.workstream uses ai_memory_wiki.wiki, so a change to ai_memory_wiki.wiki can break ai_memory_hooks.workstream, while a change to ai_memory_hooks.workstream can't break ai_memory_wiki.wiki.
Position
Below the diagonal: ai_memory_hooks.workstream uses a module listed above it, which is the healthy direction.
ai_memory_web.state uses ai_memory_store.reader, so a change to ai_memory_store.reader can break ai_memory_web.state, while a change to ai_memory_web.state can't break ai_memory_store.reader.
Position
Below the diagonal: ai_memory_web.state uses a module listed above it, which is the healthy direction.
ai_memory_web.state uses ai_memory_wiki.wiki, so a change to ai_memory_wiki.wiki can break ai_memory_web.state, while a change to ai_memory_web.state can't break ai_memory_wiki.wiki.
Position
Below the diagonal: ai_memory_web.state uses a module listed above it, which is the healthy direction.
ai_memory_consolidate.dream uses ai_memory_core.ids, so a change to ai_memory_core.ids can break ai_memory_consolidate.dream, while a change to ai_memory_consolidate.dream can't break ai_memory_core.ids.
Position
Below the diagonal: ai_memory_consolidate.dream uses a module listed above it, which is the healthy direction.
ai_memory_consolidate.dream uses ai_memory_llm.types, so a change to ai_memory_llm.types can break ai_memory_consolidate.dream, while a change to ai_memory_consolidate.dream can't break ai_memory_llm.types.
Position
Below the diagonal: ai_memory_consolidate.dream uses a module listed above it, which is the healthy direction.
ai_memory_consolidate.dream uses ai_memory_store.decay, so a change to ai_memory_store.decay can break ai_memory_consolidate.dream, while a change to ai_memory_consolidate.dream can't break ai_memory_store.decay.
Position
Below the diagonal: ai_memory_consolidate.dream uses a module listed above it, which is the healthy direction.
ai_memory_consolidate.dream uses ai_memory_store.reader, so a change to ai_memory_store.reader can break ai_memory_consolidate.dream, while a change to ai_memory_consolidate.dream can't break ai_memory_store.reader.
Position
Below the diagonal: ai_memory_consolidate.dream uses a module listed above it, which is the healthy direction.
ai_memory_consolidate.dream uses ai_memory_wiki.wiki, so a change to ai_memory_wiki.wiki can break ai_memory_consolidate.dream, while a change to ai_memory_consolidate.dream can't break ai_memory_wiki.wiki.
Position
Below the diagonal: ai_memory_consolidate.dream uses a module listed above it, which is the healthy direction.
ai_memory_consolidate.dream uses ai_memory_consolidate.sweep, so a change to ai_memory_consolidate.sweep can break ai_memory_consolidate.dream, while a change to ai_memory_consolidate.dream can't break ai_memory_consolidate.sweep.
Position
Below the diagonal: ai_memory_consolidate.dream uses a module listed above it, which is the healthy direction.
ai_memory_hooks.router uses ai_memory_core.ids, so a change to ai_memory_core.ids can break ai_memory_hooks.router, while a change to ai_memory_hooks.router can't break ai_memory_core.ids.
Position
Below the diagonal: ai_memory_hooks.router uses a module listed above it, which is the healthy direction.
ai_memory_hooks.router uses ai_memory_core.repository_identity, so a change to ai_memory_core.repository_identity can break ai_memory_hooks.router, while a change to ai_memory_hooks.router can't break ai_memory_core.repository_identity.
Position
Below the diagonal: ai_memory_hooks.router uses a module listed above it, which is the healthy direction.
ai_memory_hooks.router uses ai_memory_core.actor, so a change to ai_memory_core.actor can break ai_memory_hooks.router, while a change to ai_memory_hooks.router can't break ai_memory_core.actor.
Position
Below the diagonal: ai_memory_hooks.router uses a module listed above it, which is the healthy direction.
ai_memory_hooks.router uses ai_memory_core.observation, so a change to ai_memory_core.observation can break ai_memory_hooks.router, while a change to ai_memory_hooks.router can't break ai_memory_core.observation.
Position
Below the diagonal: ai_memory_hooks.router uses a module listed above it, which is the healthy direction.
ai_memory_hooks.router uses ai_memory_core.sanitize, so a change to ai_memory_core.sanitize can break ai_memory_hooks.router, while a change to ai_memory_hooks.router can't break ai_memory_core.sanitize.
Position
Below the diagonal: ai_memory_hooks.router uses a module listed above it, which is the healthy direction.
ai_memory_hooks.router uses ai_memory_core.workstream, so a change to ai_memory_core.workstream can break ai_memory_hooks.router, while a change to ai_memory_hooks.router can't break ai_memory_core.workstream.
Position
Below the diagonal: ai_memory_hooks.router uses a module listed above it, which is the healthy direction.
ai_memory_hooks.router uses ai_memory_hooks.payload, so a change to ai_memory_hooks.payload can break ai_memory_hooks.router, while a change to ai_memory_hooks.router can't break ai_memory_hooks.payload.
Position
Below the diagonal: ai_memory_hooks.router uses a module listed above it, which is the healthy direction.
ai_memory_hooks.router uses ai_memory_store.workstream, so a change to ai_memory_store.workstream can break ai_memory_hooks.router, while a change to ai_memory_hooks.router can't break ai_memory_store.workstream.
Position
Below the diagonal: ai_memory_hooks.router uses a module listed above it, which is the healthy direction.
ai_memory_hooks.router uses ai_memory_store.reader, so a change to ai_memory_store.reader can break ai_memory_hooks.router, while a change to ai_memory_hooks.router can't break ai_memory_store.reader.
Position
Below the diagonal: ai_memory_hooks.router uses a module listed above it, which is the healthy direction.
ai_memory_hooks.router uses ai_memory_store.writer, so a change to ai_memory_store.writer can break ai_memory_hooks.router, while a change to ai_memory_hooks.router can't break ai_memory_store.writer.
Position
Below the diagonal: ai_memory_hooks.router uses a module listed above it, which is the healthy direction.
ai_memory_hooks.router uses ai_memory_wiki.wiki, so a change to ai_memory_wiki.wiki can break ai_memory_hooks.router, while a change to ai_memory_hooks.router can't break ai_memory_wiki.wiki.
Position
Below the diagonal: ai_memory_hooks.router uses a module listed above it, which is the healthy direction.
ai_memory_hooks.router uses ai_memory_consolidate.consolidator, so a change to ai_memory_consolidate.consolidator can break ai_memory_hooks.router, while a change to ai_memory_hooks.router can't break ai_memory_consolidate.consolidator.
Position
Below the diagonal: ai_memory_hooks.router uses a module listed above it, which is the healthy direction.
27 pairs of types, where a type in ai_memory_mcp.admin uses a type in ai_memory_core.ids. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
ai_memory_mcp.admin uses ai_memory_core.ids, so a change to ai_memory_core.ids can break ai_memory_mcp.admin, while a change to ai_memory_mcp.admin can't break ai_memory_core.ids.
Position
Below the diagonal: ai_memory_mcp.admin uses a module listed above it, which is the healthy direction.
ai_memory_mcp.admin uses ai_memory_core.repository_identity, so a change to ai_memory_core.repository_identity can break ai_memory_mcp.admin, while a change to ai_memory_mcp.admin can't break ai_memory_core.repository_identity.
Position
Below the diagonal: ai_memory_mcp.admin uses a module listed above it, which is the healthy direction.
ai_memory_mcp.admin uses ai_memory_core.actor, so a change to ai_memory_core.actor can break ai_memory_mcp.admin, while a change to ai_memory_mcp.admin can't break ai_memory_core.actor.
Position
Below the diagonal: ai_memory_mcp.admin uses a module listed above it, which is the healthy direction.
ai_memory_mcp.admin uses ai_memory_core.page, so a change to ai_memory_core.page can break ai_memory_mcp.admin, while a change to ai_memory_mcp.admin can't break ai_memory_core.page.
Position
Below the diagonal: ai_memory_mcp.admin uses a module listed above it, which is the healthy direction.
ai_memory_mcp.admin uses ai_memory_llm.health, so a change to ai_memory_llm.health can break ai_memory_mcp.admin, while a change to ai_memory_mcp.admin can't break ai_memory_llm.health.
Position
Below the diagonal: ai_memory_mcp.admin uses a module listed above it, which is the healthy direction.
ai_memory_mcp.admin uses ai_memory_store.auto_improve, so a change to ai_memory_store.auto_improve can break ai_memory_mcp.admin, while a change to ai_memory_mcp.admin can't break ai_memory_store.auto_improve.
Position
Below the diagonal: ai_memory_mcp.admin uses a module listed above it, which is the healthy direction.
ai_memory_mcp.admin uses ai_memory_store.decay, so a change to ai_memory_store.decay can break ai_memory_mcp.admin, while a change to ai_memory_mcp.admin can't break ai_memory_store.decay.
Position
Below the diagonal: ai_memory_mcp.admin uses a module listed above it, which is the healthy direction.
ai_memory_mcp.admin uses ai_memory_store.ops, so a change to ai_memory_store.ops can break ai_memory_mcp.admin, while a change to ai_memory_mcp.admin can't break ai_memory_store.ops.
Position
Below the diagonal: ai_memory_mcp.admin uses a module listed above it, which is the healthy direction.
ai_memory_mcp.admin uses ai_memory_store.reader, so a change to ai_memory_store.reader can break ai_memory_mcp.admin, while a change to ai_memory_mcp.admin can't break ai_memory_store.reader.
Position
Below the diagonal: ai_memory_mcp.admin uses a module listed above it, which is the healthy direction.
ai_memory_mcp.admin uses ai_memory_store.writer, so a change to ai_memory_store.writer can break ai_memory_mcp.admin, while a change to ai_memory_mcp.admin can't break ai_memory_store.writer.
Position
Below the diagonal: ai_memory_mcp.admin uses a module listed above it, which is the healthy direction.
ai_memory_mcp.admin uses ai_memory_store.scope, so a change to ai_memory_store.scope can break ai_memory_mcp.admin, while a change to ai_memory_mcp.admin can't break ai_memory_store.scope.
Position
Below the diagonal: ai_memory_mcp.admin uses a module listed above it, which is the healthy direction.
ai_memory_mcp.admin uses ai_memory_wiki.wiki, so a change to ai_memory_wiki.wiki can break ai_memory_mcp.admin, while a change to ai_memory_mcp.admin can't break ai_memory_wiki.wiki.
Position
Below the diagonal: ai_memory_mcp.admin uses a module listed above it, which is the healthy direction.
ai_memory_mcp.admin uses ai_memory_consolidate.sweep, so a change to ai_memory_consolidate.sweep can break ai_memory_mcp.admin, while a change to ai_memory_mcp.admin can't break ai_memory_consolidate.sweep.
Position
Below the diagonal: ai_memory_mcp.admin uses a module listed above it, which is the healthy direction.
ai_memory_cli.config uses ai_memory_core.i18n, so a change to ai_memory_core.i18n can break ai_memory_cli.config, while a change to ai_memory_cli.config can't break ai_memory_core.i18n.
Position
Below the diagonal: ai_memory_cli.config uses a module listed above it, which is the healthy direction.
ai_memory_cli.config uses ai_memory_llm.types, so a change to ai_memory_llm.types can break ai_memory_cli.config, while a change to ai_memory_cli.config can't break ai_memory_llm.types.
Position
Below the diagonal: ai_memory_cli.config uses a module listed above it, which is the healthy direction.
ai_memory_cli.config uses ai_memory_core.sanitize, so a change to ai_memory_core.sanitize can break ai_memory_cli.config, while a change to ai_memory_cli.config can't break ai_memory_core.sanitize.
Position
Below the diagonal: ai_memory_cli.config uses a module listed above it, which is the healthy direction.
ai_memory_cli.config uses ai_memory_store.decay, so a change to ai_memory_store.decay can break ai_memory_cli.config, while a change to ai_memory_cli.config can't break ai_memory_store.decay.
Position
Below the diagonal: ai_memory_cli.config uses a module listed above it, which is the healthy direction.
ai_memory_cli.config uses ai_memory_consolidate.sweep, so a change to ai_memory_consolidate.sweep can break ai_memory_cli.config, while a change to ai_memory_cli.config can't break ai_memory_consolidate.sweep.
Position
Below the diagonal: ai_memory_cli.config uses a module listed above it, which is the healthy direction.
ai_memory_cli.config uses ai_memory_consolidate.dream, so a change to ai_memory_consolidate.dream can break ai_memory_cli.config, while a change to ai_memory_cli.config can't break ai_memory_consolidate.dream.
Position
Below the diagonal: ai_memory_cli.config uses a module listed above it, which is the healthy direction.
ai_memory_mcp.server uses ai_memory_core.ids, so a change to ai_memory_core.ids can break ai_memory_mcp.server, while a change to ai_memory_mcp.server can't break ai_memory_core.ids.
Position
Below the diagonal: ai_memory_mcp.server uses a module listed above it, which is the healthy direction.
ai_memory_mcp.server uses ai_memory_core.repository_identity, so a change to ai_memory_core.repository_identity can break ai_memory_mcp.server, while a change to ai_memory_mcp.server can't break ai_memory_core.repository_identity.
Position
Below the diagonal: ai_memory_mcp.server uses a module listed above it, which is the healthy direction.
ai_memory_mcp.server uses ai_memory_llm.types, so a change to ai_memory_llm.types can break ai_memory_mcp.server, while a change to ai_memory_mcp.server can't break ai_memory_llm.types.
Position
Below the diagonal: ai_memory_mcp.server uses a module listed above it, which is the healthy direction.
ai_memory_mcp.server uses ai_memory_core.actor, so a change to ai_memory_core.actor can break ai_memory_mcp.server, while a change to ai_memory_mcp.server can't break ai_memory_core.actor.
Position
Below the diagonal: ai_memory_mcp.server uses a module listed above it, which is the healthy direction.
ai_memory_mcp.server uses ai_memory_core.page, so a change to ai_memory_core.page can break ai_memory_mcp.server, while a change to ai_memory_mcp.server can't break ai_memory_core.page.
Position
Below the diagonal: ai_memory_mcp.server uses a module listed above it, which is the healthy direction.
ai_memory_mcp.server uses ai_memory_store.project_authz, so a change to ai_memory_store.project_authz can break ai_memory_mcp.server, while a change to ai_memory_mcp.server can't break ai_memory_store.project_authz.
Position
Below the diagonal: ai_memory_mcp.server uses a module listed above it, which is the healthy direction.
ai_memory_mcp.server uses ai_memory_core.sanitize, so a change to ai_memory_core.sanitize can break ai_memory_mcp.server, while a change to ai_memory_mcp.server can't break ai_memory_core.sanitize.
Position
Below the diagonal: ai_memory_mcp.server uses a module listed above it, which is the healthy direction.
ai_memory_mcp.server uses ai_memory_store.decay, so a change to ai_memory_store.decay can break ai_memory_mcp.server, while a change to ai_memory_mcp.server can't break ai_memory_store.decay.
Position
Below the diagonal: ai_memory_mcp.server uses a module listed above it, which is the healthy direction.
ai_memory_mcp.server uses ai_memory_store.ops, so a change to ai_memory_store.ops can break ai_memory_mcp.server, while a change to ai_memory_mcp.server can't break ai_memory_store.ops.
Position
Below the diagonal: ai_memory_mcp.server uses a module listed above it, which is the healthy direction.
ai_memory_mcp.server uses ai_memory_store.reader, so a change to ai_memory_store.reader can break ai_memory_mcp.server, while a change to ai_memory_mcp.server can't break ai_memory_store.reader.
Position
Below the diagonal: ai_memory_mcp.server uses a module listed above it, which is the healthy direction.
ai_memory_mcp.server uses ai_memory_store.writer, so a change to ai_memory_store.writer can break ai_memory_mcp.server, while a change to ai_memory_mcp.server can't break ai_memory_store.writer.
Position
Below the diagonal: ai_memory_mcp.server uses a module listed above it, which is the healthy direction.
ai_memory_mcp.server uses ai_memory_store.scope, so a change to ai_memory_store.scope can break ai_memory_mcp.server, while a change to ai_memory_mcp.server can't break ai_memory_store.scope.
Position
Below the diagonal: ai_memory_mcp.server uses a module listed above it, which is the healthy direction.
ai_memory_mcp.server uses ai_memory_wiki.wiki, so a change to ai_memory_wiki.wiki can break ai_memory_mcp.server, while a change to ai_memory_mcp.server can't break ai_memory_wiki.wiki.
Position
Below the diagonal: ai_memory_mcp.server uses a module listed above it, which is the healthy direction.
ai_memory_mcp.server uses ai_memory_consolidate.consolidator, so a change to ai_memory_consolidate.consolidator can break ai_memory_mcp.server, while a change to ai_memory_mcp.server can't break ai_memory_consolidate.consolidator.
Position
Below the diagonal: ai_memory_mcp.server uses a module listed above it, which is the healthy direction.
ai_memory_mcp.server uses ai_memory_consolidate.sweep, so a change to ai_memory_consolidate.sweep can break ai_memory_mcp.server, while a change to ai_memory_mcp.server can't break ai_memory_consolidate.sweep.
Position
Below the diagonal: ai_memory_mcp.server uses a module listed above it, which is the healthy direction.
ai_memory_mcp.server uses ai_memory_consolidate.dream, so a change to ai_memory_consolidate.dream can break ai_memory_mcp.server, while a change to ai_memory_mcp.server can't break ai_memory_consolidate.dream.
Position
Below the diagonal: ai_memory_mcp.server uses a module listed above it, which is the healthy direction.
ai_memory_cli.cli uses ai_memory_core.i18n, so a change to ai_memory_core.i18n can break ai_memory_cli.cli, while a change to ai_memory_cli.cli can't break ai_memory_core.i18n.
Position
Below the diagonal: ai_memory_cli.cli uses a module listed above it, which is the healthy direction.
ai_memory_cli.cli uses ai_memory_core.ids, so a change to ai_memory_core.ids can break ai_memory_cli.cli, while a change to ai_memory_cli.cli can't break ai_memory_core.ids.
Position
Below the diagonal: ai_memory_cli.cli uses a module listed above it, which is the healthy direction.
ai_memory_cli.cli uses ai_memory_workstream.harness, so a change to ai_memory_workstream.harness can break ai_memory_cli.cli, while a change to ai_memory_cli.cli can't break ai_memory_workstream.harness.
Position
Below the diagonal: ai_memory_cli.cli uses a module listed above it, which is the healthy direction.
ai_memory_cli.cli uses ai_memory_cli.config, so a change to ai_memory_cli.config can break ai_memory_cli.cli, while a change to ai_memory_cli.cli can't break ai_memory_cli.config.
Position
Below the diagonal: ai_memory_cli.cli uses a module listed above it, which is the healthy direction.
ai_memory_cli.http_client uses ai_memory_core.i18n, so a change to ai_memory_core.i18n can break ai_memory_cli.http_client, while a change to ai_memory_cli.http_client can't break ai_memory_core.i18n.
Position
Below the diagonal: ai_memory_cli.http_client uses a module listed above it, which is the healthy direction.
ai_memory_cli.http_client uses ai_memory_web.management.backend, so a change to ai_memory_web.management.backend can break ai_memory_cli.http_client, while a change to ai_memory_cli.http_client can't break ai_memory_web.management.backend.
Position
Below the diagonal: ai_memory_cli.http_client uses a module listed above it, which is the healthy direction.
ai_memory_cli.http_client uses ai_memory_cli.config, so a change to ai_memory_cli.config can break ai_memory_cli.http_client, while a change to ai_memory_cli.http_client can't break ai_memory_cli.config.
Position
Below the diagonal: ai_memory_cli.http_client uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.backfill uses ai_memory_core.i18n, so a change to ai_memory_core.i18n can break ai_memory_cli.commands.backfill, while a change to ai_memory_cli.commands.backfill can't break ai_memory_core.i18n.
Position
Below the diagonal: ai_memory_cli.commands.backfill uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.backfill uses ai_memory_workstream.harness, so a change to ai_memory_workstream.harness can break ai_memory_cli.commands.backfill, while a change to ai_memory_cli.commands.backfill can't break ai_memory_workstream.harness.
Position
Below the diagonal: ai_memory_cli.commands.backfill uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.backfill uses ai_memory_core.workstream, so a change to ai_memory_core.workstream can break ai_memory_cli.commands.backfill, while a change to ai_memory_cli.commands.backfill can't break ai_memory_core.workstream.
Position
Below the diagonal: ai_memory_cli.commands.backfill uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.backfill uses ai_memory_cli.config, so a change to ai_memory_cli.config can break ai_memory_cli.commands.backfill, while a change to ai_memory_cli.commands.backfill can't break ai_memory_cli.config.
Position
Below the diagonal: ai_memory_cli.commands.backfill uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.backfill uses ai_memory_cli.cli, so a change to ai_memory_cli.cli can break ai_memory_cli.commands.backfill, while a change to ai_memory_cli.commands.backfill can't break ai_memory_cli.cli.
Position
Below the diagonal: ai_memory_cli.commands.backfill uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.backfill uses ai_memory_cli.http_client, so a change to ai_memory_cli.http_client can break ai_memory_cli.commands.backfill, while a change to ai_memory_cli.commands.backfill can't break ai_memory_cli.http_client.
Position
Below the diagonal: ai_memory_cli.commands.backfill uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.run uses ai_memory_core.i18n, so a change to ai_memory_core.i18n can break ai_memory_cli.commands.run, while a change to ai_memory_cli.commands.run can't break ai_memory_core.i18n.
Position
Below the diagonal: ai_memory_cli.commands.run uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.run uses ai_memory_core.ids, so a change to ai_memory_core.ids can break ai_memory_cli.commands.run, while a change to ai_memory_cli.commands.run can't break ai_memory_core.ids.
Position
Below the diagonal: ai_memory_cli.commands.run uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.run uses ai_memory_core.repository_identity, so a change to ai_memory_core.repository_identity can break ai_memory_cli.commands.run, while a change to ai_memory_cli.commands.run can't break ai_memory_core.repository_identity.
Position
Below the diagonal: ai_memory_cli.commands.run uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.run uses ai_memory_workstream.harness, so a change to ai_memory_workstream.harness can break ai_memory_cli.commands.run, while a change to ai_memory_cli.commands.run can't break ai_memory_workstream.harness.
Position
Below the diagonal: ai_memory_cli.commands.run uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.run uses ai_memory_core.sanitize, so a change to ai_memory_core.sanitize can break ai_memory_cli.commands.run, while a change to ai_memory_cli.commands.run can't break ai_memory_core.sanitize.
Position
Below the diagonal: ai_memory_cli.commands.run uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.run uses ai_memory_core.workstream, so a change to ai_memory_core.workstream can break ai_memory_cli.commands.run, while a change to ai_memory_cli.commands.run can't break ai_memory_core.workstream.
Position
Below the diagonal: ai_memory_cli.commands.run uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.run uses ai_memory_cli.config, so a change to ai_memory_cli.config can break ai_memory_cli.commands.run, while a change to ai_memory_cli.commands.run can't break ai_memory_cli.config.
Position
Below the diagonal: ai_memory_cli.commands.run uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.run uses ai_memory_cli.cli, so a change to ai_memory_cli.cli can break ai_memory_cli.commands.run, while a change to ai_memory_cli.commands.run can't break ai_memory_cli.cli.
Position
Below the diagonal: ai_memory_cli.commands.run uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.run uses ai_memory_cli.http_client, so a change to ai_memory_cli.http_client can break ai_memory_cli.commands.run, while a change to ai_memory_cli.commands.run can't break ai_memory_cli.http_client.
Position
Below the diagonal: ai_memory_cli.commands.run uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.serve uses ai_memory_core.ids, so a change to ai_memory_core.ids can break ai_memory_cli.commands.serve, while a change to ai_memory_cli.commands.serve can't break ai_memory_core.ids.
Position
Below the diagonal: ai_memory_cli.commands.serve uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.serve uses ai_memory_core.actor, so a change to ai_memory_core.actor can break ai_memory_cli.commands.serve, while a change to ai_memory_cli.commands.serve can't break ai_memory_core.actor.
Position
Below the diagonal: ai_memory_cli.commands.serve uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.serve uses ai_memory_llm.health, so a change to ai_memory_llm.health can break ai_memory_cli.commands.serve, while a change to ai_memory_cli.commands.serve can't break ai_memory_llm.health.
Position
Below the diagonal: ai_memory_cli.commands.serve uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.serve uses ai_memory_store.decay, so a change to ai_memory_store.decay can break ai_memory_cli.commands.serve, while a change to ai_memory_cli.commands.serve can't break ai_memory_store.decay.
Position
Below the diagonal: ai_memory_cli.commands.serve uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.serve uses ai_memory_store.reader, so a change to ai_memory_store.reader can break ai_memory_cli.commands.serve, while a change to ai_memory_cli.commands.serve can't break ai_memory_store.reader.
Position
Below the diagonal: ai_memory_cli.commands.serve uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.serve uses ai_memory_store.writer, so a change to ai_memory_store.writer can break ai_memory_cli.commands.serve, while a change to ai_memory_cli.commands.serve can't break ai_memory_store.writer.
Position
Below the diagonal: ai_memory_cli.commands.serve uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.serve uses ai_memory_wiki.wiki, so a change to ai_memory_wiki.wiki can break ai_memory_cli.commands.serve, while a change to ai_memory_cli.commands.serve can't break ai_memory_wiki.wiki.
Position
Below the diagonal: ai_memory_cli.commands.serve uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.serve uses ai_memory_consolidate.consolidator, so a change to ai_memory_consolidate.consolidator can break ai_memory_cli.commands.serve, while a change to ai_memory_cli.commands.serve can't break ai_memory_consolidate.consolidator.
Position
Below the diagonal: ai_memory_cli.commands.serve uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.serve uses ai_memory_consolidate.sweep, so a change to ai_memory_consolidate.sweep can break ai_memory_cli.commands.serve, while a change to ai_memory_cli.commands.serve can't break ai_memory_consolidate.sweep.
Position
Below the diagonal: ai_memory_cli.commands.serve uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.serve uses ai_memory_consolidate.dream, so a change to ai_memory_consolidate.dream can break ai_memory_cli.commands.serve, while a change to ai_memory_cli.commands.serve can't break ai_memory_consolidate.dream.
Position
Below the diagonal: ai_memory_cli.commands.serve uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.serve uses ai_memory_cli.config, so a change to ai_memory_cli.config can break ai_memory_cli.commands.serve, while a change to ai_memory_cli.commands.serve can't break ai_memory_cli.config.
Position
Below the diagonal: ai_memory_cli.commands.serve uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.serve uses ai_memory_mcp.server, so a change to ai_memory_mcp.server can break ai_memory_cli.commands.serve, while a change to ai_memory_cli.commands.serve can't break ai_memory_mcp.server.
Position
Below the diagonal: ai_memory_cli.commands.serve uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.serve uses ai_memory_cli.cli, so a change to ai_memory_cli.cli can break ai_memory_cli.commands.serve, while a change to ai_memory_cli.commands.serve can't break ai_memory_cli.cli.
Position
Below the diagonal: ai_memory_cli.commands.serve uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.status uses ai_memory_core.i18n, so a change to ai_memory_core.i18n can break ai_memory_cli.commands.status, while a change to ai_memory_cli.commands.status can't break ai_memory_core.i18n.
Position
Below the diagonal: ai_memory_cli.commands.status uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.status uses ai_memory_llm.health, so a change to ai_memory_llm.health can break ai_memory_cli.commands.status, while a change to ai_memory_cli.commands.status can't break ai_memory_llm.health.
Position
Below the diagonal: ai_memory_cli.commands.status uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.status uses ai_memory_cli.config, so a change to ai_memory_cli.config can break ai_memory_cli.commands.status, while a change to ai_memory_cli.commands.status can't break ai_memory_cli.config.
Position
Below the diagonal: ai_memory_cli.commands.status uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.status uses ai_memory_cli.cli, so a change to ai_memory_cli.cli can break ai_memory_cli.commands.status, while a change to ai_memory_cli.commands.status can't break ai_memory_cli.cli.
Position
Below the diagonal: ai_memory_cli.commands.status uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.status uses ai_memory_cli.http_client, so a change to ai_memory_cli.http_client can break ai_memory_cli.commands.status, while a change to ai_memory_cli.commands.status can't break ai_memory_cli.http_client.
Position
Below the diagonal: ai_memory_cli.commands.status uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.doctor uses ai_memory_core.i18n, so a change to ai_memory_core.i18n can break ai_memory_cli.commands.doctor, while a change to ai_memory_cli.commands.doctor can't break ai_memory_core.i18n.
Position
Below the diagonal: ai_memory_cli.commands.doctor uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.doctor uses ai_memory_core.ids, so a change to ai_memory_core.ids can break ai_memory_cli.commands.doctor, while a change to ai_memory_cli.commands.doctor can't break ai_memory_core.ids.
Position
Below the diagonal: ai_memory_cli.commands.doctor uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.doctor uses ai_memory_workstream.harness, so a change to ai_memory_workstream.harness can break ai_memory_cli.commands.doctor, while a change to ai_memory_cli.commands.doctor can't break ai_memory_workstream.harness.
Position
Below the diagonal: ai_memory_cli.commands.doctor uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.doctor uses ai_memory_store.reader, so a change to ai_memory_store.reader can break ai_memory_cli.commands.doctor, while a change to ai_memory_cli.commands.doctor can't break ai_memory_store.reader.
Position
Below the diagonal: ai_memory_cli.commands.doctor uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.doctor uses ai_memory_cli.config, so a change to ai_memory_cli.config can break ai_memory_cli.commands.doctor, while a change to ai_memory_cli.commands.doctor can't break ai_memory_cli.config.
Position
Below the diagonal: ai_memory_cli.commands.doctor uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.doctor uses ai_memory_cli.cli, so a change to ai_memory_cli.cli can break ai_memory_cli.commands.doctor, while a change to ai_memory_cli.commands.doctor can't break ai_memory_cli.cli.
Position
Below the diagonal: ai_memory_cli.commands.doctor uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.doctor uses ai_memory_cli.http_client, so a change to ai_memory_cli.http_client can break ai_memory_cli.commands.doctor, while a change to ai_memory_cli.commands.doctor can't break ai_memory_cli.http_client.
Position
Below the diagonal: ai_memory_cli.commands.doctor uses a module listed above it, which is the healthy direction.
ai_memory_cli.commands.doctor uses ai_memory_cli.commands.backfill, so a change to ai_memory_cli.commands.backfill can break ai_memory_cli.commands.doctor, while a change to ai_memory_cli.commands.doctor can't break ai_memory_cli.commands.backfill.
Position
Below the diagonal: ai_memory_cli.commands.doctor uses a module listed above it, which is the healthy direction.
At a glance — Code Health · 64% · Adequate · gated by D2, R3 ·
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 category
Findings
Severity
A05:2025 — Injection
135
High / Critical
A03:2025 — Software Supply Chain Failures
11
High / Critical
A02:2025 — Security Misconfiguration
4
High / Critical
Roadmap
Top priorities: Split each oversized file along the responsibilities already in it, into smaller focused modules in the same package; Act on each finding's own remediation rather than one rule: the move depends on what recurs. Where the copies are executable blocks, give the shared part one home and call it from each site; where they are declarations, a listing, a specialisation already delegating to its base, or one shape repeated per entity, there is no call site and the move is a shared type, a generated set or a factory — sometimes there is nothing to extract; Fix the listed violations: move the shared test helper into a source directory production code may depend on (3 rows).
Ranked by impact ÷ effort. "Helps" is the estimated gain on the 0–100 health score.
Do this
Helps
Effort
Dimension
Split each oversized file along the responsibilities already in it, into smaller focused modules in the same package.
Act on each finding's own remediation rather than one rule: the move depends on what recurs. Where the copies are executable blocks, give the shared part one home and call it from each site; where they are declarations, a listing, a specialisation already delegating to its base, or one shape repeated per entity, there is no call site and the move is a shared type, a generated set or a factory — sometimes there is nothing to extract.
Bring the 5 bodies over 120 down to 120 or less in Cognitive Complexity — start with ai_memory_cli::commands::hook::run_with_payload_in_home (cognitive 233), ai_memory_cli::commands::run::run_once_with_wiring (cognitive 196), ai_memory_cli::commands::hook_spool::drain_with_live_token (cognitive 182).
Bring the 9 bodies over 60 down to 60 or less in Cyclomatic Complexity — start with ai_memory_store::writer::worker_loop (cyclomatic 152), ai_memory_cli::commands::hook::run_with_payload_in_home (cyclomatic 151), ai_memory_cli::commands::run::run_once_with_wiring (cyclomatic 146).
Strengthen data-at-rest protection: vault your keys (AWS KMS / Secrets Manager, GCP KMS / Secret Manager, Azure Key Vault, HashiCorp Vault — not a key read from an environment variable beside the data) and encrypt the most sensitive columns (an AEAD over the field before Diesel/sqlx write it, SQLCipher, pgcrypto) — partial coverage still leaves gaps.
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 — 21
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 — 1621
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 — 100
Recorded, with no effect on how the codebase functions.
Present so the survey is complete, not because it needs doing.
Could not be resolved — 13
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 76 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 — 76 dimensions across the health lenses
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
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, 1705 of 1742 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.)
Is there a tool behind the number? Every score below names the method that produced it: Roslyn, git or a scanner, not a narrative.
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.
Method
Backs
Version
Evaluator
Roslyn static analysis
Complexity, cohesion, coupling, dead code, API surface, layering
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 Swift half could not be measured — the Swift suite in companions/ai-memory-macos produced no coverage export. Coverage is excluded from the score rather than counted as a near-zero. This is OUR limitation, not a defect in the repo.
D10 Test Quality — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. The 156 test(s) behind this row are the ones the JavaScript/TypeScript census could read, and this repository also carries at least 212 test source file(s) (.rs) that it cannot: it reads JavaScript/TypeScript test declarations off disk, so a JUnit/pytest-style suite is invisible to it. Skipped tests, zero-assertion tests and the other quality signals on this row are UNMEASURED in that suite — their absence from the counts above is a gap in this analyzer's language coverage, not a finding that those tests are sound.
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 source is present (.rs, .ts) and this repository declares a Cargo test suite (repository root, 482 test files), but it was not re-run: its build outgrew the 7 GB scratch ceiling (7.459 GB measured) and was stopped; its suite was not run. Not scored — this is a gap in the analyzer's language coverage, not a finding about this repository.
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.
D21 Naming Consistency — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. D21's naming rules read C# through Roslyn and every other language through its sidecar model; these languages are left out (PHP's reading is its own change, a Roslyn-loaded VB or F# project has no population builder yet). Their declarations carry no naming verdict this run — this says nothing about whether their names are consistent.
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 — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. D22's deterministic call-shape rules are gated on C# first (docs/plans/deterministic-engine.md, P5): each other language is switched on only after its own concept suite and A/B gate pass. This says nothing about whether that surface is consistent.
D24 Comment Value — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. Each source language's comment syntax, and the code a comment annotates in it, needs its own proof before D24 judges it. Until then those comments are left unread, not counted as clean.
D27 Navigability — 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. Navigability is taken over call sites whose callee resolved. For C# that population includes calls into referenced assemblies; for this language only calls declared inside the repository count, so the abstention threshold reads the repository's use of its standard library as a resolution failure. That is a limit of this analyzer, not a build problem in this repository.
D32 Data Compliance (PII/GDPR) — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. `companions/ai-memory-ts/src/index.ts`, `companions/ai-memory-ts/src/types.ts` 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 docker/.env.production not found: stat docker/.env.production: no such file or directory; runtime evidence skipped.
GD1 Unfinished & placeholder code — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, F#, JavaScript/TypeScript, Dart, Ruby and Scala source only, and this repository's Rust, Swift is most of its product and is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
IC1 Incompleteness & stubs — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, JavaScript/TypeScript, Java, Dart, Ruby and Scala source only, and this repository's Rust, Swift is most of its product and is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
M4 Documentation accuracy — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. M4 checks only the claim kinds adjudicated at or above 95 % precision: links and versions (PREREGISTRATION version 9), and artefact counts an order of magnitude off. Paths, command arguments, installs, environment variables, settings, projects, packages, routes, cd targets, infrastructure products and removed modules are read but not checked, and none of them is reported or counted.
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.
X17 Uncapped recursion over a caller-supplied document — 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 reads C# syntax, and JavaScript/TypeScript, Go, PHP, Dart, Kotlin, Ruby, Scala, Java, Python and Rust source only, and no C# was loaded, and no named async function in this repository's JavaScript/TypeScript, nor any Go, PHP or Dart function or Kotlin suspend function, makes a request that can be cancelled (fetch, axios, ky, ofetch, got, undici, node:http; net/http, net.Dial; amphp; Dio; Ktor, OkHttp), so there is nothing to judge, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
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.
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.
D10 Test Quality: Assertion density is structural — it cannot tell a meaningful behavioural assertion from a trivial one, only that an assertion is present.
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 Secret Scanning: Secret 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.
D16 Bus Factor: Bus-factor is a time-decayed model of commit attribution (who has recently, repeatedly worked a file), not comprehension — pairing, review and reading-without-committing spread knowledge it can't see; bot commits and shared accounts still distort it.
D17 Explicit Debt: Acknowledged-debt signals (TODO/FIXME, suppressions, dead code) are textual — undocumented debt that nobody marked, and debt that lives in design rather than annotations, is invisible. Committed machine-written code (scaffolded migrations, designer/codegen output, generated stubs) is excluded — it is never the team's dead code to delete.
D19 Documentation Quality: Documentation quality publishes two things only: a runnable or packaged unit with no example, and a multi-project root README that maps none of its parts. It does not judge clarity, and its other checks (overview, licence, boilerplate, structure, empty sections, XML-doc coverage) are withheld after adjudication: their candidates are counted in the card's gaps, not shown as rows. A false statement in a document is M4's; units are .NET projects only.
D20 ADR Quality: ADR quality checks the structure of the decision records present: it cannot know about decisions made and never recorded, and it does not judge how well a record argues its case. Records in a language the section lexicon does not cover are not evaluated.
D24 Comment Value: Comment value is measured as redundancy only: a comment that repeats its code's words is found, but a paraphrase in other words, a vague comment, or one the code contradicts is not, and whether a comment is valuable is not claimed. Comments in other scripts or languages, and outside C#, are not judged.
D26 Project Cohesion: Project focus is sized from members/namespaces per project — a project that is broad by deliberate design reads the same as one that has sprawled.
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.
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 Dockerfile (D31's subject), in a CI workflow (D29's), or in a file this pass does not parse (go.mod, a Gemfile ruby directive) is invisible here, which is why a repository declaring none of them abstains rather than scoring. Only frameworks with a PUBLISHED support policy are tracked: React, Flask and Express publish none, so their age cannot be judged and their absence from a report is not a statement that they are supported.
AC1 Text alternatives: Alt-text is detected structurally — the scan sees that an alternative EXISTS, not whether it meaningfully describes the image, and decorative-vs-missing is judged by attribute shape; runtime-injected images and a non-role=img decorative svg are out of scope. This is accessibility readiness, never a WCAG conformance claim.
AC2 Forms & labels: Label association is read from static markup — a label wired up at runtime (JS-set aria-labelledby, framework-injected ids) reads as missing, a present label says nothing about whether its text is correct. A known UI-library field component (e.g. a JSX <TextField>) is now checked conservatively — flagged only when it carries NO label/aria-label/aria-labelledby/id/name — but wrapper/context-labelled libraries (Chakra/Radix FormControl+FormLabel) aren't statically visible (possible false positive) and non-JSX lowercased components are still skipped. A click handler on a plain element is now asked for a name too (it is a control the author declared), but the subtree test that answers it is deliberately generous: any DYNAMIC text expression in the subtree counts as a name, so an icon chosen by a ternary ({cond ? <IconA/> : <IconB/>}) reads as named, and a glyph component from a library the icon-import list does not know still names its parent. A clean result is "no unlabelled control found", not a labelling proof.
AC3 Page structure: Page structure is read from the static markup tree — landmarks, headings and lang injected at runtime aren't seen, heading ORDER is checked structurally (not against the rendered visual hierarchy), and lang/title/main fire only on full documents, never partials, and the data-table check sees header-cell presence (a <th> exists), not whether each header correctly associates with its cells. Static readiness, not conformance.
AC5 ARIA correctness: ARIA correctness is checked against the static role/attribute shape — roles/attributes set dynamically aren't seen, a valid role says nothing about whether it matches the element's real behaviour, and required-state checks are suppressed when a JSX spread could supply them. The two-branch toggle check (a control whose state is conveyed only by which of two mutually exclusive branches renders) reads CONDITIONALS THAT ARE ATTRIBUTES — Vue v-if/v-else/v-show and Alpine x-if/x-show — so the same toggle written as a Svelte {#if} block or a JSX ternary is control flow the markup model never projects as a branch and is not seen at all.
AC6 Visual & motion safety: Contrast and motion safety are PARTIAL by construction — literal colours (hex/rgb/hsl/named) in inline styles, in-repo <style> blocks, in-repo .css files, var() tokens, Tailwind neutral utilities and CSS-in-JS top-level declarations are read (same-rule/same-element colour+background pairs only); computed/runtime/theme colour, external-CDN stylesheets, CSS-in-JS dynamic (${…}) and nested-selector colours, cross-element pairs and image contrast stay out of reach, so a clean result is bounded by what the static CSS itself shows.
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.
C3 Audit Trail: This control is scored from in-repo evidence only — a working control configured outside the repository leaves no signal a static scan can credit.
C4 Data Retention: This control is scored from in-repo evidence only — its real-world effectiveness, exercised only at runtime, is outside a static scan.
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.
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.
149 method(s) exceeded the cyclomatic complexity threshold of 15; the worst was ai_memory_store::writer::worker_loop at 152. A further 19 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 ai_memory_cli::commands::install_mcp::mcp_config_path_with at 33 — they are counted neither in the figure above nor in this dimension's score. 9 files carry no cyclomatic complexity row at all for this reason — every one of their over-threshold functions was excluded, so the exclusion is disclosed nowhere in the file itself: crates/ai-memory-core/src/ids.rs (AgentKind::as_str at 31), crates/ai-memory-web/src/templates.rs (ai_memory_web::templates::agent_label at 31), crates/ai-memory-cli/src/cli.rs (AgentChoice::kind at 27), crates/ai-memory-cli/src/commands/jail_folders.rs (PickerState::handle at 21), crates/ai-memory-core/src/okf.rs (ai_memory_core::okf::derive_type at 20), and 4 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.
+ 25 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Bring the 9 bodies over 60 down to 60 or less in Cyclomatic Complexity — start with ai_memory_store::writer::worker_loop (cyclomatic 152), ai_memory_cli::commands::hook::run_with_payload_in_home (cyclomatic 151), ai_memory_cli::commands::run::run_once_with_wiring (cyclomatic 146). — This score is capped by its worst body, so a finding fixed alone moves it by almost nothing — the next one down takes its place. Refactoring these 9 together lifts Cyclomatic Complexity from 5.6 to about 6.5/10, projected with the scoring formula itself and assuming each lands exactly at 60; a cleaner split scores higher.
Detailed fixes: d1_recommendation.md · top locations in Appendix A, every location in findings.md.
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.
+ 39 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Bring the 5 bodies over 120 down to 120 or less in Cognitive Complexity — start with ai_memory_cli::commands::hook::run_with_payload_in_home (cognitive 233), ai_memory_cli::commands::run::run_once_with_wiring (cognitive 196), ai_memory_cli::commands::hook_spool::drain_with_live_token (cognitive 182). — 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 5 together lifts Cognitive Complexity from 3.7 to about 4.7/10, projected with the scoring formula itself and assuming each lands exactly at 120; a cleaner split scores higher.
Detailed fixes: d2_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D3 · God Classes8.9 / 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.
+ 2 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 111 FunctionTooLong finding(s) in God Classes — start with ops.rs (13), admin.rs (9), workstream.rs (6). — One of this dimension's main actionable groups (111 warning-level).
Resolve the 73 FileTooLong finding(s) in God Classes — start with profile.rs (4), workstream.rs (2), auto_improve.rs (2). — One of this dimension's main actionable groups (73 warning-level).
Resolve the 40 MethodTooLong finding(s) in God Classes — start with reader.rs (22), server.rs (10), consolidator.rs (2). — One of this dimension's main actionable groups (40 warning-level).
Detailed fixes: d3_recommendation.md · top locations in Appendix A, every location in findings.md.
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.
394 duplicated block group(s) detected. 3.2 % of the production lines (16,135 of 498,897) are in a reported copy. A further 229 rows report members as variants of one another; the share counts each copied line once, however many rows cite it.
+ 171 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 40 Duplicated block (8 lines × 2) finding(s) in Code Duplication — start with admin.rs (5), reader.rs (4), hook_spool.rs (3). — One of this dimension's main actionable groups (40 warning-level).
Resolve the 33 Duplicated block (7 lines × 2) finding(s) in Code Duplication — start with install_hooks.rs (3), transcript.rs (2), scrub.rs. — One of this dimension's main actionable groups (33 warning-level).
Resolve the 30 Duplicated block (6 lines × 2) finding(s) in Code Duplication — start with reader.rs (6), install_hooks.rs (3), mcp.rs (2). — One of this dimension's main actionable groups (30 warning-level).
Detailed fixes: d4_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D5 · Coupling7.4 / 10Strong✓ 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.
19 production modules (Cargo+npm+SwiftPM), 0 dependency cycle(s), 1 unstable depended-on module(s). Read from the build's own module declarations; 5 module(s) off the main sequence.
Off the main sequence: ai-memory-client · ×5
Unstable project ai-memory-mcp
What to do
Resolve the 5 Off the main sequence finding(s) in Coupling. — One of this dimension's main actionable groups (5 warning-level).
Resolve the 1 Unstable project ai-memory-mcp finding(s) in Coupling. — One of this dimension's main actionable groups (1 warning-level).
Detailed fixes: d5_recommendation.md · top locations in Appendix A, every location in findings.md.
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.
Resolve the 2 Low cohesion finding(s) in Cohesion (LCOM4) — start with dream.rs, auth.rs. — One of this dimension's main actionable groups (2 warning-level).
Detailed fixes: d6_recommendation.md · top locations in Appendix A, every location in findings.md.
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.
No mechanizable ADR was identified, so enforcement is not measured. Dependency cycles not checked (no project-reference graph; where this repository's language has an import-cycle lens, cycles are reported there).
Detailed fixes: d7_recommendation.md.
Do you agree with this assessment?
D10 · Test Quality10.0 / 10Exemplary✓ Tool-verified
What it measures: Whether the tests truly assert behaviour rather than just running the code.
Method: Per-test assertions, skips, and mock references analyzed via Roslyn; structured skip-reason tags (BUG:/ENV:) separate documented deferrals from debt. Deterministic.
0 skipped, 0 zero-assertion, no mocking-framework packages referenced (hand-written doubles or no mocking) across 156 tests. Measured on the JavaScript/TypeScript suite only — at least 212 test source file(s) (.rs) went unread, so its test quality is unmeasured and is not in these counts.
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.
23 outdated, 0 yanked direct Cargo dependencies. 67 of 74 direct crates were graded against crates.io (0 not published there, 7 not resolved by a committed REDACTED). Only DIRECT edges are graded: a transitive crate cannot be moved past what its parent's requirement admits, so reporting one would be advice its owner cannot take. A newer release is reported only where this repository's OWN requirement already admits it, so the remedy is `cargo update` and never a manifest edit — which means a release outside the declared range is deliberately NOT charged, because a written-down constraint is a decision rather than a defect. Note that a bare requirement is a CARET, and for a 0.x crate its ceiling is the minor. Whether any crate is UNMAINTAINED is not graded — crates.io publishes no maintenance status, and release age does not stand in for one. Known CVEs in this dependency graph are D30's question, read from REDACTED there.
Outdated: anyhow · ×23
Detailed fixes: d12_recommendation.md · top locations in Appendix A, every location in findings.md.
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.
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.
0 of 519 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. A further 1 crate(s) in the closure resolve from git, a path or a private registry and publish no licence this pass can read; they are outside this verdict. This repository publishes itself under MIT, which is its own choice and is not judged here.
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.
Top hotspots: crates/ai-memory-hooks/src/router.rs (173×101=17473); crates/ai-memory-cli/src/commands/install_hooks.rs (171×96=16416); crates/ai-memory-cli/src/commands/hook.rs (100×151=15100) Repeated repair below the complexity floor: crates/ai-memory-cli/src/commands/render_shared.rs (54 of 91 changes were fixes); crates/ai-memory-hooks/src/payload.rs (33 of 64 changes were fixes); crates/ai-memory-cli/src/commands/backfill.rs (26 of 42 changes were fixes)
Resolve the 92 Repeated repair finding(s) in Churn × Complexity Hotspots — start with error.rs (3), markdown.rs (2), profile.rs (2). — One of this dimension's main actionable groups (92 warning-level).
Resolve the 65 Hotspot finding(s) in Churn × Complexity Hotspots — start with workstream.rs (2), mod.rs (2), presentation.rs (2). — One of this dimension's main actionable groups (65 warning-level).
Detailed fixes: d15_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D16 · Bus Factor9.3 / 10Exemplary✓ Tool-verified
What it measures: Whether knowledge is concentrated in too few people (the "bus factor").
Method: Living knowledge per author via time-decayed commit attribution (6-month half-life, focus weighting) across largest source files. Deterministic, avoids blame's mechanical-refactor false positives.
25 source file(s) have their living knowledge concentrated in one author (≥90% of recent, decayed contribution). The largest is crates/ai-memory-cli/src/commands/setup_web.rs. Counted over 371 of the 406 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.
Off-boarding risk: anonymized user #1
Further sole-owners (lower concentration)
✓ On the Gold path — maintain.
Detailed fixes: d16_recommendation.md · top locations in Appendix A, every location in findings.md.
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.
0 deducted task-comment markers across 498897 LoC (0.0/KLoC) → score 10.0. Task comments only: this repository's language is read without a compiler, so D17's suppression, dead-code and commented-out-code arms did not run and this score counts fewer marker kinds than a .NET repository's would.
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.
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.
0 of 2 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.
What it measures: Whether comments are worth it — explaining WHY (valuable) rather than WHAT (redundant).
Method: Every inline C# comment compared word by word with the identifiers, literals and constructs of the code it annotates (taken from the syntax); a comment whose words that code already contains is redundant, as are closing-brace labels and generator template text. Comments giving a reason or a reference are kept; other scripts and languages are not judged. Deterministic, exhaustive, advisory.
3 of 19 build units (Cargo, SwiftPM, npm) flagged as possibly oversized/incoherent.
Projects may be oversized for their cohesion
What to do
Resolve the 1 Projects may be oversized for their cohesion finding(s) in Project Cohesion. — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d26_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether any secrets were ever committed — scanned across the full git history, not just now.
Method: Secret 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.
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).
150 finding(s): 0 critical, 16 high, 134 medium, 0 low. semgrep hit a parse error in 39 file(s) — `bin/ai-memory`, `bin/release` (lines 141–214), `companions/ai-memory-ts/src/index.ts` (line 58), `companions/ai-memory-ts/src/types.ts` (line 12, line 97), `crates/ai-memory-cli/src/commands/doctor.rs` (line 1077, line 1078, line 1079), … (+34 more) — so no absence of findings in the named regions is evidence of anything; rows reported elsewhere in those files are real. Fix the syntax error (or exclude the file deliberately) and re-scan to cover them. Separately, one or more rules could not re-parse an embedded snippet in 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
+ 5 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 4 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (4). — One of this dimension's main actionable groups (4 issue-level).
Resolve the 2 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (2). — One of this dimension's main actionable groups (2 issue-level).
Resolve the 2 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (2). — One of this dimension's main actionable groups (2 issue-level).
Detailed fixes: d29_recommendation.md · top locations in Appendix A, every location in findings.md.
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.
Resolve the 1 Critical CVE finding(s) in Dependency Vulnerabilities — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).
Resolve the 5 Medium advisory (unsound) finding(s) in Dependency Vulnerabilities — start with REDACTED (5). — One of this dimension's main actionable groups (5 warning-level).
Resolve the 1 Medium vulnerability finding(s) in Dependency Vulnerabilities — start with REDACTED. — One of this dimension's main actionable groups (1 warning-level).
Detailed fixes: d30_recommendation.md · top locations in Appendix A, every location in findings.md.
Resolve the 3 High IaC finding(s) in IaC & Container Security — start with REDACTED (2), REDACTED. — One of this dimension's main actionable groups (3 issue-level).
Resolve the 1 Medium IaC finding(s) in IaC & Container Security — start with REDACTED. — One of this dimension's main actionable groups (1 warning-level).
Detailed fixes: d31_recommendation.md · top locations in Appendix A, every location in findings.md.
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.
Every significant source file has living knowledge — recently and meaningfully worked. Counted over 371 of the 406 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.
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.
Resolve the 3 Change coupling finding(s) in Change Coupling — start with client.ts, coverage.ts, curator.rs. — One of this dimension's main actionable groups (3 warning-level).
Detailed fixes: d35_recommendation.md · top locations in Appendix A, every location in findings.md.
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.
What it measures: Whether the repository publishes a coordinated-vulnerability-disclosure policy (SECURITY.md or security.txt) with a reporting contact, so finders know how to report a vulnerability. Presence of a policy file with a contact, not whether the policy is adequate or honoured.
Method: Vulnerability-disclosure policy read deterministically from the repo: a SECURITY.md (root/.github/docs) or .well-known/security.txt / security.txt, regex-checked for a reporting contact (email / URL / mailto). Present + contact → 10; present without a contact → 4; NotApplicable when no policy file exists (it may live off-repo). Detects the policy file's presence + contact, not its adequacy.
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.
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.
1 end-of-life runtime(s) and 0 end-of-life framework(s), read from 2 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.
Resolve the 1 End-of-life runtime finding(s) in Platform End-of-Life — start with rust-toolchain.toml. — 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.
Do you agree with this assessment?
Frontend & cross-cutting dimensions
R = React/JS · M = Maturity · P = Readiness.
AC1 · Text alternatives10.0 / 10Exemplary○ Nothing flagged
Other · Accessibility — Whether non-text content carries a text alternative — img/area/input[type=image] have alt, a meaningful svg has a title or aria-label, video has a captions track, and object/embed/canvas have a name or fallback content. Static markup readiness, not a WCAG conformance claim.
Method: Static markup-model scan: every img/area/input[type=image] checked for alt, svg[role=img] for a title/aria-label, video for a captions <track>. Components skipped, spreads suppressed. Deterministic, hard fact per element.
Coverage: Population: image/media elements — img, area, input[type=image], svg, video, object, embed, canvas — across the PARSED MARKUP files only (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx); components, hidden subtrees and dynamic-attribute elements are skipped. Markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is NOT read by any producer, so it contributes no element to this population; where such a frontend is present the card discloses it as an analyzer gap rather than scoring around it.
Do you agree with this assessment?
AC2 · Forms & labels7.9 / 10Strong✓ Tool-verified
Other · Accessibility — Whether form controls have a programmatic label (an associated label, aria-label or aria-labelledby), buttons have text, links have an accessible name, a click handler on a plain element names the control it declares, fieldsets have a non-empty legend, known UI-library field components carry a label prop, and a placeholder isn't used as the only label. Static markup readiness, not a WCAG conformance claim.
Method: Static markup-model scan: inputs/selects/textareas checked for an associated label[for]/wrapping label/aria-label/aria-labelledby (per document), buttons for accessible text, fieldsets for a legend; placeholder-only labelling flagged. Deterministic, hard fact per control.
Coverage: Population: form controls, buttons, links, fieldsets and known UI-library field components in the PARSED MARKUP files only (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx); components, hidden subtrees and spread/dynamic-attribute elements are skipped, so a control whose label arrives through a spread or a runtime expression is deliberately not judged. Markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is not read at all.
This <label> has no for and wraps no form control, so it names nothing: assistive tech never announces it, and clicking the caption focuses no field. Note that an id on the label is not an association — it is the TARGET of one, so a control still has to point at it. Give the label for="<the control's id>", move the control inside the label, or point the control's aria-labelledby at this label's id. — crates/ai-memory-core/locales/en/diagnostics.ftl:155
What to do
Give every control a programmatic label (a <label for> / wrapping <label> / aria-label) and every button text — a placeholder is not a label.
Other · Accessibility — Whether pages declare a language (well-formed BCP-47) and a non-empty title, expose exactly one main landmark and a sane heading order with non-empty headings, keep zoom enabled, title their iframes, give data tables header cells, and avoid meta-refresh. Static markup readiness, not a WCAG conformance claim.
Method: Static markup-model scan: html lang, document <title>, a main landmark and heading order on full documents only, plus zoom-disabling viewports, untitled iframes and meta-refresh anywhere. Deterministic, per structural checkpoint.
Coverage: Population: the PARSED MARKUP documents (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx). The page-level checks — lang, title, single main landmark — fire ONCE PER FULL DOCUMENT (an <html> root) and never on a partial or component fragment, so a repo of fragments is assessed only on the per-element checks (heading order, table headers, iframe titles, meta-refresh, zoom). Markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is not read at all.
Other · Accessibility — Whether ARIA is used correctly — valid non-abstract roles, the ARIA state a role requires, valid (non-misspelled) aria-* attribute names, in-enum values for token-typed aria-* attributes, and no aria-hidden on (or wrapping) a focusable element. Static markup readiness, not a WCAG conformance claim.
Method: Static markup-model scan: role values checked against the WAI-ARIA role set (abstract/invalid flagged), required ARIA state for a role, and aria-hidden on a focusable element. Deterministic, role/attribute level.
Coverage: Population: elements in the PARSED MARKUP files (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx) that carry a role or an aria-* attribute; roles and token values are checked against the ARIA enums exhaustively within that set. An expression-valued (dynamic) role or aria-* value is skipped rather than guessed, and markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is not read at all.
Other · Accessibility — Whether focus outlines aren't removed without a replacement, motion respects prefers-reduced-motion, and literal CSS colour pairs meet contrast — PARTIAL: inline styles, in-repo <style> blocks, in-repo .css files, var() tokens, Tailwind neutral utilities and CSS-in-JS literals are read (hex/rgb/hsl/named), never computed/runtime/external-CDN colour. Static markup readiness, not a WCAG conformance claim.
Method: Static markup/CSS scan: inline outline:none/0, literal inline colour/background contrast against the 4.5:1 AA floor, and <style>-block animation without a prefers-reduced-motion guard. Deterministic but PARTIAL — only inline styles and in-repo CSS literals are visible.
Coverage: Population: styled elements in the PARSED MARKUP files (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx), plus in-repo <style> blocks, in-repo .css files and CSS-in-JS literals. Colour contrast is computed from LITERAL colour pairs only (hex/rgb/hsl/named, including var() tokens and Tailwind neutral utilities) — computed, runtime-themed and external-CDN colour is never resolved, so this is a partial read of contrast by construction. Markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is not read at all.
This element's Tailwind text/background colour utilities fall below the 4.5:1 WCAG AA minimum for normal text. Pick a darker or lighter shade. — REDACTED:36
`.agent-avatar` sets color: #9b6048 on background-color: #f6ebe4 — 4.3:1, below the 4.5:1 WCAG AA minimum for normal text. Darken or lighten one of them. — crates/ai-memory-web/static/input.css:59
`.agent-avatar` sets color: #9b6048 on background-color: #f6ebe4 — 4.3:1, below the 4.5:1 WCAG AA minimum for normal text. This is a MINIFIED, build-generated sheet — editing the literal here is undone by the next vendor drop or rebuild, so override the rule in your own stylesheet (or fix it upstream / in the source the bundle is built from). — crates/ai-memory-web/static/tailwind.css:1
`.app-content` sets the outline to none/0 and no visible :focus / :focus-visible style for that element replaces it in this stylesheet, so a keyboard user cannot see where focus is. Draw a focus ring (outline, box-shadow or border) under :focus-visible. (×2) — crates/ai-memory-web/static/input.css:48, crates/ai-memory-web/static/tailwind.css:1
`.metric-link` moves (`transition: border-color .15s ease,box-shadow .15s ease,transform .15s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce. (×2) — crates/ai-memory-web/static/input.css:53, crates/ai-memory-web/static/tailwind.css:1
What to do
Keep a visible focus style (don't remove the outline without a replacement), guard animation with prefers-reduced-motion, and raise low-contrast colour pairs to at least 4.5:1.
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.
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.
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.
Do you agree with this assessment?
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.
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.
Do you agree with this assessment?
C1 · Data Protection4.0 / 10Weak✓ Tool-verified
Other · Security — Whether sensitive data is encrypted at rest and in transit and keys are vaulted.
Method: Roslyn plus filesystem scan: encryption presence (EF ColumnEncryption, key-vault references, HTTPS enforcement) and key-derivation KDF detection. Deterministic.
No in-app HTTPS enforcement, but the server reads the forwarded scheme (X-Forwarded-Proto, actix's connection_info().scheme(), Rocket's proxy_proto_header) — a TLS-terminating reverse proxy sits in front of it, where serving TLS in the app would be wrong. Verify the reverse proxy enforces TLS. — crates/ai-memory-cli/src/commands/serve.rs:3547
What to do
Strengthen data-at-rest protection: vault your keys (AWS KMS / Secrets Manager, GCP KMS / Secret Manager, Azure Key Vault, HashiCorp Vault — not a key read from an environment variable beside the data) and encrypt the most sensitive columns (an AEAD over the field before Diesel/sqlx write it, SQLCipher, pgcrypto) — partial coverage still leaves gaps.
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.
Do you agree with this assessment?
C3 · Audit Trail7.5 / 10Strong✓ Tool-verified
Other · Security — Whether changes to sensitive data are recorded (who, what, when) for compliance + incident response.
An audit mechanism is present, but the trail is not yet complete — missing: a write-side hook every change flows through (a SeaORM ActiveModelBehavior hook or a database trigger recording each change, or an event-sourced store), per-entity coverage (an event-sourced aggregate, or a hook on each entity that needs a who-changed-what trail).
What to do
Back the audit convention with a structural mechanism: a SeaORM ActiveModelBehavior before_save/after_save hook or a database trigger writing each sensitive change to an audit-log table, with the acting user and time on every entry.
Do you agree with this assessment?
C4 · Data Retention10.0 / 10Exemplary✓ Tool-verified
Other · Security — Whether data has a defined lifetime — retention periods, TTLs, cleanup jobs (storage limitation).
Method: Roslyn scan: retention/TTL configuration presence in schema; CascadeDelete detected but not scored as retention control. Deterministic, gated by PII presence.
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.
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.
2 ADR-shaped document(s) detected by content — `docs/design-decisions.md`, `plugins/claude-code/skills/ai-memory-durable-pages/SKILL.md`. They are not under a conventional ADR folder (docs/adr/) and are not named NNNN-title.md, and this check found them by their decision signature rather than by where they live — so a reader who does not already know these paths has no route to them. Detected by content signature only: records kept outside the repository, or written without a Status/Decision/Consequences shape, are not visible to this check and are not counted here.
What to do
Move ADRs under docs/adr/ (or docs/adrs/) and name them NNNN-title.md so they're easy to find.
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.
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.
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.
Do you agree with this assessment?
P10 · Library API & versioning10.0 / 10Exemplary○ Nothing flagged
Readiness · Readiness — For a library: a deliberate (small) public API surface and explicit semantic versioning so consumers can depend on it safely.
Method: Roslyn scan: public API surface area and semantic-versioning markers (SemVer attributes, changelog entries) for libraries; off .NET, a library is the ecosystem's publication act (an npm package that is not private and names an entry point, a PyPI distribution with a build system, a Rust library crate, a Maven/Gradle module that publishes, a Go module with no package main, a gemspec, a Composer library, a SwiftPM library product, a pub.dev or Hex package), its surface is the share of types the language's code model records as public (Rust, Swift, Java, Kotlin, Go, Dart; not measured where the model records no type visibility or, as in TypeScript, only module-level export), and its version is read from the manifest, a semver CHANGELOG, release tooling or semver git tags. Exhaustive, deterministic.
Do you agree with this assessment?
P2 · Observability6.9 / 10Adequate✓ Tool-verified
Readiness · Readiness — Whether the code is diagnosable in production — structured logging, tracing/metrics, health checks.
Only 10/16 runnable modules use logging (modules with no entry point or server are excluded — they are libraries a runnable module hosts). Silent: `companions/ai-memory-desktop`, `companions/ai-memory-importer`, `companions/ai-memory-macos`, `companions/ai-memory-relay`, `companions/ai-memory-wikisync` and 1 more.
What to do
Extend structured logging to the remaining runnable modules so everything you run is diagnosable in production.
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.
`REDACTED` schedules updates, but no `package-ecosystem` entry covers `npm`, `cargo`, which this tree depends on — so those dependencies get no update pull requests and no advisory pressure, however complete the dep-scan credit looks. Add the missing entries to the `updates:` list. — REDACTED:2
What to do
Dependabot is configured but does not watch `npm`, `cargo` — add those `package-ecosystem` entries to REDACTED so those dependencies get the same automatic update and advisory pressure as the ones it already covers.
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.
Do you agree with this assessment?
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.
Readiness · Readiness — Whether outbound HTTP calls are wrapped in resilience (retry/timeout/circuit-breaker) so a failing dependency doesn't cascade.
Method: Source scan: outbound HTTP clients and what bounds them — resilience handlers (Polly, AddStandardResilienceHandler) on .NET; on Go, the JVM, Python, JavaScript/TypeScript, Ruby, PHP, Rust, Elixir, Swift, Dart and Erlang, a timeout, deadline, retry or breaker beside each call, or a process-wide client default (a framework-wide deadline such as Drupal core's, Laravel's or actix's awc counts). Exhaustive, deterministic.
`reqwest::Client::builder(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout. (×2) — crates/ai-memory-llm/src/oidc.rs:294, crates/ai-memory-llm/src/openai_oauth.rs:158
`reqwest::get(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout. — evals/src/retrieval/dataset.rs:175
What to do
Give every client a whole-request bound: `reqwest::Client::builder().timeout(Duration::from_secs(10))` (never `reqwest::get` or `Client::new()`, which have none), ureq's `timeout_global`, or wrap the call in `tokio::time::timeout`; add retry with back-off (`reqwest-retry`'s `RetryTransientMiddleware`, `backoff`) around dependencies that fail.
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.
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.
Do you agree with this assessment?
R1 · Type Safety8.9 / 10Strong✓ Tool-verified
React / JS · Code Health — How much of the frontend is typed TypeScript vs untyped JavaScript.
Method: Frontend file inventory: the share of typed TypeScript vs untyped JavaScript across the source tree. Deterministic, exhaustive over frontend files.
React / JS · Code Health — The share of the scored frontend lines inside a near-exact copy-pasted block of substantial extent (the D4 clone algorithm over JS/TS tokens, D-386; each line once, 10 at none and 0 at a quarter of the lines, as D4): a block is reported only where its copies still agree on most of their own identifiers and literals, or were renamed as they were pasted but kept most of their constants, and where the copies carry enough code to stand on their own or the copied extent reaches 30 lines — so a re-implementation sharing neither names nor values, and a small pasted declaration, are both found and deliberately not reported, and a clean R10 is not a claim that nothing was copied.
Method: Near-exact copy-pasted blocks of substantial extent across the frontend (the D4 clone algorithm run over JS/TS tokens). Masking finds the candidates; a block is reported when its copies still agree on most of their own identifiers and literals, or when a renamed copy still agrees on most of its constants, AND the copies carry enough code to stand on their own — or when the copied extent reaches 30 lines. So a re-implementation sharing neither names nor values, and a small pasted declaration, are deliberately not counted. Scored on the share of the scored frontend lines inside a reported copy, on the same curve as D4. Deterministic.
companions/ai-memory-ts/src/client.ts:347 · companions/ai-memory-ts/src/client.ts:609 — the two spans are one implementation copied and then locally edited — 516 tokens are still identical, in the same order in both spans, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one. — companions/ai-memory-ts/src/client.ts:347
companions/ai-memory-ts/src/decode.ts:55 · companions/ai-memory-ts/src/decode.ts:77 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — companions/ai-memory-ts/src/decode.ts:55
companions/ai-memory-ts/src/decode.ts:164 · companions/ai-memory-ts/src/decode.ts:325 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — companions/ai-memory-ts/src/decode.ts:164
companions/ai-memory-ts/src/client.ts:661 · companions/ai-memory-ts/src/client.ts:699 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. — companions/ai-memory-ts/src/client.ts:661
companions/ai-memory-ts/src/decode.ts:234 · companions/ai-memory-ts/src/decode.ts:305 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — companions/ai-memory-ts/src/decode.ts:234
companions/ai-memory-ts/src/client.ts:1171 · companions/ai-memory-ts/src/transport.ts:568 — the two spans are one implementation copied and then locally edited — 53 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one. — companions/ai-memory-ts/src/client.ts:1171
companions/ai-memory-ts/src/core.ts:120 · companions/ai-memory-ts/src/core.ts:135 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — companions/ai-memory-ts/src/core.ts:120
companions/ai-memory-ts/src/decode.ts:195 · companions/ai-memory-ts/src/decode.ts:250 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — companions/ai-memory-ts/src/decode.ts:195
companions/ai-memory-ts/src/decode.ts:358 · companions/ai-memory-ts/src/decode.ts:372 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — companions/ai-memory-ts/src/decode.ts:358
companions/ai-memory-ts/src/core.ts:30 · companions/ai-memory-ts/src/scope.ts:20 — the 2 copies are spread across 2 files, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are. — companions/ai-memory-ts/src/core.ts:30
companions/ai-memory-ts/src/client.ts:309 · companions/ai-memory-ts/src/client.ts:364 · companions/ai-memory-ts/src/client.ts:595 · companions/ai-memory-ts/src/client.ts:692 · +1 more site(s) not listed — all 5 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — companions/ai-memory-ts/src/client.ts:309
companions/ai-memory-ts/src/api.ts:174 · companions/ai-memory-ts/src/client.ts:624 · companions/ai-memory-ts/src/client.ts:925 · companions/ai-memory-ts/src/client.ts:1029 · +2 more site(s) not listed — the 6 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — companions/ai-memory-ts/src/api.ts:174
companions/ai-memory-ts/src/decode.ts:151 · companions/ai-memory-ts/src/decode.ts:169 — all 2 copies are in the same file, and the CITED SPAN is a run of DECLARATIONS inside a construct — the members of a type, or the entries of an object or array literal — with no statement anywhere in it. Do not read this as an extract-a-helper row: nothing here executes, so there is no call site, and a call expression cannot stand where a member declaration or a literal's entry was. What repeats is a SHAPE, and which shape decides the move. Where the copies declare the same members, the repetition is a missing common ancestor: give it a base type, an interface both extend, a generic instantiated twice, or — where the copies are a literal's entries rather than a type's members — one shared constant each site spreads or refers to, so the set is written once. Where they declare DIFFERENT members and only the form is shared — a decorator and its options, an annotation, a registration table's keys — the form is prescribed by a framework or a schema rather than copied, and the only collapse available is to generate the declarations from that schema; where you do not own the generator, this is the cost of the framework and there is nothing to extract. Check which of the two it is before acting: these copies still drift apart the first time only one of them is edited, which is why the repetition is reported, but the sentence to act on is not the same in both cases. — companions/ai-memory-ts/src/decode.ts:151
What to do
Act on each finding's own remediation rather than one rule: the move depends on what recurs. Where the copies are executable blocks, give the shared part one home and call it from each site; where they are declarations, a listing, a specialisation already delegating to its base, or one shape repeated per entity, there is no call site and the move is a shared type, a generated set or a factory — sometimes there is nothing to extract.
React / JS · Architecture — Conformance to the detected frontend architecture layout (feature-sliced / layered src) plus cross-package deep-import rules (D-386).
Method: Conformance to the detected frontend layout (feature-sliced / layered src) plus cross-package deep-import rules, over the module graph. Deterministic.
companions/ai-memory-ts/scripts/schema-update.ts:10 imports companions/ai-memory-ts/test/support/tools-list.ts, a module inside the test suite — test helpers carry no compatibility contract and are maintained for the suite, not as an API, so production code that depends on one is coupled to a module nobody keeps stable. Move the shared helper into a source directory both layers may depend on. — companions/ai-memory-ts/scripts/schema-update.ts:10
companions/ai-memory-ts/scripts/schema-update.ts:11 imports companions/ai-memory-ts/test/support/schema.ts, a module inside the test suite — test helpers carry no compatibility contract and are maintained for the suite, not as an API, so production code that depends on one is coupled to a module nobody keeps stable. Move the shared helper into a source directory both layers may depend on. — companions/ai-memory-ts/scripts/schema-update.ts:11
companions/ai-memory-ts/scripts/schema-update.ts:12 imports companions/ai-memory-ts/test/support/server.ts, a module inside the test suite — test helpers carry no compatibility contract and are maintained for the suite, not as an API, so production code that depends on one is coupled to a module nobody keeps stable. Move the shared helper into a source directory both layers may depend on. — companions/ai-memory-ts/scripts/schema-update.ts:12
What to do
Fix the listed violations: move the shared test helper into a source directory production code may depend on (3 rows).
React / JS · Code Health — Per-function cyclomatic/cognitive complexity from the token-level function scanner (D-386) — real branching, not a regex heuristic.
Method: Per-function cyclomatic/cognitive complexity from a token-level function scanner (real branching, not a regex heuristic), computed over every frontend function. Deterministic.
normalizeSchema has cyclomatic complexity 28 and cognitive complexity 43; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — companions/ai-memory-ts/test/support/schema.ts:40
request has cyclomatic complexity 23 and cognitive complexity 29; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — companions/ai-memory-ts/src/transport.ts:280
metadataFromFrontmatter has cyclomatic complexity 22 and cognitive complexity 25; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — companions/ai-memory-ts/src/client.ts:143
query has cyclomatic complexity 18 and cognitive complexity 27; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — companions/ai-memory-ts/src/client.ts:946
main has cyclomatic complexity 17 and cognitive complexity 22; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — tests/e2e/web_dashboard_browser.mjs:141
read has cyclomatic complexity 17 and cognitive complexity 17; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — companions/ai-memory-ts/src/client.ts:433
update has cyclomatic complexity 16 and cognitive complexity 19; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — companions/ai-memory-ts/src/client.ts:542
constructor has cyclomatic complexity 15 and cognitive complexity 15; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — companions/ai-memory-ts/src/transport.ts:200
startServer has cyclomatic complexity 14 and cognitive complexity 24; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — companions/ai-memory-ts/test/support/server.ts:88
paused has cyclomatic complexity 12 and cognitive complexity 11; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — tests/e2e/web_dashboard_browser.mjs:187
httpError has cyclomatic complexity 11 and cognitive complexity 9; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — companions/ai-memory-ts/src/transport.ts:388
Do you agree with this assessment?
R3 · Large Files2.9 / 10Weak✓ Tool-verified
React / JS · Code Health — How many source files exceed the large-file threshold.
Method: Components/modules exceeding the large-file threshold, counted exhaustively across the frontend source tree. Deterministic.
companions/ai-memory-ts/src/client.ts has 1141 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — companions/ai-memory-ts/src/client.ts:1
companions/ai-memory-ts/src/transport.ts has 543 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — companions/ai-memory-ts/src/transport.ts:1
What to do
Split each oversized file along the responsibilities already in it, into smaller focused modules in the same package.
Do you agree with this assessment?
R4 · Test Coverage6.7 / 10Adequate✓ Tool-verified
React / JS · Readiness — Static test reachability (D-386): the share of production files reachable from any test via the import graph — measured without running anything.
Method: Static test reachability: the share of production files reachable from any test via the import graph — measured without running anything. Deterministic.
companions/ai-memory-ts/test/integration/examples.test.ts:14 imports '../../examples/', which names no file in this repository — and no rule in its .gitignore chain could cover one, so no build writes it either. The import throws as the runner collects this file, so none of its test cases run and nothing it was written to verify is verified. Restore the missing module or delete the test. It is excluded from the reachability measured above, because a file that cannot load reaches nothing. — companions/ai-memory-ts/test/integration/examples.test.ts:14
No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one. (×5) — companions/ai-memory-ts/scripts/generate-docs.ts:1, companions/ai-memory-ts/scripts/schema-check.ts:1, crates/ai-memory-web/static/management/theme.js:1, …
What to do
Add tests that import the unreached modules (directly or through their public entry).
React / JS · Readiness — How outdated the npm dependencies are (a maturity signal). JS/npm CVEs are scored separately in D30 (JS/npm Dependency Vulnerabilities).
Method: npm dependency staleness from manifest/registry metadata (a maturity signal; JS/npm CVEs are scored separately in D30, which answers dependency vulnerabilities for every ecosystem). Deterministic.
Do you agree with this assessment?
R6 · Tooling10.0 / 10Exemplary✓ Tool-verified
React / JS · Readiness — Whether the project wires up test, lint and typecheck — detected from each package.json script's COMMAND (eslint / tsc / vitest / jest / playwright), not just its name, and corroborated against CI-workflow invocations so a tool run only in CI still counts.
Method: package.json scanned for test/lint/typecheck script wiring. Deterministic presence check.
This repository declares test tooling, and the ✓ above records that declaration — but companions/ai-memory-ts/test/integration/examples.test.ts cannot be loaded at all: it imports a module that names no file in this repository, so the runner throws while collecting it and none of its cases execute. The wiring is present and the suite it points at does not run as written, which is why the tooling tick must not be read as a statement that the tests pass. Fix the unloadable file(s) — each one is reported with its failing import under Test Coverage — then the declared script exercises what it claims to. — companions/ai-memory-ts/test/integration/examples.test.ts:14
Do you agree with this assessment?
R7 · Dead Code10.0 / 10Exemplary✓ Tool-verified
React / JS · Code Health — Files unreachable from every application/tooling/test entry point, and exports nothing imports (module-graph reachability, D-386).
Method: Dead code: files unreachable from every application/tooling/test entry point plus exports nothing imports, via module-graph reachability. Deterministic, exhaustive over the import graph.
React / JS · Readiness — npm dependency truthfulness (D-386): unused dependencies, imports not declared anywhere, and type-/test-only packages shipped as production deps.
Method: npm dependency truthfulness: unused dependencies, imports declared nowhere, and type-/test-only packages shipped as production deps — from the manifest + import graph. Deterministic.
React / JS · Architecture — Import cycles in the module graph (D-386) — files that can only be understood and changed together.
Method: Import cycles in the module graph, detected exhaustively over JS/TS imports (the same cycle detection as the .NET coupling dimension). Deterministic.
Other · Security — Read from this repository's Rust source: cryptographic hygiene (weak hash or cipher, key material fixed in the source) and outbound TLS (certificate validation, protocol version) — facts about code that hold whether or not it serves anything itself. This repository commits the configuration that serves its own HTTP surface, so that configuration was read in full for the security response headers it sets. This repository serves HTTP itself (`axum::serve(` (crates/ai-memory-cli/src/commands/setup_web.rs:228)), so its Rust source was also read for the server controls: TLS served or HSTS set, security response headers, cookie flags and inbound validation — each credited where its Rust spelling appears in production source, not proven on every route. A Rocket 0.5 application is credited the headers Rocket's default `Shield` sends unless it attaches its own, and its cookie jar's SameSite=Strict default; a session middleware its default cookie flags.
Method: Roslyn plus filesystem scan: HSTS/security headers, secure cookies, input validation, middleware order, weak crypto (MD5/SHA1/DES); HTTPS-metadata context-aware. On a repository with no .NET source it reads JavaScript/TypeScript, Dart, Ruby, Scala, Rust or Elixir source itself (test, vendored, generated and minified paths not) for the arms that hold whether or not the code serves HTTP: a weak hash or cipher, key material fixed in the source, a TLS client that accepts any certificate, and (JavaScript/TypeScript, Ruby, Scala, Rust and Elixir) an obsolete TLS version; the server controls are not assessed there, and a Dart, Ruby, Scala, Rust or Elixir repository that serves no HTTP of its own is N/A on them. Deterministic.
None of the 11 security response headers the OWASP Secure Headers Project recommends (Content-Security-Policy, Strict-Transport-Security, X-Content-Type-Options, X-Frame-Options, …) is configured — defense in depth, even when a reverse proxy could set them. This is reported because `nginx.conf` is committed to this repository and declares the server that serves it, so the configuration that would carry these headers is in this repository and was read in full. (−2.0 on this card.) — docker/multiuser-test/nginx.conf:21
What to do
Set security response headers on the surface this repository serves: an `add_header` directive per header in the nginx/Caddy/Apache config, a `_headers` / `vercel.json` / `netlify.toml` entry for a static host, or `helmet()` in the HTTP server. `Content-Security-Policy` is the one that pays for itself first — it is what contains an injected script once one reaches the page — followed by `X-Content-Type-Options: nosniff` and a frame policy (`X-Frame-Options: DENY`, or CSP `frame-ancestors`). Where the app is served from a build container, the header configuration belongs in the image beside the built assets, so it ships with them rather than depending on where it lands.
Other · Code Health — Whether the code avoids sync-over-async (deadlock-prone blocking on tasks) and async void.
Method: Roslyn syntax scan: async methods scanned for .Wait()/.GetAwaiter().GetResult() and async-void outside event handlers. Deterministic, hard fact per invocation.
Other · Security — Whether a hand-rolled public/private IP check can be walked past — a method that unwraps IPv4-mapped IPv6 but returns the opposite verdict for the same host written as IPv4-compatible, 6to4 or NAT64.
Method: Roslyn syntax + semantics: methods that unwrap IPv4-mapped IPv6 and hand-roll IPv4 range carve-outs, checked for whether the IPv6 branch also accounts for the IPv4-compatible, 6to4 and NAT64 embeddings. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether a `when` guard is free of side effects — a guard that increments a counter or assigns while deciding whether its arm matches applies that change during PATTERN MATCHING, on an arm that may not be selected, and skips it entirely when a short-circuit to its left answers first.
Method: Roslyn syntax: `when` guards on case labels and switch-expression arms, read for a mutation (`++`/`--`/assignment) sitting in a position the guard's own `&&`/`||`/`??`/`?:`/`?.` can skip. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X28 · Index access outside its own emptiness guard10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a condition that tests a value for emptiness indexes that same value only where the test holds — an `||` written one parenthesis too far to the left leaves an index access outside the guard beside it, so the empty case the guard exists to anticipate reaches the index and throws.
Method: Roslyn syntax only, no semantic model: the OUTERMOST `&&`/`||` of every boolean condition, read for a symbol the condition tests for emptiness (`string.IsNullOrEmpty`/`IsNullOrWhiteSpace`, a `Length`/`Count` comparison against a literal, `Any()`, a `Length`/`Count` pattern, or a comparison against `""`) and ALSO indexes. Each `symbol[...]` access is placed by a boolean-reachability walk from the access up to the outermost connective: an access is COVERED when some enclosing step has it in the right operand and the left operand, under the truth value that step forces, proves the symbol non-empty — a recursion over `&&`/`||` whose true- and false-directions are asymmetric. A finding needs BOTH an uncovered access and a covered one on the same symbol in the same condition, which is the agreeing twin that separates a misplaced parenthesis from an unrelated length test. Bare index accesses with no emptiness test in the condition are neither counted nor reported; a non-identifier receiver and a lambda nested inside the condition are outside the population. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X29 · Per-element action decided by a fixed element10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a decision taken once per element is taken ABOUT that element — a test inside a counted loop that reads a fixed subscript of the very collection its guarded statement indexes by the loop variable applies element zero's answer to all of them, so the elements that differ from it are all handled wrongly, and in the same direction.
Method: Roslyn syntax only, no semantic model: every `for` statement declaring exactly ONE loop variable, and every `if` inside its body that is not under a nested loop or a lambda. A site enters the population when the `if`’s condition never mentions the loop variable while the statement it guards indexes some collection by that variable ALONE (`c[i]`; `c[i + 1]` and `c[i, j]` are outside it). A finding additionally needs the AGREEING TWIN at the same-collection grain: the condition must read THAT SAME collection at a subscript that does not move — written into the condition, or reached through a local declared BEFORE the loop, so an alias bound inside the body is not followed. Both collection expressions must be simple identifiers. On a repository with no .NET source the same rule reads JavaScript/TypeScript off the engine’s own token stream (tests included, bundles and vendored paths not): a `for (let|var|const x = …; …; …)` with one declarator and a braced body, an alias followed only when it is declared before the loop in a block that encloses it and never assigned inside the loop. Deterministic, provable per finding. Advisory.
Do you agree with this assessment?
X30 · Support guard that admits what it rejects10.0 / 10Exemplary○ Nothing flagged
Other · Code Health — Whether a guard written as a NEGATED `||` says what its author meant — `!(a || b || x != k)` is `!a && !b && x == k` by De Morgan, so a bail-out that mixes capabilities the code needs with a fault it refuses turns inside out: it fires only where the capabilities are ABSENT, and lets every value the fault term names walk straight into the body that cannot handle it.
Method: Roslyn syntax only, no semantic model: every logical-not whose operand is a parenthesised `||` chain of two or more disjuncts, flattened (a left-nested `a || b || c` read once would see `(a || b)` as one disjunct). A site enters the population on that shape alone. A finding additionally needs the disjuncts to DISAGREE in polarity: at least one bare boolean read — an identifier or member access, never an invocation, which is a predicate rather than a capability flag — and at least one `x != <constant>`, the only form that negates into an exact-value pin (`== null` negates into a looser requirement and is outside the fault set). Consistently-polarised disjunctions, all-fault or all-capability, are counted and never reported; a negated `&&` is outside the population entirely. No same-receiver gate: it was measured to cost a real defect and remove no false positive. Deterministic, provable per finding. Advisory.
Other · Code Health — Whether log calls use message templates (queryable) rather than interpolated strings.
Method: Roslyn syntax scan: every log call-site counted; interpolated-string first-argument violations flagged. Population is all log calls, not estimated. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `trace`/`debug`/`info`/`warn`/`error`/`fatal`/`verbose`/`silly`/`http`/`log` call on a receiver named for a logger, in a package whose own or an enclosing `package.json` declares a logger that carries values as fields (pino, pino-http, nestjs-pino, Fastify, winston, bunyan, tslog, LogTape, roarr), whose first deciding argument is a template literal with substitutions; an object-literal fields argument is stepped over, a plain string message clears the call. Python is read the same way: a `debug`/`info`/`warning`/`error`/`exception`/`critical`/`log` call on a logger in a file that imports the standard library’s `logging` or structlog (loguru, which formats at the call, is not judged), whose message is a whole f-string with a non-constant field; a `%`-formatted, `.format()`-ed or concatenated message is not convicted, as in C#. PHP is read the same way: a PSR-3 level call (`emergency`…`debug`, `log`) on a logger (`$logger`, `$this->logger`, Laravel’s `Log::`, `logger()`, `\Drupal::logger()`) in a package whose `composer.json` requires a PSR-3 logger or a framework that hands one out (psr/log, Monolog, Laravel, Symfony, Drupal, CakePHP), or a file that imports one, whose message is a double-quoted string interpolating a variable; a single-quoted message clears the call, and `sprintf` or `.` concatenation is not convicted, as in C#. Dart is read the same way: a `trace`/`debug`/`info`/`warn`/`error`/`fatal` call on Sentry’s structured logger (`Sentry.logger`) whose message is a whole string literal interpolating a value (`$name`, `${…}`); the `Sentry.logger.fmt` template API clears the call. Dart that logs only through loggers with one message and no fields (package:logging, package:logger, talker, dart:developer) is not applicable rather than a reach gap. Ruby is read the same way: a `trace`/`debug`/`info`/`warn`/`error`/`fatal` call on the console gem’s `Console` (declared by a Gemfile, gemspec or Gemfile.lock, or required) or, where SemanticLogger, Ougai or dry-logger is declared or required, on a receiver named for a logger (`logger`, `@logger`, `Rails.logger`, `log`), whose first deciding argument is, as the whole argument, a double-quoted string interpolating a non-constant value (`#{…}`, `#@ivar`); a plain literal clears the call, keyword arguments are the fields, and a block, `%`-format or `+` concatenation is not convicted. Ruby that logs only through the standard Logger (Rails.logger) is not applicable rather than a reach gap. Deterministic.
`info!` at line 174 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — evals/src/retrieval/dataset.rs:174
`error!` at line 746 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `error!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — evals/src/retrieval/mod.rs:746
`warn!` at line 286 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ai-memory-store/src/lib.rs:286
`warn!` at line 9153 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ai-memory-mcp/src/admin.rs:9153
`warn!` at line 6520 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ai-memory-hooks/src/router.rs:6520
`debug!` at line 6523 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ai-memory-hooks/src/router.rs:6523
`warn!` at line 35 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ai-memory-cli/src/proxy_env.rs:35
`error!` at line 373 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `error!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ai-memory-cli/src/commands/service_host.rs:373
Other · Code Health — Whether strict null checking is enabled and not undermined by heavy `!` assertion — TypeScript's `strictNullChecks` (which `strict` turns on) is what makes `string` exclude `null` and `undefined`, and the postfix `!` is the operator that silences it.
Method: Roslyn compiler-options scan: NullableContextOptions per project; null-forgiving (!) suppression density per 1k syntax nodes. Deterministic, adoption plus suppression penalty.
Do you agree with this assessment?
WCAG coverage — what static analysis assessed
Statically assessed 13 of 55 WCAG 2.2 Level A/AA success criteria (24%; ≈26% of the 50 WCAG 2.1 AA criteria for EN 301 549). The other 42 require runtime or manual evaluation. Partial signal only (a clean result is necessary, not sufficient; static analysis fully verifies none). This is accessibility readiness, not a conformance claim — a WCAG conformance claim requires manual evaluation (WCAG-EM 1.0).
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.
Unscored — 2 check(s) recorded observations but carry no score
These checks ran and found something, but they do not carry a score — either by design (an advisory check reports evidence rather than grading it) or because they could not be scored here. They are excluded from the score for that reason, not because there was nothing to see.
X10 Duplicated predicate — 40 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
X7 Silent fallback defaults — 17 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
Not evidenced — 1 control(s) we could not find positive evidence for
These checks grade a working control, and the repository shows no evidence of one. That is deliberately not scored as a zero: a repository cannot show an ops runbook, a database TTL or an infrastructure-side audit log, so absence of evidence here is not evidence the control is missing. It is also not a statement that the check is irrelevant to this codebase — the thing it grades applies; we just could not see it. Excluded from the score either way.
C5 Data-Subject Rights — Repo shows no corroborated data-subject-rights mechanism (erasure / export-portability / consent) tied to a subject id or GDPR vocabulary — absence of evidence is not evidence of a working control. Implement erasure, data export/portability and consent tracking over the subject's records.
Not included — 51 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.
AC4 Keyboard semantics — No interactive element found in the parsed markup — AC4 not applicable here.
AX1 Captive dependencies — Not applicable: this repository's JavaScript imports no dependency-injection container and defines no container of its own — nothing that both registers and resolves bindings, and nothing that names two lifetimes — so nothing holds one lifetime's instance while handing out another's; Rust with no dependency-injection crate has no container to hand one lifetime's instance to another — every value is owned by the code that builds it, and the borrow checker rejects a longer-lived value keeping a borrow of a shorter-lived one; this repository's Swift imports no dependency-injection container and defines no container of its own — nothing that both registers and resolves bindings, and nothing that names two lifetimes — so nothing holds one lifetime's instance while handing out another's; this repository's TypeScript imports no dependency-injection container and defines no container of its own — nothing that both registers and resolves bindings, and nothing that names two lifetimes — so nothing holds one lifetime's instance while handing out another's.
AX2 Stateful singletons — No container singleton was found, so there is no shared instance for concurrent requests to race on. No function in this Python code is served by a threaded web framework (a Flask, Bottle or FastAPI route, a Django or Pyramid view), so no module is shared between request threads. No Swift request handler (a Vapor, Hummingbird, Kitura, Swifter or Perfect route handler, as a method or a registered closure) is declared, so no state is shared between request threads. Rust's compiler refuses unsynchronised shared mutation — a value shared across threads must be Sync — so the race this check looks for cannot be written. TypeScript/JavaScript runs each process's requests on one event loop, so no two requests write a shared object at the same instant (interleaving across an await is a different defect).
AX5 Architecture & structure — not assessed — architecture style/structure is computed from a project graph (projects, types, module namespaces) that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
AX6 Interface segregation — AX6 reached only 1% of this repository's production lines — rust (491,235 lines), swift (1,675 lines), python (722 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 docker/.env.production not found: stat docker/.env.production: 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.
D11 Test Reliability — Test reliability not included — the .rs suite was found but not re-run
D18 Solution Shape — D18 scores the shape of a .NET solution; this repository has no .NET solution or project files, so the dimension does not apply.
D21 Naming Consistency — Naming consistency does not read html yet; not measured.
D22 Internal API Consistency — API consistency is measured on C# only; the exposed Rust surface was not measured.
D23 Boundary Type-Coupling — No bounded-context organisation was detected either — neither a context-shaped layout, nor 2+ sibling source directories each declaring an aggregate root, nor 2+ sibling projects each declaring an entity of their own or taking another project's integration events. Declaring this codebase's bounded contexts (≥2) would let cross-boundary type coupling be assessed. Declare them in `.codehealth/config.yaml` at the repository root (create it if absent), mapping each context name to the module-path or namespace prefixes that belong to it — e.g. `architecture:` → `contexts:` → `Billing: ["src/billing", "Acme.Billing"]`, `Catalog: ["src/catalog", "Acme.Catalog"]`.
D25 ADR Conformance — None of 0 binding record(s) states a rule in checkable form (a backticked element with a prohibition, or an `adr-rules` block), so conformance cannot be read from the code. Write the rule as an `adr-rules` block (`forbid:` a symbol, a package or a dependency) to make it checkable.
D27 Navigability — D27 counts a call into the standard library or a dependency as unresolved for this repository's language (.rs), so too few call sites counted as resolved to assess navigability. Not scored: this is a gap in the analyzer, not a verdict about this repository.
D32 Data Compliance (PII/GDPR) — 2 file(s) were not parsed by semgrep — the PII/GDPR ruleset never ran over them
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 — Swift suite
DM1 Domain Modelling — not scored — this repository shows only 1 of the 3 signals this lens looks for (69 value object(s))
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 Event Sourcing — not scored — this repository shows none of the 3 signals this lens looks for
GD1 Unfinished & placeholder code — no source files were read — this check reads C#, F#, JavaScript/TypeScript, Dart, Ruby and Scala, and none was read for this repository's product. That is a limit of the analyzer, not a finding about your code.
IC1 Incompleteness & stubs — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
P12 CI test-gate honesty — Reported, not scored — and nothing was matched here. The coverage check applies to any stack, and the automatic-re-run check to any GitHub-Actions workflow, but the checks for excluded tests, skipped tests and sleep-based synchronisation currently recognise only some ecosystems' test-runner idioms, so on a repository built with another stack the zeros below mean 'not checked', not 'clean'.
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 — Not applicable: no benchmark suite was found. This check searched for `#[bench]`, criterion's `bench_function`/`bench_with_input`, `#[divan::bench]` or `#[library_benchmark]` in any `.rs` file, or criterion, divan, iai or a `[[bench]]` target in a Cargo.toml, and for a `*benchmark*` script that this repository's CI runs. Benchmarks are credited as a bonus, so their absence is neither scored nor deducted.
PF2 Allocation hygiene — Not 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.
SC1 Supply-chain hygiene — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
X12 Unreachable branch — X12 reached only 1% of this repository's production lines — rust (491,235 lines), swift (1,675 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
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 — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
X17 Uncapped recursion over a caller-supplied document — X17 reached only 1% of this repository's production lines — rust (491,235 lines), swift (1,675 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
X18 Disposal-pattern correctness — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
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 — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
X20 Mistyped argument guard — This check asks whether an argument guard reports an EMPTY value as a NULL one, which needs a language that throws a null-specific argument exception — .NET's ArgumentNullException, the JVM's NullPointerException, Dart's ArgumentError.notNull. This repository contains none of those languages: the ones it is written in have a single exception for a bad argument, so there is no pair of exceptions to confuse and nothing here for it to assess. Not a gap in the analyzer and not a finding about your code.
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 — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
X3 Exception handling — X3 reached only 2% of this repository's production lines — rust (491,235 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
X32 Type resolved by simple name across every loaded assembly — This check is about how a .NET program searches the assemblies loaded into its process for a type, and this repository contains no .NET source, so there is nothing here for it to assess. Not a gap in the analyzer and not a finding about your code.
X6 Hand-rolled structured-format parsing — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
X9 Subsumed condition operand — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
Appendix A — Findings (grouped)
The findings behind the scores, grouped by severity, then by dimension and kind. The high-severity issues are enumerated in full below; items per group are capped at 25 with any overflow stated explicitly per group, never silently truncated. The complete machine-readable list of every finding (all severities) is the companion findings.md in this report's bundle.
AC2 · Forms & labels· <label> that labels no control · ×1
<label> that labels no control crates/ai-memory-core/locales/en/diagnostics.ftl:155— This <label> has no for and wraps no form control, so it names nothing: assistive tech never announces it, and clicking the caption focuses no field. Note that an id on the label is not an association — it is the TARGET of one, so a control still has to point at it. Give the label for="<the control's id>", move the control inside the label, or point the control's aria-labelledby at this label's id.
FunctionTooLong: ai_memory_cli::commands::run::run_once_with_wiring crates/ai-memory-cli/src/commands/run.rs:613— FunctionTooLong — ai_memory_cli::commands::run::run_once_with_wiring runs 1003 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 903 over it, 10.03× 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: ai_memory_cli::commands::serve::run crates/ai-memory-cli/src/commands/serve.rs:1221— FunctionTooLong — ai_memory_cli::commands::serve::run runs 644 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 544 over it, 6.44× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: ai_memory_hooks::router::process_authorized crates/ai-memory-hooks/src/router.rs:4995— FunctionTooLong — ai_memory_hooks::router::process_authorized runs 637 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 537 over it, 6.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: ai_memory_cli::commands::backup_agents::discover_assets crates/ai-memory-cli/src/commands/backup_agents.rs:173— FunctionTooLong — ai_memory_cli::commands::backup_agents::discover_assets runs 567 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 467 over it, 5.67× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: ai_memory_importer::agentmemory::export::plan companions/ai-memory-importer/src/agentmemory/export.rs:665— FunctionTooLong — ai_memory_importer::agentmemory::export::plan runs 442 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 342 over it, 4.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.
FunctionTooLong: ai_memory_cli::commands::hook_spool::drain_with_live_token crates/ai-memory-cli/src/commands/hook_spool.rs:1462— FunctionTooLong — ai_memory_cli::commands::hook_spool::drain_with_live_token runs 407 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 307 over it, 4.07× 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: ai_memory_store::ops::merge_project crates/ai-memory-store/src/ops.rs:8798— FunctionTooLong — ai_memory_store::ops::merge_project runs 380 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 280 over it, 3.80× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: ai_memory_cli::commands::serve::start_maintenance_scheduler crates/ai-memory-cli/src/commands/serve.rs:2188— FunctionTooLong — ai_memory_cli::commands::serve::start_maintenance_scheduler runs 330 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 230 over it, 3.30× 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: ai_memory_cli::commands::status::presentation::render crates/ai-memory-cli/src/commands/status/presentation.rs:19— FunctionTooLong — ai_memory_cli::commands::status::presentation::render runs 311 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 211 over it, 3.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.
FunctionTooLong: ai_memory_cli::commands::uninstall::build_plan crates/ai-memory-cli/src/commands/uninstall.rs:206— FunctionTooLong — ai_memory_cli::commands::uninstall::build_plan runs 305 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 205 over it, 3.05× 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: ai_memory_web::features::states crates/ai-memory-web/src/features.rs:48— FunctionTooLong — ai_memory_web::features::states runs 274 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 174 over it, 2.74× 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: ai_memory_consolidate::sweep::run_sweep_at crates/ai-memory-consolidate/src/sweep.rs:604— FunctionTooLong — ai_memory_consolidate::sweep::run_sweep_at runs 262 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 162 over it, 2.62× 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: ai_memory_workstream::harness::launch_mode crates/ai-memory-workstream/src/harness.rs:786— FunctionTooLong — ai_memory_workstream::harness::launch_mode runs 249 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 149 over it, 2.49× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: ai_memory_mcp::admin::copy_purge_merge crates/ai-memory-mcp/src/admin.rs:8609— FunctionTooLong — ai_memory_mcp::admin::copy_purge_merge runs 248 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 148 over it, 2.48× 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: ai_memory_hooks::router::resolve_project_ids_inner crates/ai-memory-hooks/src/router.rs:4178— FunctionTooLong — ai_memory_hooks::router::resolve_project_ids_inner runs 232 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 132 over it, 2.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: ai_memory_store::ops::move_session crates/ai-memory-store/src/ops.rs:9393— FunctionTooLong — ai_memory_store::ops::move_session runs 219 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 119 over it, 2.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: ai_memory_web::routes::inbox::handler crates/ai-memory-web/src/routes/inbox.rs:46— FunctionTooLong — ai_memory_web::routes::inbox::handler runs 217 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 117 over it, 2.17× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: ai_memory_store::workstream::finish_run_inner crates/ai-memory-store/src/workstream.rs:1396— FunctionTooLong — ai_memory_store::workstream::finish_run_inner runs 214 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 114 over it, 2.14× 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: ai_memory_store::ops::purge_session_with_owner crates/ai-memory-store/src/ops.rs:7575— FunctionTooLong — ai_memory_store::ops::purge_session_with_owner runs 209 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 109 over it, 2.09× 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: ai_memory_cli::commands::recovery::recover crates/ai-memory-cli/src/commands/recovery.rs:553— FunctionTooLong — ai_memory_cli::commands::recovery::recover runs 206 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 106 over it, 2.06× 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: ai_memory_consolidate::profile::converge crates/ai-memory-consolidate/src/profile.rs:1448— FunctionTooLong — ai_memory_consolidate::profile::converge runs 204 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 104 over it, 2.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.
FunctionTooLong: ai_memory_consolidate::auto_improve_schedule::run_auto_improve_scheduler_tick crates/ai-memory-consolidate/src/auto_improve_schedule.rs:153— FunctionTooLong — ai_memory_consolidate::auto_improve_schedule::run_auto_improve_scheduler_tick runs 202 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 102 over it, 2.02× 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: ai_memory_cli::commands::openclaw_plugin::build_plugin crates/ai-memory-cli/src/commands/openclaw_plugin.rs:241— FunctionTooLong — ai_memory_cli::commands::openclaw_plugin::build_plugin runs 201 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 101 over it, 2.01× 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: ai_memory_web::routes::health::sections crates/ai-memory-web/src/routes/health.rs:206— FunctionTooLong — ai_memory_web::routes::health::sections runs 200 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 100 over it, 2.00× 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: ai_memory_web::routes::search::handler crates/ai-memory-web/src/routes/search.rs:87— FunctionTooLong — ai_memory_web::routes::search::handler runs 200 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 100 over it, 2.00× 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.
Repeated repair: crates/ai-memory-cli/src/commands/render_shared.rs crates/ai-memory-cli/src/commands/render_shared.rs:2515— crates/ai-memory-cli/src/commands/render_shared.rs changed 91 times in last 90 days and 54 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 12 (its worst body is ai_memory_cli::commands::render_shared::hook_command at line 2515), 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(hermes): resolve the Hermes home the way Hermes does”; “fix(cli): wire Gemini CLI's AfterAgent to the stop hook”; “fix(cli): wire Gemini CLI's BeforeAgent to the prompt hook”; “fix(hooks): single-quote PowerShell-run Windows hook commands”. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-cli/src/commands/render_shared.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: crates/ai-memory-hooks/src/payload.rs crates/ai-memory-hooks/src/payload.rs:664— crates/ai-memory-hooks/src/payload.rs changed 64 times in last 90 days and 33 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 HookEnvelope::from_query_and_body at line 664), 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(hooks): read Gemini CLI's BeforeAgent and AfterAgent event names”; “fix(hooks): cut Gemini CLI's @ expansion out of a hook prompt”; “fix(hooks): read a Cline subagent from parent_agent_id, not agent_id”; “fix(hooks): capture OpenClaw tool observation titles and bodies (#2130)”. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-hooks/src/payload.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: crates/ai-memory-cli/src/commands/backfill.rs crates/ai-memory-cli/src/commands/backfill.rs:372— crates/ai-memory-cli/src/commands/backfill.rs changed 42 times in last 90 days and 26 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 15 (its worst body is ai_memory_cli::commands::backfill::run_in at line 372), 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(cli): neutralize scope names in the backfill and repair lines”; “fix(cli): neutralize the names mid-run lines quote, not only errors”; “fix(cli): route checkout commands through the marker's server profile (#2016)”; “fix(hooks): answer an agent-label mismatch with 409 instead of a silent drop (#2023)”. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-cli/src/commands/backfill.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: crates/ai-memory-wiki/src/markdown.rs crates/ai-memory-wiki/src/markdown.rs:909— crates/ai-memory-wiki/src/markdown.rs changed 28 times in last 90 days and 22 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 12 (its worst body is ai_memory_wiki::markdown::extract_markdown_links at line 909), 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(wiki): treat a protocol-relative link destination as external”; “fix(wiki): pin the frontmatter shapes that read differently since serde-saphyr”; “fix(wiki): keep a literal percent in exported wikilink targets”; “fix(wiki): recognize an empty frontmatter block”. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-wiki/src/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.
Repeated repair: crates/ai-memory-web/src/markdown.rs crates/ai-memory-web/src/markdown.rs:111— crates/ai-memory-web/src/markdown.rs changed 27 times in last 90 days and 21 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 ai_memory_web::markdown::scope_relative_link at line 111), 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(audit): harden integrated bug fixes”; “fix(web): keep a literal mark tag from page text out of a search snippet”; “fix(wiki): resolve encoded Markdown destinations once”; “fix(web): leave directory and stemless wikilinks as literal text”. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-web/src/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.
Repeated repair: crates/ai-memory-core/src/sanitize.rs crates/ai-memory-core/src/sanitize.rs:191— crates/ai-memory-core/src/sanitize.rs changed 30 times in last 90 days and 19 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 ai_memory_core::sanitize::json_escape_at at line 191), 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(sanitize): redact own-prefix and AWS keys glued onto a word by a stripped character”; “fix(sanitize): anchor sk- and Stripe keys on a preceding letter (#2025)”; “fix(sanitize): anchor the api_key rule to a word boundary”; “fix(sanitize): redact ai-memory's own credentials”. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-core/src/sanitize.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: crates/ai-memory-wiki/src/git.rs crates/ai-memory-wiki/src/git.rs:1166— crates/ai-memory-wiki/src/git.rs changed 24 times in last 90 days and 19 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 ai_memory_wiki::git::stage_paths at line 1166), 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(restore): restore only git's data from the wiki's .git ([GHSA redacted])”; “fix(wiki): keep serve running when the wiki git repo is owned by another account”; “fix(wiki): revalidate root before git staging”; “fix(wiki): confine reported git staging paths”. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-wiki/src/git.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: crates/ai-memory-cli/src/commands/openclaw_plugin.rs crates/ai-memory-cli/src/commands/openclaw_plugin.rs:161— crates/ai-memory-cli/src/commands/openclaw_plugin.rs changed 28 times in last 90 days and 18 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 ai_memory_cli::commands::openclaw_plugin::install_plugin at line 161), 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(handoff): offer the baton under external capture in every hook bundle”; “fix(cli): neutralize the names mid-run lines quote, not only errors”; “fix(openclaw): refuse redirects in the OpenClaw plugin”; “fix(hooks): keep allowlist plugins from fetching a handoff in unmarked repos”. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-cli/src/commands/openclaw_plugin.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: crates/ai-memory-llm/src/opencode.rs crates/ai-memory-llm/src/opencode.rs:224— crates/ai-memory-llm/src/opencode.rs changed 22 times in last 90 days and 17 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 ai_memory_llm::opencode::model_api at line 224), 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(opencode): classify Responses output budget stops”; “fix(llm): strip unsupported numeric schema formats”; “fix(llm): include compat schema in tolerant prompts”; “fix(llm): make compat streaming configurable”. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-llm/src/opencode.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: crates/ai-memory-cli/src/commands/setup.rs crates/ai-memory-cli/src/commands/setup.rs:833— crates/ai-memory-cli/src/commands/setup.rs changed 30 times in last 90 days and 16 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 ai_memory_cli::commands::setup::execute at line 833), 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(mcp): fall back to the bridge's launch scope on a pointer miss (#2005)”; “fix(cli): neutralize the names mid-run lines quote, not only errors”; “fix(cli): record Scoop's current junction, refuse self-upgrade under Scoop”; “fix(cli): strip URL userinfo from the startup log and thin-client errors”. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-cli/src/commands/setup.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: crates/ai-memory-hooks/src/synth.rs crates/ai-memory-hooks/src/synth.rs:824— crates/ai-memory-hooks/src/synth.rs changed 24 times in last 90 days and 16 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 ai_memory_hooks::synth::render_body at line 824), 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(core): keep Claude Code machine turns out of session titles and prompt lists”; “fix(hooks): stamp an idle end with the whole session's count”; “fix(hooks): keep bare tool-family labels out of session titles and summaries”; “fix(hooks): capture Claude Code tool failures via PostToolUseFailure”. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-hooks/src/synth.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: crates/ai-memory-store/src/fts_query.rs crates/ai-memory-store/src/fts_query.rs:404— crates/ai-memory-store/src/fts_query.rs changed 19 times in last 90 days and 16 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 ai_memory_store::fts_query::prepare_fts5_token at line 404), 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(store): keep accented Latin words whole in query-signal similarity”; “fix(store): let title:/body: filters reach the hyphen-split columns (#2013)”; “fix(store): index the parts of hyphenated words so `alpha` finds `foo-bar-alpha`”; “fix(store): split paths on `/` in full-text search (#1921)”. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-store/src/fts_query.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: crates/ai-memory-cli/src/commands/upgrade.rs crates/ai-memory-cli/src/commands/upgrade.rs:640— crates/ai-memory-cli/src/commands/upgrade.rs changed 26 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 13 (its worst body is ai_memory_cli::commands::upgrade::validate_release_path at line 640), 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(upgrade): preserve installed Claude Code hook endpoints”; “fix(upgrade): refresh the OpenCode plugin in the installed major (#1887)”; “fix(cli): neutralize the names mid-run lines quote, not only errors”; “fix(cli): record Scoop's current junction, refuse self-upgrade under Scoop”. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-cli/src/commands/upgrade.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: crates/ai-memory-cli/src/commands/mcp_bridge.rs crates/ai-memory-cli/src/commands/mcp_bridge.rs:664— crates/ai-memory-cli/src/commands/mcp_bridge.rs changed 25 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 8 (its worst body is ai_memory_cli::commands::mcp_bridge::wait_for_server at line 664), 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(mcp): fall back to the bridge's launch scope on a pointer miss (#2005)”; “fix(mcp-bridge): restore resultType on forwarded results for 2026-07-28 clients (#2022)”; “fix(hooks): never repeat inbox-notice query keys; compaction starts claim nothing”; “fix(cli): strip URL userinfo from the startup log and thin-client errors”. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-cli/src/commands/mcp_bridge.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: crates/ai-memory-cli/src/http_client.rs crates/ai-memory-cli/src/http_client.rs:581— crates/ai-memory-cli/src/http_client.rs changed 22 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 9 (its worst body is ai_memory_cli::http_client::error_chain_indicates_no_answer at line 581), 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(backup): verify the downloaded gzip stream before replacing the archive”; “fix(cli): preserve archives on non-gzip download responses”; “fix: route selected checkouts and bind only admitted hook agents”; “fix(cli): match profile roots against the shell's logical cwd (#2016)”. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-cli/src/http_client.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: crates/ai-memory-web/src/routes/page.rs crates/ai-memory-web/src/routes/page.rs:35— crates/ai-memory-web/src/routes/page.rs changed 19 times in last 90 days and 11 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 ai_memory_web::routes::page::handler 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(web): show a project refusal instead of redirecting to change-password”; “fix(web): sort recent pages by timestamp”; “fix(web): show exact timestamps on the page view”; “fix(web): mark an expired page on the page view”. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-web/src/routes/page.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: crates/ai-memory-store/src/scope.rs crates/ai-memory-store/src/scope.rs:242— crates/ai-memory-store/src/scope.rs changed 18 times in last 90 days and 11 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 ScopeResolutionError::fmt at line 242), 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(scope): name the workspace when a write hits an ambiguous project”; “fix(mcp): refuse an inferred scope for message pop, cancel and send”; “fix(store): try the exact name first and never create a slashed project”; “fix(store): auto-split a `workspace/project` label passed as the project”. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-store/src/scope.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: crates/ai-memory-cli/src/commands/purge_project.rs crates/ai-memory-cli/src/commands/purge_project.rs:172— crates/ai-memory-cli/src/commands/purge_project.rs changed 16 times in last 90 days and 11 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 ai_memory_cli::commands::purge_project::run at line 172), 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(cli): neutralize scope names in the project administration lines”; “fix(cli): send the purge previews to the server the purge will use”; “fix(cli): route checkout commands through the marker's server profile (#2016)”; “fix(cli): neutralize server text in the exit report and purge listings”. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-cli/src/commands/purge_project.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: crates/ai-memory-store/src/error.rs crates/ai-memory-store/src/error.rs:45— crates/ai-memory-store/src/error.rs changed 16 times in last 90 days and 11 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 15 (its worst body is AmbiguousProjectHolders::fmt at line 45), 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(hooks): answer an agent-label mismatch with 409 instead of a silent drop (#2023)”; “fix(store): resolve a remote-derived name past an empty twin (#2018)”; “fix(workstream): retry renewable lease lapses”; “fix(hooks): drop a spooled event its managed run boundary refuses”. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-store/src/error.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: crates/ai-memory-wiki/src/migrations/m2026_09_okf_conformance.rs crates/ai-memory-wiki/src/migrations/m2026_09_okf_conformance.rs:209— crates/ai-memory-wiki/src/migrations/m2026_09_okf_conformance.rs changed 15 times in last 90 days and 11 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 15 (its worst body is ai_memory_wiki::migrations::m2026_09_okf_conformance::nonconformant_files at line 209), 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(wiki): keep serve running when the wiki git repo is owned by another account”; “fix(okf): conform a nested index.md instead of skipping it as the bundle index”; “fix(okf): encode directory links in generated bundle indexes”; “fix(wiki): confine page I/O to the project tree”. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-wiki/src/migrations/m2026_09_okf_conformance.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: crates/ai-memory-llm/src/copilot.rs crates/ai-memory-llm/src/copilot.rs:944— crates/ai-memory-llm/src/copilot.rs changed 17 times in last 90 days and 10 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 ai_memory_llm::copilot::response_text at line 944), 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(copilot): reject structured token-budget stops”; “fix(llm): honor provider retry hints”; “fix(copilot): report an incomplete /responses answer as a truncated response”; “fix(llm): treat a throttled or overloaded token endpoint as transient”. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-llm/src/copilot.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: crates/ai-memory-llm/src/openai_compat.rs crates/ai-memory-llm/src/openai_compat.rs:301— crates/ai-memory-llm/src/openai_compat.rs changed 16 times in last 90 days and 10 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 OpenAiCompatProvider::complete_structured at line 301), 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(llm): find the JSON answer after braced prose”; “fix(llm): include compat schema in tolerant prompts”; “fix(llm): reject unsupported compat streaming”; “fix(llm): make compat streaming configurable”. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-llm/src/openai_compat.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: crates/ai-memory-llm/src/openai.rs crates/ai-memory-llm/src/openai.rs:695— crates/ai-memory-llm/src/openai.rs changed 17 times in last 90 days and 9 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 12 (its worst body is ai_memory_llm::openai::enforce_strict_object_schemas at line 695), 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(profile): split a truncated classification batch instead of dropping it”; “fix(llm): strip unsupported numeric schema formats”; “fix(llm): make compat streaming configurable”; “fix(llm): honor provider retry hints”. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-llm/src/openai.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: crates/ai-memory-cli/src/commands/finalize_session.rs crates/ai-memory-cli/src/commands/finalize_session.rs:212— crates/ai-memory-cli/src/commands/finalize_session.rs changed 15 times in last 90 days and 9 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 ai_memory_cli::commands::finalize_session::fetch_open_sessions at line 212), 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(cli): neutralize the names mid-run lines quote, not only errors”; “fix(cli): route checkout commands through the marker's server profile (#2016)”; “fix(cli): prevent server text from injecting terminal controls”; “fix(cli): refuse redirects across thin-client call sites”. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-cli/src/commands/finalize_session.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: crates/ai-memory-llm/src/embedding.rs crates/ai-memory-llm/src/embedding.rs:349— crates/ai-memory-llm/src/embedding.rs changed 14 times in last 90 days and 9 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 ai_memory_llm::embedding::openai_style_embed at line 349), 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(llm): honor provider retry hints”; “fix(embeddings): size local capacity from the CPU and bound the query wait”; “fix(embed): leave the Voyage input to Voyage's own truncation”; “fix(embed): bound the embedding input on the Gemini and Voyage embedders”. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-llm/src/embedding.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.
FileTooLong: src/reader.rs crates/ai-memory-store/src/reader.rs— FileTooLong — 10922 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 76% of them inside a single declaration: ReaderPool (2 blocks, 2955-14844), declaring 89 free functions. The bar is 500 significant lines; this is 10422 over it, 21.84× 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: src/server.rs crates/ai-memory-mcp/src/server.rs— FileTooLong — 6548 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 70% of them inside a single declaration: AiMemoryServer (5 blocks, 573-9038), declaring 48 free functions. The bar is 500 significant lines; this is 6048 over it, 13.10× 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: src/admin.rs crates/ai-memory-mcp/src/admin.rs— FileTooLong — 6336 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 191 free functions. The bar is 500 significant lines; this is 5836 over it, 12.67× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: src/ops.rs crates/ai-memory-store/src/ops.rs— FileTooLong — 6265 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 154 free functions. The bar is 500 significant lines; this is 5765 over it, 12.53× 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: commands/install_hooks.rs crates/ai-memory-cli/src/commands/install_hooks.rs— FileTooLong — 6085 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 241 free functions. The bar is 500 significant lines; this is 5585 over it, 12.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: src/transcript.rs crates/ai-memory-workstream/src/transcript.rs— FileTooLong — 4569 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 150 free functions. The bar is 500 significant lines; this is 4069 over it, 9.14× 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: commands/run.rs crates/ai-memory-cli/src/commands/run.rs— FileTooLong — 4351 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 151 free functions. The bar is 500 significant lines; this is 3851 over it, 8.70× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: src/router.rs crates/ai-memory-hooks/src/router.rs— FileTooLong — 3810 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 95 free functions. The bar is 500 significant lines; this is 3310 over it, 7.62× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: src/writer.rs crates/ai-memory-store/src/writer.rs— FileTooLong — 3784 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 3284 over it, 7.57× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: src/capture_policy.rs crates/ai-memory-hooks/src/capture_policy.rs— FileTooLong — 2927 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 118 free functions. The bar is 500 significant lines; this is 2427 over it, 5.85× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: src/wiki.rs crates/ai-memory-wiki/src/wiki.rs— FileTooLong — 2715 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 2215 over it, 5.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: commands/serve.rs crates/ai-memory-cli/src/commands/serve.rs— FileTooLong — 2268 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 60 free functions. The bar is 500 significant lines; this is 1768 over it, 4.54× 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: commands/install_mcp.rs crates/ai-memory-cli/src/commands/install_mcp.rs— FileTooLong — 1918 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 107 free functions. The bar is 500 significant lines; this is 1418 over it, 3.84× 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: commands/hook.rs crates/ai-memory-cli/src/commands/hook.rs— FileTooLong — 1907 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 107 free functions. The bar is 500 significant lines; this is 1407 over it, 3.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: src/config.rs crates/ai-memory-cli/src/config.rs— FileTooLong — 1798 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 38 free functions. The bar is 500 significant lines; this is 1298 over it, 3.60× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: src/profile.rs crates/ai-memory-consolidate/src/profile.rs— FileTooLong — 1798 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 61 free functions. The bar is 500 significant lines; this is 1298 over it, 3.60× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: src/workstream.rs crates/ai-memory-store/src/workstream.rs— FileTooLong — 1779 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 32 free functions. The bar is 500 significant lines; this is 1279 over it, 3.56× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: src/cli.rs crates/ai-memory-cli/src/cli.rs— FileTooLong — 1699 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 1199 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: commands/render_shared.rs crates/ai-memory-cli/src/commands/render_shared.rs— FileTooLong — 1653 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 73 free functions. The bar is 500 significant lines; this is 1153 over it, 3.31× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: src/auto_improve.rs crates/ai-memory-consolidate/src/auto_improve.rs— FileTooLong — 1647 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 59 free functions. The bar is 500 significant lines; this is 1147 over it, 3.29× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: commands/hook_spool.rs crates/ai-memory-cli/src/commands/hook_spool.rs— FileTooLong — 1593 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 58 free functions. The bar is 500 significant lines; this is 1093 over it, 3.19× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: src/consolidator.rs crates/ai-memory-consolidate/src/consolidator.rs— FileTooLong — 1516 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 47 free functions. The bar is 500 significant lines; this is 1016 over it, 3.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: commands/uninstall.rs crates/ai-memory-cli/src/commands/uninstall.rs— FileTooLong — 1353 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 44 free functions. The bar is 500 significant lines; this is 853 over it, 2.71× 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: routes/api.rs crates/ai-memory-web/src/routes/api.rs— FileTooLong — 1258 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 758 over it, 2.52× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: src/harness.rs crates/ai-memory-workstream/src/harness.rs— FileTooLong — 1188 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 54 free functions. The bar is 500 significant lines; this is 688 over it, 2.38× 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.
Hotspot: crates/ai-memory-hooks/src/router.rs crates/ai-memory-hooks/src/router.rs:4995— crates/ai-memory-hooks/src/router.rs changed 173 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 101 in ai_memory_hooks::router::process_authorized at line 4995. 97 of those changes were fix/bug commits, so the churn is repair rather than feature work. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-hooks/src/router.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: crates/ai-memory-cli/src/commands/install_hooks.rs crates/ai-memory-cli/src/commands/install_hooks.rs:807— crates/ai-memory-cli/src/commands/install_hooks.rs changed 171 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 96 in ai_memory_cli::commands::install_hooks::run_with_hook_connection at line 807. 92 of those changes were fix/bug commits, so the churn is repair rather than feature work. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-cli/src/commands/install_hooks.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: crates/ai-memory-cli/src/commands/hook.rs crates/ai-memory-cli/src/commands/hook.rs:1557— crates/ai-memory-cli/src/commands/hook.rs changed 100 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 151 in ai_memory_cli::commands::hook::run_with_payload_in_home at line 1557. 58 of those changes were fix/bug commits, so the churn is repair rather than feature work. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-cli/src/commands/hook.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: crates/ai-memory-cli/src/commands/run.rs crates/ai-memory-cli/src/commands/run.rs:613— crates/ai-memory-cli/src/commands/run.rs changed 92 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 146 in ai_memory_cli::commands::run::run_once_with_wiring at line 613. 51 of those changes were fix/bug commits, so the churn is repair rather than feature work. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-cli/src/commands/run.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: crates/ai-memory-store/src/writer.rs crates/ai-memory-store/src/writer.rs:4030— crates/ai-memory-store/src/writer.rs changed 73 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 152 in ai_memory_store::writer::worker_loop at line 4030. 30 of those changes were fix/bug commits, and the other 43 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-store/src/writer.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: crates/ai-memory-store/src/reader.rs crates/ai-memory-store/src/reader.rs:8730— crates/ai-memory-store/src/reader.rs changed 172 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 59 in ReaderPool::hybrid_search_inner at line 8730. 87 of those changes were fix/bug commits, so the churn is repair rather than feature work. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-store/src/reader.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: crates/ai-memory-mcp/src/server.rs crates/ai-memory-mcp/src/server.rs:3216— crates/ai-memory-mcp/src/server.rs changed 171 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 43 in AiMemoryServer::memory_query at line 3216. 74 of those changes were fix/bug commits, and the other 97 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-mcp/src/server.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: crates/ai-memory-cli/src/commands/serve.rs crates/ai-memory-cli/src/commands/serve.rs:1221— crates/ai-memory-cli/src/commands/serve.rs changed 118 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 61 in ai_memory_cli::commands::serve::run at line 1221. 44 of those changes were fix/bug commits, and the other 74 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-cli/src/commands/serve.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: crates/ai-memory-cli/src/config.rs crates/ai-memory-cli/src/config.rs:2477— crates/ai-memory-cli/src/config.rs changed 121 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 42 in Config::load_with_runtime_env at line 2477. 40 of those changes were fix/bug commits, and the other 81 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-cli/src/config.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: crates/ai-memory-store/src/ops.rs crates/ai-memory-store/src/ops.rs:3471— crates/ai-memory-store/src/ops.rs changed 124 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 28 in ai_memory_store::ops::admit_hook_session_event at line 3471. 57 of those changes were fix/bug commits, and the other 67 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-store/src/ops.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: crates/ai-memory-cli/src/commands/hook_spool.rs crates/ai-memory-cli/src/commands/hook_spool.rs:1462— crates/ai-memory-cli/src/commands/hook_spool.rs changed 35 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 82 in ai_memory_cli::commands::hook_spool::drain_with_live_token at line 1462. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-cli/src/commands/hook_spool.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: crates/ai-memory-hooks/src/capture_policy.rs crates/ai-memory-hooks/src/capture_policy.rs:3526— crates/ai-memory-hooks/src/capture_policy.rs changed 79 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 35 in ai_memory_hooks::capture_policy::has_unevaluated_expansion at line 3526. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-hooks/src/capture_policy.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: crates/ai-memory-mcp/src/admin.rs crates/ai-memory-mcp/src/admin.rs:8609— crates/ai-memory-mcp/src/admin.rs changed 119 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 23 in ai_memory_mcp::admin::copy_purge_merge at line 8609. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-mcp/src/admin.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: crates/ai-memory-cli/src/lib.rs crates/ai-memory-cli/src/lib.rs:68— crates/ai-memory-cli/src/lib.rs changed 30 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 88 in ai_memory_cli::dispatch at line 68. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-cli/src/lib.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: crates/ai-memory-workstream/src/transcript.rs crates/ai-memory-workstream/src/transcript.rs:1247— crates/ai-memory-workstream/src/transcript.rs changed 58 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 43 in ai_memory_workstream::transcript::export_jsonl_range at line 1247. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-workstream/src/transcript.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: crates/ai-memory-cli/src/commands/uninstall.rs crates/ai-memory-cli/src/commands/uninstall.rs:206— crates/ai-memory-cli/src/commands/uninstall.rs changed 51 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 47 in ai_memory_cli::commands::uninstall::build_plan at line 206. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-cli/src/commands/uninstall.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: crates/ai-memory-cli/src/commands/install_mcp.rs crates/ai-memory-cli/src/commands/install_mcp.rs:1802— crates/ai-memory-cli/src/commands/install_mcp.rs changed 60 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 38 in ai_memory_cli::commands::install_mcp::build_mcp_entry at line 1802. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-cli/src/commands/install_mcp.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: crates/ai-memory-wiki/src/wiki.rs crates/ai-memory-wiki/src/wiki.rs:3328— crates/ai-memory-wiki/src/wiki.rs changed 76 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 22 in Wiki::apply_batch_inner at line 3328. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-wiki/src/wiki.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: crates/ai-memory-cli/src/commands/setup_agent.rs crates/ai-memory-cli/src/commands/setup_agent.rs:57— crates/ai-memory-cli/src/commands/setup_agent.rs changed 33 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 37 in ai_memory_cli::commands::setup_agent::run at line 57. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-cli/src/commands/setup_agent.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: crates/ai-memory-consolidate/src/consolidator.rs crates/ai-memory-consolidate/src/consolidator.rs:844— crates/ai-memory-consolidate/src/consolidator.rs changed 53 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 22 in Consolidator::consolidate_session_multi_in_scope at line 844. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-consolidate/src/consolidator.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: crates/ai-memory-workstream/src/harness.rs crates/ai-memory-workstream/src/harness.rs:409— crates/ai-memory-workstream/src/harness.rs changed 23 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 38 in ai_memory_workstream::harness::build_launch_plan_with_env_lookup at line 409. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-workstream/src/harness.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: crates/ai-memory-cli/src/commands/hook_capture.rs crates/ai-memory-cli/src/commands/hook_capture.rs:765— crates/ai-memory-cli/src/commands/hook_capture.rs changed 41 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 19 in ai_memory_cli::commands::hook_capture::build_marker_query_suffix at line 765. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-cli/src/commands/hook_capture.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: crates/ai-memory-hooks/src/workstream.rs crates/ai-memory-hooks/src/workstream.rs:324— crates/ai-memory-hooks/src/workstream.rs changed 25 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 30 in ai_memory_hooks::workstream::prepare_run at line 324. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-hooks/src/workstream.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: crates/ai-memory-consolidate/src/bootstrap.rs crates/ai-memory-consolidate/src/bootstrap.rs:436— crates/ai-memory-consolidate/src/bootstrap.rs changed 33 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 22 in Bootstrap::process_sources at line 436. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-consolidate/src/bootstrap.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: crates/ai-memory-cli/src/commands/show.rs crates/ai-memory-cli/src/commands/show.rs:827— crates/ai-memory-cli/src/commands/show.rs changed 26 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 25 in ai_memory_cli::commands::show::select_inner at line 827. 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-08-16..2026-11-14, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-16 14:04:13 -03:00' --until='2026-11-14 14:04:13 -03:00' --full-history --no-merges -- crates/ai-memory-cli/src/commands/show.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.
ai_memory_cli::commands::hook::run_with_payload_in_home (cognitive 233) crates/ai-memory-cli/src/commands/hook.rs:1557— ai_memory_cli::commands::hook::run_with_payload_in_home has cognitive complexity 233 (threshold 15). Drivers by points: if/else 89 (158 pts), boolean chains 54, match/switch 11 (19 pts), loops 1 (2 pts) (nesting depth added 78). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_cli::commands::run::run_once_with_wiring (cognitive 196) crates/ai-memory-cli/src/commands/run.rs:613— ai_memory_cli::commands::run::run_once_with_wiring has cognitive complexity 196 (threshold 15). Drivers by points: if/else 84 (101 pts), match/switch 29 (49 pts), boolean chains 39, loops 6 (7 pts) (nesting depth added 38). 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.
ai_memory_cli::commands::hook_spool::drain_with_live_token (cognitive 182) crates/ai-memory-cli/src/commands/hook_spool.rs:1462— ai_memory_cli::commands::hook_spool::drain_with_live_token has cognitive complexity 182 (threshold 15). Drivers by points: if/else 34 (101 pts), loops 10 (44 pts), match/switch 9 (30 pts), boolean chains 7 (nesting depth added 122). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_cli::commands::uninstall::build_plan (cognitive 99) crates/ai-memory-cli/src/commands/uninstall.rs:206— ai_memory_cli::commands::uninstall::build_plan has cognitive complexity 99 (threshold 15). Drivers by points: if/else 30 (60 pts), loops 13 (31 pts), boolean chains 5, match/switch 1 (3 pts) (nesting depth added 50). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_cli::commands::serve::run (cognitive 93) crates/ai-memory-cli/src/commands/serve.rs:1221— ai_memory_cli::commands::serve::run has cognitive complexity 93 (threshold 15). Drivers by points: if/else 40 (60 pts), match/switch 11 (22 pts), boolean chains 11 (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_cli::commands::backup_agents::discover_assets (cognitive 79) crates/ai-memory-cli/src/commands/backup_agents.rs:173— ai_memory_cli::commands::backup_agents::discover_assets has cognitive complexity 79 (threshold 15). Drivers by points: if/else 43 (71 pts), boolean chains 8 (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.
ai_memory_cli::commands::serve::start_maintenance_scheduler (cognitive 68) crates/ai-memory-cli/src/commands/serve.rs:2188— ai_memory_cli::commands::serve::start_maintenance_scheduler has cognitive complexity 68 (threshold 15). Drivers by points: if/else 19 (26 pts), match/switch 9 (25 pts), loops 4 (9 pts), boolean chains 8 (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.
ai_memory_cli::commands::recovery::recover (cognitive 66) crates/ai-memory-cli/src/commands/recovery.rs:553— ai_memory_cli::commands::recovery::recover has cognitive complexity 66 (threshold 15). Drivers by points: if/else 21 (40 pts), match/switch 8 (16 pts), boolean chains 5, loops 5 (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_cli::commands::session_usage::read_live_calls (cognitive 63) crates/ai-memory-cli/src/commands/session_usage.rs:161— ai_memory_cli::commands::session_usage::read_live_calls has cognitive complexity 63 (threshold 15). Drivers by points: if/else 30 (59 pts), boolean chains 3, loops 1 (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_cli::commands::install_hooks::run_with_hook_connection (cognitive 49) crates/ai-memory-cli/src/commands/install_hooks.rs:807— ai_memory_cli::commands::install_hooks::run_with_hook_connection has cognitive complexity 49 (threshold 15). Drivers by points: if/else 19 (22 pts), match/switch 10 (14 pts), boolean chains 13 (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.
ai_memory_cli::commands::install_mcp::build_mcp_entry (cognitive 42) crates/ai-memory-cli/src/commands/install_mcp.rs:1802— ai_memory_cli::commands::install_mcp::build_mcp_entry has cognitive complexity 42 (threshold 15). Drivers by points: if/else 19 (39 pts), boolean chains 2, match/switch 1 (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.
ai_memory_cli::commands::session_usage::locate_codex_rollout (cognitive 38) crates/ai-memory-cli/src/commands/session_usage.rs:618— ai_memory_cli::commands::session_usage::locate_codex_rollout has cognitive complexity 38 (threshold 15). Drivers by points: if/else 10 (26 pts), loops 4 (9 pts), boolean chains 3 (nesting depth added 21). 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.
ai_memory_cli::commands::hook_spool::recover_stranded_temp_entries (cognitive 37) crates/ai-memory-cli/src/commands/hook_spool.rs:443— ai_memory_cli::commands::hook_spool::recover_stranded_temp_entries has cognitive complexity 37 (threshold 15). Drivers by points: if/else 12 (25 pts), match/switch 5 (10 pts), boolean chains 1, 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.
ai_memory_cli::commands::doctor::presentation::render (cognitive 34) crates/ai-memory-cli/src/commands/doctor/presentation.rs:6— ai_memory_cli::commands::doctor::presentation::render has cognitive complexity 34 (threshold 15). Drivers by points: if/else 24 (31 pts), match/switch 1 (2 pts), loops 1 (nesting depth added 8). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
ai_memory_cli::commands::serve::run_session_consolidation_worker (cognitive 34) crates/ai-memory-cli/src/commands/serve.rs:1007— ai_memory_cli::commands::serve::run_session_consolidation_worker has cognitive complexity 34 (threshold 15). Drivers by points: match/switch 8 (18 pts), if/else 7 (14 pts), boolean chains 1, loops 1 (nesting depth added 17). 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.
ai_memory_cli::commands::show::select_inner (cognitive 34) crates/ai-memory-cli/src/commands/show.rs:827— ai_memory_cli::commands::show::select_inner has cognitive complexity 34 (threshold 15). Drivers by points: if/else 13 (28 pts), boolean chains 2, loops 2, match/switch 1 (2 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_cli::commands::hook::foreign_decision_within (cognitive 33) crates/ai-memory-cli/src/commands/hook.rs:2849— ai_memory_cli::commands::hook::foreign_decision_within has cognitive complexity 33 (threshold 15). Drivers by points: if/else 9 (19 pts), match/switch 5 (10 pts), loops 2 (3 pts), boolean chains 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.
ai_memory_cli::commands::install_mcp::run_with_opencode_dialect (cognitive 33) crates/ai-memory-cli/src/commands/install_mcp.rs:70— ai_memory_cli::commands::install_mcp::run_with_opencode_dialect has cognitive complexity 33 (threshold 15). Drivers by points: boolean chains 16, if/else 10 (16 pts), match/switch 1 (nesting depth added 6). 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.
ai_memory_cli::commands::restore::stage_then_swap (cognitive 33) crates/ai-memory-cli/src/commands/restore.rs:281— ai_memory_cli::commands::restore::stage_then_swap has cognitive complexity 33 (threshold 15). Drivers by points: if/else 18 (28 pts), match/switch 2 (3 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_cli::commands::restore_agents::run (cognitive 33) crates/ai-memory-cli/src/commands/restore_agents.rs:56— ai_memory_cli::commands::restore_agents::run has cognitive complexity 33 (threshold 15). Drivers by points: if/else 15 (23 pts), boolean chains 4, match/switch 2 (4 pts), loops 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_cli::commands::status::presentation::render (cognitive 32) crates/ai-memory-cli/src/commands/status/presentation.rs:19— ai_memory_cli::commands::status::presentation::render has cognitive complexity 32 (threshold 15). Drivers by points: if/else 18 (23 pts), loops 4 (5 pts), boolean chains 2, match/switch 1 (2 pts) (nesting depth added 7). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
ai_memory_cli::commands::restore_agents::stage_archive (cognitive 28) crates/ai-memory-cli/src/commands/restore_agents.rs:271— ai_memory_cli::commands::restore_agents::stage_archive has cognitive complexity 28 (threshold 15). Drivers by points: if/else 12 (25 pts), loops 2 (3 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.
ai_memory_cli::commands::uninstall::run (cognitive 28) crates/ai-memory-cli/src/commands/uninstall.rs:864— ai_memory_cli::commands::uninstall::run has cognitive complexity 28 (threshold 15). Drivers by points: if/else 14 (15 pts), loops 4 (6 pts), boolean chains 5, match/switch 1 (2 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.
ai_memory_cli::commands::run_autowire::ensure_wired_with_env (cognitive 27) crates/ai-memory-cli/src/commands/run_autowire.rs:466— ai_memory_cli::commands::run_autowire::ensure_wired_with_env has cognitive complexity 27 (threshold 15). Drivers by points: if/else 14 (18 pts), match/switch 2 (5 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 8). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
ai_memory_cli::localization::command (cognitive 25) crates/ai-memory-cli/src/localization.rs:131— ai_memory_cli::localization::command has cognitive complexity 25 (threshold 15). Drivers by points: if/else 16 (23 pts), boolean chains 1, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MethodTooLong: AiMemoryServer.memory_query crates/ai-memory-mcp/src/server.rs:3216— MethodTooLong — memory_query runs 422 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 322 over it, 4.22× 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: ReaderPool.hybrid_search_inner crates/ai-memory-store/src/reader.rs:8730— MethodTooLong — hybrid_search_inner runs 393 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 293 over it, 3.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: AiMemoryServer.write_page_in_scope crates/ai-memory-mcp/src/server.rs:5139— MethodTooLong — write_page_in_scope runs 265 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 165 over it, 2.65× 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: Config.load_with_runtime_env crates/ai-memory-cli/src/config.rs:2477— MethodTooLong — load_with_runtime_env 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.
MethodTooLong: AiMemoryServer.memory_auto_improve crates/ai-memory-mcp/src/server.rs:4700— MethodTooLong — memory_auto_improve runs 222 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 122 over it, 2.22× 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: AiMemoryServer.memory_read_page crates/ai-memory-mcp/src/server.rs:5922— MethodTooLong — memory_read_page runs 221 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 121 over it, 2.21× 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: ReaderPool.audit_contamination crates/ai-memory-store/src/reader.rs:13617— MethodTooLong — audit_contamination runs 213 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 113 over it, 2.13× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: Bootstrap.process_sources crates/ai-memory-consolidate/src/bootstrap.rs:436— MethodTooLong — process_sources runs 202 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 102 over it, 2.02× 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: ReaderPool.briefing_for_project_with_slot_visibility crates/ai-memory-store/src/reader.rs:10069— MethodTooLong — briefing_for_project_with_slot_visibility runs 199 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 99 over it, 1.99× 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: ReaderPool.observation_stream_votes crates/ai-memory-store/src/reader.rs:4528— MethodTooLong — observation_stream_votes runs 189 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 89 over it, 1.89× 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: Consolidator.consolidate_session_multi_in_scope crates/ai-memory-consolidate/src/consolidator.rs:844— MethodTooLong — consolidate_session_multi_in_scope runs 185 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 85 over it, 1.85× 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: AiMemoryServer.memory_write_pages_batch crates/ai-memory-mcp/src/server.rs:5504— MethodTooLong — memory_write_pages_batch runs 180 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 80 over it, 1.80× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: ReaderPool.search_pages_with_meta crates/ai-memory-store/src/reader.rs:3547— MethodTooLong — search_pages_with_meta runs 148 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 48 over it, 1.48× 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: ReaderPool.briefing_for_workspace_with_slot_visibility crates/ai-memory-store/src/reader.rs:10586— MethodTooLong — briefing_for_workspace_with_slot_visibility runs 146 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 46 over it, 1.46× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: AiMemoryServer.memory_read_session_observations crates/ai-memory-mcp/src/server.rs:6286— MethodTooLong — memory_read_session_observations 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: ReaderPool.search_page_candidates_for_project_at crates/ai-memory-store/src/reader.rs:3910— MethodTooLong — search_page_candidates_for_project_at 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.
MethodTooLong: Consolidator.consolidate_session_in_scope crates/ai-memory-consolidate/src/consolidator.rs:303— MethodTooLong — consolidate_session_in_scope runs 134 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 34 over it, 1.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.
MethodTooLong: ReaderPool.search_page_candidates_for_project crates/ai-memory-store/src/reader.rs:3750— MethodTooLong — search_page_candidates_for_project runs 133 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 33 over it, 1.33× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: AiMemoryServer.memory_message_send crates/ai-memory-mcp/src/server.rs:7389— MethodTooLong — memory_message_send runs 127 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 27 over it, 1.27× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: ReaderPool.entity_hits_filtered crates/ai-memory-store/src/reader.rs:7859— MethodTooLong — entity_hits_filtered runs 126 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 26 over it, 1.26× 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: ReaderPool.search_observations_for_project_as crates/ai-memory-store/src/reader.rs:4276— MethodTooLong — search_observations_for_project_as 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: ReaderPool.diagnose_project_coordinate crates/ai-memory-store/src/reader.rs:13270— MethodTooLong — diagnose_project_coordinate runs 122 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 22 over it, 1.22× 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: ReaderPool.search_pages crates/ai-memory-store/src/reader.rs:3394— MethodTooLong — search_pages runs 121 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 21 over it, 1.21× 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: ReaderPool.derived_index_status_inner crates/ai-memory-store/src/reader.rs:14215— MethodTooLong — derived_index_status_inner runs 120 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 20 over it, 1.20× 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: HookEnvelope.from_query_and_body crates/ai-memory-hooks/src/payload.rs:664— MethodTooLong — from_query_and_body 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.
Duplicated block (8 lines × 2) companions/ai-memory-importer/src/agentmemory/export.rs:860— companions/ai-memory-importer/src/agentmemory/export.rs:860-867 | companions/ai-memory-importer/src/agentmemory/export.rs:878-885 — both copies are in the same file, so extract the 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 `companions/ai-memory-importer/src/agentmemory/export.rs:860` 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) companions/ai-memory-importer/src/mcp.rs:535— companions/ai-memory-importer/src/mcp.rs:535-542 | companions/ai-memory-wikisync/src/mcp.rs:272-279 — before extracting anything, compare `companions/ai-memory-importer/src/mcp.rs` and `companions/ai-memory-wikisync/src/mcp.rs` as WHOLE FILES: this scan already matched 5 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. 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. 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 (8 lines × 2) crates/ai-memory-cli/src/commands/hook_spool.rs:1000— crates/ai-memory-cli/src/commands/hook_spool.rs:1000-1007 | crates/ai-memory-cli/src/commands/hook_spool.rs:1110-1117 — both copies are in the same file, so extract the 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 `crates/ai-memory-cli/src/commands/hook_spool.rs:1000` 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) crates/ai-memory-cli/src/commands/hook_spool.rs:1909— crates/ai-memory-cli/src/commands/hook_spool.rs:1909-1916 | crates/ai-memory-cli/src/commands/hook_spool.rs:2001-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 `crates/ai-memory-cli/src/commands/hook_spool.rs:1909` 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 lines × 2) crates/ai-memory-cli/src/commands/install_hooks.rs:2504— crates/ai-memory-cli/src/commands/install_hooks.rs:2504-2511 | crates/ai-memory-cli/src/commands/install_hooks.rs:2544-2551 — both copies are in the same file, so extract the 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 `crates/ai-memory-cli/src/commands/install_hooks.rs:2504` 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) crates/ai-memory-cli/src/commands/install_hooks.rs:5479— crates/ai-memory-cli/src/commands/install_hooks.rs:5479-5486 | crates/ai-memory-cli/src/commands/install_hooks.rs:6400-6407 — both copies are in the same file, so extract the 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 `crates/ai-memory-cli/src/commands/install_hooks.rs:5479` 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) crates/ai-memory-cli/src/commands/purge_project.rs:279— crates/ai-memory-cli/src/commands/purge_project.rs:279-286 | crates/ai-memory-cli/src/commands/purge_session.rs:179-186 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ai-memory-cli/src/commands/purge_project.rs:279` 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 lines × 2) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:97— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:97-104 | crates/ai-memory-consolidate/src/projection.rs:98-105 — before extracting anything, compare `crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs` and `crates/ai-memory-consolidate/src/projection.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 354 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 (8 lines × 2) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:194— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:194-203 | crates/ai-memory-consolidate/src/projection.rs:289-296 — before extracting anything, compare `crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs` and `crates/ai-memory-consolidate/src/projection.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 354 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 `crates/ai-memory-consolidate/src/consolidator_frozen_oracle.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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 2) crates/ai-memory-consolidate/src/embed.rs:194— crates/ai-memory-consolidate/src/embed.rs:194-201 | crates/ai-memory-consolidate/src/embed.rs:220-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. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ai-memory-consolidate/src/embed.rs:194` 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) crates/ai-memory-core/src/active_project.rs:501— crates/ai-memory-core/src/active_project.rs:501-508 | crates/ai-memory-core/src/active_project.rs:549-556 — both copies are in the same file, so extract the 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, `crates/ai-memory-core/src/active_project.rs:499` calls `write_single`, `write_single_default_global` and `crates/ai-memory-core/src/active_project.rs:548` 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) crates/ai-memory-hooks/src/antigravity.rs:722— crates/ai-memory-hooks/src/antigravity.rs:722-729 | crates/ai-memory-workstream/src/transcript.rs:5263-5270 — 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.
Duplicated block (8 lines × 2) crates/ai-memory-mcp/src/admin.rs:3798— crates/ai-memory-mcp/src/admin.rs:3798-3805 | crates/ai-memory-mcp/src/admin.rs:3868-3875 — both copies are in the same file, so extract the 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) crates/ai-memory-mcp/src/admin.rs:4021— crates/ai-memory-mcp/src/admin.rs:4021-4028 | crates/ai-memory-mcp/src/admin.rs:4088-4095 — both copies are in the same file, so extract the 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, `crates/ai-memory-mcp/src/admin.rs:4085` calls `Err`, `pending_detail` and `crates/ai-memory-mcp/src/admin.rs:4020` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 2) crates/ai-memory-mcp/src/admin.rs:5220— crates/ai-memory-mcp/src/admin.rs:5220-5227 | crates/ai-memory-mcp/src/admin.rs:6450-6457 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/admin.rs:5220` 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) crates/ai-memory-mcp/src/admin.rs:6556— crates/ai-memory-mcp/src/admin.rs:6556-6563 | crates/ai-memory-mcp/src/admin.rs:6695-6702 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/admin.rs:6556` 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) crates/ai-memory-mcp/src/server.rs:6153— crates/ai-memory-mcp/src/server.rs:6153-6160 | crates/ai-memory-mcp/src/server.rs:6186-6193 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/server.rs:6153` 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) crates/ai-memory-mcp/src/server.rs:6986— crates/ai-memory-mcp/src/server.rs:6986-6994 | crates/ai-memory-mcp/src/server.rs:7961-7968 — both copies are in the same file, so extract the 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 before the matched lines, `crates/ai-memory-mcp/src/server.rs:7960` calls `unwrap_or` and `crates/ai-memory-mcp/src/server.rs:6985` 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) crates/ai-memory-store/src/api_credentials.rs:166— crates/ai-memory-store/src/api_credentials.rs:166-173 | crates/ai-memory-store/src/api_credentials.rs:301-308 — both copies are in the same file, so extract the 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) crates/ai-memory-store/src/profile.rs:157— crates/ai-memory-store/src/profile.rs:157-164 | crates/ai-memory-store/src/profile.rs:783-790 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ai-memory-store/src/profile.rs:157` 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 lines × 2) crates/ai-memory-store/src/profile.rs:152— crates/ai-memory-store/src/profile.rs:152-159 | crates/ai-memory-store/src/profile.rs:503-510 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/profile.rs:152` 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 lines × 2) crates/ai-memory-store/src/reader.rs:3630— crates/ai-memory-store/src/reader.rs:3630-3638 | crates/ai-memory-store/src/reader.rs:3687-3694 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/reader.rs:3630` 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, `crates/ai-memory-store/src/reader.rs:3695` calls `page_descriptor` and `crates/ai-memory-store/src/reader.rs:3639` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 2) crates/ai-memory-store/src/reader.rs:4323— crates/ai-memory-store/src/reader.rs:4323-4330 | crates/ai-memory-store/src/reader.rs:4379-4386 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/reader.rs:4323` 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) crates/ai-memory-store/src/reader.rs:9799— crates/ai-memory-store/src/reader.rs:9799-9806 | crates/ai-memory-store/src/reader.rs:9844-9851 — both copies are in the same file, so extract the 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) crates/ai-memory-store/src/reader.rs:11016— crates/ai-memory-store/src/reader.rs:11016-11023 | crates/ai-memory-store/src/reader.rs:11043-11050 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
ai_memory_hooks::router::process_authorized (cognitive 159) crates/ai-memory-hooks/src/router.rs:4995— ai_memory_hooks::router::process_authorized has cognitive complexity 159 (threshold 15). Drivers by points: if/else 62 (103 pts), match/switch 19 (35 pts), boolean chains 20, loops 1 (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.
ai_memory_hooks::router::resolve_project_ids_inner (cognitive 53) crates/ai-memory-hooks/src/router.rs:4178— ai_memory_hooks::router::resolve_project_ids_inner has cognitive complexity 53 (threshold 15). Drivers by points: if/else 21 (32 pts), match/switch 7 (12 pts), boolean chains 7, loops 1 (2 pts) (nesting depth added 17). Of this number, 38 points are the body's own statements and 15 belong to 4 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_hooks::capture_policy::capture_lookup_locations (cognitive 48) crates/ai-memory-hooks/src/capture_policy.rs:2076— ai_memory_hooks::capture_policy::capture_lookup_locations has cognitive complexity 48 (threshold 15). Drivers by points: loops 11 (34 pts), if/else 6 (12 pts), boolean chains 1, match/switch 1 (nesting depth added 29). 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.
ai_memory_hooks::router::fetch_and_accept_handoff_at (cognitive 38) crates/ai-memory-hooks/src/router.rs:2018— ai_memory_hooks::router::fetch_and_accept_handoff_at has cognitive complexity 38 (threshold 15). Drivers by points: if/else 23 (24 pts), match/switch 7 (12 pts), boolean chains 2 (nesting depth added 6). 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.
ai_memory_hooks::capture_policy::brace_overflow_could_leave (cognitive 34) crates/ai-memory-hooks/src/capture_policy.rs:2653— ai_memory_hooks::capture_policy::brace_overflow_could_leave has cognitive complexity 34 (threshold 15). Drivers by points: if/else 9 (23 pts), boolean chains 7, loops 2, match/switch 1 (2 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_hooks::capture_policy::output_spool (cognitive 33) crates/ai-memory-hooks/src/capture_policy.rs:1643— ai_memory_hooks::capture_policy::output_spool has cognitive complexity 33 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 13, loops 3 (5 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_hooks::capture_policy::glob_walk_with (cognitive 33) crates/ai-memory-hooks/src/capture_policy.rs:2417— ai_memory_hooks::capture_policy::glob_walk_with has cognitive complexity 33 (threshold 15). Drivers by points: if/else 12 (17 pts), boolean chains 12, loops 2, match/switch 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_hooks::capture_policy::extract_paths (cognitive 28) crates/ai-memory-hooks/src/capture_policy.rs:1913— ai_memory_hooks::capture_policy::extract_paths has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (17 pts), loops 3 (6 pts), boolean chains 5 (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.
ai_memory_hooks::router::handle_hook_batch (cognitive 28) crates/ai-memory-hooks/src/router.rs:1203— ai_memory_hooks::router::handle_hook_batch has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (21 pts), loops 2 (4 pts), match/switch 1 (2 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.
ai_memory_hooks::capture_policy::has_unevaluated_expansion (cognitive 27) crates/ai-memory-hooks/src/capture_policy.rs:3526— ai_memory_hooks::capture_policy::has_unevaluated_expansion has cognitive complexity 27 (threshold 15). Drivers by points: if/else 5 (13 pts), boolean chains 8, match/switch 2 (5 pts), loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_hooks::workstream::finish_run_inner (cognitive 27) crates/ai-memory-hooks/src/workstream.rs:1183— ai_memory_hooks::workstream::finish_run_inner has cognitive complexity 27 (threshold 15). Drivers by points: if/else 13 (14 pts), match/switch 7 (9 pts), boolean chains 3, loops 1 (nesting depth added 3). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ai_memory_hooks::workstream::prepare_run (cognitive 26) crates/ai-memory-hooks/src/workstream.rs:324— ai_memory_hooks::workstream::prepare_run has cognitive complexity 26 (threshold 15). Drivers by points: if/else 12 (13 pts), match/switch 6 (7 pts), boolean chains 5, loops 1 (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.
ai_memory_hooks::capture_policy::tool_observation_outcome (cognitive 25) crates/ai-memory-hooks/src/capture_policy.rs:493— ai_memory_hooks::capture_policy::tool_observation_outcome has cognitive complexity 25 (threshold 15). Drivers by points: match/switch 10 (22 pts), if/else 2 (3 pts) (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.
ai_memory_hooks::capture_policy::extract (cognitive 25) crates/ai-memory-hooks/src/capture_policy.rs:1362— ai_memory_hooks::capture_policy::extract has cognitive complexity 25 (threshold 15). Drivers by points: if/else 13, boolean chains 9, match/switch 3. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ai_memory_hooks::capture_policy::tokenize (cognitive 25) crates/ai-memory-hooks/src/capture_policy.rs:3718— ai_memory_hooks::capture_policy::tokenize has cognitive complexity 25 (threshold 15). Drivers by points: match/switch 4 (12 pts), boolean chains 8, if/else 2 (4 pts), loops 1 (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.
ai_memory_hooks::capture_policy::expand_braces (cognitive 24) crates/ai-memory-hooks/src/capture_policy.rs:2530— ai_memory_hooks::capture_policy::expand_braces has cognitive complexity 24 (threshold 15). Drivers by points: if/else 5 (10 pts), loops 4 (8 pts), match/switch 2 (6 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_hooks::capture_policy::search_scope (cognitive 23) crates/ai-memory-hooks/src/capture_policy.rs:2250— ai_memory_hooks::capture_policy::search_scope has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (9 pts), loops 4 (7 pts), match/switch 3 (4 pts), boolean chains 3 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_hooks::antigravity::read_transcript_prompts (cognitive 22) crates/ai-memory-hooks/src/antigravity.rs:486— ai_memory_hooks::antigravity::read_transcript_prompts has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (17 pts), boolean chains 2, match/switch 1 (2 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_hooks::capture_policy::windows_spellings (cognitive 22) crates/ai-memory-hooks/src/capture_policy.rs:4435— ai_memory_hooks::capture_policy::windows_spellings has cognitive complexity 22 (threshold 15). Drivers by points: if/else 13 (16 pts), boolean chains 6 (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.
ai_memory_hooks::router::render_interrupted_session_markdown (cognitive 22) crates/ai-memory-hooks/src/router.rs:2855— ai_memory_hooks::router::render_interrupted_session_markdown has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 6, loops 2 (4 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_hooks::synth::render_body (cognitive 22) crates/ai-memory-hooks/src/synth.rs:824— ai_memory_hooks::synth::render_body has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (11 pts), loops 4 (11 pts) (nesting depth added 9). 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.
ai_memory_hooks::antigravity::read_bounded_line (cognitive 20) crates/ai-memory-hooks/src/antigravity.rs:581— ai_memory_hooks::antigravity::read_bounded_line has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (19 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_hooks::brief_tiers::assign_tiers (cognitive 20) crates/ai-memory-hooks/src/brief_tiers.rs:95— ai_memory_hooks::brief_tiers::assign_tiers has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (10 pts), boolean chains 4, match/switch 3 (4 pts), loops 2 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, 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.
ai_memory_hooks::router::inspect_capture_envelope (cognitive 20) crates/ai-memory-hooks/src/router.rs:1439— ai_memory_hooks::router::inspect_capture_envelope has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (17 pts), 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.
ai_memory_hooks::capture_policy::globs_intersect (cognitive 19) crates/ai-memory-hooks/src/capture_policy.rs:1734— ai_memory_hooks::capture_policy::globs_intersect has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (9 pts), boolean chains 7, loops 2 (3 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Duplicated block (7 lines × 2) companions/ai-memory-client/src/scrub.rs:123— companions/ai-memory-client/src/scrub.rs:123-129 | crates/ai-memory-core/src/sanitize.rs:105-111 — 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.
Duplicated block (7 lines × 2) companions/ai-memory-importer/src/claude_mem.rs:681— companions/ai-memory-importer/src/claude_mem.rs:681-688 | companions/ai-memory-importer/src/claude_mem.rs:771-777 — both copies are in the same file, so extract the 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 lines × 2) companions/ai-memory-importer/src/main.rs:1109— companions/ai-memory-importer/src/main.rs:1109-1115 | crates/ai-memory-wiki/src/markdown.rs:66-72 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (7 lines × 2) companions/ai-memory-wikisync/src/bidi.rs:779— companions/ai-memory-wikisync/src/bidi.rs:779-785 | companions/ai-memory-wikisync/src/bidi.rs:832-838 — both copies are in the same file, so extract the 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 `companions/ai-memory-wikisync/src/bidi.rs:779` 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) crates/ai-memory-cli/src/commands/auto_improve_report.rs:69— crates/ai-memory-cli/src/commands/auto_improve_report.rs:69-75 | crates/ai-memory-cli/src/commands/curator.rs:64-70 — before extracting anything, compare `crates/ai-memory-cli/src/commands/auto_improve_report.rs` and `crates/ai-memory-cli/src/commands/curator.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 48 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 first that the copies are not typed on the same thing: the declarations holding them bind `args` to `AutoImproveReportArgs` in one and `CuratorArgs` 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) crates/ai-memory-cli/src/commands/install_hooks.rs:2766— crates/ai-memory-cli/src/commands/install_hooks.rs:2766-2772 | crates/ai-memory-cli/src/commands/install_hooks.rs:2959-2965 — both copies are in the same file, so extract the 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 `crates/ai-memory-cli/src/commands/install_hooks.rs:2766` 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) crates/ai-memory-cli/src/commands/install_hooks.rs:7051— crates/ai-memory-cli/src/commands/install_hooks.rs:7051-7057 | crates/ai-memory-cli/src/commands/setup_agent.rs:183-189 — before extracting anything, compare `crates/ai-memory-cli/src/commands/install_hooks.rs` and `crates/ai-memory-cli/src/commands/setup_agent.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 44 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) crates/ai-memory-cli/src/commands/install_instructions.rs:634— crates/ai-memory-cli/src/commands/install_instructions.rs:634-640 | crates/ai-memory-cli/src/commands/uninstall.rs:1297-1303 — 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) crates/ai-memory-cli/src/commands/render_shared.rs:2523— crates/ai-memory-cli/src/commands/render_shared.rs:2523-2529 | crates/ai-memory-cli/src/commands/render_shared.rs:2561-2567 — both copies are in the same file, so extract the 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) crates/ai-memory-cli/src/http_client.rs:495— crates/ai-memory-cli/src/http_client.rs:495-501 | crates/ai-memory-cli/src/http_client.rs:673-679 — both copies are in the same file, so extract the 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) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:647— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:647-653 | crates/ai-memory-consolidate/src/projection.rs:1179-1185 — before extracting anything, compare `crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs` and `crates/ai-memory-consolidate/src/projection.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 354 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 (7 lines × 2) crates/ai-memory-hooks/src/recap.rs:412— crates/ai-memory-hooks/src/recap.rs:412-418 | crates/ai-memory-hooks/src/recap.rs:686-695 — both copies are in the same file, so extract the 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) crates/ai-memory-hooks/src/router.rs:2948— crates/ai-memory-hooks/src/router.rs:2948-2954 | crates/ai-memory-hooks/src/router.rs:3839-3845 — both copies are in the same file, so extract the 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) crates/ai-memory-store/src/api_credentials.rs:303— crates/ai-memory-store/src/api_credentials.rs:303-309 | crates/ai-memory-store/src/web_sessions.rs:195-201 — 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 `crates/ai-memory-store/src/api_credentials.rs:303` 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 (7 lines × 2) crates/ai-memory-store/src/ops.rs:1753— crates/ai-memory-store/src/ops.rs:1753-1759 | crates/ai-memory-store/src/ops.rs:1781-1787 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ai-memory-store/src/ops.rs:1753` 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 (7 lines × 2) crates/ai-memory-store/src/profile.rs:779— crates/ai-memory-store/src/profile.rs:779-785 | crates/ai-memory-store/src/reader.rs:12556-12562 — before extracting anything, compare `crates/ai-memory-store/src/profile.rs` and `crates/ai-memory-store/src/reader.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 53 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 `crates/ai-memory-store/src/profile.rs:779` 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 (7 lines × 2) crates/ai-memory-store/src/reader.rs:11439— crates/ai-memory-store/src/reader.rs:11439-11445 | crates/ai-memory-store/src/reader.rs:11504-11510 — both copies are in the same file, so extract the 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) crates/ai-memory-web/src/markdown.rs:388— crates/ai-memory-web/src/markdown.rs:388-394 | crates/ai-memory-wiki/src/markdown.rs:440-446 — 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 `crates/ai-memory-web/src/markdown.rs:388` 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) crates/ai-memory-workstream/src/transcript.rs:3528— crates/ai-memory-workstream/src/transcript.rs:3528-3534 | crates/ai-memory-workstream/src/transcript.rs:5979-5985 — both copies are in the same file, so extract the 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 `crates/ai-memory-workstream/src/transcript.rs:3528` 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) evals/src/ab.rs:517— evals/src/ab.rs:517-523 | evals/src/retrieval/qa.rs:457-463 — 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 `evals/src/ab.rs:517` 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) evals/src/abstention.rs:405— evals/src/abstention.rs:405-411 | evals/src/retrieval/grep.rs:77-83 — 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 `evals/src/abstention.rs:405` 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) evals/src/retrieval/mod.rs:444— evals/src/retrieval/mod.rs:444-450 | evals/src/retrieval/mod.rs:557-563 — both copies are in the same file, so extract the 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) crates/ai-memory-workstream/src/transcript.rs:4650— crates/ai-memory-workstream/src/transcript.rs:4650-4656 | crates/ai-memory-workstream/src/transcript.rs:4691-4697 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ai-memory-workstream/src/transcript.rs:4647` calls `parse_str`, `is_err`, `Ok` and `crates/ai-memory-workstream/src/transcript.rs:4690` 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) companions/ai-memory-wikisync/src/atomic.rs:166— companions/ai-memory-wikisync/src/atomic.rs:166-172 | crates/ai-memory-wiki/src/atomic.rs: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) crates/ai-memory-consolidate/src/embed.rs:244— crates/ai-memory-consolidate/src/embed.rs:244-250 | crates/ai-memory-wiki/src/wiki.rs:4207-4213 — 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.
ai_memory_cli::commands::hook::run_with_payload_in_home (cyclomatic 151) crates/ai-memory-cli/src/commands/hook.rs:1557— ai_memory_cli::commands::hook::run_with_payload_in_home has cyclomatic complexity 151 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ai_memory_cli::commands::run::run_once_with_wiring (cyclomatic 146) crates/ai-memory-cli/src/commands/run.rs:613— ai_memory_cli::commands::run::run_once_with_wiring has cyclomatic complexity 146 (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.
ai_memory_cli::commands::install_hooks::run_with_hook_connection (cyclomatic 96) crates/ai-memory-cli/src/commands/install_hooks.rs:807— ai_memory_cli::commands::install_hooks::run_with_hook_connection has cyclomatic complexity 96 (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.
ai_memory_cli::dispatch (cyclomatic 88) crates/ai-memory-cli/src/lib.rs:68— ai_memory_cli::dispatch has cyclomatic complexity 88 (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.
ai_memory_cli::commands::hook_spool::drain_with_live_token (cyclomatic 82) crates/ai-memory-cli/src/commands/hook_spool.rs:1462— ai_memory_cli::commands::hook_spool::drain_with_live_token has cyclomatic complexity 82 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ai_memory_cli::commands::serve::run (cyclomatic 61) crates/ai-memory-cli/src/commands/serve.rs:1221— ai_memory_cli::commands::serve::run 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.
ai_memory_cli::commands::backup_agents::discover_assets (cyclomatic 52) crates/ai-memory-cli/src/commands/backup_agents.rs:173— ai_memory_cli::commands::backup_agents::discover_assets has cyclomatic complexity 52 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ai_memory_cli::commands::uninstall::build_plan (cyclomatic 47) crates/ai-memory-cli/src/commands/uninstall.rs:206— ai_memory_cli::commands::uninstall::build_plan has cyclomatic complexity 47 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ai_memory_cli::commands::serve::start_maintenance_scheduler (cyclomatic 41) crates/ai-memory-cli/src/commands/serve.rs:2188— ai_memory_cli::commands::serve::start_maintenance_scheduler has cyclomatic complexity 41 (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.
ai_memory_cli::commands::recovery::recover (cyclomatic 40) crates/ai-memory-cli/src/commands/recovery.rs:553— ai_memory_cli::commands::recovery::recover has cyclomatic complexity 40 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ai_memory_cli::commands::install_mcp::build_mcp_entry (cyclomatic 38) crates/ai-memory-cli/src/commands/install_mcp.rs:1802— ai_memory_cli::commands::install_mcp::build_mcp_entry has cyclomatic complexity 38 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ai_memory_cli::commands::setup_agent::run (cyclomatic 37) crates/ai-memory-cli/src/commands/setup_agent.rs:57— ai_memory_cli::commands::setup_agent::run has cyclomatic complexity 37 (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.
ai_memory_cli::commands::session_usage::read_live_calls (cyclomatic 29) crates/ai-memory-cli/src/commands/session_usage.rs:161— ai_memory_cli::commands::session_usage::read_live_calls 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.
ai_memory_cli::commands::install_mcp::run_with_opencode_dialect (cyclomatic 28) crates/ai-memory-cli/src/commands/install_mcp.rs:70— ai_memory_cli::commands::install_mcp::run_with_opencode_dialect has cyclomatic complexity 28 (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. This is NOT this file's highest cyclomatic complexity: ai_memory_cli::commands::install_mcp::mcp_config_path_with (cyclomatic 33) 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.
ai_memory_cli::commands::restore_agents::run (cyclomatic 25) crates/ai-memory-cli/src/commands/restore_agents.rs:56— ai_memory_cli::commands::restore_agents::run 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.
ai_memory_cli::commands::show::select_inner (cyclomatic 25) crates/ai-memory-cli/src/commands/show.rs:827— ai_memory_cli::commands::show::select_inner 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.
ai_memory_cli::commands::status::presentation::render (cyclomatic 25) crates/ai-memory-cli/src/commands/status/presentation.rs:19— ai_memory_cli::commands::status::presentation::render 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.
ai_memory_cli::commands::uninstall::generated_file_is_ours (cyclomatic 24) crates/ai-memory-cli/src/commands/uninstall.rs:1704— ai_memory_cli::commands::uninstall::generated_file_is_ours has cyclomatic complexity 24 (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.
ai_memory_cli::commands::uninstall::run (cyclomatic 23) crates/ai-memory-cli/src/commands/uninstall.rs:864— ai_memory_cli::commands::uninstall::run has cyclomatic complexity 23 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ai_memory_cli::commands::doctor::presentation::render (cyclomatic 22) crates/ai-memory-cli/src/commands/doctor/presentation.rs:6— ai_memory_cli::commands::doctor::presentation::render has cyclomatic complexity 22 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ai_memory_cli::commands::uninstall::apply_change (cyclomatic 21) crates/ai-memory-cli/src/commands/uninstall.rs:744— ai_memory_cli::commands::uninstall::apply_change 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.
ai_memory_cli::commands::restore::stage_then_swap (cyclomatic 20) crates/ai-memory-cli/src/commands/restore.rs:281— ai_memory_cli::commands::restore::stage_then_swap 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.
ai_memory_cli::commands::hook_capture::build_marker_query_suffix (cyclomatic 19) crates/ai-memory-cli/src/commands/hook_capture.rs:765— ai_memory_cli::commands::hook_capture::build_marker_query_suffix has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ai_memory_cli::commands::hook_spool::recover_stranded_temp_entries (cyclomatic 19) crates/ai-memory-cli/src/commands/hook_spool.rs:443— ai_memory_cli::commands::hook_spool::recover_stranded_temp_entries 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.
ai_memory_cli::commands::serve::run_session_consolidation_worker (cyclomatic 19) crates/ai-memory-cli/src/commands/serve.rs:1007— ai_memory_cli::commands::serve::run_session_consolidation_worker has cyclomatic complexity 19 (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.
Duplicated block (6 lines × 2) companions/ai-memory-importer/src/mcp.rs:137— companions/ai-memory-importer/src/mcp.rs:137-142 | companions/ai-memory-wikisync/src/mcp.rs:109-114 — before extracting anything, compare `companions/ai-memory-importer/src/mcp.rs` and `companions/ai-memory-wikisync/src/mcp.rs` as WHOLE FILES: this scan already matched 5 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. 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) crates/ai-memory-cli/src/commands/render_shared.rs:451— crates/ai-memory-cli/src/commands/render_shared.rs:451-456 | crates/ai-memory-cli/src/commands/user_service.rs:178-183 — 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 `crates/ai-memory-cli/src/commands/render_shared.rs:451` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `crates/ai-memory-cli/src/commands/render_shared.rs:459` calls `push_str` and `crates/ai-memory-cli/src/commands/user_service.rs:186` 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 × 2) crates/ai-memory-mcp/src/admin.rs:4025— crates/ai-memory-mcp/src/admin.rs:4025-4030 | crates/ai-memory-mcp/src/admin.rs:9309-9315 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/admin.rs:4025` 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) crates/ai-memory-mcp/src/auth.rs:358— crates/ai-memory-mcp/src/auth.rs:358-363 | crates/ai-memory-mcp/src/human_auth.rs:1145-1150 — 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) crates/ai-memory-store/src/dashboard.rs:78— crates/ai-memory-store/src/dashboard.rs:78-83 | crates/ai-memory-store/src/reader.rs:5622-5627 — 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 `crates/ai-memory-store/src/dashboard.rs:78` 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) crates/ai-memory-store/src/reader.rs:3555— crates/ai-memory-store/src/reader.rs:3555-3560 | crates/ai-memory-store/src/reader.rs:3760-3765 — both copies are in the same file, so extract the 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) crates/ai-memory-store/src/reader.rs:4383— crates/ai-memory-store/src/reader.rs:4383-4388 | crates/ai-memory-store/src/reader.rs:4484-4489 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/reader.rs:4383` 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) crates/ai-memory-store/src/reader.rs:4937— crates/ai-memory-store/src/reader.rs:4937-4942 | crates/ai-memory-store/src/reader.rs:8057-8062 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/reader.rs:4937` 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, `crates/ai-memory-store/src/reader.rs:4944` calls `from_slice` and `crates/ai-memory-store/src/reader.rs:8064` 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 × 2) crates/ai-memory-store/src/reader.rs:6782— crates/ai-memory-store/src/reader.rs:6782-6787 | crates/ai-memory-store/src/reader.rs:7021-7026 — both copies are in the same file, so extract the 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) crates/ai-memory-store/src/reader.rs:9294— crates/ai-memory-store/src/reader.rs:9294-9299 | crates/ai-memory-store/src/reader.rs:9340-9345 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/reader.rs:9294` 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) crates/ai-memory-store/src/workstream.rs:910— crates/ai-memory-store/src/workstream.rs:910-915 | crates/ai-memory-store/src/workstream.rs:2118-2123 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/workstream.rs:910` 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 `input` to `&PrepareWorkstreamRun` in one and `&RenameWorkstream` 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 (6 lines × 2) crates/ai-memory-workstream/src/transcript.rs:703— crates/ai-memory-workstream/src/transcript.rs:703-708 | crates/ai-memory-workstream/src/transcript.rs:962-967 — both copies are in the same file, so extract the 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) evals/src/projection.rs:67— evals/src/projection.rs:67-72 | evals/src/projection.rs:90-97 — both copies are in the same file, so extract the 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 `evals/src/projection.rs:67` 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) companions/ai-memory-importer/src/agentmemory/export.rs:139— companions/ai-memory-importer/src/agentmemory/export.rs:139-144 | companions/ai-memory-importer/src/claude_mem.rs:99-104 — before extracting anything, compare `companions/ai-memory-importer/src/agentmemory/export.rs` and `companions/ai-memory-importer/src/claude_mem.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 48 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) crates/ai-memory-cli/src/commands/show.rs:838— crates/ai-memory-cli/src/commands/show.rs:838-843 | crates/ai-memory-cli/src/commands/show.rs:965-970 — both copies are in the same file, so extract the 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) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:787— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:787-792 | crates/ai-memory-consolidate/src/projection.rs:1322-1327 — before extracting anything, compare `crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs` and `crates/ai-memory-consolidate/src/projection.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 354 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 × 2) crates/ai-memory-hooks/src/router.rs:4392— crates/ai-memory-hooks/src/router.rs:4392-4397 | crates/ai-memory-mcp/src/admin.rs:4265-4270 — 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.
Duplicated block (6 lines × 2) crates/ai-memory-wiki/src/wiki.rs:2239— crates/ai-memory-wiki/src/wiki.rs:2239-2244 | crates/ai-memory-wiki/src/wiki.rs:2256-2261 — both copies are in the same file, so extract the 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 `crates/ai-memory-wiki/src/wiki.rs:2239` 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 (6 lines × 2) companions/ai-memory-importer/src/mcp.rs:546— companions/ai-memory-importer/src/mcp.rs:546-551 | companions/ai-memory-wikisync/src/mcp.rs:283-288 — before extracting anything, compare `companions/ai-memory-importer/src/mcp.rs` and `companions/ai-memory-wikisync/src/mcp.rs` as WHOLE FILES: this scan already matched 5 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. 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) crates/ai-memory-cli/src/commands/install_hooks.rs:2139— crates/ai-memory-cli/src/commands/install_hooks.rs:2139-2144 | crates/ai-memory-workstream/src/transcript.rs:6504-6509 — 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) crates/ai-memory-cli/src/commands/install_hooks.rs:7106— crates/ai-memory-cli/src/commands/install_hooks.rs:7106-7111 | crates/ai-memory-cli/src/commands/setup_agent.rs:880-885 — before extracting anything, compare `crates/ai-memory-cli/src/commands/install_hooks.rs` and `crates/ai-memory-cli/src/commands/setup_agent.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 44 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) crates/ai-memory-cli/src/commands/serve.rs:618— crates/ai-memory-cli/src/commands/serve.rs:618-623 | crates/ai-memory-wiki/src/backup.rs:65-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 (6 lines × 2) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:566— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:566-571 | crates/ai-memory-consolidate/src/projection.rs:1097-1102 — before extracting anything, compare `crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs` and `crates/ai-memory-consolidate/src/projection.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 354 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) crates/ai-memory-cli/src/commands/continue_session.rs:141— crates/ai-memory-cli/src/commands/continue_session.rs:141-146 | crates/ai-memory-cli/src/commands/list_projects.rs:91-99 — 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) crates/ai-memory-mcp/src/server.rs:6528— crates/ai-memory-mcp/src/server.rs:6528-6537 | crates/ai-memory-mcp/src/server.rs:7288-7293 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/server.rs:6528` 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.
ai_memory_consolidate::sweep::run_sweep_at (cognitive 113) crates/ai-memory-consolidate/src/sweep.rs:604— ai_memory_consolidate::sweep::run_sweep_at has cognitive complexity 113 (threshold 15). Drivers by points: match/switch 15 (52 pts), if/else 17 (32 pts), loops 9 (27 pts), boolean chains 2 (nesting depth added 70). 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.
ai_memory_consolidate::auto_improve_schedule::run_auto_improve_scheduler_tick (cognitive 48) crates/ai-memory-consolidate/src/auto_improve_schedule.rs:153— ai_memory_consolidate::auto_improve_schedule::run_auto_improve_scheduler_tick has cognitive complexity 48 (threshold 15). Drivers by points: if/else 8 (22 pts), match/switch 6 (19 pts), loops 3 (7 pts) (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_consolidate::profile::harvest_project (cognitive 44) crates/ai-memory-consolidate/src/profile.rs:2235— ai_memory_consolidate::profile::harvest_project has cognitive complexity 44 (threshold 15). Drivers by points: if/else 13 (26 pts), loops 6 (12 pts), match/switch 1 (4 pts), boolean chains 2 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_consolidate::link_guard::unresolved_generated_links (cognitive 42) crates/ai-memory-consolidate/src/link_guard.rs:55— ai_memory_consolidate::link_guard::unresolved_generated_links has cognitive complexity 42 (threshold 15). Drivers by points: if/else 9 (26 pts), loops 7 (11 pts), boolean chains 3, match/switch 1 (2 pts) (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_consolidate::sweep::plan_cold_cluster_dedup (cognitive 40) crates/ai-memory-consolidate/src/sweep.rs:1265— ai_memory_consolidate::sweep::plan_cold_cluster_dedup has cognitive complexity 40 (threshold 15). Drivers by points: if/else 14 (22 pts), loops 6 (9 pts), match/switch 3 (8 pts), boolean chains 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.
ai_memory_consolidate::embed::run_embedding_backfill (cognitive 36) crates/ai-memory-consolidate/src/embed.rs:85— ai_memory_consolidate::embed::run_embedding_backfill has cognitive complexity 36 (threshold 15). Drivers by points: if/else 12 (23 pts), match/switch 3 (9 pts), boolean chains 3, 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.
ai_memory_consolidate::profile::converge (cognitive 35) crates/ai-memory-consolidate/src/profile.rs:1448— ai_memory_consolidate::profile::converge has cognitive complexity 35 (threshold 15). Drivers by points: if/else 15 (26 pts), boolean chains 5, loops 4 (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.
ai_memory_consolidate::bootstrap::collect_rust_module_headers (cognitive 34) crates/ai-memory-consolidate/src/bootstrap.rs:1295— ai_memory_consolidate::bootstrap::collect_rust_module_headers has cognitive complexity 34 (threshold 15). Drivers by points: if/else 9 (23 pts), loops 3 (7 pts), boolean chains 2, 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.
ai_memory_consolidate::dream::run_dream_pass (cognitive 33) crates/ai-memory-consolidate/src/dream.rs:383— ai_memory_consolidate::dream::run_dream_pass has cognitive complexity 33 (threshold 15). Drivers by points: if/else 16 (25 pts), loops 5 (6 pts), match/switch 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_consolidate::curator::run_curator_report_with_breadth (cognitive 30) crates/ai-memory-consolidate/src/curator.rs:104— ai_memory_consolidate::curator::run_curator_report_with_breadth has cognitive complexity 30 (threshold 15). Drivers by points: if/else 14 (24 pts), boolean chains 3, loops 3 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_consolidate::profile::convergence_targets (cognitive 29) crates/ai-memory-consolidate/src/profile.rs:2445— ai_memory_consolidate::profile::convergence_targets has cognitive complexity 29 (threshold 15). Drivers by points: if/else 5 (16 pts), loops 3 (7 pts), match/switch 2 (5 pts), boolean chains 1 (nesting depth added 18). 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.
ai_memory_consolidate::profile::converge_target (cognitive 27) crates/ai-memory-consolidate/src/profile.rs:2552— ai_memory_consolidate::profile::converge_target has cognitive complexity 27 (threshold 15). Drivers by points: if/else 7 (18 pts), match/switch 3 (6 pts), boolean chains 2, loops 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_consolidate::cold_cluster::dbscan (cognitive 26) crates/ai-memory-consolidate/src/cold_cluster.rs:134— ai_memory_consolidate::cold_cluster::dbscan has cognitive complexity 26 (threshold 15). Drivers by points: if/else 4 (14 pts), loops 3 (8 pts), match/switch 1 (3 pts), boolean chains 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_consolidate::auto_improve::apply_eval_gate_with_before_bodies (cognitive 25) crates/ai-memory-consolidate/src/auto_improve.rs:918— ai_memory_consolidate::auto_improve::apply_eval_gate_with_before_bodies has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (15 pts), match/switch 2 (5 pts), boolean chains 4, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_consolidate::lint::run_lint (cognitive 25) crates/ai-memory-consolidate/src/lint.rs:198— ai_memory_consolidate::lint::run_lint has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (16 pts), match/switch 3 (5 pts), loops 3, boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_consolidate::consolidator::fold_rule_slug (cognitive 24) crates/ai-memory-consolidate/src/consolidator.rs:2314— ai_memory_consolidate::consolidator::fold_rule_slug has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (14 pts), match/switch 3 (5 pts), loops 3 (4 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_consolidate::projection::project_from_rows (cognitive 23) crates/ai-memory-consolidate/src/projection.rs:218— ai_memory_consolidate::projection::project_from_rows has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (17 pts), loops 3 (4 pts), boolean chains 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.
ai_memory_consolidate::consolidator_frozen_oracle::project_observations (cognitive 22) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:109— ai_memory_consolidate::consolidator_frozen_oracle::project_observations has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (17 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_consolidate::keep_tokens::mine (cognitive 22) crates/ai-memory-consolidate/src/keep_tokens.rs:178— ai_memory_consolidate::keep_tokens::mine has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (18 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.
ai_memory_consolidate::auto_improve::materialize_patch (cognitive 21) crates/ai-memory-consolidate/src/auto_improve.rs:2299— ai_memory_consolidate::auto_improve::materialize_patch has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (18 pts), match/switch 1 (2 pts), loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_consolidate::auto_improve::builtin_structure_score (cognitive 20) crates/ai-memory-consolidate/src/auto_improve.rs:1105— ai_memory_consolidate::auto_improve::builtin_structure_score has cognitive complexity 20 (threshold 15). Drivers by points: if/else 15 (19 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.
ai_memory_consolidate::lint::rule_based_findings (cognitive 20) crates/ai-memory-consolidate/src/lint.rs:380— ai_memory_consolidate::lint::rule_based_findings has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (12 pts), boolean chains 6, loops 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_consolidate::experience::run_experience_review (cognitive 18) crates/ai-memory-consolidate/src/experience.rs:70— ai_memory_consolidate::experience::run_experience_review has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (11 pts), loops 3 (5 pts), match/switch 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_consolidate::projection::project_session_observations (cognitive 18) crates/ai-memory-consolidate/src/projection.rs:573— ai_memory_consolidate::projection::project_session_observations has cognitive complexity 18 (threshold 15). Drivers by points: if/else 12 (13 pts), match/switch 2 (4 pts), loops 1 (nesting depth added 3). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ai_memory_consolidate::profile::slugify (cognitive 17) crates/ai-memory-consolidate/src/profile.rs:1096— ai_memory_consolidate::profile::slugify has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (15 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.
ai_memory_hooks::router::process_authorized (cyclomatic 101) crates/ai-memory-hooks/src/router.rs:4995— ai_memory_hooks::router::process_authorized has cyclomatic complexity 101 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ai_memory_hooks::router::resolve_project_ids_inner (cyclomatic 38) crates/ai-memory-hooks/src/router.rs:4178— ai_memory_hooks::router::resolve_project_ids_inner has cyclomatic complexity 38 (threshold 15). Of this number, 29 points are the body's own statements and 9 belong to 4 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ai_memory_hooks::capture_policy::has_unevaluated_expansion (cyclomatic 35) crates/ai-memory-hooks/src/capture_policy.rs:3526— ai_memory_hooks::capture_policy::has_unevaluated_expansion has cyclomatic complexity 35 (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.
ai_memory_hooks::capture_policy::tool_observation_outcome (cyclomatic 30) crates/ai-memory-hooks/src/capture_policy.rs:493— ai_memory_hooks::capture_policy::tool_observation_outcome has cyclomatic complexity 30 (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.
ai_memory_hooks::workstream::prepare_run (cyclomatic 30) crates/ai-memory-hooks/src/workstream.rs:324— ai_memory_hooks::workstream::prepare_run has cyclomatic complexity 30 (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.
ai_memory_hooks::capture_policy::extract (cyclomatic 27) crates/ai-memory-hooks/src/capture_policy.rs:1362— ai_memory_hooks::capture_policy::extract has cyclomatic complexity 27 (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.
ai_memory_hooks::capture_policy::glob_walk_with (cyclomatic 26) crates/ai-memory-hooks/src/capture_policy.rs:2417— ai_memory_hooks::capture_policy::glob_walk_with has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ai_memory_hooks::router::fetch_and_accept_handoff_at (cyclomatic 26) crates/ai-memory-hooks/src/router.rs:2018— ai_memory_hooks::router::fetch_and_accept_handoff_at has cyclomatic complexity 26 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ai_memory_hooks::capture_policy::tokenize (cyclomatic 25) crates/ai-memory-hooks/src/capture_policy.rs:3718— ai_memory_hooks::capture_policy::tokenize 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.
ai_memory_hooks::capture_policy::output_spool (cyclomatic 24) crates/ai-memory-hooks/src/capture_policy.rs:1643— ai_memory_hooks::capture_policy::output_spool 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.
ai_memory_hooks::workstream::finish_run_inner (cyclomatic 24) crates/ai-memory-hooks/src/workstream.rs:1183— ai_memory_hooks::workstream::finish_run_inner has cyclomatic complexity 24 (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.
ai_memory_hooks::capture_policy::capture_lookup_locations (cyclomatic 22) crates/ai-memory-hooks/src/capture_policy.rs:2076— ai_memory_hooks::capture_policy::capture_lookup_locations 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.
ai_memory_hooks::capture_policy::brace_overflow_could_leave (cyclomatic 22) crates/ai-memory-hooks/src/capture_policy.rs:2653— ai_memory_hooks::capture_policy::brace_overflow_could_leave 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.
ai_memory_hooks::router::handle_hook_batch (cyclomatic 21) crates/ai-memory-hooks/src/router.rs:1203— ai_memory_hooks::router::handle_hook_batch 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.
ai_memory_hooks::capture_policy::search_scope (cyclomatic 19) crates/ai-memory-hooks/src/capture_policy.rs:2250— ai_memory_hooks::capture_policy::search_scope 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. This is NOT this file's highest cyclomatic complexity: ClassMember::admits (cyclomatic 22) 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.
ai_memory_hooks::capture_policy::extract_paths (cyclomatic 18) crates/ai-memory-hooks/src/capture_policy.rs:1913— ai_memory_hooks::capture_policy::extract_paths 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. This is NOT this file's highest cyclomatic complexity: ClassMember::admits (cyclomatic 22) 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.
ai_memory_hooks::capture_policy::windows_spellings (cyclomatic 18) crates/ai-memory-hooks/src/capture_policy.rs:4435— ai_memory_hooks::capture_policy::windows_spellings has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This is NOT this file's highest cyclomatic complexity: ClassMember::admits (cyclomatic 22) 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.
ai_memory_hooks::workstream::list_recent_workstreams (cyclomatic 18) crates/ai-memory-hooks/src/workstream.rs:795— ai_memory_hooks::workstream::list_recent_workstreams 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.
ai_memory_hooks::brief_tiers::assign_tiers (cyclomatic 17) crates/ai-memory-hooks/src/brief_tiers.rs:95— ai_memory_hooks::brief_tiers::assign_tiers 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.
ai_memory_hooks::idle_end::run_idle_end_tick (cyclomatic 17) crates/ai-memory-hooks/src/idle_end.rs:127— ai_memory_hooks::idle_end::run_idle_end_tick has cyclomatic complexity 17 (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.
ai_memory_hooks::router::render_interrupted_session_markdown (cyclomatic 17) crates/ai-memory-hooks/src/router.rs:2855— ai_memory_hooks::router::render_interrupted_session_markdown 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.
ai_memory_hooks::antigravity::read_transcript_prompts (cyclomatic 16) crates/ai-memory-hooks/src/antigravity.rs:486— ai_memory_hooks::antigravity::read_transcript_prompts 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.
ai_memory_hooks::capture_policy::runs_inline_code (cyclomatic 16) crates/ai-memory-hooks/src/capture_policy.rs:3455— ai_memory_hooks::capture_policy::runs_inline_code 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. This is NOT this file's highest cyclomatic complexity: ClassMember::admits (cyclomatic 22) 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.
ai_memory_hooks::capture_policy::glob_states (cyclomatic 16) crates/ai-memory-hooks/src/capture_policy.rs:4774— ai_memory_hooks::capture_policy::glob_states 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. This is NOT this file's highest cyclomatic complexity: ClassMember::admits (cyclomatic 22) 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.
ai_memory_hooks::workstream::rename_workstream (cyclomatic 16) crates/ai-memory-hooks/src/workstream.rs:910— ai_memory_hooks::workstream::rename_workstream 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.
Duplicated block (9 lines × 2) crates/ai-memory-cli/src/commands/doctor.rs:1074— crates/ai-memory-cli/src/commands/doctor.rs:1074-1082 | crates/ai-memory-web/src/routes/health.rs:156-164 — 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 `crates/ai-memory-cli/src/commands/doctor.rs:1074` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) crates/ai-memory-cli/src/commands/hook_spool.rs:1011— crates/ai-memory-cli/src/commands/hook_spool.rs:1011-1019 | crates/ai-memory-cli/src/commands/hook_spool.rs:1121-1129 — both copies are in the same file, so extract the 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 `crates/ai-memory-cli/src/commands/hook_spool.rs:1011` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:213— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:213-221 | crates/ai-memory-consolidate/src/projection.rs:311-319 — before extracting anything, compare `crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs` and `crates/ai-memory-consolidate/src/projection.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 354 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 `crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:213` 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 (9 lines × 2) crates/ai-memory-hooks/src/router.rs:1547— crates/ai-memory-hooks/src/router.rs:1547-1555 | crates/ai-memory-hooks/src/router.rs:1646-1654 — both copies are in the same file, so extract the 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 first that the copies are not typed on the same thing: the declarations holding them bind `protocol` to `&CaptureProtocol` in one and `Option<&CaptureProtocol>` 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 (9 lines × 2) crates/ai-memory-mcp/src/admin.rs:2044— crates/ai-memory-mcp/src/admin.rs:2044-2052 | crates/ai-memory-mcp/src/admin.rs:2173-2181 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/admin.rs:2044` 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) crates/ai-memory-mcp/src/server.rs:7581— crates/ai-memory-mcp/src/server.rs:7581-7589 | crates/ai-memory-mcp/src/server.rs:7814-7822 — both copies are in the same file, so extract the 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) crates/ai-memory-mcp/src/server.rs:7667— crates/ai-memory-mcp/src/server.rs:7667-7675 | crates/ai-memory-mcp/src/server.rs:7769-7777 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/server.rs:7667` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) crates/ai-memory-store/src/ops.rs:9409— crates/ai-memory-store/src/ops.rs:9409-9417 | crates/ai-memory-store/src/reader.rs:6401-6409 — before extracting anything, compare `crates/ai-memory-store/src/ops.rs` and `crates/ai-memory-store/src/reader.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 69 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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 `crates/ai-memory-store/src/ops.rs:9409` 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 × 2) crates/ai-memory-store/src/reader.rs:3419— crates/ai-memory-store/src/reader.rs:3419-3427 | crates/ai-memory-store/src/reader.rs:3482-3490 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/reader.rs:3419` 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 × 2) crates/ai-memory-store/src/reader.rs:9970— crates/ai-memory-store/src/reader.rs:9970-9978 | crates/ai-memory-store/src/reader.rs:9984-9992 — both copies are in the same file, so extract the 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) crates/ai-memory-store/src/reader.rs:11000— crates/ai-memory-store/src/reader.rs:11000-11008 | crates/ai-memory-store/src/reader.rs:11026-11034 — both copies are in the same file, so extract the 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) crates/ai-memory-wiki/src/wiki.rs:61— crates/ai-memory-wiki/src/wiki.rs:61-69 | crates/ai-memory-wiki/src/wiki.rs:85-93 — both copies are in the same file, so extract the 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 `crates/ai-memory-wiki/src/wiki.rs:61` 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 (9 lines × 2) crates/ai-memory-cli/src/commands/hook.rs:178— crates/ai-memory-cli/src/commands/hook.rs:178-186 | crates/ai-memory-cli/src/commands/hook.rs:323-331 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ai-memory-cli/src/commands/hook.rs:178` 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) crates/ai-memory-hooks/src/workstream.rs:438— crates/ai-memory-hooks/src/workstream.rs:438-446 | crates/ai-memory-hooks/src/workstream.rs:846-854 — both copies are in the same file, so extract the 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) crates/ai-memory-store/src/provenance.rs:67— crates/ai-memory-store/src/provenance.rs:67-85 | crates/ai-memory-store/src/reader.rs:5623-5631 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Note 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 (9 lines × 2) crates/ai-memory-cli/src/commands/delete_page.rs:42— crates/ai-memory-cli/src/commands/delete_page.rs:42-54 | crates/ai-memory-cli/src/commands/read_page.rs:71-79 — 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 `crates/ai-memory-cli/src/commands/delete_page.rs:42` 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 `args` to `DeletePageArgs` in one and `ReadPageArgs` 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 (9 lines × 2) crates/ai-memory-mcp/src/admin.rs:910— crates/ai-memory-mcp/src/admin.rs:910-920 | crates/ai-memory-mcp/src/admin_profile.rs:81-89 — 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 `crates/ai-memory-mcp/src/admin.rs:910` 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 × 2) crates/ai-memory-mcp/src/admin.rs:7231— crates/ai-memory-mcp/src/admin.rs:7231-7240 | crates/ai-memory-mcp/src/admin.rs:8839-8847 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/admin.rs:7231` 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 × 2) crates/ai-memory-mcp/src/admin.rs:9814— crates/ai-memory-mcp/src/admin.rs:9814-9822 | crates/ai-memory-mcp/src/admin.rs:9869-9877 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/admin.rs:9814` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) crates/ai-memory-cli/src/commands/pending_writes.rs:139— crates/ai-memory-cli/src/commands/pending_writes.rs:139-147 | crates/ai-memory-cli/src/commands/pending_writes.rs:167-175 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ai-memory-cli/src/commands/pending_writes.rs:139` 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 `args` to `PendingWriteIdArgs` in one and `PendingWriteRejectArgs` 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 (9 lines × 2) crates/ai-memory-llm/src/embedding.rs:168— crates/ai-memory-llm/src/embedding.rs:168-176 | crates/ai-memory-llm/src/embedding.rs:627-635 — both copies are in the same file, so extract the 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 `crates/ai-memory-llm/src/embedding.rs:168` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) crates/ai-memory-consolidate/src/auto_improve.rs:1988— crates/ai-memory-consolidate/src/auto_improve.rs:1988-1996 | crates/ai-memory-consolidate/src/auto_improve.rs:2004-2012 — both copies are in the same file, so extract the 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 `crates/ai-memory-consolidate/src/auto_improve.rs:1988` 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. 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) companions/ai-memory-importer/src/document.rs:1393— companions/ai-memory-importer/src/document.rs:1393-1403 | companions/ai-memory-importer/src/main.rs:1270-1280 — before extracting anything, compare `companions/ai-memory-importer/src/document.rs` and `companions/ai-memory-importer/src/main.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 60 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) crates/ai-memory-cli/src/commands/render_shared.rs:1075— crates/ai-memory-cli/src/commands/render_shared.rs:1075-1085 | crates/ai-memory-cli/src/commands/render_shared.rs:1160-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 `crates/ai-memory-cli/src/commands/render_shared.rs:1075` 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) crates/ai-memory-cli/src/commands/run.rs:2323— crates/ai-memory-cli/src/commands/run.rs:2323-2333 | crates/ai-memory-cli/src/commands/run.rs:2575-2585 — both copies are in the same file, so extract the 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 `crates/ai-memory-cli/src/commands/run.rs:2323` 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 (11 lines × 2) crates/ai-memory-cli/src/commands/show.rs:1043— crates/ai-memory-cli/src/commands/show.rs:1043-1053 | crates/ai-memory-cli/src/commands/show.rs:1121-1131 — both copies are in the same file, so extract the 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, `crates/ai-memory-cli/src/commands/show.rs:1118` calls `viewport_rows`, `min`, `scroll_offset` and `crates/ai-memory-cli/src/commands/show.rs:1042` 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 × 2) crates/ai-memory-cli/src/commands/uninstall.rs:1400— crates/ai-memory-cli/src/commands/uninstall.rs:1400-1410 | crates/ai-memory-cli/src/commands/uninstall.rs:1634-1644 — both copies are in the same file, so extract the 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 `crates/ai-memory-cli/src/commands/uninstall.rs:1400` 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) crates/ai-memory-mcp/src/admin.rs:2082— crates/ai-memory-mcp/src/admin.rs:2082-2092 | crates/ai-memory-mcp/src/admin.rs:2208-2218 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/admin.rs:2082` 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) crates/ai-memory-mcp/src/admin.rs:5791— crates/ai-memory-mcp/src/admin.rs:5791-5801 | crates/ai-memory-mcp/src/admin.rs:5892-5902 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/admin.rs:5791` 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) crates/ai-memory-store/src/ops.rs:646— crates/ai-memory-store/src/ops.rs:646-656 | crates/ai-memory-store/src/ops.rs:747-757 — both copies are in the same file, so extract the 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, `crates/ai-memory-store/src/ops.rs:758` calls `path_style_name`, `as_deref`, `Some` and `crates/ai-memory-store/src/ops.rs:657` 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 (11 lines × 2) crates/ai-memory-store/src/reader.rs:10847— crates/ai-memory-store/src/reader.rs:10847-10857 | crates/ai-memory-store/src/reader.rs:10866-10876 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (11 lines × 2) crates/ai-memory-wiki/src/watcher.rs:879— crates/ai-memory-wiki/src/watcher.rs:879-889 | crates/ai-memory-wiki/src/watcher.rs:896-906 — both copies are in the same file, so extract the 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 `crates/ai-memory-wiki/src/watcher.rs:879` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 2) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:700— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:700-710 | crates/ai-memory-consolidate/src/projection.rs:1235-1245 — before extracting anything, compare `crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs` and `crates/ai-memory-consolidate/src/projection.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 354 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 `crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:700` 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) crates/ai-memory-workstream/src/transcript.rs:2718— crates/ai-memory-workstream/src/transcript.rs:2718-2728 | crates/ai-memory-workstream/src/transcript.rs:2744-2754 — both copies are in the same file, so extract the 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 `crates/ai-memory-workstream/src/transcript.rs:2718` 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) companions/ai-memory-client/src/scrub.rs:133— companions/ai-memory-client/src/scrub.rs:133-143 | crates/ai-memory-core/src/sanitize.rs:116-126 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (11 lines × 2) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:312— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:312-322 | crates/ai-memory-consolidate/src/projection.rs:750-760 — before extracting anything, compare `crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs` and `crates/ai-memory-consolidate/src/projection.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 354 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) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:336— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:336-346 | crates/ai-memory-consolidate/src/projection.rs:774-784 — before extracting anything, compare `crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs` and `crates/ai-memory-consolidate/src/projection.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 354 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) crates/ai-memory-llm/src/codex.rs:181— crates/ai-memory-llm/src/codex.rs:181-191 | crates/ai-memory-llm/src/openai_oauth.rs:235-245 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (11 lines × 2) crates/ai-memory-hooks/src/router.rs:1401— crates/ai-memory-hooks/src/router.rs:1401-1411 | crates/ai-memory-hooks/src/router.rs:4828-4843 — both copies are in the same file, so extract the 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 `crates/ai-memory-hooks/src/router.rs:1401` 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 (11 lines × 2) crates/ai-memory-store/src/reader.rs:7621— crates/ai-memory-store/src/reader.rs:7621-7631 | crates/ai-memory-store/src/reader.rs:8409-8421 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/reader.rs:7621` 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) crates/ai-memory-mcp/src/admin.rs:5099— crates/ai-memory-mcp/src/admin.rs:5099-5109 | crates/ai-memory-mcp/src/admin.rs:5723-5733 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (11 lines × 2) crates/ai-memory-mcp/src/server.rs:3258— crates/ai-memory-mcp/src/server.rs:3258-3268 | crates/ai-memory-mcp/src/server.rs:6694-6704 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/server.rs:3258` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 2) crates/ai-memory-workstream/src/harness.rs:509— crates/ai-memory-workstream/src/harness.rs:509-519 | crates/ai-memory-workstream/src/harness.rs:563-573 — both copies are in the same file, so extract the 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 (10 lines × 2) companions/ai-memory-importer/src/mcp.rs:195— companions/ai-memory-importer/src/mcp.rs:195-204 | companions/ai-memory-importer/src/mcp.rs:236-245 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (10 lines × 2) crates/ai-memory-cli/src/commands/hook_capture.rs:996— crates/ai-memory-cli/src/commands/hook_capture.rs:996-1005 | crates/ai-memory-cli/src/commands/hook_capture.rs:1086-1095 — both copies are in the same file, so extract the 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 `crates/ai-memory-cli/src/commands/hook_capture.rs:996` 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) crates/ai-memory-cli/src/commands/install_mcp.rs:702— crates/ai-memory-cli/src/commands/install_mcp.rs:702-711 | crates/ai-memory-llm/src/stored_token.rs:34-43 — 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) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:325— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:325-334 | crates/ai-memory-consolidate/src/projection.rs:763-772 — before extracting anything, compare `crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs` and `crates/ai-memory-consolidate/src/projection.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 354 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 (10 lines × 2) crates/ai-memory-consolidate/src/dream.rs:485— crates/ai-memory-consolidate/src/dream.rs:485-494 | crates/ai-memory-consolidate/src/sweep.rs:1344-1353 — before extracting anything, compare `crates/ai-memory-consolidate/src/dream.rs` and `crates/ai-memory-consolidate/src/sweep.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 45 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, `crates/ai-memory-consolidate/src/dream.rs:483` calls `cluster_surprisal` and `crates/ai-memory-consolidate/src/sweep.rs:1343` 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 (10 lines × 2) crates/ai-memory-hooks/src/antigravity.rs:674— crates/ai-memory-hooks/src/antigravity.rs:674-683 | crates/ai-memory-workstream/src/transcript.rs:5227-5236 — 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) crates/ai-memory-hooks/src/capture_policy.rs:1928— crates/ai-memory-hooks/src/capture_policy.rs:1928-1937 | crates/ai-memory-hooks/src/capture_policy.rs:1957-1966 — both copies are in the same file, so extract the 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 `crates/ai-memory-hooks/src/capture_policy.rs:1928` 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) crates/ai-memory-hooks/src/workstream.rs:554— crates/ai-memory-hooks/src/workstream.rs:554-563 | crates/ai-memory-hooks/src/workstream.rs:644-653 — both copies are in the same file, so extract the 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 `crates/ai-memory-hooks/src/workstream.rs:554` 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) crates/ai-memory-llm/src/redirect.rs:18— crates/ai-memory-llm/src/redirect.rs:18-27 | crates/ai-memory-wiki/src/admission.rs:798-807 — 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 `crates/ai-memory-llm/src/redirect.rs:18` 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) crates/ai-memory-mcp/src/admin.rs:4431— crates/ai-memory-mcp/src/admin.rs:4431-4440 | crates/ai-memory-mcp/src/admin.rs:4480-4489 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/admin.rs:4431` 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) crates/ai-memory-store/src/reader.rs:4197— crates/ai-memory-store/src/reader.rs:4197-4206 | crates/ai-memory-store/src/reader.rs:9014-9023 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/reader.rs:4197` 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) crates/ai-memory-store/src/reader.rs:5432— crates/ai-memory-store/src/reader.rs:5432-5441 | crates/ai-memory-store/src/reader.rs:5471-5480 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/reader.rs:5432` 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) crates/ai-memory-store/src/reader.rs:9521— crates/ai-memory-store/src/reader.rs:9521-9530 | crates/ai-memory-store/src/reader.rs:9731-9740 — both copies are in the same file, so extract the 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) crates/ai-memory-cli/src/commands/install_mcp.rs:2063— crates/ai-memory-cli/src/commands/install_mcp.rs:2063-2072 | crates/ai-memory-cli/src/commands/install_mcp.rs:2080-2089 — both copies are in the same file, so extract the 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 (10 lines × 2) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:286— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:286-295 | crates/ai-memory-consolidate/src/projection.rs:724-733 — before extracting anything, compare `crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs` and `crates/ai-memory-consolidate/src/projection.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 354 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) crates/ai-memory-consolidate/src/profile.rs:1147— crates/ai-memory-consolidate/src/profile.rs:1147-1156 | crates/ai-memory-hooks/src/router.rs:3727-3736 — 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) crates/ai-memory-store/src/workstream.rs:1828— crates/ai-memory-store/src/workstream.rs:1828-1837 | crates/ai-memory-store/src/workstream.rs:2194-2205 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/workstream.rs:1828` 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) crates/ai-memory-cli/src/commands/checkpoints.rs:42— crates/ai-memory-cli/src/commands/checkpoints.rs:42-51 | crates/ai-memory-cli/src/commands/workstream_search.rs:29-39 — 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 `crates/ai-memory-cli/src/commands/checkpoints.rs:42` 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, `crates/ai-memory-cli/src/commands/workstream_search.rs:40` calls `display_label` and `crates/ai-memory-cli/src/commands/checkpoints.rs:52` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (10 lines × 2) companions/ai-memory-importer/src/agentmemory/export.rs:888— companions/ai-memory-importer/src/agentmemory/export.rs:888-898 | companions/ai-memory-importer/src/agentmemory/export.rs:901-910 — both copies are in the same file, so extract the 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 `companions/ai-memory-importer/src/agentmemory/export.rs:888` 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 (10 lines × 2) crates/ai-memory-cli/src/commands/install_hooks.rs:6102— crates/ai-memory-cli/src/commands/install_hooks.rs:6102-6111 | crates/ai-memory-cli/src/commands/install_hooks.rs:6199-6208 — both copies are in the same file, so extract the 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) crates/ai-memory-cli/src/commands/move_project.rs:192— crates/ai-memory-cli/src/commands/move_project.rs:192-201 | crates/ai-memory-cli/src/commands/move_project.rs:215-224 — both copies are in the same file, so extract the 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 `crates/ai-memory-cli/src/commands/move_project.rs:192` 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) crates/ai-memory-cli/src/commands/hook_spool.rs:892— crates/ai-memory-cli/src/commands/hook_spool.rs:892-896 | crates/ai-memory-cli/src/server_profiles.rs:535-539 — 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) crates/ai-memory-cli/src/commands/install_hooks.rs:3062— crates/ai-memory-cli/src/commands/install_hooks.rs:3062-3069 | crates/ai-memory-cli/src/commands/install_hooks.rs:3467-3471 — both copies are in the same file, so extract the 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 `crates/ai-memory-cli/src/commands/install_hooks.rs:3062` 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) crates/ai-memory-cli/src/commands/install_mcp.rs:1859— crates/ai-memory-cli/src/commands/install_mcp.rs:1859-1863 | crates/ai-memory-cli/src/commands/install_mcp.rs:1874-1878 — both copies are in the same file, so extract the 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 `crates/ai-memory-cli/src/commands/install_mcp.rs:1859` 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) crates/ai-memory-consolidate/src/bootstrap.rs:675— crates/ai-memory-consolidate/src/bootstrap.rs:675-679 | crates/ai-memory-consolidate/src/consolidator.rs:1118-1122 — 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 `crates/ai-memory-consolidate/src/bootstrap.rs:675` 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) crates/ai-memory-consolidate/src/bootstrap.rs:887— crates/ai-memory-consolidate/src/bootstrap.rs:887-891 | crates/ai-memory-consolidate/src/bootstrap.rs:898-902 — both copies are in the same file, so extract the 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 `crates/ai-memory-consolidate/src/bootstrap.rs:887` 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 (5 lines × 2) crates/ai-memory-mcp/src/admin.rs:994— crates/ai-memory-mcp/src/admin.rs:994-998 | crates/ai-memory-mcp/src/admin.rs:1165-1169 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/admin.rs:994` 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) crates/ai-memory-store/src/project_coordinates.rs:193— crates/ai-memory-store/src/project_coordinates.rs:193-198 | crates/ai-memory-store/src/workstream.rs:1834-1838 — 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 `crates/ai-memory-store/src/project_coordinates.rs:193` 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) crates/ai-memory-wiki/src/wiki.rs:584— crates/ai-memory-wiki/src/wiki.rs:584-588 | crates/ai-memory-wiki/src/wiki.rs:609-613 — both copies are in the same file, so extract the 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) crates/ai-memory-workstream/src/jail.rs:902— crates/ai-memory-workstream/src/jail.rs:902-906 | crates/ai-memory-workstream/src/jail_contract.rs:245-249 — 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) crates/ai-memory-workstream/src/transcript.rs:3043— crates/ai-memory-workstream/src/transcript.rs:3043-3049 | crates/ai-memory-workstream/src/transcript.rs:3179-3183 — both copies are in the same file, so extract the 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 `crates/ai-memory-workstream/src/transcript.rs:3043` 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) crates/ai-memory-cli/src/commands/project_registry.rs:496— crates/ai-memory-cli/src/commands/project_registry.rs:496-500 | crates/ai-memory-cli/src/commands/recovery.rs:391-395 — 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) crates/ai-memory-cli/src/commands/backfill.rs:550— crates/ai-memory-cli/src/commands/backfill.rs:550-554 | crates/ai-memory-cli/src/commands/mod.rs:14-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 (5 lines × 2) crates/ai-memory-store/src/profile.rs:553— crates/ai-memory-store/src/profile.rs:553-562 | crates/ai-memory-store/src/reader.rs:7764-7768 — before extracting anything, compare `crates/ai-memory-store/src/profile.rs` and `crates/ai-memory-store/src/reader.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 53 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 `crates/ai-memory-store/src/profile.rs:553` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ai-memory-store/src/reader.rs:7762` calls `with_conn` and `crates/ai-memory-store/src/profile.rs:551` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5 lines × 2) crates/ai-memory-cli/src/commands/install_mcp.rs:1378— crates/ai-memory-cli/src/commands/install_mcp.rs:1378-1383 | crates/ai-memory-cli/src/commands/install_mcp.rs:1410-1414 — both copies are in the same file, so extract the 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 `crates/ai-memory-cli/src/commands/install_mcp.rs:1410` 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) companions/ai-memory-importer/src/agentmemory/mod.rs:191— companions/ai-memory-importer/src/agentmemory/mod.rs:191-195 | crates/ai-memory-cli/src/commands/install_hooks.rs:2386-2390 — 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 `companions/ai-memory-importer/src/agentmemory/mod.rs:191` 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) evals/src/abstention.rs:306— evals/src/abstention.rs:306-310 | evals/src/retrieval/mod.rs:431-435 — 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) companions/ai-memory-importer/src/agentmemory/mod.rs:600— companions/ai-memory-importer/src/agentmemory/mod.rs:600-604 | companions/ai-memory-importer/src/agentmemory/mod.rs:654-658 — both copies are in the same file, so extract the 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 `companions/ai-memory-importer/src/agentmemory/mod.rs:600` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (5 lines × 2) crates/ai-memory-cli/src/commands/project_registry.rs:489— crates/ai-memory-cli/src/commands/project_registry.rs:489-493 | crates/ai-memory-cli/src/commands/recovery.rs:305-309 — 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 `crates/ai-memory-cli/src/commands/project_registry.rs:489` 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) crates/ai-memory-store/src/reader.rs:7431— crates/ai-memory-store/src/reader.rs:7431-7435 | crates/ai-memory-store/src/reader.rs:7476-7480 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/reader.rs:7431` 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) crates/ai-memory-wiki/src/markdown.rs:634— crates/ai-memory-wiki/src/markdown.rs:634-638 | crates/ai-memory-wiki/src/markdown.rs:744-748 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
ai_memory_workstream::transcript::locate_session_file (cognitive 78) crates/ai-memory-workstream/src/transcript.rs:4036— ai_memory_workstream::transcript::locate_session_file has cognitive complexity 78 (threshold 15). Drivers by points: if/else 28 (63 pts), loops 6 (15 pts) (nesting depth added 44). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_workstream::transcript::export_jsonl_range (cognitive 65) crates/ai-memory-workstream/src/transcript.rs:1247— ai_memory_workstream::transcript::export_jsonl_range has cognitive complexity 65 (threshold 15). Drivers by points: if/else 30 (51 pts), match/switch 5 (9 pts), boolean chains 4, loops 1 (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_workstream::harness::build_launch_plan_with_env_lookup (cognitive 63) crates/ai-memory-workstream/src/harness.rs:409— ai_memory_workstream::harness::build_launch_plan_with_env_lookup has cognitive complexity 63 (threshold 15). Drivers by points: if/else 23 (53 pts), match/switch 4 (5 pts), boolean chains 4, loops 1 (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_workstream::transcript::claude_continued_sessions (cognitive 46) crates/ai-memory-workstream/src/transcript.rs:851— ai_memory_workstream::transcript::claude_continued_sessions has cognitive complexity 46 (threshold 15). Drivers by points: if/else 15 (38 pts), boolean chains 5, loops 2 (3 pts) (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_workstream::transcript::export_antigravity (cognitive 40) crates/ai-memory-workstream/src/transcript.rs:4892— ai_memory_workstream::transcript::export_antigravity has cognitive complexity 40 (threshold 15). Drivers by points: if/else 13 (25 pts), match/switch 4 (7 pts), boolean chains 6, loops 2 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_workstream::transcript::parse_opencode2 (cognitive 36) crates/ai-memory-workstream/src/transcript.rs:6006— ai_memory_workstream::transcript::parse_opencode2 has cognitive complexity 36 (threshold 15). Drivers by points: if/else 10 (25 pts), match/switch 4 (9 pts), loops 1 (2 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.
ai_memory_workstream::transcript::transcript_baseline_blocking (cognitive 29) crates/ai-memory-workstream/src/transcript.rs:528— ai_memory_workstream::transcript::transcript_baseline_blocking has cognitive complexity 29 (threshold 15). Drivers by points: if/else 7 (23 pts), match/switch 2 (4 pts), loops 1 (2 pts) (nesting depth added 19). 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.
ai_memory_workstream::transcript::parse_kimi (cognitive 26) crates/ai-memory-workstream/src/transcript.rs:2145— ai_memory_workstream::transcript::parse_kimi has cognitive complexity 26 (threshold 15). Drivers by points: match/switch 5 (12 pts), if/else 4 (11 pts), loops 1 (3 pts) (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.
ai_memory_workstream::transcript::parse_command_code (cognitive 25) crates/ai-memory-workstream/src/transcript.rs:2369— ai_memory_workstream::transcript::parse_command_code has cognitive complexity 25 (threshold 15). Drivers by points: if/else 13 (21 pts), match/switch 2 (3 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_workstream::transcript::parse_kiro (cognitive 25) crates/ai-memory-workstream/src/transcript.rs:2686— ai_memory_workstream::transcript::parse_kiro has cognitive complexity 25 (threshold 15). Drivers by points: if/else 3 (11 pts), match/switch 4 (8 pts), loops 3 (6 pts) (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.
ai_memory_workstream::transcript::parse_content_blocks (cognitive 19) crates/ai-memory-workstream/src/transcript.rs:3256— ai_memory_workstream::transcript::parse_content_blocks has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (16 pts), match/switch 1 (2 pts), loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_workstream::transcript::read_bounded_line (cognitive 19) crates/ai-memory-workstream/src/transcript.rs:5420— ai_memory_workstream::transcript::read_bounded_line has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (15 pts), match/switch 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_workstream::transcript::discover_crush (cognitive 19) crates/ai-memory-workstream/src/transcript.rs:5668— ai_memory_workstream::transcript::discover_crush has cognitive complexity 19 (threshold 15). Drivers by points: if/else 11 (16 pts), loops 2 (3 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_workstream::harness::launch_mode (cognitive 18) crates/ai-memory-workstream/src/harness.rs:786— ai_memory_workstream::harness::launch_mode 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.
ai_memory_workstream::jail::parse_jail_toggles (cognitive 18) crates/ai-memory-workstream/src/jail.rs:776— ai_memory_workstream::jail::parse_jail_toggles has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (9 pts), loops 3 (5 pts), match/switch 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.
ai_memory_workstream::transcript::transcript_file (cognitive 17) crates/ai-memory-workstream/src/transcript.rs:4251— ai_memory_workstream::transcript::transcript_file has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9, boolean chains 8. 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.
ai_memory_workstream::transcript::export_crush_range_inner (cognitive 16) crates/ai-memory-workstream/src/transcript.rs:3678— ai_memory_workstream::transcript::export_crush_range_inner has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (13 pts), boolean chains 2, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_workstream::transcript::session_header (cognitive 16) crates/ai-memory-workstream/src/transcript.rs:4569— ai_memory_workstream::transcript::session_header has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (10 pts), match/switch 3 (5 pts), loops 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
ai_memory_store::ops::admit_hook_session_event (cognitive 43) crates/ai-memory-store/src/ops.rs:3471— ai_memory_store::ops::admit_hook_session_event has cognitive complexity 43 (threshold 15). Drivers by points: if/else 21 (32 pts), boolean chains 8, match/switch 2 (3 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_store::ops::resolve_project_by_identity (cognitive 42) crates/ai-memory-store/src/ops.rs:847— ai_memory_store::ops::resolve_project_by_identity has cognitive complexity 42 (threshold 15). Drivers by points: if/else 12 (21 pts), match/switch 7 (13 pts), loops 2 (5 pts), boolean chains 3 (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.
ai_memory_store::writer::worker_loop (cognitive 37) crates/ai-memory-store/src/writer.rs:4030— ai_memory_store::writer::worker_loop has cognitive complexity 37 (threshold 15). Drivers by points: if/else 5 (14 pts), match/switch 5 (14 pts), loops 3 (7 pts), boolean chains 2 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_store::ops::merge_project (cognitive 34) crates/ai-memory-store/src/ops.rs:8798— ai_memory_store::ops::merge_project has cognitive complexity 34 (threshold 15). Drivers by points: if/else 17 (24 pts), loops 7, boolean chains 3 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_store::workstream::finish_run_inner (cognitive 28) crates/ai-memory-store/src/workstream.rs:1396— ai_memory_store::workstream::finish_run_inner has cognitive complexity 28 (threshold 15). Drivers by points: if/else 15 (22 pts), boolean chains 5, 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.
ai_memory_store::ops::repair_session_times (cognitive 26) crates/ai-memory-store/src/ops.rs:3166— ai_memory_store::ops::repair_session_times has cognitive complexity 26 (threshold 15). Drivers by points: if/else 12 (20 pts), boolean chains 5, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_store::ops::accept_handoff_in_transaction (cognitive 26) crates/ai-memory-store/src/ops.rs:5640— ai_memory_store::ops::accept_handoff_in_transaction has cognitive complexity 26 (threshold 15). Drivers by points: if/else 13 (23 pts), match/switch 3 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_store::ops::purge_session_with_owner (cognitive 25) crates/ai-memory-store/src/ops.rs:7575— ai_memory_store::ops::purge_session_with_owner has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (18 pts), loops 4 (5 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_store::auto_improve::stage_run_impl (cognitive 24) crates/ai-memory-store/src/auto_improve.rs:800— ai_memory_store::auto_improve::stage_run_impl has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (15 pts), match/switch 3 (7 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.
ai_memory_store::ops::idle_end_sessions_inner (cognitive 23) crates/ai-memory-store/src/ops.rs:3961— ai_memory_store::ops::idle_end_sessions_inner has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (15 pts), match/switch 3 (7 pts), loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_store::reader::page_descriptor (cognitive 20) crates/ai-memory-store/src/reader.rs:366— ai_memory_store::reader::page_descriptor has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (17 pts), boolean chains 2, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_store::ops::move_session (cognitive 19) crates/ai-memory-store/src/ops.rs:9393— ai_memory_store::ops::move_session has cognitive complexity 19 (threshold 15). Drivers by points: if/else 12 (14 pts), boolean chains 2, match/switch 1 (2 pts), loops 1 (nesting depth added 3). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ai_memory_store::workstream::link_native_session_in_transaction (cognitive 18) crates/ai-memory-store/src/workstream.rs:1013— ai_memory_store::workstream::link_native_session_in_transaction has cognitive complexity 18 (threshold 15). Drivers by points: if/else 11 (15 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.
ai_memory_store::fts_query::prepare_fts5_token (cognitive 17) crates/ai-memory-store/src/fts_query.rs:404— ai_memory_store::fts_query::prepare_fts5_token has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 5 (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.
ai_memory_store::reader::entity_query_tokens (cognitive 17) crates/ai-memory-store/src/reader.rs:910— ai_memory_store::reader::entity_query_tokens has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 2 (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.
ai_memory_store::project_authz::resolve (cognitive 16) crates/ai-memory-store/src/project_authz.rs:419— ai_memory_store::project_authz::resolve has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (7 pts), match/switch 3 (6 pts), boolean chains 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.
ai_memory_store::workstream::link_or_adopt_native_session (cognitive 16) crates/ai-memory-store/src/workstream.rs:1158— ai_memory_store::workstream::link_or_adopt_native_session has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (9 pts), match/switch 3 (4 pts), boolean chains 3 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
ai_memory_importer::agentmemory::export::plan (cognitive 117) companions/ai-memory-importer/src/agentmemory/export.rs:665— ai_memory_importer::agentmemory::export::plan has cognitive complexity 117 (threshold 15). Drivers by points: if/else 38 (78 pts), loops 23 (31 pts), match/switch 5 (7 pts), boolean chains 1 (nesting depth added 50). Of this number, 116 points are the body's own statements and 1 belongs 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.
ai_memory_importer::document::extract_xlsx_sheet_with_limit (cognitive 55) companions/ai-memory-importer/src/document.rs:872— ai_memory_importer::document::extract_xlsx_sheet_with_limit has cognitive complexity 55 (threshold 15). Drivers by points: if/else 17 (45 pts), boolean chains 4, loops 2 (4 pts), match/switch 1 (2 pts) (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_importer::agentmemory::apply_pages_batched (cognitive 48) companions/ai-memory-importer/src/agentmemory/mod.rs:487— ai_memory_importer::agentmemory::apply_pages_batched has cognitive complexity 48 (threshold 15). Drivers by points: if/else 9 (29 pts), loops 4 (9 pts), boolean chains 5, match/switch 2 (5 pts) (nesting depth added 28). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_importer::agentmemory::vault::plan (cognitive 41) companions/ai-memory-importer/src/agentmemory/vault.rs:151— ai_memory_importer::agentmemory::vault::plan has cognitive complexity 41 (threshold 15). Drivers by points: if/else 11 (28 pts), loops 7 (11 pts), match/switch 1 (2 pts) (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_importer::run_omc (cognitive 28) companions/ai-memory-importer/src/main.rs:429— ai_memory_importer::run_omc has cognitive complexity 28 (threshold 15). Drivers by points: if/else 10 (16 pts), loops 3 (7 pts), boolean chains 3, match/switch 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_importer::plan_external_conversation (cognitive 26) companions/ai-memory-importer/src/main.rs:545— ai_memory_importer::plan_external_conversation has cognitive complexity 26 (threshold 15). Drivers by points: if/else 14 (21 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.
ai_memory_importer::document::xlsx_shared_strings (cognitive 25) companions/ai-memory-importer/src/document.rs:807— ai_memory_importer::document::xlsx_shared_strings has cognitive complexity 25 (threshold 15). Drivers by points: if/else 7 (20 pts), boolean chains 2, match/switch 1 (2 pts), loops 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_importer::document::extract_transcript (cognitive 23) companions/ai-memory-importer/src/document.rs:1068— ai_memory_importer::document::extract_transcript has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 5, loops 2 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_importer::agentmemory::apply_page (cognitive 20) companions/ai-memory-importer/src/agentmemory/mod.rs:682— ai_memory_importer::agentmemory::apply_page has cognitive complexity 20 (threshold 15). Drivers by points: if/else 4 (13 pts), loops 2 (4 pts), match/switch 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.
ai_memory_importer::agentmemory::export::run (cognitive 20) companions/ai-memory-importer/src/agentmemory/export.rs:408— ai_memory_importer::agentmemory::export::run has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 3, loops 2 (3 pts), 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.
ai_memory_importer::claude_mem::read_summaries (cognitive 20) companions/ai-memory-importer/src/claude_mem.rs:727— ai_memory_importer::claude_mem::read_summaries has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (15 pts), loops 2 (3 pts), match/switch 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.
ai_memory_importer::document::run (cognitive 19) companions/ai-memory-importer/src/document.rs:213— ai_memory_importer::document::run has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10 (16 pts), match/switch 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.
ai_memory_importer::run_conversation (cognitive 18) companions/ai-memory-importer/src/main.rs:325— ai_memory_importer::run_conversation has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (13 pts), loops 1 (3 pts), boolean chains 1, match/switch 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.
ai_memory_importer::first_h1_line (cognitive 16) companions/ai-memory-importer/src/main.rs:1191— ai_memory_importer::first_h1_line has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (7 pts), boolean chains 4, match/switch 1 (4 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.
ai_memory_importer::claude_mem::snapshot_database (cognitive 16) companions/ai-memory-importer/src/claude_mem.rs:352— ai_memory_importer::claude_mem::snapshot_database has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (10 pts), boolean chains 2, loops 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.
Duplicated block (13 lines × 2) crates/ai-memory-cli/src/commands/render_shared.rs:1087— crates/ai-memory-cli/src/commands/render_shared.rs:1087-1099 | crates/ai-memory-cli/src/commands/render_shared.rs:1172-1184 — both copies are in the same file, so extract the 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 `crates/ai-memory-cli/src/commands/render_shared.rs:1087` 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) crates/ai-memory-llm/src/copilot.rs:626— crates/ai-memory-llm/src/copilot.rs:626-638 | crates/ai-memory-llm/src/embedding.rs:389-401 — 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 `crates/ai-memory-llm/src/copilot.rs:626` 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) crates/ai-memory-mcp/src/human_auth.rs:627— crates/ai-memory-mcp/src/human_auth.rs:627-639 | crates/ai-memory-mcp/src/human_auth.rs:724-736 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/human_auth.rs:627` 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) crates/ai-memory-mcp/src/self_service_keys.rs:73— crates/ai-memory-mcp/src/self_service_keys.rs:73-85 | crates/ai-memory-mcp/src/session_management.rs:82-94 — 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 (13 lines × 2) crates/ai-memory-mcp/src/server.rs:7651— crates/ai-memory-mcp/src/server.rs:7651-7663 | crates/ai-memory-mcp/src/server.rs:7754-7766 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/server.rs:7651` 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) crates/ai-memory-store/src/reader.rs:4338— crates/ai-memory-store/src/reader.rs:4338-4351 | crates/ai-memory-store/src/reader.rs:5006-5018 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/reader.rs:4338` 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) crates/ai-memory-store/src/reader.rs:9310— crates/ai-memory-store/src/reader.rs:9310-9322 | crates/ai-memory-store/src/reader.rs:9355-9367 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/reader.rs:9310` 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) crates/ai-memory-web/src/markdown.rs:236— crates/ai-memory-web/src/markdown.rs:236-248 | crates/ai-memory-wiki/src/markdown.rs:553-565 — 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 `crates/ai-memory-web/src/markdown.rs:236` 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) crates/ai-memory-workstream/src/transcript.rs:2451— crates/ai-memory-workstream/src/transcript.rs:2451-2463 | crates/ai-memory-workstream/src/transcript.rs:2471-2483 — both copies are in the same file, so extract the 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 `crates/ai-memory-workstream/src/transcript.rs:2451` 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) crates/ai-memory-workstream/src/transcript.rs:5603— crates/ai-memory-workstream/src/transcript.rs:5603-5615 | crates/ai-memory-workstream/src/transcript.rs:6209-6221 — both copies are in the same file, so extract the 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 `crates/ai-memory-workstream/src/transcript.rs:5603` 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) crates/ai-memory-store/src/reader.rs:9004— crates/ai-memory-store/src/reader.rs:9004-9016 | crates/ai-memory-store/src/reader.rs:9024-9036 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/reader.rs:9004` 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) crates/ai-memory-store/src/reader.rs:5750— crates/ai-memory-store/src/reader.rs:5750-5762 | crates/ai-memory-store/src/reader.rs:6153-6179 — both copies are in the same file, so extract the 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) crates/ai-memory-cli/src/commands/pending_writes.rs:149— crates/ai-memory-cli/src/commands/pending_writes.rs:149-161 | crates/ai-memory-cli/src/commands/pending_writes.rs:177-189 — both copies are in the same file, so extract the 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 `crates/ai-memory-cli/src/commands/pending_writes.rs:149` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `args` to `PendingWriteIdArgs` in one and `PendingWriteRejectArgs` 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) crates/ai-memory-store/src/profile.rs:139— crates/ai-memory-store/src/profile.rs:139-151 | crates/ai-memory-store/src/profile.rs:766-778 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/profile.rs:139` 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) crates/ai-memory-store/src/users.rs:123— crates/ai-memory-store/src/users.rs:123-135 | crates/ai-memory-store/src/users.rs:162-174 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/users.rs: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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `crates/ai-memory-store/src/users.rs:175` calls `revoke_user_sessions` and `crates/ai-memory-store/src/users.rs:136` 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.
ai_memory_consolidate::sweep::run_sweep_at (cyclomatic 47) crates/ai-memory-consolidate/src/sweep.rs:604— ai_memory_consolidate::sweep::run_sweep_at has cyclomatic complexity 47 (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.
ai_memory_consolidate::sweep::plan_cold_cluster_dedup (cyclomatic 25) crates/ai-memory-consolidate/src/sweep.rs:1265— ai_memory_consolidate::sweep::plan_cold_cluster_dedup 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.
ai_memory_consolidate::dream::run_dream_pass (cyclomatic 22) crates/ai-memory-consolidate/src/dream.rs:383— ai_memory_consolidate::dream::run_dream_pass 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.
ai_memory_consolidate::link_guard::unresolved_generated_links (cyclomatic 22) crates/ai-memory-consolidate/src/link_guard.rs:55— ai_memory_consolidate::link_guard::unresolved_generated_links 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.
ai_memory_consolidate::profile::converge (cyclomatic 21) crates/ai-memory-consolidate/src/profile.rs:1448— ai_memory_consolidate::profile::converge 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.
ai_memory_consolidate::profile::harvest_project (cyclomatic 21) crates/ai-memory-consolidate/src/profile.rs:2235— ai_memory_consolidate::profile::harvest_project 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.
ai_memory_consolidate::auto_improve_schedule::run_auto_improve_scheduler_tick (cyclomatic 20) crates/ai-memory-consolidate/src/auto_improve_schedule.rs:153— ai_memory_consolidate::auto_improve_schedule::run_auto_improve_scheduler_tick 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.
ai_memory_consolidate::curator::run_curator_report_with_breadth (cyclomatic 19) crates/ai-memory-consolidate/src/curator.rs:104— ai_memory_consolidate::curator::run_curator_report_with_breadth 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.
ai_memory_consolidate::embed::run_embedding_backfill (cyclomatic 17) crates/ai-memory-consolidate/src/embed.rs:85— ai_memory_consolidate::embed::run_embedding_backfill 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.
ai_memory_consolidate::auto_improve::apply_eval_gate_with_before_bodies (cyclomatic 16) crates/ai-memory-consolidate/src/auto_improve.rs:918— ai_memory_consolidate::auto_improve::apply_eval_gate_with_before_bodies 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.
ai_memory_consolidate::consolidator_frozen_oracle::project_observations (cyclomatic 16) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:109— ai_memory_consolidate::consolidator_frozen_oracle::project_observations 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: ai_memory_consolidate::consolidator_frozen_oracle::observation_score (cyclomatic 17) 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.
ai_memory_consolidate::profile::converge_target (cyclomatic 16) crates/ai-memory-consolidate/src/profile.rs:2552— ai_memory_consolidate::profile::converge_target 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.
ai_memory_consolidate::projection::project_from_rows (cyclomatic 16) crates/ai-memory-consolidate/src/projection.rs:218— ai_memory_consolidate::projection::project_from_rows 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: ai_memory_consolidate::projection::observation_score (cyclomatic 17) 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.
D4 · Code Duplication· Edited copy of a member (9 corresponding lines) · ×13
Edited copy of a member (9 corresponding lines) crates/ai-memory-core/src/active_project.rs:849— crates/ai-memory-core/src/active_project.rs:849-857 | crates/ai-memory-core/src/active_project.rs:861-869 — 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) companions/ai-memory-importer/src/mcp.rs:534— companions/ai-memory-importer/src/mcp.rs:534-542 | companions/ai-memory-wikisync/src/mcp.rs:271-279 — 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) crates/ai-memory-hooks/src/antigravity.rs:721— crates/ai-memory-hooks/src/antigravity.rs:721-729 | crates/ai-memory-workstream/src/transcript.rs:5262-5270 — 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) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:550— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:550-558 | crates/ai-memory-consolidate/src/projection.rs:1081-1089 — 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) evals/src/abstention.rs:538— evals/src/abstention.rs:538-546 | evals/src/retrieval/score.rs:183-193 — 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) crates/ai-memory-cli/src/commands/hook.rs:1236— crates/ai-memory-cli/src/commands/hook.rs:1236-1244 | crates/ai-memory-hooks/src/recap.rs:768-778 — 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) crates/ai-memory-core/src/sanitize.rs:966— crates/ai-memory-core/src/sanitize.rs:966-975 | crates/ai-memory-hooks/src/router.rs:6411-6419 — 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) crates/ai-memory-cli/src/commands/install_hooks.rs:725— crates/ai-memory-cli/src/commands/install_hooks.rs:725-733 | crates/ai-memory-cli/src/commands/install_mcp.rs:1026-1034 — 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) crates/ai-memory-store/src/api_credentials.rs:17— crates/ai-memory-store/src/api_credentials.rs:17-25 | crates/ai-memory-store/src/web_sessions.rs:30-38 — 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) crates/ai-memory-llm/src/health.rs:893— crates/ai-memory-llm/src/health.rs:893-901 | crates/ai-memory-web/src/routes/graph.rs:267-275 — 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) companions/ai-memory-wikisync/src/state.rs:36— companions/ai-memory-wikisync/src/state.rs:36-44 | crates/ai-memory-store/src/auto_improve.rs:1550-1558 — 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) crates/ai-memory-cli/src/commands/run.rs:4356— crates/ai-memory-cli/src/commands/run.rs:4356-4365 | crates/ai-memory-cli/src/commands/setup.rs:348-356 — 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) crates/ai-memory-store/src/api_credentials.rs:268— crates/ai-memory-store/src/api_credentials.rs:268-276 | crates/ai-memory-store/src/maintenance.rs:30-38 — 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.
ai_memory_wiki::watcher::handle_event (cognitive 39) crates/ai-memory-wiki/src/watcher.rs:243— ai_memory_wiki::watcher::handle_event has cognitive complexity 39 (threshold 15). Drivers by points: if/else 15 (30 pts), match/switch 2 (4 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_wiki::migrations::m2026_09_okf_conformance::nonconformant_files (cognitive 33) crates/ai-memory-wiki/src/migrations/m2026_09_okf_conformance.rs:209— ai_memory_wiki::migrations::m2026_09_okf_conformance::nonconformant_files has cognitive complexity 33 (threshold 15). Drivers by points: if/else 8 (25 pts), boolean chains 3, loops 2 (3 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.
ai_memory_wiki::watcher::walk_project_dirs (cognitive 25) crates/ai-memory-wiki/src/watcher.rs:860— ai_memory_wiki::watcher::walk_project_dirs has cognitive complexity 25 (threshold 15). Drivers by points: if/else 7 (16 pts), match/switch 3 (4 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_wiki::watcher::reconcile_at (cognitive 24) crates/ai-memory-wiki/src/watcher.rs:722— ai_memory_wiki::watcher::reconcile_at has cognitive complexity 24 (threshold 15). Drivers by points: if/else 6 (14 pts), match/switch 2 (6 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_wiki::backup::create_pre_migration_backup_inner (cognitive 23) crates/ai-memory-wiki/src/backup.rs:133— ai_memory_wiki::backup::create_pre_migration_backup_inner has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 3 (4 pts), boolean chains 2, match/switch 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.
ai_memory_wiki::watcher::walk_markdown_partial (cognitive 21) crates/ai-memory-wiki/src/watcher.rs:984— ai_memory_wiki::watcher::walk_markdown_partial has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (13 pts), match/switch 2 (4 pts), loops 2 (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.
ai_memory_wiki::markdown::extract_relation_links (cognitive 20) crates/ai-memory-wiki/src/markdown.rs:373— ai_memory_wiki::markdown::extract_relation_links has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_wiki::markdown::extract_markdown_links (cognitive 20) crates/ai-memory-wiki/src/markdown.rs:909— ai_memory_wiki::markdown::extract_markdown_links has cognitive complexity 20 (threshold 15). Drivers by points: if/else 4 (14 pts), boolean chains 3, match/switch 1 (2 pts), loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_wiki::git::stage_paths (cognitive 19) crates/ai-memory-wiki/src/git.rs:1166— ai_memory_wiki::git::stage_paths has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (15 pts), match/switch 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_wiki::markdown::inline_code_spans (cognitive 19) crates/ai-memory-wiki/src/markdown.rs:281— ai_memory_wiki::markdown::inline_code_spans has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 2 (3 pts), match/switch 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_wiki::markdown::split_scope (cognitive 18) crates/ai-memory-wiki/src/markdown.rs:428— ai_memory_wiki::markdown::split_scope has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (11 pts), boolean chains 4, match/switch 1 (3 pts) (nesting depth added 8). 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.
ai_memory_wiki::confinement::inspect_tree_except (cognitive 17) crates/ai-memory-wiki/src/confinement.rs:197— ai_memory_wiki::confinement::inspect_tree_except has cognitive complexity 17 (threshold 15). Drivers by points: match/switch 4 (9 pts), if/else 3 (5 pts), loops 2 (3 pts) (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.
Duplicated block (16 lines × 2) companions/ai-memory-importer/src/agentmemory/export.rs:151— companions/ai-memory-importer/src/agentmemory/export.rs:151-166 | companions/ai-memory-importer/src/claude_mem.rs:137-152 — before extracting anything, compare `companions/ai-memory-importer/src/agentmemory/export.rs` and `companions/ai-memory-importer/src/claude_mem.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 48 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 `companions/ai-memory-importer/src/agentmemory/export.rs:151` 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) crates/ai-memory-cli/src/commands/install_instructions.rs:359— crates/ai-memory-cli/src/commands/install_instructions.rs:359-374 | crates/ai-memory-cli/src/marker.rs:1402-1417 — 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 `crates/ai-memory-cli/src/marker.rs:1402` 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) crates/ai-memory-cli/src/commands/run.rs:5049— crates/ai-memory-cli/src/commands/run.rs:5049-5064 | crates/ai-memory-workstream/src/jail.rs:111-126 — 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.
Duplicated block (16 lines × 2) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:656— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:656-671 | crates/ai-memory-consolidate/src/projection.rs:1188-1203 — before extracting anything, compare `crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs` and `crates/ai-memory-consolidate/src/projection.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 354 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 (16 lines × 2) crates/ai-memory-mcp/src/admin.rs:2056— crates/ai-memory-mcp/src/admin.rs:2056-2071 | crates/ai-memory-mcp/src/admin.rs:2188-2203 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/admin.rs:2056` 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 (16 lines × 2) crates/ai-memory-mcp/src/server.rs:7884— crates/ai-memory-mcp/src/server.rs:7884-7899 | crates/ai-memory-mcp/src/server.rs:7963-7978 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/server.rs:7884` 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 (16 lines × 2) crates/ai-memory-store/src/reader.rs:8963— crates/ai-memory-store/src/reader.rs:8963-8978 | crates/ai-memory-store/src/reader.rs:8982-8997 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/reader.rs:8963` 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) crates/ai-memory-store/src/reader.rs:10195— crates/ai-memory-store/src/reader.rs:10195-10210 | crates/ai-memory-store/src/reader.rs:10410-10425 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (16 lines × 2) crates/ai-memory-wiki/src/wiki.rs:691— crates/ai-memory-wiki/src/wiki.rs:691-706 | crates/ai-memory-wiki/src/wiki.rs:762-777 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (16 lines × 2) crates/ai-memory-store/src/reader.rs:3468— crates/ai-memory-store/src/reader.rs:3468-3483 | crates/ai-memory-store/src/reader.rs:3643-3660 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/reader.rs:3468` 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 (16 lines × 2) crates/ai-memory-cli/src/commands/auto_improve_report.rs:103— crates/ai-memory-cli/src/commands/auto_improve_report.rs:103-118 | crates/ai-memory-cli/src/commands/curator.rs:97-112 — before extracting anything, compare `crates/ai-memory-cli/src/commands/auto_improve_report.rs` and `crates/ai-memory-cli/src/commands/curator.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 48 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 `crates/ai-memory-cli/src/commands/auto_improve_report.rs:103` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `report` to `&AutoImproveTelemetryReport` in one and `&CuratorReport` 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 (16 lines × 2) crates/ai-memory-workstream/src/transcript.rs:5634— crates/ai-memory-workstream/src/transcript.rs:5634-5649 | crates/ai-memory-workstream/src/transcript.rs:6241-6256 — both copies are in the same file, so extract the 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 `crates/ai-memory-workstream/src/transcript.rs:5634` 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.
ai_memory_workstream::transcript::export_jsonl_range (cyclomatic 43) crates/ai-memory-workstream/src/transcript.rs:1247— ai_memory_workstream::transcript::export_jsonl_range has cyclomatic complexity 43 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ai_memory_workstream::harness::build_launch_plan_with_env_lookup (cyclomatic 38) crates/ai-memory-workstream/src/harness.rs:409— ai_memory_workstream::harness::build_launch_plan_with_env_lookup has cyclomatic complexity 38 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ai_memory_workstream::transcript::locate_session_file (cyclomatic 35) crates/ai-memory-workstream/src/transcript.rs:4036— ai_memory_workstream::transcript::locate_session_file 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.
ai_memory_workstream::transcript::export_antigravity (cyclomatic 29) crates/ai-memory-workstream/src/transcript.rs:4892— ai_memory_workstream::transcript::export_antigravity 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.
ai_memory_workstream::harness::launch_mode (cyclomatic 26) crates/ai-memory-workstream/src/harness.rs:786— ai_memory_workstream::harness::launch_mode 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.
ai_memory_workstream::transcript::claude_continued_sessions (cyclomatic 23) crates/ai-memory-workstream/src/transcript.rs:851— ai_memory_workstream::transcript::claude_continued_sessions 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.
ai_memory_workstream::transcript::parse_command_code (cyclomatic 21) crates/ai-memory-workstream/src/transcript.rs:2369— ai_memory_workstream::transcript::parse_command_code 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.
ai_memory_workstream::transcript::parse_opencode2 (cyclomatic 21) crates/ai-memory-workstream/src/transcript.rs:6006— ai_memory_workstream::transcript::parse_opencode2 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.
ai_memory_workstream::transcript::parse_kimi (cyclomatic 19) crates/ai-memory-workstream/src/transcript.rs:2145— ai_memory_workstream::transcript::parse_kimi has cyclomatic complexity 19 (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.
ai_memory_workstream::transcript::session_header (cyclomatic 19) crates/ai-memory-workstream/src/transcript.rs:4569— ai_memory_workstream::transcript::session_header has cyclomatic complexity 19 (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.
ai_memory_workstream::transcript::transcript_file (cyclomatic 18) crates/ai-memory-workstream/src/transcript.rs:4251— ai_memory_workstream::transcript::transcript_file has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ai_memory_web::features::states (cognitive 49) crates/ai-memory-web/src/features.rs:48— ai_memory_web::features::states has cognitive complexity 49 (threshold 15). Drivers by points: if/else 35 (44 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 10). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
ai_memory_web::routes::inbox::handler (cognitive 37) crates/ai-memory-web/src/routes/inbox.rs:46— ai_memory_web::routes::inbox::handler has cognitive complexity 37 (threshold 15). Drivers by points: match/switch 13 (19 pts), if/else 12 (14 pts), boolean chains 4 (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.
ai_memory_web::routes::search::handler (cognitive 36) crates/ai-memory-web/src/routes/search.rs:87— ai_memory_web::routes::search::handler has cognitive complexity 36 (threshold 15). Drivers by points: match/switch 12 (20 pts), loops 4 (7 pts), if/else 3 (6 pts), boolean chains 3 (nesting depth added 14). 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.
ai_memory_web::knowledge::view (cognitive 34) crates/ai-memory-web/src/knowledge.rs:68— ai_memory_web::knowledge::view has cognitive complexity 34 (threshold 15). Drivers by points: if/else 18 (25 pts), loops 2 (4 pts), match/switch 2 (4 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.
ai_memory_web::management::forms::submit (cognitive 31) crates/ai-memory-web/src/management/forms.rs:67— ai_memory_web::management::forms::submit has cognitive complexity 31 (threshold 15). Drivers by points: if/else 17 (21 pts), boolean chains 5, match/switch 4 (5 pts) (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
ai_memory_web::health::localized_checks (cognitive 28) crates/ai-memory-web/src/health.rs:168— ai_memory_web::health::localized_checks has cognitive complexity 28 (threshold 15). Drivers by points: if/else 16 (21 pts), boolean chains 4, match/switch 2, loops 1 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
ai_memory_web::diff::backtrack (cognitive 21) crates/ai-memory-web/src/diff.rs:160— ai_memory_web::diff::backtrack has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 3, 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.
ai_memory_web::diff::hunks (cognitive 19) crates/ai-memory-web/src/diff.rs:192— ai_memory_web::diff::hunks has cognitive complexity 19 (threshold 15). Drivers by points: if/else 2 (7 pts), loops 4 (6 pts), match/switch 2 (5 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_web::diff::myers (cognitive 18) crates/ai-memory-web/src/diff.rs:122— ai_memory_web::diff::myers has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (8 pts), loops 3 (6 pts), boolean chains 4 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_web::operations::usage_panel (cognitive 18) crates/ai-memory-web/src/operations.rs:245— ai_memory_web::operations::usage_panel has cognitive complexity 18 (threshold 15). Drivers by points: if/else 16, boolean chains 1, match/switch 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.
ai_memory_web::routes::session::handler (cognitive 18) crates/ai-memory-web/src/routes/session.rs:64— ai_memory_web::routes::session::handler has cognitive complexity 18 (threshold 15). Drivers by points: if/else 11, match/switch 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.
ai_memory_mcp::admin::build_okf_bundle_file (cognitive 37) crates/ai-memory-mcp/src/admin.rs:1073— ai_memory_mcp::admin::build_okf_bundle_file has cognitive complexity 37 (threshold 15). Drivers by points: if/else 9 (30 pts), loops 3 (4 pts), boolean chains 3 (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.
ai_memory_mcp::page_patch::apply (cognitive 36) crates/ai-memory-mcp/src/page_patch.rs:127— ai_memory_mcp::page_patch::apply has cognitive complexity 36 (threshold 15). Drivers by points: if/else 11 (24 pts), match/switch 2 (5 pts), loops 4, 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.
ai_memory_mcp::admin::move_session_batch (cognitive 32) crates/ai-memory-mcp/src/admin.rs:8323— ai_memory_mcp::admin::move_session_batch has cognitive complexity 32 (threshold 15). Drivers by points: if/else 13 (20 pts), match/switch 5 (7 pts), boolean chains 4, 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.
ai_memory_mcp::admin::copy_purge_merge (cognitive 32) crates/ai-memory-mcp/src/admin.rs:8609— ai_memory_mcp::admin::copy_purge_merge has cognitive complexity 32 (threshold 15). Drivers by points: if/else 12 (16 pts), match/switch 6 (10 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_mcp::server::answer_evidence_order (cognitive 32) crates/ai-memory-mcp/src/server.rs:9379— ai_memory_mcp::server::answer_evidence_order has cognitive complexity 32 (threshold 15). Drivers by points: loops 9 (16 pts), if/else 5 (14 pts), boolean chains 2 (nesting depth added 16). 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.
ai_memory_mcp::server::answer_sentence_suffix (cognitive 30) crates/ai-memory-mcp/src/server.rs:9478— ai_memory_mcp::server::answer_sentence_suffix has cognitive complexity 30 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 13, loops 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_mcp::server::resolve_def_pass (cognitive 20) crates/ai-memory-mcp/src/server.rs:8528— ai_memory_mcp::server::resolve_def_pass has cognitive complexity 20 (threshold 15). Drivers by points: if/else 5 (10 pts), loops 3 (8 pts), boolean chains 1, 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.
ai_memory_mcp::admin::handle_embed (cognitive 19) crates/ai-memory-mcp/src/admin.rs:4577— ai_memory_mcp::admin::handle_embed has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 1 (3 pts), boolean chains 2, 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.
ai_memory_mcp::auth::authenticate_token (cognitive 19) crates/ai-memory-mcp/src/auth.rs:304— ai_memory_mcp::auth::authenticate_token has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (13 pts), match/switch 2 (4 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_mcp::admin::handle_read_page (cognitive 18) crates/ai-memory-mcp/src/admin.rs:2261— ai_memory_mcp::admin::handle_read_page has cognitive complexity 18 (threshold 15). Drivers by points: match/switch 7 (11 pts), if/else 6, boolean chains 1 (nesting depth added 4). 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.
ai_memory_mcp::human_auth::require_dual_auth (cognitive 17) crates/ai-memory-mcp/src/human_auth.rs:1057— ai_memory_mcp::human_auth::require_dual_auth has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (10 pts), match/switch 4 (5 pts), boolean chains 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D4 · Code Duplication· Edited copy of a member (13 corresponding lines) · ×11
Edited copy of a member (13 corresponding lines) companions/ai-memory-importer/src/agentmemory/export.rs:169— companions/ai-memory-importer/src/agentmemory/export.rs:169-181 | companions/ai-memory-importer/src/claude_mem.rs:154-172 — 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) companions/ai-memory-wikisync/src/hook.rs:246— companions/ai-memory-wikisync/src/hook.rs:246-258 | companions/ai-memory-wikisync/src/state.rs:231-246 — 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) crates/ai-memory-cli/src/commands/hook_spool.rs:418— crates/ai-memory-cli/src/commands/hook_spool.rs:418-430 | crates/ai-memory-cli/src/commands/run.rs:5398-5413 — 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) crates/ai-memory-consolidate/src/embed.rs:256— crates/ai-memory-consolidate/src/embed.rs:256-268 | crates/ai-memory-consolidate/src/embed.rs:274-286 — 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) crates/ai-memory-wiki/src/git.rs:1412— crates/ai-memory-wiki/src/git.rs:1412-1424 | crates/ai-memory-wiki/src/git.rs:1524-1538 — 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) crates/ai-memory-store/src/profile.rs:111— crates/ai-memory-store/src/profile.rs:111-123 | crates/ai-memory-store/src/profile.rs:711-727 — 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) crates/ai-memory-consolidate/src/auto_improve.rs:418— crates/ai-memory-consolidate/src/auto_improve.rs:418-431 | crates/ai-memory-consolidate/src/auto_improve.rs:443-455 — 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) crates/ai-memory-store/src/reader.rs:6810— crates/ai-memory-store/src/reader.rs:6810-6822 | crates/ai-memory-store/src/reader.rs:6836-6848 — 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) crates/ai-memory-store/src/reader.rs:10515— crates/ai-memory-store/src/reader.rs:10515-10527 | crates/ai-memory-store/src/reader.rs:10539-10551 — 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) crates/ai-memory-consolidate/src/auto_improve_schedule.rs:472— crates/ai-memory-consolidate/src/auto_improve_schedule.rs:472-484 | crates/ai-memory-consolidate/src/auto_improve_schedule.rs:491-512 — 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) crates/ai-memory-llm/src/openai_oauth.rs:555— crates/ai-memory-llm/src/openai_oauth.rs:555-568 | crates/ai-memory-llm/src/opencode.rs:379-391 — 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 (15 corresponding lines) · ×10
Edited copy of a member (15 corresponding lines) companions/ai-memory-desktop/src/lib.rs:175— companions/ai-memory-desktop/src/lib.rs:175-191 | crates/ai-memory-cli/src/commands/upgrade.rs:864-878 — 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) crates/ai-memory-cli/src/commands/api_key.rs:86— crates/ai-memory-cli/src/commands/api_key.rs:86-100 | crates/ai-memory-cli/src/commands/user.rs:128-142 — 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) crates/ai-memory-store/src/ops.rs:7931— crates/ai-memory-store/src/ops.rs:7931-7945 | crates/ai-memory-store/src/reader.rs:6497-6522 — 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) crates/ai-memory-cli/src/commands/render_shared.rs:450— crates/ai-memory-cli/src/commands/render_shared.rs:450-465 | crates/ai-memory-cli/src/commands/user_service.rs:177-191 — 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) crates/ai-memory-web/src/markdown.rs:339— crates/ai-memory-web/src/markdown.rs:339-372 | crates/ai-memory-web/src/templates.rs:135-149 — 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) crates/ai-memory-cli/src/commands/backfill.rs:1275— crates/ai-memory-cli/src/commands/backfill.rs:1275-1289 | crates/ai-memory-cli/src/commands/hook_spool.rs:1068-1084 — 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) companions/ai-memory-macos/Sources/AIMemoryMenu/AppModel.swift:192— companions/ai-memory-macos/Sources/AIMemoryMenu/AppModel.swift:192-207 | companions/ai-memory-macos/Sources/AIMemoryMenu/AppModel.swift:217-231 — 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) crates/ai-memory-cli/src/commands/install_skills.rs:507— crates/ai-memory-cli/src/commands/install_skills.rs:507-529 | crates/ai-memory-cli/src/commands/install_skills.rs:531-545 — 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) crates/ai-memory-llm/src/anthropic.rs:586— crates/ai-memory-llm/src/anthropic.rs:586-600 | crates/ai-memory-llm/src/anthropic.rs:612-627 — 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) crates/ai-memory-cli/src/commands/hook.rs:594— crates/ai-memory-cli/src/commands/hook.rs:594-609 | crates/ai-memory-cli/src/commands/hook.rs:1220-1234 — 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· Edited copy of a member (12 corresponding lines) · ×10
Edited copy of a member (12 corresponding lines) crates/ai-memory-mcp/src/human_auth.rs:459— crates/ai-memory-mcp/src/human_auth.rs:459-471 | crates/ai-memory-mcp/src/human_auth.rs:493-504 — 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) crates/ai-memory-cli/src/commands/doctor.rs:1071— crates/ai-memory-cli/src/commands/doctor.rs:1071-1082 | crates/ai-memory-web/src/routes/health.rs: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) companions/ai-memory-importer/src/claude_mem.rs:441— companions/ai-memory-importer/src/claude_mem.rs:441-452 | crates/ai-memory-wiki/src/watcher.rs:427-438 — 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) crates/ai-memory-hooks/src/capture_policy.rs:3185— crates/ai-memory-hooks/src/capture_policy.rs:3185-3199 | crates/ai-memory-hooks/src/capture_policy.rs:3297-3308 — 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) crates/ai-memory-store/src/reader.rs:16240— crates/ai-memory-store/src/reader.rs:16240-16256 | crates/ai-memory-store/src/reader.rs:16261-16272 — 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) crates/ai-memory-mcp/src/admin.rs:9666— crates/ai-memory-mcp/src/admin.rs:9666-9677 | crates/ai-memory-mcp/src/admin.rs:9827-9838 — 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) crates/ai-memory-hooks/src/payload.rs:1262— crates/ai-memory-hooks/src/payload.rs:1262-1273 | crates/ai-memory-hooks/src/payload.rs:1307-1322 — 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) crates/ai-memory-store/src/writer.rs:1047— crates/ai-memory-store/src/writer.rs:1047-1058 | crates/ai-memory-store/src/writer.rs:1394-1406 — 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) crates/ai-memory-cli/src/commands/install_hooks.rs:75— crates/ai-memory-cli/src/commands/install_hooks.rs:75-88 | crates/ai-memory-cli/src/commands/install_hooks.rs:8799-8810 — 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) crates/ai-memory-cli/src/commands/install_hooks.rs:2416— crates/ai-memory-cli/src/commands/install_hooks.rs:2416-2430 | crates/ai-memory-cli/src/commands/install_mcp.rs:2845-2856 — 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.
D4 · Code Duplication· Edited copy of a member (10 corresponding lines) · ×10
Edited copy of a member (10 corresponding lines) crates/ai-memory-wiki/src/wiki.rs:2235— crates/ai-memory-wiki/src/wiki.rs:2235-2244 | crates/ai-memory-wiki/src/wiki.rs:2252-2261 — 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) crates/ai-memory-web/src/markdown.rs:180— crates/ai-memory-web/src/markdown.rs:180-190 | crates/ai-memory-wiki/src/markdown.rs:517-526 — 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) companions/ai-memory-importer/src/agentmemory/vault.rs:363— companions/ai-memory-importer/src/agentmemory/vault.rs:363-372 | companions/ai-memory-importer/src/main.rs:1169-1178 — 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) crates/ai-memory-llm/src/health.rs:400— crates/ai-memory-llm/src/health.rs:400-409 | crates/ai-memory-llm/src/health.rs:411-420 — 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) crates/ai-memory-llm/src/embedding_capacity.rs:128— crates/ai-memory-llm/src/embedding_capacity.rs:128-137 | crates/ai-memory-llm/src/embedding_capacity.rs:139-148 — 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) crates/ai-memory-mcp/src/server.rs:9158— crates/ai-memory-mcp/src/server.rs:9158-9167 | crates/ai-memory-mcp/src/admin.rs:4711-4720 — 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) crates/ai-memory-cli/src/commands/render_shared.rs:2807— crates/ai-memory-cli/src/commands/render_shared.rs:2807-2816 | crates/ai-memory-web/src/routes/pending.rs: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) crates/ai-memory-store/src/grants.rs:97— crates/ai-memory-store/src/grants.rs:97-113 | crates/ai-memory-store/src/api_credentials.rs:208-217 — 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) crates/ai-memory-workstream/src/transcript.rs:6448— crates/ai-memory-workstream/src/transcript.rs:6448-6457 | evals/src/retrieval/ingest.rs:137-146 — 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) crates/ai-memory-cli/src/config.rs:1833— crates/ai-memory-cli/src/config.rs:1833-1842 | crates/ai-memory-consolidate/src/auto_improve.rs:139-148 — 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.
D4 · Code Duplication· Edited copy of a member (7 corresponding lines) · ×10
Edited copy of a member (7 corresponding lines) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:733— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:733-741 | crates/ai-memory-consolidate/src/projection.rs:1270-1276 — 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) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:786— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:786-792 | crates/ai-memory-consolidate/src/projection.rs:1321-1327 — 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) crates/ai-memory-cli/src/config.rs:3794— crates/ai-memory-cli/src/config.rs:3794-3800 | crates/ai-memory-wiki/src/wiki.rs:4338-4344 — 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) crates/ai-memory-cli/src/commands/purge_project.rs:111— crates/ai-memory-cli/src/commands/purge_project.rs:111-120 | crates/ai-memory-cli/src/commands/purge_session.rs:80-86 — 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) companions/ai-memory-relay/src/identity.rs:80— companions/ai-memory-relay/src/identity.rs:80-86 | crates/ai-memory-hooks/src/capture_policy.rs:261-267 — 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) crates/ai-memory-cli/src/commands/backfill.rs:303— crates/ai-memory-cli/src/commands/backfill.rs:303-311 | crates/ai-memory-cli/src/commands/hook.rs:437-443 — 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) companions/ai-memory-relay/src/relay.rs:619— companions/ai-memory-relay/src/relay.rs:619-627 | crates/ai-memory-cli/src/commands/hook_spool.rs:2222-2228 — 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) crates/ai-memory-hooks/src/capture_policy.rs:253— crates/ai-memory-hooks/src/capture_policy.rs:253-259 | crates/ai-memory-hooks/src/payload.rs:950-956 — 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) crates/ai-memory-core/src/excerpt.rs:173— crates/ai-memory-core/src/excerpt.rs:173-179 | crates/ai-memory-store/src/auto_improve.rs:1430-1437 — 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) crates/ai-memory-store/src/ops.rs:625— crates/ai-memory-store/src/ops.rs:625-631 | crates/ai-memory-store/src/project_coordinates.rs:104-114 — 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.
Duplicated block (15 lines × 2) crates/ai-memory-cli/src/commands/compact.rs:66— crates/ai-memory-cli/src/commands/compact.rs:66-80 | crates/ai-memory-web/src/routes/index.rs:196-210 — 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 `crates/ai-memory-cli/src/commands/compact.rs:66` 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) crates/ai-memory-cli/src/commands/install_hooks.rs:4181— crates/ai-memory-cli/src/commands/install_hooks.rs:4181-4195 | crates/ai-memory-cli/src/commands/install_hooks.rs:4415-4429 — both copies are in the same file, so extract the 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 `crates/ai-memory-cli/src/commands/install_hooks.rs:4181` 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 (15 lines × 2) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:713— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:713-727 | crates/ai-memory-consolidate/src/projection.rs:1248-1262 — before extracting anything, compare `crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs` and `crates/ai-memory-consolidate/src/projection.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 354 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 (15 lines × 2) crates/ai-memory-hooks/src/workstream.rs:852— crates/ai-memory-hooks/src/workstream.rs:852-866 | crates/ai-memory-hooks/src/workstream.rs:971-985 — both copies are in the same file, so extract the 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 `crates/ai-memory-hooks/src/workstream.rs:852` 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 (15 lines × 2) crates/ai-memory-mcp/src/admin.rs:5745— crates/ai-memory-mcp/src/admin.rs:5745-5759 | crates/ai-memory-mcp/src/admin.rs:5876-5890 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/admin.rs:5745` 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) crates/ai-memory-store/src/reader.rs:4350— crates/ai-memory-store/src/reader.rs:4350-4364 | crates/ai-memory-store/src/reader.rs:4397-4411 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (15 lines × 2) crates/ai-memory-store/src/reader.rs:4798— crates/ai-memory-store/src/reader.rs:4798-4812 | crates/ai-memory-store/src/reader.rs:4942-4956 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/reader.rs:4798` 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) crates/ai-memory-workstream/src/transcript.rs:3543— crates/ai-memory-workstream/src/transcript.rs:3543-3557 | crates/ai-memory-workstream/src/transcript.rs:5990-6004 — both copies are in the same file, so extract the 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 `crates/ai-memory-workstream/src/transcript.rs:3543` 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) crates/ai-memory-store/src/reader.rs:8311— crates/ai-memory-store/src/reader.rs:8311-8325 | crates/ai-memory-store/src/reader.rs:8387-8401 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/reader.rs:8311` 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 (15 lines × 2) crates/ai-memory-cli/src/commands/purge_project.rs:61— crates/ai-memory-cli/src/commands/purge_project.rs:61-75 | crates/ai-memory-cli/src/commands/purge_session.rs:51-66 — 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 `crates/ai-memory-cli/src/commands/purge_project.rs:61` 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) companions/ai-memory-importer/src/mcp.rs:345— companions/ai-memory-importer/src/mcp.rs:345-358 | companions/ai-memory-wikisync/src/mcp.rs:178-191 — before extracting anything, compare `companions/ai-memory-importer/src/mcp.rs` and `companions/ai-memory-wikisync/src/mcp.rs` as WHOLE FILES: this scan already matched 5 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. 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 `companions/ai-memory-importer/src/mcp.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.
Duplicated block (14 lines × 2) crates/ai-memory-cli/src/commands/hook_spool.rs:1761— crates/ai-memory-cli/src/commands/hook_spool.rs:1761-1774 | crates/ai-memory-cli/src/commands/hook_spool.rs:2051-2064 — both copies are in the same file, so extract the 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 `crates/ai-memory-cli/src/commands/hook_spool.rs:1761` 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) crates/ai-memory-cli/src/commands/serve.rs:3001— crates/ai-memory-cli/src/commands/serve.rs:3001-3014 | crates/ai-memory-mcp/src/server.rs:4771-4784 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (14 lines × 2) crates/ai-memory-cli/src/config.rs:1899— crates/ai-memory-cli/src/config.rs:1899-1916 | crates/ai-memory-mcp/src/server.rs:72-85 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (14 lines × 2) crates/ai-memory-cli/src/marker.rs:339— crates/ai-memory-cli/src/marker.rs:339-352 | crates/ai-memory-cli/src/marker.rs:382-395 — both copies are in the same file, so extract the 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 `crates/ai-memory-cli/src/marker.rs:339` 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 (14 lines × 2) crates/ai-memory-mcp/src/server.rs:5253— crates/ai-memory-mcp/src/server.rs:5253-5266 | crates/ai-memory-mcp/src/server.rs:5282-5295 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/server.rs:5253` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (14 lines × 2) crates/ai-memory-store/src/auto_improve.rs:1055— crates/ai-memory-store/src/auto_improve.rs:1055-1068 | crates/ai-memory-store/src/auto_improve.rs:1104-1117 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/auto_improve.rs:1055` 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. Note first that the copies are not typed on the same thing: the declarations holding them bind `input` to `&FailAutoImproveProposal` in one and `&RejectAutoImproveProposal` 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 (14 lines × 2) crates/ai-memory-store/src/reader.rs:696— crates/ai-memory-store/src/reader.rs:696-709 | crates/ai-memory-store/src/reader.rs:716-729 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/reader.rs:696` 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) crates/ai-memory-store/src/ops.rs:8204— crates/ai-memory-store/src/ops.rs:8204-8217 | crates/ai-memory-store/src/ops.rs:8461-8474 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/ops.rs:8204` 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, `crates/ai-memory-store/src/ops.rs:8219` calls `to_string` and `crates/ai-memory-store/src/ops.rs:8476` 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 (14 lines × 2) crates/ai-memory-wiki/src/wiki.rs:3917— crates/ai-memory-wiki/src/wiki.rs:3917-3934 | crates/ai-memory-wiki/src/wiki.rs:3964-3977 — both copies are in the same file, so extract the 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 `crates/ai-memory-wiki/src/wiki.rs:3917` 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.
ai_memory_store::writer::worker_loop (cyclomatic 152) crates/ai-memory-store/src/writer.rs:4030— ai_memory_store::writer::worker_loop has cyclomatic complexity 152 (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.
ai_memory_store::ops::admit_hook_session_event (cyclomatic 28) crates/ai-memory-store/src/ops.rs:3471— ai_memory_store::ops::admit_hook_session_event 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.
ai_memory_store::ops::merge_project (cyclomatic 27) crates/ai-memory-store/src/ops.rs:8798— ai_memory_store::ops::merge_project 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.
ai_memory_store::ops::resolve_project_by_identity (cyclomatic 21) crates/ai-memory-store/src/ops.rs:847— ai_memory_store::ops::resolve_project_by_identity 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.
ai_memory_store::workstream::finish_run_inner (cyclomatic 20) crates/ai-memory-store/src/workstream.rs:1396— ai_memory_store::workstream::finish_run_inner 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.
ai_memory_store::ops::accept_handoff_in_transaction (cyclomatic 19) crates/ai-memory-store/src/ops.rs:5640— ai_memory_store::ops::accept_handoff_in_transaction 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.
ai_memory_store::auto_improve::stage_run_impl (cyclomatic 17) crates/ai-memory-store/src/auto_improve.rs:800— ai_memory_store::auto_improve::stage_run_impl has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ai_memory_store::ops::repair_session_times (cyclomatic 17) crates/ai-memory-store/src/ops.rs:3166— ai_memory_store::ops::repair_session_times 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.
ai_memory_store::ops::purge_session_with_owner (cyclomatic 17) crates/ai-memory-store/src/ops.rs:7575— ai_memory_store::ops::purge_session_with_owner 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.
ai_memory_importer::agentmemory::export::plan (cyclomatic 70) companions/ai-memory-importer/src/agentmemory/export.rs:665— ai_memory_importer::agentmemory::export::plan has cyclomatic complexity 70 (threshold 15). Of this number, 69 points are the body's own statements and 1 belongs 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.
ai_memory_importer::document::extract_xlsx_sheet_with_limit (cyclomatic 34) companions/ai-memory-importer/src/document.rs:872— ai_memory_importer::document::extract_xlsx_sheet_with_limit 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.
ai_memory_importer::agentmemory::apply_pages_batched (cyclomatic 22) companions/ai-memory-importer/src/agentmemory/mod.rs:487— ai_memory_importer::agentmemory::apply_pages_batched 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.
ai_memory_importer::agentmemory::vault::plan (cyclomatic 22) companions/ai-memory-importer/src/agentmemory/vault.rs:151— ai_memory_importer::agentmemory::vault::plan 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.
ai_memory_importer::document::xlsx_shared_strings (cyclomatic 21) companions/ai-memory-importer/src/document.rs:807— ai_memory_importer::document::xlsx_shared_strings 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.
ai_memory_importer::document::xml_text (cyclomatic 18) companions/ai-memory-importer/src/document.rs:1247— ai_memory_importer::document::xml_text 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.
ai_memory_importer::run_omc (cyclomatic 17) companions/ai-memory-importer/src/main.rs:429— ai_memory_importer::run_omc 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.
ai_memory_importer::plan_external_conversation (cyclomatic 17) companions/ai-memory-importer/src/main.rs:545— ai_memory_importer::plan_external_conversation 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.
ai_memory_importer::agentmemory::export::run (cyclomatic 16) companions/ai-memory-importer/src/agentmemory/export.rs:408— ai_memory_importer::agentmemory::export::run 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 (26 corresponding lines) · ×9
Edited copy of a member (26 corresponding lines) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:677— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:677-710 | crates/ai-memory-consolidate/src/projection.rs:1220-1245 — 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) crates/ai-memory-mcp/src/admin.rs:4174— crates/ai-memory-mcp/src/admin.rs:4174-4199 | crates/ai-memory-store/src/reader.rs:7056-7095 — 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) crates/ai-memory-store/src/reader.rs:15767— crates/ai-memory-store/src/reader.rs:15767-15792 | crates/ai-memory-store/src/reader.rs:15977-16002 — 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) crates/ai-memory-store/src/users.rs:324— crates/ai-memory-store/src/users.rs:324-349 | crates/ai-memory-store/src/users.rs:361-394 — 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) crates/ai-memory-cli/src/commands/install_hooks.rs:332— crates/ai-memory-cli/src/commands/install_hooks.rs:332-360 | crates/ai-memory-cli/src/commands/install_hooks.rs:468-493 — 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) crates/ai-memory-store/src/reader.rs:9787— crates/ai-memory-store/src/reader.rs:9787-9813 | crates/ai-memory-store/src/reader.rs:9833-9858 — 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) crates/ai-memory-store/src/reader.rs:7158— crates/ai-memory-store/src/reader.rs:7158-7183 | crates/ai-memory-store/src/reader.rs:7193-7228 — 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) crates/ai-memory-hooks/src/router.rs:4860— crates/ai-memory-hooks/src/router.rs:4860-4885 | crates/ai-memory-hooks/src/router.rs:4892-4917 — 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) crates/ai-memory-store/src/reader.rs:11104— crates/ai-memory-store/src/reader.rs:11104-11129 | crates/ai-memory-store/src/reader.rs:12330-12360 — 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 (18 corresponding lines) · ×9
Edited copy of a member (18 corresponding lines) crates/ai-memory-store/src/reader.rs:6778— crates/ai-memory-store/src/reader.rs:6778-6795 | crates/ai-memory-store/src/reader.rs:7011-7040 — 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) crates/ai-memory-cli/src/commands/hook_spool.rs:2275— crates/ai-memory-cli/src/commands/hook_spool.rs:2275-2294 | crates/ai-memory-workstream/src/transcript.rs:4511-4528 — 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) crates/ai-memory-llm/src/redirect.rs:17— crates/ai-memory-llm/src/redirect.rs:17-34 | crates/ai-memory-wiki/src/admission.rs:797-814 — 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) crates/ai-memory-consolidate/src/consolidator.rs:1695— crates/ai-memory-consolidate/src/consolidator.rs:1695-1714 | crates/ai-memory-consolidate/src/consolidator.rs:1843-1860 — 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) crates/ai-memory-cli/src/marker.rs:1400— crates/ai-memory-cli/src/marker.rs:1400-1417 | crates/ai-memory-workstream/src/harness.rs:1493-1512 — 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) crates/ai-memory-store/src/reader.rs:13246— crates/ai-memory-store/src/reader.rs:13246-13263 | crates/ai-memory-store/src/reader.rs:13421-13438 — 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) crates/ai-memory-workstream/src/harness.rs:222— crates/ai-memory-workstream/src/harness.rs:222-244 | crates/ai-memory-workstream/src/harness.rs:248-265 — 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) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:582— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:582-599 | crates/ai-memory-consolidate/src/projection.rs:1114-1131 — 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) crates/ai-memory-store/src/reader.rs:5042— crates/ai-memory-store/src/reader.rs:5042-5059 | crates/ai-memory-store/src/reader.rs:7388-7407 — 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.
Duplicated block (12 lines × 2) crates/ai-memory-cli/src/commands/mod.rs:165— crates/ai-memory-cli/src/commands/mod.rs:165-176 | crates/ai-memory-hooks/src/router.rs:2663-2674 — 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.
Duplicated block (12 lines × 2) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:378— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:378-389 | crates/ai-memory-consolidate/src/projection.rs:886-897 — before extracting anything, compare `crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs` and `crates/ai-memory-consolidate/src/projection.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 354 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 `crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:378` 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) crates/ai-memory-llm/src/copilot.rs:387— crates/ai-memory-llm/src/copilot.rs:387-398 | crates/ai-memory-llm/src/copilot.rs:409-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. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `body` to `&CopilotChatRequest<'_>` in one and `&CopilotResponsesRequest<'_>` 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 (12 lines × 2) crates/ai-memory-mcp/src/admin.rs:3261— crates/ai-memory-mcp/src/admin.rs:3261-3272 | crates/ai-memory-mcp/src/admin.rs:3386-3398 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/admin.rs:3261` 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) crates/ai-memory-store/src/ops.rs:671— crates/ai-memory-store/src/ops.rs:671-682 | crates/ai-memory-store/src/ops.rs:765-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 `crates/ai-memory-store/src/ops.rs:671` 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) crates/ai-memory-store/src/reader.rs:10681— crates/ai-memory-store/src/reader.rs:10681-10692 | crates/ai-memory-store/src/reader.rs:10698-10709 — both copies are in the same file, so extract the 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 (12 lines × 2) crates/ai-memory-workstream/src/transcript.rs:4077— crates/ai-memory-workstream/src/transcript.rs:4077-4088 | crates/ai-memory-workstream/src/transcript.rs:4110-4121 — both copies are in the same file, so extract the 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, `crates/ai-memory-workstream/src/transcript.rs:4122` calls `Ok` and `crates/ai-memory-workstream/src/transcript.rs:4089` 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) crates/ai-memory-mcp/src/admin.rs:9640— crates/ai-memory-mcp/src/admin.rs:9640-9651 | crates/ai-memory-mcp/src/admin.rs:9726-9737 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/admin.rs:9640` 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) crates/ai-memory-cli/src/commands/install_hooks.rs:2756— crates/ai-memory-cli/src/commands/install_hooks.rs:2756-2767 | crates/ai-memory-cli/src/commands/install_hooks.rs:2837-2848 — both copies are in the same file, so extract the 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 `crates/ai-memory-cli/src/commands/install_hooks.rs:2756` 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 (11 corresponding lines) · ×8
Edited copy of a member (11 corresponding lines) companions/ai-memory-relay/src/fsguard.rs:241— companions/ai-memory-relay/src/fsguard.rs:241-254 | companions/ai-memory-relay/src/fsguard.rs:258-268 — 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) crates/ai-memory-cli/src/commands/api_key.rs:153— crates/ai-memory-cli/src/commands/api_key.rs:153-163 | crates/ai-memory-cli/src/commands/user.rs:193-203 — 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) crates/ai-memory-cli/src/commands/run.rs:5846— crates/ai-memory-cli/src/commands/run.rs:5846-5858 | crates/ai-memory-cli/src/commands/run.rs:6143-6153 — 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) crates/ai-memory-cli/src/http_client.rs:481— crates/ai-memory-cli/src/http_client.rs:481-491 | crates/ai-memory-cli/src/http_client.rs:494-504 — 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) crates/ai-memory-core/src/active_project.rs:548— crates/ai-memory-core/src/active_project.rs:548-564 | crates/ai-memory-core/src/active_project.rs:699-709 — 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) crates/ai-memory-cli/src/commands/user.rs:379— crates/ai-memory-cli/src/commands/user.rs:379-389 | crates/ai-memory-mcp/src/launch_scope.rs:63-73 — 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) crates/ai-memory-hooks/src/workstream.rs:228— crates/ai-memory-hooks/src/workstream.rs:228-238 | crates/ai-memory-web/src/routes/api.rs:1433-1443 — 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) crates/ai-memory-cli/src/commands/install_mcp.rs:663— crates/ai-memory-cli/src/commands/install_mcp.rs:663-673 | crates/ai-memory-cli/src/commands/install_mcp.rs:678-693 — 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.
ai_memory_mcp::server::answer_sentence_suffix (cyclomatic 24) crates/ai-memory-mcp/src/server.rs:9478— ai_memory_mcp::server::answer_sentence_suffix 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.
ai_memory_mcp::admin::copy_purge_merge (cyclomatic 23) crates/ai-memory-mcp/src/admin.rs:8609— ai_memory_mcp::admin::copy_purge_merge has cyclomatic complexity 23 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
ai_memory_mcp::page_patch::apply (cyclomatic 23) crates/ai-memory-mcp/src/page_patch.rs:127— ai_memory_mcp::page_patch::apply 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.
ai_memory_mcp::admin::move_session_batch (cyclomatic 21) crates/ai-memory-mcp/src/admin.rs:8323— ai_memory_mcp::admin::move_session_batch 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.
ai_memory_mcp::server::answer_evidence_order (cyclomatic 17) crates/ai-memory-mcp/src/server.rs:9379— ai_memory_mcp::server::answer_evidence_order has cyclomatic complexity 17 (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.
ai_memory_mcp::admin::build_okf_bundle_file (cyclomatic 16) crates/ai-memory-mcp/src/admin.rs:1073— ai_memory_mcp::admin::build_okf_bundle_file 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.
ai_memory_mcp::human_auth::handle_change_password (cyclomatic 16) crates/ai-memory-mcp/src/human_auth.rs:832— ai_memory_mcp::human_auth::handle_change_password 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.
ai_memory_eval::retrieval::run (cognitive 32) evals/src/retrieval/mod.rs:387— ai_memory_eval::retrieval::run has cognitive complexity 32 (threshold 15). Drivers by points: if/else 19 (22 pts), boolean chains 5, match/switch 2 (3 pts), loops 1 (2 pts) (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
ai_memory_eval::abstention::validate_fixture (cognitive 25) evals/src/abstention.rs:332— ai_memory_eval::abstention::validate_fixture has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 7, 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.
ai_memory_eval::ab::run (cognitive 20) evals/src/ab.rs:211— ai_memory_eval::ab::run has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (11 pts), loops 3 (6 pts), match/switch 2, boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_eval::retrieval::run_config (cognitive 17) evals/src/retrieval/mod.rs:600— ai_memory_eval::retrieval::run_config has cognitive complexity 17 (threshold 15). Drivers by points: match/switch 3 (7 pts), if/else 4 (6 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.
ai_memory_eval::retrieval::ingest::ingest_question (cognitive 17) evals/src/retrieval/ingest.rs:270— ai_memory_eval::retrieval::ingest::ingest_question has cognitive complexity 17 (threshold 15). Drivers by points: if/else 3 (8 pts), loops 3 (6 pts), match/switch 1 (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.
ai_memory_eval::ab::extract_first_balanced_object (cognitive 16) evals/src/ab.rs:703— ai_memory_eval::ab::extract_first_balanced_object has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (15 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.
ai_memory_eval::retrieval::reachability::evidence_turns (cognitive 16) evals/src/retrieval/reachability.rs:243— ai_memory_eval::retrieval::reachability::evidence_turns has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (8 pts), loops 5 (8 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.
D4 · Code Duplication· Edited copy of a member (6 corresponding lines) · ×7
Edited copy of a member (6 corresponding lines) crates/ai-memory-cli/src/commands/setup_web.rs:131— crates/ai-memory-cli/src/commands/setup_web.rs:131-136 | crates/ai-memory-cli/src/commands/setup_web.rs:138-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) crates/ai-memory-store/src/password.rs:105— crates/ai-memory-store/src/password.rs:105-110 | crates/ai-memory-store/src/web_sessions.rs:44-49 — 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) crates/ai-memory-cli/src/commands/hook_capture.rs:933— crates/ai-memory-cli/src/commands/hook_capture.rs:933-939 | crates/ai-memory-cli/src/http_client.rs:408-413 — 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) crates/ai-memory-cli/src/commands/project_init.rs:146— crates/ai-memory-cli/src/commands/project_init.rs:146-151 | crates/ai-memory-cli/src/commands/show.rs:579-588 — 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) crates/ai-memory-store/src/ops.rs:5255— crates/ai-memory-store/src/ops.rs:5255-5260 | crates/ai-memory-store/src/workstream.rs:1331-1336 — 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) crates/ai-memory-store/src/ops.rs:6278— crates/ai-memory-store/src/ops.rs:6278-6283 | crates/ai-memory-store/src/session_consolidation.rs:115-120 — 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) crates/ai-memory-cli/src/commands/install_hooks.rs:6180— crates/ai-memory-cli/src/commands/install_hooks.rs:6180-6185 | crates/ai-memory-cli/src/commands/install_mcp.rs:1138-1143 — 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.
ai_memory_web::routes::inbox::handler (cyclomatic 30) crates/ai-memory-web/src/routes/inbox.rs:46— ai_memory_web::routes::inbox::handler has cyclomatic complexity 30 (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.
ai_memory_web::routes::search::handler (cyclomatic 26) crates/ai-memory-web/src/routes/search.rs:87— ai_memory_web::routes::search::handler has cyclomatic complexity 26 (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.
ai_memory_web::health::localized_checks (cyclomatic 25) crates/ai-memory-web/src/health.rs:168— ai_memory_web::health::localized_checks 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.
ai_memory_web::features::states (cyclomatic 23) crates/ai-memory-web/src/features.rs:48— ai_memory_web::features::states has cyclomatic complexity 23 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ai_memory_web::management::forms::submit (cyclomatic 22) crates/ai-memory-web/src/management/forms.rs:67— ai_memory_web::management::forms::submit has cyclomatic complexity 22 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ai_memory_web::knowledge::view (cyclomatic 18) crates/ai-memory-web/src/knowledge.rs:68— ai_memory_web::knowledge::view 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.
ReaderPool::hybrid_search_inner (cognitive 121) crates/ai-memory-store/src/reader.rs:8730— ReaderPool::hybrid_search_inner has cognitive complexity 121 (threshold 15). Drivers by points: if/else 52 (97 pts), loops 12 (14 pts), boolean chains 6, match/switch 2 (4 pts) (nesting depth added 49). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ReaderPool::audit_contamination (cognitive 47) crates/ai-memory-store/src/reader.rs:13617— ReaderPool::audit_contamination has cognitive complexity 47 (threshold 15). Drivers by points: if/else 14 (26 pts), loops 8 (11 pts), boolean chains 6, match/switch 2 (4 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ReaderPool::observation_stream_votes (cognitive 33) crates/ai-memory-store/src/reader.rs:4528— ReaderPool::observation_stream_votes has cognitive complexity 33 (threshold 15). Drivers by points: if/else 11 (20 pts), loops 5 (6 pts), match/switch 2 (5 pts), boolean chains 2 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ReaderPool::related_walk (cognitive 23) crates/ai-memory-store/src/reader.rs:11301— ReaderPool::related_walk has cognitive complexity 23 (threshold 15). Drivers by points: if/else 4 (13 pts), loops 4 (10 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ReaderPool::diagnose_project_coordinate (cognitive 23) crates/ai-memory-store/src/reader.rs:13270— ReaderPool::diagnose_project_coordinate has cognitive complexity 23 (threshold 15). Drivers by points: if/else 15 (17 pts), boolean chains 6 (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.
ReaderPool::hybrid_search_scopes_outcome (cognitive 17) crates/ai-memory-store/src/reader.rs:8620— ReaderPool::hybrid_search_scopes_outcome has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (10 pts), match/switch 2 (4 pts), loops 2 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D4 · Code Duplication· Edited copy of a member (23 corresponding lines) · ×6
Edited copy of a member (23 corresponding lines) crates/ai-memory-workstream/src/transcript.rs:5602— crates/ai-memory-workstream/src/transcript.rs:5602-5624 | crates/ai-memory-workstream/src/transcript.rs:6208-6231 — 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) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:468— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:468-490 | crates/ai-memory-consolidate/src/projection.rs:999-1021 — 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) crates/ai-memory-wiki/src/wiki.rs:1701— crates/ai-memory-wiki/src/wiki.rs:1701-1726 | crates/ai-memory-wiki/src/wiki.rs:1742-1764 — 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) crates/ai-memory-mcp/src/admin.rs:2453— crates/ai-memory-mcp/src/admin.rs:2453-2475 | crates/ai-memory-mcp/src/server.rs:2771-2795 — 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) crates/ai-memory-llm/src/codex.rs:197— crates/ai-memory-llm/src/codex.rs:197-219 | crates/ai-memory-llm/src/openai_oauth.rs:251-274 — 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) crates/ai-memory-store/src/reader.rs:8481— crates/ai-memory-store/src/reader.rs:8481-8503 | crates/ai-memory-store/src/reader.rs:8560-8588 — 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· Edited copy of a member (8 corresponding lines) · ×6
Edited copy of a member (8 corresponding lines) crates/ai-memory-cli/src/commands/restore.rs:584— crates/ai-memory-cli/src/commands/restore.rs:584-591 | crates/ai-memory-wiki/src/confinement.rs:292-300 — 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) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:646— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:646-653 | crates/ai-memory-consolidate/src/projection.rs:1178-1185 — 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) companions/ai-memory-client/src/scrub.rs:122— companions/ai-memory-client/src/scrub.rs:122-129 | crates/ai-memory-core/src/sanitize.rs:104-111 — 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) companions/ai-memory-importer/src/agentmemory/export.rs:1247— companions/ai-memory-importer/src/agentmemory/export.rs:1247-1256 | crates/ai-memory-hooks/src/router.rs:3330-3337 — 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) crates/ai-memory-cli/src/commands/show.rs:1090— crates/ai-memory-cli/src/commands/show.rs:1090-1103 | crates/ai-memory-store/src/reader.rs:415-422 — 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) crates/ai-memory-cli/src/commands/run.rs:5573— crates/ai-memory-cli/src/commands/run.rs:5573-5580 | companions/ai-memory-client/src/lib.rs:16-23 — 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.
Duplicated block (10 lines × 3) crates/ai-memory-mcp/src/admin.rs:5793— crates/ai-memory-mcp/src/admin.rs:5793-5802 | crates/ai-memory-mcp/src/admin.rs:5894-5903 | crates/ai-memory-mcp/src/admin.rs:6462-6471 — 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ai-memory-mcp/src/admin.rs:6460` calls `to_string` and `crates/ai-memory-mcp/src/admin.rs:5892` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (10 lines × 3) crates/ai-memory-store/src/reader.rs:11187— crates/ai-memory-store/src/reader.rs:11187-11196 | crates/ai-memory-store/src/reader.rs:11310-11319 | crates/ai-memory-store/src/reader.rs:12600-12609 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (10 lines × 3) crates/ai-memory-store/src/reader.rs:13565— crates/ai-memory-store/src/reader.rs:13565-13574 | crates/ai-memory-store/src/reader.rs:13717-13726 | crates/ai-memory-store/src/reader.rs:13745-13754 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (10 lines × 3) crates/ai-memory-wiki/src/markdown.rs:484— crates/ai-memory-wiki/src/markdown.rs:484-493 | crates/ai-memory-wiki/src/markdown.rs:590-599 | crates/ai-memory-wiki/src/markdown.rs:694-703 — 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 `crates/ai-memory-wiki/src/markdown.rs:484` 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 (10 lines × 3) crates/ai-memory-consolidate/src/auto_improve_schedule.rs:665— crates/ai-memory-consolidate/src/auto_improve_schedule.rs:665-674 | crates/ai-memory-mcp/src/admin.rs:687-696 | crates/ai-memory-mcp/src/server.rs:8189-8198 — before extracting anything, compare `crates/ai-memory-consolidate/src/auto_improve_schedule.rs` and `crates/ai-memory-mcp/src/admin.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 31 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. 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 (10 lines × 3) crates/ai-memory-store/src/reader.rs:9299— crates/ai-memory-store/src/reader.rs:9299-9310 | crates/ai-memory-store/src/reader.rs:9345-9355 | crates/ai-memory-store/src/reader.rs:9390-9399 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (7 lines × 3) crates/ai-memory-cli/src/commands/hook.rs:2398— crates/ai-memory-cli/src/commands/hook.rs:2398-2404 | crates/ai-memory-cli/src/commands/hook.rs:2494-2500 | crates/ai-memory-cli/src/commands/hook.rs:2539-2545 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (7 lines × 3) crates/ai-memory-cli/src/commands/uninstall.rs:1399— crates/ai-memory-cli/src/commands/uninstall.rs:1399-1405 | crates/ai-memory-cli/src/commands/uninstall.rs:1502-1508 | crates/ai-memory-cli/src/commands/uninstall.rs:1633-1639 — 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 `crates/ai-memory-cli/src/commands/uninstall.rs:1399` 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) crates/ai-memory-consolidate/src/auto_improve_schedule.rs:646— crates/ai-memory-consolidate/src/auto_improve_schedule.rs:646-652 | crates/ai-memory-mcp/src/admin.rs:3069-3076 | crates/ai-memory-mcp/src/server.rs:4846-4853 — before extracting anything, compare `crates/ai-memory-consolidate/src/auto_improve_schedule.rs` and `crates/ai-memory-mcp/src/admin.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 31 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 `crates/ai-memory-consolidate/src/auto_improve_schedule.rs:646` 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 × 3) crates/ai-memory-store/src/reader.rs:684— crates/ai-memory-store/src/reader.rs:684-690 | crates/ai-memory-store/src/reader.rs:8317-8323 | crates/ai-memory-store/src/reader.rs:8393-8399 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (7 lines × 3) crates/ai-memory-cli/src/commands/uninstall.rs:1500— crates/ai-memory-cli/src/commands/uninstall.rs:1500-1506 | crates/ai-memory-cli/src/commands/uninstall.rs:1549-1555 | crates/ai-memory-cli/src/commands/uninstall.rs:1631-1637 — 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 `crates/ai-memory-cli/src/commands/uninstall.rs:1500` 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 (7 lines × 3) crates/ai-memory-store/src/reader.rs:10173— crates/ai-memory-store/src/reader.rs:10173-10179 | crates/ai-memory-store/src/reader.rs:10187-10193 | crates/ai-memory-store/src/reader.rs:10270-10276 — 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.
ai_memory_wikisync::bidi::build_plan (cyclomatic 29) companions/ai-memory-wikisync/src/bidi.rs:408— ai_memory_wikisync::bidi::build_plan 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.
ai_memory_wikisync::bidi::decide (cyclomatic 26) companions/ai-memory-wikisync/src/bidi.rs:102— ai_memory_wikisync::bidi::decide has cyclomatic complexity 26 (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.
ai_memory_wikisync::bidi::local_pages (cyclomatic 17) companions/ai-memory-wikisync/src/bidi.rs:660— ai_memory_wikisync::bidi::local_pages 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.
ai_memory_wikisync::bidi::apply_plan (cyclomatic 16) companions/ai-memory-wikisync/src/bidi.rs:743— ai_memory_wikisync::bidi::apply_plan 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.
ai_memory_wikisync::bidi::print_plan (cyclomatic 16) companions/ai-memory-wikisync/src/bidi.rs:1023— ai_memory_wikisync::bidi::print_plan 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.
AiMemoryServer::memory_query (cognitive 73) crates/ai-memory-mcp/src/server.rs:3216— AiMemoryServer::memory_query has cognitive complexity 73 (threshold 15). Drivers by points: if/else 30 (39 pts), match/switch 5 (16 pts), boolean chains 12, loops 2 (6 pts) (nesting depth added 24). 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.
AiMemoryServer::write_page_in_scope (cognitive 42) crates/ai-memory-mcp/src/server.rs:5139— AiMemoryServer::write_page_in_scope has cognitive complexity 42 (threshold 15). Drivers by points: if/else 23 (28 pts), match/switch 5 (8 pts), boolean chains 6 (nesting depth added 8). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
AiMemoryServer::memory_read_page (cognitive 32) crates/ai-memory-mcp/src/server.rs:5922— AiMemoryServer::memory_read_page has cognitive complexity 32 (threshold 15). Drivers by points: if/else 16 (22 pts), match/switch 5 (8 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AiMemoryServer::memory_write_pages_batch (cognitive 29) crates/ai-memory-mcp/src/server.rs:5504— AiMemoryServer::memory_write_pages_batch has cognitive complexity 29 (threshold 15). Drivers by points: if/else 15 (24 pts), boolean chains 2, match/switch 2, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AiMemoryServer::memory_auto_improve (cognitive 17) crates/ai-memory-mcp/src/server.rs:4700— AiMemoryServer::memory_auto_improve has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (8 pts), boolean chains 3, loops 3, match/switch 2 (3 pts) (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Wiki::merge_project (cognitive 36) crates/ai-memory-wiki/src/wiki.rs:754— Wiki::merge_project has cognitive complexity 36 (threshold 15). Drivers by points: if/else 19 (25 pts), boolean chains 9, loops 1, match/switch 1 (nesting depth added 6). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
Wiki::apply_batch_inner (cognitive 31) crates/ai-memory-wiki/src/wiki.rs:3328— Wiki::apply_batch_inner has cognitive complexity 31 (threshold 15). Drivers by points: if/else 9 (16 pts), loops 8 (10 pts), match/switch 3 (4 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Wiki::move_session_page (cognitive 19) crates/ai-memory-wiki/src/wiki.rs:943— Wiki::move_session_page has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (10 pts), match/switch 3 (5 pts), loops 2 (4 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Wiki::plan_session_page_files_locked (cognitive 19) crates/ai-memory-wiki/src/wiki.rs:1082— Wiki::plan_session_page_files_locked has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Wiki::reindex_all (cognitive 19) crates/ai-memory-wiki/src/wiki.rs:2998— Wiki::reindex_all has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (8 pts), match/switch 2 (5 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_llm::openai_compat::strip_reasoning_blocks (cognitive 23) crates/ai-memory-llm/src/openai_compat.rs:42— ai_memory_llm::openai_compat::strip_reasoning_blocks has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11 (21 pts), boolean chains 1, loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_llm::gemini::normalize_nullable_types (cognitive 20) crates/ai-memory-llm/src/gemini.rs:459— ai_memory_llm::gemini::normalize_nullable_types has cognitive complexity 20 (threshold 15). Drivers by points: match/switch 3 (8 pts), loops 3 (7 pts), if/else 2 (5 pts) (nesting depth added 12). 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.
ai_memory_llm::openai_oauth::parse_sse_response (cognitive 19) crates/ai-memory-llm/src/openai_oauth.rs:341— ai_memory_llm::openai_oauth::parse_sse_response has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (13 pts), match/switch 2 (3 pts), boolean chains 2, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_llm::openai::enforce_strict_object_schemas (cognitive 18) crates/ai-memory-llm/src/openai.rs:695— ai_memory_llm::openai::enforce_strict_object_schemas has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 2 (4 pts), boolean chains 2, 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.
ai_memory_llm::copilot::response_text (cognitive 16) crates/ai-memory-llm/src/copilot.rs:944— ai_memory_llm::copilot::response_text has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D30 · Dependency Vulnerabilities· Medium advisory (unsound) · ×5
REDACTED
REDACTED
REDACTED
REDACTED
REDACTED
D4 · Code Duplication· Edited copy of a member (17 corresponding lines) · ×5
Edited copy of a member (17 corresponding lines) crates/ai-memory-cli/src/commands/render_plugins.rs:293— crates/ai-memory-cli/src/commands/render_plugins.rs:293-316 | crates/ai-memory-cli/src/commands/user_service.rs:802-818 — 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) companions/ai-memory-importer/src/mcp.rs:342— companions/ai-memory-importer/src/mcp.rs:342-358 | companions/ai-memory-wikisync/src/mcp.rs: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) crates/ai-memory-hooks/src/antigravity.rs:698— crates/ai-memory-hooks/src/antigravity.rs:698-717 | crates/ai-memory-workstream/src/transcript.rs:5244-5260 — 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) crates/ai-memory-hooks/src/workstream.rs:593— crates/ai-memory-hooks/src/workstream.rs:593-610 | crates/ai-memory-hooks/src/workstream.rs:619-635 — 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) crates/ai-memory-cli/src/commands/forget_sweep.rs:26— crates/ai-memory-cli/src/commands/forget_sweep.rs:26-42 | crates/ai-memory-cli/src/commands/lint.rs:24-41 — 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.
Duplicated block (9 lines × 3) crates/ai-memory-mcp/src/server.rs:4277— crates/ai-memory-mcp/src/server.rs:4277-4285 | crates/ai-memory-mcp/src/server.rs:5768-5776 | crates/ai-memory-mcp/src/server.rs:7086-7094 — 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ai-memory-mcp/src/server.rs:4276` calls `require_admin_capability` and `crates/ai-memory-mcp/src/server.rs:7085` 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 × 3) crates/ai-memory-web/src/routes/inbox.rs:586— crates/ai-memory-web/src/routes/inbox.rs:586-594 | crates/ai-memory-web/src/routes/inbox.rs:625-633 | crates/ai-memory-web/src/routes/inbox.rs:680-688 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (9 lines × 3) companions/ai-memory-importer/src/document.rs:221— companions/ai-memory-importer/src/document.rs:221-233 | companions/ai-memory-importer/src/main.rs:329-341 | companions/ai-memory-importer/src/main.rs:437-445 — before extracting anything, compare `companions/ai-memory-importer/src/document.rs` and `companions/ai-memory-importer/src/main.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 60 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 `companions/ai-memory-importer/src/document.rs:221` 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 `args` to `ConversationArgs` in one and `OmcArgs` 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 (9 lines × 3) crates/ai-memory-mcp/src/admin.rs:1365— crates/ai-memory-mcp/src/admin.rs:1365-1373 | crates/ai-memory-mcp/src/admin.rs:1748-1756 | crates/ai-memory-mcp/src/admin.rs:1884-1892 — 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 `crates/ai-memory-mcp/src/admin.rs:1365` 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) crates/ai-memory-cli/src/commands/install_hooks.rs:3262— crates/ai-memory-cli/src/commands/install_hooks.rs:3262-3270 | crates/ai-memory-cli/src/commands/install_hooks.rs:3566-3574 | crates/ai-memory-cli/src/commands/install_hooks.rs:3657-3665 — 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 `crates/ai-memory-cli/src/commands/install_hooks.rs:3262` 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–8 lines × 2) companions/ai-memory-importer/src/claude_mem.rs:654— companions/ai-memory-importer/src/claude_mem.rs:654-661 | companions/ai-memory-importer/src/claude_mem.rs:759-765 — both copies are in the same file, so extract the 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 `companions/ai-memory-importer/src/claude_mem.rs:654` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (7–8 lines × 2) crates/ai-memory-mcp/src/admin.rs:2361— crates/ai-memory-mcp/src/admin.rs:2361-2367 | crates/ai-memory-mcp/src/server.rs:6176-6183 — before extracting anything, compare `crates/ai-memory-mcp/src/admin.rs` and `crates/ai-memory-mcp/src/server.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 39 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–8 lines × 2) crates/ai-memory-mcp/src/server.rs:4438— crates/ai-memory-mcp/src/server.rs:4438-4445 | crates/ai-memory-mcp/src/server.rs:6377-6383 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/server.rs:4438` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (7–8 lines × 2) crates/ai-memory-store/src/ops.rs:1551— crates/ai-memory-store/src/ops.rs:1551-1558 | crates/ai-memory-store/src/reader.rs:11977-11983 — before extracting anything, compare `crates/ai-memory-store/src/ops.rs` and `crates/ai-memory-store/src/reader.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 69 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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 `crates/ai-memory-store/src/ops.rs:1551` 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–8 lines × 2) crates/ai-memory-store/src/ops.rs:7938— crates/ai-memory-store/src/ops.rs:7938-7945 | crates/ai-memory-store/src/reader.rs:6513-6519 — before extracting anything, compare `crates/ai-memory-store/src/ops.rs` and `crates/ai-memory-store/src/reader.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 69 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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 `crates/ai-memory-store/src/ops.rs:7938` 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.
Off the main sequence: ai-memory-client — ai-memory-client: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 2 project(s), so it's rigid to change.
Off the main sequence: ai-memory-core — ai-memory-core: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 10 project(s), so it's rigid to change.
Off the main sequence: AIMemoryMenuCore — AIMemoryMenuCore: abstractness 0.09, instability 0.00, distance 0.91 — zone of pain — concrete and depended on by 1 project(s), so it's rigid to change.
Off the main sequence: ai-memory-store — ai-memory-store: abstractness 0.00, instability 0.14, distance 0.86 — zone of pain — concrete and depended on by 6 project(s), so it's rigid to change.
Off the main sequence: ai-memory-llm — ai-memory-llm: abstractness 0.02, instability 0.14, distance 0.84 — zone of pain — concrete and depended on by 6 project(s), so it's rigid to change.
R4 · Test Coverage· No test reaches this file · ×5
No test reaches this file companions/ai-memory-ts/scripts/generate-docs.ts:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file companions/ai-memory-ts/scripts/schema-check.ts:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file crates/ai-memory-web/static/management/theme.js:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file companions/ai-memory-ts/scripts/schema-update.ts:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
No test reaches this file companions/ai-memory-desktop/ui/app.js:1— No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
ReaderPool::hybrid_search_inner (cyclomatic 59) crates/ai-memory-store/src/reader.rs:8730— ReaderPool::hybrid_search_inner has cyclomatic complexity 59 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ReaderPool::audit_contamination (cyclomatic 31) crates/ai-memory-store/src/reader.rs:13617— ReaderPool::audit_contamination has cyclomatic complexity 31 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ReaderPool::observation_stream_votes (cyclomatic 20) crates/ai-memory-store/src/reader.rs:4528— ReaderPool::observation_stream_votes 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.
ReaderPool::diagnose_project_coordinate (cyclomatic 18) crates/ai-memory-store/src/reader.rs:13270— ReaderPool::diagnose_project_coordinate has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
AiMemoryServer::memory_query (cyclomatic 43) crates/ai-memory-mcp/src/server.rs:3216— AiMemoryServer::memory_query has cyclomatic complexity 43 (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.
AiMemoryServer::write_page_in_scope (cyclomatic 33) crates/ai-memory-mcp/src/server.rs:5139— AiMemoryServer::write_page_in_scope has cyclomatic complexity 33 (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.
AiMemoryServer::memory_read_page (cyclomatic 23) crates/ai-memory-mcp/src/server.rs:5922— AiMemoryServer::memory_read_page 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.
AiMemoryServer::memory_write_pages_batch (cyclomatic 19) crates/ai-memory-mcp/src/server.rs:5504— AiMemoryServer::memory_write_pages_batch 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.
ai_memory_wikisync::bidi::local_pages (cognitive 46) companions/ai-memory-wikisync/src/bidi.rs:660— ai_memory_wikisync::bidi::local_pages has cognitive complexity 46 (threshold 15). Drivers by points: if/else 9 (27 pts), match/switch 3 (13 pts), loops 3 (6 pts) (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_wikisync::bidi::build_plan (cognitive 39) companions/ai-memory-wikisync/src/bidi.rs:408— ai_memory_wikisync::bidi::build_plan has cognitive complexity 39 (threshold 15). Drivers by points: if/else 11 (25 pts), match/switch 4 (10 pts), boolean chains 3, loops 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.
ai_memory_wikisync::bidi::print_plan (cognitive 18) companions/ai-memory-wikisync/src/bidi.rs:1023— ai_memory_wikisync::bidi::print_plan has cognitive complexity 18 (threshold 15). Drivers by points: loops 8, if/else 5 (7 pts), match/switch 2 (3 pts) (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_wikisync::page_file::parse (cognitive 17) companions/ai-memory-wikisync/src/page_file.rs:90— ai_memory_wikisync::page_file::parse has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (11 pts), match/switch 2 (5 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_core::excerpt::leading_prose (cognitive 29) crates/ai-memory-core/src/excerpt.rs:74— ai_memory_core::excerpt::leading_prose has cognitive complexity 29 (threshold 15). Drivers by points: if/else 6 (20 pts), loops 4 (7 pts), boolean chains 2 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_core::repository_identity::normalize_remote_url (cognitive 19) crates/ai-memory-core/src/repository_identity.rs:643— ai_memory_core::repository_identity::normalize_remote_url has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 4, match/switch 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.
ai_memory_core::i18n::diagnostic_templates (cognitive 18) crates/ai-memory-core/src/i18n.rs:546— ai_memory_core::i18n::diagnostic_templates has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 3 (5 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_core::profile::render_digest (cognitive 17) crates/ai-memory-core/src/profile.rs:698— ai_memory_core::profile::render_digest has cognitive complexity 17 (threshold 15). Drivers by points: if/else 13 (16 pts), loops 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, 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.
ClassTooLong: ReaderPool crates/ai-memory-store/src/reader.rs:2955— ClassTooLong — 8249 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 237 methods, 2 blocks, lines 2955-14844. The bar is 400 significant lines; this is 7849 over it, 20.62× 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: AiMemoryServer crates/ai-memory-mcp/src/server.rs:573— ClassTooLong — 4565 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 108 methods, 5 blocks, lines 573-9038. The bar is 400 significant lines; this is 4165 over it, 11.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: Config crates/ai-memory-cli/src/config.rs:292— ClassTooLong — 769 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 27 methods, 3 blocks, lines 292-3551. The bar is 400 significant lines; this is 369 over it, 1.92× 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: Consolidator crates/ai-memory-consolidate/src/consolidator.rs:175— ClassTooLong — 587 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 20 methods, 2 blocks, lines 175-1162. The bar is 400 significant lines; this is 187 over it, 1.47× 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: ReaderPool crates/ai-memory-store/src/reader.rs:2955— TooManyMethods — 237 methods, declared across 3 files: src/reader.rs (228), src/dashboard.rs (8), src/provenance.rs (1). The bar is 30 methods; this is 207 over it, 7.90× 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: WriterHandle crates/ai-memory-store/src/writer.rs:927— TooManyMethods — 152 methods. The bar is 30 methods; this is 122 over it, 5.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.
TooManyMethods: AiMemoryServer crates/ai-memory-mcp/src/server.rs:573— TooManyMethods — 108 methods. The bar is 30 methods; this is 78 over it, 3.60× 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: Wiki crates/ai-memory-wiki/src/wiki.rs:233— TooManyMethods — 98 methods. The bar is 30 methods; this is 68 over it, 3.27× 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.
TooManyFields: Config crates/ai-memory-cli/src/config.rs:292— TooManyFields — 70 stored fields beside 27 methods. The bar is 30 stored fields; this is 40 over it, 2.33× 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: AiMemoryServer crates/ai-memory-mcp/src/server.rs:573— TooManyFields — 32 stored fields beside 108 methods. The bar is 30 stored fields; this is 2 over it, 1.07× 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: RuntimeEnv crates/ai-memory-cli/src/config.rs:777— TooManyFields — 32 stored fields beside 15 methods. The bar is 30 stored fields; this is 2 over it, 1.07× 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: HookState crates/ai-memory-hooks/src/router.rs:608— 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 (19 corresponding lines) · ×4
Edited copy of a member (19 corresponding lines) crates/ai-memory-store/src/reader.rs:4773— crates/ai-memory-store/src/reader.rs:4773-4812 | crates/ai-memory-store/src/reader.rs:4849-4898 — 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) companions/ai-memory-importer/src/document.rs:1392— companions/ai-memory-importer/src/document.rs:1392-1410 | companions/ai-memory-importer/src/main.rs:1269-1287 — 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) crates/ai-memory-store/src/reader.rs:15545— crates/ai-memory-store/src/reader.rs:15545-15567 | crates/ai-memory-store/src/reader.rs:15707-15725 — 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) crates/ai-memory-store/src/reader.rs:5075— crates/ai-memory-store/src/reader.rs:5075-5098 | crates/ai-memory-store/src/reader.rs:5116-5134 — 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· Members sharing a duplicated core (4 members, 50+ identical tokens) · ×4
Members sharing a duplicated core (4 members, 50+ identical tokens) crates/ai-memory-cli/src/commands/uninstall.rs:1398— crates/ai-memory-cli/src/commands/uninstall.rs:1398-1417 | crates/ai-memory-cli/src/commands/uninstall.rs:1491-1540 | crates/ai-memory-cli/src/commands/uninstall.rs:1542-1579 | crates/ai-memory-cli/src/commands/uninstall.rs:1627-1660 — 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) crates/ai-memory-llm/src/fallback.rs:234— crates/ai-memory-llm/src/fallback.rs:234-258 | crates/ai-memory-llm/src/fallback.rs:264-293 | crates/ai-memory-llm/src/fallback.rs:299-328 | crates/ai-memory-llm/src/fallback.rs:335-368 — 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) crates/ai-memory-store/src/reader.rs:738— crates/ai-memory-store/src/reader.rs:738-768 | crates/ai-memory-store/src/reader.rs:774-804 | crates/ai-memory-store/src/reader.rs:4115-4243 | crates/ai-memory-store/src/reader.rs:8745-9283 — 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) crates/ai-memory-workstream/src/transcript.rs:5631— crates/ai-memory-workstream/src/transcript.rs:5631-5666 | crates/ai-memory-workstream/src/transcript.rs:5674-5746 | crates/ai-memory-workstream/src/transcript.rs:5776-5809 | crates/ai-memory-workstream/src/transcript.rs:6238-6273 — 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 (37 corresponding lines) · ×4
Edited copy of a member (37 corresponding lines) crates/ai-memory-hooks/src/antigravity.rs:650— crates/ai-memory-hooks/src/antigravity.rs:650-694 | crates/ai-memory-workstream/src/transcript.rs:5206-5242 — These two members are one piece of code written twice and then edited apart: 37 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (37 corresponding lines) crates/ai-memory-wiki/src/markdown.rs:618— crates/ai-memory-wiki/src/markdown.rs:618-654 | crates/ai-memory-wiki/src/markdown.rs:727-768 — These two members are one piece of code written twice and then edited apart: 37 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (37 corresponding lines) crates/ai-memory-cli/src/commands/auto_improve_report.rs:41— crates/ai-memory-cli/src/commands/auto_improve_report.rs:41-77 | crates/ai-memory-cli/src/commands/curator.rs:36-73 — These two members are one piece of code written twice and then edited apart: 37 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (37 corresponding lines) crates/ai-memory-store/src/auto_improve.rs:1045— crates/ai-memory-store/src/auto_improve.rs:1045-1083 | crates/ai-memory-store/src/auto_improve.rs:1094-1130 — These two members are one piece of code written twice and then edited apart: 37 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport 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 (29 corresponding lines) · ×4
Edited copy of a member (29 corresponding lines) crates/ai-memory-hooks/src/workstream.rs:691— crates/ai-memory-hooks/src/workstream.rs:691-719 | crates/ai-memory-hooks/src/workstream.rs:1068-1108 — 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) crates/ai-memory-store/src/reader.rs:9293— crates/ai-memory-store/src/reader.rs:9293-9322 | crates/ai-memory-store/src/reader.rs:9339-9367 — 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) crates/ai-memory-store/src/reader.rs:5160— crates/ai-memory-store/src/reader.rs:5160-5188 | crates/ai-memory-store/src/reader.rs:5213-5241 — 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) crates/ai-memory-store/src/auto_improve.rs:665— crates/ai-memory-store/src/auto_improve.rs:665-713 | crates/ai-memory-store/src/auto_improve.rs:737-765 — 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 copy of a member (27 corresponding lines) · ×4
Edited copy of a member (27 corresponding lines) crates/ai-memory-wiki/src/markdown.rs:585— crates/ai-memory-wiki/src/markdown.rs:585-611 | crates/ai-memory-wiki/src/markdown.rs:689-720 — 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) crates/ai-memory-cli/src/commands/backup.rs:19— crates/ai-memory-cli/src/commands/backup.rs:19-45 | crates/ai-memory-cli/src/commands/export_okf.rs:25-58 — 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) crates/ai-memory-store/src/users.rs:109— crates/ai-memory-store/src/users.rs:109-139 | crates/ai-memory-store/src/users.rs:153-179 — 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) crates/ai-memory-cli/src/commands/pending_writes.rs:137— crates/ai-memory-cli/src/commands/pending_writes.rs:137-163 | crates/ai-memory-cli/src/commands/pending_writes.rs:165-191 — 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· Edited copies of one member (3 members, 17+ corresponding lines) · ×4
Edited copies of one member (3 members, 17+ corresponding lines) crates/ai-memory-llm/src/copilot.rs:384— crates/ai-memory-llm/src/copilot.rs:384-400 | crates/ai-memory-llm/src/copilot.rs:406-422 | crates/ai-memory-llm/src/gemini.rs:260-279 — 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.
Edited copies of one member (3 members, 17+ corresponding lines) crates/ai-memory-cli/src/commands/backup.rs:48— crates/ai-memory-cli/src/commands/backup.rs:48-65 | crates/ai-memory-cli/src/commands/compact.rs:64-80 | crates/ai-memory-web/src/routes/index.rs:194-210 — 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.
Edited copies of one member (3 members, 17+ corresponding lines) crates/ai-memory-cli/src/commands/auth.rs:546— crates/ai-memory-cli/src/commands/auth.rs:546-563 | crates/ai-memory-cli/src/commands/auth.rs:611-632 | crates/ai-memory-cli/src/commands/auth.rs:637-653 — 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.
Edited copies of one member (3 members, 17+ corresponding lines) crates/ai-memory-llm/src/embedding.rs:161— crates/ai-memory-llm/src/embedding.rs:161-180 | crates/ai-memory-llm/src/embedding.rs:510-526 | crates/ai-memory-llm/src/embedding.rs:620-637 — 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 copies of one member (3 members, 10+ corresponding lines) · ×4
Edited copies of one member (3 members, 10+ corresponding lines) crates/ai-memory-core/src/active_project.rs:810— crates/ai-memory-core/src/active_project.rs:810-821 | crates/ai-memory-core/src/active_project.rs:824-833 | crates/ai-memory-core/src/active_project.rs:836-845 — 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) crates/ai-memory-cli/src/commands/project_registry.rs:481— crates/ai-memory-cli/src/commands/project_registry.rs:481-493 | crates/ai-memory-cli/src/commands/recovery.rs:296-309 | crates/ai-memory-cli/src/commands/recovery.rs:379-388 — 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) crates/ai-memory-store/src/ops.rs:7904— crates/ai-memory-store/src/ops.rs:7904-7915 | crates/ai-memory-store/src/project_authz.rs:343-357 | crates/ai-memory-store/src/reader.rs:16520-16529 — 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) crates/ai-memory-store/src/reader.rs:6981— crates/ai-memory-store/src/reader.rs:6981-6993 | crates/ai-memory-store/src/reader.rs:14425-14434 | crates/ai-memory-store/src/users.rs:470-480 — 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 (16 corresponding lines) · ×4
Edited copy of a member (16 corresponding lines) crates/ai-memory-store/src/reader.rs:694— crates/ai-memory-store/src/reader.rs:694-709 | crates/ai-memory-store/src/reader.rs:714-729 — 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) crates/ai-memory-cli/src/marker.rs:337— crates/ai-memory-cli/src/marker.rs:337-352 | crates/ai-memory-cli/src/marker.rs:380-395 — 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) crates/ai-memory-web/src/routes/api.rs:758— crates/ai-memory-web/src/routes/api.rs:758-773 | crates/ai-memory-web/src/routes/api.rs:1216-1234 — 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) crates/ai-memory-cli/src/commands/install_hooks.rs:2632— crates/ai-memory-cli/src/commands/install_hooks.rs:2632-2647 | crates/ai-memory-cli/src/commands/install_hooks.rs:3156-3172 — 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 (5 corresponding lines) · ×4
Edited copy of a member (5 corresponding lines) crates/ai-memory-mcp/src/admin.rs:4705— crates/ai-memory-mcp/src/admin.rs:4705-4709 | crates/ai-memory-mcp/src/server.rs:9152-9156 — 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) crates/ai-memory-cli/src/commands/hook.rs:430— crates/ai-memory-cli/src/commands/hook.rs:430-435 | crates/ai-memory-cli/src/config.rs:3839-3843 — 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) crates/ai-memory-cli/src/commands/hook.rs:1278— crates/ai-memory-cli/src/commands/hook.rs:1278-1282 | crates/ai-memory-hooks/src/router.rs:876-880 — 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) crates/ai-memory-wiki/src/git.rs:1100— crates/ai-memory-wiki/src/git.rs:1100-1106 | crates/ai-memory-wiki/src/watcher.rs:1049-1053 — 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.
Duplicated block (20 lines × 2) companions/ai-memory-importer/src/mcp.rs:383— companions/ai-memory-importer/src/mcp.rs:383-402 | companions/ai-memory-wikisync/src/mcp.rs:226-245 — before extracting anything, compare `companions/ai-memory-importer/src/mcp.rs` and `companions/ai-memory-wikisync/src/mcp.rs` as WHOLE FILES: this scan already matched 5 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. 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 `companions/ai-memory-importer/src/mcp.rs:383` 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 (20 lines × 2) crates/ai-memory-consolidate/src/consolidator.rs:382— crates/ai-memory-consolidate/src/consolidator.rs:382-401 | crates/ai-memory-consolidate/src/consolidator.rs:919-938 — both copies are in the same file, so extract the 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) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:471— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:471-490 | crates/ai-memory-consolidate/src/projection.rs:1002-1021 — before extracting anything, compare `crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs` and `crates/ai-memory-consolidate/src/projection.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 354 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 `crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:471` 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 (20 lines × 2) crates/ai-memory-store/src/ops.rs:2180— crates/ai-memory-store/src/ops.rs:2180-2199 | crates/ai-memory-store/src/ops.rs:2271-2290 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/ops.rs:2180` 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–10 lines × 2) companions/ai-memory-importer/src/agentmemory/mod.rs:630— companions/ai-memory-importer/src/agentmemory/mod.rs:630-638 | companions/ai-memory-importer/src/agentmemory/mod.rs:746-755 — both copies are in the same file, so extract the 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 `companions/ai-memory-importer/src/agentmemory/mod.rs:630` 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, `companions/ai-memory-importer/src/agentmemory/mod.rs:629` calls `Err`, `fail` and `companions/ai-memory-importer/src/agentmemory/mod.rs:746` 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–10 lines × 2) crates/ai-memory-cli/src/commands/install_hooks.rs:3259— crates/ai-memory-cli/src/commands/install_hooks.rs:3259-3268 | crates/ai-memory-cli/src/commands/install_hooks.rs:3468-3476 — both copies are in the same file, so extract the 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 `crates/ai-memory-cli/src/commands/install_hooks.rs:3259` 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 (9–10 lines × 2) crates/ai-memory-mcp/src/server.rs:6291— crates/ai-memory-mcp/src/server.rs:6291-6300 | crates/ai-memory-mcp/src/server.rs:6985-6993 — both copies are in the same file, so extract the 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 (9–10 lines × 2) crates/ai-memory-store/src/workstream.rs:1166— crates/ai-memory-store/src/workstream.rs:1166-1175 | crates/ai-memory-store/src/workstream.rs:1280-1288 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/workstream.rs:1166` 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 `input` to `&LinkOrAdoptManagedRunSession` in one and `&LinkManagedRunSessionInScope` 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 (6 lines × 3) crates/ai-memory-store/src/reader.rs:11000— crates/ai-memory-store/src/reader.rs:11000-11005 | crates/ai-memory-store/src/reader.rs:11026-11031 | crates/ai-memory-store/src/reader.rs:11051-11056 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (6 lines × 3) crates/ai-memory-store/src/ops.rs:2783— crates/ai-memory-store/src/ops.rs:2783-2796 | crates/ai-memory-store/src/ops.rs:5324-5330 | crates/ai-memory-store/src/ops.rs:5389-5394 — 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 `crates/ai-memory-store/src/ops.rs:2783` 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) crates/ai-memory-store/src/ops.rs:8698— crates/ai-memory-store/src/ops.rs:8698-8703 | crates/ai-memory-store/src/ops.rs:8706-8711 | crates/ai-memory-store/src/ops.rs:8714-8719 — 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 `crates/ai-memory-store/src/ops.rs:8698` 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) crates/ai-memory-store/src/reader.rs:8136— crates/ai-memory-store/src/reader.rs:8136-8141 | crates/ai-memory-store/src/reader.rs:8317-8322 | crates/ai-memory-store/src/reader.rs:8393-8398 — 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 `crates/ai-memory-store/src/reader.rs:8136` 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 × 3) crates/ai-memory-mcp/src/admin.rs:2920— crates/ai-memory-mcp/src/admin.rs:2920-2924 | crates/ai-memory-mcp/src/admin.rs:4026-4030 | crates/ai-memory-mcp/src/admin.rs:9311-9315 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (5 lines × 3) crates/ai-memory-store/src/reader.rs:4186— crates/ai-memory-store/src/reader.rs:4186-4190 | crates/ai-memory-store/src/reader.rs:9001-9005 | crates/ai-memory-store/src/reader.rs:9021-9025 — 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 `crates/ai-memory-store/src/reader.rs:4186` 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, `crates/ai-memory-store/src/reader.rs:9019` calls `clone` and `crates/ai-memory-store/src/reader.rs:4184` 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 (5 lines × 3) crates/ai-memory-store/src/reader.rs:7632— crates/ai-memory-store/src/reader.rs:7632-7636 | crates/ai-memory-store/src/reader.rs:11825-11831 | crates/ai-memory-store/src/reader.rs:12122-12126 — 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 `crates/ai-memory-store/src/reader.rs:7632` 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 × 3) crates/ai-memory-store/src/reader.rs:4331— crates/ai-memory-store/src/reader.rs:4331-4335 | crates/ai-memory-store/src/reader.rs:15130-15134 | crates/ai-memory-store/src/reader.rs:15797-15801 — 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.
CapturePolicy::inspect (cognitive 49) crates/ai-memory-hooks/src/capture_policy.rs:914— CapturePolicy::inspect has cognitive complexity 49 (threshold 15). Drivers by points: if/else 7 (22 pts), match/switch 5 (13 pts), loops 2 (9 pts), boolean chains 5 (nesting depth added 30). 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.
CapturePolicy::match_command (cognitive 34) crates/ai-memory-hooks/src/capture_policy.rs:1101— CapturePolicy::match_command has cognitive complexity 34 (threshold 15). Drivers by points: if/else 7 (23 pts), loops 4 (10 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.
CapturePolicy::match_pattern_candidate (cognitive 19) crates/ai-memory-hooks/src/capture_policy.rs:1184— CapturePolicy::match_pattern_candidate has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (11 pts), boolean chains 7, 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.
Change coupling: client.ts ↔ coverage.ts companions/ai-memory-ts/src/client.ts:1— `companions/ai-memory-ts/src/client.ts` and `companions/ai-memory-ts/src/coverage.ts` change together 87% of the time (13 of the 15 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 between them. They sit in the same directory, but in this ecosystem each file is its own module — a sibling reference still needs an import — so the missing import edge is real: the coupling runs through shared behaviour, not a declared dependency. If they duplicate structure, extract the common part into one unit; otherwise the coupling is hidden and worth breaking. You can check this without leaving the row: of the 13 shared commits counted here, the most recent 3 are `88999109` fix(ts-sdk): preserve profile metadata on page updates; `f97f0682` docs(sdk): document source_files and carry it through the TypeScript SDK; `fda4cc82` feat(mcp): address messages to a harness and record the sender harness — run `git show` on any of them.
Change coupling: coverage.ts ↔ types.ts companions/ai-memory-ts/src/coverage.ts:1— `companions/ai-memory-ts/src/coverage.ts` and `companions/ai-memory-ts/src/types.ts` change together 87% of the time (13 of the 15 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 between them. They sit in the same directory, but in this ecosystem each file is its own module — a sibling reference still needs an import — so the missing import edge is real: the coupling runs through shared behaviour, not a declared dependency. If they duplicate structure, extract the common part into one unit; otherwise the coupling is hidden and worth breaking. You can check this without leaving the row: of the 13 shared commits counted here, the most recent 3 are `88999109` fix(ts-sdk): preserve profile metadata on page updates; `f97f0682` docs(sdk): document source_files and carry it through the TypeScript SDK; `fda4cc82` feat(mcp): address messages to a harness and record the sender harness — run `git show` on any of them.
Change coupling: curator.rs ↔ writer.rs crates/ai-memory-consolidate/src/curator.rs:1— `crates/ai-memory-consolidate/src/curator.rs` and `crates/ai-memory-store/src/writer.rs` change together 54% of the time (7 of the 13 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 `0861e4c0` fix: harden proposal ownership and breadth retention; `197eaeae` feat(auto-improve,decay): scope proposal staging and reinforcement to…; `5044af97` feat(auto-improve,decay): scope proposal staging and reinforcement to… — run `git show` on any of them.
D4 · Code Duplication· Edited copy of a member (35 corresponding lines) · ×3
Edited copy of a member (35 corresponding lines) crates/ai-memory-store/src/reader.rs:12629— crates/ai-memory-store/src/reader.rs:12629-12663 | crates/ai-memory-store/src/reader.rs:12684-12726 — 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.
Edited copy of a member (35 corresponding lines) crates/ai-memory-store/src/reader.rs:11418— crates/ai-memory-store/src/reader.rs:11418-11462 | crates/ai-memory-store/src/reader.rs:11491-11525 — 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.
Edited copy of a member (35 corresponding lines) crates/ai-memory-cli/src/commands/install_hooks.rs:8589— crates/ai-memory-cli/src/commands/install_hooks.rs:8589-8632 | crates/ai-memory-cli/src/commands/install_hooks.rs:8640-8674 — 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 (20 corresponding lines) · ×3
Edited copy of a member (20 corresponding lines) crates/ai-memory-cli/src/commands/recent.rs:37— crates/ai-memory-cli/src/commands/recent.rs:37-59 | crates/ai-memory-cli/src/commands/search.rs:37-56 — 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) crates/ai-memory-workstream/src/transcript.rs:182— crates/ai-memory-workstream/src/transcript.rs:182-201 | crates/ai-memory-workstream/src/transcript.rs:322-349 — 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) companions/ai-memory-wikisync/src/client.rs:122— companions/ai-memory-wikisync/src/client.rs:122-146 | companions/ai-memory-wikisync/src/client.rs:279-298 — 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 (28 corresponding lines) · ×3
Edited copy of a member (28 corresponding lines) crates/ai-memory-store/src/api_credentials.rs:300— crates/ai-memory-store/src/api_credentials.rs:300-327 | crates/ai-memory-store/src/users.rs:586-617 — 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) crates/ai-memory-consolidate/src/auto_improve.rs:203— crates/ai-memory-consolidate/src/auto_improve.rs:203-230 | crates/ai-memory-mcp/src/server.rs:55-88 — 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) crates/ai-memory-cli/src/commands/install_hooks.rs:8688— crates/ai-memory-cli/src/commands/install_hooks.rs:8688-8715 | crates/ai-memory-cli/src/commands/install_hooks.rs:9002-9029 — 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 copies of one member (3 members, 35+ corresponding lines) · ×3
Edited copies of one member (3 members, 35+ corresponding lines) crates/ai-memory-cli/src/commands/install_hooks.rs:2747— crates/ai-memory-cli/src/commands/install_hooks.rs:2747-2791 | crates/ai-memory-cli/src/commands/install_hooks.rs:2950-2984 | crates/ai-memory-cli/src/commands/install_hooks.rs:3051-3088 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 35 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, 35+ corresponding lines) crates/ai-memory-store/src/profile.rs:419— crates/ai-memory-store/src/profile.rs:419-464 | crates/ai-memory-store/src/reader.rs:6726-6762 | crates/ai-memory-store/src/reader.rs:14074-14108 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 35 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, 35+ corresponding lines) crates/ai-memory-cli/src/commands/install_hooks.rs:4171— crates/ai-memory-cli/src/commands/install_hooks.rs:4171-4206 | crates/ai-memory-cli/src/commands/install_hooks.rs:4399-4440 | crates/ai-memory-cli/src/commands/install_hooks.rs:6193-6227 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 35 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 (24 corresponding lines) · ×3
Edited copy of a member (24 corresponding lines) crates/ai-memory-web/src/routes/inbox.rs:585— crates/ai-memory-web/src/routes/inbox.rs:585-613 | crates/ai-memory-web/src/routes/inbox.rs:679-702 — 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) crates/ai-memory-llm/src/copilot.rs:1079— crates/ai-memory-llm/src/copilot.rs:1079-1102 | crates/ai-memory-llm/src/copilot.rs:1104-1133 — 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) companions/ai-memory-importer/src/main.rs:779— companions/ai-memory-importer/src/main.rs:779-802 | crates/ai-memory-cli/src/commands/backfill.rs:1306-1329 — 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, 19+ corresponding lines) · ×3
Edited copies of one member (3 members, 19+ corresponding lines) crates/ai-memory-store/src/reader.rs:6434— crates/ai-memory-store/src/reader.rs:6434-6455 | crates/ai-memory-store/src/reader.rs:7423-7441 | crates/ai-memory-store/src/reader.rs:7464-7489 — These 3 members are one piece of code written 3 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 3 times and the copies will drift further apart.
Edited copies of one member (3 members, 19+ corresponding lines) crates/ai-memory-mcp/src/admin.rs:9684— crates/ai-memory-mcp/src/admin.rs:9684-9702 | crates/ai-memory-mcp/src/admin.rs:9743-9761 | crates/ai-memory-mcp/src/admin.rs:9767-9785 — These 3 members are one piece of code written 3 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 3 times and the copies will drift further apart.
Edited copies of one member (3 members, 19+ corresponding lines) crates/ai-memory-workstream/src/transcript.rs:5816— crates/ai-memory-workstream/src/transcript.rs:5816-5834 | crates/ai-memory-workstream/src/transcript.rs:5852-5870 | crates/ai-memory-workstream/src/transcript.rs:6279-6297 — These 3 members are one piece of code written 3 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 3 times and the copies 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) crates/ai-memory-store/src/reader.rs:5392— crates/ai-memory-store/src/reader.rs:5392-5412 | crates/ai-memory-store/src/reader.rs:6395-6420 | crates/ai-memory-store/src/reader.rs:16584-16597 — 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) crates/ai-memory-cli/src/commands/auth.rs:211— crates/ai-memory-cli/src/commands/auth.rs:211-224 | crates/ai-memory-cli/src/commands/auth.rs:285-298 | crates/ai-memory-cli/src/commands/auth.rs:335-348 — 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) crates/ai-memory-llm/src/health.rs:739— crates/ai-memory-llm/src/health.rs:739-752 | crates/ai-memory-llm/src/health.rs:762-778 | crates/ai-memory-llm/src/health.rs:784-797 — 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) crates/ai-memory-cli/src/commands/api_key.rs:165— crates/ai-memory-cli/src/commands/api_key.rs:165-182 | crates/ai-memory-cli/src/commands/user.rs:205-222 | crates/ai-memory-cli/src/commands/user.rs:224-238 — 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) companions/ai-memory-importer/src/mcp.rs:135— companions/ai-memory-importer/src/mcp.rs:135-151 | companions/ai-memory-importer/src/mcp.rs:156-172 | companions/ai-memory-wikisync/src/mcp.rs:107-121 — 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) crates/ai-memory-cli/src/commands/codex_hook_trust.rs:83— crates/ai-memory-cli/src/commands/codex_hook_trust.rs:83-97 | crates/ai-memory-cli/src/commands/opencode_dialect.rs:136-150 | crates/ai-memory-llm/src/cursor_agent.rs:410-424 — 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· Edited copy of a member (14 corresponding lines) · ×3
Edited copy of a member (14 corresponding lines) crates/ai-memory-store/src/scope.rs:393— crates/ai-memory-store/src/scope.rs:393-406 | crates/ai-memory-store/src/scope.rs:885-902 — 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) crates/ai-memory-mcp/src/self_service_keys.rs:33— crates/ai-memory-mcp/src/self_service_keys.rs:33-47 | crates/ai-memory-mcp/src/session_management.rs:42-55 — 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) crates/ai-memory-llm/src/types.rs:85— crates/ai-memory-llm/src/types.rs:85-98 | crates/ai-memory-llm/src/types.rs:102-115 — 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.
D4 · Code Duplication· Edited copy of a member (4 corresponding lines) · ×3
Edited copy of a member (4 corresponding lines) companions/ai-memory-importer/src/agentmemory/mod.rs:402— companions/ai-memory-importer/src/agentmemory/mod.rs:402-405 | companions/ai-memory-importer/src/document.rs:201-204 — 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) crates/ai-memory-consolidate/src/profile.rs:1164— crates/ai-memory-consolidate/src/profile.rs:1164-1167 | crates/ai-memory-consolidate/src/slug_digest.rs:52-59 — 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) crates/ai-memory-cli/src/commands/jail_folders.rs:866— crates/ai-memory-cli/src/commands/jail_folders.rs:866-869 | crates/ai-memory-cli/src/commands/show.rs:747-750 — 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.
Duplicated block (18 lines × 2) crates/ai-memory-consolidate/src/dream.rs:773— crates/ai-memory-consolidate/src/dream.rs:773-790 | crates/ai-memory-consolidate/src/sweep.rs:1402-1419 — before extracting anything, compare `crates/ai-memory-consolidate/src/dream.rs` and `crates/ai-memory-consolidate/src/sweep.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 45 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 `crates/ai-memory-consolidate/src/dream.rs:773` 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) crates/ai-memory-workstream/src/transcript.rs:3733— crates/ai-memory-workstream/src/transcript.rs:3733-3750 | crates/ai-memory-workstream/src/transcript.rs:5960-5977 — both copies are in the same file, so extract the 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 `crates/ai-memory-workstream/src/transcript.rs:3733` 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) crates/ai-memory-wiki/src/wiki.rs:1702— crates/ai-memory-wiki/src/wiki.rs:1702-1719 | crates/ai-memory-wiki/src/wiki.rs:1743-1760 — both copies are in the same file, so extract the 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 `crates/ai-memory-wiki/src/wiki.rs:1702` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 2) crates/ai-memory-store/src/ops.rs:2162— crates/ai-memory-store/src/ops.rs:2162-2178 | crates/ai-memory-store/src/ops.rs:2253-2269 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/ops.rs:2162` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 2) crates/ai-memory-wiki/src/markdown.rs:586— crates/ai-memory-wiki/src/markdown.rs:586-602 | crates/ai-memory-wiki/src/markdown.rs:690-706 — both copies are in the same file, so extract the 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 `crates/ai-memory-wiki/src/markdown.rs:586` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17 lines × 2) crates/ai-memory-store/src/reader.rs:7513— crates/ai-memory-store/src/reader.rs:7513-7532 | crates/ai-memory-store/src/reader.rs:16078-16094 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/reader.rs:7513` 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–14 lines × 2) crates/ai-memory-store/src/ops.rs:1549— crates/ai-memory-store/src/ops.rs:1549-1562 | crates/ai-memory-store/src/ops.rs:1636-1648 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/ops.rs:1549` 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–14 lines × 2) crates/ai-memory-store/src/reader.rs:7171— crates/ai-memory-store/src/reader.rs:7171-7183 | crates/ai-memory-store/src/reader.rs:7215-7228 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/reader.rs:7171` 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–14 lines × 2) crates/ai-memory-wiki/src/wiki.rs:1570— crates/ai-memory-wiki/src/wiki.rs:1570-1583 | crates/ai-memory-wiki/src/wiki.rs:2880-2892 — both copies are in the same file, so extract the 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 `crates/ai-memory-wiki/src/wiki.rs:1570` 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 (13 lines × 3) crates/ai-memory-consolidate/src/auto_improve_schedule.rs:632— crates/ai-memory-consolidate/src/auto_improve_schedule.rs:632-644 | crates/ai-memory-mcp/src/admin.rs:3055-3067 | crates/ai-memory-mcp/src/server.rs:4827-4839 — before extracting anything, compare `crates/ai-memory-consolidate/src/auto_improve_schedule.rs` and `crates/ai-memory-mcp/src/admin.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 31 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 `crates/ai-memory-consolidate/src/auto_improve_schedule.rs:632` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 3) crates/ai-memory-wiki/src/markdown.rs:534— crates/ai-memory-wiki/src/markdown.rs:534-546 | crates/ai-memory-wiki/src/markdown.rs:619-631 | crates/ai-memory-wiki/src/markdown.rs:728-740 — 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 `crates/ai-memory-wiki/src/markdown.rs:534` 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 × 3) crates/ai-memory-cli/src/commands/install_hooks.rs:3185— crates/ai-memory-cli/src/commands/install_hooks.rs:3185-3200 | crates/ai-memory-cli/src/commands/install_hooks.rs:4182-4194 | crates/ai-memory-cli/src/commands/install_hooks.rs:4416-4428 — 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 `crates/ai-memory-cli/src/commands/install_hooks.rs:3185` 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) companions/ai-memory-wikisync/src/client.rs:123— companions/ai-memory-wikisync/src/client.rs:123-133 | companions/ai-memory-wikisync/src/client.rs:280-291 — both copies are in the same file, so extract the 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 `companions/ai-memory-wikisync/src/client.rs:123` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. 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) crates/ai-memory-mcp/src/admin.rs:3298— crates/ai-memory-mcp/src/admin.rs:3298-3309 | crates/ai-memory-mcp/src/admin.rs:3423-3433 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/admin.rs:3298` 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 (11–12 lines × 2) crates/ai-memory-store/src/reader.rs:10799— crates/ai-memory-store/src/reader.rs:10799-10810 | crates/ai-memory-store/src/reader.rs:10947-10957 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (11 lines × 3) crates/ai-memory-store/src/ops.rs:1359— crates/ai-memory-store/src/ops.rs:1359-1369 | crates/ai-memory-store/src/reader.rs:11912-11922 | crates/ai-memory-store/src/workstream.rs:1694-1704 — before extracting anything, compare `crates/ai-memory-store/src/ops.rs` and `crates/ai-memory-store/src/reader.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 69 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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 `crates/ai-memory-store/src/ops.rs:1359` 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 before the matched lines, `crates/ai-memory-store/src/workstream.rs:1693` calls `get` and `crates/ai-memory-store/src/ops.rs:1358` 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 (11 lines × 3) crates/ai-memory-workstream/src/transcript.rs:3506— crates/ai-memory-workstream/src/transcript.rs:3506-3516 | crates/ai-memory-workstream/src/transcript.rs:3731-3741 | crates/ai-memory-workstream/src/transcript.rs:5958-5968 — 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 `crates/ai-memory-workstream/src/transcript.rs:3506` 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 (11 lines × 3) crates/ai-memory-cli/src/commands/install_hooks.rs:8066— crates/ai-memory-cli/src/commands/install_hooks.rs:8066-8076 | crates/ai-memory-cli/src/commands/install_hooks.rs:8229-8239 | crates/ai-memory-cli/src/commands/install_hooks.rs:8315-8325 — 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 `crates/ai-memory-cli/src/commands/install_hooks.rs:8066` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10–11 lines × 2) crates/ai-memory-cli/src/commands/install_hooks.rs:7076— crates/ai-memory-cli/src/commands/install_hooks.rs:7076-7085 | crates/ai-memory-cli/src/commands/setup_agent.rs:906-916 — before extracting anything, compare `crates/ai-memory-cli/src/commands/install_hooks.rs` and `crates/ai-memory-cli/src/commands/setup_agent.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 44 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 `crates/ai-memory-cli/src/commands/install_hooks.rs:7076` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (10–11 lines × 2) crates/ai-memory-mcp/src/server.rs:1032— crates/ai-memory-mcp/src/server.rs:1032-1042 | crates/ai-memory-web/src/recall.rs:103-112 — 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 `crates/ai-memory-mcp/src/server.rs:1032` 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 (10–11 lines × 2) crates/ai-memory-store/src/reader.rs:12630— crates/ai-memory-store/src/reader.rs:12630-12640 | crates/ai-memory-store/src/reader.rs:12685-12694 — both copies are in the same file, so extract the 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 × 3) crates/ai-memory-workstream/src/transcript.rs:5827— crates/ai-memory-workstream/src/transcript.rs:5827-5834 | crates/ai-memory-workstream/src/transcript.rs:5863-5870 | crates/ai-memory-workstream/src/transcript.rs:6290-6297 — 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 `crates/ai-memory-workstream/src/transcript.rs:5827` 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) crates/ai-memory-cli/src/commands/delete_page.rs:42— crates/ai-memory-cli/src/commands/delete_page.rs:42-54 | crates/ai-memory-cli/src/commands/message.rs:465-472 | crates/ai-memory-cli/src/commands/read_page.rs:71-79 — 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 `crates/ai-memory-cli/src/commands/delete_page.rs:42` 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 `args` to `DeletePageArgs` in one and `MessageCancelArgs` 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 × 3) crates/ai-memory-store/src/provenance.rs:56— crates/ai-memory-store/src/provenance.rs:56-63 | crates/ai-memory-store/src/reader.rs:11188-11196 | crates/ai-memory-store/src/reader.rs:11311-11319 — 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.
Outbound HTTP without resilience crates/ai-memory-llm/src/oidc.rs:294— `reqwest::Client::builder(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
Outbound HTTP without resilience crates/ai-memory-llm/src/openai_oauth.rs:158— `reqwest::Client::builder(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
Outbound HTTP without resilience evals/src/retrieval/dataset.rs:175— `reqwest::get(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
Duplicated block (8 lines × 2 locations) companions/ai-memory-ts/src/core.ts:120— companions/ai-memory-ts/src/core.ts:120 · companions/ai-memory-ts/src/core.ts:135 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Duplicated block (8 lines × 2 locations) companions/ai-memory-ts/src/decode.ts:195— companions/ai-memory-ts/src/decode.ts:195 · companions/ai-memory-ts/src/decode.ts:250 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Duplicated block (8 lines × 2 locations) companions/ai-memory-ts/src/decode.ts:358— companions/ai-memory-ts/src/decode.ts:358 · companions/ai-memory-ts/src/decode.ts:372 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Boundary violation [package:test-suite-dependency] companions/ai-memory-ts/scripts/schema-update.ts:10— companions/ai-memory-ts/scripts/schema-update.ts:10 imports companions/ai-memory-ts/test/support/tools-list.ts, a module inside the test suite — test helpers carry no compatibility contract and are maintained for the suite, not as an API, so production code that depends on one is coupled to a module nobody keeps stable. Move the shared helper into a source directory both layers may depend on.
Boundary violation [package:test-suite-dependency] companions/ai-memory-ts/scripts/schema-update.ts:11— companions/ai-memory-ts/scripts/schema-update.ts:11 imports companions/ai-memory-ts/test/support/schema.ts, a module inside the test suite — test helpers carry no compatibility contract and are maintained for the suite, not as an API, so production code that depends on one is coupled to a module nobody keeps stable. Move the shared helper into a source directory both layers may depend on.
Boundary violation [package:test-suite-dependency] companions/ai-memory-ts/scripts/schema-update.ts:12— companions/ai-memory-ts/scripts/schema-update.ts:12 imports companions/ai-memory-ts/test/support/server.ts, a module inside the test suite — test helpers carry no compatibility contract and are maintained for the suite, not as an API, so production code that depends on one is coupled to a module nobody keeps stable. Move the shared helper into a source directory both layers may depend on.
Low contrast colour pair in CSS (4.3:1) crates/ai-memory-web/static/input.css:59— `.agent-avatar` sets color: #9b6048 on background-color: #f6ebe4 — 4.3:1, below the 4.5:1 WCAG AA minimum for normal text. Darken or lighten one of them.
Low contrast colour pair in CSS (4.3:1) crates/ai-memory-web/static/tailwind.css:1— `.agent-avatar` sets color: #9b6048 on background-color: #f6ebe4 — 4.3:1, below the 4.5:1 WCAG AA minimum for normal text. This is a MINIFIED, build-generated sheet — editing the literal here is undone by the next vendor drop or rebuild, so override the rule in your own stylesheet (or fix it upstream / in the source the bundle is built from).
AC6 · Visual & motion safety· Focus outline removed in CSS without a · ×2
Focus outline removed in CSS without a :focus replacement crates/ai-memory-web/static/input.css:48— `.app-content` sets the outline to none/0 and no visible :focus / :focus-visible style for that element replaces it in this stylesheet, so a keyboard user cannot see where focus is. Draw a focus ring (outline, box-shadow or border) under :focus-visible.
Focus outline removed in CSS without a :focus replacement crates/ai-memory-web/static/tailwind.css:1— `.app-content` sets the outline to none/0 and no visible :focus / :focus-visible style for that element replaces it in this stylesheet, so a keyboard user cannot see where focus is. Draw a focus ring (outline, box-shadow or border) under :focus-visible.
AC6 · Visual & motion safety· Animation without a prefers-reduced-motion guard · ×2
Animation without a prefers-reduced-motion guard crates/ai-memory-web/static/input.css:53— `.metric-link` moves (`transition: border-color .15s ease,box-shadow .15s ease,transform .15s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce.
Animation without a prefers-reduced-motion guard crates/ai-memory-web/static/tailwind.css:1— `.metric-link` moves (`transition: border-color .15s ease,box-shadow .15s ease,transform .15s ease`) and nothing reads prefers-reduced-motion for it — no @media (prefers-reduced-motion) rule for this element, no reset this project loads — so a motion-sensitive user cannot turn it off (WCAG 2.3.3). Declare it under @media (prefers-reduced-motion: no-preference), or neutralise it under reduce.
Config::load_with_runtime_env (cyclomatic 42) crates/ai-memory-cli/src/config.rs:2477— Config::load_with_runtime_env has cyclomatic complexity 42 (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.
Config::embedder_config (cyclomatic 25) crates/ai-memory-cli/src/config.rs:3266— Config::embedder_config 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.
Wiki::merge_project (cyclomatic 28) crates/ai-memory-wiki/src/wiki.rs:754— Wiki::merge_project has cyclomatic complexity 28 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
Wiki::apply_batch_inner (cyclomatic 22) crates/ai-memory-wiki/src/wiki.rs:3328— Wiki::apply_batch_inner 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.
ai_memory_wiki::watcher::handle_event (cyclomatic 24) crates/ai-memory-wiki/src/watcher.rs:243— ai_memory_wiki::watcher::handle_event 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.
ai_memory_wiki::watcher::walk_project_dirs (cyclomatic 17) crates/ai-memory-wiki/src/watcher.rs:860— ai_memory_wiki::watcher::walk_project_dirs 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.
ai_memory_eval::retrieval::run (cyclomatic 24) evals/src/retrieval/mod.rs:387— ai_memory_eval::retrieval::run has cyclomatic complexity 24 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ai_memory_eval::abstention::validate_fixture (cyclomatic 19) evals/src/abstention.rs:332— ai_memory_eval::abstention::validate_fixture 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.
ai_memory_llm::openai_oauth::parse_sse_response (cyclomatic 18) crates/ai-memory-llm/src/openai_oauth.rs:341— ai_memory_llm::openai_oauth::parse_sse_response 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.
ai_memory_llm::factory::build_provider (cyclomatic 16) crates/ai-memory-llm/src/factory.rs:386— ai_memory_llm::factory::build_provider 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.
ai_memory_relay::relay::flush_locked (cognitive 72) companions/ai-memory-relay/src/relay.rs:281— ai_memory_relay::relay::flush_locked has cognitive complexity 72 (threshold 15). Drivers by points: if/else 20 (40 pts), loops 9 (22 pts), match/switch 4 (9 pts), boolean chains 1 (nesting depth added 38). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ai_memory_relay::ack::validate (cognitive 17) companions/ai-memory-relay/src/ack.rs:85— ai_memory_relay::ack::validate has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 2, match/switch 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.
ScanContext::observe (cognitive 52) crates/ai-memory-cli/src/commands/session_usage_context.rs:61— ScanContext::observe has cognitive complexity 52 (threshold 15). Drivers by points: if/else 17 (37 pts), loops 4 (11 pts), boolean chains 4 (nesting depth added 27). 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.
ScanContext::for_call (cognitive 20) crates/ai-memory-cli/src/commands/session_usage_context.rs:171— ScanContext::for_call has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 2 (6 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D4 · Code Duplication· Edited copy of a member (46 corresponding lines) · ×2
Edited copy of a member (46 corresponding lines) crates/ai-memory-store/src/reader.rs:8310— crates/ai-memory-store/src/reader.rs:8310-8355 | crates/ai-memory-store/src/reader.rs:8386-8441 — These two members are one piece of code written twice and then edited apart: 46 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
Edited copy of a member (46 corresponding lines) crates/ai-memory-cli/src/commands/delete_page.rs:37— crates/ai-memory-cli/src/commands/delete_page.rs:37-82 | crates/ai-memory-cli/src/commands/message.rs:458-503 — These two members are one piece of code written twice and then edited apart: 46 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport 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) companions/ai-memory-importer/src/mcp.rs:361— companions/ai-memory-importer/src/mcp.rs:361-402 | companions/ai-memory-wikisync/src/mcp.rs:194-245 — 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) crates/ai-memory-cli/src/commands/render_shared.rs:1070— crates/ai-memory-cli/src/commands/render_shared.rs:1070-1111 | crates/ai-memory-cli/src/commands/render_shared.rs:1156-1203 — 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 copy of a member (33 corresponding lines) · ×2
Edited copy of a member (33 corresponding lines) crates/ai-memory-workstream/src/transcript.rs:4643— crates/ai-memory-workstream/src/transcript.rs:4643-4678 | crates/ai-memory-workstream/src/transcript.rs:4683-4715 — 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) crates/ai-memory-mcp/src/admin.rs:887— crates/ai-memory-mcp/src/admin.rs:887-927 | crates/ai-memory-mcp/src/admin_profile.rs:67-99 — 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 (38 corresponding lines) · ×2
Edited copy of a member (38 corresponding lines) crates/ai-memory-consolidate/src/auto_improve_schedule.rs:625— crates/ai-memory-consolidate/src/auto_improve_schedule.rs:625-662 | crates/ai-memory-mcp/src/admin.rs:3041-3087 — 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) crates/ai-memory-cli/src/commands/api_key.rs:109— crates/ai-memory-cli/src/commands/api_key.rs:109-146 | crates/ai-memory-cli/src/commands/grant.rs:67-107 — These two members are one piece of code written twice and then edited apart: 38 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (25 corresponding lines) · ×2
Edited copy of a member (25 corresponding lines) companions/ai-memory-importer/src/document.rs:641— companions/ai-memory-importer/src/document.rs:641-665 | companions/ai-memory-importer/src/document.rs:667-695 — 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) crates/ai-memory-consolidate/src/bootstrap.rs:359— crates/ai-memory-consolidate/src/bootstrap.rs:359-386 | crates/ai-memory-consolidate/src/consolidator.rs:146-170 — 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 (22 corresponding lines) · ×2
Edited copy of a member (22 corresponding lines) crates/ai-memory-wiki/src/wiki.rs:388— crates/ai-memory-wiki/src/wiki.rs:388-412 | crates/ai-memory-wiki/src/wiki.rs:456-477 — 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) crates/ai-memory-cli/src/commands/install_mcp.rs:697— crates/ai-memory-cli/src/commands/install_mcp.rs:697-718 | crates/ai-memory-llm/src/stored_token.rs:31-52 — 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.
D4 · Code Duplication· Edited copies of one member (3 members, 13+ corresponding lines) · ×2
Edited copies of one member (3 members, 13+ corresponding lines) crates/ai-memory-cli/src/http_client.rs:424— crates/ai-memory-cli/src/http_client.rs:424-440 | crates/ai-memory-cli/src/http_client.rs:450-462 | crates/ai-memory-cli/src/http_client.rs:515-528 — 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) crates/ai-memory-wiki/src/wiki.rs:2062— crates/ai-memory-wiki/src/wiki.rs:2062-2074 | crates/ai-memory-wiki/src/wiki.rs:2087-2099 | crates/ai-memory-wiki/src/wiki.rs:2111-2123 — 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.
Duplicated block (26 lines × 2) crates/ai-memory-store/src/reader.rs:743— crates/ai-memory-store/src/reader.rs:743-768 | crates/ai-memory-store/src/reader.rs:779-804 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/reader.rs:743` 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 `auxiliary` to `Vec<(PageHit, PageAuthority)>` in one and `Vec<(PageHitWithMeta, PageAuthority)>` 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 (26 lines × 2) crates/ai-memory-store/src/workstream.rs:1879— crates/ai-memory-store/src/workstream.rs:1879-1904 | crates/ai-memory-store/src/workstream.rs:1964-2010 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/workstream.rs:1879` 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 (23 lines × 2) crates/ai-memory-workstream/src/transcript.rs:3465— crates/ai-memory-workstream/src/transcript.rs:3465-3487 | crates/ai-memory-workstream/src/transcript.rs:5919-5941 — both copies are in the same file, so extract the 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 `crates/ai-memory-workstream/src/transcript.rs:3465` 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 (23 lines × 2) crates/ai-memory-workstream/src/transcript.rs:3494— crates/ai-memory-workstream/src/transcript.rs:3494-3516 | crates/ai-memory-workstream/src/transcript.rs:5946-5968 — both copies are in the same file, so extract the 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 `crates/ai-memory-workstream/src/transcript.rs:3494` 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 (22 lines × 2) crates/ai-memory-mcp/src/admin.rs:5895— crates/ai-memory-mcp/src/admin.rs:5895-5916 | crates/ai-memory-mcp/src/admin.rs:6463-6484 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/admin.rs:5895` 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, `crates/ai-memory-mcp/src/admin.rs:6460` calls `to_string` and `crates/ai-memory-mcp/src/admin.rs:5892` 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 (22 lines × 2) crates/ai-memory-store/src/reader.rs:3769— crates/ai-memory-store/src/reader.rs:3769-3792 | crates/ai-memory-store/src/reader.rs:3839-3860 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (21 lines × 2) crates/ai-memory-mcp/src/server.rs:3518— crates/ai-memory-mcp/src/server.rs:3518-3538 | crates/ai-memory-mcp/src/server.rs:3598-3618 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (21 lines × 2) crates/ai-memory-store/src/reader.rs:5168— crates/ai-memory-store/src/reader.rs:5168-5188 | crates/ai-memory-store/src/reader.rs:5221-5241 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/reader.rs:5168` 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 (18–19 lines × 2) crates/ai-memory-cli/src/commands/hook_spool.rs:1802— crates/ai-memory-cli/src/commands/hook_spool.rs:1802-1820 | crates/ai-memory-cli/src/commands/hook_spool.rs:2089-2106 — both copies are in the same file, so extract the 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 `crates/ai-memory-cli/src/commands/hook_spool.rs:1802` 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–19 lines × 2) crates/ai-memory-llm/src/copilot.rs:668— crates/ai-memory-llm/src/copilot.rs:668-686 | crates/ai-memory-llm/src/stored_token.rs:174-191 — 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 `crates/ai-memory-llm/src/copilot.rs:668` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (15–16 lines × 2) companions/ai-memory-wikisync/src/atomic.rs:143— companions/ai-memory-wikisync/src/atomic.rs:143-158 | crates/ai-memory-wiki/src/atomic.rs:62-76 — 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.
Duplicated block (15–16 lines × 2) crates/ai-memory-store/src/reader.rs:16115— crates/ai-memory-store/src/reader.rs:16115-16129 | crates/ai-memory-store/src/reader.rs:16146-16161 — both copies are in the same file, so extract the 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 (12–14 lines × 2) crates/ai-memory-store/src/reader.rs:3853— crates/ai-memory-store/src/reader.rs:3853-3864 | crates/ai-memory-store/src/reader.rs:4661-4674 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/reader.rs:3853` 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 × 2) crates/ai-memory-cli/src/commands/recent.rs:41— crates/ai-memory-cli/src/commands/recent.rs:41-54 | crates/ai-memory-cli/src/commands/search.rs:41-52 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ai-memory-cli/src/commands/recent.rs: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. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. Note first that the copies are not typed on the same thing: the declarations holding them bind `args` to `RecentArgs` in one and `SearchArgs` 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 (12 lines × 3) crates/ai-memory-cli/src/commands/auto_improve.rs:86— crates/ai-memory-cli/src/commands/auto_improve.rs:86-97 | crates/ai-memory-cli/src/commands/serve.rs:3003-3014 | crates/ai-memory-mcp/src/server.rs:4773-4784 — 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 after the matched lines, `crates/ai-memory-cli/src/commands/auto_improve.rs:99` calls `clone` and `crates/ai-memory-mcp/src/server.rs:4785` 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 × 3) crates/ai-memory-hooks/src/router.rs:1755— crates/ai-memory-hooks/src/router.rs:1755-1767 | crates/ai-memory-hooks/src/router.rs:5137-5149 | crates/ai-memory-hooks/src/router.rs:5345-5356 — 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 `crates/ai-memory-hooks/src/router.rs:1755` 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 (10–12 lines × 2) companions/ai-memory-importer/src/agentmemory/mod.rs:537— companions/ai-memory-importer/src/agentmemory/mod.rs:537-548 | companions/ai-memory-importer/src/agentmemory/mod.rs:694-703 — both copies are in the same file, so extract the 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 (10–12 lines × 2) crates/ai-memory-mcp/src/admin.rs:2524— crates/ai-memory-mcp/src/admin.rs:2524-2533 | crates/ai-memory-mcp/src/admin.rs:2573-2584 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/admin.rs:2524` 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–11 lines × 3) crates/ai-memory-mcp/src/admin.rs:1598— crates/ai-memory-mcp/src/admin.rs:1598-1607 | crates/ai-memory-mcp/src/admin.rs:6131-6141 | crates/ai-memory-mcp/src/admin.rs:6224-6234 — 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 `crates/ai-memory-mcp/src/admin.rs:1598` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ai-memory-mcp/src/admin.rs:6130` calls `bytes_reclaimed` and `crates/ai-memory-mcp/src/admin.rs:6223` 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–11 lines × 3) crates/ai-memory-store/src/reader.rs:4796— crates/ai-memory-store/src/reader.rs:4796-4805 | crates/ai-memory-store/src/reader.rs:4882-4891 | crates/ai-memory-store/src/reader.rs:4939-4949 — 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 `crates/ai-memory-store/src/reader.rs:4796` 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–11 lines × 2) crates/ai-memory-mcp/src/admin.rs:4814— crates/ai-memory-mcp/src/admin.rs:4814-4820 | crates/ai-memory-mcp/src/admin.rs:9417-9427 — both copies are in the same file, so extract the 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–11 lines × 2) crates/ai-memory-store/src/reader.rs:10219— crates/ai-memory-store/src/reader.rs:10219-10229 | crates/ai-memory-store/src/reader.rs:10725-10731 — both copies are in the same file, so extract the 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 × 4) crates/ai-memory-hooks/src/workstream.rs:595— crates/ai-memory-hooks/src/workstream.rs:595-604 | crates/ai-memory-hooks/src/workstream.rs:621-630 | crates/ai-memory-hooks/src/workstream.rs:693-702 | crates/ai-memory-hooks/src/workstream.rs:1070-1079 — 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 `crates/ai-memory-hooks/src/workstream.rs:595` 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, `crates/ai-memory-hooks/src/workstream.rs:1067` calls `Json` and `crates/ai-memory-hooks/src/workstream.rs:592` 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 × 4) crates/ai-memory-cli/src/commands/auth.rs:215— crates/ai-memory-cli/src/commands/auth.rs:215-224 | crates/ai-memory-cli/src/commands/auth.rs:289-298 | crates/ai-memory-cli/src/commands/auth.rs:324-333 | crates/ai-memory-cli/src/commands/auth.rs:339-348 — 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 `crates/ai-memory-cli/src/commands/auth.rs:215` 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 × 5) crates/ai-memory-store/src/ops.rs:1358— crates/ai-memory-store/src/ops.rs:1358-1365 | crates/ai-memory-store/src/reader.rs:11911-11918 | crates/ai-memory-store/src/reader.rs:11977-11984 | crates/ai-memory-store/src/workstream.rs:1692-1699 | crates/ai-memory-store/src/workstream.rs:2376-2383 — before extracting anything, compare `crates/ai-memory-store/src/ops.rs` and `crates/ai-memory-store/src/reader.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 69 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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 `crates/ai-memory-store/src/ops.rs:1358` 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, `crates/ai-memory-store/src/workstream.rs:1700` calls `get` and `crates/ai-memory-store/src/ops.rs:1366` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 5) crates/ai-memory-cli/src/commands/install_hooks.rs:8076— crates/ai-memory-cli/src/commands/install_hooks.rs:8076-8083 | crates/ai-memory-cli/src/commands/install_hooks.rs:8157-8164 | crates/ai-memory-cli/src/commands/install_hooks.rs:8239-8246 | crates/ai-memory-cli/src/commands/install_hooks.rs:8325-8332 | crates/ai-memory-cli/src/commands/install_hooks.rs:8414-8421 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ai-memory-cli/src/commands/install_hooks.rs:8412` calls `entry`, `or_insert_with`, `from` and `crates/ai-memory-cli/src/commands/install_hooks.rs:8075` 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 (5 lines × 4) crates/ai-memory-cli/src/commands/install_mcp.rs:1830— crates/ai-memory-cli/src/commands/install_mcp.rs:1830-1834 | crates/ai-memory-cli/src/commands/install_mcp.rs:1924-1928 | crates/ai-memory-cli/src/commands/install_mcp.rs:1936-1940 | crates/ai-memory-cli/src/commands/install_mcp.rs:1941-1951 — 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 `crates/ai-memory-cli/src/commands/install_mcp.rs:1830` 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, `crates/ai-memory-cli/src/commands/install_mcp.rs:1952` calls `insert`, `into` and `crates/ai-memory-cli/src/commands/install_mcp.rs:1835` 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 × 4) crates/ai-memory-store/src/ops.rs:8697— crates/ai-memory-store/src/ops.rs:8697-8701 | crates/ai-memory-store/src/ops.rs:8705-8709 | crates/ai-memory-store/src/ops.rs:8713-8717 | crates/ai-memory-store/src/ops.rs:8721-8725 — 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 `crates/ai-memory-store/src/ops.rs:8697` 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.
Low cohesion: DreamConfig (LCOM4 5) crates/ai-memory-consolidate/src/dream.rs:150— DreamConfig's methods fall into 5 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 5 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low cohesion: AuthState (LCOM4 5) crates/ai-memory-mcp/src/auth.rs:70— AuthState's methods fall into 5 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 5 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Low contrast Tailwind colour pair (4.3:1) REDACTED:36— This element's Tailwind text/background colour utilities fall below the 4.5:1 WCAG AA minimum for normal text. Pick a darker or lighter shade.
PageWriteMetadata::into_frontmatter (cyclomatic 37) crates/ai-memory-core/src/page.rs:246— PageWriteMetadata::into_frontmatter has cyclomatic complexity 37 (threshold 15). Of this number, 35 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.
ai_memory_relay::relay::flush_locked (cyclomatic 34) companions/ai-memory-relay/src/relay.rs:281— ai_memory_relay::relay::flush_locked 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.
client.metadataFromFrontmatter (cyclomatic 28) companions/ai-memory-ts/src/client.ts:143— client.metadataFromFrontmatter has cyclomatic complexity 28 (threshold 15). Of this number, 23 points are the body's own statements and 5 belong to 3 function items inside it that branch. 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.
CapturePolicy::inspect (cyclomatic 27) crates/ai-memory-hooks/src/capture_policy.rs:914— CapturePolicy::inspect has cyclomatic complexity 27 (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.
ScanContext::observe (cyclomatic 23) crates/ai-memory-cli/src/commands/session_usage_context.rs:61— ScanContext::observe 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.
Bootstrap::process_sources (cyclomatic 22) crates/ai-memory-consolidate/src/bootstrap.rs:436— Bootstrap::process_sources 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.
Consolidator::consolidate_session_multi_in_scope (cyclomatic 22) crates/ai-memory-consolidate/src/consolidator.rs:844— Consolidator::consolidate_session_multi_in_scope 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.
Transport.request (cyclomatic 22) companions/ai-memory-ts/src/transport.ts:280— Transport.request 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.
PageAuthority::from_stored (cyclomatic 19) crates/ai-memory-store/src/reader.rs:525— PageAuthority::from_stored has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
TranscriptCapture::decide (cyclomatic 17) crates/ai-memory-cli/src/commands/transcript_capture.rs:126— TranscriptCapture::decide 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.
AdmissionChain::run (cyclomatic 17) crates/ai-memory-wiki/src/admission.rs:405— AdmissionChain::run has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
PagesNamespace.read (cyclomatic 17) companions/ai-memory-ts/src/client.ts:433— PagesNamespace.read has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
AiMemoryClient.query (cyclomatic 17) companions/ai-memory-ts/src/client.ts:946— AiMemoryClient.query 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.
Walker::node (cyclomatic 16) crates/ai-memory-wiki/src/frontmatter_yaml.rs:86— Walker::node 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.
PageWriteMetadata::into_frontmatter (cognitive 57) crates/ai-memory-core/src/page.rs:246— PageWriteMetadata::into_frontmatter has cognitive complexity 57 (threshold 15). Drivers by points: if/else 19 (36 pts), boolean chains 12, loops 5 (6 pts), match/switch 1 (3 pts) (nesting depth added 20). Of this number, 55 points are the body's own statements and 2 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.
Config::load_with_runtime_env (cognitive 45) crates/ai-memory-cli/src/config.rs:2477— Config::load_with_runtime_env has cognitive complexity 45 (threshold 15). Drivers by points: if/else 28 (31 pts), boolean chains 12, loops 2 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, 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.
AdmissionChain::run (cognitive 39) crates/ai-memory-wiki/src/admission.rs:405— AdmissionChain::run has cognitive complexity 39 (threshold 15). Drivers by points: if/else 9 (29 pts), match/switch 3 (8 pts), boolean chains 1, loops 1 (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Bootstrap::process_sources (cognitive 35) crates/ai-memory-consolidate/src/bootstrap.rs:436— Bootstrap::process_sources has cognitive complexity 35 (threshold 15). Drivers by points: if/else 13 (19 pts), loops 6 (11 pts), match/switch 2 (5 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.
Consolidator::consolidate_session_multi_in_scope (cognitive 34) crates/ai-memory-consolidate/src/consolidator.rs:844— Consolidator::consolidate_session_multi_in_scope has cognitive complexity 34 (threshold 15). Drivers by points: if/else 11 (18 pts), match/switch 5 (11 pts), loops 3 (5 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TranscriptCapture::decide (cognitive 31) crates/ai-memory-cli/src/commands/transcript_capture.rs:126— TranscriptCapture::decide has cognitive complexity 31 (threshold 15). Drivers by points: if/else 11 (23 pts), match/switch 2 (5 pts), boolean chains 2, loops 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
GlobBudget::markers_below (cognitive 29) crates/ai-memory-cli/src/commands/hook.rs:3019— GlobBudget::markers_below has cognitive complexity 29 (threshold 15). Drivers by points: if/else 6 (17 pts), loops 4 (9 pts), match/switch 1 (3 pts) (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
client.metadataFromFrontmatter (cognitive 28) companions/ai-memory-ts/src/client.ts:143— client.metadataFromFrontmatter has cognitive complexity 28 (threshold 15). Drivers by points: if/else 15 (18 pts), boolean chains 6, loops 1 (2 pts), ternaries 2 (nesting depth added 4). Of this number, 25 points are the body's own statements and 3 belong to 3 function items inside it that branch. 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.
Transport.request (cognitive 27) companions/ai-memory-ts/src/transport.ts:280— Transport.request has cognitive complexity 27 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 3, ternaries 3, loops 1 (2 pts), error handling 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
HomeRoutes::parse (cognitive 26) crates/ai-memory-cli/src/marker.rs:187— HomeRoutes::parse has cognitive complexity 26 (threshold 15). Drivers by points: if/else 11 (23 pts), boolean chains 2, 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.
Walker::node (cognitive 24) crates/ai-memory-wiki/src/frontmatter_yaml.rs:86— Walker::node has cognitive complexity 24 (threshold 15). Drivers by points: if/else 6 (11 pts), match/switch 4 (8 pts), loops 2 (4 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.
Queue::enqueue (cognitive 23) companions/ai-memory-relay/src/queue.rs:323— Queue::enqueue has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (18 pts), boolean chains 3, loops 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AiMemoryClient.query (cognitive 23) companions/ai-memory-ts/src/client.ts:946— AiMemoryClient.query has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (12 pts), ternaries 6 (8 pts), boolean chains 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.
ClaudeCodeTotals::add (cognitive 21) crates/ai-memory-cli/src/commands/session_usage.rs:464— ClaudeCodeTotals::add has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (20 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ShellCommand::split (cognitive 21) crates/ai-memory-hooks/src/capture_policy.rs:3066— ShellCommand::split has cognitive complexity 21 (threshold 15). Drivers by points: loops 6 (12 pts), if/else 3 (5 pts), boolean chains 3, 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.
HookEnvelope::from_query_and_body (cognitive 19) crates/ai-memory-hooks/src/payload.rs:664— HookEnvelope::from_query_and_body has cognitive complexity 19 (threshold 15). Drivers by points: if/else 14, boolean chains 4, match/switch 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.
EvalServer::launch (cognitive 19) evals/src/retrieval/server.rs:68— EvalServer::launch has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (9 pts), loops 3 (5 pts), match/switch 3 (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.
LiveCallBatch::commit (cognitive 18) crates/ai-memory-cli/src/commands/session_usage.rs:42— LiveCallBatch::commit has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 2 (5 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
AmbiguousProjectHolders::fmt (cognitive 17) crates/ai-memory-store/src/error.rs:45— AmbiguousProjectHolders::fmt has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (6 pts), match/switch 3 (6 pts), boolean chains 3, loops 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ConsoleView::load_sessions (cognitive 17) crates/ai-memory-web/src/management/views.rs:179— ConsoleView::load_sessions has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (12 pts), match/switch 2 (3 pts), boolean chains 1, loops 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, 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.
ApiNamespace.recent (cognitive 17) companions/ai-memory-ts/src/api.ts:174— ApiNamespace.recent has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (9 pts), boolean chains 3, loops 2 (3 pts), ternaries 1 (2 pts) (nesting depth added 6). Most of this is not in the body itself: 2 of the 17 points are its own statements and the rest belongs to one function literal inside it that branches (line 187). The decisions are inside the literal, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literal's work into a named function or method at the enclosing scope and have the literal call it, then reduce whichever part then reads as the largest.
PagesNamespace.update (cognitive 17) companions/ai-memory-ts/src/client.ts:542— PagesNamespace.update has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 2, 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.
ProjectAuthz::authorize (cognitive 16) crates/ai-memory-store/src/project_authz.rs:210— ProjectAuthz::authorize has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 3, match/switch 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.
LaunchdController.restart (cognitive 16) companions/ai-memory-macos/Sources/AIMemoryMenuCore/LaunchdController.swift:105— LaunchdController.restart has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (8 pts), error handling 2 (5 pts), boolean chains 2, ternaries 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
PagesNamespace.read (cognitive 16) companions/ai-memory-ts/src/client.ts:433— PagesNamespace.read has cognitive complexity 16 (threshold 15). Drivers by points: ternaries 9, if/else 4, boolean chains 3. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
TooManyFunctions: ai_memory_cli::commands::install_instructions crates/ai-memory-cli/src/commands/install_instructions.rs:45— TooManyFunctions — 32 free functions. The bar is 30 free functions; this is 2 over it, 1.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.
D30 · Dependency Vulnerabilities· Medium vulnerability · ×1
REDACTED
D30 · Dependency Vulnerabilities· Medium advisory (unmaintained) · ×1
D4 · Code Duplication· Near-duplicate member family (3 members, 63 shared lines) · ×1
Near-duplicate member family (3 members, 63 shared lines) crates/ai-memory-store/src/reader.rs:3399— crates/ai-memory-store/src/reader.rs:3399-3533 | crates/ai-memory-store/src/reader.rs:3759-3900 | crates/ai-memory-store/src/reader.rs:3918-4064 — These 3 members are variants of one another: a block of 63 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 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 3 times.
Near-duplicate member pair (68 shared lines) crates/ai-memory-workstream/src/transcript.rs:3464— crates/ai-memory-workstream/src/transcript.rs:3464-3557 | crates/ai-memory-workstream/src/transcript.rs:5918-6004 — These two members are variants of one another: 68 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.
Near-duplicate member pair (60 shared lines) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:112— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:112-284 | crates/ai-memory-consolidate/src/projection.rs:224-381 — 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.
Near-duplicate member pair (50 shared lines) crates/ai-memory-store/src/reader.rs:9907— crates/ai-memory-store/src/reader.rs:9907-10036 | crates/ai-memory-store/src/reader.rs:10593-10756 — These two members are variants of one another: 50 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.
Near-duplicate member pair (36 shared lines) crates/ai-memory-mcp/src/admin.rs:2043— crates/ai-memory-mcp/src/admin.rs:2043-2092 | crates/ai-memory-mcp/src/admin.rs:2172-2218 — These two members are variants of one another: 36 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 (6 members, 50+ identical tokens) · ×1
Members sharing a duplicated core (6 members, 50+ identical tokens) crates/ai-memory-store/src/grants.rs:355— crates/ai-memory-store/src/grants.rs:355-406 | crates/ai-memory-store/src/profile.rs:136-173 | crates/ai-memory-store/src/profile.rs:474-531 | crates/ai-memory-store/src/profile.rs:765-801 | crates/ai-memory-store/src/reader.rs:3554-3713 | crates/ai-memory-store/src/reader.rs:12537-12588 — 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· Members sharing a duplicated core (5 members, 50+ identical tokens) · ×1
Members sharing a duplicated core (5 members, 50+ identical tokens) crates/ai-memory-cli/src/commands/install_hooks.rs:8062— crates/ai-memory-cli/src/commands/install_hooks.rs:8062-8099 | crates/ai-memory-cli/src/commands/install_hooks.rs:8144-8180 | crates/ai-memory-cli/src/commands/install_hooks.rs:8225-8262 | crates/ai-memory-cli/src/commands/install_hooks.rs:8311-8348 | crates/ai-memory-cli/src/commands/install_hooks.rs:8398-8437 — 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· Edited copy of a member (56 corresponding lines) · ×1
Edited copy of a member (56 corresponding lines) crates/ai-memory-llm/src/copilot.rs:593— crates/ai-memory-llm/src/copilot.rs:593-648 | crates/ai-memory-llm/src/embedding.rs:356-411 — These two members are one piece of code written twice and then edited apart: 56 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (52 corresponding lines) · ×1
Edited copy of a member (52 corresponding lines) crates/ai-memory-store/src/ops.rs:1542— crates/ai-memory-store/src/ops.rs:1542-1593 | crates/ai-memory-store/src/ops.rs:1626-1679 — These two members are one piece of code written twice and then edited apart: 52 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (69 corresponding lines) · ×1
Edited copy of a member (69 corresponding lines) crates/ai-memory-mcp/src/admin.rs:5848— crates/ai-memory-mcp/src/admin.rs:5848-5916 | crates/ai-memory-mcp/src/admin.rs:6412-6484 — These two members are one piece of code written twice and then edited apart: 69 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport 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 (48 corresponding lines) · ×1
Edited copy of a member (48 corresponding lines) crates/ai-memory-store/src/reader.rs:4909— crates/ai-memory-store/src/reader.rs:4909-4956 | crates/ai-memory-store/src/reader.rs:4977-5032 — 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 (34 corresponding lines) · ×1
Edited copy of a member (34 corresponding lines) companions/ai-memory-importer/src/main.rs:1108— companions/ai-memory-importer/src/main.rs:1108-1141 | crates/ai-memory-wiki/src/markdown.rs:65-102 — 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 copies of one member (3 members, 27+ corresponding lines) · ×1
Edited copies of one member (3 members, 27+ corresponding lines) crates/ai-memory-consolidate/src/code_fence.rs:20— crates/ai-memory-consolidate/src/code_fence.rs:20-48 | crates/ai-memory-core/src/excerpt.rs:131-157 | crates/ai-memory-wiki/src/markdown.rs:181-208 — 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 copy of a member (57 corresponding lines) · ×1
Edited copy of a member (57 corresponding lines) crates/ai-memory-store/src/ops.rs:4942— crates/ai-memory-store/src/ops.rs:4942-4998 | crates/ai-memory-store/src/ops.rs:5016-5083 — These two members are one piece of code written twice and then edited apart: 57 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport 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) crates/ai-memory-llm/src/openai.rs:444— crates/ai-memory-llm/src/openai.rs:444-495 | crates/ai-memory-llm/src/opencode.rs:398-436 — 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 copy of a member (31 corresponding lines) · ×1
Edited copy of a member (31 corresponding lines) crates/ai-memory-web/src/markdown.rs:218— crates/ai-memory-web/src/markdown.rs:218-248 | crates/ai-memory-wiki/src/markdown.rs:533-565 — 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 copy of a member (32 corresponding lines) · ×1
Edited copy of a member (32 corresponding lines) crates/ai-memory-mcp/src/admin.rs:9791— crates/ai-memory-mcp/src/admin.rs:9791-9822 | crates/ai-memory-mcp/src/admin.rs:9844-9877 — 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 (30 corresponding lines) · ×1
Edited copy of a member (30 corresponding lines) crates/ai-memory-cli/src/commands/install_hooks.rs:8723— crates/ai-memory-cli/src/commands/install_hooks.rs:8723-8752 | crates/ai-memory-cli/src/commands/install_hooks.rs:9037-9069 — 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 copies of one member (3 members, 28+ corresponding lines) · ×1
Edited copies of one member (3 members, 28+ corresponding lines) crates/ai-memory-store/src/reader.rs:16619— crates/ai-memory-store/src/reader.rs:16619-16646 | crates/ai-memory-store/src/reader.rs:16655-16697 | crates/ai-memory-store/src/reader.rs:16708-16742 — 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 (3 members, 39+ corresponding lines) · ×1
Edited copies of one member (3 members, 39+ corresponding lines) crates/ai-memory-cli/src/commands/install_hooks.rs:7340— crates/ai-memory-cli/src/commands/install_hooks.rs:7340-7387 | crates/ai-memory-cli/src/commands/install_hooks.rs:8489-8531 | crates/ai-memory-cli/src/commands/install_hooks.rs:8543-8581 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 39 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, 28+ corresponding lines) · ×1
Edited copies of one member (4 members, 28+ corresponding lines) crates/ai-memory-cli/src/commands/install_hooks.rs:3298— crates/ai-memory-cli/src/commands/install_hooks.rs:3298-3326 | crates/ai-memory-cli/src/commands/install_hooks.rs:3506-3533 | crates/ai-memory-cli/src/commands/install_hooks.rs:3592-3621 | crates/ai-memory-cli/src/commands/install_hooks.rs:3685-3712 — These 4 members are one piece of code written 4 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 4 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 29+ corresponding lines) · ×1
Edited copies of one member (3 members, 29+ corresponding lines) crates/ai-memory-cli/src/commands/install_hooks.rs:3445— crates/ai-memory-cli/src/commands/install_hooks.rs:3445-3482 | crates/ai-memory-cli/src/commands/install_hooks.rs:3542-3574 | crates/ai-memory-cli/src/commands/install_hooks.rs:3637-3665 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 29 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, 43+ corresponding lines) · ×1
Edited copies of one member (3 members, 43+ corresponding lines) crates/ai-memory-store/src/ops.rs:4776— crates/ai-memory-store/src/ops.rs:4776-4819 | crates/ai-memory-store/src/ops.rs:4853-4895 | crates/ai-memory-store/src/ops.rs:6488-6534 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 43 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, 11+ corresponding lines) · ×1
Edited copies of one member (3 members, 11+ corresponding lines) crates/ai-memory-cli/src/commands/install_mcp.rs:1992— crates/ai-memory-cli/src/commands/install_mcp.rs:1992-2007 | crates/ai-memory-cli/src/commands/install_mcp.rs:2031-2045 | crates/ai-memory-cli/src/commands/install_mcp.rs:2047-2057 — 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 (7 members, 20+ corresponding lines) · ×1
Edited copies of one member (7 members, 20+ corresponding lines) crates/ai-memory-cli/src/commands/setup_agent.rs:323— crates/ai-memory-cli/src/commands/setup_agent.rs:323-346 | crates/ai-memory-cli/src/commands/setup_agent.rs:354-377 | crates/ai-memory-cli/src/commands/setup_agent.rs:424-443 | crates/ai-memory-cli/src/commands/setup_agent.rs:449-469 | crates/ai-memory-cli/src/commands/setup_agent.rs:474-493 | crates/ai-memory-cli/src/commands/setup_agent.rs:497-516 | crates/ai-memory-cli/src/commands/setup_agent.rs:520-539 — These 7 members are one piece of code written 7 times and then edited apart: every two of them correspond over at least 20 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 copy of a member (379 corresponding lines) · ×1
Edited copy of a member (379 corresponding lines) crates/ai-memory-cli/src/commands/install_hooks.rs:5478— crates/ai-memory-cli/src/commands/install_hooks.rs:5478-5963 | crates/ai-memory-cli/src/commands/install_hooks.rs:6399-6777 — These two members are one piece of code written twice and then edited apart: 379 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport 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 (6 members, 22+ corresponding lines) · ×1
Edited copies of one member (6 members, 22+ corresponding lines) crates/ai-memory-cli/src/commands/install_hooks.rs:7495— crates/ai-memory-cli/src/commands/install_hooks.rs:7495-7516 | crates/ai-memory-cli/src/commands/install_hooks.rs:8027-8051 | crates/ai-memory-cli/src/commands/install_hooks.rs:8114-8136 | crates/ai-memory-cli/src/commands/install_hooks.rs:8193-8215 | crates/ai-memory-cli/src/commands/install_hooks.rs:8279-8300 | crates/ai-memory-cli/src/commands/install_hooks.rs:8363-8385 — These 6 members are one piece of code written 6 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 6 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (4 members, 13+ corresponding lines) · ×1
Edited copies of one member (4 members, 13+ corresponding lines) crates/ai-memory-llm/src/anthropic.rs:70— crates/ai-memory-llm/src/anthropic.rs:70-84 | crates/ai-memory-llm/src/anthropic.rs:95-109 | crates/ai-memory-llm/src/gemini.rs:43-55 | crates/ai-memory-llm/src/openai.rs:141-159 — These 4 members are one piece of code written 4 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 4 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (4 members, 15+ corresponding lines) · ×1
Edited copies of one member (4 members, 15+ corresponding lines) crates/ai-memory-store/src/ops.rs:353— crates/ai-memory-store/src/ops.rs:353-368 | crates/ai-memory-store/src/reader.rs:5425-5441 | crates/ai-memory-store/src/reader.rs:5456-5480 | crates/ai-memory-store/src/reader.rs:12599-12613 — These 4 members are one piece of code written 4 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 4 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 24+ corresponding lines) · ×1
Edited copies of one member (3 members, 24+ corresponding lines) crates/ai-memory-store/src/reader.rs:16042— crates/ai-memory-store/src/reader.rs:16042-16065 | crates/ai-memory-store/src/reader.rs:16105-16129 | crates/ai-memory-store/src/reader.rs:16137-16161 — These 3 members are one piece of code written 3 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 3 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (7 members, 13+ corresponding lines) · ×1
Edited copies of one member (7 members, 13+ corresponding lines) crates/ai-memory-store/src/writer.rs:1217— crates/ai-memory-store/src/writer.rs:1217-1232 | crates/ai-memory-store/src/writer.rs:1270-1283 | crates/ai-memory-store/src/writer.rs:1326-1338 | crates/ai-memory-store/src/writer.rs:1747-1759 | crates/ai-memory-store/src/writer.rs:2388-2402 | crates/ai-memory-store/src/writer.rs:2602-2616 | crates/ai-memory-store/src/writer.rs:2696-2710 — These 7 members are one piece of code written 7 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 7 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 9+ corresponding lines) · ×1
Edited copies of one member (3 members, 9+ corresponding lines) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:96— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:96-104 | crates/ai-memory-consolidate/src/projection.rs:97-105 | crates/ai-memory-web/src/routes/api.rs:1348-1359 — 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 (3 members, 8+ corresponding lines) · ×1
Edited copies of one member (3 members, 8+ corresponding lines) crates/ai-memory-store/src/api_credentials.rs:126— crates/ai-memory-store/src/api_credentials.rs:126-133 | crates/ai-memory-store/src/users.rs:400-407 | crates/ai-memory-store/src/workstream.rs:977-985 — 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) · ×1
Edited copies of one member (4 members, 4+ corresponding lines) crates/ai-memory-cli/src/commands/api_key.rs:148— crates/ai-memory-cli/src/commands/api_key.rs:148-151 | crates/ai-memory-cli/src/commands/grant.rs:109-112 | crates/ai-memory-cli/src/commands/list_projects.rs:194-197 | crates/ai-memory-cli/src/commands/user.rs:188-191 — 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.
Duplicated block (44 lines × 2) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:497— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:497-540 | crates/ai-memory-consolidate/src/projection.rs:1028-1071 — before extracting anything, compare `crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs` and `crates/ai-memory-consolidate/src/projection.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 354 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 (43 lines × 2) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:234— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:234-276 | crates/ai-memory-consolidate/src/projection.rs:331-373 — before extracting anything, compare `crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs` and `crates/ai-memory-consolidate/src/projection.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 354 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 `crates/ai-memory-consolidate/src/consolidator_frozen_oracle.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 (35–37 lines × 2) crates/ai-memory-consolidate/src/consolidator.rs:313— crates/ai-memory-consolidate/src/consolidator.rs:313-349 | crates/ai-memory-consolidate/src/consolidator.rs:854-888 — both copies are in the same file, so extract the 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 `crates/ai-memory-consolidate/src/consolidator.rs:313` 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 (37 lines × 2) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:748— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:748-784 | crates/ai-memory-consolidate/src/projection.rs:1283-1319 — before extracting anything, compare `crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs` and `crates/ai-memory-consolidate/src/projection.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 354 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 (4–36 lines × 5) crates/ai-memory-store/src/reader.rs:3436— crates/ai-memory-store/src/reader.rs:3436-3471 | crates/ai-memory-store/src/reader.rs:3594-3597 | crates/ai-memory-store/src/reader.rs:3801-3836 | crates/ai-memory-store/src/reader.rs:3963-3998 | crates/ai-memory-store/src/reader.rs:8423-8426 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ai-memory-store/src/reader.rs:3436` 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 (31 lines × 2) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:614— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:614-644 | crates/ai-memory-consolidate/src/projection.rs:1146-1176 — before extracting anything, compare `crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs` and `crates/ai-memory-consolidate/src/projection.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 354 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 (29–30 lines × 2) crates/ai-memory-store/src/ops.rs:4777— crates/ai-memory-store/src/ops.rs:4777-4806 | crates/ai-memory-store/src/ops.rs:4854-4882 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/ops.rs:4777` 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 (30 lines × 2) crates/ai-memory-store/src/reader.rs:10007— crates/ai-memory-store/src/reader.rs:10007-10036 | crates/ai-memory-store/src/reader.rs:10727-10756 — both copies are in the same file, so extract the 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 (29 lines × 2) crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:802— crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:802-830 | crates/ai-memory-consolidate/src/projection.rs:1337-1365 — before extracting anything, compare `crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs` and `crates/ai-memory-consolidate/src/projection.rs` as WHOLE FILES: this scan already matched 21 separate duplicated blocks between them, totalling at least 354 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 (27–28 lines × 2) crates/ai-memory-cli/src/commands/hook_spool.rs:1879— crates/ai-memory-cli/src/commands/hook_spool.rs:1879-1906 | crates/ai-memory-cli/src/commands/hook_spool.rs:1973-1999 — both copies are in the same file, so extract the 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 `crates/ai-memory-cli/src/commands/hook_spool.rs:1879` 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, `crates/ai-memory-cli/src/commands/hook_spool.rs:1909` calls `insert` and `crates/ai-memory-cli/src/commands/hook_spool.rs:2002` 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 (26–28 lines × 2) crates/ai-memory-cli/src/commands/move_project.rs:94— crates/ai-memory-cli/src/commands/move_project.rs:94-119 | crates/ai-memory-cli/src/commands/purge_project.rs:191-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. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ai-memory-cli/src/commands/move_project.rs:94` 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 `args` to `MoveProjectArgs` in one and `PurgeProjectArgs` 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 (25 lines × 2) crates/ai-memory-cli/src/commands/auto_improve_report.rs:169— crates/ai-memory-cli/src/commands/auto_improve_report.rs:169-193 | crates/ai-memory-cli/src/commands/curator.rs:111-135 — before extracting anything, compare `crates/ai-memory-cli/src/commands/auto_improve_report.rs` and `crates/ai-memory-cli/src/commands/curator.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 48 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 `crates/ai-memory-cli/src/commands/auto_improve_report.rs:169` 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 `report` to `&AutoImproveTelemetryReport` in one and `&CuratorReport` 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 (24–25 lines × 2) crates/ai-memory-mcp/src/server.rs:5331— crates/ai-memory-mcp/src/server.rs:5331-5354 | crates/ai-memory-mcp/src/server.rs:5624-5648 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/server.rs:5331` 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 (4–25 lines × 4) crates/ai-memory-store/src/ops.rs:9484— crates/ai-memory-store/src/ops.rs:9484-9487 | crates/ai-memory-store/src/profile.rs:369-372 | crates/ai-memory-store/src/reader.rs:13710-13733 | crates/ai-memory-store/src/reader.rs:13738-13762 — before extracting anything, compare `crates/ai-memory-store/src/ops.rs` and `crates/ai-memory-store/src/reader.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 69 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. 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 `crates/ai-memory-store/src/ops.rs:9484` 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 (23 lines × 3) crates/ai-memory-store/src/reader.rs:3500— crates/ai-memory-store/src/reader.rs:3500-3522 | crates/ai-memory-store/src/reader.rs:3870-3892 | crates/ai-memory-store/src/reader.rs:4034-4056 — 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 `crates/ai-memory-store/src/reader.rs:3500` 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 (26–36 lines × 2) crates/ai-memory-hooks/src/router.rs:1374— crates/ai-memory-hooks/src/router.rs:1374-1399 | crates/ai-memory-hooks/src/router.rs:4790-4825 — both copies are in the same file, so extract the 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 `crates/ai-memory-hooks/src/router.rs:1374` 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 (16–20 lines × 2) companions/ai-memory-importer/src/document.rs:219— companions/ai-memory-importer/src/document.rs:219-238 | companions/ai-memory-importer/src/main.rs:435-450 — before extracting anything, compare `companions/ai-memory-importer/src/document.rs` and `companions/ai-memory-importer/src/main.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 60 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 `companions/ai-memory-importer/src/document.rs:219` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (19–20 lines × 2) crates/ai-memory-cli/src/commands/api_key.rs:218— crates/ai-memory-cli/src/commands/api_key.rs:218-236 | crates/ai-memory-cli/src/commands/user.rs:358-377 — 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 (18–20 lines × 2) crates/ai-memory-cli/src/commands/install_hooks.rs:7168— crates/ai-memory-cli/src/commands/install_hooks.rs:7168-7187 | crates/ai-memory-cli/src/commands/setup_agent.rs:962-979 — before extracting anything, compare `crates/ai-memory-cli/src/commands/install_hooks.rs` and `crates/ai-memory-cli/src/commands/setup_agent.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 44 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 `crates/ai-memory-cli/src/commands/install_hooks.rs:7168` 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 (4–20 lines × 4) crates/ai-memory-workstream/src/transcript.rs:5647— crates/ai-memory-workstream/src/transcript.rs:5647-5666 | crates/ai-memory-workstream/src/transcript.rs:5691-5694 | crates/ai-memory-workstream/src/transcript.rs:5792-5795 | crates/ai-memory-workstream/src/transcript.rs:6254-6273 — 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 `crates/ai-memory-workstream/src/transcript.rs:5647` 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 (16–19 lines × 4) crates/ai-memory-llm/src/fallback.rs:243— crates/ai-memory-llm/src/fallback.rs:243-258 | crates/ai-memory-llm/src/fallback.rs:276-293 | crates/ai-memory-llm/src/fallback.rs:311-328 | crates/ai-memory-llm/src/fallback.rs:350-368 — 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 `crates/ai-memory-llm/src/fallback.rs:243` 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 (19 lines × 3) crates/ai-memory-cli/src/commands/install_hooks.rs:3515— crates/ai-memory-cli/src/commands/install_hooks.rs:3515-3533 | crates/ai-memory-cli/src/commands/install_hooks.rs:3694-3712 | crates/ai-memory-cli/src/commands/install_hooks.rs:3972-3990 — 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 `crates/ai-memory-cli/src/commands/install_hooks.rs:3515` 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 (19 lines × 2) crates/ai-memory-cli/src/commands/auth.rs:365— crates/ai-memory-cli/src/commands/auth.rs:365-383 | crates/ai-memory-cli/src/commands/auth.rs:471-489 — both copies are in the same file, so extract the 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 `crates/ai-memory-cli/src/commands/auth.rs:365` 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–18 lines × 3) crates/ai-memory-consolidate/src/code_fence.rs:23— crates/ai-memory-consolidate/src/code_fence.rs:23-39 | crates/ai-memory-core/src/excerpt.rs:134-150 | crates/ai-memory-wiki/src/markdown.rs:184-201 — 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 `crates/ai-memory-consolidate/src/code_fence.rs:23` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `line` to `&str) -> (Option<Self>` in one and `&str) -> (Option<(char, usize)>` 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 (15–18 lines × 2) crates/ai-memory-mcp/src/admin.rs:3690— crates/ai-memory-mcp/src/admin.rs:3690-3707 | crates/ai-memory-mcp/src/admin.rs:3807-3821 — both copies are in the same file, so extract the 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–17 lines × 2) crates/ai-memory-mcp/src/server.rs:6988— crates/ai-memory-mcp/src/server.rs:6988-7000 | crates/ai-memory-mcp/src/server.rs:7089-7105 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/server.rs:6988` 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–16 lines × 3) companions/ai-memory-importer/src/agentmemory/vault.rs:83— companions/ai-memory-importer/src/agentmemory/vault.rs:83-95 | companions/ai-memory-importer/src/document.rs:214-229 | companions/ai-memory-importer/src/main.rs:430-442 — before extracting anything, compare `companions/ai-memory-importer/src/document.rs` and `companions/ai-memory-importer/src/main.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 60 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 (12–16 lines × 2) crates/ai-memory-mcp/src/server.rs:4409— crates/ai-memory-mcp/src/server.rs:4409-4424 | crates/ai-memory-mcp/src/server.rs:4735-4746 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/server.rs:4409` 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 (15 lines × 3) crates/ai-memory-cli/src/commands/install_hooks.rs:2777— crates/ai-memory-cli/src/commands/install_hooks.rs:2777-2791 | crates/ai-memory-cli/src/commands/install_hooks.rs:2970-2984 | crates/ai-memory-cli/src/commands/install_hooks.rs:3074-3088 — 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 `crates/ai-memory-cli/src/commands/install_hooks.rs:2777` 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–15 lines × 3) crates/ai-memory-store/src/reader.rs:9911— crates/ai-memory-store/src/reader.rs:9911-9925 | crates/ai-memory-store/src/reader.rs:10081-10092 | crates/ai-memory-store/src/reader.rs:10600-10611 — 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 `crates/ai-memory-store/src/reader.rs:9911` 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–15 lines × 2) crates/ai-memory-cli/src/commands/install_hooks.rs:2961— crates/ai-memory-cli/src/commands/install_hooks.rs:2961-2971 | crates/ai-memory-cli/src/commands/install_hooks.rs:3559-3573 — both copies are in the same file, so extract the 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 `crates/ai-memory-cli/src/commands/install_hooks.rs:3559` 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 (14–15 lines × 2) crates/ai-memory-mcp/src/admin.rs:8737— crates/ai-memory-mcp/src/admin.rs:8737-8751 | crates/ai-memory-mcp/src/admin.rs:8764-8777 — both copies are in the same file, so extract the 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 (13–15 lines × 2) crates/ai-memory-wiki/src/admission.rs:433— crates/ai-memory-wiki/src/admission.rs:433-447 | crates/ai-memory-wiki/src/admission.rs:619-631 — both copies are in the same file, so extract the 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 `crates/ai-memory-wiki/src/admission.rs:433` 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–14 lines × 3) crates/ai-memory-cli/src/commands/install_hooks.rs:2664— crates/ai-memory-cli/src/commands/install_hooks.rs:2664-2677 | crates/ai-memory-cli/src/commands/install_hooks.rs:2961-2969 | crates/ai-memory-cli/src/commands/install_hooks.rs:3559-3570 — 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 `crates/ai-memory-cli/src/commands/install_hooks.rs:2664` 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, `crates/ai-memory-cli/src/commands/install_hooks.rs:2679` calls `remove_ai_memory_event_hooks` and `crates/ai-memory-cli/src/commands/install_hooks.rs:2970` 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 (11–14 lines × 2) crates/ai-memory-cli/src/commands/install_hooks.rs:3252— crates/ai-memory-cli/src/commands/install_hooks.rs:3252-3262 | crates/ai-memory-cli/src/commands/install_hooks.rs:3553-3566 — both copies are in the same file, so extract the 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 `crates/ai-memory-cli/src/commands/install_hooks.rs:3252` 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 × 9) crates/ai-memory-cli/src/commands/install_hooks.rs:2777— crates/ai-memory-cli/src/commands/install_hooks.rs:2777-2789 | crates/ai-memory-cli/src/commands/install_hooks.rs:2970-2982 | crates/ai-memory-cli/src/commands/install_hooks.rs:3074-3086 | crates/ai-memory-cli/src/commands/install_hooks.rs:7966-7978 | crates/ai-memory-cli/src/commands/install_hooks.rs:8084-8096 | crates/ai-memory-cli/src/commands/install_hooks.rs:8165-8177 | crates/ai-memory-cli/src/commands/install_hooks.rs:8247-8259 | crates/ai-memory-cli/src/commands/install_hooks.rs:8333-8345 | crates/ai-memory-cli/src/commands/install_hooks.rs:8422-8434 — all 9 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 `crates/ai-memory-cli/src/commands/install_hooks.rs:2777` 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–13 lines × 2) companions/ai-memory-importer/src/agentmemory/export.rs:171— companions/ai-memory-importer/src/agentmemory/export.rs:171-178 | companions/ai-memory-importer/src/claude_mem.rs:157-169 — before extracting anything, compare `companions/ai-memory-importer/src/agentmemory/export.rs` and `companions/ai-memory-importer/src/claude_mem.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 48 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 `companions/ai-memory-importer/src/agentmemory/export.rs:171` 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 (12–13 lines × 2) companions/ai-memory-importer/src/agentmemory/export.rs:458— companions/ai-memory-importer/src/agentmemory/export.rs:458-470 | companions/ai-memory-importer/src/claude_mem.rs:299-310 — before extracting anything, compare `companions/ai-memory-importer/src/agentmemory/export.rs` and `companions/ai-memory-importer/src/claude_mem.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 48 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 `companions/ai-memory-importer/src/agentmemory/export.rs:458` 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 (4–13 lines × 3) crates/ai-memory-store/src/reader.rs:3041— crates/ai-memory-store/src/reader.rs:3041-3044 | crates/ai-memory-store/src/reader.rs:4615-4627 | crates/ai-memory-store/src/reader.rs:4673-4685 — 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 `crates/ai-memory-store/src/reader.rs:3041` 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 (8–12 lines × 3) crates/ai-memory-cli/src/commands/hook_spool.rs:1728— crates/ai-memory-cli/src/commands/hook_spool.rs:1728-1739 | crates/ai-memory-cli/src/commands/hook_spool.rs:1901-1908 | crates/ai-memory-cli/src/commands/hook_spool.rs:1994-2001 — 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 `crates/ai-memory-cli/src/commands/hook_spool.rs:1728` 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, `crates/ai-memory-cli/src/commands/hook_spool.rs:1909` calls `insert` and `crates/ai-memory-cli/src/commands/hook_spool.rs:1740` 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 (16–17 lines × 2) crates/ai-memory-consolidate/src/dream.rs:436— crates/ai-memory-consolidate/src/dream.rs:436-451 | crates/ai-memory-consolidate/src/sweep.rs:1296-1312 — before extracting anything, compare `crates/ai-memory-consolidate/src/dream.rs` and `crates/ai-memory-consolidate/src/sweep.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 45 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 `crates/ai-memory-consolidate/src/dream.rs:436` 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, `crates/ai-memory-consolidate/src/dream.rs:451` calls `push`, `clone` and `crates/ai-memory-consolidate/src/sweep.rs:1312` 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–11 lines × 3) crates/ai-memory-llm/src/copilot.rs:616— crates/ai-memory-llm/src/copilot.rs:616-624 | crates/ai-memory-llm/src/embedding.rs:377-387 | crates/ai-memory-llm/src/google.rs:106-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 all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ai-memory-llm/src/copilot.rs:616` 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–10 lines × 4) crates/ai-memory-llm/src/factory.rs:393— crates/ai-memory-llm/src/factory.rs:393-402 | crates/ai-memory-llm/src/factory.rs:406-415 | crates/ai-memory-llm/src/factory.rs:418-425 | crates/ai-memory-llm/src/factory.rs:485-494 — 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 `crates/ai-memory-llm/src/factory.rs:393` 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. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `crates/ai-memory-llm/src/factory.rs:425` calls `with_extra_headers` and `crates/ai-memory-llm/src/factory.rs:494` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8–10 lines × 2) crates/ai-memory-mcp/src/admin.rs:5038— crates/ai-memory-mcp/src/admin.rs:5038-5047 | crates/ai-memory-mcp/src/admin.rs:5187-5194 — both copies are in the same file, so extract the 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 `crates/ai-memory-mcp/src/admin.rs:5038` 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 (8–9 lines × 6) crates/ai-memory-store/src/reader.rs:3453— crates/ai-memory-store/src/reader.rs:3453-3461 | crates/ai-memory-store/src/reader.rs:3505-3512 | crates/ai-memory-store/src/reader.rs:3818-3826 | crates/ai-memory-store/src/reader.rs:3875-3882 | crates/ai-memory-store/src/reader.rs:3980-3988 | crates/ai-memory-store/src/reader.rs:4039-4046 — 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. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ai-memory-store/src/reader.rs:3453` 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, `crates/ai-memory-store/src/reader.rs:3513` calls `page_descriptor` and `crates/ai-memory-store/src/reader.rs:3462` 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–9 lines × 4) crates/ai-memory-store/src/reader.rs:761— crates/ai-memory-store/src/reader.rs:761-766 | crates/ai-memory-store/src/reader.rs:797-802 | crates/ai-memory-store/src/reader.rs:4236-4241 | crates/ai-memory-store/src/reader.rs:9260-9268 — 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 `crates/ai-memory-store/src/reader.rs:761` 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–9 lines × 3) crates/ai-memory-mcp/src/admin.rs:4184— crates/ai-memory-mcp/src/admin.rs:4184-4191 | crates/ai-memory-store/src/reader.rs:7077-7081 | crates/ai-memory-store/src/reader.rs:7307-7315 — 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 `crates/ai-memory-mcp/src/admin.rs:4184` 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 (8–9 lines × 2) crates/ai-memory-store/src/ops.rs:1639— crates/ai-memory-store/src/ops.rs:1639-1646 | crates/ai-memory-store/src/ops.rs:1897-1905 — both copies are in the same file, so extract the 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 `crates/ai-memory-store/src/ops.rs:1639` 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 (6–9 lines × 2) crates/ai-memory-wiki/src/confinement.rs:207— crates/ai-memory-wiki/src/confinement.rs:207-215 | crates/ai-memory-wiki/src/migrations/m2026_09_okf_conformance.rs:213-218 — 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 `crates/ai-memory-wiki/src/confinement.rs:207` 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–8 lines × 3) crates/ai-memory-store/src/reader.rs:9944— crates/ai-memory-store/src/reader.rs:9944-9950 | crates/ai-memory-store/src/reader.rs:10137-10144 | crates/ai-memory-store/src/reader.rs:10654-10661 — 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 `crates/ai-memory-store/src/reader.rs:9944` 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 × 5) crates/ai-memory-hooks/src/workstream.rs:594— crates/ai-memory-hooks/src/workstream.rs:594-600 | crates/ai-memory-hooks/src/workstream.rs:620-626 | crates/ai-memory-hooks/src/workstream.rs:643-649 | crates/ai-memory-hooks/src/workstream.rs:692-698 | crates/ai-memory-hooks/src/workstream.rs:1069-1075 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ai-memory-hooks/src/workstream.rs:1067` calls `Json` and `crates/ai-memory-hooks/src/workstream.rs:592` 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–7 lines × 3) crates/ai-memory-cli/src/commands/delete_page.rs:38— crates/ai-memory-cli/src/commands/delete_page.rs:38-43 | crates/ai-memory-cli/src/commands/restore_page.rs:41-47 | crates/ai-memory-cli/src/commands/write_page.rs:51-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 all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ai-memory-cli/src/commands/delete_page.rs:38` 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. Note first that the copies are not typed on the same thing: the declarations holding them bind `args` to `DeletePageArgs` in one and `RestorePageArgs` 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 (6 lines × 5) crates/ai-memory-cli/src/commands/hook_spool.rs:1733— crates/ai-memory-cli/src/commands/hook_spool.rs:1733-1738 | crates/ai-memory-cli/src/commands/hook_spool.rs:1887-1892 | crates/ai-memory-cli/src/commands/hook_spool.rs:1902-1907 | crates/ai-memory-cli/src/commands/hook_spool.rs:1980-1985 | crates/ai-memory-cli/src/commands/hook_spool.rs:1995-2000 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `crates/ai-memory-cli/src/commands/hook_spool.rs:1909` calls `insert` and `crates/ai-memory-cli/src/commands/hook_spool.rs:1740` 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 × 4) crates/ai-memory-store/src/profile.rs:154— crates/ai-memory-store/src/profile.rs:154-159 | crates/ai-memory-store/src/profile.rs:505-510 | crates/ai-memory-store/src/profile.rs:780-785 | crates/ai-memory-store/src/reader.rs:12557-12562 — before extracting anything, compare `crates/ai-memory-store/src/profile.rs` and `crates/ai-memory-store/src/reader.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 53 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 `crates/ai-memory-store/src/profile.rs:154` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (3–6 lines × 8) crates/ai-memory-store/src/reader.rs:3429— crates/ai-memory-store/src/reader.rs:3429-3431 | crates/ai-memory-store/src/reader.rs:3794-3796 | crates/ai-memory-store/src/reader.rs:4789-4791 | crates/ai-memory-store/src/reader.rs:4875-4877 | crates/ai-memory-store/src/reader.rs:4931-4934 | crates/ai-memory-store/src/reader.rs:7977-7982 | crates/ai-memory-store/src/reader.rs:8187-8192 | crates/ai-memory-store/src/reader.rs:8336-8339 — all 8 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 `crates/ai-memory-store/src/reader.rs:3429` 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, `crates/ai-memory-store/src/reader.rs:7982` calls `get` and `crates/ai-memory-store/src/reader.rs:3431` 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 × 6) crates/ai-memory-store/src/grants.rs:377— crates/ai-memory-store/src/grants.rs:377-381 | crates/ai-memory-store/src/profile.rs:156-160 | crates/ai-memory-store/src/profile.rs:507-511 | crates/ai-memory-store/src/profile.rs:782-786 | crates/ai-memory-store/src/reader.rs:3671-3675 | crates/ai-memory-store/src/reader.rs:12559-12563 — before extracting anything, compare `crates/ai-memory-store/src/profile.rs` and `crates/ai-memory-store/src/reader.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 53 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 `crates/ai-memory-store/src/grants.rs:377` 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 (4–5 lines × 6) crates/ai-memory-store/src/reader.rs:3490— crates/ai-memory-store/src/reader.rs:3490-3494 | crates/ai-memory-store/src/reader.rs:3860-3864 | crates/ai-memory-store/src/reader.rs:4027-4030 | crates/ai-memory-store/src/reader.rs:4728-4731 | crates/ai-memory-store/src/reader.rs:9401-9404 | crates/ai-memory-store/src/workstream.rs:2012-2015 — there are 6 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 6 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ai-memory-store/src/reader.rs:3490` 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 (14 lines × 3) crates/ai-memory-cli/src/commands/auth.rs:380— crates/ai-memory-cli/src/commands/auth.rs:380-393 | crates/ai-memory-cli/src/commands/auth.rs:445-458 | crates/ai-memory-cli/src/commands/auth.rs:486-499 — 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 `crates/ai-memory-cli/src/commands/auth.rs:380` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (8 lines × 4) crates/ai-memory-mcp/src/admin.rs:9692— crates/ai-memory-mcp/src/admin.rs:9692-9699 | crates/ai-memory-mcp/src/admin.rs:9721-9729 | crates/ai-memory-mcp/src/admin.rs:9751-9758 | crates/ai-memory-mcp/src/admin.rs:9775-9782 — 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 `crates/ai-memory-mcp/src/admin.rs:9692` 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 (9 lines × 4) crates/ai-memory-cli/src/commands/install_hooks.rs:8069— crates/ai-memory-cli/src/commands/install_hooks.rs:8069-8077 | crates/ai-memory-cli/src/commands/install_hooks.rs:8150-8158 | crates/ai-memory-cli/src/commands/install_hooks.rs:8232-8240 | crates/ai-memory-cli/src/commands/install_hooks.rs:8318-8326 — 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 `crates/ai-memory-cli/src/commands/install_hooks.rs:8069` 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 × 7) crates/ai-memory-cli/src/commands/install_hooks.rs:2771— crates/ai-memory-cli/src/commands/install_hooks.rs:2771-2778 | crates/ai-memory-cli/src/commands/install_hooks.rs:2862-2870 | crates/ai-memory-cli/src/commands/install_hooks.rs:2964-2971 | crates/ai-memory-cli/src/commands/install_hooks.rs:3068-3075 | crates/ai-memory-cli/src/commands/install_hooks.rs:3261-3268 | crates/ai-memory-cli/src/commands/install_hooks.rs:3565-3572 | crates/ai-memory-cli/src/commands/install_hooks.rs:3656-3663 — all 7 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 `crates/ai-memory-cli/src/commands/install_hooks.rs:2771` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ai-memory-cli/src/commands/install_hooks.rs:3065` calls `insert`, `into` and `crates/ai-memory-cli/src/commands/install_hooks.rs:2768` 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.
End-of-life runtime: Rust 1.95 rust-toolchain.toml:1— rust-toolchain.toml declares Rust 1.95 as this project's toolchain file, and Rust 1.95, superseded by 1.96 on 2026-05-28 (the Rust project patches only the current stable). An unsupported runtime receives no security patches, so every vulnerability disclosed in it since 2026-05-28 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.
Unstable project ai-memory-mcp — ai-memory-mcp has instability 0.83 with 1 dependents.
R10 · Code Duplication· Duplicated block with local edits (76 matched lines × 2 locations) · ×1
Duplicated block with local edits (76 matched lines × 2 locations) companions/ai-memory-ts/src/client.ts:347— companions/ai-memory-ts/src/client.ts:347 · companions/ai-memory-ts/src/client.ts:609 — the two spans are one implementation copied and then locally edited — 516 tokens are still identical, in the same order in both spans, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
Duplicated block (14 lines × 2 locations) companions/ai-memory-ts/src/decode.ts:55— companions/ai-memory-ts/src/decode.ts:55 · companions/ai-memory-ts/src/decode.ts:77 — both copies are in the same file, so extract the 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 locations) companions/ai-memory-ts/src/decode.ts:164— companions/ai-memory-ts/src/decode.ts:164 · companions/ai-memory-ts/src/decode.ts:325 — both copies are in the same file, so extract the 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 (12 lines × 2 locations) companions/ai-memory-ts/src/client.ts:661— companions/ai-memory-ts/src/client.ts:661 · companions/ai-memory-ts/src/client.ts:699 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (11 lines × 2 locations) companions/ai-memory-ts/src/decode.ts:234— companions/ai-memory-ts/src/decode.ts:234 · companions/ai-memory-ts/src/decode.ts:305 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
R10 · Code Duplication· Duplicated block with local edits (9 matched lines × 2 locations) · ×1
Duplicated block with local edits (9 matched lines × 2 locations) companions/ai-memory-ts/src/client.ts:1171— companions/ai-memory-ts/src/client.ts:1171 · companions/ai-memory-ts/src/transport.ts:568 — the two spans are one implementation copied and then locally edited — 53 tokens are still identical, in the same order in both files, with only local edits between them. The copies have already begun to drift, which is this row's finding: an edit made to one and not the other changes behaviour silently. Diff the two spans first to learn what genuinely differs, then extract the shared core into one module both sites use, passing the differences in as parameters — or, if one copy exists only because the other could not be imported from its context, make one of them the single source the other is generated or re-exported from. If one copy is no longer reachable, delete it rather than letting it shadow the live one.
Duplicated block (7 lines × 2 locations) companions/ai-memory-ts/src/core.ts:30— companions/ai-memory-ts/src/core.ts:30 · companions/ai-memory-ts/src/scope.ts:20 — the 2 copies are spread across 2 files, and the SHAPE of this repetition could not be determined. It is not a run of declarations, a listing, a declaration header, a type body or a slice through a construct — and it was not measured as a run of executable statements either, so this row cannot tell you whether a function can stand where these lines are. Read the two spans before acting, because the move is opposite in the two cases. Where they are statements, the ordinary answer holds: give the shared part one home and call it from each site. Where they turn out to be declarations, a literal's entries, or the cases of an enumeration, there is no call site to call anything from, and collapsing them would delete what each copy pins — a shared base type, a generated set, or one exported constant each site refers to is the move instead, and sometimes the honest answer is that there is nothing to extract at all. Reported because the copies drift apart the first time only one of them is edited, which is true whichever of those they are.
Duplicated block (6 lines × 5 locations) companions/ai-memory-ts/src/client.ts:309— companions/ai-memory-ts/src/client.ts:309 · companions/ai-memory-ts/src/client.ts:364 · companions/ai-memory-ts/src/client.ts:595 · companions/ai-memory-ts/src/client.ts:692 · +1 more site(s) not listed — all 5 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Duplicated block (5 lines × 6 locations) companions/ai-memory-ts/src/api.ts:174— companions/ai-memory-ts/src/api.ts:174 · companions/ai-memory-ts/src/client.ts:624 · companions/ai-memory-ts/src/client.ts:925 · companions/ai-memory-ts/src/client.ts:1029 · +2 more site(s) not listed — the 6 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
Duplicated block (5 lines × 2 locations) companions/ai-memory-ts/src/decode.ts:151— companions/ai-memory-ts/src/decode.ts:151 · companions/ai-memory-ts/src/decode.ts:169 — all 2 copies are in the same file, and the CITED SPAN is a run of DECLARATIONS inside a construct — the members of a type, or the entries of an object or array literal — with no statement anywhere in it. Do not read this as an extract-a-helper row: nothing here executes, so there is no call site, and a call expression cannot stand where a member declaration or a literal's entry was. What repeats is a SHAPE, and which shape decides the move. Where the copies declare the same members, the repetition is a missing common ancestor: give it a base type, an interface both extend, a generic instantiated twice, or — where the copies are a literal's entries rather than a type's members — one shared constant each site spreads or refers to, so the set is written once. Where they declare DIFFERENT members and only the form is shared — a decorator and its options, an annotation, a registration table's keys — the form is prescribed by a framework or a schema rather than copied, and the only collapse available is to generate the declarations from that schema; where you do not own the generator, this is the cost of the framework and there is nothing to extract. Check which of the two it is before acting: these copies still drift apart the first time only one of them is edited, which is why the repetition is reported, but the sentence to act on is not the same in both cases.
Complex function normalizeSchema (cyclomatic 28, cognitive 43) companions/ai-memory-ts/test/support/schema.ts:40— normalizeSchema has cyclomatic complexity 28 and cognitive complexity 43; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function request (cyclomatic 23, cognitive 29) companions/ai-memory-ts/src/transport.ts:280— request has cyclomatic complexity 23 and cognitive complexity 29; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function metadataFromFrontmatter (cyclomatic 22, cognitive 25) companions/ai-memory-ts/src/client.ts:143— metadataFromFrontmatter has cyclomatic complexity 22 and cognitive complexity 25; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function query (cyclomatic 18, cognitive 27) companions/ai-memory-ts/src/client.ts:946— query has cyclomatic complexity 18 and cognitive complexity 27; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R2 · Cyclomatic Complexity· Complex function main (cyclomatic 17, cognitive 22) · ×1
Complex function main (cyclomatic 17, cognitive 22) tests/e2e/web_dashboard_browser.mjs:141— main has cyclomatic complexity 17 and cognitive complexity 22; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function read (cyclomatic 17, cognitive 17) companions/ai-memory-ts/src/client.ts:433— read has cyclomatic complexity 17 and cognitive complexity 17; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function update (cyclomatic 16, cognitive 19) companions/ai-memory-ts/src/client.ts:542— update has cyclomatic complexity 16 and cognitive complexity 19; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function constructor (cyclomatic 15, cognitive 15) companions/ai-memory-ts/src/transport.ts:200— constructor has cyclomatic complexity 15 and cognitive complexity 15; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function startServer (cyclomatic 14, cognitive 24) companions/ai-memory-ts/test/support/server.ts:88— startServer has cyclomatic complexity 14 and cognitive complexity 24; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function paused (cyclomatic 12, cognitive 11) tests/e2e/web_dashboard_browser.mjs:187— paused has cyclomatic complexity 12 and cognitive complexity 11; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
Complex function httpError (cyclomatic 11, cognitive 9) companions/ai-memory-ts/src/transport.ts:388— httpError has cyclomatic complexity 11 and cognitive complexity 9; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R3 · Large Files· companions/ai-memory-ts/src/client.ts · ×1
companions/ai-memory-ts/src/client.ts: 1141 lines of code companions/ai-memory-ts/src/client.ts:1— companions/ai-memory-ts/src/client.ts has 1141 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R3 · Large Files· companions/ai-memory-ts/src/transport.ts · ×1
companions/ai-memory-ts/src/transport.ts: 543 lines of code companions/ai-memory-ts/src/transport.ts:1— companions/ai-memory-ts/src/transport.ts has 543 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
R4 · Test Coverage· This test file cannot be loaded · ×1
This test file cannot be loaded companions/ai-memory-ts/test/integration/examples.test.ts:14— companions/ai-memory-ts/test/integration/examples.test.ts:14 imports '../../examples/', which names no file in this repository — and no rule in its .gitignore chain could cover one, so no build writes it either. The import throws as the runner collects this file, so none of its test cases run and nothing it was written to verify is verified. Restore the missing module or delete the test. It is excluded from the reachability measured above, because a file that cannot load reaches nothing.
R6 · Tooling· The declared test suite includes a file that cannot be loaded · ×1
The declared test suite includes a file that cannot be loaded companions/ai-memory-ts/test/integration/examples.test.ts:14— This repository declares test tooling, and the ✓ above records that declaration — but companions/ai-memory-ts/test/integration/examples.test.ts cannot be loaded at all: it imports a module that names no file in this repository, so the runner throws while collecting it and none of its cases execute. The wiring is present and the suite it points at does not run as written, which is why the tooling tick must not be read as a statement that the tests pass. Fix the unloadable file(s) — each one is reported with its failing import under Test Coverage — then the declared script exercises what it claims to.
Duplicated predicate companions/ai-memory-ts/src/api.ts:227— `a.scope !== undefined || a.scopes !== undefined` appears character-identically in 2 files — companions/ai-memory-ts/src/api.ts, companions/ai-memory-ts/src/client.ts. 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 companions/ai-memory-ts/src/client.ts:481— `frontmatter !== null && typeof frontmatter === "object" && !Array.isArray(frontmatter)` appears character-identically in 2 files — companions/ai-memory-ts/src/client.ts, companions/ai-memory-ts/src/decode.ts. 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 companions/ai-memory-ts/src/api.ts:153— `response.status < 200 || response.status >= 300` appears character-identically in 2 files — companions/ai-memory-ts/src/api.ts, companions/ai-memory-ts/src/transport.ts. 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 companions/ai-memory-ts/src/core.ts:31— `typeof value !== "string" || value.trim() === ""` appears character-identically in 2 files — companions/ai-memory-ts/src/core.ts, companions/ai-memory-ts/src/scope.ts. 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 companions/ai-memory-ts/src/capabilities.ts:83— `value !== null && typeof value === "object" && !Array.isArray(value)` appears character-identically in 2 files — companions/ai-memory-ts/src/capabilities.ts, companions/ai-memory-ts/src/transport.ts. 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 companions/ai-memory-ts/src/admin.ts:182— `value === null || typeof value !== "object" || Array.isArray(value)` appears character-identically in 3 files — companions/ai-memory-ts/src/admin.ts, companions/ai-memory-ts/src/core.ts, companions/ai-memory-ts/src/decode.ts. 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 crates/ai-memory-hooks/src/router.rs:6308— `!body.is_empty() && !is_acknowledgment(body)` appears character-identically in 2 files — crates/ai-memory-hooks/src/router.rs, crates/ai-memory-hooks/src/session_end_equivalence.rs. 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 crates/ai-memory-consolidate/src/curator.rs:113— `!breadth_weight.is_finite() || breadth_weight < 0.0` appears character-identically in 2 files — crates/ai-memory-consolidate/src/curator.rs, crates/ai-memory-consolidate/src/sweep.rs. 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 crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:325— `!self.groups.is_empty() && self.char_count() > max_chars` appears character-identically in 2 files — crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs, crates/ai-memory-consolidate/src/projection.rs. 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 crates/ai-memory-cli/src/commands/resume.rs:37— `!std::io::stdin().is_terminal() || !std::io::stdout().is_terminal()` appears character-identically in 2 files — crates/ai-memory-cli/src/commands/resume.rs, crates/ai-memory-cli/src/commands/show.rs. 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 crates/ai-memory-cli/src/commands/api_key.rs:228— `!trimmed.eq_ignore_ascii_case("y") && !trimmed.eq_ignore_ascii_case("yes") && !trimmed.eq_ignore_ascii_case("s") && !trimmed.eq_ignore_ascii…` appears character-identically in 2 files — crates/ai-memory-cli/src/commands/api_key.rs, crates/ai-memory-cli/src/commands/user.rs. 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 crates/ai-memory-cli/src/commands/serve.rs:622— `Path::new("/.dockerenv").exists() || Path::new("/run/.containerenv").exists()` appears character-identically in 2 files — crates/ai-memory-cli/src/commands/serve.rs, crates/ai-memory-wiki/src/backup.rs. 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 companions/ai-memory-importer/src/agentmemory/export.rs:409— `args.apply && args.manifest_out.is_none()` appears character-identically in 2 files — companions/ai-memory-importer/src/agentmemory/export.rs, companions/ai-memory-importer/src/claude_mem.rs. 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 crates/ai-memory-hooks/src/router.rs:6274— `body.ends_with('?') || body.ends_with('?')` appears character-identically in 2 files — crates/ai-memory-hooks/src/router.rs, crates/ai-memory-hooks/src/session_end_equivalence.rs. 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 crates/ai-memory-hooks/src/session_end_equivalence.rs:180— `candidate.trim() == SUBAGENT_PROMPT_PREAMBLE || looks_like_scaffolding(candidate)` appears character-identically in 2 files — crates/ai-memory-hooks/src/session_end_equivalence.rs, crates/ai-memory-hooks/src/synth.rs. 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 crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:125— `cfg.max_selected_observations == 0 || cfg.max_total_chars == 0` appears character-identically in 2 files — crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs, crates/ai-memory-consolidate/src/projection.rs. 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 crates/ai-memory-cli/src/commands/install_mcp.rs:609— `config.server_url_configured() || config.server_url_derived_from_bind` appears character-identically in 2 files — crates/ai-memory-cli/src/commands/install_mcp.rs, crates/ai-memory-cli/src/commands/run.rs. 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 crates/ai-memory-cli/src/commands/restore.rs:694— `entry_type.is_file() || entry_type == tar::EntryType::GNUSparse` appears character-identically in 2 files — crates/ai-memory-cli/src/commands/restore.rs, crates/ai-memory-cli/src/commands/upgrade.rs. 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 crates/ai-memory-cli/src/commands/restore.rs:701— `entry_type.is_symlink() || entry_type.is_hard_link()` appears character-identically in 2 files — crates/ai-memory-cli/src/commands/restore.rs, crates/ai-memory-cli/src/commands/upgrade.rs. 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 companions/ai-memory-importer/src/mcp.rs:509— `error.get("code").and_then(Value::as_i64) != Some(INVALID_REQUEST) || data.get("reason").and_then(Value::as_str) != Some("precondition_faile…` appears character-identically in 2 files — companions/ai-memory-importer/src/mcp.rs, companions/ai-memory-wikisync/src/mcp.rs. 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 crates/ai-memory-cli/src/commands/codex_hook_trust.rs:89— `error.kind() == std::io::ErrorKind::ExecutableFileBusy && attempt < ATTEMPTS` appears character-identically in 2 files — crates/ai-memory-cli/src/commands/codex_hook_trust.rs, crates/ai-memory-cli/src/commands/opencode_dialect.rs. 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 crates/ai-memory-cli/src/commands/show.rs:571— `first.is_ascii_lowercase() || first.is_ascii_digit()` appears character-identically in 2 files — crates/ai-memory-cli/src/commands/show.rs, crates/ai-memory-cli/src/server_profiles.rs. 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 crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs:552— `first_line.starts_with("tool_family:") || first_line.starts_with("tool:")` appears character-identically in 2 files — crates/ai-memory-consolidate/src/consolidator_frozen_oracle.rs, crates/ai-memory-consolidate/src/projection.rs. 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 crates/ai-memory-cli/src/commands/run.rs:10355— `hooks_json.contains("ai-memory") || hooks_json.contains("ai_memory")` appears character-identically in 2 files — crates/ai-memory-cli/src/commands/run.rs, crates/ai-memory-cli/src/commands/run_autowire.rs. 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 crates/ai-memory-cli/src/commands/restore.rs:704— `is_regular_file(entry_type) || entry_type.is_dir()` appears character-identically in 2 files — crates/ai-memory-cli/src/commands/restore.rs, crates/ai-memory-cli/src/commands/upgrade.rs. 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.
Silent fallback default on Err crates/ai-memory-cli/src/commands/hook.rs:3097— `child_directories` turns every `Err` into `Some(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 crates/ai-memory-cli/src/commands/jail_folders.rs:258— `list` 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 crates/ai-memory-cli/src/http_client.rs:292— `identity` turns every `Err` into `"<invalid-server-url>".to_owned()` — 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 crates/ai-memory-cli/src/commands/doctor/hermes.rs:109— `approvals` 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 crates/ai-memory-cli/src/commands/hook_capture.rs:645— `hook_scope_from_selection` turns every `Err` into `Some("invalid".to_owned())` — 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 crates/ai-memory-cli/src/commands/hook_capture.rs:736— `marker_query_suffix_impl` 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.
Silent fallback default on Err crates/ai-memory-cli/src/commands/hook_capture.rs:938— `build_client` turns every `Err` into `reqwest::Client::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 crates/ai-memory-cli/src/commands/hook_spool.rs:196— `spool_health` turns every `Err` into `SpoolHealth::default()` — 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 crates/ai-memory-cli/src/commands/session_usage.rs:517— `claude_subagent_transcripts` 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 crates/ai-memory-cli/src/commands/show.rs:696— `humanize_age` turns every `Err` into `"unknown activity".to_owned()` — 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 crates/ai-memory-cli/src/commands/workstreams.rs:263— `humanize_age` turns every `Err` into `"unknown activity".to_owned()` — 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 crates/ai-memory-cli/src/http_client.rs:363— `display_url` turns every `Err` into `"an unparsable URL".to_owned()` — 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 crates/ai-memory-cli/src/http_client.rs:412— `http_client` turns every `Err` into `reqwest::Client::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 crates/ai-memory-store/src/workstream.rs:997— `link_native_session` turns every `Err` into `Ok(false)` — 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 crates/ai-memory-test-support/src/lib.rs:92— `dead_http_endpoint` turns every `Err` into `"http://127.0.0.1:1".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 crates/ai-memory-workstream/src/transcript.rs:5110— `antigravity_brain_prompt_events` 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 evals/src/retrieval/server.rs:196— `stderr_snapshot` turns every `Err` into `"(stderr capture poisoned)".into()` — 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.
Interpolated log message defeats structured logging evals/src/retrieval/dataset.rs:174— `info!` at line 174 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Interpolated log message defeats structured logging evals/src/retrieval/mod.rs:746— `error!` at line 746 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `error!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Interpolated log message defeats structured logging crates/ai-memory-store/src/lib.rs:286— `warn!` at line 286 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Interpolated log message defeats structured logging crates/ai-memory-mcp/src/admin.rs:9153— `warn!` at line 9153 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Interpolated log message defeats structured logging crates/ai-memory-hooks/src/router.rs:6520— `warn!` at line 6520 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Interpolated log message defeats structured logging crates/ai-memory-hooks/src/router.rs:6523— `debug!` at line 6523 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Interpolated log message defeats structured logging crates/ai-memory-cli/src/proxy_env.rs:35— `warn!` at line 35 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Interpolated log message defeats structured logging crates/ai-memory-cli/src/commands/service_host.rs:373— `error!` at line 373 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `error!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
Partial audit-trail evidence — An audit mechanism is present, but the trail is not yet complete — missing: a write-side hook every change flows through (a SeaORM ActiveModelBehavior hook or a database trigger recording each change, or an event-sourced store), per-entity coverage (an event-sourced aggregate, or a hook on each entity that needs a who-changed-what trail).
Off-boarding risk: anonymized user #1 — If anonymized user #1 becomes unavailable, 18 significant file(s) lose their only recent owner: crates/ai-memory-cli/src/commands/setup_web.rs, evals/src/retrieval/reachability.rs, crates/ai-memory-cli/src/commands/agentmemory_residue.rs, evals/src/retrieval/ingest.rs, companions/ai-memory-ts/src/transport.ts, crates/ai-memory-cli/src/commands/render_plugins.rs, crates/ai-memory-wiki/src/confinement.rs, crates/ai-memory-llm/src/local.rs (+10 more). Pair on, review, or document these before any departure.
D16 · Bus Factor· Further sole-owners (lower concentration) · ×1
Further sole-owners (lower concentration) — 6 other contributor(s) are each the sole owner of a small amount of code below the off-boarding threshold — folded into the bus-factor score and metrics (25 single-owned of 371 analysed files in total, counted over production source files of roughly 2,400 bytes or more, excluding vendored, generated, example/demo and scaffolding-template trees and test files identified by path convention, largest first; 371 of the 406 production source files in this repository met that bar). They are anonymized user #2 (2 file(s)), anonymized user #3 (1 file(s)), anonymized user #4 (1 file(s)), anonymized user #5 (1 file(s)), anonymized user #6 (1 file(s)), anonymized user #7 (1 file(s)) — spread or document their files in the same way, at lower priority than the named off-boarding risks above. The files folded here: companions/ai-memory-relay/src/identity.rs, companions/ai-memory-relay/src/ack.rs, crates/ai-memory-hooks/src/brief_tiers.rs, crates/ai-memory-consolidate/src/compaction.rs, crates/ai-memory-consolidate/src/prompt_template.rs, crates/ai-memory-core/src/agent_backup.rs, crates/ai-memory-cli/src/commands/data_purge.rs.
D26 · Project Cohesion· Projects may be oversized for their cohesion · ×1
Projects may be oversized for their cohesion — 3 of 19 project(s) overshoot their size bounds, lowering Project Cohesion to 6.8/10. The most over is `crates/ai-memory-cli` (155118 LoC, 311 module-visible types across 5 directories). Review these for cohesion — draw the boundary inside the module first (group each responsibility into its own package or directory and keep the cross-boundary members non-public), since splitting a published package moves types between packages and breaks consumers.
D30 · Dependency Vulnerabilities· Medium advisory (unmaintained) · ×1
M2 · Architecture documentation· ADRs not easily discoverable · ×1
ADRs not easily discoverable — 2 ADR-shaped document(s) detected by content — `docs/design-decisions.md`, `plugins/claude-code/skills/ai-memory-durable-pages/SKILL.md`. They are not under a conventional ADR folder (docs/adr/) and are not named NNNN-title.md, and this check found them by their decision signature rather than by where they live — so a reader who does not already know these paths has no route to them. Detected by content signature only: records kept outside the repository, or written without a Status/Decision/Consequences shape, are not visible to this check and are not counted here.
Logging is not universal — Only 10/16 runnable modules use logging (modules with no entry point or server are excluded — they are libraries a runnable module hosts). Silent: `companions/ai-memory-desktop`, `companions/ai-memory-importer`, `companions/ai-memory-macos`, `companions/ai-memory-relay`, `companions/ai-memory-wikisync` and 1 more.
P3 · Security & performance tooling· Dependabot does not watch npm/cargo · ×1
Dependabot does not watch npm/cargo REDACTED:2— `REDACTED` schedules updates, but no `package-ecosystem` entry covers `npm`, `cargo`, which this tree depends on — so those dependencies get no update pull requests and no advisory pressure, however complete the dep-scan credit looks. Add the missing entries to the `updates:` list.
No security response headers detected docker/multiuser-test/nginx.conf:21— None of the 11 security response headers the OWASP Secure Headers Project recommends (Content-Security-Policy, Strict-Transport-Security, X-Content-Type-Options, X-Frame-Options, …) is configured — defense in depth, even when a reverse proxy could set them. This is reported because `nginx.conf` is committed to this repository and declares the server that serves it, so the configuration that would carry these headers is in this repository and was read in full. (−2.0 on this card.)
Outdated: anyhow — `anyhow` is locked at 1.0.103 but 1.0.104 is the current stable release on crates.io, and it already satisfies the `"1"` requirement declared in evals/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p anyhow` and commit the updated REDACTED.
Outdated: async-trait — `async-trait` is locked at 0.1.89 but 0.1.92 is the current stable release on crates.io, and it already satisfies the `"0.1"` requirement declared in crates/ai-memory-cli/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p async-trait` and commit the updated REDACTED.
Outdated: candle-core — `candle-core` is locked at 0.11.0 but 0.11.1 is the current stable release on crates.io, and it already satisfies the `"0.11"` requirement declared in crates/ai-memory-llm/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p candle-core` and commit the updated REDACTED.
Outdated: candle-nn — `candle-nn` is locked at 0.11.0 but 0.11.1 is the current stable release on crates.io, and it already satisfies the `"0.11"` requirement declared in crates/ai-memory-llm/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p candle-nn` and commit the updated REDACTED.
Outdated: candle-transformers — `candle-transformers` is locked at 0.11.0 but 0.11.1 is the current stable release on crates.io, and it already satisfies the `"0.11"` requirement declared in crates/ai-memory-llm/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p candle-transformers` and commit the updated REDACTED.
Outdated: clap — `clap` is locked at 4.6.1 but 4.6.7 is the current stable release on crates.io, and it already satisfies the `"4"` requirement declared in evals/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p clap` and commit the updated REDACTED.
Outdated: clap_complete — `clap_complete` is locked at 4.6.7 but 4.6.11 is the current stable release on crates.io, and it already satisfies the `"4"` requirement declared in crates/ai-memory-cli/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p clap_complete` and commit the updated REDACTED.
Outdated: flate2 — `flate2` is locked at 1.1.9 but 1.1.11 is the current stable release on crates.io, and it already satisfies the `"1"` requirement declared in crates/ai-memory-cli/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p flate2` and commit the updated REDACTED.
Outdated: futures-util — `futures-util` is locked at 0.3.32 but 0.3.34 is the current stable release on crates.io, and it already satisfies the `"0.3"` requirement declared in crates/ai-memory-wiki/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p futures-util` and commit the updated REDACTED.
Outdated: http — `http` is locked at 1.4.0 but 1.5.0 is the current stable release on crates.io, and it already satisfies the `"1"` requirement declared in crates/ai-memory-cli/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p http` and commit the updated REDACTED.
Outdated: icu_normalizer — `icu_normalizer` is locked at 2.2.0 but 2.4.0 is the current stable release on crates.io, and it already satisfies the `"2"` requirement declared in crates/ai-memory-consolidate/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p icu_normalizer` and commit the updated REDACTED.
Outdated: jiff — `jiff` is locked at 0.2.24 but 0.2.44 is the current stable release on crates.io, and it already satisfies the `"0.2"` requirement declared in evals/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p jiff` and commit the updated REDACTED.
Outdated: libc — `libc` is locked at 0.2.186 but 0.2.191 is the current stable release on crates.io, and it already satisfies the `"0.2"` requirement declared in companions/ai-memory-importer/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p libc` and commit the updated REDACTED.
Outdated: notify — `notify` is locked at 8.2.0 but 8.2.2 is the current stable release on crates.io, and it already satisfies the `"8"` requirement declared in crates/ai-memory-wiki/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p notify` and commit the updated REDACTED.
Outdated: regex — `regex` is locked at 1.12.3 but 1.13.1 is the current stable release on crates.io, and it already satisfies the `"1"` requirement declared in companions/ai-memory-client/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p regex` and commit the updated REDACTED.
Outdated: rmcp — `rmcp` is locked at 3.9.0 but 3.10.0 is the current stable release on crates.io, and it already satisfies the `"3.9"` requirement declared in crates/ai-memory-cli/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p rmcp` and commit the updated REDACTED.
Outdated: schemars — `schemars` is locked at 1.2.1 but 1.2.3 is the current stable release on crates.io, and it already satisfies the `"1"` requirement declared in evals/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p schemars` and commit the updated REDACTED.
Outdated: serde — `serde` is locked at 1.0.228 but 1.0.229 is the current stable release on crates.io, and it already satisfies the `"1"` requirement declared in evals/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p serde` and commit the updated REDACTED.
Outdated: serde_json — `serde_json` is locked at 1.0.150 but 1.0.154 is the current stable release on crates.io, and it already satisfies the `"1"` requirement declared in evals/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p serde_json` and commit the updated REDACTED.
Outdated: socket2 — `socket2` is locked at 0.6.3 but 0.6.5 is the current stable release on crates.io, and it already satisfies the `"0.6.3"` requirement declared in crates/ai-memory-cli/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p socket2` and commit the updated REDACTED.
Outdated: tokio-util — `tokio-util` is locked at 0.7.18 but 0.7.20 is the current stable release on crates.io, and it already satisfies the `"0.7"` requirement declared in crates/ai-memory-cli/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p tokio-util` and commit the updated REDACTED.
Outdated: unicode-width — `unicode-width` is locked at 0.2.2 but 0.2.3 is the current stable release on crates.io, and it already satisfies the `"0.2"` requirement declared in crates/ai-memory-cli/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p unicode-width` and commit the updated REDACTED.
Outdated: uuid — `uuid` is locked at 1.23.1 but 1.29.2 is the current stable release on crates.io, and it already satisfies the `"1"` requirement declared in evals/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p uuid` and commit the updated REDACTED.
doc comments repeat the names companions/ai-memory-ts/src/admin.ts:77— 0 of 0 documented parameters and 58 of 756 summaries in `ai-memory-ts` only repeat the member or parameter name (e.g. "Result of ." for `RestorePageResult`). Delete the restating tags, or add what the name does not say.
Appendix B — Reproduction & audit trail
Every external tool invocation behind a deep-scan dimension — the tool, its captured version, the exact command, how many findings it yielded, and a link to the retained raw output. To reproduce any finding: check out the same commit and run the command shown (repo-relative — never an absolute scratch path). The complete raw scanner output is retained verbatim under artifacts/raw/ (indexed in artifacts/raw/index.json); per-invocation exit codes and wall-clock durations are in sidecar.json — kept out of this table so the rendered report stays byte-identical across runs of the same commit.
semgrep: not applicable — No personal data was found crossing a boundary the PII/GDPR ruleset checks — nothing written to a log or console sink, placed in a URL or query string, or persisted to browser storage. That is a clean result for the LEAK surface only: this ruleset detects personal data escaping, it does not inventory the personal data a repository holds, so it is not evidence that this repository has no personal-data surface. The personal-data map (Appendix C) and the C1-C5 compliance cards are what speak to that. semgrep could not parse 2 file(s) — `companions/ai-memory-ts/src/index.ts`, `companions/ai-memory-ts/src/types.ts` — so the PII/GDPR sweep did not cover the unparsed regions of them; rows reported elsewhere in those files are real.
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.
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.
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.
Run 01a1db3a-2b3b-71fe-a77e-97033e9c67d1 · every finding is also locatable in findings.md, and the complete scoring record (with exit codes + durations) in sidecar.json.
Issues: 21 · Warnings: 1621 · Recommendations: 76 · Info: 24 — Appendix A · all findings · full markdown report.
Generated by the Canine Code Analyzer: deterministic code-health analysis. 14-11-2026 @ 18:03 UTC.
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.