Skip to content

#3945 / #3946 / #3949 / #3950: generated Java reads KSDS files in key order, rejects bad timestamps and packed data, and keeps decimal scale - #3951

Merged
squid-protocol merged 2 commits into
mainfrom
fix/generated-java-3945-3946-3949-3950
Sep 28, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
fix/generated-java-3945-3946-3949-3950

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Fixes #3945
Fixes #3946
Fixes #3949
Fixes #3950

The last four open items on "GitGalaxy Tours the Globe". All four are generator changes to the generated Java record layer. The engine is untouched, and the golden masters did not move.

#3945: a sequential READ of a KSDS comes back in key order

Why: the batch branch of RepositoryForge._service_methods generated readAll{name}() as a bare findAll(). That sends no ORDER BY, so records came back in the database's order: heap order on PostgreSQL, code-point PK order on H2. The mainframe returns them in key order. This silently changed control breaks and merge/match logic.

What: the new RepositoryForge._file_order(st) picks the order. The method is now return repo.findAll(org.springframework.data.domain.Sort.by(...));. The FQN matches the existing PageRequest.of usage and avoids a clash with a generated class named Sort. A comment above the method says which order it uses and why.

Store Order
KSDS, one-field String key, culture.key_collation: ebcdic (default) Sort.by("<key>Sort"), the #3822 code-page sort column the CICS browse finders already use
KSDS, numeric / binary key, or String key under binary / database collation Sort.by("<key>")
KSDS, group key (@EmbeddedId) Sort.by("id.<part1>", "id.<part2>", ...). Under ebcdic with a text part, a TODO says the text parts follow the DB collation, not code-page bytes (no sort column exists for a composite key)
RRDS (NUMBERED) Sort.by("id"), the relative record number
ESDS (NONINDEXED) Sort.by("id"). Entry (RBA) order, which the @GeneratedValue id follows as rows are added
key not one field (vsamKey) Sort.by("vsamKey"), with a TODO under ebcdic (no sort column)

Other generated multi-record reads I checked:

The new TODO wording is filed under the worklist's vsam-key category.

#3946: Db2Dates.parseTimestamp takes ASCII digits only

Before Integer.parseInt runs, the time part must be hour 1–2 digits, minutes and seconds exactly 2, and fraction 0–12 digits, all ASCII 0-9 (new private digits() check). This rejects Arabic-Indic and full-width digits and signs like +1.

Invalid input throws DateTimeParseException("not a DB2 timestamp: ..."). That is the exception parseDate / parseTime already throw for DB2's -180 / -181. An out-of-range time is wrapped in the same exception, and so is a string too short to hold a time (it used to throw StringIndexOutOfBoundsException). The date part still goes through parseDate.

