Skip to content

cobol globals counts WORKING-STORAGE SECTION: a region header stacked on top of the item-level GLOBAL/EXTERNAL clauses, unconditional on every COBOL program #2805

Description

@squid-protocol

globals cobol 3, planted 2, median 2 — +50% amber. The third hit is a section header, not a global, and it fires on every COBOL program ever written.

Measured 2026-09-06 on engine main a59ecf6b / corpus main 2038a86. Ledger: cobol-working-storage-globals (disposition: keyword-overlap, still_reproduces: true, no upstream issue).

The measurement

"globals": re.compile(r"\b(WORKING-STORAGE\s+SECTION|COMMON|GLOBAL|EXTERNAL)\b", re.I),

The corpus plants two, both of them data items:

data/cobol/a.cpy:6      77 REGION-ITEM PIC 9 GLOBAL.
data/cobol/a.cpy:7      77 ARGS-ITEM  PIC 9 EXTERNAL.

The third hit is data/cobol/main.cbl:12:

       DATA DIVISION.
       WORKING-STORAGE SECTION.

The point

GLOBAL and EXTERNAL are item-level clauses — they mark one data item as visible outside the program. WORKING-STORAGE SECTION is a region header — it opens the area where a program declares its own state, and it is mandatory in any COBOL program that declares any. The rule counts one hit for the region and one hit per item, so a program with a working-storage section and five GLOBAL items scores 6, and a program with a working-storage section and nothing global scores 1.

That is the same granularity mismatch #2771 describes for raw_arch_api — a per-region declaration banded against a per-item count — with an extra property that makes it worse: the region hit is unconditional. Every real COBOL file in the crucible with a working-storage section carries a phantom globals ≥ 1 whether or not the program shares any state, and globals is an input to encapsulation_ratio (1 - globals / (core_var_decl + globals)), which is itself already flagged as reading an unplanted denominator (#2766). cobol's encapsulation_ratio reads 0.50 against a 0.75 median, and the numerator is inflated by one on the only file that has a working-storage section.

Candidate shapes

(a) Drop the region header from the rule. WORKING-STORAGE SECTION states where state lives, not that any of it is global. The two item clauses (GLOBAL, EXTERNAL) plus COMMON already say what the signal means. cobol reads the planted 2, green, and the crucible loses a phantom per file.

(b) Keep it and treat it as the fallback. If a file has a working-storage section and no item-level clause, count 1; if it has item clauses, count those and not the header. This preserves "this program has program-level state" for the many COBOL programs that never write GLOBAL, without double-counting the ones that do. Closer to what the rule appears to want, and the same shape as #2771's fallback-family reasoning.

(c) Leave it and re-plant. Corpus drops one planted item so cobol reads 2 against the median. Cheapest for the chart and wrong for the engine — it hides an unconditional +1 that every real COBOL scan carries.

My reading is (b): the header genuinely is evidence of program-level state in a language where most programs never use GLOBAL, but it must not stack with the items.

How this survived

Worth recording, because it is the more general finding. The corpus's own overlap miner never showed this keyword to anyone. tools/keyword_menu.py scrapes plantable literals out of each compiled rule and cobol's globals menu reads:

"globals": {"core": true, "keywords": ["COMMON", "GLOBAL", "EXTERNAL"], "pattern_defined": true}

WORKING-STORAGE SECTION is absent, and so is every other hyphenated COBOL keyword — the candidate tokenizer has no hyphen in its joiner set. That is filed separately as squid-protocol/keyword-rosetta#68; it affects 21 languages and 252 literals, including PowerShell's Invoke-Expression.

Corpus pairing

Under (a) or (b), data/cobol/expected_signals.json re-blesses globals 3 → 2 (= median, green) and encapsulation_ratio moves; no plant change — the two planted items stay. cobol-working-storage-globals closes. rosetta:rebless-owed.

Part of #2669. Related: #2771, #2766 (both open), #2567.

Metadata

Metadata

Assignees

No one assigned

    Labels

    core-engineModifications to the central physics and parsing engineenhancementNew feature, sensor, or structural signaturemetricsHeuristics, risk exposures, and topological math updates

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions