@fluentcommerce/ai-skills 0.1.0 → 0.3.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.

Potentially problematic release.


This version of @fluentcommerce/ai-skills might be problematic. Click here for more details.

Files changed (168) hide show
  1. package/README.md +866 -622
  2. package/bin/cli.mjs +2112 -1973
  3. package/content/cli/agents/fluent-cli/agent.json +149 -149
  4. package/content/cli/agents/fluent-cli.md +132 -132
  5. package/content/cli/skills/fluent-bootstrap/SKILL.md +214 -181
  6. package/content/cli/skills/fluent-cli-index/SKILL.md +1 -1
  7. package/content/cli/skills/fluent-cli-mcp-cicd/SKILL.md +117 -1
  8. package/content/cli/skills/fluent-cli-reference/SKILL.md +1040 -1031
  9. package/content/cli/skills/fluent-cli-retailer/SKILL.md +27 -2
  10. package/content/cli/skills/fluent-cli-settings/SKILL.md +21 -1
  11. package/content/cli/skills/fluent-connect/SKILL.md +937 -886
  12. package/content/cli/skills/fluent-module-deploy/SKILL.md +63 -5
  13. package/content/cli/skills/fluent-profile/SKILL.md +73 -0
  14. package/content/cli/skills/fluent-workflow/SKILL.md +360 -310
  15. package/content/dev/agents/fluent-backend-dev/AGENT.md +58 -0
  16. package/content/dev/agents/fluent-backend-dev/agent.json +69 -0
  17. package/content/dev/agents/fluent-backend-dev.md +287 -0
  18. package/content/dev/agents/fluent-dev/AGENT.md +98 -0
  19. package/content/dev/agents/fluent-dev/agent.json +14 -2
  20. package/content/dev/agents/fluent-dev.md +194 -525
  21. package/content/dev/agents/fluent-frontend-dev/AGENT.md +63 -0
  22. package/content/dev/agents/fluent-frontend-dev/agent.json +52 -0
  23. package/content/dev/agents/fluent-frontend-dev.md +323 -0
  24. package/content/dev/skills/fluent-archive/SKILL.md +234 -0
  25. package/content/dev/skills/fluent-build/SKILL.md +312 -192
  26. package/content/dev/skills/fluent-connection-analysis/SKILL.md +422 -386
  27. package/content/dev/skills/fluent-custom-code/SKILL.md +15 -9
  28. package/content/dev/skills/fluent-data-module-scaffold/SKILL.md +19 -2
  29. package/content/dev/skills/fluent-e2e-test/SKILL.md +501 -394
  30. package/content/dev/skills/fluent-event-api/SKILL.md +962 -945
  31. package/content/dev/skills/fluent-feature-explain/SKILL.md +680 -603
  32. package/content/dev/skills/fluent-feature-plan/PLAN_TEMPLATE.md +27 -2
  33. package/content/dev/skills/fluent-feature-plan/SKILL.md +478 -227
  34. package/content/dev/skills/fluent-feature-status/SKILL.md +335 -0
  35. package/content/dev/skills/fluent-feedback/SKILL.md +221 -0
  36. package/content/dev/skills/fluent-implementation-map/SKILL.md +644 -0
  37. package/content/dev/skills/fluent-job-batch/SKILL.md +10 -0
  38. package/content/dev/skills/fluent-module-scaffold/SKILL.md +64 -2
  39. package/content/dev/skills/fluent-module-validate/SKILL.md +778 -775
  40. package/content/dev/skills/fluent-mystique-analyze/SKILL.md +817 -0
  41. package/content/dev/skills/fluent-mystique-builder/COMPONENT_TEMPLATE.md +81 -0
  42. package/content/dev/skills/fluent-mystique-builder/README.md +63 -0
  43. package/content/dev/skills/fluent-mystique-builder/SKILL.md +1294 -0
  44. package/content/dev/skills/fluent-mystique-builder/components/INDEX.md +92 -0
  45. package/content/dev/skills/fluent-mystique-builder/components/fc.accordion.md +48 -0
  46. package/content/dev/skills/fluent-mystique-builder/components/fc.action.field.fulfilmentpack.md +20 -0
  47. package/content/dev/skills/fluent-mystique-builder/components/fc.action.field.multiparcel.md +21 -0
  48. package/content/dev/skills/fluent-mystique-builder/components/fc.action.field.returnitems.md +21 -0
  49. package/content/dev/skills/fluent-mystique-builder/components/fc.action.field.wavepick.md +21 -0
  50. package/content/dev/skills/fluent-mystique-builder/components/fc.action.inline.md +24 -0
  51. package/content/dev/skills/fluent-mystique-builder/components/fc.activity.entity.md +25 -0
  52. package/content/dev/skills/fluent-mystique-builder/components/fc.analytics.viz.md +20 -0
  53. package/content/dev/skills/fluent-mystique-builder/components/fc.attribute.column.md +111 -0
  54. package/content/dev/skills/fluent-mystique-builder/components/fc.attribute.json.md +20 -0
  55. package/content/dev/skills/fluent-mystique-builder/components/fc.attribute.jsoneditor.md +54 -0
  56. package/content/dev/skills/fluent-mystique-builder/components/fc.attribute.locationId.md +51 -0
  57. package/content/dev/skills/fluent-mystique-builder/components/fc.attribute.retailerId.md +52 -0
  58. package/content/dev/skills/fluent-mystique-builder/components/fc.button.bar.md +57 -0
  59. package/content/dev/skills/fluent-mystique-builder/components/fc.button.print.download.md +53 -0
  60. package/content/dev/skills/fluent-mystique-builder/components/fc.button.print.inline.compatibility.md +60 -0
  61. package/content/dev/skills/fluent-mystique-builder/components/fc.button.print.inline.md +53 -0
  62. package/content/dev/skills/fluent-mystique-builder/components/fc.button.print.md +24 -0
  63. package/content/dev/skills/fluent-mystique-builder/components/fc.button.print.pick.md +61 -0
  64. package/content/dev/skills/fluent-mystique-builder/components/fc.buttons.add.reject.md +20 -0
  65. package/content/dev/skills/fluent-mystique-builder/components/fc.card.attribute.md +73 -0
  66. package/content/dev/skills/fluent-mystique-builder/components/fc.card.attributes.grid.md +40 -0
  67. package/content/dev/skills/fluent-mystique-builder/components/fc.card.image.md +37 -0
  68. package/content/dev/skills/fluent-mystique-builder/components/fc.card.map.point.md +24 -0
  69. package/content/dev/skills/fluent-mystique-builder/components/fc.card.multi.md +79 -0
  70. package/content/dev/skills/fluent-mystique-builder/components/fc.card.product.md +27 -0
  71. package/content/dev/skills/fluent-mystique-builder/components/fc.chart.area.md +34 -0
  72. package/content/dev/skills/fluent-mystique-builder/components/fc.chart.area.wrapper.feed.md +98 -0
  73. package/content/dev/skills/fluent-mystique-builder/components/fc.chart.bar.md +52 -0
  74. package/content/dev/skills/fluent-mystique-builder/components/fc.chart.bar.wrapper.source.md +104 -0
  75. package/content/dev/skills/fluent-mystique-builder/components/fc.chart.gauge.md +28 -0
  76. package/content/dev/skills/fluent-mystique-builder/components/fc.chart.gauge.wrapper.threshold.md +118 -0
  77. package/content/dev/skills/fluent-mystique-builder/components/fc.chart.line.md +32 -0
  78. package/content/dev/skills/fluent-mystique-builder/components/fc.conditional.md +62 -0
  79. package/content/dev/skills/fluent-mystique-builder/components/fc.dashboard.threshold.md +65 -0
  80. package/content/dev/skills/fluent-mystique-builder/components/fc.daterange.wrapper.forwarder.md +56 -0
  81. package/content/dev/skills/fluent-mystique-builder/components/fc.drawer.button.md +21 -0
  82. package/content/dev/skills/fluent-mystique-builder/components/fc.event.detail.md +20 -0
  83. package/content/dev/skills/fluent-mystique-builder/components/fc.events.search.md +21 -0
  84. package/content/dev/skills/fluent-mystique-builder/components/fc.field.daterange.md +83 -0
  85. package/content/dev/skills/fluent-mystique-builder/components/fc.field.filterComplex.md +106 -0
  86. package/content/dev/skills/fluent-mystique-builder/components/fc.field.intrange.md +82 -0
  87. package/content/dev/skills/fluent-mystique-builder/components/fc.field.multistring.md +50 -0
  88. package/content/dev/skills/fluent-mystique-builder/components/fc.filterPanel.md +53 -0
  89. package/content/dev/skills/fluent-mystique-builder/components/fc.json.editor.md +22 -0
  90. package/content/dev/skills/fluent-mystique-builder/components/fc.json.viewer.md +21 -0
  91. package/content/dev/skills/fluent-mystique-builder/components/fc.list.customAction.md +79 -0
  92. package/content/dev/skills/fluent-mystique-builder/components/fc.list.md +116 -0
  93. package/content/dev/skills/fluent-mystique-builder/components/fc.list.wrapper.bppmetrics.md +69 -0
  94. package/content/dev/skills/fluent-mystique-builder/components/fc.list.wrapper.feed.md +65 -0
  95. package/content/dev/skills/fluent-mystique-builder/components/fc.list.wrapper.source.md +64 -0
  96. package/content/dev/skills/fluent-mystique-builder/components/fc.modal.button.addItem.md +60 -0
  97. package/content/dev/skills/fluent-mystique-builder/components/fc.modal.button.md +21 -0
  98. package/content/dev/skills/fluent-mystique-builder/components/fc.mutation.inline.md +88 -0
  99. package/content/dev/skills/fluent-mystique-builder/components/fc.mystique.collapsible.attributes.md +83 -0
  100. package/content/dev/skills/fluent-mystique-builder/components/fc.mystique.collapsible.text.md +33 -0
  101. package/content/dev/skills/fluent-mystique-builder/components/fc.mystique.link.md +30 -0
  102. package/content/dev/skills/fluent-mystique-builder/components/fc.order.itemDetails.md +20 -0
  103. package/content/dev/skills/fluent-mystique-builder/components/fc.order.shipmentDetails.md +20 -0
  104. package/content/dev/skills/fluent-mystique-builder/components/fc.page.filter.select.md +87 -0
  105. package/content/dev/skills/fluent-mystique-builder/components/fc.page.md +64 -0
  106. package/content/dev/skills/fluent-mystique-builder/components/fc.page.refresh.md +48 -0
  107. package/content/dev/skills/fluent-mystique-builder/components/fc.page.section.column.md +71 -0
  108. package/content/dev/skills/fluent-mystique-builder/components/fc.page.section.header.md +61 -0
  109. package/content/dev/skills/fluent-mystique-builder/components/fc.page.section.md +59 -0
  110. package/content/dev/skills/fluent-mystique-builder/components/fc.page.wizard.md +45 -0
  111. package/content/dev/skills/fluent-mystique-builder/components/fc.page.wizard.summary.md +56 -0
  112. package/content/dev/skills/fluent-mystique-builder/components/fc.progress.circular.md +20 -0
  113. package/content/dev/skills/fluent-mystique-builder/components/fc.provider.graphql.md +71 -0
  114. package/content/dev/skills/fluent-mystique-builder/components/fc.quantity.list.md +87 -0
  115. package/content/dev/skills/fluent-mystique-builder/components/fc.repeater.md +56 -0
  116. package/content/dev/skills/fluent-mystique-builder/components/fc.reports.ipuipc.md +54 -0
  117. package/content/dev/skills/fluent-mystique-builder/components/fc.return.rowExpansion.md +19 -0
  118. package/content/dev/skills/fluent-mystique-builder/components/fc.scanner.barcode.md +21 -0
  119. package/content/dev/skills/fluent-mystique-builder/components/fc.scanner.barcodeFilter.md +72 -0
  120. package/content/dev/skills/fluent-mystique-builder/components/fc.scanner.camera.md +20 -0
  121. package/content/dev/skills/fluent-mystique-builder/components/fc.settingForm.md +64 -0
  122. package/content/dev/skills/fluent-mystique-builder/components/fc.sourcing.profile.drawer.button.md +19 -0
  123. package/content/dev/skills/fluent-mystique-builder/components/fc.sourcing.profile.modal.button.md +64 -0
  124. package/content/dev/skills/fluent-mystique-builder/components/fc.sourcing.strategy.modal.button.md +20 -0
  125. package/content/dev/skills/fluent-mystique-builder/components/fc.stepper.md +20 -0
  126. package/content/dev/skills/fluent-mystique-builder/components/fc.tab.content.md +56 -0
  127. package/content/dev/skills/fluent-mystique-builder/components/fc.tabs.card.md +64 -0
  128. package/content/dev/skills/fluent-mystique-builder/components/fc.tabs.md +69 -0
  129. package/content/dev/skills/fluent-mystique-builder/components/fc.tile.metric.md +73 -0
  130. package/content/dev/skills/fluent-mystique-builder/components/fc.workflow.provider.md +77 -0
  131. package/content/dev/skills/fluent-mystique-builder/validate-docs.ps1 +260 -0
  132. package/content/dev/skills/fluent-mystique-scaffold/SKILL.md +1830 -0
  133. package/content/dev/skills/fluent-mystique-validate/SKILL.md +646 -0
  134. package/content/dev/skills/fluent-pre-deploy-check/SKILL.md +1144 -1108
  135. package/content/dev/skills/fluent-retailer-config/SKILL.md +1162 -1111
  136. package/content/dev/skills/fluent-rollback/SKILL.md +387 -0
  137. package/content/dev/skills/fluent-rule-scaffold/SKILL.md +515 -385
  138. package/content/dev/skills/fluent-scope-decompose/SKILL.md +1123 -1021
  139. package/content/dev/skills/fluent-session-audit-export/SKILL.md +880 -632
  140. package/content/dev/skills/fluent-session-summary/SKILL.md +320 -195
  141. package/content/dev/skills/fluent-settings/SKILL.md +160 -1
  142. package/content/dev/skills/fluent-source-onboard/SKILL.md +31 -3
  143. package/content/dev/skills/fluent-sourcing/SKILL.md +1185 -0
  144. package/content/dev/skills/fluent-system-monitoring/SKILL.md +771 -767
  145. package/content/dev/skills/fluent-test-data/SKILL.md +514 -513
  146. package/content/dev/skills/fluent-trace/SKILL.md +1169 -1143
  147. package/content/dev/skills/fluent-transition-api/SKILL.md +364 -346
  148. package/content/dev/skills/fluent-use-case-discover/SKILL.md +593 -0
  149. package/content/dev/skills/fluent-use-case-discover/SPEC_TEMPLATE.md +281 -0
  150. package/content/dev/skills/fluent-version-manage/SKILL.md +53 -2
  151. package/content/dev/skills/fluent-workflow-analyzer/SKILL.md +995 -959
  152. package/content/dev/skills/fluent-workflow-builder/SKILL.md +668 -319
  153. package/content/dev/skills/fluent-workflow-deploy/SKILL.md +480 -267
  154. package/content/dev/skills/fluent-workspace-tree/SKILL.md +281 -0
  155. package/content/mcp-extn/agents/fluent-mcp.md +133 -69
  156. package/content/mcp-extn/skills/fluent-mcp-tools/SKILL.md +812 -461
  157. package/content/mcp-official/agents/fluent-mcp-core.md +91 -91
  158. package/content/mcp-official/skills/fluent-mcp-core/SKILL.md +94 -94
  159. package/content/rfl/skills/fluent-rfl-assess/SKILL.md +172 -172
  160. package/docs/CAPABILITY_MAP.md +106 -77
  161. package/docs/DEPLOYMENT_PROMOTION_RUNBOOK.md +218 -0
  162. package/docs/DESIGN-implementation-map.md +698 -0
  163. package/docs/DEV_WORKFLOW.md +814 -802
  164. package/docs/FLOW_RUN.md +142 -142
  165. package/docs/GETTING_STARTED.md +427 -0
  166. package/docs/USE_CASES.md +909 -52
  167. package/metadata.json +184 -156
  168. package/package.json +3 -2
