Track 11 — External Brownfield OSS Renovation Crucible (jezz renovate --ratchet)¶
1. Objective & Engineering Motivation¶
Tracks 2 and 8 audited 7.71M LOC of external Python, TypeScript, Rust, and Go repositories in read-only inspection mode, while Tracks 5 and 9 validated jezz renovate on self-contained workspaces where the entire repository reached 0 violations. Real-world open-source adoption, however, rarely permits rewriting 700 legacy modules in one commit: brownfield onboarding requires surgical, scope-isolated renovation where touched files achieve full Jezz Software Building Code (JBC Edition 1.2) occupancy (or formally time-bounded CodeVariance waivers) while untouched legacy debt remains strictly isolated and whole-graph cyclic/encapsulation invariants (JBC-COG-003) are preserved.
Track 11 implements the Differential Final Occupancy Ratchet (jezz renovate --ratchet) and validates it end-to-end against three external open-source repositories across Go (go-chi/chi), Rust (serde-rs/json), and Python (github/spec-kit — 291,626 LOC).
2. Architectural Extensions¶
- Differential Final Occupancy Gate (
inspect_differential_final,src/jezz/codes/ratchet.py): - Evaluates per-unit
JBCv1.2 static rules strictly overDifferentialScope.changed_paths, runs whole-graphJBC-COG-003Tarjan SCC cycle and encapsulation analysis across the complete repository filtered tochanged_paths, and appends dynamic compiler/suite attestations (JBC-VRF-005&JBC-VRF-006) to issue a true FinalInspectionReport(APPROVED,APPROVED_WITH_VARIANCES, orRED_TAG) without falseRED_TAGblockers from untouched legacy modules. - Ratchet-Scoped
PceWorkflowOrchestrator&EngineeringDossierSeal (src/jezz/agents/nodes.py,src/jezz/methodology/dossier.py,src/jezz/cli.py): - Added
PceRuntimeBudget.ratchet_to_scope: bool = False,EngineeringDossier.ratchet_scoped: bool = False, and CLI flagjezz renovate --ratchet(persisted automatically by--write-dossier). - When enabled,
InspectCodeNode(BHV-04),VerifyStaticNode(BHV-18),VerifyDynamicNode(BHV-19), andCertifyNode(BHV-21) enforce differential occupancy overmandate.authorized_files() | sandbox.modified_files, whileCertificateOfOccupancyhashes only the scoped slice (audit_pce_dossierindependently recomputes and verifies the scoped SHA-256 digest against the full repository AST/CST symbol set). UvSubprocessGateRunnerscopesmypyunder--ratchetviauv run mypy --follow-imports=silent <authorized_py_files>so upstream type debt in untouched sibling modules does not block surgical Python renovations.
3. Empirical Calibrations Surfaced on External Monorepos (Calibrations 11A–11C)¶
Executing jezz renovate --ratchet against serde-rs/json and 291,626-LOC github/spec-kit surfaced three real-world monorepo calibrations, all locked in by permanent regression tests (tests/test_track11_differential_renovation.py):
| Calibration | Root Cause Surfaced | Architectural Fix |
|---|---|---|
11A — Monorepo Unit Ceilings & Safe ValidationError Formatting |
github/spec-kit contains 700 Python units, exceeding Field(max_length=512) on find_type_alias_misuse (workspace.py) and compute_structural_health (verifier.py). Formatting str(exc) on the resulting ValidationError attempted to serialize SourceUnit.tree (ast.Module). |
Widened workspace unit/symbol ceilings to 100,000 / 200,000 (workspace.py, ast_graph.py, verifier.py) and added _format_cli_exception (cli.py) using exc.errors(include_input=False, include_context=False). |
11B — Rust Inline-Module (mod { use super::*; }) Lexical Scope Resolution |
In serde-rs/json's src/lexical/math.rs, inline submodules mod small { use super::*; } and mod large { use super::*; } resolved super::* against the file's lexical.math path rather than lexical.math.small, fabricating a false lexical <-> ... <-> lexical.math cycle. |
Added _enclosing_inline_mod_names, _effective_rs_module, and multi-super:: resolution in src/jezz/codes/polyglot_rust.py, resolving use super::*; inside mod small accurately to lexical.math. |
11C — Referentially Transparent Unit Memoization & Differential Rough-In Preview |
On github/spec-kit (291,626 LOC, 32,419 baseline violations), _tool_preview_rough_in and _parse_and_rough_in_check re-parsed all 700 files and ran full-repo 29-rule inspect_rough_in (>12s), exceeding FunctionToolset(timeout=10.0). |
Added @functools.lru_cache(maxsize=8192) on immutable _parse_cached_source_unit (discovery.py), switched preview/validator cross-module checks to inspect_differential_rough_in, and raised toolset timeouts to 30.0s — cutting warm preview latency on spec-kit to 1.61s (0.09s warm unit load). |
4. Live External OSS Crucible Results (3 / 3 Certified & OCCUPANCY_SEALED)¶
All three probes executed via jezz renovate --ratchet using symmetric tiered routing (--architect-model google:gemini-4-hydrogen --builder-model google:gemini-3.8-flash) with real ecosystem static/dynamic compilers (go vet + go test ./..., cargo check --all-targets + cargo test, mypy + pytest) followed by independent out-of-band jezz inspect --changed-since HEAD and jezz audit dossier.json verification:
| Probe | Repository & Commit | Language & Total Units | Baseline Repo \(\to\) Post-Renovation Violations | Target Scope Violations (Before \(\to\) After) | Ruling & Seal | Requests / Tools / Latency | Cache Hit Ratio (cache_read / input) |
|---|---|---|---|---|---|---|---|
11A_go_chi |
go-chi/chi @ c64ed7d663 |
Go (90 units, 88 untouched) |
266 \(\to\) 261 (-5) |
5 \(\to\) 0 unwaived (0 waived) |
APPROVED / OCCUPANCY_SEALED (76a9e711...) |
15 reqs / 13 tools / 238.92s |
79.0% (194,080 / 245,758) |
11B_serde_json |
serde-rs/json @ f51fa15a70 |
Rust (61 units, 58 untouched) |
269 \(\to\) 256 (-13) |
18 \(\to\) 0 unwaived (5 waived via CodePermit) |
APPROVED_WITH_VARIANCES / OCCUPANCY_SEALED (d2e2da81...) |
11 reqs / 9 tools / 201.70s |
79.8% (218,165 / 273,369) |
11C_github_spec_kit |
github/spec-kit @ a55782f1f1 |
Python (700 units, 699 untouched) |
32,419 \(\to\) 32,403 (-16) |
16 \(\to\) 0 unwaived (0 waived) |
APPROVED / OCCUPANCY_SEALED (20b92409...) |
17 reqs / 15 tools / 312.56s |
76.9% (201,284 / 261,896) |
Surgical Diff Highlights¶
go-chi/chi(middleware/basic_auth.go,middleware/strip.go—+25 / -0lines):- Remediated
5JBC-DBC-004/005boundary hazards while preserving exact public signatures (BasicAuth,StripSlashes,RedirectSlashes,StripPrefix) and100%upstreamgo test ./...compatibility—including CRLF header-injection (\r\n), empty-realm,maxBasicAuthRealmLen = 256, andmaxBasicAuthCreds = 10000guards inBasicAuth. serde-rs/json(build.rs,src/lexical/bignum.rs,src/lexical/algorithm.rs—+37 / -36lines):- Upgraded
build.rsfromfn main()with6LIFE_SAFETY.unwrap()panics (JBC-DBC-003) tofn main() -> Result<(), Box<dyn std::error::Error>>propagatingOUT_DIR/CARGO_CFG_*/fs::writeerrors via.ok_or(...)?and?; replaced6wildcarduse super::...::*;imports (JBC-COG-003) with explicit item imports; flattenedfast_path's 4-branchelse ifladder (JBC-COG-004) into early guard returns; and exercisedPERMIT-SERDE-LEXICAL-11B(VAR-SERDE-BUILDRS-STDOUT-01for Cargo's mandatoryprintln!("cargo:...")stdout protocol andVAR-SERDE-NOSTD-IMPORT-01forno_std + alloc#[allow(unused_imports)]) to sealAPPROVED_WITH_VARIANCES. github/spec-kit(src/specify_cli/workflows/expressions/operators.py—+41 / -21lines):- Renovated GitHub
spec-kit's own workflow expression operator module (16baseline violations) without addingjezzas a runtime dependency: eliminated all12Anytype erasions (JBC-DBC-002) and all4# type: ignore[operator]suppressions (JBC-VRF-004) via explicitobjecttyping,isinstance(right, (Container, Iterable))narrowing, and typed_compare_numbers/_compare_stringshelpers, passing all497upstream expression unit tests and strictmypy.