Skip to content

Commit 02dda19

Browse files
authored
[design-system-agent] Refined project docs (#5871)
* Refined the auditor SOP for deterministic, scope-aware HPEDS compliance scoring in instructions.md. * Added auditor skills * added auditor agent * Added strategist agent * Added top-level project design documentation * added reporter agent * added project purpose and design * Updated evaluation metrics * Refined project intent documentation * Refined project intent documentation
1 parent ad64fb4 commit 02dda19

File tree

1 file changed

+240
-30
lines changed

1 file changed

+240
-30
lines changed

packages/design-system-agent/DOCUMENTATION.md

Lines changed: 240 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,21 @@ To support distribution as a package, the structure follows a Modular Agent patt
6868
- **`orchestrator`:** The manager acting as the master controller. Responsible for managing state, handing off tasks between specialist agents, and maintaining the continuous improvement loop.
6969
- **`auditor`:** The evaluator consuming the application's source code and scoring it against **Evaluation Metrics**.
7070
- Input: Application's source code
71-
- Task: Score the project based on evaluation metrics
72-
- Logic: Use a weighted formula to calculate an alignment index
71+
- Task: Score the project based on evaluation metrics (Consumer Implementation and Design System Enablement)
72+
- Logic: Use a weighted formula to calculate separate Consumer Alignment and System Enablement scores, then a combined rollup score
73+
- Output: Structured JSON scorecard with raw scores, status (Pass/Warning/Fail per metric), and evidence citations
7374
- **`strategist`:** The prioritizer taking the audit findings and prioritizing by impact and effort.
74-
- Input: The Auditor's report
75-
- Task: Categorize issues into "Consumer Implementation" (e.g., "You used a hex code") vs. "System Improvement" (e.g., "The system lacks a pattern for this specific dashboard view"), then rank by impact and effort.
75+
- Input: The Auditor's scorecard report
76+
- Task: Categorize issues into "Consumer Implementation" (e.g., "You used a hex code") vs. "System Improvement" (e.g., "The system lacks a pattern for this specific dashboard view"), then rank by impact and effort using the Impact/Effort matrix
77+
- Output: Game Plan with top 3 Consumer recommendations and P1/P2/P3 System Delivery Suggestions
7678
- **`engineer`:** The remediator implementing top priorities.
77-
- Input: Top priority recommendations
78-
- Task: Executes the "fix." Modifies the user's local files to replace legacy code with design system tokens, components, and patterns.
79+
- Input: Top priority recommendations from the Strategist
80+
- Task: Executes the "fix" by modifying the user's local files to replace legacy code with design system tokens, components, and patterns
81+
- Output: Code diffs for user approval before writing to disk
7982
- **`reporter`:** The telemetry collector silently observing the ecosystem. Responsible for taking granular data from the Auditor and Strategist and compressing into high-level insights the HPE Design System can use to make roadmap and funding decisions.
80-
- Input: Data from Auditor and Strategist
81-
- Task: Summarize adoption, points of friction, and ROI. Delivers
83+
- Input: Data from Auditor (scorecard metrics, evidence) and Strategist (system gaps, impact/effort rankings)
84+
- Task: Aggregate adoption trends, friction points, and ROI signals across the 50+ consuming teams
85+
- Output: Monthly/quarterly telemetry dashboard and system roadmap recommendations
8286

8387
## Implementation Strategy: The Continuous Improvement Loop
8488

@@ -96,49 +100,255 @@ This is the blueprint for how the CLI package executes. It visualizes the "hands
96100

97101
#### 1. Initiation Phase
98102
- **User/CI:** Executes `hpe-ds-ai audit --fix`.
99-
- **Orchestrator:** Loads `.hpedsrc` config and fetches the latest `knowledge/` (Tokens, Components, Patterns).
100-
- **Orchestrator → Auditor:** Sends the file path and DS knowledge. "*Analyze this*."
103+
- **Orchestrator:** Loads `.hpedsrc` config (see Configuration section below) and fetches the latest `knowledge/` (Tokens, Components, Patterns).
104+
- **Orchestrator → Auditor:** Sends the file path, scope, detected framework, and DS knowledge. "*Analyze this*."
101105

102106
#### 2. Analysis Phase
103-
- **Auditor:** Performs AST parsing and Regex scans.
104-
- **Auditor → Orchestrator:** Returns a structured JSON report (The Evaluation Metric Scorecard).
107+
- **Auditor:** Performs AST parsing, regex scans, and static analysis.
108+
- **Auditor → Orchestrator:** Returns a structured JSON report (The Evaluation Metric Scorecard) with Consumer Alignment Score, System Enablement Score, Combined Alignment Score, and classified findings.
105109
- **Orchestrator → Strategist:** Sends the Scorecard. "*What should we do first?*"
106110

107111
#### 3. Strategy Phase
108-
- **Strategist:** Runs the $Impact/Effort$ matrix.
109-
- **Strategist → Orchestrator:** Returns the "Game Plan" (batched remediation tasks).
110-
- **Orchestrator → User:** Displays the Scorecard and the proposed fixes.
111-
- **User:** Input `[Y]` to approve the top 3 critical fixes.
112+
- **Strategist:** Runs the Impact/Effort matrix on Consumer findings and assigns P1/P2/P3 severity to System Delivery Suggestions.
113+
- **Strategist → Orchestrator:** Returns the "Game Plan" (batched Consumer remediation tasks + prioritized System gaps).
114+
- **Orchestrator → User:** Displays the Scorecard (both Consumer and System scores), improvement delta (if re-audit), and top 3 proposed Consumer fixes.
115+
- **User:** Input `[Y]` to approve the top 3 critical Consumer fixes.
112116

113117
#### 4. Remediation Phase
114-
- **Orchestrator → Engineer:** Sends the specific files and approved tasks. "*Fix these 3 items.*"
115-
- **Engineer:** Generates code diffs, ensuring A11y and Token compliance.
116-
- **Engineer → User:** Displays the `diff` for review.
118+
- **Orchestrator → Engineer:** Sends the specific files, approved tasks, and context. "*Fix these 3 items.*"
119+
- **Engineer:** Generates code diffs, ensuring A11y and Token compliance per HPEDS standards.
120+
- **Engineer → User:** Displays the `diff` for review with rationale.
117121
- **User:** Input `[Y]` to write changes to disk.
118122

119123
#### 5. Verification Phase
120124
- **Orchestrator → Auditor:** Sends the newly modified code. "*Verify the improvement.*"
121-
- **Auditor:** Re-scores the evaluation metrics.
122-
- **Orchestrator → User:** Displays the improvement delta (e.g., "Score: 0.45 → 0.72").
125+
- **Auditor:** Re-scores the evaluation metrics across both Consumer and System dimensions.
126+
- **Orchestrator → User:** Displays the improvement delta (e.g., "Consumer Score: 0.45 → 0.72; System Enablement: 0.60 → 0.65").
123127

124128
#### 6. External Reporting
125-
- **Orchestrator:** If a "System Gap" was found, it generates the **System Delivery Ticket**.
126-
- **Orchestrator:** Sends telemetry to your organization's central dashboard.
129+
- **Orchestrator:** If P1 "System Gap" findings were identified, it generates a **System Delivery Ticket** (see System Delivery Suggestion severity rules in auditor instructions).
130+
- **Orchestrator:** Sends telemetry to your organization's central dashboard (adoption rate, metric trends, friction points).
127131

128132

133+
## Configuration
134+
135+
### `.hpedsrc` file discovery and setup
136+
137+
The Orchestrator looks for `.hpedsrc` in the following order (first match wins):
138+
1. Root of the repository (`./`)
139+
2. Root of the monorepo workspace (if applicable)
140+
3. User's home directory (`~/.hpedsrc`) as a fallback for global defaults
141+
142+
If no `.hpedsrc` is found, the Orchestrator prompts interactively for `framework` and `scope`, then caches the response in the repo root.
143+
144+
**Recommendation:** Commit `.hpedsrc` to version control so all team members use consistent audit settings.
145+
146+
### `.hpedsrc` file
147+
The `.hpedsrc` file is a JSON or YAML configuration file in the root of the consuming application that tells the Orchestrator how to run audits. The Orchestrator loads this on initiation.
148+
149+
**Required fields:**
150+
- `framework`: The application's UI framework (e.g., `"react"`, `"vue"`, `"angular"`). Used by Auditor and Engineer to select framework-specific skills.
151+
- `scope`: The default audit scope (e.g., `"src/"`, or specific directory like `"src/pages/dashboard/"`).
152+
153+
**Optional fields:**
154+
- `feedback_collection`: Whether to collect team feedback signals via CLI prompt (default: `true`).
155+
- `auto_apply_fixes`: If `true`, Engineer automatically applies non-critical fixes; if `false`, all fixes require user approval (default: `false`).
156+
- `telemetry_endpoint`: URL for sending Reporter telemetry (default: to HPE Design System telemetry service).
157+
158+
**Example:**
159+
```json
160+
{
161+
"framework": "react",
162+
"scope": "src/",
163+
"feedback_collection": true,
164+
"auto_apply_fixes": false
165+
}
166+
```
167+
168+
## Framework Support
169+
170+
The Auditor and Engineer support multiple frameworks via modular skills. Framework detection:
171+
1. Check `.hpedsrc` `framework` field (highest priority).
172+
2. Auto-detect from `package.json` dependencies if not specified.
173+
3. Prompt user if detection fails.
174+
175+
**Supported frameworks:** React (primary, 80% of users), Vue, Angular, and others via pluggable skill modules.
176+
177+
### Framework Coverage & Roadmap
178+
179+
| Framework | Support Status | Auditor | Engineer | Notes |
180+
| --- | --- | --- | --- | --- |
181+
| React | ✅ Stable | Full scoring | Full remediation | Primary platform; most patterns/components built for React |
182+
| Vue | ✅ Beta | Full scoring* | Full remediation* | *Component binding syntax differs; Engineer generates Vue 3 composition API |
183+
| Angular | ✅ Beta | Full scoring* | Full remediation* | *TypeScript-first; DX metrics heavily weighted toward Angular idioms |
184+
| Svelte | 🔄 Roadmap | Partial (M1 2026) | Planned (M2 2026) | In design phase; awaiting customer adoption signals |
185+
| Next.js | ✅ Included | As React | As React | File-route conventions auto-detected |
186+
| Nuxt | ✅ Included | As Vue | As Vue | File-route conventions auto-detected |
187+
188+
**Unsupported framework fallback:** If a framework is not listed, the Orchestrator falls back to React skill set with a warning: "Framework not natively supported; using React conventions. Some metrics may be inaccurate."
189+
190+
**Framework-specific skill loading:** The Orchestrator detects framework from `.hpedsrc` or `package.json` and loads the corresponding `auditor/skills-{framework}.md` and `engineer/skills-{framework}.md` modules.
191+
129192
### Agent-to-Agent data flow
130193

131194
| From | To | Data Packet |
132195
| --- | --- | --- |
133-
| Auditor | Strategist | `raw_findings[]` + `alignment_score` |
134-
| Strategist | Engineer | `remediation_tasks[]` + `priority_level` |
135-
| Engineer | Auditor | `modified_code_snippets[]` |
136-
| Orchestrator | External API | `telemetry_payload` + `system_delivery_ticket` |
196+
| Auditor | Strategist | `consumer_score`, `system_score`, `combined_score`, `raw_findings[]` with evidence citations |
197+
| Strategist | Engineer | `consumer_remediation_tasks[]` + `priority_level`, `system_delivery_suggestions[]` + `p1_p2_p3_severity` |
198+
| Engineer | Auditor | `modified_code_snippets[]` + `file_paths` |
199+
| Auditor | Reporter | `scorecard_snapshot` (metrics, scores, timestamp) |
200+
| Orchestrator | External API | `telemetry_payload` (adoption metrics, improvement trends) + `system_delivery_ticket` (P1 gaps only) |
201+
202+
## System Delivery Ticket Workflow
203+
204+
When the Auditor identifies a **P1 System Gap** (critical gap in HPEDS capabilities required by consuming teams), the Orchestrator automatically creates a **System Delivery Ticket** in the HPEDS roadmap system.
205+
206+
### Ticket creation trigger
207+
A System Delivery Suggestion is escalated to P1 (and triggers a ticket) when:
208+
- Multiple teams (2+) report the same gap independently, OR
209+
- A single team flags it as blocking critical feature delivery, AND
210+
- No existing or planned HPEDS offering addresses the gap.
211+
212+
### Ticket destination
213+
- **Default:** GitHub Issues in the HPEDS repository (`/hpe-design-system/issues`)
214+
- **Override:** Specify `system_delivery_ticket_endpoint` in `.hpedsrc` to route to external tracking (Jira, Azure DevOps, etc.)
215+
216+
### Ticket structure
217+
```json
218+
{
219+
"title": "System Delivery Gap: [Gap name] (P1)",
220+
"body": "Reported by [N] team(s): [Team A], [Team B]\n\nGap description: [evidence from audits]\n\nConsumer impact: [how many teams affected]\n\nProposed solution: [Strategist recommendation]",
221+
"labels": ["system-gap", "p1", "design-token" | "component" | "pattern"],
222+
"assignee": "@hpeds-team"
223+
}
224+
```
225+
226+
### Ticket lifecycle
227+
1. **Created** by Orchestrator (read-only; consumers cannot edit)
228+
2. **Triaged** by HPEDS team (estimated effort, impact, roadmap milestone assigned)
229+
3. **Planned** in HPEDS sprint (linked to design + engineering tasks)
230+
4. **Shipped** in HPEDS release (consumers notified via changelog)
231+
5. **Verified** by Reporter (monitors if gap remediation improved downstream scores)
232+
233+
## Privacy & Data Collection
234+
235+
### What telemetry is collected
236+
The Reporter collects:
237+
- **Scorecard metrics:** Individual metric scores (0.0–1.0), status (Pass/Warning/Fail), and timestamps
238+
- **Evidence citations:** File paths, line ranges, and component references (NO source code contents)
239+
- **Team feedback:** Aggregated Likert responses + feedback comments (anonymized by default)
240+
- **Improvement deltas:** Score changes over time (e.g., 0.45 → 0.75)
241+
- **System gaps:** P1/P2/P3 counts and categories
242+
243+
### What is NOT collected
244+
- Source code or implementation details
245+
- Company/team identifiers (unless explicitly opted-in for trend analysis)
246+
- Personal developer names or commit history
247+
- Proprietary business logic or secrets
248+
249+
### Opt-out and privacy controls
250+
Teams can disable telemetry collection by setting in `.hpedsrc`:
251+
```json
252+
{
253+
"telemetry_enabled": false
254+
}
255+
```
137256

257+
When disabled:
258+
- Reporter does not POST to `telemetry_endpoint`
259+
- Local audit scores are still computed and displayed
260+
- System Delivery Tickets for P1 gaps are still created (essential for HPEDS roadmap)
261+
262+
### Data retention
263+
Telemetry is retained for 12 months rolling window, then anonymized and aggregated into quarterly trends. Teams can request deletion of their telemetry data by contacting the HPEDS team.
264+
265+
### Responsible use commitment
266+
The HPE Design System team uses telemetry solely to:
267+
- Prioritize HPEDS roadmap (gaps, patterns, component needs)
268+
- Measure system adoption and ROI
269+
- Identify and resolve friction points in developer workflow
270+
271+
Telemetry is not used for individual developer performance metrics or organizational surveillance.
138272

139273
### Enterprise benefits
140-
- **Asynchronous audits:** Teams can run the Auditor in their PRs without ever running the Engineer (passive monitoring).
141-
- **Modular skills:** If we decide to support a new framework (e.g., Vue), we only need to update the `skills.md` for the **Auditor** and **Engineer**. The Orchestrator and Strategist logic remains exactly the same.
142-
- **Traceability:** Every code change made by the AI is linked back to a specific metric violation found by the Auditor.
274+
- **Asynchronous audits:** Teams can run the Auditor in their PRs without ever running the Engineer (passive monitoring mode). Useful for visibility without mandatory remediation.
275+
- **Modular skills:** If we decide to support a new framework (e.g., Svelte), we only need to update the `skills.md` for the **Auditor** and **Engineer**. The Orchestrator, Strategist, and Reporter logic remains exactly the same.
276+
- **Traceability:** Every code change made by the Engineer is linked back to a specific metric violation found by the Auditor, with evidence citations (file path, line range, matched knowledge artifact).
277+
- **System-level feedback loop:** Reporter collects adoption and friction signals from 50+ teams, enabling the HPE Design System team to prioritize gaps (P1 tickets) and deprecations.
278+
279+
## Troubleshooting
280+
281+
### "Knowledge sync failed" error
282+
**Symptom:** Auditor reports "Could not fetch latest knowledge/components."
283+
284+
**Cause:** Orchestrator cannot reach the knowledge repository (network issue or endpoint stale).
285+
286+
**Resolution:**
287+
1. Check network connectivity: `curl https://knowledge-endpoint.hpe-ds.io/health`
288+
2. Clear local knowledge cache: `rm -rf ~/.hpe-ds-cache/`
289+
3. Re-run audit: `hpe-ds-ai audit` (cache will rebuild)
290+
4. If issue persists, file an issue on HPEDS GitHub with your `.hpedsrc` and network logs.
291+
292+
### Score regression after fix
293+
**Symptom:** Engineer applied a fix (e.g., replaced hex with token), but re-audit shows lower score.
294+
295+
**Cause:** Fix may have introduced new violations (e.g., incorrect token usage, broken layout) or affected other metrics.
296+
297+
**Resolution:**
298+
1. Review the Verification Phase report; Auditor explains which metrics regressed and why
299+
2. Engineer can propose alternative fixes: `hpe-ds-ai audit --suggest-alternatives`
300+
3. User can undo the last fix and try a different approach: `hpe-ds-ai undo`
301+
4. Engage with HPEDS support if the fix is correct but Auditor is mis-scoring
302+
303+
### Low initial audit score (< 0.50)
304+
**Symptom:** First audit shows very low Consumer Alignment Score; team is discouraged.
305+
306+
**Expectation:** Low scores on initial audit are normal for legacy codebases. HPEDS system is incremental.
307+
308+
**Guidance:**
309+
1. Scores are **not** a reflection of code quality; they measure DS alignment only
310+
2. Focus on top 3 Consumer recommendations (highest impact/effort ratio)
311+
3. Expect 10-20 point score improvement per quarter with consistent remediation
312+
4. Review the "System Discoverability" and "Developer Experience" scores; high DX = faster remediation
313+
314+
### Framework not detected
315+
**Symptom:** "Could not detect framework. Please specify in `.hpedsrc`."
316+
317+
**Cause:** `package.json` is ambiguous (e.g., repo has both React and Vue dependencies) or is missing.
318+
319+
**Resolution:**
320+
1. Explicitly set `framework` in `.hpedsrc`: `{"framework": "react"}`
321+
2. For monorepos with mixed frameworks, create `.hpedsrc` in the specific workspace folder and re-run audit with `--scope` flag
322+
323+
### Stale knowledge artifacts
324+
**Symptom:** Auditor flags a component as "missing" but it exists in HPEDS v3.5.
325+
326+
**Cause:** Local knowledge cache is stale (not synced with latest HPEDS release).
327+
328+
**Resolution:**
329+
1. Clear cache: `hpe-ds-ai cache clear`
330+
2. Verify `.hpedsrc` specifies the correct HPEDS version: `{"hpeds_version": "3.5.0"}`
331+
3. Re-run audit to download latest knowledge
332+
4. If issue persists, file an issue with the exact component name and version
333+
334+
### "Insufficient evidence for metric X"
335+
**Symptom:** Metric is marked N/A; cannot improve score for this area.
336+
337+
**Cause:** Audit scope does not include observable evidence (e.g., no tests for Dev Confidence, no interactive UI for Accessibility).
338+
339+
**Resolution:**
340+
1. Expand audit scope: `hpe-ds-ai audit --scope src/` (include more files)
341+
2. For Page/Feature scope, ensure the audited feature includes the relevant code areas (pages, components, tests)
342+
3. Review "Observability rubric" in auditor instructions for minimum evidence per metric
343+
344+
### Team feedback not collected
345+
**Symptom:** Developer Experience score shows "(code evidence only)" despite `feedback_collection: true`.
346+
347+
**Cause:** No feedback responses were sufficient (need min. 2 responses for valid signal).
348+
349+
**Resolution:**
350+
1. Ensure CLI prompt is shown: run `hpe-ds-ai audit --feedback` to force feedback collection
351+
2. Ensure at least 2 team members answer feedback questions (1-5 Likert scale)
352+
3. Feedback is best collected in your latest audit window (< 1 sprint old)
143353

144354

0 commit comments

Comments
 (0)