Skip to content

feat(evidence): show the device state, UI tree and logs behind a verdict - #406

Merged
ElbertePlinio merged 20 commits into
mainfrom
feat/352-evidence-state
Oct 28, 2026
Merged

ElbertePlinio merged 20 commits into
mainfrom
feat/352-evidence-state

Conversation

@ElbertePlinio

@ElbertePlinio ElbertePlinio commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Evidence accepted only screenshots. A reviewer could not see the UI tree or the log excerpt behind a verdict, or the device state at capture time, and matrix runs and the rule checks in #353 need all three.

pickforge evidence record now writes schema v4. Each state can carry a capture with the requested and observed device state, the capture time, the app build and the emulator and system image versions; a value that was not observed is recorded as unknown. UI trees, log excerpts and Lighthouse reports are read as UTF-8 files of at most 4 MiB, redacted, and stored as plain .txt that no viewer runs. A source that is not available records its reason. Schema v1 to v3 inputs and recorded runs stay valid.

Redaction keeps stored output usable. JSON is rewritten token by token, so numbers, spacing and order survive and rule checks can parse it. XML is redacted in decoded form and encoded again, so trees stay well formed. JSON inside a log line is redacted with its key context, and broken JSON is read leniently so a secret after the break is still found.

Proof: the CI jobs pass locally on the merge with main (231151b): cargo fmt, clippy and workspace tests, tsc, oxlint, vitest (3370 passed) and build. The evidence fixtures are marked -text, so Windows checkouts keep them byte for byte. PickCheck reports no violations. The QA pass ran nine CLI journeys; the redaction journey that failed was rerun on b2997ea and passes.

Council (Sol and Fable, with Kimi in rounds 1 and 2): ten rounds. On 0a38a23 Sol approved with 10/10 and Fable with 9/10; a differential fuzz of 18,000 outputs found valid JSON unchanged and no new leaks.

Rollback: revert the merge commit. No release has shipped schema v4, so only v4 runs recorded locally in between would be skipped by the older reader.

Closes #352

Requirement How verified Scenario and edge cases Result Evidence
Decide how non-screenshot artifacts fit the Rust evidence path Design in evidence.rs: text artifacts are copied, redacted and stored as .txt with kind, origin, format and capture time Screenshots keep their PNG path Met Diff
Requested and observed device state: display mode, fold state, posture, rotation, density, font scale, dark mode, locale tests/evidence_capture.rs; QA journeys 1 and 7 Partial values become unknown; requested lists only given keys; invalid rotation, density, font scale, dark mode, time, unknown fields and empty build are rejected with no run written Met ~/.pickforge/investigations/qa-352/out/j7.txt
Capture time, app build, emulator and system image versions tests/evidence_capture.rs; QA journey 1 Omitted values are unknown; secrets in build strings are redacted Met ~/.pickforge/investigations/qa-352/out/j1.out
UI tree or log excerpt as an artifact, with size limits QA journey 5; tests/evidence_capture.rs Exactly 4 MiB is stored; 4 MiB + 1, non-UTF-8 and symlinks fail with no partial run; the limit also holds after redaction Met ~/.pickforge/investigations/qa-352/out/j5-*.out
Same redaction as other stored output 18 unit tests in text_redaction.rs; QA journey 2 rerun on b2997ea; CLI run with the council's broken-JSON inputs OAuth tokens, client secret, cookie and API key; cookie inside an XML attribute keeps the tree well formed; JSON in log lines with missing commas, stray closers and escaped keys Met ~/.pickforge/investigations/qa-352/rerun-b2997ea/
Sources named with capture time; unavailable source reports unavailable QA journeys 1, 4 and 8 Android UI tree, logcat, DevTools accessibility and console, Lighthouse, AT-SPI with unavailable: "no AT-SPI bus" Met ~/.pickforge/investigations/qa-352/out/j8-report.txt
Imported report HTML is untrusted QA journey 3 Lighthouse HTML with <script> and onerror is stored only as .txt; report.md escapes markup and links only to the artifact path Met ~/.pickforge/investigations/qa-352/out/j3.out
Schema v3 documents stay valid inputs QA journey 6; v3 fixture test A v3 input records as v4; an old v3 run still lists and reports Met ~/.pickforge/investigations/qa-352/out/j6-report-v3.txt
Viewer and report show the new fields QA journey 8; packages/core/test/rust-evidence.test.ts report.md and pickforge-lab artifacts report show captures and artifacts as captured, unavailable or missing Met ~/.pickforge/investigations/qa-352/out/j8-report-missing.txt
Tests and docs Diff; CI jobs above Flutter skill steps 7 and 8, README, release note Met Diff

