Skip to content

Fix #4026: read non-ASCII and END-xxx paragraph/section names in the graveyard finder - #4028

Merged
squid-protocol merged 2 commits into
mainfrom
fix/4026-unicode-unit-names
Sep 30, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
fix/4026-unicode-unit-names

Conversation

@squid-protocol

@squid-protocol squid-protocol commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner

Fixes #4026.

What changed

gitgalaxy/tools/cobol_to_cobol/cobol_graveyard_finder.py (the unit reader behind the refractor's dead-paragraph masking, cobol_dag_architect, cobol_microservice_slicer and the answer-key tooling):

  1. Unicode unit names. _NAME is now [^\W_a-z](?:[^\W_a-z]|[\--−])*: a letter or digit in any script (full-width, CJK, full-width digits) plus - and the two full-width hyphens opensourcecobol4j writes (U+FF0D, U+2212, the same set as the engine's WIDE_HYPHENS). On ASCII text [^\W_a-z] is exactly the old [A-Z0-9], so ASCII behaviour is unchanged. U+3000 is not \w, so it stays a separator (COBOL: a full-width space (U+3000) separator hides data entries and pictures (opensourcecobol4j dialect) #3956). _V uses the same class ((?<![^\W_a-z])(?<![\--−]), two fixed-width lookbehinds), so _PERFORM, _GO_TO, _ALTER, _TERMINAL_TAIL, _TAIL_PERFORM and _CICS_LABEL follow the new names. No nested quantifiers were added. test_tool_regex_redos passes with the baseline unchanged.
  2. END-xxx paragraph names. _NOT_A_PARAGRAPH now rejects only the reserved END- words (ACCEPT, ADD, CALL, CHAIN, COLOR, COMPUTE, DELETE, DISPLAY, DIVIDE, EVALUATE, EXEC, FREE, IF, INVOKE, JSON, MULTIPLY, OF-PAGE, PERFORM, READ, RECEIVE, RETURN, REWRITE, SEARCH, SEND, START, STRING, SUBTRACT, UNSTRING, WAIT, WRITE, XML), plus GOBACK/EXIT/CONTINUE/STOP/DECLARATIVES as before. END-IPROC1. in Area A is a paragraph again.

tests/tools/cobol_answer_key.py: the key's independent unit reader had the same startswith("END-") rule. It now uses the same reserved list, with a test.

What this found on a pinned corpus: GENAPP End-Program.

Fix 2 is not ledger-neutral. CICS GENAPP has a real paragraph End-Program. (Area A, EXEC CICS RETURN END-EXEC., reached by PERFORM END-PROGRAM) in lgipdb01, lgucdb01, lgucus01, lgupdb01, lgupol01. The forge, the answer key and the engine all skipped it because of the same END- rule. The census reviewers didn't catch it either.

  • The forge now reads it. Refraction snapshots for those 5 programs move total_paras +1 each and change nothing else (blessed in this PR). dead_paras stays {MAINLINE-EXIT}.
  • The answer key still lacks it, so ground_truth_ledger.py check shows 5 NEW mismatch forge | units | … | END-PROGRAM | fp, and test_refraction_differential (cics-genapp, excerpt + full) shows 5 unexplained paragraph/old END-PROGRAM. Per the mainframe-ground-truth protocol, the key is what's wrong here ("fix the key and its reader, with a test"). The reader fix is in this PR. Re-running the fixed reader over all six keys changes only these five units lists (one {"name": "END-PROGRAM", "kind": "paragraph", "line": …} each). No dead entry changes. The key JSON edit itself was not applied because it needs the maintainer's approval (see Blocked below).
  • The engine has the same END-[…]+ shield in languages/cobol.py's func_start. Once the key gains END-PROGRAM, the engine side will likely show 5 fn mismatches (an engine defect of the same class, in the galaxyscope scan path, so it's a separate change with a golden-master bless).

Blocked / left to do (why this is a draft)

  • Refresh tests/cobol_mainframe/answer_key/cics-genapp.json units for the 5 programs by re-running the fixed _units reader, then decide how to record it (a key_fixed ruling / re-census of those 5 programs).
  • ground_truth_ledger.py update, and assign any engine-side END-PROGRAM fn rows to an issue, or fix the engine shield.

Verification

  • tests/cobol_mainframe/ + tests/tools/ (plain pytest from an outside directory): 1250 passed, 25 skipped, 2 failed. The 2 failures are the cics-genapp refraction-differential cases above, which are blocked on the key.
  • New tests: a Japanese SECTION whose PERFORM is followed (not dead), plus a CJK paragraph that really is dead; U+3000 not joining names (header and PERFORM); END-IPROC1. as a paragraph reached by AT END GO TO, with END-IF. / END-PERFORM. / END-EXEC. / END-OF-PAGE. still not paragraphs; the key reader's END-PROGRAM shape.
  • tests/tools/audit_check.py: all clear (ruff, mypy, dead-key, ast-accuracy).
  • ground_truth_ledger.py check: only the 5 genapp END-PROGRAM rows above. Nothing moved on carddemo, cbsa, zecs, dsf or zopeneditor-sample.
  • Golden masters: not re-blessed. cobol_graveyard_finder is not in the galaxyscope scan path. galaxyscope imports only galaxy_ir from tools/cobol_to_cobol, and neither imports the finder (sys.modules after importing both holds no cobol_graveyard_finder). Only the refractor, dag architect, slicer and schema forge use it.
  • opensourcecobol4j check (cobol_utf8, jp-compat, i18n_sjis, 353 programs, Shift-JIS decoded as cp932). Old and new procedure_units were compared against an independent Area-A header scan:
    • All 13 non-ASCII programs named in the issue now read all their units: cobol_utf8 005, 006, 007, 008, 021, 081, 115 and i18n_sjis 005, 006, 007, 008, 023, 080.
    • So do the 5 jp-compat END-xPROC1 programs (029–033).
    • No other program's unit list changed.
    • Reachability gaps outside this issue: jp-compat 029–033's sections are entered only through SORT … INPUT/OUTPUT PROCEDURE IS …, which reachable_units does not follow, so they read as dead. In 021/023, section S1節 is entered by GO TO L2見出し IN S1節 (a qualified GO TO into its paragraph), so the section header itself reads unreached.

Cross-repo / companion

The field-testing defect entry D036 for this issue is added by #4027 (not yet merged). After both merge, D036 gets "fixed_by": "#4028". This PR does not add D036.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RZE6us7fUL6Hynk59rWLvZ

@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

squid-protocol and others added 2 commits September 30, 2026 08:09
…graveyard finder

cobol_graveyard_finder's unit reader took only ASCII names and rejected every
`END-...` word as a scope terminator:

- `_NAME` is now Unicode-aware: a letter or digit in any script (full-width,
  CJK, full-width digits) plus `-`, U+FF0D and U+2212. `[^\W_a-z]` is exactly
  `[A-Z0-9]` on ASCII text, so ASCII behaviour is unchanged; U+3000 is not `\w`
  and stays a separator (#3956). `_V` uses the same word class, so PERFORM /
  GO TO / ALTER / CICS HANDLE labels follow the new names.
- `_NOT_A_PARAGRAPH` rejects only the reserved END- words (END-IF,
  END-PERFORM, ... END-OF-PAGE), so `END-IPROC1.` in Area A is a paragraph.

The answer key's own unit reader (tests/tools/cobol_answer_key.py) had the same
`startswith("END-")` rule and gets the same reserved list: GENAPP's
`End-Program.` (LGIPDB01, LGUCDB01, LGUCUS01, LGUPDB01, LGUPOL01) is a
PERFORMed paragraph that the key, the forge and the engine all missed.
Refraction snapshots for those five programs move total_paras by +1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RZE6us7fUL6Hynk59rWLvZ
#4031), log D037; D036 fixed by #4028

The fixed reader finds a real paragraph End-Program. in Area A in 5 GENAPP programs
(lgipdb01 312, lgucdb01 142, lgucus01 119, lgupdb01 215, lgupol01 146). It is reached by
fall-through from MAINLINE and by PERFORM END-PROGRAM. The key's reader, the forge and the
engine all skipped it: each rejected every END- name as a scope terminator.

- Answer key: units gains END-PROGRAM in those 5 programs, read against the source, with a
  dated key_fixed note in each verification. Dead is unchanged (MAINLINE-EXIT).
- Ground-truth ledger: the forge now matches the key. The engine still misses the 5 units
  (its COBOL function-start rule, #4031), so they are ledgered as the open defect
  engine_end_prefixed_paragraph_not_a_unit (#4031).
- Refraction differential: cics-genapp re-blessed with 1 (excerpt) and 5 (full) unexplained
  forge-only END-PROGRAM paragraphs, noted as #4031's. They go back to 0 when it lands.
- Field testing: D037 logs the engine defect found by the ledger on cics-genapp, and D036 (#4026)
  is marked fixed_by #4028; report regenerated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RZE6us7fUL6Hynk59rWLvZ
@squid-protocol
squid-protocol force-pushed the fix/4026-unicode-unit-names branch from 1fa4c30 to 1f4eec0 Compare September 30, 2026 12:13
@squid-protocol
squid-protocol merged commit 3c49cf3 into main Sep 30, 2026
40 of 41 checks passed
@squid-protocol
squid-protocol deleted the fix/4026-unicode-unit-names branch September 30, 2026 13:25
squid-protocol added a commit that referenced this pull request Oct 1, 2026
…ND- words are terminators (#4069)

The engine's COBOL func_start shield excluded every `END-...` word as a
scope terminator, so a legal paragraph named END-... was never a unit.
It now excludes only the reserved END- words -- the list #4028 gave the
graveyard finder (COBOL 2014 / IBM Enterprise COBOL / GnuCOBOL).

Golden masters re-blessed (both modes), because galaxyscope's output
changes on real code: the NIST CCVS85 suite in language-crucible names
~600 paragraphs END-ROUTINE / END-ROUTINE-1 / END-RTN-EXIT / ...
(`PERFORM END-ROUTINE THRU END-ROUTINE-13`) that the engine missed; COBOL
units and archetype counts rise, and every file's map coordinates move
slightly with the totals. cics-genapp's END-PROGRAM is a unit in 5
programs (ground-truth ledger: units tp 157 -> 162, the 5 #4031 rows
ratcheted away, the fixed cause removed). Three of those END-PROGRAMs are
reached only by fall-through, so the engine's unreferenced-by-name census
flags them -- assigned to the existing deliberate cause (#2806: usage_status
is a name census, not reachability).

Tests: END-PROGRAM / END-IPROC1 / End-Program are units, END-IF /
END-PERFORM / END-EXEC are not; the carried-forward `END-TargetFunc.`
invalid case was the old behaviour and is now a valid one.


Claude-Session: https://claude.ai/code/session_01RZE6us7fUL6Hynk59rWLvZ

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

COBOL unit reader (cobol_graveyard_finder): non-ASCII paragraph/section names and names starting END- are not units

1 participant