Skip to content

docs: state INPUT/OUTPUT/EXIT CODES for every shipped tool - #5

Merged
mxuanvan02 merged 1 commit into
mainfrom
docs/tool-io-contracts
Sep 25, 2026
Merged

mxuanvan02 merged 1 commit into
mainfrom
docs/tool-io-contracts

Conversation

@mxuanvan02

Copy link
Copy Markdown
Owner

docs: state INPUT/OUTPUT/EXIT CODES for every shipped tool

Why

An audit of this repository's entry points found that none of them stated what they read, what they write, or what their exit codes mean. A caller could not distinguish "all quantities matched" (0) from "one mismatched" (1) from "the records were absent" without reading the source — which is the opposite of what a reproducibility artifact should require.

What was measured before writing

Every statement added was measured on this checkout, not inferred from a file's shape, because documenting I/O by inspection produces confident fiction:

Tool Measured behaviour
tools/machine_semantic_audit.py --help exit 0, 8 lines stdout, stdlib only
run_paid.py / run_smoke.py --help exit 0 (31 / 16 lines) only with Pillow; exit 1 ModuleNotFoundError: No module named 'PIL' without it
4 × run_round2*_census.py --help exit 1, ModuleNotFoundError: ecm_tqag.judge_output_contract
audit_round2_duplicates.py --help exit 1, ModuleNotFoundError: ecm_tqag.official_outcomes
verify_reported_quantities.py exit 0 / checked: 119 mismatches: 0; exit 1 missing released record: records/protocol.json when a record is hidden; --json emits 19758 bytes, 10 top-level keys

Exit codes were read with the ast module rather than guessed. main() in audit_round2_duplicates, run_paid and run_smoke has a single return 0, so their failure mode is an uncaught exception (run_paid.py contains zero try blocks — verified), not a distinct non-zero code. machine_semantic_audit returns the boolean status != "PASS", which SystemExit turns into 1. The round-2 census main() returns 2 only from except ConcurrentRunBlocked, and 1 from stop-first-failure.

Two files are not CLIs and were not given exit codes

stats/report.py has no __main__; tests/test_run_transport.py is a pytest module. Inventing an EXIT CODES section for a library would be the same class of error as inventing runnability, so each gets a ROLE block instead. For the test module the block records the invocation that actually works (cd experiments/six_arm && PYTHONPATH=.:../../src pytest tests/test_run_transport.py, 4 passed) and the fact that testpaths = ["tests"] means CI's plain pytest never collects it.

Runnability documented as measured, including where it fails

Five round-2 scripts cannot run from this checkout: they import ecm_tqag.judge_output_contract, official_credentials, official_outcomes, official_transport, the v310_* modules and the round2 package — none present under src/ or experiments/six_arm/. Section 10 already states the builder is not part of the release; each script now names exactly what is missing so a reader is not sent chasing an environment problem. run_paid.py / run_smoke.py need Pillow, which pyproject.toml does not declare (dependencies = []), and run only from experiments/six_arm.

The pinned verifier was deliberately not edited

experiments/census_5arm_framef/MANIFEST.json pins verify_reported_quantities.py at 49090 bytes / sha256 20d68f6f… beside the eight released record files. Nothing here regenerates that manifest and no test verifies it, so adding a docstring would silently falsify a published integrity claim while every check still passed. Its contract is documented in the new README §8.1 instead. The pin is re-verified unchanged after every step.

The receipt is regenerated because the digest is content-derived: adding a single comment line was measured to move repo_tree_digest from 96445d36… to 81cd0d8f…. The receipt itself is excluded from that digest, so one pass is stable — also measured.

Test plan

Compared against an untouched worktree of origin/main (ee9d015) run the same way, since a check that fails on the baseline cannot be blamed on the diff:

                                 pytest exit   result string                     validate exit  PASS