Declined: validating locale, display mode and fold state against a fixed vocabulary, because the rule checks in #353 own normalization; Fable's notes on unterminated strings losing their text and on redacting the rest of a line after a break inside a secret value, which trade readable text for safety; continuing instead of stopping when a key appears inside a secret value, which is equally safe; and duplicate [REDACTED] keys for undecodable keys.

Follow-ups: #388 (capture trees, logs and reports from the tools), #389 (align the Rust and TypeScript redactors), #390 (show a deleted screenshot as missing), #401 (secret context across pretty-printed JSON), #403 (escaped key names in plain-text rules), #405 (a stray closer between a secret key and its colon).

Evidence schema v4 adds a capture record to every state and tree, log
and report artifacts with a named origin and capture time. Unobserved
values read unknown. Text artifacts are redacted with the existing
evidence redaction, capped at 4 MiB, and stored as inert .txt files.
Unavailable sources are recorded with a reason. Schema v1 to v3 inputs
and recorded runs stay valid, proven with real v3 fixtures.

Refs #352
Authorization redaction covers any scheme, an unquoted cookie stops at
quotes and angle brackets, and JSON values honour escaped quotes. The
size limit also holds after redaction. Unavailable artifacts show their
capture time, and the TypeScript report drops terminal controls.
…xact

Each JSON value in a line is masked while the plain-text rules run, so
JSON before trailing text is redacted and a Cookie header still covers
the rest of its line. The secret-name prefix rule now uses the JSON key
rules, so max_tokens keeps its value. In a Lighthouse report only audit
ids lose secret-key handling. Decoding keeps unknown references apart
from decoded ampersands. Candidate parsing stops 32 levels down and
after 4096 failed starts, so lines of brackets stay linear.
A JSON string with a lone surrogate, such as a console message cut
inside an emoji, decoded to an empty value, so its text skipped
redaction. It is now replaced whole, and a key that does not decode is
matched as written.
…imits

A small JSON scanner replaces the serde check. It reads numbers as text,
so 1e400 no longer rejects a value, and it has no nesting limit. Where
JSON stops being valid, the valid part is redacted as JSON in place and
stays plain text, and the search goes on from there, so each byte is
read once and no fallback skips nested secrets. A literal marker
character in the input is escaped, so only inserted markers are
restored.
When JSON in a line breaks inside a value under a secret key, the rest
of that value is redacted up to the bracket that closes it, or to the
end of the line, so the plain-text rules no longer see it without its
key. A JSON key that does not decode now counts as a secret key.
…y context

JSON that breaks off is now rewritten by the same token rewriter, read
leniently up to where its outer container closes, so keys after the
break, including escaped ones, keep their meaning. Stray words are
copied or redacted under a secret key, a closer closes back to the
container it matches, and a closer that does not match inside a secret
value redacts the rest of the line. Inside a secret container of broken
JSON, keys are redacted too. Each fragment trims its line break once,
and a closer that matches no container costs O(1).
@ElbertePlinio
ElbertePlinio merged commit b4a7bf6 into main Oct 28, 2026
14 of 15 checks passed
@ElbertePlinio
ElbertePlinio deleted the feat/352-evidence-state branch October 28, 2026 20:11
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.

evidence: record device state, UI trees and logs

1 participant