Requirement 064. New skill kvb-code-review: review.py target, plan, run,
brief, record, judge, verdict, stamp, status, question, waive and hook.
It reviews a change against the repository's standards and lenses
(MEDUSA, principles, efficiency, legal, quality), remembers reviewed
blobs and stamps a clean verdict for HEAD^{tree} in kvb-review.json.
The pre-bash hook of hooks.py refuses every push row (--check pushed:
or a --command running git push, gipsn or git-sign-push, also nested
in sh -c) while the tree has neither a clean stamp nor an operator
waiver that operator_message of the installed hub verifies. The hub
port comes only from the hub's .env, never from argv or the stamp.
kvb-git-push gains the review step.
🎯 Fix: 92 %
💥 Break: 3 %
💸 Tokens: 113 %
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 79
🚦 Gate: ⚠️ tokens 113 % > 100: operator approved the commit
Created-with: https://s.veen.world/skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
12 KiB
12 KiB
064 - Code Review
User Story
As the operator, I want one skill that reviews a change against every standard of its repository and every check Quality offers before a push, so that no commit reaches a remote that a deep review would have stopped.
Decisions (operator-confirmed 2026-11-26; do not re-litigate)
- Two skills, one owner each (operator):
kvb-code-reviewin this repository is the wrapper and manager (target, standards, harness skills, skeptics, memory, stamp, hook, waiver);kvb-quality-reviewin the quality repository is the base that runs every quality check, written and built by Quality as the eighth skill of quality 003 (amending its decision 1: security, legal, architecture, score, confidence, break-risk, performance, review), which also holds the call contract (--base,--staged,--range,--all, repeatable--path; exit 0 clean, 1 findings, 2 usage or tool error; findings with lens, rule, severity, path, line, commit, tier and the file's blob hash; a version per lens; the performance lens runs only with--measureand fills the efficiency and speed scores ofkvb-quality-score; break risk and confidence left to this skill). Rejected: the review in Quality (Quality analyses, the review orchestrates and gates pushes);kvb-check-review(the check category empties once quality 003 moves the scanners);kvb-reviewwithout category. - Target first (operator): the skill first asks what to review: the
branch against the default branch (
mainormaster), a commit range, the staged changes, or a pull request; the detected target is the recommended option: staged changes present → staged; an open pull request for the branch → that pull request; commits ahead of the default branch → the branch; else the range the operator names. - Repository standards:
AGENTS.md,CONTRIBUTING.md, every file underdocs/contributing/and theAGENTS.mdof everyroles/<role>/the diff touches; a standards finding cites the rule'sfile:line. - Everything Quality offers (operator): one call to
kvb-quality-reviewonce a quality tag carries it (quality 003), with--dbwhen aquality db updatebundle exists (else its deep tier is listed as skipped) and--measurewhen the change touches runnable code (the performance lens: CPU, RAM and wall clock). Until then (operator: build now, switch later)quality check(--base <ref>or--staged;.qualityignore.ymland folder.nocheckare honoured by Quality itself) and the analysis skills of today:kvb-check-security,kvb-check-legal,kvb-check-principles,kvb-check-break-risk,kvb-check-confidence,kvb-check-score,kvb-check-efficiency(itsmeasure.py, the later performance lens, only with runnable code). A lens that cannot run is listed with its reason, never dropped. - Harness review skills (operator): every read-only review skill the
harness lists runs as a further lens (Claude Code today:
/code-reviewas the correctness lens,/security-review); a harness that lists none gets only the own lenses. Rejected: fix-applying skills (/simplify,--fix), because the review never edits. - Skeptics (operator): one skeptic per lens checks all its findings in one pass; every critical or high finding gets its own extra skeptic before it may block. A refuted finding stays in the table as refuted. Rejected: one skeptic per finding (cost grows per finding); skeptics for blockers only (medium and low unverified).
- Clean (operator): a review is clean when no confirmed finding is critical or high. Rejected: every confirmed finding blocks; only critical blocks.
- Stamp (operator, P1):
review.py stamprecords the verdict forHEAD^{tree}inkvb-review.jsonin the git common dir, only when the review's target is everything the push sends (upstream..HEAD, the default branch without an upstream) and the tracked tree is clean. A new tree voids it; a signing-only rewrite keeps it.kvb-git-pushhands a push row only whengate.py statusis green andreview.py statusis clean or waived for the same tree. - Hook (operator, P3): a pre-bash handler in
kvb-org-organize/scripts/hooks.pyrefusesoperator.py addwith--check pushed:<dir>while<dir>'sHEAD^{tree}has neither a clean stamp nor a waiver. - Waiver (operator): per push, through a hub decision card ("Waive
the review for the push of tree
<hash>in<dir>?");review.py waiverecords the signed answer onceoperator_messagereturnsmatch, and the hook verifies it again through the hub'soperator_message; an unreachable hub refuses. Rejected: the operator pushing by hand; a typed waiver flag (any agent can type it). - Output: one table ranked by severity,
| Severity | Lens | File:line | Finding | Skeptic | Evidence |, then the commit score block ofblock.py(063;kvb-git-commit-no-verifyafter 022 decision 10), its break risk and confidence judged by this skill. - Read-only: the review never edits, stages, commits or pushes. The CI review of pushes and pull requests with inline comments is its own requirement, after this one.
- Memory (operator): what was reviewed is not reviewed again. Results
live in
kvb-review-cache.jsonin the git common dir, keyed by lens, lens version, path, the file's blob hash and the digest of the standards files it was judged against; skeptic verdicts are keyed by the finding (lens, rule, path, blob hash, the flagged line's text). A lens reruns only on files whose key changed; a lens that judges the whole diff reruns only when the diff'sgit patch-idchanged. - Tokens and velocity (operator): lenses run in parallel, scripts as
processes and judging lenses as subagents, heavy runs through
queue.py hold, light runs self-admitted (kvb-org-organizeCapacity); the skeptics of different lenses run in parallel. A subagent gets only its files' hunks and the cited standard sections, never whole documents, on the modelkvb-org-performpicks, and answers in the table's columns.
Approach
flowchart TD
subgraph P["🧭 0 · Preparation"]
P1["📋 Write requirement"] --> P2{"✅ Operator approves?"}
P2 -- "✏️ corrections" --> P1
end
P2 -- "🤖 yes" --> T1
subgraph T["🎯 A · Target"]
T1["🔎 Detect staged, PR, branch, range"] --> T2["🙋 Ask, detected target first"]
T2 --> T3{"🧪 Target tests green?"}
T3 -- "🔴 no: fix" --> T1
end
T3 -- "🟢 yes" --> M1
subgraph M["🧠 B · Memory"]
M1["🗂️ Key per lens, path, blob, standards digest"] --> M2["♻️ Reuse cached results"]
M2 --> M3{"🧪 Cache tests green?"}
M3 -- "🔴 no: fix" --> M1
end
M3 -- "🟢 yes" --> L1
subgraph L["🔍 C · Lenses in parallel"]
L1["📜 Standards"] --> L4{"🧪 Lens tests green?"}
L2["🏭 Quality check and kvb-check-*"] --> L4
L3["🧰 Harness read-only skills"] --> L4
L4 -- "🔴 no: fix" --> L1
end
L4 -- "🟢 yes" --> S1
subgraph S["🧐 D · Skeptics and verdict"]
S1["⚖️ One per lens, one per blocker"] --> S2["🧾 Table and score block"]
S2 --> S3["🏷️ Stamp the tree"]
S3 --> SF{"💬 Operator feedback on a sample run?"}
SF -- "✏️ changes" --> S1
end
SF -- "👍 fits" --> G1
subgraph G["🚧 E · Push gate"]
G1["🚀 kvb-git-push needs gate and review"] --> G2["🪝 Hook refuses unstamped push rows"]
G2 --> G3["🔏 Signed waiver card"]
G3 --> G4{"🧪 Unit, integration, e2e green?"}
G4 -- "🔴 no: fix" --> G1
G4 -- "🟢 yes" --> GF{"💬 Operator feedback?"}
GF -- "✏️ changes" --> G1
end
GF -- "👍 fits" --> D1["🏁 Review, commit with operator OK, hand-over"]
Acceptance Criteria
Target
review.py target --repo <root>printsstagedfor a fixture with staged changes,pr <n>with an open pull request (ghstubbed),branch <default>for commits ahead ofmainormaster, elserange.- The skill's first question lists the four targets with the detected
one first and marked recommended (
SKILL.mdtext and a test on it).
Lenses
- The standards lens reads
AGENTS.md,CONTRIBUTING.md, every file underdocs/contributing/androles/<role>/AGENTS.mdfor each touched role, and names each file it read in the output. quality check --base <ref>runs for a branch, pull request or range target,--stagedfor a staged one; a finding Quality waives in.qualityignore.ymlor.nocheckdoes not appear.- Each of the seven
kvb-check-*lenses runs or appears underskippedwith its reason; none is silently absent. - With
/code-reviewand/security-reviewlisted by the harness both run; with none listed the output saysharness: noneand the own lenses still run.
Memory
- A second review of an unchanged tree starts no lens and no skeptic
and prints every row from
kvb-review-cache.json. - Changing one file reruns the per-file lenses on that file only;
a whole-diff lens reruns because the
git patch-idchanged. - Changing a standards file reruns the standards lens on every file.
- A cached skeptic verdict is reused for the same finding key and never for a changed flagged line.
Tokens and velocity
- The lenses of one review start in parallel; the run's log shows their
start times within one second of each other, heavy ones as
queue.py holdjobs. - A subagent brief holds only its files' hunks and the cited standard
sections; a test asserts no whole
AGENTS.mdorCONTRIBUTING.mdis in a brief. - A re-review of an unchanged tree finishes in under 5 s wall clock.
Verdict and stamp
- A confirmed high finding gives
verdict: blocked; only medium and low confirmed givesverdict: clean. review.py stamprefuses with exit 2 when the tracked tree is dirty or the target is not upstream..HEAD.review.py status --repo <root>printsreview: clean,blocked,waivedormissingforHEAD^{tree}; a new commit givesmissing; a signing-only rewrite keepsclean.
Push gate
kvb-git-pushhands no push row whilereview.py statusis notcleanorwaived(SKILL.mdstep and a test).- The hook refuses
operator.py add ... --check pushed:<dir>with exit 2 and the reasonno clean review for tree <hash>; with a clean stamp it allows; otheroperator.py addrows pass untouched. - A row whose
--commandrunsgit push,gipsnorgit-sign-pushis a push row for its--dirwhatever its check (operator 2026-11-26:--check manualpush rows are reviewed too). - A waiver whose signed answer
operator_messagedoes not match, or an unreachable hub, keeps the row refused.
Tests
- Unit:
- Target detection, cache keys, stamp, status and waiver in
tests/test_code_review.py. - The hook handler in
tests/test_hooks.py.
- Target detection, cache keys, stamp, status and waiver in
- Integration:
operator.py add --check pushed:throughhooks.py pre-bashon a fixture repository: refused without a stamp, allowed with a clean one, allowed with a verified waiver.- A run on a fixture with a planted high finding ends
blocked; the same run again starts no lens.
- E2E:
- Hub e2e: the waiver decision card is signed with the virtual
passkey,
review.py waiverecords it and the hook then allows the row.
- Hub e2e: the waiver decision card is signed with the virtual
passkey,