1 line
3.4 KiB
Plaintext
1 line
3.4 KiB
Plaintext
Project Sentinel: Code Review & Quality GovernanceVersion: 3.0.0-EnterpriseModule: 13-Workflow-ReviewMaps to: docs/workflows/CODE_REVIEW.mdScope: Automated pre-review verification, human-approval enforcement, and "LGTM" policy locking.1. The Pre-Review GateIn the Sentinel ecosystem, "Code Review" is not just a human looking at a Pull Request. It is a multi-stage validation pipeline. The Agent is physically blocked from requesting a human review until the automated "Pre-Review" passes.1.1 The "Ready for Review" CriteriaTrigger: Agent calls request_review(pr_id="123").Sentinel Logic:Diff Analysis: Sentinel calculates the "Churn" (lines changed) and "Complexity" (Cyclomatic Complexity delta).Test Coverage: Checks coverage.out. If coverage dropped by > 1%, the request is rejected.Lint Status: Runs golangci-lint or eslint. If any error exists, the request is rejected.Output:Pass: "PR #123 marked as REVIEW_PENDING. Notifying Human Approvers."Fail: "Review Request Denied. You have 3 lint errors and coverage dropped by 2.5%. Fix these first."1.2 The Self-Correction LoopIf the Pre-Review fails, Sentinel enters Correction Mode.Constraint: The Agent cannot start a new task. It is locked into the current task context.Tooling: Sentinel auto-mounts the lint_report.json into the context window so the Agent sees exactly what failed without needing to grep logs.2. Human-in-the-Loop (HITL) ApprovalSentinel adheres to the "Four Eyes Principle." No code authored by an AI Agent can reach main without Human cryptographic signature.2.1 The Approval LockMechanism: The merge_pr tool is Disabled by default.Activation:Sentinel polls the GitHub/GitLab API (or local git notes) for a review signature.Condition: approvals >= 1 AND changes_requested == 0.Unlock: Once the condition is met, the merge_pr tool becomes available in the Agent's tool definition list.2.2 The "Sycophant" FilterThreat: A lazy human reviewer types "LGTM" without reading the code.Sentinel Defense:If the Reviewer approves a PR > 500 lines in < 1 minute, Sentinel flags it.Alert: "Suspicious Approval Detected. Review time was insufficient for change size. Please re-verify." (Logged to Audit DB with severity: warning).3. Automated Review Agents (The "Bot Review")Before the human sees the code, Sentinel's "Static Analysis Agent" does a pass.3.1 Policy ScanningSentinel scans the diff for specific forbidden patterns defined in docs/standards/.Forbidden: time.Sleep(10 * time.Second) (Arbitrary waits).Forbidden: TODO: Fix this later (Tech debt injection).Forbidden: chmod 777 (Insecure permissions).3.2 The "Nitpicker" BotAction: Sentinel posts comments directly to the PR line-by-line.Example:Line 45: You ignored the error return from json.Marshal. Please handle it.Blocker: These automated comments act as "Change Requests." The Agent must resolve them (and mark them resolved) before the PR can merge.4. Post-Review Integrity4.1 The "ninja-commit" PreventionVulnerability: Agent gets approval, then pushes a "quick fix" commit after approval but before merge.Defense: Stale Review Invalidation.If last_commit_time > last_approval_time:Sentinel revokes the "Approved" status in the internal DB.The merge_pr tool re-locks.Message: "Code changed after approval. Re-review required."4.2 Merge Strategy EnforcementRule: Squash and Merge.Enforcement:Sentinel executes the merge using git merge --squash.It prompts the Agent to generate a Summary Commit Message based on the PR description, discarding the "wip" commit messages from the history. |