altimate-code icon indicating copy to clipboard operation
altimate-code copied to clipboard

dbt PR reviewer: stale doc comments contradict APPROVE→COMMENT; harden no-formal-approve invariant at compile time

Open anandgupta42 opened this issue 6 months ago • 1 comments

Context

PR #870 changed the dbt PR reviewer so an APPROVE verdict maps to a GitHub COMMENT review event (the bot must never submit a formal approval that could satisfy branch protection). That fix was correct, but it left two loose ends:

  1. Stale doc comments in packages/opencode/src/altimate/review/post-github.ts still claimed "in gate mode it maps the verdict to APPROVE/REQUEST_CHANGES" and "gate mode keeps APPROVE / REQUEST_CHANGES" — directly contradicting the new behavior. Misleading documentation on a security-relevant path.

  2. The no-formal-APPROVE invariant was only enforced at runtime. VCS_EVENT's value type still included "APPROVE", so a future edit could map a verdict back to a formal GitHub approval without the compiler objecting.

Proposed change

  • Correct the doc comments in post-github.ts to describe the actual behavior (APPROVE → COMMENT always; comment mode also softens REQUEST_CHANGES → COMMENT; gate mode keeps REQUEST_CHANGES as a blocking review; env.verdict arrives pre-softened from buildEnvelope).
  • Narrow the VCS_EVENT value type to "COMMENT" | "REQUEST_CHANGES" so the invariant is a compile-time guarantee (the narrower union is still assignable to Octokit's createReview event param).
  • Document applyMode's APPROVE/COMMENT passthrough.
  • Add a composition test asserting the positive expected GitHub event for every verdict-producing finding-set across both modes, plus the semantic-verdict-vs-VCS-event separation.

Acceptance

  • No code path or type permits a formal GitHub APPROVE.
  • Docs match runtime behavior.
  • Typecheck + review test suite green.

anandgupta42 avatar Jun 02 '26 23:06 anandgupta42

Resolved in v0.8.1.

anandgupta42 avatar Jun 03 '26 19:06 anandgupta42