Repository navigation
fix(cobol): detect fixed-format source that carries sequence numbers - #3813
abhay-codes07 wants to merge 1 commit into
Conversation
The fixed/free format detector counted a line as fixed-format only when its
first six columns were blank (`^ {6}[ *\-/ ]`). Legacy mainframe COBOL — the
main reason to have a COBOL extractor — puts a sequence NUMBER in columns 1-6,
so every such file scored zero fixed markers and was classified free-format.
In free mode the code is taken verbatim (no column-8 slice), so the sequence
number stays glued to the statement: `000400 MAIN-PARA.` no longer matches the
paragraph anchor `^NAME .? .$`, and the whole procedure layer disappears. A
seven-line program with two paragraphs and a PERFORM collapsed to just the file
and program nodes — zero paragraphs, zero `calls` edges — silently.
Match a sequence area that is six spaces OR six digits, followed by a valid
indicator column (space = code, `*`/`/` = comment, `-` = continuation, `D` =
debug). Once the file is correctly read as fixed-format the existing
column-8..72 slice strips the sequence number and paragraphs/PERFORMs resolve
as they should. Blank-sequence fixed-format and genuinely free-format source are
unaffected (a 6-digit prefix is not something free-format code begins a line
with).
Regression test: a sequence-numbered program now yields its program, both
paragraphs, and the PERFORM `calls` edge — and fails on the old detector.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JJbLfztSxm2tH5cJwBbe9q
There was a problem hiding this comment.
Graphify reviewed this change.
Worth a look — the grounded gate found no coupling regressions or blocking issues, but 1 advisory finding(s) below merit a look before merge.
Formal verification. 1 change(s) tested, no difference found (not proven).
Graphify review — findings
Fixes fixed-format detection in _code_lines so legacy source carrying a six-digit sequence number in columns 1–6 (previously requiring six blank columns) is no longer misread as free-format. This keeps paragraphs and PERFORM edges intact instead of dropping everything but the file and program nodes when the sequence number leaked into the code and broke the ^NAME.$ anchor. Adds test_cobol_fixed_format_with_sequence_numbers covering a sequence-numbered file with a paragraph call edge.
Worth a look
- Alphanumeric fixed-format sequence areas still misdetected as free format —
graphify/extractors/cobol.py:50· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 19 functions depend on the 19 functions this change touches.
Health — this change adds coupling hotspots:
- new:
extract_cobol()— 2 callers, 7 callees
Verification — 19 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 19 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
300 of 300 test file(s) selected (100%) via static blast radius.
Escalated to a full run for safety — the selection is not trustworthy on its own (see below). CI should run the whole suite.
tests/test_affected_cli.py— full-run-safetytests/test_affected_member_seed.py— full-run-safetytests/test_agents_platform.py— full-run-safetytests/test_analyze.py— full-run-safetytests/test_anthropic_custom_endpoint.py— full-run-safetytests/test_antigravity_install.py— full-run-safetytests/test_apm_fallback_version.py— full-run-safetytests/test_architecture_doc.py— full-run-safetytests/test_astro_extraction.py— full-run-safetytests/test_astro_import_ids.py— full-run-safetytests/test_atomic_canvas_export.py— full-run-safetytests/test_atomic_version_stamp.py— full-run-safetytests/test_atomic_writes.py— full-run-safetytests/test_backend_env_isolation.py— full-run-safetytests/test_backend_extras.py— full-run-safetytests/test_benchmark.py— full-run-safetytests/test_benchmark_raw_graph.py— full-run-safetytests/test_build.py— full-run-safetytests/test_build_merge_dedup_scope.py— full-run-safetytests/test_build_merge_hyperedges_and_prune.py— full-run-safetytests/test_build_merge_shrink_guard.py— full-run-safetytests/test_builtin_global_type_refs.py— full-run-safetytests/test_cache.py— full-run-safetytests/test_callflow_html.py— full-run-safetytests/test_cargo_introspect.py— full-run-safetytests/test_cargo_missing_manifest.py— full-run-safetytests/test_carried_hyperedge_remap.py— full-run-safetytests/test_case_sensitive_resolution.py— full-run-safetytests/test_charmap_encoding.py— full-run-safetytests/test_chunking.py— full-run-safetytests/test_cjs_module_extension.py— full-run-safetytests/test_claude_cli_backend.py— full-run-safetytests/test_claude_md.py— full-run-safetytests/test_cli_broken_pipe.py— full-run-safetytests/test_cli_export.py— full-run-safetytests/test_cli_help.py— full-run-safetytests/test_cluster.py— full-run-safetytests/test_cobol_extractor.py— impact, changed-test, full-run-safetytests/test_codebuddy.py— full-run-safetytests/test_community_hub_labels.py— full-run-safetytests/test_community_labels_skill.py— full-run-safetytests/test_confidence.py— full-run-safetytests/test_corrupt_graph_json.py— full-run-safetytests/test_cpp_nested_and_cli.py— full-run-safetytests/test_cpp_objc_cross_file_calls.py— full-run-safetytests/test_cpp_preprocess.py— full-run-safetytests/test_cross_extension_reexport_self_cycle.py— full-run-safetytests/test_cross_language_call_resolution.py— full-run-safetytests/test_cross_repo_external_call_guards.py— full-run-safetytests/test_cross_repo_member_calls.py— full-run-safety- … and 250 more
changed code file(s) with no mapped test (
graphify/extractors/cobol.py) — a coverage gap or a missing link — running the full suite rather than only the selected tests
Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.
Formal verification
No difference found (not proven): No behavior difference found in \_code\_lines (not a proof).
The verifier ran both versions of \_code\_lines on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.
Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.
Note: An input the sampler did not try could still differ.
· 1 more finding(s) on lines outside this diff (see the check run).
Windows hash-seed re-exec wait (#3816/#3799), Terraform secret-named variable-default/output redaction (#3817), COBOL fixed-format sequence-number detection (#3813) and PERFORM...THRU both-endpoint linking (#3814), and gate the GRAPH_REPORT undocumented-components reason on a real semantic layer (#3828/#3801). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Shipped in v0.9.68 (now on PyPI) via an authorship-preserving cherry-pick, so your commit keeps contributor-graph credit. Thanks @abhay-codes07! COBOL fixed-format sequence-number detection. |
What
The COBOL fixed/free format detector counts a line as fixed-format only when its first six columns are blank (
^ {6}[ *\-/ ]). But legacy mainframe COBOL — the main reason a COBOL extractor exists — puts a sequence number in columns 1-6. Such a file scores zero fixed markers and is misclassified as free-format.In free mode the code is taken verbatim (no column-8 slice), so the sequence number stays glued to the statement.
000400 MAIN-PARA.then no longer matches the paragraph anchor^(NAME)(?: SECTION)?\s*\.\s*$, and the entire procedure layer disappears: a seven-line program with two paragraphs and aPERFORMcollapses to just the file and program nodes — zero paragraphs, zerocallsedges — silently.Fix
Count a fixed-format marker when the six-column sequence area is six spaces OR six digits, followed by a valid indicator column (space = code,
*//= comment,-= continuation,D= debug):^(?: {6}|\d{6})[ *\-/dD]. Once the file is correctly read as fixed-format, the existing column-8..72 slice already strips the sequence number and indicator, so paragraphs andPERFORMs resolve normally.A six-digit prefix is not something free-format code begins a line with, so blank-sequence fixed-format and genuinely free-format source are both unaffected (verified).
Verification
callsbefore.PERFORMcallsedge — and fails on the old detector.