@edjbarron/ux-guard 0.6.1 → 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 +264 -104
- package/docs/cli-reference.md +38 -0
- package/docs/scoring-and-backslide.md +40 -0
- package/docs/test-suite.md +69 -2
- 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 +288 -46
- 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 +131 -1
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
# Use-case review
|
|
2
|
+
|
|
3
|
+
`ux-guard review` opens a local app for deciding which user workflows the
|
|
4
|
+
repository's use-case catalog should cover. The app helps people review an
|
|
5
|
+
assessment; it does not approve, adopt, check in, or enforce anything.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npx ux-guard review
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or ask your agent:
|
|
12
|
+
|
|
13
|
+
> Help me discover and review the important use cases in this repository.
|
|
14
|
+
> Populate every required definition field that repository evidence supports.
|
|
15
|
+
> If a field cannot be supported, mark the item as an incomplete draft, add a
|
|
16
|
+
> focused unresolved question, and never invent a goal. Open ux-guard’s local
|
|
17
|
+
> review experience, explain the proposals and drafts in plain language, and
|
|
18
|
+
> do not activate policy without my explicit approval.
|
|
19
|
+
|
|
20
|
+
Other prompts the bundled skill understands:
|
|
21
|
+
|
|
22
|
+
> Continue my ux-guard use-case review.
|
|
23
|
+
|
|
24
|
+
> Open the ux-guard review app for this repository.
|
|
25
|
+
|
|
26
|
+
> Help me resolve the remaining unmapped workflows and exclusions. Do not
|
|
27
|
+
> approve or activate anything.
|
|
28
|
+
|
|
29
|
+
## Workflow
|
|
30
|
+
|
|
31
|
+
1. **Assess.** An agent or a person writes an assessment draft to
|
|
32
|
+
`ux-guard/use-case-draft.json`: the navigation surfaces and workflows
|
|
33
|
+
found in the repository, complete proposals and incomplete drafts grouped by
|
|
34
|
+
user outcome, and a
|
|
35
|
+
proposed mapping or exclusion for each surface and workflow. ux-guard does
|
|
36
|
+
not guess these.
|
|
37
|
+
2. **Prepare.** `ux-guard review prepare` validates the draft and writes an
|
|
38
|
+
unapproved candidate to `ux-guard/use-case-candidate.json`, stamped with the
|
|
39
|
+
repository's root commits, the current commit, and a SHA-256 of every
|
|
40
|
+
assessed file. Navigation surfaces found in source but missing from the
|
|
41
|
+
draft are listed and later appear as unresolved. Prepare stamps every
|
|
42
|
+
definition with its deterministic proposal-or-draft status and adds a
|
|
43
|
+
field-linked unresolved question when an incomplete draft lacks one. If all
|
|
44
|
+
definitions are drafts, prepare prints a prominent warning.
|
|
45
|
+
3. **Review.** `ux-guard review` starts the local app. In it, people:
|
|
46
|
+
- approve the complete definition currently shown, including edits, with
|
|
47
|
+
one approval choice;
|
|
48
|
+
- complete an incomplete discovery draft and explicitly accept the
|
|
49
|
+
completed use case;
|
|
50
|
+
- reject, merge, or split a proposal, or add a missed use case;
|
|
51
|
+
- map each surface and workflow to use cases, or exclude it with a
|
|
52
|
+
rationale;
|
|
53
|
+
- edit persona, goal, success outcome, tier, effect, rationale, and optional
|
|
54
|
+
entry points;
|
|
55
|
+
- see unresolved decisions, validation problems, and coverage totals;
|
|
56
|
+
- preview the exact catalog diff.
|
|
57
|
+
4. **Save.** Saving writes the decisions to `ux-guard/use-case-review.json` and
|
|
58
|
+
the generated catalog to `ux-guard/use-case-catalog.preview.yml`. Both are
|
|
59
|
+
unapproved. The app shows the saved revision, UTC timestamp, path, and
|
|
60
|
+
unapproved status. Saving can be repeated; reopening the app resumes from
|
|
61
|
+
the saved decisions. Dirty reviews warn before browser unload or Close.
|
|
62
|
+
5. **Adopt, separately.** Only after explicit owner approval, the owner runs
|
|
63
|
+
`ux-guard review adopt` in a terminal. The app shows the command but never
|
|
64
|
+
runs it.
|
|
65
|
+
6. **Check in and enforce, separately.** Adoption writes only the catalog.
|
|
66
|
+
Checking it in, changing inventory or enforcement, and adopting baselines
|
|
67
|
+
or waivers remain separate decisions.
|
|
68
|
+
|
|
69
|
+
## Commands
|
|
70
|
+
|
|
71
|
+
| Command | Writes |
|
|
72
|
+
| --- | --- |
|
|
73
|
+
| `ux-guard review` | Nothing until **Save review**; then the review and preview only |
|
|
74
|
+
| `ux-guard review --format json` | Nothing; reports status without starting the app |
|
|
75
|
+
| `ux-guard review prepare` | The candidate only, never overwriting |
|
|
76
|
+
| `ux-guard review audit --base <ref> --format json\|markdown` | Nothing; assesses the exact saved unapproved preview against trusted policy |
|
|
77
|
+
| `ux-guard review adopt` | The active catalog only, after every check passes |
|
|
78
|
+
|
|
79
|
+
Options:
|
|
80
|
+
|
|
81
|
+
- `--candidate`, `--review`, `--preview`, and `--draft` select other
|
|
82
|
+
repository-relative paths. They cannot name active configuration, the
|
|
83
|
+
catalog, navigation sources, baselines, journey policy, or visual policy.
|
|
84
|
+
- `--port <number>` selects the loopback port; the default is any free port.
|
|
85
|
+
- `--no-open` prints the address without opening a browser. The browser is
|
|
86
|
+
also not opened when `CI` is set.
|
|
87
|
+
|
|
88
|
+
Without a candidate, `ux-guard review` explains what is missing, prints the
|
|
89
|
+
agent prompt above, and writes nothing. An explicit `--candidate` path that
|
|
90
|
+
does not exist is an error.
|
|
91
|
+
|
|
92
|
+
### Audit before adoption
|
|
93
|
+
|
|
94
|
+
`review audit` makes later assessment work usable while decisions are still
|
|
95
|
+
pending. It requires a saved review, an on-disk preview that exactly matches
|
|
96
|
+
that review, and an explicit trusted base. It evaluates the preview in memory;
|
|
97
|
+
it never copies the preview over the active catalog.
|
|
98
|
+
|
|
99
|
+
The audit reports:
|
|
100
|
+
|
|
101
|
+
- candidate, review, preview, trusted-base, and evidence provenance;
|
|
102
|
+
- complete proposals, incomplete drafts, pending decisions, mapping readiness,
|
|
103
|
+
unbound use cases, and blocking issues;
|
|
104
|
+
- active reviewed catalog and unapproved preview as separate states;
|
|
105
|
+
- source/control-policy findings from candidate source against trusted policy;
|
|
106
|
+
- journey compatibility and coverage, quality, reviewed-target attainment,
|
|
107
|
+
regression, and score-or-not-scored per preview use case;
|
|
108
|
+
- a non-activating guard recommendation and the two remediation paths: fix
|
|
109
|
+
candidate product/source code, or prepare a visible policy/catalog/workflow,
|
|
110
|
+
target, or baseline candidate for separate review.
|
|
111
|
+
|
|
112
|
+
The working active catalog must still match the trusted base. Catalog changes
|
|
113
|
+
belong in the saved unapproved preview; a changed working active catalog is
|
|
114
|
+
refused so candidate policy cannot silently replace the judge.
|
|
115
|
+
|
|
116
|
+
Use `--journey-report <repository-relative-path>` to point at new versioned
|
|
117
|
+
runtime evidence without replacing the configured report. Evidence produced by
|
|
118
|
+
another ux-guard version, malformed evidence, and missing evidence remain
|
|
119
|
+
`incompatible`, `invalid`, or `missing`; none is treated as a pass. JSON and
|
|
120
|
+
Markdown are rendering formats for the same source-of-truth contract. Visual
|
|
121
|
+
evidence is `not-evaluated` unless an explicitly current manifest is supplied
|
|
122
|
+
with `--visual-candidate`; the audit never silently reuses a historical
|
|
123
|
+
configured visual candidate.
|
|
124
|
+
|
|
125
|
+
Schema-compatible local journey evidence can render diagnostic quality,
|
|
126
|
+
targets, regression, and scores, but it is labelled `candidate-untrusted`. Its
|
|
127
|
+
recommended check-in result stays fail-closed until the consumer's pinned-base
|
|
128
|
+
authoritative runner regenerates and classifies the evidence.
|
|
129
|
+
|
|
130
|
+
The command exits 0 when it renders the audit successfully, even when its
|
|
131
|
+
`guard.recommendedExit` is 1 or 2. That guard value is advice only. A consumer
|
|
132
|
+
must separately review and activate a pinned trusted-base CI classifier before
|
|
133
|
+
it can block check-in.
|
|
134
|
+
|
|
135
|
+
### Adoption
|
|
136
|
+
|
|
137
|
+
```sh
|
|
138
|
+
npx ux-guard review adopt \
|
|
139
|
+
--reviewer <owner> \
|
|
140
|
+
--reviewed-at 2026-01-31T12:00:00Z \
|
|
141
|
+
--rationale "Reviewed with design and engineering." \
|
|
142
|
+
--replace-catalog-sha256 <current catalog sha256>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Adoption refuses unless:
|
|
146
|
+
|
|
147
|
+
- the review is saved, and the saved preview exactly matches what the saved
|
|
148
|
+
decisions generate;
|
|
149
|
+
- the candidate is not stale;
|
|
150
|
+
- no blocking issues remain;
|
|
151
|
+
- the reviewer, a UTC review time, and a rationale are recorded;
|
|
152
|
+
- an existing catalog is replaced only with `--replace-catalog-sha256` equal to
|
|
153
|
+
its current hash. The app and `review --format json` show the exact command,
|
|
154
|
+
including the hash.
|
|
155
|
+
|
|
156
|
+
The catalog path comes from `.uxguard.json`. Before configuration exists, pass
|
|
157
|
+
`--catalog <path>`. Adoption keeps the existing catalog's `inventory` value, or
|
|
158
|
+
uses `partial` for a new catalog, so enforcement does not change. Unresolved
|
|
159
|
+
items are reported as unresolved, never as covered. The printed adoption
|
|
160
|
+
record names the approval; keep it with the change for review.
|
|
161
|
+
|
|
162
|
+
## Draft format
|
|
163
|
+
|
|
164
|
+
The draft is JSON. Unknown fields are rejected, so mistakes are reported
|
|
165
|
+
instead of ignored.
|
|
166
|
+
|
|
167
|
+
```json
|
|
168
|
+
{
|
|
169
|
+
"kind": "ux-guard-use-case-draft",
|
|
170
|
+
"version": 1,
|
|
171
|
+
"approval": { "status": "unapproved", "activatesCatalog": false },
|
|
172
|
+
"source": { "catalog": "ux/use-cases.yml", "navigation": ["src/nav.tsx"] },
|
|
173
|
+
"outcomes": [{ "id": "manage-records", "title": "Manage records" }],
|
|
174
|
+
"proposals": [
|
|
175
|
+
{
|
|
176
|
+
"id": "export-records",
|
|
177
|
+
"definitionStatus": "proposal",
|
|
178
|
+
"outcome": "manage-records",
|
|
179
|
+
"title": "Export records",
|
|
180
|
+
"persona": "Analyst",
|
|
181
|
+
"tier": "tertiary",
|
|
182
|
+
"effect": "read",
|
|
183
|
+
"goal": "Export the record list.",
|
|
184
|
+
"success": "A file with the visible records downloads.",
|
|
185
|
+
"rationale": "Export is offered from the record list.",
|
|
186
|
+
"starts": [{ "entry": "route", "route": "/records/export" }],
|
|
187
|
+
"capability": "present"
|
|
188
|
+
}
|
|
189
|
+
],
|
|
190
|
+
"surfaces": [
|
|
191
|
+
{
|
|
192
|
+
"id": "records",
|
|
193
|
+
"label": "Records",
|
|
194
|
+
"route": "/records",
|
|
195
|
+
"sources": ["src/nav.tsx"],
|
|
196
|
+
"classification": {
|
|
197
|
+
"disposition": "proposed-use-case",
|
|
198
|
+
"useCaseIds": ["export-records"],
|
|
199
|
+
"rationale": "Top-level destination."
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
],
|
|
203
|
+
"workflows": [
|
|
204
|
+
{
|
|
205
|
+
"id": "debug-panel",
|
|
206
|
+
"title": "Developer debug panel",
|
|
207
|
+
"sources": ["src/Debug.tsx"],
|
|
208
|
+
"capability": "not-applicable",
|
|
209
|
+
"classification": { "disposition": "excluded", "rationale": "Developer-only diagnostics." }
|
|
210
|
+
}
|
|
211
|
+
],
|
|
212
|
+
"questions": [{ "id": "export-scope", "question": "Is export in scope?", "impact": "Changes the tier list." }]
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Fields:
|
|
217
|
+
|
|
218
|
+
- `source.catalog` is the catalog the assessment targets; `source.navigation`
|
|
219
|
+
lists the navigation sources it read. The draft must not contain
|
|
220
|
+
`repository`, `commit`, or `inputs`; `prepare` computes them.
|
|
221
|
+
- `outcomes` group proposals by the user outcome they serve.
|
|
222
|
+
- Every discovered definition needs `id` (lowercase words separated by
|
|
223
|
+
hyphens) and `title`. A complete proposal also has `persona`, `tier`
|
|
224
|
+
(`primary`, `secondary`, `tertiary`), `effect` (`read`, `create`, `change`),
|
|
225
|
+
`goal`, and `success`, and declares `"definitionStatus": "proposal"`. If any
|
|
226
|
+
required definition field is not supported by evidence, omit that content
|
|
227
|
+
and declare `"definitionStatus": "draft"`. Prepare and the parser infer the
|
|
228
|
+
same status for older files without the field, but reject an explicit status
|
|
229
|
+
that contradicts completeness. `starts` is
|
|
230
|
+
an optional implementation binding whose entries are `{ "nav_id", "route" }`
|
|
231
|
+
for navigation, `{ "entry": "route", "route" }` for a direct application
|
|
232
|
+
route, or `{ "entry": "assistant", "prompt" }`. Direct routes are canonical
|
|
233
|
+
absolute paths: `/` or a path such as `/login`, without a query, fragment,
|
|
234
|
+
traversal segment, encoded separator, repeated slash, or trailing slash.
|
|
235
|
+
They do not count as navigation-surface coverage. A use case without
|
|
236
|
+
`starts` remains valid and appears in the preview with implementation
|
|
237
|
+
coverage marked unknown. `requirements`, `gaps`, `rationale`, and
|
|
238
|
+
`capability` (`present`,
|
|
239
|
+
`partial`, `absent`, `deployment-dependent`, `not-applicable`, `unknown`)
|
|
240
|
+
are optional.
|
|
241
|
+
- Assessment authors should populate every required field supported by
|
|
242
|
+
repository evidence. They must never invent a goal or success statement.
|
|
243
|
+
Add a direct-route binding only when repository routes, workflows, or tests
|
|
244
|
+
show that the route is a true user entry point. Do not turn action labels or
|
|
245
|
+
incidental URLs into starts, and leave an unknown binding absent.
|
|
246
|
+
Each incomplete draft needs a focused question with `useCaseId` and
|
|
247
|
+
`missingFields`, for example:
|
|
248
|
+
|
|
249
|
+
```json
|
|
250
|
+
{
|
|
251
|
+
"id": "archive-record-definition",
|
|
252
|
+
"question": "What evidence-supported Goal should complete “Archive a record”?",
|
|
253
|
+
"impact": "Until answered, archive-record remains an incomplete draft and cannot be accepted as proposed.",
|
|
254
|
+
"useCaseId": "archive-record",
|
|
255
|
+
"missingFields": ["goal"]
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
Prepare adds this question deterministically when the author omitted it,
|
|
260
|
+
reports complete proposals separately from incomplete drafts, and warns when
|
|
261
|
+
every discovered definition is incomplete.
|
|
262
|
+
- Legacy `owner` metadata is accepted and preserved when it already exists in
|
|
263
|
+
a catalog or candidate, but the review form does not collect or require it.
|
|
264
|
+
Approval provenance belongs to the separate adoption record. No migration
|
|
265
|
+
removes legacy metadata.
|
|
266
|
+
- A surface needs `id`, `label`, and `classification`; `route`, `kind`
|
|
267
|
+
(`destination`, `group`, `subtree`, `hidden`, `other`), and `sources` are
|
|
268
|
+
optional. A workflow needs `id`, `title`, and `classification`; `entry`,
|
|
269
|
+
`capability`, and `sources` are optional.
|
|
270
|
+
- `classification.disposition` is `existing-use-case`, `proposed-use-case`,
|
|
271
|
+
`excluded`, or `unresolved`. Use `unresolved` when ownership or scope is
|
|
272
|
+
unclear; ux-guard keeps it visible rather than counting it as covered.
|
|
273
|
+
- `sources` and `navigation` are repository-relative files. Each is hashed by
|
|
274
|
+
`prepare` so later edits mark the candidate stale.
|
|
275
|
+
|
|
276
|
+
## What the app shows
|
|
277
|
+
|
|
278
|
+
- **Summary**: discovered, mapped, awaiting decision, excluded, and unresolved
|
|
279
|
+
totals; separate complete-proposal, incomplete-draft, and decisions-needed
|
|
280
|
+
progress; every unresolved decision with a link to it;
|
|
281
|
+
blocking issues and warnings; open questions from the assessment.
|
|
282
|
+
- **Use cases**: proposals and drafts grouped by outcome with search and
|
|
283
|
+
decision filters, draft-first editable definition fields, a leading
|
|
284
|
+
**Complete this draft** path with field links, one approval choice for the
|
|
285
|
+
complete definition currently shown, **Accept completed use case**, reset
|
|
286
|
+
controls, searchable merge targets with movement previews, split controls,
|
|
287
|
+
and the source surfaces and workflows beside the resulting catalog entry.
|
|
288
|
+
- **Surfaces and workflows**: each item with its route, sources, and the
|
|
289
|
+
assessment's proposal; map it to use cases, exclude it with a required
|
|
290
|
+
rationale, or leave it unresolved.
|
|
291
|
+
- **Catalog preview**: the exact unified diff against the active catalog, the
|
|
292
|
+
full generated catalog, entries that cannot be included yet and why, and the
|
|
293
|
+
adoption steps.
|
|
294
|
+
|
|
295
|
+
A mapped navigation surface becomes a `starts` entry of its use cases,
|
|
296
|
+
including use cases already in the active catalog. Manual direct-route and
|
|
297
|
+
assistant bindings remain supported. A direct route describes a route entry
|
|
298
|
+
without claiming a navigation mapping; a mapped surface explicitly classified
|
|
299
|
+
as `hidden` therefore derives a direct route rather than a navigation id. A
|
|
300
|
+
merged proposal contributes its entry points,
|
|
301
|
+
requirements, and gaps to its target. A use case with no manual or derived
|
|
302
|
+
entry point stays in the catalog while its implementation coverage is shown as
|
|
303
|
+
unknown. Rejecting or splitting a proposal leaves anything mapped to it
|
|
304
|
+
unresolved until it is remapped. An exclusion without a rationale counts as
|
|
305
|
+
unresolved.
|
|
306
|
+
|
|
307
|
+
Editing an undecided candidate stores `fields` on an `action: "pending"`
|
|
308
|
+
decision. Saving preserves those edits without accepting them. A complete
|
|
309
|
+
source proposal offers one **Approve this use case** choice, which accepts the
|
|
310
|
+
complete definition currently shown. The existing **Reset to assessment
|
|
311
|
+
proposal** control restores the source definition; the same approval choice
|
|
312
|
+
then accepts that definition. Internally unchanged content remains the
|
|
313
|
+
compatible `action: "approve"` representation and changed content remains
|
|
314
|
+
`action: "revise"`. Editing or resetting an already approved complete
|
|
315
|
+
definition automatically switches between those representations while keeping
|
|
316
|
+
the reviewer’s approval choice. Existing saved reviews using either action
|
|
317
|
+
continue to load. An incomplete source draft retains its distinct **Accept
|
|
318
|
+
completed use case** action once all required fields are present. Stale or
|
|
319
|
+
hand-authored approval choices for incomplete definitions are rejected by the
|
|
320
|
+
local API.
|
|
321
|
+
|
|
322
|
+
Merge does not choose a target automatically. Its picker lists active and
|
|
323
|
+
reviewed targets, shows complete undecided proposals as unavailable until they
|
|
324
|
+
are accepted, excludes self/rejected/incomplete targets, and displays title,
|
|
325
|
+
id, status, goal or outcome, mapping counts, entry points, and a preview of
|
|
326
|
+
mappings, bindings, requirements, gaps, duplicates, and conflicts.
|
|
327
|
+
|
|
328
|
+
## Safety model
|
|
329
|
+
|
|
330
|
+
- **Distinct artifacts.** The candidate, the review decisions, the preview,
|
|
331
|
+
and the active catalog are separate files. Only `review adopt` writes the
|
|
332
|
+
active catalog. The candidate and review always record
|
|
333
|
+
`"status": "unapproved"`, and a file claiming approval is rejected.
|
|
334
|
+
- **Stale detection.** The review records the candidate's SHA-256, so a review
|
|
335
|
+
saved against another candidate is refused rather than reapplied. If an
|
|
336
|
+
assessed file changes, disappears, or the repository's root commits differ,
|
|
337
|
+
the candidate is stale: the app keeps working, but adoption is blocked until
|
|
338
|
+
a fresh candidate is prepared. New commits that leave every assessed file
|
|
339
|
+
unchanged are reported but do not block.
|
|
340
|
+
- **Writes.** All paths are repository-relative and refuse traversal, symbolic
|
|
341
|
+
links, and policy destinations. New files are created atomically without
|
|
342
|
+
overwriting. A save replaces the review only when its revision and hash
|
|
343
|
+
still match, so a concurrent save is reported instead of lost; a preview
|
|
344
|
+
that ux-guard did not generate is never overwritten.
|
|
345
|
+
- **Trusted policy.** The candidate can propose catalog entries only. It
|
|
346
|
+
cannot change configuration, inventory, baselines, targets, waivers, or
|
|
347
|
+
enforcement, and generated entries pass the same catalog validation as
|
|
348
|
+
`ux-guard check`. Comments in an existing catalog are not preserved by
|
|
349
|
+
adoption; the diff shows every removed line.
|
|
350
|
+
- **Local only.** The server binds to `127.0.0.1` on an ephemeral port and
|
|
351
|
+
serves only its bundled page, script, and stylesheet. Every API request
|
|
352
|
+
needs the per-session token from the printed link, a loopback `Host`
|
|
353
|
+
header, and a same-origin JSON request. Responses forbid framing, caching,
|
|
354
|
+
sniffing, and external resources. There is no telemetry and no external
|
|
355
|
+
asset. Choose **Close review** or press Ctrl+C to stop the server.
|
|
356
|
+
|
|
357
|
+
Design decisions, schema boundaries, and accepted limits are recorded in
|
|
358
|
+
[use-case review design](use-case-review-design.md).
|
|
359
|
+
|
|
360
|
+
## Accessibility
|
|
361
|
+
|
|
362
|
+
The app uses native controls with visible labels, a skip link, landmark
|
|
363
|
+
regions, the tab pattern with arrow, Home, and End keys, arrow-key navigation
|
|
364
|
+
in lists, visible focus, polite live status for every change and save, a
|
|
365
|
+
focusable save confirmation, an alert region for errors, and text labels on
|
|
366
|
+
every status color. Dirty state is prominent, browser unload and Close warn
|
|
367
|
+
before discarding edits, and the clean Save button stays disabled. It follows
|
|
368
|
+
the system dark-mode and reduced-motion preferences. Ctrl+S or Cmd+S saves.
|
package/lib/catalog.mjs
CHANGED
|
@@ -4,8 +4,8 @@ import { ConfigError, parseYamlSubset } from './yaml.mjs';
|
|
|
4
4
|
|
|
5
5
|
const TIERS = new Set(['primary', 'secondary', 'tertiary']);
|
|
6
6
|
const EFFECTS = new Set(['read', 'create', 'change']);
|
|
7
|
-
const REQUIRED = ['id', 'title', 'persona', 'tier', 'effect', '
|
|
8
|
-
const TEXT_FIELDS = ['title', 'persona', '
|
|
7
|
+
const REQUIRED = ['id', 'title', 'persona', 'tier', 'effect', 'goal', 'success'];
|
|
8
|
+
const TEXT_FIELDS = ['title', 'persona', 'goal', 'success'];
|
|
9
9
|
|
|
10
10
|
// Object literals that declare a string `id` and an absolute string `route`
|
|
11
11
|
// are navigation surfaces.
|
|
@@ -110,10 +110,16 @@ export function validateCatalog(catalog, surfaces) {
|
|
|
110
110
|
throw new ConfigError(`${useCase.id}: ${field} must be text`);
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
// `owner` is accepted as deprecated catalog metadata so existing catalogs
|
|
114
|
+
// remain readable, but governance provenance is not definition validity.
|
|
115
|
+
if (useCase.owner !== undefined && (typeof useCase.owner !== 'string' || !useCase.owner.trim())) {
|
|
116
|
+
throw new ConfigError(`${useCase.id}: owner must be text when present`);
|
|
115
117
|
}
|
|
116
|
-
|
|
118
|
+
const starts = useCase.starts ?? [];
|
|
119
|
+
if (!Array.isArray(starts)) {
|
|
120
|
+
throw new ConfigError(`${useCase.id}: starts must be a list when present`);
|
|
121
|
+
}
|
|
122
|
+
for (const start of starts) {
|
|
117
123
|
for (const id of checkStart(useCase.id, start, byId)) covered.add(id);
|
|
118
124
|
}
|
|
119
125
|
for (const field of ['requirements', 'gaps']) {
|
|
@@ -129,6 +135,7 @@ export function validateCatalog(catalog, surfaces) {
|
|
|
129
135
|
useCases: cases,
|
|
130
136
|
surfaces,
|
|
131
137
|
unmapped: surfaces.filter((surface) => !covered.has(surface.id)),
|
|
138
|
+
unbound: cases.filter((useCase) => !Array.isArray(useCase.starts) || useCase.starts.length === 0),
|
|
132
139
|
};
|
|
133
140
|
}
|
|
134
141
|
|
|
@@ -143,6 +150,20 @@ function checkStart(caseId, start, byId) {
|
|
|
143
150
|
}
|
|
144
151
|
return [];
|
|
145
152
|
}
|
|
153
|
+
if (start.entry === 'route') {
|
|
154
|
+
if (!sameKeys(start, ['entry', 'route'])) {
|
|
155
|
+
throw new ConfigError(`${caseId}: a direct-route start has entry and route only`);
|
|
156
|
+
}
|
|
157
|
+
if (!isCanonicalDirectRoute(start.route)) {
|
|
158
|
+
throw new ConfigError(`${caseId}: a direct-route start needs a canonical absolute route`);
|
|
159
|
+
}
|
|
160
|
+
// A direct route is an implementation entry point, not evidence that a
|
|
161
|
+
// configured navigation surface is covered.
|
|
162
|
+
return [];
|
|
163
|
+
}
|
|
164
|
+
if (start.entry !== undefined) {
|
|
165
|
+
throw new ConfigError(`${caseId}: start entry must be assistant or route`);
|
|
166
|
+
}
|
|
146
167
|
if (!sameKeys(start, ['nav_id', 'route'])) {
|
|
147
168
|
throw new ConfigError(`${caseId}: a navigation start has nav_id and route only`);
|
|
148
169
|
}
|
|
@@ -158,6 +179,22 @@ function checkStart(caseId, start, byId) {
|
|
|
158
179
|
return [start.nav_id];
|
|
159
180
|
}
|
|
160
181
|
|
|
182
|
+
export function isCanonicalDirectRoute(value) {
|
|
183
|
+
if (
|
|
184
|
+
typeof value !== 'string' ||
|
|
185
|
+
value !== value.trim() ||
|
|
186
|
+
!value.startsWith('/') ||
|
|
187
|
+
value.startsWith('//') ||
|
|
188
|
+
value.includes('//') ||
|
|
189
|
+
/[\s\\?#]/.test(value) ||
|
|
190
|
+
/%(?:2e|2f|5c)/i.test(value)
|
|
191
|
+
) {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
if (value !== '/' && value.endsWith('/')) return false;
|
|
195
|
+
return value.split('/').every((segment) => segment !== '.' && segment !== '..');
|
|
196
|
+
}
|
|
197
|
+
|
|
161
198
|
function sameKeys(value, keys) {
|
|
162
199
|
const actual = Object.keys(value).sort();
|
|
163
200
|
return actual.length === keys.length && [...keys].sort().every((key, index) => key === actual[index]);
|
|
@@ -181,13 +218,15 @@ export function renderCatalog(report) {
|
|
|
181
218
|
`Use-case catalog: ${report.inventory}, ${report.useCases.length} recorded`,
|
|
182
219
|
`Navigation surfaces: ${report.surfaces.length}`,
|
|
183
220
|
`Unmapped surfaces: ${report.unmapped.length}`,
|
|
221
|
+
`Use cases without entry points: ${report.unbound.length}`,
|
|
184
222
|
];
|
|
185
223
|
if (report.inventory === 'partial') {
|
|
186
|
-
lines.push('Unmapped surfaces are expected until the
|
|
224
|
+
lines.push('Unmapped surfaces are expected until the inventory is finished.');
|
|
187
225
|
}
|
|
188
226
|
lines.push('', 'Recorded:');
|
|
189
227
|
for (const useCase of report.useCases) {
|
|
190
|
-
|
|
228
|
+
const binding = Array.isArray(useCase.starts) && useCase.starts.length ? '' : ', entry points unknown';
|
|
229
|
+
lines.push(` - ${useCase.id}: ${useCase.title} (${useCase.tier}, ${useCase.effect}${binding})`);
|
|
191
230
|
}
|
|
192
231
|
lines.push('', 'Unmapped:');
|
|
193
232
|
for (const surface of report.unmapped) {
|