Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions BACKLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ CC-001/CC-002 were consumed by PR #24 fix bundle inline, with no standalone entr
| CC-697 | 🔵 active | **[`gate` 的 scope manifest 超預算時仍掃完所有來源(issue #781)]** 127 個變更路徑的 full-tier gate 在原生 Windows 建 manifest 花 495 秒才以 INCOMPLETE 結束。省略計數只增不減,只要來源、符號、搜尋匹配或契約消費者任一項已超預算,結果就是 INCOMPLETE,其後的掃描只是白花時間。修法:不接受截斷時,在來源之間一發現超預算就停止並註明省略數是下限;接受截斷時照舊掃完。 | ops/gate | 2026-11-05 | feedback:2026-11-05 pr:#788 | P2 | hygiene | |
| CC-698 | 🔵 active | **[`pmctl artifacts list` 每筆 run 啟動多個外部程序,原生 Windows 約 0.18 秒/筆(issue #749)]** 60 筆約 11.8 秒、200 筆約 36 秒。改成批次 stat 取 mtime、用 bash 內建 `printf %()T` 轉時間,輸出逐字節不變;60 筆約 1.3 秒、200 筆約 2.1 秒。 | ops/portability | 2026-11-06 | feedback:2026-11-06 pr:#789 | P2 | hygiene | |
| CC-699 | 🔵 active | **[claude 審查員的 guard check 受工作目錄與命令後綴影響而被拒,gate 沒有判定]** brief 的 guard 命令改為 cd 不受影響的絕對路徑,adapter 同步放行同一字串;加 `; echo` 後綴仍被拒,維持由 brief 要求。 | ops/gate | 2026-11-06 | feedback:2026-11-06 | P2 | hygiene | |
| CC-700 | 🟢 someday | **[gate 的 reviewer 發現沒有回流成確定性檢查,也不知道哪個 reviewer 值得派]** `gate stats` 已有每個 reviewer 的參與次數與「有發現的比例」;下一步是讓重複出現的發現能被歸類並提案成 lint/型別/測試,以及用比例資料檢討 tier 預設的 reviewer 名單。 | ops/gate | 2026-11-19 | — | P3 | design |

---

Expand Down Expand Up @@ -2662,3 +2663,21 @@ symlink 或改名的 adapter 仍被拒絕。
**未做**:放寬 `echo` 或其他後綴;讓 guard check 不由模型組字串(例如由 supervisor 代跑);審查員用 `cd … && git diff`/`git -C` 讀 diff 被視為不受信任的設定而被拒,目前只能少讀內容。

**See**: 2026-11-06 gate 執行紀錄、CC-697。

---

## CC-700 — gate 的 reviewer 發現沒有回流成確定性檢查 🟢 someday

**Problem**:同一類問題被 reviewer 在不同 gate 重複指出(例如 DECISIONS 記錄的 `.gate-overrides.md` 四輪 `block-soft`、多次 CRLF/Windows 路徑類發現),但每次都是新的 reviewer session 重新推導,沒有機制把「已經被抓過 N 次」的發現變成 lint 規則、型別或 regression test。另一方面,tier 的預設 reviewer 名單(`core/policy/gate-tiers.tsv`)沒有任何資料說明每位 reviewer 在該 tier 的實際產出。

**已有的基礎**:`pmctl gate stats` 的 `by_reviewer.<r>.participation`(`runs`、`finding_evidence_runs`、`runs_with_findings`),分母是讀得到發現的 gate,讀不到的不算「沒發現」。

**Evidence boundary**:尚未對真實 state store 跑過新欄位,比例數字未知;n 太小時(例如某 reviewer 只有 3 次 evidence run)任何結論都不可靠。

**Requirement**:(a) 先跑 `pmctl gate stats --json` 看各 reviewer、各 tier 的 `runs_with_findings / finding_evidence_runs`,並加上依 tier 分組;(b) 在 `gate_reviewer_result_v1` 的 finding 加一個可選的 `rule_candidate`(或 `category`)欄位,讓 reviewer 標記「這可以變成確定性檢查」,additive、不 bump schema_version;(c) `gate stats` 依該欄位聚合重複出現的類別,輸出「被指出 ≥ K 次、尚無對應檢查」的清單,作為開 lint 票的輸入,不自動產生規則;(d) 只有在 (a) 有足夠樣本時,才討論調整 tier 預設名單,且 hard-gate reviewer(security、risk、qa-tester)不因低比例被移除——它們的價值在於少數高嚴重度發現。

**Done-when**:有一份真實資料的比例報告;`rule_candidate` 能被 reviewer 填寫並在 stats 聚合;至少一個重複類別被轉成確定性檢查並記錄來源。

**See**: [[CC-685]](gate 耗時)、`docs/review-model.md`、`docs/CONCEPTS.md`(把反覆出現的「不該那樣做」寫成 hook)。

---
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Versions follow [Semantic Versioning](https://semver.org/).

### Changed

- **`pmctl gate stats` shows how often each reviewer finds something (CC-700, first step).** Each `by_reviewer.<name>` now carries `participation`: `runs` (complete gates that list the reviewer), `finding_evidence_runs` (of those, gates whose findings could be read and include this reviewer) and `runs_with_findings` (of those, gates where it reported at least one finding). The text report prints `runs=N with-findings=a/b`. The denominator is the evidence count, not `runs`, so a gate whose findings degraded to `unavailable` (no `reviewer_result_v1` block, or a malformed one) is counted as unknown rather than as a silent review. The field is additive; the existing `verdicts` and `findings` keys are unchanged. This is data for deciding which reviewers a tier should start, not a policy change: no reviewer is skipped because of it. Recording which findings recur and could become lint rules is the rest of CC-700.
- **Native Windows is measured in CI.** A `windows-native-suites` job runs the suites that complete in native Git Bash on a `windows-latest` runner (`test-pmctl-memory`, `test-pmctl-pm`, `test-pmctl-ship-finish` and others), beside the existing smoke job. The three suites that failed only natively now pass there too; their fixtures use the spelling the product records.

- **Windows usage documented, and the native test suite made honest (Windows report items 1 to 6, 10).** `docs/platform-support.md` gains the standard way to drive WSL2 from a Windows session (`ops/diagnostics/wsl-run.sh`: script files and pmctl arguments reach WSL without re-quoting, with `--pmctl-command` and the command's own exit status), where to edit, which permission rules to allow, what a native gate run needs (measured: about 17 minutes, five gates on one branch), and the native test status in four groups. `docs/review-model.md` states why a targeted pass is judged against the whole current subject. Test fixes: cases that need symlinks, POSIX mode bits, special file names or a PATH of links now skip with a reason instead of failing; two tests no longer use `grep -Fi`, which aborts in the GNU grep 3.0 of some Git for Windows installs; path assertions accept the `C:/` spelling the product records; the relocated-host fixture copies `jq-lf.sh` as a real checkout has it.
Expand Down
29 changes: 26 additions & 3 deletions runtime/lib/pmctl-gate-stats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -315,15 +315,37 @@ pmctl_gate_stats_aggregate_program() {
by_mode: (
reduce ($ok[] | select(.mode != null)) as $r ({};
.[$r.mode] = ((.[$r.mode] // 0) + 1))),
# participation answers "does this reviewer earn its seat?":
# runs complete gates that list the reviewer
# finding_evidence_runs of those, gates whose findings were readable
# AND carry a block for this reviewer
# runs_with_findings of those, gates where it reported >= 1
# The yield denominator is finding_evidence_runs, never runs: a gate
# whose findings degraded to "unavailable" is unknown, not silent.
by_reviewer: (
reduce $ok[] as $r ({};
reduce ($r.reviewers | to_entries[]) as $rv (.;
.[$rv.key].verdicts[$rv.value] = ((.[$rv.key].verdicts[$rv.value] // 0) + 1))
.[$rv.key].verdicts[$rv.value] = ((.[$rv.key].verdicts[$rv.value] // 0) + 1)
| .[$rv.key].participation.runs = ((.[$rv.key].participation.runs // 0) + 1))
| if ($r.findings_by_severity | type) == "array"
then reduce $r.findings_by_severity[] as $f (.;
reduce ($f.counts // {} | to_entries[]) as $c (.;
.[$f.reviewer].findings[$c.key] = ((.[$f.reviewer].findings[$c.key] // 0) + $c.value)))
else . end)),
# One evidence run per reviewer per gate, even if a gate
# somehow carries two blocks for the same reviewer.
| reduce ($r.findings_by_severity
| group_by(.reviewer)[]
| {reviewer: .[0].reviewer,
n: (map((.counts // {}) | [.[]] | add // 0) | add)}) as $p (.;
.[$p.reviewer].participation.finding_evidence_runs =
((.[$p.reviewer].participation.finding_evidence_runs // 0) + 1)
| if $p.n > 0
then .[$p.reviewer].participation.runs_with_findings =
((.[$p.reviewer].participation.runs_with_findings // 0) + 1)
else . end)
else . end)
| map_values(.participation =
({runs: 0, finding_evidence_runs: 0, runs_with_findings: 0} + (.participation // {})))),
protocol_failures: (
reduce ($rows[] | select(.protocol != null and (.protocol | length) > 0)) as $r
({accepted: 0, "retryable-failure": 0, other: 0, reasons: {}};
Expand Down Expand Up @@ -374,7 +396,8 @@ pmctl_gate_stats_render_text() {
([.by_reviewer | to_entries[]
| ((.value.verdicts // {}) | to_entries | map("\(.key):\(.value)") | join(",")) as $v
| ((.value.findings // {}) | to_entries | map("\(.key):\(.value)") | join(",")) as $f
| " \(.key) verdicts=\($v) findings=\(if $f == "" then "-" else $f end)"]
| (.value.participation // {}) as $p
| " \(.key) runs=\($p.runs // 0) with-findings=\($p.runs_with_findings // 0)/\($p.finding_evidence_runs // 0) verdicts=\($v) findings=\(if $f == "" then "-" else $f end)"]
| join("\n")),
"",
# Text mode caps the protocol-reason list to the five most common; --json
Expand Down
37 changes: 37 additions & 0 deletions tests/shell/test-pmctl-gate-stats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,42 @@ case_malformed_reviewer_block_forces_unavailable() {
fi
}

# Behavior: by_reviewer.<r>.participation counts the gates a reviewer sat in,
# the gates whose findings were readable for it, and the gates where it found
# at least one thing. A gate with no readable findings (no blocks, or a
# malformed block) adds to runs only -- it is unknown, never "silent".
# Steps: four complete gates for critic+qa-tester -- one with findings, one
# with empty findings, one with no blocks, one with a malformed block; assert
# 4 runs, 2 evidence runs, 1 run with findings, in --json and in text.
case_by_reviewer_participation_yield() {
local name="pmctl gate stats: by_reviewer participation separates silent runs from unreadable ones"
should_run "$name" || return 0
local store proj out err tout terr status=0
store="$tmp_root/part-store"
proj="$(gs_project_dir "$store")"
gs_make_gate_run "$proj" gate-20260811-000100-p1 NO-GO full sequential "critic=advise,qa-tester=block" \
2026-08-11T00:00:00Z 2026-08-11T00:10:00Z p1 \
'[{"id":"x-F001","severity":"high"},{"id":"x-F002","severity":"low"}]'
gs_make_gate_run "$proj" gate-20260811-000200-p2 GO full sequential "critic=approve,qa-tester=pass" \
2026-08-11T01:00:00Z 2026-08-11T01:05:00Z p2 '[]'
gs_make_gate_run "$proj" gate-20260811-000300-p3 GO full sequential "critic=approve,qa-tester=pass" \
2026-08-11T02:00:00Z 2026-08-11T02:05:00Z p3
gs_make_gate_run "$proj" gate-20260811-000400-p4 GO full sequential "critic=approve,qa-tester=pass" \
2026-08-11T03:00:00Z 2026-08-11T03:05:00Z p4 '[{"id":"x-F001","severity":"high"}]' "" 1
out="$tmp_root/part.out"; err="$tmp_root/part.err"
tout="$tmp_root/part.tout"; terr="$tmp_root/part.terr"
gs_run "$store" "$out" "$err" --json || status=$?
gs_run "$store" "$tout" "$terr" || status=$?
if [[ "$status" -eq 0 ]] \
&& [[ "$(jq -c '.by_reviewer.critic.participation' "$out")" == '{"runs":4,"finding_evidence_runs":2,"runs_with_findings":1}' ]] \
&& [[ "$(jq -c '.by_reviewer."qa-tester".participation' "$out")" == '{"runs":4,"finding_evidence_runs":2,"runs_with_findings":1}' ]] \
&& grep -q 'critic runs=4 with-findings=1/2 ' "$tout"; then
pass "$name"
else
fail "$name" "status=$status by_reviewer=$(jq -c '.by_reviewer' "$out") text=$(<"$tout") err=$(<"$err")"
fi
}

case_protocol_failures_tally() {
local name="pmctl gate stats: protocol_failures tallies outcomes and retryable reasons"
should_run "$name" || return 0
Expand Down Expand Up @@ -737,6 +773,7 @@ case_round_clusters_heuristic
case_wall_time_from_assurance_and_mtime
case_by_reviewer_merges_verdicts_and_findings
case_malformed_reviewer_block_forces_unavailable
case_by_reviewer_participation_yield
case_protocol_failures_tally
case_since_filters_by_run_id_date_for_frozen
case_since_time_aware_for_live_rows
Expand Down
Loading