@codyswann/lisa 4.23.39 → 4.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/core/lisa-owned-hash-ledger.d.ts.map +1 -1
  2. package/dist/core/lisa-owned-hash-ledger.js +4 -0
  3. package/dist/core/lisa-owned-hash-ledger.js.map +1 -1
  4. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  5. package/dist/core/nightly-e2e-guard-behavior-certificate.js.map +1 -1
  6. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  7. package/dist/core/upstream-evidence-manifest.js +16 -5
  8. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  9. package/expo/copy-overwrite/scripts/classify-maestro-failures.mjs +535 -47
  10. package/expo/create-only/.maestro/flake-classification.json +6 -0
  11. package/package.json +3 -3
  12. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  13. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  14. package/plugins/lisa/.codex-plugin/skills/lisa-github-write-issue/SKILL.md +1 -1
  15. package/plugins/lisa/.codex-plugin/skills/lisa-validate-tracker-mapping/SKILL.md +111 -1
  16. package/plugins/lisa/scripts/scoping-label-audit.mjs +474 -0
  17. package/plugins/lisa/skills/lisa-github-write-issue/SKILL.md +1 -1
  18. package/plugins/lisa/skills/lisa-validate-tracker-mapping/SKILL.md +112 -2
  19. package/plugins/lisa-agy/plugin.json +1 -1
  20. package/plugins/lisa-agy/scripts/scoping-label-audit.mjs +474 -0
  21. package/plugins/lisa-agy/skills/lisa-github-write-issue/SKILL.md +1 -1
  22. package/plugins/lisa-agy/skills/lisa-validate-tracker-mapping/SKILL.md +112 -2
  23. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  24. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  25. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  26. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  27. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  28. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  29. package/plugins/lisa-copilot/scripts/scoping-label-audit.mjs +474 -0
  30. package/plugins/lisa-copilot/skills/lisa-github-write-issue/SKILL.md +1 -1
  31. package/plugins/lisa-copilot/skills/lisa-validate-tracker-mapping/SKILL.md +112 -2
  32. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  33. package/plugins/lisa-cursor/scripts/scoping-label-audit.mjs +474 -0
  34. package/plugins/lisa-cursor/skills/lisa-github-write-issue/SKILL.md +1 -1
  35. package/plugins/lisa-cursor/skills/lisa-validate-tracker-mapping/SKILL.md +112 -2
  36. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  37. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  38. package/plugins/lisa-expo-agy/plugin.json +1 -1
  39. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  40. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  41. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  42. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  43. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  44. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  45. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  46. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  47. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  48. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  49. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  50. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  51. package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
  52. package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
  53. package/plugins/lisa-openclaw-agy/plugin.json +1 -1
  54. package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
  55. package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
  56. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  57. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  58. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  59. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  60. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  61. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  62. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  63. package/plugins/lisa-rails-agy/plugin.json +1 -1
  64. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  65. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  66. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  67. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  68. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  69. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  70. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  71. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  72. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  73. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  74. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  75. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  76. package/plugins/src/base/scripts/scoping-label-audit.mjs +474 -0
  77. package/plugins/src/base/skills/lisa-github-write-issue/SKILL.md +1 -1
  78. package/plugins/src/base/skills/lisa-validate-tracker-mapping/SKILL.md +112 -2
  79. package/typescript/copy-contents/.husky/pre-push +76 -0
@@ -4,6 +4,12 @@
4
4
  "_signInMarkers": "Selectors that identify a subflow as performing sign-in. Preamble identity is DERIVED from these rather than from a list of filenames, so the classifier cannot drift when a gate is edited. Replace the shipped values with the selectors YOUR sign-in flow uses. Leaving them unmatched is safe: nothing qualifies as a preamble and every failure reads as a product failure, which is the direction this tool is required to err in — a false 'product' costs an investigation, a false 'preamble' hides a real regression.",
5
5
  "signInMarkers": ["landing:sign-in", "signin:email-input"],
6
6
 
