Skip to content

ab_control_flow: stage outcomes.tsv so a write failure keeps the previous report - #9021

Open
Grimkeh wants to merge 1 commit into
ItsNotRexed:mainfrom
Grimkeh:fix/ab-control-flow-preserve-outcomes
Open

Grimkeh wants to merge 1 commit into
ItsNotRexed:mainfrom
Grimkeh:fix/ab-control-flow-preserve-outcomes

Conversation

@Grimkeh

@Grimkeh Grimkeh commented Nov 23, 2026

Copy link
Copy Markdown

Summary

Claim: #8504 (comment)

Synthetic; no game files. AI-assisted (Cursor / Composer).

Test plan

  • python3 -I -m unittest discover -s tests -p test_ab_control_flow.py — OK

Made with Cursor

…ious report

Publish the TSV report through a temp file + replace so a mid-write OSError leaves any prior complete outcomes file intact.

Co-authored-by: Cursor <cursoragent@cursor.com>
@catminou4

Copy link
Copy Markdown

Tested on Apple M1 Max, macOS 27.2.1 arm64, Python 3.12.16: python -I tests/test_ab_control_flow.py → 13 tests OK (1 skipped). No game files. AI-assisted (Devin).

@neoisg8

neoisg8 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 107d677d on Windows 11 (Python 3.14.3, CPU-only, clean-room synthetic inputs, zero game data): pass.

Test Suite Execution

  • python -I tests/test_ab_control_flow.py: 64 passed, 1 skipped in 2.55s.
    • Successfully verifies test_outcomes_write_failure_preserves_previous_report: publishes outcomes.tsv through staged temp file .ab_control_flow-*.tmp and replace_retry().
    • When writing or replacing fails mid-operation with OSError, existing report files remain intact without truncation.
    • Handles non-regular output destinations cleanly via direct write fallback.
    • Tests write permissions on existing regular destinations via os.close(os.open(destination, os.O_WRONLY)) without truncating the existing report.

Negative Control

Reverted tools/ab_control_flow.py to origin/main (dde82f27e) while evaluating tests/test_ab_control_flow.py:

  • test_outcomes_write_failure_preserves_previous_report: FAILED (errors=1):
    • AttributeError: <module 'ab_control_flow_under_test'> does not have the attribute 'replace_retry' (on main, direct unbuffered open(path, "w") in write_outcomes truncated destination files immediately).
  • Restoring 107d677d brings all 64 tests cleanly back to green.

Clean-Room & Repository Hygiene

  • git merge-tree --write-tree origin/main 107d677d: clean merge (a5c24fba).
  • python -m compileall -q tools/ab_control_flow.py tests/test_ab_control_flow.py: clean.
  • python -I scripts/check_no_game_data.py tools/ab_control_flow.py tests/test_ab_control_flow.py: clean (0 violations).
  • git diff --check origin/main: clean (0 whitespace or conflict markers).
  • Line endings: strict Unix LF (\n) preserved.

LGTM!

AI-assisted: verified and reviewed on Windows 11 environment.

@ne1i

ne1i commented Nov 23, 2026

Copy link
Copy Markdown

Tested 107d677d on Linux, CPython 3.14, CPU only, synthetic inputs, merged onto main 867d922f: pass

  • python -I tests/test_ab_control_flow.py: Ran 65 tests, OK. With only the non-test files reverted to main: FAILED (errors=1), so the new tests exercise the change.
  • compileall and scripts/check_no_game_data.py on the changed files: clean.

Independent check (not the author). Run by an AI agent (DeepSeek V4.1 Flash) and re-run by the orchestrating session (Claude Code) before posting.

@sds-228 sds-228 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Focused suite passes 65/65 at this head (1 skip); the new write-failure case fails against the pre-change tool. The staged publish keeps an existing outcomes report intact, and non-regular destinations still get a direct write.

AI-assisted (OpenCode).

@neoisg8

neoisg8 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 107d677d6 on Windows 11 (CPython 3.14.0, CPU only): pass.

What was verified:

  1. Preservation on write failure: Verified write_text_report() stages outcomes.tsv through .ab_control_flow-*.tmp and atomically publishes via replace_retry. When replace_retry raises OSError, existing TSV report contents remain unchanged.
  2. Directory hierarchy & non-regular files: Verified write_outcomes() ensures out_dir exists via os.makedirs(out_dir, exist_ok=True). Verified non-regular destinations write directly, and existing regular files check writability via os.close(os.open(destination, os.O_WRONLY)) without truncating.
  3. Test suite: python -I -m unittest discover -s tests -p test_ab_control_flow.py passes 64/64 runnable tests (1 expected skip).
  4. Hygiene: compileall, check_no_game_data.py, and git diff --check all exit 0.

Negative control:

Restoring tools/ab_control_flow.py from origin/main produced:
AttributeError: <module 'ab_control_flow_under_test' ...> does not have the attribute 'replace_retry' (65 tests: 63 pass, 1 error, 1 skip).

No game files used. AI-assisted.

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.

5 participants