Skip to content

#3805: fresh-estate trials -- the trial ledger, trial start / report, and the attempts-to-proof histogram - #3959

Merged
squid-protocol merged 1 commit into
mainfrom
feat/3805-trials
Sep 28, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
feat/3805-trials

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Fixes #3805 (part of epic #3803)

Design

The headline is the first-try proof rate on estates the system has never seen: per program, did the porting loop's first attempt produce Java that the equivalence harness proves identical to the COBOL? tests/tools/trial.py is modelled on field_testing.py. A committed ledger feeds a generated page and a CI check. The trial reuses the existing machinery and does not reimplement it:

  • start runs the same scan, refract and cobol-to-java path the equivalence harness builds its project with (java_target_matrix.refactor(scan=True) + generate(..., "h2")). That path writes the porting tickets.
  • sync reads port_runner's port_log.jsonl through port_runner.events().
  • Fix causes come from git log trailers.
  • The ledger is seeded with the six development estates (CardDemo, CBSA, zopeneditor, GENAPP, zECS, DSF) as development, with no trials.

Ledger schema (tests/cobol_mainframe/trials.json)

  • estates[]: id, kind public | private, status fresh | development. A public estate also has repo and ref. A private estate has an anonymised label only, and validation fails if it carries a repo, ref or path. trialled_by is set once a trial starts; a trialled estate is development for good.
  • trials[]: id, estate, started, closed.
  • system (the frozen system):
    • engine_commit;
    • engine_version (the last tag);
    • porting_rules_hash (sha256 of PORTING_RULES + TICKET_VERSION) and ticket_version;
    • model, model_version, backend;
    • harness_commit (the last commit touching tests/tools/equivalence*.py or the GnuCOBOL Dockerfile).
  • eligible[] and out_of_scope{program: reason} are declared at start. declared is a sha256 over both, so an exclusion edited in later to hide a failure fails validation. Only start --exclude can add one.
  • programs{PROG: {attempts: [{n, outcome proven|failed|no-port|error, cause model|ticket|generator|engine|harness|null, fix_commit, at, model}], final}}. final is one of:
    • proven@N, followed by the causes of the earlier failures, e.g. proven@2(generator);
    • not-proven(cause), set at close;
    • open.
      Out-of-scope programs show as out-of-scope(reason) in the report.
  • The validator checks:
    • that final follows from the attempts;
    • that attempts are numbered 1..n and stop at the first proven one;
    • that a fix commit appears only with one of our causes;
    • that a closed trial leaves no program open.

Eligibility (declared in code, ELIGIBILITY_RULES)

A program is eligible if the batch harness can run it. The first rule that fails gives the out-of-scope reason:

A program with no ticket is out of scope as "no business logic to port".

How an attempt and its cause are recorded

  • An attempt is one proof verdict (proven / proof-failed in the port log), or one run that produced no port: no-port, or error when the backend raised. A proposed port that was replaced by another run before any proof counts as an error attempt. Attempts stop at the first proven one.
  • A failed attempt's cause is decided by what happened next:
    • a commit whose message carries Trial-Cause: <ticket|generator|engine|harness> <PROGRAM>, landed between the failed verdict and the next attempt's start, is a fix on our side (that cause plus fix_commit);
    • a retry with no such commit is model;
    • with nothing after it yet, the cause stays null.
  • Sync is idempotent. An attempt already recorded is never rewritten; only a null cause may be filled in later.