7
+ "_deviceFaultMarkers": "Tokens whose PRESENCE in a flow's `--debug-output` artifacts proves the DEVICE died rather than the product misbehaving — the flow never exercised your app, so its failure is not a regression. Read off the run, never off the JUnit `<failure>` text: the two measured device deaths wrote a BLANK failure element and one reading only `Unknown error`, so a classifier keyed on that text would have caught neither while still sorting every ordinary assertion failure correctly. Shipped with exactly the one fault this repository has a measurement for; add your own as you measure them, and keep the list to faults nothing but a broken device can raise.",
8
+ "deviceFaultMarkers": ["DeviceServerDiedException"],
9
+
10
+ "_deviceInstabilityMarkers": "Tokens whose RATE, not presence, indicates a degraded device — a healthy flow emits one or two. A flow is called a device fault when its count clears both a floor and a multiple of the run's own median flow. The measured case: 25 `animations-not-complete` events on the two affected flows against 0-1 across the other thirty-nine, a stuck IME-insets animation starving UiAutomator's `waitForIdle`. Counting against a baseline is robust to a blank `<failure>` precisely because it never needs the failure to carry any text.",
11
+ "deviceInstabilityMarkers": ["animations-not-complete"],
12
+
7
13
  "_knownIntermittent": "Flows that fail SOMETIMES on an unchanged build. Every entry MUST carry a `measured` block — `failures`/`runs` from a real repeated run, the ISO date it was measured, and the methodology behind it. An entry missing any of those is reported as a registry defect and annotates nothing, on purpose: an unmeasured 'known flake' entry is exactly how a real regression gets dismissed. Keep the narrative — what was ruled out, the local repro recipe — in your BDD README and point at it from `notes`; this file holds only the claim a machine can check. Remeasure and update `measuredAt` rather than letting a stale rate justify today's failure.",
8
14
  "_exampleEntry": {
9
15
  "flow": "saved-insight-save-and-unsave.yaml",
package/package.json CHANGED
@@ -161,7 +161,7 @@
161
161
  "zod-validation-error": "^4.0.0"
162
162
  },
163
163
  "name": "@codyswann/lisa",
164
- "version": "4.23.39",
164
+ "version": "4.24.1",
165
165
  "description": "Claude Code governance framework that applies guardrails, guidance, and automated enforcement to projects",
166
166
  "main": "dist/index.js",
167
167
  "exports": {
@@ -305,6 +305,6 @@
305
305
  "test": "tests"
306
306
  },
307
307
  "types": "./dist/index.d.ts",
308
- "lisaReleaseCommit": "c2404694523aa5b90b3eb68c01487b90199f5ff3",
309
- "gitHead": "c2404694523aa5b90b3eb68c01487b90199f5ff3"
308
+ "lisaReleaseCommit": "2708698cfaab62ab347c27f23c58a17d597aa39a",
309
+ "gitHead": "2708698cfaab62ab347c27f23c58a17d597aa39a"
310
310
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "4.23.39",
3
+ "version": "4.24.1",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "4.23.39",
3
+ "version": "4.24.1",
4
4
  "description": "Universal governance: agents, skills, commands, hooks, and rules for all projects.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -242,7 +242,7 @@ GitHub Issues uses **labels** for the structured metadata that JIRA stores in cu
242
242
 
243
243
  | Concept | Label format | Example |
244
244
  |---------|--------------|---------|
245
- | Issue type | `type:<value>` | `type:Story`, `type:Bug`, `type:Epic`, `type:Sub-task`, `type:Spike`, `type:Improvement` |
245
+ | Issue type | `type:<value>` | `type:Epic`, `type:Story`, `type:Task`, `type:Bug`, `type:Sub-task`, `type:Spike`, `type:Improvement` |
246
246
  | Status | `status:<value>` | `status:ready`, `status:in-progress`, `status:on-dev`, `status:done` |
247
247
  | Priority | `priority:<value>` | `priority:low`, `priority:medium`, `priority:high`, `priority:critical` |
248
248
  | Components | `component:<name>` | `component:auth`, `component:billing` |
@@ -126,6 +126,89 @@ A project's verdict:
126
126
  - **DRIFTED** — at least one CASE_DRIFT, MISSING, or INVERTED role, none of which is UNRESOLVABLE. An INVERTED `ready` is never VALID, no matter how cleanly it resolves.
127
127
  - **UNRESOLVABLE** — the live set couldn't be enumerated (auth mismatch, missing tracker config, access failure). Distinguish this loudly from VALID — an unresolved audit is not a passing audit.
128
128
 
