Repository navigation
Description
Found by the 46-language audit in docs/args_rule_contract.md, written for #2773. Much narrower
than the other findings in that pass -- 2 hits on the control shell, not a systemic call-site leak.
The contract
argsmatches the parameters a callable declares.
Measured
keyword-rosetta/data/haskell, args against func_start:
| file | func_start |
args |
the extra hits |
|---|---|---|---|
a.hs |
3 | 5 | region :: IORef Int, home :: IORef Int |
| b/c/main | 10 | 10 | exact |
| total | 15 | 15 | -- (func_start counts the same two, so the ratio hides it) |
The planted figure is 13 (one parameter per probe, SPEC.md); haskell reads 15.
region :: IORef Int -- a top-level VALUE. Zero parameters.
region = unsafePerformIO (newIORef 0)region is a globals probe -- a top-level mutable IORef, planted for the globals signal. It is
not a callable at all, and the :: arm of args scores it anyway.
The cause
"args": re.compile(
r"::(?:[ \t\n]|--[^\n]*\n|\{-…-\})*((?:[a-zA-Z0-9_\'.,()\[\]]|=>|->|⊸)…)" # arm 1
r"|\\(…)->"
r"|@[A-Z][a-zA-Z0-9_\']*"
r"|^[ \t]*…([a-zA-Z_][a-zA-Z0-9_']*)[ \t]+(…LHS pattern list…)[ \t]*(?:=(?!=)…)"
),
"_args_arrow_count_groups": {1},Arm 1 matches any :: type signature. _args_arrow_count_groups then counts top-level ->
occurrences in the captured type to get the arity -- which is correct, and for IORef Int correctly
yields zero parameters. But the match itself still lands in struct_args, which is a count of
matches, not of parameters. So a module of pure top-level constants records a parameter surface it
does not have.
Note this is the narrow, contract-level version of the same thing func_start does here: a ::
signature for a value is also counted as a function start. Whether that is a second defect or the
deliberate "a CAF is a nullary function" reading is worth settling in the same pass -- the two
should agree.
Suggested shape
Require arm 1's captured type to contain a top-level -> (or ⊸) before it counts. A signature
with no arrow declares no parameters, so the match earns nothing downstream anyway, and dropping it
makes struct_args agree with the arity _args_arrow_count_groups already computes.
language-crucible/data/haskell: 169 args against 250 func_start (a/f 0.68); the change is
small there and worth measuring before/after.
Corpus pairing
keyword-rosetta/data/haskell needs no authoring change -- the fix should land it on 13 exactly.
Part of #2669 (rosetta[haskell] tracking issue).
Activity
fix(core-engine): args counts declared parameters, not call sites (ob…
fix(core-engine): args counts declared parameters, not call sites (ob…
fix(core-engine): args counts declared parameters, not call sites (ob…
squid-protocol commentedon Sep 6, 2026
Closing as already settled, and settled correctly — I filed this without checking keyword-rosetta's
deviation_ledger.json, which is exactly the audit trail that exists to stop a question being re-litigated.The behaviour is covered by
haskell-caf-bindings-count-as-functions(dispositionengine-semantic, validated 2026-09-04):That reading is better than mine. In Haskell a top-level value genuinely is a nullary function —
region :: IORef Intbinds a CAF, not a variable in the C sense — and the engine is consistent about it:func_startandargsboth count it, and_args_arrow_count_groupscorrectly derives arity 0 from the arrow-less type. My proposal (require a top-level->before the::arm counts) would have madeargsandfunc_startdisagree with each other on the same binding, which is worse than the thing I was trying to fix.The one observation worth keeping is cross-language and not a haskell bug:
struct_argscounts matches, so a zero-parameter callable contributes 1 in haskell but 0 in objective-c (- (void)deallocmatches nothing). That inconsistency is real but it is a property of the file-level metric's definition, not of this rule — noting it here rather than reopening under it.docs/args_rule_contract.mdlists haskell as a contract violation on the strength of this issue; I'll correct that entry in a follow-up.docs(args-contract): correct two audit findings that keyword-rosetta …