Repository navigation
Description
Same pass as #2763–#2765 (2026-09-05, engine 3b3568e0, corpus main 6183c4b). encapsulation is unplanted and ungated, but it feeds encapsulation_ratio and def_encapsulation, and def_encapsulation is the derivation edge behind five red risk_api_exposure cells (agc_assembly −76%, css −56%, haskell −75%, perl −52%, rust −50%). Reading the 46 rules side by side, the signal has no agreed meaning and two of them are outright broken.
The rules disagree about direction
java \b(private|protected|internal)\b
csharp \b(private|protected|internal|file)\b
c ^[ \t]*static\b
python \b_[a-zA-Z_]\w*\b
zig ^[ \t]*(?!(?:pub|export|extern)\b)(?:const|var|fn)\s+
go ^func\s+(?:\([^)]*\)[ \t]+)?[a-z]\w+|^(?:type|var|const)\s+[a-z]\w+|...
perl \b(my|state|local)\b|:private\b
haskell ^[ \t]*module\s+[A-Z][a-zA-Z0-9_.]*\s*\([^)]*\)\s*where
rust \bpub(?:\(crate\)|\(super\)|\(self\))?\bEvery one of those except the last measures non-public surface: an explicit private modifier (java, csharp), internal linkage (c), a private-by-convention name (python), a lexical scope (perl), an export list that hides what it omits (haskell), or a declaration without a visibility keyword (go's lowercase test, zig's negative lookahead on pub).
rust matches pub. pub is the public modifier. Rust has no private keyword because private is the default, so the language's own encapsulation surface is the zig/go shape — a declaration with no pub — and the rule records the exact complement. Measured on keyword-rosetta/data/rust: 3 hits per file, all pub, on four files whose probes are deliberately public. Rust's def_encapsulation reads 3.0 where java's reads 0.0 on the same intent, and the sign is backwards.
Worth checking in the same pass whether perl's my (a lexical scope, present on every local variable) and python's _name (a convention, but also every dunder and every _-prefixed parameter) are measuring visibility or just counting declarations — perl records 3–4 per file and python 0–1, on identical intent.
agc_assembly matches every line
"encapsulation": re.compile(r"^[ \t]*[A-Za-z0-9_][a-zA-Z0-9_.]*")There is no keyword in it. It matches the first identifier-shaped token on any line, at any indentation. Measured on keyword-rosetta/data/agc_assembly — 50 hits over 4 files, against 0 for 37 of the 46 languages:
| file | hits | tokens matched |
|---|---|---|
a.agc |
13 | BANK, L, PROBEGLOB, CA, COMMON, COMMON, PROBETEST, CA, SELFCHECK, ROPECHK, PROBESAFE, CA, RELINT |
b.agc |
12 | BANK, Q, PROBEBYP, CA, TASKOVER, … |
c.agc |
9 | Z, PROBECLEAN, CA, ENDOFJOB, RESUME, … |
main.agc |
16 | BANK, A, DISPATCH, CA, PROBEBR, CA, BZF, PROBEIO, CA, DSKY, CHANNEL, READ, … |
Labels, opcodes (CA, XCH, BZF), operands (A, Q, Z, L) and prose-adjacent tokens (WHIMPER, CURTAINS) all count. AGC assembly has no visibility construct at all — the honest value is a None rule with a ledgered absence, exactly like the class_start absences reviewed in the n/a sweep, not 12.5 per file. def_encapsulation 12.5 is why agc's risk_api_exposure reads 1.675 against a 7.052 median.
Candidate shape
Contract sentence, in the #2730 form: encapsulation is a declaration that restricts a name's visibility below its language's default. Corollaries that fall out of the audit above:
- A public modifier is not encapsulation. rust becomes the zig shape:
(
"encapsulation": re.compile(r"^[ \t]*(?!pub\b)(?:pub\((?:crate|super|self)\)[ \t]+)?(?:fn|struct|enum|trait|mod|const|static|type)\s+", re.M),
pub(crate)/pub(super)/pub(self)are restrictions below the crate-public default and stay counted; barepubdoes not.) - A language with no visibility construct declares
Noneand ledgers the absence — agc_assembly, and re-check assembly/m4/makefile/jcl/yacc in the same table. - A rule with no keyword and no anchor is not a rule. A quick guard worth adding to the language-standards test suite: every
encapsulationpattern must contain at least one literal token or a negative lookahead, so a bare[A-Za-z0-9_]catch-all cannot ship again.
The 46-language audit table belongs next to docs/api_rule_contract.md, and language-crucible gives the before/after incidence per language the way #2743's table was built.
Corpus pairing
encapsulation is not planted, so the corpus change is manifest values plus ledger. Entries that narrow or retire: visibility-morphology-encapsulation, encapsulation-is-language-idiom, encapsulation-ratio-tracks-unplanted-local-declarations, and the def_encapsulation arm of the derived risk_api_exposure cells for agc_assembly/css/haskell/perl/rust. Whether encapsulation should be promoted to a planted signal in SPEC.md once it has a contract is a separate question worth raising in the same PR — today it is an unplanted risk input that five gated cells nonetheless inherit from.
Part of #2669 (rosetta[agc_assembly] is #2563, rosetta[rust] is #2595).
Activity
domain sensors: declare the 40 unplanted, ungated sheet rows in one b…
test: the encapsulation carve-out's exit condition is met -- pin stat…
fix(rules): state the encapsulation contract and align all 46 languag…
Activate auth_middleware as a first-class domain sensor across the re…