You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Location fix (the material one). The body located process_module_intrinsic_opts and process_module in build.rs. Both are actually in crates/mds-core/src/resolver.rs. Phase 1 was therefore scoped as a build.rs-only phase; it is not — it spans both files.
Function sizes corrected.run_build 265 -> 348 L; process_module_intrinsic_opts 163 -> 203 L; process_module 128 -> 355 L. process_module nearly tripled against the recorded figure and is now the largest of the three.
Sequencing constraint recorded: this issue is scheduled strictly last among all waves.
The title still carries the pre-rescope figures (2518L / 1964L). This pass edits bodies only; the body is authoritative.
Figures not listed above (the six #[allow(clippy::too_many_arguments)] annotations, the watch.rs context-struct line references) were not re-measured in this pass and should be re-checked before Phase 3 starts.
Correction 2026-08-26 (6d41777) — one figure was materially wrong, not merely drifted:
process_module is 127 L, not 355 L. Measured crates/mds-core/src/resolver.rs:1006-1132. It was also 127 L at the 113f472 rescope baseline (measured 997-1123 in git show 113f472:crates/mds-core/src/resolver.rs), so the recorded "355 L / nearly tripled" claim was wrong when written — it is not drift. This materially over-sizes the Phase 1 decomposition being proposed:process_module is not the largest of the three and may not warrant extraction at all under the <= 80 L criterion.
run_build 348 -> 335 L (crates/mds-cli/src/build.rs:1081-1415; cited :1051 is stale).
process_module_intrinsic_opts 203 -> 198 L (crates/mds-core/src/resolver.rs:777-974; cited :768 is stale).
#[allow(clippy::too_many_arguments)] count in watch.rs/error.rs is 4, not 6 — watch.rs:1039, watch.rs:1951, watch.rs:2316, error.rs:576. (A fifth exists at crates/mds-python/src/lib.rs:464, outside Phase 3 scope.) This figure was flagged "not re-measured" in the 2026-08-09 pass; it is now measured.
Scope, phasing, and acceptance criteria are unchanged.
Background
crates/mds-core/src/resolver.rs (2564 lines) and crates/mds-cli/src/build.rs (2071 lines) are the two largest files in the codebase. Both exceed the practical size threshold for safe incremental modification. Within each file, several functions have accumulated #[allow(clippy::too_many_arguments)] annotations (watch.rs/error.rs carry 4 pre-existing allows), and the three largest individual functions are:
Function
File
Size
run_build
crates/mds-cli/src/build.rs:1081-1415
335 L
process_module_intrinsic_opts
crates/mds-core/src/resolver.rs:777-974
198 L
process_module
crates/mds-core/src/resolver.rs:1006-1132
127 L — was recorded as 355 L; that figure was wrong
Neither is separately actionable — extracting either function without the surrounding decomposition just relocates the problem.
Problem
At 2564 lines, resolver.rs contains the compiler's resolution logic, import threading, type inference, span construction, and the two oversized module-processing functions (process_module, process_module_intrinsic_opts) in a single module. PR #196 threaded additional arguments through this module (+125 lines) without worsening structure, but the module is already past the upper bound of what can be safely modified without unintended coupling.
At 2071 lines, build.rs contains the CLI build driver, source-map construction, and output formatting interleaved, with run_build (335 L) as the driver.
Four pre-existing #[allow(clippy::too_many_arguments)] annotations in watch.rs and error.rs are the same category: functions that grew beyond the point where introducing a context struct is the obvious fix.
Sequencing constraint — this issue goes LAST
#223 is scheduled strictly last among all waves. It rewrites resolver.rs and build.rs wholesale. Every behavior fix that touches either file would have to be rebased across this decomposition if it landed first, so all such work ships before #223 starts, not after. Do not pull this forward to unblock anything — nothing is blocked by it.
Decomposing a 2500+-line resolver is a system restructure, not a refactor. It must be sequenced against ADR-005 sourcemap threading and ADR-001 formatter gate work that both run through these modules. Explicitly out of scope for a pre-release remediation branch.
Proposed approach
This is not a single PR — it is a phased decomposition:
Phase 2 — resolver.rs module split: separate resolution/import-threading from span-construction and type-inference. This needs design work first (ADR on module boundaries).
Phase 3 — watch.rs/error.rs context structs: replace #[allow(clippy::too_many_arguments)] functions with FileCompileCtx/DirWatchCtx structs (the pattern already introduced in watch.rs for the same reason — see issue Tech Debt Backlog #6 and PR fix: v0.4.0 remediation — dogfooding blockers, bug batch, UX polish, docs sweep #196 notes; re-locate those references before starting, they were not re-measured in this rescope).
Acceptance Criteria
Each phase has its own AC; tracked here as the umbrella:
Phase 1: all three oversized functions extracted — run_build out of build.rs, process_module and process_module_intrinsic_opts out of resolver.rs — each replaced by a unit of <= 80 lines
Phase 1: build.rs reduced to <= 500 lines with functions <= 80 lines each
Phase 2: resolver.rs split into at least 2 sub-modules; no single file exceeds 1000 lines
Phase 3: All #[allow(clippy::too_many_arguments)] in watch.rs/error.rs eliminated via context structs
Cargo test suite passes at each phase boundary
No #[allow(clippy::too_many_arguments)] added in any phase
Deferred from: PR #196 (identified as pre-existing, explicitly not in scope for remediation) Absorbs: CX-2 (#184), ISS-25 (#229) Note: This is a multi-sprint effort, scheduled last. Open sub-issues per phase as work begins.
Reference-corrected 2026-08-26 against main @ 6d41777 — locations and completion state only; scope and acceptance criteria unchanged.
Background
crates/mds-core/src/resolver.rs(2564 lines) andcrates/mds-cli/src/build.rs(2071 lines) are the two largest files in the codebase. Both exceed the practical size threshold for safe incremental modification. Within each file, several functions have accumulated#[allow(clippy::too_many_arguments)]annotations (watch.rs/error.rscarry 4 pre-existing allows), and the three largest individual functions are:run_buildcrates/mds-cli/src/build.rs:1081-1415process_module_intrinsic_optscrates/mds-core/src/resolver.rs:777-974process_modulecrates/mds-core/src/resolver.rs:1006-1132Ledger ID: #91 (
complexity-preexisting_oversized_modules)Originating reviewer: Complexity (pre-existing informational)
Absorbed items
This issue now subsumes two findings filed elsewhere against functions already in its scope:
process_module_intrinsic_optscrates/mds-core/src/resolver.rs:768run_buildcrates/mds-cli/src/build.rs:1051Neither is separately actionable — extracting either function without the surrounding decomposition just relocates the problem.
Problem
At 2564 lines,
resolver.rscontains the compiler's resolution logic, import threading, type inference, span construction, and the two oversized module-processing functions (process_module,process_module_intrinsic_opts) in a single module. PR #196 threaded additional arguments through this module (+125 lines) without worsening structure, but the module is already past the upper bound of what can be safely modified without unintended coupling.At 2071 lines,
build.rscontains the CLI build driver, source-map construction, and output formatting interleaved, withrun_build(335 L) as the driver.Four pre-existing
#[allow(clippy::too_many_arguments)]annotations inwatch.rsanderror.rsare the same category: functions that grew beyond the point where introducing a context struct is the obvious fix.Sequencing constraint — this issue goes LAST
#223 is scheduled strictly last among all waves. It rewrites
resolver.rsandbuild.rswholesale. Every behavior fix that touches either file would have to be rebased across this decomposition if it landed first, so all such work ships before #223 starts, not after. Do not pull this forward to unblock anything — nothing is blocked by it.Why deferred from PR #196
Decomposing a 2500+-line resolver is a system restructure, not a refactor. It must be sequenced against ADR-005 sourcemap threading and ADR-001 formatter gate work that both run through these modules. Explicitly out of scope for a pre-release remediation branch.
Proposed approach
This is not a single PR — it is a phased decomposition:
Phase 1 — Extract the three oversized functions.
run_build->BuildPipeline::run()inbuild.rs;process_module_intrinsic_opts->IntrinsicOpts::apply()andprocess_module->ModuleProcessor::process(), both out ofresolver.rs, notbuild.rs. These have clear seams. This phase closes CX-2 (Refactor oversized source-map core functions (CX-1, CX-2, CX-3) #184) and ISS-25 (build.rs DRY: consolidate embed_sources warnings and sidecar/stdout ladder duplication #229).Phase 2 —
resolver.rsmodule split: separate resolution/import-threading from span-construction and type-inference. This needs design work first (ADR on module boundaries).Phase 3 —
watch.rs/error.rscontext structs: replace#[allow(clippy::too_many_arguments)]functions withFileCompileCtx/DirWatchCtxstructs (the pattern already introduced inwatch.rsfor the same reason — see issue Tech Debt Backlog #6 and PR fix: v0.4.0 remediation — dogfooding blockers, bug batch, UX polish, docs sweep #196 notes; re-locate those references before starting, they were not re-measured in this rescope).Acceptance Criteria
Each phase has its own AC; tracked here as the umbrella:
run_buildout ofbuild.rs,process_moduleandprocess_module_intrinsic_optsout ofresolver.rs— each replaced by a unit of <= 80 linesbuild.rsreduced to <= 500 lines with functions <= 80 lines eachresolver.rssplit into at least 2 sub-modules; no single file exceeds 1000 lines#[allow(clippy::too_many_arguments)]inwatch.rs/error.rseliminated via context structs#[allow(clippy::too_many_arguments)]added in any phaseDeferred from: PR #196 (identified as pre-existing, explicitly not in scope for remediation)
Absorbs: CX-2 (#184), ISS-25 (#229)
Note: This is a multi-sprint effort, scheduled last. Open sub-issues per phase as work begins.