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
{{ message }}
Repository navigation
c api rule counts top-level variable declarations as public surface (a.c reads api 5 for 3 functions; +25.0% sits at the band edge) #2907
c's api rule counts a non-static top-level variable declaration as public surface. On the keyword-rosetta corpus data/c/a.c records raw_arch_api 5 for three functions: the two globals plants (int shared_region = ..., int shared_home = ...) match the rule's fourth alternative, the generic ^(?!static\b)... <type> <name> ... =? declaration shape, alongside the three function headers.
main.c reads 4 (entry + 3 probes, correct) and b.c reads 3, so the language's mean is 3.75 against a cross-language median of 3.0: +25.0%, inside the ±25% band by zero margin. No ledger entry names it, and risk_documentation for c sits at +24% for the same reason (a.c scores 68.2 where its siblings score 40.6; see the per-file decomposition on the risk_documentation epic).
Why it is a contract violation
docs/api_rule_contract.md: "api matches a declaration that makes a named function or type visible outside the file." A file-scope variable has external linkage, but it is neither, and the same token is already globals's hit — the count contract's one-owner corollary (#2841 C2, #2852 C2) says a token that two rules claim collapses to its owner. Here the owner is globals.
Fix
Anchor the generic alternative to a function declarator: require ( after the name (<type> <name>(), the way the c func_start rule already does, and keep extern, __declspec(dllexport) and the visibility attribute as they are. Expected corpus effect: a.c api 5 → 3, c mean 3.75 → 3.0, risk_documentation c 48.6 → 38.3 (the median). Check the crucible for header files: extern int x; stays counted by the first alternative, which is the intended public-variable form.
Golden-master diff expected on c-heavy crucible repos (curl, cpython); scope it with bless_scope.py before blessing. Label rosetta:rebless-owed: the corpus c manifest re-blesses api in a.c.
Phase 1 prerequisite of the risk_documentation score-contract epic (child of #2812).
Activity
c api: a file-scope variable is globals' hit, not public surface (#2907…
api_declared_orphans: test the orphan's real name, not \b\w+\b tokens (…
Contextual Baseline Fix: case-fold the resolver for case-insensitive-…
feat(tools): the score-contract tooling batch — closes #2916 (#2931)
fix(rules): objective-c api counts the method definition -- closes #2940