Add assert --format json|toon (typed AssertView) - #213
Merged
Conversation
assert emitted only a human ASCII table plus an exit code, so a CI PR-comment script had to scrape the table -- the one place a gate consumed text instead of JSON. It now emits a typed AssertView under --format json|toon, mirroring the query/diff verbs: a row per threshold (axis count/timing/slice, budget, measured value or null, verdict pass/fail/n-a-fail, plus the routed member on a run-group), the overall passed flag, the violation lines, and any group notes. The exit code is unchanged (0 = passed, 1 = any failed), so a --format json gate fails the build exactly as the human report does; the human table and its wording are byte-identical. AssertView/AssertThresholdRow are exported from the package root and covered by the public-types walker.
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.
Problem
assertemitted only a human ASCII table plus an exit code.diffandcpu-diffboth have--format json, but a CI PR-comment script gating onasserthad to scrape the ASCII table to render "layout slice 6 ms > 4 ms budget" — the one place in a gate that consumed text instead of structured output.Change
assertgains--format json|toon, emitting a typedAssertView(additive, off the stored types, the same pattern as the other views):thresholds[]: oneAssertThresholdRowper gate —target(run / step / group),metric,axis(count|timing|slice),budget,value(the measured number ornullwhen not measured),verdict(pass|fail|n/a-fail), and the routedmemberon a run-group.passed,violations[],notes[](group disclosures), and akinddiscriminator (recording|group).Example (
--target node, a not-measured forced-count on a node recording is a loud n/a-fail):{ "target": ".../rec.json", "kind": "recording", "thresholds": [ { "target": "run", "metric": "forced layout/style", "axis": "count", "budget": 0, "value": null, "verdict": "n/a-fail", "reason": "not measured" }, { "target": "run", "metric": "wall ms", "axis": "timing", "budget": 100000, "value": 22.565, "verdict": "pass" } ], "passed": false, "violations": ["run: forced layout/style was not measured; cannot satisfy max 0"], "notes": [] }Invariants held
passedis true exactly when the process exits 0. A--format jsongate fails the build exactly as the human report does (unit + e2e assertpassed↔status).value: null/verdict: "n/a-fail"/ exit 1, never a fabricated0that silently passes.Scope
src/model/query.ts:AssertView,AssertThresholdRow,AssertVerdict,AssertAxis.src/commands/assert.ts: build the view in both the plain and run-group paths; a sharedfinishAssertemits structured or prints the human report and sets the exit code.src/cli.ts:--format+ hidden--jsononassert.src/index.ts+ README type table +public-typeswalker:AssertView/AssertThresholdRowexported and enumerated.test/unit/assert-format.test.mjs(7 tests: shape, the n/a-fail exit-code guarantee, the slice axis, TOON, exit-code parity, and the run-group member routing).Gates: lint, format:check, build, unit (745), the 3 Chrome-driven
asserte2e tests all green.