Skip to content

fix(cobol): globals drops WORKING-STORAGE header (#2805); args counts operands not clauses (#2804) - #2830

Merged
squid-protocol merged 4 commits into
mainfrom
fix/cobol-globals-2805-args-2804
Sep 6, 2026
Merged

squid-protocol merged 4 commits into
mainfrom
fix/cobol-globals-2805-args-2804

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Two COBOL rosetta cells, both corpus-morphology rejections that no longer hold. Engine-side (first) half of a rosetta sweep.

#2805 — globals over-counts WORKING-STORAGE SECTION

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), 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 — args counts clauses, not declared parameters

The file-level args signal counted USING/RETURNING clauses, not parameters — USING A, B, C read the same 1 as USING A. Two coupled fixes:

  • 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.
  • 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.

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

  • 215 cobol extraction/mainframe tests pass; new operand-count + two over-capture-guard cases in test_cobol_strict.py; args regex confirmed ReDoS-immune.
  • Golden-crucible cobol deltas all move 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 — this engine PR merges first)

Closes #2805. Advances #2804 (engine half; corpus shape (a) optional follow-up).

🤖 Generated with Claude Code

https://claude.ai/code/session_01GVJXkEphGEjmupV9j5mdSr

… 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
@squid-protocol squid-protocol added the rosetta:rebless-owed Intentionally moves keyword-rosetta counts; audit warns, corpus re-blesses after merge label Sep 6, 2026
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

squid-protocol and others added 3 commits September 6, 2026 19:15
…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
squid-protocol merged commit 68cd8ad into main Sep 6, 2026
32 checks passed
@squid-protocol
squid-protocol deleted the fix/cobol-globals-2805-args-2804 branch September 6, 2026 23:26
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rosetta:rebless-owed Intentionally moves keyword-rosetta counts; audit warns, corpus re-blesses after merge

Projects

None yet

1 participant