archik 0.12.12 → 0.12.14

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.
@@ -29,15 +29,45 @@ done at step 1 — the diagram changed; the code probably hasn't.
29
29
  non-code-bearing kind, description-only edit, pure metadata),
30
30
  skip steps 3–6 and jump straight to step 7.
31
31
 
32
- 3. **BUILD — plan (HITL).** Translate the diagram delta into a
33
- numbered file-level plan and present it for approval **before**
34
- touching code:
32
+ 3. **BUILD — behavioral model first, then plan (HITL).**
33
+
34
+ **Before writing the plan**, check whether any new or modified
35
+ slice has behavior that warrants a seq diagram. A slice needs
36
+ one when it involves branching, async fan-out, cross-context
37
+ interaction, or three or more nodes in a single user-visible
38
+ action. Run:
39
+ ```
40
+ npx archik q usecases
41
+ ```
42
+ For each active slice without a `realization.seqFile` that meets
43
+ the above criteria:
44
+ - Author the `.archik.seq.yaml` now (direct-write), including a
45
+ `realizes: { useCase, slice }` block.
46
+ - Run `npx archik validate` — catches ECB violations, broken
47
+ `nodeId` refs, and duplicate step ids.
48
+ - Show the seq YAML inline and wait for confirmation before
49
+ writing the plan.
50
+
51
+ A slice without a seq diagram has no traceable spec — the build
52
+ plan for it is guesswork. Author the seq first; trace it in the
53
+ plan. If the slice is genuinely simple (single node, no
54
+ branching), skip the seq and note why.
55
+
56
+ **Then** translate the diagram delta into a numbered file-level
57
+ plan and present it for approval **before** touching code:
35
58
  - Each new code-bearing node (`service`, `function`, `worker`,
36
59
  `module`, `page`, `component`, `store`, `hook`) → its
37
60
  `sourcePath` and the concrete files / signatures to land there.
38
61
  - Each new edge that requires code → the corresponding code
39
62
  change (a new `http_call` needs a client; `subscribes` needs a
40
63
  consumer handler; `writes` needs a repository method; etc).
64
+ - Each seq diagram that realizes a slice → trace it: every
65
+ message in the seq must map to a concrete function call in this
66
+ plan. This is the traceability requirement — the seq is the
67
+ spec, the plan is the contract, the code is the proof.
68
+ - Each slice's `tests` paths → include scaffolding those test
69
+ files in the plan; they must exist on disk before the slice
70
+ can be marked active.
41
71
  - Any node still `status: proposed` → flag it; code must land
42
72
  before flipping to `active`.
43
73
  - Default to **tests-first** when behaviour is clearly bounded.
@@ -72,6 +102,18 @@ done at step 1 — the diagram changed; the code probably hasn't.
72
102
  npx archik validate
73
103
  ```
74
104
  Plus the project's tests / typecheck / lint.
105
+ ```
106
+ npx archik drift
107
+ ```
108
+ Catches both missing `sourcePath` directories and missing slice
109
+ test files on disk.
110
+ If the project has use cases, run the coverage matrix:
111
+ ```
112
+ npx archik trace
113
+ ```
114
+ No active slice should be untraced at ship time. Partial is a
115
+ warning; untraced is a gap — add the missing test path or
116
+ realization seq before declaring the milestone done.
75
117
  `superpowers:verification-before-completion` when available.
76
118
  If `docs/architecture.svg` is committed, regenerate it:
77
119
  ```
@@ -85,3 +127,12 @@ done at step 1 — the diagram changed; the code probably hasn't.
85
127
  - *"Want me to schedule a drift check in two weeks?"*
86
128
  - *"This left `payments-worker` as `status: proposed` — flip it
87
129
  to `active` once deployed."*
130
+ - If this milestone completed a significant chunk of work, check
131
+ whether any alpha state can be promoted:
132
+ ```
133
+ npx archik alpha show
134
+ ```
135
+ If a state is verified and the next rung's criteria are met,
136
+ offer to promote: *"Requirements is at `acceptable` and all
137
+ active slices now have tests — want me to promote it to
138
+ `addressed`?"*
@@ -45,6 +45,27 @@ any file under `.archik/`.
45
45
  — there's nothing meaningful to evolve. Suggest `/archik:spawn`
46
46
  first.
47
47
 