#3949: invalid packed decimal is a data exception, not ZERO

  • EbcdicDecoderUtil.unpackComp3 (decoder forge) now throws the new nested EbcdicDecoderUtil.PackedDecimalDataException when it finds:
    • a digit nibble above 9 (high or low), or
    • a sign nibble below A.
    • It extends NumberFormatException, so existing catches still work.
    • The message names the nibble and byte, e.g. invalid packed decimal (S0C7 data exception) in WS-AMT: digit nibble A at byte 1 of 3.
    • A new overload unpackComp3(bytes, scale, field) names the field; the 2-arg form passes null.
    • The catch-all catch (Exception) -> ZERO and the "Defaulting to ZERO" warnings are gone.
  • CobolRecords.packed (repository forge; the entities' fromRecord reads COMP-3 through it) had the same flaw. A 0-9 sign nibble decoded as positive, and it never checked digit nibbles. It now throws NumberFormatException("invalid packed decimal (S0C7): byte X'..' at offset N, a digit nibble above 9 | a sign nibble below A"), matching how zoned already rejects bad data (Java runtime accepts non-ASCII digits as numbers (Arabic-Indic, Devanagari, full-width) where COBOL NUMERIC/NUMVAL would not #3831).
  • No config switch was added. Nothing in the generator needs zero-fill.
  • Note: fromRecord decodes eagerly. A record whose packed field holds LOW-VALUES now throws on load. On z/OS only arithmetic on that field would S0C7, but this is the same eager choice zoned already makes for spaces.

#3950: VSAM BigDecimal columns keep their precision and scale

The new _decimal_attrs(f) adds precision = <digits>, scale = <decimals> to every BigDecimal @Column of a VSAM entity and of its @EmbeddedId key class. Existing attributes (name, length, columnDefinition, @Id) stay as they were.

  • Examples: S9(5)V9(4) gives precision = 9, scale = 4. S9(7)V99 COMP-3 gives 9, 2. S9(20) gives 20, 0.
  • Where the numbers come from: the digits and scale come from parse_pic_precision, the function the schema forge uses.
  • Currency and decimal comma: in the VSAM entities only plain 9/S/V/P pictures become BigDecimal (java_type). An edited or currency-edited picture is its display text, a String column of its byte width. So no currency symbol (PICTURE SYMBOL 'U' currency mis-sizes the schema: UUU,UU9.99 -> DECIMAL(3, 2) #3910) or DECIMAL-POINT IS COMMA can move a digit of a BigDecimal field here, and no currency symbols are passed. The Spring clean-room entity already applies PICTURE SYMBOL 'U' currency mis-sizes the schema: UUU,UU9.99 -> DECIMAL(3, 2) #3910's currency-aware precision; a test pins that as well.
  • P scaling: P positions widen the precision: SVPP9(3) gives 5, 5.
  • PL/I items: a PL/I picture or FIXED DEC(p,q) gets p,q. FIXED BIN and negative scales get none.
  • Hibernate: I checked Hibernate 6.5 (AnnotatedColumn). When precision > 0 it applies the annotation's precision and scale, so scale = 0 is honoured.

Cultural Gauntlet

before (main) after
--full --run --db 616/696 pass, 80 ledgered (32 collation-static, 24 collation-db, 24 `input_* runtime-run`)
tests/cultural_gauntlet/baseline.txt 80 cells empty (header only)
--ci / --full --ci / --full --run --db --ci exit 0 / 0 / 0 (189/189, 581/581, 696/696)

Snapshot changes (re-blessed deliberately)

tests/cobol_mainframe/refraction_snapshot/{excerpts,full}/<6 corpora>/, 36 files:

The snapshot corpora generate no VSAM repositories or Db2Dates, so #3945 / #3946 / #3950 move no snapshot. tests/tools_recorders/test_decoder_forge.py's golden image was updated for the same reason. Golden masters (engine) did not move.

Tests

New file tests/cobol_mainframe/test_generated_record_layer.py (15 tests; 14 fail on main). Where behaviour matters, it compiles and runs with the JDK, using the gauntlet's jdk():

Gates

  • tests/tools/pr_gates.py (full): lint, audits, secrets, xray, gauntlet, golden, suite. 7/7 pass.
  • Equivalence e2e proofs (EQUIVALENCE_E2E=1, Docker GnuCOBOL, JDK 17): test_equivalence, test_equivalence_inputs, test_equivalence_cics, test_equivalence_environments, test_rounding, test_regional_options. 93 passed.
  • git merge origin/main: already up to date when pushed, so the gate results above are for this exact tree.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TmgE1CwLgaqxqKEgQn5Dw5

… order, rejects bad timestamps and packed data, and keeps decimal scale

- #3945: a batch sequential READ orders by the file's order (KSDS: the code-page sort column or the key;
  RRDS: RRN id; ESDS: generated id / entry order) instead of a bare findAll().
- #3946: Db2Dates.parseTimestamp takes ASCII digits only; invalid -> DateTimeParseException like parseDate.
- #3949: EbcdicDecoderUtil.unpackComp3 and CobolRecords.packed throw on invalid nibbles (S0C7) instead of 0.
- #3950: VSAM entity / key-class BigDecimal columns carry @column(precision, scale) from the PICTURE.
- Cultural Gauntlet: the executed read-all runs the generated readAll's ORDER BY; baseline now empty.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TmgE1CwLgaqxqKEgQn5Dw5
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit 42d503c into main Sep 28, 2026
37 checks passed
@squid-protocol
squid-protocol deleted the fix/generated-java-3945-3946-3949-3950 branch September 28, 2026 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment