Engineering
Good experiments leave a trail
Ocuna Research
· 6 min read · Updated

Start with a failed check
A CI-reporting script says eight jobs ran. There were only five: some were retried, and the script counted every attempt as a separate job. To explain the fix a week later, you need the input that exposed the bug, both versions of the script, and the test results.
Our example includes two versions of that reporter: an intentionally buggy starter and a fixed version. A local script runs the same tests against each and saves both results. The fixed reporter groups attempts by job, uses the highest attempt number to determine the final outcome, and checks for invalid input.
Ocura OSS records the commands, results, logs, and connection between the two runs. The example also saves copies of its source files and sample input. That gives the next person or agent enough context to follow the change without running the tests again.
Run the example
Start in an activated virtual environment with Python 3.11 or later. Clone the examples branch and install Ocura OSS 0.7.0 using the commands below. You don't need any other Python packages. The checkout provides the example scripts, which are distributed separately from the package.
Choose a directory name that doesn't exist yet; the script will create it. It saves the reporter, tests, and sample input there before running the checks. Keep that directory for the inspection steps below.
git clone --branch examples/0.7 --single-branch https://github.com/Protention/ocura-oss.git ocura-oss-examples
cd ocura-oss-examples
git checkout 7249891621c5f2d613b395b1acd2e001322209e4
python -m pip install ocura-oss==0.7.0
python examples/ci_report/workflow.py run --root ./ci-report-run
python examples/ci_report/workflow.py report --root ./ci-report-run
See the failure and the fix
The first run is supposed to fail: the starter has the bug we're demonstrating. It fails all 31 checks, while the fixed version passes all 31. These are local checks of the example reporter. When both runs produce those expected results, the workflow reports complete.
The report links the passing run to the original failure and includes the reason for the fix. Here's a shortened excerpt. The full report also includes run IDs and the saved error output.
starter: failed (0/31 checks passed; exit 1)
intent: Count final job outcomes by highest attempt; validate rows before emitting a summary.
completed: passed (31/31 checks passed; exit 0)
reason: Group attempts by job, account for retries and recovery, and reject invalid rows.
Verified 4 logs and preserved source hashes.
Connect the fix to the failed run
After the baseline finishes, Ocura returns a branch point: a reference you can use when trying another version. Pass that reference and a reason to run() to connect the fix to the original failure. Ocura creates a new pathway and records the command in one call.
This excerpt shows the connection. The first check stops an interrupted run or an unexpected exit status from becoming the baseline for the fix. The complete driver also saves the source files and their hashes, then labels both attempts.
If Ocura reports a storage error, inspect the run IDs and execution details in the error before retrying. The command may already have started, and repeating the call creates another attempt.
from ocura_oss import Outcome, run
baseline = run(starter_command, root=root)
if baseline.record.outcome is not Outcome.FAILED or baseline.record.return_code != 1:
raise RuntimeError("Inspect the baseline before continuing")
corrected = run(
corrected_command,
root=root,
source_branch_point_id=baseline.branch_point.id,
reason="Group attempts by job and validate input rows",
)
Inspect what happened
To look closer, use runs to list the history, show to inspect a command and its pathway, and logs to read its output. Replace RUN_ID below with a run_id from the example report.
A run ID identifies the execution and its output. A branch-point ID is the reference you pass when starting a variation. For compatibility, the CLI's JSON still uses the older names atom_id and chokepoint_id; the Python properties are record and branch_point. Use the full IDs returned by the tools.
Ocura checks the logs against their recorded hashes before returning them. The example checks its saved source files the same way. These checks tell you whether the files match the record; they don't establish who wrote them or whether the tests cover every requirement.
ocura-oss runs --root ./ci-report-run --all --json
ocura-oss show RUN_ID --root ./ci-report-run --command --json
ocura-oss logs RUN_ID --root ./ci-report-run --stream stderr
Pick up the work later
After the run finishes and nothing is writing to the directory, you can rebuild the report from the saved copy of the driver. This reads the existing files without running the tests again. If you move the project, keep the whole directory together.
A future collaborator can now follow the failure, the reason for the change, and the passing result. An agent can do the same through its shell or Python environment. The explanation still comes from the caller: Ocura records the reason you give it.
Training experiments can use the same approach. The training code saves checkpoints and validation results, while Ocura records the commands and how the runs relate. Our Dream-RSI example uses that history to choose the next attempt and explain the choices afterward.
python ci-report-run/sources/workflow.py report --root ./ci-report-run
ocura-oss verify --root ./ci-report-run --archive