48
+ Also check the Jacobson-chain artifacts so you can surface
49
+ ECB and coverage smells alongside structural ones:
50
+ ```
51
+ npx archik q actors
52
+ npx archik q usecases
53
+ npx archik trace --json
54
+ ```
55
+ (These are non-fatal if no UC/actor files exist — note that
56
+ and skip the UC smells below; focus on structural smells only.)
57
+
58
+ **Identify nodes at risk of seq breakage.** As you read the
59
+ node list, mentally note which nodes you're likely to remove,
60
+ split, or merge. For each such node, run:
61
+ ```
62
+ npx archik q sequences --node <id>
63
+ ```
64
+ This returns the seq files whose participants reference that
65
+ node ID. Collect these — you'll need the list in step 6 to
66
+ warn the user. If the list is empty for all affected nodes,
67
+ no seq diagrams are at risk.
68
+
48
69
  3. **Identify smells and missing structure.** Don't propose change
49
70
  for change's sake — every modification should fix one of:
50
71
 
@@ -68,6 +89,26 @@ any file under `.archik/`.
68
89
  - **Anaemic queues.** Two services connected by `http_call`
69
90
  for what's clearly an async fire-and-forget → introduce a
70
91
  `queue` or `topic` and rewire to `publishes` / `subscribes`.
92
+ - **Missing ECB stereotypes.** Only applies when actor/UC files
93
+ exist (`npx archik q usecases` returns results). Nodes that
94
+ appear in active UC slices (visible in `archik trace` output),
95
+ or that have user-facing relationships (`http_call` from a
96
+ gateway, `writes`/`reads` to a domain DB) but no `stereotype`
97
+ field → classify each as `boundary`, `control`, or `entity`.
98
+ This is a prerequisite for ECB validation on seq diagrams.
99
+ Evolve may **add** a stereotype to nodes spawn left blank, but
100
+ only when this smell is triggered. Never invent stereotypes on
101
+ a pure structural diagram with no UC files.
102
+ - **UC coverage gaps.** Only applies when UC files exist and
103
+ `archik trace --json` returns rows. Active slices that are
104
+ `partial` (tests exist but no seq realization) usually signal
105
+ a missing seq diagram or a missing port/adapter in the
106
+ structural model. Active slices that are `none` (no tests, no
107
+ realization) signal untested behaviour — propose a test
108
+ scaffold or a seq diagram, and flag any architectural gap that
109
+ makes the slice hard to realize (e.g. missing adapter for an
110
+ external call). If trace output is empty or all slices are
111
+ `full`, skip this smell.
71
112
 
72
113
  Aim for 3–8 changes — enough to be meaningful, few enough that
73
114
  the user can reason about each. If you'd need more, propose
@@ -102,8 +143,9 @@ any file under `.archik/`.
102
143
  - Preserve every existing node id you keep — only add or remove
103
144
  ids, never rename. Renames break diff and require the user to
104
145
  manually re-link references in code.
105
- - Don't drop `description`, `responsibilities`, `notes`, or
106
- `sourcePath` fields the user authored. Carry them over verbatim.
146
+ - Don't drop `description`, `responsibilities`, `notes`,
147
+ `sourcePath`, or `stereotype` fields the user authored. Carry
148
+ them over verbatim.
107
149
  - Every new code-bearing node (`service`, `function`, `worker`,
108
150
  `module`, `page`, `component`, `store`, `hook`) needs a
109
151
  `sourcePath:` that exists on disk — the validator rejects
@@ -117,6 +159,9 @@ any file under `.archik/`.
117
159
  until the code lands.
118
160
  - Every node MUST have a non-empty `description` explaining
119
161
  what it does. Don't introduce a node without one.
162
+ - When adding a `stereotype` to address the ECB smell, use only
163
+ `boundary`, `control`, or `entity`. Don't add `stereotype` to
164
+ purely infra nodes (`database`, `queue`, `external`, `cloud`).
120
165
  - Every change should be motivated by step 3, not by aesthetics.
121
166
 
122
167
  If `suggest set` reports validation errors, re-run with the