129
+ ## Step 4b — Scoping-label smells (GitHub, advisory)
130
+
131
+ Steps 2–4 audit **lifecycle** roles, and they can only ever audit lifecycle
132
+ roles: every pair they compare comes from a `(role, configured-name)` mapping
133
+ declared in `.lisa.config.json`. The **scoping** vocabulary — `type:`,
134
+ `priority:`, `points:`, `component:` — is declared in no config key at all, so
135
+ there is no configured name to compare a live name against. The audit was not
136
+ failing to check those labels; it had nothing to check them with.
137
+
138
+ That blind spot matters because `lisa-github-write-issue` instructs the write
139
+ path to `gh label create` any label it needs. That is correct for bootstrapping
140
+ a fresh repo, and it makes the scoping vocabulary **unbounded and
141
+ self-expanding**: every typo becomes a permanent new label, and two labels
142
+ meaning one thing silently split every query that filters on them — including
143
+ the `--label "component:<component>"` related-work query the same skill runs to
144
+ find related issues. A component split across two spellings returns half its
145
+ related issues to that query, and nothing anywhere reports it.
146
+
147
+ **Lisa asserts no authority over a project's label vocabularies.**
148
+ `component:` is open by design — an open vocabulary has no wrong member, only
149
+ inconsistent ones — so this step reports *smells*, not violations. `type:` and
150
+ `priority:` are the exception: they are closed sets already enumerated by
151
+ `lisa-github-write-issue`, so membership there is checked against the declared
152
+ set because the lists exist already and cost nothing to assert.
153
+
154
+ > **Advisory only. This is not a gate and must not become one.** A heuristic
155
+ > that guesses at synonyms will be wrong sometimes, and a wrong gate is worse
156
+ > than no gate. Scoping findings never change a project's verdict, never enter
157
+ > the repair path, and never change this skill's exit status. They report; a
158
+ > human decides.
159
+
160
+ Skip this step for non-GitHub trackers — the families are GitHub label
161
+ conventions. Skip it silently, and never let a `gh` failure here downgrade a
162
+ lifecycle verdict; the scoping section simply reports "not collected".
163
+
164
+ ### Collect the vocabulary and its usage
165
+
166
+ Rarity is the whole signal, so the declared label set alone is not enough — a
167
+ label that exists is not a label anyone uses. Collect both, and union them so a
168
+ declared-but-never-applied label lands with a usage of `0`:
169
+
170
+ ```bash
171
+ gh label list --repo "$REPO" --limit 500 --json name \
172
+ | jq '[.[] | {name: .name, count: 0}]' > /tmp/lisa-labels-declared.json
173
+
174
+ gh issue list --repo "$REPO" --state all --limit 1000 --json labels \
175
+ | jq '[.[].labels[].name]
176
+ | group_by(.)
177
+ | [.[] | {name: .[0], count: length}]' > /tmp/lisa-labels-used.json
178
+
179
+ jq -s '{labels: (.[0] + .[1])}' \
180
+ /tmp/lisa-labels-declared.json /tmp/lisa-labels-used.json \
181
+ > /tmp/lisa-scoping-input.json
182
+ ```
183
+
184
+ The `--limit 1000` cap is a sample, not a census. Say so in the report when the
185
+ issue count reaches the cap, because rarity measured on a truncated sample can
186
+ call an established value rare.
187
+
188
+ ### Classify
189
+
190
+ ```bash
191
+ node "${CLAUDE_PLUGIN_ROOT}/scripts/scoping-label-audit.mjs" \
192
+ < /tmp/lisa-scoping-input.json
193
+ ```
194
+
195
+ It returns `{ findings, familiesWalked, advisory: true }` and always exits `0`.
196
+ Three finding kinds, all `severity: "advisory"`:
197
+
198
+ - **`outside-vocabulary`** — a `type:` or `priority:` value outside the closed
199
+ set `lisa-github-write-issue` declares.
200
+ - **`probable-synonym`** — a `component:` value used at most once that sits
201
+ within two edits of a well-established value. **Both** conditions are
202
+ required. Rarity alone is not evidence of a synonym (a single-use
203
+ `component:billing` with no near neighbour is not reported), and proximity
204
+ alone reports healthy repositories forever — `component:ci` and
205
+ `component:cli` are one edit apart and genuinely distinct.
206
+ - **`off-scale`** — a `points:` value off the Fibonacci scale. `points:` is
207
+ open, so this is a consistency smell, not an invalid value.
208
+
209
+ Do not re-derive any of these thresholds in prose or in a second script. The
210
+ module is the single definition; this step calls it.
211
+
129
212
  ## Step 5 — Report
130
213
 
131
214
  Per project, print a terminal-first section:
@@ -151,7 +234,21 @@ An INVERTED `ready` gets a full line rather than a one-word status, because the
151
234
  via /lisa:setup:linear, then set linear.workflow.ready to it.
152
235
  ```
153
236
 
154
- End with a roll-up: counts of VALID / DRIFTED / UNRESOLVABLE projects and the exact next command (`… repair=true` when drift is auto-repairable; an admin note when a status is genuinely MISSING; `/lisa:setup:linear` when a `ready` is INVERTED).
237
+ Print the Step 4b findings, when there are any, as a clearly separate advisory
238
+ block **below** the mapping table so nobody reads a smell as a mapping failure:
239
+
240
+ ```
241
+ scoping labels (advisory — no effect on the verdict above)
242
+ component:plugin used 1×, 1 edit from component:plugins (used 40×) probable synonym
243
+ type:Chore outside the declared type vocabulary review
244
+ points:4 off the Fibonacci scale review
245
+ ```
246
+
247
+ Write those lines for a non-technical operator: say what was seen and what a
248
+ person might do about it, never "FAIL". A healthy repository prints
249
+ `scoping labels: none` and nothing else.
250
+
251
+ End with a roll-up: counts of VALID / DRIFTED / UNRESOLVABLE projects and the exact next command (`… repair=true` when drift is auto-repairable; an admin note when a status is genuinely MISSING; `/lisa:setup:linear` when a `ready` is INVERTED). Scoping findings are reported alongside that roll-up as a **separate count**, never folded into DRIFTED.
155
252
 
156
253
  ## Step 6 — Repair (only when `repair=true`)
157
254
 
@@ -195,6 +292,17 @@ So: present the team's non-default states via `AskUserQuestion`, and write `line
195
292
 
