Skip to content

cobolrt: rules as data — declarative tables, specs, docs and test vectors for MOVE, COMPARE, ARITH, STRING, and FUNC (Fixes #4712) - #6950

Merged
squid-protocol merged 6 commits into
mainfrom
feat/4712-rules-as-data
Oct 29, 2026
Merged

squid-protocol merged 6 commits into
mainfrom
feat/4712-rules-as-data

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Fixes #4712. Part of epic #4710.

What changed

Expresses COBOL runtime rules as declarative, authoritative data tables under gitgalaxy/standards/cobol/ and generates Java runtime specification classes (cobolrt/), rendered Markdown documentation (docs/language_status/), and fast deterministic test vectors (tests/cobol_mainframe/).

Issue #4712 asked to "start with one family" (MOVE or COMPARE). This PR delivers five complete families, covering 45 rules (100% of the FUNC family, and 33 of 46 CBL rules):

  1. Family 1: MOVE (gitgalaxy/standards/cobol/move.py)
    • 11 rules (CBL-MOVE-01 through 11), 9x9 permissible move matrix (81 cells) aligned with IBM SC26-4940-06.
    • Generates MoveSpec.java, docs/language_status/cobol_move_matrix.md, and test vectors.
  2. Family 2: COMPARE (gitgalaxy/standards/cobol/compare.py)
    • 8 rules (CBL-CMP-01 through 08), 9x9 comparison matrix (81 cells) covering numeric, alphanumeric, figurative, and class comparisons with sign/collating sequence handling.
    • Generates CompareSpec.java, docs/language_status/cobol_compare_matrix.md, and test vectors.
  3. Family 3: ARITH (gitgalaxy/standards/cobol/arith.py)
    • 10 rules (CBL-ARITH-01 through 10), 7 rounding modes (ROUNDED [MODE IS ...]), 5 ON SIZE ERROR conditions, intermediate quotient scale formulas, and remainder semantics.
    • Generates ArithSpec.java, docs/language_status/cobol_arith_matrix.md, and test vectors.
  4. Family 4: STRING (gitgalaxy/standards/cobol/string_ops.py)
    • 4 rules (CBL-STR-01 through 04), 4 inspect modes (ALL, LEADING, FIRST, CHARACTERS), BEFORE/AFTER delimiter phrases, and POINTER / ON OVERFLOW semantics for STRING and UNSTRING.
    • Generates StringSpec.java, docs/language_status/cobol_string_matrix.md, and test vectors.
  5. Family 5: FUNC (gitgalaxy/standards/cobol/func.py)
    • 12 rules (FUNC-01 through 12) spanning string manipulation, financial/date, statistical/math, bitwise operations, and national/Unicode conversion.
    • Generates FuncSpec.java, docs/language_status/cobol_func_matrix.md, and test vectors.

Tooling & CLI

  • CLI generator module: gitgalaxy/standards/cobol/cli.py (python -m gitgalaxy.standards.cobol).
  • Subcommands:
    • emit [family]: Outputs generated Java specs or Markdown docs to stdout.
    • check: Validates internal consistency across all matrices, rule IDs, and modes.
    • regen [--check | --out]: Regenerates all target files and enforces zero-drift in CI.

Invariance & Compatibility

  • Zero Port Movement: All generated classes (MoveSpec.java, CompareSpec.java, ArithSpec.java, StringSpec.java, FuncSpec.java) are pure specification and matrix query classes in cobolrt. No existing deterministic port bytecode or behaviour is altered.
  • Catalogue Integrity: All 5 generated specs registered in docs/language_status/cobolrt_rules.json; tests/tools/cobolrt_rules.py --check passes cleanly with zero discrepancies.
  • Fast, Native CI: 100 pytest test cases in tests/cobol_mainframe/test_cobol_*_vectors.py execute natively in 0.34s without requiring Docker or a local JVM installation.
  • Lint & Style: tests/ruff_audit.py --ci passes with 0 new lint findings beyond baseline. All files include PolyForm Noncommercial License 1.0.0 headers.

Gates

  • pr_gates (lint, audits, secrets, xray, gen-docs, derived, workflows): 7/7 pass.
  • cobolrt_rules.py --check: consistent (0 discrepancies).
  • gitgalaxy.standards.cobol check: 45 rules, 162 matrix cells, ok.
  • pytest tests/cobol_mainframe/test_cobol_*_vectors.py: 100 passed in 0.34s.
  • ruff_audit.py --ci: 0 new lint findings beyond baseline.

Plan for Remaining Families (Epic #4710)

With the generator infrastructure established, the remaining 141 runtime rules in cobolrt_rules.json can be delivered in discrete, high-velocity slices:

  • Slice 1: Numeric Storage Codecs & Editing (NUM + EDIT, 18 rules: Codec.java, Zoned.java, Editing.java).
  • Slice 2: Hexadecimal Floating Point (HFP, 14 rules: Hfp.java).
  • Slice 3: Language Environment Services (LE, 19 rules: le/*.java).
  • Slice 4: System Subsystems (DLI, MQ, SQL, CICS).

squid-protocol and others added 6 commits October 28, 2026 17:04
… and test vectors (Part of #4712)

* Declarative standards table: gitgalaxy/standards/cobol/move.py defining categories, Field.Kind mappings, IBM SC26-4940-06 9x9 permissible move matrix, and test vectors.
* Generator CLI: gitgalaxy/standards/cobol/cli.py with emit, check, and regen [--check].
* Generated runtime class: MoveSpec.java in cobolrt with category, isPermissible, ruleId, action, and sameZonedShape.
* Rendered documentation: docs/language_status/cobol_move_matrix.md.
* Fast CI test vectors: tests/cobol_mainframe/test_cobol_move_vectors.py (20 tests passed in 0.10s without requiring Docker).
* Catalogue update: docs/language_status/cobolrt_rules.json registers MoveSpec.java under CBL family; cobolrt_rules.py --check passes.

Co-Authored-By: Claude Sonnet 3.8 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

COMPARE_RULES,
COMPARE_VECTORS,
)
from gitgalaxy.standards.cobol.move import KINDS
@squid-protocol
squid-protocol merged commit 1884cfc into main Oct 29, 2026
72 of 74 checks passed
@squid-protocol
squid-protocol deleted the feat/4712-rules-as-data branch October 29, 2026 00:09
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.

cobolrt: rules as data — generate runtime code, test vectors and docs from rule tables (start with one family)

2 participants