Skip to content

Commit 11713ed

Browse files
feat: add error taxonomy and UI state contract (issue #12)
* docs: define error taxonomy and ui state contract (issue #12) * test: add coverage for error taxonomy and ui state contract * feat: add error taxonomy and ui state contract schema * feat: add canonical error taxonomy and ui state mapping spec
1 parent 49545c8 commit 11713ed

File tree

4 files changed

+935
-0
lines changed

4 files changed

+935
-0
lines changed

docs/spec/error-ui-contract.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Error Taxonomy and UI State Contract v1
2+
3+
This document defines the canonical error taxonomy and deterministic UI state mappings for issue `#12`.
4+
5+
## Error Categories
6+
7+
MVP supports exactly six categories:
8+
9+
1. `parse`
10+
2. `permission`
11+
3. `validation`
12+
4. `conflict`
13+
5. `io`
14+
6. `unknown`
15+
16+
Each category includes:
17+
18+
- `canonicalCode`: stable machine-readable error code
19+
- `messagePattern`: user-visible template with placeholders
20+
- `suggestedActions`: one or more concrete next actions
21+
- `nonActionable`: must be `false` for MVP
22+
23+
## Generic Error Policy
24+
25+
- Generic phrases like `something went wrong` are disallowed.
26+
- Unknown failures are normalized through the fallback policy:
27+
- category: `unknown`
28+
- code: `AM_UNKNOWN_999`
29+
- message template with explicit operation/resource context
30+
- actionable fallback suggestions
31+
32+
## UI States
33+
34+
The UI contract freezes these states:
35+
36+
- `idle`
37+
- `loading`
38+
- `success_full`
39+
- `success_empty`
40+
- `success_partial`
41+
- `error`
42+
43+
Each state has explicit rendering flags (`showSpinner`, `showData`, `showEmptyHint`, `showWarningBanner`, `showErrorBanner`, `allowRetry`) to keep behavior deterministic.
44+
45+
## Flow Contracts
46+
47+
Three flow contracts are defined:
48+
49+
1. `detection`
50+
2. `read`
51+
3. `write`
52+
53+
All flows specify:
54+
55+
- single initial state
56+
- terminal states
57+
- transition table (`from` + `event` -> `to`)
58+
- `outcomeToState` mapping for loading/empty/partial/full/error outcomes
59+
- `errorCategoryToState` mapping for all six categories
60+
61+
## Files
62+
63+
- Schema:
64+
- `schemas/error-ui-contract.schema.json`
65+
- Canonical sample:
66+
- `docs/spec/error-ui-contract.v1.json`
67+
- Unit tests:
68+
- `tests/error-ui-contract.test.mjs`

0 commit comments

Comments
 (0)