Repository navigation
Coverage ledger: record examined, ruled-out and untested risk classes - #207
Merged
Merged
Conversation
Workers record per (surface, risk_area) outcomes with the new record_coverage
tool (reported, no_issue_found, ruled_out, not_applicable, needs_follow_up).
Gaps are needs_follow_up entries, entries missing their required evidence or
reason, and goal vulnclass values with no entry (unrecorded_risk_class), so an
absent finding never reads as a clean target. Completeness marks timeout,
budget wrap-up, pause, abort and running tasks as incomplete with a caveat.
Surfaced in the planner context (one line per round, full gap list on the
timeout/budget wrap-up round), GET /api/tasks/{id}/coverage, the coverage card
and the Markdown report. Follows coverage_enabled; no new env var.
…es, per-run end_reason) Normalise and length-check ledger fields in db.RecordCoverage, frame the planner gap lines in the data envelope, cap the wrap-up (25) and report (200) gap lists, cap current rows at 2000 per task. Replace the activity budget marker with tasks.end_reason, written with the guarded terminal status and cleared on revive. Generic 500 message in taskCoverage; early return on an empty ledger in the planner block.
wxcvm
referenced
this pull request
in wxcvm/ARTEX
Nov 14, 2026
* feat(coverage): persist task check results and expose coverage gaps Adapt upstream #207 with task archive, report and overview integration; preserve existing coverage switch. * fix(coverage): surface structured planning gaps and localize overview
liuxiaobo0920
added a commit
to liuxiaobo0920/ARTEX_2
that referenced
this pull request
Nov 17, 2026
…port The task report and the findings export asserted every finding with no qualification: nothing said how far exploitation actually reached (PoE level), whether the claim was machine-verified (verification status and note), whether counterevidence was recorded, or whether any traffic was bound. The web UI badges all of it (VERIFICATION_META, the detail page), so the report — the artifact a client actually reads — was the last surface still asserting bare claims. Render it from one place: - report/quality.go (new): two constructors and two pure renderers, no I/O, no DB handle, so the block is unit-tested without a database. - Both surfaces call the same helpers, which is the point: the task report and the per-finding export cannot drift apart the way duplicated formatting does. - Missing is explicit: a finding node with no standalone row prints "not assessed (no finding record)" instead of an invented zero — the honest gap the existing coverage work (BaaRai#207) also insists on. - Labels match the shipped UI wording (Verification, Confidence rationale, Counterevidence) and states are humanised ("Not assessed", "False positive"), with an unrecognised value printed verbatim so a new state cannot silently vanish from a report. - Bound-traffic count appears once per document: as a Proof bullet in the task report (it has no traffic section), and in the export only when nothing is bound — otherwise the traffic section already states it. - The detailed report is capped at 8 KiB in the task report only, rune-safe, with the cap derived into the truncation message; the export is the canonical per-finding document and is never silently shortened. - The export keeps its document structure: the single-finding document gets "## Detailed Report" (a section like its siblings), the multi-finding summary gets a bold label. Read paths only: no change to the write side of poe_level or verification_status, no schema change (all five columns already exist), no API/DTO change (the widened FindingMeta stays internal to the report path, and the findings list keeps selecting only what it renders). One extra task-scoped query on GET /api/report, because findings bodies stay off the list path. docs/vulnerability-traffic-evidence.md §Export describes the new Markdown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A coverage ledger. It records what workers examined, ruled out or left open for each surface and risk class, so that a missing finding never reads as "clean target".
record_coverage(surface, risk_area, outcome, evidence, reason). Outcomes:reported,no_issue_found,ruled_out,not_applicable,needs_follow_up.coverage_ledger(one current row per task, surface and risk_area) andcoverage_ledger_history(every write). New additive columntasks.end_reason.GET /api/tasks/{id}/coverage, in the coverage card and in the Markdown report (GET /api/report).Why
The model comes from Strix
strix/report/coverage.py(skill_coverage_gaps). The invariant is that absence is not clean. A risk class with no ledger entry isunexamined, neverclean. Ano_issue_foundis never derived from the absence of a finding. It must be written by a worker, with evidence.Design
Two layers.
agent_reportedholds the ledger entries.machine_observedholds what execution produced: the existing asset coverage (TaskCoverageWithSourceswithdeclaredScopeFilter, unchanged) andfindings_by_classfromfindings. The ledger adds the risk-class dimension and the negative results. It does not recompute tested assets.Gaps (
db.BuildCoverageLedger, a pure function) come from three sources:needs_follow_up;vulnclasswith no entry at all, reported asunrecorded_risk_classand also listed inunexamined;missing_evidenceforno_issue_found,missing_reasonforruled_outandnot_applicable.Mandatory classes come only from the goals'
vulnclass. There is no asset x class matrix. An intent that records nothing creates no gap (recon has no class obligation).Warn, do not block. The tool accepts an entry with missing evidence or reason, records it, and answers "counted as a gap".
prove_goaland the done status are unchanged.Switch. Everything follows
tasks.coverage_enabled. When it is false,record_coverageis incoverageOnlyTools, so it is dropped from the tool list (the worker now callsDropCoverageToolstoo). The handler also refuses to write, the planner block is empty, and the API keeps its existing{enabled:false}short-circuit. There is no new environment variable.Seeding.
record_coverageis part ofWorkerTools(), soBuiltinToolSeeds()andSeedTool(ON CONFLICT DO NOTHING) insert the new key on existing databases at startup. It is bound toworkerby default. No existing tool's schema or description is changed, so no migration is needed.Planner. At each round the planner gets one line with entry counters by outcome, the gap count and the top 3 gaps. On the task-timeout final round and on the budget wrap-up round (Hierarchical budgets: min(child, parent) with forced wrap-up (off by default) #206), it gets the remaining gaps instead (at most 25, then a count line). The gap lines are agent-reported text, so they sit inside the round's data envelope (
env.wrap("coverage_ledger", ...), F3 nonce framing); the code-owned header and counters stay outside the frame.Small adjacent edits:
record_coverageis allowed during the worker budget wrap-up (BudgetWrapupBlocks), like the other write-back tools.intercept.noTargetTools: it only writes to the DB, so itssurfaceURL is not a network target.Choices
These are the points where the brief was ambiguous. Each time I took the conservative option.
Table shape. There are two tables.
coverage_ledgerhasUNIQUE (task_id, surface, risk_area)and is upserted.coverage_ledger_historyis append-only, and both writes happen in one transaction. Every text field is normalised to one line indb.RecordCoverage(see Review fixes);risk_areais also lower-cased and matched against the lower-cased goalvulnclass. Both tables have an FK totaskswithON DELETE CASCADE. They are not added to the task archive/restore path.Completeness source.
CoverageCompletenessFor(status, paused, budget, pastDeadline)decides:budget:tasks.end_reason = 'budget'. The budget settle inengine_timeout.gowrites it in the same guarded UPDATE as the terminal status; it is per run (cleared when a revive moves the task back to running).timeout:status = timeout, ordonewithcompleted_at >= deadline_at(goals met on the final timeout round still count as a timeout).aborted:failed.paused: the paused flag or status.in_progress: any other status that is notdone.complete:doneonly.A budget end reason wins over everything else for that run, even when the final round met the goals. A caveat string is always set, including on
complete.A finding does not close a class. Only a ledger entry satisfies a mandatory class. Findings are reported separately as
findings_by_class(machine_observed). A worker that reports a finding is expected to record areportedentry as well.Planner line when there are no entries. The per-round line is absent until at least one entry exists, as the test list asks. It stays absent even if goals carry a vulnclass. Unrecorded classes still appear in the API, the card, the report and the wrap-up gap list. If you would rather show unexamined classes from round 1, it is a one-line change in
renderCoverageLedger.Wrap-up text. The gap list is added to the planner's wrap-up round (task timeout and budget). The worker wrap-up prompts are unchanged.
API shape. The ledger fields
entries,gaps,unexamined,findings_by_classandcompletenessare flattened into the existing coverage document.db.Coverageembeds*db.CoverageLedger, so the existing fields are unchanged.Export. "Export" is the Markdown report (
GET /api/report), which gets a "Coverage gaps" section with completeness and the gap list (at most 200 entries, then a count line). The findings CSV/JSON export is unchanged.Ledger scope. The ledger is per task. It does not read inherited source tasks.
Completeness caveat
A run that ended by timeout, the budget wrap-up, pause, abort, or that is still running is reported as
complete: false, with astateand a caveat. The caveat says that the absence of a finding does not mean the target is clean and that unexamined classes and open gaps were not covered. The caveat is never omitted. The report always prints it, and the card shows it when the run is incomplete.Review fixes
Blocker 1: planner injection through ledger text.
db.RecordCoverageitself (not only the tool handler) normalisessurface,risk_area,evidenceandreasonto one line: every control character (C0 including\r\n\t, DEL, C1) and U+2028/U+2029 become a space, whitespace runs collapse, ends are trimmed. Then length limits apply: surface 200, risk_area 64, evidence 500, reason 500 (characters). Over a limit the write is refused with e.g.surface too long (max 200); nothing is truncated.agent/planner.gokeeps oneenv := newDataEnvelope()per message, passes it toplannerSituationaland tocoverageLedgerBlock. Only the gap lines are framed (field=coverage_ledger); the envelope neutraliser rewrites anyARTEX_DATAmarker inside them. The header (counters, "prove_goal stays allowed") and the "and N more" line are code-owned and stay outside. The budget line is unchanged (numbers only).- and N more (see the coverage API/report); the Markdown report lists at most 200, then a count line.Blocker 2: stale budget completeness after a revive.
tasks.end_reason TEXT NOT NULL DEFAULT ''(ALTER TABLE ... ADD COLUMN IF NOT EXISTS, like the other additive task columns).SetTerminalStatusGuarded/Manager.SetTaskStatusGuardedtake an end reason and store it in the same guarded UPDATE as the terminal status;settleTaskpassesbudgeton a budget settle, the normal done path passes empty. A losing writer stores nothing.ApplyTaskAdmission(same UPDATE as the terminal -> running revive), inSetStatusto a non-terminal status, and inresetSettledRun(also reached fromresetTimeoutRevival), which clears it only if the task is not terminal again.CoverageLedgerreadstasks.end_reason. The activity-metadata marker is removed (the "Task run budget exhausted" activity text stays, as on main); there is a single source.Non-blocking.
SELECT ... FOR UPDATEon the task row) so the cap holds under concurrency. The history stays append-only and is not capped.COUNT(*)first and returns early when the task has no entries, instead of the full 4-query load. The wrap-up round still loads the full ledger (unrecorded classes matter there).taskCoverage: on a 500 the real error is logged ([coverage] ...) and the client gets a generic message, as other handlers do.Limitations
evidenceis unverified free text. Ano_issue_foundwithfact 999closes a class even if fact 999 does not exist for the task. This follows Strix'sagent_reportedmodel; a later hardening can check that a cited fact/intent/traffic id exists for the task.outcome=reportedcloses a class without checking that a matching finding exists.coverage_ledgerorcoverage_ledger_history. A restored task reads every class as unexamined, which is the conservative direction.Tests run locally
The system Go toolchain in Kali (go1.26.10). The PG tests ran against a throwaway
postgres:16container bound to 127.0.0.1, removed afterwards.gofmt -lon the changed files: the only output isagent/tools.go,db/tasks.go,server/manager.goandserver/server.go. All four are already unformatted onmainat lines this PR does not touch (checked by runninggofmt -lon themainversions) and are left as they are.go build ./...: OK.go vet ./...: OK.go test -count=1 ./...with PG: all 16 packages pass.go test -race -count=1 ./agent ./db ./server ./report: on a fresh database all four pass with no data race. Whendbreuses the database of a previous full run, 4 db tests fail on leftover rows (duplicate llm profile names, a leftover company), as before. One race run ofserveralso reported data races in other tests; the same package onmain(afa6f4f) also races intermittently (TestTriggeredConversationInheritsGate,TestTrafficIngestRequiresAuth), so this is pre-existing flakiness, not this PR.db:TestBuildCoverageLedgerGaps,TestCoverageCompletenessFor,TestCoverageJSONCarriesLedger,TestRecordCoverageUpsertHistory(PG: upsert plus history, ledger load, budget end reason),TestNormalizeCoverageEntry(one-line folding of control characters, exact limits and error text),TestCoverageCompletenessBudgetThenReviveDone(PG: budget settle, losing writer, revive, later planner/worker activity carrying the old marker, normal done =>complete),TestRecordCoverageRowCap(PG: new key past 2000 refused, existing key updated).agent:TestRecordCoverageDisabledPassthrough,TestRenderCoverageLedger,TestRenderCoverageLedgerInjection(a surface with\n\n,[[ARTEX_DATA/[[END_ARTEX_DATAand a fake[Operator]line stays on one line inside the one ledger frame: no extra marker, no extra section),TestRenderCoverageLedgerWrapupCap(100 gaps => 25 lines thenand 75 more),TestRecordCoverageSeededOnExistingDB(PG),TestRecordCoverageToolWritesEntry(PG).server:TestReviveClearsBudgetEndReason(PG: budget settle stores the reason, same-status admission keeps it, terminal -> running admission clears it,resetSettledRunclears a running task's reason andresetTimeoutRevivalleaves a terminal one).report:TestMarkdownCoverageGaps,TestMarkdownCoverageGapsCap(230 gaps => 200 listed plusand 30 more).Not verified
overview-tab.tsx,api.ts) is type-checked by the CI web job but was not visually rendered.record_coverage, or how the planner reacts to the line.taskCoverageandgetReporthandlers are not exercised end-to-end in tests. The JSON shape and the Markdown rendering are tested directly.