Repository navigation
docs(cobolrt): write and enforce the public API contract (Part of #4718) - #7356
Merged
Merged
Conversation
The runtime had no definition of what generated code may call. Add a manifest read from the real sources (cobolrt, CicsSpec and the classes the forges emit), a contract doc, and tests that fail when the surface moves without the manifest or when a port or generator string uses an internal member. Nothing under gitgalaxy/tools/cobol_to_java changes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
squid-protocol
marked this pull request as ready for review
October 31, 2026 22:00
Contributor
|
No description provided. |
Contributor
|
No description provided. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #4718 (epic #4710). This does not close #4718: its version, licence and developer-docs items stay open.
What this does
cobolrtships inside every port, but nothing said what a port may call. This PR writes that down and enforces it:docs/language_status/cobolrt_api.json: every public type and member of the runtime, each classifiedpublicorinternal, with the evidence for the call.docs/cobolrt_api_contract.md: what public means, the compatibility promise, the variants, how to change the surface, and the commands.tests/tools/cobolrt_api.pywrites and checks the manifest.tests/cobol_mainframe/test_cobolrt_api.pyfails when:Nothing under
gitgalaxy/tools/cobol_to_java/**changes, so no proof record goes stale. The det-sweep plan for this diff isnone.The surface
There is no single runtime artifact, so the scope follows what a project actually gets: the 48 Java files,
CicsSpec.java, and the classes the forges emit (CicsTask, thebatchruntime,CobolRecords,CobolEdit,CobolCompare,Db2Dates,CobolRef). Forge text comes from the forges' own constants and functions, parsed with tree-sitter-java. Java's accessibility rules decide what is in scope, so the package-privateCodec,EditingandZonedare out.CicsRegionandBatchJobControllerare generated per estate: they are callers, not surface.cobolrt.*cics.CicsTask*The classification is evidence-based. It was seeded from all 152 committed Java files that call the runtime (the ports plus the frozen copies), the translator's strings, and
det_port.py --translate-onlyover all 201 cases in three forms (default,--style structured,--no-typed --groups).Classification calls to review
CicsTaskis almost half the surface. 365 of the 781 public members are on it. That is honest, because ports program against it directly, but it is the part of the promise that would cost most to keep.with*builders are internal.CicsTask.withClock,withStartcodeand so on are harness-facing (191 internal members carryharnessevidence). A customer running ports outside our harness may need some of them. That is a product decision.*Spectables,QueueManager,LosslessandField.Kindare internal. A port never names them.emitter-dynamicevidence. Computed emission (f"Cobol.{fn}",f"{var}.nextInput()") can't be read literally, so this over-approximates on purpose. Some accessors are probably public by name match alone. The cost of the safe direction: a new internal helper whose name matches such a string fails the check until it is made public or renamed.What ports call that may surprise you
Nothing calls a member the Java does not expose: the check reports 0 unresolved names. Since the seed made every used member public, the review question is which uses should have been public at all:
CicsTask.events()(tests/cics_crucible/ports/ca-link-lengths/CALINK), which reads the task's event log, andabcodeFor,receiveText(int)andstartAt(...).events()looks like harness introspection, not port API.DetCics.within(Field,int,String)is called by 8 committed det ports but no longer emitted (the translator now writeswithinRecord). Those ports are older translations.Cobol.x" count was an artefact of the literal grep. Of the 75Cobolmembers, 69 have a real or possible generated caller, 3 are runtime-only,setTruncBinaryandsetTruncOptare test-only, and onlyNAN_SCALEhas no caller found.The frozen overlays
tests/cics_crucible/ports/pc-wizard/PCCONF/overlay/cobolrtandpc-return-immediate/PCIMMA/overlay/cobolrtare the only places a port runs on an older runtime. They are handled like this:frozen-overlayevidence. Four are public mainly because of that (CicsSpec.condition,CicsTask.acquireReceived,addressOf,storageAt).Against the current runtime, the copies declare only two members that no longer exist:
Sort.rewind()and the 5-argumentCeesecs.call. No overlay service calls either.Limits
These are stated in the tool and the doc:
contains,end,execute) or original estate Java.cobolrt_api.py --check --generated DIRis the local form.Class / Sibling gaps
Class: the runtime's callable surface, across every unit a generated project receives (cobolrt, CicsSpec, the forge-emitted classes), against every caller (committed ports, generated output, emitter strings). Every member of the class is handled here: all 124 public types, including every class
port_runner._RUNTIME_HELPERSnames.Sibling gaps, none done here because each needs a different mechanism or an excluded file:
--style structuredwrites invalid Java for a digit-first COBOL name:zecs-zecs001getsprivate final Field 50702Message.--check --generatedon a structured work directory reports that one file until it is fixed. Default-style and--no-typed --groupsoutput parse clean.--check --generatedin the det sweep, so CI sees all generated output.det-sweep.ymlis aDET_INPUTSfile, so it would trigger a full sweep.@Internalor a package move).gitgalaxy/tools/cobol_to_java/**and stale proof records.Test evidence
tests/cobol_mainframe/test_cobolrt_api.py: 61 passed, also from an unrelated working directory with the plainpytestscript, as CI runs it. Time ratchet: 61 tests checked, 0 over the per-test limit, 0 warned.pr_gates.py --fast: 9/9 gates pass.tests/tools/underheavy-run.sh: exit 0.audit_check.py: all clear.test_det_sweep_plan.py: 315 passed.cobolrt_api.py --check: holds.--check --generatedover the default and--no-typed --groupswork directories: holds. Over the--style structuredone: exit 1 on the onezecs-zecs001file listed under Sibling gaps.Cobol.move,CicsTask.storageAt,Sort.nextInputandFuncs.absto internal fails on the right caller label for each, and dropping a manifest row fails as a surface change.Lessons for agents
CICS_TASK_JAVAhas one, because the forge's Python string writes'\0'as the byte. Mask literals before parsing (cobolrt_api.parse).🤖 Generated with Claude Code