Skip to content
Merged
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
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

All notable changes to `agent-readback`. Dates are UTC.

## Unreleased

### Fixed

- `readback dashboard` on a phone: every table had a 520px minimum width, so
at 375px the Failed and Unverified counts and the findings Count column were
scrolled out of view. Only the five-column "Latest problems" table keeps a
minimum width now; the others fit, action names wrap after each dot, and
headers and verdict badges no longer break mid-word.
- Dashboard accessibility: each table's scroll area is focusable
(`tabindex="0"`), is a labelled region named by its heading, and has a
visible focus outline, so keyboard users can scroll it in any browser.
Column headers carry `scope="col"` and each table is labelled by its heading.

## 0.3.1 — 2026-11-22

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ python -m pip install -e ".[security]" && python -m bandit -r agent_readback exa
- All HTTP goes through an injected `httpx.Client`; tests swap in `httpx.MockTransport`. Keep new verifiers and providers injectable the same way.
- New verifier: implement `snapshot`/`check` per `core.Verifier`, name actions `<system>.<resource>.<verb>`, export from `verifiers/__init__.py`, update the README verifier table.
- The verifier must use credentials the agent doesn't hold; a shared write path makes the check meaningless.
- The README's "What is tested and what is not" and "Security model" tables are kept honest. Update them (and the test count, currently 199, of which 1 skips on Windows without symlink privileges) when coverage or guarantees change.
- The README's "What is tested and what is not" and "Security model" tables are kept honest. Update them (and the test count, currently 200, of which 1 skips on Windows without symlink privileges) when coverage or guarantees change.
- Security changes need a test that demonstrates the attack failing (see `test_keyed_log_detects_a_chain_forged_without_the_key`), not just the happy path.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ external security or compliance review has been done.

## What is tested and what is not

