Skip to content

fix(issues): harden formatter contract handling - #3004

Merged
stranske merged 20 commits into
mainfrom
automation/issue-formatter-review-debt
Aug 9, 2026
Merged

fix(issues): harden formatter contract handling#3004
stranske merged 20 commits into
mainfrom
automation/issue-formatter-review-debt

Conversation

@stranske

@stranske stranske commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Fixes the shared source for the active consumer-sync review debt.

  • require command-shaped targets in the canonical issue validator
  • recover attributed Original-Issue wrappers and only promote safe verify hints
  • recompute and propagate final formatter validity, pausing auto-pilot instead of labeling non-conforming output as formatted

Validation:

  • python -m pytest -q tests/scripts/test_issue_formatter.py tests/scripts/test_issue_format.py tests/workflows/test_agents_issue_optimizer_format_trigger.py
  • python scripts/sync_tool_versions.py --check
  • python scripts/sync_manifest_compiler.py --manifest .github/sync-manifest.yml --output-json /tmp/consumer-sync-plan.json
  • git diff --check

Summary by CodeRabbit

  • Bug Fixes

    • Improved task validation so vague requests and incomplete commands are not treated as actionable.
    • Verification instructions now accept only safe, recognized commands and exclude unsafe shell commands.
    • Improved handling of original issue content in expandable sections, including sections with attributes.
    • Formatting results requiring refinement are now detected consistently.
  • Workflow Improvements

    • Issues needing refinement are flagged for human review, with an explanation and workflow pause.
  • Tests

    • Added coverage for validation, safe commands, refinement handling, and expandable sections.

Copilot AI lite review requested due to automatic review settings August 9, 2026 05:33
@cursor

cursor Bot commented Aug 9, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR tightens task and verification command validation, supports attributed <details> wrappers, exposes needs_refinement, and pauses auto-pilot before publishing incomplete formatting results.

Changes

Issue formatting validation

Layer / File(s) Summary
Concrete task command validation
.github/scripts/issue_format.py, templates/consumer-repo/.github/scripts/issue_format.py, tests/scripts/test_issue_format.py
Command detection now requires command-shaped invocations. Tests reject vague phrases and accept complete command forms, including backticked make test.
Formatter output validation
scripts/langchain/issue_formatter.py, tests/scripts/test_issue_formatter.py
Verification hints require approved shell-safe commands and canonical validation. Formatting reports needs_refinement, and Original Issue parsing accepts attributed <details> tags.
Auto-pilot refinement stop
.github/workflows/agents-auto-pilot.yml, templates/consumer-repo/.github/workflows/agents-auto-pilot.yml, langsmith-fleet-worker-attempt.json
Both workflows pause auto-pilot, apply review labels, post the refinement reason, and avoid publishing formatted content. Worker metadata is updated for PR 3004.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant issue_formatter.py
  participant agents-auto-pilot.yml
  participant GitHubIssue
  issue_formatter.py->>agents-auto-pilot.yml: Return needs_refinement and reason
  agents-auto-pilot.yml->>GitHubIssue: Apply pause labels
  agents-auto-pilot.yml->>GitHubIssue: Post refinement comment
  agents-auto-pilot.yml-->>GitHubIssue: Skip body update and formatted marker
Loading

Possibly related PRs

Suggested labels: autofix:escalated, verify:compare

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes to formatter contract validation and handling.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch automation/issue-formatter-review-debt

Comment @coderabbitai help to get the list of available commands.

@stranske
stranske temporarily deployed to agent-high-privilege August 9, 2026 05:33 — with GitHub Actions Inactive
@agents-workflows-bot

Copy link
Copy Markdown
Contributor

Workflow source needed

PR #3004 needs either a linked GitHub issue or one valid non-issue Workflow Source before PR metadata automation can manage it safely.

Please do one of:

  • Add <!-- meta:issue:123 --> or a normal Closes #123 / Related to #123 line.
  • Check one Workflow Source option in the PR body.
  • Add a hidden marker such as <!-- workflow-source:local_request -->, <!-- workflow-source:manual_remote -->, <!-- workflow-source:review_followup -->, <!-- workflow-source:sync_campaign -->, or <!-- workflow-source:dependabot -->.
  • Add a workflow source label such as workflow:source-direct-pr, workflow:source-local-request, workflow:source-review-followup, workflow:source-sync, or workflow:no-automation.

