v11.3.1 — SYMBOL_REPLACE_LIMIT empirical recalibration
Summary
Empirical recalibration of NREKI's mode:"replace" symbol-size cap. Default raised from 40 L → 100 L, now configurable via NREKI_SYMBOL_LIMIT env override.
The legacy 40 L value was introduced in v9.1 (commit 3661c31) as a magic number with no measurement. v11.3.1 replaces it with a value derived from a 2 880-function empirical study.
Why
Phase 1 measurement across 5 production TypeScript codebases (NREKI src/, zod, ajv, eventsource, ajv-formats):
| Threshold | % real-world functions blocked | % NREKI's own src/ blocked |
|---|---|---|
| 40 L (legacy) | 10.45% | 19.06% (self-inconsistency) |
| 80 L | 4.20% | 8.01% |
| 100 L (new default) | 3.02% | 5.52% |
Aggregate p95 of real functions = 66 L; p99 = 146 L. The 40 L cap was rejecting legitimate medium-sized functions (the user's reported case: 55 L processText).
NREKI's 10 other defense-in-depth gates (anti-sweep shield, kernel TS validation, TTRD, blast radius, Fiedler bridge, Chronos friction, auto-backup, ACID, file lock, topology invalidate) continue to detect every defect class the size-only gate was incidentally catching. Raising 40 → 100 weakens no defect-detection gate.
Changes
SYMBOL_REPLACE_LIMIT— central named constant insrc/limits.ts, replacing the magic40insrc/semantic-edit.ts:638(batch) andsrc/semantic-edit.ts:1029(single).NREKI_SYMBOL_LIMITenv — integer 1..1000, clamps at the ceiling, warns + falls back on parse failure (never silently disables the gate). Backward-compat for legacy 40 L behavior:NREKI_SYMBOL_LIMIT=40.- Error message now reports the active threshold and the env override path.
- Templates (
CLAUDE.md,AGENTS.md,SKILL.md) updated to document the new default. - Tests: 3 new cases (55 L allowed, 120 L still blocked, dynamic error message). Full suite: 1415 passed / 3 skipped / 0 failed.
Documentation
- docs/threshold-empirical-analysis.md — methodology, samples, percentiles, false-positive rates per candidate threshold.
- docs/furia-threshold-review.md — adversarial Q1-Q5 (arbitrariness check, risk surface, ratio-vs-absolute, env constraints, legitimate-rewrite scenario).
- scripts/analyze-symbol-sizes.mjs — reproducible TypeScript Compiler API analyzer.
Migration
No file format change, no API change, no breaking signature. Symbols 41-100 L now accept mode:"replace" where they were previously rejected.
To restore exact pre-v11.3.1 behavior:
export NREKI_SYMBOL_LIMIT=40🤖 Generated with Claude Code