Version 0.3.1. The suite has 199 offline tests; with the optional test dependencies
installed, 198 pass on Windows and the symlink test is skipped there without symlink privileges; elsewhere it runs too. A separate public HAPI FHIR R4 sandbox run verified 10 scripted
Version 0.3.1. The suite has 200 offline tests; with the optional test dependencies
installed, 199 pass on Windows and the symlink test is skipped there without symlink privileges; elsewhere it runs too. A separate public HAPI FHIR R4 sandbox run verified 10 scripted
operations (6 bookings, 1 reschedule, 3 cancellations); this is a
compatibility smoke test, not production validation. A Stripe test-mode run
produced the expected verdict for all four refund scenarios, using a separate
Expand Down
34 changes: 26 additions & 8 deletions agent_readback/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
.sub{color:var(--mut);margin:0 0 22px}.tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px}
.tile{background:var(--card);border:1px solid var(--line);border-radius:10px;padding:14px 16px}.tile b{display:block;font-size:28px;line-height:1.1;font-variant-numeric:tabular-nums}
.tile span{color:var(--mut);font-size:13px}.ok b{color:var(--ok)}.bad b{color:var(--bad)}.warn b{color:var(--warn)}
.wrap{overflow-x:auto;border:1px solid var(--line);border-radius:10px;background:var(--card)}table{border-collapse:collapse;width:100%;min-width:520px}
th,td{text-align:left;padding:9px 14px;border-bottom:1px solid var(--line);font-variant-numeric:tabular-nums;vertical-align:top}th{font-size:12px;color:var(--mut);font-weight:600}
tr:last-child td{border-bottom:0}code{font:13px ui-monospace,Menlo,Consolas,monospace}.pill{display:inline-block;border-radius:99px;padding:1px 9px;font-size:12px;border:1px solid currentColor}
.wrap{overflow-x:auto;border:1px solid var(--line);border-radius:10px;background:var(--card)}.wrap:focus-visible{outline:2px solid var(--fg);outline-offset:2px}
table{border-collapse:collapse;width:100%}table.wide{min-width:560px}
th,td{text-align:left;padding:9px 14px;border-bottom:1px solid var(--line);font-variant-numeric:tabular-nums;vertical-align:top;overflow-wrap:anywhere}th{font-size:12px;color:var(--mut);font-weight:600;white-space:nowrap;overflow-wrap:normal}
tr:last-child td{border-bottom:0}code{font:13px ui-monospace,Menlo,Consolas,monospace}
@media (max-width:480px){th,td{padding:8px 8px}}.pill{display:inline-block;border-radius:99px;padding:1px 9px;font-size:12px;border:1px solid currentColor;white-space:nowrap;overflow-wrap:normal}
.chain{margin-top:22px;font-size:13px;color:var(--mut)}
"""

Expand All @@ -26,6 +28,22 @@ def _tile(css: str, value: str, label: str) -> str:
return f'<div class="tile {css}"><b>{escape(value)}</b><span>{escape(label)}</span></div>'


def _breakable(action: str) -> str:
"""Escape an action name and let it wrap after each dot, not mid-word, on narrow screens."""
return escape(action).replace(".", ".<wbr>")


def _table(key: str, heading: str, columns: tuple[str, ...], rows: str, wide: bool = False) -> str:
# The scroll box is focusable and named by its heading, so keyboard users can scroll it in any browser.
# Only the wide table keeps a minimum width; the narrow ones fit a phone screen without scrolling.
head = "".join(f'<th scope="col">{escape(c)}</th>' for c in columns)
return (
f'<h2 id="h-{key}">{escape(heading)}</h2>'
f'<div class="wrap" role="region" aria-labelledby="h-{key}" tabindex="0">'
f'<table{" class=wide" if wide else ""} aria-labelledby="h-{key}"><tr>{head}</tr>{rows}</table></div>'
)


def render_html(
records: list[dict[str, Any]], chain_intact: bool, title: str = "Readback report", unkeyed: bool = False,
) -> str:
Expand All @@ -39,7 +57,7 @@ def render_html(
]
)
action_rows = "".join(
f"<tr><td><code>{escape(action)}</code></td><td>{counts.get('verified', 0)}</td>"
f"<tr><td><code>{_breakable(action)}</code></td><td>{counts.get('verified', 0)}</td>"
f"<td>{counts.get('failed', 0)}</td><td>{counts.get('unverified', 0)}</td></tr>"
for action, counts in summary["by_action"].items()
)
Expand All @@ -51,7 +69,7 @@ def render_html(
problem_rows = "".join(
"<tr><td>{when}</td><td><code>{action}</code></td><td><span class='pill' style='color:var(--{tone})'>{status}</span></td><td>{why}</td><td>{ctx}</td></tr>".format(
when=escape(body["checked_at"][:19].replace("T", " ")),
action=escape(body["claim"]["action"]),
action=_breakable(body["claim"]["action"]),
tone="bad" if body["status"] == "failed" else "warn",
status=escape(body["status"]),
why=escape(", ".join(f["kind"].replace("_", " ") + (f" ({f['field']})" if f.get("field") else "") for f in body["findings"])),
Expand All @@ -67,9 +85,9 @@ def render_html(
<title>{escape(title)}</title><style>{STYLE}</style></head><body><main>
<h1>{escape(title)}</h1><p class="sub">What the agent claimed, checked against the system of record.</p>
<div class="tiles">{tiles}</div>
<h2>By action</h2><div class="wrap"><table><tr><th>Action</th><th>Verified</th><th>Failed</th><th>Unverified</th></tr>{action_rows}</table></div>
<h2>Why claims failed</h2><div class="wrap"><table><tr><th>Finding</th><th>Count</th></tr>{finding_rows}</table></div>
<h2>Latest problems</h2><div class="wrap"><table><tr><th>Checked (UTC)</th><th>Action</th><th>Verdict</th><th>Findings</th><th>Context</th></tr>{problem_rows}</table></div>
{_table("actions", "By action", ("Action", "Verified", "Failed", "Unverified"), action_rows)}
{_table("findings", "Why claims failed", ("Finding", "Count"), finding_rows)}
{_table("problems", "Latest problems", ("Checked (UTC)", "Action", "Verdict", "Findings", "Context"), problem_rows, wide=True)}
<p class="chain">Evidence chain: {escape(chain)}. {len(records)} records.</p>
</main></body></html>
"""
27 changes: 27 additions & 0 deletions tests/test_evidence_and_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,33 @@ def test_dashboard_page_is_redacted_and_escapes_hostile_context(tmp_path):
assert "<script>" not in html and "&lt;script&gt;" in html


def test_dashboard_tables_are_keyboard_reachable_and_labelled():
# Each scroll box must be focusable and named, every header a column header, and only the wide table
# may force sideways scrolling (a min-width on all tables hid the Failed and Count columns on phones).
from html.parser import HTMLParser
from agent_readback.dashboard import STYLE, render_html

class Collect(HTMLParser):
def __init__(self):
super().__init__()
self.tags = []

def handle_starttag(self, tag, attrs):
self.tags.append((tag, dict(attrs)))

parser = Collect()
parser.feed(render_html([], True))
ids = {a["id"] for t, a in parser.tags if "id" in a}
wraps = [a for t, a in parser.tags if t == "div" and a.get("class") == "wrap"]
assert len(wraps) == 3
for wrap in wraps:
assert wrap.get("tabindex") == "0" and wrap.get("role") == "region" and wrap.get("aria-labelledby") in ids
headers = [a for t, a in parser.tags if t == "th"]
assert headers and all(a.get("scope") == "col" for a in headers)
assert [a.get("class") for t, a in parser.tags if t == "table"] == [None, None, "wide"]
assert "min-width" not in STYLE.split("table{", 1)[1].split("}", 1)[0] # no width floor on every table


def test_dashboard_of_a_tampered_log_says_broken_and_exits_1(tmp_path):
path, out = tmp_path / "log.jsonl", tmp_path / "page.html"
log = EvidenceLog(path)
Expand Down
Loading