Once a valid source is present, this warning will not be reposted.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 134d91f1d1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/langchain/issue_formatter.py
Comment thread .github/workflows/agents-auto-pilot.yml

Copilot AI 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.

Pull request overview

Hardens the issue formatting pipeline so that automated formatting doesn’t incorrectly “green light” output that fails the canonical issue-format contract, and tightens the validator so vague tasks aren’t treated as concrete.

Changes:

  • Tighten the canonical issue validator to require command-shaped invocations (not just command words in prose) for task concreteness.
  • Improve formatter fallback handling: recover pre-existing “Original Issue” wrappers, and only promote verify hints when they match a safe/contract-compliant shape.
  • Propagate a final needs_refinement signal and pause auto-pilot (label + comment) instead of publishing non-conforming formatted output.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/scripts/test_issue_formatter.py Adds regression tests for safe verify-hint promotion and for recovering attributed Original Issue <details> wrappers.
tests/scripts/test_issue_format.py Adds coverage ensuring command words in prose aren’t treated as concrete task targets.
scripts/langchain/issue_formatter.py Adds safe verify-hint gating, improves Original Issue wrapper recovery, and computes/returns needs_refinement from the final output validity.
.github/workflows/agents-auto-pilot.yml Pauses auto-pilot when the formatter reports non-conforming final output (needs_refinement).
.github/scripts/issue_format.py Strengthens task-target detection by requiring command-shaped invocations (and expands the command patterns).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/workflows/agents-auto-pilot.yml
Comment thread scripts/langchain/issue_formatter.py
Comment thread .github/scripts/issue_format.py Outdated
@agents-workflows-bot

agents-workflows-bot Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Automated Status Summary

Head SHA: 2e2cf1a
Latest Runs: ⏳ pending — Gate
Required contexts: summary
Required: core tests (3.12): ⏳ pending, core tests (3.13): ⏳ pending, docker smoke: ⏳ pending, gate: ⏳ pending

Workflow / Job Result Logs
(no jobs reported) ⏳ pending

Coverage Overview

  • Coverage history entries: 1

Coverage Trend

Metric Value
Current 76.24%
Baseline 85.00%
Delta -8.76%
Minimum 70.00%
Status ✅ Pass

Top Coverage Hotspots (lowest coverage)

File Coverage Missing
scripts/issue_dedup_smoke.py 0.0% 4
scripts/runner_lib/__main__.py 0.0% 3
scripts/validate_template_sync.py 0.0% 81
scripts/langchain/topic_splitter.py 19.1% 57
tools/codex_log_analyzer.py 19.6% 140
scripts/repo_review_round2_runner.py 25.1% 344
scripts/prune_agent_stubs.py 39.7% 26
scripts/repo_review_round1_runner.py 40.7% 133
tools/ensure_workflow_timeout_variables.py 42.1% 74
scripts/sync_label_docs.py 42.9% 64
tools/discover_model_catalog.py 44.8% 55
scripts/repo_review_backlog_scan.py 45.3% 116
scripts/repo_review_body_writer.py 46.5% 86
tools/codex_session_analyzer.py 47.9% 59
scripts/create_verifier_labels.py 48.3% 58

Low Coverage Files (<50.0%)

File Coverage Missing
scripts/issue_dedup_smoke.py 0.0% 4
scripts/runner_lib/__main__.py 0.0% 3
scripts/validate_template_sync.py 0.0% 81
scripts/langchain/topic_splitter.py 19.1% 57
tools/codex_log_analyzer.py 19.6% 140
scripts/repo_review_round2_runner.py 25.1% 344
scripts/prune_agent_stubs.py 39.7% 26
scripts/repo_review_round1_runner.py 40.7% 133
tools/ensure_workflow_timeout_variables.py 42.1% 74
scripts/sync_label_docs.py 42.9% 64
tools/discover_model_catalog.py 44.8% 55
scripts/repo_review_backlog_scan.py 45.3% 116
scripts/repo_review_body_writer.py 46.5% 86
tools/codex_session_analyzer.py 47.9% 59
scripts/create_verifier_labels.py 48.3% 58

Updated automatically; will refresh on subsequent CI/Docker completions.


Keepalive checklist

Scope

No scope information available

Tasks

  • No tasks defined

Acceptance criteria

  • No acceptance criteria defined

@stranske

stranske commented Aug 9, 2026

Copy link
Copy Markdown
Owner Author