196
293
  Until then, say plainly that the build queue is claiming unapproved work and that pausing build intake is the safe interim.
197
294
 
295
+ ### Scoping-label findings — never repaired at all
296
+
297
+ `repair=true` does not touch scoping labels, and there is no flag that makes it.
298
+ The lifecycle roles are repairable because the live tracker already holds the
299
+ one correct answer; a scoping smell has no such answer anywhere. Renaming or
300
+ merging a `component:` value is a project-vocabulary decision with no
301
+ machine-checkable right answer, and acting on a heuristic guess would rewrite
302
+ real issue metadata on a coin flip. Report the finding, name the two spellings,
303
+ and leave the decision to a human — and note that reconciling them means
304
+ relabelling the issues, which is a tracker mutation this skill never performs.
305
+
198
306
  ### Invalidate the verification cache
199
307
 
200
308
  After any JIRA repair, clear the `setup-jira` reachability cache so it re-verifies the new mapping:
@@ -222,3 +330,5 @@ Re-print the project section showing the post-repair mapping and the new verdict
222
330
  - Use `jq` for all JSON reads/writes; write only changed keys via `jq … > tmp && mv`.
223
331
  - In batch mode, audit each project independently — one project's `UNRESOLVABLE` (e.g. an auth mismatch) must not abort the rest of the sweep.
224
332
  - Reuse the config-resolution defaults and the vendor access skills (`atlassian-access`, `gh`, Linear/Notion MCP); do not invent a parallel mapping or lifecycle vocabulary.
