cjc0013 commited on
Commit
f19845f
·
verified ·
1 Parent(s): ba8335d

Add AWS CardDemo no-cost modernization proof

Browse files

Reproducible no-cost modernization proof bundle. Static/source-oracle parity is B=50/F=0/gaps=0 under the current rubric. This does not claim live COBOL/CICS all-path runtime equivalence; paid/licensed legacy runtime validation remains outside the no-cost path.

Files changed (42) hide show
  1. DUE_DILIGENCE.md +33 -0
  2. HF_PUBLICATION_MANIFEST.json +235 -0
  3. METHODOLOGY.md +33 -0
  4. PUBLICATION_NOTES.md +8 -0
  5. README.md +86 -0
  6. REPRODUCIBILITY.md +16 -0
  7. final_proof/ARTIFACT_MANIFEST.json +155 -0
  8. final_proof/A_GRADE_PROMOTION_README.md +37 -0
  9. final_proof/A_GRADE_PROMOTION_REPORT.json +867 -0
  10. final_proof/CLEAN_REPRO_VERIFICATION.json +197 -0
  11. final_proof/FINAL_PROOF_README.md +130 -0
  12. final_proof/FINAL_RECEIPT_SUMMARY.json +380 -0
  13. final_proof/KNOWN_LIMITS.md +13 -0
  14. final_proof/NO_COST_CONFIDENCE_README.md +41 -0
  15. final_proof/NO_COST_CONFIDENCE_REPORT.json +932 -0
  16. final_proof/REPRO_COMMANDS.txt +41 -0
  17. final_proof/STATIC_ORACLE_REPLAY_REPORT.json +573 -0
  18. modern_code/README.md +83 -0
  19. modern_code/carddemo/__init__.py +4 -0
  20. modern_code/carddemo/api.py +336 -0
  21. modern_code/carddemo/cli.py +40 -0
  22. modern_code/carddemo/legacy_parser.py +384 -0
  23. modern_code/carddemo/parity.py +0 -0
  24. modern_code/carddemo/repository.py +346 -0
  25. modern_code/carddemo/service.py +0 -0
  26. modern_code/static/app.js +526 -0
  27. modern_code/static/index.html +84 -0
  28. modern_code/static/styles.css +253 -0
  29. modern_code/tests/test_a_grade_promotion.py +96 -0
  30. modern_code/tests/test_hf_public_bundle.py +102 -0
  31. modern_code/tests/test_legacy_parser.py +73 -0
  32. modern_code/tests/test_no_cost_confidence.py +101 -0
  33. modern_code/tests/test_parity.py +175 -0
  34. modern_code/tests/test_service.py +758 -0
  35. modern_code/tests/test_static_oracle_replay.py +57 -0
  36. modern_code/tools/build_hf_public_bundle.py +394 -0
  37. modern_code/tools/build_no_cost_confidence.py +441 -0
  38. modern_code/tools/evaluate_a_grade_promotion.py +501 -0
  39. modern_code/tools/generate_receipts.py +163 -0
  40. modern_code/tools/package_final_proof.py +619 -0
  41. modern_code/tools/replay_static_oracles.py +396 -0
  42. modern_code/tools/verify_clean_repro.py +274 -0
DUE_DILIGENCE.md ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Basic Due Diligence
2
+
3
+ Clone this HF repository and inspect:
4
+
5
+ 1. `README.md`
6
+ 2. `final_proof/FINAL_PROOF_README.md`
7
+ 3. `final_proof/NO_COST_CONFIDENCE_README.md`
8
+ 4. `final_proof/A_GRADE_PROMOTION_README.md`
9
+
10
+ Then clone the upstream AWS source next to `modern_code`:
11
+
12
+ ```powershell
13
+ git clone https://github.com/aws-samples/aws-mainframe-modernization-carddemo.git source
14
+ git -C source checkout 59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e
15
+ ```
16
+
17
+ From `modern_code`, run:
18
+
19
+ ```powershell
20
+ python -m unittest discover -s tests
21
+ python tools\replay_static_oracles.py --source-root ..\source --out-dir .\reports --source-head 59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e
22
+ python tools\build_no_cost_confidence.py --source-root ..\source --out-dir .\final_proof
23
+ python tools\evaluate_a_grade_promotion.py --source-root ..\source --out-dir .\final_proof
24
+ ```
25
+
26
+ Expected high-level result:
27
+
28
+ - tests pass,
29
+ - static replay returns `"passed": true`,
30
+ - no-cost confidence returns `"reviewer_posture": "strong_pre_runtime_confidence"`,
31
+ - A-grade gate returns `"promotable_to_A": false`.
32
+
33
+ That last result is intentional: `cjc0013/aws-carddemo-no-cost-modernization-proof` does not claim live COBOL/CICS runtime parity.
HF_PUBLICATION_MANIFEST.json ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bundle_version": "carddemo_hf_public_bundle_v0",
3
+ "claim_boundary": "No live COBOL/CICS all-path runtime equivalence is claimed.",
4
+ "files": [
5
+ {
6
+ "path": "DUE_DILIGENCE.md",
7
+ "sha256": "ba1761daf4641891cbb3c019715104dde6e86d766fb1a29f926158e5a6186eae",
8
+ "size_bytes": 1223
9
+ },
10
+ {
11
+ "path": "final_proof/A_GRADE_PROMOTION_README.md",
12
+ "sha256": "5f2f3ea1974e43f1defa62831a6d79d1c4f2e66700fe1d5f6dc152514ce33939",
13
+ "size_bytes": 1489
14
+ },
15
+ {
16
+ "path": "final_proof/A_GRADE_PROMOTION_REPORT.json",
17
+ "sha256": "8ad18619c8e593c0f0e1d17864fa52a9882f9829feb27ac00560545fbdd6049a",
18
+ "size_bytes": 28860
19
+ },
20
+ {
21
+ "path": "final_proof/ARTIFACT_MANIFEST.json",
22
+ "sha256": "786f290fe46f735840da5622692ba2097c2c88fb14ec5238291f64d421ce013f",
23
+ "size_bytes": 7662
24
+ },
25
+ {
26
+ "path": "final_proof/CLEAN_REPRO_VERIFICATION.json",
27
+ "sha256": "5adda5d20e306a2c4d5cdcc316d669a99cb8d63043c055362862d43fb06f6d02",
28
+ "size_bytes": 15468
29
+ },
30
+ {
31
+ "path": "final_proof/FINAL_PROOF_README.md",
32
+ "sha256": "9dc65f1351b5891211a2762c76e33c3888f6d4e05e1f5dc33df0954e53d84da6",
33
+ "size_bytes": 5534
34
+ },
35
+ {
36
+ "path": "final_proof/FINAL_RECEIPT_SUMMARY.json",
37
+ "sha256": "e7a72987c737f87cd8ede33de7206349952a3ecc1a6c7f547d383c9c19abeee1",
38
+ "size_bytes": 25158
39
+ },
40
+ {
41
+ "path": "final_proof/KNOWN_LIMITS.md",
42
+ "sha256": "529ec1c050d1ada363dfc1bfce17d1be823b7f282a915678e7b895346da5efd4",
43
+ "size_bytes": 1306
44
+ },
45
+ {
46
+ "path": "final_proof/NO_COST_CONFIDENCE_README.md",
47
+ "sha256": "0da33294abcda04a421a4bb27ea02cd2d656983c6c75f28adc04ecb1b41bbab0",
48
+ "size_bytes": 1561
49
+ },
50
+ {
51
+ "path": "final_proof/NO_COST_CONFIDENCE_REPORT.json",
52
+ "sha256": "081061a5b5bdda980854336936b03218f083a150cc1120311da3364fb764a7d8",
53
+ "size_bytes": 28924
54
+ },
55
+ {
56
+ "path": "final_proof/REPRO_COMMANDS.txt",
57
+ "sha256": "975ba3c0ebdb7c5dd248e75ee4c03a5dd0ca832cf32e8917da920afa8667f363",
58
+ "size_bytes": 2043
59
+ },
60
+ {
61
+ "path": "final_proof/STATIC_ORACLE_REPLAY_REPORT.json",
62
+ "sha256": "55f09392a6a1166990c6349959fba676149e7d761bc1579c60636e8e2970a5a8",
63
+ "size_bytes": 18230
64
+ },
65
+ {
66
+ "path": "HF_PUBLICATION_MANIFEST.json",
67
+ "sha256": "baf84de3db93763c53c55b74c6baae728905ca4e79aab34a6fab46a99236b2a0",
68
+ "size_bytes": 8258
69
+ },
70
+ {
71
+ "path": "METHODOLOGY.md",
72
+ "sha256": "91f46037b3a525bd2284a0d7469156112054e2d32a8cb6a3e4f0c4445373f52b",
73
+ "size_bytes": 1526
74
+ },
75
+ {
76
+ "path": "modern_code/carddemo/__init__.py",
77
+ "sha256": "88e21b7382dd9fe71363fda8b550e14579b7b6efa15941a4fff87b2129d03edc",
78
+ "size_bytes": 55
79
+ },
80
+ {
81
+ "path": "modern_code/carddemo/api.py",
82
+ "sha256": "c9c66bc488f2e9cbb7c2b91cdd7a18feea97e8d65e9fce2590d7a05780ef65e6",
83
+ "size_bytes": 17553
84
+ },
85
+ {
86
+ "path": "modern_code/carddemo/cli.py",
87
+ "sha256": "28653d1b7f7797d31cdd2d57405807542c2b708822ec0d8fe58d6f728706f18e",
88
+ "size_bytes": 1443
89
+ },
90
+ {
91
+ "path": "modern_code/carddemo/legacy_parser.py",
92
+ "sha256": "fcf1123c214e8fd373ef6f80d0c318c295f90b3d971f217975962d2b0878385b",
93
+ "size_bytes": 12511
94
+ },
95
+ {
96
+ "path": "modern_code/carddemo/parity.py",
97
+ "sha256": "e749277f5f900a44b0a50c1208baa3f1b73016f5037653cb8288d2f9c572e527",
98
+ "size_bytes": 98504
99
+ },
100
+ {
101
+ "path": "modern_code/carddemo/repository.py",
102
+ "sha256": "bcb4198d782f88fdf41b07fde8bc3502e49de1d6bf2341bfa6c66d41f469b106",
103
+ "size_bytes": 11744
104
+ },
105
+ {
106
+ "path": "modern_code/carddemo/service.py",
107
+ "sha256": "f7ba4759d188c41e55ce2239e392f19409f1118c2aff4535dd29da3ed3b5d46e",
108
+ "size_bytes": 146360
109
+ },
110
+ {
111
+ "path": "modern_code/README.md",
112
+ "sha256": "373916dcb6ff772687cb824e26553529c971ddaa88531c55580e64a83f56484a",
113
+ "size_bytes": 8553
114
+ },
115
+ {
116
+ "path": "modern_code/static/app.js",
117
+ "sha256": "1322d5918649e8c57f714c6d6e4a7fff5cf0e83024ae2beae9534514158531bf",
118
+ "size_bytes": 20295
119
+ },
120
+ {
121
+ "path": "modern_code/static/index.html",
122
+ "sha256": "004cc27d08bb4ebe4dd78d0895fa97cb3bd97c987b426f95b17af245960ee322",
123
+ "size_bytes": 3386
124
+ },
125
+ {
126
+ "path": "modern_code/static/styles.css",
127
+ "sha256": "c416c17a163b560a88d2a816dd68701826ed9b21617ee3166205ec721f4fbd4b",
128
+ "size_bytes": 3822
129
+ },
130
+ {
131
+ "path": "modern_code/tests/test_a_grade_promotion.py",
132
+ "sha256": "ce335d767c4492cc8c78f7123aafa238afa97173938afca77c8641614a240dfb",
133
+ "size_bytes": 4022
134
+ },
135
+ {
136
+ "path": "modern_code/tests/test_hf_public_bundle.py",
137
+ "sha256": "53c0798a41d36b0df9ff29ed2c63a445b5a3152b2bcd1c290c4f657f66f95b1e",
138
+ "size_bytes": 3865
139
+ },
140
+ {
141
+ "path": "modern_code/tests/test_legacy_parser.py",
142
+ "sha256": "c0c949f0793328fe01bd7d0304f15507a59d3b3573400249f7c753be95d99379",
143
+ "size_bytes": 2935
144
+ },
145
+ {
146
+ "path": "modern_code/tests/test_no_cost_confidence.py",
147
+ "sha256": "ff1ab81e962269bb72f953929722857937fb6aed48ada518c33f767e76279551",
148
+ "size_bytes": 3542
149
+ },
150
+ {
151
+ "path": "modern_code/tests/test_parity.py",
152
+ "sha256": "a313fcddfd58a7790b30a8b601196dada407a043515f59399db0ac1e86d4815a",
153
+ "size_bytes": 12652
154
+ },
155
+ {
156
+ "path": "modern_code/tests/test_service.py",
157
+ "sha256": "b5c16936a031ad435a622bc1b00f4c7c4074e8bf5bbbeb7fc09e1e42090261f2",
158
+ "size_bytes": 40006
159
+ },
160
+ {
161
+ "path": "modern_code/tests/test_static_oracle_replay.py",
162
+ "sha256": "1c399d1ec36bc5f34c3379f4374df03e7a040da4636b0ee9db0cb90ece99a8aa",
163
+ "size_bytes": 2245
164
+ },
165
+ {
166
+ "path": "modern_code/tools/build_hf_public_bundle.py",
167
+ "sha256": "b4fa079c50b33f1a4b4ea497a37581e0e0e19fc7ffd42af7f4d54d2681b4aa47",
168
+ "size_bytes": 16171
169
+ },
170
+ {
171
+ "path": "modern_code/tools/build_no_cost_confidence.py",
172
+ "sha256": "1e9b63e25971041174c094e80f76fd8a84823dd2c5b5216dd3c40b787e000406",
173
+ "size_bytes": 20629
174
+ },
175
+ {
176
+ "path": "modern_code/tools/evaluate_a_grade_promotion.py",
177
+ "sha256": "fed8e1c221d0078971c2b692ce3ba04ade0ac6682203e68cc3a41292a069a3ca",
178
+ "size_bytes": 21030
179
+ },
180
+ {
181
+ "path": "modern_code/tools/generate_receipts.py",
182
+ "sha256": "ae376f9fbb319314e12d2ac59e8c59cb7bf65898c4b53db8edb536c92aeab6e1",
183
+ "size_bytes": 7332
184
+ },
185
+ {
186
+ "path": "modern_code/tools/package_final_proof.py",
187
+ "sha256": "d5595e8f8fa0da9d4d06f6b56a3100cecb9bd038620b56dd2f5090556f6f389b",
188
+ "size_bytes": 25482
189
+ },
190
+ {
191
+ "path": "modern_code/tools/replay_static_oracles.py",
192
+ "sha256": "be50faa32dfb4d9c1eb685f389e8976f481c3c761a71c99a31c22144a75f931b",
193
+ "size_bytes": 15393
194
+ },
195
+ {
196
+ "path": "modern_code/tools/verify_clean_repro.py",
197
+ "sha256": "27dea778fd820e427678ae24ff22b74d369a9ece5901e36f83394a3fd516481c",
198
+ "size_bytes": 10249
199
+ },
200
+ {
201
+ "path": "PUBLICATION_NOTES.md",
202
+ "sha256": "338803c95bda8a098211dca8008b363890ea57ba099eb8689f9e95f4f9c4e3ba",
203
+ "size_bytes": 520
204
+ },
205
+ {
206
+ "path": "README.md",
207
+ "sha256": "e16aac36654e08b761c308a0673deae0a1c057c33b213be1f389366aa3d8aac1",
208
+ "size_bytes": 3762
209
+ },
210
+ {
211
+ "path": "REPRODUCIBILITY.md",
212
+ "sha256": "e4f570ed3618fe4e87240fc7734ff82458deddead341de87e5432295dd8f95c2",
213
+ "size_bytes": 1126
214
+ }
215
+ ],
216
+ "generated_utc": "2026-05-23T15:02:36+00:00",
217
+ "hf_repo_id": "cjc0013/aws-carddemo-no-cost-modernization-proof",
218
+ "manifest_hash": "d58f22794bbd4eeec620cedf766e6f312a8702a8c56209c38a7ae8122e7d7441",
219
+ "modern_snapshot_file_count": 25,
220
+ "proof_file_count": 11,
221
+ "proof_summary": {
222
+ "B": 50,
223
+ "F": 0,
224
+ "a_promotable": false,
225
+ "gaps": 0,
226
+ "no_cost_reviewer_posture": "strong_pre_runtime_confidence"
227
+ },
228
+ "public_safe_checks": {
229
+ "live_runtime_equivalence_claim_made": false,
230
+ "original_source_tree_copied": false,
231
+ "paid_runtime_claim_made": false
232
+ },
233
+ "source_head": "59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e",
234
+ "source_repo": "https://github.com/aws-samples/aws-mainframe-modernization-carddemo.git"
235
+ }
METHODOLOGY.md ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Methodology
2
+
3
+ ## Goal
4
+
5
+ Produce the strongest practical modernization proof possible without paid or licensed legacy runtime infrastructure.
6
+
7
+ ## Method
8
+
9
+ 1. Pin the upstream AWS CardDemo source repository and commit.
10
+ 2. Hash the source files and generated modern files.
11
+ 3. Extract capabilities from legacy source, copybooks, BMS maps, JCL, seed data, and static contracts.
12
+ 4. Build a one-for-one capability ledger.
13
+ 5. Implement the modern Python/SQLite target against those source-derived contracts.
14
+ 6. Generate receipts, golden traces, edge cases, and parity reports.
15
+ 7. Execute the modern service against static/source-oracle replay checks.
16
+ 8. Run clean-copy reproduction and API smoke checks.
17
+ 9. Run a strict A-grade gate that refuses promotion without live legacy runtime traces.
18
+ 10. Publish the evidence with explicit boundaries.
19
+
20
+ ## Current Proof State
21
+
22
+ - B-grade static/source-oracle capabilities: `50`
23
+ - F-grade gaps: `0`
24
+ - Gap count: `0`
25
+ - Static replay passed: `True`
26
+ - No-cost confidence posture: `strong_pre_runtime_confidence`
27
+ - A-grade promotable: `False`
28
+
29
+ ## What Would Upgrade This To A
30
+
31
+ The A-grade gate requires accepted live legacy runtime trace records for every capability. Each record must bind a capability ID to the pinned source head, a live runtime trace kind, a raw legacy trace hash, a modern observation hash, a comparator version, and `matched=true`.
32
+
33
+ The current bundle has zero accepted live runtime matches because no paid/licensed legacy runtime was executed.
PUBLICATION_NOTES.md ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ # Publication Notes
2
+
3
+ - This is a proof artifact, not a production migration recommendation.
4
+ - The original AWS CardDemo source tree is not redistributed here.
5
+ - The modern code snapshot is provided for review of the local modernization artifact.
6
+ - The proof explicitly avoids claiming live COBOL/CICS equivalence.
7
+ - The phrase "strong pre-runtime confidence" means the no-cost checks passed; it does not mean production acceptance.
8
+ - Further proof requires paid/licensed or customer-owned legacy runtime access.
README.md ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ language:
4
+ - en
5
+ tags:
6
+ - mainframe-modernization
7
+ - cobol
8
+ - cics
9
+ - static-analysis
10
+ - verification
11
+ - reproducibility
12
+ - legacy-modernization
13
+ pretty_name: AWS CardDemo No-Cost Modernization Proof
14
+ ---
15
+
16
+ # AWS CardDemo No-Cost Modernization Proof
17
+
18
+ This repository publishes a reproducible proof bundle for a local modernization run against AWS CardDemo. It is intentionally **not** a claim of live COBOL/CICS all-path runtime equivalence.
19
+
20
+ Plainly: this is not a claim of live COBOL/CICS all-path runtime equivalence.
21
+
22
+ The practical claim is narrower and receipt-backed: we pushed the free/no-cost verification path as far as we reasonably could. The remaining validation requires a real or licensed-compatible legacy runtime for COBOL/CICS/VSAM/JCL execution.
23
+
24
+ In short: without paid/licensed legacy runtime access, this is as far as this proof can honestly go.
25
+
26
+ ## Headline Result
27
+
28
+ - Reviewer posture: `strong_pre_runtime_confidence`
29
+ - Ready for pre-runtime review: `True`
30
+ - Current static/source-oracle parity: `B=50 / F=0 / gaps=0`
31
+ - A-grade live runtime parity: `A=0`
32
+ - A-grade promotion gate: `do_not_promote`
33
+ - A-grade live matches accepted: `0`
34
+ - A-grade live matches missing: `50`
35
+ - Paid runtime used: `False`
36
+ - Legacy runtime equivalence claimed: `False`
37
+
38
+ ## Source Identity
39
+
40
+ - Upstream source repo: `https://github.com/aws-samples/aws-mainframe-modernization-carddemo.git`
41
+ - Upstream source commit: `59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e`
42
+ - Source files hashed in receipt: `204`
43
+ - Source hash digest: `0703f97553bde0f5bd170aa95ec8c771a975b397be7d9e8088ec6fbf31d333c2`
44
+
45
+ The upstream AWS CardDemo source tree is **not copied into this repository**. Clone it from the upstream project at the exact commit above when reproducing.
46
+
47
+ ## Evidence Included
48
+
49
+ - `final_proof/FINAL_PROOF_README.md`: technical reviewer entry point.
50
+ - `final_proof/FINAL_RECEIPT_SUMMARY.json`: machine-readable receipt summary.
51
+ - `final_proof/NO_COST_CONFIDENCE_REPORT.json`: no-cost confidence evidence and methodology.
52
+ - `final_proof/A_GRADE_PROMOTION_REPORT.json`: strict A-grade gate and why it does not promote without live traces.
53
+ - `final_proof/STATIC_ORACLE_REPLAY_REPORT.json`: executable modern replay over static/source-derived oracles.
54
+ - `METHODOLOGY.md`: evidence method and proof boundaries.
55
+ - `REPRODUCIBILITY.md`: one-command local checks.
56
+ - `DUE_DILIGENCE.md`: quick reviewer checklist.
57
+ - `modern_code/`: modern Python/SQLite implementation snapshot and proof tooling.
58
+
59
+ ## No-Cost Evidence Summary
60
+
61
+ - Capability count: `50`
62
+ - Static/source-oracle-ready capabilities: `50`
63
+ - Capability source references: `101`
64
+ - Golden traces: `34`
65
+ - Edge cases: `40`
66
+ - COBOL programs scanned: `44`
67
+ - CICS programs identified: `25`
68
+ - Free GnuCOBOL probe candidates: `17`
69
+
70
+ ## The Unpaid Boundary
71
+
72
+ We cannot honestly push this to live runtime parity without access to a real or licensed-compatible legacy execution environment. That means one of:
73
+
74
+ - AWS Mainframe Modernization runtime access,
75
+ - Micro Focus / Enterprise Server-style runtime access,
76
+ - UniKix or equivalent runtime access,
77
+ - a real z/OS/CICS/VSAM/JCL endpoint,
78
+ - or another compatible environment capable of executing the original legacy paths.
79
+
80
+ Without that, the correct remaining statement is: the modernization is strongly supported by source-derived static oracles and executable modern replay, but final production-equivalence validation must happen on the legacy runtime owner’s environment.
81
+
82
+ ## Repository Type
83
+
84
+ This is published as a Hugging Face dataset-style proof artifact, not a trained model and not a hosted runtime.
85
+
86
+ HF repo target used for staging: `cjc0013/aws-carddemo-no-cost-modernization-proof`
REPRODUCIBILITY.md ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Reproducibility
2
+
3
+ This bundle is reproducible with no paid legacy runtime, but it still requires cloning the upstream AWS source at the pinned commit.
4
+
5
+ ```powershell
6
+ git clone https://github.com/aws-samples/aws-mainframe-modernization-carddemo.git source
7
+ git -C source checkout 59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e
8
+ cd modern_code
9
+ powershell -NoProfile -Command "python -m carddemo.cli init-db --source-root ..\source --db-path .\carddemo.sqlite; python -m unittest discover -s tests; python tools\generate_receipts.py --source-root ..\source --db-path .\carddemo.sqlite --out-dir .\reports; python tools\replay_static_oracles.py --source-root ..\source --out-dir .\reports --source-head 59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e; python tools\evaluate_a_grade_promotion.py --source-root ..\source --out-dir .\final_proof; python tools\build_no_cost_confidence.py --source-root ..\source --out-dir .\final_proof; python tools\package_final_proof.py --source-root ..\source"
10
+ ```
11
+
12
+ For clean-copy reproduction, run:
13
+
14
+ ```powershell
15
+ python tools\verify_clean_repro.py --modern-root . --source-root ..\source
16
+ ```
final_proof/ARTIFACT_MANIFEST.json ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bundle_files": [
3
+ {
4
+ "absolute_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\final_proof\\FINAL_PROOF_README.md",
5
+ "exists": true,
6
+ "path": "FINAL_PROOF_README.md",
7
+ "role": "final_bundle_output",
8
+ "sha256": "9dc65f1351b5891211a2762c76e33c3888f6d4e05e1f5dc33df0954e53d84da6",
9
+ "size_bytes": 5534
10
+ },
11
+ {
12
+ "absolute_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\final_proof\\FINAL_RECEIPT_SUMMARY.json",
13
+ "exists": true,
14
+ "path": "FINAL_RECEIPT_SUMMARY.json",
15
+ "role": "final_bundle_output",
16
+ "sha256": "e7a72987c737f87cd8ede33de7206349952a3ecc1a6c7f547d383c9c19abeee1",
17
+ "size_bytes": 25158
18
+ },
19
+ {
20
+ "absolute_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\final_proof\\REPRO_COMMANDS.txt",
21
+ "exists": true,
22
+ "path": "REPRO_COMMANDS.txt",
23
+ "role": "final_bundle_output",
24
+ "sha256": "975ba3c0ebdb7c5dd248e75ee4c03a5dd0ca832cf32e8917da920afa8667f363",
25
+ "size_bytes": 2043
26
+ },
27
+ {
28
+ "absolute_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\final_proof\\STATIC_ORACLE_REPLAY_REPORT.json",
29
+ "exists": true,
30
+ "path": "STATIC_ORACLE_REPLAY_REPORT.json",
31
+ "role": "final_bundle_output",
32
+ "sha256": "55f09392a6a1166990c6349959fba676149e7d761bc1579c60636e8e2970a5a8",
33
+ "size_bytes": 18230
34
+ },
35
+ {
36
+ "absolute_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\final_proof\\KNOWN_LIMITS.md",
37
+ "exists": true,
38
+ "path": "KNOWN_LIMITS.md",
39
+ "role": "final_bundle_output",
40
+ "sha256": "529ec1c050d1ada363dfc1bfce17d1be823b7f282a915678e7b895346da5efd4",
41
+ "size_bytes": 1306
42
+ },
43
+ {
44
+ "absolute_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\final_proof\\A_GRADE_PROMOTION_REPORT.json",
45
+ "exists": true,
46
+ "path": "A_GRADE_PROMOTION_REPORT.json",
47
+ "role": "final_bundle_output",
48
+ "sha256": "8ad18619c8e593c0f0e1d17864fa52a9882f9829feb27ac00560545fbdd6049a",
49
+ "size_bytes": 28860
50
+ },
51
+ {
52
+ "absolute_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\final_proof\\A_GRADE_PROMOTION_README.md",
53
+ "exists": true,
54
+ "path": "A_GRADE_PROMOTION_README.md",
55
+ "role": "final_bundle_output",
56
+ "sha256": "5f2f3ea1974e43f1defa62831a6d79d1c4f2e66700fe1d5f6dc152514ce33939",
57
+ "size_bytes": 1489
58
+ },
59
+ {
60
+ "absolute_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\final_proof\\NO_COST_CONFIDENCE_REPORT.json",
61
+ "exists": true,
62
+ "path": "NO_COST_CONFIDENCE_REPORT.json",
63
+ "role": "final_bundle_output",
64
+ "sha256": "081061a5b5bdda980854336936b03218f083a150cc1120311da3364fb764a7d8",
65
+ "size_bytes": 28924
66
+ },
67
+ {
68
+ "absolute_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\final_proof\\NO_COST_CONFIDENCE_README.md",
69
+ "exists": true,
70
+ "path": "NO_COST_CONFIDENCE_README.md",
71
+ "role": "final_bundle_output",
72
+ "sha256": "0da33294abcda04a421a4bb27ea02cd2d656983c6c75f28adc04ecb1b41bbab0",
73
+ "size_bytes": 1561
74
+ }
75
+ ],
76
+ "bundle_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\final_proof",
77
+ "generated_utc": "2026-05-23T15:02:34+00:00",
78
+ "manifest_payload_hash": "5e97ab3467cc265a15902e1e9bd803c034744fc6487152b4a41389d364776f59",
79
+ "manifest_version": "carddemo_final_proof_manifest_v0",
80
+ "public_actions_allowed": false,
81
+ "referenced_existing_artifacts": [
82
+ {
83
+ "absolute_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\reports\\modernization_receipt.json",
84
+ "exists": true,
85
+ "path": "reports/modernization_receipt.json",
86
+ "role": "referenced_evidence",
87
+ "sha256": "fe8b6f2b11d60f9085c8b6b9fd37d8fa41012b390ffdded4207bf970131b3590",
88
+ "size_bytes": 27485
89
+ },
90
+ {
91
+ "absolute_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\reports\\parity_gap_report.json",
92
+ "exists": true,
93
+ "path": "reports/parity_gap_report.json",
94
+ "role": "referenced_evidence",
95
+ "sha256": "4fea2ff8f8383a188b0156f9c98876a32fc6aab7794e6a0cb3824ae5bd755c75",
96
+ "size_bytes": 2298
97
+ },
98
+ {
99
+ "absolute_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\reports\\capability_ledger.json",
100
+ "exists": true,
101
+ "path": "reports/capability_ledger.json",
102
+ "role": "referenced_evidence",
103
+ "sha256": "ef96f795ea230024bad6a8694898f8e31491a3e6ccc7e2b8879d0eea6cab0c97",
104
+ "size_bytes": 56984
105
+ },
106
+ {
107
+ "absolute_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\reports\\golden_traces.json",
108
+ "exists": true,
109
+ "path": "reports/golden_traces.json",
110
+ "role": "referenced_evidence",
111
+ "sha256": "076eb929e91912ffa6e8e633d79ca728e81980bad26bea4370f33b315a2d4eef",
112
+ "size_bytes": 22277
113
+ },
114
+ {
115
+ "absolute_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\reports\\edge_cases.json",
116
+ "exists": true,
117
+ "path": "reports/edge_cases.json",
118
+ "role": "referenced_evidence",
119
+ "sha256": "71bc1bb1be6e08528121e41195b07a4057e9ed6c4350c251e163442a16b3819a",
120
+ "size_bytes": 17467
121
+ },
122
+ {
123
+ "absolute_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\reports\\next_gap_ranking.json",
124
+ "exists": true,
125
+ "path": "reports/next_gap_ranking.json",
126
+ "role": "referenced_evidence",
127
+ "sha256": "4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945",
128
+ "size_bytes": 2
129
+ },
130
+ {
131
+ "absolute_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\reports\\static_oracle_replay.json",
132
+ "exists": true,
133
+ "path": "reports/static_oracle_replay.json",
134
+ "role": "referenced_evidence",
135
+ "sha256": "55f09392a6a1166990c6349959fba676149e7d761bc1579c60636e8e2970a5a8",
136
+ "size_bytes": 18230
137
+ },
138
+ {
139
+ "absolute_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\reports\\ui_batch_reports_smoke.png",
140
+ "exists": true,
141
+ "path": "reports/ui_batch_reports_smoke.png",
142
+ "role": "referenced_evidence",
143
+ "sha256": "f192f2b751ee902b70defbb5b49b745bbf8855a10bb8dc23d60e6c8bb9f6e537",
144
+ "size_bytes": 69723
145
+ },
146
+ {
147
+ "absolute_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\final_proof\\CLEAN_REPRO_VERIFICATION.json",
148
+ "exists": true,
149
+ "path": "final_proof/CLEAN_REPRO_VERIFICATION.json",
150
+ "role": "referenced_evidence",
151
+ "sha256": "5adda5d20e306a2c4d5cdcc316d669a99cb8d63043c055362862d43fb06f6d02",
152
+ "size_bytes": 15468
153
+ }
154
+ ]
155
+ }
final_proof/A_GRADE_PROMOTION_README.md ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AWS CardDemo A-Grade Promotion Gate
2
+
3
+ Report version: `carddemo_a_grade_promotion_readme_v0`
4
+
5
+ This file records the attempt to promote the AWS CardDemo modernization proof from B-grade static/source-oracle parity to A-grade live runtime parity.
6
+
7
+ ## Decision
8
+
9
+ - Action: `do_not_promote`
10
+ - Promotable to A: `False`
11
+ - Current grade counts: `{'A': 0, 'B': 50, 'C': 0, 'F': 0}`
12
+ - Required live legacy runtime matches: `50`
13
+ - Accepted live legacy runtime matches: `0`
14
+ - Missing live legacy runtime matches: `50`
15
+ - Current static/source-oracle status: B=`50`, F=`0`, gaps=`0`
16
+
17
+ ## Rubric Boundary
18
+
19
+ A-grade is reserved for actual legacy COBOL/CICS runtime traces matched against modern observed behavior for each capability. The existing proof remains B=50/F=0/gaps=0 under the current static/source-oracle rubric.
20
+
21
+ This is not live COBOL/CICS all-path runtime equivalence.
22
+
23
+ ## Replay Command
24
+
25
+ ```powershell
26
+ python tools\evaluate_a_grade_promotion.py --source-root ..\source --out-dir .\final_proof
27
+ ```
28
+
29
+ To test a future live trace corpus, add:
30
+
31
+ ```powershell
32
+ --legacy-trace-dir <path-to-live-trace-json-corpus>
33
+ ```
34
+
35
+ ## Required Trace Contract
36
+
37
+ Each accepted live trace record must include the fields listed in `A_GRADE_PROMOTION_REPORT.json` under `legacy_runtime_trace_contract`. The key requirements are: pinned source head, live trace kind, matched=true, a capability ID from the ledger, and SHA-256 hashes for the raw legacy trace and modern observation.
final_proof/A_GRADE_PROMOTION_REPORT.json ADDED
@@ -0,0 +1,867 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "a_grade_gate": {
3
+ "accepted_live_matches": 0,
4
+ "current_A": 0,
5
+ "missing_capability_ids": [
6
+ "batch:ACCTFILE",
7
+ "batch:CARDFILE",
8
+ "batch:CBPAUP0J",
9
+ "batch:CLOSEFIL",
10
+ "batch:COMBTRAN",
11
+ "batch:CREADB21",
12
+ "batch:CREASTMT",
13
+ "batch:CUSTFILE",
14
+ "batch:DEFGDGB",
15
+ "batch:DEFGDGD",
16
+ "batch:DISCGRP",
17
+ "batch:DUSRSECJ",
18
+ "batch:ESDSRRDS",
19
+ "batch:INTCALC",
20
+ "batch:MNTTRDB2",
21
+ "batch:OPENFIL",
22
+ "batch:POSTTRAN",
23
+ "batch:TCATBALF",
24
+ "batch:TRANBKP",
25
+ "batch:TRANCATG",
26
+ "batch:TRANEXTR",
27
+ "batch:TRANFILE",
28
+ "batch:TRANIDX",
29
+ "batch:TRANREPT",
30
+ "batch:TRANTYPE",
31
+ "batch:XREFFILE",
32
+ "online:CA00",
33
+ "online:CAUP",
34
+ "online:CAVW",
35
+ "online:CB00",
36
+ "online:CC00",
37
+ "online:CCDL",
38
+ "online:CCLI",
39
+ "online:CCUP",
40
+ "online:CDRA",
41
+ "online:CDRD",
42
+ "online:CM00",
43
+ "online:CP00",
44
+ "online:CPVD",
45
+ "online:CPVS",
46
+ "online:CR00",
47
+ "online:CT00",
48
+ "online:CT01",
49
+ "online:CT02",
50
+ "online:CTLI",
51
+ "online:CTTU",
52
+ "online:CU00",
53
+ "online:CU01",
54
+ "online:CU02",
55
+ "online:CU03"
56
+ ],
57
+ "missing_live_matches": 50,
58
+ "promotable_to_A": false,
59
+ "proposed_grade_counts_if_gate_passes": {
60
+ "A": 0,
61
+ "B": 50,
62
+ "C": 0,
63
+ "F": 0
64
+ },
65
+ "required_live_matches": 50,
66
+ "target_A": 50
67
+ },
68
+ "blockers": [
69
+ {
70
+ "code": "missing_live_legacy_trace_corpus",
71
+ "detail": "A-grade requires accepted live legacy runtime matches for all 50 capabilities; accepted=0, missing=50."
72
+ },
73
+ {
74
+ "code": "runtime_assets_not_execution_evidence",
75
+ "detail": "AWS M2/Micro Focus/UniKix package artifacts were found, but this run did not execute them to produce COBOL/CICS transaction traces."
76
+ },
77
+ {
78
+ "code": "no_local_mainframe_or_aws_runtime_path_detected",
79
+ "detail": "Neither AWS CLI nor a local mainframe emulator was detected for a runtime capture path."
80
+ },
81
+ {
82
+ "code": "static_oracle_is_not_a_grade",
83
+ "detail": "The current B=50 proof is strong static/source-oracle evidence, but A requires live runtime traces."
84
+ }
85
+ ],
86
+ "capability_match_status": [
87
+ {
88
+ "a_grade_match_found": false,
89
+ "accepted_trace": null,
90
+ "capability_id": "batch:ACCTFILE",
91
+ "current_proof_grade": "B",
92
+ "function": "Refresh Account Master",
93
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
94
+ "program": "IDCAMS",
95
+ "surface": "batch",
96
+ "transaction": ""
97
+ },
98
+ {
99
+ "a_grade_match_found": false,
100
+ "accepted_trace": null,
101
+ "capability_id": "batch:CARDFILE",
102
+ "current_proof_grade": "B",
103
+ "function": "Refresh Card Master",
104
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
105
+ "program": "IDCAMS",
106
+ "surface": "batch",
107
+ "transaction": ""
108
+ },
109
+ {
110
+ "a_grade_match_found": false,
111
+ "accepted_trace": null,
112
+ "capability_id": "batch:CBPAUP0J",
113
+ "current_proof_grade": "B",
114
+ "function": "Purge Expired Authorizations",
115
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
116
+ "program": "CBPAUP0C",
117
+ "surface": "batch",
118
+ "transaction": ""
119
+ },
120
+ {
121
+ "a_grade_match_found": false,
122
+ "accepted_trace": null,
123
+ "capability_id": "batch:CLOSEFIL",
124
+ "current_proof_grade": "B",
125
+ "function": "Close VSAM files in CICS",
126
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
127
+ "program": "IEFBR14",
128
+ "surface": "batch",
129
+ "transaction": ""
130
+ },
131
+ {
132
+ "a_grade_match_found": false,
133
+ "accepted_trace": null,
134
+ "capability_id": "batch:COMBTRAN",
135
+ "current_proof_grade": "B",
136
+ "function": "Combine transaction files",
137
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
138
+ "program": "SORT",
139
+ "surface": "batch",
140
+ "transaction": ""
141
+ },
142
+ {
143
+ "a_grade_match_found": false,
144
+ "accepted_trace": null,
145
+ "capability_id": "batch:CREADB21",
146
+ "current_proof_grade": "B",
147
+ "function": "Creates CardDemo Db2 database and loads tables",
148
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
149
+ "program": "DSNTEP4",
150
+ "surface": "batch",
151
+ "transaction": ""
152
+ },
153
+ {
154
+ "a_grade_match_found": false,
155
+ "accepted_trace": null,
156
+ "capability_id": "batch:CREASTMT",
157
+ "current_proof_grade": "B",
158
+ "function": "Produce transaction statement",
159
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
160
+ "program": "CBSTM03A",
161
+ "surface": "batch",
162
+ "transaction": ""
163
+ },
164
+ {
165
+ "a_grade_match_found": false,
166
+ "accepted_trace": null,
167
+ "capability_id": "batch:CUSTFILE",
168
+ "current_proof_grade": "B",
169
+ "function": "Refresh Customer Master",
170
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
171
+ "program": "IDCAMS",
172
+ "surface": "batch",
173
+ "transaction": ""
174
+ },
175
+ {
176
+ "a_grade_match_found": false,
177
+ "accepted_trace": null,
178
+ "capability_id": "batch:DEFGDGB",
179
+ "current_proof_grade": "B",
180
+ "function": "Setup GDG Bases",
181
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
182
+ "program": "IDCAMS",
183
+ "surface": "batch",
184
+ "transaction": ""
185
+ },
186
+ {
187
+ "a_grade_match_found": false,
188
+ "accepted_trace": null,
189
+ "capability_id": "batch:DEFGDGD",
190
+ "current_proof_grade": "B",
191
+ "function": "Setup more GDG Bases for Db2",
192
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
193
+ "program": "IDCAMS",
194
+ "surface": "batch",
195
+ "transaction": ""
196
+ },
197
+ {
198
+ "a_grade_match_found": false,
199
+ "accepted_trace": null,
200
+ "capability_id": "batch:DISCGRP",
201
+ "current_proof_grade": "B",
202
+ "function": "Load Disclosure Group File",
203
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
204
+ "program": "IDCAMS",
205
+ "surface": "batch",
206
+ "transaction": ""
207
+ },
208
+ {
209
+ "a_grade_match_found": false,
210
+ "accepted_trace": null,
211
+ "capability_id": "batch:DUSRSECJ",
212
+ "current_proof_grade": "B",
213
+ "function": "Initial Load of User security file",
214
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
215
+ "program": "IEBGENER",
216
+ "surface": "batch",
217
+ "transaction": ""
218
+ },
219
+ {
220
+ "a_grade_match_found": false,
221
+ "accepted_trace": null,
222
+ "capability_id": "batch:ESDSRRDS",
223
+ "current_proof_grade": "B",
224
+ "function": "Create ESDS and RRDS VSAM files",
225
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
226
+ "program": "IDCAMS",
227
+ "surface": "batch",
228
+ "transaction": ""
229
+ },
230
+ {
231
+ "a_grade_match_found": false,
232
+ "accepted_trace": null,
233
+ "capability_id": "batch:INTCALC",
234
+ "current_proof_grade": "B",
235
+ "function": "Run interest calculations",
236
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
237
+ "program": "CBACT04C",
238
+ "surface": "batch",
239
+ "transaction": ""
240
+ },
241
+ {
242
+ "a_grade_match_found": false,
243
+ "accepted_trace": null,
244
+ "capability_id": "batch:MNTTRDB2",
245
+ "current_proof_grade": "B",
246
+ "function": "Maintain Transaction type table",
247
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
248
+ "program": "COBTUPDT",
249
+ "surface": "batch",
250
+ "transaction": ""
251
+ },
252
+ {
253
+ "a_grade_match_found": false,
254
+ "accepted_trace": null,
255
+ "capability_id": "batch:OPENFIL",
256
+ "current_proof_grade": "B",
257
+ "function": "Open files in CICS",
258
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
259
+ "program": "IEFBR14",
260
+ "surface": "batch",
261
+ "transaction": ""
262
+ },
263
+ {
264
+ "a_grade_match_found": false,
265
+ "accepted_trace": null,
266
+ "capability_id": "batch:POSTTRAN",
267
+ "current_proof_grade": "B",
268
+ "function": "Transaction processing job",
269
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
270
+ "program": "CBTRN02C",
271
+ "surface": "batch",
272
+ "transaction": ""
273
+ },
274
+ {
275
+ "a_grade_match_found": false,
276
+ "accepted_trace": null,
277
+ "capability_id": "batch:TCATBALF",
278
+ "current_proof_grade": "B",
279
+ "function": "Refresh Transaction Category Balance",
280
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
281
+ "program": "IDCAMS",
282
+ "surface": "batch",
283
+ "transaction": ""
284
+ },
285
+ {
286
+ "a_grade_match_found": false,
287
+ "accepted_trace": null,
288
+ "capability_id": "batch:TRANBKP",
289
+ "current_proof_grade": "B",
290
+ "function": "Refresh Transaction Master",
291
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
292
+ "program": "IDCAMS",
293
+ "surface": "batch",
294
+ "transaction": ""
295
+ },
296
+ {
297
+ "a_grade_match_found": false,
298
+ "accepted_trace": null,
299
+ "capability_id": "batch:TRANCATG",
300
+ "current_proof_grade": "B",
301
+ "function": "Load Transaction category types",
302
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
303
+ "program": "IDCAMS",
304
+ "surface": "batch",
305
+ "transaction": ""
306
+ },
307
+ {
308
+ "a_grade_match_found": false,
309
+ "accepted_trace": null,
310
+ "capability_id": "batch:TRANEXTR",
311
+ "current_proof_grade": "B",
312
+ "function": "Extracts latest Db2 data for Transaction types",
313
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
314
+ "program": "DSNTIAUL",
315
+ "surface": "batch",
316
+ "transaction": ""
317
+ },
318
+ {
319
+ "a_grade_match_found": false,
320
+ "accepted_trace": null,
321
+ "capability_id": "batch:TRANFILE",
322
+ "current_proof_grade": "B",
323
+ "function": "Load Transaction Master file",
324
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
325
+ "program": "IDCAMS",
326
+ "surface": "batch",
327
+ "transaction": ""
328
+ },
329
+ {
330
+ "a_grade_match_found": false,
331
+ "accepted_trace": null,
332
+ "capability_id": "batch:TRANIDX",
333
+ "current_proof_grade": "B",
334
+ "function": "Define AIX for transaction file",
335
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
336
+ "program": "IDCAMS",
337
+ "surface": "batch",
338
+ "transaction": ""
339
+ },
340
+ {
341
+ "a_grade_match_found": false,
342
+ "accepted_trace": null,
343
+ "capability_id": "batch:TRANREPT",
344
+ "current_proof_grade": "B",
345
+ "function": "Transaction Report - Submitted from CICS",
346
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
347
+ "program": "CBTRN03C",
348
+ "surface": "batch",
349
+ "transaction": ""
350
+ },
351
+ {
352
+ "a_grade_match_found": false,
353
+ "accepted_trace": null,
354
+ "capability_id": "batch:TRANTYPE",
355
+ "current_proof_grade": "B",
356
+ "function": "Load Transaction type file",
357
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
358
+ "program": "IDCAMS",
359
+ "surface": "batch",
360
+ "transaction": ""
361
+ },
362
+ {
363
+ "a_grade_match_found": false,
364
+ "accepted_trace": null,
365
+ "capability_id": "batch:XREFFILE",
366
+ "current_proof_grade": "B",
367
+ "function": "Account, Card and Customer cross reference",
368
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
369
+ "program": "IDCAMS",
370
+ "surface": "batch",
371
+ "transaction": ""
372
+ },
373
+ {
374
+ "a_grade_match_found": false,
375
+ "accepted_trace": null,
376
+ "capability_id": "online:CA00",
377
+ "current_proof_grade": "B",
378
+ "function": "Admin Menu",
379
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
380
+ "program": "COADM01C",
381
+ "surface": "online",
382
+ "transaction": "CA00"
383
+ },
384
+ {
385
+ "a_grade_match_found": false,
386
+ "accepted_trace": null,
387
+ "capability_id": "online:CAUP",
388
+ "current_proof_grade": "B",
389
+ "function": "Account Update",
390
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
391
+ "program": "COACTUPC",
392
+ "surface": "online",
393
+ "transaction": "CAUP"
394
+ },
395
+ {
396
+ "a_grade_match_found": false,
397
+ "accepted_trace": null,
398
+ "capability_id": "online:CAVW",
399
+ "current_proof_grade": "B",
400
+ "function": "Account View",
401
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
402
+ "program": "COACTVWC",
403
+ "surface": "online",
404
+ "transaction": "CAVW"
405
+ },
406
+ {
407
+ "a_grade_match_found": false,
408
+ "accepted_trace": null,
409
+ "capability_id": "online:CB00",
410
+ "current_proof_grade": "B",
411
+ "function": "Bill Payment",
412
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
413
+ "program": "COBIL00C",
414
+ "surface": "online",
415
+ "transaction": "CB00"
416
+ },
417
+ {
418
+ "a_grade_match_found": false,
419
+ "accepted_trace": null,
420
+ "capability_id": "online:CC00",
421
+ "current_proof_grade": "B",
422
+ "function": "Signon Screen",
423
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
424
+ "program": "COSGN00C",
425
+ "surface": "online",
426
+ "transaction": "CC00"
427
+ },
428
+ {
429
+ "a_grade_match_found": false,
430
+ "accepted_trace": null,
431
+ "capability_id": "online:CCDL",
432
+ "current_proof_grade": "B",
433
+ "function": "Credit Card View",
434
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
435
+ "program": "COCRDSLC",
436
+ "surface": "online",
437
+ "transaction": "CCDL"
438
+ },
439
+ {
440
+ "a_grade_match_found": false,
441
+ "accepted_trace": null,
442
+ "capability_id": "online:CCLI",
443
+ "current_proof_grade": "B",
444
+ "function": "Credit Card List",
445
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
446
+ "program": "COCRDLIC",
447
+ "surface": "online",
448
+ "transaction": "CCLI"
449
+ },
450
+ {
451
+ "a_grade_match_found": false,
452
+ "accepted_trace": null,
453
+ "capability_id": "online:CCUP",
454
+ "current_proof_grade": "B",
455
+ "function": "Credit Card Update",
456
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
457
+ "program": "COCRDUPC",
458
+ "surface": "online",
459
+ "transaction": "CCUP"
460
+ },
461
+ {
462
+ "a_grade_match_found": false,
463
+ "accepted_trace": null,
464
+ "capability_id": "online:CDRA",
465
+ "current_proof_grade": "B",
466
+ "function": "Inquire account details via MQ",
467
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
468
+ "program": "COACCT01",
469
+ "surface": "online",
470
+ "transaction": "CDRA"
471
+ },
472
+ {
473
+ "a_grade_match_found": false,
474
+ "accepted_trace": null,
475
+ "capability_id": "online:CDRD",
476
+ "current_proof_grade": "B",
477
+ "function": "Inquire System Date via MQ",
478
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
479
+ "program": "CODATE01",
480
+ "surface": "online",
481
+ "transaction": "CDRD"
482
+ },
483
+ {
484
+ "a_grade_match_found": false,
485
+ "accepted_trace": null,
486
+ "capability_id": "online:CM00",
487
+ "current_proof_grade": "B",
488
+ "function": "Main Menu",
489
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
490
+ "program": "COMEN01C",
491
+ "surface": "online",
492
+ "transaction": "CM00"
493
+ },
494
+ {
495
+ "a_grade_match_found": false,
496
+ "accepted_trace": null,
497
+ "capability_id": "online:CP00",
498
+ "current_proof_grade": "B",
499
+ "function": "Process Authorization Requests",
500
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
501
+ "program": "COPAUA0C",
502
+ "surface": "online",
503
+ "transaction": "CP00"
504
+ },
505
+ {
506
+ "a_grade_match_found": false,
507
+ "accepted_trace": null,
508
+ "capability_id": "online:CPVD",
509
+ "current_proof_grade": "B",
510
+ "function": "Pending Authorization Details",
511
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
512
+ "program": "COPAUS1C",
513
+ "surface": "online",
514
+ "transaction": "CPVD"
515
+ },
516
+ {
517
+ "a_grade_match_found": false,
518
+ "accepted_trace": null,
519
+ "capability_id": "online:CPVS",
520
+ "current_proof_grade": "B",
521
+ "function": "Pending Authorization Summary",
522
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
523
+ "program": "COPAUS0C",
524
+ "surface": "online",
525
+ "transaction": "CPVS"
526
+ },
527
+ {
528
+ "a_grade_match_found": false,
529
+ "accepted_trace": null,
530
+ "capability_id": "online:CR00",
531
+ "current_proof_grade": "B",
532
+ "function": "Transaction Reports",
533
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
534
+ "program": "CORPT00C",
535
+ "surface": "online",
536
+ "transaction": "CR00"
537
+ },
538
+ {
539
+ "a_grade_match_found": false,
540
+ "accepted_trace": null,
541
+ "capability_id": "online:CT00",
542
+ "current_proof_grade": "B",
543
+ "function": "Transaction List",
544
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
545
+ "program": "COTRN00C",
546
+ "surface": "online",
547
+ "transaction": "CT00"
548
+ },
549
+ {
550
+ "a_grade_match_found": false,
551
+ "accepted_trace": null,
552
+ "capability_id": "online:CT01",
553
+ "current_proof_grade": "B",
554
+ "function": "Transaction View",
555
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
556
+ "program": "COTRN01C",
557
+ "surface": "online",
558
+ "transaction": "CT01"
559
+ },
560
+ {
561
+ "a_grade_match_found": false,
562
+ "accepted_trace": null,
563
+ "capability_id": "online:CT02",
564
+ "current_proof_grade": "B",
565
+ "function": "Transaction Add",
566
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
567
+ "program": "COTRN02C",
568
+ "surface": "online",
569
+ "transaction": "CT02"
570
+ },
571
+ {
572
+ "a_grade_match_found": false,
573
+ "accepted_trace": null,
574
+ "capability_id": "online:CTLI",
575
+ "current_proof_grade": "B",
576
+ "function": "Tran Type list/update/delete",
577
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
578
+ "program": "COTRTLIC",
579
+ "surface": "online",
580
+ "transaction": "CTLI"
581
+ },
582
+ {
583
+ "a_grade_match_found": false,
584
+ "accepted_trace": null,
585
+ "capability_id": "online:CTTU",
586
+ "current_proof_grade": "B",
587
+ "function": "Tran Type add/edit",
588
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
589
+ "program": "COTRTUPC",
590
+ "surface": "online",
591
+ "transaction": "CTTU"
592
+ },
593
+ {
594
+ "a_grade_match_found": false,
595
+ "accepted_trace": null,
596
+ "capability_id": "online:CU00",
597
+ "current_proof_grade": "B",
598
+ "function": "List Users",
599
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
600
+ "program": "COUSR00C",
601
+ "surface": "online",
602
+ "transaction": "CU00"
603
+ },
604
+ {
605
+ "a_grade_match_found": false,
606
+ "accepted_trace": null,
607
+ "capability_id": "online:CU01",
608
+ "current_proof_grade": "B",
609
+ "function": "Add User",
610
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
611
+ "program": "COUSR01C",
612
+ "surface": "online",
613
+ "transaction": "CU01"
614
+ },
615
+ {
616
+ "a_grade_match_found": false,
617
+ "accepted_trace": null,
618
+ "capability_id": "online:CU02",
619
+ "current_proof_grade": "B",
620
+ "function": "Update User",
621
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
622
+ "program": "COUSR02C",
623
+ "surface": "online",
624
+ "transaction": "CU02"
625
+ },
626
+ {
627
+ "a_grade_match_found": false,
628
+ "accepted_trace": null,
629
+ "capability_id": "online:CU03",
630
+ "current_proof_grade": "B",
631
+ "function": "Delete User",
632
+ "missing_reason": "no_accepted_live_legacy_runtime_trace",
633
+ "program": "COUSR03C",
634
+ "surface": "online",
635
+ "transaction": "CU03"
636
+ }
637
+ ],
638
+ "current_static_source_oracle_status": {
639
+ "capability_count": 50,
640
+ "gap_count": 0,
641
+ "grade_counts": {
642
+ "A": 0,
643
+ "B": 50,
644
+ "C": 0,
645
+ "F": 0
646
+ },
647
+ "receipt_generated_utc": "2026-05-23T15:01:51+00:00",
648
+ "receipt_hash": "fea9dfeca8e1b400afe6fbf4a25f92282a6330da0bb031f87b8dbd6e41044819",
649
+ "static_oracle_or_better_count": 50,
650
+ "strict_runtime_parity_count": 0
651
+ },
652
+ "decision": {
653
+ "action": "do_not_promote",
654
+ "next_non_human_path": [
655
+ "Run the pinned AWS CardDemo source in an AWS M2/mainframe-compatible runtime.",
656
+ "Capture transaction and batch outputs for each capability ID in reports/capability_ledger.json.",
657
+ "Replay the same inputs through the modern Python/SQLite service.",
658
+ "Emit JSON trace records satisfying legacy_runtime_trace_contract.",
659
+ "Rerun this gate with --legacy-trace-dir pointing at that corpus."
660
+ ],
661
+ "why": "The current bundle proves B=50/F=0/gaps=0 under the static/source-oracle rubric, but it does not contain accepted live COBOL/CICS runtime traces for all capabilities."
662
+ },
663
+ "generated_utc": "2026-05-23T15:01:52+00:00",
664
+ "legacy_runtime_environment_assessment": {
665
+ "local_execution_path_found": false,
666
+ "local_execution_path_reason": "No runnable COBOL/CICS/VSAM/JCL runtime was executed in this workspace. Static replay and modern API tests are not live legacy execution.",
667
+ "runtime_assets": [
668
+ {
669
+ "entry_count": 112,
670
+ "exists": true,
671
+ "has_app_config": true,
672
+ "has_catalog_data": false,
673
+ "has_catalog_jcl": false,
674
+ "has_shared_load_modules": false,
675
+ "has_unikix_layout": false,
676
+ "path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\source\\samples\\m2\\mf\\CardDemo_runtime.zip",
677
+ "runtime_conclusion": "Deployment/runtime asset detected. This is useful provenance, but it is not a live executed COBOL/CICS trace corpus by itself.",
678
+ "sample_entries": [
679
+ "loadlib/",
680
+ "loadlib/COCRDUPC.so",
681
+ "loadlib/COTRN02.MOD",
682
+ "loadlib/CBACT02C.so",
683
+ "loadlib/COUSR02C.so",
684
+ "loadlib/CORPT00C.so",
685
+ "loadlib/COUSR03C.so",
686
+ "loadlib/CBACT03C.so",
687
+ "loadlib/COTRN01.MOD",
688
+ "loadlib/CBACT01C.so",
689
+ "loadlib/COACTVW.MOD",
690
+ "loadlib/COSGN00.MOD",
691
+ "loadlib/COUSR01C.so",
692
+ "loadlib/COACTUPC.so",
693
+ "loadlib/COUSR00C.so",
694
+ "loadlib/CBSTM03B.so",
695
+ "loadlib/COTRN00.MOD",
696
+ "loadlib/CBACT04C.so",
697
+ "loadlib/COBIL00C.so",
698
+ "loadlib/COCRDLI.MOD",
699
+ "loadlib/CBCUS01C.so",
700
+ "loadlib/COCRDSL.MOD",
701
+ "loadlib/COMEN01.MOD",
702
+ "loadlib/COADM01.MOD",
703
+ "loadlib/COMEN01C.so",
704
+ "loadlib/COCRDSLC.so",
705
+ "loadlib/CBTRN03C.so",
706
+ "loadlib/CBTRN02C.so",
707
+ "loadlib/COADM01C.so",
708
+ "loadlib/CBTRN01C.so"
709
+ ],
710
+ "sha256": "683ef5bb461553ae9cee17c8c115f63bcb241ddeb832a2f1c62e8f96e9dbe2e3",
711
+ "size_bytes": 468566
712
+ },
713
+ {
714
+ "entry_count": 381,
715
+ "exists": true,
716
+ "has_app_config": false,
717
+ "has_catalog_data": false,
718
+ "has_catalog_jcl": false,
719
+ "has_shared_load_modules": false,
720
+ "has_unikix_layout": true,
721
+ "path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\source\\samples\\m2\\unikix\\UniKix_CardDemo_runtime_v1.zip",
722
+ "runtime_conclusion": "Deployment/runtime asset detected. This is useful provenance, but it is not a live executed COBOL/CICS trace corpus by itself.",
723
+ "sample_entries": [
724
+ "bin/",
725
+ "__MACOSX/._bin",
726
+ "bin/compbms",
727
+ "__MACOSX/bin/._compbms",
728
+ "bin/compile.all",
729
+ "__MACOSX/bin/._compile.all",
730
+ "bin/carddemo.env",
731
+ "bin/create_project",
732
+ "__MACOSX/bin/._create_project",
733
+ "bin/compile",
734
+ "__MACOSX/bin/._compile",
735
+ "bin/compbms.all",
736
+ "__MACOSX/bin/._compbms.all",
737
+ "bin/deploy_app",
738
+ "__MACOSX/bin/._deploy_app",
739
+ "migrated_app/",
740
+ "__MACOSX/._migrated_app",
741
+ "migrated_app/proc/",
742
+ "migrated_app/.DS_Store",
743
+ "__MACOSX/migrated_app/._.DS_Store",
744
+ "migrated_app/jcl/",
745
+ "migrated_app/catlg/",
746
+ "migrated_app/cpy-bms/",
747
+ "migrated_app/bms/",
748
+ "migrated_app/cbl/",
749
+ "migrated_app/cpy/",
750
+ "migrated_app/ctl/",
751
+ "migrated_app/data/",
752
+ "migrated_app/proc/REPROC",
753
+ "__MACOSX/migrated_app/proc/._REPROC"
754
+ ],
755
+ "sha256": "431f67920a1e9b980cc21a6de1a375aac0c21b62d256c584d109ff7735c436ca",
756
+ "size_bytes": 434174
757
+ }
758
+ ],
759
+ "source_prerequisites": [
760
+ "mainframe environment with CICS, VSAM, and JCL support",
761
+ "optional DB2, IMS DB, and MQ paths for optional modules"
762
+ ],
763
+ "tooling_probe": {
764
+ "aws": {
765
+ "path": null,
766
+ "present": false,
767
+ "purpose": "AWS CLI; needed for AWS-hosted M2/Mainframe runtime paths.",
768
+ "tool": "aws"
769
+ },
770
+ "cobc": {
771
+ "path": null,
772
+ "present": false,
773
+ "purpose": "GnuCOBOL compiler; useful for limited COBOL probes, not sufficient for CICS/VSAM/JCL parity.",
774
+ "tool": "cobc"
775
+ },
776
+ "docker": {
777
+ "path": "C:\\Program Files\\Docker\\Docker\\resources\\bin\\docker.EXE",
778
+ "present": true,
779
+ "purpose": "Container runtime; useful only when a licensed/runnable legacy runtime image exists.",
780
+ "tool": "docker",
781
+ "version_probe_ok": true,
782
+ "version_probe_output": "\"29.1.2\"",
783
+ "version_probe_returncode": 0
784
+ },
785
+ "gradle": {
786
+ "path": null,
787
+ "present": false,
788
+ "purpose": "Gradle; useful for Java-based runtime harnesses.",
789
+ "tool": "gradle"
790
+ },
791
+ "hercules": {
792
+ "path": null,
793
+ "present": false,
794
+ "purpose": "Mainframe emulator; still not a CICS/VSAM/JCL runtime by itself.",
795
+ "tool": "hercules"
796
+ },
797
+ "java": {
798
+ "path": null,
799
+ "present": false,
800
+ "purpose": "JVM; required by several migration/runtime toolchains.",
801
+ "tool": "java"
802
+ },
803
+ "mvn": {
804
+ "path": null,
805
+ "present": false,
806
+ "purpose": "Maven; useful for Java-based runtime harnesses.",
807
+ "tool": "mvn"
808
+ },
809
+ "tn3270": {
810
+ "path": null,
811
+ "present": false,
812
+ "purpose": "3270 terminal client; useful for interactive CICS transaction capture.",
813
+ "tool": "tn3270"
814
+ }
815
+ }
816
+ },
817
+ "legacy_runtime_trace_contract": {
818
+ "accepted_trace_kinds": [
819
+ "live_cobol_cics_runtime",
820
+ "live_mainframe_runtime"
821
+ ],
822
+ "field_rules": {
823
+ "capability_id": "must match one ID in reports/capability_ledger.json",
824
+ "hash_fields": "64-character SHA-256 hex digests",
825
+ "matched": true,
826
+ "source_head": "59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e"
827
+ },
828
+ "required_fields": [
829
+ "capability_id",
830
+ "trace_kind",
831
+ "source_head",
832
+ "legacy_runtime_environment",
833
+ "modern_observation_hash",
834
+ "comparator_version",
835
+ "matched",
836
+ "raw_legacy_trace_hash or legacy_runtime_trace_hash"
837
+ ]
838
+ },
839
+ "live_trace_scan": {
840
+ "accepted_matches": {},
841
+ "files_scanned": [],
842
+ "rejected_records": [],
843
+ "trace_dir": null,
844
+ "trace_dir_exists": false
845
+ },
846
+ "modern_code": {
847
+ "local_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo"
848
+ },
849
+ "public_actions_allowed": false,
850
+ "report_hash": "4f962c34517806cf2dee00f3fdd0b7c4f51e9ec3f5935eedfabd04104e3ad3af",
851
+ "report_version": "carddemo_a_grade_promotion_gate_v0",
852
+ "requested_target": {
853
+ "capability_count": 50,
854
+ "grade": "A",
855
+ "scope": "all capabilities"
856
+ },
857
+ "rubric": {
858
+ "A": "actual legacy COBOL/CICS runtime trace matched to modern observed behavior for the capability",
859
+ "B": "static legacy data/copybook/source-oracle match plus executable modern-service replay",
860
+ "F": "known parity gap or missing capability under the current rubric"
861
+ },
862
+ "source": {
863
+ "head": "59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e",
864
+ "local_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\source",
865
+ "repo_url": "https://github.com/aws-samples/aws-mainframe-modernization-carddemo.git"
866
+ }
867
+ }
final_proof/CLEAN_REPRO_VERIFICATION.json ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "api_smoke": {
3
+ "batch_resource_setup_tranidx": {
4
+ "alternate_index": {
5
+ "cylinders": [
6
+ 5,
7
+ 1
8
+ ],
9
+ "data": "AWS.M2.CARDDEMO.TRANSACT.VSAM.AIX.DATA",
10
+ "index": "AWS.M2.CARDDEMO.TRANSACT.VSAM.AIX.INDEX",
11
+ "keys": {
12
+ "length": 26,
13
+ "offset": 304
14
+ },
15
+ "name": "AWS.M2.CARDDEMO.TRANSACT.VSAM.AIX",
16
+ "nonunique": true,
17
+ "record_size": [
18
+ 350,
19
+ 350
20
+ ],
21
+ "relate": "AWS.M2.CARDDEMO.TRANSACT.VSAM.KSDS",
22
+ "upgrade": true,
23
+ "volume": "AWSHJ1"
24
+ },
25
+ "bldindex": {
26
+ "indataset": "AWS.M2.CARDDEMO.TRANSACT.VSAM.KSDS",
27
+ "outdataset": "AWS.M2.CARDDEMO.TRANSACT.VSAM.AIX",
28
+ "source_record_count": 300
29
+ },
30
+ "function": "Define AIX for transaction file",
31
+ "legacy_job": "TRANIDX",
32
+ "legacy_program": "IDCAMS",
33
+ "path": {
34
+ "name": "AWS.M2.CARDDEMO.TRANSACT.VSAM.AIX.PATH",
35
+ "pathentry": "AWS.M2.CARDDEMO.TRANSACT.VSAM.AIX"
36
+ },
37
+ "source_oracle": "TRANIDX.jcl DEFINE ALTERNATEINDEX, DEFINE PATH, and BLDINDEX statements",
38
+ "steps": [
39
+ {
40
+ "control": "DEFINE ALTERNATEINDEX",
41
+ "program": "IDCAMS",
42
+ "step": "STEP20"
43
+ },
44
+ {
45
+ "control": "DEFINE PATH",
46
+ "program": "IDCAMS",
47
+ "step": "STEP25"
48
+ },
49
+ {
50
+ "control": "BLDINDEX",
51
+ "program": "IDCAMS",
52
+ "step": "STEP30"
53
+ }
54
+ ]
55
+ },
56
+ "health": {
57
+ "source_root": "..\\source",
58
+ "status": "ok"
59
+ },
60
+ "mq_system_date": {
61
+ "error_queue": "CARD.DEMO.ERROR.QUEUE",
62
+ "input_queue": "CARD.DEMO.REQUEST.DATE",
63
+ "legacy_pattern": "MQ request/reply",
64
+ "legacy_program": "CODATE01",
65
+ "legacy_transaction": "CDRD",
66
+ "message_format": {
67
+ "correlation": "reply reuses MQMD message id and correl id",
68
+ "mq_format": "MQFMT_STRING",
69
+ "reply_length": 1000,
70
+ "request_copy": "REQUEST-MSG-COPY"
71
+ },
72
+ "reply_message": "SYSTEM DATE : 05-23-2026SYSTEM TIME : 11:12:13",
73
+ "reply_queue": "CARD.DEMO.REPLY.DATE",
74
+ "request_message": "DATE ",
75
+ "source_oracle": "CODATE01 4000-PROCESS-REQUEST-REPLY uses CICS ASKTIME/FORMATTIME MMDDYYYY DATESEP('-') TIMESEP and does not validate WS-FUNC",
76
+ "system_date": "05-23-2026",
77
+ "system_time": "11:12:13"
78
+ },
79
+ "summary": {
80
+ "claim_limit": "capability ledger and static-oracle traces only; no all-path COBOL runtime proof yet",
81
+ "counts": {
82
+ "accounts": 50,
83
+ "authorization_frauds": 0,
84
+ "card_xrefs": 50,
85
+ "cards": 50,
86
+ "customers": 50,
87
+ "disclosure_groups": 51,
88
+ "pending_authorization_details": 202,
89
+ "pending_authorization_summaries": 21,
90
+ "transaction_categories": 18,
91
+ "transaction_category_balances": 50,
92
+ "transaction_types": 7,
93
+ "transactions": 300,
94
+ "users": 10
95
+ },
96
+ "portfolio": {
97
+ "credit_limit": "233711.00",
98
+ "current_balance": "12269.00"
99
+ }
100
+ }
101
+ },
102
+ "api_smoke_passed": true,
103
+ "commands": [
104
+ {
105
+ "command": "C:\\Users\\Cjc00\\AppData\\Local\\Programs\\Python\\Python311\\python.exe -m carddemo.cli init-db --source-root ..\\source --db-path .\\carddemo.sqlite",
106
+ "cwd": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\clean_repro_20260523T150205Z\\modern_carddemo",
107
+ "duration_seconds": 0.781,
108
+ "name": "setup",
109
+ "passed": true,
110
+ "returncode": 0,
111
+ "stderr_tail": "",
112
+ "stdout_tail": "{'customers': 50, 'accounts': 50, 'cards': 50, 'card_xrefs': 50, 'transactions': 300, 'transaction_types': 7, 'transaction_categories': 18, 'disclosure_groups': 51, 'transaction_category_balances': 50, 'users': 10, 'pending_authorization_summaries': 21, 'pending_authorization_details': 202}\n"
113
+ },
114
+ {
115
+ "command": "C:\\Users\\Cjc00\\AppData\\Local\\Programs\\Python\\Python311\\python.exe -m unittest discover -s tests",
116
+ "cwd": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\clean_repro_20260523T150205Z\\modern_carddemo",
117
+ "duration_seconds": 21.297,
118
+ "name": "test",
119
+ "passed": true,
120
+ "returncode": 0,
121
+ "stderr_tail": "..................................................\n----------------------------------------------------------------------\nRan 50 tests in 20.718s\n\nOK\n",
122
+ "stdout_tail": ""
123
+ },
124
+ {
125
+ "command": "C:\\Users\\Cjc00\\AppData\\Local\\Programs\\Python\\Python311\\python.exe tools\\generate_receipts.py --source-root ..\\source --db-path .\\carddemo.sqlite --out-dir .\\reports",
126
+ "cwd": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\clean_repro_20260523T150205Z\\modern_carddemo",
127
+ "duration_seconds": 0.797,
128
+ "name": "receipt",
129
+ "passed": true,
130
+ "returncode": 0,
131
+ "stderr_tail": "",
132
+ "stdout_tail": "{\n \"receipt\": \"reports\\\\modernization_receipt.json\",\n \"parity\": \"reports\\\\parity_gap_report.json\",\n \"passed\": true\n}\n"
133
+ },
134
+ {
135
+ "command": "C:\\Users\\Cjc00\\AppData\\Local\\Programs\\Python\\Python311\\python.exe tools\\replay_static_oracles.py --source-root ..\\source --out-dir .\\reports --source-head 59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e",
136
+ "cwd": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\clean_repro_20260523T150205Z\\modern_carddemo",
137
+ "duration_seconds": 0.516,
138
+ "name": "static_oracle_replay",
139
+ "passed": true,
140
+ "returncode": 0,
141
+ "stderr_tail": "",
142
+ "stdout_tail": "{\n \"replay\": \"reports\\\\static_oracle_replay.json\",\n \"passed\": true,\n \"replay_hash\": \"da60110c66ee3b44432933de91afec1ba09dcbc9551f4495933f9eba3779f56e\",\n \"failed_checks\": [],\n \"claim_limit\": \"Executable modern replay over static/source-oracle traces only; no live COBOL/CICS runtime replay has been performed.\"\n}\n"
143
+ },
144
+ {
145
+ "command": "C:\\Users\\Cjc00\\AppData\\Local\\Programs\\Python\\Python311\\python.exe tools\\evaluate_a_grade_promotion.py --source-root ..\\source --out-dir .\\final_proof",
146
+ "cwd": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\clean_repro_20260523T150205Z\\modern_carddemo",
147
+ "duration_seconds": 0.234,
148
+ "name": "a_grade_promotion",
149
+ "passed": true,
150
+ "returncode": 0,
151
+ "stderr_tail": "",
152
+ "stdout_tail": "{\n \"accepted_live_matches\": 0,\n \"current_grade_counts\": {\n \"A\": 0,\n \"B\": 50,\n \"C\": 0,\n \"F\": 0\n },\n \"missing_live_matches\": 50,\n \"out_dir\": \"D:\\\\scraper_storage\\\\modernization_labs\\\\aws-carddemo-modernization-20260523T073000Z\\\\clean_repro_20260523T150205Z\\\\modern_carddemo\\\\final_proof\",\n \"promotable_to_A\": false,\n \"report_hash\": \"88b3cc4916145340ed2dec0135ba25ee1b9ddd4029c7e1e4aedb586643286544\",\n \"required_live_matches\": 50\n}\n"
153
+ },
154
+ {
155
+ "command": "C:\\Users\\Cjc00\\AppData\\Local\\Programs\\Python\\Python311\\python.exe tools\\build_no_cost_confidence.py --source-root ..\\source --out-dir .\\final_proof",
156
+ "cwd": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\clean_repro_20260523T150205Z\\modern_carddemo",
157
+ "duration_seconds": 0.578,
158
+ "name": "no_cost_confidence",
159
+ "passed": true,
160
+ "returncode": 0,
161
+ "stderr_tail": "",
162
+ "stdout_tail": "{\n \"out_dir\": \"D:\\\\scraper_storage\\\\modernization_labs\\\\aws-carddemo-modernization-20260523T073000Z\\\\clean_repro_20260523T150205Z\\\\modern_carddemo\\\\final_proof\",\n \"ready_for_pre_runtime_review\": true,\n \"report_hash\": \"20fd4a66a6fa52e75037c4ca5a6c389f613eefa9fdcc4087c036c6b355145c1a\",\n \"reviewer_posture\": \"strong_pre_runtime_confidence\",\n \"status_counts\": {\n \"pass\": 6,\n \"warn\": 1\n }\n}\n"
163
+ },
164
+ {
165
+ "command": "C:\\Users\\Cjc00\\AppData\\Local\\Programs\\Python\\Python311\\python.exe tools\\package_final_proof.py --source-root ..\\source",
166
+ "cwd": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\clean_repro_20260523T150205Z\\modern_carddemo",
167
+ "duration_seconds": 0.313,
168
+ "name": "package_final_proof",
169
+ "passed": true,
170
+ "returncode": 0,
171
+ "stderr_tail": "",
172
+ "stdout_tail": "\"report_hash\": \"88b3cc4916145340ed2dec0135ba25ee1b9ddd4029c7e1e4aedb586643286544\",\n \"report_version\": \"carddemo_a_grade_promotion_gate_v0\",\n \"required_live_matches\": 50,\n \"target_A\": 50,\n \"trace_contract\": {\n \"accepted_trace_kinds\": [\n \"live_cobol_cics_runtime\",\n \"live_mainframe_runtime\"\n ],\n \"field_rules\": {\n \"capability_id\": \"must match one ID in reports/capability_ledger.json\",\n \"hash_fields\": \"64-character SHA-256 hex digests\",\n \"matched\": true,\n \"source_head\": \"59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e\"\n },\n \"required_fields\": [\n \"capability_id\",\n \"trace_kind\",\n \"source_head\",\n \"legacy_runtime_environment\",\n \"modern_observation_hash\",\n \"comparator_version\",\n \"matched\",\n \"raw_legacy_trace_hash or legacy_runtime_trace_hash\"\n ]\n }\n },\n \"clean_repro_verification_present\": false,\n \"files\": [\n \"FINAL_PROOF_README.md\",\n \"FINAL_RECEIPT_SUMMARY.json\",\n \"REPRO_COMMANDS.txt\",\n \"STATIC_ORACLE_REPLAY_REPORT.json\",\n \"KNOWN_LIMITS.md\",\n \"ARTIFACT_MANIFEST.json\"\n ],\n \"no_cost_confidence\": {\n \"a_missing_live_matches\": 50,\n \"a_promotable\": false,\n \"capability_count\": 50,\n \"edge_case_count\": 40,\n \"generated_utc\": \"2026-05-23T15:02:32+00:00\",\n \"golden_trace_count\": 34,\n \"legacy_runtime_claim_made\": false,\n \"paid_runtime_used\": false,\n \"path\": \"D:\\\\scraper_storage\\\\modernization_labs\\\\aws-carddemo-modernization-20260523T073000Z\\\\clean_repro_20260523T150205Z\\\\modern_carddemo\\\\final_proof\\\\NO_COST_CONFIDENCE_REPORT.json\",\n \"readme_path\": \"D:\\\\scraper_storage\\\\modernization_labs\\\\aws-carddemo-modernization-20260523T073000Z\\\\clean_repro_20260523T150205Z\\\\modern_carddemo\\\\final_proof\\\\NO_COST_CONFIDENCE_README.md\",\n \"ready_for_pre_runtime_review\": true,\n \"remaining_gap\": \"live legacy COBOL/CICS/VSAM/JCL runtime validation on a real or licensed-compatible runtime\",\n \"report_hash\": \"20fd4a66a6fa52e75037c4ca5a6c389f613eefa9fdcc4087c036c6b355145c1a\",\n \"report_version\": \"carddemo_no_cost_confidence_v0\",\n \"reviewer_posture\": \"strong_pre_runtime_confidence\",\n \"source_ref_total\": 101,\n \"static_oracle_ready_count\": 50,\n \"static_replay_passed\": true\n },\n \"out_dir\": \"D:\\\\scraper_storage\\\\modernization_labs\\\\aws-carddemo-modernization-20260523T073000Z\\\\clean_repro_20260523T150205Z\\\\modern_carddemo\\\\final_proof\",\n \"parity\": {\n \"B\": 50,\n \"F\": 0,\n \"capability_count\": 50,\n \"gap_count\": 0,\n \"grade_counts\": {\n \"A\": 0,\n \"B\": 50,\n \"C\": 0,\n \"F\": 0\n },\n \"next_gap_ranking_count\": 0,\n \"one_for_one_parity_ready\": true,\n \"parity_hash\": \"677ea1276946f3b2acd1791ad704445c5ecd1d208b8246c4de40b02c773916c4\",\n \"parity_report_passed\": true,\n \"proof_grade_meanings\": {\n \"A\": \"actual legacy runtime trace match\",\n \"B\": \"static legacy data/copybook oracle match\",\n \"C\": \"implemented or inferred without strict parity proof\",\n \"F\": \"discovered capability gap\"\n },\n \"rubric\": \"current static/source-oracle rubric\",\n \"static_oracle_or_better_count\": 50,\n \"strict_runtime_parity_count\": 0\n },\n \"static_oracle_replay\": {\n \"claim_limit\": \"Executable modern replay over static/source-oracle traces only; no live COBOL/CICS runtime replay has been performed.\",\n \"evidence_hash\": \"b800ca64245b6229211cc4ace2b7c375f59d6d84afd08d04491c67b2ac50d847\",\n \"failed_checks\": [],\n \"passed\": true,\n \"path\": \"D:\\\\scraper_storage\\\\modernization_labs\\\\aws-carddemo-modernization-20260523T073000Z\\\\clean_repro_20260523T150205Z\\\\modern_carddemo\\\\final_proof\\\\STATIC_ORACLE_REPLAY_REPORT.json\",\n \"replay_hash\": \"da60110c66ee3b44432933de91afec1ba09dcbc9551f4495933f9eba3779f56e\",\n \"runtime_probe_count\": 6,\n \"source_report_path\": \"D:\\\\scraper_storage\\\\modernization_labs\\\\aws-carddemo-modernization-20260523T073000Z\\\\clean_repro_20260523T150205Z\\\\modern_carddemo\\\\reports\\\\static_oracle_replay.json\"\n }\n}\n"
173
+ }
174
+ ],
175
+ "copied_workspace": {
176
+ "modern_copy": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\clean_repro_20260523T150205Z\\modern_carddemo",
177
+ "scratch_root": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\clean_repro_20260523T150205Z",
178
+ "source_copy": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\clean_repro_20260523T150205Z\\source"
179
+ },
180
+ "generated_utc": "2026-05-23T15:02:33+00:00",
181
+ "passed": true,
182
+ "server_port": 8091,
183
+ "server_smoke": {
184
+ "checks": {
185
+ "health_ok": true,
186
+ "mq_date_reply": true,
187
+ "summary_customers_50": true,
188
+ "tranidx_key_contract": true
189
+ },
190
+ "passed": true,
191
+ "server_command": "C:\\Users\\Cjc00\\AppData\\Local\\Programs\\Python\\Python311\\python.exe -m carddemo.cli serve --source-root ..\\source --db-path .\\carddemo.sqlite --port 8091",
192
+ "stderr_log": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\clean_repro_20260523T150205Z\\modern_carddemo\\server_smoke.err.log",
193
+ "stdout_log": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\clean_repro_20260523T150205Z\\modern_carddemo\\server_smoke.out.log"
194
+ },
195
+ "source_head": "59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e",
196
+ "verification_version": "carddemo_clean_repro_verification_v0"
197
+ }
final_proof/FINAL_PROOF_README.md ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # AWS CardDemo Modernization Final Proof
3
+
4
+ This bundle packages the local AWS CardDemo modernization run as a reproducible technical-review artifact. It does not add application features; it records the source identity, modern code location, commands, receipts, static-oracle replay, no-cost confidence proof, A-grade promotion gate, known limits, and clean-copy verification status.
5
+
6
+ ## Source Identity
7
+
8
+ - Source repo: `https://github.com/aws-samples/aws-mainframe-modernization-carddemo.git`
9
+ - Source version: `59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e`
10
+ - Source local path used for this run: `D:\scraper_storage\modernization_labs\aws-carddemo-modernization-20260523T073000Z\source`
11
+ - Source file hash count in receipt: `204`
12
+ - Source hash digest over receipt map: `0703f97553bde0f5bd170aa95ec8c771a975b397be7d9e8088ec6fbf31d333c2`
13
+
14
+ ## Modern Code
15
+
16
+ - Modern code path: `D:\scraper_storage\modernization_labs\aws-carddemo-modernization-20260523T073000Z\modern_carddemo`
17
+ - Modern file hash count in receipt: `29`
18
+ - Modern hash digest over receipt map: `599294a7df7226c4d2a4b820de4bf567abbd1bdd1e41a1b6fd123457cb3abf40`
19
+
20
+ ## One-Command Setup And Run
21
+
22
+ Run these from the modern code root with the AWS CardDemo source clone/copy at `..\source`.
23
+
24
+ Setup database:
25
+
26
+ ```powershell
27
+ python -m carddemo.cli init-db --source-root ..\source --db-path .\carddemo.sqlite
28
+ ```
29
+
30
+ Run web/API server:
31
+
32
+ ```powershell
33
+ python -m carddemo.cli serve --source-root ..\source --db-path .\carddemo.sqlite --port 8087
34
+ ```
35
+
36
+ Open `http://127.0.0.1:8087`.
37
+
38
+ ## One-Command Tests
39
+
40
+ ```powershell
41
+ python -m unittest discover -s tests
42
+ ```
43
+
44
+ ## One-Command Static-Oracle Replay
45
+
46
+ ```powershell
47
+ python tools\replay_static_oracles.py --source-root ..\source --out-dir .\reports --source-head 59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e
48
+ ```
49
+
50
+ ## One-Command A-Grade Promotion Gate
51
+
52
+ ```powershell
53
+ python tools\evaluate_a_grade_promotion.py --source-root ..\source --out-dir .\final_proof
54
+ ```
55
+
56
+ ## One-Command No-Cost Confidence Proof
57
+
58
+ ```powershell
59
+ python tools\build_no_cost_confidence.py --source-root ..\source --out-dir .\final_proof
60
+ ```
61
+
62
+ ## Full Local Proof Refresh
63
+
64
+ ```powershell
65
+ powershell -NoProfile -Command "python -m carddemo.cli init-db --source-root ..\source --db-path .\carddemo.sqlite; python -m unittest discover -s tests; python tools\generate_receipts.py --source-root ..\source --db-path .\carddemo.sqlite --out-dir .\reports; python tools\replay_static_oracles.py --source-root ..\source --out-dir .\reports --source-head 59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e; python tools\evaluate_a_grade_promotion.py --source-root ..\source --out-dir .\final_proof; python tools\build_no_cost_confidence.py --source-root ..\source --out-dir .\final_proof; python tools\package_final_proof.py --source-root ..\source"
66
+ ```
67
+
68
+ ## Final Receipt Summary
69
+
70
+ - Receipt hash: `fea9dfeca8e1b400afe6fbf4a25f92282a6330da0bb031f87b8dbd6e41044819`
71
+ - Receipt generated: `2026-05-23T15:01:51+00:00`
72
+ - Static replay hash: `912e98e11d46cd967070d06ec17aaed3402bed44026267d1906ea6a2d54b9a42`
73
+ - Static replay passed: `True`
74
+ - Runtime probe count: `6`
75
+ - Failed replay checks: `[]`
76
+
77
+ ## Parity Summary
78
+
79
+ Under the current static/source-oracle rubric:
80
+
81
+ - Capability count: `50`
82
+ - B-grade static/source-oracle capabilities: `50`
83
+ - F-grade gaps: `0`
84
+ - Gap count: `0`
85
+ - Next-gap ranking count: `0`
86
+ - Static-oracle-or-better count: `50`
87
+ - A-grade live legacy runtime trace count: `0`
88
+
89
+ Proof grade meanings are recorded in `FINAL_RECEIPT_SUMMARY.json`.
90
+
91
+ ## No-Cost Confidence Proof
92
+
93
+ - Reviewer posture: `strong_pre_runtime_confidence`
94
+ - Ready for pre-runtime review: `True`
95
+ - Paid runtime used: `False`
96
+ - Legacy runtime claim made: `False`
97
+ - Source-backed static capabilities: `50`
98
+ - Source refs in capability ledger: `101`
99
+ - Golden traces / edge cases: `34` / `40`
100
+ - Remaining gap: `live legacy COBOL/CICS/VSAM/JCL runtime validation on a real or licensed-compatible runtime`
101
+ - No-cost confidence report hash: `c72a4b6b30b7bbee9096b3d79e2893fb0263d5aee1f4aebaec37401810208441`
102
+
103
+ This is the maximum unpaid/pre-runtime evidence layer. It is meant to convince a technical reviewer that the modernization is probably functional under the extracted legacy-derived behavior, while preserving the live runtime validation gap.
104
+
105
+ ## A-Grade Promotion Gate
106
+
107
+ - A-grade gate decision: `do_not_promote`
108
+ - Promotable to A: `False`
109
+ - Required live legacy runtime matches: `50`
110
+ - Accepted live legacy runtime matches: `0`
111
+ - Missing live legacy runtime matches: `50`
112
+ - A-grade report hash: `4f962c34517806cf2dee00f3fdd0b7c4f51e9ec3f5935eedfabd04104e3ad3af`
113
+
114
+ The A-grade gate is intentionally stricter than the B-grade static/source-oracle proof. It requires accepted live legacy COBOL/CICS runtime trace matches for each capability before any capability can be promoted to A.
115
+
116
+ ## Smoke Evidence
117
+
118
+ - Screenshot: `reports/ui_batch_reports_smoke.png` SHA-256 `f192f2b751ee902b70defbb5b49b745bbf8855a10bb8dc23d60e6c8bb9f6e537`.
119
+ - Clean-copy API smoke: passed=True port=8091 endpoints=batch_resource_setup_tranidx, health, mq_system_date, summary.
120
+
121
+ ## Clean-Copy Verification
122
+
123
+ - Clean-copy verification status: `passed`
124
+ - Verification report included in `FINAL_RECEIPT_SUMMARY.json` when present.
125
+
126
+ ## Caveat
127
+
128
+ This proof is static/source-oracle parity plus executable modern-service replay. It is not live COBOL/CICS all-path runtime equivalence.
129
+
130
+ See `KNOWN_LIMITS.md` for the full claim boundary.
final_proof/FINAL_RECEIPT_SUMMARY.json ADDED
@@ -0,0 +1,380 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "a_grade_promotion": {
3
+ "accepted_live_matches": 0,
4
+ "blocker_codes": [
5
+ "missing_live_legacy_trace_corpus",
6
+ "runtime_assets_not_execution_evidence",
7
+ "no_local_mainframe_or_aws_runtime_path_detected",
8
+ "static_oracle_is_not_a_grade"
9
+ ],
10
+ "current_A": 0,
11
+ "current_gap_count": 0,
12
+ "current_grade_counts": {
13
+ "A": 0,
14
+ "B": 50,
15
+ "C": 0,
16
+ "F": 0
17
+ },
18
+ "decision_action": "do_not_promote",
19
+ "generated_utc": "2026-05-23T15:01:52+00:00",
20
+ "missing_live_matches": 50,
21
+ "path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\final_proof\\A_GRADE_PROMOTION_REPORT.json",
22
+ "promotable_to_A": false,
23
+ "readme_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\final_proof\\A_GRADE_PROMOTION_README.md",
24
+ "report_hash": "4f962c34517806cf2dee00f3fdd0b7c4f51e9ec3f5935eedfabd04104e3ad3af",
25
+ "report_version": "carddemo_a_grade_promotion_gate_v0",
26
+ "required_live_matches": 50,
27
+ "target_A": 50,
28
+ "trace_contract": {
29
+ "accepted_trace_kinds": [
30
+ "live_cobol_cics_runtime",
31
+ "live_mainframe_runtime"
32
+ ],
33
+ "field_rules": {
34
+ "capability_id": "must match one ID in reports/capability_ledger.json",
35
+ "hash_fields": "64-character SHA-256 hex digests",
36
+ "matched": true,
37
+ "source_head": "59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e"
38
+ },
39
+ "required_fields": [
40
+ "capability_id",
41
+ "trace_kind",
42
+ "source_head",
43
+ "legacy_runtime_environment",
44
+ "modern_observation_hash",
45
+ "comparator_version",
46
+ "matched",
47
+ "raw_legacy_trace_hash or legacy_runtime_trace_hash"
48
+ ]
49
+ }
50
+ },
51
+ "bundle_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\final_proof",
52
+ "clean_repro_verification": {
53
+ "api_smoke": {
54
+ "batch_resource_setup_tranidx": {
55
+ "alternate_index": {
56
+ "cylinders": [
57
+ 5,
58
+ 1
59
+ ],
60
+ "data": "AWS.M2.CARDDEMO.TRANSACT.VSAM.AIX.DATA",
61
+ "index": "AWS.M2.CARDDEMO.TRANSACT.VSAM.AIX.INDEX",
62
+ "keys": {
63
+ "length": 26,
64
+ "offset": 304
65
+ },
66
+ "name": "AWS.M2.CARDDEMO.TRANSACT.VSAM.AIX",
67
+ "nonunique": true,
68
+ "record_size": [
69
+ 350,
70
+ 350
71
+ ],
72
+ "relate": "AWS.M2.CARDDEMO.TRANSACT.VSAM.KSDS",
73
+ "upgrade": true,
74
+ "volume": "AWSHJ1"
75
+ },
76
+ "bldindex": {
77
+ "indataset": "AWS.M2.CARDDEMO.TRANSACT.VSAM.KSDS",
78
+ "outdataset": "AWS.M2.CARDDEMO.TRANSACT.VSAM.AIX",
79
+ "source_record_count": 300
80
+ },
81
+ "function": "Define AIX for transaction file",
82
+ "legacy_job": "TRANIDX",
83
+ "legacy_program": "IDCAMS",
84
+ "path": {
85
+ "name": "AWS.M2.CARDDEMO.TRANSACT.VSAM.AIX.PATH",
86
+ "pathentry": "AWS.M2.CARDDEMO.TRANSACT.VSAM.AIX"
87
+ },
88
+ "source_oracle": "TRANIDX.jcl DEFINE ALTERNATEINDEX, DEFINE PATH, and BLDINDEX statements",
89
+ "steps": [
90
+ {
91
+ "control": "DEFINE ALTERNATEINDEX",
92
+ "program": "IDCAMS",
93
+ "step": "STEP20"
94
+ },
95
+ {
96
+ "control": "DEFINE PATH",
97
+ "program": "IDCAMS",
98
+ "step": "STEP25"
99
+ },
100
+ {
101
+ "control": "BLDINDEX",
102
+ "program": "IDCAMS",
103
+ "step": "STEP30"
104
+ }
105
+ ]
106
+ },
107
+ "health": {
108
+ "source_root": "..\\source",
109
+ "status": "ok"
110
+ },
111
+ "mq_system_date": {
112
+ "error_queue": "CARD.DEMO.ERROR.QUEUE",
113
+ "input_queue": "CARD.DEMO.REQUEST.DATE",
114
+ "legacy_pattern": "MQ request/reply",
115
+ "legacy_program": "CODATE01",
116
+ "legacy_transaction": "CDRD",
117
+ "message_format": {
118
+ "correlation": "reply reuses MQMD message id and correl id",
119
+ "mq_format": "MQFMT_STRING",
120
+ "reply_length": 1000,
121
+ "request_copy": "REQUEST-MSG-COPY"
122
+ },
123
+ "reply_message": "SYSTEM DATE : 05-23-2026SYSTEM TIME : 11:12:13",
124
+ "reply_queue": "CARD.DEMO.REPLY.DATE",
125
+ "request_message": "DATE ",
126
+ "source_oracle": "CODATE01 4000-PROCESS-REQUEST-REPLY uses CICS ASKTIME/FORMATTIME MMDDYYYY DATESEP('-') TIMESEP and does not validate WS-FUNC",
127
+ "system_date": "05-23-2026",
128
+ "system_time": "11:12:13"
129
+ },
130
+ "summary": {
131
+ "claim_limit": "capability ledger and static-oracle traces only; no all-path COBOL runtime proof yet",
132
+ "counts": {
133
+ "accounts": 50,
134
+ "authorization_frauds": 0,
135
+ "card_xrefs": 50,
136
+ "cards": 50,
137
+ "customers": 50,
138
+ "disclosure_groups": 51,
139
+ "pending_authorization_details": 202,
140
+ "pending_authorization_summaries": 21,
141
+ "transaction_categories": 18,
142
+ "transaction_category_balances": 50,
143
+ "transaction_types": 7,
144
+ "transactions": 300,
145
+ "users": 10
146
+ },
147
+ "portfolio": {
148
+ "credit_limit": "233711.00",
149
+ "current_balance": "12269.00"
150
+ }
151
+ }
152
+ },
153
+ "api_smoke_passed": true,
154
+ "commands": [
155
+ {
156
+ "command": "C:\\Users\\Cjc00\\AppData\\Local\\Programs\\Python\\Python311\\python.exe -m carddemo.cli init-db --source-root ..\\source --db-path .\\carddemo.sqlite",
157
+ "cwd": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\clean_repro_20260523T150205Z\\modern_carddemo",
158
+ "duration_seconds": 0.781,
159
+ "name": "setup",
160
+ "passed": true,
161
+ "returncode": 0,
162
+ "stderr_tail": "",
163
+ "stdout_tail": "{'customers': 50, 'accounts': 50, 'cards': 50, 'card_xrefs': 50, 'transactions': 300, 'transaction_types': 7, 'transaction_categories': 18, 'disclosure_groups': 51, 'transaction_category_balances': 50, 'users': 10, 'pending_authorization_summaries': 21, 'pending_authorization_details': 202}\n"
164
+ },
165
+ {
166
+ "command": "C:\\Users\\Cjc00\\AppData\\Local\\Programs\\Python\\Python311\\python.exe -m unittest discover -s tests",
167
+ "cwd": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\clean_repro_20260523T150205Z\\modern_carddemo",
168
+ "duration_seconds": 21.297,
169
+ "name": "test",
170
+ "passed": true,
171
+ "returncode": 0,
172
+ "stderr_tail": "..................................................\n----------------------------------------------------------------------\nRan 50 tests in 20.718s\n\nOK\n",
173
+ "stdout_tail": ""
174
+ },
175
+ {
176
+ "command": "C:\\Users\\Cjc00\\AppData\\Local\\Programs\\Python\\Python311\\python.exe tools\\generate_receipts.py --source-root ..\\source --db-path .\\carddemo.sqlite --out-dir .\\reports",
177
+ "cwd": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\clean_repro_20260523T150205Z\\modern_carddemo",
178
+ "duration_seconds": 0.797,
179
+ "name": "receipt",
180
+ "passed": true,
181
+ "returncode": 0,
182
+ "stderr_tail": "",
183
+ "stdout_tail": "{\n \"receipt\": \"reports\\\\modernization_receipt.json\",\n \"parity\": \"reports\\\\parity_gap_report.json\",\n \"passed\": true\n}\n"
184
+ },
185
+ {
186
+ "command": "C:\\Users\\Cjc00\\AppData\\Local\\Programs\\Python\\Python311\\python.exe tools\\replay_static_oracles.py --source-root ..\\source --out-dir .\\reports --source-head 59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e",
187
+ "cwd": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\clean_repro_20260523T150205Z\\modern_carddemo",
188
+ "duration_seconds": 0.516,
189
+ "name": "static_oracle_replay",
190
+ "passed": true,
191
+ "returncode": 0,
192
+ "stderr_tail": "",
193
+ "stdout_tail": "{\n \"replay\": \"reports\\\\static_oracle_replay.json\",\n \"passed\": true,\n \"replay_hash\": \"da60110c66ee3b44432933de91afec1ba09dcbc9551f4495933f9eba3779f56e\",\n \"failed_checks\": [],\n \"claim_limit\": \"Executable modern replay over static/source-oracle traces only; no live COBOL/CICS runtime replay has been performed.\"\n}\n"
194
+ },
195
+ {
196
+ "command": "C:\\Users\\Cjc00\\AppData\\Local\\Programs\\Python\\Python311\\python.exe tools\\evaluate_a_grade_promotion.py --source-root ..\\source --out-dir .\\final_proof",
197
+ "cwd": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\clean_repro_20260523T150205Z\\modern_carddemo",
198
+ "duration_seconds": 0.234,
199
+ "name": "a_grade_promotion",
200
+ "passed": true,
201
+ "returncode": 0,
202
+ "stderr_tail": "",
203
+ "stdout_tail": "{\n \"accepted_live_matches\": 0,\n \"current_grade_counts\": {\n \"A\": 0,\n \"B\": 50,\n \"C\": 0,\n \"F\": 0\n },\n \"missing_live_matches\": 50,\n \"out_dir\": \"D:\\\\scraper_storage\\\\modernization_labs\\\\aws-carddemo-modernization-20260523T073000Z\\\\clean_repro_20260523T150205Z\\\\modern_carddemo\\\\final_proof\",\n \"promotable_to_A\": false,\n \"report_hash\": \"88b3cc4916145340ed2dec0135ba25ee1b9ddd4029c7e1e4aedb586643286544\",\n \"required_live_matches\": 50\n}\n"
204
+ },
205
+ {
206
+ "command": "C:\\Users\\Cjc00\\AppData\\Local\\Programs\\Python\\Python311\\python.exe tools\\build_no_cost_confidence.py --source-root ..\\source --out-dir .\\final_proof",
207
+ "cwd": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\clean_repro_20260523T150205Z\\modern_carddemo",
208
+ "duration_seconds": 0.578,
209
+ "name": "no_cost_confidence",
210
+ "passed": true,
211
+ "returncode": 0,
212
+ "stderr_tail": "",
213
+ "stdout_tail": "{\n \"out_dir\": \"D:\\\\scraper_storage\\\\modernization_labs\\\\aws-carddemo-modernization-20260523T073000Z\\\\clean_repro_20260523T150205Z\\\\modern_carddemo\\\\final_proof\",\n \"ready_for_pre_runtime_review\": true,\n \"report_hash\": \"20fd4a66a6fa52e75037c4ca5a6c389f613eefa9fdcc4087c036c6b355145c1a\",\n \"reviewer_posture\": \"strong_pre_runtime_confidence\",\n \"status_counts\": {\n \"pass\": 6,\n \"warn\": 1\n }\n}\n"
214
+ },
215
+ {
216
+ "command": "C:\\Users\\Cjc00\\AppData\\Local\\Programs\\Python\\Python311\\python.exe tools\\package_final_proof.py --source-root ..\\source",
217
+ "cwd": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\clean_repro_20260523T150205Z\\modern_carddemo",
218
+ "duration_seconds": 0.313,
219
+ "name": "package_final_proof",
220
+ "passed": true,
221
+ "returncode": 0,
222
+ "stderr_tail": "",
223
+ "stdout_tail": "\"report_hash\": \"88b3cc4916145340ed2dec0135ba25ee1b9ddd4029c7e1e4aedb586643286544\",\n \"report_version\": \"carddemo_a_grade_promotion_gate_v0\",\n \"required_live_matches\": 50,\n \"target_A\": 50,\n \"trace_contract\": {\n \"accepted_trace_kinds\": [\n \"live_cobol_cics_runtime\",\n \"live_mainframe_runtime\"\n ],\n \"field_rules\": {\n \"capability_id\": \"must match one ID in reports/capability_ledger.json\",\n \"hash_fields\": \"64-character SHA-256 hex digests\",\n \"matched\": true,\n \"source_head\": \"59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e\"\n },\n \"required_fields\": [\n \"capability_id\",\n \"trace_kind\",\n \"source_head\",\n \"legacy_runtime_environment\",\n \"modern_observation_hash\",\n \"comparator_version\",\n \"matched\",\n \"raw_legacy_trace_hash or legacy_runtime_trace_hash\"\n ]\n }\n },\n \"clean_repro_verification_present\": false,\n \"files\": [\n \"FINAL_PROOF_README.md\",\n \"FINAL_RECEIPT_SUMMARY.json\",\n \"REPRO_COMMANDS.txt\",\n \"STATIC_ORACLE_REPLAY_REPORT.json\",\n \"KNOWN_LIMITS.md\",\n \"ARTIFACT_MANIFEST.json\"\n ],\n \"no_cost_confidence\": {\n \"a_missing_live_matches\": 50,\n \"a_promotable\": false,\n \"capability_count\": 50,\n \"edge_case_count\": 40,\n \"generated_utc\": \"2026-05-23T15:02:32+00:00\",\n \"golden_trace_count\": 34,\n \"legacy_runtime_claim_made\": false,\n \"paid_runtime_used\": false,\n \"path\": \"D:\\\\scraper_storage\\\\modernization_labs\\\\aws-carddemo-modernization-20260523T073000Z\\\\clean_repro_20260523T150205Z\\\\modern_carddemo\\\\final_proof\\\\NO_COST_CONFIDENCE_REPORT.json\",\n \"readme_path\": \"D:\\\\scraper_storage\\\\modernization_labs\\\\aws-carddemo-modernization-20260523T073000Z\\\\clean_repro_20260523T150205Z\\\\modern_carddemo\\\\final_proof\\\\NO_COST_CONFIDENCE_README.md\",\n \"ready_for_pre_runtime_review\": true,\n \"remaining_gap\": \"live legacy COBOL/CICS/VSAM/JCL runtime validation on a real or licensed-compatible runtime\",\n \"report_hash\": \"20fd4a66a6fa52e75037c4ca5a6c389f613eefa9fdcc4087c036c6b355145c1a\",\n \"report_version\": \"carddemo_no_cost_confidence_v0\",\n \"reviewer_posture\": \"strong_pre_runtime_confidence\",\n \"source_ref_total\": 101,\n \"static_oracle_ready_count\": 50,\n \"static_replay_passed\": true\n },\n \"out_dir\": \"D:\\\\scraper_storage\\\\modernization_labs\\\\aws-carddemo-modernization-20260523T073000Z\\\\clean_repro_20260523T150205Z\\\\modern_carddemo\\\\final_proof\",\n \"parity\": {\n \"B\": 50,\n \"F\": 0,\n \"capability_count\": 50,\n \"gap_count\": 0,\n \"grade_counts\": {\n \"A\": 0,\n \"B\": 50,\n \"C\": 0,\n \"F\": 0\n },\n \"next_gap_ranking_count\": 0,\n \"one_for_one_parity_ready\": true,\n \"parity_hash\": \"677ea1276946f3b2acd1791ad704445c5ecd1d208b8246c4de40b02c773916c4\",\n \"parity_report_passed\": true,\n \"proof_grade_meanings\": {\n \"A\": \"actual legacy runtime trace match\",\n \"B\": \"static legacy data/copybook oracle match\",\n \"C\": \"implemented or inferred without strict parity proof\",\n \"F\": \"discovered capability gap\"\n },\n \"rubric\": \"current static/source-oracle rubric\",\n \"static_oracle_or_better_count\": 50,\n \"strict_runtime_parity_count\": 0\n },\n \"static_oracle_replay\": {\n \"claim_limit\": \"Executable modern replay over static/source-oracle traces only; no live COBOL/CICS runtime replay has been performed.\",\n \"evidence_hash\": \"b800ca64245b6229211cc4ace2b7c375f59d6d84afd08d04491c67b2ac50d847\",\n \"failed_checks\": [],\n \"passed\": true,\n \"path\": \"D:\\\\scraper_storage\\\\modernization_labs\\\\aws-carddemo-modernization-20260523T073000Z\\\\clean_repro_20260523T150205Z\\\\modern_carddemo\\\\final_proof\\\\STATIC_ORACLE_REPLAY_REPORT.json\",\n \"replay_hash\": \"da60110c66ee3b44432933de91afec1ba09dcbc9551f4495933f9eba3779f56e\",\n \"runtime_probe_count\": 6,\n \"source_report_path\": \"D:\\\\scraper_storage\\\\modernization_labs\\\\aws-carddemo-modernization-20260523T073000Z\\\\clean_repro_20260523T150205Z\\\\modern_carddemo\\\\reports\\\\static_oracle_replay.json\"\n }\n}\n"
224
+ }
225
+ ],
226
+ "copied_workspace": {
227
+ "modern_copy": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\clean_repro_20260523T150205Z\\modern_carddemo",
228
+ "scratch_root": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\clean_repro_20260523T150205Z",
229
+ "source_copy": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\clean_repro_20260523T150205Z\\source"
230
+ },
231
+ "generated_utc": "2026-05-23T15:02:33+00:00",
232
+ "passed": true,
233
+ "server_port": 8091,
234
+ "server_smoke": {
235
+ "checks": {
236
+ "health_ok": true,
237
+ "mq_date_reply": true,
238
+ "summary_customers_50": true,
239
+ "tranidx_key_contract": true
240
+ },
241
+ "passed": true,
242
+ "server_command": "C:\\Users\\Cjc00\\AppData\\Local\\Programs\\Python\\Python311\\python.exe -m carddemo.cli serve --source-root ..\\source --db-path .\\carddemo.sqlite --port 8091",
243
+ "stderr_log": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\clean_repro_20260523T150205Z\\modern_carddemo\\server_smoke.err.log",
244
+ "stdout_log": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\clean_repro_20260523T150205Z\\modern_carddemo\\server_smoke.out.log"
245
+ },
246
+ "source_head": "59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e",
247
+ "verification_version": "carddemo_clean_repro_verification_v0"
248
+ },
249
+ "commands": {
250
+ "a_grade_promotion": "python tools\\evaluate_a_grade_promotion.py --source-root ..\\source --out-dir .\\final_proof",
251
+ "all_local_proof_no_server": "powershell -NoProfile -Command \"python -m carddemo.cli init-db --source-root ..\\source --db-path .\\carddemo.sqlite; python -m unittest discover -s tests; python tools\\generate_receipts.py --source-root ..\\source --db-path .\\carddemo.sqlite --out-dir .\\reports; python tools\\replay_static_oracles.py --source-root ..\\source --out-dir .\\reports --source-head 59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e; python tools\\evaluate_a_grade_promotion.py --source-root ..\\source --out-dir .\\final_proof; python tools\\build_no_cost_confidence.py --source-root ..\\source --out-dir .\\final_proof; python tools\\package_final_proof.py --source-root ..\\source\"",
252
+ "no_cost_confidence": "python tools\\build_no_cost_confidence.py --source-root ..\\source --out-dir .\\final_proof",
253
+ "package_final_proof": "python tools\\package_final_proof.py --source-root ..\\source",
254
+ "receipt": "python tools\\generate_receipts.py --source-root ..\\source --db-path .\\carddemo.sqlite --out-dir .\\reports",
255
+ "run": "python -m carddemo.cli serve --source-root ..\\source --db-path .\\carddemo.sqlite --port 8087",
256
+ "setup": "python -m carddemo.cli init-db --source-root ..\\source --db-path .\\carddemo.sqlite",
257
+ "static_oracle_replay": "python tools\\replay_static_oracles.py --source-root ..\\source --out-dir .\\reports --source-head 59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e",
258
+ "test": "python -m unittest discover -s tests"
259
+ },
260
+ "generated_utc": "2026-05-23T15:02:34+00:00",
261
+ "known_limits": [
262
+ "This proof is static/source-oracle parity plus executable modern-service replay. It is not live COBOL/CICS all-path runtime equivalence.",
263
+ "A-grade live legacy runtime trace matching remains 0 under the current proof-grade rubric.",
264
+ "A-grade promotion is gated by A_GRADE_PROMOTION_REPORT.json and requires accepted live legacy runtime traces.",
265
+ "NO_COST_CONFIDENCE_REPORT.json records maximum unpaid/pre-runtime evidence and the remaining paid/runtime validation boundary.",
266
+ "The static replay exercises selected trace expectations; it is not exhaustive path coverage.",
267
+ "The modern app is a local Python/SQLite target and not a production deployment package."
268
+ ],
269
+ "modern_code": {
270
+ "local_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo",
271
+ "modern_hash_count": 29,
272
+ "modern_hashes_digest": "599294a7df7226c4d2a4b820de4bf567abbd1bdd1e41a1b6fd123457cb3abf40"
273
+ },
274
+ "no_cost_confidence": {
275
+ "a_missing_live_matches": 50,
276
+ "a_promotable": false,
277
+ "capability_count": 50,
278
+ "edge_case_count": 40,
279
+ "generated_utc": "2026-05-23T15:02:34+00:00",
280
+ "golden_trace_count": 34,
281
+ "legacy_runtime_claim_made": false,
282
+ "paid_runtime_used": false,
283
+ "path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\final_proof\\NO_COST_CONFIDENCE_REPORT.json",
284
+ "readme_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\final_proof\\NO_COST_CONFIDENCE_README.md",
285
+ "ready_for_pre_runtime_review": true,
286
+ "remaining_gap": "live legacy COBOL/CICS/VSAM/JCL runtime validation on a real or licensed-compatible runtime",
287
+ "report_hash": "c72a4b6b30b7bbee9096b3d79e2893fb0263d5aee1f4aebaec37401810208441",
288
+ "report_version": "carddemo_no_cost_confidence_v0",
289
+ "reviewer_posture": "strong_pre_runtime_confidence",
290
+ "source_ref_total": 101,
291
+ "static_oracle_ready_count": 50,
292
+ "static_replay_passed": true
293
+ },
294
+ "parity": {
295
+ "B": 50,
296
+ "F": 0,
297
+ "capability_count": 50,
298
+ "gap_count": 0,
299
+ "grade_counts": {
300
+ "A": 0,
301
+ "B": 50,
302
+ "C": 0,
303
+ "F": 0
304
+ },
305
+ "next_gap_ranking_count": 0,
306
+ "one_for_one_parity_ready": true,
307
+ "parity_hash": "eef71685c56f22c2669311d9e2e7f1ce4f0cbe20b6542f405bb3d16cab1da95e",
308
+ "parity_report_passed": true,
309
+ "proof_grade_meanings": {
310
+ "A": "actual legacy runtime trace match",
311
+ "B": "static legacy data/copybook oracle match",
312
+ "C": "implemented or inferred without strict parity proof",
313
+ "F": "discovered capability gap"
314
+ },
315
+ "rubric": "current static/source-oracle rubric",
316
+ "static_oracle_or_better_count": 50,
317
+ "strict_runtime_parity_count": 0
318
+ },
319
+ "public_actions_allowed": false,
320
+ "receipt": {
321
+ "generated_utc": "2026-05-23T15:01:51+00:00",
322
+ "path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\reports\\modernization_receipt.json",
323
+ "receipt_hash": "fea9dfeca8e1b400afe6fbf4a25f92282a6330da0bb031f87b8dbd6e41044819",
324
+ "seed_counts": {
325
+ "accounts": 50,
326
+ "card_xrefs": 50,
327
+ "cards": 50,
328
+ "customers": 50,
329
+ "disclosure_groups": 51,
330
+ "pending_authorization_details": 202,
331
+ "pending_authorization_summaries": 21,
332
+ "transaction_categories": 18,
333
+ "transaction_category_balances": 50,
334
+ "transaction_types": 7,
335
+ "transactions": 300,
336
+ "users": 10
337
+ },
338
+ "source_head": "59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e"
339
+ },
340
+ "smoke_evidence": [
341
+ {
342
+ "absolute_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\reports\\ui_batch_reports_smoke.png",
343
+ "exists": true,
344
+ "path": "reports/ui_batch_reports_smoke.png",
345
+ "role": "existing_screenshot",
346
+ "sha256": "f192f2b751ee902b70defbb5b49b745bbf8855a10bb8dc23d60e6c8bb9f6e537",
347
+ "size_bytes": 69723
348
+ },
349
+ {
350
+ "endpoints": [
351
+ "batch_resource_setup_tranidx",
352
+ "health",
353
+ "mq_system_date",
354
+ "summary"
355
+ ],
356
+ "passed": true,
357
+ "port": 8091,
358
+ "role": "clean_copy_api_smoke"
359
+ }
360
+ ],
361
+ "source": {
362
+ "head": "59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e",
363
+ "local_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\source",
364
+ "repo_url": "https://github.com/aws-samples/aws-mainframe-modernization-carddemo.git",
365
+ "source_hash_count": 204,
366
+ "source_hashes_digest": "0703f97553bde0f5bd170aa95ec8c771a975b397be7d9e8088ec6fbf31d333c2",
367
+ "status_short": ""
368
+ },
369
+ "static_oracle_replay": {
370
+ "claim_limit": "Executable modern replay over static/source-oracle traces only; no live COBOL/CICS runtime replay has been performed.",
371
+ "evidence_hash": "c661998c6538b8118b5abf4d248cad72dfa138e087bded1a4c37a5e6a7377bab",
372
+ "failed_checks": [],
373
+ "passed": true,
374
+ "path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\final_proof\\STATIC_ORACLE_REPLAY_REPORT.json",
375
+ "replay_hash": "912e98e11d46cd967070d06ec17aaed3402bed44026267d1906ea6a2d54b9a42",
376
+ "runtime_probe_count": 6,
377
+ "source_report_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\reports\\static_oracle_replay.json"
378
+ },
379
+ "summary_version": "carddemo_final_proof_summary_v0"
380
+ }
final_proof/KNOWN_LIMITS.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # Known Limits
3
+
4
+ This proof is static/source-oracle parity plus executable modern-service replay. It is not live COBOL/CICS all-path runtime equivalence.
5
+
6
+ - Proof grade `B` means static legacy data/copybook/source-oracle match. It does not mean the original COBOL/CICS system was executed and compared for every path.
7
+ - Proof grade `A` is reserved for actual legacy runtime trace match; this bundle records `A=0`.
8
+ - `A_GRADE_PROMOTION_REPORT.json` is the executable promotion gate. It fails closed unless accepted live legacy runtime trace records exist for every capability.
9
+ - `NO_COST_CONFIDENCE_REPORT.json` records maximum unpaid/pre-runtime evidence. It is designed to support review confidence, not to replace live legacy validation.
10
+ - The replay report executes the modern Python service against extracted static/source-oracle expectations. It is useful evidence, but not exhaustive path coverage.
11
+ - The source data and copybooks are from AWS CardDemo at the pinned source version in `FINAL_RECEIPT_SUMMARY.json`.
12
+ - The app is a local Python/SQLite modernization target. Production concerns such as deployment topology, operations, security hardening, and load testing are outside this proof bundle.
13
+ - Public release, upload, or promotion is intentionally not performed by this bundle.
final_proof/NO_COST_CONFIDENCE_README.md ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AWS CardDemo No-Cost Confidence Proof
2
+
3
+ Report version: `carddemo_no_cost_confidence_readme_v0`
4
+
5
+ This artifact answers the practical question: how far did we get without paying for or depending on a licensed legacy runtime?
6
+
7
+ ## Result
8
+
9
+ - Reviewer posture: `strong_pre_runtime_confidence`
10
+ - Ready for pre-runtime review: `True`
11
+ - Paid runtime used: `False`
12
+ - Public actions allowed: `False`
13
+ - Remaining gap: `live legacy COBOL/CICS/VSAM/JCL runtime validation on a real or licensed-compatible runtime`
14
+
15
+ ## Evidence We Can Produce For Free
16
+
17
+ - Capability coverage: `50` capabilities.
18
+ - Static/source-oracle ready: `50` capabilities.
19
+ - Source references attached to capability ledger: `101`.
20
+ - Static replay passed: `True`.
21
+ - Static replay hash: `912e98e11d46cd967070d06ec17aaed3402bed44026267d1906ea6a2d54b9a42`.
22
+ - Golden traces: `34`.
23
+ - Edge cases: `40`.
24
+ - Clean-copy/API smoke evidence is recorded in `FINAL_RECEIPT_SUMMARY.json`.
25
+
26
+ ## Legacy Source Runtime Shape
27
+
28
+ - COBOL programs scanned: `44`.
29
+ - CICS programs: `25`.
30
+ - Non-CICS COBOL programs: `19`.
31
+ - Free GnuCOBOL probe candidates: `17`.
32
+ - Programs still requiring mainframe-compatible runtime for honest execution: `27`.
33
+
34
+ ## A-Grade Boundary
35
+
36
+ - A-grade decision: `do_not_promote`.
37
+ - Promotable to A: `False`.
38
+ - Accepted live runtime matches: `0`.
39
+ - Missing live runtime matches: `50`.
40
+
41
+ This does not pretend to be live COBOL/CICS equivalence. It shows that the unpaid work is strong and that the remaining proof step is specifically live legacy runtime validation.
final_proof/NO_COST_CONFIDENCE_REPORT.json ADDED
@@ -0,0 +1,932 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "a_grade_gate": {
3
+ "accepted_live_matches": 0,
4
+ "decision": "do_not_promote",
5
+ "missing_live_matches": 50,
6
+ "present": true,
7
+ "promotable_to_A": false,
8
+ "report_hash": "4f962c34517806cf2dee00f3fdd0b7c4f51e9ec3f5935eedfabd04104e3ad3af",
9
+ "required_live_matches": 50
10
+ },
11
+ "capability_coverage": {
12
+ "all_have_source_refs": true,
13
+ "all_static_oracle_ready": true,
14
+ "capability_count": 50,
15
+ "proof_grade_counts": {
16
+ "B": 50
17
+ },
18
+ "source_ref_max": 3,
19
+ "source_ref_min": 1,
20
+ "source_ref_total": 101,
21
+ "static_oracle_ready_count": 50,
22
+ "strict_runtime_ready_count": 0,
23
+ "surface_counts": {
24
+ "batch": 26,
25
+ "online": 24
26
+ },
27
+ "zero_source_ref_capability_ids": []
28
+ },
29
+ "claim_boundary": "Maximum no-cost confidence evidence only. This is not live COBOL/CICS all-path runtime equivalence.",
30
+ "fixture_corpus": {
31
+ "edge_case_count": 40,
32
+ "edge_case_hash": "505e3dd03fad7208896802f1a160d32514ce6b7a0f59d2d3947f21b81d6d8fb5",
33
+ "golden_trace_count": 34,
34
+ "golden_trace_hash": "0acaa652f42e6faba2fec61ec9836d7c2fbf0ded5cbda40cf479c38ea2812f01"
35
+ },
36
+ "generated_utc": "2026-05-23T15:02:34+00:00",
37
+ "legacy_source_semantics_scan": {
38
+ "cics_program_count": 25,
39
+ "cobol_program_count": 44,
40
+ "free_gnucobol_probe_candidate_count": 17,
41
+ "free_gnucobol_probe_candidate_paths": [
42
+ "app/app-authorization-ims-db2-mq/cbl/DBUNLDGS.CBL",
43
+ "app/app-authorization-ims-db2-mq/cbl/PAUDBLOD.CBL",
44
+ "app/app-authorization-ims-db2-mq/cbl/PAUDBUNL.CBL",
45
+ "app/cbl/CBACT01C.cbl",
46
+ "app/cbl/CBACT02C.cbl",
47
+ "app/cbl/CBACT03C.cbl",
48
+ "app/cbl/CBACT04C.cbl",
49
+ "app/cbl/CBCUS01C.cbl",
50
+ "app/cbl/CBEXPORT.cbl",
51
+ "app/cbl/CBIMPORT.cbl",
52
+ "app/cbl/CBSTM03A.CBL",
53
+ "app/cbl/CBSTM03B.CBL",
54
+ "app/cbl/CBTRN01C.cbl",
55
+ "app/cbl/CBTRN02C.cbl",
56
+ "app/cbl/CBTRN03C.cbl",
57
+ "app/cbl/COBSWAIT.cbl",
58
+ "app/cbl/CSUTLDTC.cbl"
59
+ ],
60
+ "non_cics_cobol_count": 19,
61
+ "programs": [
62
+ {
63
+ "cics_operation_hints": [],
64
+ "free_compile_feasibility": "requires_mainframe_or_compatible_runtime",
65
+ "has_cics": false,
66
+ "has_dli": true,
67
+ "has_file_io": true,
68
+ "has_mq_hint": false,
69
+ "has_sql": false,
70
+ "has_vsam_shape": false,
71
+ "line_count": 386,
72
+ "path": "app/app-authorization-ims-db2-mq/cbl/CBPAUP0C.cbl"
73
+ },
74
+ {
75
+ "cics_operation_hints": [
76
+ "READ",
77
+ "RETURN",
78
+ "SEND",
79
+ "WRITE"
80
+ ],
81
+ "free_compile_feasibility": "requires_mainframe_or_compatible_runtime",
82
+ "has_cics": true,
83
+ "has_dli": true,
84
+ "has_file_io": true,
85
+ "has_mq_hint": true,
86
+ "has_sql": false,
87
+ "has_vsam_shape": false,
88
+ "line_count": 1026,
89
+ "path": "app/app-authorization-ims-db2-mq/cbl/COPAUA0C.cbl"
90
+ },
91
+ {
92
+ "cics_operation_hints": [
93
+ "READ",
94
+ "RECEIVE",
95
+ "RETURN",
96
+ "SEND",
97
+ "XCTL"
98
+ ],
99
+ "free_compile_feasibility": "requires_mainframe_or_compatible_runtime",
100
+ "has_cics": true,
101
+ "has_dli": true,
102
+ "has_file_io": true,
103
+ "has_mq_hint": false,
104
+ "has_sql": false,
105
+ "has_vsam_shape": false,
106
+ "line_count": 1032,
107
+ "path": "app/app-authorization-ims-db2-mq/cbl/COPAUS0C.cbl"
108
+ },
109
+ {
110
+ "cics_operation_hints": [
111
+ "LINK",
112
+ "READ",
113
+ "RECEIVE",
114
+ "RETURN",
115
+ "SEND",
116
+ "XCTL"
117
+ ],
118
+ "free_compile_feasibility": "requires_mainframe_or_compatible_runtime",
119
+ "has_cics": true,
120
+ "has_dli": true,
121
+ "has_file_io": true,
122
+ "has_mq_hint": false,
123
+ "has_sql": false,
124
+ "has_vsam_shape": false,
125
+ "line_count": 604,
126
+ "path": "app/app-authorization-ims-db2-mq/cbl/COPAUS1C.cbl"
127
+ },
128
+ {
129
+ "cics_operation_hints": [
130
+ "RETURN"
131
+ ],
132
+ "free_compile_feasibility": "requires_mainframe_or_compatible_runtime",
133
+ "has_cics": true,
134
+ "has_dli": false,
135
+ "has_file_io": false,
136
+ "has_mq_hint": false,
137
+ "has_sql": true,
138
+ "has_vsam_shape": false,
139
+ "line_count": 244,
140
+ "path": "app/app-authorization-ims-db2-mq/cbl/COPAUS2C.cbl"
141
+ },
142
+ {
143
+ "cics_operation_hints": [],
144
+ "free_compile_feasibility": "possible_isolated_gnucobol_probe",
145
+ "has_cics": false,
146
+ "has_dli": false,
147
+ "has_file_io": true,
148
+ "has_mq_hint": false,
149
+ "has_sql": false,
150
+ "has_vsam_shape": true,
151
+ "line_count": 366,
152
+ "path": "app/app-authorization-ims-db2-mq/cbl/DBUNLDGS.CBL"
153
+ },
154
+ {
155
+ "cics_operation_hints": [],
156
+ "free_compile_feasibility": "possible_isolated_gnucobol_probe",
157
+ "has_cics": false,
158
+ "has_dli": false,
159
+ "has_file_io": true,
160
+ "has_mq_hint": false,
161
+ "has_sql": false,
162
+ "has_vsam_shape": true,
163
+ "line_count": 369,
164
+ "path": "app/app-authorization-ims-db2-mq/cbl/PAUDBLOD.CBL"
165
+ },
166
+ {
167
+ "cics_operation_hints": [],
168
+ "free_compile_feasibility": "possible_isolated_gnucobol_probe",
169
+ "has_cics": false,
170
+ "has_dli": false,
171
+ "has_file_io": true,
172
+ "has_mq_hint": false,
173
+ "has_sql": false,
174
+ "has_vsam_shape": true,
175
+ "line_count": 317,
176
+ "path": "app/app-authorization-ims-db2-mq/cbl/PAUDBUNL.CBL"
177
+ },
178
+ {
179
+ "cics_operation_hints": [],
180
+ "free_compile_feasibility": "requires_mainframe_or_compatible_runtime",
181
+ "has_cics": false,
182
+ "has_dli": false,
183
+ "has_file_io": true,
184
+ "has_mq_hint": false,
185
+ "has_sql": true,
186
+ "has_vsam_shape": true,
187
+ "line_count": 237,
188
+ "path": "app/app-transaction-type-db2/cbl/COBTUPDT.cbl"
189
+ },
190
+ {
191
+ "cics_operation_hints": [
192
+ "DELETE",
193
+ "READ",
194
+ "RECEIVE",
195
+ "RETURN",
196
+ "SEND",
197
+ "XCTL"
198
+ ],
199
+ "free_compile_feasibility": "requires_mainframe_or_compatible_runtime",
200
+ "has_cics": true,
201
+ "has_dli": false,
202
+ "has_file_io": true,
203
+ "has_mq_hint": false,
204
+ "has_sql": true,
205
+ "has_vsam_shape": false,
206
+ "line_count": 2098,
207
+ "path": "app/app-transaction-type-db2/cbl/COTRTLIC.cbl"
208
+ },
209
+ {
210
+ "cics_operation_hints": [
211
+ "DELETE",
212
+ "READ",
213
+ "RECEIVE",
214
+ "RETURN",
215
+ "SEND",
216
+ "WRITE",
217
+ "XCTL"
218
+ ],
219
+ "free_compile_feasibility": "requires_mainframe_or_compatible_runtime",
220
+ "has_cics": true,
221
+ "has_dli": false,
222
+ "has_file_io": true,
223
+ "has_mq_hint": false,
224
+ "has_sql": true,
225
+ "has_vsam_shape": false,
226
+ "line_count": 1702,
227
+ "path": "app/app-transaction-type-db2/cbl/COTRTUPC.cbl"
228
+ },
229
+ {
230
+ "cics_operation_hints": [
231
+ "READ",
232
+ "RETURN",
233
+ "SEND"
234
+ ],
235
+ "free_compile_feasibility": "requires_mainframe_or_compatible_runtime",
236
+ "has_cics": true,
237
+ "has_dli": false,
238
+ "has_file_io": true,
239
+ "has_mq_hint": true,
240
+ "has_sql": false,
241
+ "has_vsam_shape": false,
242
+ "line_count": 620,
243
+ "path": "app/app-vsam-mq/cbl/COACCT01.cbl"
244
+ },
245
+ {
246
+ "cics_operation_hints": [
247
+ "RETURN"
248
+ ],
249
+ "free_compile_feasibility": "requires_mainframe_or_compatible_runtime",
250
+ "has_cics": true,
251
+ "has_dli": false,
252
+ "has_file_io": false,
253
+ "has_mq_hint": true,
254
+ "has_sql": false,
255
+ "has_vsam_shape": false,
256
+ "line_count": 524,
257
+ "path": "app/app-vsam-mq/cbl/CODATE01.cbl"
258
+ },
259
+ {
260
+ "cics_operation_hints": [],
261
+ "free_compile_feasibility": "possible_isolated_gnucobol_probe",
262
+ "has_cics": false,
263
+ "has_dli": false,
264
+ "has_file_io": true,
265
+ "has_mq_hint": false,
266
+ "has_sql": false,
267
+ "has_vsam_shape": true,
268
+ "line_count": 430,
269
+ "path": "app/cbl/CBACT01C.cbl"
270
+ },
271
+ {
272
+ "cics_operation_hints": [],
273
+ "free_compile_feasibility": "possible_isolated_gnucobol_probe",
274
+ "has_cics": false,
275
+ "has_dli": false,
276
+ "has_file_io": true,
277
+ "has_mq_hint": false,
278
+ "has_sql": false,
279
+ "has_vsam_shape": true,
280
+ "line_count": 178,
281
+ "path": "app/cbl/CBACT02C.cbl"
282
+ },
283
+ {
284
+ "cics_operation_hints": [],
285
+ "free_compile_feasibility": "possible_isolated_gnucobol_probe",
286
+ "has_cics": false,
287
+ "has_dli": false,
288
+ "has_file_io": true,
289
+ "has_mq_hint": false,
290
+ "has_sql": false,
291
+ "has_vsam_shape": true,
292
+ "line_count": 178,
293
+ "path": "app/cbl/CBACT03C.cbl"
294
+ },
295
+ {
296
+ "cics_operation_hints": [],
297
+ "free_compile_feasibility": "possible_isolated_gnucobol_probe",
298
+ "has_cics": false,
299
+ "has_dli": false,
300
+ "has_file_io": true,
301
+ "has_mq_hint": false,
302
+ "has_sql": false,
303
+ "has_vsam_shape": true,
304
+ "line_count": 652,
305
+ "path": "app/cbl/CBACT04C.cbl"
306
+ },
307
+ {
308
+ "cics_operation_hints": [],
309
+ "free_compile_feasibility": "possible_isolated_gnucobol_probe",
310
+ "has_cics": false,
311
+ "has_dli": false,
312
+ "has_file_io": true,
313
+ "has_mq_hint": false,
314
+ "has_sql": false,
315
+ "has_vsam_shape": true,
316
+ "line_count": 178,
317
+ "path": "app/cbl/CBCUS01C.cbl"
318
+ },
319
+ {
320
+ "cics_operation_hints": [],
321
+ "free_compile_feasibility": "possible_isolated_gnucobol_probe",
322
+ "has_cics": false,
323
+ "has_dli": false,
324
+ "has_file_io": true,
325
+ "has_mq_hint": false,
326
+ "has_sql": false,
327
+ "has_vsam_shape": true,
328
+ "line_count": 582,
329
+ "path": "app/cbl/CBEXPORT.cbl"
330
+ },
331
+ {
332
+ "cics_operation_hints": [],
333
+ "free_compile_feasibility": "possible_isolated_gnucobol_probe",
334
+ "has_cics": false,
335
+ "has_dli": false,
336
+ "has_file_io": true,
337
+ "has_mq_hint": false,
338
+ "has_sql": false,
339
+ "has_vsam_shape": true,
340
+ "line_count": 487,
341
+ "path": "app/cbl/CBIMPORT.cbl"
342
+ },
343
+ {
344
+ "cics_operation_hints": [],
345
+ "free_compile_feasibility": "possible_isolated_gnucobol_probe",
346
+ "has_cics": false,
347
+ "has_dli": false,
348
+ "has_file_io": true,
349
+ "has_mq_hint": false,
350
+ "has_sql": false,
351
+ "has_vsam_shape": false,
352
+ "line_count": 924,
353
+ "path": "app/cbl/CBSTM03A.CBL"
354
+ },
355
+ {
356
+ "cics_operation_hints": [],
357
+ "free_compile_feasibility": "possible_isolated_gnucobol_probe",
358
+ "has_cics": false,
359
+ "has_dli": false,
360
+ "has_file_io": true,
361
+ "has_mq_hint": false,
362
+ "has_sql": false,
363
+ "has_vsam_shape": true,
364
+ "line_count": 230,
365
+ "path": "app/cbl/CBSTM03B.CBL"
366
+ },
367
+ {
368
+ "cics_operation_hints": [],
369
+ "free_compile_feasibility": "possible_isolated_gnucobol_probe",
370
+ "has_cics": false,
371
+ "has_dli": false,
372
+ "has_file_io": true,
373
+ "has_mq_hint": false,
374
+ "has_sql": false,
375
+ "has_vsam_shape": true,
376
+ "line_count": 494,
377
+ "path": "app/cbl/CBTRN01C.cbl"
378
+ },
379
+ {
380
+ "cics_operation_hints": [],
381
+ "free_compile_feasibility": "possible_isolated_gnucobol_probe",
382
+ "has_cics": false,
383
+ "has_dli": false,
384
+ "has_file_io": true,
385
+ "has_mq_hint": false,
386
+ "has_sql": false,
387
+ "has_vsam_shape": true,
388
+ "line_count": 731,
389
+ "path": "app/cbl/CBTRN02C.cbl"
390
+ },
391
+ {
392
+ "cics_operation_hints": [],
393
+ "free_compile_feasibility": "possible_isolated_gnucobol_probe",
394
+ "has_cics": false,
395
+ "has_dli": false,
396
+ "has_file_io": true,
397
+ "has_mq_hint": false,
398
+ "has_sql": false,
399
+ "has_vsam_shape": true,
400
+ "line_count": 649,
401
+ "path": "app/cbl/CBTRN03C.cbl"
402
+ },
403
+ {
404
+ "cics_operation_hints": [
405
+ "READ",
406
+ "RECEIVE",
407
+ "RETURN",
408
+ "REWRITE",
409
+ "SEND",
410
+ "WRITE",
411
+ "XCTL"
412
+ ],
413
+ "free_compile_feasibility": "requires_mainframe_or_compatible_runtime",
414
+ "has_cics": true,
415
+ "has_dli": false,
416
+ "has_file_io": true,
417
+ "has_mq_hint": false,
418
+ "has_sql": false,
419
+ "has_vsam_shape": false,
420
+ "line_count": 4236,
421
+ "path": "app/cbl/COACTUPC.cbl"
422
+ },
423
+ {
424
+ "cics_operation_hints": [
425
+ "READ",
426
+ "RECEIVE",
427
+ "RETURN",
428
+ "SEND",
429
+ "XCTL"
430
+ ],
431
+ "free_compile_feasibility": "requires_mainframe_or_compatible_runtime",
432
+ "has_cics": true,
433
+ "has_dli": false,
434
+ "has_file_io": true,
435
+ "has_mq_hint": false,
436
+ "has_sql": false,
437
+ "has_vsam_shape": false,
438
+ "line_count": 941,
439
+ "path": "app/cbl/COACTVWC.cbl"
440
+ },
441
+ {
442
+ "cics_operation_hints": [
443
+ "RECEIVE",
444
+ "RETURN",
445
+ "SEND",
446
+ "XCTL"
447
+ ],
448
+ "free_compile_feasibility": "requires_mainframe_or_compatible_runtime",
449
+ "has_cics": true,
450
+ "has_dli": false,
451
+ "has_file_io": false,
452
+ "has_mq_hint": false,
453
+ "has_sql": false,
454
+ "has_vsam_shape": false,
455
+ "line_count": 288,
456
+ "path": "app/cbl/COADM01C.cbl"
457
+ },
458
+ {
459
+ "cics_operation_hints": [
460
+ "ENDBR",
461
+ "READ",
462
+ "RECEIVE",
463
+ "RETURN",
464
+ "REWRITE",
465
+ "SEND",
466
+ "STARTBR",
467
+ "WRITE",
468
+ "XCTL"
469
+ ],
470
+ "free_compile_feasibility": "requires_mainframe_or_compatible_runtime",
471
+ "has_cics": true,
472
+ "has_dli": false,
473
+ "has_file_io": true,
474
+ "has_mq_hint": false,
475
+ "has_sql": false,
476
+ "has_vsam_shape": false,
477
+ "line_count": 572,
478
+ "path": "app/cbl/COBIL00C.cbl"
479
+ },
480
+ {
481
+ "cics_operation_hints": [],
482
+ "free_compile_feasibility": "possible_isolated_gnucobol_probe",
483
+ "has_cics": false,
484
+ "has_dli": false,
485
+ "has_file_io": false,
486
+ "has_mq_hint": false,
487
+ "has_sql": false,
488
+ "has_vsam_shape": false,
489
+ "line_count": 41,
490
+ "path": "app/cbl/COBSWAIT.cbl"
491
+ },
492
+ {
493
+ "cics_operation_hints": [
494
+ "ENDBR",
495
+ "READ",
496
+ "READNEXT",
497
+ "RECEIVE",
498
+ "RETURN",
499
+ "SEND",
500
+ "STARTBR",
501
+ "XCTL"
502
+ ],
503
+ "free_compile_feasibility": "requires_mainframe_or_compatible_runtime",
504
+ "has_cics": true,
505
+ "has_dli": false,
506
+ "has_file_io": true,
507
+ "has_mq_hint": false,
508
+ "has_sql": false,
509
+ "has_vsam_shape": false,
510
+ "line_count": 1459,
511
+ "path": "app/cbl/COCRDLIC.cbl"
512
+ },
513
+ {
514
+ "cics_operation_hints": [
515
+ "READ",
516
+ "RECEIVE",
517
+ "RETURN",
518
+ "SEND",
519
+ "XCTL"
520
+ ],
521
+ "free_compile_feasibility": "requires_mainframe_or_compatible_runtime",
522
+ "has_cics": true,
523
+ "has_dli": false,
524
+ "has_file_io": true,
525
+ "has_mq_hint": false,
526
+ "has_sql": false,
527
+ "has_vsam_shape": false,
528
+ "line_count": 887,
529
+ "path": "app/cbl/COCRDSLC.cbl"
530
+ },
531
+ {
532
+ "cics_operation_hints": [
533
+ "READ",
534
+ "RECEIVE",
535
+ "RETURN",
536
+ "REWRITE",
537
+ "SEND",
538
+ "WRITE",
539
+ "XCTL"
540
+ ],
541
+ "free_compile_feasibility": "requires_mainframe_or_compatible_runtime",
542
+ "has_cics": true,
543
+ "has_dli": false,
544
+ "has_file_io": true,
545
+ "has_mq_hint": false,
546
+ "has_sql": false,
547
+ "has_vsam_shape": false,
548
+ "line_count": 1560,
549
+ "path": "app/cbl/COCRDUPC.cbl"
550
+ },
551
+ {
552
+ "cics_operation_hints": [
553
+ "RECEIVE",
554
+ "RETURN",
555
+ "SEND",
556
+ "XCTL"
557
+ ],
558
+ "free_compile_feasibility": "requires_mainframe_or_compatible_runtime",
559
+ "has_cics": true,
560
+ "has_dli": false,
561
+ "has_file_io": false,
562
+ "has_mq_hint": false,
563
+ "has_sql": false,
564
+ "has_vsam_shape": false,
565
+ "line_count": 308,
566
+ "path": "app/cbl/COMEN01C.cbl"
567
+ },
568
+ {
569
+ "cics_operation_hints": [
570
+ "RECEIVE",
571
+ "RETURN",
572
+ "SEND",
573
+ "WRITE",
574
+ "XCTL"
575
+ ],
576
+ "free_compile_feasibility": "requires_mainframe_or_compatible_runtime",
577
+ "has_cics": true,
578
+ "has_dli": false,
579
+ "has_file_io": true,
580
+ "has_mq_hint": false,
581
+ "has_sql": false,
582
+ "has_vsam_shape": false,
583
+ "line_count": 649,
584
+ "path": "app/cbl/CORPT00C.cbl"
585
+ },
586
+ {
587
+ "cics_operation_hints": [
588
+ "READ",
589
+ "RECEIVE",
590
+ "RETURN",
591
+ "SEND",
592
+ "XCTL"
593
+ ],
594
+ "free_compile_feasibility": "requires_mainframe_or_compatible_runtime",
595
+ "has_cics": true,
596
+ "has_dli": false,
597
+ "has_file_io": true,
598
+ "has_mq_hint": false,
599
+ "has_sql": false,
600
+ "has_vsam_shape": false,
601
+ "line_count": 260,
602
+ "path": "app/cbl/COSGN00C.cbl"
603
+ },
604
+ {
605
+ "cics_operation_hints": [
606
+ "ENDBR",
607
+ "READNEXT",
608
+ "RECEIVE",
609
+ "RETURN",
610
+ "SEND",
611
+ "STARTBR",
612
+ "XCTL"
613
+ ],
614
+ "free_compile_feasibility": "requires_mainframe_or_compatible_runtime",
615
+ "has_cics": true,
616
+ "has_dli": false,
617
+ "has_file_io": false,
618
+ "has_mq_hint": false,
619
+ "has_sql": false,
620
+ "has_vsam_shape": false,
621
+ "line_count": 699,
622
+ "path": "app/cbl/COTRN00C.cbl"
623
+ },
624
+ {
625
+ "cics_operation_hints": [
626
+ "READ",
627
+ "RECEIVE",
628
+ "RETURN",
629
+ "SEND",
630
+ "XCTL"
631
+ ],
632
+ "free_compile_feasibility": "requires_mainframe_or_compatible_runtime",
633
+ "has_cics": true,
634
+ "has_dli": false,
635
+ "has_file_io": true,
636
+ "has_mq_hint": false,
637
+ "has_sql": false,
638
+ "has_vsam_shape": false,
639
+ "line_count": 330,
640
+ "path": "app/cbl/COTRN01C.cbl"
641
+ },
642
+ {
643
+ "cics_operation_hints": [
644
+ "ENDBR",
645
+ "READ",
646
+ "RECEIVE",
647
+ "RETURN",
648
+ "SEND",
649
+ "STARTBR",
650
+ "WRITE",
651
+ "XCTL"
652
+ ],
653
+ "free_compile_feasibility": "requires_mainframe_or_compatible_runtime",
654
+ "has_cics": true,
655
+ "has_dli": false,
656
+ "has_file_io": true,
657
+ "has_mq_hint": false,
658
+ "has_sql": false,
659
+ "has_vsam_shape": false,
660
+ "line_count": 783,
661
+ "path": "app/cbl/COTRN02C.cbl"
662
+ },
663
+ {
664
+ "cics_operation_hints": [
665
+ "ENDBR",
666
+ "READNEXT",
667
+ "RECEIVE",
668
+ "RETURN",
669
+ "SEND",
670
+ "STARTBR",
671
+ "XCTL"
672
+ ],
673
+ "free_compile_feasibility": "requires_mainframe_or_compatible_runtime",
674
+ "has_cics": true,
675
+ "has_dli": false,
676
+ "has_file_io": false,
677
+ "has_mq_hint": false,
678
+ "has_sql": false,
679
+ "has_vsam_shape": false,
680
+ "line_count": 695,
681
+ "path": "app/cbl/COUSR00C.cbl"
682
+ },
683
+ {
684
+ "cics_operation_hints": [
685
+ "RECEIVE",
686
+ "RETURN",
687
+ "SEND",
688
+ "WRITE",
689
+ "XCTL"
690
+ ],
691
+ "free_compile_feasibility": "requires_mainframe_or_compatible_runtime",
692
+ "has_cics": true,
693
+ "has_dli": false,
694
+ "has_file_io": true,
695
+ "has_mq_hint": false,
696
+ "has_sql": false,
697
+ "has_vsam_shape": false,
698
+ "line_count": 299,
699
+ "path": "app/cbl/COUSR01C.cbl"
700
+ },
701
+ {
702
+ "cics_operation_hints": [
703
+ "READ",
704
+ "RECEIVE",
705
+ "RETURN",
706
+ "REWRITE",
707
+ "SEND",
708
+ "XCTL"
709
+ ],
710
+ "free_compile_feasibility": "requires_mainframe_or_compatible_runtime",
711
+ "has_cics": true,
712
+ "has_dli": false,
713
+ "has_file_io": true,
714
+ "has_mq_hint": false,
715
+ "has_sql": false,
716
+ "has_vsam_shape": false,
717
+ "line_count": 414,
718
+ "path": "app/cbl/COUSR02C.cbl"
719
+ },
720
+ {
721
+ "cics_operation_hints": [
722
+ "DELETE",
723
+ "READ",
724
+ "RECEIVE",
725
+ "RETURN",
726
+ "SEND",
727
+ "XCTL"
728
+ ],
729
+ "free_compile_feasibility": "requires_mainframe_or_compatible_runtime",
730
+ "has_cics": true,
731
+ "has_dli": false,
732
+ "has_file_io": true,
733
+ "has_mq_hint": false,
734
+ "has_sql": false,
735
+ "has_vsam_shape": false,
736
+ "line_count": 359,
737
+ "path": "app/cbl/COUSR03C.cbl"
738
+ },
739
+ {
740
+ "cics_operation_hints": [],
741
+ "free_compile_feasibility": "possible_isolated_gnucobol_probe",
742
+ "has_cics": false,
743
+ "has_dli": false,
744
+ "has_file_io": false,
745
+ "has_mq_hint": false,
746
+ "has_sql": false,
747
+ "has_vsam_shape": false,
748
+ "line_count": 157,
749
+ "path": "app/cbl/CSUTLDTC.cbl"
750
+ }
751
+ ],
752
+ "runtime_required_program_count": 27
753
+ },
754
+ "local_runtime_feasibility": {
755
+ "conclusion": "Free/local analysis can inspect, parse, hash, replay extracted expectations, and optionally probe isolated non-CICS COBOL if cobc is available. It cannot honestly replace CICS/VSAM/JCL execution.",
756
+ "tooling_probe": {
757
+ "aws": {
758
+ "path": null,
759
+ "present": false,
760
+ "tool": "aws",
761
+ "why_checked": "AWS runtime path probe; not required for no-cost proof and not used here."
762
+ },
763
+ "cobc": {
764
+ "path": null,
765
+ "present": false,
766
+ "tool": "cobc",
767
+ "why_checked": "Free COBOL compiler probe for isolated non-CICS COBOL logic."
768
+ },
769
+ "docker": {
770
+ "path": "C:\\Program Files\\Docker\\Docker\\resources\\bin\\docker.EXE",
771
+ "present": true,
772
+ "tool": "docker",
773
+ "version_probe_ok": true,
774
+ "version_probe_output": "\"29.1.2\"",
775
+ "version_probe_returncode": 0,
776
+ "why_checked": "Container runtime probe; useful only if a runnable legacy runtime image is available."
777
+ },
778
+ "gradle": {
779
+ "path": null,
780
+ "present": false,
781
+ "tool": "gradle",
782
+ "why_checked": "Gradle probe for Java tooling."
783
+ },
784
+ "hercules": {
785
+ "path": null,
786
+ "present": false,
787
+ "tool": "hercules",
788
+ "why_checked": "Mainframe emulator probe; not sufficient by itself for CICS/VSAM/JCL."
789
+ },
790
+ "java": {
791
+ "path": null,
792
+ "present": false,
793
+ "tool": "java",
794
+ "why_checked": "JVM probe for possible migration/runtime tools."
795
+ },
796
+ "mvn": {
797
+ "path": null,
798
+ "present": false,
799
+ "tool": "mvn",
800
+ "why_checked": "Maven probe for Java tooling."
801
+ },
802
+ "tn3270": {
803
+ "path": null,
804
+ "present": false,
805
+ "tool": "tn3270",
806
+ "why_checked": "3270 terminal probe for live CICS transaction capture."
807
+ }
808
+ }
809
+ },
810
+ "modern_code": {
811
+ "local_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo"
812
+ },
813
+ "no_cost_confidence_layers": [
814
+ {
815
+ "detail": "source_head=59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e source_hash_count=204",
816
+ "layer": "source_identity_and_hashes",
817
+ "status": "pass"
818
+ },
819
+ {
820
+ "detail": "capabilities=50 B=50 gaps=0",
821
+ "layer": "one_for_one_capability_ledger",
822
+ "status": "pass"
823
+ },
824
+ {
825
+ "detail": "source_refs=101 static_ready=50",
826
+ "layer": "source_reference_coverage",
827
+ "status": "pass"
828
+ },
829
+ {
830
+ "detail": "runtime_probe_count=6 failed_checks=0",
831
+ "layer": "executable_static_oracle_replay",
832
+ "status": "pass"
833
+ },
834
+ {
835
+ "detail": "edge_cases=40 golden_traces=34",
836
+ "layer": "edge_case_and_golden_trace_corpus",
837
+ "status": "pass"
838
+ },
839
+ {
840
+ "detail": "clean_repro=True api_smoke=True",
841
+ "layer": "clean_copy_reproduction_and_api_smoke",
842
+ "status": "pass"
843
+ },
844
+ {
845
+ "detail": "promotable_to_A=False accepted_live=0 missing_live=50",
846
+ "layer": "honest_a_grade_runtime_gate",
847
+ "status": "pass"
848
+ }
849
+ ],
850
+ "no_cost_confidence_summary": {
851
+ "plain_english": "The modern app is strongly supported by source-derived static oracles, executable modern replay, edge cases, clean-copy tests, and API smoke. A reviewer should still require live legacy runtime validation before accepting production equivalence.",
852
+ "ready_for_pre_runtime_review": true,
853
+ "remaining_gap": "live legacy COBOL/CICS/VSAM/JCL runtime validation on a real or licensed-compatible runtime",
854
+ "reviewer_posture": "strong_pre_runtime_confidence",
855
+ "status_counts": {
856
+ "pass": 7
857
+ }
858
+ },
859
+ "no_cost_scope": {
860
+ "goal": "Produce the strongest practical pre-runtime evidence without paid/licensed legacy infrastructure, then leave only live legacy runtime validation as the named residual gap.",
861
+ "legacy_runtime_claim_made": false,
862
+ "paid_runtime_used": false,
863
+ "public_actions_allowed": false
864
+ },
865
+ "public_actions_allowed": false,
866
+ "report_hash": "c72a4b6b30b7bbee9096b3d79e2893fb0263d5aee1f4aebaec37401810208441",
867
+ "report_version": "carddemo_no_cost_confidence_v0",
868
+ "reviewer_language": {
869
+ "what_this_cannot_claim": [
870
+ "It cannot claim all-path live COBOL/CICS equivalence.",
871
+ "It cannot prove CICS, VSAM, JCL, DB2, IMS, MQ, or terminal behavior that only appears in a paid or hosted runtime.",
872
+ "It cannot remove the need for final validation in the customer's legacy runtime environment."
873
+ ],
874
+ "what_this_should_convince": [
875
+ "The modernization has a pinned source identity and hashed evidence base.",
876
+ "Every tracked capability has source-backed static/source-oracle coverage.",
877
+ "The modern service executes against legacy-derived fixtures without current gaps.",
878
+ "The remaining risk is specifically runtime-environment validation, not a known missing feature in the current rubric."
879
+ ]
880
+ },
881
+ "source": {
882
+ "head": "59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e",
883
+ "local_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\source",
884
+ "repo_url": "https://github.com/aws-samples/aws-mainframe-modernization-carddemo.git"
885
+ },
886
+ "source_inventory": {
887
+ "app_root": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\source\\app",
888
+ "evidence_file_count": 184,
889
+ "evidence_file_hash_digest": "826c7838bf339294bbf185f7d0e8bd2bc970ae34a97bef74ce56ba954590d031",
890
+ "extension_counts": {
891
+ ".asm": 2,
892
+ ".bms": 21,
893
+ ".ca7": 1,
894
+ ".cbl": 44,
895
+ ".controlm": 1,
896
+ ".cpy": 62,
897
+ ".csd": 4,
898
+ ".ctl": 8,
899
+ ".dat": 1,
900
+ ".dbd": 4,
901
+ ".dcl": 3,
902
+ ".ddl": 6,
903
+ ".init": 1,
904
+ ".jcl": 46,
905
+ ".mac": 2,
906
+ ".md": 3,
907
+ ".prc": 2,
908
+ ".ps": 12,
909
+ ".psb": 4,
910
+ ".txt": 10,
911
+ "<none>": 3
912
+ },
913
+ "file_count": 240
914
+ },
915
+ "static_oracle_replay": {
916
+ "claim_limit": "Executable modern replay over static/source-oracle traces only; no live COBOL/CICS runtime replay has been performed.",
917
+ "evidence_hash": "c661998c6538b8118b5abf4d248cad72dfa138e087bded1a4c37a5e6a7377bab",
918
+ "failed_checks": [],
919
+ "passed": true,
920
+ "present": true,
921
+ "replay_hash": "912e98e11d46cd967070d06ec17aaed3402bed44026267d1906ea6a2d54b9a42",
922
+ "runtime_probe_count": 6
923
+ },
924
+ "test_and_smoke_evidence": {
925
+ "api_smoke_passed": true,
926
+ "clean_repro_passed": true,
927
+ "clean_repro_present": true,
928
+ "final_summary_present": true,
929
+ "screenshot_present": true,
930
+ "screenshot_sha256": "f192f2b751ee902b70defbb5b49b745bbf8855a10bb8dc23d60e6c8bb9f6e537"
931
+ }
932
+ }
final_proof/REPRO_COMMANDS.txt ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Run from the modern code root. The source clone/copy must be at ..\source.
3
+
4
+ SOURCE REPO:
5
+ https://github.com/aws-samples/aws-mainframe-modernization-carddemo.git
6
+
7
+ SOURCE HEAD:
8
+ 59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e
9
+
10
+ MODERN CODE:
11
+ D:\scraper_storage\modernization_labs\aws-carddemo-modernization-20260523T073000Z\modern_carddemo
12
+
13
+ SETUP:
14
+ python -m carddemo.cli init-db --source-root ..\source --db-path .\carddemo.sqlite
15
+
16
+ RUN SERVER:
17
+ python -m carddemo.cli serve --source-root ..\source --db-path .\carddemo.sqlite --port 8087
18
+
19
+ TEST:
20
+ python -m unittest discover -s tests
21
+
22
+ STATIC ORACLE REPLAY:
23
+ python tools\replay_static_oracles.py --source-root ..\source --out-dir .\reports --source-head 59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e
24
+
25
+ A-GRADE PROMOTION GATE:
26
+ python tools\evaluate_a_grade_promotion.py --source-root ..\source --out-dir .\final_proof
27
+
28
+ NO-COST CONFIDENCE PROOF:
29
+ python tools\build_no_cost_confidence.py --source-root ..\source --out-dir .\final_proof
30
+
31
+ REGENERATE RECEIPTS:
32
+ python tools\generate_receipts.py --source-root ..\source --db-path .\carddemo.sqlite --out-dir .\reports
33
+
34
+ PACKAGE FINAL PROOF:
35
+ python tools\package_final_proof.py --source-root ..\source
36
+
37
+ FULL LOCAL PROOF REFRESH WITHOUT SERVER:
38
+ powershell -NoProfile -Command "python -m carddemo.cli init-db --source-root ..\source --db-path .\carddemo.sqlite; python -m unittest discover -s tests; python tools\generate_receipts.py --source-root ..\source --db-path .\carddemo.sqlite --out-dir .\reports; python tools\replay_static_oracles.py --source-root ..\source --out-dir .\reports --source-head 59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e; python tools\evaluate_a_grade_promotion.py --source-root ..\source --out-dir .\final_proof; python tools\build_no_cost_confidence.py --source-root ..\source --out-dir .\final_proof; python tools\package_final_proof.py --source-root ..\source"
39
+
40
+ CAVEAT:
41
+ This proof is static/source-oracle parity plus executable modern-service replay. It is not live COBOL/CICS all-path runtime equivalence.
final_proof/STATIC_ORACLE_REPLAY_REPORT.json ADDED
@@ -0,0 +1,573 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "capability_count": 50,
3
+ "checks": [
4
+ {
5
+ "actual": {
6
+ "accounts": 50,
7
+ "card_xrefs": 50,
8
+ "cards": 50,
9
+ "customers": 50,
10
+ "disclosure_groups": 51,
11
+ "pending_authorization_details": 202,
12
+ "pending_authorization_summaries": 21,
13
+ "transaction_categories": 18,
14
+ "transaction_category_balances": 50,
15
+ "transaction_types": 7,
16
+ "transactions": 300,
17
+ "users": 10
18
+ },
19
+ "check": "legacy_seed_count_contract",
20
+ "expected": {
21
+ "accounts": 50,
22
+ "card_xrefs": 50,
23
+ "cards": 50,
24
+ "customers": 50,
25
+ "disclosure_groups": 51,
26
+ "pending_authorization_details": 202,
27
+ "pending_authorization_summaries": 21,
28
+ "transaction_categories": 18,
29
+ "transaction_category_balances": 50,
30
+ "transaction_types": 7,
31
+ "transactions": 300,
32
+ "users": 10
33
+ },
34
+ "passed": true
35
+ },
36
+ {
37
+ "actual": 0,
38
+ "check": "zero_capability_gaps",
39
+ "expected": 0,
40
+ "passed": true
41
+ },
42
+ {
43
+ "actual": [],
44
+ "check": "empty_next_gap_ranking",
45
+ "expected": [],
46
+ "passed": true
47
+ },
48
+ {
49
+ "actual": 50,
50
+ "check": "all_capabilities_static_oracle_or_better",
51
+ "expected": 50,
52
+ "passed": true
53
+ },
54
+ {
55
+ "actual": 0,
56
+ "check": "no_partial_or_inferred_capabilities",
57
+ "expected": 0,
58
+ "passed": true
59
+ },
60
+ {
61
+ "actual": [
62
+ "batch_resource_setup_gdg_vsam_aix_cics",
63
+ "mq_account_inquiry_cdra_success_and_invalid",
64
+ "mq_system_date_cdrd_reply",
65
+ "pending_authorization_cp00_request_response_and_insert",
66
+ "pending_authorization_cpvs_summary_page",
67
+ "transaction_type_lookup"
68
+ ],
69
+ "check": "required_static_oracle_traces_present",
70
+ "details": {
71
+ "missing": []
72
+ },
73
+ "expected": [
74
+ "batch_resource_setup_gdg_vsam_aix_cics",
75
+ "mq_account_inquiry_cdra_success_and_invalid",
76
+ "mq_system_date_cdrd_reply",
77
+ "pending_authorization_cp00_request_response_and_insert",
78
+ "pending_authorization_cpvs_summary_page",
79
+ "transaction_type_lookup"
80
+ ],
81
+ "passed": true
82
+ },
83
+ {
84
+ "actual": [
85
+ "authorization_available_credit_boundary",
86
+ "batch_gdg_limit_scratch_first_generation",
87
+ "cics_file_control_command_set",
88
+ "mq_cdra_inqa_account_key_validation",
89
+ "mq_cdrd_request_payload_ignored",
90
+ "pending_authorization_ims_segment_header_offset",
91
+ "transaction_aix_processed_timestamp_key",
92
+ "vsam_esds_rrds_user_security_layout"
93
+ ],
94
+ "check": "required_edge_cases_present",
95
+ "details": {
96
+ "missing": []
97
+ },
98
+ "expected": [
99
+ "authorization_available_credit_boundary",
100
+ "batch_gdg_limit_scratch_first_generation",
101
+ "cics_file_control_command_set",
102
+ "mq_cdra_inqa_account_key_validation",
103
+ "mq_cdrd_request_payload_ignored",
104
+ "pending_authorization_ims_segment_header_offset",
105
+ "transaction_aix_processed_timestamp_key",
106
+ "vsam_esds_rrds_user_security_layout"
107
+ ],
108
+ "passed": true
109
+ },
110
+ {
111
+ "actual": {
112
+ "account_1_recent_transactions": "B",
113
+ "account_bundle_1": "B",
114
+ "account_statement_1": "B",
115
+ "account_update_caup_validated_rewrite": "B",
116
+ "admin_menu_options": "B",
117
+ "batch_resource_setup_gdg_vsam_aix_cics": "B",
118
+ "batch_transaction_type_mnttrdb2_fixed_record_flow": "B",
119
+ "bill_payment_full_balance": "B",
120
+ "card_detail_ccdl_account_1": "B",
121
+ "card_update_ccup_validated_rewrite": "B",
122
+ "combined_transactions_seed_plus_interest_preview": "B",
123
+ "customer_search_kessler": "B",
124
+ "db2_reference_creadb21_schema_and_load": "B",
125
+ "interest_projection_seed_tcatbal_discgrp": "B",
126
+ "mq_account_inquiry_cdra_success_and_invalid": "B",
127
+ "mq_system_date_cdrd_reply": "B",
128
+ "pending_authorization_cp00_request_response_and_insert": "B",
129
+ "pending_authorization_cpvd_detail_lookup": "B",
130
+ "pending_authorization_cpvd_fraud_and_cbpaup0j_purge": "B",
131
+ "pending_authorization_cpvs_summary_page": "B",
132
+ "posttran_accept_updates_account_and_tcatbal": "B",
133
+ "posttran_reject_codes": "B",
134
+ "regular_main_menu_options": "B",
135
+ "signon_admin_success": "B",
136
+ "signon_bad_password_message": "B",
137
+ "summary_seed_counts": "B",
138
+ "transaction_add_ct02_validated_write": "B",
139
+ "transaction_master_tranbkp_backup_redefine": "B",
140
+ "transaction_report_account_1": "B",
141
+ "transaction_type_cttu_validated_upsert_delete": "B",
142
+ "transaction_type_lookup": "B",
143
+ "transaction_type_tranextr_reference_extract": "B",
144
+ "user_maintenance_add_update_delete": "B",
145
+ "user_security_decode": "B"
146
+ },
147
+ "check": "all_golden_traces_static_oracle_or_better",
148
+ "passed": true
149
+ },
150
+ {
151
+ "actual": {
152
+ "legacy_program": "CODATE01",
153
+ "legacy_transaction": "CDRD",
154
+ "reply_message": "SYSTEM DATE : 05-23-2026SYSTEM TIME : 11:12:13",
155
+ "reply_queue": "CARD.DEMO.REPLY.DATE",
156
+ "request_payload_validated": false,
157
+ "system_date": "05-23-2026",
158
+ "system_time": "11:12:13"
159
+ },
160
+ "check": "mq_system_date_cdrd_reply_runtime_probe",
161
+ "expected": {
162
+ "legacy_program": "CODATE01",
163
+ "legacy_transaction": "CDRD",
164
+ "reply_message": "SYSTEM DATE : 05-23-2026SYSTEM TIME : 11:12:13",
165
+ "reply_queue": "CARD.DEMO.REPLY.DATE",
166
+ "request_payload_validated": false,
167
+ "system_date": "05-23-2026",
168
+ "system_time": "11:12:13"
169
+ },
170
+ "passed": true
171
+ },
172
+ {
173
+ "actual": {
174
+ "account_id": 1,
175
+ "active_status": "Y",
176
+ "bad_function_reply": "INVALID REQUEST PARAMETERS ACCT ID : 00000000001FUNCTION : BAD ",
177
+ "legacy_program": "COACCT01",
178
+ "legacy_transaction": "CDRA",
179
+ "not_found_reply": "INVALID REQUEST PARAMETERS ACCT ID : 99999999999",
180
+ "reply_has_account_label": true,
181
+ "reply_queue": "CARD.DEMO.REPLY.ACCT",
182
+ "request_account_key": "00000000001"
183
+ },
184
+ "check": "mq_account_inquiry_cdra_success_and_invalid_runtime_probe",
185
+ "expected": {
186
+ "account_id": 1,
187
+ "active_status": "Y",
188
+ "bad_function_reply": "INVALID REQUEST PARAMETERS ACCT ID : 00000000001FUNCTION : BAD ",
189
+ "legacy_program": "COACCT01",
190
+ "legacy_transaction": "CDRA",
191
+ "not_found_reply": "INVALID REQUEST PARAMETERS ACCT ID : 99999999999",
192
+ "reply_has_account_label": true,
193
+ "reply_queue": "CARD.DEMO.REPLY.ACCT",
194
+ "request_account_key": "00000000001"
195
+ },
196
+ "passed": true
197
+ },
198
+ {
199
+ "actual": {
200
+ "base_gdg_names": [
201
+ "AWS.M2.CARDDEMO.TRANSACT.BKUP",
202
+ "AWS.M2.CARDDEMO.TRANSACT.DALY",
203
+ "AWS.M2.CARDDEMO.TRANREPT",
204
+ "AWS.M2.CARDDEMO.TCATBALF.BKUP",
205
+ "AWS.M2.CARDDEMO.SYSTRAN",
206
+ "AWS.M2.CARDDEMO.TRANSACT.COMBINED"
207
+ ],
208
+ "close_code": "CLO",
209
+ "db2_first_generation_counts": [
210
+ 7,
211
+ 18,
212
+ 51
213
+ ],
214
+ "esds_rrds_organizations": [
215
+ "NONINDEXED",
216
+ "NUMBERED"
217
+ ],
218
+ "file_sets_match": true,
219
+ "open_code": "OPE",
220
+ "resource_count": 6,
221
+ "tranidx_keys": {
222
+ "length": 26,
223
+ "offset": 304
224
+ },
225
+ "tranidx_source_count": 300
226
+ },
227
+ "check": "batch_resource_setup_gdg_vsam_aix_cics_runtime_probe",
228
+ "expected": {
229
+ "base_gdg_names": [
230
+ "AWS.M2.CARDDEMO.TRANSACT.BKUP",
231
+ "AWS.M2.CARDDEMO.TRANSACT.DALY",
232
+ "AWS.M2.CARDDEMO.TRANREPT",
233
+ "AWS.M2.CARDDEMO.TCATBALF.BKUP",
234
+ "AWS.M2.CARDDEMO.SYSTRAN",
235
+ "AWS.M2.CARDDEMO.TRANSACT.COMBINED"
236
+ ],
237
+ "close_code": "CLO",
238
+ "db2_first_generation_counts": [
239
+ 7,
240
+ 18,
241
+ 51
242
+ ],
243
+ "esds_rrds_organizations": [
244
+ "NONINDEXED",
245
+ "NUMBERED"
246
+ ],
247
+ "file_sets_match": true,
248
+ "open_code": "OPE",
249
+ "resource_count": 6,
250
+ "tranidx_keys": {
251
+ "length": 26,
252
+ "offset": 304
253
+ },
254
+ "tranidx_source_count": 300
255
+ },
256
+ "passed": true
257
+ },
258
+ {
259
+ "actual": {
260
+ "first_transaction_id": "960b9b5480d045a",
261
+ "next_page": true,
262
+ "returned_authorizations": 5,
263
+ "summary_amount_cents": 944,
264
+ "summary_count": 6
265
+ },
266
+ "check": "pending_authorization_cpvs_summary_page_runtime_probe",
267
+ "expected": {
268
+ "first_transaction_id": "960b9b5480d045a",
269
+ "next_page": true,
270
+ "returned_authorizations": 5,
271
+ "summary_amount_cents": 944,
272
+ "summary_count": 6
273
+ },
274
+ "passed": true
275
+ },
276
+ {
277
+ "actual": {
278
+ "backward_page_type_codes": [
279
+ "04",
280
+ "05",
281
+ "06"
282
+ ],
283
+ "category_count": 18,
284
+ "description_filter_count": 1,
285
+ "legacy_program": "COTRTLIC",
286
+ "legacy_transaction": "CTLI",
287
+ "page_size": 7,
288
+ "type_count": 7,
289
+ "type_filter_result": [
290
+ "01"
291
+ ]
292
+ },
293
+ "check": "transaction_type_lookup_runtime_probe",
294
+ "expected": {
295
+ "backward_page_type_codes": [
296
+ "04",
297
+ "05",
298
+ "06"
299
+ ],
300
+ "category_count": 18,
301
+ "description_filter_count": 1,
302
+ "legacy_program": "COTRTLIC",
303
+ "legacy_transaction": "CTLI",
304
+ "page_size": 7,
305
+ "type_count": 7,
306
+ "type_filter_result": [
307
+ "01"
308
+ ]
309
+ },
310
+ "passed": true
311
+ },
312
+ {
313
+ "actual": {
314
+ "approved": true,
315
+ "approved_count_delta": 1,
316
+ "invalid_card_response_reason": "3100",
317
+ "invalid_card_written": false,
318
+ "response_code": "00",
319
+ "response_reason": "0000",
320
+ "written": true
321
+ },
322
+ "check": "pending_authorization_cp00_request_response_and_insert_runtime_probe",
323
+ "expected": {
324
+ "approved": true,
325
+ "approved_count_delta": 1,
326
+ "invalid_card_response_reason": "3100",
327
+ "invalid_card_written": false,
328
+ "response_code": "00",
329
+ "response_reason": "0000",
330
+ "written": true
331
+ },
332
+ "passed": true
333
+ }
334
+ ],
335
+ "claim_limit": "Executable modern replay over static/source-oracle traces only; no live COBOL/CICS runtime replay has been performed.",
336
+ "edge_case_count": 40,
337
+ "evidence_hash": "c661998c6538b8118b5abf4d248cad72dfa138e087bded1a4c37a5e6a7377bab",
338
+ "failed_checks": [],
339
+ "gap_count": 0,
340
+ "generated_utc": "2026-05-23T15:01:52+00:00",
341
+ "golden_trace_count": 34,
342
+ "grade_counts": {
343
+ "A": 0,
344
+ "B": 50,
345
+ "C": 0,
346
+ "F": 0
347
+ },
348
+ "passed": true,
349
+ "public_actions_allowed": false,
350
+ "replay_hash": "912e98e11d46cd967070d06ec17aaed3402bed44026267d1906ea6a2d54b9a42",
351
+ "replay_version": "modern_carddemo_static_oracle_replay_v0",
352
+ "runtime_probe_count": 6,
353
+ "runtime_probes": [
354
+ {
355
+ "actual": {
356
+ "legacy_program": "CODATE01",
357
+ "legacy_transaction": "CDRD",
358
+ "reply_message": "SYSTEM DATE : 05-23-2026SYSTEM TIME : 11:12:13",
359
+ "reply_queue": "CARD.DEMO.REPLY.DATE",
360
+ "request_payload_validated": false,
361
+ "system_date": "05-23-2026",
362
+ "system_time": "11:12:13"
363
+ },
364
+ "expected": {
365
+ "legacy_program": "CODATE01",
366
+ "legacy_transaction": "CDRD",
367
+ "reply_message": "SYSTEM DATE : 05-23-2026SYSTEM TIME : 11:12:13",
368
+ "reply_queue": "CARD.DEMO.REPLY.DATE",
369
+ "request_payload_validated": false,
370
+ "system_date": "05-23-2026",
371
+ "system_time": "11:12:13"
372
+ },
373
+ "passed": true,
374
+ "trace_id": "mq_system_date_cdrd_reply"
375
+ },
376
+ {
377
+ "actual": {
378
+ "account_id": 1,
379
+ "active_status": "Y",
380
+ "bad_function_reply": "INVALID REQUEST PARAMETERS ACCT ID : 00000000001FUNCTION : BAD ",
381
+ "legacy_program": "COACCT01",
382
+ "legacy_transaction": "CDRA",
383
+ "not_found_reply": "INVALID REQUEST PARAMETERS ACCT ID : 99999999999",
384
+ "reply_has_account_label": true,
385
+ "reply_queue": "CARD.DEMO.REPLY.ACCT",
386
+ "request_account_key": "00000000001"
387
+ },
388
+ "expected": {
389
+ "account_id": 1,
390
+ "active_status": "Y",
391
+ "bad_function_reply": "INVALID REQUEST PARAMETERS ACCT ID : 00000000001FUNCTION : BAD ",
392
+ "legacy_program": "COACCT01",
393
+ "legacy_transaction": "CDRA",
394
+ "not_found_reply": "INVALID REQUEST PARAMETERS ACCT ID : 99999999999",
395
+ "reply_has_account_label": true,
396
+ "reply_queue": "CARD.DEMO.REPLY.ACCT",
397
+ "request_account_key": "00000000001"
398
+ },
399
+ "passed": true,
400
+ "trace_id": "mq_account_inquiry_cdra_success_and_invalid"
401
+ },
402
+ {
403
+ "actual": {
404
+ "base_gdg_names": [
405
+ "AWS.M2.CARDDEMO.TRANSACT.BKUP",
406
+ "AWS.M2.CARDDEMO.TRANSACT.DALY",
407
+ "AWS.M2.CARDDEMO.TRANREPT",
408
+ "AWS.M2.CARDDEMO.TCATBALF.BKUP",
409
+ "AWS.M2.CARDDEMO.SYSTRAN",
410
+ "AWS.M2.CARDDEMO.TRANSACT.COMBINED"
411
+ ],
412
+ "close_code": "CLO",
413
+ "db2_first_generation_counts": [
414
+ 7,
415
+ 18,
416
+ 51
417
+ ],
418
+ "esds_rrds_organizations": [
419
+ "NONINDEXED",
420
+ "NUMBERED"
421
+ ],
422
+ "file_sets_match": true,
423
+ "open_code": "OPE",
424
+ "resource_count": 6,
425
+ "tranidx_keys": {
426
+ "length": 26,
427
+ "offset": 304
428
+ },
429
+ "tranidx_source_count": 300
430
+ },
431
+ "expected": {
432
+ "base_gdg_names": [
433
+ "AWS.M2.CARDDEMO.TRANSACT.BKUP",
434
+ "AWS.M2.CARDDEMO.TRANSACT.DALY",
435
+ "AWS.M2.CARDDEMO.TRANREPT",
436
+ "AWS.M2.CARDDEMO.TCATBALF.BKUP",
437
+ "AWS.M2.CARDDEMO.SYSTRAN",
438
+ "AWS.M2.CARDDEMO.TRANSACT.COMBINED"
439
+ ],
440
+ "close_code": "CLO",
441
+ "db2_first_generation_counts": [
442
+ 7,
443
+ 18,
444
+ 51
445
+ ],
446
+ "esds_rrds_organizations": [
447
+ "NONINDEXED",
448
+ "NUMBERED"
449
+ ],
450
+ "file_sets_match": true,
451
+ "open_code": "OPE",
452
+ "resource_count": 6,
453
+ "tranidx_keys": {
454
+ "length": 26,
455
+ "offset": 304
456
+ },
457
+ "tranidx_source_count": 300
458
+ },
459
+ "passed": true,
460
+ "trace_id": "batch_resource_setup_gdg_vsam_aix_cics"
461
+ },
462
+ {
463
+ "actual": {
464
+ "first_transaction_id": "960b9b5480d045a",
465
+ "next_page": true,
466
+ "returned_authorizations": 5,
467
+ "summary_amount_cents": 944,
468
+ "summary_count": 6
469
+ },
470
+ "expected": {
471
+ "first_transaction_id": "960b9b5480d045a",
472
+ "next_page": true,
473
+ "returned_authorizations": 5,
474
+ "summary_amount_cents": 944,
475
+ "summary_count": 6
476
+ },
477
+ "passed": true,
478
+ "trace_id": "pending_authorization_cpvs_summary_page"
479
+ },
480
+ {
481
+ "actual": {
482
+ "backward_page_type_codes": [
483
+ "04",
484
+ "05",
485
+ "06"
486
+ ],
487
+ "category_count": 18,
488
+ "description_filter_count": 1,
489
+ "legacy_program": "COTRTLIC",
490
+ "legacy_transaction": "CTLI",
491
+ "page_size": 7,
492
+ "type_count": 7,
493
+ "type_filter_result": [
494
+ "01"
495
+ ]
496
+ },
497
+ "expected": {
498
+ "backward_page_type_codes": [
499
+ "04",
500
+ "05",
501
+ "06"
502
+ ],
503
+ "category_count": 18,
504
+ "description_filter_count": 1,
505
+ "legacy_program": "COTRTLIC",
506
+ "legacy_transaction": "CTLI",
507
+ "page_size": 7,
508
+ "type_count": 7,
509
+ "type_filter_result": [
510
+ "01"
511
+ ]
512
+ },
513
+ "passed": true,
514
+ "trace_id": "transaction_type_lookup"
515
+ },
516
+ {
517
+ "actual": {
518
+ "approved": true,
519
+ "approved_count_delta": 1,
520
+ "invalid_card_response_reason": "3100",
521
+ "invalid_card_written": false,
522
+ "response_code": "00",
523
+ "response_reason": "0000",
524
+ "written": true
525
+ },
526
+ "expected": {
527
+ "approved": true,
528
+ "approved_count_delta": 1,
529
+ "invalid_card_response_reason": "3100",
530
+ "invalid_card_written": false,
531
+ "response_code": "00",
532
+ "response_reason": "0000",
533
+ "written": true
534
+ },
535
+ "passed": true,
536
+ "trace_id": "pending_authorization_cp00_request_response_and_insert"
537
+ }
538
+ ],
539
+ "scratch_db_path": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\modern_carddemo\\reports\\static_oracle_replay.sqlite",
540
+ "seed_counts": {
541
+ "accounts": 50,
542
+ "card_xrefs": 50,
543
+ "cards": 50,
544
+ "customers": 50,
545
+ "disclosure_groups": 51,
546
+ "pending_authorization_details": 202,
547
+ "pending_authorization_summaries": 21,
548
+ "transaction_categories": 18,
549
+ "transaction_category_balances": 50,
550
+ "transaction_types": 7,
551
+ "transactions": 300,
552
+ "users": 10
553
+ },
554
+ "source_head": "59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e",
555
+ "source_root": "D:\\scraper_storage\\modernization_labs\\aws-carddemo-modernization-20260523T073000Z\\source",
556
+ "summary": {
557
+ "capability_count": 50,
558
+ "claim_limit": "capability ledger and static-oracle traces only; no all-path COBOL runtime proof yet",
559
+ "edge_case_count": 40,
560
+ "gap_count": 0,
561
+ "golden_trace_count": 34,
562
+ "grade_counts": {
563
+ "A": 0,
564
+ "B": 50,
565
+ "C": 0,
566
+ "F": 0
567
+ },
568
+ "one_for_one_parity_ready": true,
569
+ "partial_or_inferred_count": 0,
570
+ "static_oracle_or_better_count": 50,
571
+ "strict_runtime_parity_count": 0
572
+ }
573
+ }
modern_code/README.md ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Modern CardDemo
2
+
3
+ Autonomous best-effort modernization of AWS CardDemo from COBOL/CICS/VSAM/JCL into a small Python web/API application.
4
+
5
+ ## What This Preserves
6
+
7
+ - The original AWS CardDemo source clone is preserved at `../source`.
8
+ - Seed data is loaded from the original ASCII/EBCDIC files under `../source/app/data`.
9
+ - Fixed-width layouts are derived from CardDemo copybooks for customer, account, card, card xref, transaction, transaction type, transaction category, and user security records.
10
+ - The old system remains the behavioral oracle where it can be exercised. This lab does not require human approval; unresolved behavior becomes an assumption or gap receipt.
11
+
12
+ ## Modern Target
13
+
14
+ - Standard-library Python 3 application.
15
+ - SQLite persistence.
16
+ - JSON API plus browser UI.
17
+ - No external package install required.
18
+ - Batch/report parity surfaces for `TRANREPT`, `CREASTMT`, `INTCALC`, and `COMBTRAN`.
19
+ - Batch resource setup/control parity metadata for `DEFGDGB`, `DEFGDGD`, `ESDSRRDS`, `TRANIDX`, `CLOSEFIL`, and `OPENFIL`.
20
+ - Signon, regular/admin menu routing, and SQLite-backed user security maintenance for `CC00`, `CM00`, `CA00`, `CU01`, `CU02`, and `CU03`.
21
+ - Transaction type maintenance for `CTTU`, including type-code validation, update/insert, no-change rejection, and guarded delete.
22
+ - MQ request/reply parity surfaces for `CDRD` and `CDRA`, including source-shaped 1000-byte message metadata, system date/time reply formatting, and account inquiry over `ACCTDAT`.
23
+ - Pending authorization IMS/DB2/MQ parity surfaces for `CPVS`, `CPVD`, `CP00`, and `CBPAUP0J`, seeded from the original `DBPAUTP0` IMS unload.
24
+
25
+ ## Run
26
+
27
+ ```powershell
28
+ cd D:\scraper_storage\modernization_labs\aws-carddemo-modernization-20260523T073000Z\modern_carddemo
29
+ python -m carddemo.cli init-db --source-root ..\source --db-path .\carddemo.sqlite
30
+ python -m carddemo.cli serve --source-root ..\source --db-path .\carddemo.sqlite --port 8087
31
+ ```
32
+
33
+ Open `http://127.0.0.1:8087`.
34
+
35
+ ## Test And Receipts
36
+
37
+ ```powershell
38
+ python -m unittest discover -s tests
39
+ python tools\generate_receipts.py --source-root ..\source --db-path .\carddemo.sqlite --out-dir .\reports
40
+ python tools\replay_static_oracles.py --source-root ..\source --out-dir .\reports
41
+ ```
42
+
43
+ Receipt and replay generation write the capability-parity proof pack:
44
+
45
+ - `reports/capability_ledger.json`: every discovered AWS CardDemo online and batch capability with source refs and proof grade.
46
+ - `reports/golden_traces.json`: deterministic service traces backed by legacy seed files or explicit inferred rules.
47
+ - `reports/edge_cases.json`: data- and copybook-derived edge cases to drive future parity closure.
48
+ - `reports/next_gap_ranking.json`: autonomous next-work queue, sorted by gap severity and capability priority.
49
+ - `reports/static_oracle_replay.json`: executable modern-service replay over the static/source-oracle trace pack, using a scratch SQLite database.
50
+
51
+ Proof grades are `A` for actual legacy runtime trace match, `B` for static legacy data/copybook oracle match, `C` for implemented or inferred without strict parity proof, and `F` for discovered capability gaps.
52
+
53
+ ## Added Batch/API Surfaces
54
+
55
+ - `GET /api/reports/transactions`: seed-data transaction detail report following the legacy `TRANREPT` joins and date filter shape.
56
+ - `GET /api/statements/{account_id}`: account statement text/HTML payload following the `CREASTMT` account, customer, card, transaction source sort, 80-byte statement line, and total-expense flow.
57
+ - `GET /api/interest-projection`: `INTCALC` formula preview using `TCATBALF` and `DISCGRP` seed files.
58
+ - `GET /api/batch/combined-transactions`: `COMBTRAN`-style concatenation of `TRANSACT.BKUP(0)` and `SYSTRAN(0)`, ascending `TRAN-ID` sort, `TRANSACT.COMBINED(+1)` output metadata, and transaction KSDS REPRO target metadata.
59
+ - `GET /api/batch/transaction-master-backup`: `TRANBKP`-style transaction master backup/redefine metadata, including `REPROC` source/backup datasets, IDCAMS delete targets, 350-byte KSDS record size, and 16-byte transaction-id key contract.
60
+ - `GET /api/batch/transaction-type-extract`: `TRANEXTR`-style `DSNTIAUL` extract for transaction type/category reference files, including backup/output datasets, ordered 60-byte records, and zero-fill suffixes.
61
+ - `GET /api/batch/db2-reference-setup`: `CREADB21`-style Db2 transaction reference setup, including free-plan/create/load step order, database/tablespace/table/index/grant metadata, load counts, and category-to-type restrict-delete foreign key.
62
+ - `GET /api/batch/resource-setup`: setup/control metadata for `DEFGDGB`, `DEFGDGD`, `ESDSRRDS`, `TRANIDX`, `CLOSEFIL`, and `OPENFIL`; pass `job=<name>` for one source job.
63
+ - `GET`/`POST /api/mq/system-date`: `CDRD`/`CODATE01` MQ request/reply model that returns `SYSTEM DATE : MM-DD-YYYY` and `SYSTEM TIME : HH:MM:SS` using the source reply labels.
64
+ - `GET`/`POST /api/mq/account-inquiry`: `CDRA`/`COACCT01` MQ request/reply model for `INQA` plus an 11-digit account key, returning labeled `ACCTDAT` account fields or the source-shaped invalid-parameters reply.
65
+ - `GET /api/pending-authorizations/summary`: `CPVS` pending authorization summary and five-row page flow over decoded `PAUTSUM0`/`PAUTDTL1` IMS unload records.
66
+ - `GET /api/pending-authorizations/detail`: `CPVD` pending authorization detail lookup by source-shaped authorization key or transaction id.
67
+ - `POST /api/pending-authorizations/process`: `CP00` authorization request processing with comma-delimited MQ request shape, available-credit decision, response CSV, summary update/insert, and detail insert.
68
+ - `POST /api/pending-authorizations/fraud`: `CPVD`/`COPAUS2C` fraud mark/remove flow with `AUTHFRDS` shadow-table write.
69
+ - `POST /api/batch/purge-authorizations`: `CBPAUP0J`/`CBPAUP0C` expired authorization purge using the reverse-date `PA-AUTH-DATE-9C` calculation and summary counter adjustment.
70
+ - `PATCH /api/accounts/{account_id}`: `CAUP` account update flow with account/xref lookup, Y/N status validation, signed money/date validation, no-change rejection, and account/customer SQLite rewrites.
71
+ - `GET /api/cards/{card_number}` and `PATCH /api/cards/{card_number}`: `CCDL`/`CCUP` card detail and update flow with account/card key validation, alphabetic embossed names, Y/N status, expiry month/year validation, no-change rejection, hidden-field preservation, and card SQLite rewrites.
72
+ - `POST /api/transactions`: `CT02` transaction-add flow with account/card xref lookup, confirmation, signed amount/date/merchant validation, transaction-id increment, and `TRANSACT` write without account-balance mutation.
73
+ - `GET /api/transaction-types`: `CTLI` transaction type list view with source-shaped seven-row cursor paging, forward/backward navigation, exact type-code filtering, and `LIKE` description filtering.
74
+ - `POST /api/transaction-types`, `PATCH /api/transaction-types/{type_code}`, and `DELETE /api/transaction-types/{type_code}`: `CTTU` transaction type maintenance with two-digit numeric nonzero type codes, required alphanumeric descriptions, no-change rejection, update-or-insert behavior, and child-record delete protection.
75
+ - `POST /api/batch/transaction-types`: `MNTTRDB2`/`COBTUPDT` batch transaction type maintenance over fixed `INPFILE` records, including `A` add, `U` update, `D` delete, `*` comment handling, return-code 4 error reporting, duplicate/missing-row SQL outcomes, and Db2 restrict-delete behavior.
76
+ - `POST /api/post-transactions`: `POSTTRAN`-style batch posting with card/account lookup, overlimit rejection, expiration rejection, category-balance update, and account cycle update.
77
+ - `POST /api/signon`: `CC00` signon over decoded `USRSEC`, including uppercase credential normalization and admin/user menu routing.
78
+ - `GET /api/menu/main` and `GET /api/menu/admin`: `CM00` and `CA00` menu option surfaces transcribed from the legacy menu copybooks/source.
79
+ - `POST /api/users`, `PATCH /api/users/{user_id}`, and `DELETE /api/users/{user_id}`: `CU01`, `CU02`, and `CU03` user maintenance flows over the modern SQLite user table, including source-shaped blank-field, duplicate, no-change, not-found, and non-admin user-type behavior.
80
+
81
+ ## Current Claim Limit
82
+
83
+ This is not claimed to be a proven production-equivalent replacement. It is a runnable modern target with seed-data parity checks, source fingerprints, tests, capability proof grades, gap ranking, and executable modern-service replay over static/source-oracle traces. Runtime parity against the original COBOL/CICS execution remains a gap unless a compatible mainframe or emulator harness is attached.
modern_code/carddemo/__init__.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ """Modern CardDemo package."""
2
+
3
+ __version__ = "0.1.0"
4
+
modern_code/carddemo/api.py ADDED
@@ -0,0 +1,336 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ import mimetypes
5
+ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
6
+ from pathlib import Path
7
+ from urllib.parse import parse_qs, urlparse
8
+
9
+ from .repository import seed_from_legacy
10
+ from .service import CardDemoService
11
+
12
+
13
+ STATIC_ROOT = Path(__file__).resolve().parent.parent / "static"
14
+
15
+
16
+ def make_handler(service: CardDemoService, source_root: Path):
17
+ class Handler(BaseHTTPRequestHandler):
18
+ server_version = "ModernCardDemo/0.1"
19
+
20
+ def do_GET(self) -> None:
21
+ parsed = urlparse(self.path)
22
+ query = parse_qs(parsed.query)
23
+ try:
24
+ if parsed.path == "/api/health":
25
+ self.json_response({"status": "ok", "source_root": str(source_root)})
26
+ elif parsed.path == "/api/summary":
27
+ self.json_response(service.summary())
28
+ elif parsed.path == "/api/menu/main":
29
+ self.json_response(service.main_menu(user_type=(query.get("user_type") or ["U"])[0]))
30
+ elif parsed.path == "/api/menu/admin":
31
+ self.json_response(service.admin_menu())
32
+ elif parsed.path == "/api/customers":
33
+ self.json_response(
34
+ service.list_customers(
35
+ query=(query.get("query") or [""])[0],
36
+ limit=int((query.get("limit") or ["50"])[0]),
37
+ )
38
+ )
39
+ elif parsed.path == "/api/accounts":
40
+ customer_id = (query.get("customer_id") or [""])[0]
41
+ self.json_response(
42
+ service.list_accounts(
43
+ customer_id=int(customer_id) if customer_id else None,
44
+ limit=int((query.get("limit") or ["50"])[0]),
45
+ )
46
+ )
47
+ elif parsed.path.startswith("/api/accounts/"):
48
+ account_id = int(parsed.path.rsplit("/", 1)[-1])
49
+ bundle = service.get_account_bundle(account_id)
50
+ if not bundle:
51
+ self.error_response(404, "account not found")
52
+ else:
53
+ self.json_response(bundle)
54
+ elif parsed.path == "/api/cards":
55
+ account_id = (query.get("account_id") or [""])[0]
56
+ customer_id = (query.get("customer_id") or [""])[0]
57
+ self.json_response(
58
+ service.list_cards(
59
+ account_id=int(account_id) if account_id else None,
60
+ customer_id=int(customer_id) if customer_id else None,
61
+ )
62
+ )
63
+ elif parsed.path.startswith("/api/cards/"):
64
+ card_number = parsed.path.rsplit("/", 1)[-1]
65
+ account_id = (query.get("account_id") or [""])[0]
66
+ self.json_response(service.get_card_detail(card_number, account_id=account_id or None))
67
+ elif parsed.path == "/api/transactions":
68
+ account_id = (query.get("account_id") or [""])[0]
69
+ self.json_response(
70
+ service.list_transactions(
71
+ account_id=int(account_id) if account_id else None,
72
+ card_number=(query.get("card_number") or [""])[0] or None,
73
+ limit=int((query.get("limit") or ["100"])[0]),
74
+ )
75
+ )
76
+ elif parsed.path == "/api/reports/transactions":
77
+ account_id = (query.get("account_id") or [""])[0]
78
+ self.json_response(
79
+ service.transaction_report(
80
+ start_date=(query.get("start_date") or [""])[0] or None,
81
+ end_date=(query.get("end_date") or [""])[0] or None,
82
+ account_id=int(account_id) if account_id else None,
83
+ card_number=(query.get("card_number") or [""])[0] or None,
84
+ limit=int((query.get("limit") or ["1000"])[0]),
85
+ )
86
+ )
87
+ elif parsed.path.startswith("/api/statements/"):
88
+ account_id = int(parsed.path.rsplit("/", 1)[-1])
89
+ self.json_response(service.account_statement(account_id))
90
+ elif parsed.path == "/api/interest-projection":
91
+ self.json_response(
92
+ service.interest_projection(
93
+ processing_date=(query.get("processing_date") or [""])[0] or None,
94
+ limit=int((query.get("limit") or ["1000"])[0]),
95
+ )
96
+ )
97
+ elif parsed.path == "/api/batch/combined-transactions":
98
+ self.json_response(
99
+ service.combined_transactions(
100
+ processing_date=(query.get("processing_date") or [""])[0] or None,
101
+ limit=int((query.get("limit") or ["1000"])[0]),
102
+ )
103
+ )
104
+ elif parsed.path == "/api/batch/transaction-master-backup":
105
+ self.json_response(
106
+ service.transaction_master_backup(
107
+ limit=int((query.get("limit") or ["20"])[0]),
108
+ )
109
+ )
110
+ elif parsed.path == "/api/batch/transaction-type-extract":
111
+ self.json_response(service.transaction_type_extract())
112
+ elif parsed.path == "/api/batch/db2-reference-setup":
113
+ self.json_response(service.db2_reference_setup())
114
+ elif parsed.path == "/api/batch/resource-setup":
115
+ self.json_response(
116
+ service.batch_resource_setup(
117
+ job=(query.get("job") or [""])[0] or None,
118
+ )
119
+ )
120
+ elif parsed.path == "/api/mq/system-date":
121
+ self.json_response(
122
+ service.mq_system_date(
123
+ {
124
+ "now": (query.get("now") or [""])[0] or None,
125
+ "request_message": (query.get("request_message") or [""])[0] or None,
126
+ }
127
+ )
128
+ )
129
+ elif parsed.path == "/api/mq/account-inquiry":
130
+ self.json_response(
131
+ service.mq_account_inquiry(
132
+ {
133
+ "function": (query.get("function") or ["INQA"])[0],
134
+ "account_id": (query.get("account_id") or query.get("account_number") or ["0"])[0],
135
+ "request_message": (query.get("request_message") or [""])[0] or None,
136
+ }
137
+ )
138
+ )
139
+ elif parsed.path == "/api/pending-authorizations/summary":
140
+ self.json_response(
141
+ service.pending_authorization_summary(
142
+ int((query.get("account_id") or ["0"])[0]),
143
+ start_key=(query.get("start_key") or [""])[0] or None,
144
+ page_size=int((query.get("page_size") or ["5"])[0]),
145
+ )
146
+ )
147
+ elif parsed.path == "/api/pending-authorizations/detail":
148
+ self.json_response(
149
+ service.pending_authorization_detail(
150
+ int((query.get("account_id") or ["0"])[0]),
151
+ authorization_key=(query.get("authorization_key") or [""])[0] or None,
152
+ transaction_id=(query.get("transaction_id") or [""])[0] or None,
153
+ )
154
+ )
155
+ elif parsed.path == "/api/users":
156
+ self.json_response(service.list_users())
157
+ elif parsed.path.startswith("/api/users/"):
158
+ user_id = parsed.path.rsplit("/", 1)[-1]
159
+ user = service.get_user(user_id)
160
+ if not user:
161
+ self.error_response(404, "User ID NOT found...")
162
+ else:
163
+ self.json_response(user)
164
+ elif parsed.path == "/api/transaction-types":
165
+ self.json_response(
166
+ service.transaction_types(
167
+ start_key=(query.get("start_key") or [""])[0],
168
+ direction=(query.get("direction") or ["forward"])[0],
169
+ type_filter=(query.get("type_code") or [""])[0] or None,
170
+ description_filter=(query.get("description") or [""])[0] or None,
171
+ page_size=int((query.get("page_size") or ["7"])[0]),
172
+ )
173
+ )
174
+ elif parsed.path == "/" or parsed.path.startswith("/static/"):
175
+ self.static_response(parsed.path)
176
+ else:
177
+ self.error_response(404, "not found")
178
+ except KeyError as exc:
179
+ self.error_response(404, str(exc))
180
+ except ValueError as exc:
181
+ self.error_response(400, str(exc))
182
+ except Exception as exc: # pragma: no cover - defensive API boundary
183
+ self.error_response(500, str(exc))
184
+
185
+ def do_POST(self) -> None:
186
+ parsed = urlparse(self.path)
187
+ try:
188
+ payload = self.read_json()
189
+ if parsed.path == "/api/signon":
190
+ self.json_response(service.signon(payload.get("user_id", ""), payload.get("password", "")))
191
+ elif parsed.path == "/api/users":
192
+ self.json_response(service.add_user(payload), status=201)
193
+ elif parsed.path == "/api/transactions":
194
+ self.json_response(service.add_transaction(payload), status=201)
195
+ elif parsed.path == "/api/transaction-types":
196
+ result = service.upsert_transaction_type(payload)
197
+ self.json_response(result, status=201 if result["action"] == "inserted" else 200)
198
+ elif parsed.path == "/api/batch/transaction-types":
199
+ records = payload.get("records")
200
+ if records is None:
201
+ records = str(payload.get("input_text", "")).splitlines()
202
+ self.json_response(
203
+ service.maintain_transaction_types(
204
+ records,
205
+ dry_run=bool(payload.get("dry_run", False)),
206
+ )
207
+ )
208
+ elif parsed.path == "/api/mq/system-date":
209
+ self.json_response(service.mq_system_date(payload))
210
+ elif parsed.path == "/api/mq/account-inquiry":
211
+ self.json_response(service.mq_account_inquiry(payload))
212
+ elif parsed.path == "/api/pending-authorizations/process":
213
+ self.json_response(service.process_authorization_request(payload), status=201)
214
+ elif parsed.path == "/api/pending-authorizations/fraud":
215
+ self.json_response(
216
+ service.mark_authorization_fraud(
217
+ int(payload.get("account_id")),
218
+ str(payload.get("authorization_key")),
219
+ action=str(payload.get("action") or "toggle"),
220
+ report_date=payload.get("report_date"),
221
+ )
222
+ )
223
+ elif parsed.path == "/api/batch/purge-authorizations":
224
+ self.json_response(
225
+ service.purge_expired_authorizations(
226
+ current_yyddd=payload.get("current_yyddd"),
227
+ expiry_days=int(payload.get("expiry_days", 5)),
228
+ dry_run=bool(payload.get("dry_run", False)),
229
+ )
230
+ )
231
+ elif parsed.path == "/api/bill-payments":
232
+ amount = payload.get("amount_cents")
233
+ self.json_response(
234
+ service.bill_payment(
235
+ account_id=int(payload.get("account_id")),
236
+ amount_cents=int(amount) if amount is not None else None,
237
+ ),
238
+ status=201,
239
+ )
240
+ elif parsed.path == "/api/post-transactions":
241
+ result = service.post_transaction(payload, reject_on_failure=False)
242
+ self.json_response(result, status=201 if result["accepted"] else 422)
243
+ elif parsed.path == "/api/admin/reseed":
244
+ counts = seed_from_legacy(source_root, service.db_path, reset=True)
245
+ self.json_response({"status": "reseeded", "counts": counts})
246
+ else:
247
+ self.error_response(404, "not found")
248
+ except Exception as exc:
249
+ self.error_response(400, str(exc))
250
+
251
+ def do_PATCH(self) -> None:
252
+ parsed = urlparse(self.path)
253
+ try:
254
+ payload = self.read_json()
255
+ if parsed.path.startswith("/api/accounts/"):
256
+ account_id = int(parsed.path.rsplit("/", 1)[-1])
257
+ self.json_response(service.update_account(account_id, payload))
258
+ elif parsed.path.startswith("/api/cards/"):
259
+ card_number = parsed.path.rsplit("/", 1)[-1]
260
+ self.json_response(service.update_card(card_number, payload))
261
+ elif parsed.path.startswith("/api/users/"):
262
+ user_id = parsed.path.rsplit("/", 1)[-1]
263
+ self.json_response(service.update_user(user_id, payload))
264
+ elif parsed.path.startswith("/api/transaction-types/"):
265
+ type_code = parsed.path.rsplit("/", 1)[-1]
266
+ self.json_response(service.upsert_transaction_type({**payload, "type_code": type_code}))
267
+ else:
268
+ self.error_response(404, "not found")
269
+ except KeyError as exc:
270
+ self.error_response(404, str(exc))
271
+ except Exception as exc:
272
+ self.error_response(400, str(exc))
273
+
274
+ def do_DELETE(self) -> None:
275
+ parsed = urlparse(self.path)
276
+ try:
277
+ if parsed.path.startswith("/api/users/"):
278
+ user_id = parsed.path.rsplit("/", 1)[-1]
279
+ self.json_response(service.delete_user(user_id))
280
+ elif parsed.path.startswith("/api/transaction-types/"):
281
+ type_code = parsed.path.rsplit("/", 1)[-1]
282
+ self.json_response(service.delete_transaction_type(type_code))
283
+ else:
284
+ self.error_response(404, "not found")
285
+ except KeyError as exc:
286
+ self.error_response(404, str(exc))
287
+ except Exception as exc:
288
+ self.error_response(400, str(exc))
289
+
290
+ def read_json(self) -> dict:
291
+ length = int(self.headers.get("Content-Length") or "0")
292
+ if not length:
293
+ return {}
294
+ return json.loads(self.rfile.read(length).decode("utf-8"))
295
+
296
+ def json_response(self, payload, status: int = 200) -> None:
297
+ body = json.dumps(payload, indent=2).encode("utf-8")
298
+ self.send_response(status)
299
+ self.send_header("Content-Type", "application/json; charset=utf-8")
300
+ self.send_header("Content-Length", str(len(body)))
301
+ self.end_headers()
302
+ self.wfile.write(body)
303
+
304
+ def error_response(self, status: int, message: str) -> None:
305
+ self.json_response({"error": message}, status=status)
306
+
307
+ def static_response(self, path: str) -> None:
308
+ rel = "index.html" if path == "/" else path.removeprefix("/static/")
309
+ target = (STATIC_ROOT / rel).resolve()
310
+ if STATIC_ROOT not in target.parents and target != STATIC_ROOT:
311
+ self.error_response(403, "forbidden")
312
+ return
313
+ if not target.exists() or not target.is_file():
314
+ self.error_response(404, "not found")
315
+ return
316
+ body = target.read_bytes()
317
+ content_type = mimetypes.guess_type(str(target))[0] or "application/octet-stream"
318
+ self.send_response(200)
319
+ self.send_header("Content-Type", content_type)
320
+ self.send_header("Content-Length", str(len(body)))
321
+ self.end_headers()
322
+ self.wfile.write(body)
323
+
324
+ def log_message(self, fmt: str, *args) -> None:
325
+ print(f"{self.address_string()} - {fmt % args}")
326
+
327
+ return Handler
328
+
329
+
330
+ def serve(source_root: Path, db_path: Path, host: str = "127.0.0.1", port: int = 8087) -> None:
331
+ if not db_path.exists():
332
+ seed_from_legacy(source_root, db_path, reset=True)
333
+ service = CardDemoService(db_path)
334
+ server = ThreadingHTTPServer((host, port), make_handler(service, source_root))
335
+ print(f"Modern CardDemo serving http://{host}:{port}")
336
+ server.serve_forever()
modern_code/carddemo/cli.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ from pathlib import Path
5
+
6
+ from .api import serve
7
+ from .repository import seed_from_legacy
8
+ from .service import CardDemoService
9
+
10
+
11
+ def main() -> None:
12
+ parser = argparse.ArgumentParser(description="Modern CardDemo runner")
13
+ sub = parser.add_subparsers(dest="command", required=True)
14
+
15
+ init_db = sub.add_parser("init-db", help="Initialize SQLite from legacy CardDemo data")
16
+ init_db.add_argument("--source-root", type=Path, required=True)
17
+ init_db.add_argument("--db-path", type=Path, required=True)
18
+
19
+ serve_cmd = sub.add_parser("serve", help="Serve the modern web/API app")
20
+ serve_cmd.add_argument("--source-root", type=Path, required=True)
21
+ serve_cmd.add_argument("--db-path", type=Path, required=True)
22
+ serve_cmd.add_argument("--host", default="127.0.0.1")
23
+ serve_cmd.add_argument("--port", type=int, default=8087)
24
+
25
+ summary = sub.add_parser("summary", help="Print database summary")
26
+ summary.add_argument("--db-path", type=Path, required=True)
27
+
28
+ args = parser.parse_args()
29
+ if args.command == "init-db":
30
+ counts = seed_from_legacy(args.source_root, args.db_path, reset=True)
31
+ print(counts)
32
+ elif args.command == "serve":
33
+ serve(args.source_root, args.db_path, host=args.host, port=args.port)
34
+ elif args.command == "summary":
35
+ print(CardDemoService(args.db_path).summary())
36
+
37
+
38
+ if __name__ == "__main__":
39
+ main()
40
+
modern_code/carddemo/legacy_parser.py ADDED
@@ -0,0 +1,384 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from pathlib import Path
5
+ from typing import Iterable
6
+
7
+
8
+ POS_OVERPUNCH = {
9
+ "{": "0",
10
+ "A": "1",
11
+ "B": "2",
12
+ "C": "3",
13
+ "D": "4",
14
+ "E": "5",
15
+ "F": "6",
16
+ "G": "7",
17
+ "H": "8",
18
+ "I": "9",
19
+ }
20
+ NEG_OVERPUNCH = {
21
+ "}": "0",
22
+ "J": "1",
23
+ "K": "2",
24
+ "L": "3",
25
+ "M": "4",
26
+ "N": "5",
27
+ "O": "6",
28
+ "P": "7",
29
+ "Q": "8",
30
+ "R": "9",
31
+ }
32
+
33
+
34
+ @dataclass(frozen=True)
35
+ class Field:
36
+ name: str
37
+ start: int
38
+ length: int
39
+ kind: str = "text"
40
+ scale: int = 0
41
+
42
+
43
+ CUSTOMER_FIELDS = [
44
+ Field("customer_id", 0, 9, "int"),
45
+ Field("first_name", 9, 25),
46
+ Field("middle_name", 34, 25),
47
+ Field("last_name", 59, 25),
48
+ Field("address_line_1", 84, 50),
49
+ Field("address_line_2", 134, 50),
50
+ Field("address_line_3", 184, 50),
51
+ Field("state", 234, 2),
52
+ Field("country", 236, 3),
53
+ Field("zip_code", 239, 10),
54
+ Field("phone_1", 249, 15),
55
+ Field("phone_2", 264, 15),
56
+ Field("ssn", 279, 9),
57
+ Field("government_id", 288, 20),
58
+ Field("date_of_birth", 308, 10),
59
+ Field("eft_account_id", 318, 10),
60
+ Field("primary_card_holder", 328, 1),
61
+ Field("fico_score", 329, 3, "int"),
62
+ ]
63
+
64
+ ACCOUNT_FIELDS = [
65
+ Field("account_id", 0, 11, "int"),
66
+ Field("active_status", 11, 1),
67
+ Field("current_balance_cents", 12, 12, "money", 2),
68
+ Field("credit_limit_cents", 24, 12, "money", 2),
69
+ Field("cash_credit_limit_cents", 36, 12, "money", 2),
70
+ Field("open_date", 48, 10),
71
+ Field("expiration_date", 58, 10),
72
+ Field("reissue_date", 68, 10),
73
+ Field("current_cycle_credit_cents", 78, 12, "money", 2),
74
+ Field("current_cycle_debit_cents", 90, 12, "money", 2),
75
+ Field("zip_code", 102, 10),
76
+ Field("group_id", 112, 10),
77
+ ]
78
+
79
+ CARD_FIELDS = [
80
+ Field("card_number", 0, 16),
81
+ Field("account_id", 16, 11, "int"),
82
+ Field("cvv", 27, 3),
83
+ Field("embossed_name", 30, 50),
84
+ Field("expiration_date", 80, 10),
85
+ Field("active_status", 90, 1),
86
+ ]
87
+
88
+ CARD_XREF_FIELDS = [
89
+ Field("card_number", 0, 16),
90
+ Field("customer_id", 16, 9, "int"),
91
+ Field("account_id", 25, 11, "int"),
92
+ ]
93
+
94
+ TRANSACTION_FIELDS = [
95
+ Field("transaction_id", 0, 16),
96
+ Field("type_code", 16, 2),
97
+ Field("category_code", 18, 4),
98
+ Field("source", 22, 10),
99
+ Field("description", 32, 100),
100
+ Field("amount_cents", 132, 11, "money", 2),
101
+ Field("merchant_id", 143, 9),
102
+ Field("merchant_name", 152, 50),
103
+ Field("merchant_city", 202, 50),
104
+ Field("merchant_zip", 252, 10),
105
+ Field("card_number", 262, 16),
106
+ Field("original_timestamp", 278, 26),
107
+ Field("processed_timestamp", 304, 26),
108
+ ]
109
+
110
+ TRANSACTION_TYPE_FIELDS = [
111
+ Field("type_code", 0, 2),
112
+ Field("description", 2, 50),
113
+ ]
114
+
115
+ TRANSACTION_CATEGORY_FIELDS = [
116
+ Field("type_code", 0, 2),
117
+ Field("category_code", 2, 4),
118
+ Field("description", 6, 50),
119
+ ]
120
+
121
+ DISCLOSURE_GROUP_FIELDS = [
122
+ Field("group_id", 0, 10),
123
+ Field("type_code", 10, 2),
124
+ Field("category_code", 12, 4),
125
+ Field("interest_rate_basis_points", 16, 6, "money", 2),
126
+ ]
127
+
128
+ TRANSACTION_CATEGORY_BALANCE_FIELDS = [
129
+ Field("account_id", 0, 11, "int"),
130
+ Field("type_code", 11, 2),
131
+ Field("category_code", 13, 4),
132
+ Field("balance_cents", 17, 11, "money", 2),
133
+ ]
134
+
135
+ USER_FIELDS = [
136
+ Field("user_id", 0, 8),
137
+ Field("first_name", 8, 20),
138
+ Field("last_name", 28, 20),
139
+ Field("password", 48, 8),
140
+ Field("user_type", 56, 1),
141
+ ]
142
+
143
+ PAUTSUM0_MARKER = b"\xd7\xc1\xe4\xe3\xe2\xe4\xd4\xf0"
144
+ PAUTDTL1_MARKER = b"\xd7\xc1\xe4\xe3\xc4\xe3\xd3\xf1"
145
+ IMS_UNLOAD_SEGMENT_DATA_OFFSET = 29
146
+
147
+
148
+ def parse_overpunch_int(raw: str) -> int:
149
+ text = raw.strip()
150
+ if not text:
151
+ return 0
152
+ last = text[-1]
153
+ sign = 1
154
+ if last in POS_OVERPUNCH:
155
+ text = text[:-1] + POS_OVERPUNCH[last]
156
+ elif last in NEG_OVERPUNCH:
157
+ text = text[:-1] + NEG_OVERPUNCH[last]
158
+ sign = -1
159
+ elif last in "+-":
160
+ sign = -1 if last == "-" else 1
161
+ text = text[:-1]
162
+ return sign * int(text or "0")
163
+
164
+
165
+ def parse_money(raw: str, scale: int = 2) -> int:
166
+ return parse_overpunch_int(raw) if scale == 2 else parse_overpunch_int(raw)
167
+
168
+
169
+ def money_to_display(cents: int | None) -> str:
170
+ cents = int(cents or 0)
171
+ sign = "-" if cents < 0 else ""
172
+ value = abs(cents)
173
+ return f"{sign}{value // 100}.{value % 100:02d}"
174
+
175
+
176
+ def parse_fixed_width(line: str, fields: Iterable[Field]) -> dict[str, object]:
177
+ out: dict[str, object] = {}
178
+ for field in fields:
179
+ raw = line[field.start : field.start + field.length]
180
+ if field.kind == "int":
181
+ out[field.name] = int(raw.strip() or "0")
182
+ elif field.kind == "money":
183
+ out[field.name] = parse_money(raw, field.scale)
184
+ else:
185
+ out[field.name] = raw.rstrip()
186
+ return out
187
+
188
+
189
+ def fixed_lines(path: Path, width: int | None = None, encoding: str = "utf-8") -> list[str]:
190
+ text = path.read_text(encoding=encoding)
191
+ lines = text.splitlines()
192
+ if width and len(lines) == 1 and len(lines[0]) > width:
193
+ joined = lines[0]
194
+ return [joined[index : index + width] for index in range(0, len(joined), width)]
195
+ return [line for line in lines if line]
196
+
197
+
198
+ def parse_ascii_file(path: Path, fields: Iterable[Field], width: int) -> list[dict[str, object]]:
199
+ return [parse_fixed_width(line.ljust(width), fields) for line in fixed_lines(path, width=width)]
200
+
201
+
202
+ def parse_user_security(path: Path) -> list[dict[str, object]]:
203
+ raw = path.read_bytes()
204
+ decoded = raw.decode("cp037")
205
+ records: list[dict[str, object]] = []
206
+ for index in range(0, len(decoded), 80):
207
+ chunk = decoded[index : index + 80]
208
+ if not chunk.strip():
209
+ continue
210
+ records.append(parse_fixed_width(chunk.ljust(80), USER_FIELDS))
211
+ return records
212
+
213
+
214
+ def parse_packed_decimal(raw: bytes) -> int:
215
+ digits: list[str] = []
216
+ sign = 1
217
+ for index, byte in enumerate(raw):
218
+ high = byte >> 4
219
+ low = byte & 0x0F
220
+ if index == len(raw) - 1:
221
+ if high > 9 or low not in (0x0C, 0x0D, 0x0F):
222
+ raise ValueError(f"invalid packed decimal byte: {byte:02x}")
223
+ digits.append(str(high))
224
+ sign = -1 if low == 0x0D else 1
225
+ else:
226
+ if high > 9 or low > 9:
227
+ raise ValueError(f"invalid packed decimal byte: {byte:02x}")
228
+ digits.extend((str(high), str(low)))
229
+ return sign * int("".join(digits) or "0")
230
+
231
+
232
+ def parse_comp(raw: bytes) -> int:
233
+ return int.from_bytes(raw, "big", signed=True)
234
+
235
+
236
+ def _ebcdic_text(raw: bytes) -> str:
237
+ return raw.decode("cp037", errors="replace").replace("\x00", "").rstrip()
238
+
239
+
240
+ def _iter_ims_unload_segments(raw: bytes):
241
+ markers: list[tuple[int, str]] = []
242
+ for marker, name in ((PAUTSUM0_MARKER, "summary"), (PAUTDTL1_MARKER, "detail")):
243
+ start = 0
244
+ while True:
245
+ offset = raw.find(marker, start)
246
+ if offset < 0:
247
+ break
248
+ markers.append((offset, name))
249
+ start = offset + 1
250
+ for offset, name in sorted(markers):
251
+ length = 100 if name == "summary" else 200
252
+ data_start = offset + IMS_UNLOAD_SEGMENT_DATA_OFFSET
253
+ yield offset, name, raw[data_start : data_start + length]
254
+
255
+
256
+ def _parse_pending_authorization_summary(raw: bytes, sequence_no: int) -> dict[str, object]:
257
+ offset = 0
258
+ account_id = parse_packed_decimal(raw[offset : offset + 6])
259
+ offset += 6
260
+ customer_id = int(_ebcdic_text(raw[offset : offset + 9]) or "0")
261
+ offset += 9
262
+ auth_status = _ebcdic_text(raw[offset : offset + 1])
263
+ offset += 1
264
+ account_statuses = []
265
+ for _ in range(5):
266
+ account_statuses.append(_ebcdic_text(raw[offset : offset + 2]))
267
+ offset += 2
268
+ credit_limit_cents = parse_packed_decimal(raw[offset : offset + 6])
269
+ offset += 6
270
+ cash_limit_cents = parse_packed_decimal(raw[offset : offset + 6])
271
+ offset += 6
272
+ credit_balance_cents = parse_packed_decimal(raw[offset : offset + 6])
273
+ offset += 6
274
+ cash_balance_cents = parse_packed_decimal(raw[offset : offset + 6])
275
+ offset += 6
276
+ approved_auth_count = parse_comp(raw[offset : offset + 2])
277
+ offset += 2
278
+ declined_auth_count = parse_comp(raw[offset : offset + 2])
279
+ offset += 2
280
+ approved_auth_amount_cents = parse_packed_decimal(raw[offset : offset + 6])
281
+ offset += 6
282
+ declined_auth_amount_cents = parse_packed_decimal(raw[offset : offset + 6])
283
+ offset += 6
284
+ return {
285
+ "account_id": account_id,
286
+ "customer_id": customer_id,
287
+ "sequence_no": sequence_no,
288
+ "auth_status": auth_status,
289
+ "account_status_1": account_statuses[0],
290
+ "account_status_2": account_statuses[1],
291
+ "account_status_3": account_statuses[2],
292
+ "account_status_4": account_statuses[3],
293
+ "account_status_5": account_statuses[4],
294
+ "credit_limit_cents": credit_limit_cents,
295
+ "cash_limit_cents": cash_limit_cents,
296
+ "credit_balance_cents": credit_balance_cents,
297
+ "cash_balance_cents": cash_balance_cents,
298
+ "approved_auth_count": approved_auth_count,
299
+ "declined_auth_count": declined_auth_count,
300
+ "approved_auth_amount_cents": approved_auth_amount_cents,
301
+ "declined_auth_amount_cents": declined_auth_amount_cents,
302
+ }
303
+
304
+
305
+ def _parse_pending_authorization_detail(raw: bytes, account_id: int, sequence_no: int) -> dict[str, object]:
306
+ offset = 0
307
+ authorization_key = raw[offset : offset + 8]
308
+ auth_date_key = parse_packed_decimal(raw[offset : offset + 3])
309
+ offset += 3
310
+ auth_time_key = parse_packed_decimal(raw[offset : offset + 5])
311
+ offset += 5
312
+
313
+ def text_field(length: int) -> str:
314
+ nonlocal offset
315
+ value = _ebcdic_text(raw[offset : offset + length])
316
+ offset += length
317
+ return value
318
+
319
+ detail: dict[str, object] = {
320
+ "account_id": account_id,
321
+ "sequence_no": sequence_no,
322
+ "authorization_key": authorization_key.hex(),
323
+ "auth_date_key": auth_date_key,
324
+ "auth_time_key": auth_time_key,
325
+ "auth_yyddd": 99999 - auth_date_key,
326
+ "auth_orig_date": text_field(6),
327
+ "auth_orig_time": text_field(6),
328
+ "card_number": text_field(16),
329
+ "auth_type": text_field(4),
330
+ "card_expiry_date": text_field(4),
331
+ "message_type": text_field(6),
332
+ "message_source": text_field(6),
333
+ "auth_id_code": text_field(6),
334
+ "auth_resp_code": text_field(2),
335
+ "auth_resp_reason": text_field(4),
336
+ "processing_code": text_field(6),
337
+ }
338
+ detail["transaction_amount_cents"] = parse_packed_decimal(raw[offset : offset + 7])
339
+ offset += 7
340
+ detail["approved_amount_cents"] = parse_packed_decimal(raw[offset : offset + 7])
341
+ offset += 7
342
+ detail.update(
343
+ {
344
+ "merchant_category_code": text_field(4),
345
+ "acqr_country_code": text_field(3),
346
+ "pos_entry_mode": text_field(2),
347
+ "merchant_id": text_field(15),
348
+ "merchant_name": text_field(22),
349
+ "merchant_city": text_field(13),
350
+ "merchant_state": text_field(2),
351
+ "merchant_zip": text_field(9),
352
+ "transaction_id": text_field(15),
353
+ "match_status": text_field(1),
354
+ "auth_fraud": text_field(1),
355
+ "fraud_rpt_date": text_field(8),
356
+ }
357
+ )
358
+ return detail
359
+
360
+
361
+ def parse_pending_authorizations(path: Path) -> dict[str, list[dict[str, object]]]:
362
+ raw = path.read_bytes()
363
+ summaries: list[dict[str, object]] = []
364
+ details: list[dict[str, object]] = []
365
+ current_account_id: int | None = None
366
+
367
+ for _, segment_name, segment_data in _iter_ims_unload_segments(raw):
368
+ try:
369
+ if segment_name == "summary":
370
+ summary = _parse_pending_authorization_summary(segment_data, len(summaries) + 1)
371
+ account_id = int(summary["account_id"])
372
+ if account_id <= 0 or account_id > 99_999_999_999 or int(summary["customer_id"]) <= 0:
373
+ continue
374
+ summaries.append(summary)
375
+ current_account_id = account_id
376
+ elif current_account_id is not None:
377
+ detail = _parse_pending_authorization_detail(segment_data, current_account_id, len(details) + 1)
378
+ if not str(detail["card_number"]).isdigit() or not str(detail["auth_orig_date"]).isdigit():
379
+ continue
380
+ details.append(detail)
381
+ except (ValueError, UnicodeDecodeError):
382
+ continue
383
+
384
+ return {"summaries": summaries, "details": details}
modern_code/carddemo/parity.py ADDED
The diff for this file is too large to render. See raw diff
 
modern_code/carddemo/repository.py ADDED
@@ -0,0 +1,346 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import sqlite3
4
+ from pathlib import Path
5
+ from typing import Any
6
+
7
+ from .legacy_parser import (
8
+ ACCOUNT_FIELDS,
9
+ CARD_FIELDS,
10
+ CARD_XREF_FIELDS,
11
+ CUSTOMER_FIELDS,
12
+ DISCLOSURE_GROUP_FIELDS,
13
+ TRANSACTION_CATEGORY_BALANCE_FIELDS,
14
+ TRANSACTION_CATEGORY_FIELDS,
15
+ TRANSACTION_FIELDS,
16
+ TRANSACTION_TYPE_FIELDS,
17
+ parse_ascii_file,
18
+ parse_pending_authorizations,
19
+ parse_user_security,
20
+ )
21
+
22
+
23
+ SCHEMA = """
24
+ PRAGMA foreign_keys = ON;
25
+
26
+ CREATE TABLE IF NOT EXISTS customers (
27
+ customer_id INTEGER PRIMARY KEY,
28
+ first_name TEXT NOT NULL,
29
+ middle_name TEXT NOT NULL,
30
+ last_name TEXT NOT NULL,
31
+ address_line_1 TEXT NOT NULL,
32
+ address_line_2 TEXT NOT NULL,
33
+ address_line_3 TEXT NOT NULL,
34
+ state TEXT NOT NULL,
35
+ country TEXT NOT NULL,
36
+ zip_code TEXT NOT NULL,
37
+ phone_1 TEXT NOT NULL,
38
+ phone_2 TEXT NOT NULL,
39
+ ssn TEXT NOT NULL,
40
+ government_id TEXT NOT NULL,
41
+ date_of_birth TEXT NOT NULL,
42
+ eft_account_id TEXT NOT NULL,
43
+ primary_card_holder TEXT NOT NULL,
44
+ fico_score INTEGER NOT NULL
45
+ );
46
+
47
+ CREATE TABLE IF NOT EXISTS accounts (
48
+ account_id INTEGER PRIMARY KEY,
49
+ active_status TEXT NOT NULL,
50
+ current_balance_cents INTEGER NOT NULL,
51
+ credit_limit_cents INTEGER NOT NULL,
52
+ cash_credit_limit_cents INTEGER NOT NULL,
53
+ open_date TEXT NOT NULL,
54
+ expiration_date TEXT NOT NULL,
55
+ reissue_date TEXT NOT NULL,
56
+ current_cycle_credit_cents INTEGER NOT NULL,
57
+ current_cycle_debit_cents INTEGER NOT NULL,
58
+ zip_code TEXT NOT NULL,
59
+ group_id TEXT NOT NULL
60
+ );
61
+
62
+ CREATE TABLE IF NOT EXISTS cards (
63
+ card_number TEXT PRIMARY KEY,
64
+ account_id INTEGER NOT NULL,
65
+ cvv TEXT NOT NULL,
66
+ embossed_name TEXT NOT NULL,
67
+ expiration_date TEXT NOT NULL,
68
+ active_status TEXT NOT NULL,
69
+ FOREIGN KEY(account_id) REFERENCES accounts(account_id)
70
+ );
71
+
72
+ CREATE TABLE IF NOT EXISTS card_xrefs (
73
+ card_number TEXT PRIMARY KEY,
74
+ customer_id INTEGER NOT NULL,
75
+ account_id INTEGER NOT NULL,
76
+ FOREIGN KEY(customer_id) REFERENCES customers(customer_id),
77
+ FOREIGN KEY(account_id) REFERENCES accounts(account_id)
78
+ );
79
+
80
+ CREATE TABLE IF NOT EXISTS transactions (
81
+ transaction_id TEXT PRIMARY KEY,
82
+ type_code TEXT NOT NULL,
83
+ category_code TEXT NOT NULL,
84
+ source TEXT NOT NULL,
85
+ description TEXT NOT NULL,
86
+ amount_cents INTEGER NOT NULL,
87
+ merchant_id TEXT NOT NULL,
88
+ merchant_name TEXT NOT NULL,
89
+ merchant_city TEXT NOT NULL,
90
+ merchant_zip TEXT NOT NULL,
91
+ card_number TEXT NOT NULL,
92
+ original_timestamp TEXT NOT NULL,
93
+ processed_timestamp TEXT NOT NULL
94
+ );
95
+
96
+ CREATE TABLE IF NOT EXISTS transaction_types (
97
+ type_code TEXT PRIMARY KEY,
98
+ description TEXT NOT NULL
99
+ );
100
+
101
+ CREATE TABLE IF NOT EXISTS transaction_categories (
102
+ type_code TEXT NOT NULL,
103
+ category_code TEXT NOT NULL,
104
+ description TEXT NOT NULL,
105
+ PRIMARY KEY(type_code, category_code)
106
+ );
107
+
108
+ CREATE TABLE IF NOT EXISTS disclosure_groups (
109
+ group_id TEXT NOT NULL,
110
+ type_code TEXT NOT NULL,
111
+ category_code TEXT NOT NULL,
112
+ interest_rate_basis_points INTEGER NOT NULL,
113
+ PRIMARY KEY(group_id, type_code, category_code)
114
+ );
115
+
116
+ CREATE TABLE IF NOT EXISTS transaction_category_balances (
117
+ account_id INTEGER NOT NULL,
118
+ type_code TEXT NOT NULL,
119
+ category_code TEXT NOT NULL,
120
+ balance_cents INTEGER NOT NULL,
121
+ PRIMARY KEY(account_id, type_code, category_code),
122
+ FOREIGN KEY(account_id) REFERENCES accounts(account_id)
123
+ );
124
+
125
+ CREATE TABLE IF NOT EXISTS users (
126
+ user_id TEXT PRIMARY KEY,
127
+ first_name TEXT NOT NULL,
128
+ last_name TEXT NOT NULL,
129
+ password TEXT NOT NULL,
130
+ user_type TEXT NOT NULL
131
+ );
132
+
133
+ CREATE TABLE IF NOT EXISTS pending_authorization_summaries (
134
+ account_id INTEGER PRIMARY KEY,
135
+ customer_id INTEGER NOT NULL,
136
+ sequence_no INTEGER NOT NULL,
137
+ auth_status TEXT NOT NULL,
138
+ account_status_1 TEXT NOT NULL,
139
+ account_status_2 TEXT NOT NULL,
140
+ account_status_3 TEXT NOT NULL,
141
+ account_status_4 TEXT NOT NULL,
142
+ account_status_5 TEXT NOT NULL,
143
+ credit_limit_cents INTEGER NOT NULL,
144
+ cash_limit_cents INTEGER NOT NULL,
145
+ credit_balance_cents INTEGER NOT NULL,
146
+ cash_balance_cents INTEGER NOT NULL,
147
+ approved_auth_count INTEGER NOT NULL,
148
+ declined_auth_count INTEGER NOT NULL,
149
+ approved_auth_amount_cents INTEGER NOT NULL,
150
+ declined_auth_amount_cents INTEGER NOT NULL,
151
+ FOREIGN KEY(account_id) REFERENCES accounts(account_id),
152
+ FOREIGN KEY(customer_id) REFERENCES customers(customer_id)
153
+ );
154
+
155
+ CREATE TABLE IF NOT EXISTS pending_authorization_details (
156
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
157
+ account_id INTEGER NOT NULL,
158
+ sequence_no INTEGER NOT NULL,
159
+ authorization_key TEXT NOT NULL,
160
+ auth_date_key INTEGER NOT NULL,
161
+ auth_time_key INTEGER NOT NULL,
162
+ auth_yyddd INTEGER NOT NULL,
163
+ auth_orig_date TEXT NOT NULL,
164
+ auth_orig_time TEXT NOT NULL,
165
+ card_number TEXT NOT NULL,
166
+ auth_type TEXT NOT NULL,
167
+ card_expiry_date TEXT NOT NULL,
168
+ message_type TEXT NOT NULL,
169
+ message_source TEXT NOT NULL,
170
+ auth_id_code TEXT NOT NULL,
171
+ auth_resp_code TEXT NOT NULL,
172
+ auth_resp_reason TEXT NOT NULL,
173
+ processing_code TEXT NOT NULL,
174
+ transaction_amount_cents INTEGER NOT NULL,
175
+ approved_amount_cents INTEGER NOT NULL,
176
+ merchant_category_code TEXT NOT NULL,
177
+ acqr_country_code TEXT NOT NULL,
178
+ pos_entry_mode TEXT NOT NULL,
179
+ merchant_id TEXT NOT NULL,
180
+ merchant_name TEXT NOT NULL,
181
+ merchant_city TEXT NOT NULL,
182
+ merchant_state TEXT NOT NULL,
183
+ merchant_zip TEXT NOT NULL,
184
+ transaction_id TEXT NOT NULL,
185
+ match_status TEXT NOT NULL,
186
+ auth_fraud TEXT NOT NULL,
187
+ fraud_rpt_date TEXT NOT NULL,
188
+ UNIQUE(account_id, authorization_key),
189
+ FOREIGN KEY(account_id) REFERENCES pending_authorization_summaries(account_id) ON DELETE CASCADE
190
+ );
191
+
192
+ CREATE TABLE IF NOT EXISTS authorization_frauds (
193
+ card_number TEXT NOT NULL,
194
+ auth_timestamp TEXT NOT NULL,
195
+ account_id INTEGER NOT NULL,
196
+ customer_id INTEGER NOT NULL,
197
+ authorization_key TEXT NOT NULL,
198
+ auth_type TEXT NOT NULL,
199
+ card_expiry_date TEXT NOT NULL,
200
+ message_type TEXT NOT NULL,
201
+ message_source TEXT NOT NULL,
202
+ auth_id_code TEXT NOT NULL,
203
+ auth_resp_code TEXT NOT NULL,
204
+ auth_resp_reason TEXT NOT NULL,
205
+ processing_code TEXT NOT NULL,
206
+ transaction_amount_cents INTEGER NOT NULL,
207
+ approved_amount_cents INTEGER NOT NULL,
208
+ merchant_category_code TEXT NOT NULL,
209
+ acqr_country_code TEXT NOT NULL,
210
+ pos_entry_mode TEXT NOT NULL,
211
+ merchant_id TEXT NOT NULL,
212
+ merchant_name TEXT NOT NULL,
213
+ merchant_city TEXT NOT NULL,
214
+ merchant_state TEXT NOT NULL,
215
+ merchant_zip TEXT NOT NULL,
216
+ transaction_id TEXT NOT NULL,
217
+ match_status TEXT NOT NULL,
218
+ auth_fraud TEXT NOT NULL,
219
+ fraud_rpt_date TEXT NOT NULL,
220
+ PRIMARY KEY(card_number, auth_timestamp)
221
+ );
222
+
223
+ CREATE TABLE IF NOT EXISTS modernization_meta (
224
+ key TEXT PRIMARY KEY,
225
+ value TEXT NOT NULL
226
+ );
227
+ """
228
+
229
+
230
+ def connect(db_path: Path) -> sqlite3.Connection:
231
+ conn = sqlite3.connect(str(db_path))
232
+ conn.row_factory = sqlite3.Row
233
+ conn.execute("PRAGMA foreign_keys = ON")
234
+ return conn
235
+
236
+
237
+ def initialize_schema(conn: sqlite3.Connection) -> None:
238
+ conn.executescript(SCHEMA)
239
+ conn.commit()
240
+
241
+
242
+ def reset_database(conn: sqlite3.Connection) -> None:
243
+ initialize_schema(conn)
244
+ for table in (
245
+ "authorization_frauds",
246
+ "pending_authorization_details",
247
+ "pending_authorization_summaries",
248
+ "transactions",
249
+ "transaction_category_balances",
250
+ "card_xrefs",
251
+ "cards",
252
+ "accounts",
253
+ "customers",
254
+ "transaction_categories",
255
+ "transaction_types",
256
+ "disclosure_groups",
257
+ "users",
258
+ "modernization_meta",
259
+ ):
260
+ conn.execute(f"DELETE FROM {table}")
261
+ conn.commit()
262
+
263
+
264
+ def insert_many(conn: sqlite3.Connection, table: str, rows: list[dict[str, Any]]) -> None:
265
+ if not rows:
266
+ return
267
+ columns = list(rows[0].keys())
268
+ placeholders = ", ".join("?" for _ in columns)
269
+ col_sql = ", ".join(columns)
270
+ values = [[row[column] for column in columns] for row in rows]
271
+ conn.executemany(f"INSERT OR REPLACE INTO {table} ({col_sql}) VALUES ({placeholders})", values)
272
+
273
+
274
+ def seed_from_legacy(source_root: Path, db_path: Path, *, reset: bool = True) -> dict[str, int]:
275
+ data = source_root / "app" / "data"
276
+ conn = connect(db_path)
277
+ try:
278
+ if reset:
279
+ reset_database(conn)
280
+ else:
281
+ initialize_schema(conn)
282
+
283
+ customers = parse_ascii_file(data / "ASCII" / "custdata.txt", CUSTOMER_FIELDS, 500)
284
+ accounts = parse_ascii_file(data / "ASCII" / "acctdata.txt", ACCOUNT_FIELDS, 300)
285
+ cards = parse_ascii_file(data / "ASCII" / "carddata.txt", CARD_FIELDS, 150)
286
+ xrefs = parse_ascii_file(data / "ASCII" / "cardxref.txt", CARD_XREF_FIELDS, 50)
287
+ transactions = parse_ascii_file(data / "ASCII" / "dailytran.txt", TRANSACTION_FIELDS, 350)
288
+ transaction_types = parse_ascii_file(data / "ASCII" / "trantype.txt", TRANSACTION_TYPE_FIELDS, 60)
289
+ transaction_categories = parse_ascii_file(
290
+ data / "ASCII" / "trancatg.txt", TRANSACTION_CATEGORY_FIELDS, 60
291
+ )
292
+ disclosure_groups = parse_ascii_file(data / "ASCII" / "discgrp.txt", DISCLOSURE_GROUP_FIELDS, 50)
293
+ transaction_category_balances = parse_ascii_file(
294
+ data / "ASCII" / "tcatbal.txt", TRANSACTION_CATEGORY_BALANCE_FIELDS, 50
295
+ )
296
+ users = parse_user_security(data / "EBCDIC" / "AWS.M2.CARDDEMO.USRSEC.PS")
297
+ pending_authorizations = parse_pending_authorizations(
298
+ source_root
299
+ / "app"
300
+ / "app-authorization-ims-db2-mq"
301
+ / "data"
302
+ / "EBCDIC"
303
+ / "AWS.M2.CARDDEMO.IMSDATA.DBPAUTP0.dat"
304
+ )
305
+
306
+ insert_many(conn, "customers", customers)
307
+ insert_many(conn, "accounts", accounts)
308
+ insert_many(conn, "cards", cards)
309
+ insert_many(conn, "card_xrefs", xrefs)
310
+ insert_many(conn, "transactions", transactions)
311
+ insert_many(conn, "transaction_types", transaction_types)
312
+ insert_many(conn, "transaction_categories", transaction_categories)
313
+ insert_many(conn, "disclosure_groups", disclosure_groups)
314
+ insert_many(conn, "transaction_category_balances", transaction_category_balances)
315
+ insert_many(conn, "users", users)
316
+ insert_many(conn, "pending_authorization_summaries", pending_authorizations["summaries"])
317
+ insert_many(conn, "pending_authorization_details", pending_authorizations["details"])
318
+ conn.execute(
319
+ "INSERT OR REPLACE INTO modernization_meta(key, value) VALUES (?, ?)",
320
+ ("source_root", str(source_root.resolve())),
321
+ )
322
+ conn.commit()
323
+ return {
324
+ "customers": len(customers),
325
+ "accounts": len(accounts),
326
+ "cards": len(cards),
327
+ "card_xrefs": len(xrefs),
328
+ "transactions": len(transactions),
329
+ "transaction_types": len(transaction_types),
330
+ "transaction_categories": len(transaction_categories),
331
+ "disclosure_groups": len(disclosure_groups),
332
+ "transaction_category_balances": len(transaction_category_balances),
333
+ "users": len(users),
334
+ "pending_authorization_summaries": len(pending_authorizations["summaries"]),
335
+ "pending_authorization_details": len(pending_authorizations["details"]),
336
+ }
337
+ finally:
338
+ conn.close()
339
+
340
+
341
+ def row_to_dict(row: sqlite3.Row | None) -> dict[str, Any] | None:
342
+ return dict(row) if row is not None else None
343
+
344
+
345
+ def rows_to_dicts(rows: list[sqlite3.Row]) -> list[dict[str, Any]]:
346
+ return [dict(row) for row in rows]
modern_code/carddemo/service.py ADDED
The diff for this file is too large to render. See raw diff
 
modern_code/static/app.js ADDED
@@ -0,0 +1,526 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const $ = (id) => document.getElementById(id);
2
+
3
+ async function api(path, options = {}) {
4
+ const response = await fetch(path, {
5
+ headers: { "Content-Type": "application/json" },
6
+ ...options,
7
+ });
8
+ const payload = await response.json();
9
+ if (!response.ok) {
10
+ throw new Error(payload.error || response.statusText);
11
+ }
12
+ return payload;
13
+ }
14
+
15
+ function moneyCell(value) {
16
+ return `<span class="money">${value}</span>`;
17
+ }
18
+
19
+ function escapeHtml(value) {
20
+ return String(value ?? "")
21
+ .replaceAll("&", "&amp;")
22
+ .replaceAll("<", "&lt;")
23
+ .replaceAll(">", "&gt;")
24
+ .replaceAll('"', "&quot;")
25
+ .replaceAll("'", "&#039;");
26
+ }
27
+
28
+ function cardEditor(card, accountId) {
29
+ const [year, month] = String(card.expiration_date || "").split("-");
30
+ const suffix = String(card.card_number);
31
+ return `
32
+ <div class="account-update-editor">
33
+ <input id="cardName${suffix}" value="${escapeHtml(card.embossed_name)}" maxlength="50">
34
+ <select id="cardStatus${suffix}">
35
+ <option value="Y" ${card.active_status === "Y" ? "selected" : ""}>Active</option>
36
+ <option value="N" ${card.active_status === "N" ? "selected" : ""}>Inactive</option>
37
+ </select>
38
+ <input id="cardMonth${suffix}" value="${escapeHtml(month || "")}" maxlength="2">
39
+ <input id="cardYear${suffix}" value="${escapeHtml(year || "")}" maxlength="4">
40
+ <button onclick="updateCardDetails('${suffix}', ${accountId})">Update</button>
41
+ </div>
42
+ <div id="cardStatusMsg${suffix}"></div>
43
+ `;
44
+ }
45
+
46
+ let activeAccountId = null;
47
+
48
+ async function loadSummary() {
49
+ const summary = await api("/api/summary");
50
+ $("claimLimit").textContent = summary.claim_limit;
51
+ $("summary").innerHTML = Object.entries(summary.counts)
52
+ .map(([key, value]) => `<div class="metric"><strong>${value}</strong>${key.replaceAll("_", " ")}</div>`)
53
+ .join("");
54
+ }
55
+
56
+ async function searchCustomers() {
57
+ const query = encodeURIComponent($("customerQuery").value);
58
+ const customers = await api(`/api/customers?query=${query}&limit=25`);
59
+ $("customers").innerHTML = customers
60
+ .map((customer) => `
61
+ <div class="row">
62
+ <h3>${customer.first_name} ${customer.last_name}</h3>
63
+ <div class="meta">Customer ${customer.customer_id} · ${customer.city || customer.address_line_3}, ${customer.state} ${customer.zip_code}</div>
64
+ <div class="actions">
65
+ <button class="secondary" onclick="loadCustomerAccounts(${customer.customer_id})">Accounts</button>
66
+ </div>
67
+ </div>
68
+ `)
69
+ .join("") || `<div class="empty">No matches.</div>`;
70
+ }
71
+
72
+ async function loadCustomerAccounts(customerId) {
73
+ const accounts = await api(`/api/accounts?customer_id=${customerId}`);
74
+ $("accountDetail").innerHTML = `
75
+ <div class="notice">Customer ${customerId} account results are sourced from the original CardDemo fixed-width seed files.</div>
76
+ <div class="list">
77
+ ${accounts.map((account) => `
78
+ <div class="row">
79
+ <h3>Account ${account.account_id}</h3>
80
+ <div class="meta">Status ${account.active_status} · balance ${account.current_balance} · limit ${account.credit_limit}</div>
81
+ <div class="actions"><button onclick="loadAccount(${account.account_id})">Open Workspace</button></div>
82
+ </div>
83
+ `).join("")}
84
+ </div>
85
+ `;
86
+ }
87
+
88
+ async function loadAccount(accountId) {
89
+ activeAccountId = accountId;
90
+ const bundle = await api(`/api/accounts/${accountId}`);
91
+ const account = bundle.account;
92
+ const today = new Date().toISOString().slice(0, 10);
93
+ $("accountDetail").innerHTML = `
94
+ <div class="detail-grid">
95
+ <div class="metric"><strong>${account.current_balance}</strong>Current balance</div>
96
+ <div class="metric"><strong>${account.credit_limit}</strong>Credit limit</div>
97
+ <div class="metric"><strong>${account.cash_credit_limit}</strong>Cash limit</div>
98
+ </div>
99
+ <div class="row">
100
+ <h3>Account ${account.account_id}</h3>
101
+ <div class="meta">Status ${account.active_status} · Open ${account.open_date} · Expires ${account.expiration_date}</div>
102
+ <div class="actions">
103
+ <input id="payAmount" placeholder="Payment dollars" value="${account.current_balance}">
104
+ <button onclick="makePayment(${account.account_id})">Pay Balance</button>
105
+ </div>
106
+ </div>
107
+ <h2>Update Account</h2>
108
+ <div class="account-update-editor">
109
+ <select id="accountStatus">
110
+ <option value="Y" ${account.active_status === "Y" ? "selected" : ""}>Active</option>
111
+ <option value="N" ${account.active_status === "N" ? "selected" : ""}>Inactive</option>
112
+ </select>
113
+ <input id="accountCreditLimit" placeholder="Credit limit" value="${account.credit_limit}">
114
+ <input id="accountCashLimit" placeholder="Cash limit" value="${account.cash_credit_limit}">
115
+ <input id="accountGroup" placeholder="Group" value="${account.group_id}" maxlength="10">
116
+ <button onclick="updateAccountDetails(${account.account_id})">Update</button>
117
+ </div>
118
+ <div id="accountUpdateStatus"></div>
119
+ <h2>Cards</h2>
120
+ <div class="list">
121
+ ${bundle.cards.map((card) => `
122
+ <div class="row">
123
+ <h3>${card.card_number}</h3>
124
+ ${cardEditor(card, account.account_id)}
125
+ <div class="meta">${card.embossed_name} · status ${card.active_status} · exp ${card.expiration_date}</div>
126
+ </div>
127
+ `).join("")}
128
+ </div>
129
+ <h2>Add Transaction</h2>
130
+ <div class="transaction-editor">
131
+ <input id="ct02Type" placeholder="Type" value="01" maxlength="2">
132
+ <input id="ct02Category" placeholder="Category" value="0001" maxlength="4">
133
+ <input id="ct02Source" placeholder="Source" value="POS TERM" maxlength="10">
134
+ <input id="ct02Amount" placeholder="Amount" value="+00000012.34" maxlength="12">
135
+ <input id="ct02OrigDate" type="date" value="${today}">
136
+ <input id="ct02ProcDate" type="date" value="${today}">
137
+ <input id="ct02MerchantId" placeholder="Merchant ID" value="123456789" maxlength="9">
138
+ <input id="ct02MerchantName" placeholder="Merchant" value="MODERN CARDDEMO" maxlength="30">
139
+ <input id="ct02MerchantCity" placeholder="City" value="SEATTLE" maxlength="25">
140
+ <input id="ct02MerchantZip" placeholder="ZIP" value="98101" maxlength="10">
141
+ <input id="ct02Description" placeholder="Description" value="Modern CT02 transaction" maxlength="60">
142
+ <button onclick="addCt02Transaction(${account.account_id})">Add</button>
143
+ </div>
144
+ <div id="ct02Status"></div>
145
+ <h2>Recent Transactions</h2>
146
+ <table class="table">
147
+ <thead><tr><th>ID</th><th>Type</th><th>Description</th><th>Merchant</th><th>Amount</th></tr></thead>
148
+ <tbody>
149
+ ${bundle.transactions.map((tran) => `
150
+ <tr>
151
+ <td>${tran.transaction_id}</td>
152
+ <td>${tran.type_code}/${tran.category_code}</td>
153
+ <td>${tran.description}</td>
154
+ <td>${tran.merchant_name}</td>
155
+ <td class="money">${tran.amount}</td>
156
+ </tr>
157
+ `).join("")}
158
+ </tbody>
159
+ </table>
160
+ `;
161
+ $("batchReports").innerHTML = `<div class="notice">Account ${accountId} selected for statement, transaction report, interest projection, and combined batch preview.</div>`;
162
+ }
163
+
164
+ async function updateAccountDetails(accountId) {
165
+ try {
166
+ const updated = await api(`/api/accounts/${accountId}`, {
167
+ method: "PATCH",
168
+ body: JSON.stringify({
169
+ active_status: $("accountStatus").value,
170
+ credit_limit_cents: Math.round(Number($("accountCreditLimit").value) * 100),
171
+ cash_credit_limit_cents: Math.round(Number($("accountCashLimit").value) * 100),
172
+ group_id: $("accountGroup").value,
173
+ }),
174
+ });
175
+ await loadAccount(accountId);
176
+ $("accountUpdateStatus").innerHTML = `<div class="notice">${escapeHtml(updated.message)}</div>`;
177
+ await loadSummary();
178
+ } catch (error) {
179
+ $("accountUpdateStatus").innerHTML = `<div class="notice">${escapeHtml(error.message)}</div>`;
180
+ }
181
+ }
182
+
183
+ async function updateCardDetails(cardNumber, accountId) {
184
+ const suffix = String(cardNumber);
185
+ try {
186
+ const updated = await api(`/api/cards/${encodeURIComponent(cardNumber)}`, {
187
+ method: "PATCH",
188
+ body: JSON.stringify({
189
+ account_id: accountId,
190
+ embossed_name: $(`cardName${suffix}`).value,
191
+ active_status: $(`cardStatus${suffix}`).value,
192
+ expiration_month: $(`cardMonth${suffix}`).value,
193
+ expiration_year: $(`cardYear${suffix}`).value,
194
+ }),
195
+ });
196
+ await loadAccount(accountId);
197
+ $(`cardStatusMsg${suffix}`).innerHTML = `<div class="notice">${escapeHtml(updated.message)}</div>`;
198
+ await loadSummary();
199
+ } catch (error) {
200
+ $(`cardStatusMsg${suffix}`).innerHTML = `<div class="notice">${escapeHtml(error.message)}</div>`;
201
+ }
202
+ }
203
+
204
+ async function addCt02Transaction(accountId) {
205
+ try {
206
+ const transaction = await api("/api/transactions", {
207
+ method: "POST",
208
+ body: JSON.stringify({
209
+ account_id: accountId,
210
+ type_code: $("ct02Type").value,
211
+ category_code: $("ct02Category").value,
212
+ source: $("ct02Source").value,
213
+ description: $("ct02Description").value,
214
+ amount: $("ct02Amount").value,
215
+ original_timestamp: $("ct02OrigDate").value,
216
+ processed_timestamp: $("ct02ProcDate").value,
217
+ merchant_id: $("ct02MerchantId").value,
218
+ merchant_name: $("ct02MerchantName").value,
219
+ merchant_city: $("ct02MerchantCity").value,
220
+ merchant_zip: $("ct02MerchantZip").value,
221
+ confirm: "Y",
222
+ }),
223
+ });
224
+ await loadAccount(accountId);
225
+ $("ct02Status").innerHTML = `<div class="notice">${escapeHtml(transaction.message)}</div>`;
226
+ } catch (error) {
227
+ $("ct02Status").innerHTML = `<div class="notice">${escapeHtml(error.message)}</div>`;
228
+ }
229
+ }
230
+
231
+ async function makePayment(accountId) {
232
+ const raw = $("payAmount").value.trim();
233
+ const cents = Math.round(Number(raw) * 100);
234
+ await api("/api/bill-payments", {
235
+ method: "POST",
236
+ body: JSON.stringify({ account_id: accountId, amount_cents: cents }),
237
+ });
238
+ await loadAccount(accountId);
239
+ await loadSummary();
240
+ }
241
+
242
+ function needAccount() {
243
+ if (!activeAccountId) {
244
+ $("batchReports").innerHTML = `<div class="empty">Select an account first.</div>`;
245
+ return false;
246
+ }
247
+ return true;
248
+ }
249
+
250
+ async function loadStatement() {
251
+ if (!needAccount()) return;
252
+ const statement = await api(`/api/statements/${activeAccountId}`);
253
+ $("batchReports").innerHTML = `
254
+ <div class="detail-grid">
255
+ <div class="metric"><strong>${statement.transaction_count}</strong>Transactions</div>
256
+ <div class="metric"><strong>${statement.total_expense}</strong>Total EXP</div>
257
+ <div class="metric"><strong>${statement.legacy_job}</strong>Legacy job</div>
258
+ </div>
259
+ <div class="statement-lines">${statement.plain_text_lines.join("\n")}</div>
260
+ `;
261
+ }
262
+
263
+ async function loadTransactionReport() {
264
+ if (!needAccount()) return;
265
+ const report = await api(`/api/reports/transactions?account_id=${activeAccountId}&limit=1000`);
266
+ $("batchReports").innerHTML = `
267
+ <div class="detail-grid">
268
+ <div class="metric"><strong>${report.totals.transaction_count}</strong>Rows</div>
269
+ <div class="metric"><strong>${report.totals.total_amount}</strong>Total</div>
270
+ <div class="metric"><strong>${report.legacy_job}</strong>Legacy job</div>
271
+ </div>
272
+ <table class="table">
273
+ <thead><tr><th>ID</th><th>Date</th><th>Type</th><th>Description</th><th>Amount</th></tr></thead>
274
+ <tbody>
275
+ ${report.rows.slice(0, 25).map((tran) => `
276
+ <tr>
277
+ <td>${tran.transaction_id}</td>
278
+ <td>${tran.processed_timestamp.slice(0, 10)}</td>
279
+ <td>${tran.type_code}/${tran.category_code}</td>
280
+ <td>${tran.description}</td>
281
+ <td class="money">${tran.amount}</td>
282
+ </tr>
283
+ `).join("")}
284
+ </tbody>
285
+ </table>
286
+ `;
287
+ }
288
+
289
+ async function loadInterest() {
290
+ const projection = await api("/api/interest-projection?limit=1000");
291
+ $("batchReports").innerHTML = `
292
+ <div class="detail-grid">
293
+ <div class="metric"><strong>${projection.totals.account_count}</strong>Accounts</div>
294
+ <div class="metric"><strong>${projection.totals.total_interest}</strong>Total Interest</div>
295
+ <div class="metric"><strong>${projection.legacy_job}</strong>Legacy job</div>
296
+ </div>
297
+ <table class="table">
298
+ <thead><tr><th>Account</th><th>Categories</th><th>Generated Amount</th></tr></thead>
299
+ <tbody>
300
+ ${projection.account_totals.slice(0, 25).map((row) => `
301
+ <tr>
302
+ <td>${row.account_id}</td>
303
+ <td>${row.category_count}</td>
304
+ <td class="money">${row.total_interest}</td>
305
+ </tr>
306
+ `).join("")}
307
+ </tbody>
308
+ </table>
309
+ `;
310
+ }
311
+
312
+ async function loadCombined() {
313
+ const combined = await api("/api/batch/combined-transactions?limit=40");
314
+ $("batchReports").innerHTML = `
315
+ <div class="detail-grid">
316
+ <div class="metric"><strong>${combined.source_counts.transaction_master}</strong>Seed tx</div>
317
+ <div class="metric"><strong>${combined.source_counts.interest_projection}</strong>Interest tx</div>
318
+ <div class="metric"><strong>${combined.legacy_job}</strong>Legacy job</div>
319
+ </div>
320
+ <table class="table">
321
+ <thead><tr><th>ID</th><th>Source</th><th>Card</th><th>Date</th><th>Amount</th></tr></thead>
322
+ <tbody>
323
+ ${combined.rows.map((row) => `
324
+ <tr>
325
+ <td>${row.transaction_id}</td>
326
+ <td>${row.combine_source}</td>
327
+ <td>${row.card_number}</td>
328
+ <td>${row.processed_timestamp.slice(0, 10)}</td>
329
+ <td class="money">${row.amount}</td>
330
+ </tr>
331
+ `).join("")}
332
+ </tbody>
333
+ </table>
334
+ `;
335
+ }
336
+
337
+ function renderMenu(menu) {
338
+ return `
339
+ <div class="detail-grid">
340
+ <div class="metric"><strong>${escapeHtml(menu.legacy_transaction)}</strong>Transaction</div>
341
+ <div class="metric"><strong>${escapeHtml(menu.legacy_program)}</strong>Program</div>
342
+ <div class="metric"><strong>${menu.option_count}</strong>Options</div>
343
+ </div>
344
+ <table class="table">
345
+ <thead><tr><th>#</th><th>Option</th><th>Program</th><th>Tx</th></tr></thead>
346
+ <tbody>
347
+ ${menu.options.map((row) => `
348
+ <tr>
349
+ <td>${row.option}</td>
350
+ <td>${escapeHtml(row.name)}</td>
351
+ <td>${escapeHtml(row.program)}</td>
352
+ <td>${escapeHtml(row.transaction)}</td>
353
+ </tr>
354
+ `).join("")}
355
+ </tbody>
356
+ </table>
357
+ `;
358
+ }
359
+
360
+ async function signOn() {
361
+ const result = await api("/api/signon", {
362
+ method: "POST",
363
+ body: JSON.stringify({
364
+ user_id: $("signonUser").value,
365
+ password: $("signonPassword").value,
366
+ }),
367
+ });
368
+ if (!result.authenticated) {
369
+ $("securityDetail").innerHTML = `<div class="notice">${escapeHtml(result.message)}</div>`;
370
+ return;
371
+ }
372
+ $("securityDetail").innerHTML = `
373
+ <div class="notice">${escapeHtml(result.user.user_id)} routed to ${escapeHtml(result.route_transaction)} / ${escapeHtml(result.route_program)}</div>
374
+ ${renderMenu(result.menu)}
375
+ `;
376
+ }
377
+
378
+ function userPayload() {
379
+ return {
380
+ user_id: $("userId").value,
381
+ first_name: $("userFirstName").value,
382
+ last_name: $("userLastName").value,
383
+ password: $("userPassword").value,
384
+ user_type: $("userType").value,
385
+ };
386
+ }
387
+
388
+ function fillUser(user) {
389
+ $("userId").value = user.user_id;
390
+ $("userFirstName").value = user.first_name;
391
+ $("userLastName").value = user.last_name;
392
+ $("userPassword").value = user.password;
393
+ $("userType").value = user.user_type;
394
+ }
395
+
396
+ async function loadUser(userId) {
397
+ const user = await api(`/api/users/${encodeURIComponent(userId)}`);
398
+ fillUser(user);
399
+ }
400
+
401
+ async function loadUsers() {
402
+ const users = await api("/api/users");
403
+ $("securityDetail").innerHTML = `
404
+ <table class="table">
405
+ <thead><tr><th>User</th><th>Name</th><th>Type</th><th></th></tr></thead>
406
+ <tbody>
407
+ ${users.map((user) => `
408
+ <tr>
409
+ <td>${escapeHtml(user.user_id)}</td>
410
+ <td>${escapeHtml(user.first_name)} ${escapeHtml(user.last_name)}</td>
411
+ <td>${escapeHtml(user.user_type)}</td>
412
+ <td><button class="secondary" onclick="loadUser('${escapeHtml(user.user_id)}')">Edit</button></td>
413
+ </tr>
414
+ `).join("")}
415
+ </tbody>
416
+ </table>
417
+ `;
418
+ }
419
+
420
+ async function addUser() {
421
+ const result = await api("/api/users", {
422
+ method: "POST",
423
+ body: JSON.stringify(userPayload()),
424
+ });
425
+ $("securityDetail").innerHTML = `<div class="notice">${escapeHtml(result.message)}</div>`;
426
+ await loadUsers();
427
+ await loadSummary();
428
+ }
429
+
430
+ async function updateUser() {
431
+ const payload = userPayload();
432
+ const result = await api(`/api/users/${encodeURIComponent(payload.user_id)}`, {
433
+ method: "PATCH",
434
+ body: JSON.stringify(payload),
435
+ });
436
+ $("securityDetail").innerHTML = `<div class="notice">${escapeHtml(result.message)}</div>`;
437
+ await loadUsers();
438
+ }
439
+
440
+ async function deleteUser() {
441
+ const userId = $("userId").value.trim();
442
+ const result = await api(`/api/users/${encodeURIComponent(userId)}`, { method: "DELETE" });
443
+ $("securityDetail").innerHTML = `<div class="notice">${escapeHtml(result.message)}</div>`;
444
+ await loadUsers();
445
+ await loadSummary();
446
+ }
447
+
448
+ function transactionTypePayload() {
449
+ return {
450
+ type_code: $("typeCode").value,
451
+ description: $("typeDescription").value,
452
+ };
453
+ }
454
+
455
+ function fillTransactionType(type) {
456
+ $("typeCode").value = type.type_code;
457
+ $("typeDescription").value = type.description;
458
+ }
459
+
460
+ function renderTransactionTypes(catalog, status = "") {
461
+ $("transactionTypeDetail").innerHTML = `
462
+ ${status ? `<div class="notice">${escapeHtml(status)}</div>` : ""}
463
+ <table class="table">
464
+ <thead><tr><th>Type</th><th>Description</th><th></th></tr></thead>
465
+ <tbody>
466
+ ${catalog.types.map((type) => `
467
+ <tr>
468
+ <td>${escapeHtml(type.type_code)}</td>
469
+ <td>${escapeHtml(type.description)}</td>
470
+ <td><button class="secondary" onclick="fillTransactionType({ type_code: '${escapeHtml(type.type_code)}', description: '${escapeHtml(type.description)}' })">Edit</button></td>
471
+ </tr>
472
+ `).join("")}
473
+ </tbody>
474
+ </table>
475
+ `;
476
+ }
477
+
478
+ async function loadTransactionTypes(status = "") {
479
+ const catalog = await api("/api/transaction-types");
480
+ renderTransactionTypes(catalog, status);
481
+ }
482
+
483
+ async function saveTransactionType() {
484
+ const result = await api("/api/transaction-types", {
485
+ method: "POST",
486
+ body: JSON.stringify(transactionTypePayload()),
487
+ });
488
+ await loadTransactionTypes(`${result.message} (${result.action} ${result.type_code})`);
489
+ await loadSummary();
490
+ }
491
+
492
+ async function deleteTransactionType() {
493
+ const typeCode = $("typeCode").value.trim();
494
+ const result = await api(`/api/transaction-types/${encodeURIComponent(typeCode)}`, { method: "DELETE" });
495
+ await loadTransactionTypes(result.message);
496
+ await loadSummary();
497
+ }
498
+
499
+ function showSecurityError(error) {
500
+ $("securityDetail").innerHTML = `<div class="notice">${escapeHtml(error.message)}</div>`;
501
+ }
502
+
503
+ function showTransactionTypeError(error) {
504
+ $("transactionTypeDetail").innerHTML = `<div class="notice">${escapeHtml(error.message)}</div>`;
505
+ }
506
+
507
+ $("refreshBtn").addEventListener("click", () => {
508
+ loadSummary();
509
+ searchCustomers();
510
+ });
511
+ $("searchBtn").addEventListener("click", searchCustomers);
512
+ $("statementBtn").addEventListener("click", loadStatement);
513
+ $("transactionReportBtn").addEventListener("click", loadTransactionReport);
514
+ $("interestBtn").addEventListener("click", loadInterest);
515
+ $("combinedBtn").addEventListener("click", loadCombined);
516
+ $("signonBtn").addEventListener("click", () => signOn().catch(showSecurityError));
517
+ $("usersBtn").addEventListener("click", () => loadUsers().catch(showSecurityError));
518
+ $("addUserBtn").addEventListener("click", () => addUser().catch(showSecurityError));
519
+ $("updateUserBtn").addEventListener("click", () => updateUser().catch(showSecurityError));
520
+ $("deleteUserBtn").addEventListener("click", () => deleteUser().catch(showSecurityError));
521
+ $("typesBtn").addEventListener("click", () => loadTransactionTypes().catch(showTransactionTypeError));
522
+ $("saveTypeBtn").addEventListener("click", () => saveTransactionType().catch(showTransactionTypeError));
523
+ $("deleteTypeBtn").addEventListener("click", () => deleteTransactionType().catch(showTransactionTypeError));
524
+
525
+ loadSummary();
526
+ searchCustomers();
modern_code/static/index.html ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Modern CardDemo</title>
7
+ <link rel="stylesheet" href="/static/styles.css">
8
+ </head>
9
+ <body>
10
+ <header class="topbar">
11
+ <div>
12
+ <h1>Modern CardDemo</h1>
13
+ <p id="claimLimit">Loading modernization claim limits...</p>
14
+ </div>
15
+ <button id="refreshBtn">Refresh</button>
16
+ </header>
17
+
18
+ <main class="layout">
19
+ <section class="panel">
20
+ <h2>Portfolio</h2>
21
+ <div id="summary" class="metrics"></div>
22
+ </section>
23
+
24
+ <section class="panel">
25
+ <h2>Customer Search</h2>
26
+ <div class="searchbar">
27
+ <input id="customerQuery" placeholder="Name, customer id, or ZIP" value="Kessler">
28
+ <button id="searchBtn">Search</button>
29
+ </div>
30
+ <div id="customers" class="list"></div>
31
+ </section>
32
+
33
+ <section class="panel wide">
34
+ <h2>Account Workspace</h2>
35
+ <div id="accountDetail" class="detail empty">Select a customer/account.</div>
36
+ </section>
37
+
38
+ <section class="panel wide">
39
+ <h2>Batch Reports</h2>
40
+ <div class="actions report-actions">
41
+ <button id="statementBtn">Statement</button>
42
+ <button id="transactionReportBtn" class="secondary">Transactions</button>
43
+ <button id="interestBtn" class="secondary">Interest</button>
44
+ <button id="combinedBtn" class="secondary">Combined</button>
45
+ </div>
46
+ <div id="batchReports" class="detail empty">Open an account, then choose a report.</div>
47
+ </section>
48
+
49
+ <section class="panel wide">
50
+ <h2>Security</h2>
51
+ <div class="security-grid">
52
+ <input id="signonUser" placeholder="User ID" value="ADMIN001">
53
+ <input id="signonPassword" placeholder="Password" value="PASSWORD" type="password">
54
+ <button id="signonBtn">Sign On</button>
55
+ </div>
56
+ <div class="user-editor">
57
+ <input id="userId" placeholder="User ID" maxlength="8">
58
+ <input id="userFirstName" placeholder="First name" maxlength="20">
59
+ <input id="userLastName" placeholder="Last name" maxlength="20">
60
+ <input id="userPassword" placeholder="Password" maxlength="8" type="password">
61
+ <select id="userType">
62
+ <option value="U">User</option>
63
+ <option value="A">Admin</option>
64
+ </select>
65
+ <button id="addUserBtn">Add</button>
66
+ <button id="updateUserBtn" class="secondary">Update</button>
67
+ <button id="deleteUserBtn" class="secondary">Delete</button>
68
+ <button id="usersBtn" class="secondary">Users</button>
69
+ </div>
70
+ <div class="type-editor">
71
+ <input id="typeCode" placeholder="Type code" maxlength="2">
72
+ <input id="typeDescription" placeholder="Description" maxlength="50">
73
+ <button id="saveTypeBtn">Save Type</button>
74
+ <button id="deleteTypeBtn" class="secondary">Delete Type</button>
75
+ <button id="typesBtn" class="secondary">Types</button>
76
+ </div>
77
+ <div id="securityDetail" class="detail empty">Sign on or load users.</div>
78
+ <div id="transactionTypeDetail" class="detail empty">Load transaction types or save a type.</div>
79
+ </section>
80
+ </main>
81
+
82
+ <script src="/static/app.js"></script>
83
+ </body>
84
+ </html>
modern_code/static/styles.css ADDED
@@ -0,0 +1,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ :root {
2
+ color-scheme: light;
3
+ --ink: #20242c;
4
+ --muted: #637083;
5
+ --line: #d7dce3;
6
+ --panel: #ffffff;
7
+ --page: #f5f7f8;
8
+ --accent: #146b5f;
9
+ --accent-2: #405c9a;
10
+ --warn: #8b5a00;
11
+ }
12
+
13
+ * {
14
+ box-sizing: border-box;
15
+ }
16
+
17
+ body {
18
+ margin: 0;
19
+ font-family: Arial, Helvetica, sans-serif;
20
+ color: var(--ink);
21
+ background: var(--page);
22
+ }
23
+
24
+ .topbar {
25
+ display: flex;
26
+ align-items: center;
27
+ justify-content: space-between;
28
+ gap: 24px;
29
+ padding: 18px 24px;
30
+ background: #ffffff;
31
+ border-bottom: 1px solid var(--line);
32
+ }
33
+
34
+ h1,
35
+ h2,
36
+ h3 {
37
+ margin: 0;
38
+ font-weight: 700;
39
+ }
40
+
41
+ h1 {
42
+ font-size: 24px;
43
+ }
44
+
45
+ h2 {
46
+ font-size: 16px;
47
+ margin-bottom: 12px;
48
+ }
49
+
50
+ p {
51
+ margin: 6px 0 0;
52
+ color: var(--muted);
53
+ }
54
+
55
+ button {
56
+ border: 1px solid var(--accent);
57
+ background: var(--accent);
58
+ color: white;
59
+ padding: 8px 12px;
60
+ border-radius: 6px;
61
+ cursor: pointer;
62
+ }
63
+
64
+ button.secondary {
65
+ background: #ffffff;
66
+ color: var(--accent);
67
+ }
68
+
69
+ input,
70
+ select {
71
+ border: 1px solid var(--line);
72
+ padding: 8px;
73
+ border-radius: 6px;
74
+ min-width: 0;
75
+ }
76
+
77
+ .layout {
78
+ display: grid;
79
+ grid-template-columns: minmax(220px, 320px) minmax(280px, 380px) minmax(460px, 1fr);
80
+ gap: 16px;
81
+ padding: 16px;
82
+ }
83
+
84
+ .panel {
85
+ background: var(--panel);
86
+ border: 1px solid var(--line);
87
+ border-radius: 8px;
88
+ padding: 16px;
89
+ min-height: 120px;
90
+ }
91
+
92
+ .wide {
93
+ min-height: 520px;
94
+ grid-column: span 1;
95
+ }
96
+
97
+ .metrics {
98
+ display: grid;
99
+ grid-template-columns: repeat(2, minmax(0, 1fr));
100
+ gap: 10px;
101
+ }
102
+
103
+ .metric {
104
+ border: 1px solid var(--line);
105
+ border-radius: 6px;
106
+ padding: 10px;
107
+ }
108
+
109
+ .metric strong {
110
+ display: block;
111
+ font-size: 20px;
112
+ color: var(--accent-2);
113
+ }
114
+
115
+ .searchbar {
116
+ display: grid;
117
+ grid-template-columns: 1fr auto;
118
+ gap: 8px;
119
+ margin-bottom: 12px;
120
+ }
121
+
122
+ .list {
123
+ display: grid;
124
+ gap: 8px;
125
+ }
126
+
127
+ .row {
128
+ border: 1px solid var(--line);
129
+ border-radius: 6px;
130
+ padding: 10px;
131
+ background: #fbfcfd;
132
+ }
133
+
134
+ .row h3 {
135
+ font-size: 14px;
136
+ }
137
+
138
+ .row .meta,
139
+ .detail .meta {
140
+ color: var(--muted);
141
+ font-size: 12px;
142
+ margin-top: 4px;
143
+ }
144
+
145
+ .actions {
146
+ display: flex;
147
+ gap: 8px;
148
+ flex-wrap: wrap;
149
+ margin-top: 10px;
150
+ }
151
+
152
+ .detail-grid {
153
+ display: grid;
154
+ grid-template-columns: repeat(3, minmax(0, 1fr));
155
+ gap: 12px;
156
+ margin-bottom: 14px;
157
+ }
158
+
159
+ .table {
160
+ width: 100%;
161
+ border-collapse: collapse;
162
+ font-size: 13px;
163
+ }
164
+
165
+ .table th,
166
+ .table td {
167
+ border-bottom: 1px solid var(--line);
168
+ padding: 7px;
169
+ text-align: left;
170
+ vertical-align: top;
171
+ }
172
+
173
+ .money {
174
+ font-variant-numeric: tabular-nums;
175
+ text-align: right;
176
+ }
177
+
178
+ .empty {
179
+ color: var(--muted);
180
+ }
181
+
182
+ .notice {
183
+ border-left: 4px solid var(--warn);
184
+ padding: 8px 10px;
185
+ background: #fff8e8;
186
+ margin-bottom: 12px;
187
+ color: #453000;
188
+ }
189
+
190
+ .report-actions {
191
+ margin-bottom: 12px;
192
+ }
193
+
194
+ .security-grid,
195
+ .user-editor,
196
+ .account-update-editor,
197
+ .type-editor,
198
+ .transaction-editor {
199
+ display: grid;
200
+ gap: 8px;
201
+ margin-bottom: 12px;
202
+ }
203
+
204
+ .security-grid {
205
+ grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) auto;
206
+ }
207
+
208
+ .user-editor {
209
+ grid-template-columns: repeat(5, minmax(90px, 1fr)) repeat(4, auto);
210
+ }
211
+
212
+ .account-update-editor {
213
+ grid-template-columns: repeat(4, minmax(90px, 1fr)) auto;
214
+ }
215
+
216
+ .type-editor {
217
+ grid-template-columns: minmax(80px, 120px) minmax(180px, 1fr) repeat(3, auto);
218
+ }
219
+
220
+ .transaction-editor {
221
+ grid-template-columns: repeat(6, minmax(90px, 1fr));
222
+ }
223
+
224
+ .transaction-editor button {
225
+ min-width: 80px;
226
+ }
227
+
228
+ .statement-lines {
229
+ max-height: 380px;
230
+ overflow: auto;
231
+ white-space: pre-wrap;
232
+ font-family: Consolas, "Courier New", monospace;
233
+ font-size: 12px;
234
+ line-height: 1.45;
235
+ border: 1px solid var(--line);
236
+ border-radius: 6px;
237
+ padding: 10px;
238
+ background: #fbfcfd;
239
+ }
240
+
241
+ @media (max-width: 1000px) {
242
+ .layout {
243
+ grid-template-columns: 1fr;
244
+ }
245
+
246
+ .security-grid,
247
+ .user-editor,
248
+ .account-update-editor,
249
+ .type-editor,
250
+ .transaction-editor {
251
+ grid-template-columns: 1fr;
252
+ }
253
+ }
modern_code/tests/test_a_grade_promotion.py ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ import subprocess
5
+ import sys
6
+ import tempfile
7
+ import unittest
8
+ from pathlib import Path
9
+
10
+ from tools.evaluate_a_grade_promotion import SOURCE_HEAD, build_a_grade_report
11
+
12
+
13
+ MODERN_ROOT = Path(__file__).resolve().parents[1]
14
+ SOURCE = Path(__file__).resolve().parents[2] / "source"
15
+
16
+
17
+ class AGradePromotionTests(unittest.TestCase):
18
+ @classmethod
19
+ def setUpClass(cls) -> None:
20
+ required_reports = [
21
+ MODERN_ROOT / "reports" / "capability_ledger.json",
22
+ MODERN_ROOT / "reports" / "modernization_receipt.json",
23
+ ]
24
+ if all(path.exists() for path in required_reports):
25
+ return
26
+ subprocess.run(
27
+ [
28
+ sys.executable,
29
+ str(MODERN_ROOT / "tools" / "generate_receipts.py"),
30
+ "--source-root",
31
+ str(SOURCE),
32
+ "--db-path",
33
+ str(MODERN_ROOT / "carddemo.sqlite"),
34
+ "--out-dir",
35
+ str(MODERN_ROOT / "reports"),
36
+ ],
37
+ check=True,
38
+ capture_output=True,
39
+ text=True,
40
+ )
41
+
42
+ def test_gate_does_not_promote_without_live_legacy_trace_corpus(self) -> None:
43
+ report = build_a_grade_report(MODERN_ROOT, SOURCE)
44
+
45
+ self.assertFalse(report["a_grade_gate"]["promotable_to_A"])
46
+ self.assertEqual(50, report["a_grade_gate"]["required_live_matches"])
47
+ self.assertEqual(0, report["a_grade_gate"]["accepted_live_matches"])
48
+ self.assertEqual(50, report["a_grade_gate"]["missing_live_matches"])
49
+ self.assertEqual(50, report["current_static_source_oracle_status"]["grade_counts"]["B"])
50
+ self.assertEqual(0, report["current_static_source_oracle_status"]["grade_counts"]["F"])
51
+ self.assertEqual(0, report["current_static_source_oracle_status"]["gap_count"])
52
+ self.assertTrue(
53
+ any(blocker["code"] == "missing_live_legacy_trace_corpus" for blocker in report["blockers"])
54
+ )
55
+
56
+ def test_gate_accepts_only_contract_compliant_live_trace_records(self) -> None:
57
+ with tempfile.TemporaryDirectory() as tmp:
58
+ trace_dir = Path(tmp)
59
+ partial_trace = {
60
+ "capability_matches": [
61
+ {
62
+ "capability_id": "online:CC00",
63
+ "trace_kind": "live_cobol_cics_runtime",
64
+ "source_head": SOURCE_HEAD,
65
+ "legacy_runtime_environment": "unit-test-mainframe-runtime",
66
+ "raw_legacy_trace_hash": "a" * 64,
67
+ "modern_observation_hash": "b" * 64,
68
+ "comparator_version": "unit-test",
69
+ "matched": True,
70
+ },
71
+ {
72
+ "capability_id": "online:CC01",
73
+ "trace_kind": "static_oracle_replay",
74
+ "source_head": SOURCE_HEAD,
75
+ "legacy_runtime_environment": "not-live-runtime",
76
+ "raw_legacy_trace_hash": "c" * 64,
77
+ "modern_observation_hash": "d" * 64,
78
+ "comparator_version": "unit-test",
79
+ "matched": True,
80
+ },
81
+ ]
82
+ }
83
+ (trace_dir / "partial_trace.json").write_text(json.dumps(partial_trace), encoding="utf-8")
84
+
85
+ report = build_a_grade_report(MODERN_ROOT, SOURCE, trace_dir)
86
+
87
+ self.assertFalse(report["a_grade_gate"]["promotable_to_A"])
88
+ self.assertEqual(1, report["a_grade_gate"]["accepted_live_matches"])
89
+ self.assertEqual(49, report["a_grade_gate"]["missing_live_matches"])
90
+ self.assertIn("online:CC00", report["live_trace_scan"]["accepted_matches"])
91
+ rejected_ids = {item.get("capability_id") for item in report["live_trace_scan"]["rejected_records"]}
92
+ self.assertIn("online:CC01", rejected_ids)
93
+
94
+
95
+ if __name__ == "__main__":
96
+ unittest.main()
modern_code/tests/test_hf_public_bundle.py ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import subprocess
4
+ import sys
5
+ import tempfile
6
+ import unittest
7
+ from pathlib import Path
8
+
9
+ from tools.build_hf_public_bundle import SOURCE_HEAD, build_bundle
10
+
11
+
12
+ MODERN_ROOT = Path(__file__).resolve().parents[1]
13
+ SOURCE = Path(__file__).resolve().parents[2] / "source"
14
+
15
+
16
+ class HfPublicBundleTests(unittest.TestCase):
17
+ @classmethod
18
+ def setUpClass(cls) -> None:
19
+ required = [
20
+ MODERN_ROOT / "final_proof" / "FINAL_RECEIPT_SUMMARY.json",
21
+ MODERN_ROOT / "final_proof" / "NO_COST_CONFIDENCE_REPORT.json",
22
+ MODERN_ROOT / "final_proof" / "A_GRADE_PROMOTION_REPORT.json",
23
+ ]
24
+ if all(path.exists() for path in required):
25
+ return
26
+ commands = [
27
+ [
28
+ sys.executable,
29
+ "-m",
30
+ "carddemo.cli",
31
+ "init-db",
32
+ "--source-root",
33
+ str(SOURCE),
34
+ "--db-path",
35
+ str(MODERN_ROOT / "carddemo.sqlite"),
36
+ ],
37
+ [
38
+ sys.executable,
39
+ str(MODERN_ROOT / "tools" / "generate_receipts.py"),
40
+ "--source-root",
41
+ str(SOURCE),
42
+ "--db-path",
43
+ str(MODERN_ROOT / "carddemo.sqlite"),
44
+ "--out-dir",
45
+ str(MODERN_ROOT / "reports"),
46
+ ],
47
+ [
48
+ sys.executable,
49
+ str(MODERN_ROOT / "tools" / "replay_static_oracles.py"),
50
+ "--source-root",
51
+ str(SOURCE),
52
+ "--out-dir",
53
+ str(MODERN_ROOT / "reports"),
54
+ "--source-head",
55
+ SOURCE_HEAD,
56
+ ],
57
+ [
58
+ sys.executable,
59
+ str(MODERN_ROOT / "tools" / "evaluate_a_grade_promotion.py"),
60
+ "--source-root",
61
+ str(SOURCE),
62
+ "--out-dir",
63
+ str(MODERN_ROOT / "final_proof"),
64
+ ],
65
+ [
66
+ sys.executable,
67
+ str(MODERN_ROOT / "tools" / "build_no_cost_confidence.py"),
68
+ "--source-root",
69
+ str(SOURCE),
70
+ "--out-dir",
71
+ str(MODERN_ROOT / "final_proof"),
72
+ ],
73
+ [
74
+ sys.executable,
75
+ str(MODERN_ROOT / "tools" / "package_final_proof.py"),
76
+ "--source-root",
77
+ str(SOURCE),
78
+ ],
79
+ ]
80
+ for command in commands:
81
+ subprocess.run(command, check=True, capture_output=True, text=True, cwd=MODERN_ROOT)
82
+
83
+ def test_public_bundle_has_disclaimers_and_excludes_upstream_source_tree(self) -> None:
84
+ with tempfile.TemporaryDirectory() as tmp:
85
+ out_dir = Path(tmp) / "hf_bundle"
86
+ manifest = build_bundle(MODERN_ROOT, out_dir, "cjc0013/aws-carddemo-no-cost-modernization-proof")
87
+ readme = (out_dir / "README.md").read_text(encoding="utf-8")
88
+ all_paths = {item["path"] for item in manifest["files"]}
89
+
90
+ self.assertIn(SOURCE_HEAD, readme)
91
+ self.assertIn("not a claim of live COBOL/CICS all-path runtime equivalence", readme)
92
+ self.assertIn("without paid/licensed legacy runtime", readme)
93
+ self.assertFalse(any(path.startswith("source/") for path in all_paths))
94
+ self.assertFalse(any("/app/cbl/" in path or path.startswith("app/cbl/") for path in all_paths))
95
+ self.assertIn("final_proof/NO_COST_CONFIDENCE_REPORT.json", all_paths)
96
+ self.assertIn("modern_code/tools/build_hf_public_bundle.py", all_paths)
97
+ self.assertFalse(manifest["public_safe_checks"]["original_source_tree_copied"])
98
+ self.assertFalse(manifest["public_safe_checks"]["live_runtime_equivalence_claim_made"])
99
+
100
+
101
+ if __name__ == "__main__":
102
+ unittest.main()
modern_code/tests/test_legacy_parser.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import unittest
4
+ from pathlib import Path
5
+
6
+ from carddemo.legacy_parser import (
7
+ ACCOUNT_FIELDS,
8
+ CUSTOMER_FIELDS,
9
+ TRANSACTION_FIELDS,
10
+ parse_ascii_file,
11
+ parse_overpunch_int,
12
+ parse_pending_authorizations,
13
+ parse_user_security,
14
+ )
15
+
16
+
17
+ ROOT = Path(__file__).resolve().parents[2]
18
+ SOURCE = ROOT / "source"
19
+
20
+
21
+ class LegacyParserTests(unittest.TestCase):
22
+ def test_overpunch_money_signs(self) -> None:
23
+ self.assertEqual(parse_overpunch_int("00000001940{"), 19400)
24
+ self.assertEqual(parse_overpunch_int("0000005047G"), 50477)
25
+ self.assertEqual(parse_overpunch_int("0000009190}"), -91900)
26
+
27
+ def test_customer_record_layout(self) -> None:
28
+ rows = parse_ascii_file(SOURCE / "app" / "data" / "ASCII" / "custdata.txt", CUSTOMER_FIELDS, 500)
29
+ self.assertEqual(len(rows), 50)
30
+ self.assertEqual(rows[0]["customer_id"], 1)
31
+ self.assertEqual(rows[0]["first_name"], "Immanuel")
32
+ self.assertEqual(rows[0]["last_name"], "Kessler")
33
+
34
+ def test_account_record_layout(self) -> None:
35
+ rows = parse_ascii_file(SOURCE / "app" / "data" / "ASCII" / "acctdata.txt", ACCOUNT_FIELDS, 300)
36
+ self.assertEqual(len(rows), 50)
37
+ self.assertEqual(rows[0]["account_id"], 1)
38
+ self.assertEqual(rows[0]["current_balance_cents"], 19400)
39
+ self.assertEqual(rows[0]["credit_limit_cents"], 202000)
40
+
41
+ def test_transaction_record_layout(self) -> None:
42
+ rows = parse_ascii_file(SOURCE / "app" / "data" / "ASCII" / "dailytran.txt", TRANSACTION_FIELDS, 350)
43
+ self.assertEqual(len(rows), 300)
44
+ self.assertEqual(rows[0]["type_code"], "01")
45
+ self.assertEqual(rows[0]["amount_cents"], 50477)
46
+ self.assertEqual(rows[1]["amount_cents"], -91900)
47
+
48
+ def test_user_security_decodes_ebcdic(self) -> None:
49
+ users = parse_user_security(SOURCE / "app" / "data" / "EBCDIC" / "AWS.M2.CARDDEMO.USRSEC.PS")
50
+ self.assertEqual(len(users), 10)
51
+ self.assertEqual(users[0]["user_id"], "ADMIN001")
52
+ self.assertEqual(users[0]["user_type"], "A")
53
+
54
+ def test_pending_authorization_ims_unload_decodes_segments(self) -> None:
55
+ parsed = parse_pending_authorizations(
56
+ SOURCE
57
+ / "app"
58
+ / "app-authorization-ims-db2-mq"
59
+ / "data"
60
+ / "EBCDIC"
61
+ / "AWS.M2.CARDDEMO.IMSDATA.DBPAUTP0.dat"
62
+ )
63
+ self.assertEqual(len(parsed["summaries"]), 21)
64
+ self.assertEqual(len(parsed["details"]), 202)
65
+ self.assertEqual(parsed["summaries"][0]["account_id"], 1)
66
+ self.assertEqual(parsed["summaries"][0]["approved_auth_count"], 6)
67
+ self.assertEqual(parsed["details"][0]["card_number"], "9680294154603697")
68
+ self.assertEqual(parsed["details"][0]["auth_orig_date"], "231027")
69
+ self.assertEqual(parsed["details"][0]["auth_resp_code"], "00")
70
+
71
+
72
+ if __name__ == "__main__":
73
+ unittest.main()
modern_code/tests/test_no_cost_confidence.py ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import subprocess
4
+ import sys
5
+ import unittest
6
+ from pathlib import Path
7
+
8
+ from tools.build_no_cost_confidence import SOURCE_HEAD, build_no_cost_confidence_report
9
+
10
+
11
+ MODERN_ROOT = Path(__file__).resolve().parents[1]
12
+ SOURCE = Path(__file__).resolve().parents[2] / "source"
13
+
14
+
15
+ class NoCostConfidenceTests(unittest.TestCase):
16
+ @classmethod
17
+ def setUpClass(cls) -> None:
18
+ subprocess.run(
19
+ [
20
+ sys.executable,
21
+ "-m",
22
+ "carddemo.cli",
23
+ "init-db",
24
+ "--source-root",
25
+ str(SOURCE),
26
+ "--db-path",
27
+ str(MODERN_ROOT / "carddemo.sqlite"),
28
+ ],
29
+ check=True,
30
+ capture_output=True,
31
+ text=True,
32
+ cwd=MODERN_ROOT,
33
+ )
34
+ subprocess.run(
35
+ [
36
+ sys.executable,
37
+ str(MODERN_ROOT / "tools" / "generate_receipts.py"),
38
+ "--source-root",
39
+ str(SOURCE),
40
+ "--db-path",
41
+ str(MODERN_ROOT / "carddemo.sqlite"),
42
+ "--out-dir",
43
+ str(MODERN_ROOT / "reports"),
44
+ ],
45
+ check=True,
46
+ capture_output=True,
47
+ text=True,
48
+ )
49
+ subprocess.run(
50
+ [
51
+ sys.executable,
52
+ str(MODERN_ROOT / "tools" / "replay_static_oracles.py"),
53
+ "--source-root",
54
+ str(SOURCE),
55
+ "--out-dir",
56
+ str(MODERN_ROOT / "reports"),
57
+ "--source-head",
58
+ SOURCE_HEAD,
59
+ ],
60
+ check=True,
61
+ capture_output=True,
62
+ text=True,
63
+ )
64
+ subprocess.run(
65
+ [
66
+ sys.executable,
67
+ str(MODERN_ROOT / "tools" / "evaluate_a_grade_promotion.py"),
68
+ "--source-root",
69
+ str(SOURCE),
70
+ "--out-dir",
71
+ str(MODERN_ROOT / "final_proof"),
72
+ ],
73
+ check=True,
74
+ capture_output=True,
75
+ text=True,
76
+ )
77
+
78
+ def test_no_cost_report_keeps_runtime_boundary_honest(self) -> None:
79
+ report = build_no_cost_confidence_report(MODERN_ROOT, SOURCE, MODERN_ROOT / "final_proof")
80
+
81
+ self.assertFalse(report["no_cost_scope"]["paid_runtime_used"])
82
+ self.assertFalse(report["no_cost_scope"]["legacy_runtime_claim_made"])
83
+ self.assertEqual("strong_pre_runtime_confidence", report["no_cost_confidence_summary"]["reviewer_posture"])
84
+ self.assertEqual(50, report["capability_coverage"]["capability_count"])
85
+ self.assertEqual(50, report["capability_coverage"]["static_oracle_ready_count"])
86
+ self.assertEqual(50, report["a_grade_gate"]["missing_live_matches"])
87
+ self.assertFalse(report["a_grade_gate"]["promotable_to_A"])
88
+
89
+ def test_source_semantics_scan_names_why_free_runtime_is_limited(self) -> None:
90
+ report = build_no_cost_confidence_report(MODERN_ROOT, SOURCE, MODERN_ROOT / "final_proof")
91
+ scan = report["legacy_source_semantics_scan"]
92
+
93
+ self.assertGreaterEqual(scan["cobol_program_count"], 30)
94
+ self.assertGreater(scan["cics_program_count"], 0)
95
+ self.assertGreater(scan["free_gnucobol_probe_candidate_count"], 0)
96
+ self.assertGreater(scan["runtime_required_program_count"], 0)
97
+ self.assertIn("CICS/VSAM/JCL", report["no_cost_confidence_summary"]["remaining_gap"])
98
+
99
+
100
+ if __name__ == "__main__":
101
+ unittest.main()
modern_code/tests/test_parity.py ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import tempfile
4
+ import unittest
5
+ from pathlib import Path
6
+
7
+ from carddemo.parity import build_capability_ledger, build_parity_evidence
8
+ from carddemo.repository import seed_from_legacy
9
+
10
+
11
+ ROOT = Path(__file__).resolve().parents[2]
12
+ SOURCE = ROOT / "source"
13
+
14
+
15
+ class ParityEvidenceTests(unittest.TestCase):
16
+ def setUp(self) -> None:
17
+ self.tmp = tempfile.TemporaryDirectory()
18
+ self.db_path = Path(self.tmp.name) / "carddemo.sqlite"
19
+ seed_from_legacy(SOURCE, self.db_path, reset=True)
20
+
21
+ def tearDown(self) -> None:
22
+ self.tmp.cleanup()
23
+
24
+ def test_capability_ledger_covers_readme_inventory(self) -> None:
25
+ ledger = build_capability_ledger(SOURCE)
26
+ self.assertEqual(len(ledger), 50)
27
+ by_id = {row["capability_id"]: row for row in ledger}
28
+ self.assertEqual(by_id["online:CAVW"]["proof_grade"], "B")
29
+ self.assertEqual(by_id["online:CP00"]["proof_grade"], "B")
30
+ self.assertEqual(by_id["online:CPVS"]["proof_grade"], "B")
31
+ self.assertEqual(by_id["online:CPVD"]["proof_grade"], "B")
32
+ self.assertEqual(by_id["online:CC00"]["proof_grade"], "B")
33
+ self.assertEqual(by_id["online:CM00"]["proof_grade"], "B")
34
+ self.assertEqual(by_id["online:CA00"]["proof_grade"], "B")
35
+ self.assertEqual(by_id["online:CAUP"]["proof_grade"], "B")
36
+ self.assertEqual(by_id["online:CCDL"]["proof_grade"], "B")
37
+ self.assertEqual(by_id["online:CCUP"]["proof_grade"], "B")
38
+ self.assertEqual(by_id["online:CU01"]["proof_grade"], "B")
39
+ self.assertEqual(by_id["online:CU02"]["proof_grade"], "B")
40
+ self.assertEqual(by_id["online:CU03"]["proof_grade"], "B")
41
+ self.assertEqual(by_id["online:CT02"]["proof_grade"], "B")
42
+ self.assertEqual(by_id["online:CTLI"]["proof_grade"], "B")
43
+ self.assertEqual(by_id["online:CTTU"]["proof_grade"], "B")
44
+ self.assertEqual(by_id["batch:INTCALC"]["proof_grade"], "B")
45
+ self.assertEqual(by_id["batch:POSTTRAN"]["proof_grade"], "B")
46
+ self.assertEqual(by_id["online:CB00"]["proof_grade"], "B")
47
+ self.assertEqual(by_id["batch:TRANREPT"]["proof_grade"], "B")
48
+ self.assertEqual(by_id["batch:COMBTRAN"]["proof_grade"], "B")
49
+ self.assertEqual(by_id["batch:CREASTMT"]["proof_grade"], "B")
50
+ self.assertEqual(by_id["batch:MNTTRDB2"]["proof_grade"], "B")
51
+ self.assertEqual(by_id["batch:TRANBKP"]["proof_grade"], "B")
52
+ self.assertEqual(by_id["batch:TRANEXTR"]["proof_grade"], "B")
53
+ self.assertEqual(by_id["batch:CREADB21"]["proof_grade"], "B")
54
+ self.assertEqual(by_id["batch:CBPAUP0J"]["proof_grade"], "B")
55
+ self.assertEqual(by_id["online:CDRD"]["proof_grade"], "B")
56
+ self.assertEqual(by_id["online:CDRA"]["proof_grade"], "B")
57
+ self.assertEqual(by_id["batch:DEFGDGB"]["proof_grade"], "B")
58
+ self.assertEqual(by_id["batch:DEFGDGD"]["proof_grade"], "B")
59
+ self.assertEqual(by_id["batch:ESDSRRDS"]["proof_grade"], "B")
60
+ self.assertEqual(by_id["batch:TRANIDX"]["proof_grade"], "B")
61
+ self.assertEqual(by_id["batch:CLOSEFIL"]["proof_grade"], "B")
62
+ self.assertEqual(by_id["batch:OPENFIL"]["proof_grade"], "B")
63
+ self.assertGreater(by_id["online:CAVW"]["source_ref_count"], 0)
64
+
65
+ def test_parity_evidence_materializes_traces_edges_and_gaps(self) -> None:
66
+ evidence = build_parity_evidence(
67
+ SOURCE,
68
+ self.db_path,
69
+ source_head="59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e",
70
+ )
71
+ self.assertEqual(evidence["summary"]["capability_count"], 50)
72
+ self.assertTrue(evidence["summary"]["one_for_one_parity_ready"])
73
+ self.assertGreater(evidence["summary"]["static_oracle_or_better_count"], 0)
74
+ self.assertEqual(evidence["summary"]["gap_count"], 0)
75
+ self.assertGreaterEqual(len(evidence["golden_traces"]), 21)
76
+ self.assertTrue(any(row["trace_id"] == "signon_admin_success" for row in evidence["golden_traces"]))
77
+ self.assertTrue(any(row["trace_id"] == "regular_main_menu_options" for row in evidence["golden_traces"]))
78
+ user_trace = next(
79
+ row for row in evidence["golden_traces"] if row["trace_id"] == "user_maintenance_add_update_delete"
80
+ )
81
+ self.assertEqual(user_trace["proof_grade"], "B")
82
+ self.assertEqual(user_trace["expected"]["required_field_messages"]["user_type"], "User Type can NOT be empty...")
83
+ self.assertEqual(user_trace["expected"]["non_admin_signon_route"], "CM00")
84
+ self.assertTrue(any(row["trace_id"] == "transaction_add_ct02_validated_write" for row in evidence["golden_traces"]))
85
+ self.assertTrue(any(row["trace_id"] == "account_update_caup_validated_rewrite" for row in evidence["golden_traces"]))
86
+ self.assertTrue(any(row["trace_id"] == "card_detail_ccdl_account_1" for row in evidence["golden_traces"]))
87
+ self.assertTrue(any(row["trace_id"] == "card_update_ccup_validated_rewrite" for row in evidence["golden_traces"]))
88
+ mq_date_trace = next(row for row in evidence["golden_traces"] if row["trace_id"] == "mq_system_date_cdrd_reply")
89
+ self.assertEqual(mq_date_trace["expected"]["reply_message"], "SYSTEM DATE : 05-23-2026SYSTEM TIME : 11:12:13")
90
+ mq_account_trace = next(
91
+ row for row in evidence["golden_traces"] if row["trace_id"] == "mq_account_inquiry_cdra_success_and_invalid"
92
+ )
93
+ self.assertTrue(mq_account_trace["expected"]["reply_has_account_label"])
94
+ self.assertIn("INVALID REQUEST PARAMETERS", mq_account_trace["expected"]["not_found_reply"])
95
+ resource_trace = next(
96
+ row for row in evidence["golden_traces"] if row["trace_id"] == "batch_resource_setup_gdg_vsam_aix_cics"
97
+ )
98
+ self.assertEqual(resource_trace["expected"]["resource_count"], 6)
99
+ self.assertEqual(resource_trace["expected"]["tranidx_keys"], {"length": 26, "offset": 304})
100
+ self.assertTrue(resource_trace["expected"]["file_sets_match"])
101
+ ctli_trace = next(row for row in evidence["golden_traces"] if row["trace_id"] == "transaction_type_lookup")
102
+ self.assertEqual(ctli_trace["expected"]["legacy_transaction"], "CTLI")
103
+ self.assertEqual(ctli_trace["expected"]["page_size"], 7)
104
+ self.assertEqual(ctli_trace["expected"]["type_filter_result"], ["01"])
105
+ self.assertTrue(any(row["trace_id"] == "transaction_type_cttu_validated_upsert_delete" for row in evidence["golden_traces"]))
106
+ self.assertTrue(any(row["trace_id"] == "bill_payment_full_balance" for row in evidence["golden_traces"]))
107
+ self.assertTrue(any(row["trace_id"] == "posttran_reject_codes" for row in evidence["golden_traces"]))
108
+ self.assertTrue(any(row["trace_id"] == "pending_authorization_cpvs_summary_page" for row in evidence["golden_traces"]))
109
+ self.assertTrue(any(row["trace_id"] == "pending_authorization_cpvd_detail_lookup" for row in evidence["golden_traces"]))
110
+ self.assertTrue(any(row["trace_id"] == "pending_authorization_cp00_request_response_and_insert" for row in evidence["golden_traces"]))
111
+ self.assertTrue(any(row["trace_id"] == "pending_authorization_cpvd_fraud_and_cbpaup0j_purge" for row in evidence["golden_traces"]))
112
+ comb_trace = next(
113
+ row for row in evidence["golden_traces"] if row["trace_id"] == "combined_transactions_seed_plus_interest_preview"
114
+ )
115
+ self.assertEqual(comb_trace["proof_grade"], "B")
116
+ self.assertEqual(comb_trace["expected"]["sort"]["symbol"], "TRAN-ID")
117
+ self.assertTrue(comb_trace["expected"]["transaction_ids_sorted"])
118
+ mnt_trace = next(
119
+ row for row in evidence["golden_traces"] if row["trace_id"] == "batch_transaction_type_mnttrdb2_fixed_record_flow"
120
+ )
121
+ self.assertEqual(mnt_trace["proof_grade"], "B")
122
+ self.assertEqual(mnt_trace["expected"]["legacy_program"], "COBTUPDT")
123
+ self.assertEqual(mnt_trace["expected"]["return_code"], 4)
124
+ self.assertEqual(mnt_trace["expected"]["applied_count"], 3)
125
+ self.assertEqual(mnt_trace["expected"]["error_count"], 4)
126
+ tranbkp_trace = next(
127
+ row for row in evidence["golden_traces"] if row["trace_id"] == "transaction_master_tranbkp_backup_redefine"
128
+ )
129
+ self.assertEqual(tranbkp_trace["proof_grade"], "B")
130
+ self.assertEqual(tranbkp_trace["expected"]["define_cluster"]["keys"], {"length": 16, "offset": 0})
131
+ self.assertEqual(tranbkp_trace["expected"]["record_count"], 300)
132
+ tranextr_trace = next(
133
+ row for row in evidence["golden_traces"] if row["trace_id"] == "transaction_type_tranextr_reference_extract"
134
+ )
135
+ self.assertEqual(tranextr_trace["proof_grade"], "B")
136
+ self.assertEqual(tranextr_trace["expected"]["lrecl"], 60)
137
+ self.assertEqual(tranextr_trace["expected"]["type_record_lengths"], [60])
138
+ self.assertEqual(tranextr_trace["expected"]["category_record_lengths"], [60])
139
+ db2_trace = next(
140
+ row for row in evidence["golden_traces"] if row["trace_id"] == "db2_reference_creadb21_schema_and_load"
141
+ )
142
+ self.assertEqual(db2_trace["proof_grade"], "B")
143
+ self.assertEqual(db2_trace["expected"]["steps"], ["FREEPLN", "CRCRDDB", "RUNTEP2", "LDTCCAT"])
144
+ self.assertEqual(db2_trace["expected"]["transaction_type_load_count"], 7)
145
+ self.assertEqual(db2_trace["expected"]["transaction_category_load_count"], 18)
146
+ self.assertTrue(any(row["edge_case_id"] == "transaction_largest_credit_or_negative" for row in evidence["edge_cases"]))
147
+ self.assertTrue(any(row["edge_case_id"] == "signon_lowercase_credentials" for row in evidence["edge_cases"]))
148
+ self.assertTrue(any(row["edge_case_id"] == "user_security_required_fields" for row in evidence["edge_cases"]))
149
+ self.assertTrue(any(row["edge_case_id"] == "user_security_non_admin_type_regular_route" for row in evidence["edge_cases"]))
150
+ self.assertTrue(any(row["edge_case_id"] == "ct02_signed_amount_format" for row in evidence["edge_cases"]))
151
+ self.assertTrue(any(row["edge_case_id"] == "caup_no_change_update" for row in evidence["edge_cases"]))
152
+ self.assertTrue(any(row["edge_case_id"] == "ccdl_ccup_card_key_validation" for row in evidence["edge_cases"]))
153
+ self.assertTrue(any(row["edge_case_id"] == "ccup_card_update_validation" for row in evidence["edge_cases"]))
154
+ self.assertTrue(any(row["edge_case_id"] == "ctli_cursor_filters_and_page_size" for row in evidence["edge_cases"]))
155
+ self.assertTrue(any(row["edge_case_id"] == "cttu_child_delete_guard" for row in evidence["edge_cases"]))
156
+ self.assertTrue(any(row["edge_case_id"] == "mnttrdb2_fixed_record_actions_and_sql_errors" for row in evidence["edge_cases"]))
157
+ self.assertTrue(any(row["edge_case_id"] == "creastmt_fixed_width_source_sort" for row in evidence["edge_cases"]))
158
+ self.assertTrue(any(row["edge_case_id"] == "combtran_transaction_id_sort_repro" for row in evidence["edge_cases"]))
159
+ self.assertTrue(any(row["edge_case_id"] == "tranbkp_transaction_master_ksds_contract" for row in evidence["edge_cases"]))
160
+ self.assertTrue(any(row["edge_case_id"] == "tranextr_reference_extract_fixed_width" for row in evidence["edge_cases"]))
161
+ self.assertTrue(any(row["edge_case_id"] == "creadb21_db2_reference_schema_and_load_order" for row in evidence["edge_cases"]))
162
+ self.assertTrue(any(row["edge_case_id"] == "pending_authorization_ims_segment_header_offset" for row in evidence["edge_cases"]))
163
+ self.assertTrue(any(row["edge_case_id"] == "authorization_available_credit_boundary" for row in evidence["edge_cases"]))
164
+ self.assertTrue(any(row["edge_case_id"] == "authorization_purge_reverse_date_key" for row in evidence["edge_cases"]))
165
+ self.assertTrue(any(row["edge_case_id"] == "mq_cdrd_request_payload_ignored" for row in evidence["edge_cases"]))
166
+ self.assertTrue(any(row["edge_case_id"] == "mq_cdra_inqa_account_key_validation" for row in evidence["edge_cases"]))
167
+ self.assertTrue(any(row["edge_case_id"] == "batch_gdg_limit_scratch_first_generation" for row in evidence["edge_cases"]))
168
+ self.assertTrue(any(row["edge_case_id"] == "vsam_esds_rrds_user_security_layout" for row in evidence["edge_cases"]))
169
+ self.assertTrue(any(row["edge_case_id"] == "transaction_aix_processed_timestamp_key" for row in evidence["edge_cases"]))
170
+ self.assertTrue(any(row["edge_case_id"] == "cics_file_control_command_set" for row in evidence["edge_cases"]))
171
+ self.assertEqual(evidence["next_gap_ranking"], [])
172
+
173
+
174
+ if __name__ == "__main__":
175
+ unittest.main()
modern_code/tests/test_service.py ADDED
@@ -0,0 +1,758 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import tempfile
4
+ import unittest
5
+ from pathlib import Path
6
+
7
+ from carddemo.repository import connect, seed_from_legacy
8
+ from carddemo.service import CardDemoService
9
+
10
+
11
+ ROOT = Path(__file__).resolve().parents[2]
12
+ SOURCE = ROOT / "source"
13
+
14
+
15
+ class ServiceTests(unittest.TestCase):
16
+ def setUp(self) -> None:
17
+ self.tmp = tempfile.TemporaryDirectory()
18
+ self.db_path = Path(self.tmp.name) / "carddemo.sqlite"
19
+ self.counts = seed_from_legacy(SOURCE, self.db_path, reset=True)
20
+ self.service = CardDemoService(self.db_path)
21
+
22
+ def tearDown(self) -> None:
23
+ self.tmp.cleanup()
24
+
25
+ def test_seed_counts(self) -> None:
26
+ self.assertEqual(self.counts["customers"], 50)
27
+ self.assertEqual(self.counts["accounts"], 50)
28
+ self.assertEqual(self.counts["cards"], 50)
29
+ self.assertEqual(self.counts["transactions"], 300)
30
+ self.assertGreater(self.counts["disclosure_groups"], 0)
31
+ self.assertGreater(self.counts["transaction_category_balances"], 0)
32
+ self.assertEqual(self.counts["users"], 10)
33
+ self.assertEqual(self.counts["pending_authorization_summaries"], 21)
34
+ self.assertEqual(self.counts["pending_authorization_details"], 202)
35
+
36
+ def test_signon_routes_admin_and_rejects_bad_password(self) -> None:
37
+ success = self.service.signon("admin001", "password")
38
+ self.assertTrue(success["authenticated"])
39
+ self.assertEqual(success["legacy_transaction"], "CC00")
40
+ self.assertEqual(success["route_transaction"], "CA00")
41
+ self.assertEqual(success["route_program"], "COADM01C")
42
+ self.assertEqual(success["menu"]["option_count"], 6)
43
+
44
+ failure = self.service.signon("ADMIN001", "wrong")
45
+ self.assertFalse(failure["authenticated"])
46
+ self.assertEqual(failure["reason"], "wrong_password")
47
+ self.assertIn("Wrong Password", failure["message"])
48
+
49
+ def test_main_and_admin_menus_match_copybook_counts(self) -> None:
50
+ main = self.service.main_menu()
51
+ admin = self.service.admin_menu()
52
+ self.assertEqual(main["legacy_transaction"], "CM00")
53
+ self.assertEqual(main["option_count"], 11)
54
+ self.assertEqual(main["options"][9]["program"], "COBIL00C")
55
+ self.assertEqual(admin["legacy_transaction"], "CA00")
56
+ self.assertEqual(admin["option_count"], 6)
57
+ self.assertEqual(admin["options"][1]["program"], "COUSR01C")
58
+ with self.assertRaises(ValueError):
59
+ self.service.select_menu_option("CM00", 99)
60
+
61
+ def test_user_maintenance_add_update_delete(self) -> None:
62
+ payload = {
63
+ "user_id": "qauser01",
64
+ "first_name": "Quality",
65
+ "last_name": "Check",
66
+ "password": "secret",
67
+ "user_type": "U",
68
+ }
69
+ required_messages = {
70
+ "user_id": "User ID can NOT be empty...",
71
+ "first_name": "First Name can NOT be empty...",
72
+ "last_name": "Last Name can NOT be empty...",
73
+ "password": "Password can NOT be empty...",
74
+ "user_type": "User Type can NOT be empty...",
75
+ }
76
+ for field, message in required_messages.items():
77
+ invalid = dict(payload)
78
+ invalid[field] = ""
79
+ with self.assertRaises(ValueError) as err:
80
+ self.service.add_user(invalid)
81
+ self.assertEqual(str(err.exception), message)
82
+
83
+ added = self.service.add_user(payload)
84
+ self.assertEqual(added["legacy_transaction"], "CU01")
85
+ self.assertEqual(added["user"]["user_id"], "QAUSER01")
86
+ self.assertEqual(self.service.get_user("qauser01")["password"], "SECRET")
87
+ with self.assertRaises(ValueError) as err:
88
+ self.service.add_user(payload)
89
+ self.assertEqual(str(err.exception), "User ID already exist...")
90
+
91
+ non_admin = self.service.add_user(
92
+ {
93
+ "user_id": "qauser02",
94
+ "first_name": "Quality",
95
+ "last_name": "Nonadmin",
96
+ "password": "secret",
97
+ "user_type": "z",
98
+ }
99
+ )
100
+ self.assertEqual(non_admin["user"]["user_type"], "Z")
101
+ self.assertEqual(self.service.signon("qauser02", "secret")["route_transaction"], "CM00")
102
+
103
+ updated = self.service.update_user(
104
+ "qauser01",
105
+ {
106
+ "first_name": "Quality",
107
+ "last_name": "Updated",
108
+ "password": "secret2",
109
+ "user_type": "A",
110
+ },
111
+ )
112
+ self.assertEqual(updated["legacy_transaction"], "CU02")
113
+ self.assertEqual(updated["user"]["last_name"], "Updated")
114
+ self.assertEqual(updated["user"]["password"], "SECRET2")
115
+ with self.assertRaises(ValueError) as err:
116
+ self.service.update_user("qauser01", updated["user"])
117
+ self.assertEqual(str(err.exception), "Please modify to update ...")
118
+ with self.assertRaises(ValueError) as err:
119
+ self.service.update_user("", updated["user"])
120
+ self.assertEqual(str(err.exception), "User ID can NOT be empty...")
121
+
122
+ deleted = self.service.delete_user("qauser01")
123
+ self.assertEqual(deleted["legacy_transaction"], "CU03")
124
+ self.assertIsNone(self.service.get_user("qauser01"))
125
+ self.service.delete_user("qauser02")
126
+ with self.assertRaises(KeyError) as err:
127
+ self.service.delete_user("qauser01")
128
+ self.assertEqual(err.exception.args[0], "User ID NOT found...")
129
+
130
+ def test_account_bundle_joins_customer_card_transaction(self) -> None:
131
+ bundle = self.service.get_account_bundle(1)
132
+ self.assertIsNotNone(bundle)
133
+ assert bundle is not None
134
+ self.assertEqual(bundle["account"]["account_id"], 1)
135
+ self.assertGreaterEqual(len(bundle["cards"]), 1)
136
+ self.assertGreaterEqual(len(bundle["customers"]), 1)
137
+
138
+ def test_card_detail_follows_ccdl_lookup_shape(self) -> None:
139
+ bundle = self.service.get_account_bundle(1)
140
+ assert bundle is not None
141
+ card = bundle["cards"][0]
142
+ detail = self.service.get_card_detail(card["card_number"], account_id=1)
143
+ self.assertEqual(detail["legacy_transaction"], "CCDL")
144
+ self.assertEqual(detail["legacy_program"], "COCRDSLC")
145
+ self.assertEqual(detail["card"]["card_number"], card["card_number"])
146
+ self.assertEqual(detail["card"]["account_id"], 1)
147
+ self.assertIn("embossed_name", detail["editable_fields"])
148
+ with self.assertRaisesRegex(ValueError, "16 digit number"):
149
+ self.service.get_card_detail("123", account_id=1)
150
+ with self.assertRaisesRegex(KeyError, "Did not find cards"):
151
+ self.service.get_card_detail(card["card_number"], account_id=999)
152
+
153
+ def test_card_update_follows_ccup_validation_and_rewrite_shape(self) -> None:
154
+ bundle = self.service.get_account_bundle(1)
155
+ assert bundle is not None
156
+ card = bundle["cards"][0]
157
+ old_year, old_month, old_day = card["expiration_date"].split("-")
158
+ updated = self.service.update_card(
159
+ card["card_number"],
160
+ {
161
+ "account_id": 1,
162
+ "embossed_name": "Trace Holder",
163
+ "active_status": "N",
164
+ "expiration_month": "12",
165
+ "expiration_year": "2030",
166
+ },
167
+ )
168
+ self.assertEqual(updated["legacy_transaction"], "CCUP")
169
+ self.assertEqual(updated["legacy_program"], "COCRDUPC")
170
+ self.assertEqual(updated["card"]["embossed_name"], "Trace Holder")
171
+ self.assertEqual(updated["card"]["active_status"], "N")
172
+ self.assertEqual(updated["card"]["expiration_date"], f"2030-12-{old_day}")
173
+ self.assertIn("expiration_day", updated["preserved_fields"])
174
+ self.assertIn("expiration_date", updated["changed_fields"])
175
+ self.assertEqual(updated["card"]["cvv"], card["cvv"])
176
+ with self.assertRaisesRegex(ValueError, "No change detected"):
177
+ self.service.update_card(
178
+ card["card_number"],
179
+ {
180
+ "account_id": 1,
181
+ "embossed_name": "trace holder",
182
+ "active_status": "N",
183
+ "expiration_month": "12",
184
+ "expiration_year": "2030",
185
+ },
186
+ )
187
+ self.assertNotEqual((old_year, old_month), ("2030", "12"))
188
+
189
+ def test_card_update_rejects_ccup_screen_edge_cases(self) -> None:
190
+ card = self.service.get_account_bundle(1)["cards"][0]
191
+ with self.assertRaisesRegex(ValueError, "Card name can only contain alphabets"):
192
+ self.service.update_card(card["card_number"], {"embossed_name": "Bad123"})
193
+ with self.assertRaisesRegex(ValueError, "Card Active Status must be Y or N"):
194
+ self.service.update_card(card["card_number"], {"active_status": "X"})
195
+ with self.assertRaisesRegex(ValueError, "Card expiry month must be between 1 and 12"):
196
+ self.service.update_card(card["card_number"], {"expiration_month": "13"})
197
+ with self.assertRaisesRegex(ValueError, "Invalid card expiry year"):
198
+ self.service.update_card(card["card_number"], {"expiration_year": "2100"})
199
+
200
+ def test_account_update_follows_caup_validation_and_rewrite_shape(self) -> None:
201
+ before = self.service.get_account_bundle(1)
202
+ assert before is not None
203
+ account = before["account"]
204
+ updated = self.service.update_account(
205
+ 1,
206
+ {
207
+ "active_status": "N",
208
+ "credit_limit_cents": account["credit_limit_cents"] + 10000,
209
+ "cash_credit_limit_cents": account["cash_credit_limit_cents"] + 5000,
210
+ "group_id": "TRACEGRP",
211
+ "customer": {"zip_code": "27514"},
212
+ },
213
+ )
214
+ self.assertEqual(updated["legacy_transaction"], "CAUP")
215
+ self.assertEqual(updated["legacy_program"], "COACTUPC")
216
+ self.assertEqual(updated["active_status"], "N")
217
+ self.assertEqual(updated["credit_limit_cents"], account["credit_limit_cents"] + 10000)
218
+ self.assertEqual(updated["cash_credit_limit_cents"], account["cash_credit_limit_cents"] + 5000)
219
+ self.assertEqual(updated["group_id"], "TRACEGRP")
220
+ self.assertEqual(updated["customer"]["zip_code"], "27514")
221
+ self.assertIn("credit_limit_cents", updated["updated_account_fields"])
222
+ self.assertIn("zip_code", updated["updated_customer_fields"])
223
+
224
+ with self.assertRaisesRegex(ValueError, "No changes"):
225
+ self.service.update_account(
226
+ 1,
227
+ {
228
+ "active_status": "N",
229
+ "credit_limit_cents": updated["credit_limit_cents"],
230
+ "cash_credit_limit_cents": updated["cash_credit_limit_cents"],
231
+ "group_id": "TRACEGRP",
232
+ "customer": {"zip_code": "27514"},
233
+ },
234
+ )
235
+
236
+ def test_account_update_rejects_caup_screen_edge_cases(self) -> None:
237
+ with self.assertRaisesRegex(ValueError, "Account Status must be Y or N"):
238
+ self.service.update_account(1, {"active_status": "X"})
239
+ with self.assertRaisesRegex(ValueError, "Credit Limit is not valid"):
240
+ self.service.update_account(1, {"credit_limit_cents": "not-money"})
241
+ with self.assertRaisesRegex(ValueError, "State: is not a valid state code"):
242
+ self.service.update_account(1, {"customer": {"state": "ZZ"}})
243
+ with self.assertRaisesRegex(KeyError, "Account ID NOT found"):
244
+ self.service.update_account(999999, {"active_status": "N"})
245
+
246
+ def test_bill_payment_adds_credit_transaction(self) -> None:
247
+ before = self.service.get_account_bundle(1)
248
+ assert before is not None
249
+ before_balance = before["account"]["current_balance_cents"]
250
+ transaction = self.service.bill_payment(1, before_balance)
251
+ after = self.service.get_account_bundle(1)
252
+ assert after is not None
253
+ self.assertEqual(transaction["type_code"], "02")
254
+ self.assertEqual(transaction["category_code"], "0002")
255
+ self.assertEqual(transaction["source"], "POS TERM")
256
+ self.assertEqual(transaction["amount_cents"], before_balance)
257
+ self.assertEqual(after["account"]["current_balance_cents"], 0)
258
+
259
+ def test_bill_payment_rejects_partial_payment_for_legacy_full_pay_flow(self) -> None:
260
+ with self.assertRaises(ValueError):
261
+ self.service.bill_payment(1, 2500)
262
+
263
+ def test_post_transaction_accepts_and_updates_account_and_category_balance(self) -> None:
264
+ before = self.service.get_account_bundle(1)
265
+ assert before is not None
266
+ account = before["account"]
267
+ card_number = before["cards"][0]["card_number"]
268
+ conn = connect(self.db_path)
269
+ try:
270
+ starting_tcatbal = conn.execute(
271
+ """
272
+ SELECT balance_cents FROM transaction_category_balances
273
+ WHERE account_id = ? AND type_code = ? AND category_code = ?
274
+ """,
275
+ (1, "01", "0001"),
276
+ ).fetchone()
277
+ starting_tcatbal_cents = int(starting_tcatbal["balance_cents"]) if starting_tcatbal else 0
278
+ finally:
279
+ conn.close()
280
+ result = self.service.post_transaction(
281
+ {
282
+ "card_number": card_number,
283
+ "amount_cents": 100,
284
+ "type_code": "01",
285
+ "category_code": "0001",
286
+ "source": "TEST",
287
+ "description": "POSTTRAN ACCEPT TEST",
288
+ "merchant_id": "123456789",
289
+ "merchant_name": "POSTTRAN TEST",
290
+ "merchant_city": "BATCH",
291
+ "merchant_zip": "00000",
292
+ "original_timestamp": f"{account['expiration_date']} 00:00:00.000000",
293
+ "processed_timestamp": f"{account['expiration_date']} 00:00:00.000000",
294
+ }
295
+ )
296
+ self.assertTrue(result["accepted"])
297
+ after = self.service.get_account_bundle(1)
298
+ assert after is not None
299
+ self.assertEqual(after["account"]["current_balance_cents"], account["current_balance_cents"] + 100)
300
+ self.assertEqual(after["account"]["current_cycle_credit_cents"], account["current_cycle_credit_cents"] + 100)
301
+ conn = connect(self.db_path)
302
+ try:
303
+ ending_tcatbal = conn.execute(
304
+ """
305
+ SELECT balance_cents FROM transaction_category_balances
306
+ WHERE account_id = ? AND type_code = ? AND category_code = ?
307
+ """,
308
+ (1, "01", "0001"),
309
+ ).fetchone()
310
+ finally:
311
+ conn.close()
312
+ assert ending_tcatbal is not None
313
+ self.assertEqual(int(ending_tcatbal["balance_cents"]), starting_tcatbal_cents + 100)
314
+
315
+ def test_post_transaction_rejects_invalid_overlimit_and_expired_cases(self) -> None:
316
+ before = self.service.get_account_bundle(1)
317
+ assert before is not None
318
+ account = before["account"]
319
+ card_number = before["cards"][0]["card_number"]
320
+ invalid = self.service.post_transaction(
321
+ {"card_number": "9999999999999999", "amount_cents": 100},
322
+ reject_on_failure=False,
323
+ )
324
+ self.assertFalse(invalid["accepted"])
325
+ self.assertEqual(invalid["validation"]["reason_code"], 100)
326
+ overlimit = self.service.post_transaction(
327
+ {
328
+ "card_number": card_number,
329
+ "amount_cents": account["credit_limit_cents"] + 1,
330
+ "original_timestamp": f"{account['expiration_date']} 00:00:00.000000",
331
+ },
332
+ reject_on_failure=False,
333
+ )
334
+ self.assertFalse(overlimit["accepted"])
335
+ self.assertEqual(overlimit["validation"]["reason_code"], 102)
336
+ expired = self.service.post_transaction(
337
+ {
338
+ "card_number": card_number,
339
+ "amount_cents": 1,
340
+ "original_timestamp": "2099-01-01 00:00:00.000000",
341
+ },
342
+ reject_on_failure=False,
343
+ )
344
+ self.assertFalse(expired["accepted"])
345
+ self.assertEqual(expired["validation"]["reason_code"], 103)
346
+
347
+ def test_transaction_add_follows_ct02_validation_and_transact_write(self) -> None:
348
+ before = self.service.get_account_bundle(1)
349
+ assert before is not None
350
+ before_balance = before["account"]["current_balance_cents"]
351
+ transaction = self.service.add_transaction(
352
+ {
353
+ "account_id": 1,
354
+ "type_code": "01",
355
+ "category_code": "0001",
356
+ "source": "POS TERM",
357
+ "description": "CT02 SOURCE VALIDATION",
358
+ "amount_cents": -1234,
359
+ "original_timestamp": "2022-01-30",
360
+ "processed_timestamp": "2022-01-31",
361
+ "merchant_id": "123456789",
362
+ "merchant_name": "CT02 MERCHANT",
363
+ "merchant_city": "SEATTLE",
364
+ "merchant_zip": "98101",
365
+ "confirm": "Y",
366
+ }
367
+ )
368
+ after = self.service.get_account_bundle(1)
369
+ assert after is not None
370
+ self.assertEqual(transaction["legacy_transaction"], "CT02")
371
+ self.assertEqual(transaction["legacy_program"], "COTRN02C")
372
+ self.assertEqual(transaction["account_id"], 1)
373
+ self.assertEqual(transaction["legacy_amount"], "-00000012.34")
374
+ self.assertEqual(transaction["original_timestamp"], "2022-01-30")
375
+ self.assertEqual(after["account"]["current_balance_cents"], before_balance)
376
+ self.assertTrue(any(row["transaction_id"] == transaction["transaction_id"] for row in after["transactions"]))
377
+
378
+ def test_transaction_add_rejects_ct02_screen_edge_cases(self) -> None:
379
+ base = {
380
+ "card_number": self.service.get_account_bundle(1)["cards"][0]["card_number"],
381
+ "type_code": "01",
382
+ "category_code": "0001",
383
+ "source": "POS TERM",
384
+ "description": "CT02 REJECT TEST",
385
+ "amount": "+00000012.34",
386
+ "original_timestamp": "2022-01-30",
387
+ "processed_timestamp": "2022-01-31",
388
+ "merchant_id": "123456789",
389
+ "merchant_name": "CT02 MERCHANT",
390
+ "merchant_city": "SEATTLE",
391
+ "merchant_zip": "98101",
392
+ }
393
+ with self.assertRaisesRegex(ValueError, "Confirm to add"):
394
+ self.service.add_transaction(base)
395
+ with self.assertRaisesRegex(ValueError, "Amount should be"):
396
+ self.service.add_transaction({**base, "amount": "12.34", "confirm": "Y"})
397
+ with self.assertRaisesRegex(ValueError, "Proc Date - Not a valid date"):
398
+ self.service.add_transaction({**base, "processed_timestamp": "2022-02-31", "confirm": "Y"})
399
+ with self.assertRaisesRegex(ValueError, "Merchant ID must be Numeric"):
400
+ self.service.add_transaction({**base, "merchant_id": "ABC", "confirm": "Y"})
401
+
402
+ def test_transaction_type_list_follows_ctli_cursor_filters(self) -> None:
403
+ first_page = self.service.transaction_types(page_size=3)
404
+ self.assertEqual(first_page["legacy_transaction"], "CTLI")
405
+ self.assertEqual(first_page["legacy_program"], "COTRTLIC")
406
+ self.assertEqual(first_page["page"]["page_size"], 3)
407
+ self.assertEqual([row["type_code"] for row in first_page["types"]], ["01", "02", "03"])
408
+ self.assertEqual(first_page["page"]["next_start_key"], "04")
409
+
410
+ next_page = self.service.transaction_types(start_key=first_page["page"]["next_start_key"], page_size=3)
411
+ self.assertEqual([row["type_code"] for row in next_page["types"]], ["04", "05", "06"])
412
+
413
+ previous_page = self.service.transaction_types(start_key="07", direction="backward", page_size=3)
414
+ self.assertEqual([row["type_code"] for row in previous_page["types"]], ["04", "05", "06"])
415
+
416
+ type_filtered = self.service.transaction_types(type_filter="1")
417
+ self.assertEqual([row["type_code"] for row in type_filtered["types"]], ["01"])
418
+
419
+ description_filtered = self.service.transaction_types(description_filter="%PAYMENT%")
420
+ self.assertGreaterEqual(len(description_filtered["types"]), 1)
421
+ self.assertTrue(all("PAYMENT" in row["description"].upper() for row in description_filtered["types"]))
422
+
423
+ def test_transaction_type_maintenance_follows_cttu_validation_and_write_shape(self) -> None:
424
+ inserted = self.service.upsert_transaction_type({"type_code": "8", "description": "Manual Review"})
425
+ self.assertEqual(inserted["legacy_transaction"], "CTTU")
426
+ self.assertEqual(inserted["legacy_program"], "COTRTUPC")
427
+ self.assertEqual(inserted["type_code"], "08")
428
+ self.assertEqual(inserted["action"], "inserted")
429
+
430
+ updated = self.service.upsert_transaction_type({"type_code": "08", "description": "Manual Review 2"})
431
+ self.assertEqual(updated["action"], "updated")
432
+ self.assertEqual(updated["description"], "Manual Review 2")
433
+ with self.assertRaisesRegex(ValueError, "No change detected"):
434
+ self.service.upsert_transaction_type({"type_code": "08", "description": "manual review 2"})
435
+
436
+ deleted = self.service.delete_transaction_type("08")
437
+ self.assertTrue(deleted["deleted"])
438
+ with self.assertRaisesRegex(KeyError, "No record found"):
439
+ self.service.delete_transaction_type("08")
440
+
441
+ def test_transaction_type_maintenance_rejects_cttu_screen_edge_cases(self) -> None:
442
+ with self.assertRaisesRegex(ValueError, "Tran Type code must be supplied"):
443
+ self.service.upsert_transaction_type({"type_code": "", "description": "Valid Desc"})
444
+ with self.assertRaisesRegex(ValueError, "Tran Type code must be numeric"):
445
+ self.service.upsert_transaction_type({"type_code": "A1", "description": "Valid Desc"})
446
+ with self.assertRaisesRegex(ValueError, "Tran Type code must not be zero"):
447
+ self.service.upsert_transaction_type({"type_code": "00", "description": "Valid Desc"})
448
+ with self.assertRaisesRegex(ValueError, "Transaction Desc must be supplied"):
449
+ self.service.upsert_transaction_type({"type_code": "08", "description": ""})
450
+ with self.assertRaisesRegex(ValueError, "Transaction Desc can have numbers or alphabets only"):
451
+ self.service.upsert_transaction_type({"type_code": "08", "description": "Bad-Desc"})
452
+ with self.assertRaisesRegex(ValueError, "Please delete associated child records first"):
453
+ self.service.delete_transaction_type("01")
454
+
455
+ def test_batch_transaction_type_maintenance_follows_mnttrdb2_fixed_record_flow(self) -> None:
456
+ result = self.service.maintain_transaction_types(
457
+ [
458
+ "*COMMENT".ljust(53),
459
+ "A09" + "Batch Review".ljust(50),
460
+ "U09" + "Batch Review 2".ljust(50),
461
+ "D09" + "".ljust(50),
462
+ ]
463
+ )
464
+
465
+ self.assertEqual(result["legacy_job"], "MNTTRDB2")
466
+ self.assertEqual(result["legacy_program"], "COBTUPDT")
467
+ self.assertEqual(result["legacy_driver"], "IKJEFT01")
468
+ self.assertEqual(result["input_dd"], "INPFILE")
469
+ self.assertEqual(result["return_code"], 0)
470
+ self.assertEqual(result["counts"]["input_record_count"], 4)
471
+ self.assertEqual(result["counts"]["comment_count"], 1)
472
+ self.assertEqual(result["counts"]["applied_count"], 3)
473
+ self.assertEqual([row["status"] for row in result["actions"]], ["comment_ignored", "inserted", "updated", "deleted"])
474
+ conn = connect(self.db_path)
475
+ try:
476
+ self.assertIsNone(
477
+ conn.execute("SELECT type_code FROM transaction_types WHERE type_code = '09'").fetchone()
478
+ )
479
+ finally:
480
+ conn.close()
481
+
482
+ def test_batch_transaction_type_maintenance_reports_cobol_return_code_for_errors(self) -> None:
483
+ result = self.service.maintain_transaction_types(
484
+ [
485
+ "X09" + "Bad Action".ljust(50),
486
+ "U98" + "Missing Update".ljust(50),
487
+ "D98" + "".ljust(50),
488
+ "A01" + "Duplicate Purchase".ljust(50),
489
+ "D01" + "".ljust(50),
490
+ ]
491
+ )
492
+
493
+ self.assertEqual(result["return_code"], 4)
494
+ self.assertEqual(result["counts"]["applied_count"], 0)
495
+ self.assertEqual(result["counts"]["error_count"], 5)
496
+ messages = [row["message"] for row in result["actions"]]
497
+ self.assertIn("ERROR: TYPE NOT VALID", messages)
498
+ self.assertIn("No records found.", messages)
499
+ self.assertIn("Error accessing: TRANSACTION_TYPE table. SQLCODE:-803", messages)
500
+ self.assertIn("Error accessing: TRANSACTION_TYPE table. SQLCODE:-532", messages)
501
+
502
+ def test_transaction_report_groups_seed_data_by_account(self) -> None:
503
+ report = self.service.transaction_report(account_id=1, limit=1000)
504
+ self.assertEqual(report["legacy_job"], "TRANREPT")
505
+ self.assertGreater(report["totals"]["transaction_count"], 0)
506
+ self.assertTrue(all(row["account_id"] == 1 for row in report["rows"]))
507
+ self.assertEqual(
508
+ report["totals"]["total_amount_cents"],
509
+ sum(row["amount_cents"] for row in report["rows"]),
510
+ )
511
+
512
+ def test_account_statement_materializes_legacy_sections(self) -> None:
513
+ statement = self.service.account_statement(1)
514
+ self.assertEqual(statement["legacy_job"], "CREASTMT")
515
+ self.assertEqual(statement["legacy_programs"], ["CBSTM03A", "CBSTM03B"])
516
+ self.assertEqual(statement["source_sort_key"], "card_number,transaction_id")
517
+ self.assertIn("START OF STATEMENT", statement["plain_text_lines"][0])
518
+ self.assertIn("END OF STATEMENT", statement["plain_text_lines"][-1])
519
+ self.assertTrue(all(len(line) == statement["statement_lines_lrecl"] for line in statement["plain_text_lines"]))
520
+ self.assertTrue(all(len(line) <= statement["html_lines_lrecl"] for line in statement["html_lines"]))
521
+ self.assertGreater(statement["transaction_count"], 0)
522
+ self.assertEqual(statement["transaction_count"], len(statement["statement_rows"]))
523
+ self.assertEqual(
524
+ statement["total_expense_cents"],
525
+ sum(row["amount_cents"] for row in statement["statement_rows"]),
526
+ )
527
+ sort_keys = [(row["card_number"], row["transaction_id"]) for row in statement["statement_rows"]]
528
+ self.assertEqual(sort_keys, sorted(sort_keys))
529
+
530
+ def test_interest_projection_uses_disclosure_rates_and_formula(self) -> None:
531
+ projection = self.service.interest_projection(limit=20)
532
+ self.assertEqual(projection["legacy_job"], "INTCALC")
533
+ self.assertGreater(len(projection["rows"]), 0)
534
+ first = projection["rows"][0]
535
+ expected = int(
536
+ (first["balance_cents"] * first["interest_rate_basis_points"]) / 120000
537
+ )
538
+ self.assertEqual(first["monthly_interest_cents"], expected)
539
+ self.assertEqual(projection["generated_transactions"][0]["type_code"], "01")
540
+ self.assertEqual(projection["generated_transactions"][0]["category_code"], "0005")
541
+
542
+ def test_transaction_master_backup_models_tranbkp_repro_and_ksds_redefine(self) -> None:
543
+ backup = self.service.transaction_master_backup(limit=5)
544
+ self.assertEqual(backup["legacy_job"], "TRANBKP")
545
+ self.assertEqual(backup["legacy_proc"], "REPROC")
546
+ self.assertEqual(backup["source_dataset"], "AWS.M2.CARDDEMO.TRANSACT.VSAM.KSDS")
547
+ self.assertEqual(backup["backup_dataset"], "AWS.M2.CARDDEMO.TRANSACT.BKUP(+1)")
548
+ self.assertEqual(backup["define_cluster"]["keys"], {"length": 16, "offset": 0})
549
+ self.assertEqual(backup["define_cluster"]["record_size"], {"min": 350, "max": 350})
550
+ self.assertEqual(backup["record_count"], 300)
551
+ self.assertEqual(len(backup["preview_records"]), 5)
552
+ self.assertTrue(all(row["record_length"] == 350 for row in backup["preview_records"]))
553
+ keys = [row["key"] for row in backup["preview_records"]]
554
+ self.assertEqual(keys, sorted(keys))
555
+
556
+ def test_transaction_type_extract_models_tranextr_dsntiaul_records(self) -> None:
557
+ extract = self.service.transaction_type_extract()
558
+ self.assertEqual(extract["legacy_job"], "TRANEXTR")
559
+ self.assertEqual(extract["legacy_program"], "DSNTIAUL")
560
+ self.assertEqual(extract["legacy_plan"], "DSNTIAUL")
561
+ self.assertEqual(extract["lrecl"], 60)
562
+ self.assertEqual(extract["counts"]["transaction_types"], 7)
563
+ self.assertEqual(extract["counts"]["transaction_categories"], 18)
564
+ type_records = extract["records"]["transaction_types"]
565
+ category_records = extract["records"]["transaction_categories"]
566
+ self.assertTrue(all(len(record) == 60 for record in type_records + category_records))
567
+ self.assertEqual(type_records[0][:2], "01")
568
+ self.assertTrue(type_records[0].endswith("0" * 8))
569
+ self.assertEqual(category_records[0][:6], "010001")
570
+ self.assertTrue(category_records[0].endswith("0" * 4))
571
+
572
+ def test_db2_reference_setup_models_creadb21_schema_and_loads(self) -> None:
573
+ setup = self.service.db2_reference_setup()
574
+ self.assertEqual(setup["legacy_job"], "CREADB21")
575
+ self.assertEqual(setup["legacy_jcl_job"], "CREADB2")
576
+ self.assertEqual(setup["db2_system"], "DAZ1")
577
+ self.assertEqual(setup["database"]["name"], "CARDDEMO")
578
+ self.assertEqual([step["step"] for step in setup["steps"]], ["FREEPLN", "CRCRDDB", "RUNTEP2", "LDTCCAT"])
579
+ self.assertEqual(setup["tables"]["transaction_type"]["load_count"], 7)
580
+ self.assertEqual(setup["tables"]["transaction_type_category"]["load_count"], 18)
581
+ self.assertEqual(
582
+ setup["tables"]["transaction_type_category"]["foreign_key"]["references"],
583
+ "CARDDEMO.TRANSACTION_TYPE(TR_TYPE)",
584
+ )
585
+ self.assertEqual(setup["tables"]["transaction_type_category"]["foreign_key"]["on_delete"], "RESTRICT")
586
+
587
+ def test_mq_system_date_cdrd_formats_source_reply(self) -> None:
588
+ result = self.service.mq_system_date({"request_message": "ANYTHING"}, now="2026-05-23T11:12:13")
589
+ self.assertEqual(result["legacy_transaction"], "CDRD")
590
+ self.assertEqual(result["legacy_program"], "CODATE01")
591
+ self.assertEqual(result["reply_queue"], "CARD.DEMO.REPLY.DATE")
592
+ self.assertEqual(result["system_date"], "05-23-2026")
593
+ self.assertEqual(result["system_time"], "11:12:13")
594
+ self.assertEqual(result["reply_message"], "SYSTEM DATE : 05-23-2026SYSTEM TIME : 11:12:13")
595
+
596
+ def test_mq_account_inquiry_cdra_reads_account_and_rejects_invalid_requests(self) -> None:
597
+ result = self.service.mq_account_inquiry({"function": "INQA", "account_id": 1})
598
+ self.assertEqual(result["legacy_transaction"], "CDRA")
599
+ self.assertEqual(result["legacy_program"], "COACCT01")
600
+ self.assertTrue(result["valid_request"])
601
+ self.assertEqual(result["request"]["account_id_text"], "00000000001")
602
+ self.assertEqual(result["account_data"]["account_id"], 1)
603
+ self.assertIn("ACCOUNT ID : 00000000001", result["reply_message"])
604
+ self.assertIn("ACCOUNT STATUS : Y", result["reply_message"])
605
+ self.assertIn("GROUP ID : ", result["reply_message"])
606
+
607
+ from_raw = self.service.mq_account_inquiry({"request_message": "INQA00000000001"})
608
+ self.assertTrue(from_raw["valid_request"])
609
+ self.assertEqual(from_raw["account_data"]["account_id"], 1)
610
+
611
+ not_found = self.service.mq_account_inquiry({"function": "INQA", "account_id": 99999999999})
612
+ self.assertFalse(not_found["valid_request"])
613
+ self.assertIn("INVALID REQUEST PARAMETERS ACCT ID : 99999999999", not_found["reply_message"])
614
+
615
+ bad_function = self.service.mq_account_inquiry({"function": "BAD", "account_id": 1})
616
+ self.assertFalse(bad_function["valid_request"])
617
+ self.assertIn("FUNCTION : BAD ", bad_function["reply_message"])
618
+
619
+ def test_batch_resource_setup_models_remaining_gdg_vsam_aix_and_cics_jobs(self) -> None:
620
+ setup = self.service.batch_resource_setup()
621
+ self.assertEqual(setup["legacy_jobs"], ["DEFGDGB", "DEFGDGD", "ESDSRRDS", "TRANIDX", "CLOSEFIL", "OPENFIL"])
622
+ self.assertEqual(setup["resource_count"], 6)
623
+
624
+ gdg_base = self.service.batch_resource_setup("DEFGDGB")
625
+ self.assertEqual(len(gdg_base["gdg_bases"]), 6)
626
+ self.assertEqual(gdg_base["gdg_bases"][0]["name"], "AWS.M2.CARDDEMO.TRANSACT.BKUP")
627
+ self.assertEqual(gdg_base["gdg_bases"][0]["limit"], 5)
628
+ self.assertTrue(gdg_base["gdg_bases"][0]["scratch"])
629
+
630
+ db2_gdg = self.service.batch_resource_setup("DEFGDGD")
631
+ self.assertEqual(db2_gdg["steps"][1]["target"], "AWS.M2.CARDDEMO.TRANTYPE.BKUP(+1)")
632
+ self.assertEqual(db2_gdg["steps"][1]["lrecl"], 60)
633
+ self.assertEqual(db2_gdg["steps"][1]["record_count"], 7)
634
+ self.assertEqual(db2_gdg["steps"][5]["record_count"], 51)
635
+
636
+ esds_rrds = self.service.batch_resource_setup("ESDSRRDS")
637
+ self.assertEqual(esds_rrds["instream_user_records"], 10)
638
+ self.assertEqual([cluster["organization"] for cluster in esds_rrds["clusters"]], ["NONINDEXED", "NUMBERED"])
639
+ self.assertEqual(esds_rrds["clusters"][0]["record_size"], [80, 80])
640
+
641
+ tranidx = self.service.batch_resource_setup("TRANIDX")
642
+ self.assertEqual(tranidx["alternate_index"]["keys"], {"length": 26, "offset": 304})
643
+ self.assertEqual(tranidx["path"]["pathentry"], "AWS.M2.CARDDEMO.TRANSACT.VSAM.AIX")
644
+ self.assertEqual(tranidx["bldindex"]["source_record_count"], 300)
645
+
646
+ closefil = self.service.batch_resource_setup("CLOSEFIL")
647
+ openfil = self.service.batch_resource_setup("OPENFIL")
648
+ self.assertEqual(closefil["cemt_code"], "CLO")
649
+ self.assertEqual(openfil["cemt_code"], "OPE")
650
+ self.assertEqual(closefil["files"], ["TRANSACT", "CCXREF", "ACCTDAT", "CXACAIX", "USRSEC"])
651
+ self.assertEqual(openfil["files"], closefil["files"])
652
+
653
+ def test_pending_authorization_summary_and_detail_use_ims_seed(self) -> None:
654
+ summary = self.service.pending_authorization_summary(1, page_size=5)
655
+ self.assertEqual(summary["legacy_transaction"], "CPVS")
656
+ self.assertEqual(summary["summary"]["approved_auth_count"], 6)
657
+ self.assertEqual(summary["summary"]["approved_auth_amount_cents"], 944)
658
+ self.assertEqual(len(summary["authorizations"]), 5)
659
+ self.assertTrue(summary["next_page"])
660
+
661
+ first = summary["authorizations"][0]
662
+ detail = self.service.pending_authorization_detail(1, authorization_key=first["authorization_key"])
663
+ self.assertEqual(detail["legacy_transaction"], "CPVD")
664
+ self.assertEqual(detail["authorization"]["transaction_id"], "960b9b5480d045a")
665
+ self.assertEqual(detail["authorization"]["authorization_date"], "10/27/23")
666
+ self.assertEqual(detail["authorization"]["authorization_response"], "A")
667
+
668
+ def test_authorization_request_updates_summary_and_inserts_detail(self) -> None:
669
+ before = self.service.pending_authorization_summary(1, page_size=1)
670
+ result = self.service.process_authorization_request(
671
+ {
672
+ "card_number": "9680294154603697",
673
+ "auth_date": "260523",
674
+ "auth_time": "111213",
675
+ "card_expiry_date": "1129",
676
+ "transaction_amount_cents": 100,
677
+ "merchant_category_code": "5442",
678
+ "merchant_id": "123501000675423",
679
+ "merchant_name": "Amazon.com",
680
+ "merchant_city": "Wilmington",
681
+ "merchant_state": "DE",
682
+ "merchant_zip": "19801",
683
+ "transaction_id": "AUTHREQ00000001",
684
+ "processing_datetime": "2026-05-23T11:12:13.456",
685
+ }
686
+ )
687
+ self.assertEqual(result["legacy_transaction"], "CP00")
688
+ self.assertTrue(result["approved"])
689
+ self.assertEqual(result["response"]["auth_resp_code"], "00")
690
+ self.assertTrue(result["written_to_pending_authorizations"])
691
+
692
+ after = self.service.pending_authorization_summary(1, page_size=1)
693
+ self.assertEqual(after["summary"]["approved_auth_count"], before["summary"]["approved_auth_count"] + 1)
694
+ detail = self.service.pending_authorization_detail(1, transaction_id="AUTHREQ00000001")
695
+ self.assertEqual(detail["authorization"]["approved_amount_cents"], 100)
696
+ self.assertEqual(detail["authorization"]["auth_id_code"], "111213")
697
+
698
+ def test_authorization_declines_invalid_card_without_write(self) -> None:
699
+ result = self.service.process_authorization_request(
700
+ {
701
+ "card_number": "9999999999999999",
702
+ "transaction_amount_cents": 100,
703
+ "transaction_id": "AUTHREQBAD0001",
704
+ }
705
+ )
706
+ self.assertFalse(result["approved"])
707
+ self.assertEqual(result["response"]["auth_resp_code"], "05")
708
+ self.assertEqual(result["response"]["auth_resp_reason"], "3100")
709
+ self.assertFalse(result["written_to_pending_authorizations"])
710
+
711
+ def test_authorization_fraud_mark_writes_authfrds_shadow_table(self) -> None:
712
+ summary = self.service.pending_authorization_summary(1, page_size=1)
713
+ auth_key = summary["authorizations"][0]["authorization_key"]
714
+ result = self.service.mark_authorization_fraud(1, auth_key, action="report", report_date="20260523")
715
+ self.assertEqual(result["legacy_program"], "COPAUS1C/COPAUS2C")
716
+ self.assertEqual(result["fraud_status"], "F")
717
+ detail = self.service.pending_authorization_detail(1, authorization_key=auth_key)
718
+ self.assertEqual(detail["authorization"]["auth_fraud"], "F")
719
+ conn = connect(self.db_path)
720
+ try:
721
+ count = conn.execute("SELECT COUNT(*) FROM authorization_frauds").fetchone()[0]
722
+ finally:
723
+ conn.close()
724
+ self.assertEqual(count, 1)
725
+
726
+ def test_purge_expired_authorizations_dry_run_and_apply(self) -> None:
727
+ dry_run = self.service.purge_expired_authorizations(current_yyddd=23305, expiry_days=5, dry_run=True)
728
+ self.assertEqual(dry_run["legacy_job"], "CBPAUP0J")
729
+ self.assertGreater(dry_run["purged_count"], 0)
730
+ applied = self.service.purge_expired_authorizations(current_yyddd=23305, expiry_days=5)
731
+ self.assertGreater(applied["purged_count"], 0)
732
+ with self.assertRaises(KeyError):
733
+ self.service.pending_authorization_summary(1, page_size=10)
734
+
735
+ def test_combined_transactions_includes_seed_and_interest_previews(self) -> None:
736
+ combined = self.service.combined_transactions(limit=1000)
737
+ self.assertEqual(combined["legacy_job"], "COMBTRAN")
738
+ self.assertEqual(combined["source_datasets"][0], "AWS.M2.CARDDEMO.TRANSACT.BKUP(0)")
739
+ self.assertEqual(combined["source_datasets"][1], "AWS.M2.CARDDEMO.SYSTRAN(0)")
740
+ self.assertEqual(combined["sort"]["symbol"], "TRAN-ID")
741
+ self.assertEqual(combined["sort"]["start"], 1)
742
+ self.assertEqual(combined["sort"]["length"], 16)
743
+ self.assertEqual(combined["sort"]["order"], "A")
744
+ self.assertEqual(combined["sortout_dataset"], "AWS.M2.CARDDEMO.TRANSACT.COMBINED(+1)")
745
+ self.assertEqual(combined["repro_target"], "AWS.M2.CARDDEMO.TRANSACT.VSAM.KSDS")
746
+ self.assertEqual(combined["source_counts"]["transaction_master"], 300)
747
+ self.assertGreater(combined["source_counts"]["interest_projection"], 0)
748
+ self.assertEqual(
749
+ combined["source_counts"]["total_combined"],
750
+ combined["source_counts"]["transaction_master"] + combined["source_counts"]["interest_projection"],
751
+ )
752
+ self.assertEqual(combined["source_counts"]["returned"], len(combined["rows"]))
753
+ transaction_ids = [row["transaction_id"] for row in combined["rows"]]
754
+ self.assertEqual(transaction_ids, sorted(transaction_ids))
755
+
756
+
757
+ if __name__ == "__main__":
758
+ unittest.main()
modern_code/tests/test_static_oracle_replay.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ import tempfile
5
+ import unittest
6
+ from pathlib import Path
7
+
8
+ from tools.replay_static_oracles import build_static_oracle_replay, write_json
9
+
10
+
11
+ ROOT = Path(__file__).resolve().parents[2]
12
+ SOURCE = ROOT / "source"
13
+
14
+
15
+ class StaticOracleReplayTests(unittest.TestCase):
16
+ def setUp(self) -> None:
17
+ self.tmp = tempfile.TemporaryDirectory()
18
+ self.tmp_path = Path(self.tmp.name)
19
+ self.db_path = self.tmp_path / "static_oracle_replay.sqlite"
20
+
21
+ def tearDown(self) -> None:
22
+ self.tmp.cleanup()
23
+
24
+ def test_static_oracle_replay_executes_modern_service_against_trace_expectations(self) -> None:
25
+ report = build_static_oracle_replay(SOURCE, self.db_path, source_head="test-source-head")
26
+
27
+ self.assertTrue(report["passed"], report["failed_checks"])
28
+ self.assertEqual(report["capability_count"], 50)
29
+ self.assertEqual(report["grade_counts"], {"A": 0, "B": 50, "C": 0, "F": 0})
30
+ self.assertEqual(report["gap_count"], 0)
31
+ self.assertEqual(report["runtime_probe_count"], 6)
32
+ self.assertFalse(report["public_actions_allowed"])
33
+ self.assertIn("no live COBOL/CICS runtime replay", report["claim_limit"])
34
+ self.assertEqual(len(report["replay_hash"]), 64)
35
+
36
+ probes = {row["trace_id"]: row for row in report["runtime_probes"]}
37
+ self.assertEqual(
38
+ probes["mq_system_date_cdrd_reply"]["actual"]["reply_message"],
39
+ "SYSTEM DATE : 05-23-2026SYSTEM TIME : 11:12:13",
40
+ )
41
+ self.assertTrue(probes["mq_account_inquiry_cdra_success_and_invalid"]["actual"]["reply_has_account_label"])
42
+ self.assertEqual(
43
+ probes["batch_resource_setup_gdg_vsam_aix_cics"]["actual"]["tranidx_keys"],
44
+ {"length": 26, "offset": 304},
45
+ )
46
+ self.assertEqual(
47
+ probes["pending_authorization_cp00_request_response_and_insert"]["actual"]["approved_count_delta"],
48
+ 1,
49
+ )
50
+
51
+ output_path = write_json(self.tmp_path / "static_oracle_replay.json", report)
52
+ loaded = json.loads(output_path.read_text(encoding="utf-8"))
53
+ self.assertEqual(loaded["replay_hash"], report["replay_hash"])
54
+
55
+
56
+ if __name__ == "__main__":
57
+ unittest.main()
modern_code/tools/build_hf_public_bundle.py ADDED
@@ -0,0 +1,394 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import hashlib
5
+ import json
6
+ import shutil
7
+ from datetime import datetime, timezone
8
+ from pathlib import Path
9
+ from typing import Any
10
+
11
+
12
+ SOURCE_REMOTE = "https://github.com/aws-samples/aws-mainframe-modernization-carddemo.git"
13
+ SOURCE_HEAD = "59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e"
14
+ BUNDLE_VERSION = "carddemo_hf_public_bundle_v0"
15
+ DEFAULT_REPO_ID = "cjc0013/aws-carddemo-no-cost-modernization-proof"
16
+ EXCLUDE_DIRS = {"__pycache__", ".dettools_backups", ".dettools_checkpoints", ".git", "final_proof", "reports"}
17
+ EXCLUDE_SUFFIXES = {".pyc", ".sqlite", ".db", ".log"}
18
+ FINAL_PROOF_FILES = [
19
+ "FINAL_PROOF_README.md",
20
+ "FINAL_RECEIPT_SUMMARY.json",
21
+ "REPRO_COMMANDS.txt",
22
+ "STATIC_ORACLE_REPLAY_REPORT.json",
23
+ "KNOWN_LIMITS.md",
24
+ "ARTIFACT_MANIFEST.json",
25
+ "A_GRADE_PROMOTION_REPORT.json",
26
+ "A_GRADE_PROMOTION_README.md",
27
+ "NO_COST_CONFIDENCE_REPORT.json",
28
+ "NO_COST_CONFIDENCE_README.md",
29
+ "CLEAN_REPRO_VERIFICATION.json",
30
+ ]
31
+
32
+
33
+ def read_json(path: Path) -> Any:
34
+ return json.loads(path.read_text(encoding="utf-8"))
35
+
36
+
37
+ def write_json(path: Path, payload: Any) -> None:
38
+ path.parent.mkdir(parents=True, exist_ok=True)
39
+ path.write_text(json.dumps(payload, indent=2, sort_keys=True, default=str) + "\n", encoding="utf-8")
40
+
41
+
42
+ def write_text(path: Path, text: str) -> None:
43
+ path.parent.mkdir(parents=True, exist_ok=True)
44
+ path.write_text(text.strip() + "\n", encoding="utf-8")
45
+
46
+
47
+ def sha256_path(path: Path) -> str:
48
+ digest = hashlib.sha256()
49
+ with path.open("rb") as handle:
50
+ for chunk in iter(lambda: handle.read(1024 * 1024), b""):
51
+ digest.update(chunk)
52
+ return digest.hexdigest()
53
+
54
+
55
+ def stable_hash(payload: Any) -> str:
56
+ return hashlib.sha256(json.dumps(payload, sort_keys=True, default=str).encode("utf-8")).hexdigest()
57
+
58
+
59
+ def clean_dir(path: Path) -> None:
60
+ resolved = path.resolve()
61
+ if resolved.anchor == str(resolved):
62
+ raise ValueError(f"Refusing to clear drive root: {resolved}")
63
+ if resolved.exists():
64
+ shutil.rmtree(resolved)
65
+ resolved.mkdir(parents=True, exist_ok=True)
66
+
67
+
68
+ def should_copy_modern_file(path: Path, modern_root: Path) -> bool:
69
+ rel = path.resolve().relative_to(modern_root.resolve())
70
+ if any(part in EXCLUDE_DIRS for part in rel.parts):
71
+ return False
72
+ if path.suffix.lower() in EXCLUDE_SUFFIXES:
73
+ return False
74
+ if rel.parts and rel.parts[0].startswith(".dettools"):
75
+ return False
76
+ return path.is_file()
77
+
78
+
79
+ def copy_tree_filtered(src_root: Path, dst_root: Path) -> list[dict[str, Any]]:
80
+ copied = []
81
+ for path in sorted(src_root.rglob("*")):
82
+ if not should_copy_modern_file(path, src_root):
83
+ continue
84
+ rel = path.resolve().relative_to(src_root.resolve())
85
+ target = dst_root / rel
86
+ target.parent.mkdir(parents=True, exist_ok=True)
87
+ shutil.copy2(path, target)
88
+ copied.append(file_record(target, dst_root))
89
+ return copied
90
+
91
+
92
+ def file_record(path: Path, base: Path) -> dict[str, Any]:
93
+ return {
94
+ "path": str(path.resolve().relative_to(base.resolve())).replace("\\", "/"),
95
+ "size_bytes": path.stat().st_size,
96
+ "sha256": sha256_path(path),
97
+ }
98
+
99
+
100
+ def collect_files(root: Path) -> list[dict[str, Any]]:
101
+ return [file_record(path, root) for path in sorted(root.rglob("*")) if path.is_file()]
102
+
103
+
104
+ def copy_final_proof(modern_root: Path, bundle_root: Path) -> list[dict[str, Any]]:
105
+ src = modern_root / "final_proof"
106
+ dst = bundle_root / "final_proof"
107
+ copied = []
108
+ for name in FINAL_PROOF_FILES:
109
+ source = src / name
110
+ if not source.exists():
111
+ continue
112
+ target = dst / name
113
+ target.parent.mkdir(parents=True, exist_ok=True)
114
+ shutil.copy2(source, target)
115
+ copied.append(file_record(target, bundle_root))
116
+ return copied
117
+
118
+
119
+ def build_readme(summary: dict[str, Any], no_cost: dict[str, Any], repo_id: str) -> str:
120
+ no_cost_summary = no_cost["no_cost_confidence_summary"]
121
+ coverage = no_cost["capability_coverage"]
122
+ a_gate = summary["a_grade_promotion"]
123
+ return f"""---
124
+ license: other
125
+ language:
126
+ - en
127
+ tags:
128
+ - mainframe-modernization
129
+ - cobol
130
+ - cics
131
+ - static-analysis
132
+ - verification
133
+ - reproducibility
134
+ - legacy-modernization
135
+ pretty_name: AWS CardDemo No-Cost Modernization Proof
136
+ ---
137
+
138
+ # AWS CardDemo No-Cost Modernization Proof
139
+
140
+ This repository publishes a reproducible proof bundle for a local modernization run against AWS CardDemo. It is intentionally **not** a claim of live COBOL/CICS all-path runtime equivalence.
141
+
142
+ Plainly: this is not a claim of live COBOL/CICS all-path runtime equivalence.
143
+
144
+ The practical claim is narrower and receipt-backed: we pushed the free/no-cost verification path as far as we reasonably could. The remaining validation requires a real or licensed-compatible legacy runtime for COBOL/CICS/VSAM/JCL execution.
145
+
146
+ In short: without paid/licensed legacy runtime access, this is as far as this proof can honestly go.
147
+
148
+ ## Headline Result
149
+
150
+ - Reviewer posture: `{no_cost_summary['reviewer_posture']}`
151
+ - Ready for pre-runtime review: `{no_cost_summary['ready_for_pre_runtime_review']}`
152
+ - Current static/source-oracle parity: `B={summary['parity']['B']} / F={summary['parity']['F']} / gaps={summary['parity']['gap_count']}`
153
+ - A-grade live runtime parity: `A={summary['parity']['grade_counts'].get('A', 0)}`
154
+ - A-grade promotion gate: `{a_gate['decision_action']}`
155
+ - A-grade live matches accepted: `{a_gate['accepted_live_matches']}`
156
+ - A-grade live matches missing: `{a_gate['missing_live_matches']}`
157
+ - Paid runtime used: `{no_cost['no_cost_scope']['paid_runtime_used']}`
158
+ - Legacy runtime equivalence claimed: `{no_cost['no_cost_scope']['legacy_runtime_claim_made']}`
159
+
160
+ ## Source Identity
161
+
162
+ - Upstream source repo: `{SOURCE_REMOTE}`
163
+ - Upstream source commit: `{SOURCE_HEAD}`
164
+ - Source files hashed in receipt: `{summary['source']['source_hash_count']}`
165
+ - Source hash digest: `{summary['source']['source_hashes_digest']}`
166
+
167
+ The upstream AWS CardDemo source tree is **not copied into this repository**. Clone it from the upstream project at the exact commit above when reproducing.
168
+
169
+ ## Evidence Included
170
+
171
+ - `final_proof/FINAL_PROOF_README.md`: technical reviewer entry point.
172
+ - `final_proof/FINAL_RECEIPT_SUMMARY.json`: machine-readable receipt summary.
173
+ - `final_proof/NO_COST_CONFIDENCE_REPORT.json`: no-cost confidence evidence and methodology.
174
+ - `final_proof/A_GRADE_PROMOTION_REPORT.json`: strict A-grade gate and why it does not promote without live traces.
175
+ - `final_proof/STATIC_ORACLE_REPLAY_REPORT.json`: executable modern replay over static/source-derived oracles.
176
+ - `METHODOLOGY.md`: evidence method and proof boundaries.
177
+ - `REPRODUCIBILITY.md`: one-command local checks.
178
+ - `DUE_DILIGENCE.md`: quick reviewer checklist.
179
+ - `modern_code/`: modern Python/SQLite implementation snapshot and proof tooling.
180
+
181
+ ## No-Cost Evidence Summary
182
+
183
+ - Capability count: `{coverage['capability_count']}`
184
+ - Static/source-oracle-ready capabilities: `{coverage['static_oracle_ready_count']}`
185
+ - Capability source references: `{coverage['source_ref_total']}`
186
+ - Golden traces: `{no_cost['fixture_corpus']['golden_trace_count']}`
187
+ - Edge cases: `{no_cost['fixture_corpus']['edge_case_count']}`
188
+ - COBOL programs scanned: `{no_cost['legacy_source_semantics_scan']['cobol_program_count']}`
189
+ - CICS programs identified: `{no_cost['legacy_source_semantics_scan']['cics_program_count']}`
190
+ - Free GnuCOBOL probe candidates: `{no_cost['legacy_source_semantics_scan']['free_gnucobol_probe_candidate_count']}`
191
+
192
+ ## The Unpaid Boundary
193
+
194
+ We cannot honestly push this to live runtime parity without access to a real or licensed-compatible legacy execution environment. That means one of:
195
+
196
+ - AWS Mainframe Modernization runtime access,
197
+ - Micro Focus / Enterprise Server-style runtime access,
198
+ - UniKix or equivalent runtime access,
199
+ - a real z/OS/CICS/VSAM/JCL endpoint,
200
+ - or another compatible environment capable of executing the original legacy paths.
201
+
202
+ Without that, the correct remaining statement is: the modernization is strongly supported by source-derived static oracles and executable modern replay, but final production-equivalence validation must happen on the legacy runtime owner’s environment.
203
+
204
+ ## Repository Type
205
+
206
+ This is published as a Hugging Face dataset-style proof artifact, not a trained model and not a hosted runtime.
207
+
208
+ HF repo target used for staging: `{repo_id}`
209
+ """
210
+
211
+
212
+ def build_methodology(summary: dict[str, Any], no_cost: dict[str, Any]) -> str:
213
+ return f"""
214
+ # Methodology
215
+
216
+ ## Goal
217
+
218
+ Produce the strongest practical modernization proof possible without paid or licensed legacy runtime infrastructure.
219
+
220
+ ## Method
221
+
222
+ 1. Pin the upstream AWS CardDemo source repository and commit.
223
+ 2. Hash the source files and generated modern files.
224
+ 3. Extract capabilities from legacy source, copybooks, BMS maps, JCL, seed data, and static contracts.
225
+ 4. Build a one-for-one capability ledger.
226
+ 5. Implement the modern Python/SQLite target against those source-derived contracts.
227
+ 6. Generate receipts, golden traces, edge cases, and parity reports.
228
+ 7. Execute the modern service against static/source-oracle replay checks.
229
+ 8. Run clean-copy reproduction and API smoke checks.
230
+ 9. Run a strict A-grade gate that refuses promotion without live legacy runtime traces.
231
+ 10. Publish the evidence with explicit boundaries.
232
+
233
+ ## Current Proof State
234
+
235
+ - B-grade static/source-oracle capabilities: `{summary['parity']['B']}`
236
+ - F-grade gaps: `{summary['parity']['F']}`
237
+ - Gap count: `{summary['parity']['gap_count']}`
238
+ - Static replay passed: `{summary['static_oracle_replay']['passed']}`
239
+ - No-cost confidence posture: `{no_cost['no_cost_confidence_summary']['reviewer_posture']}`
240
+ - A-grade promotable: `{summary['a_grade_promotion']['promotable_to_A']}`
241
+
242
+ ## What Would Upgrade This To A
243
+
244
+ The A-grade gate requires accepted live legacy runtime trace records for every capability. Each record must bind a capability ID to the pinned source head, a live runtime trace kind, a raw legacy trace hash, a modern observation hash, a comparator version, and `matched=true`.
245
+
246
+ The current bundle has zero accepted live runtime matches because no paid/licensed legacy runtime was executed.
247
+ """
248
+
249
+
250
+ def build_due_diligence(summary: dict[str, Any], repo_id: str) -> str:
251
+ return f"""
252
+ # Basic Due Diligence
253
+
254
+ Clone this HF repository and inspect:
255
+
256
+ 1. `README.md`
257
+ 2. `final_proof/FINAL_PROOF_README.md`
258
+ 3. `final_proof/NO_COST_CONFIDENCE_README.md`
259
+ 4. `final_proof/A_GRADE_PROMOTION_README.md`
260
+
261
+ Then clone the upstream AWS source next to `modern_code`:
262
+
263
+ ```powershell
264
+ git clone {SOURCE_REMOTE} source
265
+ git -C source checkout {SOURCE_HEAD}
266
+ ```
267
+
268
+ From `modern_code`, run:
269
+
270
+ ```powershell
271
+ python -m unittest discover -s tests
272
+ python tools\\replay_static_oracles.py --source-root ..\\source --out-dir .\\reports --source-head {SOURCE_HEAD}
273
+ python tools\\build_no_cost_confidence.py --source-root ..\\source --out-dir .\\final_proof
274
+ python tools\\evaluate_a_grade_promotion.py --source-root ..\\source --out-dir .\\final_proof
275
+ ```
276
+
277
+ Expected high-level result:
278
+
279
+ - tests pass,
280
+ - static replay returns `"passed": true`,
281
+ - no-cost confidence returns `"reviewer_posture": "strong_pre_runtime_confidence"`,
282
+ - A-grade gate returns `"promotable_to_A": false`.
283
+
284
+ That last result is intentional: `{repo_id}` does not claim live COBOL/CICS runtime parity.
285
+ """
286
+
287
+
288
+ def build_reproducibility(summary: dict[str, Any]) -> str:
289
+ source_head = summary["source"]["head"]
290
+ return f"""
291
+ # Reproducibility
292
+
293
+ This bundle is reproducible with no paid legacy runtime, but it still requires cloning the upstream AWS source at the pinned commit.
294
+
295
+ ```powershell
296
+ git clone {SOURCE_REMOTE} source
297
+ git -C source checkout {source_head}
298
+ cd modern_code
299
+ powershell -NoProfile -Command "python -m carddemo.cli init-db --source-root ..\\source --db-path .\\carddemo.sqlite; python -m unittest discover -s tests; python tools\\generate_receipts.py --source-root ..\\source --db-path .\\carddemo.sqlite --out-dir .\\reports; python tools\\replay_static_oracles.py --source-root ..\\source --out-dir .\\reports --source-head {source_head}; python tools\\evaluate_a_grade_promotion.py --source-root ..\\source --out-dir .\\final_proof; python tools\\build_no_cost_confidence.py --source-root ..\\source --out-dir .\\final_proof; python tools\\package_final_proof.py --source-root ..\\source"
300
+ ```
301
+
302
+ For clean-copy reproduction, run:
303
+
304
+ ```powershell
305
+ python tools\\verify_clean_repro.py --modern-root . --source-root ..\\source
306
+ ```
307
+ """
308
+
309
+
310
+ def build_publication_notes() -> str:
311
+ return """
312
+ # Publication Notes
313
+
314
+ - This is a proof artifact, not a production migration recommendation.
315
+ - The original AWS CardDemo source tree is not redistributed here.
316
+ - The modern code snapshot is provided for review of the local modernization artifact.
317
+ - The proof explicitly avoids claiming live COBOL/CICS equivalence.
318
+ - The phrase "strong pre-runtime confidence" means the no-cost checks passed; it does not mean production acceptance.
319
+ - Further proof requires paid/licensed or customer-owned legacy runtime access.
320
+ """
321
+
322
+
323
+ def build_bundle(modern_root: Path, out_dir: Path, repo_id: str) -> dict[str, Any]:
324
+ modern_root = modern_root.resolve()
325
+ out_dir = out_dir.resolve()
326
+ final_proof = modern_root / "final_proof"
327
+ summary = read_json(final_proof / "FINAL_RECEIPT_SUMMARY.json")
328
+ no_cost = read_json(final_proof / "NO_COST_CONFIDENCE_REPORT.json")
329
+
330
+ clean_dir(out_dir)
331
+ write_text(out_dir / "README.md", build_readme(summary, no_cost, repo_id))
332
+ write_text(out_dir / "METHODOLOGY.md", build_methodology(summary, no_cost))
333
+ write_text(out_dir / "DUE_DILIGENCE.md", build_due_diligence(summary, repo_id))
334
+ write_text(out_dir / "REPRODUCIBILITY.md", build_reproducibility(summary))
335
+ write_text(out_dir / "PUBLICATION_NOTES.md", build_publication_notes())
336
+ proof_files = copy_final_proof(modern_root, out_dir)
337
+ modern_files = copy_tree_filtered(modern_root, out_dir / "modern_code")
338
+
339
+ manifest = {
340
+ "bundle_version": BUNDLE_VERSION,
341
+ "generated_utc": datetime.now(timezone.utc).replace(microsecond=0).isoformat(),
342
+ "hf_repo_id": repo_id,
343
+ "source_repo": SOURCE_REMOTE,
344
+ "source_head": SOURCE_HEAD,
345
+ "claim_boundary": "No live COBOL/CICS all-path runtime equivalence is claimed.",
346
+ "proof_summary": {
347
+ "B": summary["parity"]["B"],
348
+ "F": summary["parity"]["F"],
349
+ "gaps": summary["parity"]["gap_count"],
350
+ "no_cost_reviewer_posture": summary["no_cost_confidence"]["reviewer_posture"],
351
+ "a_promotable": summary["a_grade_promotion"]["promotable_to_A"],
352
+ },
353
+ "proof_file_count": len(proof_files),
354
+ "modern_snapshot_file_count": len(modern_files),
355
+ "files": collect_files(out_dir),
356
+ "public_safe_checks": {
357
+ "original_source_tree_copied": False,
358
+ "paid_runtime_claim_made": False,
359
+ "live_runtime_equivalence_claim_made": False,
360
+ },
361
+ }
362
+ manifest["manifest_hash"] = stable_hash(manifest)
363
+ write_json(out_dir / "HF_PUBLICATION_MANIFEST.json", manifest)
364
+ manifest["files"] = collect_files(out_dir)
365
+ manifest["manifest_hash"] = stable_hash(manifest)
366
+ write_json(out_dir / "HF_PUBLICATION_MANIFEST.json", manifest)
367
+ return manifest
368
+
369
+
370
+ def main() -> None:
371
+ parser = argparse.ArgumentParser(description="Build HF-ready public proof bundle")
372
+ parser.add_argument("--modern-root", type=Path, default=Path(__file__).resolve().parents[1])
373
+ parser.add_argument("--out-dir", type=Path, required=True)
374
+ parser.add_argument("--repo-id", default=DEFAULT_REPO_ID)
375
+ args = parser.parse_args()
376
+
377
+ manifest = build_bundle(args.modern_root, args.out_dir, args.repo_id)
378
+ print(
379
+ json.dumps(
380
+ {
381
+ "out_dir": str(args.out_dir.resolve()),
382
+ "hf_repo_id": args.repo_id,
383
+ "file_count": len(manifest["files"]),
384
+ "manifest_hash": manifest["manifest_hash"],
385
+ "proof_summary": manifest["proof_summary"],
386
+ },
387
+ indent=2,
388
+ sort_keys=True,
389
+ )
390
+ )
391
+
392
+
393
+ if __name__ == "__main__":
394
+ main()
modern_code/tools/build_no_cost_confidence.py ADDED
@@ -0,0 +1,441 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import hashlib
5
+ import json
6
+ import re
7
+ import shutil
8
+ import subprocess
9
+ from collections import Counter
10
+ from datetime import datetime, timezone
11
+ from pathlib import Path
12
+ from typing import Any
13
+
14
+
15
+ SOURCE_REMOTE = "https://github.com/aws-samples/aws-mainframe-modernization-carddemo.git"
16
+ SOURCE_HEAD = "59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e"
17
+ REPORT_VERSION = "carddemo_no_cost_confidence_v0"
18
+ README_VERSION = "carddemo_no_cost_confidence_readme_v0"
19
+ CLAIM_BOUNDARY = (
20
+ "Maximum no-cost confidence evidence only. This is not live COBOL/CICS all-path runtime equivalence."
21
+ )
22
+ TOOL_PROBES = {
23
+ "cobc": "Free COBOL compiler probe for isolated non-CICS COBOL logic.",
24
+ "docker": "Container runtime probe; useful only if a runnable legacy runtime image is available.",
25
+ "aws": "AWS runtime path probe; not required for no-cost proof and not used here.",
26
+ "java": "JVM probe for possible migration/runtime tools.",
27
+ "mvn": "Maven probe for Java tooling.",
28
+ "gradle": "Gradle probe for Java tooling.",
29
+ "hercules": "Mainframe emulator probe; not sufficient by itself for CICS/VSAM/JCL.",
30
+ "tn3270": "3270 terminal probe for live CICS transaction capture.",
31
+ }
32
+
33
+
34
+ def read_json(path: Path, default: Any = None) -> Any:
35
+ if not path.exists():
36
+ return default
37
+ return json.loads(path.read_text(encoding="utf-8"))
38
+
39
+
40
+ def write_json(path: Path, payload: Any) -> None:
41
+ path.parent.mkdir(parents=True, exist_ok=True)
42
+ path.write_text(json.dumps(payload, indent=2, sort_keys=True, default=str) + "\n", encoding="utf-8")
43
+
44
+
45
+ def write_text(path: Path, text: str) -> None:
46
+ path.parent.mkdir(parents=True, exist_ok=True)
47
+ path.write_text(text.strip() + "\n", encoding="utf-8")
48
+
49
+
50
+ def stable_hash(payload: Any) -> str:
51
+ return hashlib.sha256(json.dumps(payload, sort_keys=True, default=str).encode("utf-8")).hexdigest()
52
+
53
+
54
+ def sha256_path(path: Path) -> str:
55
+ digest = hashlib.sha256()
56
+ with path.open("rb") as handle:
57
+ for chunk in iter(lambda: handle.read(1024 * 1024), b""):
58
+ digest.update(chunk)
59
+ return digest.hexdigest()
60
+
61
+
62
+ def path_record(path: Path, base: Path) -> dict[str, Any]:
63
+ return {
64
+ "path": str(path.resolve().relative_to(base.resolve())).replace("\\", "/"),
65
+ "size_bytes": path.stat().st_size,
66
+ "sha256": sha256_path(path),
67
+ }
68
+
69
+
70
+ def probe_tool(name: str) -> dict[str, Any]:
71
+ resolved = shutil.which(name)
72
+ result = {
73
+ "tool": name,
74
+ "present": resolved is not None,
75
+ "path": resolved,
76
+ "why_checked": TOOL_PROBES[name],
77
+ }
78
+ if not resolved:
79
+ return result
80
+ args = [resolved, "--version"]
81
+ if name == "docker":
82
+ args = [resolved, "version", "--format", "{{json .Server.Version}}"]
83
+ try:
84
+ completed = subprocess.run(args, check=False, capture_output=True, text=True, timeout=8)
85
+ except Exception as exc: # pragma: no cover - environment dependent
86
+ result.update({"version_probe_ok": False, "version_probe_error": str(exc)})
87
+ return result
88
+ output = (completed.stdout or completed.stderr or "").strip()
89
+ result.update(
90
+ {
91
+ "version_probe_ok": completed.returncode == 0,
92
+ "version_probe_returncode": completed.returncode,
93
+ "version_probe_output": output[:500],
94
+ }
95
+ )
96
+ return result
97
+
98
+
99
+ def source_file_inventory(source_root: Path) -> dict[str, Any]:
100
+ app_root = source_root / "app"
101
+ files = [path for path in app_root.rglob("*") if path.is_file()]
102
+ by_suffix = Counter(path.suffix.lower() or "<none>" for path in files)
103
+ evidence_suffixes = {".cbl", ".cpy", ".bms", ".jcl", ".dat", ".txt"}
104
+ evidence_files = [path_record(path, source_root) for path in files if path.suffix.lower() in evidence_suffixes]
105
+ return {
106
+ "app_root": str(app_root.resolve()),
107
+ "file_count": len(files),
108
+ "extension_counts": dict(sorted(by_suffix.items())),
109
+ "evidence_file_count": len(evidence_files),
110
+ "evidence_file_hash_digest": stable_hash(evidence_files),
111
+ }
112
+
113
+
114
+ def classify_cobol_program(path: Path, source_root: Path) -> dict[str, Any]:
115
+ text = path.read_text(encoding="utf-8", errors="ignore")
116
+ upper = text.upper()
117
+ has_cics = bool(re.search(r"\bEXEC\s+CICS\b", upper))
118
+ has_sql = bool(re.search(r"\bEXEC\s+SQL\b", upper))
119
+ has_dli = bool(re.search(r"\bEXEC\s+DLI\b", upper))
120
+ has_mq = " MQ" in upper or "MQ" in path.name.upper()
121
+ has_file_io = bool(re.search(r"\b(SELECT|FD|READ|WRITE|REWRITE|DELETE|START)\b", upper))
122
+ has_vsam_shape = bool(
123
+ re.search(r"\b(KSDS|ESDS|RRDS|VSAM|ORGANIZATION\s+IS\s+INDEXED|ACCESS\s+MODE)\b", upper)
124
+ )
125
+ cics_ops = sorted(set(re.findall(r"\b(?:READNEXT|STARTBR|ENDBR|READ|WRITE|REWRITE|DELETE|LINK|XCTL|RETURN|SEND|RECEIVE)\b", upper)))
126
+ return {
127
+ "path": str(path.resolve().relative_to(source_root.resolve())).replace("\\", "/"),
128
+ "line_count": len(text.splitlines()),
129
+ "has_cics": has_cics,
130
+ "has_sql": has_sql,
131
+ "has_dli": has_dli,
132
+ "has_mq_hint": has_mq,
133
+ "has_file_io": has_file_io,
134
+ "has_vsam_shape": has_vsam_shape,
135
+ "cics_operation_hints": cics_ops if has_cics else [],
136
+ "free_compile_feasibility": (
137
+ "possible_isolated_gnucobol_probe"
138
+ if not has_cics and not has_sql and not has_dli and not has_mq
139
+ else "requires_mainframe_or_compatible_runtime"
140
+ ),
141
+ }
142
+
143
+
144
+ def legacy_source_semantics_scan(source_root: Path) -> dict[str, Any]:
145
+ program_map: dict[str, Path] = {}
146
+ for pattern in ("*.cbl", "*.CBL"):
147
+ for path in (source_root / "app").rglob(pattern):
148
+ program_map[str(path.resolve()).lower()] = path
149
+ programs = sorted(program_map.values(), key=lambda path: str(path).lower())
150
+ classified = [classify_cobol_program(path, source_root) for path in programs]
151
+ cics_programs = [item for item in classified if item["has_cics"]]
152
+ free_probe_candidates = [item for item in classified if item["free_compile_feasibility"] == "possible_isolated_gnucobol_probe"]
153
+ return {
154
+ "cobol_program_count": len(classified),
155
+ "cics_program_count": len(cics_programs),
156
+ "non_cics_cobol_count": len(classified) - len(cics_programs),
157
+ "free_gnucobol_probe_candidate_count": len(free_probe_candidates),
158
+ "free_gnucobol_probe_candidate_paths": [item["path"] for item in free_probe_candidates[:25]],
159
+ "runtime_required_program_count": len([item for item in classified if item["free_compile_feasibility"] == "requires_mainframe_or_compatible_runtime"]),
160
+ "programs": classified,
161
+ }
162
+
163
+
164
+ def capability_coverage(ledger: list[dict[str, Any]]) -> dict[str, Any]:
165
+ source_ref_counts = [int(item.get("source_ref_count", 0)) for item in ledger]
166
+ surfaces = Counter(str(item.get("surface") or "unknown") for item in ledger)
167
+ grades = Counter(str(item.get("proof_grade") or "unknown") for item in ledger)
168
+ static_ready = sum(1 for item in ledger if item.get("static_oracle_ready") is True)
169
+ strict_ready = sum(1 for item in ledger if item.get("strict_parity_ready") is True)
170
+ zero_ref_ids = [item.get("capability_id") for item in ledger if int(item.get("source_ref_count", 0)) <= 0]
171
+ return {
172
+ "capability_count": len(ledger),
173
+ "surface_counts": dict(sorted(surfaces.items())),
174
+ "proof_grade_counts": dict(sorted(grades.items())),
175
+ "static_oracle_ready_count": static_ready,
176
+ "strict_runtime_ready_count": strict_ready,
177
+ "source_ref_total": sum(source_ref_counts),
178
+ "source_ref_min": min(source_ref_counts) if source_ref_counts else 0,
179
+ "source_ref_max": max(source_ref_counts) if source_ref_counts else 0,
180
+ "zero_source_ref_capability_ids": zero_ref_ids,
181
+ "all_have_source_refs": not zero_ref_ids,
182
+ "all_static_oracle_ready": static_ready == len(ledger),
183
+ }
184
+
185
+
186
+ def final_proof_status(modern_root: Path, out_dir: Path) -> dict[str, Any]:
187
+ final_summary = read_json(out_dir / "FINAL_RECEIPT_SUMMARY.json", {})
188
+ clean = read_json(out_dir / "CLEAN_REPRO_VERIFICATION.json", {})
189
+ return {
190
+ "final_summary_present": bool(final_summary),
191
+ "clean_repro_present": bool(clean),
192
+ "clean_repro_passed": clean.get("passed"),
193
+ "api_smoke_passed": clean.get("api_smoke_passed"),
194
+ "screenshot_present": (modern_root / "reports" / "ui_batch_reports_smoke.png").exists(),
195
+ "screenshot_sha256": sha256_path(modern_root / "reports" / "ui_batch_reports_smoke.png")
196
+ if (modern_root / "reports" / "ui_batch_reports_smoke.png").exists()
197
+ else None,
198
+ }
199
+
200
+
201
+ def confidence_layers(
202
+ receipt: dict[str, Any],
203
+ replay: dict[str, Any],
204
+ a_grade: dict[str, Any],
205
+ coverage: dict[str, Any],
206
+ final_status: dict[str, Any],
207
+ ) -> list[dict[str, Any]]:
208
+ parity = receipt.get("capability_parity", {})
209
+ grade_counts = parity.get("grade_counts", {})
210
+ a_gate = a_grade.get("a_grade_gate", {})
211
+ layers = [
212
+ {
213
+ "layer": "source_identity_and_hashes",
214
+ "status": "pass" if receipt.get("source_hash_count", 0) > 0 and receipt.get("source_head") == SOURCE_HEAD else "fail",
215
+ "detail": f"source_head={receipt.get('source_head')} source_hash_count={receipt.get('source_hash_count')}",
216
+ },
217
+ {
218
+ "layer": "one_for_one_capability_ledger",
219
+ "status": "pass" if parity.get("capability_count") == 50 and grade_counts.get("B") == 50 and parity.get("gap_count") == 0 else "fail",
220
+ "detail": f"capabilities={parity.get('capability_count')} B={grade_counts.get('B')} gaps={parity.get('gap_count')}",
221
+ },
222
+ {
223
+ "layer": "source_reference_coverage",
224
+ "status": "pass" if coverage["all_have_source_refs"] and coverage["all_static_oracle_ready"] else "fail",
225
+ "detail": f"source_refs={coverage['source_ref_total']} static_ready={coverage['static_oracle_ready_count']}",
226
+ },
227
+ {
228
+ "layer": "executable_static_oracle_replay",
229
+ "status": "pass" if replay.get("passed") and not replay.get("failed_checks") else "fail",
230
+ "detail": f"runtime_probe_count={replay.get('runtime_probe_count')} failed_checks={len(replay.get('failed_checks', []))}",
231
+ },
232
+ {
233
+ "layer": "edge_case_and_golden_trace_corpus",
234
+ "status": "pass" if replay.get("edge_case_count", 0) > 0 and replay.get("golden_trace_count", 0) > 0 else "fail",
235
+ "detail": f"edge_cases={replay.get('edge_case_count')} golden_traces={replay.get('golden_trace_count')}",
236
+ },
237
+ {
238
+ "layer": "clean_copy_reproduction_and_api_smoke",
239
+ "status": "pass" if final_status["clean_repro_passed"] and final_status["api_smoke_passed"] else "warn",
240
+ "detail": f"clean_repro={final_status['clean_repro_passed']} api_smoke={final_status['api_smoke_passed']}",
241
+ },
242
+ {
243
+ "layer": "honest_a_grade_runtime_gate",
244
+ "status": "pass" if a_gate.get("promotable_to_A") is False and a_gate.get("missing_live_matches") == 50 else "warn",
245
+ "detail": (
246
+ f"promotable_to_A={a_gate.get('promotable_to_A')} "
247
+ f"accepted_live={a_gate.get('accepted_live_matches')} missing_live={a_gate.get('missing_live_matches')}"
248
+ ),
249
+ },
250
+ ]
251
+ return layers
252
+
253
+
254
+ def build_no_cost_confidence_report(modern_root: Path, source_root: Path, out_dir: Path) -> dict[str, Any]:
255
+ modern_root = modern_root.resolve()
256
+ source_root = source_root.resolve()
257
+ out_dir = out_dir.resolve()
258
+ reports = modern_root / "reports"
259
+ receipt = read_json(reports / "modernization_receipt.json", {})
260
+ ledger = read_json(reports / "capability_ledger.json", [])
261
+ replay = read_json(reports / "static_oracle_replay.json", {})
262
+ edge_cases = read_json(reports / "edge_cases.json", [])
263
+ golden_traces = read_json(reports / "golden_traces.json", [])
264
+ a_grade = read_json(out_dir / "A_GRADE_PROMOTION_REPORT.json", {})
265
+
266
+ inventory = source_file_inventory(source_root)
267
+ semantics_scan = legacy_source_semantics_scan(source_root)
268
+ coverage = capability_coverage(ledger)
269
+ final_status = final_proof_status(modern_root, out_dir)
270
+ layers = confidence_layers(receipt, replay, a_grade, coverage, final_status)
271
+ counts = Counter(layer["status"] for layer in layers)
272
+ no_cost_ready = counts.get("fail", 0) == 0 and counts.get("pass", 0) >= 6
273
+
274
+ report: dict[str, Any] = {
275
+ "report_version": REPORT_VERSION,
276
+ "generated_utc": datetime.now(timezone.utc).replace(microsecond=0).isoformat(),
277
+ "source": {
278
+ "repo_url": SOURCE_REMOTE,
279
+ "head": SOURCE_HEAD,
280
+ "local_path": str(source_root),
281
+ },
282
+ "modern_code": {
283
+ "local_path": str(modern_root),
284
+ },
285
+ "claim_boundary": CLAIM_BOUNDARY,
286
+ "no_cost_scope": {
287
+ "paid_runtime_used": False,
288
+ "public_actions_allowed": False,
289
+ "legacy_runtime_claim_made": False,
290
+ "goal": (
291
+ "Produce the strongest practical pre-runtime evidence without paid/licensed legacy infrastructure, "
292
+ "then leave only live legacy runtime validation as the named residual gap."
293
+ ),
294
+ },
295
+ "source_inventory": inventory,
296
+ "legacy_source_semantics_scan": semantics_scan,
297
+ "capability_coverage": coverage,
298
+ "static_oracle_replay": {
299
+ "present": bool(replay),
300
+ "passed": replay.get("passed"),
301
+ "replay_hash": replay.get("replay_hash"),
302
+ "evidence_hash": replay.get("evidence_hash"),
303
+ "runtime_probe_count": replay.get("runtime_probe_count"),
304
+ "failed_checks": replay.get("failed_checks", []),
305
+ "claim_limit": replay.get("claim_limit"),
306
+ },
307
+ "test_and_smoke_evidence": final_status,
308
+ "fixture_corpus": {
309
+ "edge_case_count": len(edge_cases),
310
+ "golden_trace_count": len(golden_traces),
311
+ "edge_case_hash": stable_hash(edge_cases),
312
+ "golden_trace_hash": stable_hash(golden_traces),
313
+ },
314
+ "local_runtime_feasibility": {
315
+ "tooling_probe": {name: probe_tool(name) for name in TOOL_PROBES},
316
+ "conclusion": (
317
+ "Free/local analysis can inspect, parse, hash, replay extracted expectations, and optionally probe "
318
+ "isolated non-CICS COBOL if cobc is available. It cannot honestly replace CICS/VSAM/JCL execution."
319
+ ),
320
+ },
321
+ "a_grade_gate": {
322
+ "present": bool(a_grade),
323
+ "decision": (a_grade.get("decision") or {}).get("action"),
324
+ "promotable_to_A": (a_grade.get("a_grade_gate") or {}).get("promotable_to_A"),
325
+ "required_live_matches": (a_grade.get("a_grade_gate") or {}).get("required_live_matches"),
326
+ "accepted_live_matches": (a_grade.get("a_grade_gate") or {}).get("accepted_live_matches"),
327
+ "missing_live_matches": (a_grade.get("a_grade_gate") or {}).get("missing_live_matches"),
328
+ "report_hash": a_grade.get("report_hash"),
329
+ },
330
+ "no_cost_confidence_layers": layers,
331
+ "no_cost_confidence_summary": {
332
+ "status_counts": dict(sorted(counts.items())),
333
+ "ready_for_pre_runtime_review": no_cost_ready,
334
+ "reviewer_posture": "strong_pre_runtime_confidence" if no_cost_ready else "needs_more_no_cost_evidence",
335
+ "remaining_gap": "live legacy COBOL/CICS/VSAM/JCL runtime validation on a real or licensed-compatible runtime",
336
+ "plain_english": (
337
+ "The modern app is strongly supported by source-derived static oracles, executable modern replay, "
338
+ "edge cases, clean-copy tests, and API smoke. A reviewer should still require live legacy runtime "
339
+ "validation before accepting production equivalence."
340
+ ),
341
+ },
342
+ "reviewer_language": {
343
+ "what_this_should_convince": [
344
+ "The modernization has a pinned source identity and hashed evidence base.",
345
+ "Every tracked capability has source-backed static/source-oracle coverage.",
346
+ "The modern service executes against legacy-derived fixtures without current gaps.",
347
+ "The remaining risk is specifically runtime-environment validation, not a known missing feature in the current rubric.",
348
+ ],
349
+ "what_this_cannot_claim": [
350
+ "It cannot claim all-path live COBOL/CICS equivalence.",
351
+ "It cannot prove CICS, VSAM, JCL, DB2, IMS, MQ, or terminal behavior that only appears in a paid or hosted runtime.",
352
+ "It cannot remove the need for final validation in the customer's legacy runtime environment.",
353
+ ],
354
+ },
355
+ "public_actions_allowed": False,
356
+ }
357
+ report["report_hash"] = stable_hash(report)
358
+ return report
359
+
360
+
361
+ def confidence_readme(report: dict[str, Any]) -> str:
362
+ summary = report["no_cost_confidence_summary"]
363
+ coverage = report["capability_coverage"]
364
+ semantics = report["legacy_source_semantics_scan"]
365
+ replay = report["static_oracle_replay"]
366
+ a_gate = report["a_grade_gate"]
367
+ return f"""
368
+ # AWS CardDemo No-Cost Confidence Proof
369
+
370
+ Report version: `{README_VERSION}`
371
+
372
+ This artifact answers the practical question: how far did we get without paying for or depending on a licensed legacy runtime?
373
+
374
+ ## Result
375
+
376
+ - Reviewer posture: `{summary['reviewer_posture']}`
377
+ - Ready for pre-runtime review: `{summary['ready_for_pre_runtime_review']}`
378
+ - Paid runtime used: `False`
379
+ - Public actions allowed: `False`
380
+ - Remaining gap: `{summary['remaining_gap']}`
381
+
382
+ ## Evidence We Can Produce For Free
383
+
384
+ - Capability coverage: `{coverage['capability_count']}` capabilities.
385
+ - Static/source-oracle ready: `{coverage['static_oracle_ready_count']}` capabilities.
386
+ - Source references attached to capability ledger: `{coverage['source_ref_total']}`.
387
+ - Static replay passed: `{replay['passed']}`.
388
+ - Static replay hash: `{replay['replay_hash']}`.
389
+ - Golden traces: `{report['fixture_corpus']['golden_trace_count']}`.
390
+ - Edge cases: `{report['fixture_corpus']['edge_case_count']}`.
391
+ - Clean-copy/API smoke evidence is recorded in `FINAL_RECEIPT_SUMMARY.json`.
392
+
393
+ ## Legacy Source Runtime Shape
394
+
395
+ - COBOL programs scanned: `{semantics['cobol_program_count']}`.
396
+ - CICS programs: `{semantics['cics_program_count']}`.
397
+ - Non-CICS COBOL programs: `{semantics['non_cics_cobol_count']}`.
398
+ - Free GnuCOBOL probe candidates: `{semantics['free_gnucobol_probe_candidate_count']}`.
399
+ - Programs still requiring mainframe-compatible runtime for honest execution: `{semantics['runtime_required_program_count']}`.
400
+
401
+ ## A-Grade Boundary
402
+
403
+ - A-grade decision: `{a_gate['decision']}`.
404
+ - Promotable to A: `{a_gate['promotable_to_A']}`.
405
+ - Accepted live runtime matches: `{a_gate['accepted_live_matches']}`.
406
+ - Missing live runtime matches: `{a_gate['missing_live_matches']}`.
407
+
408
+ This does not pretend to be live COBOL/CICS equivalence. It shows that the unpaid work is strong and that the remaining proof step is specifically live legacy runtime validation.
409
+ """
410
+
411
+
412
+ def main() -> None:
413
+ parser = argparse.ArgumentParser(description="Build the no-cost CardDemo confidence proof")
414
+ parser.add_argument("--modern-root", type=Path, default=Path(__file__).resolve().parents[1])
415
+ parser.add_argument("--source-root", type=Path, default=Path(__file__).resolve().parents[2] / "source")
416
+ parser.add_argument("--out-dir", type=Path, default=None)
417
+ args = parser.parse_args()
418
+
419
+ modern_root = args.modern_root.resolve()
420
+ source_root = args.source_root.resolve()
421
+ out_dir = (args.out_dir or modern_root / "final_proof").resolve()
422
+ report = build_no_cost_confidence_report(modern_root, source_root, out_dir)
423
+ write_json(out_dir / "NO_COST_CONFIDENCE_REPORT.json", report)
424
+ write_text(out_dir / "NO_COST_CONFIDENCE_README.md", confidence_readme(report))
425
+ print(
426
+ json.dumps(
427
+ {
428
+ "out_dir": str(out_dir),
429
+ "reviewer_posture": report["no_cost_confidence_summary"]["reviewer_posture"],
430
+ "ready_for_pre_runtime_review": report["no_cost_confidence_summary"]["ready_for_pre_runtime_review"],
431
+ "status_counts": report["no_cost_confidence_summary"]["status_counts"],
432
+ "report_hash": report["report_hash"],
433
+ },
434
+ indent=2,
435
+ sort_keys=True,
436
+ )
437
+ )
438
+
439
+
440
+ if __name__ == "__main__":
441
+ main()
modern_code/tools/evaluate_a_grade_promotion.py ADDED
@@ -0,0 +1,501 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import hashlib
5
+ import json
6
+ import shutil
7
+ import subprocess
8
+ import zipfile
9
+ from datetime import datetime, timezone
10
+ from pathlib import Path
11
+ from typing import Any
12
+
13
+
14
+ SOURCE_REMOTE = "https://github.com/aws-samples/aws-mainframe-modernization-carddemo.git"
15
+ SOURCE_HEAD = "59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e"
16
+ REPORT_VERSION = "carddemo_a_grade_promotion_gate_v0"
17
+ README_VERSION = "carddemo_a_grade_promotion_readme_v0"
18
+ ACCEPTED_TRACE_KINDS = {"live_cobol_cics_runtime", "live_mainframe_runtime"}
19
+ TRACE_HASH_FIELDS = ("raw_legacy_trace_hash", "legacy_runtime_trace_hash")
20
+ REQUIRED_TRACE_FIELDS = (
21
+ "capability_id",
22
+ "trace_kind",
23
+ "source_head",
24
+ "legacy_runtime_environment",
25
+ "modern_observation_hash",
26
+ "comparator_version",
27
+ )
28
+ RUNTIME_TOOL_PROBES = {
29
+ "cobc": "GnuCOBOL compiler; useful for limited COBOL probes, not sufficient for CICS/VSAM/JCL parity.",
30
+ "aws": "AWS CLI; needed for AWS-hosted M2/Mainframe runtime paths.",
31
+ "java": "JVM; required by several migration/runtime toolchains.",
32
+ "mvn": "Maven; useful for Java-based runtime harnesses.",
33
+ "gradle": "Gradle; useful for Java-based runtime harnesses.",
34
+ "hercules": "Mainframe emulator; still not a CICS/VSAM/JCL runtime by itself.",
35
+ "tn3270": "3270 terminal client; useful for interactive CICS transaction capture.",
36
+ "docker": "Container runtime; useful only when a licensed/runnable legacy runtime image exists.",
37
+ }
38
+ M2_RUNTIME_ZIPS = (
39
+ Path("samples/m2/mf/CardDemo_runtime.zip"),
40
+ Path("samples/m2/unikix/UniKix_CardDemo_runtime_v1.zip"),
41
+ )
42
+
43
+
44
+ def read_json(path: Path) -> Any:
45
+ return json.loads(path.read_text(encoding="utf-8"))
46
+
47
+
48
+ def write_json(path: Path, payload: Any) -> None:
49
+ path.parent.mkdir(parents=True, exist_ok=True)
50
+ path.write_text(json.dumps(payload, indent=2, sort_keys=True, default=str) + "\n", encoding="utf-8")
51
+
52
+
53
+ def write_text(path: Path, text: str) -> None:
54
+ path.parent.mkdir(parents=True, exist_ok=True)
55
+ path.write_text(text.strip() + "\n", encoding="utf-8")
56
+
57
+
58
+ def stable_hash(payload: Any) -> str:
59
+ return hashlib.sha256(json.dumps(payload, sort_keys=True, default=str).encode("utf-8")).hexdigest()
60
+
61
+
62
+ def sha256_path(path: Path) -> str:
63
+ digest = hashlib.sha256()
64
+ with path.open("rb") as handle:
65
+ for chunk in iter(lambda: handle.read(1024 * 1024), b""):
66
+ digest.update(chunk)
67
+ return digest.hexdigest()
68
+
69
+
70
+ def is_sha256(value: Any) -> bool:
71
+ if not isinstance(value, str) or len(value) != 64:
72
+ return False
73
+ return all(ch in "0123456789abcdefABCDEF" for ch in value)
74
+
75
+
76
+ def load_capability_ledger(modern_root: Path) -> list[dict[str, Any]]:
77
+ ledger = read_json(modern_root / "reports" / "capability_ledger.json")
78
+ if not isinstance(ledger, list):
79
+ raise ValueError("capability_ledger.json must be a list")
80
+ return [dict(item) for item in ledger]
81
+
82
+
83
+ def load_current_parity(modern_root: Path) -> dict[str, Any]:
84
+ receipt = read_json(modern_root / "reports" / "modernization_receipt.json")
85
+ parity = dict(receipt["capability_parity"])
86
+ parity["receipt_hash"] = receipt["receipt_hash"]
87
+ parity["source_head"] = receipt["source_head"]
88
+ parity["receipt_generated_utc"] = receipt["generated_utc"]
89
+ return parity
90
+
91
+
92
+ def command_probe(executable: str) -> dict[str, Any]:
93
+ resolved = shutil.which(executable)
94
+ result: dict[str, Any] = {
95
+ "tool": executable,
96
+ "present": resolved is not None,
97
+ "path": resolved,
98
+ "purpose": RUNTIME_TOOL_PROBES[executable],
99
+ }
100
+ if not resolved:
101
+ return result
102
+
103
+ version_args = [resolved, "--version"]
104
+ if executable == "docker":
105
+ version_args = [resolved, "version", "--format", "{{json .Server.Version}}"]
106
+
107
+ try:
108
+ completed = subprocess.run(
109
+ version_args,
110
+ check=False,
111
+ capture_output=True,
112
+ text=True,
113
+ timeout=8,
114
+ )
115
+ except Exception as exc: # pragma: no cover - environment dependent
116
+ result.update({"version_probe_ok": False, "version_probe_error": str(exc)})
117
+ return result
118
+
119
+ output = (completed.stdout or completed.stderr or "").strip()
120
+ result.update(
121
+ {
122
+ "version_probe_ok": completed.returncode == 0,
123
+ "version_probe_returncode": completed.returncode,
124
+ "version_probe_output": output[:500],
125
+ }
126
+ )
127
+ return result
128
+
129
+
130
+ def inspect_zip(path: Path) -> dict[str, Any]:
131
+ record: dict[str, Any] = {
132
+ "path": str(path.resolve()),
133
+ "exists": path.exists(),
134
+ "size_bytes": path.stat().st_size if path.exists() else None,
135
+ "sha256": sha256_path(path) if path.exists() else None,
136
+ }
137
+ if not path.exists():
138
+ return record
139
+
140
+ with zipfile.ZipFile(path) as archive:
141
+ names = archive.namelist()
142
+ lowered = [name.replace("\\", "/").lower() for name in names]
143
+ record.update(
144
+ {
145
+ "entry_count": len(names),
146
+ "sample_entries": names[:30],
147
+ "has_shared_load_modules": any("/loadlib/" in name and name.endswith(".so") for name in lowered),
148
+ "has_app_config": any(name.endswith("app_config.json") for name in lowered),
149
+ "has_catalog_jcl": any("/catalog/jcl/" in name for name in lowered),
150
+ "has_catalog_data": any("/catalog/data/" in name for name in lowered),
151
+ "has_unikix_layout": any("unikix" in name or "/migrated_app/" in name for name in lowered),
152
+ "runtime_conclusion": (
153
+ "Deployment/runtime asset detected. This is useful provenance, but it is not a live "
154
+ "executed COBOL/CICS trace corpus by itself."
155
+ ),
156
+ }
157
+ )
158
+ return record
159
+
160
+
161
+ def inspect_runtime_assets(source_root: Path) -> list[dict[str, Any]]:
162
+ return [inspect_zip(source_root / relative) for relative in M2_RUNTIME_ZIPS]
163
+
164
+
165
+ def trace_candidates(payload: Any) -> list[dict[str, Any]]:
166
+ if isinstance(payload, list):
167
+ return [item for item in payload if isinstance(item, dict)]
168
+ if not isinstance(payload, dict):
169
+ return []
170
+ candidates: list[dict[str, Any]] = []
171
+ if "capability_id" in payload:
172
+ candidates.append(payload)
173
+ for key in ("capability_matches", "matches", "traces", "results"):
174
+ value = payload.get(key)
175
+ if isinstance(value, list):
176
+ candidates.extend(item for item in value if isinstance(item, dict))
177
+ return candidates
178
+
179
+
180
+ def validate_trace_record(record: dict[str, Any], required_ids: set[str]) -> tuple[bool, list[str]]:
181
+ reasons: list[str] = []
182
+ capability_id = record.get("capability_id")
183
+ if capability_id not in required_ids:
184
+ reasons.append("unknown_or_missing_capability_id")
185
+ for field in REQUIRED_TRACE_FIELDS:
186
+ if not record.get(field):
187
+ reasons.append(f"missing_{field}")
188
+ if record.get("trace_kind") not in ACCEPTED_TRACE_KINDS:
189
+ reasons.append("trace_kind_not_live_legacy_runtime")
190
+ if record.get("source_head") != SOURCE_HEAD:
191
+ reasons.append("source_head_mismatch")
192
+ if record.get("matched") is not True:
193
+ reasons.append("matched_not_true")
194
+ legacy_hash = next((record.get(field) for field in TRACE_HASH_FIELDS if record.get(field)), None)
195
+ if not legacy_hash:
196
+ reasons.append("missing_legacy_runtime_trace_hash")
197
+ elif not is_sha256(legacy_hash):
198
+ reasons.append("legacy_runtime_trace_hash_not_sha256")
199
+ if not is_sha256(record.get("modern_observation_hash")):
200
+ reasons.append("modern_observation_hash_not_sha256")
201
+ return not reasons, reasons
202
+
203
+
204
+ def load_live_trace_matches(trace_dir: Path | None, required_ids: set[str]) -> dict[str, Any]:
205
+ if trace_dir is None:
206
+ return {
207
+ "trace_dir": None,
208
+ "trace_dir_exists": False,
209
+ "accepted_matches": {},
210
+ "rejected_records": [],
211
+ "files_scanned": [],
212
+ }
213
+
214
+ trace_dir = trace_dir.resolve()
215
+ files = sorted(trace_dir.rglob("*.json")) if trace_dir.exists() else []
216
+ accepted: dict[str, dict[str, Any]] = {}
217
+ rejected: list[dict[str, Any]] = []
218
+ for path in files:
219
+ try:
220
+ payload = read_json(path)
221
+ except Exception as exc:
222
+ rejected.append({"path": str(path), "reasons": [f"json_parse_error:{exc}"]})
223
+ continue
224
+ for record in trace_candidates(payload):
225
+ ok, reasons = validate_trace_record(record, required_ids)
226
+ capability_id = record.get("capability_id")
227
+ if ok and isinstance(capability_id, str):
228
+ accepted[capability_id] = {
229
+ "path": str(path),
230
+ "trace_kind": record["trace_kind"],
231
+ "legacy_runtime_environment": record["legacy_runtime_environment"],
232
+ "raw_legacy_trace_hash": next(record.get(field) for field in TRACE_HASH_FIELDS if record.get(field)),
233
+ "modern_observation_hash": record["modern_observation_hash"],
234
+ "comparator_version": record["comparator_version"],
235
+ }
236
+ else:
237
+ rejected.append(
238
+ {
239
+ "path": str(path),
240
+ "capability_id": capability_id,
241
+ "reasons": reasons,
242
+ }
243
+ )
244
+ return {
245
+ "trace_dir": str(trace_dir),
246
+ "trace_dir_exists": trace_dir.exists(),
247
+ "accepted_matches": accepted,
248
+ "rejected_records": rejected,
249
+ "files_scanned": [str(path) for path in files],
250
+ }
251
+
252
+
253
+ def build_a_grade_report(modern_root: Path, source_root: Path, trace_dir: Path | None = None) -> dict[str, Any]:
254
+ modern_root = modern_root.resolve()
255
+ source_root = source_root.resolve()
256
+ ledger = load_capability_ledger(modern_root)
257
+ current_parity = load_current_parity(modern_root)
258
+ required_ids = {item["capability_id"] for item in ledger}
259
+ trace_status = load_live_trace_matches(trace_dir, required_ids)
260
+ accepted_matches = trace_status["accepted_matches"]
261
+ missing_ids = sorted(required_ids - set(accepted_matches))
262
+ runtime_assets = inspect_runtime_assets(source_root)
263
+ tool_probe = {name: command_probe(name) for name in RUNTIME_TOOL_PROBES}
264
+
265
+ blockers = []
266
+ if missing_ids:
267
+ blockers.append(
268
+ {
269
+ "code": "missing_live_legacy_trace_corpus",
270
+ "detail": (
271
+ f"A-grade requires accepted live legacy runtime matches for all {len(required_ids)} "
272
+ f"capabilities; accepted={len(accepted_matches)}, missing={len(missing_ids)}."
273
+ ),
274
+ }
275
+ )
276
+ if not any(asset.get("exists") for asset in runtime_assets):
277
+ blockers.append(
278
+ {
279
+ "code": "missing_legacy_runtime_assets",
280
+ "detail": "No AWS M2 runtime zip assets were found under the pinned source tree.",
281
+ }
282
+ )
283
+ else:
284
+ blockers.append(
285
+ {
286
+ "code": "runtime_assets_not_execution_evidence",
287
+ "detail": (
288
+ "AWS M2/Micro Focus/UniKix package artifacts were found, but this run did not execute "
289
+ "them to produce COBOL/CICS transaction traces."
290
+ ),
291
+ }
292
+ )
293
+ if not tool_probe["aws"]["present"] and not tool_probe["hercules"]["present"]:
294
+ blockers.append(
295
+ {
296
+ "code": "no_local_mainframe_or_aws_runtime_path_detected",
297
+ "detail": "Neither AWS CLI nor a local mainframe emulator was detected for a runtime capture path.",
298
+ }
299
+ )
300
+ blockers.append(
301
+ {
302
+ "code": "static_oracle_is_not_a_grade",
303
+ "detail": "The current B=50 proof is strong static/source-oracle evidence, but A requires live runtime traces.",
304
+ }
305
+ )
306
+
307
+ promotable = not missing_ids
308
+ current_grade_counts = dict(current_parity["grade_counts"])
309
+ proposed_grade_counts = dict(current_grade_counts)
310
+ if promotable:
311
+ proposed_grade_counts.update({"A": len(required_ids), "B": 0, "F": 0})
312
+
313
+ capability_status = []
314
+ ledger_by_id = {item["capability_id"]: item for item in ledger}
315
+ for capability_id in sorted(required_ids):
316
+ ledger_item = ledger_by_id[capability_id]
317
+ capability_status.append(
318
+ {
319
+ "capability_id": capability_id,
320
+ "surface": ledger_item.get("surface"),
321
+ "transaction": ledger_item.get("transaction"),
322
+ "program": ledger_item.get("program"),
323
+ "function": ledger_item.get("function"),
324
+ "current_proof_grade": ledger_item.get("proof_grade"),
325
+ "a_grade_match_found": capability_id in accepted_matches,
326
+ "accepted_trace": accepted_matches.get(capability_id),
327
+ "missing_reason": None if capability_id in accepted_matches else "no_accepted_live_legacy_runtime_trace",
328
+ }
329
+ )
330
+
331
+ report: dict[str, Any] = {
332
+ "report_version": REPORT_VERSION,
333
+ "generated_utc": datetime.now(timezone.utc).replace(microsecond=0).isoformat(),
334
+ "source": {
335
+ "repo_url": SOURCE_REMOTE,
336
+ "head": SOURCE_HEAD,
337
+ "local_path": str(source_root),
338
+ },
339
+ "modern_code": {
340
+ "local_path": str(modern_root),
341
+ },
342
+ "requested_target": {
343
+ "grade": "A",
344
+ "scope": "all capabilities",
345
+ "capability_count": len(required_ids),
346
+ },
347
+ "rubric": {
348
+ "A": "actual legacy COBOL/CICS runtime trace matched to modern observed behavior for the capability",
349
+ "B": "static legacy data/copybook/source-oracle match plus executable modern-service replay",
350
+ "F": "known parity gap or missing capability under the current rubric",
351
+ },
352
+ "current_static_source_oracle_status": {
353
+ "capability_count": current_parity["capability_count"],
354
+ "grade_counts": current_grade_counts,
355
+ "gap_count": current_parity["gap_count"],
356
+ "static_oracle_or_better_count": current_parity["static_oracle_or_better_count"],
357
+ "strict_runtime_parity_count": current_parity["strict_runtime_parity_count"],
358
+ "receipt_hash": current_parity["receipt_hash"],
359
+ "receipt_generated_utc": current_parity["receipt_generated_utc"],
360
+ },
361
+ "a_grade_gate": {
362
+ "promotable_to_A": promotable,
363
+ "required_live_matches": len(required_ids),
364
+ "accepted_live_matches": len(accepted_matches),
365
+ "missing_live_matches": len(missing_ids),
366
+ "current_A": current_grade_counts.get("A", 0),
367
+ "target_A": len(required_ids),
368
+ "proposed_grade_counts_if_gate_passes": proposed_grade_counts,
369
+ "missing_capability_ids": missing_ids,
370
+ },
371
+ "legacy_runtime_trace_contract": {
372
+ "accepted_trace_kinds": sorted(ACCEPTED_TRACE_KINDS),
373
+ "required_fields": list(REQUIRED_TRACE_FIELDS) + ["matched", "raw_legacy_trace_hash or legacy_runtime_trace_hash"],
374
+ "field_rules": {
375
+ "source_head": SOURCE_HEAD,
376
+ "matched": True,
377
+ "hash_fields": "64-character SHA-256 hex digests",
378
+ "capability_id": "must match one ID in reports/capability_ledger.json",
379
+ },
380
+ },
381
+ "legacy_runtime_environment_assessment": {
382
+ "source_prerequisites": [
383
+ "mainframe environment with CICS, VSAM, and JCL support",
384
+ "optional DB2, IMS DB, and MQ paths for optional modules",
385
+ ],
386
+ "local_execution_path_found": False,
387
+ "local_execution_path_reason": (
388
+ "No runnable COBOL/CICS/VSAM/JCL runtime was executed in this workspace. "
389
+ "Static replay and modern API tests are not live legacy execution."
390
+ ),
391
+ "tooling_probe": tool_probe,
392
+ "runtime_assets": runtime_assets,
393
+ },
394
+ "live_trace_scan": trace_status,
395
+ "capability_match_status": capability_status,
396
+ "blockers": blockers if not promotable else [],
397
+ "decision": {
398
+ "action": "promote_to_A" if promotable else "do_not_promote",
399
+ "why": (
400
+ "All required live runtime trace matches were accepted."
401
+ if promotable
402
+ else "The current bundle proves B=50/F=0/gaps=0 under the static/source-oracle rubric, "
403
+ "but it does not contain accepted live COBOL/CICS runtime traces for all capabilities."
404
+ ),
405
+ "next_non_human_path": [
406
+ "Run the pinned AWS CardDemo source in an AWS M2/mainframe-compatible runtime.",
407
+ "Capture transaction and batch outputs for each capability ID in reports/capability_ledger.json.",
408
+ "Replay the same inputs through the modern Python/SQLite service.",
409
+ "Emit JSON trace records satisfying legacy_runtime_trace_contract.",
410
+ "Rerun this gate with --legacy-trace-dir pointing at that corpus.",
411
+ ],
412
+ },
413
+ "public_actions_allowed": False,
414
+ }
415
+ report["report_hash"] = stable_hash(report)
416
+ return report
417
+
418
+
419
+ def promotion_readme(report: dict[str, Any]) -> str:
420
+ gate = report["a_grade_gate"]
421
+ parity = report["current_static_source_oracle_status"]
422
+ return f"""
423
+ # AWS CardDemo A-Grade Promotion Gate
424
+
425
+ Report version: `{README_VERSION}`
426
+
427
+ This file records the attempt to promote the AWS CardDemo modernization proof from B-grade static/source-oracle parity to A-grade live runtime parity.
428
+
429
+ ## Decision
430
+
431
+ - Action: `{report['decision']['action']}`
432
+ - Promotable to A: `{gate['promotable_to_A']}`
433
+ - Current grade counts: `{parity['grade_counts']}`
434
+ - Required live legacy runtime matches: `{gate['required_live_matches']}`
435
+ - Accepted live legacy runtime matches: `{gate['accepted_live_matches']}`
436
+ - Missing live legacy runtime matches: `{gate['missing_live_matches']}`
437
+ - Current static/source-oracle status: B=`{parity['grade_counts'].get('B', 0)}`, F=`{parity['grade_counts'].get('F', 0)}`, gaps=`{parity['gap_count']}`
438
+
439
+ ## Rubric Boundary
440
+
441
+ A-grade is reserved for actual legacy COBOL/CICS runtime traces matched against modern observed behavior for each capability. The existing proof remains B=50/F=0/gaps=0 under the current static/source-oracle rubric.
442
+
443
+ This is not live COBOL/CICS all-path runtime equivalence.
444
+
445
+ ## Replay Command
446
+
447
+ ```powershell
448
+ python tools\\evaluate_a_grade_promotion.py --source-root ..\\source --out-dir .\\final_proof
449
+ ```
450
+
451
+ To test a future live trace corpus, add:
452
+
453
+ ```powershell
454
+ --legacy-trace-dir <path-to-live-trace-json-corpus>
455
+ ```
456
+
457
+ ## Required Trace Contract
458
+
459
+ Each accepted live trace record must include the fields listed in `A_GRADE_PROMOTION_REPORT.json` under `legacy_runtime_trace_contract`. The key requirements are: pinned source head, live trace kind, matched=true, a capability ID from the ledger, and SHA-256 hashes for the raw legacy trace and modern observation.
460
+ """
461
+
462
+
463
+ def main() -> None:
464
+ parser = argparse.ArgumentParser(description="Evaluate whether CardDemo proof can be promoted to A-grade parity")
465
+ parser.add_argument("--modern-root", type=Path, default=Path(__file__).resolve().parents[1])
466
+ parser.add_argument("--source-root", type=Path, default=Path(__file__).resolve().parents[2] / "source")
467
+ parser.add_argument("--out-dir", type=Path, default=None)
468
+ parser.add_argument("--legacy-trace-dir", type=Path, default=None)
469
+ parser.add_argument("--fail-if-not-promotable", action="store_true")
470
+ args = parser.parse_args()
471
+
472
+ modern_root = args.modern_root.resolve()
473
+ source_root = args.source_root.resolve()
474
+ out_dir = (args.out_dir or modern_root / "final_proof").resolve()
475
+ trace_dir = args.legacy_trace_dir.resolve() if args.legacy_trace_dir else None
476
+
477
+ report = build_a_grade_report(modern_root, source_root, trace_dir)
478
+ write_json(out_dir / "A_GRADE_PROMOTION_REPORT.json", report)
479
+ write_text(out_dir / "A_GRADE_PROMOTION_README.md", promotion_readme(report))
480
+
481
+ print(
482
+ json.dumps(
483
+ {
484
+ "out_dir": str(out_dir),
485
+ "promotable_to_A": report["a_grade_gate"]["promotable_to_A"],
486
+ "current_grade_counts": report["current_static_source_oracle_status"]["grade_counts"],
487
+ "required_live_matches": report["a_grade_gate"]["required_live_matches"],
488
+ "accepted_live_matches": report["a_grade_gate"]["accepted_live_matches"],
489
+ "missing_live_matches": report["a_grade_gate"]["missing_live_matches"],
490
+ "report_hash": report["report_hash"],
491
+ },
492
+ indent=2,
493
+ sort_keys=True,
494
+ )
495
+ )
496
+ if args.fail_if_not_promotable and not report["a_grade_gate"]["promotable_to_A"]:
497
+ raise SystemExit(2)
498
+
499
+
500
+ if __name__ == "__main__":
501
+ main()
modern_code/tools/generate_receipts.py ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import hashlib
5
+ import json
6
+ import sys
7
+ from datetime import datetime, timezone
8
+ from pathlib import Path
9
+ from typing import Any
10
+
11
+ PROJECT_ROOT = Path(__file__).resolve().parents[1]
12
+ if str(PROJECT_ROOT) not in sys.path:
13
+ sys.path.insert(0, str(PROJECT_ROOT))
14
+
15
+ from carddemo.parity import build_parity_evidence
16
+ from carddemo.repository import seed_from_legacy
17
+ from carddemo.service import CardDemoService
18
+
19
+
20
+ def sha256_path(path: Path) -> str:
21
+ digest = hashlib.sha256()
22
+ with path.open("rb") as handle:
23
+ for chunk in iter(lambda: handle.read(1024 * 1024), b""):
24
+ digest.update(chunk)
25
+ return digest.hexdigest()
26
+
27
+
28
+ def collect_hashes(root: Path, patterns: tuple[str, ...]) -> dict[str, str]:
29
+ hashes: dict[str, str] = {}
30
+ for pattern in patterns:
31
+ for path in root.rglob(pattern):
32
+ if path.is_file():
33
+ hashes[str(path.relative_to(root)).replace("\\", "/")] = sha256_path(path)
34
+ return dict(sorted(hashes.items()))
35
+
36
+
37
+ def write_json(path: Path, payload: dict[str, Any]) -> None:
38
+ path.parent.mkdir(parents=True, exist_ok=True)
39
+ path.write_text(json.dumps(payload, indent=2, sort_keys=True), encoding="utf-8")
40
+
41
+
42
+ def main() -> None:
43
+ parser = argparse.ArgumentParser()
44
+ parser.add_argument("--source-root", type=Path, required=True)
45
+ parser.add_argument("--db-path", type=Path, required=True)
46
+ parser.add_argument("--out-dir", type=Path, required=True)
47
+ args = parser.parse_args()
48
+
49
+ counts = seed_from_legacy(args.source_root, args.db_path, reset=True)
50
+ service = CardDemoService(args.db_path)
51
+ summary = service.summary()
52
+ source_hashes = collect_hashes(
53
+ args.source_root,
54
+ ("*.cbl", "*.CBL", "*.cpy", "*.CPY", "*.bms", "*.jcl", "*.JCL", "*.txt", "*.PS"),
55
+ )
56
+ modern_root = Path(__file__).resolve().parents[1]
57
+ modern_hashes = collect_hashes(modern_root, ("*.py", "*.html", "*.css", "*.js", "*.md"))
58
+ source_head = "59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e"
59
+ capability_evidence = build_parity_evidence(args.source_root, args.db_path, source_head=source_head)
60
+
61
+ receipt = {
62
+ "receipt_version": "modern_carddemo_receipt_v0",
63
+ "generated_utc": datetime.now(timezone.utc).replace(microsecond=0).isoformat(),
64
+ "source_root": str(args.source_root.resolve()),
65
+ "source_head": source_head,
66
+ "modern_root": str(modern_root.resolve()),
67
+ "seed_counts": counts,
68
+ "summary": summary,
69
+ "source_hash_count": len(source_hashes),
70
+ "modern_hash_count": len(modern_hashes),
71
+ "source_hashes": source_hashes,
72
+ "modern_hashes": modern_hashes,
73
+ "supported_capabilities": [
74
+ "customer_search",
75
+ "account_view",
76
+ "account_update",
77
+ "card_list",
78
+ "card_view",
79
+ "card_update",
80
+ "transaction_list",
81
+ "transaction_add",
82
+ "bill_payment",
83
+ "post_transaction",
84
+ "signon",
85
+ "main_menu",
86
+ "admin_menu",
87
+ "user_add",
88
+ "user_update",
89
+ "user_delete",
90
+ "transaction_type_and_category_lookup",
91
+ "transaction_type_maintenance",
92
+ "transaction_report",
93
+ "account_statement",
94
+ "interest_projection",
95
+ "combined_transaction_preview",
96
+ "disclosure_group_seed_load",
97
+ "transaction_category_balance_seed_load",
98
+ "user_security_decode",
99
+ "browser_ui",
100
+ "json_api",
101
+ ],
102
+ "gap_capabilities": [
103
+ f"{row['capability_id']}: {row['function']} ({row['current_grade']})"
104
+ for row in capability_evidence["next_gap_ranking"][:20]
105
+ ],
106
+ "capability_parity": capability_evidence["summary"],
107
+ "proof_grade_meanings": capability_evidence["proof_grade_meanings"],
108
+ "claim_limit": "capability ledger and static-oracle traces only; no all-path COBOL runtime proof yet",
109
+ "public_actions_allowed": False,
110
+ }
111
+ receipt["receipt_hash"] = hashlib.sha256(
112
+ json.dumps(receipt, sort_keys=True, default=str).encode("utf-8")
113
+ ).hexdigest()
114
+ write_json(args.out_dir / "modernization_receipt.json", receipt)
115
+
116
+ parity = {
117
+ "parity_report_version": "modern_carddemo_parity_gap_v0",
118
+ "generated_utc": receipt["generated_utc"],
119
+ "checks": [
120
+ {"check": "customer_seed_count", "expected": 50, "actual": counts["customers"], "passed": counts["customers"] == 50},
121
+ {"check": "account_seed_count", "expected": 50, "actual": counts["accounts"], "passed": counts["accounts"] == 50},
122
+ {"check": "card_seed_count", "expected": 50, "actual": counts["cards"], "passed": counts["cards"] == 50},
123
+ {"check": "transaction_seed_count", "expected": 300, "actual": counts["transactions"], "passed": counts["transactions"] == 300},
124
+ {"check": "user_seed_count", "expected": 10, "actual": counts["users"], "passed": counts["users"] == 10},
125
+ {"check": "source_hashes_recorded", "expected": ">0", "actual": len(source_hashes), "passed": bool(source_hashes)},
126
+ {"check": "modern_hashes_recorded", "expected": ">0", "actual": len(modern_hashes), "passed": bool(modern_hashes)},
127
+ {
128
+ "check": "capability_ledger_materialized",
129
+ "expected": 50,
130
+ "actual": capability_evidence["summary"]["capability_count"],
131
+ "passed": capability_evidence["summary"]["capability_count"] == 50,
132
+ },
133
+ {
134
+ "check": "golden_traces_materialized",
135
+ "expected": ">0",
136
+ "actual": capability_evidence["summary"]["golden_trace_count"],
137
+ "passed": capability_evidence["summary"]["golden_trace_count"] > 0,
138
+ },
139
+ {
140
+ "check": "edge_cases_mined",
141
+ "expected": ">0",
142
+ "actual": capability_evidence["summary"]["edge_case_count"],
143
+ "passed": capability_evidence["summary"]["edge_case_count"] > 0,
144
+ },
145
+ ],
146
+ "unresolved_gaps": receipt["gap_capabilities"],
147
+ "capability_parity": capability_evidence["summary"],
148
+ "proof_grade_meanings": capability_evidence["proof_grade_meanings"],
149
+ "one_for_one_parity_ready": capability_evidence["summary"]["one_for_one_parity_ready"],
150
+ "public_actions_allowed": False,
151
+ }
152
+ parity["passed"] = all(row["passed"] for row in parity["checks"])
153
+ parity["parity_hash"] = hashlib.sha256(json.dumps(parity, sort_keys=True).encode("utf-8")).hexdigest()
154
+ write_json(args.out_dir / "capability_ledger.json", capability_evidence["capability_ledger"])
155
+ write_json(args.out_dir / "golden_traces.json", capability_evidence["golden_traces"])
156
+ write_json(args.out_dir / "edge_cases.json", capability_evidence["edge_cases"])
157
+ write_json(args.out_dir / "next_gap_ranking.json", capability_evidence["next_gap_ranking"])
158
+ write_json(args.out_dir / "parity_gap_report.json", parity)
159
+ print(json.dumps({"receipt": str(args.out_dir / "modernization_receipt.json"), "parity": str(args.out_dir / "parity_gap_report.json"), "passed": parity["passed"]}, indent=2))
160
+
161
+
162
+ if __name__ == "__main__":
163
+ main()
modern_code/tools/package_final_proof.py ADDED
@@ -0,0 +1,619 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import hashlib
5
+ import json
6
+ import shutil
7
+ import subprocess
8
+ from datetime import datetime, timezone
9
+ from pathlib import Path
10
+ from typing import Any
11
+
12
+
13
+ SOURCE_REMOTE = "https://github.com/aws-samples/aws-mainframe-modernization-carddemo.git"
14
+ SOURCE_HEAD = "59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e"
15
+ CLAIM_LIMIT = (
16
+ "This proof is static/source-oracle parity plus executable modern-service replay. "
17
+ "It is not live COBOL/CICS all-path runtime equivalence."
18
+ )
19
+ OUTPUT_FILES = [
20
+ "FINAL_PROOF_README.md",
21
+ "FINAL_RECEIPT_SUMMARY.json",
22
+ "REPRO_COMMANDS.txt",
23
+ "STATIC_ORACLE_REPLAY_REPORT.json",
24
+ "KNOWN_LIMITS.md",
25
+ "ARTIFACT_MANIFEST.json",
26
+ ]
27
+ OPTIONAL_OUTPUT_FILES = [
28
+ "A_GRADE_PROMOTION_REPORT.json",
29
+ "A_GRADE_PROMOTION_README.md",
30
+ "NO_COST_CONFIDENCE_REPORT.json",
31
+ "NO_COST_CONFIDENCE_README.md",
32
+ ]
33
+
34
+
35
+ def read_json(path: Path) -> Any:
36
+ return json.loads(path.read_text(encoding="utf-8"))
37
+
38
+
39
+ def write_json(path: Path, payload: Any) -> None:
40
+ path.parent.mkdir(parents=True, exist_ok=True)
41
+ path.write_text(json.dumps(payload, indent=2, sort_keys=True, default=str) + "\n", encoding="utf-8")
42
+
43
+
44
+ def write_text(path: Path, text: str) -> None:
45
+ path.parent.mkdir(parents=True, exist_ok=True)
46
+ path.write_text(text.rstrip() + "\n", encoding="utf-8")
47
+
48
+
49
+ def sha256_path(path: Path) -> str:
50
+ digest = hashlib.sha256()
51
+ with path.open("rb") as handle:
52
+ for chunk in iter(lambda: handle.read(1024 * 1024), b""):
53
+ digest.update(chunk)
54
+ return digest.hexdigest()
55
+
56
+
57
+ def stable_hash(payload: Any) -> str:
58
+ return hashlib.sha256(json.dumps(payload, sort_keys=True, default=str).encode("utf-8")).hexdigest()
59
+
60
+
61
+ def file_record(path: Path, *, base: Path | None = None, role: str = "artifact") -> dict[str, Any]:
62
+ label = str(path.resolve())
63
+ if base is not None:
64
+ try:
65
+ label = str(path.resolve().relative_to(base.resolve()))
66
+ except ValueError:
67
+ label = str(path.resolve())
68
+ return {
69
+ "path": label.replace("\\", "/"),
70
+ "absolute_path": str(path.resolve()),
71
+ "role": role,
72
+ "exists": path.exists(),
73
+ "size_bytes": path.stat().st_size if path.exists() else None,
74
+ "sha256": sha256_path(path) if path.exists() and path.is_file() else None,
75
+ }
76
+
77
+
78
+ def git_value(source_root: Path, *args: str) -> str:
79
+ safe_dir = source_root.resolve().as_posix()
80
+ result = subprocess.run(
81
+ ["git", "-c", f"safe.directory={safe_dir}", "-C", str(source_root), *args],
82
+ check=False,
83
+ capture_output=True,
84
+ text=True,
85
+ )
86
+ return result.stdout.strip() if result.returncode == 0 else ""
87
+
88
+
89
+ def git_identity(source_root: Path) -> dict[str, Any]:
90
+ return {
91
+ "remote_url": git_value(source_root, "remote", "get-url", "origin") or SOURCE_REMOTE,
92
+ "head": git_value(source_root, "rev-parse", "HEAD") or SOURCE_HEAD,
93
+ "status_short": git_value(source_root, "status", "--short"),
94
+ }
95
+
96
+
97
+ def command_lines(source_head: str) -> dict[str, str]:
98
+ return {
99
+ "setup": r"python -m carddemo.cli init-db --source-root ..\source --db-path .\carddemo.sqlite",
100
+ "run": r"python -m carddemo.cli serve --source-root ..\source --db-path .\carddemo.sqlite --port 8087",
101
+ "test": r"python -m unittest discover -s tests",
102
+ "receipt": r"python tools\generate_receipts.py --source-root ..\source --db-path .\carddemo.sqlite --out-dir .\reports",
103
+ "static_oracle_replay": rf"python tools\replay_static_oracles.py --source-root ..\source --out-dir .\reports --source-head {source_head}",
104
+ "a_grade_promotion": r"python tools\evaluate_a_grade_promotion.py --source-root ..\source --out-dir .\final_proof",
105
+ "no_cost_confidence": r"python tools\build_no_cost_confidence.py --source-root ..\source --out-dir .\final_proof",
106
+ "package_final_proof": r"python tools\package_final_proof.py --source-root ..\source",
107
+ "all_local_proof_no_server": (
108
+ f'powershell -NoProfile -Command "python -m carddemo.cli init-db --source-root ..\\source '
109
+ f'--db-path .\\carddemo.sqlite; python -m unittest discover -s tests; '
110
+ f'python tools\\generate_receipts.py --source-root ..\\source --db-path .\\carddemo.sqlite '
111
+ f'--out-dir .\\reports; python tools\\replay_static_oracles.py --source-root ..\\source '
112
+ f'--out-dir .\\reports --source-head {source_head}; '
113
+ f'python tools\\evaluate_a_grade_promotion.py --source-root ..\\source --out-dir .\\final_proof; '
114
+ f'python tools\\build_no_cost_confidence.py --source-root ..\\source --out-dir .\\final_proof; '
115
+ f'python tools\\package_final_proof.py --source-root ..\\source"'
116
+ ),
117
+ }
118
+
119
+
120
+ def validate_current_rubric(receipt: dict[str, Any], replay: dict[str, Any], next_gaps: list[Any]) -> None:
121
+ parity = receipt["capability_parity"]
122
+ grade_counts = parity["grade_counts"]
123
+ failures = []
124
+ if parity["capability_count"] != 50:
125
+ failures.append(f"capability_count={parity['capability_count']}")
126
+ if grade_counts.get("B") != 50:
127
+ failures.append(f"B={grade_counts.get('B')}")
128
+ if grade_counts.get("F") != 0:
129
+ failures.append(f"F={grade_counts.get('F')}")
130
+ if parity["gap_count"] != 0:
131
+ failures.append(f"gap_count={parity['gap_count']}")
132
+ if next_gaps:
133
+ failures.append("next_gap_ranking_not_empty")
134
+ if not replay.get("passed"):
135
+ failures.append("static_oracle_replay_failed")
136
+ if failures:
137
+ raise SystemExit("Cannot package final proof; rubric checks failed: " + ", ".join(failures))
138
+
139
+
140
+ def load_verification(out_dir: Path) -> dict[str, Any] | None:
141
+ path = out_dir / "CLEAN_REPRO_VERIFICATION.json"
142
+ return read_json(path) if path.exists() else None
143
+
144
+
145
+ def load_a_grade_report(out_dir: Path) -> dict[str, Any] | None:
146
+ path = out_dir / "A_GRADE_PROMOTION_REPORT.json"
147
+ return read_json(path) if path.exists() else None
148
+
149
+
150
+ def load_no_cost_report(out_dir: Path) -> dict[str, Any] | None:
151
+ path = out_dir / "NO_COST_CONFIDENCE_REPORT.json"
152
+ return read_json(path) if path.exists() else None
153
+
154
+
155
+ def summarize_a_grade_report(out_dir: Path, report: dict[str, Any] | None) -> dict[str, Any] | None:
156
+ if report is None:
157
+ return None
158
+ gate = report["a_grade_gate"]
159
+ parity = report["current_static_source_oracle_status"]
160
+ return {
161
+ "path": str((out_dir / "A_GRADE_PROMOTION_REPORT.json").resolve()),
162
+ "readme_path": str((out_dir / "A_GRADE_PROMOTION_README.md").resolve()),
163
+ "report_version": report["report_version"],
164
+ "report_hash": report["report_hash"],
165
+ "generated_utc": report["generated_utc"],
166
+ "decision_action": report["decision"]["action"],
167
+ "promotable_to_A": gate["promotable_to_A"],
168
+ "required_live_matches": gate["required_live_matches"],
169
+ "accepted_live_matches": gate["accepted_live_matches"],
170
+ "missing_live_matches": gate["missing_live_matches"],
171
+ "current_A": gate["current_A"],
172
+ "target_A": gate["target_A"],
173
+ "current_grade_counts": parity["grade_counts"],
174
+ "current_gap_count": parity["gap_count"],
175
+ "blocker_codes": [blocker["code"] for blocker in report.get("blockers", [])],
176
+ "trace_contract": report["legacy_runtime_trace_contract"],
177
+ }
178
+
179
+
180
+ def summarize_no_cost_report(out_dir: Path, report: dict[str, Any] | None) -> dict[str, Any] | None:
181
+ if report is None:
182
+ return None
183
+ summary = report["no_cost_confidence_summary"]
184
+ coverage = report["capability_coverage"]
185
+ replay = report["static_oracle_replay"]
186
+ a_gate = report["a_grade_gate"]
187
+ return {
188
+ "path": str((out_dir / "NO_COST_CONFIDENCE_REPORT.json").resolve()),
189
+ "readme_path": str((out_dir / "NO_COST_CONFIDENCE_README.md").resolve()),
190
+ "report_version": report["report_version"],
191
+ "report_hash": report["report_hash"],
192
+ "generated_utc": report["generated_utc"],
193
+ "reviewer_posture": summary["reviewer_posture"],
194
+ "ready_for_pre_runtime_review": summary["ready_for_pre_runtime_review"],
195
+ "remaining_gap": summary["remaining_gap"],
196
+ "capability_count": coverage["capability_count"],
197
+ "static_oracle_ready_count": coverage["static_oracle_ready_count"],
198
+ "source_ref_total": coverage["source_ref_total"],
199
+ "static_replay_passed": replay["passed"],
200
+ "edge_case_count": report["fixture_corpus"]["edge_case_count"],
201
+ "golden_trace_count": report["fixture_corpus"]["golden_trace_count"],
202
+ "paid_runtime_used": report["no_cost_scope"]["paid_runtime_used"],
203
+ "legacy_runtime_claim_made": report["no_cost_scope"]["legacy_runtime_claim_made"],
204
+ "a_promotable": a_gate["promotable_to_A"],
205
+ "a_missing_live_matches": a_gate["missing_live_matches"],
206
+ }
207
+
208
+
209
+ def build_summary(
210
+ modern_root: Path,
211
+ source_root: Path,
212
+ out_dir: Path,
213
+ receipt: dict[str, Any],
214
+ parity_report: dict[str, Any],
215
+ replay: dict[str, Any],
216
+ next_gaps: list[Any],
217
+ verification: dict[str, Any] | None,
218
+ a_grade_report: dict[str, Any] | None,
219
+ no_cost_report: dict[str, Any] | None,
220
+ ) -> dict[str, Any]:
221
+ source_git = git_identity(source_root)
222
+ commands = command_lines(source_git["head"])
223
+ screenshot = modern_root / "reports" / "ui_batch_reports_smoke.png"
224
+ smoke_evidence = []
225
+ if screenshot.exists():
226
+ smoke_evidence.append(file_record(screenshot, base=modern_root, role="existing_screenshot"))
227
+ if verification and verification.get("api_smoke"):
228
+ smoke_evidence.append(
229
+ {
230
+ "role": "clean_copy_api_smoke",
231
+ "passed": verification.get("api_smoke_passed"),
232
+ "port": verification.get("server_port"),
233
+ "endpoints": list(verification["api_smoke"].keys()),
234
+ }
235
+ )
236
+
237
+ parity = receipt["capability_parity"]
238
+ return {
239
+ "summary_version": "carddemo_final_proof_summary_v0",
240
+ "generated_utc": datetime.now(timezone.utc).replace(microsecond=0).isoformat(),
241
+ "source": {
242
+ "repo_url": source_git["remote_url"],
243
+ "head": source_git["head"],
244
+ "local_path": str(source_root.resolve()),
245
+ "status_short": source_git["status_short"],
246
+ "source_hash_count": receipt["source_hash_count"],
247
+ "source_hashes_digest": stable_hash(receipt["source_hashes"]),
248
+ },
249
+ "modern_code": {
250
+ "local_path": str(modern_root.resolve()),
251
+ "modern_hash_count": receipt["modern_hash_count"],
252
+ "modern_hashes_digest": stable_hash(receipt["modern_hashes"]),
253
+ },
254
+ "commands": commands,
255
+ "receipt": {
256
+ "path": str((modern_root / "reports" / "modernization_receipt.json").resolve()),
257
+ "receipt_hash": receipt["receipt_hash"],
258
+ "generated_utc": receipt["generated_utc"],
259
+ "seed_counts": receipt["seed_counts"],
260
+ "source_head": receipt["source_head"],
261
+ },
262
+ "parity": {
263
+ "rubric": "current static/source-oracle rubric",
264
+ "capability_count": parity["capability_count"],
265
+ "grade_counts": parity["grade_counts"],
266
+ "B": parity["grade_counts"].get("B", 0),
267
+ "F": parity["grade_counts"].get("F", 0),
268
+ "gap_count": parity["gap_count"],
269
+ "next_gap_ranking_count": len(next_gaps),
270
+ "one_for_one_parity_ready": parity["one_for_one_parity_ready"],
271
+ "static_oracle_or_better_count": parity["static_oracle_or_better_count"],
272
+ "strict_runtime_parity_count": parity["strict_runtime_parity_count"],
273
+ "proof_grade_meanings": receipt["proof_grade_meanings"],
274
+ "parity_report_passed": parity_report["passed"],
275
+ "parity_hash": parity_report["parity_hash"],
276
+ },
277
+ "static_oracle_replay": {
278
+ "path": str((out_dir / "STATIC_ORACLE_REPLAY_REPORT.json").resolve()),
279
+ "source_report_path": str((modern_root / "reports" / "static_oracle_replay.json").resolve()),
280
+ "passed": replay["passed"],
281
+ "replay_hash": replay["replay_hash"],
282
+ "evidence_hash": replay["evidence_hash"],
283
+ "runtime_probe_count": replay["runtime_probe_count"],
284
+ "failed_checks": replay["failed_checks"],
285
+ "claim_limit": replay["claim_limit"],
286
+ },
287
+ "smoke_evidence": smoke_evidence,
288
+ "clean_repro_verification": verification,
289
+ "a_grade_promotion": summarize_a_grade_report(out_dir, a_grade_report),
290
+ "no_cost_confidence": summarize_no_cost_report(out_dir, no_cost_report),
291
+ "known_limits": [
292
+ CLAIM_LIMIT,
293
+ "A-grade live legacy runtime trace matching remains 0 under the current proof-grade rubric.",
294
+ "A-grade promotion is gated by A_GRADE_PROMOTION_REPORT.json and requires accepted live legacy runtime traces.",
295
+ "NO_COST_CONFIDENCE_REPORT.json records maximum unpaid/pre-runtime evidence and the remaining paid/runtime validation boundary.",
296
+ "The static replay exercises selected trace expectations; it is not exhaustive path coverage.",
297
+ "The modern app is a local Python/SQLite target and not a production deployment package.",
298
+ ],
299
+ "public_actions_allowed": False,
300
+ "bundle_path": str(out_dir.resolve()),
301
+ }
302
+
303
+
304
+ def final_readme(summary: dict[str, Any]) -> str:
305
+ commands = summary["commands"]
306
+ verification = summary.get("clean_repro_verification") or {}
307
+ a_grade = summary.get("a_grade_promotion")
308
+ no_cost = summary.get("no_cost_confidence")
309
+ clean_status = "not run"
310
+ if verification:
311
+ clean_status = "passed" if verification.get("passed") else "failed"
312
+ smoke_lines = []
313
+ for item in summary["smoke_evidence"]:
314
+ if item["role"] == "existing_screenshot":
315
+ smoke_lines.append(f"- Screenshot: `{item['path']}` SHA-256 `{item['sha256']}`.")
316
+ elif item["role"] == "clean_copy_api_smoke":
317
+ smoke_lines.append(
318
+ f"- Clean-copy API smoke: passed={item['passed']} port={item['port']} endpoints={', '.join(item['endpoints'])}."
319
+ )
320
+ if not smoke_lines:
321
+ smoke_lines.append("- No screenshot or API smoke artifact is bundled.")
322
+ if a_grade:
323
+ a_grade_lines = [
324
+ f"- A-grade gate decision: `{a_grade['decision_action']}`",
325
+ f"- Promotable to A: `{a_grade['promotable_to_A']}`",
326
+ f"- Required live legacy runtime matches: `{a_grade['required_live_matches']}`",
327
+ f"- Accepted live legacy runtime matches: `{a_grade['accepted_live_matches']}`",
328
+ f"- Missing live legacy runtime matches: `{a_grade['missing_live_matches']}`",
329
+ f"- A-grade report hash: `{a_grade['report_hash']}`",
330
+ ]
331
+ else:
332
+ a_grade_lines = ["- A-grade promotion gate was not run before packaging."]
333
+ if no_cost:
334
+ no_cost_lines = [
335
+ f"- Reviewer posture: `{no_cost['reviewer_posture']}`",
336
+ f"- Ready for pre-runtime review: `{no_cost['ready_for_pre_runtime_review']}`",
337
+ f"- Paid runtime used: `{no_cost['paid_runtime_used']}`",
338
+ f"- Legacy runtime claim made: `{no_cost['legacy_runtime_claim_made']}`",
339
+ f"- Source-backed static capabilities: `{no_cost['static_oracle_ready_count']}`",
340
+ f"- Source refs in capability ledger: `{no_cost['source_ref_total']}`",
341
+ f"- Golden traces / edge cases: `{no_cost['golden_trace_count']}` / `{no_cost['edge_case_count']}`",
342
+ f"- Remaining gap: `{no_cost['remaining_gap']}`",
343
+ f"- No-cost confidence report hash: `{no_cost['report_hash']}`",
344
+ ]
345
+ else:
346
+ no_cost_lines = ["- No-cost confidence proof was not run before packaging."]
347
+
348
+ return f"""
349
+ # AWS CardDemo Modernization Final Proof
350
+
351
+ This bundle packages the local AWS CardDemo modernization run as a reproducible technical-review artifact. It does not add application features; it records the source identity, modern code location, commands, receipts, static-oracle replay, no-cost confidence proof, A-grade promotion gate, known limits, and clean-copy verification status.
352
+
353
+ ## Source Identity
354
+
355
+ - Source repo: `{summary['source']['repo_url']}`
356
+ - Source version: `{summary['source']['head']}`
357
+ - Source local path used for this run: `{summary['source']['local_path']}`
358
+ - Source file hash count in receipt: `{summary['source']['source_hash_count']}`
359
+ - Source hash digest over receipt map: `{summary['source']['source_hashes_digest']}`
360
+
361
+ ## Modern Code
362
+
363
+ - Modern code path: `{summary['modern_code']['local_path']}`
364
+ - Modern file hash count in receipt: `{summary['modern_code']['modern_hash_count']}`
365
+ - Modern hash digest over receipt map: `{summary['modern_code']['modern_hashes_digest']}`
366
+
367
+ ## One-Command Setup And Run
368
+
369
+ Run these from the modern code root with the AWS CardDemo source clone/copy at `..\\source`.
370
+
371
+ Setup database:
372
+
373
+ ```powershell
374
+ {commands['setup']}
375
+ ```
376
+
377
+ Run web/API server:
378
+
379
+ ```powershell
380
+ {commands['run']}
381
+ ```
382
+
383
+ Open `http://127.0.0.1:8087`.
384
+
385
+ ## One-Command Tests
386
+
387
+ ```powershell
388
+ {commands['test']}
389
+ ```
390
+
391
+ ## One-Command Static-Oracle Replay
392
+
393
+ ```powershell
394
+ {commands['static_oracle_replay']}
395
+ ```
396
+
397
+ ## One-Command A-Grade Promotion Gate
398
+
399
+ ```powershell
400
+ {commands['a_grade_promotion']}
401
+ ```
402
+
403
+ ## One-Command No-Cost Confidence Proof
404
+
405
+ ```powershell
406
+ {commands['no_cost_confidence']}
407
+ ```
408
+
409
+ ## Full Local Proof Refresh
410
+
411
+ ```powershell
412
+ {commands['all_local_proof_no_server']}
413
+ ```
414
+
415
+ ## Final Receipt Summary
416
+
417
+ - Receipt hash: `{summary['receipt']['receipt_hash']}`
418
+ - Receipt generated: `{summary['receipt']['generated_utc']}`
419
+ - Static replay hash: `{summary['static_oracle_replay']['replay_hash']}`
420
+ - Static replay passed: `{summary['static_oracle_replay']['passed']}`
421
+ - Runtime probe count: `{summary['static_oracle_replay']['runtime_probe_count']}`
422
+ - Failed replay checks: `{summary['static_oracle_replay']['failed_checks']}`
423
+
424
+ ## Parity Summary
425
+
426
+ Under the current static/source-oracle rubric:
427
+
428
+ - Capability count: `{summary['parity']['capability_count']}`
429
+ - B-grade static/source-oracle capabilities: `{summary['parity']['B']}`
430
+ - F-grade gaps: `{summary['parity']['F']}`
431
+ - Gap count: `{summary['parity']['gap_count']}`
432
+ - Next-gap ranking count: `{summary['parity']['next_gap_ranking_count']}`
433
+ - Static-oracle-or-better count: `{summary['parity']['static_oracle_or_better_count']}`
434
+ - A-grade live legacy runtime trace count: `{summary['parity']['strict_runtime_parity_count']}`
435
+
436
+ Proof grade meanings are recorded in `FINAL_RECEIPT_SUMMARY.json`.
437
+
438
+ ## No-Cost Confidence Proof
439
+
440
+ {chr(10).join(no_cost_lines)}
441
+
442
+ This is the maximum unpaid/pre-runtime evidence layer. It is meant to convince a technical reviewer that the modernization is probably functional under the extracted legacy-derived behavior, while preserving the live runtime validation gap.
443
+
444
+ ## A-Grade Promotion Gate
445
+
446
+ {chr(10).join(a_grade_lines)}
447
+
448
+ The A-grade gate is intentionally stricter than the B-grade static/source-oracle proof. It requires accepted live legacy COBOL/CICS runtime trace matches for each capability before any capability can be promoted to A.
449
+
450
+ ## Smoke Evidence
451
+
452
+ {chr(10).join(smoke_lines)}
453
+
454
+ ## Clean-Copy Verification
455
+
456
+ - Clean-copy verification status: `{clean_status}`
457
+ - Verification report included in `FINAL_RECEIPT_SUMMARY.json` when present.
458
+
459
+ ## Caveat
460
+
461
+ {CLAIM_LIMIT}
462
+
463
+ See `KNOWN_LIMITS.md` for the full claim boundary.
464
+ """
465
+
466
+
467
+ def known_limits() -> str:
468
+ return f"""
469
+ # Known Limits
470
+
471
+ {CLAIM_LIMIT}
472
+
473
+ - Proof grade `B` means static legacy data/copybook/source-oracle match. It does not mean the original COBOL/CICS system was executed and compared for every path.
474
+ - Proof grade `A` is reserved for actual legacy runtime trace match; this bundle records `A=0`.
475
+ - `A_GRADE_PROMOTION_REPORT.json` is the executable promotion gate. It fails closed unless accepted live legacy runtime trace records exist for every capability.
476
+ - `NO_COST_CONFIDENCE_REPORT.json` records maximum unpaid/pre-runtime evidence. It is designed to support review confidence, not to replace live legacy validation.
477
+ - The replay report executes the modern Python service against extracted static/source-oracle expectations. It is useful evidence, but not exhaustive path coverage.
478
+ - The source data and copybooks are from AWS CardDemo at the pinned source version in `FINAL_RECEIPT_SUMMARY.json`.
479
+ - The app is a local Python/SQLite modernization target. Production concerns such as deployment topology, operations, security hardening, and load testing are outside this proof bundle.
480
+ - Public release, upload, or promotion is intentionally not performed by this bundle.
481
+ """
482
+
483
+
484
+ def repro_commands(summary: dict[str, Any]) -> str:
485
+ commands = summary["commands"]
486
+ return f"""
487
+ Run from the modern code root. The source clone/copy must be at ..\\source.
488
+
489
+ SOURCE REPO:
490
+ {summary['source']['repo_url']}
491
+
492
+ SOURCE HEAD:
493
+ {summary['source']['head']}
494
+
495
+ MODERN CODE:
496
+ {summary['modern_code']['local_path']}
497
+
498
+ SETUP:
499
+ {commands['setup']}
500
+
501
+ RUN SERVER:
502
+ {commands['run']}
503
+
504
+ TEST:
505
+ {commands['test']}
506
+
507
+ STATIC ORACLE REPLAY:
508
+ {commands['static_oracle_replay']}
509
+
510
+ A-GRADE PROMOTION GATE:
511
+ {commands['a_grade_promotion']}
512
+
513
+ NO-COST CONFIDENCE PROOF:
514
+ {commands['no_cost_confidence']}
515
+
516
+ REGENERATE RECEIPTS:
517
+ {commands['receipt']}
518
+
519
+ PACKAGE FINAL PROOF:
520
+ {commands['package_final_proof']}
521
+
522
+ FULL LOCAL PROOF REFRESH WITHOUT SERVER:
523
+ {commands['all_local_proof_no_server']}
524
+
525
+ CAVEAT:
526
+ {CLAIM_LIMIT}
527
+ """
528
+
529
+
530
+ def build_manifest(out_dir: Path, modern_root: Path) -> dict[str, Any]:
531
+ bundle_names = [name for name in OUTPUT_FILES if name != "ARTIFACT_MANIFEST.json"]
532
+ bundle_names.extend(name for name in OPTIONAL_OUTPUT_FILES if (out_dir / name).exists())
533
+ bundle_files = [file_record(out_dir / name, base=out_dir, role="final_bundle_output") for name in bundle_names]
534
+ existing = [
535
+ modern_root / "reports" / "modernization_receipt.json",
536
+ modern_root / "reports" / "parity_gap_report.json",
537
+ modern_root / "reports" / "capability_ledger.json",
538
+ modern_root / "reports" / "golden_traces.json",
539
+ modern_root / "reports" / "edge_cases.json",
540
+ modern_root / "reports" / "next_gap_ranking.json",
541
+ modern_root / "reports" / "static_oracle_replay.json",
542
+ modern_root / "reports" / "ui_batch_reports_smoke.png",
543
+ ]
544
+ verification = out_dir / "CLEAN_REPRO_VERIFICATION.json"
545
+ if verification.exists():
546
+ existing.append(verification)
547
+ payload = {
548
+ "manifest_version": "carddemo_final_proof_manifest_v0",
549
+ "generated_utc": datetime.now(timezone.utc).replace(microsecond=0).isoformat(),
550
+ "bundle_path": str(out_dir.resolve()),
551
+ "bundle_files": bundle_files,
552
+ "referenced_existing_artifacts": [file_record(path, base=modern_root, role="referenced_evidence") for path in existing if path.exists()],
553
+ "public_actions_allowed": False,
554
+ }
555
+ payload["manifest_payload_hash"] = stable_hash(payload)
556
+ return payload
557
+
558
+
559
+ def main() -> None:
560
+ parser = argparse.ArgumentParser(description="Package the final CardDemo proof bundle")
561
+ parser.add_argument("--modern-root", type=Path, default=Path(__file__).resolve().parents[1])
562
+ parser.add_argument("--source-root", type=Path, default=Path(__file__).resolve().parents[2] / "source")
563
+ parser.add_argument("--out-dir", type=Path, default=None)
564
+ args = parser.parse_args()
565
+
566
+ modern_root = args.modern_root.resolve()
567
+ source_root = args.source_root.resolve()
568
+ out_dir = (args.out_dir or modern_root / "final_proof").resolve()
569
+ reports = modern_root / "reports"
570
+
571
+ receipt = read_json(reports / "modernization_receipt.json")
572
+ parity_report = read_json(reports / "parity_gap_report.json")
573
+ replay = read_json(reports / "static_oracle_replay.json")
574
+ next_gaps = read_json(reports / "next_gap_ranking.json")
575
+ validate_current_rubric(receipt, replay, next_gaps)
576
+
577
+ out_dir.mkdir(parents=True, exist_ok=True)
578
+ verification = load_verification(out_dir)
579
+ a_grade_report = load_a_grade_report(out_dir)
580
+ no_cost_report = load_no_cost_report(out_dir)
581
+ summary = build_summary(
582
+ modern_root,
583
+ source_root,
584
+ out_dir,
585
+ receipt,
586
+ parity_report,
587
+ replay,
588
+ next_gaps,
589
+ verification,
590
+ a_grade_report,
591
+ no_cost_report,
592
+ )
593
+
594
+ shutil.copy2(reports / "static_oracle_replay.json", out_dir / "STATIC_ORACLE_REPLAY_REPORT.json")
595
+ write_json(out_dir / "FINAL_RECEIPT_SUMMARY.json", summary)
596
+ write_text(out_dir / "FINAL_PROOF_README.md", final_readme(summary))
597
+ write_text(out_dir / "REPRO_COMMANDS.txt", repro_commands(summary))
598
+ write_text(out_dir / "KNOWN_LIMITS.md", known_limits())
599
+ write_json(out_dir / "ARTIFACT_MANIFEST.json", build_manifest(out_dir, modern_root))
600
+
601
+ print(
602
+ json.dumps(
603
+ {
604
+ "out_dir": str(out_dir),
605
+ "files": OUTPUT_FILES,
606
+ "parity": summary["parity"],
607
+ "static_oracle_replay": summary["static_oracle_replay"],
608
+ "a_grade_promotion": summary["a_grade_promotion"],
609
+ "no_cost_confidence": summary["no_cost_confidence"],
610
+ "clean_repro_verification_present": verification is not None,
611
+ },
612
+ indent=2,
613
+ sort_keys=True,
614
+ )
615
+ )
616
+
617
+
618
+ if __name__ == "__main__":
619
+ main()
modern_code/tools/replay_static_oracles.py ADDED
@@ -0,0 +1,396 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import hashlib
5
+ import json
6
+ import sys
7
+ from datetime import datetime, timezone
8
+ from pathlib import Path
9
+ from typing import Any
10
+
11
+ PROJECT_ROOT = Path(__file__).resolve().parents[1]
12
+ if str(PROJECT_ROOT) not in sys.path:
13
+ sys.path.insert(0, str(PROJECT_ROOT))
14
+
15
+ from carddemo.parity import build_parity_evidence
16
+ from carddemo.repository import seed_from_legacy
17
+ from carddemo.service import CardDemoService
18
+
19
+
20
+ DEFAULT_SOURCE_HEAD = "59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e"
21
+ CLAIM_LIMIT = (
22
+ "Executable modern replay over static/source-oracle traces only; "
23
+ "no live COBOL/CICS runtime replay has been performed."
24
+ )
25
+
26
+ EXPECTED_SEED_COUNTS = {
27
+ "customers": 50,
28
+ "accounts": 50,
29
+ "cards": 50,
30
+ "card_xrefs": 50,
31
+ "transactions": 300,
32
+ "transaction_types": 7,
33
+ "transaction_categories": 18,
34
+ "disclosure_groups": 51,
35
+ "transaction_category_balances": 50,
36
+ "users": 10,
37
+ "pending_authorization_summaries": 21,
38
+ "pending_authorization_details": 202,
39
+ }
40
+
41
+ REQUIRED_TRACE_IDS = {
42
+ "mq_system_date_cdrd_reply",
43
+ "mq_account_inquiry_cdra_success_and_invalid",
44
+ "batch_resource_setup_gdg_vsam_aix_cics",
45
+ "pending_authorization_cpvs_summary_page",
46
+ "pending_authorization_cp00_request_response_and_insert",
47
+ "transaction_type_lookup",
48
+ }
49
+
50
+ REQUIRED_EDGE_CASE_IDS = {
51
+ "mq_cdrd_request_payload_ignored",
52
+ "mq_cdra_inqa_account_key_validation",
53
+ "batch_gdg_limit_scratch_first_generation",
54
+ "vsam_esds_rrds_user_security_layout",
55
+ "transaction_aix_processed_timestamp_key",
56
+ "cics_file_control_command_set",
57
+ "pending_authorization_ims_segment_header_offset",
58
+ "authorization_available_credit_boundary",
59
+ }
60
+
61
+
62
+ def stable_json_hash(payload: Any) -> str:
63
+ return hashlib.sha256(json.dumps(payload, sort_keys=True, default=str).encode("utf-8")).hexdigest()
64
+
65
+
66
+ def write_json(path: Path, payload: Any) -> Path:
67
+ path.parent.mkdir(parents=True, exist_ok=True)
68
+ path.write_text(json.dumps(payload, indent=2, sort_keys=True, default=str) + "\n", encoding="utf-8")
69
+ return path
70
+
71
+
72
+ def add_check(
73
+ checks: list[dict[str, Any]],
74
+ name: str,
75
+ passed: bool,
76
+ *,
77
+ expected: Any = None,
78
+ actual: Any = None,
79
+ details: dict[str, Any] | None = None,
80
+ ) -> None:
81
+ row: dict[str, Any] = {"check": name, "passed": bool(passed)}
82
+ if expected is not None:
83
+ row["expected"] = expected
84
+ if actual is not None:
85
+ row["actual"] = actual
86
+ if details:
87
+ row["details"] = details
88
+ checks.append(row)
89
+
90
+
91
+ def trace_expectations(evidence: dict[str, Any]) -> dict[str, dict[str, Any]]:
92
+ return {row["trace_id"]: row["expected"] for row in evidence["golden_traces"]}
93
+
94
+
95
+ def add_runtime_probe(
96
+ checks: list[dict[str, Any]],
97
+ runtime_probes: list[dict[str, Any]],
98
+ trace_id: str,
99
+ actual: dict[str, Any],
100
+ expected_by_trace: dict[str, dict[str, Any]],
101
+ ) -> None:
102
+ expected = expected_by_trace.get(trace_id, {})
103
+ passed = bool(expected) and actual == expected
104
+ runtime_probes.append(
105
+ {
106
+ "trace_id": trace_id,
107
+ "passed": passed,
108
+ "expected": expected,
109
+ "actual": actual,
110
+ }
111
+ )
112
+ add_check(checks, f"{trace_id}_runtime_probe", passed, expected=expected, actual=actual)
113
+
114
+
115
+ def build_runtime_probes(service: CardDemoService, expected_by_trace: dict[str, dict[str, Any]]) -> list[dict[str, Any]]:
116
+ checks: list[dict[str, Any]] = []
117
+ runtime_probes: list[dict[str, Any]] = []
118
+
119
+ mq_date = service.mq_system_date({"request_message": "IGNR00000000001"}, now="2026-05-23T11:12:13")
120
+ add_runtime_probe(
121
+ checks,
122
+ runtime_probes,
123
+ "mq_system_date_cdrd_reply",
124
+ {
125
+ "legacy_transaction": mq_date["legacy_transaction"],
126
+ "legacy_program": mq_date["legacy_program"],
127
+ "reply_queue": mq_date["reply_queue"],
128
+ "system_date": mq_date["system_date"],
129
+ "system_time": mq_date["system_time"],
130
+ "reply_message": mq_date["reply_message"],
131
+ "request_payload_validated": False,
132
+ },
133
+ expected_by_trace,
134
+ )
135
+
136
+ mq_account = service.mq_account_inquiry({"request_message": "INQA00000000001"})
137
+ mq_account_not_found = service.mq_account_inquiry({"function": "INQA", "account_id": 99999999999})
138
+ mq_account_bad_function = service.mq_account_inquiry({"function": "BAD", "account_id": 1})
139
+ add_runtime_probe(
140
+ checks,
141
+ runtime_probes,
142
+ "mq_account_inquiry_cdra_success_and_invalid",
143
+ {
144
+ "legacy_transaction": mq_account["legacy_transaction"],
145
+ "legacy_program": mq_account["legacy_program"],
146
+ "reply_queue": mq_account["reply_queue"],
147
+ "request_account_key": mq_account["request"]["account_id_text"],
148
+ "account_id": mq_account["account_data"]["account_id"],
149
+ "active_status": mq_account["account_data"]["active_status"],
150
+ "reply_has_account_label": "ACCOUNT ID : 00000000001" in mq_account["reply_message"],
151
+ "not_found_reply": mq_account_not_found["reply_message"],
152
+ "bad_function_reply": mq_account_bad_function["reply_message"],
153
+ },
154
+ expected_by_trace,
155
+ )
156
+
157
+ resource_setup = service.batch_resource_setup()
158
+ gdg_base_setup = service.batch_resource_setup("DEFGDGB")
159
+ db2_gdg_setup = service.batch_resource_setup("DEFGDGD")
160
+ esds_rrds_setup = service.batch_resource_setup("ESDSRRDS")
161
+ tranidx_setup = service.batch_resource_setup("TRANIDX")
162
+ closefil_setup = service.batch_resource_setup("CLOSEFIL")
163
+ openfil_setup = service.batch_resource_setup("OPENFIL")
164
+ add_runtime_probe(
165
+ checks,
166
+ runtime_probes,
167
+ "batch_resource_setup_gdg_vsam_aix_cics",
168
+ {
169
+ "resource_count": resource_setup["resource_count"],
170
+ "base_gdg_names": [row["name"] for row in gdg_base_setup["gdg_bases"]],
171
+ "db2_first_generation_counts": [
172
+ db2_gdg_setup["steps"][1]["record_count"],
173
+ db2_gdg_setup["steps"][3]["record_count"],
174
+ db2_gdg_setup["steps"][5]["record_count"],
175
+ ],
176
+ "esds_rrds_organizations": [row["organization"] for row in esds_rrds_setup["clusters"]],
177
+ "tranidx_keys": tranidx_setup["alternate_index"]["keys"],
178
+ "tranidx_source_count": tranidx_setup["bldindex"]["source_record_count"],
179
+ "close_code": closefil_setup["cemt_code"],
180
+ "open_code": openfil_setup["cemt_code"],
181
+ "file_sets_match": closefil_setup["files"] == openfil_setup["files"],
182
+ },
183
+ expected_by_trace,
184
+ )
185
+
186
+ pending_summary = service.pending_authorization_summary(1, page_size=5)
187
+ add_runtime_probe(
188
+ checks,
189
+ runtime_probes,
190
+ "pending_authorization_cpvs_summary_page",
191
+ {
192
+ "summary_count": pending_summary["summary"]["approved_auth_count"],
193
+ "summary_amount_cents": pending_summary["summary"]["approved_auth_amount_cents"],
194
+ "returned_authorizations": len(pending_summary["authorizations"]),
195
+ "next_page": pending_summary["next_page"],
196
+ "first_transaction_id": pending_summary["authorizations"][0]["transaction_id"],
197
+ },
198
+ expected_by_trace,
199
+ )
200
+
201
+ tx_types = service.transaction_types()
202
+ tx_types_filtered = service.transaction_types(type_filter="01")
203
+ tx_types_desc_filtered = service.transaction_types(description_filter="%PAYMENT%")
204
+ tx_types_backward = service.transaction_types(start_key="07", direction="backward", page_size=3)
205
+ add_runtime_probe(
206
+ checks,
207
+ runtime_probes,
208
+ "transaction_type_lookup",
209
+ {
210
+ "legacy_transaction": tx_types["legacy_transaction"],
211
+ "legacy_program": tx_types["legacy_program"],
212
+ "type_count": len(tx_types["types"]),
213
+ "category_count": len(tx_types["categories"]),
214
+ "page_size": tx_types["page"]["page_size"],
215
+ "type_filter_result": [row["type_code"] for row in tx_types_filtered["types"]],
216
+ "description_filter_count": len(tx_types_desc_filtered["types"]),
217
+ "backward_page_type_codes": [row["type_code"] for row in tx_types_backward["types"]],
218
+ },
219
+ expected_by_trace,
220
+ )
221
+
222
+ account_bundle = service.get_account_bundle(1) or {}
223
+ cards = account_bundle.get("cards", [])
224
+ card_number = cards[0]["card_number"] if cards else "9680294154603697"
225
+ cp00_before = service.pending_authorization_summary(1, page_size=1)
226
+ cp00 = service.process_authorization_request(
227
+ {
228
+ "card_number": card_number,
229
+ "auth_date": "260523",
230
+ "auth_time": "111213",
231
+ "card_expiry_date": "1129",
232
+ "transaction_amount_cents": 100,
233
+ "merchant_category_code": "5442",
234
+ "merchant_id": "123501000675423",
235
+ "merchant_name": "Amazon.com",
236
+ "merchant_city": "Wilmington",
237
+ "merchant_state": "DE",
238
+ "merchant_zip": "19801",
239
+ "transaction_id": "AUTHREQ00000001",
240
+ "processing_datetime": "2026-05-23T11:12:13.456",
241
+ }
242
+ )
243
+ cp00_after = service.pending_authorization_summary(1, page_size=1)
244
+ cp00_invalid = service.process_authorization_request(
245
+ {
246
+ "card_number": "9999999999999999",
247
+ "transaction_amount_cents": 100,
248
+ "transaction_id": "AUTHREQBAD0001",
249
+ }
250
+ )
251
+ add_runtime_probe(
252
+ checks,
253
+ runtime_probes,
254
+ "pending_authorization_cp00_request_response_and_insert",
255
+ {
256
+ "approved": cp00["approved"],
257
+ "response_code": cp00["response"]["auth_resp_code"],
258
+ "response_reason": cp00["response"]["auth_resp_reason"],
259
+ "written": cp00["written_to_pending_authorizations"],
260
+ "approved_count_delta": cp00_after["summary"]["approved_auth_count"]
261
+ - cp00_before["summary"]["approved_auth_count"],
262
+ "invalid_card_response_reason": cp00_invalid["response"]["auth_resp_reason"],
263
+ "invalid_card_written": cp00_invalid["written_to_pending_authorizations"],
264
+ },
265
+ expected_by_trace,
266
+ )
267
+
268
+ return checks + runtime_probes
269
+
270
+
271
+ def build_static_oracle_replay(source_root: Path, db_path: Path, *, source_head: str = DEFAULT_SOURCE_HEAD) -> dict[str, Any]:
272
+ source_root = Path(source_root)
273
+ db_path = Path(db_path)
274
+ db_path.parent.mkdir(parents=True, exist_ok=True)
275
+
276
+ seed_counts = seed_from_legacy(source_root, db_path, reset=True)
277
+ evidence = build_parity_evidence(source_root, db_path, source_head=source_head)
278
+ summary = evidence["summary"]
279
+ checks: list[dict[str, Any]] = []
280
+
281
+ actual_seed_counts = {key: seed_counts.get(key) for key in EXPECTED_SEED_COUNTS}
282
+ add_check(
283
+ checks,
284
+ "legacy_seed_count_contract",
285
+ actual_seed_counts == EXPECTED_SEED_COUNTS,
286
+ expected=EXPECTED_SEED_COUNTS,
287
+ actual=actual_seed_counts,
288
+ )
289
+ add_check(checks, "zero_capability_gaps", summary["gap_count"] == 0, expected=0, actual=summary["gap_count"])
290
+ add_check(checks, "empty_next_gap_ranking", evidence["next_gap_ranking"] == [], expected=[], actual=evidence["next_gap_ranking"])
291
+ add_check(
292
+ checks,
293
+ "all_capabilities_static_oracle_or_better",
294
+ summary["static_oracle_or_better_count"] == summary["capability_count"],
295
+ expected=summary["capability_count"],
296
+ actual=summary["static_oracle_or_better_count"],
297
+ )
298
+ add_check(
299
+ checks,
300
+ "no_partial_or_inferred_capabilities",
301
+ summary["partial_or_inferred_count"] == 0,
302
+ expected=0,
303
+ actual=summary["partial_or_inferred_count"],
304
+ )
305
+
306
+ trace_ids = {row["trace_id"] for row in evidence["golden_traces"]}
307
+ edge_case_ids = {row["edge_case_id"] for row in evidence["edge_cases"]}
308
+ missing_traces = sorted(REQUIRED_TRACE_IDS - trace_ids)
309
+ missing_edge_cases = sorted(REQUIRED_EDGE_CASE_IDS - edge_case_ids)
310
+ add_check(
311
+ checks,
312
+ "required_static_oracle_traces_present",
313
+ not missing_traces,
314
+ expected=sorted(REQUIRED_TRACE_IDS),
315
+ actual=sorted(trace_ids & REQUIRED_TRACE_IDS),
316
+ details={"missing": missing_traces},
317
+ )
318
+ add_check(
319
+ checks,
320
+ "required_edge_cases_present",
321
+ not missing_edge_cases,
322
+ expected=sorted(REQUIRED_EDGE_CASE_IDS),
323
+ actual=sorted(edge_case_ids & REQUIRED_EDGE_CASE_IDS),
324
+ details={"missing": missing_edge_cases},
325
+ )
326
+ add_check(
327
+ checks,
328
+ "all_golden_traces_static_oracle_or_better",
329
+ all(row["proof_grade"] in {"A", "B"} for row in evidence["golden_traces"]),
330
+ actual={row["trace_id"]: row["proof_grade"] for row in evidence["golden_traces"]},
331
+ )
332
+
333
+ expected_by_trace = trace_expectations(evidence)
334
+ service = CardDemoService(db_path)
335
+ probe_rows = build_runtime_probes(service, expected_by_trace)
336
+ runtime_probe_checks = [row for row in probe_rows if "check" in row]
337
+ runtime_probes = [row for row in probe_rows if "trace_id" in row]
338
+ checks.extend(runtime_probe_checks)
339
+
340
+ failed_checks = [row["check"] for row in checks if not row["passed"]]
341
+ report = {
342
+ "replay_version": "modern_carddemo_static_oracle_replay_v0",
343
+ "generated_utc": datetime.now(timezone.utc).replace(microsecond=0).isoformat(),
344
+ "source_root": str(source_root.resolve()),
345
+ "source_head": source_head,
346
+ "scratch_db_path": str(db_path.resolve()),
347
+ "seed_counts": seed_counts,
348
+ "summary": summary,
349
+ "capability_count": summary["capability_count"],
350
+ "grade_counts": summary["grade_counts"],
351
+ "gap_count": summary["gap_count"],
352
+ "golden_trace_count": len(evidence["golden_traces"]),
353
+ "edge_case_count": len(evidence["edge_cases"]),
354
+ "runtime_probe_count": len(runtime_probes),
355
+ "checks": checks,
356
+ "runtime_probes": runtime_probes,
357
+ "failed_checks": failed_checks,
358
+ "passed": not failed_checks,
359
+ "claim_limit": CLAIM_LIMIT,
360
+ "public_actions_allowed": False,
361
+ "evidence_hash": stable_json_hash(evidence),
362
+ }
363
+ report["replay_hash"] = stable_json_hash(report)
364
+ return report
365
+
366
+
367
+ def main() -> None:
368
+ parser = argparse.ArgumentParser()
369
+ parser.add_argument("--source-root", type=Path, required=True)
370
+ parser.add_argument("--db-path", type=Path)
371
+ parser.add_argument("--out-dir", type=Path, required=True)
372
+ parser.add_argument("--source-head", default=DEFAULT_SOURCE_HEAD)
373
+ args = parser.parse_args()
374
+
375
+ args.out_dir.mkdir(parents=True, exist_ok=True)
376
+ db_path = args.db_path or args.out_dir / "static_oracle_replay.sqlite"
377
+ report = build_static_oracle_replay(args.source_root, db_path, source_head=args.source_head)
378
+ report_path = write_json(args.out_dir / "static_oracle_replay.json", report)
379
+ print(
380
+ json.dumps(
381
+ {
382
+ "replay": str(report_path),
383
+ "passed": report["passed"],
384
+ "replay_hash": report["replay_hash"],
385
+ "failed_checks": report["failed_checks"],
386
+ "claim_limit": report["claim_limit"],
387
+ },
388
+ indent=2,
389
+ )
390
+ )
391
+ if not report["passed"]:
392
+ raise SystemExit(1)
393
+
394
+
395
+ if __name__ == "__main__":
396
+ main()
modern_code/tools/verify_clean_repro.py ADDED
@@ -0,0 +1,274 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import json
5
+ import shutil
6
+ import socket
7
+ import subprocess
8
+ import sys
9
+ import time
10
+ import urllib.request
11
+ from datetime import datetime, timezone
12
+ from pathlib import Path
13
+ from typing import Any
14
+
15
+
16
+ SOURCE_HEAD = "59cc6c2fd7ebd7ef7925cad552a01a4b8b6e4d5e"
17
+
18
+
19
+ def write_json(path: Path, payload: Any) -> None:
20
+ path.parent.mkdir(parents=True, exist_ok=True)
21
+ path.write_text(json.dumps(payload, indent=2, sort_keys=True, default=str) + "\n", encoding="utf-8")
22
+
23
+
24
+ def truncate(text: str, limit: int = 4000) -> str:
25
+ return text[-limit:] if len(text) > limit else text
26
+
27
+
28
+ def ignore_modern(dir_path: str, names: list[str]) -> set[str]:
29
+ ignored = {"reports", "final_proof", ".dettools_checkpoints", "__pycache__"}
30
+ ignored.update(name for name in names if name.endswith(".pyc"))
31
+ ignored.update(name for name in names if name.startswith(".dettools_"))
32
+ ignored.update(name for name in names if name == "carddemo.sqlite")
33
+ return ignored & set(names)
34
+
35
+
36
+ def ignore_source(dir_path: str, names: list[str]) -> set[str]:
37
+ ignored = {".git", "__pycache__"}
38
+ ignored.update(name for name in names if name.endswith(".pyc"))
39
+ return ignored & set(names)
40
+
41
+
42
+ def copy_clean_workspace(modern_root: Path, source_root: Path, scratch_root: Path) -> dict[str, str]:
43
+ if scratch_root.exists():
44
+ raise SystemExit(f"scratch root already exists; choose another path: {scratch_root}")
45
+ source_copy = scratch_root / "source"
46
+ modern_copy = scratch_root / "modern_carddemo"
47
+ scratch_root.mkdir(parents=True)
48
+ shutil.copytree(source_root, source_copy, ignore=ignore_source)
49
+ shutil.copytree(modern_root, modern_copy, ignore=ignore_modern)
50
+ return {"scratch_root": str(scratch_root), "source_copy": str(source_copy), "modern_copy": str(modern_copy)}
51
+
52
+
53
+ def run_command(name: str, command: list[str], cwd: Path, timeout: int = 120) -> dict[str, Any]:
54
+ started = time.monotonic()
55
+ result = subprocess.run(command, cwd=cwd, capture_output=True, text=True, timeout=timeout)
56
+ return {
57
+ "name": name,
58
+ "command": " ".join(command),
59
+ "cwd": str(cwd),
60
+ "returncode": result.returncode,
61
+ "passed": result.returncode == 0,
62
+ "duration_seconds": round(time.monotonic() - started, 3),
63
+ "stdout_tail": truncate(result.stdout),
64
+ "stderr_tail": truncate(result.stderr),
65
+ }
66
+
67
+
68
+ def free_port(start: int = 8091, stop: int = 8999) -> int:
69
+ for port in range(start, stop + 1):
70
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
71
+ sock.settimeout(0.1)
72
+ if sock.connect_ex(("127.0.0.1", port)) != 0:
73
+ return port
74
+ raise SystemExit("no free local port found for clean server smoke")
75
+
76
+
77
+ def fetch_json(url: str, timeout: float = 5.0) -> Any:
78
+ with urllib.request.urlopen(url, timeout=timeout) as response:
79
+ return json.loads(response.read().decode("utf-8"))
80
+
81
+
82
+ def wait_for_server(port: int, timeout_seconds: float = 10.0) -> None:
83
+ deadline = time.monotonic() + timeout_seconds
84
+ last_error = ""
85
+ while time.monotonic() < deadline:
86
+ try:
87
+ fetch_json(f"http://127.0.0.1:{port}/api/health", timeout=1.0)
88
+ return
89
+ except Exception as exc: # noqa: BLE001
90
+ last_error = str(exc)
91
+ time.sleep(0.25)
92
+ raise RuntimeError(f"server did not become healthy on port {port}: {last_error}")
93
+
94
+
95
+ def run_server_smoke(modern_copy: Path, port: int) -> dict[str, Any]:
96
+ out_path = modern_copy / "server_smoke.out.log"
97
+ err_path = modern_copy / "server_smoke.err.log"
98
+ with out_path.open("w", encoding="utf-8") as stdout, err_path.open("w", encoding="utf-8") as stderr:
99
+ proc = subprocess.Popen(
100
+ [
101
+ sys.executable,
102
+ "-m",
103
+ "carddemo.cli",
104
+ "serve",
105
+ "--source-root",
106
+ "..\\source",
107
+ "--db-path",
108
+ ".\\carddemo.sqlite",
109
+ "--port",
110
+ str(port),
111
+ ],
112
+ cwd=modern_copy,
113
+ stdout=stdout,
114
+ stderr=stderr,
115
+ text=True,
116
+ )
117
+ try:
118
+ wait_for_server(port)
119
+ api_smoke = {
120
+ "health": fetch_json(f"http://127.0.0.1:{port}/api/health"),
121
+ "summary": fetch_json(f"http://127.0.0.1:{port}/api/summary"),
122
+ "mq_system_date": fetch_json(
123
+ f"http://127.0.0.1:{port}/api/mq/system-date?now=2026-05-23T11:12:13"
124
+ ),
125
+ "batch_resource_setup_tranidx": fetch_json(
126
+ f"http://127.0.0.1:{port}/api/batch/resource-setup?job=TRANIDX"
127
+ ),
128
+ }
129
+ checks = {
130
+ "health_ok": api_smoke["health"].get("status") == "ok",
131
+ "summary_customers_50": api_smoke["summary"]["counts"]["customers"] == 50,
132
+ "mq_date_reply": api_smoke["mq_system_date"]["reply_message"]
133
+ == "SYSTEM DATE : 05-23-2026SYSTEM TIME : 11:12:13",
134
+ "tranidx_key_contract": api_smoke["batch_resource_setup_tranidx"]["alternate_index"]["keys"]
135
+ == {"length": 26, "offset": 304},
136
+ }
137
+ return {
138
+ "passed": all(checks.values()),
139
+ "server_command": f"{sys.executable} -m carddemo.cli serve --source-root ..\\source --db-path .\\carddemo.sqlite --port {port}",
140
+ "port": port,
141
+ "checks": checks,
142
+ "api_smoke": api_smoke,
143
+ "stdout_log": str(out_path),
144
+ "stderr_log": str(err_path),
145
+ }
146
+ finally:
147
+ proc.terminate()
148
+ try:
149
+ proc.wait(timeout=5)
150
+ except subprocess.TimeoutExpired:
151
+ proc.kill()
152
+ proc.wait(timeout=5)
153
+
154
+
155
+ def main() -> None:
156
+ parser = argparse.ArgumentParser(description="Verify CardDemo reproducibility from a clean copied workspace")
157
+ parser.add_argument("--modern-root", type=Path, default=Path(__file__).resolve().parents[1])
158
+ parser.add_argument("--source-root", type=Path, default=Path(__file__).resolve().parents[2] / "source")
159
+ parser.add_argument("--scratch-root", type=Path, default=None)
160
+ parser.add_argument("--out-path", type=Path, default=None)
161
+ parser.add_argument("--source-head", default=SOURCE_HEAD)
162
+ args = parser.parse_args()
163
+
164
+ modern_root = args.modern_root.resolve()
165
+ source_root = args.source_root.resolve()
166
+ timestamp = datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ")
167
+ scratch_root = (args.scratch_root or modern_root.parent / f"clean_repro_{timestamp}").resolve()
168
+ out_path = (args.out_path or modern_root / "final_proof" / "CLEAN_REPRO_VERIFICATION.json").resolve()
169
+
170
+ copied = copy_clean_workspace(modern_root, source_root, scratch_root)
171
+ modern_copy = Path(copied["modern_copy"])
172
+ port = free_port()
173
+ commands = [
174
+ run_command(
175
+ "setup",
176
+ [sys.executable, "-m", "carddemo.cli", "init-db", "--source-root", "..\\source", "--db-path", ".\\carddemo.sqlite"],
177
+ modern_copy,
178
+ ),
179
+ run_command("test", [sys.executable, "-m", "unittest", "discover", "-s", "tests"], modern_copy, timeout=180),
180
+ run_command(
181
+ "receipt",
182
+ [
183
+ sys.executable,
184
+ "tools\\generate_receipts.py",
185
+ "--source-root",
186
+ "..\\source",
187
+ "--db-path",
188
+ ".\\carddemo.sqlite",
189
+ "--out-dir",
190
+ ".\\reports",
191
+ ],
192
+ modern_copy,
193
+ timeout=180,
194
+ ),
195
+ run_command(
196
+ "static_oracle_replay",
197
+ [
198
+ sys.executable,
199
+ "tools\\replay_static_oracles.py",
200
+ "--source-root",
201
+ "..\\source",
202
+ "--out-dir",
203
+ ".\\reports",
204
+ "--source-head",
205
+ args.source_head,
206
+ ],
207
+ modern_copy,
208
+ timeout=180,
209
+ ),
210
+ run_command(
211
+ "a_grade_promotion",
212
+ [
213
+ sys.executable,
214
+ "tools\\evaluate_a_grade_promotion.py",
215
+ "--source-root",
216
+ "..\\source",
217
+ "--out-dir",
218
+ ".\\final_proof",
219
+ ],
220
+ modern_copy,
221
+ timeout=180,
222
+ ),
223
+ run_command(
224
+ "no_cost_confidence",
225
+ [
226
+ sys.executable,
227
+ "tools\\build_no_cost_confidence.py",
228
+ "--source-root",
229
+ "..\\source",
230
+ "--out-dir",
231
+ ".\\final_proof",
232
+ ],
233
+ modern_copy,
234
+ timeout=180,
235
+ ),
236
+ run_command(
237
+ "package_final_proof",
238
+ [
239
+ sys.executable,
240
+ "tools\\package_final_proof.py",
241
+ "--source-root",
242
+ "..\\source",
243
+ ],
244
+ modern_copy,
245
+ timeout=180,
246
+ ),
247
+ ]
248
+ server_smoke = run_server_smoke(modern_copy, port)
249
+ report = {
250
+ "verification_version": "carddemo_clean_repro_verification_v0",
251
+ "generated_utc": datetime.now(timezone.utc).replace(microsecond=0).isoformat(),
252
+ "source_head": args.source_head,
253
+ "copied_workspace": copied,
254
+ "server_port": port,
255
+ "commands": commands,
256
+ "api_smoke_passed": server_smoke["passed"],
257
+ "api_smoke": server_smoke["api_smoke"],
258
+ "server_smoke": {
259
+ "passed": server_smoke["passed"],
260
+ "server_command": server_smoke["server_command"],
261
+ "checks": server_smoke["checks"],
262
+ "stdout_log": server_smoke["stdout_log"],
263
+ "stderr_log": server_smoke["stderr_log"],
264
+ },
265
+ }
266
+ report["passed"] = all(row["passed"] for row in commands) and server_smoke["passed"]
267
+ write_json(out_path, report)
268
+ print(json.dumps({"passed": report["passed"], "out_path": str(out_path), "scratch_root": str(scratch_root)}, indent=2))
269
+ if not report["passed"]:
270
+ raise SystemExit(1)
271
+
272
+
273
+ if __name__ == "__main__":
274
+ main()