@fluentcommerce/ai-skills 0.13.0 โ†’ 0.14.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.
Files changed (42) hide show
  1. package/README.md +14 -12
  2. package/bin/cli.mjs +29 -2
  3. package/content/cli/skills/fluent-connect/SKILL.md +57 -2
  4. package/content/cli/skills/fluent-profile/SKILL.md +35 -5
  5. package/content/dev/agents/fluent-backend-dev.md +2 -2
  6. package/content/dev/agents/fluent-dev.md +1 -1
  7. package/content/dev/skills/fluent-custom-code/SKILL.md +1 -1
  8. package/content/dev/skills/fluent-data-module-scaffold/SKILL.md +5 -5
  9. package/content/dev/skills/fluent-event-api/SKILL.md +1 -1
  10. package/content/dev/skills/{fluent-source-onboard โ†’ fluent-module-convert}/SKILL.md +223 -24
  11. package/content/dev/skills/fluent-module-validate/SKILL.md +6 -6
  12. package/content/dev/skills/fluent-mystique-builder/SKILL.md +1 -1
  13. package/content/dev/skills/fluent-mystique-scaffold/SDK_REFERENCE.md +2 -2
  14. package/content/dev/skills/fluent-mystique-scaffold/SKILL.md +1 -1
  15. package/content/dev/skills/fluent-mystique-scaffold/TEMPLATES.md +1 -1
  16. package/content/dev/skills/fluent-retailer-config/SKILL.md +2 -2
  17. package/content/dev/skills/fluent-scope-plan/SKILL.md +1 -1
  18. package/content/dev/skills/fluent-transition-api/SKILL.md +1 -1
  19. package/content/dev/skills/fluent-ui-test/SKILL.md +8 -7
  20. package/content/dev/skills/fluent-workspace-tree/SKILL.md +2 -2
  21. package/content/knowledge/index.md +3 -3
  22. package/content/knowledge/platform/module-structure.md +5 -5
  23. package/content/knowledge/platform/mystique-routing.md +6 -3
  24. package/content/knowledge/platform/permissions-and-contexts.md +2 -2
  25. package/content/knowledge/platform/rule-test-patterns.md +1 -1
  26. package/docs/01-first-session.md +175 -0
  27. package/docs/02-prompt-guide.md +246 -0
  28. package/docs/03-use-cases.md +1179 -0
  29. package/docs/04-onboarding-plan.md +355 -0
  30. package/docs/05-getting-started.md +262 -0
  31. package/docs/06-dev-workflow.md +1040 -0
  32. package/docs/INDEX.md +40 -0
  33. package/docs/agents-and-skills-guide.md +199 -0
  34. package/docs/capability-map.md +165 -0
  35. package/docs/chrome-devtools-mcp-reference.md +400 -0
  36. package/docs/fluent-ai-skills-reference.md +1351 -0
  37. package/docs/manifest-safety.md +79 -0
  38. package/docs/mcp-servers.md +209 -0
  39. package/docs/workflow-reference.md +167 -0
  40. package/lib/fluent-brand.css +55 -0
  41. package/metadata.json +7 -6
  42. package/package.json +12 -3
@@ -0,0 +1,1040 @@
1
+ # Autonomous Development Workflow
2
+
3
+ > [!CAUTION]
4
+ > **๐Ÿงช EXPERIMENTAL โ€” LABS PROJECT**
5
+ > This package is not production-ready. No stability guarantees, no support, no warranty. See [README](../README.md) for full disclaimer.
6
+
7
+ Orchestration protocol for AI agents to analyze existing Fluent Commerce implementations, add new functionality, deploy, test end-to-end, and fix issues in a seamless loop.
8
+
9
+ ## Overview
10
+
11
+ ```
12
+ WORKSPACE CHECK โ†’ ANALYZE โ†’ EXPLAIN (if requested) or PLAN โ†’ [USER APPROVAL] โ†’ IMPLEMENT โ†’ VALIDATE โ†’ BUILD โ†’ DEPLOY โ†’ TEST โ†’ DIAGNOSE โ†’ FIX โ†’ (loop back)
13
+ ```
14
+
15
+ This is a closed loop with a mandatory planning gate. After analysis, the agent presents a structured implementation plan (workflow changes, settings, rules, Mermaid diagrams, risk assessment, test plan) and waits for explicit user approval before making changes. The agent then continues iterating until all E2E tests pass or an unresolvable blocker is hit (missing credentials, infrastructure down, ambiguous requirements). The planning gate is skipped for pure read-only tasks (tracing, monitoring, querying). When the user asks to **explain** an existing feature instead of change it, the EXPLAIN phase produces a Feature Architecture Document (persisted to `accounts/<PROFILE>/features/<slug>/architecture.md`) and terminates โ€” no PLAN/IMPLEMENT needed.
16
+
17
+ **Three-agent architecture:** The `fluent-dev` orchestrator routes work to domain-specific agents: `fluent-backend-dev` (workflows, rules, modules, settings, events, deployment) and `fluent-frontend-dev` (Mystique manifests, SDK components, manifest validation, UI analysis, browser UI testing). Cross-domain features use `/fluent-feature-plan` at the orchestrator level. Frontend work follows: `/fluent-mystique-builder` โ†’ `/fluent-mystique-assess` โ†’ deploy via `/fluent-settings` (setting upsert) โ†’ optionally `/fluent-ui-test` (browser verification via Chrome DevTools MCP). Custom SDK components: `/fluent-mystique-scaffold` โ†’ `/fluent-frontend-build` (7-gate pipeline incl. GraphQL schema validation) โ†’ `/fluent-frontend-review` (9-phase code quality audit incl. GraphQL) โ†’ `/fluent-frontend-readme` (docs) โ†’ self-host bundle โ†’ update manifest `plugins[]`.
18
+
19
+ Event API documentation is incorporated using selective extraction (operational, tool-anchored guidance only), not full-text mirroring.
20
+
21
+ ### Agent Routing
22
+
23
+ The development lifecycle uses a three-agent architecture:
24
+
25
+ - **`fluent-dev` (orchestrator)** โ€” receives user requests, routes to the appropriate domain agent, and handles cross-cutting tasks (feature planning, E2E testing, session tracking)
26
+ - **`fluent-backend-dev`** โ€” executes backend phases: workflow analysis, rule scaffolding, module building, deployment, event tracing
27
+ - **`fluent-frontend-dev`** โ€” executes frontend phases: manifest building, SDK component scaffolding, SDK build/test/verify, code quality review, README generation, manifest validation, deployment as settings
28
+
29
+ **Routing decision:** If the request mentions workflows, rules, modules, settings, events, or Java โ†’ backend. If it mentions manifests, pages, components, UI, or Mystique โ†’ frontend. If it spans both โ†’ orchestrator creates a unified plan, then dispatches to each domain.
30
+
31
+ ---
32
+
33
+ ## Phase 0: Workspace Check
34
+
35
+ Before analyzing, ensure the workspace is initialized for the target profile.
36
+
37
+ 1. Check if `accounts/<PROFILE>/workspace-state.json` exists.
38
+ 2. If it exists, compute the content hash and compare with the stored `contentHash`.
39
+ 3. If hashes match: workspace is current. Print summary and proceed to Phase 1.
40
+ 4. If missing or stale: run `/fluent-connect --profile <PROFILE>` to discover profiles, wire MCP, download workflows, scan source repos, decompile JARs, build rule inventory, and persist state.
41
+ 5. After connect completes, proceed to Phase 1 with all artifacts available.
42
+
43
+ This ensures all downstream phases have workflows, source code, decompiled artifacts, and connectivity state ready before any analysis begins. See `/fluent-connect` for the full onboarding protocol.
44
+
45
+ ---
46
+
47
+ ## Phase 1: Analyze Existing State
48
+
49
+ Before making any changes, build a full picture of the current implementation.
50
+
51
+ ### 1.0 Account workspace intake
52
+
53
+ Use one account-scoped workspace:
54
+
55
+ - `accounts/<PROFILE>/SOURCE/backend/` โ€” Java Maven plugin repos and module artifacts (`*.jar`, `*.zip`) โ€” account-level, shared across retailers
56
+ - `accounts/<PROFILE>/SOURCE/frontend/` โ€” Mystique SDK component projects (package.json, webpack, src/index.tsx)
57
+ - `accounts/<PROFILE>/workflows/<RETAILER_REF>/` โ€” downloaded workflow JSON โ€” retailer-scoped
58
+ - `accounts/<PROFILE>/analysis/` โ€” generated reusable artifacts
59
+
60
+ Rules:
61
+
62
+ 1. Prefer local evidence first (source + artifacts already under `SOURCE/backend/`).
63
+ 2. If artifacts exist, decompile into `accounts/<PROFILE>/SOURCE/backend/.decompiled/<artifact-name>/` and include in analysis.
64
+ 3. Treat JAR/ZIP and decompiled output as read-only evidence.
65
+ 4. Recommend source-level implementation options; if only artifacts are present, request source onboarding before code changes.
66
+
67
+ Always keep workflow context explicit for safety:
68
+
69
+ 5. Download and edit workflows only under `accounts/<PROFILE>/workflows/<RETAILER_REF>/`.
70
+ 6. Persist `workflow-context.json` in that folder and verify it before merge/upload.
71
+
72
+ ### 1.1 Verify connectivity
73
+
74
+ Call these MCP tools in sequence โ€” stop if any fails:
75
+
76
+ ```
77
+ config_validate โ†’ must return ok: true
78
+ health_ping โ†’ must return ok: true
79
+ connection_test โ†’ must return ok: true (also reveals retailerId, user context)
80
+ ```
81
+
82
+ If `config_validate` fails: environment variables are missing or wrong. Report and stop.
83
+ If `connection_test` fails: auth or network issue. Report and stop.
84
+
85
+ ### 1.2 Discover deployed workflows
86
+
87
+ ```
88
+ fluent workflow list -p <PROFILE> -r <RETAILER_REF>
89
+ ```
90
+
91
+ Parse the output to get all workflow names, entity types, and versions. Store this as the baseline.
92
+
93
+ ### 1.3 Reusable custom-code artifacts
94
+
95
+ If `accounts/<PROFILE>/analysis/code/` exists, read and reuse these artifacts before re-scanning. Downstream phases (Implement, Trace, Rule Scaffold) should consume them first. Regenerate via `/fluent-custom-code` when stale or out-of-scope.
96
+
97
+ | File | Purpose |
98
+ |------|---------|
99
+ | `source-map.json` | Maps rule names to source file paths |
100
+ | `workflow-rule-map.json` | Maps workflow rulesets/rules to implementing classes |
101
+ | `constraints.json` | Extracted constraints and invariants |
102
+ | `behavior-map.md` | Human-readable behavior summary |
103
+ | `extension-plan.md` | Suggested extension points and changes |
104
+ | `fingerprint.json` | Input fingerprint/hash manifest used to decide reuse vs regenerate |
105
+
106
+ Use incremental refresh by default:
107
+ - Rule source changed -> refresh `source-map.json` + impacted rows in `workflow-rule-map.json` + relevant `constraints.json` risks.
108
+ - Workflow JSON changed -> refresh `workflow-rule-map.json` + `behavior-map.md`.
109
+ - Test-only change -> refresh test metadata in `source-map.json` only.
110
+ - Structure/module metadata change -> full regenerate.
111
+
112
+ ### 1.4 Download relevant workflows
113
+
114
+ For each workflow relevant to the task:
115
+
116
+ ```
117
+ fluent workflow download -p <PROFILE> -r <RETAILER_REF> -w all -o accounts/<PROFILE>/workflows/<RETAILER_REF>/
118
+ ```
119
+
120
+ Write/update retailer context at:
121
+
122
+ `accounts/<PROFILE>/workflows/<RETAILER_REF>/workflow-context.json`
123
+
124
+ ```json
125
+ {
126
+ "profile": "<PROFILE>",
127
+ "retailerRef": "<RETAILER_REF>",
128
+ "retailerId": "<RETAILER_ID>",
129
+ "baseUrl": "<FLUENT_BASE_URL>",
130
+ "downloadedAt": "<ISO-8601>"
131
+ }
132
+ ```
133
+
134
+ Before merge/upload, verify the command target (`-p`, `-r`) matches this context file.
135
+
136
+ Read the downloaded JSON. Extract:
137
+ - All rulesets (name, triggers, rules with props)
138
+ - All statuses (name, category)
139
+ - The state machine: which events transition between which statuses
140
+ - Gate rulesets: which rulesets check child entity statuses before advancing
141
+
142
+ ### 1.4A Query live transitions
143
+
144
+ Use `workflow_transitions` to complement workflow JSON analysis with runtime-confirmed transitions:
145
+
146
+ ```
147
+ workflow_transitions({
148
+ "triggers": [{
149
+ "type": "ORDER",
150
+ "subtype": "HD",
151
+ "status": "CREATED",
152
+ "retailerId": "<RETAILER_ID>",
153
+ "flexType": "ORDER::HD"
154
+ }]
155
+ })
156
+ ```
157
+
158
+ This reveals:
159
+ - Which user actions are available at each status (runtime truth vs. workflow JSON definition)
160
+ - Required attributes for each action (avoids missing-attribute errors during testing)
161
+ - UI context (button labels, modules, confirmation dialogs)
162
+
163
+ ### 1.5 Discover deployed modules and rules
164
+
165
+ ```
166
+ fluent module list -p <PROFILE>
167
+ ```
168
+
169
+ If the project has local source code, scan it:
170
+
171
+ ```
172
+ Glob: plugins/rules/**/src/main/java/**/*.java
173
+ Grep: @RuleInfo in those files โ†’ extract rule names
174
+ Read: resources/module.json โ†’ extract registered rules and version
175
+ Read: pom.xml (and parent pom) โ†’ extract groupId/artifactId/version when module.json is missing or incomplete
176
+ ```
177
+
178
+ If JAR/ZIP artifacts are already under `accounts/<PROFILE>/SOURCE/backend/`, decompile to:
179
+
180
+ `accounts/<PROFILE>/SOURCE/backend/.decompiled/<artifact-name>/`
181
+
182
+ Then include that decompiled tree in rule mapping before asking for more inputs.
183
+
184
+ Module identity precedence (store in analysis artifacts):
185
+ - `symbolicName`: `module.json.name` -> manifest `Bundle-SymbolicName` -> `<groupId>/<artifactId>`
186
+ - `version`: `module.json.version` -> `pom project.version` (or `parent.version`) -> manifest `Implementation-Version` / `Bundle-Version`
187
+
188
+ ### 1.5A If source code is unavailable
189
+
190
+ When rule logic cannot be validated from workflow JSON alone:
191
+
192
+ 1. Request module artifacts (ZIP/JAR) from the deployed build.
193
+ 2. Extract `module.json` and map workflow rule names to Java class names.
194
+ 3. Decompile to `accounts/<PROFILE>/SOURCE/backend/.decompiled/<artifact-name>/` and start with suspected rule classes first (avoid full artifact noise).
195
+ 4. Confirm actual behavior (props read, queries/mutations/events executed, guards/status checks).
196
+ 5. Keep confidence labels in notes: **confirmed by source/decompile** vs **inferred from workflow metadata**.
197
+
198
+ ### 1.6 Query live entity state (if investigating a specific entity)
199
+
200
+ Use MCP `graphql_query`:
201
+
202
+ **Orders:**
203
+ ```graphql
204
+ { orders(ref: ["<REF>"], first: 1) { edges { node {
205
+ id ref type status createdOn updatedOn
206
+ attributes { name type value }
207
+ fulfilmentChoice { id ref type status deliveryType }
208
+ fulfilmentChoices { edges { node { id ref type status deliveryType } } }
209
+ items { edges { node { ref quantity status fulfilmentChoice { id ref type status deliveryType } } } }
210
+ } } } }
211
+ ```
212
+
213
+ Use `items[].fulfilmentChoiceRef` only on `createOrder` input. For schema-validated `ORDER::MULTI` input and readback patterns, see `knowledge/platform/create-order-reference.md` (copied to your workspace by the installer).
214
+
215
+ **Fulfilments:**
216
+ ```graphql
217
+ { fulfilments(ref: ["<REF>"], first: 1) { edges { node {
218
+ id ref type status
219
+ attributes { name type value }
220
+ items { edges { node { ref status requestedQuantity filledQuantity } } }
221
+ order { id ref status }
222
+ fromLocation { ref name }
223
+ } } } }
224
+ ```
225
+
226
+ ### 1.7 Query event history (if investigating failures)
227
+
228
+ ```
229
+ event_list({ "context.entityRef": "<REF>", "context.entityType": "<TYPE>", "count": 50 })
230
+ ```
231
+
232
+ Filter failed events:
233
+ ```
234
+ event_list({ "context.entityRef": "<REF>", "eventStatus": "FAILED", "count": 50 })
235
+ ```
236
+
237
+ For each failed event, get details:
238
+ ```
239
+ event_get({ "eventId": "<ID>" })
240
+ ```
241
+
242
+ For event-model semantics, filter capabilities, and causality patterns (`context.sourceEvents`, root-entity tracing), use `/fluent-event-api` alongside this phase.
243
+
244
+ ### 1.8 Check settings
245
+
246
+ ```graphql
247
+ { settings(first: 1, context: "RETAILER", contextId: <RETAILER_ID>, name: ["<SETTING_NAME>"]) {
248
+ edges { node { id name value lobValue } }
249
+ } }
250
+ ```
251
+
252
+ ### 1.9 Connection topology and dependency mapping
253
+
254
+ Run `/fluent-connection-analysis` on the target workflow(s) to map:
255
+ - Internal, cross-entity, and cross-workflow event edges
256
+ - Orphaned rulesets and missing SendEvent targets
257
+ - Process flow classification (CREATE, SCHEDULED, CROSS_ENTITY, USER_ACTION, INTERNAL, INTEGRATION)
258
+ - Webhook and setting dependency inventory
259
+
260
+ If investigating a specific entity, use `--validate <entity-ref> --entity-type <TYPE>` to compare static expected paths against actual runtime events (static-vs-dynamic diff).
261
+
262
+ ### 1.10 Retailer environment baseline
263
+
264
+ If environment setup is needed (new locations, networks, catalogues), use `/fluent-retailer-config` to create or verify infrastructure entities before testing.
265
+
266
+ ### 1.11 Platform health check
267
+
268
+ For broad platform issues or intermittent failures, run `/fluent-system-monitoring` to check aggregate event metrics, error rate trends, and queue health.
269
+
270
+ ### 1.12 Batch/job pipeline check
271
+
272
+ If the workflow involves batch ingestion or JOB entities, use `/fluent-job-batch` to trace job lifecycle and diagnose ingestion failures.
273
+
274
+ ### Analysis output
275
+
276
+ After Phase 1, the agent should have:
277
+ - Current workflow structure (rulesets, states, transitions)
278
+ - Connection topology and dependency map (if connection-analysis was run)
279
+ - Registered rules and their source code (if local)
280
+ - Entity state and event history (if investigating)
281
+ - Settings relevant to the task
282
+ - Evidence quality notes (confirmed vs inferred behavior)
283
+ - Clear understanding of what exists vs. what needs to change
284
+
285
+ ---
286
+
287
+ ## Phase 1b: Explain (Feature Architecture Document)
288
+
289
+ **When the user asks to understand an existing feature** rather than change it, route here instead of Phase 1.5.
290
+
291
+ Invoke `/fluent-feature-explain` which orchestrates:
292
+ 1. Workflow structure analysis (status machines, event chains, process flow classification)
293
+ 2. Rule logic analysis โ€” **tiered evidence approach**:
294
+ - **Tier 1:** `plugin_list` descriptions and parameters (always available)
295
+ - **Tier 2:** Source code analysis โ€” original source (`accounts/<PROFILE>/SOURCE/backend/`) or decompiled JARs (`backend/.decompiled/`). Invokes `/fluent-custom-code` for JAR decompilation if needed.
296
+ - **Tier 3:** Runtime evidence โ€” auto-discovers existing entities via GraphQL before asking user
297
+ 3. Connection topology (cross-entity flows, webhooks, settings dependencies)
298
+ 4. Runtime evidence (adaptive โ€” auto-discovers entities, escalates source depth when no runtime)
299
+
300
+ **Output:** A Feature Architecture Document saved to `accounts/<PROFILE>/features/<slug>/architecture.md` containing:
301
+ - Entity lifecycle state diagrams (Mermaid `stateDiagram-v2`)
302
+ - Cross-entity sequence diagrams (Mermaid `sequenceDiagram`)
303
+ - Event chain flowcharts (Mermaid `flowchart TD`)
304
+ - Input โ†’ Output data flow tables
305
+ - Rules & logic per ruleset (custom vs OOTB, source file paths)
306
+ - Settings dependencies with current values
307
+ - Integration points (webhooks, scheduled events, external systems)
308
+ - Runtime evidence timeline (when entity ref provided)
309
+ - **Analysis Confidence section** โ€” per-rule evidence levels (HIGH/MEDIUM/LOW) with recommendations for higher confidence
310
+
311
+ **Terminates here.** No PLAN/IMPLEMENT phases needed โ€” this is read-only documentation output.
312
+
313
+ ---
314
+
315
+ ## Phase 1.5: Plan & Approve (Check Gate)
316
+
317
+ **Mandatory gate.** After analysis, present a structured implementation plan and wait for user approval before any changes.
318
+
319
+ **Skip** for pure read-only tasks (tracing, monitoring, querying entity state).
320
+
321
+ ### Plan structure
322
+
323
+ Present in this order:
324
+
325
+ 1. **Business context** โ€” What problem, why now
326
+ 2. **Current state** โ€” Specific workflow names, ruleset names, setting keys
327
+ 3. **Proposed changes** โ€” Workflow changes (with Mermaid before/after), settings changes, rule/plugin changes, entity/data changes, deployment sequence
328
+ 4. **Flow visualization** โ€” Mermaid `stateDiagram-v2` for state machines, `sequenceDiagram` for cross-entity flows
329
+ 5. **Risk assessment** โ€” Breaking existing flows, runtime exceptions, missing dependencies
330
+ 6. **Test plan** โ€” Happy path, new path, edge cases, regression
331
+ 7. **Rollback plan** โ€” How to revert if issues arise
332
+
333
+ ### Approval protocol
334
+
335
+ 1. **STOP** โ€” Do not proceed to Phase 2
336
+ 2. **Approved** โ†’ proceed to Phase 2
337
+ 3. **Changes requested** โ†’ revise plan, re-present
338
+ 4. **Rejected** โ†’ restart from Phase 1 with different approach
339
+ 5. **Partially approved** โ†’ proceed with approved sections only
340
+
341
+ See `fluent-dev` agent's "Phase 2: Plan & Approve (CHECK GATE)" section for the full template.
342
+
343
+ ---
344
+
345
+ ## Phase 2: Implement Changes
346
+
347
+ Based on the approved plan, determine what type of change is needed and execute the appropriate path.
348
+
349
+ ### Decision tree
350
+
351
+ ```
352
+ What needs to change?
353
+ โ”‚
354
+ โ”œโ”€ Workflow structure (new rulesets, states, triggers)
355
+ โ”‚ โ””โ”€ Go to 2.1: Edit Workflow
356
+ โ”‚
357
+ โ”œโ”€ Business logic (new/modified rule behavior)
358
+ โ”‚ โ””โ”€ Go to 2.2: Create or Edit Rule
359
+ โ”‚
360
+ โ”œโ”€ Configuration (settings, data)
361
+ โ”‚ โ””โ”€ Go to 2.3: Update Settings/Data
362
+ โ”‚
363
+ โ”œโ”€ Multiple of the above
364
+ โ”‚ โ””โ”€ Execute each applicable section in order: 2.1 โ†’ 2.2 โ†’ 2.3
365
+ โ”‚
366
+ โ””โ”€ Unknown (need more investigation)
367
+ โ””โ”€ Return to Phase 1 with more specific queries
368
+ ```
369
+
370
+ ### 2.1 Edit workflow
371
+
372
+ Read the current workflow JSON from `accounts/<PROFILE>/workflows/<RETAILER_REF>/` (or an explicitly provided local file after context check).
373
+
374
+ **Adding a new ruleset:**
375
+
376
+ Build the ruleset JSON following the structure:
377
+ ```json
378
+ {
379
+ "name": "<RulesetName>",
380
+ "description": "[<ENTITY_TYPE>] What this ruleset does",
381
+ "type": "<ENTITY_TYPE>",
382
+ "eventType": "NORMAL",
383
+ "rules": [
384
+ {
385
+ "name": "<ACCOUNT>.<MODULE>.<RuleName>",
386
+ "props": { "key": "value" }
387
+ }
388
+ ],
389
+ "triggers": [{ "status": "<STATUS>" }],
390
+ "userActions": []
391
+ }
392
+ ```
393
+
394
+ If triggers is empty `[]`, the ruleset fires when an event with matching name arrives.
395
+
396
+ **Validation โ€” check ALL of these before proceeding:**
397
+ - [ ] Every `SetState` target status exists in the `statuses` array
398
+ - [ ] Every `SendEvent` target has a matching ruleset name
399
+ - [ ] Rule names follow `<ACCOUNT>.<MODULE>.<RuleName>` format
400
+ - [ ] No duplicate ruleset names
401
+ - [ ] Version is bumped from currently deployed version
402
+ - [ ] `versionComment` describes what changed
403
+
404
+ **Adding a new status:** Add to the `statuses` array:
405
+ ```json
406
+ { "name": "NEW_STATUS", "category": "FULFILMENT", "entityType": "ORDER" }
407
+ ```
408
+
409
+ Categories: `BOOKING`, `FULFILMENT`, `DONE`, `PAYMENT`
410
+
411
+ **Adding a gate ruleset:** Gates check child entity statuses before advancing parent:
412
+ ```json
413
+ {
414
+ "name": "CheckAllFulfilmentsComplete",
415
+ "rules": [{
416
+ "name": "ACCT.core.SendEventOnVerifyingAllFcStatus",
417
+ "props": { "eventName": "AdvanceOrder", "statuses": "DELIVERED,CANCELLED" }
418
+ }],
419
+ "triggers": [],
420
+ "userActions": []
421
+ }
422
+ ```
423
+
424
+ The `statuses` prop must include ALL terminal states for child entities.
425
+
426
+ ### 2.2 Create or edit rule
427
+
428
+ **New rule โ€” use scaffolding pattern:**
429
+
430
+ Determine:
431
+ - Rule name (PascalCase, descriptive)
432
+ - Target package (`common`, `order`, `fulfilment`, etc.)
433
+ - What props it needs (`@ParamString` annotations)
434
+ - What it does (query? mutate? send event? set attribute?)
435
+
436
+ Create the Java class at:
437
+ ```
438
+ plugins/rules/<MODULE_NAME>/src/main/java/com/fluentcommerce/rule/<package>/<RuleName>.java
439
+ ```
440
+
441
+ Must extend `BaseRule` and implement `run(ContextWrapper context)`.
442
+
443
+ Create the test class at:
444
+ ```
445
+ plugins/rules/<MODULE_NAME>/src/test/java/com/fluentcommerce/rule/<package>/<RuleName>Test.java
446
+ ```
447
+
448
+ Wire into `resources/module.json` โ€” add rule name to the `rules` array.
449
+
450
+ **Editing an existing rule:**
451
+
452
+ Find the rule class:
453
+ ```
454
+ Grep: @RuleInfo(name = "<RuleName>" across plugins/rules/**/src/main/java/
455
+ ```
456
+
457
+ Make changes. Run the unit test for that specific rule to verify:
458
+ ```bash
459
+ cd plugins && mvn test -pl rules/<module-alias> -Dtest="<RuleName>Test"
460
+ ```
461
+
462
+ **Gotchas to avoid:**
463
+ - `@ParamString` names are CASE-SENSITIVE
464
+ - `context.action().mutation()` only QUEUES โ€” mutation executes AFTER rule returns
465
+ - `DynamicMutation.buildMutationDocument` appends `!` โ€” never include `!` in type names
466
+ - `updateFulfilmentItem` does NOT exist โ€” use `updateFulfilment` with nested `items`
467
+ - Implement `run(ContextWrapper context)`, not `run(Context context)`
468
+
469
+ ### 2.3 Update settings or data
470
+
471
+ **Settings** โ€” via GraphQL mutation:
472
+ ```
473
+ graphql_query({
474
+ query: "mutation($input: UpdateSettingInput!) { updateSetting(input: $input) { id ref } }",
475
+ variables: { "input": { "id": "<ID>", "lobValue": "<JSON_STRING>" } }
476
+ })
477
+ ```
478
+
479
+ **Bulk data** โ€” via batch mutations:
480
+ ```
481
+ graphql_batchMutate({
482
+ mutation: "updateOrder",
483
+ inputs: [{ "id": "1", "status": "NEW_STATUS" }, ...],
484
+ returnFields: ["id", "ref", "status"]
485
+ })
486
+ ```
487
+
488
+ ---
489
+
490
+ ## Phase 2.5: Validate Module Structure
491
+
492
+ Before building, run `/fluent-module-validate` to catch structural issues early.
493
+
494
+ The validator uses a **content hash** to skip re-validation when module files are unchanged. Any edit to `.java`, `.json`, `.xml`, `.sh`, or `.ps1` files produces a new hash and triggers a fresh validation.
495
+
496
+ ```
497
+ /fluent-module-validate accounts/<PROFILE>/SOURCE/backend/<repo>/<module-root>
498
+ ```
499
+
500
+ If the report exists and hash matches, it prints "Module unchanged" and stops immediately. Otherwise it runs all 9 checks and writes:
501
+ - `accounts/<PROFILE>/reports/module-validate/<name>.report.json`
502
+ - `accounts/<PROFILE>/reports/module-validate/<name>.hash`
503
+
504
+ **Gate rule**: Do not proceed to Phase 3 if `summary.status === "NEEDS_FIXES"`. Fix FAILs first.
505
+
506
+ After applying fixes (e.g., new rule class, version bump), the hash will change automatically and the next `/fluent-module-validate` invocation re-runs validation.
507
+
508
+ ---
509
+
510
+ ## Phase 3: Build and Package
511
+
512
+ Only needed if Java code changed. Skip to Phase 4 if only workflow/settings changed.
513
+
514
+ ### 3.1 Bump version
515
+
516
+ Fluent ignores re-uploads of the same module version. Update ALL of these:
517
+
518
+ | File | Field |
519
+ |------|-------|
520
+ | `plugins/pom.xml` | parent `<version>` |
521
+ | `plugins/rules/<MODULE_NAME>/pom.xml` | parent + module `<version>` |
522
+ | `plugins/types/<MODULE_NAME>/pom.xml` | parent + module `<version>` |
523
+ | `plugins/util/<MODULE_NAME>/pom.xml` | parent + module `<version>` |
524
+ | `resources/module.json` | `"version"` |
525
+
526
+ Read current version from `resources/module.json`, increment patch, update all files.
527
+
528
+ ### 3.2 Compile
529
+
530
+ ```bash
531
+ cd plugins && mvn clean install
532
+ ```
533
+
534
+ **If compilation fails:**
535
+
536
+ | Error | Fix |
537
+ |-------|-----|
538
+ | `cannot find symbol` | Check imports, verify changed class references |
539
+ | `dependency not found` | Run from `plugins/` with `-am` flag |
540
+ | Test failures | Update test fixtures/expected values, or run `-DskipTests` to defer |
541
+
542
+ Fix and retry until clean build.
543
+
544
+ ### 3.3 Package
545
+
546
+ ```bash
547
+ ./scripts/build-module.sh
548
+ # or on Windows:
549
+ powershell ./scripts/build-module.ps1
550
+ ```
551
+
552
+ Verify output: `dist/<MODULE_ARTIFACT_NAME>-<VERSION>.zip`
553
+
554
+ ---
555
+
556
+ ## Phase 4: Deploy
557
+
558
+ ### Decision tree
559
+
560
+ ```
561
+ What changed?
562
+ โ”‚
563
+ โ”œโ”€ Java rules (+ possibly workflow)
564
+ โ”‚ โ””โ”€ Deploy full module ZIP
565
+ โ”‚ fluent module install dist/<module>.zip \
566
+ โ”‚ --retailer <RETAILER_REF> --profile <PROFILE>
567
+ โ”‚
568
+ โ”œโ”€ Workflow JSON only (no code changes)
569
+ โ”‚ โ””โ”€ Upload workflow directly via REST API:
570
+ โ”‚ curl -X PUT "$BASE_URL/api/v4.1/workflow" \
571
+ โ”‚ -H "Authorization: Bearer $TOKEN" \
572
+ โ”‚ -d @workflow.json
573
+ โ”‚ NOTE: Requires retailer-scoped token, not account-level.
574
+ โ”‚
575
+ โ”œโ”€ Settings/data only
576
+ โ”‚ โ””โ”€ Already applied via GraphQL mutations in Phase 2.3. No deploy needed.
577
+ โ”‚
578
+ โ””โ”€ Module + workflow with different workflow version
579
+ โ””โ”€ Deploy module with --exclude workflows, then upload workflow separately
580
+ ```
581
+
582
+ ### Post-deploy verification
583
+
584
+ After deploy, verify:
585
+ ```bash
586
+ fluent module list -p <PROFILE> # Module version matches
587
+ fluent workflow list -p <PROFILE> -r <RETAILER_REF> # Workflow version matches
588
+ ```
589
+
590
+ ---
591
+
592
+ ## Phase 5: Test End-to-End
593
+
594
+ Run E2E test sequences to verify the deployed changes work.
595
+
596
+ ### 5.1 Choose scenario
597
+
598
+ | Scenario | When to use |
599
+ |----------|------------|
600
+ | ORDER HD | Testing home delivery flow changes |
601
+ | ORDER CC | Testing click & collect flow changes |
602
+ | Cancel Order | Testing cancellation handling |
603
+ | Short Pick | Testing partial fulfilment handling |
604
+ | Custom | When change affects a specific path not covered above |
605
+
606
+ ### 5.2 Execute test sequence
607
+
608
+ Each test follows this pattern:
609
+
610
+ ```
611
+ For each step in the scenario:
612
+ 1. SEND event via event_send (mode: "async")
613
+ 2. WAIT (initial delay: 3s for simple events, 15s after ConfirmValidation cascade)
614
+ 3. QUERY entity status via graphql_query
615
+ 4. COMPARE actual status to expected status
616
+ 5. If match โ†’ PASS, continue to next step
617
+ 6. If no match โ†’ RETRY (wait 5s, query again, up to 6 retries = 30s)
618
+ 7. If still no match after retries โ†’ FAIL, go to Phase 6
619
+ ```
620
+
621
+ **Dynamic test sequence option:** Instead of hardcoded steps, use `workflow_transitions` at each
622
+ state to discover the next available action:
623
+
624
+ ```
625
+ 1. Create entity
626
+ 2. workflow_transitions โ†’ discover actions at current status
627
+ 3. Pick the expected action from userActions[]
628
+ 4. event_send with eventName and required attributes from response
629
+ 5. Poll entity status until transition completes
630
+ 6. workflow_transitions โ†’ discover next actions
631
+ 7. Repeat until no more userActions (terminal state)
632
+ ```
633
+
634
+ This approach adapts automatically when workflows change and validates that expected
635
+ user actions are available at each step.
636
+
637
+ ### 5.3 Create test order
638
+
639
+ **Run `/fluent-test-data` discovery first** to obtain all refs from the live environment. Never hardcode product SKUs, location refs, addresses, or prefixes โ€” they differ per retailer.
640
+
641
+ The discovery sequence queries: retailer context โ†’ locations โ†’ networks โ†’ product catalogues โ†’ products with inventory โ†’ customers โ†’ settings (consignment prefix).
642
+
643
+ Once discovery is complete, build the `createOrder` mutation using discovered values:
644
+
645
+ ```
646
+ graphql_query({
647
+ query: "mutation($input: CreateOrderInput!) { createOrder(input: $input) { id ref status } }",
648
+ variables: { input: {
649
+ ref: "E2E_HD_<TIMESTAMP>",
650
+ type: "MULTI",
651
+ retailer: { id: "<discovered.retailerId>" },
652
+ customer: { id: "<discovered.customerId>" },
653
+ items: [{ ref: "<discovered.productRef>", quantity: 1, productRef: "<discovered.productRef>",
654
+ productCatalogueRef: "<discovered.catalogueRef>",
655
+ fulfilmentChoiceRef: "E2E_HD_<TIMESTAMP>-FC-HD" }],
656
+ fulfilmentChoice: {
657
+ ref: "E2E_HD_<TIMESTAMP>-FC-HD", type: "HD", deliveryType: "STANDARD",
658
+ deliveryAddress: { ref: "E2E_HD_<TIMESTAMP>-ADDR",
659
+ name: "<discovered.location.primaryAddress.name or 'Test Delivery'>",
660
+ street: "<discovered.location.primaryAddress.street>",
661
+ city: "<discovered.location.primaryAddress.city>",
662
+ postcode: "<discovered.location.primaryAddress.postcode>",
663
+ country: "<discovered.location.primaryAddress.country>" },
664
+ attributes: [
665
+ { name: "sourcingLocationRef", type: "STRING", value: "<discovered.warehouseRef>" },
666
+ { name: "consignmentPrefix", type: "STRING", value: "<discovered.consignmentPrefix or 'A_'>" }
667
+ ]
668
+ }
669
+ }}
670
+ })
671
+ ```
672
+
673
+ See `/fluent-test-data` for the full discovery flow and entity creation templates (HD, CC, customer).
674
+
675
+ ### 5.4 Fire events and assert
676
+
677
+ **ORDER HD full lifecycle:**
678
+
679
+ | Step | Event | Entity | Expected Status | Wait |
680
+ |------|-------|--------|----------------|------|
681
+ | 1 | *(auto on create)* | ORDER | CREATED โ†’ ON_VALIDATION | 3s |
682
+ | 2 | `ConfirmValidation` | ORDER | IN_PROGRESS + Fulfilment CREATED | **15s** (async cascade) |
683
+ | 3 | `ConfirmAllocation` | FULFILMENT | RECEIVED | 5s |
684
+ | 4 | `CreateInvoice` | FULFILMENT | INVOICED | 5s |
685
+ | 5 | `ConfirmPick` | FULFILMENT | PICKPACK | 5s |
686
+ | 6 | `ConfirmShipment` | FULFILMENT | SHIPPED | 5s |
687
+ | 7 | `ConfirmDelivery` | FULFILMENT | DELIVERED | 5s |
688
+
689
+ After step 2, query fulfilments to get the generated fulfilment ref (pattern: `<consignmentPrefix><FC-ref>-<locationRef>`). All subsequent events target this ref.
690
+
691
+ **Event attributes required per step:**
692
+
693
+ | Event | Attributes |
694
+ |-------|-----------|
695
+ | `ConfirmPick` | `pickedAt` (ISO datetime), `pickedItems` (JSON array) |
696
+ | `ConfirmShipment` | `trackingNumber`, `carrierRef`, `shippedAt` (ISO datetime) |
697
+ | `ConfirmDelivery` | `deliveredAt` (ISO datetime) |
698
+
699
+ ### 5.5 Record results
700
+
701
+ Track each step: event sent, expected status, actual status, pass/fail, duration. If all steps pass, the change is verified. Report results and stop.
702
+
703
+ If any step fails โ†’ proceed to Phase 6.
704
+
705
+ ---
706
+
707
+ ## Phase 5b: Browser UI Verification (Optional)
708
+
709
+ **When to use:** After deploying a Mystique manifest change, verify that the UI renders correctly in the browser. This phase is optional and requires Chrome DevTools MCP to be configured in `.mcp.json`.
710
+
711
+ **Skip** when: No manifest changes were deployed, Chrome DevTools MCP is not available, or backend-only changes.
712
+
713
+ ### 5b.1 Pre-flight
714
+
715
+ 1. Verify Chrome DevTools MCP is connected (search for `navigate_page` tool availability)
716
+ 2. Determine target app URL: `https://<account>.<env>.apps.engineering.fluentcommerce.com/<appName>` โ€” where `<appName>` is `oms` (OMS App), `store` (Store App), or `servicepoint` (Store App legacy URL alias)
717
+ 3. If credentials are not configured, ask the user for login details
718
+
719
+ ### 5b.2 Execute browser test
720
+
721
+ ```
722
+ 1. navigate_page โ†’ target app URL
723
+ 2. Handle login if required (fill username/password, submit)
724
+ 3. navigate_page โ†’ specific page/route being tested
725
+ 4. take_snapshot โ†’ DOM snapshot (verify page structure, component rendering)
726
+ 5. list_console_messages โ†’ check for React errors, GraphQL failures, uncaught exceptions
727
+ 6. take_screenshot โ†’ visual evidence
728
+ ```
729
+
730
+ ### 5b.3 Verify
731
+
732
+ Check the following against expected behavior:
733
+ - Page loads without errors (no blank pages, no error boundaries)
734
+ - Key components render with data (lists have rows, forms have fields)
735
+ - Navigation works (routes resolve, breadcrumbs correct)
736
+ - User actions appear for the current workflow status (if applicable)
737
+ - No console errors or GraphQL failures
738
+
739
+ ### 5b.4 Report
740
+
741
+ Produce a pass/fail report with:
742
+ - Checks performed (login, page load, data load, component rendering)
743
+ - Screenshot evidence (file path)
744
+ - Issues found with severity (CRITICAL for page errors, MEDIUM for missing components, LOW for cosmetic)
745
+ - Remediation steps for any failures
746
+
747
+ If issues are found โ†’ route back to Phase 2 (manifest editing) or Phase 4 (redeploy).
748
+
749
+ ---
750
+
751
+ ## Phase 6: Diagnose and Fix
752
+
753
+ ### 6.1 Identify failure point
754
+
755
+ From the test results, identify:
756
+ - Which step failed
757
+ - What entity ref and type
758
+ - What was the expected vs actual status
759
+ - Was the event processed (SUCCESS/FAILED/PENDING)?
760
+
761
+ ### 6.2 Trace the failure
762
+
763
+ Query event history for the entity:
764
+ ```
765
+ event_list({ "context.entityRef": "<REF>", "context.entityType": "<TYPE>", "eventStatus": "FAILED", "count": 50 })
766
+ ```
767
+
768
+ For failed events, get details:
769
+ ```
770
+ event_get({ "eventId": "<ID>" })
771
+ ```
772
+
773
+ For deep causality analysis (parent -> child event chains, cross-entity timelines, source pattern interpretation), route to `/fluent-event-api`. `/fluent-trace` remains the owner of the root-cause decision tree.
774
+
775
+ ### 6.3 Decision tree
776
+
777
+ ```
778
+ What happened?
779
+ โ”‚
780
+ โ”œโ”€ Event FAILED with error message
781
+ โ”‚ โ”œโ”€ "Rule exception" โ†’ Rule code bug. Read the rule source, check props, fix code.
782
+ โ”‚ โ”œโ”€ "No matching ruleset" โ†’ Event name doesn't match any ruleset. Fix workflow.
783
+ โ”‚ โ”œโ”€ "Entity not found" โ†’ Wrong entityRef. Fix the test or check entity creation.
784
+ โ”‚ โ””โ”€ "Permission denied" โ†’ Check retailerId scope (account-level users get retailerId=0).
785
+ โ”‚
786
+ โ”œโ”€ Event SUCCESS but wrong status
787
+ โ”‚ โ”œโ”€ Gate not met โ†’ Query all child entities, check if they're in expected terminal states.
788
+ โ”‚ โ”œโ”€ Wrong ruleset fired โ†’ Check trigger status conflicts in workflow.
789
+ โ”‚ โ””โ”€ Rule ran but did something unexpected โ†’ Read rule code, check props.
790
+ โ”‚ If rule logic is unclear from available files โ†’ request source or decompile JAR/ZIP.
791
+ โ”‚
792
+ โ”œโ”€ Event PENDING (stuck)
793
+ โ”‚ โ””โ”€ Wait 15-30s and retry. If still pending, async queue may be backlogged.
794
+ โ”‚
795
+ โ”œโ”€ No event found
796
+ โ”‚ โ””โ”€ Event was never sent, or sent to wrong entityRef/entityType. Check test logic.
797
+ โ”‚
798
+ โ””โ”€ Entity in unexpected intermediate state
799
+ โ””โ”€ Async cascade still running. Wait and re-query.
800
+ If stuck > 60s: check if a gate condition is blocking. Query child entities.
801
+ ```
802
+
803
+ ### 6.4 Apply fix
804
+
805
+ Based on diagnosis, apply the fix:
806
+
807
+ | Root cause | Fix action | Next phase |
808
+ |-----------|------------|------------|
809
+ | Rule code bug | Edit Java source, fix logic | โ†’ Phase 3 (Build) |
810
+ | Rule behavior unclear from workflow metadata | Request source/JAR, decompile targeted classes, confirm actual logic | โ†’ Phase 1 (Analyze) |
811
+ | Missing/wrong workflow ruleset | Edit workflow JSON | โ†’ Phase 4 (Deploy) |
812
+ | Wrong props in ruleset | Edit workflow JSON | โ†’ Phase 4 (Deploy) |
813
+ | Missing status in workflow | Add to `statuses` array | โ†’ Phase 4 (Deploy) |
814
+ | Gate statuses incomplete | Update gate ruleset props | โ†’ Phase 4 (Deploy) |
815
+ | Setting value wrong | Update via GraphQL mutation | โ†’ Phase 5 (Test) |
816
+ | Test data issue | Fix test inputs | โ†’ Phase 5 (Test) |
817
+ | New rule needed | Create rule + update workflow | โ†’ Phase 2 (Implement) |
818
+
819
+ After fixing, loop back to the indicated phase and continue through to Phase 5 (Test) again.
820
+
821
+ ### 6.5 Loop termination
822
+
823
+ The loop terminates when:
824
+ - **All E2E test steps pass** โ†’ Report success with entity refs, event IDs, versions deployed
825
+ - **Unresolvable blocker** โ†’ Report what was tried, what failed, what needs human intervention
826
+ - **Requirements unclear** โ†’ Report what was analyzed, what options exist, ask for clarification
827
+
828
+ ---
829
+
830
+ ## Cross-Skill Handoff Protocol
831
+
832
+ When orchestrating across skills, use these handoff patterns:
833
+
834
+ | From | To | Handoff data |
835
+ |------|----|-------------|
836
+ | Analyze (Phase 1) | Implement (Phase 2) | Workflow JSON, rule list, entity state, identified gaps |
837
+ | Implement (Phase 2) | Validate (Phase 2.5) | Changed files list, new rule names, updated module.json |
838
+ | Validate (Phase 2.5) | Build (Phase 3) | Validation report (READY_FOR_BUILD / NEEDS_FIXES), content hash |
839
+ | Build (Phase 3) | Deploy (Phase 4) | ZIP path, new version number, what changed (code/workflow/both) |
840
+ | Deploy (Phase 4) | Test (Phase 5) | Deployed version, retailer, profile, entity type affected |
841
+ | Test (Phase 5) | Diagnose (Phase 6) | Failed step, entity ref, event name, expected vs actual status |
842
+ | Diagnose (Phase 6) | Fix (Phase 2/3/4) | Root cause, specific file/ruleset/prop to change |
843
+
844
+ ## MCP Tool Quick Reference
845
+
846
+ | Operation | Tool | Server |
847
+ |-----------|------|--------|
848
+ | Verify connectivity | `config_validate`, `health_ping`, `connection_test` | fluent-mcp-extn |
849
+ | Query entities | `graphql_query` | fluent-mcp-extn |
850
+ | Query all (paginated) | `graphql_queryAll` | fluent-mcp-extn |
851
+ | Create/update entities | `graphql_query` (with mutation) | fluent-mcp-extn |
852
+ | Bulk update | `graphql_batchMutate` | fluent-mcp-extn |
853
+ | Discover schema | `graphql_introspect` | fluent-mcp-extn |
854
+ | Send event | `event_send` | fluent-mcp-extn |
855
+ | Check event result | `event_list`, `event_get` | fluent-mcp-extn |
856
+ | Build event payload | `event_build` | fluent-mcp-extn |
857
+ | Discover transitions | `workflow_transitions` | fluent-mcp-extn |
858
+ | List workflows | CLI: `fluent workflow list` | fluent-mcp (official) |
859
+ | Download workflow | CLI: `fluent workflow download` | fluent-mcp (official) |
860
+ | Upload workflow | REST: `PUT /api/v4.1/workflow` | Direct API call |
861
+ | Deploy module | CLI: `fluent module install` | Direct CLI |
862
+ | Navigate browser | `navigate_page` | chrome-devtools |
863
+ | Page snapshot | `take_snapshot` | chrome-devtools |
864
+ | Screenshot | `take_screenshot` | chrome-devtools |
865
+ | Console errors | `list_console_messages` | chrome-devtools |
866
+ | Click element | `click` | chrome-devtools |
867
+ | Type text | `type_text` | chrome-devtools |
868
+
869
+ ---
870
+
871
+ ## Deploy, Promote, and Rollback
872
+
873
+ This section covers promoting changes across environments and rolling back if something goes wrong. It complements Phase 4 (Deploy) and Phase 5 (Test) above with environment-level operations.
874
+
875
+ ### Required inputs
876
+
877
+ | Input | Example |
878
+ |---|---|
879
+ | Profile | `MY_PROFILE` |
880
+ | Retailer ref | `MY_RETAILER` |
881
+ | Module ZIP | `dist/my-module-1.2.4.zip` |
882
+ | Config file | `module.config.MY_RETAILER.dev.json` |
883
+
884
+ Each environment needs its own config file (e.g., `module.config.MY_RETAILER.staging.json`, `module.config.MY_RETAILER.prod.json`).
885
+
886
+ ### Promotion models
887
+
888
+ Use one model consistently for a release:
889
+
890
+ - **Single-retailer model:** deploy all assets directly to one retailer.
891
+ - **Global + operational model:** deploy master data first to the global retailer, then deploy operational assets to operational retailers. Order matters: (1) global retailer data (products, locations, inventory, core settings), (2) rules (plugin JAR assets), (3) operational retailers (workflows, workflow-fragments, settings, controls). Operational retailers depend on global references, and workflows depend on rules being installed first.
892
+
893
+ ### Step-by-step promotion sequence
894
+
895
+ Promote in this order: **dev -> staging -> prod**. For each environment:
896
+
897
+ **1. Validate environment context**
898
+
899
+ ```bash
900
+ fluent profile active
901
+ fluent module list -p <PROFILE>
902
+ fluent workflow list -p <PROFILE> -r <RETAILER_REF>
903
+ ```
904
+
905
+ Confirm you are targeting the correct profile and retailer before proceeding.
906
+
907
+ **2. Back up current workflows**
908
+
909
+ ```bash
910
+ TS=$(date +%Y%m%d-%H%M%S)
911
+ mkdir -p "backup/$TS/<RETAILER_REF>"
912
+ fluent workflow download --profile <PROFILE> --retailer <RETAILER_REF> -w all -o "backup/$TS/<RETAILER_REF>/"
913
+ ```
914
+
915
+ **3. Run diagnostics gate (`flow-run`)**
916
+
917
+ ```bash
918
+ npx @fluentcommerce/ai-skills flow-run \
919
+ --profile <PROFILE> \
920
+ --retailer <RETAILER_REF> \
921
+ --module dist/<module-name>-<version>.zip \
922
+ --config module.config.<RETAILER_REF>.<env>.json
923
+ ```
924
+
925
+ This is read-only. Review the report at `.fluent-ai-skills/flow-run-report-<timestamp>.json` before deploying.
926
+
927
+ **4. Deploy**
928
+
929
+ Guarded deploy via `flow-run` (recommended):
930
+
931
+ ```bash
932
+ npx @fluentcommerce/ai-skills flow-run \
933
+ --profile <PROFILE> \
934
+ --retailer <RETAILER_REF> \
935
+ --module dist/<module-name>-<version>.zip \
936
+ --config module.config.<RETAILER_REF>.<env>.json \
937
+ --deploy --yes
938
+ ```
939
+
940
+ Or direct CLI deploy:
941
+
942
+ ```bash
943
+ fluent module install dist/<module-name>-<version>.zip \
944
+ --profile <PROFILE> \
945
+ --retailer <RETAILER_REF> \
946
+ --config module.config.<RETAILER_REF>.<env>.json \
947
+ --force
948
+ ```
949
+
950
+ **5. Verify and proceed**
951
+
952
+ ```bash
953
+ fluent module list -p <PROFILE>
954
+ fluent workflow list -p <PROFILE> -r <RETAILER_REF>
955
+ ```
956
+
957
+ Run smoke/E2E checks for the changed flows. Only proceed to the next environment after successful verification.
958
+
959
+ ### Selective deployment
960
+
961
+ Deploy only specific assets when needed:
962
+
963
+ ```bash
964
+ # Workflows + settings only
965
+ fluent module install dist/<module>.zip --profile <PROFILE> --retailer <RETAILER_REF> \
966
+ --include workflows settings --force
967
+
968
+ # Exclude workflows (deploy rules/data only)
969
+ fluent module install dist/<module>.zip --profile <PROFILE> --retailer <RETAILER_REF> \
970
+ --exclude workflows --force
971
+
972
+ # Data-only deployment
973
+ fluent module install dist/<module>.zip --profile <PROFILE> --retailer <RETAILER_REF> \
974
+ --include locations products inventory --force
975
+ ```
976
+
977
+ `--include` and `--exclude` are mutually exclusive in a single command.
978
+
979
+ ### Rollback playbook
980
+
981
+ If a release fails after deployment:
982
+
983
+ **Option A -- Redeploy previous module version**
984
+
985
+ ```bash
986
+ fluent module install dist/<module-name>-<previous-version>.zip \
987
+ --profile <PROFILE> \
988
+ --retailer <RETAILER_REF> \
989
+ --force
990
+ ```
991
+
992
+ **Option B -- Restore workflow backup**
993
+
994
+ Use workflow backups created in `backup/<timestamp>/<RETAILER_REF>/` and re-upload the required workflow JSON via your workflow deployment process or REST upload.
995
+
996
+ Keep versioned release ZIPs and workflow backups for every promotion wave.
997
+
998
+ ### Release checklist
999
+
1000
+ - [ ] Correct profile and retailer confirmed
1001
+ - [ ] New module ZIP built and versioned
1002
+ - [ ] Environment-specific config file selected
1003
+ - [ ] Workflow backup completed
1004
+ - [ ] Diagnostics report generated and reviewed
1005
+ - [ ] Deployment completed successfully
1006
+ - [ ] Post-deploy verification passed
1007
+ - [ ] Rollback artifacts (previous ZIP + workflow backups) available
1008
+
1009
+ ### `flow-run` command reference
1010
+
1011
+ `flow-run` provides a structured execution pipeline for diagnostics and optional module deployment. By default it performs **read-only diagnostics**; write operations occur only when both `--deploy` and `--yes` flags are present.
1012
+
1013
+ ```bash
1014
+ npx @fluentcommerce/ai-skills flow-run [options]
1015
+ ```
1016
+
1017
+ | Option | Description |
1018
+ |---|---|
1019
+ | `--profile <name>` | Fluent profile for module/workflow checks |
1020
+ | `--retailer <ref>` | Retailer ref for workflow checks and deploy |
1021
+ | `--module <name-or-path>` | Module package path/name |
1022
+ | `--config <file>` | Config file to scan for unresolved `[[...]]` placeholders |
1023
+ | `--deploy` | Enables `fluent module install` step |
1024
+ | `--yes` | Mandatory confirmation with `--deploy` |
1025
+ | `--exclude-workflows` | Adds `--exclude workflows` to deploy command |
1026
+ | `--force` | Adds `--force` to deploy command |
1027
+ | `--report <path>` | Custom JSON report output path |
1028
+ | `--skip-mcp-check` | Skip `.mcp.json` validation |
1029
+
1030
+ **What gets checked:** `.mcp.json` presence/validation, unresolved placeholder detection, `fluent --version`, `fluent profile active`, optional module describe/list, optional workflow list. With `--deploy`, also runs `fluent module install` and post-deploy verification.
1031
+
1032
+ **Report output:** Default path `.fluent-ai-skills/flow-run-report-<timestamp>.json`. Exits `0` when no failing checks; non-zero when any failed checks are present.
1033
+
1034
+ ---
1035
+
1036
+ ## Related
1037
+
1038
+ - [Prompt Guide](02-prompt-guide.md) โ€” which skills exist, what to type, agent routing, lifecycle stages
1039
+ - [Chrome DevTools MCP](chrome-devtools-mcp-reference.md) โ€” browser automation and UI testing reference
1040
+ - [Use Cases](03-use-cases.md) โ€” 21 scenario-based walkthroughs with exact prompts