333
+ - Scoping-label findings (Step 4b) are **advisory**. They never change a project's verdict, never change this skill's exit status, and are never auto-repaired. Do not add a flag that turns them into a gate.
334
+ - Never let Step 4b fail the run. A `gh` error, a non-GitHub tracker, or an empty repository means the scoping section reports "not collected" — the lifecycle verdict is unaffected either way.
@@ -0,0 +1,474 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Scoping-label smell detection for `/lisa:validate-tracker-mapping` (#3420).
4
+ *
5
+ * ## The gap this closes
6
+ *
7
+ * The mapping audit walks LIFECYCLE roles only — every pair it checks comes
8
+ * from a `(role, configured-name)` mapping declared in `.lisa.config.json`
9
+ * (`jira.workflow`, `github.labels.build`, `github.labels.prd`, and friends).
10
+ * The SCOPING vocabulary (`type:`, `priority:`, `points:`, `component:`) is
11
+ * declared in no config key at all, so there is no configured name to compare a
12
+ * live name against. The audit was not failing to check those labels; it had
13
+ * nothing to check them with.
14
+ *
15
+ * That matters because `lisa-github-write-issue` instructs the write path to
16
+ * `gh label create` any label it needs, which is correct for bootstrapping a
17
+ * fresh repo and makes the scoping vocabulary unbounded and self-expanding.
18
+ * Every typo becomes a permanent new label, and two labels meaning one thing
19
+ * silently split every query that filters on them — including the
20
+ * `--label "component:<component>"` related-work query that same skill runs.
21
+ *
22
+ * ## Report shape, not membership (owner ruling, 2026-08-29)
23
+ *
24
+ * Lisa asserts no authority over a project's label vocabularies. `component:`
25
+ * is open BY DESIGN — an open vocabulary has no wrong member, only inconsistent
26
+ * ones — so this module reports SMELLS, not violations. `type:` and `priority:`
27
+ * are the exception: they are closed sets already enumerated by
28
+ * `lisa-github-write-issue`, so membership there is checked against the
29
+ * declared set and costs nothing extra.
30
+ *
31
+ * **Advisory only. This is not a gate and must not become one.** A heuristic
32
+ * that guesses at synonyms will be wrong sometimes, and a wrong gate is worse
33
+ * than no gate. Every finding carries `severity: "advisory"`, the CLI always
34
+ * exits 0, and callers must leave the audit's verdict and exit status
35
+ * untouched by anything in here.
36
+ *
37
+ * ## Why rarity AND proximity, never either alone
38
+ *
39
+ * The ruling names two component smells — "a value used exactly once while a
40
+ * near-neighbour is well established" and "two values within a small edit
41
+ * distance of each other". Implemented as two independent rules, the second
42
+ * one fires forever on healthy repositories: measured on this repository's own
43
+ * live labels, `component:ci` (238 issues) and `component:cli` (103 issues) sit
44
+ * at edit distance 1 and are genuinely distinct components. A finding that
45
+ * cannot be acted on and cannot be silenced is noise, and noise is how an
46
+ * advisory report gets ignored wholesale.
47
+ *
48
+ * So the two are one rule with both conditions required: a RARE value that has
49
+ * an ESTABLISHED near neighbour. That also satisfies the ruling's own
50
+ * counter-example — a single-use `component:billing` with no near neighbour is
51
+ * NOT reported, because rarity alone is not evidence of a synonym.
52
+ *
53
+ * ## Where the closed sets come from
54
+ *
55
+ * `lisa-github-write-issue` is the authority, and it is quoted here rather than
56
+ * re-decided. Its CREATE-time field table is the operative list, because that
57
+ * is the one the write path is told to satisfy.
58
+ * `scoping-label-vocabulary-contract.test.ts` asserts the literal below equals
59
+ * both of the skill's tables, so it cannot drift away from them.
60
+ */
61
+
62
+ import { realpathSync } from "node:fs";
63
+ import { fileURLToPath } from "node:url";
64
+
65
+ /** Scoping labels are `<family>:<value>`; these are the families audited. */
66
+ export const SCOPING_LABEL_FAMILIES = Object.freeze([
67
+ "type",
68
+ "priority",
69
+ "points",
70
+ "component",
71
+ ]);
72
+
73
+ /**
74
+ * The closed issue-type vocabulary, verbatim from `lisa-github-write-issue`'s
75
+ * CREATE-time field table.
76
+ *
77
+ * `Task` belongs here. Issue #3420's own summary table omitted it, but the
78
+ * skill's CREATE row lists it and this repository carries 91 issues labelled
79
+ * `type:Task` — encoding the shorter list would have opened the audit by
80
+ * reporting 91 correctly-labelled issues as vocabulary violations.
81
+ */
82
+ export const CLOSED_TYPE_VOCABULARY = Object.freeze([
83
+ "Epic",
84
+ "Story",
85
+ "Task",
86
+ "Bug",
87
+ "Sub-task",
88
+ "Spike",
89
+ "Improvement",
90
+ ]);
91
+
92
+ /**
93
+ * The closed priority vocabulary, verbatim from `lisa-github-write-issue`.
94
+ *
95
+ * Four members, not three: the skill's Priority row is
96
+ * `priority:<low|medium|high|critical>`.
97
+ */
98
+ export const CLOSED_PRIORITY_VOCABULARY = Object.freeze([
99
+ "low",
100
+ "medium",
101
+ "high",
102
+ "critical",
103
+ ]);
104
+
105
+ /**
106
+ * The Fibonacci estimation scale `points:` conventionally follows.
107
+ *
108
+ * `points:` is an OPEN family — a project may legitimately estimate off-scale —
109
+ * so a value outside this set is reported as a smell, never as invalid.
110
+ */
111
+ export const FIBONACCI_POINT_SCALE = Object.freeze([1, 2, 3, 5, 8, 13, 21]);
112
+
113
+ /**
114
+ * Usage count at or below which a value is RARE.
115
+ *
116
+ * The ruling says "used exactly once". Zero is included because a label that
117
+ * exists in the repository's label set and was never applied carries the same
118
+ * smell for the same reason — it was created on demand by a write path and
119
+ * nothing has corroborated it since. A freshly bootstrapped repository where
120
+ * every count is 0 still reports nothing, because nothing there is ESTABLISHED.
121
+ */
122
+ export const RARE_USAGE_MAX = 1;
123
+
124
+ /** Minimum usage before a value can serve as the established side of a pair. */
125
+ export const ESTABLISHED_USAGE_FLOOR = 5;
126
+
127
+ /** How many times an established value must out-use the rare one beside it. */
128
+ export const ESTABLISHED_USAGE_FACTOR = 10;
129
+
130
+ /** Maximum Levenshtein distance at which two values are near neighbours. */
131
+ export const SYNONYM_EDIT_DISTANCE_MAX = 2;
132
+
133
+ /**
134
+ * Shortest value length eligible for proximity matching.
135
+ *
136
+ * On a two- or three-character value a single edit is a whole different word,
137
+ * not a typo — `ci` and `cli` again. Below this length, proximity carries no
138
+ * signal, so short values are compared for equality only.
139
+ */
140
+ export const SYNONYM_MIN_VALUE_LENGTH = 4;
141
+
142
+ /** Every finding this module can emit. Advisory, all of them. */
143
+ export const SCOPING_FINDING_KINDS = Object.freeze([
144
+ "outside-vocabulary",
145
+ "probable-synonym",
146
+ "off-scale",
147
+ ]);
148
+
149
+ /**
150
+ * @typedef {{ readonly name?: string, readonly count?: number, readonly usage?: number }} LabelUsage
151
+ *
152
+ * @typedef {{
153
+ * readonly family: string
154
+ * readonly label: string
155
+ * readonly value: string
156
+ * readonly usage: number
157
+ * readonly kind: string
158
+ * readonly severity: "advisory"
159
+ * readonly detail: string
160
+ * readonly neighbour?: string
161
+ * readonly neighbourUsage?: number
162
+ * readonly distance?: number
163
+ * }} ScopingFinding
164
+ */
165
+
166
+ /**
167
+ * Levenshtein edit distance between two strings.
168
+ *
169
+ * @param {string} a
170
+ * @param {string} b
171
+ * @returns {number} the minimum single-character edits between `a` and `b`
172
+ */
173
+ export function editDistance(a, b) {
174
+ const left = String(a ?? "");
175
+ const right = String(b ?? "");
176
+ if (left === right) return 0;
177
+ if (left.length === 0) return right.length;
178
+ if (right.length === 0) return left.length;
179
+
180
+ let previous = Array.from({ length: right.length + 1 }, (_, i) => i);
181
+
182
+ for (let i = 1; i <= left.length; i += 1) {
183
+ const current = [i];
184
+ for (let j = 1; j <= right.length; j += 1) {
185
+ const substitution =
186
+ previous[j - 1] + (left[i - 1] === right[j - 1] ? 0 : 1);
187
+ current[j] = Math.min(current[j - 1] + 1, previous[j] + 1, substitution);
188
+ }
189
+ previous = current;
190
+ }
191
+
192
+ return previous[right.length];
193
+ }
194
+
195
+ /**
196
+ * Split a label name into its scoping family and value.
197
+ *
198
+ * Returns `null` for anything that is not `<audited-family>:<value>` — lifecycle
199
+ * labels (`status:`, `prd-*`) and free-form labels are not this module's
200
+ * business and must fall through untouched.
201
+ *
202
+ * @param {unknown} name
203
+ * @returns {{ family: string, value: string } | null}
204
+ */
205
+ export function parseScopingLabel(name) {
206
+ if (typeof name !== "string") return null;
207
+ const trimmed = name.trim();
208
+ const separator = trimmed.indexOf(":");
209
+ if (separator <= 0) return null;
210
+ const family = trimmed.slice(0, separator).toLowerCase();
211
+ const value = trimmed.slice(separator + 1).trim();
212
+ if (value.length === 0) return null;
213
+ if (!SCOPING_LABEL_FAMILIES.includes(family)) return null;
214
+ return { family, value };
215
+ }
216
+
217
+ /**
218
+ * Audit a repository's scoping labels for consistency smells.
219
+ *
220
+ * Total and read-only: it mutates nothing, reaches nothing over the network,
221
+ * and returns every finding it has rather than the first. `advisory` is on the
222
+ * result as a standing reminder to callers — the ruling forbids this becoming
223
+ * a gate, and the flag is what a caller asserts against.
224
+ *
225
+ * @param {{ readonly labels?: readonly (string | LabelUsage)[] }} input
226
+ * `labels` is the union of the repository's declared label set and the labels
227
+ * observed on its issues, each with the number of issues carrying it.
228
+ * @returns {{
229
+ * readonly findings: readonly ScopingFinding[]
230
+ * readonly familiesWalked: readonly string[]
231
+ * readonly advisory: true
232
+ * }}
233
+ */
234
+ export function auditScopingLabels(input = {}) {
235
+ const byFamily = groupByFamily(input.labels);
236
+
237
+ const findings = [
238
+ ...closedVocabularyFindings(byFamily.get("type") ?? [], {
239
+ family: "type",
240
+ allowed: CLOSED_TYPE_VOCABULARY,
241
+ caseSensitive: true,
242
+ }),
243
+ ...closedVocabularyFindings(byFamily.get("priority") ?? [], {
244
+ family: "priority",
245
+ allowed: CLOSED_PRIORITY_VOCABULARY,
246
+ caseSensitive: false,
247
+ }),
248
+ ...pointsScaleFindings(byFamily.get("points") ?? []),
249
+ ...synonymFindings(byFamily.get("component") ?? [], "component"),
250
+ ];
251
+
252
+ return {
253
+ findings,
254
+ familiesWalked: SCOPING_LABEL_FAMILIES,
255
+ advisory: true,
256
+ };
257
+ }
258
+
259
+ /**
260
+ * Normalize the caller's label list into `family -> [{ label, value, usage }]`.
261
+ *
262
+ * Duplicates collapse by keeping the highest usage seen: callers assemble the
263
+ * list from two sources (the declared label set, which knows no counts, and the
264
+ * issue scan, which does), and the counted entry is the informative one.
265
+ *
266
+ * @param {readonly (string | LabelUsage)[] | undefined} labels
267
+ * @returns {Map<string, { label: string, value: string, usage: number }[]>}
268
+ */
269
+ function groupByFamily(labels) {
270
+ /** @type {Map<string, Map<string, { label: string, value: string, usage: number }>>} */
271
+ const families = new Map();
272
+
273
+ for (const entry of Array.isArray(labels) ? labels : []) {
274
+ const name = typeof entry === "string" ? entry : entry?.name;
275
+ const parsed = parseScopingLabel(name);
276
+ if (!parsed) continue;
277
+
278
+ const rawUsage =
279
+ typeof entry === "string" ? 0 : (entry?.count ?? entry?.usage ?? 0);
280
+ const usage =
281
+ Number.isFinite(rawUsage) && rawUsage > 0 ? Number(rawUsage) : 0;
282
+
283
+ if (!families.has(parsed.family)) families.set(parsed.family, new Map());
284
+ const bucket = families.get(parsed.family);
285
+ const existing = bucket.get(parsed.value);
286
+ if (existing) {
287
+ existing.usage = Math.max(existing.usage, usage);
288
+ continue;
289
+ }
290
+ bucket.set(parsed.value, {
291
+ label: `${parsed.family}:${parsed.value}`,
292
+ value: parsed.value,
293
+ usage,
294
+ });
295
+ }
296
+
297
+ return new Map(
298
+ [...families].map(([family, bucket]) => [family, [...bucket.values()]])
299
+ );
300
+ }
301
+
302
+ /**
303
+ * Report values outside a family's declared closed set.
304
+ *
305
+ * `type:` compares case-sensitively because its members are capitalized proper
306
+ * nouns the write path emits verbatim (`type:Sub-task`), so `type:bug` is drift
307
+ * worth seeing. `priority:` members are lowercase tokens where casing carries
308
+ * no meaning.
309
+ *
310
+ * @param {readonly { label: string, value: string, usage: number }[]} values
311
+ * @param {{ family: string, allowed: readonly string[], caseSensitive: boolean }} options
312
+ * @returns {ScopingFinding[]}
313
+ */
314
+ function closedVocabularyFindings(values, options) {
315
+ const fold = value => (options.caseSensitive ? value : value.toLowerCase());
316
+ const allowed = new Set(options.allowed.map(fold));
317
+
318
+ return values
319
+ .filter(entry => !allowed.has(fold(entry.value)))
320
+ .map(entry => ({
321
+ family: options.family,
322
+ label: entry.label,
323
+ value: entry.value,
324
+ usage: entry.usage,
325
+ kind: "outside-vocabulary",
326
+ severity: /** @type {"advisory"} */ ("advisory"),
327
+ detail:
328
+ `"${entry.label}" is outside the declared ${options.family} vocabulary ` +
329
+ `(${options.allowed.join(", ")}), which lisa-github-write-issue closes.`,
330
+ }));
331
+ }
332
+
333
+ /**
334
+ * Report `points:` values off the Fibonacci estimation scale.
335
+ *
336
+ * A non-numeric value is off-scale too — `points:xl` is a scale change, not an
337
+ * estimate, and it breaks every query that sorts or sums on points.
338
+ *
339
+ * @param {readonly { label: string, value: string, usage: number }[]} values
340
+ * @returns {ScopingFinding[]}
341
+ */
342
+ function pointsScaleFindings(values) {
343
+ return values
344
+ .filter(entry => !FIBONACCI_POINT_SCALE.includes(Number(entry.value)))
345
+ .map(entry => ({
346
+ family: "points",
347
+ label: entry.label,
348
+ value: entry.value,
349
+ usage: entry.usage,
350
+ kind: "off-scale",
351
+ severity: /** @type {"advisory"} */ ("advisory"),
352
+ detail:
353
+ `"${entry.label}" is off the Fibonacci estimation scale ` +
354
+ `(${FIBONACCI_POINT_SCALE.join(", ")}). points is an open family, so ` +
355
+ `this is a consistency smell, not an invalid value.`,
356
+ }));
357
+ }
358
+
359
+ /**
360
+ * Report rare values that look like typos of an established neighbour.
361
+ *
362
+ * Both conditions are required — see the module preamble on why an ungated
363
+ * proximity rule reports healthy repositories forever. Each rare value is
364
+ * reported at most once, against its closest established neighbour, so a value
365
+ * near two established ones does not produce two findings saying the same
366
+ * thing.
367
+ *
368
+ * @param {readonly { label: string, value: string, usage: number }[]} values
369
+ * @param {string} family
370
+ * @returns {ScopingFinding[]}
371
+ */
372
+ function synonymFindings(values, family) {
373
+ const established = values.filter(
374
+ entry => entry.usage >= ESTABLISHED_USAGE_FLOOR
375
+ );
376
+
377
+ return values.flatMap(entry => {
378
+ if (entry.usage > RARE_USAGE_MAX) return [];
379
+
380
+ const neighbour = established
381
+ .filter(candidate => candidate.value !== entry.value)
382
+ .filter(
383
+ candidate =>
384
+ candidate.usage >= ESTABLISHED_USAGE_FACTOR * Math.max(entry.usage, 1)
385
+ )
386
+ .filter(
387
+ candidate =>
388
+ Math.max(candidate.value.length, entry.value.length) >=
389
+ SYNONYM_MIN_VALUE_LENGTH
390
+ )
391
+ .map(candidate => ({
392
+ candidate,
393
+ distance: editDistance(
394
+ candidate.value.toLowerCase(),
395
+ entry.value.toLowerCase()
396
+ ),
397
+ }))
398
+ .filter(pair => pair.distance <= SYNONYM_EDIT_DISTANCE_MAX)
399
+ .sort(
400
+ (left, right) =>
401
+ left.distance - right.distance ||
402
+ right.candidate.usage - left.candidate.usage
403
+ )[0];
404
+
405
+ if (!neighbour) return [];
406
+
407
+ return [
408
+ {
409
+ family,
410
+ label: entry.label,
411
+ value: entry.value,
412
+ usage: entry.usage,
413
+ kind: "probable-synonym",
414
+ severity: /** @type {"advisory"} */ ("advisory"),
415
+ detail:
416
+ `"${entry.label}" is used ${entry.usage} time(s) and is ` +
417
+ `${neighbour.distance} edit(s) from "${neighbour.candidate.label}", ` +
418
+ `used ${neighbour.candidate.usage} time(s). ${family} is an open ` +
419
+ `vocabulary, so this is a probable synonym to reconcile, not an ` +
420
+ `invalid value — a human decides.`,
421
+ neighbour: neighbour.candidate.label,
422
+ neighbourUsage: neighbour.candidate.usage,
423
+ distance: neighbour.distance,
424
+ },
425
+ ];
426
+ });
427
+ }
428
+
429
+ /**
430
+ * CLI: read `{ labels: [{ name, count }] }` on stdin, print the findings.
431
+ *
432
+ * Exits 0 unconditionally, including when findings exist. The ruling is that
433
+ * this reports and a human decides; a non-zero exit would turn an advisory
434
+ * heuristic into a gate the first time a caller ran it under `set -e`.
435
+ *
436
+ * @returns {Promise<void>}
437
+ */
438
+ async function main() {
439
+ const chunks = [];
440
+ for await (const chunk of process.stdin) {
441
+ chunks.push(chunk);
442
+ }
443
+ const payload = JSON.parse(Buffer.concat(chunks).toString("utf8") || "{}");
444
+
445
+ process.stdout.write(
446
+ `${JSON.stringify(auditScopingLabels({ labels: payload.labels }), null, 2)}\n`
447
+ );
448
+ }
449
+
450
+ /**
451
+ * True when `moduleUrl` names the module node was asked to run.
452
+ *
453
+ * Written out rather than imported: this is a plugin payload, which has no
454
+ * `./lib/` to resolve against. Same rule and same reasoning as
455
+ * `scripts/lib/invoked-as-script.mjs` and `lifecycle-label-trust.mjs`.
456
+ * @param {string} moduleUrl - The caller's own `import.meta.url`.
457
+ * @param {string | undefined} [argv1] - Entry path; defaults to `process.argv[1]`.
458
+ * @returns {boolean} Whether the caller should run its CLI body.
459
+ */
460
+ export function invokedAsScript(moduleUrl, argv1 = process.argv[1]) {
461
+ if (!argv1) return false;
462
+ try {
463
+ return realpathSync(argv1) === realpathSync(fileURLToPath(moduleUrl));
464
+ } catch {
465
+ return false;
466
+ }
467
+ }
468
+
469
+ if (invokedAsScript(import.meta.url)) {
470
+ main().catch(error => {
471
+ process.stderr.write(`${error.message}\n`);
472
+ process.exitCode = 1;
473
+ });
474
+ }
@@ -242,7 +242,7 @@ GitHub Issues uses **labels** for the structured metadata that JIRA stores in cu
242
242
 
243
243
  | Concept | Label format | Example |
244
244
  |---------|--------------|---------|
245
- | Issue type | `type:<value>` | `type:Story`, `type:Bug`, `type:Epic`, `type:Sub-task`, `type:Spike`, `type:Improvement` |
245
+ | Issue type | `type:<value>` | `type:Epic`, `type:Story`, `type:Task`, `type:Bug`, `type:Sub-task`, `type:Spike`, `type:Improvement` |
246
246
  | Status | `status:<value>` | `status:ready`, `status:in-progress`, `status:on-dev`, `status:done` |
247
247
  | Priority | `priority:<value>` | `priority:low`, `priority:medium`, `priority:high`, `priority:critical` |
248
248
  | Components | `component:<name>` | `component:auth`, `component:billing` |