|
| 1 | +# Spec Drift Detection — Full Scan |
| 2 | + |
| 3 | +Run a comprehensive validation of all SDD ai-docs against actual source code. Deploys a parallel agent team to catch documentation drift across 7 categories. |
| 4 | + |
| 5 | +## Step 1: Auto-Discovery |
| 6 | + |
| 7 | +Detect repo type and discover all ai-docs: |
| 8 | + |
| 9 | +1. **Repo detection**: This is ccWidgets — `packages/contact-center/` exists (no `@webex` scope) |
| 10 | +2. **Root AGENTS.md**: `AGENTS.md` (repo root) |
| 11 | +3. **Framework docs**: `ai-docs/` (README, RULES, patterns/*, templates/*) |
| 12 | +4. **Package-level ai-docs**: Glob for `packages/contact-center/**/ai-docs/` to find all ai-docs folders |
| 13 | +5. **Samples ai-docs**: Check `widgets-samples/**/ai-docs/` as well |
| 14 | + |
| 15 | +For each ai-docs folder found, identify its corresponding source code directory (the parent directory of `ai-docs/`). |
| 16 | + |
| 17 | +Build an inventory (example — actual results will vary based on current branch): |
| 18 | +``` |
| 19 | +ai-docs folder → source directory |
| 20 | +packages/contact-center/store/ai-docs/ → packages/contact-center/store/src/ |
| 21 | +packages/contact-center/cc-components/ai-docs/ → packages/contact-center/cc-components/src/ |
| 22 | +packages/contact-center/cc-widgets/ai-docs/ → packages/contact-center/cc-widgets/src/ |
| 23 | +packages/contact-center/station-login/ai-docs/ → packages/contact-center/station-login/src/ |
| 24 | +packages/contact-center/task/ai-docs/widgets/CallControl/ → packages/contact-center/task/src/widgets/CallControl/ |
| 25 | +packages/contact-center/task/ai-docs/widgets/IncomingTask/ → packages/contact-center/task/src/widgets/IncomingTask/ |
| 26 | +packages/contact-center/task/ai-docs/widgets/OutdialCall/ → packages/contact-center/task/src/widgets/OutdialCall/ |
| 27 | +packages/contact-center/task/ai-docs/widgets/TaskList/ → packages/contact-center/task/src/widgets/TaskList/ |
| 28 | +packages/contact-center/user-state/ai-docs/ → packages/contact-center/user-state/src/ |
| 29 | +packages/contact-center/ui-logging/ai-docs/ → packages/contact-center/ui-logging/src/ |
| 30 | +packages/contact-center/test-fixtures/ai-docs/ → packages/contact-center/test-fixtures/src/ |
| 31 | +widgets-samples/cc/samples-cc-react-app/ai-docs/ → widgets-samples/cc/samples-cc-react-app/src/ |
| 32 | +... (discover all that exist on the current branch) |
| 33 | +``` |
| 34 | + |
| 35 | +## Step 2: Spawn Checker Agents in Parallel |
| 36 | + |
| 37 | +Use the Agent tool to spawn agents. **All agents run in parallel.** |
| 38 | + |
| 39 | +### Per-Package Checker Agents (one per ai-docs folder) |
| 40 | + |
| 41 | +For EACH ai-docs folder discovered, spawn one Explore agent with this prompt: |
| 42 | + |
| 43 | +``` |
| 44 | +You are validating SDD documentation accuracy. |
| 45 | +
|
| 46 | +SOURCE OF TRUTH (actual code): {source_code_directory} |
| 47 | +DOCS TO VALIDATE: {ai_docs_folder} |
| 48 | +
|
| 49 | +Read every markdown file in the ai-docs folder. For each document, check these 7 categories: |
| 50 | +
|
| 51 | +### Category 1: FILE TREE |
| 52 | +Read any documented file/directory trees in the docs. Glob the actual directory. Report: |
| 53 | +- Files listed in docs but missing on disk |
| 54 | +- Files on disk but missing from docs |
| 55 | +- Wrong nesting or directory structure |
| 56 | +
|
| 57 | +### Category 2: METHOD/API SIGNATURES |
| 58 | +For every method, function, or API endpoint documented: |
| 59 | +- Read the actual source file |
| 60 | +- Verify: method name, parameter names, parameter types, return type, access modifiers (public/private/static) |
| 61 | +- Check if method actually exists in the documented file |
| 62 | +- Flag any param that is documented but doesn't exist, or exists but isn't documented |
| 63 | +
|
| 64 | +### Category 3: TYPE DEFINITIONS |
| 65 | +For every type, enum, interface, or constant documented: |
| 66 | +- Find the actual definition in source (check package-level types files and shared types) |
| 67 | +- Compare: name, fields/members, field types, enum values |
| 68 | +- Flag missing fields, wrong types, renamed types |
| 69 | +
|
| 70 | +### Category 4: EVENT NAMES |
| 71 | +For every event constant or observable referenced: |
| 72 | +- Find the actual definition in source |
| 73 | +- Verify the exact name matches |
| 74 | +- For MobX observables: verify @observable, @computed, @action decorators match docs |
| 75 | +- For React events: verify prop callback names match |
| 76 | +
|
| 77 | +### Category 5: ARCHITECTURE PATTERNS |
| 78 | +For claims about architectural patterns, verify: |
| 79 | +- MobX store patterns: Are @observable, @action, @computed correctly documented? |
| 80 | +- React component patterns: Are props, state, lifecycle methods correct? |
| 81 | +- Singleton vs factory: Is the instantiation pattern correct? |
| 82 | +- Component hierarchy: Are parent-child relationships correct? |
| 83 | +- Store injection patterns: Are MobX store injections accurately described? |
| 84 | +
|
| 85 | +### Category 6: LINK VALIDATION |
| 86 | +For every relative markdown link [text](path): |
| 87 | +- Resolve the path relative to the document's location |
| 88 | +- Verify the target file exists on disk |
| 89 | +- For anchor links (#section), verify the heading exists in the target |
| 90 | +
|
| 91 | +### Category 7: CODE EXAMPLES |
| 92 | +For every inline code block or code snippet: |
| 93 | +- Verify API names, method names, parameter names are correct |
| 94 | +- Verify import paths are valid |
| 95 | +- Check that documented usage patterns match actual API signatures |
| 96 | +- Verify MobX patterns use correct decorators and patterns |
| 97 | +
|
| 98 | +## Output Format |
| 99 | +
|
| 100 | +For each finding, report: |
| 101 | +- **File**: (path to the ai-docs file with the issue) |
| 102 | +- **Line/Section**: (approximate line number or section heading) |
| 103 | +- **Category**: (1-7 from above) |
| 104 | +- **Severity**: |
| 105 | + - Blocking = wrong API that would cause runtime errors if AI agent follows the docs |
| 106 | + - Important = wrong params/types that would cause compilation errors |
| 107 | + - Medium = incomplete or stale info that would cause confusion |
| 108 | + - Minor = broken links, cosmetic issues |
| 109 | +- **What doc says**: (quoted text from the doc) |
| 110 | +- **What code actually has**: (evidence from source, with file path and line) |
| 111 | +- **Suggested fix**: (exact replacement text) |
| 112 | +
|
| 113 | +If no issues found in a category, state "No issues found" for that category. |
| 114 | +``` |
| 115 | + |
| 116 | +### Framework Agent |
| 117 | + |
| 118 | +Spawn one additional Explore agent for root-level framework validation: |
| 119 | + |
| 120 | +``` |
| 121 | +Validate the root-level SDD framework documents for ccWidgets: |
| 122 | +
|
| 123 | +1. **Root AGENTS.md** (repo root AGENTS.md): |
| 124 | + - Package Routing Table: Every package listed must exist on disk at the documented path |
| 125 | + - Every actual package directory under packages/contact-center/ should be listed |
| 126 | + - Task classification types must be consistent with template directories that exist |
| 127 | + - Quick Start Workflow steps must reference files that exist |
| 128 | +
|
| 129 | +2. **ai-docs/RULES.md**: |
| 130 | + - Test commands: Verify documented commands are correct |
| 131 | + - Naming conventions: Verify claims against actual code |
| 132 | + - Pattern references: All referenced patterns should exist |
| 133 | +
|
| 134 | +3. **ai-docs/README.md**: |
| 135 | + - File tree must match actual ai-docs directory structure |
| 136 | + - All referenced documents must exist |
| 137 | +
|
| 138 | +4. **ai-docs/patterns/*.md** (mobx-patterns, react-patterns, testing-patterns, typescript-patterns): |
| 139 | + - Each pattern file's code examples must match actual source conventions |
| 140 | + - MobX patterns must match actual decorator usage in stores |
| 141 | + - React patterns must match actual component patterns |
| 142 | + - Test patterns must reference correct commands and configs |
| 143 | +
|
| 144 | +5. **ai-docs/templates/**: |
| 145 | + - Cross-references to AGENTS.md sections must be valid |
| 146 | + - Referenced file paths in templates must exist |
| 147 | + - Workflow steps must be internally consistent |
| 148 | +
|
| 149 | +For each finding, report: |
| 150 | +- **File**: (path) |
| 151 | +- **Line/Section**: (section heading or line) |
| 152 | +- **Category**: (1-7: File Tree, Method/API, Type Definition, Event Name, Architecture Pattern, Link Validation, Code Example) |
| 153 | +- **Severity**: Blocking / Important / Medium / Minor |
| 154 | +- **What doc says**: (quoted) |
| 155 | +- **What code actually has**: (evidence with file:line) |
| 156 | +- **Suggested fix**: (replacement text) |
| 157 | +``` |
| 158 | + |
| 159 | +## Step 3: Consolidate Results |
| 160 | + |
| 161 | +After ALL agents complete, consolidate into this report format: |
| 162 | + |
| 163 | +```markdown |
| 164 | +## Spec Drift Report — ccWidgets |
| 165 | +Generated: {date} |
| 166 | +Scanned: {N} ai-docs folders, {M} documents |
| 167 | + |
| 168 | +### Summary |
| 169 | + |
| 170 | +| ai-docs Folder | Findings | Blocking | Important | Medium | Minor | |
| 171 | +|----------------|----------|----------|-----------|--------|-------| |
| 172 | +| (each folder) | | | | | | |
| 173 | +| framework | | | | | | |
| 174 | +| **Total** | **N** | | | | | |
| 175 | + |
| 176 | +### Blocking Findings |
| 177 | +(must fix — wrong APIs that would cause runtime errors if AI agent follows the docs) |
| 178 | + |
| 179 | +### Important Findings |
| 180 | +(wrong params, signatures, types — would cause compilation errors) |
| 181 | + |
| 182 | +### Medium Findings |
| 183 | +(incomplete info, stale file trees — would cause confusion) |
| 184 | + |
| 185 | +### Minor Findings |
| 186 | +(broken links, cosmetic issues) |
| 187 | + |
| 188 | +### Actionable Fixes by File |
| 189 | +(grouped by file path, each with exact old text -> new text) |
| 190 | +``` |
| 191 | + |
| 192 | +## Rules |
| 193 | + |
| 194 | +- Do NOT auto-fix anything — report findings only |
| 195 | +- Always read actual source code to verify — never assume |
| 196 | +- Use the Agent tool with `subagent_type: "Explore"` for all checker agents |
| 197 | +- Run all agents in parallel for speed |
| 198 | +- If an agent does not return within a reasonable time, note it as "Timed out — manual review needed" in the report and continue with available results |
| 199 | +- If an ai-docs folder has no corresponding source directory, flag it as a Category 1 (File Tree) finding |
| 200 | +- Count findings by severity in the summary table |
0 commit comments