baseline origin/main                 0         ..s....s.........................       0        True
this branch                          0         ..s....s.........................       0        True
  • machine_semantic_audit: PASS, 0 findings, 203 files, digest stable across two consecutive regenerations (421d39fd…)
  • pinned verifier: 20d68f6f…, 49090 bytes — unchanged
  • all ten edited files ast.parse clean and expose their contract
  • forbidden-string pre-check: none of the added text triggers absolute_private_path, secret, forbidden_baseline, revoked_artifact, human_workflow_claim

One false alarm worth recording: ecm-tqag validate fixtures/packages initially appeared to fail. That was the check's fault, not the repository's — the bare command resolved to a console script in an unrelated virtualenv where the package is not installed, and it fails identically on the untouched baseline. Run against this repository's src/ it exits 0 with "status": "PASS", package_count 3, on both trees.

Scope

Documentation only. No behaviour changed: 12 files, +327 / −1 (the single deletion is the receipt's digest line).

An audit of the repository's entry points found that none of them stated what they
read, what they write, or what their exit codes mean. A caller could not distinguish
"all quantities matched" (0) from "one mismatched" (1) from "the records were absent"
without reading the source, which is the opposite of what a reproducibility artifact
should require.

Every statement added here was measured on this checkout rather than inferred from a
file's shape, because documenting I/O by inspection produces confident fiction:

  exit codes were read with the ast module. main() in audit_round2_duplicates,
  run_paid and run_smoke has a single `return 0`, so their failure mode is an
  uncaught exception -- run_paid.py contains zero try blocks, verified -- not a
  distinct non-zero code. machine_semantic_audit returns the boolean
  status != "PASS", which SystemExit turns into 1. The round-2 census main() returns
  2 only from `except ConcurrentRunBlocked` and 1 from stop-first-failure.

Two of the flagged files are not command-line tools and were not given exit codes:
stats/report.py has no __main__ and test_run_transport.py is a pytest module. Each
gets a ROLE block instead. Inventing an EXIT CODES section for a library would be the
same class of error as inventing runnability.

RUNNABILITY IS DOCUMENTED AS MEASURED, INCLUDING WHERE IT FAILS
--------------------------------------------------------------
Five round-2 scripts cannot run from this checkout: they import
ecm_tqag.judge_output_contract, official_credentials, official_outcomes,
official_transport, the v310_* modules and the round2 package, none of which are
present under src/ or experiments/six_arm/, so even --help fails at import. Section
10 already states the builder is not part of the release; each script now carries a
RUNNABILITY block naming exactly what is missing, so a reader is not sent chasing an
environment problem. run_paid.py and run_smoke.py need Pillow, which pyproject.toml
does not declare (dependencies = []), and run only from experiments/six_arm; with
Pillow present --help exits 0 and prints 31 and 16 lines respectively.

The pinned verifier was deliberately not edited
-----------------------------------------------
experiments/census_5arm_framef/MANIFEST.json pins verify_reported_quantities.py at
49090 bytes / sha256 20d68f6f... beside the eight released record files. Nothing
here regenerates that manifest and no test verifies it, so adding a docstring would
silently falsify a published integrity claim while every check still passed. Its
contract -- exit 0 on agreement, exit 1 on a mismatch or on an absent record with
"missing released record: records/<name>", --json emitting the ten recomputed tables
-- is documented in the new README section 8.1 instead. The pin is re-verified
unchanged after every step.

The receipt is regenerated because the digest is content-derived: adding a single
comment line was measured to move repo_tree_digest from 96445d36... to 81cd0d8f....
The receipt itself is excluded from that digest, so one pass is stable, which was
also measured rather than assumed.

Verified, comparing this tree against an untouched worktree of origin/main run the
same way:
  pytest                       exit 0, identical result string on both trees
  validate fixtures/packages   exit 0, "status": "PASS", package_count 3, both trees
  machine_semantic_audit       PASS, 0 findings, 203 files, digest stable across two
                               consecutive regenerations
  pinned verifier              sha256 20d68f6f... and 49090 bytes, unchanged
  ast.parse + docstring read    all ten edited files parse and expose their contract
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@mxuanvan02
mxuanvan02 merged commit 66da37c into main Sep 25, 2026
7 checks passed
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.

1 participant