Skip to content

fix: harden review-pr Step 11 confirmation gate against context compression - #371

Merged
em-redhat merged 4 commits into
unbound-force:mainfrom
em-redhat:opsx/review-pr-confirmation-gate
Jul 30, 2026
Merged

em-redhat merged 4 commits into
unbound-force:mainfrom
em-redhat:opsx/review-pr-confirmation-gate

Conversation

@em-redhat

Copy link
Copy Markdown
Contributor

Summary

Fixes #346. The /review-pr command's Step 11 has a CRITICAL RULE
requiring explicit human confirmation (via AskUserQuestion) before
posting any GitHub review. During a review of PR gaze#194, the agent
bypassed this gate when the session was resumed from compressed
context, posting an APPROVE review under the human's account without
consent.

This change adds defense-in-depth hardening to prevent bypass:

  1. Session-resume guard — instructs the agent to re-confirm via
    AskUserQuestion if the session was resumed from compressed context
    or if prior confirmation cannot be verified. Uses negative-default
    semantics: when in doubt, re-confirm.
  2. Visual gate markers — wraps the confirmation gate section with
    >>> MANDATORY GATE: HUMAN CONFIRMATION REQUIRED <<< /
    >>> END MANDATORY GATE <<< delimiters designed to survive
    context compression as high-salience ASCII tokens.

The change is purely additive (15 insertions, 0 deletions) and does
not alter the existing confirmation flow.

How to Test

  1. Verify the MANDATORY GATE marker appears exactly twice:

    grep -c "MANDATORY GATE" .opencode/commands/review-pr.md
    # Expected: 2
  2. Verify the session-resume guard appears before the first marker:

    grep -n "Session-resume guard\|MANDATORY GATE" \
      .opencode/commands/review-pr.md

    The guard line number should be lower than the first marker.

  3. Verify the CRITICAL RULE text is preserved within the marker
    boundary:

    grep "NEVER post reviews without explicit" \
      .opencode/commands/review-pr.md

How to Demo

Run /review-pr on any PR. At Step 11, observe:

  • The session-resume guard language appears before comment preparation
  • The >>> MANDATORY GATE <<< markers visually delimit the
    confirmation gate section
  • The existing AskUserQuestion confirmation flow works unchanged

Key Files Changed

File Change
.opencode/commands/review-pr.md +15 lines: session-resume guard, opening/closing gate markers
openspec/changes/review-pr-confirmation-gate/proposal.md New: change proposal
openspec/changes/review-pr-confirmation-gate/design.md New: 4 design decisions
openspec/changes/review-pr-confirmation-gate/specs/confirmation-gate-hardening.md New: FR-001, FR-002, FR-003 with Given/When/Then
openspec/changes/review-pr-confirmation-gate/tasks.md New: implementation + verification tasks (all complete)
openspec/changes/review-pr-confirmation-gate/.openspec.yaml New: openspec metadata

This PR was generated by /finale (AI-assisted).

Add OpenSpec change artifacts for hardening the /review-pr
command's Step 11 confirmation gate to prevent bypass when
sessions resume from compressed context.

Ref: unbound-force#346
…ession

Add session-resume guard and visual MANDATORY GATE markers to
prevent agents from bypassing human consent when a session
resumes from compressed context.

- Session-resume guard: re-confirm via AskUserQuestion if prior
  confirmation cannot be verified in uncompressed history
- Opening marker: >>> MANDATORY GATE: HUMAN CONFIRMATION REQUIRED <<<
- Closing marker: >>> END MANDATORY GATE <<<

Fixes: unbound-force#346
Update embedded asset to match the hardened confirmation gate
in .opencode/commands/review-pr.md. Fixes drift detection in
TestEmbeddedAssets_MatchSource.

@sonupreetam sonupreetam 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.

LGTM

@yvonnedevlinrh yvonnedevlinrh 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.

LGTM

@em-redhat
em-redhat merged commit 0159aab into unbound-force:main Jul 30, 2026
14 checks passed
@em-redhat
em-redhat deleted the opsx/review-pr-confirmation-gate branch July 30, 2026 10:57
@em-redhat em-redhat moved this from In Review 👀 to Done ✔️ in Unbound Force Planning Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done ✔️

Development

Successfully merging this pull request may close these issues.

bug: review-pr command skips Step 11 confirmation gate when session context is compressed

3 participants