The chart (docs/language_status/fresh_estate_trials.svg, plain SVG, no plotting library)

  • Headline: first-try proof rate: X/Y (Z%) on N fresh estates at engine <ver>. The latest engine version is used; Y counts programs whose first attempt has a verdict, plus every program of a closed trial.
  • Panel 1: a per-program histogram with bins proven @1 / @2 / @3 / @4+ and not proven by cause (model / ticket / generator / engine / harness). Bars are stacked and coloured by estate (the repo's chart palette), with one facet per engine version.
  • Panel 2: failed attempts per estate, split into ours (one blue ramp, one shade per cause) and the model's (grey).
  • Caveats printed on the chart:
    • public code may be in a model's training data;
    • eligibility is declared up front.
  • Every bar has a <title> hover.
  • There are no trials yet, so the committed chart shows the empty state.

How to run a trial

python tests/tools/trial.py start <estate-id> --estate-path P --work W --model M --backend B \
    [--ref R --repo-url U | --kind private --label L] [--model-version V] [--exclude PROG=reason ...] [--shipped-data PROG ...]
# per eligible program (tickets in W/java_h2/ai_agent_jobs):
python -m gitgalaxy.tools.cobol_to_java.port_runner run   W/java_h2 --ticket PROG --backend B --model M ...
python -m gitgalaxy.tools.cobol_to_java.port_runner prove W/java_h2 --ticket PROG --command "<equivalence harness>"
# a fix on our side: commit with the trailer   Trial-Cause: generator PROG
python tests/tools/trial.py sync  <trial-id> --project W/java_h2     # alias: attempt
python tests/tools/trial.py close <trial-id> [--cause PROG=model ...]
python tests/tools/trial.py report --write                           # CI: trial.py check / test_trials.py
  • start refuses:
    • a development estate, which includes any estate already trialled; this is also how a late --exclude is refused;
    • an engine checkout with uncommitted changes under gitgalaxy/ or tests/tools/.

Tests (tests/cobol_mainframe/test_trials.py)

  • The committed ledger validates, and the page and chart are current.
  • A synthetic end-to-end trial runs on a tiny estate with two batch programs and one CICS program, with no real model:
    • port_runner uses a stub command backend and a stub proof;
    • GOODPGM is right at once;
    • FIXPGM is wrong until a Trial-Cause: generator FIXPGM commit lands in a temporary engine repo.
    • The ledger then shows proven@1 and proven@2(generator), and the report bins them.
    • The CICS program is out of scope as online (EXEC CICS).
    • Running sync twice changes nothing, and a closed trial refuses sync.
  • start refuses a development estate and an already-trialled estate (so an exclusion cannot be added late), and an exclusion edited into the ledger fails validation.
  • A retry with no fix is model, and a recorded attempt is never rewritten.

Gates

Full tests/tools/pr_gates.py: 7/7 pass (lint, audits, secrets, xray, gauntlet 188s, golden 104s, suite 509s). After merging origin/main (already up to date): lint and audits pass, and test_trials.py + test_port_runner.py give 15 passed.

Notes

  • Trial start on the fresh opensourcecobol4j checkout: I ran it against a scratch ledger only. It took 5s. 14 of 471 programs are eligible:

    • 436 are out of scope as "writes no file". They are test programs that DISPLAY to stdout, which the harness does not compare.
    • 21 are out of scope for inline FD records with no copybook.

    Widening eligibility would need the harness to compare SYSOUT and generate from inline FDs.

  • The online (CICS) harness (equivalence_cics.py) exists, but CICS programs are declared out of scope for now, as the brief's "batch" rule says.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TmgE1CwLgaqxqKEgQn5Dw5

… and the attempts-to-proof histogram

tests/tools/trial.py + tests/cobol_mainframe/trials.json: `start` freezes the system (engine
commit/version, porting-rules hash, model + backend, harness commit), runs the harness's
scan -> refract -> cobol-to-java path (the tickets), and declares eligibility up front (hashed);
`sync` imports port_runner's port_log.jsonl as attempts, causes from `Trial-Cause:` commit
trailers (a retry with no fix = model); `close` ends a trial; `report` writes
docs/language_status/fresh_estate_trials.md + .svg; `check` / test_trials.py keep them current.
The ledger is seeded with the six development estates.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TmgE1CwLgaqxqKEgQn5Dw5
Comment thread tests/tools/trial.py
Comment on lines +695 to +697
"<style>.t{font-size:15px;font-weight:600;fill:#0b0b0b}.s{font-size:11px;fill:#52514e}"
".h{font-size:10.5px;font-weight:600;fill:#0b0b0b}.a{font-size:9px;fill:#706f6a}"
".l{font-size:10px;fill:#0b0b0b}.c{font-size:10px;fill:#52514e;font-style:italic}</style>",
Comment thread tests/tools/trial.py
Comment on lines +700 to +701
'<text x="16" y="44" class="s">Programs by the attempt that proved them (or why not), coloured by estate, '
'one panel per engine version.</text>'] # fmt: skip
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit c8f4d69 into main Sep 28, 2026
29 checks passed
@squid-protocol
squid-protocol deleted the feat/3805-trials branch September 28, 2026 10:05
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.

Fresh-estate trials: trial record, trial start / report, attempts-to-proof histogram

2 participants