Repository navigation
fix(cobol): globals drops WORKING-STORAGE header (#2805); args counts operands not clauses (#2804) - #2830
Merged
Conversation
… operands not clauses (#2804) Two COBOL rosetta cells, both corpus-morphology rejections that no longer hold. #2805 -- globals: dropped `WORKING-STORAGE SECTION` from the `globals` rule. `GLOBAL`/`EXTERNAL`/`COMMON` are the item-level clauses that publish shared state; `WORKING-STORAGE SECTION` is a region header, mandatory in every program that declares any state, so counting it stacked an unconditional phantom `globals >= 1` on every real COBOL file (and inflated `encapsulation_ratio`). `SECTION` still counts under `structural_boundaries`, so no structural signal is lost. (The issue floated a fallback shape (b) too, but the rosetta corpus keeps the WS header and the item clauses in *different* files -- main.cbl vs a.cpy -- so only dropping the header reaches the planted 2; a fallback would leave it 3.) #2804 -- args: the file-level `args` signal counted USING/RETURNING *clauses*, not declared parameters -- `USING A, B, C` read the same 1 as `USING A`. Two fixes together: * the `args` regex captured only the first operand of a comma-SPACE list (`WS-A, WS-B, WS-C` -> `WS-A,`) because each operand iteration had no leading-whitespace allowance; widened the inter-operand separator so the whole list is captured. Newlines are crossed only when operands are comma-joined, and the same-line run is capped (`[ \t]{1,4}`), so a period-less list does not over-read into the next statement or bridge the wide gap to fixed-format columns 73-80 (both real regressions caught on the NIST CCVS / carddemo corpora: CSUTLDPY 3->5, IC2014 44->45). * new `_count_cobol_using_operands` turns each captured list into a real operand count (dropping BY REFERENCE/CONTENT/VALUE phrase words), and the file-level tally uses it for COBOL's `args` rule -- same "one match, real operand count" shape as the agc/assembly register counters. Verification: 215 cobol extraction/mainframe tests pass; new operand-count and over-capture-guard cases added to test_cobol_strict.py; args regex confirmed ReDoS-immune. Golden-crucible cobol deltas all move in the correct direction (346 globals -1/-2/-4 phantom removals; 41 args increases to real operand counts, extremes hand-verified: IC2014=44, IC2244=48); the 64 non-cobol golden diffs are pre-existing main drift, not from this change. ruff/mypy baselines clean. Cross-repo (rosetta sweep -- engine PR first): keyword-rosetta owes a corpus re-bless against engine main -- data/cobol/expected_signals.json main.cbl globals 1->0 (#2805). #2804's chart-cell movement is the optional corpus shape (a) (append ` USING <item>` to the nine ENTRY lines); the engine change here is the general-correctness half and is invisible on the single-operand rosetta shell. Golden-crucible cobol values also owe a re-bless at the next crucible pin bump. Label: rosetta:rebless-owed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GVJXkEphGEjmupV9j5mdSr
Contributor
…2804 args Regenerated both golden masters (full-precision and zero-dependency) against the pinned language-crucible v1.2.0 corpus via `tests/tools/crucible_check.py --update --yes`. All 387 changed cells in each fixture are COBOL and are the intended effect of this branch's engine change: * Global State Dependencies (globals): 346 files drop the phantom that the `WORKING-STORAGE SECTION` region header used to add (Expected 1 -> Got 0, and Expected N -> N-1/N-2/N-4 on multi-program NIST files). #2805. * Function Parameters (args): 41 files rise from the old clause-first-operand undercount to the real declared-operand count -- e.g. CSUTLDPY.cpy 1 -> 3, IC2014.2.cbl 11 -> 44, IC2244.2.cbl 12 -> 48. #2804. Both modes now pass `crucible_check.py`. No non-COBOL structural cell moved (the only other diff lines are the fixtures' sanitized scan-path/timestamp metadata, which the comparison ignores). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GVJXkEphGEjmupV9j5mdSr
…5-args-2804 # Conflicts: # tests/golden_master_audit.json # tests/golden_master_zero_dep_audit.json
…#2804) Regenerated both golden masters on top of the merge with main (which had itself re-blessed them for #2828's export-construct change). The fixtures now carry both main's baseline and this branch's cobol deltas; diff vs origin/main is cobol-only (Global State Dependencies phantom removals + Function Parameters operand counts) plus sanitized scan metadata. Both modes pass crucible_check.py. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GVJXkEphGEjmupV9j5mdSr
squid-protocol
added a commit
to squid-protocol/keyword-rosetta
that referenced
this pull request
Sep 6, 2026
…ORKING-STORAGE (gitgalaxy#2830) (#84) Corpus re-bless against engine main, companion to the merged engine PR squid-protocol/gitgalaxy#2830 (rosetta:rebless-owed). gitgalaxy #2805 dropped `WORKING-STORAGE SECTION` from the cobol `globals` rule (a region header, not shared state). Verifying scan on engine main ffa0a0f: main.cbl globals 1 -> 0, a.cpy still 2 (the planted GLOBAL/EXTERNAL items), cobol aggregate globals 3 -> 2 = median (green). No plant change. - data/cobol/expected_signals.json: main.cbl globals 1 -> 0. - deviation_ledger.json: cobol-working-storage-globals closed (still_reproduces false, resolved_by gitgalaxy#2830, upstream_issue #2805). verify_language.py cobol: PASS (79 assertions). na_check.py --ci: clean. Cross-repo: engine PR gitgalaxy#2830 merged first; this re-bless follows against engine main. bias-history.yml regenerates the chart/cache on merge. #2804's args cell is a separate, optional corpus change (shape (a): add ` USING <item>` to the nine ENTRY lines) and is not part of this PR.
This was referenced Sep 6, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two COBOL rosetta cells, both corpus-morphology rejections that no longer hold. Engine-side (first) half of a rosetta sweep.
#2805 —
globalsover-countsWORKING-STORAGE SECTIONDropped
WORKING-STORAGE SECTIONfrom theglobalsrule.GLOBAL/EXTERNAL/COMMONare the item-level clauses that publish shared state;WORKING-STORAGE SECTIONis a region header, mandatory in every program that declares any state, so counting it stacked an unconditional phantomglobals >= 1on every real COBOL file (and inflatedencapsulation_ratio).SECTIONstill counts understructural_boundaries, so no structural signal is lost.The issue floated a fallback shape (b), but the rosetta corpus keeps the WS header (
main.cbl) and the item clauses (a.cpy) in different files, so only dropping the header reaches the planted 2 — a fallback would leave it 3.#2804 —
argscounts clauses, not declared parametersThe file-level
argssignal counted USING/RETURNING clauses, not parameters —USING A, B, Cread the same 1 asUSING A. Two coupled fixes:argsregex captured only the first operand of a comma-SPACE list (WS-A, WS-B, WS-C→WS-A,) because each operand iteration had no leading-whitespace allowance. Widened the inter-operand separator so the whole list is captured. Newlines are crossed only when operands are comma-joined, and the same-line run is capped ([ \t]{1,4}), so a period-less list does not over-read into the next statement or bridge the wide gap to fixed-format columns 73–80._count_cobol_using_operandsturns each captured list into a real operand count (droppingBY REFERENCE/CONTENT/VALUEphrase words), and the file-level tally uses it for COBOL'sargsrule — same "one match, real operand count" shape as the agc/assembly register counters.Both over-captures above were real regressions caught and fixed during verification on the NIST CCVS / carddemo corpora (CSUTLDPY 3→5; IC2014 44→45).
Verification
test_cobol_strict.py; args regex confirmed ReDoS-immune.IC2014=44,IC2244=48). The 64 non-cobol golden diffs are pre-existingmaindrift, not from this change.Cross-repo (rosetta sweep — this engine PR merges first)
main:data/cobol/expected_signals.jsonmain.cblglobals1→0(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). Companion PR lands after this merges; itsbias-history.ymlregenerates the chart.USING <item>to the nineENTRYlines); the engine change here is the general-correctness half and is invisible on the single-operand rosetta shell.rosetta:rebless-owed.Closes #2805. Advances #2804 (engine half; corpus shape (a) optional follow-up).
🤖 Generated with Claude Code
https://claude.ai/code/session_01GVJXkEphGEjmupV9j5mdSr