🐛 fix(gates): keep a red gate's failure report when output is clipped
User description
Summary
On erp's S-0004 night, T-0007's e2e gate failed on two tests. The retry got the failed tests' names but none of their tracebacks, debugged blind, and hit the agent timeout.
pytest prints the FAILURES section first, then the coverage table, then the short summary. Every clip between the gate and the retry kept only the tail:
| Clip | Where | Before |
|---|---|---|
| gate output | base/shell.py truncate | head 2000 + tail 6000 of 8000 |
| recorded result | application/telemetry.py _recorded_result | last 4000 |
| retry's context | application/contextpack.py _red_gates | last 2000 |
The fix shares one marker and one helper:
FAILURE_REPORTfinds where pytest'sFAILURESorERRORSreport opens.truncategives that report the 6000-character share in place of the head when the report falls in the clipped middle. The tail keeps the last 2000 characters, which hold the summary.clip(text, limit)keeps three quarters from the report and the last quarter. The recorded result and the retry's context use it.- Output with no such report keeps its tail, as before. A harness stream is JSON lines, so the anchored marker can't match it, and the final-line rescue is unchanged.
Tests
test_a_failure_report_survives_every_clip_down_to_the_retryruns a synthetic e2e output through all three clips. At each one it asserts the traceback and the summary line survive within the bound.test_output_without_a_failure_report_keeps_its_tailandtest_a_failure_report_already_in_the_tail_keeps_the_plain_tailcover the unchanged behaviour.- Full
pytestpasses, as doruff check,ruff format --checkandmypy src.mypy .reports 8 errors undersandboxes/; main reports the same 8.
Only pytest's report is recognised. Other runners keep the tail as before.
🤖 Generated with Claude Code
https://claude.ai/code/session_01X5XatXv3dQLan6TyQoHFyF
Summary by cubic
Keeps a red gate's pytest failure report across every output clip, so a retry sees the tracebacks instead of just the failed test names.
Bug Fixes
- pytest prints the
FAILURESreport before the coverage table and summary, so tail-only clips dropped the tracebacks. truncategives the failure report the head's larger share — including reports that open within the head — and the tail keeps the summary.- The new
cliphelper keeps three quarters from the report and the last quarter, and is used by the recorded result and the retry's context; bounds too small for the elision keep a plain tail. - Output without a failure report keeps its tail as before.
CodeAnt-AI Description
Keep pytest tracebacks in clipped failed-gate output
What Changed
- When failed pytest output is shortened, it now preserves the failure report and traceback alongside the final summary in gate output, recorded results, and retry context.
- Output without a pytest failure report continues to keep its tail, and harness verdict lines remain intact.
Impact
✅ Tracebacks available to failed-test retries
✅ Pytest diagnostics retained in failed-gate records
✅ Existing tail behavior preserved for other output
💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
@codeant-ai ask: Your question here
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
@codeant-ai ask: Can you suggest a safer alternative to storing this secret?
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
@codeant-ai: Your feedback here
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
@codeant-ai: Do not flag unused imports.
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
@codeant-ai: review
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.
Summary by CodeRabbit
- Bug Fixes
- Long pytest output now retains the failure report and failed-test names when output is clipped, while still displaying the coverage table and final summary.
- Failure details are preserved in gate output, recorded results, and retry context without retaining tracebacks.
- Output without a failure report continues to keep its usual tail.