Skip to content

Adopt structured marker contract for quality-gate (replace grep) #185

@cbeaulieu-gt

Description

@cbeaulieu-gt

Summary

Long-term direction for the claude-pr-review/quality-gate feature: replace the regex-grep approach with a structured contract between anthropics/claude-code-action (or a wrapper) and the gate. Grep is fragile by design and the marker-validation + multi-bot collision issues in this milestone are symptoms of that fragility — addressing them tactically buys time, but the root fix is a contract.

Why grep is the wrong long-term answer

  • Prompt templates drift; regex misses become silent fail-open events
  • Severity classification is currently encoded in human-readable prose, not data — every consumer that wants to act on it has to re-implement the parser
  • Adding a new severity tier (e.g. "Note" or "Suggestion") requires every consumer to update their regex
  • The grep can't reliably distinguish "Critical finding the reviewer raised" from "the word Critical appearing in the code being reviewed"

Proposal options

Option A — Hidden JSON block in the review comment

Emit a JSON block inside an HTML comment (invisible in rendered Markdown):

<!-- claude-pr-review-summary-v1
{
  "schemaVersion": 1,
  "findings": { "critical": 2, "high": 1, "medium": 4, "low": 0 },
  "verdict": "blocking"
}
-->

Gate parses with jq. Versioned schema; backwards-compatible drift.

Option B — Use anthropics/claude-code-action outputs

Consume structured findings as step outputs (or as an uploaded artifact). Requires upstream cooperation but is the cleanest integration.

Option C — Separate structured artifact

Have the action upload a claude-review-findings.json artifact; the gate downloads and parses it. Decouples the user-facing comment from the machine-readable signal.

Blocked by

  • Fail-open issue — fix first; structured contract doesn't matter if the caller silently swallows failures
  • Validate-regex-against-upstream — informs whether upstream cooperation (Option B) is viable
  • Multi-bot selection — the sentinel from Option A or comment ID from Option B is the same mechanism that fixes selection ambiguity

Acceptance criteria

  • Choose one of Options A/B/C based on what's feasible in anthropics/claude-code-action
  • The gate consumes structured data, not grep on comment prose
  • Schema is versioned (so prompt-template evolution doesn't break consumers)
  • Test fixtures cover: schema-v1 → works; schema-v2 → works for v1 callers via compatibility shim; corrupted/missing → safe fail
  • Documentation in pr-review/README.md explains the contract

Out of scope

  • Choosing the severity taxonomy itself — orthogonal; this issue is about transport, not classification

Refs #176 #179

🤖 Generated by Claude Code on behalf of @cbeaulieu-gt

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions