Skip to content

feat: add risk-to-test traceability ledger - #262

Merged
sumithr merged 5 commits into
mainfrom
feat/issue-144-risk-test-traceability-ledger
May 31, 2026
Merged

sumithr merged 5 commits into
mainfrom
feat/issue-144-risk-test-traceability-ledger

Conversation

@sumithr

@sumithr sumithr commented May 30, 2026 •

Copy link
Copy Markdown
Owner

Closes #144.

Adds a risk-to-test traceability ledger as a structured appendix to sumo-qa's markdown-first verdict (never a replacement):

  • ledger_models.py — Pydantic schema (six required fields, five distinct evidence states planned/passing/failing/stale/accepted_residual, is_uncovered_blocker() gate helper).
  • ledger_format.py — deterministic markdown table + compact summary, max_rows-bounded for the token budget.
  • ledger_validation.py — load/validate envelope with stable kinds.
  • sumo_qa_format_risk_ledger — a read-only MCP tool. No risk inference — the host identifies the risks; the tool only validates and renders them. Tools-list snapshot regenerated.
  • Optional ledger-appendix wiring into the preparing-for-work / reviewing-before-merge / creating-test-plan / finishing-qa-work skills; the review gate requires uncovered_blocker_count == 0 before SAFE. Plus docs/RISK-LEDGER.md and 2 promptfoo evals.

Tests: full suite 1342 passed, 100% coverage. Both new evals PASS.

Review: sumo-qa-reviewing-before-merge → SAFE (all named risks covered with fresh path-matching tests). Codex adversarial review rounds 1–2 found and fixed 6 real defects: markdown-injection via unescaped newlines (closed for the full Unicode line/paragraph/vertical separator class), negative max_rows slicing, truncated-flag accuracy on empty ledgers, and schema_version mis-classification.

A further sumo-qa-reviewing-before-merge pass caught one more real defect: the optional Repo-map node column stripped the trailing table delimiter without re-adding it, rendering a ragged 6-vs-7-cell table on the documented repo-map path (#154). Fixed in ccf9836 with a cell-count regression test (the prior tests asserted only substring presence), hardened in ad13421 to split on unescaped delimiters and exercise the escape path alongside the new column. Also de-specified the surviving hand-written tool-count prose in docs/ARCHITECTURE.md / docs/INSTALL.md to capability altitude (the #256 policy). The Codex P2 thread that first flagged the delimiter bug is resolved.

A superpowers code review of the post-fix diff returned APPROVE, with the regression test empirically proven to fail on the pre-fix code.

sumithrjl added 3 commits May 30, 2026 20:00
Add a lightweight, structured risk-to-test ledger as an appendix to
sumo-qa's markdown-first verdict — never a replacement.

Schema + plumbing (file/format only, no inference):
- ledger_models.py: RiskLedgerRow / RiskLedger with the six required
  fields (stable risk id, statement, source anchor, covering/planned
  test, evidence status, residual decision), five distinct evidence
  states (planned / passing / failing / stale / accepted_residual),
  optional repo-map node-id link (#154), extra=forbid, unique-id guard.
- ledger_format.py: deterministic markdown-table projection + compact
  one-line summary, bounded by max_rows (token-budget discipline).
- ledger_validation.py: load/validate envelope with stable error kinds.
- sumo_qa_format_risk_ledger MCP tool: validates host-supplied rows and
  renders the appendix; read-only; the host identifies the risks.

Skill wiring (optional appendix, prose stays the deliverable):
- reviewing-before-merge: project named risks + coverage map below the
  verdict; uncovered_blocker_count must be 0 before SAFE; markdown table
  shape pinned (columns + worked rows) so the candidate emits a table.
- preparing-for-work: planning-only ledger (all rows planned, no code
  change / no test run).
- creating-test-plan, finishing-qa-work: traceable appendix to the plan
  / run summary.

Docs + coverage:
- docs/RISK-LEDGER.md (contract, vocabulary, when NOT to use it);
  README, TOOLS.md, ARCHITECTURE.md tool-count + index updates.
- promptfoo evals: uncovered-risk review ledger + planning-only ledger.
… inputs

- ledger_format._escape neutralises newlines/carriage returns in cell
  values so a multi-line value can no longer break the table row or
  inject markdown outside the row
- format_ledger_markdown clamps a negative max_rows to 0 before slicing,
  so a negative cap renders zero rows (truncated) instead of a Python
  negative-slice keeping all-but-the-last row
- load_ledger treats any present-but-mismatched schema_version (string
  OR non-string, e.g. int 2) as schema_version_mismatch instead of
  surfacing a confusing vocab/literal error
…ct truncated flag

_escape() collapses the complete line/paragraph/vertical separator set (VT, FF,
FS, GS, RS, NEL, U+2028, U+2029) to a single space before pipe-escaping, so no
separator can split a rendered table row. truncated now uses max(max_rows, 0) so
an empty ledger with a negative cap reports False instead of True.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2d4fa991ed

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/sumo_qa/ledger_format.py Resolved
t added 2 commits May 31, 2026 02:31
… counts

The optional "Repo-map node" column stripped the trailing table delimiter
without re-adding it, so a ledger row carrying repo_map_node_id rendered a
6-column header/rule over 7-column data rows — a malformed table on exactly
the documented repo-map path (#154). Re-add the delimiter to both the header
and the rule, and pin a cell-count regression test; the prior repo-map tests
asserted only substring presence and could not see the ragged table.

Also de-specify the surviving hand-written tool-count prose in
docs/ARCHITECTURE.md and docs/INSTALL.md to capability altitude, per the
#256 policy (docs describe capabilities, not drift-prone inventory counts).
The regression test's cell_count helper split on every '|', so an escaped
'\|' inside a cell value was double-counted — a future maintainer adding a
pipe-bearing value here would hit a confusing false failure. Split on
unescaped delimiters only (re.split with a negative lookbehind) and add a
third row that carries a literal pipe AND a repo-map node id, so the escape
path and the new column delimiter are now exercised together. Verified the
strengthened test still fails on the pre-fix delimiter bug ([6,6,7,7,7]).
@sumithr
sumithr merged commit 031abe7 into main May 31, 2026
30 checks passed
@sumithr
sumithr deleted the feat/issue-144-risk-test-traceability-ledger branch May 31, 2026 15:37
sumithr added a commit that referenced this pull request May 31, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.21.0](v0.20.3...v0.21.0)
(2026-05-31)


### Features

* add risk-to-test traceability ledger
([#262](#262))
([031abe7](031abe7))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: release-please[bot] <release-please[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task]: Add a risk-to-test traceability ledger for QA workflows

2 participants