@@ -1,603 +1,680 @@
1
- ---
2
- name: fluent-feature-explain
3
- description: Reverse-engineer and explain an existing Fluent Commerce feature. Synthesizes workflow analysis, custom code logic, connection topology, and live runtime evidence into a comprehensive, visually rich Feature Architecture Document saved to accounts/<PROFILE>/analysis/features/. Triggers on "explain feature", "how does this work", "reverse engineer", "feature architecture", "document this flow", "what does this workflow do".
4
- user-invocable: true
5
- allowed-tools: Bash, Read, Write, Edit, Glob, Grep
6
- argument-hint: <feature-name-or-workflow> [--depth shallow|full] [--include-runtime] [--output <path>]
7
- ---
8
-
9
- # Feature Explainer
10
-
11
- Reverse-engineer an existing feature to produce a comprehensive **Feature Architecture Document**. Orchestrates workflow analysis, code analysis, connection mapping, and live runtime evidence to explain *how* a feature is implemented end-to-end — from input trigger to terminal state, across all impacted entities.
12
-
13
- ## Ownership Boundary
14
-
15
- This skill owns the **synthesis** of analysis artifacts into unified feature documentation.
16
-
17
- Source analysis skills (called as needed, not duplicated):
18
- - Workflow structure analysis -> `/fluent-workflow-analyzer`
19
- - Code logic analysis -> `/fluent-custom-code`
20
- - Dependency mapping -> `/fluent-connection-analysis`
21
- - Runtime event forensics -> `/fluent-trace`
22
- - Settings cross-reference -> `/fluent-settings`
23
-
24
- MCP tools used directly:
25
- - `plugin.list` — Rule descriptions, entity types, parameters
26
- - `workflow.transitions` — Available user actions per status
27
- - `environment.discover` — Environment context (locations, networks, catalogues)
28
- - `event.flowInspect` — Runtime event trace (when `--include-runtime` or real entity ref provided)
29
- - `entity.get` — Entity state and edge traversal
30
-
31
- ## When to Use
32
-
33
- - "Explain how the Home Delivery order flow works end-to-end"
34
- - "Reverse engineer the Click & Collect fulfilment feature"
35
- - "Document the Return Order implementation for the team"
36
- - "What entities, rules, and settings are involved in order allocation?"
37
- - "How does ORDER::HD work? Show me diagrams"
38
- - Onboarding new developers to an existing implementation
39
- - Pre-change understanding before modifying a complex feature
40
- - Stakeholder documentation and handover packs
41
-
42
- ## Output Location
43
-
44
- All generated documents are saved to:
45
-
46
- ```
47
- accounts/<PROFILE>/analysis/features/<FEATURE_NAME>.md
48
- ```
49
-
50
- Where `<FEATURE_NAME>` is derived from the user's request:
51
- - Workflow name: `ORDER::HD` -> `ORDER_HD.md`
52
- - Feature name: `"Home Delivery"` -> `Home_Delivery.md`
53
- - Custom name via `--output`: saves to the specified path
54
-
55
- Each document includes a metadata header for traceability:
56
-
57
- ```markdown
58
- <!-- Feature Architecture Document -->
59
- <!-- Generated: 2026-02-23T14:30:00Z -->
60
- <!-- Profile: HMDEV -->
61
- <!-- Retailer: HM_TEST (ID: 5) -->
62
- <!-- Workflows: ORDER::HD (v1.50), FULFILMENT::HD_WH (v1.22) -->
63
- <!-- Depth: full -->
64
- <!-- Runtime evidence: yes (entity: HD-001) -->
65
- ```
66
-
67
- ## Execution Protocol
68
-
69
- ### Phase 1: Scope Identification
70
-
71
- 1. **Parse user request** — Extract feature name, workflow names, entity types, or entry points.
72
-
73
- 2. **Discover workflows** — If the user names a feature (not a workflow), map it to candidate workflows:
74
- - Search workflow JSON filenames in `accounts/<PROFILE>/workflows/<RETAILER>/`
75
- - If workflows not downloaded, download them first:
76
- ```bash
77
- fluent workflow download -p <PROFILE> -r <RETAILER_REF> -w all -o accounts/<PROFILE>/workflows/<RETAILER_REF>/
78
- ```
79
- - Match by entity type, subtype, or keyword in workflow names/rulesets
80
-
81
- 3. **Determine boundaries:**
82
- - **Primary entity type** (e.g., ORDER)
83
- - **Related entity types** (e.g., FULFILMENT_CHOICE, FULFILMENT, ARTICLE)
84
- - **Entry events** (what triggers this feature)
85
- - **Terminal states** (where the feature ends)
86
-
87
- 4. **Select depth:**
88
- - `--depth shallow` — Primary workflow only, no cross-entity tracing
89
- - `--depth full` (default) — All related workflows, cross-entity flows, settings, integrations
90
-
91
- ### Phase 2: Structural Analysis
92
-
93
- For each workflow in scope, invoke `/fluent-workflow-analyzer` capabilities:
94
-
95
- **From workflow JSON (static analysis):**
96
- - Parse all statuses, rulesets, triggers, and rules
97
- - Classify process flows (CREATE, USER_ACTION, SCHEDULED_EVENT, CROSS_WORKFLOW, INTEGRATION_EVENT, INTERNAL)
98
- - Build status transition graph
99
- - Identify event chains from entry to terminal states
100
-
101
- **From MCP tools (live data):**
102
- - `plugin.list` — Get rule descriptions, accepted entity types, produced events, parameters for every rule in the workflow
103
- - `workflow.transitions` — Query available user actions at each status (validates the state machine against deployed workflow)
104
-
105
- **Produce:**
106
- - Status state machine per entity type
107
- - Event chain from trigger to terminal
108
- - Process flow classification table
109
-
110
- ### Phase 3: Logic Analysis
111
-
112
- For rules involved in the feature, gather behavior information using a tiered approach based on available evidence:
113
-
114
- **Tier 1: `plugin.list` MCP tool** (always available):
115
- - Rule descriptions (what the rule does)
116
- - Event attributes consumed (what data the rule reads)
117
- - Parameters (configurable behavior)
118
- - Accepted entity types
119
-
120
- **Tier 2: Source code analysis** (when `accounts/<PROFILE>/SOURCE/` exists):
121
- Invoke `/fluent-custom-code` to analyze Java source:
122
- - `source-map.json` Rule class locations, test coverage
123
- - `workflow-rule-map.json` — Rule-to-workflow mapping with confidence
124
- - `behavior-map.md`Human-readable behavior descriptions
125
-
126
- **Source code validation** (automatically triggered for custom rules):
127
- - Cross-reference rule props from workflow JSON against what the Java code actually reads
128
- - Verify that configurable JSON paths (e.g., `sourcingLocationPath`) match fields the code navigates
129
- - Check test coverage per custom rule — flag untested rules
130
- - Identify any rules referenced in the workflow but missing from SOURCE (gap)
131
-
132
- **Tier 2b: JAR decompilation** (when source code is missing for some rules but JARs exist):
133
-
134
- After completing Tier 2 source analysis, identify any custom rules still unresolved (found in workflow JSON + plugin.list but not in SOURCE Java files). For these rules:
135
-
136
- **How to find rules without decompiling (discovery vs decompilation are separate):**
137
- - `plugin.list` gives you the rule's fully qualified key (e.g., `SAGIRISH.order.ForwardEventByFulfilmentChoiceType`) the namespace prefix (`order`) hints at the module name
138
- - `jar tf` lists all class file paths inside a JAR by reading the ZIP index — **no decompilation needed** for discovery
139
- - Only after confirming which JAR contains the class do you extract + decompile it
140
-
141
- 1. **Ensure CFR decompiler is available** auto-download if missing:
142
- ```bash
143
- # Check for CFR in workspace tools/ directory
144
- if [ ! -f tools/cfr.jar ]; then
145
- mkdir -p tools
146
- curl -L -o tools/cfr.jar "https://github.com/leibnitz27/cfr/releases/download/0.152/cfr-0.152.jar"
147
- fi
148
- # Verify it works
149
- java -jar tools/cfr.jar --version
150
- ```
151
- CFR is a single-JAR decompiler (~2MB), no installation needed — just `java -jar`.
152
-
153
- 2. **Search for JARs recursively** under `accounts/<PROFILE>/SOURCE/`:
154
- ```bash
155
- find accounts/<PROFILE>/SOURCE/ -name "*.jar" -type f
156
- ```
157
- Look in: reference modules (`referece modules/`, `reference-modules/`), `assets/rules/`, `dist/`, `target/`.
158
-
159
- 3. **Match unresolved rules to JARs** — `jar tf` reads the ZIP directory index (instant, no decompilation). For each JAR, check for matching class names:
160
- ```bash
161
- jar tf <path-to-jar> | grep -i "<RuleClassName>"
162
- ```
163
- This tells you exactly which JAR contains which rule, and the full package path.
164
-
165
- 4. **Decompile the matched JAR** with CFR using `--jarfilter` to extract only rule classes:
166
- ```bash
167
- java -jar tools/cfr.jar "<path-to-jar>" \
168
- --outputdir "accounts/<PROFILE>/SOURCE/.decompiled/<jar-basename>" \
169
- --jarfilter "com.fluentcommerce.rule"
170
- ```
171
- The `--jarfilter` flag restricts decompilation to classes matching the package prefix, keeping output focused on rule logic only. This produces clean, readable Java files organized by package path.
172
-
173
- 5. **Create a `DECOMPILED.md` marker** in the output directory:
174
- ```markdown
175
- # Decompiled Source
176
- - **Source JAR:** `<path-to-jar>`
177
- - **Decompiled on:** <date>
178
- - **Decompiler:** CFR 0.152
179
- - **Rule classes:** <count>
180
- - **Filter:** `com.fluentcommerce.rule.*`
181
- - **Note:** This is decompiled bytecode, not original source. Variable names may be synthetic.
182
- ```
183
-
184
- 6. **Fallback if Java not available** — extract and disassemble individual classes:
185
- ```bash
186
- mkdir -p /tmp/jar-decompile && cd /tmp/jar-decompile
187
- jar xf <path-to-jar> <class-path>
188
- javap -c -p <extracted-class-file>
189
- ```
190
- `javap -c -p` provides bytecode disassembly sufficient to determine matching logic, null guards, data flow, and exception handling.
191
-
192
- 7. **Confidence level:**
193
- - Full decompilation (CFR/Fernflower): mark as **HIGH** readable Java, prop names visible, logic clear
194
- - `javap` bytecode: mark as **HIGH** implementation logic is unambiguous from bytecode
195
- - Note the JAR version, decompiler version, and source path in the document metadata
196
-
197
- **If SOURCE directory is missing or empty (no source, no JARs):**
198
- - Ask the user: "Custom rules were found but no source code or JARs are available under `accounts/<PROFILE>/SOURCE/`. Options: (1) Clone plugin repos to `accounts/<PROFILE>/SOURCE/<repo>/` (2) Place reference module ZIPs/JARs in `accounts/<PROFILE>/SOURCE/` for decompilation (3) Run `/fluent-connect` for full workspace preparation including JAR provision"
199
- - If user declines or source unavailable, proceed with Tier 1 only and add confidence caveats to the document:
200
- - Mark affected rules as **MEDIUM confidence** (behavior inferred from plugin.list + runtime only)
201
- - Add explicit "What we don't know" column for each affected rule
202
- - Note in Analysis Caveats: "For more accurate analysis of these rules, provide source code or module JARs"
203
-
204
- **Tier 3: Runtime evidence** (when entities existsee Phase 5):
205
- - Validates static analysis against actual execution
206
- - Confirms which rulesets actually fire vs which are theorized from workflow JSON
207
-
208
- **Produce:**
209
- - Per-ruleset explanation: what it does, what triggers it, what it changes, what it emits
210
- - Decision points and conditional logic
211
- - Custom vs OOTB rule classification
212
- - **Confidence level per rule** (see Analysis Confidence Levels below)
213
-
214
- ### Phase 4: Connection & Dependency Analysis
215
-
216
- Invoke `/fluent-connection-analysis` capabilities:
217
-
218
- **Map:**
219
- - Internal connections (rulesets within same workflow)
220
- - Cross-entity connections (ORDER -> FULFILMENT_CHOICE -> FULFILMENT)
221
- - Cross-workflow connections (shared events)
222
- - Integration points (webhooks, external system calls)
223
- - Settings dependencies (which settings each ruleset reads)
224
-
225
- **From `/fluent-settings` cross-reference:**
226
- - List all settings referenced by rules in scope
227
- - Show current values (or MISSING status)
228
- - Map setting -> ruleset -> behavior impact
229
-
230
- ### Phase 5: Runtime Evidence (Adaptive)
231
-
232
- **Auto-discovery:** Before asking the user, automatically search for existing entities of the workflow's entity type via GraphQL. Query for entities with matching type/subtype that have reached a non-initial status (e.g., not just CREATED). If entities are found, use the most recently completed one for runtime evidence.
233
-
234
- **When runtime exists** (entities found, or `--include-runtime` specified, or user provides entity ref):
235
-
236
- **IMPORTANT — Staged flowInspect pattern (never call with `compact: false` upfront):**
237
-
238
- **Step 1: Compact call (always start here, ~2-3k tokens):**
239
- ```
240
- event.flowInspect({ rootEntityRef: "<REF>", rootEntityType: "<TYPE>" })
241
- ```
242
- Returns: status flow, anomaly findings, failed webhooks, slowest rulesets, event counts. This is sufficient for the Runtime Evidence section in most cases.
243
-
244
- **Step 2: Targeted drill-down (only if compact findings indicate issues):**
245
- - If anomalies found → `event.get` on specific event IDs from the compact diagnostics
246
- - If webhook failures → compact response already includes failed webhook details
247
- - If rule timing needed call `event.flowInspect` with ONLY `includeRuleDetails: true` (keep compact: true)
248
- - If custom log messages needed → call with ONLY `includeCustomLogs: true` (keep compact: true)
249
-
250
- **NEVER do this** (wastes ~30k tokens of context):
251
- ```
252
- event.flowInspect({ ..., compact: false, includeAudit: true, includeRuleDetails: true, ... })
253
- ```
254
-
255
- **From `entity.get`:**
256
- - Current entity state with edge traversal
257
- - Related entities (fulfilments, items, articles)
258
- - Attribute values at current state
259
-
260
- This grounds the static analysis in real execution evidence.
261
-
262
- **When NO runtime exists** (no entities found for this workflow type):
263
- - Skip the Runtime Evidence section
264
- - Automatically escalate source code analysis depth (Phase 3 Tier 2) if SOURCE is available
265
- - Add the "Analysis Confidence" caveat section to the document (see below)
266
- - Note in the document: "No entities of type {entityType}::{subtype} found in the environment. Runtime evidence unavailable. Deploy and process a test entity for validated analysis."
267
-
268
- ### Phase 6: Synthesis Feature Architecture Document
269
-
270
- Combine all findings into the output document with the following sections:
271
-
272
- ---
273
-
274
- ## Document Structure
275
-
276
- ### Section 1: Feature Overview
277
-
278
- ```markdown
279
- # Feature Architecture: <Feature Name>
280
-
281
- ## Overview
282
-
283
- **Purpose:** <1-2 sentence description of what the feature does>
284
- **Primary Entity:** <entity type and subtype> (e.g., ORDER::HD)
285
- **Related Entities:** <list> (e.g., FULFILMENT_CHOICE, FULFILMENT::HD_WH, ARTICLE)
286
- **Workflows:** <list with versions>
287
- **Entry Point:** <triggering event or API call>
288
- **Terminal States:** <list of end states>
289
- ```
290
-
291
- ### Section 2: Entity Lifecycle — State Machine
292
-
293
- One `stateDiagram-v2` per entity type showing ALL statuses and transitions:
294
-
295
- ````markdown
296
- ## Entity Lifecycle
297
-
298
- ### ORDER::HD
299
-
300
- ```mermaid
301
- stateDiagram-v2
302
- [*] --> CREATED : CreateOrder
303
- CREATED --> BOOKED : BookOrder
304
- BOOKED --> FULFILLED : AllFulfilmentsComplete
305
- FULFILLED --> COMPLETE : CompleteOrder
306
- CREATED --> CANCELLED : CancelOrder
307
- BOOKED --> CANCELLED : CancelOrder
308
-
309
- note right of CREATED : Entry point — order submitted
310
- note right of BOOKED : Inventory allocated, fulfilments created
311
- note right of FULFILLED : All items shipped/collected
312
- ```
313
-
314
- ### FULFILMENT::HD_WH
315
-
316
- ```mermaid
317
- stateDiagram-v2
318
- [*] --> CREATED : CreateFulfilment
319
- CREATED --> ASSIGNED : AssignToLocation
320
- ASSIGNED --> PICKED : ConfirmPick
321
- PICKED --> PACKED : ConfirmPack
322
- PACKED --> SHIPPED : ConfirmShipment
323
- SHIPPED --> DELIVERED : ConfirmDelivery
324
- SHIPPED --> COMPLETE : CompleteWithoutDelivery
325
- ```
326
- ````
327
-
328
- ### Section 3: Cross-Entity Flow Sequence Diagram
329
-
330
- Show the full lifecycle across entity types with event names and key data:
331
-
332
- ````markdown
333
- ## Cross-Entity Flow
334
-
335
- ```mermaid
336
- sequenceDiagram
337
- participant EXT as External System
338
- participant ORD as ORDER
339
- participant FC as FULFILMENT_CHOICE
340
- participant FUL as FULFILMENT
341
- participant LOC as Location / WMS
342
-
343
- EXT->>ORD: CreateOrder (ref, items, customer)
344
- ORD->>ORD: CREATED → Validate & Book
345
- ORD->>FC: SendEvent: CreateFulfilmentChoice
346
- FC->>FC: CREATED → Evaluate sourcing
347
- FC->>FUL: SendEvent: CreateFulfilment (locationRef, items)
348
- FC->>ORD: SendEvent: OrderBooked
349
- ORD->>ORD: CREATED BOOKED
350
-
351
- FUL->>LOC: Webhook: NotifyWarehouse (endpoint, payload)
352
- LOC-->>FUL: ConfirmPick (pickedItems)
353
- FUL->>FUL: ASSIGNED PICKED
354
- FUL->>FUL: PICKED PACKED SHIPPED
355
-
356
- FUL->>ORD: SendEvent: FulfilmentComplete
357
- ORD->>ORD: BOOKED FULFILLED COMPLETE
358
- ```
359
- ````
360
-
361
- ### Section 4: Event Chain
362
-
363
- Flowchart showing the event propagation tree:
364
-
365
- ````markdown
366
- ## Event Chain
367
-
368
- ```mermaid
369
- flowchart TD
370
- A[CreateOrder] --> B[ORDER: CREATED]
371
- B --> C{Validate}
372
- C -->|pass| D[BookOrder]
373
- C -->|fail| E[ORDER: CANCELLED]
374
- D --> F[FULFILMENT_CHOICE: CREATED]
375
- F --> G[FULFILMENT: CREATED]
376
- G --> H[AssignToLocation]
377
- H --> I[ConfirmPick]
378
- I --> J[ConfirmPack]
379
- J --> K[ConfirmShipment]
380
- K --> L[FULFILMENT: SHIPPED]
381
- L --> M[ORDER: FULFILLED]
382
- M --> N[ORDER: COMPLETE]
383
-
384
- style E fill:#f99
385
- style N fill:#9f9
386
- ```
387
- ````
388
-
389
- ### Section 5: Input → Output Data Flow
390
-
391
- Table mapping what data enters, transforms, and exits at each step:
392
-
393
- ```markdown
394
- ## Input → Output Data Flow
395
-
396
- | Step | Event / Action | Input Data | Logic / Transformation | Output / Side Effect |
397
- |------|---------------|------------|----------------------|---------------------|
398
- | 1 | CreateOrder | items[], customer, deliveryAddress | Validate structure | ORDER entity CREATED |
399
- | 2 | BookOrder | ORDER attributes | Inventory allocation | FULFILMENT_CHOICE created |
400
- | 3 | CreateFulfilment | locationRef, items | Assign to warehouse | FULFILMENT entity CREATED |
401
- | 4 | ConfirmPick | pickedItems[], picker | Verify quantities | FULFILMENT → PICKED |
402
- | 5 | ConfirmShipment | carrierRef, trackingNum | Link carrier | FULFILMENT → SHIPPED, webhook sent |
403
- | 6 | FulfilmentComplete | fulfilmentRef | Check all complete | ORDER → FULFILLED |
404
- ```
405
-
406
- ### Section 6: Rules & Logic
407
-
408
- Per-ruleset explanation with source:
409
-
410
- ```markdown
411
- ## Rules & Logic
412
-
413
- ### Ruleset: BookOrder (ORDER::HD)
414
-
415
- | Rule | Type | Description | Reads | Produces |
416
- |------|------|-------------|-------|----------|
417
- | ValidateOrderAttributes | OOTB | Validates required order attributes | event.attributes | - |
418
- | CreateFulfilmentChoice | Custom | Creates FC entity with sourcing logic | ORDER items, locations | FULFILMENT_CHOICE entity |
419
- | SetOrderStatus | OOTB | Sets ORDER status to BOOKED | - | status: BOOKED |
420
- | SendOrderBookedEvent | OOTB | Emits event for downstream | orderRef | Event: OrderBooked |
421
-
422
- **Decision Points:**
423
- - If validation fails → ORDER transitions to CANCELLED (CancelOrder ruleset)
424
- - If no sourcing location found → ORDER stays BOOKED, manual intervention required
425
-
426
- **Custom Rule Detail: CreateFulfilmentChoice**
427
- - Source: `accounts/HMDEV/SOURCE/fc-module-hm-extensions/src/main/java/.../CreateFulfilmentChoiceRule.java`
428
- - Reads: `order.items`, `order.deliveryAddress`, location capabilities
429
- - Logic: Evaluates location proximity, stock availability, delivery SLAs
430
- - Produces: FULFILMENT_CHOICE entity with selected location
431
- ```
432
-
433
- ### Section 7: Settings Dependencies
434
-
435
- ```markdown
436
- ## Settings Dependencies
437
-
438
- | Setting Key | Context | Current Value | Used By | Purpose |
439
- |------------|---------|---------------|---------|---------|
440
- | WEBHOOK_ENDPOINT_ORDER_BOOK | RETAILER | https://api.example.com/orders | BookOrder ruleset | Notify external OMS |
441
- | INVENTORY_ALLOCATION_STRATEGY | RETAILER | CLOSEST_LOCATION | CreateFulfilmentChoice | Sourcing algorithm |
442
- | ORDER_VALIDATION_ENABLED | RETAILER | true | ValidateOrder | Feature flag |
443
- | MAX_FULFILMENT_RETRIES | RETAILER | MISSING | RetryFulfilment | **Gap: setting not created** |
444
- ```
445
-
446
- ### Section 8: Integration Points
447
-
448
- ```markdown
449
- ## Integration Points
450
-
451
- ### Webhooks
452
-
453
- | Ruleset | Endpoint Setting | HTTP Method | Payload Shape | Direction |
454
- |---------|-----------------|-------------|---------------|-----------|
455
- | NotifyWarehouse | WEBHOOK_WMS_FULFILMENT | POST | { fulfilmentRef, items, locationRef } | Outbound |
456
- | ReceiveShipment | N/A (inbound event) | POST /event | { trackingNumber, carrier } | Inbound |
457
-
458
- ### Scheduled Events
459
-
460
- | Ruleset | Event Name | Delay | Purpose |
461
- |---------|-----------|-------|---------|
462
- | RetryAllocation | RetryFulfilmentAllocation | 30min | Retry failed sourcing |
463
- | EscalateStuck | EscalateStuckOrder | 24h | Alert ops team |
464
- ```
465
-
466
- ### Section 9: Runtime Evidence (when available)
467
-
468
- ```markdown
469
- ## Runtime Evidence
470
-
471
- **Entity:** ORDER HD-001
472
- **Trace period:** 2026-02-23T10:00:00Z to 2026-02-23T10:15:00Z
473
-
474
- ### Execution Timeline
475
-
476
- | Time | Event | Entity | Status Change | Duration |
477
- |------|-------|--------|--------------|----------|
478
- | 10:00:01 | CreateOrder | ORDER | → CREATED | - |
479
- | 10:00:02 | BookOrder | ORDER | CREATED → BOOKED | 1.2s |
480
- | 10:00:03 | CreateFC | FC | → CREATED | 0.8s |
481
- | 10:00:04 | CreateFulfilment | FUL | → CREATED | 0.5s |
482
- | 10:05:30 | ConfirmPick | FUL | ASSIGNED → PICKED | 0.3s |
483
-
484
- ### Anomalies
485
-
486
- - No anomalies detected (all events SUCCESS)
487
- - OR: `RetryAllocation` fired 3 times before success (check inventory levels)
488
- ```
489
-
490
- ### Section 10: Analysis Confidence (always included)
491
-
492
- This section is **always** included in the document and communicates the depth and reliability of the analysis based on what evidence was available.
493
-
494
- ```markdown
495
- ## Analysis Confidence
496
-
497
- ### Evidence Availability
498
-
499
- | Source | Available | Impact |
500
- |--------|-----------|--------|
501
- | Workflow JSON | Yes | State machine, rulesets, triggers, props — **structural analysis complete** |
502
- | plugin.list (deployed rules) | Yes | Rule descriptions, parameters, entity types — **rule behavior inferred** |
503
- | workflow.transitions (live) | Yes | User actions validated against deployed workflow |
504
- | Source code (Java) | No | Custom rule internals unknown — prop-to-code validation not possible |
505
- | Runtime evidence | No | No executed entities found — theoretical flow only, not validated |
506
-
507
- ### Confidence Levels
508
-
509
- | Aspect | Confidence | Reason |
510
- |--------|------------|--------|
511
- | State machine (statuses, transitions) | HIGH | Derived from workflow JSON definitive |
512
- | Event chain (happy path) | HIGH | Traced through rulesets + triggers — deterministic |
513
- | Event chain (error/edge paths) | MEDIUM | Inferred from trigger coverage — not runtime-validated |
514
- | Custom rule behavior | LOW | Only plugin.list description available — actual Java logic not inspected |
515
- | Webhook payload shapes | LOW | Setting keys identified but payload templates not inspected |
516
- | Integration timing / performance | N/A | No runtime evidence |
517
- | Settings values | MEDIUM | Keys identified from rule props — current values need `/fluent-settings` audit |
518
-
519
- ### Recommendations for Higher Confidence
520
-
521
- 1. **Clone plugin source code** to `accounts/<PROFILE>/SOURCE/` and re-run with source analysis:
522
- - Enables prop-to-code validation for custom rules
523
- - Reveals actual logic, edge cases, and error handling
524
- - Shows test coverage per rule
525
- 2. **If source repos unavailable, provide module JARs** in `accounts/<PROFILE>/SOURCE/`:
526
- - Run `/fluent-custom-code` to decompile JARs into `.decompiled/` (CFR or Fernflower)
527
- - Decompiled source gives MEDIUM confidence (synthetic variable names, no comments)
528
- - Still enables cross-referencing workflow props against actual `context.getProp()` calls
529
- 3. **Process a test entity** through the workflow and re-run with `--include-runtime`:
530
- - Validates which rulesets actually fire
531
- - Reveals timing, webhook responses, and NO_MATCH events
532
- - Confirms the theoretical flow matches reality
533
- 3. **Run `/fluent-settings` audit** to verify all referenced settings exist with correct values
534
- ```
535
-
536
- **Confidence level rules:**
537
-
538
- | Evidence combination | Custom rule confidence | Flow confidence |
539
- |---------------------|----------------------|-----------------|
540
- | Workflow JSON + plugin.list only | LOW | HIGH (structure) / MEDIUM (behavior) |
541
- | + Decompiled JAR (no original source) | MEDIUM | HIGH |
542
- | + Original source code | HIGH | HIGH |
543
- | + Runtime evidence | HIGH (validated) | HIGH (validated) |
544
- | All three (original source + runtime) | HIGHEST — fully validated | HIGHEST — fully validated |
545
-
546
- ---
547
-
548
- ## Arguments
549
-
550
- | Argument | Description | Default |
551
- |----------|-------------|---------|
552
- | `<feature>` | Feature name, workflow name (e.g., `ORDER::HD`), or entity ref | Required |
553
- | `--depth shallow` | Primary workflow only, no cross-entity tracing | `full` |
554
- | `--depth full` | All related workflows, cross-entity flows, settings, integrations | Default |
555
- | `--include-runtime` | Collect live event trace via `event.flowInspect` | Off unless entity ref provided |
556
- | `--output <path>` | Custom output path instead of default `accounts/<PROFILE>/analysis/features/` | Auto-generated |
557
-
558
- ## Quality Checklist
559
-
560
- Before saving the document, verify:
561
-
562
- - [ ] State diagram shows ALL statuses in the workflow, not just the happy path
563
- - [ ] Cross-entity sequence diagram includes event names AND key data flowing between entities
564
- - [ ] Every ruleset in scope has an explanation row in the Rules & Logic table
565
- - [ ] Settings table shows current values with MISSING flagged for any gaps
566
- - [ ] Integration points table includes endpoint, HTTP method, and payload shape
567
- - [ ] Input → Output data flow table covers every step from entry to terminal
568
- - [ ] Custom rules have source file paths (or "source unavailable" noted)
569
- - [ ] Terminal states are clearly identified (success AND failure paths)
570
- - [ ] Mermaid diagrams render correctly — validate against `/fluent-mermaid-validate` rules (no colons in free text, no unicode arrows, quoted special-char labels)
571
- - [ ] Metadata header includes profile, retailer, workflow versions, generation timestamp
572
- - [ ] **Analysis Confidence section is present** with evidence availability table and per-aspect confidence levels
573
- - [ ] **Missing evidence is called out** if no source code or runtime, recommendations section explains how to get higher confidence
574
-
575
- ## Cross-References
576
-
577
- - Workflow structure details: `/fluent-workflow-analyzer`
578
- - Custom code behavior: `/fluent-custom-code`
579
- - Connection topology: `/fluent-connection-analysis`
580
- - Runtime debugging: `/fluent-trace`
581
- - Settings audit: `/fluent-settings`
582
- - Environment discovery: `/fluent-mcp-tools` → `environment.discover`
583
- - Rule descriptions: `/fluent-mcp-tools` `plugin.list`
584
- - User actions per status: `/fluent-mcp-tools` `workflow.transitions`
585
-
586
- ## Example Usage
587
-
588
- ```bash
589
- # Explain a workflow by name
590
- /fluent-feature-explain ORDER::HD
591
-
592
- # Explain a named feature (maps to workflows automatically)
593
- /fluent-feature-explain "Home Delivery"
594
-
595
- # Shallow analysis single workflow only
596
- /fluent-feature-explain FULFILMENT::HD_WH --depth shallow
597
-
598
- # Include runtime evidence from a real entity
599
- /fluent-feature-explain ORDER::HD --include-runtime HD-001
600
-
601
- # Custom output path
602
- /fluent-feature-explain "Click & Collect" --output ./docs/cc-feature.md
603
- ```
1
+ ---
2
+ name: fluent-feature-explain
3
+ description: Reverse-engineer and explain an existing Fluent Commerce feature. Synthesizes workflow analysis, custom code logic, connection topology, and live runtime evidence into a comprehensive, visually rich Feature Architecture Document saved to accounts/<PROFILE>/features/<slug>/architecture.md. Triggers on "explain feature", "how does this work", "reverse engineer", "feature architecture", "document this flow", "what does this workflow do".
4
+ user-invocable: true
5
+ allowed-tools: Bash, Read, Write, Edit, Glob, Grep
6
+ argument-hint: <feature-name-or-workflow> [--depth shallow|full] [--include-runtime] [--output <path>]
7
+ ---
8
+
9
+ # Feature Explainer
10
+
11
+ Reverse-engineer an existing feature to produce a comprehensive **Feature Architecture Document**. Orchestrates workflow analysis, code analysis, connection mapping, and live runtime evidence to explain *how* a feature is implemented end-to-end — from input trigger to terminal state, across all impacted entities.
12
+
13
+ ## Ownership Boundary
14
+
15
+ This skill owns the **synthesis** of analysis artifacts into unified feature documentation.
16
+
17
+ Source analysis skills (called as needed, not duplicated):
18
+ - Workflow structure analysis -> `/fluent-workflow-analyzer`
19
+ - Code logic analysis -> `/fluent-custom-code`
20
+ - Dependency mapping -> `/fluent-connection-analysis`
21
+ - Runtime event forensics -> `/fluent-trace`
22
+ - Settings cross-reference -> `/fluent-settings`
23
+
24
+ MCP tools used directly:
25
+ - `plugin.list` — Rule descriptions, entity types, parameters
26
+ - `workflow.transitions` — Available user actions per status
27
+ - `environment.discover` — Environment context (locations, networks, catalogues)
28
+ - `event.flowInspect` — Runtime event trace (when `--include-runtime` or real entity ref provided)
29
+ - `entity.get` — Entity state and edge traversal
30
+
31
+ ## When to Use
32
+
33
+ - "Explain how the Home Delivery order flow works end-to-end"
34
+ - "Reverse engineer the Click & Collect fulfilment feature"
35
+ - "Document the Return Order implementation for the team"
36
+ - "What entities, rules, and settings are involved in order allocation?"
37
+ - "How does ORDER::HD work? Show me diagrams"
38
+ - Onboarding new developers to an existing implementation
39
+ - Pre-change understanding before modifying a complex feature
40
+ - Stakeholder documentation and handover packs
41
+
42
+ ## Output Location
43
+
44
+ All generated documents are saved to:
45
+
46
+ ```
47
+ accounts/<PROFILE>/features/<slug>/architecture.md
48
+ ```
49
+
50
+ Where `<slug>` is derived from the user's request (kebab-case):
51
+ - Workflow name: `ORDER::HD` -> `order-hd`
52
+ - Feature name: `"Home Delivery"` -> `home-delivery`
53
+ - Custom name via `--output`: saves to the specified path
54
+
55
+ ## Progress
56
+
57
+ Emit this block at each phase transition to show progress:
58
+
59
+ ```
60
+ /fluent-feature-explain [1/6]
61
+ Scope identification → Structural analysis
62
+ Logic analysis ○ Connection & dependencies
63
+ Runtime evidence ○ Synthesis & write doc
64
+ ```
65
+
66
+ Update the block as each phase completes — mark completed phases with `✓`, the active phase with `→`, and remaining phases with `○`. Replace `[1/6]` with the current phase number.
67
+
68
+ Each document includes a metadata header for traceability:
69
+
70
+ ```markdown
71
+ <!-- Feature Architecture Document -->
72
+ <!-- Generated: 2026-02-23T14:30:00Z -->
73
+ <!-- Profile: HMDEV -->
74
+ <!-- Retailer: HM_TEST (ID: 5) -->
75
+ <!-- Workflows: ORDER::HD (v1.50), FULFILMENT::HD_WH (v1.22) -->
76
+ <!-- Depth: full -->
77
+ <!-- Runtime evidence: yes (entity: HD-001) -->
78
+ ```
79
+
80
+ ### Feature Linkage — `basedOn` Field
81
+
82
+ When explaining an existing feature, this skill checks if a new feature is being built on top of it. The "explain then extend" pattern works as follows:
83
+
84
+ 1. User runs `/fluent-feature-explain ORDER::HD` produces `architecture.md` in `features/order-hd/`
85
+ 2. User later says "Now add curbside pickup to this" → `/fluent-use-case-discover` creates `features/curbside-pickup/`
86
+ 3. The new feature's `status.json` can include a `basedOn` field linking back to the architecture doc:
87
+
88
+ ```json
89
+ {
90
+ "basedOn": "features/order-hd/architecture.md"
91
+ }
92
+ ```
93
+
94
+ **When this skill creates an architecture document:**
95
+ - If a `status.json` already exists in the feature directory, update `architecture: true` but do NOT overwrite other fields
96
+ - If no `status.json` exists, create one with minimal fields:
97
+ ```json
98
+ {
99
+ "$schema": "feature-status-v1",
100
+ "feature": "<slug>",
101
+ "retailers": ["<retailer>"],
102
+ "status": "DISCOVERY",
103
+ "created": "<today>",
104
+ "updated": "<today>",
105
+ "spec": null,
106
+ "plan": null,
107
+ "planRevision": null,
108
+ "architecture": true,
109
+ "basedOn": null,
110
+ "next": "/fluent-use-case-discover",
111
+ "sessions": []
112
+ }
113
+ ```
114
+
115
+ **When downstream skills create a feature that builds on an explained feature:**
116
+ - `/fluent-use-case-discover` and `/fluent-feature-plan` should check if the user references an existing architecture document
117
+ - If so, set `basedOn: "features/<base-slug>/architecture.md"` in the new feature's `status.json`
118
+ - The architecture doc is then available as context during spec gathering and planning
119
+
120
+ ## Execution Protocol
121
+
122
+ ### Phase 1: Scope Identification
123
+
124
+ 1. **Parse user request** Extract feature name, workflow names, entity types, or entry points.
125
+
126
+ 2. **Discover workflows** — If the user names a feature (not a workflow), map it to candidate workflows:
127
+ - Search workflow JSON filenames in `accounts/<PROFILE>/workflows/<RETAILER>/`
128
+ - If workflows not downloaded, download them first:
129
+ ```bash
130
+ fluent workflow download -p <PROFILE> -r <RETAILER_REF> -w all -o accounts/<PROFILE>/workflows/<RETAILER_REF>/
131
+ ```
132
+ - Match by entity type, subtype, or keyword in workflow names/rulesets
133
+
134
+ 3. **Determine boundaries:**
135
+ - **Primary entity type** (e.g., ORDER)
136
+ - **Related entity types** (e.g., FULFILMENT_CHOICE, FULFILMENT, ARTICLE)
137
+ - **Entry events** (what triggers this feature)
138
+ - **Terminal states** (where the feature ends)
139
+
140
+ 4. **Select depth:**
141
+ - `--depth shallow` Primary workflow only, no cross-entity tracing
142
+ - `--depth full` (default) — All related workflows, cross-entity flows, settings, integrations
143
+
144
+ 5. **Check for feature context** — If this feature has a `status.json`, read it for context:
145
+ ```bash
146
+ cat accounts/<PROFILE>/features/<slug>/status.json
147
+ ```
148
+ If `basedOn` is set, also read the referenced architecture doc as foundational context. If `spec` is set, read the spec for business context.
149
+
150
+ ### Phase 2: Structural Analysis
151
+
152
+ For each workflow in scope, invoke `/fluent-workflow-analyzer` capabilities:
153
+
154
+ **From workflow JSON (static analysis):**
155
+ - Parse all statuses, rulesets, triggers, and rules
156
+ - Classify process flows (CREATE, USER_ACTION, SCHEDULED_EVENT, CROSS_WORKFLOW, INTEGRATION_EVENT, INTERNAL)
157
+ - Build status transition graph
158
+ - Identify event chains from entry to terminal states
159
+
160
+ **From MCP tools (live data):**
161
+ - `plugin.list` Get rule descriptions, accepted entity types, produced events, parameters for every rule in the workflow
162
+ - `workflow.transitions` — Query available user actions at each status (validates the state machine against deployed workflow)
163
+
164
+ **Strict user-action checks (anti-hallucination):**
165
+ - Treat `userActions[].eventName` as the only valid action trigger (never infer from labels).
166
+ - Treat `userActions[].attributes` as the runtime payload contract (do not invent keys).
167
+ - If expected actions are missing, re-run with `module: "all"` to separate visibility filter issues from workflow design issues.
168
+ - If actions appear under `module: "all"` only, flag `context[].modules` / `fc.mystique.apps` drift.
169
+ - Cross-check workflow authoring against `/fluent-workflow-builder` and diagnostics against `/fluent-transition-api`.
170
+
171
+ **Produce:**
172
+ - Status state machine per entity type
173
+ - Event chain from trigger to terminal
174
+ - Process flow classification table
175
+
176
+ ### Phase 3: Logic Analysis
177
+
178
+ For rules involved in the feature, gather behavior information using a tiered approach based on available evidence:
179
+
180
+ **Tier 1: `plugin.list` MCP tool** (always available):
181
+ - Rule descriptions (what the rule does)
182
+ - Event attributes consumed (what data the rule reads)
183
+ - Parameters (configurable behavior)
184
+ - Accepted entity types
185
+
186
+ **Tier 2: Source code analysis** (when `accounts/<PROFILE>/SOURCE/` exists):
187
+ Invoke `/fluent-custom-code` to analyze Java source:
188
+ - `source-map.json` — Rule class locations, test coverage
189
+ - `workflow-rule-map.json` — Rule-to-workflow mapping with confidence
190
+ - `behavior-map.md` Human-readable behavior descriptions
191
+
192
+ **Source code validation** (automatically triggered for custom rules):
193
+ - Cross-reference rule props from workflow JSON against what the Java code actually reads
194
+ - Verify that configurable JSON paths (e.g., `sourcingLocationPath`) match fields the code navigates
195
+ - Check test coverage per custom rule flag untested rules
196
+ - Identify any rules referenced in the workflow but missing from SOURCE (gap)
197
+
198
+ **Tier 2b: JAR decompilation** (when source code is missing for some rules but JARs exist):
199
+
200
+ After completing Tier 2 source analysis, identify any custom rules still unresolved (found in workflow JSON + plugin.list but not in SOURCE Java files). For these rules:
201
+
202
+ **How to find rules without decompiling (discovery vs decompilation are separate):**
203
+ - `plugin.list` gives you the rule's fully qualified key (e.g., `SAGIRISH.order.ForwardEventByFulfilmentChoiceType`) — the namespace prefix (`order`) hints at the module name
204
+ - `jar tf` lists all class file paths inside a JAR by reading the ZIP index **no decompilation needed** for discovery
205
+ - Only after confirming which JAR contains the class do you extract + decompile it
206
+
207
+ 1. **Ensure CFR decompiler is available** — auto-download if missing:
208
+ ```bash
209
+ # Check for CFR in workspace tools/ directory
210
+ if [ ! -f tools/cfr.jar ]; then
211
+ mkdir -p tools
212
+ curl -L -o tools/cfr.jar "https://github.com/leibnitz27/cfr/releases/download/0.152/cfr-0.152.jar"
213
+ fi
214
+ # Verify it works
215
+ java -jar tools/cfr.jar --version
216
+ ```
217
+ CFR is a single-JAR decompiler (~2MB), no installation needed — just `java -jar`.
218
+
219
+ 2. **Search for JARs recursively** under `accounts/<PROFILE>/SOURCE/`:
220
+ ```bash
221
+ find accounts/<PROFILE>/SOURCE/ -name "*.jar" -type f
222
+ ```
223
+ Look in: reference modules (`referece modules/`, `reference-modules/`), `assets/rules/`, `dist/`, `target/`.
224
+
225
+ 3. **Match unresolved rules to JARs** — `jar tf` reads the ZIP directory index (instant, no decompilation). For each JAR, check for matching class names:
226
+ ```bash
227
+ jar tf <path-to-jar> | grep -i "<RuleClassName>"
228
+ ```
229
+ This tells you exactly which JAR contains which rule, and the full package path.
230
+
231
+ 4. **Decompile the matched JAR** with CFR using `--jarfilter` to extract only rule classes:
232
+ ```bash
233
+ java -jar tools/cfr.jar "<path-to-jar>" \
234
+ --outputdir "accounts/<PROFILE>/SOURCE/.decompiled/<jar-basename>" \
235
+ --jarfilter "com.fluentcommerce.rule"
236
+ ```
237
+ The `--jarfilter` flag restricts decompilation to classes matching the package prefix, keeping output focused on rule logic only. This produces clean, readable Java files organized by package path.
238
+
239
+ 5. **Create a `DECOMPILED.md` marker** in the output directory:
240
+ ```markdown
241
+ # Decompiled Source
242
+ - **Source JAR:** `<path-to-jar>`
243
+ - **Decompiled on:** <date>
244
+ - **Decompiler:** CFR 0.152
245
+ - **Rule classes:** <count>
246
+ - **Filter:** `com.fluentcommerce.rule.*`
247
+ - **Note:** This is decompiled bytecode, not original source. Variable names may be synthetic.
248
+ ```
249
+
250
+ 6. **Fallback if Java not available** extract and disassemble individual classes:
251
+ ```bash
252
+ mkdir -p /tmp/jar-decompile && cd /tmp/jar-decompile
253
+ jar xf <path-to-jar> <class-path>
254
+ javap -c -p <extracted-class-file>
255
+ ```
256
+ `javap -c -p` provides bytecode disassembly sufficient to determine matching logic, null guards, data flow, and exception handling.
257
+
258
+ 7. **Confidence level:**
259
+ - Full decompilation (CFR/Fernflower): mark as **HIGH** — readable Java, prop names visible, logic clear
260
+ - `javap` bytecode: mark as **HIGH** implementation logic is unambiguous from bytecode
261
+ - Note the JAR version, decompiler version, and source path in the document metadata
262
+
263
+ **If SOURCE directory is missing or empty (no source, no JARs):**
264
+ - Ask the user: "Custom rules were found but no source code or JARs are available under `accounts/<PROFILE>/SOURCE/`. Options: (1) Clone plugin repos to `accounts/<PROFILE>/SOURCE/<repo>/` (2) Place reference module ZIPs/JARs in `accounts/<PROFILE>/SOURCE/` for decompilation (3) Run `/fluent-connect` for full workspace preparation including JAR provision"
265
+ - If user declines or source unavailable, proceed with Tier 1 only and add confidence caveats to the document:
266
+ - Mark affected rules as **MEDIUM confidence** (behavior inferred from plugin.list + runtime only)
267
+ - Add explicit "What we don't know" column for each affected rule
268
+ - Note in Analysis Caveats: "For more accurate analysis of these rules, provide source code or module JARs"
269
+
270
+ **Tier 3: Runtime evidence** (when entities exist see Phase 5):
271
+ - Validates static analysis against actual execution
272
+ - Confirms which rulesets actually fire vs which are theorized from workflow JSON
273
+
274
+ **Produce:**
275
+ - Per-ruleset explanation: what it does, what triggers it, what it changes, what it emits
276
+ - Decision points and conditional logic
277
+ - Custom vs OOTB rule classification
278
+ - **Confidence level per rule** (see Analysis Confidence Levels below)
279
+
280
+ ### Phase 4: Connection & Dependency Analysis
281
+
282
+ Invoke `/fluent-connection-analysis` capabilities:
283
+
284
+ **Map:**
285
+ - Internal connections (rulesets within same workflow)
286
+ - Cross-entity connections (ORDER -> FULFILMENT_CHOICE -> FULFILMENT)
287
+ - Cross-workflow connections (shared events)
288
+ - Integration points (webhooks, external system calls)
289
+ - Settings dependencies (which settings each ruleset reads)
290
+
291
+ **From `/fluent-settings` cross-reference:**
292
+ - List all settings referenced by rules in scope
293
+ - Show current values (or MISSING status)
294
+ - Map setting -> ruleset -> behavior impact
295
+
296
+ ### Phase 5: Runtime Evidence (Adaptive)
297
+
298
+ **Auto-discovery:** Before asking the user, automatically search for existing entities of the workflow's entity type via GraphQL. Query for entities with matching type/subtype that have reached a non-initial status (e.g., not just CREATED). If entities are found, use the most recently completed one for runtime evidence.
299
+
300
+ **When runtime exists** (entities found, or `--include-runtime` specified, or user provides entity ref):
301
+
302
+ **IMPORTANT Staged flowInspect pattern (never call with `compact: false` upfront):**
303
+
304
+ **Step 1: Compact call (always start here, ~2-3k tokens):**
305
+ ```
306
+ event.flowInspect({ rootEntityRef: "<REF>", rootEntityType: "<TYPE>" })
307
+ ```
308
+ Returns: status flow, anomaly findings, failed webhooks, slowest rulesets, event counts. This is sufficient for the Runtime Evidence section in most cases.
309
+
310
+ **Step 2: Targeted drill-down (only if compact findings indicate issues):**
311
+ - If anomalies found `event.get` on specific event IDs from the compact diagnostics
312
+ - If webhook failures → compact response already includes failed webhook details
313
+ - If rule timing needed → call `event.flowInspect` with ONLY `includeRuleDetails: true` (keep compact: true)
314
+ - If custom log messages needed → call with ONLY `includeCustomLogs: true` (keep compact: true)
315
+
316
+ **NEVER do this** (wastes ~30k tokens of context):
317
+ ```
318
+ event.flowInspect({ ..., compact: false, includeAudit: true, includeRuleDetails: true, ... })
319
+ ```
320
+
321
+ **From `entity.get`:**
322
+ - Current entity state with edge traversal
323
+ - Related entities (fulfilments, items, articles)
324
+ - Attribute values at current state
325
+
326
+ This grounds the static analysis in real execution evidence.
327
+
328
+ **When NO runtime exists** (no entities found for this workflow type):
329
+ - Skip the Runtime Evidence section
330
+ - Automatically escalate source code analysis depth (Phase 3 Tier 2) if SOURCE is available
331
+ - Add the "Analysis Confidence" caveat section to the document (see below)
332
+ - Note in the document: "No entities of type {entityType}::{subtype} found in the environment. Runtime evidence unavailable. Deploy and process a test entity for validated analysis."
333
+
334
+ ### Phase 6: Synthesis — Feature Architecture Document
335
+
336
+ Combine all findings into the output document with the following sections:
337
+
338
+ ---
339
+
340
+ ## Document Structure
341
+
342
+ ### Section 1: Feature Overview
343
+
344
+ ```markdown
345
+ # Feature Architecture: <Feature Name>
346
+
347
+ ## Overview
348
+
349
+ **Purpose:** <1-2 sentence description of what the feature does>
350
+ **Primary Entity:** <entity type and subtype> (e.g., ORDER::HD)
351
+ **Related Entities:** <list> (e.g., FULFILMENT_CHOICE, FULFILMENT::HD_WH, ARTICLE)
352
+ **Workflows:** <list with versions>
353
+ **Entry Point:** <triggering event or API call>
354
+ **Terminal States:** <list of end states>
355
+ ```
356
+
357
+ ### Section 2: Entity Lifecycle State Machine
358
+
359
+ > **Mandatory validation:** Before writing any Mermaid diagram to the feature architecture document, validate syntax via `/fluent-mermaid-validate`.
360
+
361
+ One `stateDiagram-v2` per entity type showing ALL statuses and transitions:
362
+
363
+ ````markdown
364
+ ## Entity Lifecycle
365
+
366
+ ### ORDER::HD
367
+
368
+ ```mermaid
369
+ stateDiagram-v2
370
+ [*] --> CREATED : CreateOrder
371
+ CREATED --> BOOKED : BookOrder
372
+ BOOKED --> FULFILLED : AllFulfilmentsComplete
373
+ FULFILLED --> COMPLETE : CompleteOrder
374
+ CREATED --> CANCELLED : CancelOrder
375
+ BOOKED --> CANCELLED : CancelOrder
376
+
377
+ note right of CREATED : Entry point — order submitted
378
+ note right of BOOKED : Inventory allocated, fulfilments created
379
+ note right of FULFILLED : All items shipped/collected
380
+ ```
381
+
382
+ ### FULFILMENT::HD_WH
383
+
384
+ ```mermaid
385
+ stateDiagram-v2
386
+ [*] --> CREATED : CreateFulfilment
387
+ CREATED --> ASSIGNED : AssignToLocation
388
+ ASSIGNED --> PICKED : ConfirmPick
389
+ PICKED --> PACKED : ConfirmPack
390
+ PACKED --> SHIPPED : ConfirmShipment
391
+ SHIPPED --> DELIVERED : ConfirmDelivery
392
+ SHIPPED --> COMPLETE : CompleteWithoutDelivery
393
+ ```
394
+ ````
395
+
396
+ ### Section 3: Cross-Entity Flow Sequence Diagram
397
+
398
+ Show the full lifecycle across entity types with event names and key data:
399
+
400
+ ````markdown
401
+ ## Cross-Entity Flow
402
+
403
+ ```mermaid
404
+ sequenceDiagram
405
+ participant EXT as External System
406
+ participant ORD as ORDER
407
+ participant FC as FULFILMENT_CHOICE
408
+ participant FUL as FULFILMENT
409
+ participant LOC as Location / WMS
410
+
411
+ EXT->>ORD: CreateOrder (ref, items, customer)
412
+ ORD->>ORD: CREATED → Validate & Book
413
+ ORD->>FC: SendEvent: CreateFulfilmentChoice
414
+ FC->>FC: CREATED → Evaluate sourcing
415
+ FC->>FUL: SendEvent: CreateFulfilment (locationRef, items)
416
+ FC->>ORD: SendEvent: OrderBooked
417
+ ORD->>ORD: CREATED BOOKED
418
+
419
+ FUL->>LOC: Webhook: NotifyWarehouse (endpoint, payload)
420
+ LOC-->>FUL: ConfirmPick (pickedItems)
421
+ FUL->>FUL: ASSIGNED → PICKED
422
+ FUL->>FUL: PICKED → PACKED → SHIPPED
423
+
424
+ FUL->>ORD: SendEvent: FulfilmentComplete
425
+ ORD->>ORD: BOOKED → FULFILLED → COMPLETE
426
+ ```
427
+ ````
428
+
429
+ ### Section 4: Event Chain
430
+
431
+ Flowchart showing the event propagation tree:
432
+
433
+ ````markdown
434
+ ## Event Chain
435
+
436
+ ```mermaid
437
+ flowchart TD
438
+ A[CreateOrder] --> B[ORDER: CREATED]
439
+ B --> C{Validate}
440
+ C -->|pass| D[BookOrder]
441
+ C -->|fail| E[ORDER: CANCELLED]
442
+ D --> F[FULFILMENT_CHOICE: CREATED]
443
+ F --> G[FULFILMENT: CREATED]
444
+ G --> H[AssignToLocation]
445
+ H --> I[ConfirmPick]
446
+ I --> J[ConfirmPack]
447
+ J --> K[ConfirmShipment]
448
+ K --> L[FULFILMENT: SHIPPED]
449
+ L --> M[ORDER: FULFILLED]
450
+ M --> N[ORDER: COMPLETE]
451
+
452
+ style E fill:#f99
453
+ style N fill:#9f9
454
+ ```
455
+ ````
456
+
457
+ ### Section 5: Input → Output Data Flow
458
+
459
+ Table mapping what data enters, transforms, and exits at each step:
460
+
461
+ ```markdown
462
+ ## Input Output Data Flow
463
+
464
+ | Step | Event / Action | Input Data | Logic / Transformation | Output / Side Effect |
465
+ |------|---------------|------------|----------------------|---------------------|
466
+ | 1 | CreateOrder | items[], customer, deliveryAddress | Validate structure | ORDER entity CREATED |
467
+ | 2 | BookOrder | ORDER attributes | Inventory allocation | FULFILMENT_CHOICE created |
468
+ | 3 | CreateFulfilment | locationRef, items | Assign to warehouse | FULFILMENT entity CREATED |
469
+ | 4 | ConfirmPick | pickedItems[], picker | Verify quantities | FULFILMENT → PICKED |
470
+ | 5 | ConfirmShipment | carrierRef, trackingNum | Link carrier | FULFILMENT → SHIPPED, webhook sent |
471
+ | 6 | FulfilmentComplete | fulfilmentRef | Check all complete | ORDER → FULFILLED |
472
+ ```
473
+
474
+ ### Section 6: Rules & Logic
475
+
476
+ Per-ruleset explanation with source:
477
+
478
+ ```markdown
479
+ ## Rules & Logic
480
+
481
+ ### Ruleset: BookOrder (ORDER::HD)
482
+
483
+ | Rule | Type | Description | Reads | Produces |
484
+ |------|------|-------------|-------|----------|
485
+ | ValidateOrderAttributes | OOTB | Validates required order attributes | event.attributes | - |
486
+ | CreateFulfilmentChoice | Custom | Creates FC entity with sourcing logic | ORDER items, locations | FULFILMENT_CHOICE entity |
487
+ | SetOrderStatus | OOTB | Sets ORDER status to BOOKED | - | status: BOOKED |
488
+ | SendOrderBookedEvent | OOTB | Emits event for downstream | orderRef | Event: OrderBooked |
489
+
490
+ **Decision Points:**
491
+ - If validation fails → ORDER transitions to CANCELLED (CancelOrder ruleset)
492
+ - If no sourcing location found ORDER stays BOOKED, manual intervention required
493
+
494
+ **Custom Rule Detail: CreateFulfilmentChoice**
495
+ - Source: `accounts/HMDEV/SOURCE/fc-module-hm-extensions/src/main/java/.../CreateFulfilmentChoiceRule.java`
496
+ - Reads: `order.items`, `order.deliveryAddress`, location capabilities
497
+ - Logic: Evaluates location proximity, stock availability, delivery SLAs
498
+ - Produces: FULFILMENT_CHOICE entity with selected location
499
+ ```
500
+
501
+ ### Section 7: Settings Dependencies
502
+
503
+ ```markdown
504
+ ## Settings Dependencies
505
+
506
+ | Setting Key | Context | Current Value | Used By | Purpose |
507
+ |------------|---------|---------------|---------|---------|
508
+ | WEBHOOK_ENDPOINT_ORDER_BOOK | RETAILER | https://api.example.com/orders | BookOrder ruleset | Notify external OMS |
509
+ | INVENTORY_ALLOCATION_STRATEGY | RETAILER | CLOSEST_LOCATION | CreateFulfilmentChoice | Sourcing algorithm |
510
+ | ORDER_VALIDATION_ENABLED | RETAILER | true | ValidateOrder | Feature flag |
511
+ | MAX_FULFILMENT_RETRIES | RETAILER | MISSING | RetryFulfilment | **Gap: setting not created** |
512
+ ```
513
+
514
+ ### Section 8: Integration Points
515
+
516
+ ```markdown
517
+ ## Learning Capture
518
+
519
+ This is an analysis skill — follow the **Learning Capture Protocol** (see CLAUDE.md Cross-Skill Conventions). After producing the architecture document, when the user confirms or corrects findings about feature behavior, workflow decisions, or integration patterns, write the confirmed learning to the `implementation-learnings.md` auto-memory file under the relevant account heading.
520
+
521
+ ## Integration Points
522
+
523
+ ### Webhooks
524
+
525
+ | Ruleset | Endpoint Setting | HTTP Method | Payload Shape | Direction |
526
+ |---------|-----------------|-------------|---------------|-----------|
527
+ | NotifyWarehouse | WEBHOOK_WMS_FULFILMENT | POST | { fulfilmentRef, items, locationRef } | Outbound |
528
+ | ReceiveShipment | N/A (inbound event) | POST /event | { trackingNumber, carrier } | Inbound |
529
+
530
+ ### Scheduled Events
531
+
532
+ | Ruleset | Event Name | Delay | Purpose |
533
+ |---------|-----------|-------|---------|
534
+ | RetryAllocation | RetryFulfilmentAllocation | 30min | Retry failed sourcing |
535
+ | EscalateStuck | EscalateStuckOrder | 24h | Alert ops team |
536
+ ```
537
+
538
+ ### Section 9: Runtime Evidence (when available)
539
+
540
+ ```markdown
541
+ ## Runtime Evidence
542
+
543
+ **Entity:** ORDER HD-001
544
+ **Trace period:** 2026-02-23T10:00:00Z to 2026-02-23T10:15:00Z
545
+
546
+ ### Execution Timeline
547
+
548
+ | Time | Event | Entity | Status Change | Duration |
549
+ |------|-------|--------|--------------|----------|
550
+ | 10:00:01 | CreateOrder | ORDER | → CREATED | - |
551
+ | 10:00:02 | BookOrder | ORDER | CREATED → BOOKED | 1.2s |
552
+ | 10:00:03 | CreateFC | FC | CREATED | 0.8s |
553
+ | 10:00:04 | CreateFulfilment | FUL | CREATED | 0.5s |
554
+ | 10:05:30 | ConfirmPick | FUL | ASSIGNED PICKED | 0.3s |
555
+
556
+ ### Anomalies
557
+
558
+ - No anomalies detected (all events SUCCESS)
559
+ - OR: `RetryAllocation` fired 3 times before success (check inventory levels)
560
+ ```
561
+
562
+ ### Section 10: Analysis Confidence (always included)
563
+
564
+ This section is **always** included in the document and communicates the depth and reliability of the analysis based on what evidence was available.
565
+
566
+ ```markdown
567
+ ## Analysis Confidence
568
+
569
+ ### Evidence Availability
570
+
571
+ | Source | Available | Impact |
572
+ |--------|-----------|--------|
573
+ | Workflow JSON | Yes | State machine, rulesets, triggers, props **structural analysis complete** |
574
+ | plugin.list (deployed rules) | Yes | Rule descriptions, parameters, entity types — **rule behavior inferred** |
575
+ | workflow.transitions (live) | Yes | User actions validated against deployed workflow |
576
+ | Source code (Java) | No | Custom rule internals unknown — prop-to-code validation not possible |
577
+ | Runtime evidence | No | No executed entities found — theoretical flow only, not validated |
578
+
579
+ ### Confidence Levels
580
+
581
+ | Aspect | Confidence | Reason |
582
+ |--------|------------|--------|
583
+ | State machine (statuses, transitions) | HIGH | Derived from workflow JSON — definitive |
584
+ | Event chain (happy path) | HIGH | Traced through rulesets + triggers — deterministic |
585
+ | Event chain (error/edge paths) | MEDIUM | Inferred from trigger coverage — not runtime-validated |
586
+ | Custom rule behavior | LOW | Only plugin.list description available — actual Java logic not inspected |
587
+ | Webhook payload shapes | LOW | Setting keys identified but payload templates not inspected |
588
+ | Integration timing / performance | N/A | No runtime evidence |
589
+ | Settings values | MEDIUM | Keys identified from rule props — current values need `/fluent-settings` audit |
590
+
591
+ ### Recommendations for Higher Confidence
592
+
593
+ 1. **Clone plugin source code** to `accounts/<PROFILE>/SOURCE/` and re-run with source analysis:
594
+ - Enables prop-to-code validation for custom rules
595
+ - Reveals actual logic, edge cases, and error handling
596
+ - Shows test coverage per rule
597
+ 2. **If source repos unavailable, provide module JARs** in `accounts/<PROFILE>/SOURCE/`:
598
+ - Run `/fluent-custom-code` to decompile JARs into `.decompiled/` (CFR or Fernflower)
599
+ - Decompiled source gives MEDIUM confidence (synthetic variable names, no comments)
600
+ - Still enables cross-referencing workflow props against actual `context.getProp()` calls
601
+ 3. **Process a test entity** through the workflow and re-run with `--include-runtime`:
602
+ - Validates which rulesets actually fire
603
+ - Reveals timing, webhook responses, and NO_MATCH events
604
+ - Confirms the theoretical flow matches reality
605
+ 3. **Run `/fluent-settings` audit** to verify all referenced settings exist with correct values
606
+ ```
607
+
608
+ **Confidence level rules:**
609
+
610
+ | Evidence combination | Custom rule confidence | Flow confidence |
611
+ |---------------------|----------------------|-----------------|
612
+ | Workflow JSON + plugin.list only | LOW | HIGH (structure) / MEDIUM (behavior) |
613
+ | + Decompiled JAR (no original source) | MEDIUM | HIGH |
614
+ | + Original source code | HIGH | HIGH |
615
+ | + Runtime evidence | HIGH (validated) | HIGH (validated) |
616
+ | All three (original source + runtime) | HIGHEST — fully validated | HIGHEST — fully validated |
617
+
618
+ ---
619
+
620
+ ## Arguments
621
+
622
+ | Argument | Description | Default |
623
+ |----------|-------------|---------|
624
+ | `<feature>` | Feature name, workflow name (e.g., `ORDER::HD`), or entity ref | Required |
625
+ | `--depth shallow` | Primary workflow only, no cross-entity tracing | `full` |
626
+ | `--depth full` | All related workflows, cross-entity flows, settings, integrations | Default |
627
+ | `--include-runtime` | Collect live event trace via `event.flowInspect` | Off unless entity ref provided |
628
+ | `--output <path>` | Custom output path instead of default `accounts/<PROFILE>/features/<slug>/architecture.md` | Auto-generated |
629
+
630
+ ## Quality Checklist
631
+
632
+ Before saving the document, verify:
633
+
634
+ - [ ] State diagram shows ALL statuses in the workflow, not just the happy path
635
+ - [ ] Cross-entity sequence diagram includes event names AND key data flowing between entities
636
+ - [ ] Every ruleset in scope has an explanation row in the Rules & Logic table
637
+ - [ ] Settings table shows current values with MISSING flagged for any gaps
638
+ - [ ] Integration points table includes endpoint, HTTP method, and payload shape
639
+ - [ ] Input → Output data flow table covers every step from entry to terminal
640
+ - [ ] Custom rules have source file paths (or "source unavailable" noted)
641
+ - [ ] Terminal states are clearly identified (success AND failure paths)
642
+ - [ ] Mermaid diagrams render correctly — validate against `/fluent-mermaid-validate` rules (no colons in free text, no unicode arrows, quoted special-char labels)
643
+ - [ ] Metadata header includes profile, retailer, workflow versions, generation timestamp
644
+ - [ ] **Analysis Confidence section is present** with evidence availability table and per-aspect confidence levels
645
+ - [ ] **Missing evidence is called out** — if no source code or runtime, recommendations section explains how to get higher confidence
646
+ - [ ] **User action contract validated** (if applicable) — explicit `eventName`, valid `context[].modules`, no invented user-action keys
647
+ - [ ] **status.json updated** — `architecture: true` set in the feature's status.json
648
+ - [ ] **Extends linkage noted** — if this architecture doc will be the basis for a new feature, note this in the Overview section
649
+
650
+ ## Cross-References
651
+
652
+ - Workflow structure details: `/fluent-workflow-analyzer`
653
+ - Custom code behavior: `/fluent-custom-code`
654
+ - Connection topology: `/fluent-connection-analysis`
655
+ - Runtime debugging: `/fluent-trace`
656
+ - Settings audit: `/fluent-settings`
657
+ - Environment discovery: `/fluent-mcp-tools` → `environment.discover`
658
+ - Rule descriptions: `/fluent-mcp-tools` → `plugin.list`
659
+ - User actions per status: `/fluent-mcp-tools` → `workflow.transitions`
660
+ - User action authoring contract: `/fluent-workflow-builder`
661
+ - User action diagnostics: `/fluent-transition-api`
662
+
663
+ ## Example Usage
664
+
665
+ ```bash
666
+ # Explain a workflow by name
667
+ /fluent-feature-explain ORDER::HD
668
+
669
+ # Explain a named feature (maps to workflows automatically)
670
+ /fluent-feature-explain "Home Delivery"
671
+
672
+ # Shallow analysis — single workflow only
673
+ /fluent-feature-explain FULFILMENT::HD_WH --depth shallow
674
+
675
+ # Include runtime evidence from a real entity
676
+ /fluent-feature-explain ORDER::HD --include-runtime HD-001
677
+
678
+ # Custom output path
679
+ /fluent-feature-explain "Click & Collect" --output ./docs/cc-feature.md
680
+ ```