@edjbarron/ux-guard 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +304 -58
- package/docs/cli-reference.md +92 -7
- package/docs/scoring-and-backslide.md +140 -0
- package/docs/test-suite.md +72 -5
- package/docs/use-case-review-design.md +284 -0
- package/docs/use-case-review.md +368 -0
- package/lib/catalog.mjs +46 -7
- package/lib/cli.mjs +368 -84
- package/lib/config.mjs +36 -1
- package/lib/review-app/app.css +697 -0
- package/lib/review-app/app.js +1899 -0
- package/lib/review-app/index.html +44 -0
- package/lib/review-audit.mjs +514 -0
- package/lib/review-command.mjs +409 -0
- package/lib/review-server.mjs +233 -0
- package/lib/review-store.mjs +554 -0
- package/lib/review.mjs +1385 -0
- package/lib/run-contract.mjs +1 -1
- package/package.json +1 -1
- package/skills/ux-guard/SKILL.md +154 -12
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# Scoring and backslide protection
|
|
2
|
+
|
|
3
|
+
This page defines what ux-guard scores, what it compares, and which results can
|
|
4
|
+
affect a command exit code. Quality, target attainment, regression, and
|
|
5
|
+
numerical scores are separate signals.
|
|
6
|
+
|
|
7
|
+
## Where scoring appears
|
|
8
|
+
|
|
9
|
+
After reviewed policy and journey evidence are configured, run:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npx ux-guard report
|
|
13
|
+
npx ux-guard report --base origin/main
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The Markdown report has separate **Quality verdict**, **Target attainment**,
|
|
17
|
+
**Regression and backslide**, and **Numerical scores** sections. JSON keeps the
|
|
18
|
+
same meanings in separate `quality`, `targetAttainment`, `regression`, and
|
|
19
|
+
`scoring` fields.
|
|
20
|
+
|
|
21
|
+
The trusted-base form loads reviewed policy, owner targets, and comparison
|
|
22
|
+
baselines from the resolved `origin/main` commit while evaluating candidate
|
|
23
|
+
source and evidence. A candidate cannot replace those reviewed inputs with
|
|
24
|
+
more favorable policy or baselines.
|
|
25
|
+
|
|
26
|
+
## How scores are created
|
|
27
|
+
|
|
28
|
+
Numerical scores require explicit, reviewed, product-owned metric targets.
|
|
29
|
+
Historical baselines do not produce scores. Only an `at-most` target has an
|
|
30
|
+
approved numerical formula:
|
|
31
|
+
|
|
32
|
+
- If `actual <= target`, the metric score is 100.
|
|
33
|
+
- If `actual > target`, the score is
|
|
34
|
+
`round(100 * target / actual)`.
|
|
35
|
+
- If a zero target is breached, the score is 0.
|
|
36
|
+
|
|
37
|
+
For example, if a workflow should edit at most 3 fields and actually edits 4,
|
|
38
|
+
its metric score is `round(100 * 3 / 4)`, or 75. That score means the reviewed
|
|
39
|
+
interaction target was missed. It does not change or summarize the independent
|
|
40
|
+
quality verdict.
|
|
41
|
+
|
|
42
|
+
The aggregation is deliberately non-compensating:
|
|
43
|
+
|
|
44
|
+
- A journey score is the minimum of its scoreable configured metric scores.
|
|
45
|
+
- A use-case score is the minimum of its scored required journey scores.
|
|
46
|
+
- A missing, unexecutable, unsuccessful, or unmeasured journey is not scored.
|
|
47
|
+
- An `at-least` or `exactly` target is evaluated for attainment but is not
|
|
48
|
+
numerically scored.
|
|
49
|
+
- Partial score coverage stays `partially-scored`; absent coverage stays
|
|
50
|
+
`not-scored`.
|
|
51
|
+
- There is no product-wide scalar score.
|
|
52
|
+
|
|
53
|
+
## What backslide detection compares
|
|
54
|
+
|
|
55
|
+
Reviewed comparison evidence can detect each signal independently:
|
|
56
|
+
|
|
57
|
+
- a metric increase beyond its explicitly reviewed tolerance;
|
|
58
|
+
- lifecycle degradation, missing required journeys, or reduced measured and
|
|
59
|
+
successful coverage;
|
|
60
|
+
- newly introduced findings or increased finding severity;
|
|
61
|
+
- breaches of reviewed hard floors for evidence, completion, failures, skips,
|
|
62
|
+
infrastructure errors, or critical findings;
|
|
63
|
+
- growth in static control values or pattern debt beyond the reviewed
|
|
64
|
+
non-growth baseline;
|
|
65
|
+
- visual manifest, browser profile, checkpoint, image hash, image dimension,
|
|
66
|
+
or related reviewed visual-contract drift.
|
|
67
|
+
|
|
68
|
+
Baseline equality means only that comparable evidence did not backslide. It
|
|
69
|
+
does not declare the UX good or make known defects acceptable.
|
|
70
|
+
|
|
71
|
+
## Detection versus merge prevention
|
|
72
|
+
|
|
73
|
+
ux-guard defaults to detection and advisory reporting:
|
|
74
|
+
|
|
75
|
+
- `report` exits 0 whenever it renders successfully, including when it reports
|
|
76
|
+
a quality problem, target breach, regression, or unavailable comparison
|
|
77
|
+
evidence. Missing active journey policy and malformed or unsafe inputs exit
|
|
78
|
+
2; missing or unexecutable run evidence remains visible in the report.
|
|
79
|
+
- `check` exits 0 when there is no enforceable catalog or static-pattern
|
|
80
|
+
finding, 1 when those findings exist, and 2 for configuration, evidence, or
|
|
81
|
+
execution failure.
|
|
82
|
+
- Journey, target, regression, score, and visual sections remain advisory
|
|
83
|
+
unless the consumer adopts a separate, reviewed enforcement decision.
|
|
84
|
+
|
|
85
|
+
A merge is prevented only when the consumer runs a pinned, trusted ux-guard
|
|
86
|
+
configuration in CI and makes that check required.
|
|
87
|
+
Requiring `report` alone does not block advisory backslide because a successful
|
|
88
|
+
report returns 0.
|
|
89
|
+
Consumers that choose to enforce advisory signals need a trusted classifier or
|
|
90
|
+
wrapper with an explicit reviewed failure policy.
|
|
91
|
+
|
|
92
|
+
## Prepared trusted check-in guard
|
|
93
|
+
|
|
94
|
+
`review audit` exposes a non-activating `guard.recommendedExit` for the saved
|
|
95
|
+
unapproved preview. A check-in guard should use the same meanings only after a
|
|
96
|
+
separate enforcement review:
|
|
97
|
+
|
|
98
|
+
- exit 0: trusted execution completed, required evidence is compatible, and no
|
|
99
|
+
selected reviewed-policy finding, regression, or target breach was observed;
|
|
100
|
+
- exit 1: candidate code/source has a reviewed catalog or control-policy
|
|
101
|
+
finding, trusted regression, or reviewed-target breach;
|
|
102
|
+
- exit 2: trusted configuration, evidence, or execution is missing,
|
|
103
|
+
incompatible, invalid, or failed, so the result is unknown rather than
|
|
104
|
+
clean;
|
|
105
|
+
- exit 3: candidate catalog, workflow, target, control policy, or baseline
|
|
106
|
+
files differ from the trusted base and require a separate visible policy
|
|
107
|
+
review. The candidate version is never used to judge itself.
|
|
108
|
+
|
|
109
|
+
If several categories apply, the report must retain all of them. Execution or
|
|
110
|
+
evidence failure takes exit 2 precedence, explicit policy-review work takes
|
|
111
|
+
exit 3 precedence over code findings, and code findings take exit 1. A
|
|
112
|
+
consumer can choose a stricter reviewed policy, but it must not silently turn
|
|
113
|
+
unknown evidence into success.
|
|
114
|
+
|
|
115
|
+
The trusted implementation, configuration, policy, targets, and baselines must
|
|
116
|
+
be extracted from an immutable base commit such as `origin/main`. Candidate
|
|
117
|
+
browser shards and source are inputs only. The repository should first run the
|
|
118
|
+
classifier as advisory, inspect its JSON/Markdown artifacts, then require the
|
|
119
|
+
check only after an explicit human approval names the command, selected
|
|
120
|
+
blocking signals, trusted base, and CI job. Neither ux-guard nor an agent should
|
|
121
|
+
enable that requirement automatically.
|
|
122
|
+
|
|
123
|
+
Every blocking result has two legitimate remediation paths:
|
|
124
|
+
|
|
125
|
+
1. fix candidate product/source code and regenerate evidence;
|
|
126
|
+
2. prepare an explicit policy, use-case, workflow, target, control, or baseline
|
|
127
|
+
candidate with a visible diff for separate review.
|
|
128
|
+
|
|
129
|
+
Automatically updating a baseline, target, waiver, or policy to make the same
|
|
130
|
+
candidate pass is never a remediation.
|
|
131
|
+
|
|
132
|
+
Useful Agent Skill prompts:
|
|
133
|
+
|
|
134
|
+
> Show me where ux-guard scoring comes from and explain every score
|
|
135
|
+
|
|
136
|
+
> Compare this branch with origin/main and explain every backslide signal; do
|
|
137
|
+
> not change policy or baselines
|
|
138
|
+
|
|
139
|
+
See the [CLI reference](cli-reference.md#scoring-and-backslide-protection) for
|
|
140
|
+
commands and exit behavior.
|
package/docs/test-suite.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Test suite catalog
|
|
2
2
|
|
|
3
|
-
ux-guard has exactly
|
|
3
|
+
ux-guard has exactly 160 generic tests. This catalog was built from the test
|
|
4
4
|
names discovered by Node's test runner, not from a feature checklist. Run
|
|
5
5
|
`npm test` to execute them and `npm run check:test-catalog` to verify that this
|
|
6
6
|
page still matches the test files and names.
|
|
@@ -23,11 +23,13 @@ application.
|
|
|
23
23
|
- `policy, schema, browser, and approval incompatibilities never become comparisons` — Proves incompatible evidence is reported as unavailable instead of being treated as a valid regression comparison.
|
|
24
24
|
- `owner target v2 validates desired requirements and metric policy separately from baseline tolerances` — Proves desired targets remain a distinct reviewed contract from current-state regression tolerances.
|
|
25
25
|
|
|
26
|
-
## `test/catalog.test.mjs` (
|
|
26
|
+
## `test/catalog.test.mjs` (6 tests)
|
|
27
27
|
|
|
28
28
|
- `reads navigation surfaces from nested object literals` — Proves catalog discovery recognizes navigation entries nested in source object literals.
|
|
29
29
|
- `reports navigation surfaces that no use case covers` — Proves a route missing from the use-case catalog is surfaced as unmapped.
|
|
30
30
|
- `accepts assistant starts and deep routes under a surface` — Proves assistant entry points and deeper routes can satisfy a catalogued surface mapping.
|
|
31
|
+
- `accepts canonical direct routes without treating them as navigation coverage` — Proves a route-only start remains distinct from navigation-surface mapping while still binding the use case to implementation.
|
|
32
|
+
- `accepts use cases without owner or entry points and reports their binding as unknown` — Proves definition validity does not depend on governance metadata or implementation bindings, while legacy owner metadata remains readable and unbound coverage stays explicit.
|
|
31
33
|
- `rejects malformed use cases` — Proves invalid catalog records fail validation instead of being partially accepted.
|
|
32
34
|
|
|
33
35
|
## `test/cli.test.mjs` (16 tests)
|
|
@@ -103,6 +105,71 @@ application.
|
|
|
103
105
|
- `visual capture rejects an unreviewed browser version` — Proves browser identity must match the reviewed visual profile.
|
|
104
106
|
- `visual capture requires every reviewed mask to match` — Proves visual masks are valid only when every reviewed selector resolves.
|
|
105
107
|
|
|
108
|
+
## `test/review-app.test.mjs` (12 tests)
|
|
109
|
+
|
|
110
|
+
- `the review page has landmarks, a skip link, live regions, and a labelled tab pattern` — Proves the review page exposes a skip link, header, navigation, and main landmarks, polite status and alert regions, and tabs that control labelled panels.
|
|
111
|
+
- `every rendered control is labelled and every reference resolves across views` — Proves every input, select, and textarea in every use-case and coverage view has a label, every ARIA or label reference names an element that exists, and no empty placeholder renders as visible text.
|
|
112
|
+
- `direct-route entry points edit, persist, and reject malformed paths accessibly` — Proves reviewers can enter and save a canonical direct route while malformed paths receive linked inline errors, preserve focus, and cannot be accepted or saved.
|
|
113
|
+
- `tabs and lists follow the arrow, Home, and End keyboard pattern` — Proves keyboard users can move between tabs and through inbox items across outcome groups without a pointer.
|
|
114
|
+
- `incomplete discovery drafts lead with completion and require explicit acceptance` — Proves incomplete drafts omit direct proposal approval, lead with field-specific focus guidance, persist undecided completion edits, and require a separate completed-use-case acceptance.
|
|
115
|
+
- `one approval follows the current definition and reset preserves approval intent` — Proves one approval choice stores edited content compatibly, remains selected through later edits, and changes back to original approval data when reset restores the assessment proposal.
|
|
116
|
+
- `merge requires a searchable explicit target and previews what will move` — Proves merge remains incomplete until a searchable eligible target is chosen and exposes target status, mapping counts, movement details, duplicate handling, keyboard focus, and labels.
|
|
117
|
+
- `decisions keep focus through re-rendering and Ctrl+S saves with an unapproved announcement` — Proves focus survives server re-evaluation and the keyboard save announces that the saved review is unapproved and nothing was adopted.
|
|
118
|
+
- `dirty reviews warn on browser unload and require confirmation before close` — Proves unsaved state triggers browser protection, Close requires an explicit discard confirmation, cancellation focuses Save, and confirmation closes without saving.
|
|
119
|
+
- `closing cancels queued and in-flight evaluation before a new review session` — Proves closing or tearing down a review invalidates delayed evaluation work so an old session cannot send its token to or update a later session.
|
|
120
|
+
- `an exclusion without a rationale is flagged in place and stays unresolved` — Proves excluding an item demands its own rationale, marks the field invalid with a linked message, and keeps the item unresolved.
|
|
121
|
+
- `the stylesheet provides visible focus, reduced motion, and dark mode without external assets` — Proves the app ships visible focus, reduced-motion, and dark-mode styles and loads no external resources or HTML-injection paths.
|
|
122
|
+
|
|
123
|
+
## `test/review-cli.test.mjs` (10 tests)
|
|
124
|
+
|
|
125
|
+
- `review without a candidate explains what is missing, offers the agent prompt, and writes nothing` — Proves the default command explains the missing assessment, prints the copyable agent prompt in text and JSON, and leaves the repository untouched.
|
|
126
|
+
- `an explicit candidate path that does not exist is an input error with guidance` — Proves a named but missing candidate fails with exit 2 and a next step instead of falling back silently.
|
|
127
|
+
- `review --format json reports status without starting the app or writing files` — Proves automation can read review progress and the adoption command without a server or any write.
|
|
128
|
+
- `review audit assesses the exact saved preview against an explicit trusted base without writing` — Proves JSON and Markdown audit output keeps active policy separate from the exact saved unapproved preview, reports readiness and guard advice, and leaves review artifacts byte-for-byte unchanged.
|
|
129
|
+
- `review audit distinguishes compatible candidate diagnostics from incompatible evidence without treating either as a trusted pass` — Proves current-version local evidence can inform diagnostics without becoming a trusted check-in result, while old-version evidence stays explicitly incompatible and fail-closed.
|
|
130
|
+
- `review audit rejects stale previews and a working active catalog that differs from its trusted judge` — Proves audit provenance cannot silently use a stale preview or let candidate policy replace the trusted active catalog.
|
|
131
|
+
- `prepare and adopt run end to end and leave configuration and baselines unchanged` — Proves the CLI prepares once without overwriting, refuses adoption without approval details or the exact catalog hash, and adopts without touching configuration or baselines.
|
|
132
|
+
- `prepare clearly warns when every discovered definition is an incomplete draft` — Proves preparation separately counts complete proposals and incomplete drafts, records focused questions, and warns rather than presenting an all-draft assessment as proposal-ready.
|
|
133
|
+
- `review options are rejected outside review and incompatible options are rejected inside it` — Proves review-only flags cannot leak into other commands and each review subcommand rejects options it does not use.
|
|
134
|
+
- `review help and documentation describe the unapproved workflow with the exact agent prompts` — Proves help states the loopback, unapproved boundary and that the README and review guide carry the exact agent prompts the CLI prints.
|
|
135
|
+
|
|
136
|
+
## `test/review-server.test.mjs` (6 tests)
|
|
137
|
+
|
|
138
|
+
- `the review server binds only to loopback and serves self-contained assets with strict headers` — Proves the app is bound to 127.0.0.1, never answers on other interfaces, and serves assets with a restrictive content security policy and no external URLs.
|
|
139
|
+
- `the review API requires the session token and a loopback Host header` — Proves API calls without the session token or with a rebinding Host header are refused.
|
|
140
|
+
- `the review API rejects cross-origin, cross-site, non-JSON, and oversized requests` — Proves cross-origin and cross-site requests, wrong content types, oversized or malformed bodies, unknown methods and paths, and approval claims are rejected.
|
|
141
|
+
- `the review API preserves undecided drafts and rejects stale incomplete approval choices` — Proves server evaluation accepts draft fields without approval while refusing incomplete original or revised approval payloads without writing.
|
|
142
|
+
- `evaluate never writes files and save writes only the review and its preview` — Proves evaluation is read-only, saving writes exactly the unapproved review and preview, and a replayed stale revision is refused.
|
|
143
|
+
- `closing from the app stops the server and the review command exits cleanly` — Proves Close review ends the local process and the command reports that saved decisions remain unapproved.
|
|
144
|
+
|
|
145
|
+
## `test/review-store.test.mjs` (8 tests)
|
|
146
|
+
|
|
147
|
+
- `prepare stamps repository identity and input hashes without overwriting` — Proves prepare records root commits, the current commit, and hashes of every assessed file, and never overwrites a candidate.
|
|
148
|
+
- `prepare rejects forged identity, missing or escaping inputs, and policy destinations` — Proves agent-authored identity, missing or escaping source paths, and candidate paths that name active policy are refused.
|
|
149
|
+
- `stale candidates are detected from changed inputs and from a different repository` — Proves edited or deleted assessed files and a foreign repository mark the candidate stale while unrelated commits do not.
|
|
150
|
+
- `saves are atomic, revisioned, and refuse concurrent or foreign overwrites` — Proves saves replace files atomically, advance the revision, reject a stale revision, and never overwrite a preview ux-guard did not generate.
|
|
151
|
+
- `review artifact paths cannot target active policy, escape the repository, or follow symbolic links` — Proves review, preview, and candidate paths are confined to safe repository-local destinations.
|
|
152
|
+
- `a review recorded against another candidate is refused instead of silently reapplied` — Proves decisions bound to a different candidate hash are not applied to a new assessment.
|
|
153
|
+
- `adoption requires approval details and a saved, current, conflict-free review with an exact preview` — Proves adoption refuses missing approval details, unsaved or stale reviews, blocking issues, and a preview that differs from the saved decisions.
|
|
154
|
+
- `adoption replaces an existing catalog only with its exact current hash and changes nothing else` — Proves catalog replacement requires the current hash, an unconfigured repository needs an explicit catalog path, and nothing outside the catalog changes.
|
|
155
|
+
|
|
156
|
+
## `test/review.test.mjs` (14 tests)
|
|
157
|
+
|
|
158
|
+
- `use-case candidates validate strictly and reject approval, forged identity, and unsafe paths` — Proves drafts and candidates reject unknown fields, approval claims, agent-written identity, and unsafe paths.
|
|
159
|
+
- `candidate direct-route starts validate and round-trip without impersonating navigation starts` — Proves direct routes survive candidate validation and catalog emission while malformed or navigation-disguised variants fail closed.
|
|
160
|
+
- `candidate definition status is inferred for legacy files and contradictory declarations fail closed` — Proves old candidates gain deterministic proposal-or-draft status from completeness while explicit status that conflicts with fields is rejected.
|
|
161
|
+
- `review decisions round-trip canonically and reject unknown proposals, subjects, and actions` — Proves saved decisions serialize deterministically and cannot reference proposals, subjects, or actions that do not exist.
|
|
162
|
+
- `incomplete drafts remain undecided until explicitly completed and accepted` — Proves pending completion edits affect a draft without catalog inclusion, explicit completed-use-case acceptance can include it, and incomplete or stale approval choices fail semantic validation.
|
|
163
|
+
- `complete proposals approve directly while incomplete drafts stay out until completed` — Proves complete proposals support direct approval while drafts enter the catalog only after all missing definition fields are completed and explicitly accepted.
|
|
164
|
+
- `reject and split leave dependent mappings unresolved until they are remapped` — Proves removing or dividing a proposal does not silently keep its surfaces covered.
|
|
165
|
+
- `merge folds starts and mappings into an accepted target and rejects unaccepted targets` — Proves merged proposals contribute their starts and coverage to an accepted use case and cannot merge into an undecided one.
|
|
166
|
+
- `added use cases and split parts must be complete and cannot collide with the catalog` — Proves owner-added entries and split parts are validated and cannot duplicate active or proposed identifiers.
|
|
167
|
+
- `unresolved and exclusion accounting keeps unknowns visible instead of reporting success` — Proves coverage totals count unresolved items and rationale-free exclusions as unresolved rather than covered.
|
|
168
|
+
- `mapped surfaces become catalog starts that the catalog check accepts` — Proves surface mappings become catalog starts that the existing catalog validation accepts.
|
|
169
|
+
- `the generated catalog diff is exact, deterministic, and keeps the active entries` — Proves the preview diff matches the generated catalog exactly and preserves existing entries and inventory.
|
|
170
|
+
- `catalog YAML emission round-trips through the strict parser or refuses to write` — Proves generated YAML parses back to the same catalog or is refused before writing.
|
|
171
|
+
- `unified diffs use minimal hunks with three lines of context` — Proves diff hunks are minimal and correctly positioned for additions, removals, and new files.
|
|
172
|
+
|
|
106
173
|
## `test/run-contract.test.mjs` (5 tests)
|
|
107
174
|
|
|
108
175
|
- `policy digests use canonicalized content and Node cryptographic hashes` — Proves equivalent policy content has a stable cryptographic identity.
|
|
@@ -114,10 +181,10 @@ application.
|
|
|
114
181
|
## `test/setup.test.mjs` (8 tests)
|
|
115
182
|
|
|
116
183
|
- `setup explains insufficient evidence in an empty repository without writing files` — Proves setup reports unknown evidence honestly and leaves an empty repository unchanged.
|
|
117
|
-
- `setup
|
|
184
|
+
- `setup tailors next steps and keeps the README transcript exact` — Proves the terminal flow omits irrelevant work, explains its supporting file, and stays byte-for-byte synchronized with the documented hard-coded-color example.
|
|
118
185
|
- `setup JSON is deterministic, noninteractive, and keeps approval boundaries explicit` — Proves automation output is stable and cannot imply policy, baseline, waiver, or enforcement approval.
|
|
119
|
-
- `setup never overwrites an existing
|
|
120
|
-
- `setup
|
|
186
|
+
- `setup never overwrites an existing supporting review file or active policy` — Proves setup preserves prior review work and refuses to replace active policy.
|
|
187
|
+
- `setup supporting review paths reject traversal and symlink escapes` — Proves supporting review writes remain within real repository directories.
|
|
121
188
|
- `primary help leads with setup, check, and report while advanced help preserves reference commands` — Proves everyday help stays outcome-focused while existing maintainer commands remain discoverable.
|
|
122
189
|
- `check and report errors point unconfigured repositories to the safe first step` — Proves daily commands give actionable guidance without bypassing review.
|
|
123
190
|
- `legacy discovery output and schema remain backward compatible` — Proves the additive setup flow leaves the original discovery artifact contract intact.
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
# Use-case review design
|
|
2
|
+
|
|
3
|
+
This records the design of `ux-guard review`: what it decides, what it
|
|
4
|
+
refuses to change, and the limits accepted for the first version. The user
|
|
5
|
+
workflow, draft fields, and commands are in
|
|
6
|
+
[use-case review](use-case-review.md).
|
|
7
|
+
|
|
8
|
+
## Goal
|
|
9
|
+
|
|
10
|
+
Give a person a local way to turn an assessment of a repository into a
|
|
11
|
+
reviewed use-case catalog. ux-guard validates the assessment, keeps unknowns
|
|
12
|
+
visible, and shows the exact catalog diff. It does not invent use cases, and
|
|
13
|
+
it does not treat a saved review as approval to change active policy.
|
|
14
|
+
|
|
15
|
+
Analysis stays deterministic. TypeScript parsing and the reviewed catalog
|
|
16
|
+
rules decide structure. No model is called. The optional agent explains the
|
|
17
|
+
proposals in plain language and stops before adoption, check-in, and
|
|
18
|
+
enforcement.
|
|
19
|
+
|
|
20
|
+
## Compatibility
|
|
21
|
+
|
|
22
|
+
This is an added command. `setup`, `check`, `report`, and the policy
|
|
23
|
+
lifecycle commands are unchanged. Catalog, baseline, target, waiver, and
|
|
24
|
+
configuration version numbers are unchanged. Catalog validation now treats
|
|
25
|
+
entry points as optional implementation bindings and `owner` as accepted
|
|
26
|
+
legacy metadata rather than definition validity. There is no new runtime
|
|
27
|
+
dependency. TypeScript remains the only one.
|
|
28
|
+
|
|
29
|
+
Candidate definitions now carry `definitionStatus: "proposal" | "draft"`.
|
|
30
|
+
This is additive: candidates written before the field existed are classified
|
|
31
|
+
from the same completeness rule when read. An explicit status that contradicts
|
|
32
|
+
the fields is rejected rather than trusted.
|
|
33
|
+
|
|
34
|
+
Files appear only when someone prepares a candidate, saves a review, or runs
|
|
35
|
+
`review adopt`. The active catalog changes only when `review adopt` is run
|
|
36
|
+
with the reviewer, a UTC time, a rationale, and, when a catalog already
|
|
37
|
+
exists, the current file hash.
|
|
38
|
+
|
|
39
|
+
The tool version stays `0.6.0` until a release. The change is listed under
|
|
40
|
+
Unreleased.
|
|
41
|
+
|
|
42
|
+
## Four artifacts
|
|
43
|
+
|
|
44
|
+
| Artifact | Default path | Who writes it | What it is |
|
|
45
|
+
| --- | --- | --- | --- |
|
|
46
|
+
| Draft | `ux-guard/use-case-draft.json` | A person or an agent | The assessment. It must not carry repository identity or hashes. |
|
|
47
|
+
| Candidate | `ux-guard/use-case-candidate.json` | `review prepare` | The validated draft plus identity computed by ux-guard. Always unapproved. Never overwritten. |
|
|
48
|
+
| Review | `ux-guard/use-case-review.json` | Save in the app | Decisions about proposals and mappings. Always unapproved. Revisioned. |
|
|
49
|
+
| Preview | `ux-guard/use-case-catalog.preview.yml` | Save in the app | The catalog that those decisions would produce, marked generated and unapproved. |
|
|
50
|
+
|
|
51
|
+
The active catalog stays a separate file. Only `review adopt` writes it.
|
|
52
|
+
|
|
53
|
+
A file that claims `approval.status` is `approved`, or that
|
|
54
|
+
`activatesCatalog` is true, is rejected. Approval of the catalog is the
|
|
55
|
+
`review adopt` command, not a field an agent can set.
|
|
56
|
+
|
|
57
|
+
## Read-only audit contract
|
|
58
|
+
|
|
59
|
+
`review audit` is intentionally between Save and Adopt. It requires the exact
|
|
60
|
+
saved review/preview pair and an explicit trusted Git revision. The preview
|
|
61
|
+
catalog is parsed and validated in memory while the active catalog, reviewed
|
|
62
|
+
journey policy, targets, comparison baselines, visual policy, and static
|
|
63
|
+
pattern baseline come from the trusted revision. Candidate source and optional
|
|
64
|
+
versioned journey evidence remain candidate inputs; they cannot replace their
|
|
65
|
+
judge.
|
|
66
|
+
|
|
67
|
+
The versioned `ux-guard-review-audit` document keeps definition/mapping
|
|
68
|
+
readiness, source/control compliance, evidence compatibility, quality, target
|
|
69
|
+
attainment, regression, and numerical scoring separate. Every preview use case
|
|
70
|
+
has an assessment record. A use case without reviewed journey coverage or
|
|
71
|
+
compatible measurements is `not-evaluated` and `not-scored` with the missing
|
|
72
|
+
prerequisite; catalog acceptance or an entry-point mapping alone never creates
|
|
73
|
+
a UX score.
|
|
74
|
+
|
|
75
|
+
Evidence parser/version failures are data in this read-only report:
|
|
76
|
+
`incompatible` or `invalid`, with a fail-closed recommended guard exit. Unsafe
|
|
77
|
+
paths, malformed trusted policy, a missing trusted base, an unsaved review, or
|
|
78
|
+
a preview mismatch remain command errors. Rendering the audit exits 0 because
|
|
79
|
+
the command does not enforce; its `guard.recommendedExit` documents how a
|
|
80
|
+
separately approved trusted CI classifier would treat the same state.
|
|
81
|
+
Configured visual candidates are not assumed current: visual evidence remains
|
|
82
|
+
not evaluated unless the caller supplies an explicit current manifest.
|
|
83
|
+
Compatible local journey evidence remains `candidate-untrusted`. It can support
|
|
84
|
+
diagnostic quality, target, regression, and scoring output, but the guard stays
|
|
85
|
+
fail-closed until immutable-base authoritative regeneration establishes
|
|
86
|
+
trusted execution.
|
|
87
|
+
|
|
88
|
+
No audit path writes, approves, adopts, promotes, or changes enforcement.
|
|
89
|
+
|
|
90
|
+
The local app does not yet render this audit contract. A coherent later GUI
|
|
91
|
+
addition is one read-only **Audit** tab backed by the same JSON: an active vs
|
|
92
|
+
preview provenance banner, review and mapping readiness, control findings,
|
|
93
|
+
evidence/quality/target/regression columns, per-use-case score or a named
|
|
94
|
+
missing prerequisite, and the two remediation paths. The tab must not add
|
|
95
|
+
approval, adoption, baseline, target, or enforcement controls and must not
|
|
96
|
+
reimplement evaluation in browser JavaScript.
|
|
97
|
+
|
|
98
|
+
## Use-case approval and catalog adoption
|
|
99
|
+
|
|
100
|
+
In the app, **Approve this use case** is a decision about the complete
|
|
101
|
+
definition currently shown, including edits. Save writes that decision into
|
|
102
|
+
the review file. Reopening the app shows it again. The review file itself
|
|
103
|
+
remains `unapproved`, so saving does not activate the catalog.
|
|
104
|
+
|
|
105
|
+
**Owner approval** is `ux-guard review adopt` in a terminal. That command
|
|
106
|
+
writes the catalog. Its receipt — reviewer, time, rationale, and catalog
|
|
107
|
+
hash — is printed to the terminal, and as JSON with `--format json`. It is
|
|
108
|
+
not written into the catalog or into its own file. Keep the output in the
|
|
109
|
+
commit message or pull request when a durable record is needed.
|
|
110
|
+
|
|
111
|
+
Adoption, check-in, and enforcement remain separate decisions. Adoption keeps
|
|
112
|
+
the existing catalog `inventory` value, or uses `partial` for a new catalog,
|
|
113
|
+
so enforcement does not change. Configuration, baselines, targets, and
|
|
114
|
+
waivers are not modified.
|
|
115
|
+
|
|
116
|
+
## Decision model
|
|
117
|
+
|
|
118
|
+
Discovered definitions are grouped by the user outcome they serve. A complete
|
|
119
|
+
definition is a **proposal** and can be left undecided, approved, rejected,
|
|
120
|
+
merged into an accepted use case, or split into parts. Its single approval
|
|
121
|
+
choice applies to the complete definition currently shown. Reset restores the
|
|
122
|
+
assessment proposal; editing or resetting approved content keeps the approval
|
|
123
|
+
choice while automatically selecting the compatible stored action:
|
|
124
|
+
`approve` when unchanged and `revise` when fields differ. Existing review
|
|
125
|
+
files using either action load into the same choice. An incomplete definition
|
|
126
|
+
is a **draft**: it cannot be directly approved and instead leads with
|
|
127
|
+
field-specific completion guidance. Once complete, its explicit affirmative
|
|
128
|
+
decision is **Accept completed use case**. Internally that decision uses the
|
|
129
|
+
existing `revise` action, preserving review-file compatibility. Undecided edits
|
|
130
|
+
can be saved or reset and never imply acceptance. The reviewer can also add a
|
|
131
|
+
use case the assessment missed.
|
|
132
|
+
|
|
133
|
+
A surface or workflow is mapped to one or more use cases, excluded with its
|
|
134
|
+
own rationale, or left unresolved. An exclusion does not inherit the
|
|
135
|
+
assessment's reason for mapping that item. Without a rationale it stays
|
|
136
|
+
unresolved.
|
|
137
|
+
|
|
138
|
+
Rejecting or splitting a proposal leaves anything mapped to it unresolved
|
|
139
|
+
until it is remapped. A merge contributes the proposal's entry points,
|
|
140
|
+
requirements, and gaps to an accepted target. A mapped navigation surface
|
|
141
|
+
becomes a `starts` binding on its use cases, including use cases already in the
|
|
142
|
+
active catalog. A manual `{ entry: "route", route: "/path" }` binding represents
|
|
143
|
+
a direct application route without a navigation id. It is intentionally
|
|
144
|
+
distinct from `{ nav_id, route }`, so route evidence cannot masquerade as
|
|
145
|
+
navigation-surface coverage. A mapped surface explicitly classified as
|
|
146
|
+
`hidden` derives this direct-route form and is excluded from navigation
|
|
147
|
+
coverage obligations. Assistant prompt bindings remain unchanged.
|
|
148
|
+
|
|
149
|
+
Direct routes are serialized exactly as canonical absolute paths. `/` is
|
|
150
|
+
valid; other paths have one leading slash and no trailing or repeated slash,
|
|
151
|
+
query, fragment, whitespace, backslash, dot traversal segment, or encoded dot
|
|
152
|
+
or separator. This narrow form is deterministic and consumer-neutral.
|
|
153
|
+
|
|
154
|
+
A use case enters the generated catalog when it has an id and title, persona,
|
|
155
|
+
goal, success outcome, tier, and effect. Tier and effect remain required
|
|
156
|
+
because existing generic policy uses them to classify reviewed scope. `starts`
|
|
157
|
+
is optional: missing entry points produce a nonblocking unknown implementation
|
|
158
|
+
coverage warning, never omission. `owner` is not required and is not shown in
|
|
159
|
+
the form. Legacy owner metadata is accepted and preserved in existing
|
|
160
|
+
catalogs and candidates so opening or adopting a review does not perform a
|
|
161
|
+
destructive migration. Approval provenance is recorded by `review adopt`.
|
|
162
|
+
Generated entries pass the same catalog validation as `ux-guard check`.
|
|
163
|
+
|
|
164
|
+
Completeness is computed from those same definition requirements for every
|
|
165
|
+
decision surface. Candidate parsing derives legacy status from completeness,
|
|
166
|
+
canonical preparation writes the status, and contradictory explicit status
|
|
167
|
+
fails closed. Discovery authors populate every inferable required field from
|
|
168
|
+
repository evidence. If a field cannot be supported, the item remains a draft
|
|
169
|
+
with a focused question linked by use-case id and missing fields; neither the
|
|
170
|
+
agent nor prepare invents definition content. Prepare adds a deterministic
|
|
171
|
+
focused question if needed and warns prominently when every definition is
|
|
172
|
+
incomplete. Discovery similarly records direct routes only when repository
|
|
173
|
+
routes, workflow entry evidence, or tests establish a true user start. Action
|
|
174
|
+
labels and incidental URLs are not starts; unknown bindings stay absent.
|
|
175
|
+
|
|
176
|
+
An incomplete source cannot use direct approval. Accepting a completed draft
|
|
177
|
+
or storing an edited complete-proposal approval requires at least one changed
|
|
178
|
+
field and a complete effective definition. The server rejects stale clients
|
|
179
|
+
or hand-authored review payloads that attempt either invalid action. For a
|
|
180
|
+
complete proposal, editing approved content changes stored `approve` to
|
|
181
|
+
`revise`; restoring every field changes it back to `approve`. For an incomplete
|
|
182
|
+
draft, editing an accepted completion still returns it to undecided until the
|
|
183
|
+
reviewer explicitly accepts it again.
|
|
184
|
+
|
|
185
|
+
Merge selection is intentionally two-phase. Opening merge changes no decision.
|
|
186
|
+
A searchable picker shows existing entries and complete proposals, but only
|
|
187
|
+
accepted targets can complete the merge. Self, rejected, merged, split, and
|
|
188
|
+
incomplete targets are excluded. The preview states which surface/workflow
|
|
189
|
+
mappings, manual and derived entry points, requirements, and gaps move, which
|
|
190
|
+
duplicates collapse, and whether navigation bindings conflict. The engine's
|
|
191
|
+
one-hop resolution and broken-target checks remain authoritative.
|
|
192
|
+
|
|
193
|
+
Coverage totals count discovered, mapped, awaiting decision, excluded, and
|
|
194
|
+
unresolved items. Definition progress separately counts complete proposals,
|
|
195
|
+
incomplete drafts, completed drafts, and decisions still needed. Unresolved
|
|
196
|
+
items and exclusions without a rationale are never reported as covered. Open
|
|
197
|
+
questions from the assessment stay visible.
|
|
198
|
+
|
|
199
|
+
## Identity and staleness
|
|
200
|
+
|
|
201
|
+
`review prepare` stamps the candidate with the repository's root commits, the
|
|
202
|
+
current commit, and a SHA-256 of every navigation file and source the
|
|
203
|
+
assessment named. An agent cannot supply those values. A draft that contains
|
|
204
|
+
them is rejected.
|
|
205
|
+
|
|
206
|
+
The review stores the candidate's SHA-256. Decisions saved against a
|
|
207
|
+
different candidate are refused rather than applied to a new assessment.
|
|
208
|
+
|
|
209
|
+
If an assessed file changes, disappears, or the repository's root commits
|
|
210
|
+
differ, the candidate is stale. The app still opens and can save, and
|
|
211
|
+
adoption is blocked until a fresh candidate is prepared. New commits that
|
|
212
|
+
leave every assessed file unchanged are reported and do not block. Without
|
|
213
|
+
Git history, identity is unverified; assessed file hashes are still checked.
|
|
214
|
+
|
|
215
|
+
Navigation surfaces found in source but missing from the draft are listed at
|
|
216
|
+
prepare time and appear as unresolved subjects.
|
|
217
|
+
|
|
218
|
+
## Adoption guards
|
|
219
|
+
|
|
220
|
+
`review adopt` writes the catalog only when all of these hold:
|
|
221
|
+
|
|
222
|
+
- the review has been saved;
|
|
223
|
+
- the saved preview matches the catalog the saved decisions generate;
|
|
224
|
+
- the candidate is not stale;
|
|
225
|
+
- no blocking issue remains;
|
|
226
|
+
- reviewer, UTC time, and rationale are single-line values;
|
|
227
|
+
- an existing catalog is replaced only when `--replace-catalog-sha256` equals
|
|
228
|
+
the hash of the file about to be replaced.
|
|
229
|
+
|
|
230
|
+
The catalog path comes from `.uxguard.json`. Before configuration exists,
|
|
231
|
+
`--catalog` chooses the path. That path cannot be the configuration file, the
|
|
232
|
+
candidate, the review, or the preview.
|
|
233
|
+
|
|
234
|
+
Writes stay inside the repository. Paths cannot traverse out, follow a
|
|
235
|
+
symbolic link, or name active configuration, navigation sources, baselines,
|
|
236
|
+
journey policy, or visual policy. New files are created atomically and are
|
|
237
|
+
not overwritten. Replacing the review or the catalog succeeds only when the
|
|
238
|
+
expected hash is still current, so a concurrent save is reported instead of
|
|
239
|
+
lost. A preview that ux-guard did not generate is not overwritten.
|
|
240
|
+
|
|
241
|
+
## Local app
|
|
242
|
+
|
|
243
|
+
The server binds to `127.0.0.1` on a free port and serves only its bundled
|
|
244
|
+
page, script, and stylesheet. The session token is in the printed URL
|
|
245
|
+
fragment. The page stores it for the tab and removes it from the address
|
|
246
|
+
bar. API requests must carry that token, a loopback `Host` header, and a
|
|
247
|
+
same-origin JSON body within the size limit. Responses set a restrictive
|
|
248
|
+
content security policy and forbid framing, caching, and content sniffing.
|
|
249
|
+
There is no telemetry and no external asset.
|
|
250
|
+
|
|
251
|
+
The page is a view. Decision rules, validation, coverage totals, and the diff
|
|
252
|
+
run in the ux-guard process. Evaluation writes nothing. Save writes the
|
|
253
|
+
review and the preview. Dirty state is prominent, browser unload and Close
|
|
254
|
+
warn before discarding edits, and a successful save shows the revision, UTC
|
|
255
|
+
timestamp, path, and unapproved status while briefly changing the button to
|
|
256
|
+
`Saved ✓`. Close, or Ctrl+C, stops the server. The browser is not opened when
|
|
257
|
+
`--no-open` is set or `CI` is set.
|
|
258
|
+
|
|
259
|
+
Without a candidate, `review` explains what is missing, prints the agent
|
|
260
|
+
prompt, and writes nothing. An explicit `--candidate` path that does not
|
|
261
|
+
exist is an error.
|
|
262
|
+
|
|
263
|
+
The app uses native controls, a skip link, landmarks, the tab keyboard
|
|
264
|
+
pattern, arrow keys in lists, visible focus, a polite status region, and an
|
|
265
|
+
alert region. Status is also written in text, not only in color. It follows
|
|
266
|
+
the system dark-mode and reduced-motion preferences.
|
|
267
|
+
|
|
268
|
+
## Accepted limits
|
|
269
|
+
|
|
270
|
+
- **Catalog rewrite.** Adoption emits the whole catalog. Comments are not
|
|
271
|
+
kept, and quoting or wrapping can change. The preview diff shows every
|
|
272
|
+
changed line, and the app warns that comments are dropped.
|
|
273
|
+
- **Existing entries.** A use case already in the catalog can gain `starts`
|
|
274
|
+
from a mapped surface. Its other fields, including legacy `owner` metadata,
|
|
275
|
+
are preserved and are not edited in the app.
|
|
276
|
+
- **Approval receipt.** The adopt receipt is printed, not stored as a file.
|
|
277
|
+
- **Working files.** The draft, candidate, review, and preview are ordinary
|
|
278
|
+
repository files. They are written only by prepare or save. Leaving them
|
|
279
|
+
untracked is safe. The catalog is the file adoption changes.
|
|
280
|
+
- **Diff details.** A line-ending-only change is not shown. The exact-hash
|
|
281
|
+
replacement has a small window between the hash check and the write.
|
|
282
|
+
- **Browser checks in CI.** The package tests keyboard and labelling behavior
|
|
283
|
+
with a small in-process document. A real browser pass is run locally and is
|
|
284
|
+
not a package dependency.
|