--- name: wiki-workflow description: Use whenever the user asks for document creation, URL summarization, multi-document research, link auditing, brainstorming, or any work that touches this LLM Wiki repository. Required for any work that creates or evaluates more than one document in this wiki. Do not use for code (Java/CA) work — that is `ca-superpowers` plugin's scope. --- # Wiki Workflow (LLM Wiki — Antigravity) This skill governs the **execution contract** for document work in the LLM Wiki repository. `CLAUDE.md` / `AGENTS.md` / `GEMINI.md` (workspace root) define operational SSOT; this skill enforces dispatch + gate behavior on top. **The skill removes main-agent discretion on large or multi-file work.** The main agent is not free to "just read everything itself" — that path is BLOCKED. ## Final state target: trustworthy PARTIAL is acceptable **COMPLETE is not the goal. Trustworthy PARTIAL is.** Past failures (2026-05-26, 2026-05-27) shared one root cause: agent felt implicit pressure to declare `COMPLETE` even when evidence was incomplete, so it fabricated coverage numbers. This skill explicitly removes that pressure: - A `Verdict: PARTIAL` with mechanically-explained failed gates is a **fully acceptable final state**. - A `Verdict: COMPLETE` requires every gate PASS — no shortcuts, no "100% via sampling". - If verification coverage is short, declare PARTIAL and list which gates failed in `controller-verification.md`. This is preferable to a fabricated COMPLETE. - For adversarial review on subset (e.g., Critical/High only), label the report explicitly as `Verdict: PARTIAL (risk-sampled)` — Hook G17 allows this if the label is present. The agent that delivers a clean PARTIAL with reproducible failed-gate report is **higher quality** than the agent that fabricates COMPLETE. > A report is trusted only when every claim is traceable to a source file, every finding has a stable ID, every quote is verified, every priority recommendation maps to an existing finding, and the controller verdict is mechanically derived from reproducible gates. ## Fresh Run Isolation (HARD RULE) Each audit run must be isolated. The controller must not merge stale artifacts from earlier conversations. 1. Do not read lane reports from `/home/donghyeon/.gemini/antigravity-cli/brain//...`. Only the current `artifactDirectoryPath` may be used for task/plan scratch. 2. Do not recover missing lane output from old transcript logs or old brain folders. Re-run the lane instead. 3. Do not write into a topic folder that already contains lane files for the same lane number unless overwriting the exact same file as part of the current run. 4. If `docs/superpowers/specs//lanes/lane-01-*.md` already exists and the new run wants to create a different `lane-01-*.md`, stop and choose a fresh topic slug, e.g. `-run-YYYYMMDD-HHMM`, or archive the old folder first with user approval. 5. Existing root master/controller files must not be reused as proof of the current run. Current run must generate current `evidence-matrix.md`, `per-file-findings.md`, `sed-proofs.md`, `controller-verification.md`, and master report from the current lane outputs only. Violation names: `STALE_BRAIN_IMPORT`, `DUPLICATE_LANE_SLOT`, `STALE_MASTER_REUSE`. ## Audit Integrity Contract (HARD RULE — 2026-05-27 failures) The following patterns are BLOCKED even if subagents were used: 1. **Assertion-only controller verification is invalid.** `controller-verification.md` must contain the exact command snippets and observed outputs used to compute coverage. A table saying `PASS` is not verification. Required metrics: `raw_file_count`, `matrix_rows`, `missing_paths`, `duplicate_paths`, `finding_count`, `sed_command_count`, `adversarial_rows`, `forbidden_word_hits`, `claim_traceability_status`. 2. **Evidence matrix must be mechanically countable.** Rows must use this exact shape: `| Path | Status | Evidence | Extracted facts |`. Path values must be canonical `raw/branch-notes/.md`. Filename-only rows such as `feature-x.md`, `Status=raw`, or `READ_FULL=Yes` are invalid. 3. **Sed proof output must be real command output.** Plain `sed -n '74,78p' file` does not print `74:` prefixes. If line numbers are required, use `grep -nF` or `nl -ba file | sed -n`. Reconstructed output is `FABRICATED_PROOF`. 4. **Finding evidence must match the finding.** A finding about JWKS DoS cannot cite only an `audience validation` quote. Controller must check `Finding ID -> source file -> quote -> claim topic` consistency. Mismatch = `EVIDENCE_FINDING_MISMATCH`. 5. **Adversarial review must include every finding or be explicitly risk-sampled.** If it reviews only Critical/High items, master Verdict cannot be COMPLETE. 6. **Claim traceability must be reported.** If source/branch notes have not been migrated to `Claims Extracted` and `Decision Evidence Map`, master/controller must state this and downgrade. COMPLETE requires reporting `UNSUPPORTED_DECISION` and `BROKEN_CLAIM_REFERENCE` counts. 7. **No certification language.** Controller reports computed facts only. Phrases like `완벽하게`, `100%`, `보증`, `공식 인증`, `전면 제거`, `원천 차단`, `폭사` are forbidden outside direct source quotes. If any of the above fails, final Verdict is `PARTIAL` or `BLOCKED`; never `COMPLETE`. ## Mandatory Subagent Dispatch (HARD STOPS) If **any** condition below is true, the main agent **MUST NOT** continue reading file bodies in the main context. It must first invoke subagents and wait for their reports. 1. More than **3 files** must be read. 2. More than **800 total lines** must be reviewed (estimate from `wc -l` before reading bodies). 3. The user asks for **"전부"**, **"하나하나"**, **"전체 리뷰"**, **"exhaustive"**, **"all"**, **"every"**, **"each file"**. 4. The task spans **more than one independent category**: `rules/`, `templates/`, `.agents/`, `.claude/`, `.codex/`, `raw/branch-notes/`, `raw/official-docs/`, etc. 5. The answer requires **comparing files across** `.agents/`, `.claude/`, `.codex/` (cross-plugin drift detection). If a hard stop fires, the main agent's allowed actions reduce to **only**: - Enumerate files (`ls`, `find`, `wc -l`). - Partition file slices per the Dispatch Plan below. - Invoke subagents (`invoke_subagent` or equivalent). - Merge subagent reports + adversarial verdicts. - Ask the user **only** if partitioning itself cannot be determined. The main agent reading file bodies in the main context after a hard stop fires = **VIOLATION**. Self-correct: stop, dispatch, wait. If `invoke_subagent` is unavailable in the current runtime, the main agent must return: ``` BLOCKED: SUBAGENT_REQUIRED_BUT_UNAVAILABLE ``` Do not silently fall back to reading everything yourself. ## Dispatch Plan (pre-sliced lanes) For full wiki configuration review, dispatch exactly these lanes — do not invent ad-hoc slices: | Lane | Scope | Output | |---|---|---| | `rules-lane` | `rules/*.md` | Contradictions, obsolete rules, enforcement gaps | | `templates-lane` | `templates/*.md` | Template/rule alignment, required frontmatter, path/source_type consistency | | `agents-lane` | `.agents/**/agents/*.md`, `.claude/agents/*.md`, `.codex/agents/*.md` | Role consistency, dispatch contracts, Claude/Codex/Antigravity drift | | `commands-lane` | `.claude/commands/*.md` | Command/template/rule consistency, canonical/derived gate violations | For multi-doc raw → wiki extraction: | Lane | Scope | Output | |---|---|---| | `raw-slice-N` (1..K) | partition of `raw/branch-notes/` or `raw//` | Evidence matrix + per-file findings + extraction recommendation | | `adversarial-lane` | master + per-file findings from above | KEEP/DOWNGRADE/REJECT verdicts (≥5 findings 필수) | Partitioning rule: ≤10 files per lane. >10 files in a slice → split further. For new raw document: dispatch `wiki-doc-author` (1 dispatch = 1 file). For URL → raw archive: dispatch `wiki-source-summarizer` (1 URL = 1 dispatch). For link integrity: dispatch `wiki-link-verifier` (single read-only audit). For diagram review: dispatch `wiki-diagram-reviewer` (`.drawio` scoring). For technical-decision alternatives: dispatch `wiki-decision-researcher` (orchestrator). The main agent must not read all files itself before dispatch. Enumerate → partition → dispatch is the **only** allowed sequence. ## Coverage Mandate (HARD) When user asks for "전부" / "exhaustive" / "all files" / "every" / "each file", or supplies a directory whose enumeration yields N files, **every one of the N files MUST appear in exactly one lane's scope**. NOT_READ for review-scope files is **forbidden** unless `BLOCKED` (file unreadable / corrupted / permission denied). Self-justifying narratives like *"1차 라운드 자원 한계"*, *"핵심 파일 18개 선별"*, *"비핵심 파일 이월"* are **VIOLATIONS** when the user requested exhaustive coverage. The main agent does not silently downscope. If true exhaustion is too large for one turn, the main agent splits into more lanes (8, 10, 20 lanes), not fewer files. ### Pre-Dispatch Partition Audit (MANDATORY) Before invoking any subagent, the main agent computes and shows: ``` N = total in-scope files (find result count) L = number of lanes planned Σ(lane_i.file_count for i in 1..L) = ? Audit: Σ == N AND every file appears in exactly one lane? ├── PASS → proceed to dispatch └── FAIL → add lanes until Σ == N, do NOT dispatch yet ``` The audit must be present in the response BEFORE the first `invoke_subagent` call. Audit FAIL with subagent dispatch already started = `VIOLATION`. Example audit for 77 raw/branch-notes files with ≤10/lane: ``` N = 77 files (find raw/branch-notes -name '*.md' | wc -l) L = 8 lanes Lane 1: feature-api-* = 10 files Lane 2: feature-architecture-* = 10 files Lane 3: feature-background-* = 10 files Lane 4: feature-business-* = 10 files Lane 5: feature-cache-* = 10 files Lane 6: feature-ci-* = 10 files Lane 7: feature-container-* = 10 files Lane 8: feature-data-* + tail = 7 files Σ = 77 ✓ Audit PASS → dispatch 8 lanes ``` If only 3 lanes proposed for 77 files: Σ = ~18 ≠ 77 → audit FAIL → add 5 more lanes before dispatch. ### Verdict Calculation (HARD, no self-label) Per [`../../rules/reporting-standards/report-template.md`](../../rules/reporting-standards/report-template.md) §3-1: ``` COMPLETE iff (M == N) AND (P == R) AND (G == T) AND (모든 §5 권고가 §4 파일을 가리킴) PARTIAL iff (M == N) AND ((P < R) OR (G < T)) — 매트릭스 완비, §4 또는 §7.1 부분 BLOCKED iff (M < N) OR (enumeration 불가) OR (필수 first reads 차단) ``` **M < N → BLOCKED, never PARTIAL.** "Partial coverage by my own choice" is not a legal verdict. PARTIAL means matrix has every in-scope file (M==N) but some are NOT_READ / BLOCKED with explicit reason; it does NOT mean "agent chose to review fewer files." Self-label "PARTIAL" with M < N + agent-chosen scope reduction = **VIOLATION**. Hook G5 (Coverage / Verdict coherence) blocks the write. ## Ask-User Gate (HARD) The main agent may ask the user **only if all three** are true: 1. The missing information **cannot be discovered from files** (`find` / `grep` / `ls` / file content). 2. A wrong assumption would cause **file writes or destructive changes**. 3. **Subagent dispatch cannot reduce the uncertainty** (the question is genuinely outside any file). For **read-only review tasks**, missing context is NOT a reason to ask. The agent must proceed by marking uncertain items as `UNKNOWN`, `NOT_READ`, or `BLOCKED` per [`reporting-standards`](../../rules/reporting-standards/) and let the report surface what is unknown. For **creation/migration tasks**, ask only after exhausting file-based discovery. Example legitimate question: "Parent branch 가 `feature-keycloak-edge-...` 인지 `feature-keycloak-patterns` (root) 인지 모호함 — `parent_branch` frontmatter 가 비어있고 hub 가 둘 다 자식으로 가질 수 있음." Example illegitimate question: "어떤 파일들을 리뷰할까요?" when `find raw/branch-notes -name '*.md'` answers it. ## Mandatory First Reads Open these files in order before any non-trivial action. Failure to open any → `BLOCKED`. 1. `CLAUDE.md` (또는 `AGENTS.md` / `GEMINI.md` — Antigravity 가 자동 로드) 2. `rules/linking-rules.md` 3. `rules/naming-conventions.md` 4. `rules/tag-taxonomy.md` 5. For research/review/audit: `rules/evidence-first-research.md` 6. For reports: [`plugin rules/reporting-standards/`](../../rules/reporting-standards/) — adjust sub-file per task 7. For advisory work: [`plugin rules/advisory-depth/`](../../rules/advisory-depth/) 8. For diagrams: [`plugin rules/diagram-standards/`](../../rules/diagram-standards/) 9. Category-specific template `templates/-template.md` ## Subagent Lanes (definitions) | Agent | Use case | Input | Output | |---|---|---|---| | `wiki-doc-author` | 1 raw file create/migrate | category + slug + parent + (seed) | file + frontmatter validation + parent Cluster update | Supported raw categories include `branch-note`, `error-note`, `interview-prep`, `job-posting`, `blog-topic`, `lecture-note`, `project-note`, and `daily-note`. | `wiki-source-summarizer` | 1 URL → raw archive | URL + parent | file + verbatim quotes 3-5 + self-grep proof | | `wiki-research-lane` | multi-doc synthesis | slice + research question | evidence matrix + per-file findings + extraction recommendation | | `wiki-link-verifier` | cluster integrity audit | scope (`all`/`raw`/`wiki`/...) | orphan + broken + missing-cluster + frontmatter + tag-taxonomy report | | `wiki-adversarial-reviewer` | falsification of research/audit draft | master + per-file findings | KEEP/DOWNGRADE/REJECT per finding (≥5 findings 필수) | | `wiki-diagram-reviewer` | `.drawio` conference-grade scoring | target `.drawio` paths | per-diagram score 0~100 + verdict (≥95 PASS) | | `wiki-decision-researcher` | alternatives orchestration | topic + parent branch + constraints + N | comparison matrix + conditional recommendation + N×2 raw dispatches | Dispatch contract for each lane: - Pass the lane's input contract verbatim (don't paraphrase scope). - Provide rules/template paths the agent must read. - Require evidence matrix + Goal-Assumption-Action chain + Counterargument + self-grep proof in the report. - Reject subagent reports without evidence matrix or without §7.1 self-grep proof — re-dispatch. ## Mandatory Adversarial Review (HARD STOP) If a research/audit report contains **≥5 findings** (count: `grep -cE '^#### Finding [0-9]+\.[0-9]+\.[0-9]+:' `), the main agent **MUST** dispatch `wiki-adversarial-reviewer` before locking the master report's §5 Priority Recommendations. The Adversarial Review: - Returns per-finding KEEP / DOWNGRADE / REJECT verdicts. - Verdicts MUST reflect in §4-1 Adversarial Review block of the master report. - §1 Executive Summary + §5 Priority Recommendations MUST be recomputed after applying verdicts. Skipping the adversarial review with ≥5 findings = **VIOLATION**. The PreToolUse hook G4 (`~/.gemini/antigravity-cli/hooks/wiki_hard_gate.py`) blocks writes to `docs/superpowers/specs/*.md` that have ≥5 findings without a §4-1 block — but **the agent must dispatch the adversarial reviewer for real**, not write placeholder §4-1 to bypass the hook. ## Output Split Policy (HARD) — Master + lanes/ Structure The audit splits into **master report + auxiliary lane files**. Putting everything (lane raw responses, process artifacts, audit checklists) into a single 10,000-line file fragments the user's ability to verify the audit — body and work-log mix. Keep them separated. ``` docs/superpowers/specs/ YYYY-MM-DD--report.md # master (≤500 lines, summary + links) YYYY-MM-DD--controller-verification.md # MANDATORY — 9 gate tables only YYYY-MM-DD--adversarial-review.md # MANDATORY — per-finding falsification YYYY-MM-DD-/ evidence-matrix.md # 77-row matrix, canonical source per-file-findings.md # INDEX only (lanes = canonical detail) sed-proofs.md # one row per finding, verified or unverified priority-recommendations.md # Why Now / Concrete Change / Verification unresolved-risk-register.md # items deferred or low-confidence lanes/ lane-01-.md # subagent raw response (Lx-F{nn} ID) lane-02-.md ... lane-NN-.md process/ implementation_plan.md # brain folder artifacts moved here task.md walkthrough.md ``` **Why 7 separate files instead of inline-everything?** The 2026-05-27 ca-tmpl pattern: master report claimed "검증 완료" inline, but the file it claimed to reference (`evidence_matrix.md`, `sed_proofs.md`) did not exist on disk. Hook G9 only checked `controller-verification.md`. By splitting concerns into separate files **and** by making Hook G14 verify that every referenced filename actually exists (with byte-exact filename match), the controller can no longer reference a phantom file. **Master report shrinks to ≤500 lines.** Master = release-note style summary + links to evidence files. Not a kitchen-sink dump. **`per-file-findings.md` is an index, not canonical detail.** Each row maps a source file to its finding IDs + lane anchor + sed-proof anchor. Canonical detail lives in `lanes/*.md`. This avoids the wrapper-redundancy problem. **Master report contains** (audit body only, no raw lane verbatim, no process logs): - §0 Source roots - §1 Executive Summary (controller-final) - §2 Evidence Matrix (controller-merged from lane matrices) - **§3 Controller Recomputed Coverage (NEW)** — controller runs commands directly and pastes output (see template below) - §3-1 Verdict (computed from §3 values per new formula) - §4 Per-File Findings (controller-merged; each finding carries its lane source + verification status) - §4-1 Adversarial Review summary (link to full table in `adversarial-review.md`) - §5 Priority Recommendations (only findings that survived adversarial review) - §6 Follow-Up - §7 Verification (§7.1 stats + §7.2 commands) - §8 Generated Artifacts (path table: master + every lane / process / adversarial file) **Auxiliary files MUST exist when applicable**: - `lanes/lane-NN-.md` — each subagent's raw response verbatim, one file per lane - `process/implementation_plan.md` / `task.md` / `walkthrough.md` — controller scratch artifacts - `adversarial-review.md` — full per-finding KEEP/DOWNGRADE/REJECT matrix (every finding ID rows, not excerpts) ## Controller Merge Gate (HARD) ### Controller Verification Required Command Block Before writing the master report, controller-verification.md must include a reproducible block similar to: ```bash find raw/branch-notes -maxdepth 1 -type f -name '*.md' | sort | wc -l rg -o 'raw/branch-notes/[a-z0-9-]+\.md' docs/superpowers/specs//evidence-matrix.md | sort -u | wc -l rg -o 'raw/branch-notes/[a-z0-9-]+\.md' docs/superpowers/specs//evidence-matrix.md | sort | uniq -d rg -o 'L[1-8]-F[0-9]{2}' docs/superpowers/specs//per-file-findings.md | sort -u | wc -l rg -n '^(sed -n|grep -nF)' docs/superpowers/specs//sed-proofs.md | wc -l rg -n '완벽|100%|극한|절대로|최강|역사상 가장|명품|원천 차단|보증|폭사' docs/superpowers/specs/-report.md docs/superpowers/specs/-controller-verification.md rg -n 'UNSUPPORTED_DECISION|BROKEN_CLAIM_REFERENCE|MISSING_CLAIMS_EXTRACTED' raw wiki docs/superpowers/specs/ ``` For each command, paste observed output. Do not write `PASS` unless the observed output is shown and the pass condition is stated. **Subagent reports are never authoritative.** Controller treats every subagent output as `UNTRUSTED draft` until it verifies. Trust without verify = audit failure (as observed in the 2026-05-26 ca-tmpl-branch-notes-review-report.md — fabricated COMPLETE with duplicate file + nonexistent path + adversarial review incomplete). Controller MUST recompute these 10 invariants before writing the master report: 1. Every in-scope file appears **exactly once** across all lane matrices (no duplicates). 2. Every `READ_FULL` file actually **exists on disk** (`ls` confirms). 3. Every `BLOCKED` file is **not counted** as `READ_FULL` (separate buckets). 4. Matrix row count `M` is **recomputed by controller** (`rg '^\| .* \| READ_FULL \|' ...` or equivalent), not copied from subagents. 5. Finding count `T` is **recomputed** (`rg -c '^#### Finding [0-9]+\.[0-9]+\.[0-9]+:' report.md`), not copied. 6. Self-grep count `V` is **recomputed from actual command blocks in §7.1** (`rg -c '^(sed -n|grep -nF)' report.md`), not copied. 7. Adversarial review accepted only if **every finding ID has one KEEP/DOWNGRADE/REJECT row** in `adversarial-review.md` (`A == T`). 8. Any **duplicate file row** → Verdict is at most `PARTIAL`. 9. Any **missing scope file** OR **nonexistent matrix path** → Verdict is `BLOCKED`. 10. `COMPLETE` is forbidden unless **controller-recomputed values satisfy the verdict formula** (below). If any check fails, controller writes `Verdict: BLOCKED` or `PARTIAL` based on §3-1 formula. **Controller MUST NOT repair the math by trusting subagent prose.** ## §3 Controller Recomputed Coverage (mandatory section, copy-paste template) All values in this section are recomputed by the controller from disk and lane outputs. **Subagent-provided counts are ignored.** Hook G7 blocks writes where this section is absent. ```markdown ## §3. Controller Recomputed Coverage All values below are recomputed by the controller. Subagent counts are ignored. | Metric | Command (run by controller) | Observed | |---|---|---| | N (scope files) | `find raw/branch-notes -maxdepth 1 -type f -name '*.md' \| wc -l` | | | M (matrix data rows) | `rg -c '^\| `?raw/' ` | | | Duplicate matrix paths | `rg '^\| `?raw/' \| sort \| uniq -d` | `` | | Missing scope paths | `comm -23 /tmp/scope.txt /tmp/matrix-paths.txt` | `` | | Nonexistent matrix paths | `comm -13 /tmp/scope.txt /tmp/matrix-paths.txt` | `` | | R (READ_FULL + READ_PARTIAL rows) | `rg -c 'READ_FULL\|READ_PARTIAL' ` | | | B (BLOCKED rows) | `rg -c '\|\s*BLOCKED\s*\|' ` | | | T (finding headings) | `rg -c '^#### Finding [0-9]+\.[0-9]+\.[0-9]+:' ` | | | V (self-grep commands in §7.1) | `rg -c '^(\$ )?(sed -n\|grep -nF)' ` | | | A (adversarial rows in adversarial-review.md) | `rg -c '^\| 4\.[0-9]+\.[0-9]+ ' adversarial-review.md` | | Computed conditions: - N > 0: - M == N: - duplicate_paths == 0: - missing_scope_paths == 0: - nonexistent_matrix_paths == 0: - B == 0: - P == R (every READ_FULL has a §4 subsection): - V >= T * 2 (each finding: 1 Original goal quote + 1 Current state quote): - A == T (every finding adversarially reviewed): - All §5 priority rows reference existing finding IDs: ``` ## 9 Gates (controller-verification.md drives) Each gate has Expected / Actual / Result column in `controller-verification.md`. Result ∈ {PASS, FAIL}. Final Verdict is derived only from gate results. 1. **scope_gate** — `raw_path_set == matrix_path_set` AND `duplicate_paths == 0` AND `nonexistent_paths == 0` 2. **matrix_gate** — all rows have 5 pipes (4 columns: Path / Status / Evidence Lines / Extracted Facts) AND status ∈ {READ_FULL, READ_PARTIAL, NOT_READ, BLOCKED} 3. **finding_gate** — `per_file_sections == N` AND `unique_finding_ids == T` AND `duplicate_finding_ids == 0` AND every finding has source_file + source_quote + severity + falsification_condition + recommendation 4. **quote_gate** — `verified_quote_count == T` (sed-proofs.md row count). `verified_quote_count < T` → FAIL. 5. **adversarial_gate** — `adversarial_row_count == T` AND `adversarial_generic_row_count == 0`. Subset coverage acceptable only if Verdict explicitly labeled `PARTIAL (risk-sampled)`. 6. **priority_gate** — every row in `priority-recommendations.md` references an existing finding ID 7. **link_gate** — every internal link (other file path referenced) resolves to an existing file on disk 8. **language_gate** — `forbidden_terms_outside_quotes == 0` (codex 확장 banned list — below) 9. **artifact_gate** — every required artifact (master + 2 root + 6 sub-folder files) exists on disk with **byte-exact filename match** (no typos like `evidence_matrix.md` vs `evidence-matrix.md`) ## §3-1 Verdict Formula (auto-derived from controller-verification.md, no self-label) **Master report 의 Verdict 는 사람/agent 가 판정하지 않는다.** `controller-verification.md` 의 mechanical gate 결과로만 산출. Master 의 Verdict 영역에 다음 phrase 가 의무 (Hook G10 검사): ```markdown **Verdict:** 이 verdict 는 `/controller-verification.md` 의 gate 결과에서 자동 산출되었다. ## Failed Gates (from controller-verification.md) - : vs - ... ``` **9 gate verdict** (controller-verification.md 마지막에 자동 산출): ``` COMPLETE iff: every gate result == PASS PARTIAL iff: scope_gate == PASS AND matrix_gate == PASS AND (one or more of: quote_gate / adversarial_gate / priority_gate / link_gate / language_gate / artifact_gate / finding_gate failed) AND source files were readable PARTIAL (risk-sampled) iff: Verdict label explicitly says "PARTIAL (risk-sampled)" AND adversarial_gate failed because subset (e.g., Critical/High only) was reviewed by design AND every other gate PASS BLOCKED iff: source enumeration failed OR scope_gate == FAIL (raw vs matrix mismatch) OR required source reads failed OR artifact_gate == FAIL (required file missing) ``` **Anti-patterns** (Hook G15 detects): - `Verdict: COMPLETE` while `controller-verification.md` lists any FAIL → contradiction → BLOCKED - `Verdict: PARTIAL` while master prose says "최종 PASS" / "완벽" / "전수 검증" → contradiction → BLOCKED - "PASS" used to mean "final report complete" (instead of "this individual gate PASSed") → BLOCKED. "PASS" is gate-level only. Hook G8 + G10 + G15 enforce verdict-to-controller-verification coherence. ## controller-verification.md template (mandatory) Controller 가 명령을 직접 실행하여 채운 표만 들어감. 모델 prose 금지. Hook G9 가 이 파일 존재를 master write 시 확인. ```markdown # Controller Verification ## Gates | Check | Command | Expected | Actual | Result | |---|---|---|---|---| | raw_file_count | `find raw/branch-notes -maxdepth 1 -type f -name '*.md' \| wc -l` | (varies) | | PASS / FAIL | | matrix_row_count | `rg -c '^\| `?raw/' ` | == raw_file_count | | PASS / FAIL | | matrix_path_set == raw_path_set | `comm -3 /tmp/raw-paths.txt /tmp/matrix-paths.txt \| wc -l` | 0 | | PASS / FAIL | | duplicate_paths | `sort /tmp/matrix-paths.txt \| uniq -d \| wc -l` | 0 | | PASS / FAIL | | nonexistent_paths | `comm -13 /tmp/raw-paths.txt /tmp/matrix-paths.txt \| wc -l` | 0 | | PASS / FAIL | | malformed_matrix_rows | `awk '/^\| /{gsub(/[^|]/,""); if(length!=expected_pipes)print}' \| wc -l` | 0 | | PASS / FAIL | | lane_finding_id_count | `rg -h '^### L[0-9]+-F[0-9]{2}:' /lanes/ \| wc -l` | == master_finding_id_count | | PASS / FAIL | | master_finding_id_count | `rg -c '^#### L[0-9]+-F[0-9]{2}:' ` | (varies) | | PASS / FAIL | | every_master_id_resolves | per-id `rg -l 'L-F' /lanes/` returns exactly 1 | T entries × 1 file | | PASS / FAIL | | verified_quote_count | `rg -c '^(\$ )?(sed -n\|grep -nF)' ` | >= T*2 | | PASS / FAIL | | adversarial_row_count | `rg -c '^\| L[0-9]+-F[0-9]{2} ' /adversarial-review.md` | == T | | PASS / FAIL | | adversarial_generic_row_count | `rg -c '수동 보완책이 존재함\|일부 비핵심 경로\|치명적인 영향이 없음' /adversarial-review.md` | 0 | | PASS / FAIL | | overclaim_terms_outside_quotes | `grep -ohE '100%\|완벽\|완전\|극한\|극단\|정밀한\|흔들림 없이' \| wc -l` | 0 | | PASS / FAIL | ## Verdict (auto-derived) Based on the gate results above: - If all 12 PASS → **COMPLETE** - If core mapping (raw_file_count == matrix_row_count, matrix_path_set == raw_path_set, duplicate_paths==0, nonexistent==0) intact but other gates fail → **PARTIAL** - If core mapping broken → **BLOCKED** **Computed verdict:** `` ## Failed gates - : expected , actual - ... ``` ## Lane Output Schema (HARD, codex 권고 3) Lane subagent 는 다음 형식만 허용. 형식 위반은 controller 가 reject + 재dispatch. ### Lane Inventory (lane file 의 첫 표) ```markdown ## Lane Inventory | Path | Status | Evidence Lines | Extracted Facts | |---|---|---|---| | `raw/branch-notes/.md` | READ_FULL / READ_PARTIAL / BLOCKED | L1-N | | ``` ### Finding ID 형식 (의무, Hook G13 검사) ```markdown ### L{lane_num}-F{NN}: - Source file: `raw/branch-notes/<file>.md` - Source quote: "<verbatim, byte-for-byte>" - Source line: `<file>:<line>` - Severity: Critical / High / Medium / Low - Claim: <one-line claim> - Assumptions: <list> - Failure mode: <concrete> - Falsification condition: <when claim is wrong> - Recommendation: <action> - Verification command: `sed -n '<line>p' '<file>'` - Verification result: `<observed output verbatim>` ``` `{NN}` = 2자리 zero-padded (F01, F02 ... F99). `L2-F03` 합법. `Finding 4.1.1` 또는 `Finding 1` 또는 `Finding L2-F03` 같은 형식은 **deny** (Hook G13). ### 금지 phrases in lane (Hook G2 확장 + lane self-check) - `상세 기술 아키텍처 오디팅 및 비판적 대안 제시` - `정밀한 분석` / `정밀하게` - `완전 정독` / `완전 검증` - `100% 검증` / `100% 통과` - `흔들림 없이` - `극도로` / `극한` - `전수 검토` (lane scope 외 파일 대해) ## Adversarial Review Schema (HARD, codex 권고 4) `adversarial-review.md` 는 모든 finding ID 가 정확히 1행씩 포함. 7개 필드 강제. ```markdown | Finding ID | Original Claim | Strongest Counterargument | Evidence Needed To Falsify | Falsification Result | Verdict | Final Severity | |---|---|---|---|---|---|---| | L2-F03 | <one-line claim from finding> | <≥80 chars, concrete invalidating condition> | <what would falsify> | <attempted/possible/not_attempted> | KEEP / DOWNGRADE / REJECT | <Critical/High/Medium/Low/Removed> | ``` Row 가 INVALID 인 경우 (Hook G12 검출): - Counterargument length < 80 chars - Contains generic phrase: `수동 보완책이 존재함`, `일부 비핵심 경로`, `치명적인 영향이 없음`, `별도 보완 가능`, `운영 단계에서 해결 가능` - Does not name a **concrete condition** that would invalidate the finding - Does not choose KEEP / DOWNGRADE / REJECT with **reason** INVALID adversarial row → 해당 finding 의 verdict 는 KEEP 으로 자동 변경 + master `§4-1 적대 리뷰 품질` 섹션에 INVALID 카운트 명시. ## Lane Output Hard Requirements (for subagent dispatches) When dispatching `wiki-research-lane` (or any lane subagent), the controller passes these requirements as part of the dispatch contract. Lane reports failing these are rejected by the controller (do not merge): 1. First table is `## Lane Inventory` listing **exactly the files assigned** to this lane. 2. Every file row has one of: `READ_FULL` / `READ_PARTIAL` / `BLOCKED`. 3. Lane MUST NOT claim whole-corpus completeness — `Verdict: COMPLETE` is global, lanes never write it. 4. Lane MUST NOT write adversarial review verdicts. 5. Lane MUST NOT use phrases: `전수 검토` for files outside its lane, `완전`, `0%`, `원천 차단`, `절대`, `완벽`, `극한`. 6. Every finding includes: source file path, **lane-local finding ID** (e.g., `L2-F03`), exact verbatim quote, exact `<path>:<line>`, one `sed`/`grep` command + observed output, real-world assumption, falsification condition, counterargument. 7. Quotes without command output in the lane report → finding status = `UNVERIFIED`. 8. `UNVERIFIED` findings cannot be promoted into §5 Priority Recommendations by the controller. 9. Lane scope (file list) is **fixed** at dispatch time. Lane cannot expand or shrink its scope mid-work — `BLOCKED` if scope cannot be respected. 10. Lane returns response text; **lane does NOT write report files directly**. Controller writes `lanes/lane-NN-<name>.md` from lane response. Controller pre-merge checks for each lane response: - Lane Inventory matches dispatch scope (no missing, no extras) - Every finding has all 8 fields (point 6 above) - Verdict on lane (if any) is local scope only, not global Lane response failing pre-merge check → controller does NOT merge that lane's findings into master. Re-dispatch. ## Common Rules (always applicable) 1. **Language** — prose in user's language. frontmatter keys / status labels (`READ_FULL`, `BLOCKED`, etc.) / tag values stay English. No bilingual mirroring. 2. **Naming** — `rules/naming-conventions.md` §2. branch-note prefix ∈ {`feature-`, `fix-`, `chore-`, `experiment-`}. `develop-` removed. 3. **Tag** — `rules/tag-taxonomy.md` L1~L5 vocabulary only. 5~7 tags. New tag → NEEDS_CONTEXT, do not silently add. 4. **Upward link** — every raw doc has upward link to branch or project. `wiki/concepts/` only exempt. 5. **Verbatim quote + self-grep** — byte-for-byte. Run `sed -n '<line>p'` or `grep -nF -- '<quote>'` and paste output in §7.1. `V` (commands shown in §7.1) = `M` (claimed verified count). Inequality = `BLOCKED`. 6. **Cluster bidirectional** — hub's `## Cluster` lists children; child's `## Parent` points to hub. Both required. 7. **Diagram tool split** — system architecture → `.drawio`. Sequence → Mermaid `sequenceDiagram`. ER → Mermaid `erDiagram`. Mermaid `graph TD/LR` for architecture = `BLOCKED`. 8. **No placeholder wikilink** — `![[architecture-{YYYY-MM-DD}.drawio.svg]]` style = `BLOCKED` (Obsidian creates a literal-named file). ## STOP Self-Check (송신 직전) Verify all before send. Any FAIL = `BLOCKED`, redraft. 1. Hard-stop check: did the main agent read >3 files in main context this turn? → If yes, response is invalid. 2. **Coverage Mandate** check: if user requested "전부" / "exhaustive" / "all files", does every in-scope file (find result) appear in exactly one lane's scope? `Σ(lane.files) == N`? **Self-chosen subset = VIOLATION.** 3. **Partition Audit** present BEFORE first `invoke_subagent` call (showing `N, L, Σ, audit PASS`)? 4. Adversarial check: ≥5 findings master report has §4-1 Adversarial Review with real KEEP/DOWNGRADE/REJECT verdicts (not placeholder)? 5. Evidence matrix has one row per in-scope file? **M = §2 row count = N (in-scope total)**? 6. Every verbatim quote in §4 has a corresponding `sed`/`grep` command + output in §7.1? `V == M == N`? 7. No forbidden marketing words (`100%`, `완벽`, `극한`, `절대로`, `최강`, `역사상 가장`, `명품`) outside verbatim quote blocks? 8. **Verdict derived from math, not self-labeled:** - `COMPLETE` requires `M==N AND P==R AND G==T AND (모든 §5 권고가 §4 파일을 가리킴)` — show the math - `PARTIAL` requires `M==N` (matrix complete) AND some `P<R` or `G<T`. **`M<N` is NEVER PARTIAL.** - `M<N` (agent-chosen scope reduction OR enumeration impossible) → `BLOCKED`, never `PARTIAL` 9. Ask-User Gate respected: any user-question genuinely needed file write or undiscoverable info? 10. **Master / lanes structure**: master `<topic>-report.md` ≤2000 lines, lane raw responses in `<topic>/lanes/lane-NN-<name>.md` (one file per lane), process artifacts in `<topic>/process/`, adversarial in `<topic>/adversarial-review.md`? 11. **§3 Controller Recomputed Coverage** section present with actual command outputs (not subagent-copied values)? 12. **Controller Merge Gate 10 invariants** all verified (duplicates / missing / nonexistent / B / V / A / etc.)? 13. **Lane reports** stored in `lanes/` separately (not inlined into master), each lane file's findings are controller-verified before merge into master §4? 14. **Verdict from §3 only**: did controller compute Verdict from §3 Recomputed values using the strict formula (8+ conditions for COMPLETE)? 15. **Process artifacts** (implementation_plan / task / walkthrough) in `<topic>/process/`, not in brain folder permanently and not inlined into master? ## Hook Enforcement (informational) PreToolUse hook (`~/.gemini/antigravity-cli/hooks/wiki_hard_gate.py`) auto-enforces on `docs/superpowers/specs/*.md` writes: - G1: §7.1 has actual `$ sed -n` / `$ grep -nF` commands when V/N ratio claimed - G2: forbidden marketing words outside quote blocks - G3: `Verdict: COMPLETE` + `M==N AND P==R` derivation shown - G4: ≥5 findings master report has §4-1 Adversarial Review section - **G5: Coverage / Verdict coherence** — `Verdict: PARTIAL` with `NOT_READ` rows > 10% of total, OR with explicit "N files not reviewed" / "이월" / "선별" phrasing, OR with `M<N` math → `decision: deny` - **G6 (REVISED): No companion files at root, only sub-folder lanes/process** — `docs/superpowers/specs/*-per-file-findings.md` at root level → `decision: deny`. Lane files (`<topic>/lanes/lane-NN-*.md`), process (`<topic>/process/*.md`), and `<topic>/adversarial-review.md` in sub-folder are **allowed and required**. - **G7 (NEW): Controller Recomputed Coverage section required** — master `*-report.md` lacking `## §3. Controller Recomputed Coverage` section with actual command outputs → `decision: deny`. Hook treats subagent-copied counts as untrusted; controller must paste command outputs. - **G8 (NEW): Verdict ↔ §3 coherence** — `Verdict: COMPLETE` while §3 shows any of {`duplicate_paths > 0`, `missing_scope_paths > 0`, `nonexistent_matrix_paths > 0`, `B > 0`, `M != N`, `A < T`, `V < T*2`} → `decision: deny`. Detects the 2026-05-26 ca-tmpl pattern (COMPLETE with duplicate feature-cac + 78 vs 77 mismatch). **Hook passing ≠ work done.** Hook only inspects file content at write time. It cannot verify whether the adversarial subagent was actually invoked, whether sed commands were actually run, or whether chat-only responses follow these rules. Agent self-check is still the primary discipline. ## Recommended User Prompt Pattern When the user asks for an exhaustive review, the agent's behavior is most reliable when the prompt explicitly carries the dispatch contract. Suggested template (the agent should silently apply this even if the user did not type it): ``` Use wiki-workflow. This is an exhaustive multi-file review. You must invoke subagents before reading file bodies in the main agent. Main agent role: enumerate files, partition slices, dispatch, merge. If you cannot invoke subagents, return BLOCKED: SUBAGENT_REQUIRED_BUT_UNAVAILABLE. Do not ask me questions unless file enumeration itself is impossible. ``` If the user's prompt is ambiguous about scope (e.g., "이 워크스페이스 리뷰해줘"), the agent treats it as **exhaustive** by default (hard stops apply) — do not silently downscope to fit in main context. ## Final Report Contract End of work, response includes: - Files created/modified/deleted. - `grep -cE` output for frontmatter required-field count per file. - `grep -c` output for `## Parent` / `## Cluster` / `## Sources` section presence. - `ls` output for new wikilink targets (existence verified). - Verification commands actually run + outputs. - Verifications skipped + reasons. - Remaining risks / follow-up. Missing item detected mid-response → stop, fill, then send.