@@ -130,7 +175,13 @@ any file under `.archik/`.
130
175
  grouped by motivation (e.g. *"1. Extract a `payments`
131
176
  bounded context from `orders`. Why: payment logic was leaking
132
177
  into order placement…"*). Keep each item to 2–3 sentences.
133
- c. An explicit invitation: *"Tell me what you'd like to keep,
178
+ c. **Seq diagram impact warning** — if any seq file discovered
179
+ in step 2 references a node that this proposal removes or
180
+ renames, list them explicitly:
181
+ *"⚠️ These seq diagrams reference nodes this refactor
182
+ changes — they will need updating after accept: `<list>`."*
183
+ If no seq files are affected, skip this bullet.
184
+ d. An explicit invitation: *"Tell me what you'd like to keep,
134
185
  drop, or rework before you accept. I can re-stage with
135
186
  changes — `/archik:accept` is whenever you're ready."*
136
187
 
@@ -87,11 +87,29 @@ archik suggest set` stages it.
87
87
  - **Frontends**: `apps/web`, `apps/mobile`, `client/`,
88
88
  `packages/ui` apps that ship a UI → `frontend`.
89
89
 
90
- 5. **Choose the kind for each node.** Default: `service`. Use the
91
- taxonomy from the skill — `function` for serverless, `worker`
92
- for background consumers, `agent` for LLM-driven agents, etc.
93
- When unsure, pick the closest fit and add a `notes:` entry
94
- explaining the inference rather than picking `custom`.
90
+ 5. **Choose the kind and ECB stereotype for each node.** Default
91
+ kind: `service`. Use the taxonomy from the skill — `function`
92
+ for serverless, `worker` for background consumers, `agent` for
93
+ LLM-driven agents, etc. When unsure, pick the closest fit and
94
+ add a `notes:` entry explaining the inference.
95
+
96
+ For every node that faces a user or external system, also infer
97
+ its ECB `stereotype`:
98
+ - `stereotype: boundary` — accepts requests from actors / external
99
+ systems: API handlers, gateways, adapters, webhook endpoints,
100
+ BFF layers. Rule of thumb: the first thing an actor touches.
101
+ - `stereotype: control` — orchestrates use-case logic: services
102
+ that coordinate domain objects, use-case handlers, workflow
103
+ engines. Rule of thumb: knows *what* to do but delegates *how*.
104
+ - `stereotype: entity` — stores or represents domain data:
105
+ repositories, domain models, DB-backed modules, caches.
106
+ Rule of thumb: knows the data and its invariants.
107
+
108
+ If a node's role is purely infrastructure (`database`, `queue`,
109
+ `external`, `cloud`, etc.) or genuinely ambiguous, omit
110
+ `stereotype` — don't guess. The field is optional and the
111
+ validator only enforces ECB transition rules on seq diagrams
112
+ that carry a `realizes` block.
95
113
 
96
114
  6. **Attach `sourcePath` to every code-bearing node.** This is
97
115
  non-negotiable in a normal/suggested file — the validator rejects
@@ -205,6 +223,28 @@ archik suggest set` stages it.
205
223
  `/archik:evolve` after accepting if you want a cleaner
206
224
  bounded-context version."
207
225
 
226
+ **Offer the Jacobson-chain follow-up at the end of this step**
227
+ (not after accept — you won't be there). Check what's missing
228
+ before framing the offer:
229
+ ```
230
+ npx archik q actors
231
+ npx archik q usecases
232
+ ```
233
+ Then close with one of these follow-up lines, whichever fits:
234
+ - No actors, diagram has boundary nodes / user-facing components:
235
+ *"Once you accept, ask me to author a `*.archik.actors.yaml`
236
+ — that's the starting point for use-case coverage."*
237
+ - Actors exist but no use cases:
238
+ *"Once you accept, ask me to stub `*.archik.uc.yaml` files for
239
+ the key flows."*
240
+ - Both exist already:
241
+ *"Run `/archik:evolve` after accepting for ECB and coverage
242
+ gap suggestions."*
243
+
244
+ Do NOT author actors or use cases here — that requires the
245
+ structural diagram to be accepted first and is a separate ask
246
+ from the user. This note is a prompt, not an action.
247
+
208
248
  ## Notes
209
249
 
210
250
  - Spawn is descriptive, not prescriptive. Don't reorganize, split,
@@ -37,6 +37,10 @@ start Build phase here; that's gated on accept.
37
37
  0. **Frame + clarify (entering DESIGN).** Before any CLI call, restate
38
38
  the user's intent in one sentence and list 1–3 sharp clarifying
39
39
  questions if any of these are ambiguous in `$ARGUMENTS`:
40
+ - **Actor + use case** — which actor initiates this? Does an
41
+ existing use case cover it, or is this a new user-visible
42
+ behaviour? (Check `npx archik q actors` and `q usecases` in
43
+ step 2 before asking if the answer isn't obvious from the brief.)
40
44
  - **Boundary** — which existing context owns this, or is it a new
41
45
  one? (data ownership = bounded context)
42
46
  - **Sync vs async** — request/response (`http_call`) or
@@ -53,6 +57,15 @@ start Build phase here; that's gated on accept.
53
57
  don't ask questions for the sake of asking.** When in doubt, ask
54
58
  the user "you decide?" so they can defer back if they want.
55
59
 
60
+ **Before the structural sidecar, check if the feature needs
61
+ requirements artifacts first:**
62
+ - New human-facing flow or actor? Create/update
63
+ `*.archik.actors.yaml` (direct-write) before staging the sidecar.
64
+ - New user-visible behaviour? Author a `*.archik.uc.yaml` under
65
+ `.archik/usecases/` (direct-write) with the flow and at least one
66
+ slice before staging the sidecar. The structural model references
67
+ what the use case requires.
68
+
56
69
  1. **Make sure the canvas is running** so the user can review:
57
70
  ```
58
71
  npx archik status
@@ -63,7 +76,7 @@ start Build phase here; that's gated on accept.
63
76
  ```
64
77
  Note the URL it prints — you'll surface it at the end.
65
78
 
66
- 2. **Ground yourself in the current diagram** using the query CLI
79
+ 2. **Ground yourself in the current models** using the query CLI
67
80
  (do not `cat` the YAML):
68
81
  ```
69
82
  npx archik q stats
@@ -72,6 +85,23 @@ start Build phase here; that's gated on accept.
72
85
  If `$ARGUMENTS` mentions a specific node by name, also run
73
86
  `npx archik q describe <id>` for it.
74
87
 
88
+ If the change is **non-trivial** (new actor, new user-visible
89
+ behaviour, boundary impact, more than one node affected) also
90
+ ground in the requirements model:
91
+ ```
92
+ npx archik q actors
93
+ npx archik q usecases
94
+ ```
95
+ If any use case looks related, run
96
+ `npx archik q describe-usecase <id>` to see its slices and
97
+ check whether the proposed change extends, modifies, or
98
+ introduces a UC — that determines whether you need to update
99
+ a `*.archik.uc.yaml` before staging the structural sidecar.
100
+
101
+ If step 0 already determined the change is trivially small
102
+ (one node, one edge, no boundary or UC impact), skip the
103
+ actor/UC queries and go straight to step 3.
104
+
75
105
  3. **Lock in the schema.** Run this before drafting any YAML —
76
106
  the prose in this file describes the workflow, not the field
77
107
  shapes. The CLI is the schema:
@@ -104,6 +134,18 @@ start Build phase here; that's gated on accept.
104
134
  not just its kind or name. Empty / missing descriptions are
105
135
  rejected by the validator.
106
136
 
137
+ **For nodes that participate in a use case flow**, add a
138
+ `stereotype` field to classify their role in the ECB model:
139
+ - `stereotype: boundary` — accepts requests from actors / external
140
+ systems (adapters, gateways, API handlers)
141
+ - `stereotype: control` — orchestrates the use case logic (services,
142
+ use-case handlers, orchestrators)
143
+ - `stereotype: entity` — stores or represents domain data (repos,
144
+ domain models, DB-backed modules)
145
+
146
+ The validator enforces ECB transition rules on seq diagrams that
147
+ carry a `realizes` block — tag the nodes now so the rules can fire.
148
+
107
149
  ```bash
108
150
  npx archik suggest set --note "$ARGUMENTS" - <<'YAML'
109
151
  version: "1.0"
@@ -39,6 +39,12 @@ These are the verbs you reach for during the loop. Default to `npx archik` (no g
39
39
  | Inspect the current diagram | `npx archik q list \| edges \| stats` |
40
40
  | Look up one node | `npx archik q describe <id>` |
41
41
  | Find dependencies / impact | `npx archik q deps \| dependents \| impact <id>` |
42
+ | List use cases (filter by actor) | `npx archik q usecases [--actor <id>]` |
43
+ | Describe one use case | `npx archik q describe-usecase <id>` |
44
+ | List actors | `npx archik q actors` |
45
+ | Use case coverage matrix | `npx archik trace [--json] [--fail-on partial\|none]` |
46
+ | Alpha state snapshot | `npx archik alpha show [--json]` |
47
+ | Promote / demote an alpha state | `npx archik alpha promote\|demote <alpha> <state>` |
42
48
  | Validate a file | `npx archik validate <path>` |
43
49
  | Stage a proposed change | `npx archik suggest set --note '…' - <<'YAML' … YAML` |
44
50
  | Show / accept / reject pending | `npx archik suggest show \| accept \| reject` |
@@ -55,7 +61,11 @@ You MUST NOT use `Read`, `Write`, or `Edit` against any file under `.archik/`, a
55
61
 
56
62
  If `npx archik` is unreachable (offline, sandboxed, missing), STOP and tell the user. Do NOT fall back to reading or editing YAML by hand.
57
63
 
58
- **Exception:** sequence diagrams (`*.archik.seq.yaml`) have **no sidecar workflow** — create or edit them directly with `Write` / `Edit`, then validate via `npx archik validate`. See "Sequence diagrams" below.
64
+ **Exception:** four file types have **no sidecar workflow** — create or edit them directly with `Write` / `Edit`, then validate via `npx archik validate`:
65
+ - `*.archik.seq.yaml` — sequence diagrams (see "Sequence diagrams" below)
66
+ - `*.archik.actors.yaml` — actor definitions (see "Actors" below)
67
+ - `*.archik.uc.yaml` — use cases (see "Use cases and slices" below)
68
+ - `*.archik.alphas.yaml` — Essence alpha snapshot (see "Alpha state" below)
59
69
 
60
70
  ## The engineering loop (how archik fits into delivering work)
61
71
 
@@ -88,11 +98,11 @@ Every structural change runs the loop. Don't skip phases; don't silently retry o
88
98
 
89
99
  | Phase | Driver | Tool you reach for |
90
100
  | -------- | ------------- | --------------------------------------------------- |
91
- | Discover | Claude | `npx archik q ...` + source-tree `ls` |
92
- | Design | Claude → User | sidecar via `suggest set`, after 1–3 clarifying Qs |
101
+ | Discover | Claude | `npx archik q ...` + `q usecases` + `q actors` + `ls` |
102
+ | Design | Claude → User | actors / uc files (direct-write) + sidecar via `suggest set` |
93
103
  | Decide | User | `/archik:accept` or `/archik:reject` (HITL gate) |
94
104
  | Build | Claude → User | numbered plan (HITL approval), then small commits |
95
- | Verify | Claude | `npx archik validate` + tests + `drift` + SVG regen |
105
+ | Verify | Claude | `npx archik validate` + `archik trace` + tests + `drift` + SVG regen |
96
106
 
97
107
  **Two non-obvious feedback edges:**
98
108
 
@@ -247,6 +257,9 @@ The seq schema (UML subset) is documented at the bottom of this file under "Sequ
247
257
  | `*.archik.yaml` | **normal** | The canonical architecture of code that exists. |
248
258
  | `*.archik.suggested.yaml` | **suggested** | A pending change to a normal file. Owned by `suggest set`. Becomes normal on accept. |
249
259
  | `*.archik.seq.yaml` | **sequence** | A runtime flow diagram. Direct-write. No sidecar. |
260
+ | `*.archik.actors.yaml` | **actors** | Who acts on the system (human / external-system / time / device). Direct-write. |
261
+ | `*.archik.uc.yaml` | **use case** | One use case: flows + slices + test paths. Lives under `.archik/usecases/`. Direct-write. |
262
+ | `*.archik.alphas.yaml` | **alphas** | Project-wide Essence alpha state snapshot. Direct-write. |
250
263
 
251
264
  There is no separate "discussion" file mode. Greenfield / exploratory work is expressed via `status: proposed` on the affected nodes and edges (see Lifecycle below). The diagram stays canonical.
252
265
 
@@ -286,6 +299,18 @@ Both **nodes and edges** carry an optional `status`. Same enum, same defaults, s
286
299
 
287
300
  For edges, `status: proposed` expresses "this dependency is planned" (e.g. *"orders-api will start subscribing to `payments.completed` next sprint"*). `archik drift` and the validator both respect lifecycle so proposed nodes don't trigger missing-source warnings before they're built.
288
301
 
302
+ ### Node stereotype — ECB classification
303
+
304
+ Nodes that participate in a use case flow may carry an optional `stereotype` field:
305
+
306
+ ```yaml
307
+ stereotype: boundary # accepts requests from actors / external systems
308
+ stereotype: control # orchestrates; implements the use case logic
309
+ stereotype: entity # stores data; domain model
310
+ ```
311
+
312
+ The validator enforces the ECB transition rules on **seq diagrams that carry a `realizes` block**: actors call boundaries, boundaries call controls, controls call entities or other controls. Direct actor→entity or entity→boundary messages are errors. Untagged nodes are silently skipped so adoption is incremental.
313
+
289
314
  ### Other rules worth pre-empting
290
315
 
291
316
  - **No duplicate edges by `(from, to, relationship)`.** The validator rejects the second occurrence and points at the first by id. If you genuinely need two concerns between the same pair (e.g. `service → db` for both `reads` and `writes`), use distinct relationships.
@@ -306,6 +331,7 @@ Run a candidate through this checklist before staging a sidecar. Each item is a
306
331
  - **Ports & adapters at the edge.** External integrations sit behind an `external` node, never inline in a service. Port (interface) + adapter (concrete) is preferred when the integration could swap.
307
332
  - **Public traffic → gateway/auth upstream.** Anything user-facing routes through a `gateway`/`auth` node, not directly to a service.
308
333
  - **Failure modes.** Async producers imply DLQ/retry on the consumer; `http_call` implies timeout + circuit. Don't draw the happy path alone.
334
+ - **Use case participation → ECB classification.** If a node appears in any active use case slice (check `npx archik q usecases` or trace output), it needs a `stereotype: boundary | control | entity` before the seq diagram is authored. An unclassified node in a `realizes`-linked seq passes structurally but defeats ECB rule enforcement. Classify now; the validator will catch violations at seq-authoring time, not at code-review time.
309
335
  - **Lifecycle honesty.** Code-bearing node without code on disk → `status: proposed`. About to be removed → `status: deprecated`.
310
336
 
311
337
  ## When to propose, when to defer
@@ -360,6 +386,97 @@ The loop is self-contained, but these sharpen specific phases when the user has
360
386
  | | `superpowers:requesting-code-review` |
361
387
  | Verify | `superpowers:verification-before-completion` |
362
388
 
389
+ ## Actors
390
+
391
+ Actors live in `.archik/actors.archik.actors.yaml` (one file per project). Direct-write — no sidecar. Schema: `npx archik schema actors`.
392
+
393
+ ```yaml
394
+ version: "1.0"
395
+ actors:
396
+ - id: customer
397
+ kind: human # human | external-system | time | device
398
+ description: End-user buying products.
399
+ goals: [place-orders, view-history] # optional free text
400
+ - id: payments-gw
401
+ kind: external-system
402
+ description: Stripe — charges cards and issues refunds.
403
+ ```
404
+
405
+ Use cases reference actors by `id`. The validator rejects a use case whose `primaryActor` isn't in the actor index.
406
+
407
+ ## Use cases and slices
408
+
409
+ One file per use case under `.archik/usecases/<id>.archik.uc.yaml`. Direct-write — no sidecar. Schema: `npx archik schema uc`.
410
+
411
+ ```yaml
412
+ version: "1.0"
413
+ id: place-order
414
+ kind: useCase
415
+ name: Place an order
416
+ status: active
417
+ primaryActor: customer
418
+ secondaryActors: [payments-gw]
419
+ goal: Customer pays for items in cart and receives confirmation.
420
+ flows:
421
+ basic:
422
+ steps:
423
+ - Customer submits cart.
424
+ - System reserves inventory.
425
+ - System charges payment method.
426
+ - System persists order and emits OrderPlaced.
427
+ alternates:
428
+ - id: payment-declined
429
+ branchFrom: basic.3
430
+ steps: [Payment gateway returns decline, System releases inventory.]
431
+ slices:
432
+ - id: happy-path
433
+ description: Full successful purchase.
434
+ flows: [basic]
435
+ tests: [tests/e2e/place-order.happy.spec.ts] # must exist on disk for active slices
436
+ realization:
437
+ seqFile: .archik/place-order.happy.archik.seq.yaml
438
+ - id: declined
439
+ description: Payment gateway declines.
440
+ flows: [basic, payment-declined]
441
+ tests: [tests/e2e/place-order.declined.spec.ts]
442
+ ```
443
+
444
+ **Validation rules:**
445
+ - `primaryActor` and `secondaryActors` must resolve in the actor index.
446
+ - Active slice `tests` paths must exist on disk (same discipline as `sourcePath`).
447
+ - If `realization.seqFile` is set, the named seq file must exist AND carry a matching `realizes` block (bidirectional).
448
+ - `flows.basic` is required; `alternates[].branchFrom` must reference an existing flow + step number.
449
+
450
+ Query: `npx archik q usecases [--actor <id>]` | `npx archik q describe-usecase <id>`
451
+
452
+ ## Alpha state
453
+
454
+ One file per project: `<name>.archik.alphas.yaml`. Direct-write. Tracks four Essence alphas that archik can directly evidence: **stakeholders**, **requirements**, **softwareSystem**, **work**.
455
+
456
+ ```yaml
457
+ version: "1.0"
458
+ alphas:
459
+ stakeholders:
460
+ state: represented # conceived | recognised | represented | involved | in-agreement | satisfied
461
+ evidence: ["developer (human) + claude (external-system) in actors file"]
462
+ requirements:
463
+ state: acceptable # conceived | bounded | coherent | acceptable | addressed | fulfilled
464
+ note: "All active slices test-backed; rejected slice still needs a realization seq."
465
+ softwareSystem:
466
+ state: usable # architecture-selected | demonstrable | usable | ready | operational | retired
467
+ work:
468
+ state: under-control # initiated | prepared | started | under-control | concluded | closed
469
+ ```
470
+
471
+ Manage states with:
472
+ ```bash
473
+ npx archik alpha show # verification badges: ✓ verified | ✗ over-claimed | ? subjective
474
+ npx archik alpha promote requirements addressed # runs machine check before writing
475
+ npx archik alpha demote softwareSystem usable # no check on demote
476
+ ```
477
+
478
+ The validator checks machine-checkable states (e.g. `requirements.acceptable` requires every active slice to have on-disk tests). Over-claimed states are flagged `✗` — downgrade or fix the artifacts.
479
+
363
480
  ## Sequence diagram schema reference
364
481
 
365
482
  ```yaml
@@ -367,6 +484,12 @@ version: "1.0" # required, literal
367
484
  name: "Login flow" # required, non-empty
368
485
  description: "..." # optional
369
486
 
487
+ realizes: # optional — links this seq to a use case slice
488
+ useCase: place-order # use case id (must exist in .archik/usecases/)
489
+ slice: happy-path # slice id within that use case
490
+ # validator enforces bidirectional integrity:
491
+ # the slice's realization.seqFile must name THIS file
492
+
370
493
  participants: # required, at least one
371
494
  - id: browser # participant ref id (used in steps)
372
495
  nodeId: frontend # architecture node id this participant maps to
@@ -453,12 +576,28 @@ Run `npx archik <cmd> --help` for the per-command surface.
453
576
  npx archik schema # the document shape (start here when authoring)
454
577
  --json # structured shape for piping into jq
455
578
  --seq # seq diagram schema instead of arch schema
579
+ uc # use case schema
580
+ actors # actors schema
456
581
 
457
582
  npx archik q describe <id> | deps <id> | dependents <id>
458
583
  list | edges | impact <id> | stats
459
584
  sequences [--node <id>] # list seq diagrams; --node filters to flows involving a node
585
+ usecases [--actor <id>] # list use cases; filter by actor
586
+ describe-usecase <id> # one use case in detail
587
+ actors # list actors
460
588
  --json # stable machine-readable shape
461
589
 
590
+ npx archik trace [--json] # coverage matrix: use case × slice × test × seq × ECB
591
+ --use-case <id> # filter to one use case
592
+ --actor <id> # filter by actor
593
+ --status active|proposed|deprecated
594
+ --coverage full|partial|none
595
+ --fail-on partial|none # exit 1 for CI gates
596
+
597
+ npx archik alpha show [--json] # alpha state snapshot with verification badges
598
+ alpha promote <alpha> <state> [--note <text>] # runs machine check first
599
+ alpha demote <alpha> <state>
600
+
462
601
  npx archik validate <path> [--json] # schema + cross-file check (CI-friendly)
463
602
  npx archik render --out diagram.svg --theme light|dark
464
603
  render --seq <path> --out seq.svg --theme light|dark