MESHTEN LAB•Agent Governance & Safety
November 3, 2026•Flagship Benchmark

1,610 Commits in 5 Days, Then an Untouched 27k-Line Monolith: Three-Tier Verification for Multi-Agent Refactors

Across a 5-day internal overhaul (1,610 commits, 3,090 files, 4,924 permission checks collapsed into 1 pure function) and an external replication on FlaskBB (27,039 lines, 800 tests, 17 oversized modules reduced to 0 across 72 split files), a three-tier verification plane caught 10 classes of refactor defects—including three untested error-branch NameErrors and three missing ORM equality decorators that all 800 unit tests missed.

Core Finding:Over five days (October 29 to November 3, 2026), we executed 1,610 verified commits across 3,090 files in our own multi-tenant production software: decomposing a 9,790-line monolith into bounded domain submodules so parallel agents could work in one repository without file-lock contention, and collapsing 5 disagreeing permission layers (4,924 scattered decision points) into 1 pure authorization function backed by 883 declarative operation rows and 43,005 verified access cells, cutting p50 authorization latency by 51.9% (128.7 ms to 61.9 ms). To test whether the same mechanical refactor pipeline held up on unfamiliar outside code, we pointed it at an untouched open-source Python application (FlaskBB at commit 737d76f1: 27,039 application lines across 144 Python modules, 800 passing tests, and 17 oversized modules totaling 9,322 code lines and 13,262 physical lines). Up to eight concurrent single-file agent workers decomposed all 17 oversized modules into 72 cohesive files (17 modified entrypoints + 55 new files, expanding the application tree from 144 to 199 modules and cutting peak module size by 82.2%, from 1,391 to 247 code lines) while preserving 100% test parity (800 passed, 0 failed in 12.80s). Across the FlaskBB run, our three-tier verification plane caught and resolved 10 distinct classes of agent-introduced defects before sealing the branch at commit 274427b. Most importantly, after all 800 upstream unit and end-to-end tests passed, cross-model adversarial review caught 3 latent NameError missing imports hiding inside untested error and permission-denial branches (including a lambda wrapped inside a third-party decorator), and our deterministic contract verifier caught 3 SQLAlchemy models where equality comparison contracts had been silently dropped—defects that both the 800-test suite and standard static linters had missed.

5-Day Internal Overhaul

1,610 commits, 3,090 files

Collapsed 4,924 scattered permission checks into 1 pure function (43,005 verified access cells) and cut p50 auth latency by 51.9% (128.7 ms to 61.9 ms).

External Monolith Split (FlaskBB)

17 -> 0 oversized files

All 17 oversized modules in FlaskBB (9,322 code lines / 13,262 physical lines) decomposed into 72 files (+55 new; 144 -> 199 total modules; peak size cut 82.2%).

Upstream Test Suite Parity

800 passed, 0 failed

100% behavioral parity across all 800 upstream FlaskBB unit and end-to-end tests in 12.80s, with 16/17 runtime equivalence PASS and 1 procedural migration split.

Pre-Merge Defect Classes Caught

10 catches across 3 tiers

Caught compiler directive drift, pytz.UTC identity swaps, monkeypatch breaks, 3 untested error-branch NameErrors, and 3 missing @make_comparable ORM decorators.

Empirical Findings Table

Internal 5-day consolidation telemetry (1,610 commits) and external FlaskBB decomposition results (17/17 monoliths split into 72 files, 800/800 tests passing, 10 defect classes caught).
Telemetry MetricMeasured ValueContext & Observability
Internal Sprint Throughput1,610 commits, 3,090 filesExecuted between October 29 and November 3, 2026 across Core and application repositories, backed by 2,360+ formal verification receipts.
Authorization Consolidation4,924 -> 1 pure functionCollapsed 5 disagreeing permission layers into 1 pure Core decision function governing 883 declarative operations across 43,005 verified access and CRUD cells.
Authorization Latency Reduction-51.9% p50 (128.7 ms -> 61.9 ms)Cut Core RPCs per auth resolution from 2 to 1 (-50%), document reads from 170 to 86 (-49.4%), SQL SELECTs from 9 to 4 (-55.6%), and p95 latency from 195.8 ms to 154.0 ms.
External Monolith Census (FlaskBB)17 -> 0 oversized filesDecomposed all 17 oversized modules (9,322 code lines / 13,262 physical lines) into 72 files (+55 new, taking flaskbb/ from 144 to 199 modules) with peak module size cut from 1,391 to 247 code lines (-82.2%).
External Test & Equivalence Parity800 passed, 0 failed (16/17 PASS)Full 800-test upstream FlaskBB suite passed in 12.80s; 16 of 17 splits passed full runtime equivalence and 1 single-function Alembic migration passed procedural + 19-test migration verification.
Pre-Merge Defect Classes Caught10 catches across 3 tiersCaught across Tier-1 equivalence verification, Tier-2 full-suite pytest integration, and Tier-3 cross-model review (with Catch #9 promoted into Tier 1, uncovering Catch #10).

Engineering Action Directives

DO

Enforce a strict per-module size ceiling so parallel agents can own disjoint files in a single worktree without merge collisions.

DON'T

Run parallel coding agents against 1,000+ line monoliths where every task collides on the same file.

DO

Verify export equivalence, public contract parity, and scope integrity deterministically in Tier 1.

DON'T

Claim a green test suite proves zero defects: 800 passing FlaskBB tests missed 3 missing imports in unexercised error branches and 3 dropped model comparison contracts.

DO

When review detects a defect pattern that slipped past standard checks, harden the deterministic verification gate with a regression rule permanently.

DON'T

Rely solely on non-deterministic model review for mechanical errors like missing imports or dropped class contracts.

Methodology Boundaries & Limits

  • **Language Generalizability & The Hardest Frontier.** Dynamic languages like Python represent the most difficult testing ground for automated multi-agent refactoring because of runtime monkeypatching and dynamic attribute lookup. In statically typed and compiled languages (TypeScript, Go, Rust), language compilers (tsc, go vet, cargo check) already enforce type, interface, and symbol parity natively, making the three-tier verification architecture even more direct to adopt across multi-language enterprise codebases.
  • **Procedural Single-Function Refactoring.** Massive procedural functions (such as monolithic database schema migrations) cannot be decomposed without delegating statements to structured helpers. In these workflows, the verification plane transitions from raw lexical parity to module contract validation and dedicated migration integration suites (19/19 passing).
  • **Dynamic monkeypatch delegation adds thin wrapper indirection.** When upstream tests monkeypatch attributes directly on a monolith entrypoint rather than the defining module, preserving 100% test compatibility without editing upstream tests requires thin runtime lookup wrappers in the extracted submodules.