Skip to content

COBOL→Java porting loop: bring-your-own LLM, a person approves, the harness proves (#3753) - #3763

Merged
squid-protocol merged 9 commits into
mainfrom
feat/port-loop-3753
Sep 26, 2026
Merged

squid-protocol merged 9 commits into
mainfrom
feat/port-loop-3753

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Closes #3753. Part of epic #3755; builds on #3752 (merged as #3762).

What it is

python -m gitgalaxy.tools.cobol_to_java.port_runner turns each porting ticket into done work, and the customer stays in control at every step:

  • Propose with the model you choose. Backends:

    • openai: any OpenAI-compatible endpoint (a local vLLM or Ollama, Azure, a gateway);
    • anthropic;
    • command: any CLI, e.g. an in-house model or agy.

    A person can also write the port and submit it. Keys are read from an env var you name and never stored. The port lands as an overlay, so the generated sources are never edited.

  • Prove. prove runs the equivalence harness on the overlay: the original COBOL and the port run on the same inputs, and every output record is compared field by field, along with the RETURN-CODE.

  • Approve. review --approve|--reject --by NAME: nothing is accepted without a person.

  • Status. status reports per ticket and per model what was proposed, proven, approved and rejected, from the append-only ai_agent_jobs/ports/port_log.jsonl. "Percent automated" becomes evidence, not a claim.

This differs from tools that say an LLM "converts" COBOL: here you choose the target stack (17 configs), the model and the reviewer, and every port carries a proof.

Measured (CardDemo batch, Gemini 3.1 Pro via agy, the command backend)

program result
CBACT04C proven on round 3: ACCTFILE 50/50, TRANSACT 50/50, RC 0 = 0
CBTRN02C proven on round 3: ACCTFILE 50/50, TCATBALF 100/100, TRANFILE 262/262, DALYREJS 38/38, RC 4 = 4

Every failure between rounds was traced to its cause and fixed on our side, not by hand-editing the model's answer:

  • round 1: records written with newlines, and the system clock used;
  • the dataset API guessed;
  • a hand-written overpunch decoder;
  • a harness gap.

Both ports named the original programs' own defects in comments and preserved the behavior. Both are proven but not yet approved: approval is a person's call. Details are in docs/cobol_to_java_porting_loop.md.

Changes

  • port_runner.py (new): the prompt carries the ticket's rules, the service, the imported generated classes, the runtime helpers (DatasetResolver, MainframeClock, CobolRecords), the listings, facts and worklist.
  • Batch forge: a generated MainframeClock (gitgalaxy.clock), so a run can be pinned.
  • New porting rules:
    • fixed-length sequential records;
    • MainframeClock only;
    • numeric fields decoded only through CobolRecords or the entity codecs.
  • Equivalence harness:
    • --port DIR;
    • RETURN-CODE recorded and compared;
    • sequential inputs staged into the datasets dir;
    • FILLER-only differences counted apart as filler_differs (a FILLER can't be named by any program; after INITIALIZE it holds the runtime's leftover record area).
  • New case tests/equivalence/carddemo-posttran (CBTRN02C, job POSTTRAN, CardDemo's own data; the source's Apache-2.0 LICENSE and NOTICE included).
  • Tests: test_port_runner.py, which runs the loop end to end with stand-in backend and proof commands, plus a FILLER diff test. tests/cobol_mainframe: 675 passed, 1 skipped locally.

Not covered here: a hosted API backend was not exercised live, because no keys are configured on this machine; it is covered by the request-shape code path and the missing-key test.

🤖 Generated with Claude Code

https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g

squid-protocol and others added 7 commits September 26, 2026 12:03
…ic, by default (#3752)

Every generated program leaves business logic to write, but no program got a
porting ticket by default: the ticket stage needed `--var` slicing, so
CardDemo got 0.

New cobol_to_java_port_tickets writes one ticket per program with
business-logic worklist items, on every skeleton-driven run
(features.agent_tickets):
ai_agent_jobs/<KEY>_port_ticket.json plus a Markdown twin. A ticket holds:
- the target: the service to fill, its public methods and which are still
  TODO, the overlay path a port lands on, and the chosen target stack (Java
  / Spring Boot / database / integration / UI; no local paths or
  credentials);
- the source: numbered listings (columns 1-72) of the program and its
  copybooks, written once each under ai_agent_jobs/sources/ and referenced
  (DSF's shared includes took tickets from 103 MB to 46 MB), and its
  paragraphs;
- the facts: the verified skeleton's sections, with field-testing status;
- the generated classes it builds on: those the service imports (entities
  with codecs, repositories, DTOs, the batch runtime) and every artifact the
  traceability manifest ties to the program;
- its worklist items, the porting rules the #3624 slice proved, and the
  deliverable (one Java file, proven by the equivalence harness, approved by
  a person).

The worklist links each program's items to its ticket, JSON and Markdown.
Result: CardDemo gets 44 tickets (previously 0), DSF 438.

publish_examples leaves ai_agent_jobs/sources/ out of the published
examples: the listings are the pinned source, regenerated with the tickets.

Tests (test_port_tickets.py, a real scan) pin a ticket's contents, the
worklist link and determinism across two runs.

Part of epic #3755. Closes #3752

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g
# Conflicts:
#	gitgalaxy/tools/cobol_to_java/cobol_to_java_port_tickets.py
… CobolRecords in the prompt (#3753)

- equivalence_java: a sequential input dataset (no entity) is copied into the datasets
  directory the program opens it from; CBTRN02C's DALYTRAN was never there.
- equivalence: a FILLER difference is counted apart (filler_differs) and shown in the report,
  not failed: no program can name it; after INITIALIZE it holds the runtime's leftover record area.
- port_runner: the prompt always carries the runtime helpers (DatasetResolver, MainframeClock,
  CobolRecords); a re-proof of an attempt starts from a clean report dir; lint (X | None, S310).
- port tickets: a rule to decode/encode zoned, COMP-3 and COMP fields only through CobolRecords
  or the entity codecs, never a hand-written decoder.

With these, Gemini 3.1 Pro (via agy, the command backend) ported CBACT04C and CBTRN02C and both
were proven by the harness: ACCTFILE 50/50, TRANSACT 50/50; ACCTFILE 50/50, TCATBALF 100/100,
TRANFILE 262/262, DALYREJS 38/38, RETURN-CODE 4 = 4.

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

# Conflicts:
#	gitgalaxy/tools/cobol_to_java/cobol_to_java_port_tickets.py
@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

squid-protocol and others added 2 commits September 26, 2026 13:29
…ernal documents write (#3753)

- port_runner._post refuses any scheme but http/https before urlopen (Muninn
  dynamic-urllib-use-detected; nosemgrep as in templates/bitbucket, now with a real guard).
- dead_key_audit: "choices" (the chat completion response) and "equal" (the harness's
  report.json) are written outside gitgalaxy/.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g
…and never follows a redirect (#3753)

urllib follows a POST's 301/302/303 and forwards every non-content header -- the
Authorization / x-api-key included -- to the new location; the backends now use an opener
that refuses redirects. Plain http is accepted only to a loopback host (a local vLLM /
Ollama), so a key never crosses a network unencrypted; file: and custom schemes are refused.
Tests: a real local server answering 302 gets exactly one request and the call fails.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g
@squid-protocol
squid-protocol merged commit 21950de into main Sep 26, 2026
36 checks passed
@squid-protocol
squid-protocol deleted the feat/port-loop-3753 branch September 26, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Logic porting loop: bring-your-own LLM, human approval, proven by the equivalence harness

2 participants