@lifeaitools/rdc-skills 0.15.0 → 0.17.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.
@@ -0,0 +1,189 @@
1
+ ---
2
+ name: rdc-extract-verifier-rules
3
+ version: 0.1.0
4
+ description: |
5
+ Read recent enhancement-log entries, cluster failures by pattern, generate candidate verifier rules, test them against the known-good corpus and the failure corpus, and propose pull requests adding the highest-confidence rules to forbidden-patterns.json. Use this skill on a nightly cadence (3 AM PT), or manually when the user says "extract verifier rules", "promote enhancement log", "what new rules should we add", or after a significant brochure run produced many failures.
6
+ triggers:
7
+ - "rdc:extract-verifier-rules"
8
+ - "extract verifier rules"
9
+ - "promote enhancement log"
10
+ - "what new rules should we add"
11
+ - "verifier corpus update"
12
+ - nightly cron at 3:00 AM PT
13
+ ---
14
+
15
+ # rdc:extract-verifier-rules
16
+
17
+ The self-learning loop. The verifier corpus is the moat (per `DECISIONS-LOG.md` D-009). This skill is how the corpus grows.
18
+
19
+ ## What it does
20
+
21
+ 1. Read `enhancement-log.jsonl` entries since last run timestamp
22
+ 2. Cluster entries by fingerprint similarity + reason text
23
+ 3. For each cluster with `N >= 3` occurrences:
24
+ - Generate a candidate regex or AST pattern
25
+ - Test the pattern against the **known-good corpus** (last 100 successful brochures) for false positives
26
+ - Test the pattern against the **failure cluster** for recall
27
+ - If false-positive rate = 0 AND recall ≥ 80%, mark as `propose`
28
+ 4. For each `propose` candidate:
29
+ - Open a PR on `regen-root` adding the rule to `verifiers/forbidden-patterns.json`
30
+ - Auto-merge if confidence ≥ 95% AND a maintainer's auto-merge flag is enabled
31
+ - Otherwise, await human review
32
+ 5. Write a markdown summary to `.rdc/reports/verifier-{YYYY-MM-DD}.md`
33
+
34
+ ## Cluster algorithm
35
+
36
+ Two-stage clustering:
37
+
38
+ **Stage 1 — Fingerprint clustering:**
39
+ - Each enhancement-log entry has an `input_fingerprint` (sha256 of the offending JSX block)
40
+ - Entries with identical fingerprints cluster trivially (same exact mistake)
41
+
42
+ **Stage 2 — Semantic clustering:**
43
+ - For unique fingerprints, embed the `reason` and `pattern` fields with `@xenova/transformers` (384-dim, local — no API)
44
+ - Cosine similarity ≥ 0.85 → same cluster
45
+ - Use HDBSCAN with min_samples=3 to identify real clusters vs. noise
46
+
47
+ ## Candidate rule generation
48
+
49
+ For each cluster, generate one of:
50
+
51
+ ### Regex candidate
52
+ - Take all `pattern` strings in the cluster
53
+ - Find common substring or template
54
+ - Generalize literal values to character classes
55
+ - Validate the regex is well-formed and not catastrophic
56
+
57
+ Example:
58
+ ```
59
+ Cluster patterns:
60
+ <div className="flex flex-col gap-4">
61
+ <div className="flex flex-col gap-6">
62
+ <div className="flex flex-row items-center">
63
+
64
+ Generated regex:
65
+ <div[^>]*className="[^"]*\\bflex\\b
66
+ ```
67
+
68
+ ### AST candidate
69
+ - For cluster entries with rich AST context, build an AST query string
70
+ - Test with @typescript-eslint/parser
71
+
72
+ Example:
73
+ ```
74
+ AST candidate:
75
+ JSXOpeningElement[name.name='div'] > JSXAttribute[name.name='className'] CallExpression[callee.name='clsx']
76
+ ```
77
+
78
+ ## False-positive check
79
+
80
+ Run the candidate against the known-good corpus:
81
+ - The 12 Phase 1 reference brochures
82
+ - All design-partner brochures with `final_grade >= 85`
83
+ - Any brochure tagged `corpus:reference` in Supabase
84
+
85
+ If the candidate matches any known-good output → reject the candidate. False positives in the verifier corpus are unacceptable because they break working flows.
86
+
87
+ ## Recall check
88
+
89
+ Run the candidate against the failure cluster:
90
+ - Must match ≥ 80% of cluster entries
91
+ - Below 80%, the candidate is too specific; widen and retry
92
+
93
+ ## PR generation
94
+
95
+ For each promoted candidate, create a PR on `LIFEAI/regen-root`:
96
+
97
+ ```
98
+ Title: [verifier-corpus] Add rule FP0{N} — {short description}
99
+
100
+ Body:
101
+ This rule was generated by rdc:extract-verifier-rules on {date}.
102
+
103
+ **Cluster size:** {N} occurrences over {time span}
104
+ **False positive rate:** {rate}
105
+ **Recall:** {percent}
106
+
107
+ **Sample failures:**
108
+ {3-5 example enhancement-log entries}
109
+
110
+ **Generated rule:**
111
+ ```json
112
+ {rule JSON}
113
+ ```
114
+
115
+ **Reviewer checklist:**
116
+ - [ ] Verify the rule doesn't match any known-good brochure
117
+ - [ ] Verify the suggested fix is reasonable
118
+ - [ ] Confirm severity level
119
+ - [ ] Confirm category
120
+
121
+ Auto-merging: {yes/no based on confidence}
122
+ ```
123
+
124
+ ## Auto-merge policy
125
+
126
+ Auto-merge if **all** are true:
127
+ - False-positive rate = 0
128
+ - Recall ≥ 95%
129
+ - Cluster size ≥ 10
130
+ - The rule pattern is a strict subset of an existing pattern (not a fundamentally new category)
131
+ - A maintainer's auto-merge flag is enabled in `.rdc/config.json`
132
+
133
+ Otherwise, await human review.
134
+
135
+ ## Output: nightly report
136
+
137
+ `.rdc/reports/verifier-{YYYY-MM-DD}.md`:
138
+
139
+ ```markdown
140
+ # Verifier Corpus Update — {date}
141
+
142
+ ## Summary
143
+
144
+ - Enhancement log entries since last run: {N}
145
+ - Clusters identified: {C}
146
+ - Rules proposed: {R}
147
+ - Rules auto-merged: {A}
148
+ - Rules awaiting review: {W}
149
+
150
+ ## Top clusters
151
+
152
+ | Cluster | Size | Pattern | Status |
153
+ |---|---|---|---|
154
+ | ...
155
+
156
+ ## Open PRs
157
+
158
+ - #{N}: FP0{X} — {description}
159
+ - ...
160
+
161
+ ## False-positive rejections
162
+
163
+ Candidates that failed the known-good test:
164
+ - {summary}
165
+
166
+ ## Corpus growth
167
+
168
+ - Total rules in forbidden-patterns.json: {before} → {after}
169
+ - Total component-allowlist entries: unchanged
170
+ - Pagination rules: unchanged
171
+ ```
172
+
173
+ ## Manual invocation
174
+
175
+ A maintainer can run this skill manually after a significant brochure run to immediately promote lessons learned:
176
+
177
+ ```
178
+ rdc:extract-verifier-rules --since "2026-05-27" --auto-merge=false
179
+ ```
180
+
181
+ The `--auto-merge=false` flag forces human review on all proposals regardless of confidence.
182
+
183
+ ## Why this matters
184
+
185
+ The verifier corpus is the asset. Anyone can copy the kit. Anyone can copy the ESLint plugin. **Replicating 12 months of customer-tested failure patterns is the moat.** This skill is how that moat compounds. Every brochure run feeds it. Every nightly run grows it.
186
+
187
+ After 12 months at moderate scale, the corpus will contain ~500-2,000 rules, calibrated against real customer documents, with each rule's hit count visible. New competitors entering this category will face a starting position 12 months behind.
188
+
189
+ That is the point.
@@ -109,3 +109,7 @@ rdc-skills-install --profile core
109
109
  ```
110
110
 
111
111
  Use `--profile lifeai` only on a workstation that intentionally has the LIFEAI project layout and services.
112
+
113
+ ## Capture lessons (exit step)
114
+
115
+ Before the final verdict line, follow `.rdc/guides/lessons-learned-spec.md` § Capture procedure. If this run taught something non-obvious — a first root-cause theory that turned out wrong, the documented/standard path not working, a missing gate or check that cost a round, or a surprising tool/infra behavior — write one `.rdc/lessons/<YYYY-MM-DD>-release-<short-slug>.md` per lesson using the schema in that spec. Set `scope` (`simple` | `architectural`) and `status` (`open`, or `applied` if you shipped the fix in this same run, with the commit linked). Commit the lesson file(s) on `develop` alongside the run's other commits, and note "N lessons captured" in your verdict/summary. A run that taught nothing writes nothing — absence is the default.
@@ -146,3 +146,7 @@ description: "Usage `rdc:review [--unattended]` — Post-build quality gate: tsc
146
146
  - Each fix is a separate commit (not batched)
147
147
  - Always push fixes to origin after committing *(skip if `$RDC_TEST=1` — echo `[RDC_TEST] skipping git push` instead)*
148
148
  - Unattended: NEVER pause for input
149
+
150
+ ## Capture lessons (exit step)
151
+
152
+ Before the final verdict line, follow `.rdc/guides/lessons-learned-spec.md` § Capture procedure. If this run taught something non-obvious — a first root-cause theory that turned out wrong, the documented/standard path not working, a missing gate or check that cost a round, or a surprising tool/infra behavior — write one `.rdc/lessons/<YYYY-MM-DD>-review-<short-slug>.md` per lesson using the schema in that spec. Set `scope` (`simple` | `architectural`) and `status` (`open`, or `applied` if you shipped the fix in this same run, with the commit linked). Commit the lesson file(s) on `develop` alongside the run's other commits, and note "N lessons captured" in your verdict/summary. A run that taught nothing writes nothing — absence is the default.