Runner dispatch state for autofix on PR #3004. Do not edit.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/langchain/issue_formatter.py`:
- Line 772: Add regression tests covering the needs_refinement value produced by
the issue formatting workflow for invalid finalized output, valid finalized
output, and --json output. Verify invalid output sets it true, valid output sets
it false, and JSON output preserves the same contract without defaulting or
inverting the field; anchor the tests to _formatted_output_valid and the
relevant formatter entry point.

In `@tests/scripts/test_issue_formatter.py`:
- Around line 103-113: Update
test_format_issue_fallback_does_not_promote_shell_verify_hint to assert that the
extracted Acceptance Criteria section does not contain the generated “Run
`python3 -m pytest tests/test_x.py`” criterion, ensuring the entire
shell-bearing verify hint is rejected rather than partially promoted.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: d96072df-f942-4c5f-ba12-fe3161b6eb33

📥 Commits

Reviewing files that changed from the base of the PR and between d49a908 and 61020e2.

📒 Files selected for processing (6)
  • .github/scripts/issue_format.py
  • .github/workflows/agents-auto-pilot.yml
  • langsmith-fleet-worker-attempt.json
  • scripts/langchain/issue_formatter.py
  • tests/scripts/test_issue_format.py
  • tests/scripts/test_issue_formatter.py

Comment thread scripts/langchain/issue_formatter.py
Comment thread tests/scripts/test_issue_formatter.py
Validate reused bodies before defaulting needs_refinement, stop auto-pilot
redispatch after refinement pauses, require curl args for safe verify hints,
accept backticked command targets, and mirror the refinement path in the
consumer auto-pilot template to clear template drift.
@stranske stranske added agent:codex Agent-created issues from Codex agents:keepalive Use to initiate keepalive functionality with agents autofix Opt-in automated formatting & lint remediation agent:retry Add to trigger agent retry after rate limit or pause labels Aug 9, 2026
@stranske

stranske commented Aug 9, 2026

Copy link
Copy Markdown
Owner Author

Closer review recovery (cursor)

Pushed exact head 77db0fa246212206bbe3156cd77ccd12f20de155 addressing the five active review threads plus CI blockers:

  1. Reuse needs_refinement_reuse_already_formatted now validates via _formatted_output_valid before defaulting readiness.
  2. Stop redispatch after refinement pause — format-step writes stop_autopilot=true (and same for guard-block) so Re-dispatch does not continue into optimize.
  3. Consumer template parity — mirrored needs_refinement path into templates/consumer-repo/.github/workflows/agents-auto-pilot.yml (also fixes Check Template Drift).
  4. Bare curl verify hintsSAFE_VERIFY_COMMAND_RE now requires curl\s+\S+.
  5. Backticked commands — task concrete-target check accepts a leading backtick (make test).
  6. actionlint/shellcheckREFINEMENT_NODE heredoc terminator dedented to match GUARD_NODE.

Validation: focused pytest 3 passed (reuse needs_refinement, bare curl, backticked make test); earlier filtered suite 17 passed. Mandatory post-push 7-minute review window applies before merge.

@agents-workflows-bot

agents-workflows-bot Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

🤖 Keepalive Loop Status

PR #3004 | Agent: Codex | Iteration 0/12

Current State

Metric Value
Iteration progress [----------] 0/12
Action skip (needs-human)
Disposition skipped
Gate success
Tasks 0/7 complete
Timeout 45 min (default)
Timeout usage 11m elapsed (26%, 34m remaining)
Keepalive ✅ enabled
Autofix ❌ disabled

🔍 Failure Classification

| Error type | infrastructure |
| Error category | unknown |
| Suggested recovery | Capture logs and context; retry once and escalate if the issue persists. |

⚠️ Failure Tracking

| Consecutive failures | 8/3 |
| Reason | agent-run-failed |

@stranske

stranske commented Aug 9, 2026

Copy link
Copy Markdown
Owner Author

Addressed the active CodeRabbit test-specificity finding in 96ea4f77: both canonical and consumer validator negative-command cases now assert the concrete-target diagnostic, not only report.ok == false. Validation: python -m pytest -q tests/scripts/test_issue_format.py (68 passed), python -m ruff check tests/scripts/test_issue_format.py, python -m ruff format --check tests/scripts/test_issue_format.py, and git diff --check.

