mirror of
https://github.com/waybarrios/opencode-power-pack.git
synced 2026-11-18 18:03:43 +00:00
Complete review scope guarantees
This commit is contained in:
@@ -40,7 +40,9 @@ Set the baseline to `HEAD` and the implementation to the complete working tree.
|
||||
|
||||
Discover repository-root and path-ancestor `AGENTS.md` and `CLAUDE.md` files. Read the applicable rules and map them to each changed path rather than applying unrelated nested rules.
|
||||
|
||||
Create a stable `SCOPE_ID` from the repository identity, mode, pinned baseline and implementation, and changed paths. Emit this frozen scope manifest before any dispatch:
|
||||
For staged, unstaged, and untracked evidence, capture exact bytes before analysis: snapshot staged index blobs separately from unstaged working-tree bytes, retain a frozen patch, and record SHA-256 content hashes for the patch and every entry. Record a preimage hash and deletion marker for deletions, and old and new paths with their content hashes for renames. Analyze only this frozen snapshot, never later mutable worktree bytes.
|
||||
|
||||
Create a stable `SCOPE_ID` from the repository identity, mode, pinned baseline and implementation, changed paths, frozen patch digest, and per-entry snapshot hashes. Emit this frozen scope manifest before any dispatch:
|
||||
|
||||
```text
|
||||
SCOPE_ID:
|
||||
@@ -51,6 +53,10 @@ IMPLEMENTATION:
|
||||
DIFF_SOURCE:
|
||||
CHANGED_PATHS_AND_STATUSES:
|
||||
UNTRACKED_PATHS:
|
||||
WORKTREE_INCLUDED: yes | no
|
||||
WORKTREE_PATCH_SHA256:
|
||||
WORKTREE_SNAPSHOT_SHA256:
|
||||
WORKTREE_ENTRIES: state | old/new paths | source | content/preimage SHA-256 | deletion marker
|
||||
PR_NUMBER:
|
||||
PR_TITLE:
|
||||
PR_BODY:
|
||||
@@ -62,6 +68,8 @@ RULES_BY_PATH:
|
||||
|
||||
Use empty PR fields outside PR mode. Summarize the intent and implementation only from this manifest and its pinned evidence.
|
||||
|
||||
Before every dispatch, before consuming a child result, and before output or posting, recompute the included index and working-tree hashes and compare them with the manifest. Any mutation or mismatch makes the affected detection, cross-check, and validation coverage incomplete. Do not update `SCOPE_ID`, analyze replacement bytes, or combine evidence from different snapshots; preserve valid frozen evidence and use the incomplete outcome.
|
||||
|
||||
### 2. Detect candidates
|
||||
|
||||
Dispatch these seven independent detection roles in parallel when task dispatch is available:
|
||||
@@ -105,7 +113,7 @@ Never interpret failed, blank, malformed, or partial output as no findings. Pres
|
||||
|
||||
Maintain a detection coverage ledger keyed by detection role and expected path. Record status (`pending | complete | partial | blocked | local-fallback`), dispatch/resume/retry counts, evidence, missing coverage, and fallback result.
|
||||
|
||||
Maintain a candidate ledger keyed by stable candidate ID. Record source role, evidence, cross-check disposition, validation status, final confidence, and final disposition (`reported | rejected | unresolved`). Do not silently discard a candidate because a child failed.
|
||||
Maintain a candidate ledger keyed by stable candidate ID. Record source role, evidence, cross-check status, validation status, final confidence, and final disposition (`reported | rejected`). `unresolved` is explicitly non-final and remains the candidate status until cross-check and required validation complete. Do not silently discard a candidate because a child failed.
|
||||
|
||||
### 4. Cross-check and validate candidates
|
||||
|
||||
@@ -119,7 +127,9 @@ The final reporting threshold is confidence ≥ 80. Reject candidates below the
|
||||
|
||||
For each reported finding provide path and line, Critical or Important severity, confidence, concise problem statement, concrete reproduction, fix direction or regression-test location, and rule or bug category. Findings come first and are grouped by severity.
|
||||
|
||||
Emit the exact no-issues sentence only when every detection role is complete and every candidate has a final disposition. Complete detection also requires every expected path to be covered for every applicable role, including parent-owned fallback work:
|
||||
The clean result requires complete detection, cross-check, and validation coverage with zero unresolved candidates and zero reported candidates. Detection must cover every expected path for every applicable role, including parent-owned fallback work; every candidate must complete cross-check; and every cross-check survivor must complete validation with a final disposition.
|
||||
|
||||
Emit the exact no-issues sentence only when every detection role is complete and every candidate has a final disposition. Validated reportable findings produce findings output, not clean output, even when all coverage is complete:
|
||||
|
||||
`No issues found. Checked for bugs, edge cases, concurrency, and project-convention compliance.`
|
||||
|
||||
@@ -127,7 +137,7 @@ Otherwise emit `Review incomplete` and report completed coverage, missing covera
|
||||
|
||||
### 6. Post to GitHub only when requested
|
||||
|
||||
Posting requires PR scope. If `--comment` or equivalent is requested without PR scope, report the missing target and do not post. Never post a clean summary for incomplete coverage.
|
||||
Posting requires PR scope. If `--comment` or equivalent is requested without PR scope, report the missing target and do not post. Apply the same detection, cross-check, validation, unresolved, and reported-candidate gate before posting a clean summary; never post one for incomplete coverage or validated findings.
|
||||
|
||||
Use a marker tied to repository, PR, pinned head SHA, and either `summary` or a stable finding key:
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ Resolve review mode in this order. An explicit requested scope takes precedence
|
||||
1. An explicit requested commit range or revision.
|
||||
2. An explicit PR URL or number.
|
||||
3. The open PR for the current branch, when one exists.
|
||||
4. Local pending changes.
|
||||
4. Local branch and pending changes.
|
||||
|
||||
Do not mix modes or widen the resolved scope. Requested paths are a filter over the resolved mode, not a separate baseline.
|
||||
|
||||
@@ -35,7 +35,13 @@ Run `gh pr view <PR> --json number,title,body,state,isDraft,baseRefName,baseRefO
|
||||
|
||||
#### Local scope
|
||||
|
||||
Include committed current-branch changes relative to the resolved upstream merge base and the complete working tree. Use `git diff --find-renames HEAD` for staged and unstaged tracked changes. Use `git ls-files --others --exclude-standard` and read every returned untracked file as an addition. Include committed, staged, unstaged, deleted, renamed, and untracked states without counting the same change twice.
|
||||
An explicit baseline takes precedence when supplied: resolve it to one commit OID and use it as `BASE_SHA`. Otherwise resolve exactly one upstream tracking ref and its OID with `git rev-parse --abbrev-ref --symbolic-full-name @{upstream}` and `git rev-parse --verify @{upstream}^{commit}`, then require `git merge-base --all HEAD <upstream-oid>` to return exactly one OID. That OID is the uniquely resolved upstream merge base; do not guess a remote default branch or use a symbolic ref as evidence.
|
||||
|
||||
Default local scope requires that committed-branch provenance. If no unique trustworthy base can be established because the branch has no upstream, a ref or object cannot be resolved, or the merge base is absent or ambiguous, mark scope discovery incomplete and use the incomplete terminal outcome before checking for an empty scope. Never silently use `HEAD` as a committed-branch baseline or report the empty `No reviewable changes found in the resolved scope.` outcome after baseline-resolution failure.
|
||||
|
||||
Pure pending-change local review is allowed only when the user explicitly requests pending-only scope. Record that mode unambiguously, pin `HEAD` solely as the preimage for those worktree changes, and do not infer pending-only mode from a missing upstream or a clean worktree.
|
||||
|
||||
Include committed current-branch changes relative to the resolved base and the complete working tree. Use `git diff --find-renames HEAD` for staged and unstaged tracked changes. Use `git ls-files --others --exclude-standard` and read every returned untracked file as an addition. Include committed, staged, unstaged, deleted, renamed, and untracked states without counting the same change twice.
|
||||
|
||||
#### Scope manifest
|
||||
|
||||
@@ -49,6 +55,7 @@ MODE: range | revision | pr | local
|
||||
PATH_FILTER:
|
||||
REPOSITORY_ROOT:
|
||||
BASE_SHA:
|
||||
BASE_SOURCE: explicit | upstream-merge-base | explicit-pending-only
|
||||
HEAD_SHA:
|
||||
WORKTREE_INCLUDED: yes | no
|
||||
WORKTREE_SNAPSHOT_SHA256:
|
||||
|
||||
@@ -19,6 +19,13 @@ test("code-review freezes complete PR and local scopes", () => {
|
||||
assert.doesNotMatch(review, /or the local `git diff`/);
|
||||
});
|
||||
|
||||
test("code-review content-addresses working-tree scope and detects mutation", () => {
|
||||
assert.match(review, /staged.*unstaged.*untracked.*(?:exact bytes|content hashes|SHA-256|frozen patch)/is);
|
||||
assert.match(review, /SCOPE_ID.*(?:snapshot|patch).*(?:hash|digest)/is);
|
||||
assert.match(review, /analyze only.*(?:snapshot|frozen evidence)/is);
|
||||
assert.match(review, /(?:mutation|mismatch).*coverage incomplete/is);
|
||||
});
|
||||
|
||||
test("code-review validates child output and bounds recovery", () => {
|
||||
for (const field of ["STATUS:", "SCOPE_ID:", "ROLE:", "COVERAGE:", "CANDIDATES:", "ERRORS:"]) assert.ok(review.includes(field));
|
||||
assert.match(review, /validate every child/i);
|
||||
@@ -44,6 +51,13 @@ test("code-review gates clean output on complete ledgers", () => {
|
||||
assert.ok(review.includes("No issues found. Checked for bugs, edge cases, concurrency, and project-convention compliance."));
|
||||
});
|
||||
|
||||
test("code-review treats unresolved candidates as non-final and gates every stage", () => {
|
||||
assert.match(review, /`unresolved` is (?:explicitly )?non-final/i);
|
||||
assert.match(review, /clean result requires complete detection, cross-check, and validation coverage/i);
|
||||
assert.match(review, /zero unresolved candidates and zero reported candidates/i);
|
||||
assert.match(review, /validated reportable findings.*findings output.*(?:not|never).*clean/is);
|
||||
});
|
||||
|
||||
test("code-review reconciles confidence, runtime inputs, and posting", () => {
|
||||
assert.match(review, /final reporting threshold.*confidence\s*≥\s*80/i);
|
||||
assert.match(review, /required runtime state or input is not shown to be reachable/i);
|
||||
|
||||
@@ -20,6 +20,13 @@ test("security-review filters path-only requests over the resolved change set",
|
||||
assert.match(skill, /(?:filter|restrict).*requested paths.*committed.*(?:branch|PR) changes/is);
|
||||
});
|
||||
|
||||
test("security-review fails closed when local branch provenance is ambiguous", () => {
|
||||
assert.match(skill, /explicit baseline.*(?:takes precedence|when supplied)/is);
|
||||
assert.match(skill, /uniquely resolved upstream merge base/is);
|
||||
assert.match(skill, /(?:no|cannot establish).*unique trustworthy base.*scope discovery.*incomplete/is);
|
||||
assert.match(skill, /never.*(?:silently )?use `?HEAD`?.*baseline.*(?:empty|no reviewable changes)/is);
|
||||
});
|
||||
|
||||
test("security-review content-addresses worktree scope and detects mutation", () => {
|
||||
assert.match(skill, /worktree.*(?:exact bytes|content hash|SHA-256|frozen patch)/is);
|
||||
assert.match(skill, /SCOPE_ID.*(?:worktree|snapshot).*(?:hash|digest)/is);
|
||||
|
||||
Reference in New Issue
Block a user