- {lines.map((l) => {
- const part = (n: number, key: string) => {
- const p = approverPart(n, l.checks);
- return t(`p3.ap.${key}_${p.share ? "share" : "count"}`, { n: p.value });
- };
- return (
-
- {t("p3.ap.title")}
-
- {t("p3.ap.checks", { count: l.checks })}
- {l.kind ? " · " + t(`p3.ap.kind.${l.kind}`, { defaultValue: l.kind }) : ""}
-
- {part(l.allowed, "allowed")}
- {part(l.asked, "asked")}
- {part(l.blocked, "blocked")}
-
- {t("p3.ap.could_not_run", { n: l.could_not_run })} · {t("p3.ap.overridden", { n: ap.overridden })} ·{" "}
- {t("p3.ap.median", { time: formatDuration(l.median_ms) })}
-
-
- );
- })}
-
- {t("p3.ap.tokens", { tokens: formatTokens(ap.tokens) })}
- {ap.shadow_checks > 0 ? " · " + t("p3.ap.incl_shadow", { count: ap.shadow_checks }) : ""}
-
+
+
{t("p3.ap.title")}
+
+
+
+ | {t("p3.ap.col.reviewer")} |
+ {(["checks", "allowed", "asked", "blocked", "could_not_run", "overridden", "median", "tokens"] as const).map((c) => (
+ {t(`p3.ap.col.${c}`)} |
+ ))}
+
+
+
+ {rows.map((l) => (
+
+ | {t(`p3.ap.name.${l.kind}`, { defaultValue: l.kind })} |
+ {cells(l, l.overridden, l.tokens)}
+
+ ))}
+
+ |
+ {t("p3.ap.total")}
+ {ap.shadow_checks > 0 && {t("p3.ap.incl_shadow", { count: ap.shadow_checks })} }
+ |
+ {cells(ap, ap.overridden, ap.tokens)}
+
+
+
+ {anyShare &&
{t("p3.ap.shares_note")}
}
);
}
diff --git a/surfaces/gui/src/locales/en.json b/surfaces/gui/src/locales/en.json
index 2c6367e0..5978fd88 100644
--- a/surfaces/gui/src/locales/en.json
+++ b/surfaces/gui/src/locales/en.json
@@ -3968,23 +3968,26 @@
},
"ap": {
"title": "Auto-approve",
- "checks_one": "{{count}} check",
- "checks_other": "{{count}} checks",
- "kind": {
- "session_model": "session model",
- "openai_decisions": "decision model",
- "typesafe_jev": "decision model"
+ "col": {
+ "reviewer": "Reviewer",
+ "checks": "Checks",
+ "allowed": "Allowed",
+ "asked": "Asked you",
+ "blocked": "Blocked",
+ "could_not_run": "Could not run",
+ "overridden": "Overridden",
+ "median": "Median time",
+ "tokens": "Tokens"
},
- "allowed_count": "allowed {{n}}",
- "allowed_share": "allowed {{n}}%",
- "asked_count": "asked you {{n}}",
- "asked_share": "asked you {{n}}%",
- "blocked_count": "blocked {{n}}",
- "blocked_share": "blocked {{n}}%",
- "could_not_run": "could not run {{n}}",
- "overridden": "overridden {{n}}",
- "median": "{{time}} median",
- "tokens": "{{tokens}} tokens",
+ "name": {
+ "session_model": "Session model",
+ "openai_decisions": "Decision model · OpenAI Decisions",
+ "typesafe_jev": "Decision model · Jev",
+ "unknown": "Unknown reviewer"
+ },
+ "total": "Total",
+ "share": "{{n}}%",
+ "shares_note": "From 10 checks, a row shows shares of its checks; under 10, counts.",
"incl_shadow_one": "incl. {{count}} shadow check",
"incl_shadow_other": "incl. {{count}} shadow checks"
},
diff --git a/surfaces/gui/src/locales/zh.json b/surfaces/gui/src/locales/zh.json
index fe779169..e8f837c9 100644
--- a/surfaces/gui/src/locales/zh.json
+++ b/surfaces/gui/src/locales/zh.json
@@ -3908,22 +3908,26 @@
},
"ap": {
"title": "自动审批",
- "checks_other": "{{count}} 次检查",
- "kind": {
- "session_model": "会话模型",
- "openai_decisions": "决策模型",
- "typesafe_jev": "决策模型"
+ "col": {
+ "reviewer": "审核者",
+ "checks": "检查",
+ "allowed": "允许",
+ "asked": "询问你",
+ "blocked": "阻止",
+ "could_not_run": "无法运行",
+ "overridden": "被你放行",
+ "median": "中位用时",
+ "tokens": "令牌"
},
- "allowed_count": "允许 {{n}}",
- "allowed_share": "允许 {{n}}%",
- "asked_count": "询问你 {{n}}",
- "asked_share": "询问你 {{n}}%",
- "blocked_count": "阻止 {{n}}",
- "blocked_share": "阻止 {{n}}%",
- "could_not_run": "无法运行 {{n}}",
- "overridden": "被你放行 {{n}}",
- "median": "中位数 {{time}}",
- "tokens": "{{tokens}} 令牌",
+ "name": {
+ "session_model": "会话模型",
+ "openai_decisions": "决策模型 · OpenAI Decisions",
+ "typesafe_jev": "决策模型 · Jev",
+ "unknown": "未知审核者"
+ },
+ "total": "合计",
+ "share": "{{n}}%",
+ "shares_note": "一行有 10 次及以上检查时显示占比,不足 10 次时显示次数。",
"incl_shadow_other": "含 {{count}} 次影子检查"
},
"foot": {
diff --git a/surfaces/gui/src/styles.css b/surfaces/gui/src/styles.css
index d5ceb078..ce359554 100644
--- a/surfaces/gui/src/styles.css
+++ b/surfaces/gui/src/styles.css
@@ -2644,6 +2644,9 @@ html[data-theme="dark"] { --bar-model:#4c8dff; --bar-tool:#3fb8ad; --bar-wait:#3
.p3-chip.ok { background:var(--ok-soft); color:var(--ok); }
.p3-chip.warn { background:var(--warn-soft); color:var(--warn-ink); }
.p3-chip.err { background:var(--danger-soft); color:var(--danger); }
+/* T3-6: the Auto-approve table, one row per reviewer and a Total row */
+.p3-ap td.c-ok { color:var(--ok); } .p3-ap td.c-warn { color:var(--warn-ink); } .p3-ap td.c-err { color:var(--danger); }
+.p3-ap tr.p3-total td { border-top:1px solid var(--line-strong, var(--line)); }
.p3-callout { border-radius:9px; padding:8px 12px; font-size:var(--fs-meta); margin:8px 0; }
.p3-callout.err { background:var(--danger-soft); color:var(--danger); }
.p3-event { display:flex; align-items:center; gap:8px; width:100%; background:none; border:0; padding:3px 0; font-size:var(--fs-meta); color:var(--ink); cursor:pointer; }
diff --git a/tests/test_observability_phase3_manual_fixes.py b/tests/test_observability_phase3_manual_fixes.py
new file mode 100644
index 00000000..479e9a5e
--- /dev/null
+++ b/tests/test_observability_phase3_manual_fixes.py
@@ -0,0 +1,71 @@
+"""Phase 3 manual testing (5 Nov), the server side of rows T3-6 and T3-10: the Auto-approve table
+counts "overridden" per reviewer, and the Ratings card's numbers."""
+
+from __future__ import annotations
+
+import time
+
+from coworker.observability import RecordingStore, usage_api
+
+# Turns an hour old: a store with the background writer sweeps on its first tick.
+RECENT = int(time.time() * 1000) - 3_600_000
+
+
+def _turn(tid, sid, seq, at, reviewer_kind=None):
+ return {"turn_id": tid, "session_id": sid, "seq": seq, "kind": "run", "trigger": "user", "started_at": at,
+ "duration_ms": 1000, "status": "completed", "incomplete": False, "approval_mode": "auto_approve",
+ "attended": True, "reviewer": {"kind": reviewer_kind, "active": True, "shadow": False} if reviewer_kind else None,
+ "stamp": {"machine": {"kind": "this_machine", "id": None}}, "first_message_id": None,
+ "last_message_id": None, "schema_version": 1, "wake": {"reason": "user"}}
+
+
+def _step(tid, sid, n, at, kind, attrs):
+ return {"step_id": f"{tid}-s{n}", "turn_id": tid, "session_id": sid, "parent_step_id": None, "seq": n,
+ "kind": kind, "name": kind, "started_at": at, "duration_ms": 100, "status": "ok", "call_id": None,
+ "call_index": None, "message_id": None, "shadow": False, "after_turn": False, "attrs": attrs,
+ "content": {}}
+
+
+def _check(result, kind):
+ return {"result": result, "reviewer": {"kind": kind}}
+
+
+OVERRIDE = {"decision": {"path": [{"stage": "auto_approver", "outcome": "deny"}, {"stage": "grant", "outcome": "allow_anyway"}]}}
+
+
+def test_overridden_is_counted_per_reviewer(tmp_path):
+ store = RecordingStore(tmp_path / "recordings.db", background=False)
+ turns = [_turn("A", "s1", 1, RECENT, "session_model"), _turn("B", "s2", 1, RECENT + 10, "typesafe_jev"),
+ _turn("C", "s2", 2, RECENT + 20, "typesafe_jev"), _turn("D", "s3", 1, RECENT + 30, "openai_decisions")]
+ steps = [
+ _step("A", "s1", 1, RECENT, "auto_approver", _check("allow", "session_model")),
+ _step("A", "s1", 2, RECENT + 1, "auto_approver", _check("allow", "session_model")),
+ _step("B", "s2", 1, RECENT + 10, "auto_approver", _check("deny", "typesafe_jev")),
+ # the person let Jev's block through, twice
+ _step("C", "s2", 1, RECENT + 20, "tool", OVERRIDE),
+ _step("C", "s2", 2, RECENT + 21, "tool", OVERRIDE),
+ _step("D", "s3", 1, RECENT + 30, "auto_approver", _check("unsure", "openai_decisions")),
+ # the reviewers' own model calls: tokens per reviewer
+ _step("A", "s1", 3, RECENT + 2, "model", {"purpose": "auto_approver", "model": "model-x", "usage": {
+ "reported": True, "input_fresh": 300, "cache_read": 0, "cache_write": 0, "output": 20}}),
+ _step("D", "s3", 2, RECENT + 31, "model", {"purpose": "auto_approver", "model": "model-y", "usage": {
+ "reported": True, "input_fresh": 50, "cache_read": 0, "cache_write": 0, "output": 5}}),
+ _step("A", "s1", 4, RECENT + 3, "model", {"purpose": "main", "model": "model-x", "usage": {
+ "reported": True, "input_fresh": 9000, "cache_read": 0, "cache_write": 0, "output": 100}}),
+ ]
+ for t in turns:
+ store.write_turn(t)
+ for s in steps:
+ store.write_step(s)
+ store.flush()
+ got = usage_api.approver(store, start=RECENT - 1, end=RECENT + 1000)
+ assert got["overridden"] == 2 # the total, as before
+ rows = {r["kind"]: r for r in got["by_reviewer"]}
+ assert set(rows) == {"session_model", "typesafe_jev", "openai_decisions"}
+ assert rows["typesafe_jev"]["overridden"] == 2
+ assert rows["session_model"]["overridden"] == 0 and rows["openai_decisions"]["overridden"] == 0
+ assert rows["session_model"]["checks"] == 2 and rows["openai_decisions"]["asked"] == 1
+ # each reviewer's own tokens; main work is not in them
+ assert rows["session_model"]["tokens"] == 320 and rows["openai_decisions"]["tokens"] == 55
+ assert rows["typesafe_jev"]["tokens"] == 0
+ store.close()