@stranske stranske removed needs-human Requires human intervention or review agent:needs-attention Agent needs human review or intervention labels Aug 9, 2026
@stranske
stranske temporarily deployed to agent-high-privilege August 9, 2026 07:24 — with GitHub Actions Inactive
@agents-workflows-bot
agents-workflows-bot Bot temporarily deployed to agent-high-privilege August 9, 2026 07:30 Inactive
@stranske-keepalive stranske-keepalive Bot added agent:needs-attention Agent needs human review or intervention needs-human Requires human intervention or review labels Aug 9, 2026
@stranske-keepalive
stranske-keepalive Bot temporarily deployed to agent-high-privilege August 9, 2026 07:31 Inactive
@agents-workflows-bot
agents-workflows-bot Bot temporarily deployed to agent-high-privilege August 9, 2026 07:37 Inactive
@stranske

stranske commented Aug 9, 2026

Copy link
Copy Markdown
Owner Author

Closer disposition — outdated Copilot curl thread

Resolved outdated unresolved thread PRRT_kwDOQprj9M6XkIGJ on exact head bf68a6d30f51f351ba93a9bfd40e89be2a8dbf65.

Claim: SAFE_VERIFY_COMMAND_RE treated bare curl as safe.
Current head: scripts/langchain/issue_formatter.py uses curl\s+\S+ (requires an argument), matching the canonical validator. No further code change needed.

Also clearing automation-loop needs-human / agent:needs-attention so keepalive can continue while Gate finishes on this head. Retaining agent:codex, agents:keepalive, autofix, agent:retry.

@stranske stranske removed needs-human Requires human intervention or review agent:needs-attention Agent needs human review or intervention labels Aug 9, 2026
@agents-workflows-bot
agents-workflows-bot Bot temporarily deployed to agent-high-privilege August 9, 2026 07:43 Inactive
@stranske-keepalive stranske-keepalive Bot added agent:needs-attention Agent needs human review or intervention needs-human Requires human intervention or review labels Aug 9, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Provider Comparison Report

Provider Summary

Provider Model Verdict Confidence Summary
openai gpt-5.6-terra PASS 88% The changes address all stated formatter-contract requirements. The canonical validator now requires command-shaped invocations rather than accepting command words in prose, with matching consumer-...
anthropic claude-sonnet-5 CONCERNS N/A Review the PR manually or re-run once LLM credentials are available.
📋 Full Provider Details (click to expand)

openai

  • Model: gpt-5.6-terra
  • Verdict: PASS
  • Confidence: 88%
  • Scores:
    • Correctness: 9.0/10
    • Completeness: 9.0/10
    • Quality: 9.0/10
    • Testing: 8.0/10
    • Risks: 9.0/10
  • Summary: The changes address all stated formatter-contract requirements. The canonical validator now requires command-shaped invocations rather than accepting command words in prose, with matching consumer-template synchronization. The formatter changes add handling for attributed Original-Issue content and constrain promoted verify hints to safe command forms. Auto-pilot now recognizes formatter-reported refinement requirements, avoids publishing/labeling invalid formatter output as formatted, pauses automation, and records the reason through labels and a comment. Added tests in both formatter and canonical issue-format suites provide targeted coverage for the new validation and recovery behavior. The implementation is readable, scoped to the requested behavior, and does not introduce material security or compatibility concerns.

anthropic

  • Model: claude-sonnet-5
  • Verdict: CONCERNS
  • Confidence: N/A
  • Summary: Review the PR manually or re-run once LLM credentials are available.
  • Concerns:
    • LLM evaluation could not run.
  • Error: LLM invocation failed: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'Your credit balance is too low to access the Anthropic API. Please go to Plans & Billing to upgrade or purchase credits.'}, 'request_id': 'req_011CdvkE9NnUykBcHWDAbcL8'}

Agreement

  • No clear areas of agreement.

Disagreement

Dimension openai anthropic
Verdict PASS CONCERNS

Unique Insights

  • openai: The changes address all stated formatter-contract requirements. The canonical validator now requires command-shaped invocations rather than accepting command words in prose, with matching consumer-template synchronization. The formatter changes add handling for attributed Original-Issue content a...
  • anthropic: LLM evaluation could not run.

🔍 LangSmith Traces

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent:codex Agent-created issues from Codex agent:needs-attention Agent needs human review or intervention agent:retry Add to trigger agent retry after rate limit or pause agents:keepalive Use to initiate keepalive functionality with agents autofix Opt-in automated formatting & lint remediation needs-human Requires human intervention or review verify:compare Compare multiple LLM evaluations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants