Service Diffguard
Service Diffguard reviews a diff with six focused lenses. Each lens runs as
a read-only Amp Task subagent, inspects the requested change, and returns
findings graded on one shared scale. Lenses advise only — they never edit,
stage, or commit code, never disable tests, and never bypass a failing check to
make it pass.
Default scope is the unstaged git diff unless the caller names specific
files, a branch, a commit range, or an existing PR.
Gate scale
Every finding carries a Gate. The run's overall Gate is the highest any lens
returns.
| Gate |
Name |
Meaning |
Action |
| G4 |
Stop |
Likely correctness, security, data-integrity, compile, boundary, or reliability failure. |
Block merge until fixed. |
| G3 |
Repair |
Likely user-visible bug, operational blind spot, real test gap, or misleading contract. |
Fix before the PR is ready. |
| G2 |
Tighten |
Locally safe but leaves avoidable risk, ambiguity, weak design, or brittleness. |
Address if reasonably scoped; otherwise acknowledge. |
| G1 |
Polish |
Low-risk clarity, naming, comment, or small test refinement. |
Optional; batch, don't spam. |
| G0 |
Clear |
No issue, or a positive observation. |
None. |
Every G2 or higher finding must include: file:line, Proof (evidence from
the diff), why it matters, a Patch direction (smallest safe fix), and how to
verify. Weak or speculative observations go under Open checks, not as a
finding. Cap G1 items at five per lens unless exhaustive polish is requested.
Lens catalog
| Lens |
Focus |
Reference prompt |
| Service Steward |
general code correctness & conventions |
reference/service-steward.md |
| Error Tripwire |
failure-path visibility |
reference/error-tripwire.md |
| Doc Drift Check |
comment truthfulness |
reference/doc-drift-check.md |
| Harness Map |
behavior-to-test mapping |
reference/harness-map.md |
| Boundary Keeper |
type & contract design across layers |
reference/boundary-keeper.md |
| Straight-Line Pass |
behavior-preserving simplification |
reference/straight-line-pass.md |
Languages in this repo
Diffguard reviews a changed file in whatever language it is written in. Each lens
applies its concept (correctness, failure visibility, comment truth, test
coverage, contract design, simplification) through the idioms of that language —
Go is the primary codebase, not the only one.
| Area |
Where |
Lens focus for this language |
| Go services |
app/**, business/**, foundation/**, api/** (.go) |
Full Go review; the layered type rules and Go skills apply here. |
| Admin frontend |
api/frontends/admin/src (.vue, .js, .scss) |
Vue SFC structure, component props/emits contracts, reactivity, async/fetch error handling, accessibility, leaked watchers/listeners. |
| Auth policies |
app/sdk/auth/rego (.rego) |
OPA/Rego rules: default-deny posture, input shape assumptions, unintended allows. |
| gRPC contracts |
app/domain/grpcauthapp (.proto) |
Field-number stability, backward/forward compatibility, breaking changes. |
| Database |
business/sdk/migrate/sql (.sql) |
Migration reversibility/idempotency, indexing, locking, destructive changes, seed correctness. |
| Deploy / config |
zarf/** (.yaml, .tpl), *.conf |
Helm/k8s manifests: resource limits, secrets handling, probes, value templating. |
| Scripts |
*.sh |
Shell safety: set -euo pipefail, quoting, exit-code handling. |
Repo-local authority
All lenses treat AGENTS.md (and any nested AGENTS.md) as authoritative.
Apply these repo skills only to .go files, where relevant:
use-modern-go — Go implementation style.
layered-architecture-types — App ↔ Business ↔ Storage: primitives at the
edges, strong types in Business, named converters only.
business-layer-extensions — the ExtBusiness / Extension decorator seam.
branching-logic-flow — defaulting and shallow control flow.
validate-pr-title applies whenever the PR title is in scope, regardless of
language.
Diff intake
- Resolve scope from the caller.
- With no explicit scope, inspect unstaged changes:
git status --short
git diff --name-only
git diff
- For a branch/PR:
git diff --name-only <base>...HEAD, or gh pr diff.
- Build a short change inventory: which languages/areas changed (see Languages
in this repo); production vs test files; App/Business/Storage files; comments
or doc strings; error/failure handling; new or modified types, interfaces,
converters, component contracts, proto messages, or SQL schema; PR title if a
PR is in scope.
Lens routing
Route by what changed unless the caller asks for "full", "all", or "PR-ready".
- Always (any production code changed, any language): Service Steward.
- Production code or tests changed, or coverage asked: Harness Map.
- Diff touches any failure path — Go
err/errors.Is/As/wrapping/defer/
recover/context, JS try/catch/promises/await/fetch, SQL transactions,
Rego allow/deny logic, or shell exit codes; plus logging and fallback/default
behavior: Error Tripwire.
- Any contract or shape changed — Go structs/interfaces/constructors/
converters/Business strong types/DB rows/stores, Vue
props/emits, proto
messages, or SQL schema: Boundary Keeper.
- Comments, doc strings (Go doc, JSDoc), examples, README snippets, or
TODO/FIXME changed: Doc Drift Check.
- Polish pass: Straight-Line Pass — run in a second wave after G4/G3 findings are
resolved, or in the first wave only when simplification is explicitly requested.
Execution
Run lenses as Task subagents. Because they are read-only, parallel is safe and
preferred for a broad PR sweep; prefer sequential when scope is ambiguous, the
diff is very large, or only one concern was requested.
Default is a two-wave plan:
- Wave 1 (risk): Service Steward, Harness Map, plus Error Tripwire, Boundary
Keeper, and Doc Drift Check where applicable.
- Wave 2 (polish, optional): Straight-Line Pass, after high-risk findings are
addressed or when requested.
Launch each lens with a prompt of this shape:
Use `.agents/skills/review-pr/reference/<lens>.md` as your review instructions.
Scope: <exact scope>
Diff source: <unstaged git diff | PR diff | branch range | file list>
Languages in scope: <e.g. Go; Vue/JS; Rego; proto; SQL; Helm/YAML; shell>
Repo context: polyglot monorepo (Go primary). Follow AGENTS.md; apply Go skills to .go files only.
Mode: advisory/read-only — do not modify files.
Return a Gate report only, using the G0-G4 scale.
Aggregation
Merge lens reports into one Diffguard report. Deduplicate overlapping findings by
failure mode and location; on disagreement keep the higher Gate.
# Service Diffguard Report
Scope: <scope reviewed>
Overall Gate: G[0-4] — <Clear/Polish/Tighten/Repair/Stop>
## Run matrix
| Lens | Result | Notes |
|--------------------|---------------|-------|
| Service Steward | Gx | ... |
| Error Tripwire | Gx / skipped | ... |
| Doc Drift Check | Gx / skipped | ... |
| Harness Map | Gx / skipped | ... |
| Boundary Keeper | Gx / skipped | ... |
| Straight-Line Pass | Gx / deferred | ... |
## Fix queue
### G4 Stop
- [lens] <title> — `file.go:line`
- Proof:
- Patch direction:
- Verify:
### G3 Repair
### G2 Tighten
### G1 Polish
## Clear signals
- <What looks solid and why.>
## Open checks
- <Anything not reviewed, unavailable, or needing human confirmation.>
## Suggested verification
- Go: `make test-only`, or `go test ./path/...` for a single package.
- Frontend: the project's JS test/lint/build scripts in `api/frontends/admin`.
- SQL/Rego/proto: the relevant migration, policy, or codegen check for that area.
- Re-run affected lenses after fixes.
1---2name: review-pr3description: Service Diffguard: read-only PR review lenses for correctness, error visibility, comment truthfulness, test coverage, type/contract boundaries, and simplification across every language in this repo (Go, Vue/JS/SCSS, Rego, protobuf, SQL, Helm/YAML, shell). Use for PR review, pre-commit review, unstaged-diff review, or a targeted review of one of those aspects.4---56# Service Diffguard78Service Diffguard reviews a diff with six focused **lenses**. Each lens runs as9a read-only Amp Task subagent, inspects the requested change, and returns10**findings** graded on one shared scale. Lenses advise only — they never edit,11stage, or commit code, never disable tests, and never bypass a failing check to12make it pass.1314Default scope is the **unstaged `git diff`** unless the caller names specific15files, a branch, a commit range, or an existing PR.1617## Gate scale1819Every finding carries a Gate. The run's overall Gate is the highest any lens20returns.2122| Gate | Name | Meaning | Action |23|--------|---------|------------------------------------------------------------------------------------------|------------------------------------------------------|24| **G4** | Stop | Likely correctness, security, data-integrity, compile, boundary, or reliability failure. | Block merge until fixed. |25| **G3** | Repair | Likely user-visible bug, operational blind spot, real test gap, or misleading contract. | Fix before the PR is ready. |26| **G2** | Tighten | Locally safe but leaves avoidable risk, ambiguity, weak design, or brittleness. | Address if reasonably scoped; otherwise acknowledge. |27| **G1** | Polish | Low-risk clarity, naming, comment, or small test refinement. | Optional; batch, don't spam. |28| **G0** | Clear | No issue, or a positive observation. | None. |2930Every **G2 or higher** finding must include: `file:line`, **Proof** (evidence from31the diff), why it matters, a **Patch direction** (smallest safe fix), and how to32verify. Weak or speculative observations go under **Open checks**, not as a33finding. Cap **G1** items at five per lens unless exhaustive polish is requested.3435## Lens catalog3637| Lens | Focus | Reference prompt |38|------------------------|----------------------------------------|-----------------------------------|39| **Service Steward** | general code correctness & conventions | `reference/service-steward.md` |40| **Error Tripwire** | failure-path visibility | `reference/error-tripwire.md` |41| **Doc Drift Check** | comment truthfulness | `reference/doc-drift-check.md` |42| **Harness Map** | behavior-to-test mapping | `reference/harness-map.md` |43| **Boundary Keeper** | type & contract design across layers | `reference/boundary-keeper.md` |44| **Straight-Line Pass** | behavior-preserving simplification | `reference/straight-line-pass.md` |4546## Languages in this repo4748Diffguard reviews a changed file in whatever language it is written in. Each lens49applies its concept (correctness, failure visibility, comment truth, test50coverage, contract design, simplification) through the idioms of that language —51Go is the primary codebase, not the only one.5253| Area | Where | Lens focus for this language |54|-----------------|------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------|55| Go services | `app/**`, `business/**`, `foundation/**`, `api/**` (`.go`) | Full Go review; the layered type rules and Go skills apply here. |56| Admin frontend | `api/frontends/admin/src` (`.vue`, `.js`, `.scss`) | Vue SFC structure, component `props`/`emits` contracts, reactivity, async/`fetch` error handling, accessibility, leaked watchers/listeners. |57| Auth policies | `app/sdk/auth/rego` (`.rego`) | OPA/Rego rules: default-deny posture, `input` shape assumptions, unintended allows. |58| gRPC contracts | `app/domain/grpcauthapp` (`.proto`) | Field-number stability, backward/forward compatibility, breaking changes. |59| Database | `business/sdk/migrate/sql` (`.sql`) | Migration reversibility/idempotency, indexing, locking, destructive changes, seed correctness. |60| Deploy / config | `zarf/**` (`.yaml`, `.tpl`), `*.conf` | Helm/k8s manifests: resource limits, secrets handling, probes, value templating. |61| Scripts | `*.sh` | Shell safety: `set -euo pipefail`, quoting, exit-code handling. |6263## Repo-local authority6465All lenses treat **AGENTS.md** (and any nested AGENTS.md) as authoritative.6667Apply these repo skills **only to `.go` files**, where relevant:6869- `use-modern-go` — Go implementation style.70- `layered-architecture-types` — App ↔ Business ↔ Storage: primitives at the71 edges, strong types in Business, named converters only.72- `business-layer-extensions` — the `ExtBusiness` / `Extension` decorator seam.73- `branching-logic-flow` — defaulting and shallow control flow.7475`validate-pr-title` applies whenever the PR title is in scope, regardless of76language.7778## Diff intake79801. Resolve scope from the caller.812. With no explicit scope, inspect unstaged changes:82 - `git status --short`83 - `git diff --name-only`84 - `git diff`85 - For a branch/PR: `git diff --name-only <base>...HEAD`, or `gh pr diff`.863. Build a short change inventory: which languages/areas changed (see *Languages87 in this repo*); production vs test files; App/Business/Storage files; comments88 or doc strings; error/failure handling; new or modified types, interfaces,89 converters, component contracts, proto messages, or SQL schema; PR title if a90 PR is in scope.9192## Lens routing9394Route by what changed unless the caller asks for "full", "all", or "PR-ready".9596- **Always** (any production code changed, any language): Service Steward.97- **Production code or tests changed, or coverage asked:** Harness Map.98- **Diff touches any failure path** — Go `err`/`errors.Is/As`/wrapping/`defer`/99 `recover`/context, JS `try/catch`/promises/`await`/`fetch`, SQL transactions,100 Rego allow/deny logic, or shell exit codes; plus logging and fallback/default101 behavior: Error Tripwire.102- **Any contract or shape changed** — Go structs/interfaces/constructors/103 converters/Business strong types/DB rows/stores, Vue `props`/`emits`, proto104 messages, or SQL schema: Boundary Keeper.105- **Comments, doc strings (Go doc, JSDoc), examples, README snippets, or106 TODO/FIXME changed:** Doc Drift Check.107- **Polish pass:** Straight-Line Pass — run in a second wave after G4/G3 findings are108 resolved, or in the first wave only when simplification is explicitly requested.109110## Execution111112Run lenses as Task subagents. Because they are read-only, **parallel is safe** and113preferred for a broad PR sweep; prefer **sequential** when scope is ambiguous, the114diff is very large, or only one concern was requested.115116Default is a two-wave plan:117118- **Wave 1 (risk):** Service Steward, Harness Map, plus Error Tripwire, Boundary119 Keeper, and Doc Drift Check where applicable.120- **Wave 2 (polish, optional):** Straight-Line Pass, after high-risk findings are121 addressed or when requested.122123Launch each lens with a prompt of this shape:124125```text126Use `.agents/skills/review-pr/reference/<lens>.md` as your review instructions.127128Scope: <exact scope>129Diff source: <unstaged git diff | PR diff | branch range | file list>130Languages in scope: <e.g. Go; Vue/JS; Rego; proto; SQL; Helm/YAML; shell>131Repo context: polyglot monorepo (Go primary). Follow AGENTS.md; apply Go skills to .go files only.132Mode: advisory/read-only — do not modify files.133134Return a Gate report only, using the G0-G4 scale.135```136137## Aggregation138139Merge lens reports into one Diffguard report. Deduplicate overlapping findings by140failure mode and location; on disagreement keep the higher Gate.141142```markdown143# Service Diffguard Report144145Scope: <scope reviewed>146Overall Gate: G[0-4] — <Clear/Polish/Tighten/Repair/Stop>147148## Run matrix149| Lens | Result | Notes |150|--------------------|---------------|-------|151| Service Steward | Gx | ... |152| Error Tripwire | Gx / skipped | ... |153| Doc Drift Check | Gx / skipped | ... |154| Harness Map | Gx / skipped | ... |155| Boundary Keeper | Gx / skipped | ... |156| Straight-Line Pass | Gx / deferred | ... |157158## Fix queue159### G4 Stop160- [lens] <title> — `file.go:line`161 - Proof:162 - Patch direction:163 - Verify:164### G3 Repair165### G2 Tighten166### G1 Polish167168## Clear signals169- <What looks solid and why.>170171## Open checks172- <Anything not reviewed, unavailable, or needing human confirmation.>173174## Suggested verification175- Go: `make test-only`, or `go test ./path/...` for a single package.176- Frontend: the project's JS test/lint/build scripts in `api/frontends/admin`.177- SQL/Rego/proto: the relevant migration, policy, or codegen check for that area.178- Re-run affected lenses after fixes.179```