Skip to content

HITL: Approval queue, code diff view, graduation, confidence scoring, and notifications#13

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/hitl-approval-workflow
Draft

HITL: Approval queue, code diff view, graduation, confidence scoring, and notifications#13
Copilot wants to merge 2 commits intomainfrom
copilot/hitl-approval-workflow

Conversation

Copy link

Copilot AI commented Mar 15, 2026

Formalizes the human-in-the-loop workflow that connects the Fix Review panel, pattern library, and self-healing mode into a cohesive system with persistence, graduation logic, and autonomous promotion.

Backend (serve.py)

Persistent Queue

  • fix-queue.json / fix-approval-history.json survive restarts; all mutations guarded by _fixes_lock
  • Fix records now carry: issue_class, confidence, created_at, outcome, changed_files, diffs, auto_applied

New endpoints

Method Path Purpose
POST /api/fix/resolve Approve / Partial / Reject; updates per-class history, triggers regression check
GET /api/fix/diff Parses session JSONL for Edit/Write tool calls → unified diff per file
POST /api/fix/revert git checkout -- <changed_files> for rejected fixes
GET /api/fix/graduation-stats Per-class approval rates and graduation eligibility
POST /api/fix/graduate Promotes class to autonomous (auto_apply: true)
POST /api/fix/webhook Configures Slack/webhook URL + sound toggle

Graduation & confidence

  • compute_confidence() scales 0.3–1.0 from class approval history; novel classes default to 0.3
  • check_graduation() requires ≥95% approval over ≥10 fixes
  • Graduated classes with confidence ≥ 0.9 auto-apply and skip the HITL queue entirely
  • Regression detection: a rejected fix from a graduated class revokes auto_apply

Frontend (js/fix-review.js)

  • Issue-class badge + confidence badge (green ≥70%, orange <70%) on every fix card
  • Expandable syntax-highlighted unified diff viewer (+ green / - red / @@ blue)
  • Graduation bar appears when a class hits threshold; "Graduate → Autonomous" button calls POST /api/fix/graduate
  • Collapsible graduation stats table with per-class outcomes and inline Graduate buttons
  • Batch Approve All / Reject All when multiple pending fixes share a class
  • Revert button activates after rejection, calls POST /api/fix/revert
  • resolve() now persists via POST /api/fix/resolve (previously only called window.__claude.resolve)
  • Desktop Notification API fires when a fix transitions to ready
  • _escHtml() helper applied throughout to prevent XSS from untrusted fix metadata

CSS (style.css)

Adds 222 lines: confidence badges, unified-diff syntax highlighting, graduation bar/stats table, batch action bar, revert button.

Original prompt

This section details on the original issue you should resolve

<issue_title>HITL: Human-in-the-loop approval workflow for autonomous fixes</issue_title>
<issue_description>## Description
Formalize the human-in-the-loop approval workflow that connects the Fix Review panel (#10), pattern library (#8), and self-healing mode (#7) into a cohesive HITL system.

Current State (Delivered)

  • Fix Review panel: Before/after screenshots, Approve/Partial/Reject buttons
  • Pattern library: Stores successful fixes, matches on new issues
  • Telemetry: resolve() closes the feedback loop, metrics() shows dashboard

HITL Requirements

1. Approval Queue

  • Persistent queue of pending fixes (survives page refresh)
  • Queue items show: description, issue class, before/after screenshots, code diff
  • Batch approve/reject for same-class fixes
  • Queue badge count in the visualizer header bar

2. Code Diff View

  • Show the actual file edits made by Claude Code (parse session JSONL for Edit/Write tool calls)
  • Syntax-highlighted diff alongside the visual before/after
  • One-click revert if rejected (git checkout the changed files)

3. Approval Graduation (ADR-0007)

  • Track approval rate per issue class
  • When class hits 95%+ approval over 10+ fixes, propose auto-apply
  • "Graduate" button promotes class from HITL → autonomous
  • Graduated classes still log telemetry but skip the review queue
  • Regression detection: if a graduated fix fails, revoke auto-apply

4. Confidence Scoring

  • Display confidence score based on pattern match quality
  • High-confidence fixes (known class, strong pattern match) show green badge
  • Low-confidence fixes (novel class, no prior patterns) show orange badge
  • Confidence threshold configurable (default: auto-apply above 0.9)

5. Notification Integration

  • Desktop notification when fix is ready for review
  • Optional sound (via TTS feedback skill)
  • Slack/webhook notification for remote review

Architecture

__claude.fix() → Before screenshot → Claude Code session → After screenshot
                                                                    ↓
                                              Fix Review Panel (HITL)
                                              ├── Before/After images
                                              ├── Code diff
                                              ├── Confidence score
                                              └── [Approve] [Partial] [Reject]
                                                      ↓
                                              Pattern stored (success)
                                              → Metrics updated
                                              → Graduation check

Depends On

References

  • PKM ADR-0007: Always-On Agent Fleet (operational autonomy)
  • PKM ADR-0013 Benchmarks: Self-Improvement Loop 3 (Approval Lane Graduation)
  • PKM ADR-0013 Benchmarks: North Star principles</issue_description>

Comments on the Issue (you are @copilot in this section)


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

…uation, and notifications

Co-authored-by: michaeloboyle <[email protected]>
Copilot AI changed the title [WIP] Formalize human-in-the-loop approval workflow HITL: Approval queue, code diff view, graduation, confidence scoring, and notifications Mar 15, 2026
Copilot AI requested a review from michaeloboyle March 15, 2026 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HITL: Human-in-the-loop approval workflow for autonomous fixes

2 participants