Modernize the position valuation and update slice: COBOL behavioural spec + Java 21 / Spring Boot port with COBOL-parity tests - #271
Open
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
…21 / Spring Boot Adds a behavioural spec derived from PORTTRAN/PORTVALD/PORTUPDT/RPTPOS00, a Java 21 Spring Boot port using BigDecimal with COBOL truncation semantics, and parity tests asserted against golden vectors captured from the compiled COBOL. Co-Authored-By: Samir Chaudhry <samir@cognition.ai>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Forward-engineers one coherent slice of the COBOL system — position valuation and update — into Java 21 / Spring Boot, with the behavioural specification that drives it and parity tests asserted against vectors captured from the compiled COBOL. No COBOL source or seed data is modified.
Program set migrated, and why. The slice is everything on the read → compute → write path for a position, and nothing else (6 programs of 42):
PORTTRAN.cblPORTVALD.cblPORTUPDT.cblPORT-TOTAL-VALUERPTPOS00.cbl¶2110onlyERRPROC.cbl,AUDPROC.cblCopybooks:
TRNREC,POSREC,PORTFLIO,PORTVAL,AUDITLOG,ERRHAND.The task named
src/programs/batch/POSUPDT.cblas the starting point. That file is zero bytes. The behaviour the documentation attributes toPOSUPDT(system-architecture.mdL95-97, L502) is implemented paragraph-for-paragraph inPORTTRAN 2200-UPDATE-POSITIONS, soPORTTRANis treated as the position update step — stated explicitly rather than invented (OQ-2). Two other findings of the same kind are load-bearing and are recorded, not papered over:PORTTRANcopies aPORTRECcopybook that does not exist in the repository (so the PIC clauses of the two fields carrying all the money are not recoverable from source — OQ-1), andPORTTRANnever performs2200-UPDATE-POSITIONS— no suchPERFORMexists anywhere in the program, so as committed it validates a transaction file and no balance ever changes. Both behaviours ship, switched by config, defaulting to the faithful one:Deliverables
docs/modernization/position-valuation-spec.md— 52 numbered business rules, every one citing its program and paragraph, each tagged[golden](pinned by a vector from the compiled COBOL) or[read](derived from source text), plus record layouts and 12 open questions.modernization/position-valuation/— the Java 21 / Spring Boot 3.3.5 module.modernization/position-valuation/README.md— the paragraph → method map.modernization/position-valuation/parity/— four GnuCOBOL harnesses plus the script that regenerates the golden CSVs.Rounding and precision, and their COBOL justification.
BigDecimalthroughout (COMP-3is fixed-point decimal; binary floating point diverges on the first fee). Every store names its receiving field, because in COBOL the receiving field — not the operands — fixes scale and rounding.cobol/PackedFieldis the whole of it:S9(11)V9(4)), scale 2 for money (S9(13)V9(2)), fromTRNREC/POSREC.RoundingMode.DOWNat every store: noROUNDEDphrase exists in the slice, and COBOL truncates toward zero.9999999999999.99 + 0.01is0.00, not an error, and the tests assert exactly that.COMPUTEintermediates atDECIMAL128, truncated once into the receiving field, matching IBM's ≥30-digit fixed-point intermediates.PIC +ZZ9.99is modelled as a real field, not a format string: 12245.67% prints+245.67because three integer digits with noON SIZE ERRORdiscard the rest.Test evidence.
mvn clean test→ 115 tests, 0 failures. 90 of them are golden-vector rows:parity/cobol/PVDRIVE.cblcalls the unmodifiedPORTVALD(34 inputs),PARITHM.cbl/PDIVZER.cblre-execute theADD/SUBTRACT/COMPUTEstatements ofPORTTRAN 2210-2240andRPTPOS00 2110on the production PIC clauses, andPUPDMOV.cblre-executes the twoMOVEs ofPORTUPDT 2200. Their stdout is committed as CSV and asserted row by row, so a divergence from the COBOL fails the build. The remaining tests cover the error and abend paths: insufficient units, missing portfolio, unimplemented transfer, overflow wrap, divide-by-zero, and the 101-error batch halt.Defects reproduced rather than fixed (each pinned by a vector and raised as an open question):
PORTVALD 1000-VALIDATE-IDrejects every portfolio ID, including a well-formedPORT0001, because it moves 4 characters into aPIC X(10)field and then class-tests the space-filled result;2000-VALIDATE-ACCOUNTclass-tests all 50 linkage bytes, so only a 50-digit account passes;4000-VALIDATE-AMOUNTbounds equal the receiving field's own range, so it can never fail. Three deviations are deliberate and listed in the README — the audit timestamp/field-overlay corruption is not reproduced, a non-numeric amendment value throws instead of inventing a number, and a zero divisor returns an explicit size-error outcome.Open questions a human must answer (full table in the spec): OQ-1 real PIC clauses of
PORT-TOTAL-UNITS/PORT-TOTAL-COST(missing copybook); OQ-2 shouldPORTTRANupdate at all; OQ-3/OQ-4 the two validators that can never succeed; OQ-5 wherePOS-CURRENT-VALUE/POS-PREVIOUS-VALUEcome from (absent fromPOSREC, soRPTPOS00does not compile); OQ-6 sell reduces cost basis by proceeds, not by cost of units sold, and no realised P&L exists; OQ-7 transfers are exempt from the price and amount checks but not the quantity check; OQ-8 the audit "before image" is written after the rewrite; OQ-9 does the zero-divisorCOMPUTEabend on z/OS; OQ-10PORTUPDTcan write an unrecognisedPORT-STATUS; OQ-11"12500.00"in an amendment file means different money under GnuCOBOL and IBM Enterprise COBOL; OQ-12 the 101-error halt ends the job normally with the file half-read.Devin-Org: engineering
Link to Devin session: https://app.devin.ai/sessions/ccae8de8ed00434ab0e6d275c4d376d4
Open in Devin Desktop: https://app.devin.ai/desktop/session/ccae8de8ed00434ab0e6d275c4d376d4?variant=devin
Requested by: @schaudhry123
Devin Review