@1aboveio/engineering-skills 0.0.0-stage → 0.1.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.
Files changed (233) hide show
  1. package/README.md +28 -2
  2. package/package.json +33 -4
  3. package/skills/better-review/LICENSE +3 -0
  4. package/skills/better-review/SKILL.md +249 -0
  5. package/skills/better-review/agents/openai.yaml +9 -0
  6. package/skills/better-review/references/domain-hazards.md +53 -0
  7. package/skills/better-review/references/passes.md +147 -0
  8. package/skills/better-review/references/result.md +151 -0
  9. package/skills/better-review/release-check.mjs +93 -0
  10. package/skills/better-review/scripts/pr-context.mjs +212 -0
  11. package/skills/better-review/scripts/pr-context.test.mjs +168 -0
  12. package/skills/better-review/scripts/rereview-scope.mjs +503 -0
  13. package/skills/better-review/scripts/rereview-scope.test.mjs +587 -0
  14. package/skills/better-review/scripts/scan-diff.mjs +365 -0
  15. package/skills/better-review/scripts/scan-diff.test.mjs +414 -0
  16. package/skills/better-review/scripts/vendor-sync.test.mjs +96 -0
  17. package/skills/e2e-test/LICENSE +3 -0
  18. package/skills/e2e-test/SKILL.md +98 -0
  19. package/skills/e2e-test/assets/ci-gates.cloudbuild.yaml +24 -0
  20. package/skills/e2e-test/references/authoring/auth-flows.md +159 -0
  21. package/skills/e2e-test/references/authoring/playwright-config.md +73 -0
  22. package/skills/e2e-test/references/authoring/playwright-patterns.md +144 -0
  23. package/skills/e2e-test/references/ci-integration.md +25 -0
  24. package/skills/e2e-test/references/ci-playwright-container.md +290 -0
  25. package/skills/e2e-test/references/presentation-sweep.md +104 -0
  26. package/skills/e2e-test/references/reviewing.md +41 -0
  27. package/skills/e2e-test/references/route-manifest.md +51 -0
  28. package/skills/e2e-test/release-check.mjs +93 -0
  29. package/skills/e2e-test/scripts/detect-routes-nextjs.mjs +200 -0
  30. package/skills/e2e-test/scripts/presentation-checks.mjs +171 -0
  31. package/skills/e2e-test/scripts/presentation-checks.test.mjs +106 -0
  32. package/skills/e2e-test/scripts/presentation-perceivability.mjs +179 -0
  33. package/skills/e2e-test/scripts/presentation-perceivability.test.mjs +117 -0
  34. package/skills/e2e-test/scripts/presentation-reachability.mjs +154 -0
  35. package/skills/e2e-test/scripts/presentation-reachability.test.mjs +69 -0
  36. package/skills/e2e-test/scripts/presentation-render-health.mjs +141 -0
  37. package/skills/e2e-test/scripts/presentation-render-health.test.mjs +98 -0
  38. package/skills/e2e-test/scripts/presentation-sweep.mjs +147 -0
  39. package/skills/e2e-test/scripts/presentation-sweep.test.mjs +71 -0
  40. package/skills/e2e-test/scripts/presentation-temporal.mjs +127 -0
  41. package/skills/e2e-test/scripts/presentation-temporal.test.mjs +59 -0
  42. package/skills/e2e-test/scripts/project-route-manifest.mjs +82 -0
  43. package/skills/e2e-test/scripts/project-route-manifest.test.mjs +76 -0
  44. package/skills/e2e-test/scripts/validate-manifest.mjs +106 -0
  45. package/skills/engineering-runtime/LICENSE +3 -0
  46. package/skills/engineering-runtime/SKILL.md +11 -0
  47. package/skills/engineering-runtime/agents/openai.yaml +6 -0
  48. package/skills/engineering-runtime/coherence/workflow.json +597 -0
  49. package/skills/engineering-runtime/engineering-runtime.test.mjs +68 -0
  50. package/skills/engineering-runtime/release-check.mjs +93 -0
  51. package/skills/engineering-runtime/scripts/exact-head-artifact.mjs +131 -0
  52. package/skills/engineering-runtime/scripts/head-check-set.mjs +398 -0
  53. package/skills/engineering-runtime/scripts/invocation-policy.mjs +187 -0
  54. package/skills/engineering-runtime/scripts/invocation-policy.test.mjs +95 -0
  55. package/skills/engineering-runtime/scripts/main-module.mjs +79 -0
  56. package/skills/engineering-runtime/scripts/main-module.test.mjs +288 -0
  57. package/skills/engineering-runtime/scripts/mergify-yaml.mjs +11 -0
  58. package/skills/engineering-runtime/scripts/package-lock.json +43 -0
  59. package/skills/engineering-runtime/scripts/package.json +10 -0
  60. package/skills/engineering-runtime/scripts/required-check-plan.mjs +223 -0
  61. package/skills/engineering-runtime/scripts/required-check-plan.test.mjs +96 -0
  62. package/skills/engineering-runtime/scripts/review-completion.mjs +56 -0
  63. package/skills/engineering-runtime/scripts/workflow-coherence.mjs +595 -0
  64. package/skills/engineering-runtime/scripts/workflow-policy.mjs +189 -0
  65. package/skills/engineering-runtime/scripts/yaml-mapping.mjs +18 -0
  66. package/skills/ensure-coverage/LICENSE +3 -0
  67. package/skills/ensure-coverage/SKILL.md +129 -0
  68. package/skills/ensure-coverage/references/breadth/coverage-ledger.md +92 -0
  69. package/skills/ensure-coverage/references/breadth/inventory-contract.md +85 -0
  70. package/skills/ensure-coverage/references/breadth/surface-baseline.md +44 -0
  71. package/skills/ensure-coverage/references/breadth/surface-discovery.md +16 -0
  72. package/skills/ensure-coverage/references/depth/characterization.md +68 -0
  73. package/skills/ensure-coverage/references/depth/coverage.config.example.json +19 -0
  74. package/skills/ensure-coverage/references/depth/grading.md +35 -0
  75. package/skills/ensure-coverage/references/depth/mock-policy.md +57 -0
  76. package/skills/ensure-coverage/references/depth/test-smells.md +39 -0
  77. package/skills/ensure-coverage/references/enforcement/ci-contract.md +44 -0
  78. package/skills/ensure-coverage/references/examples/coverage-ledger.md +110 -0
  79. package/skills/ensure-coverage/references/examples/refund-flow.md +35 -0
  80. package/skills/ensure-coverage/references/presentation/axis.md +64 -0
  81. package/skills/ensure-coverage/references/process/audit-mode.md +27 -0
  82. package/skills/ensure-coverage/references/process/output-template.md +139 -0
  83. package/skills/ensure-coverage/references/process/test-strategy.md +56 -0
  84. package/skills/ensure-coverage/release-check.mjs +93 -0
  85. package/skills/ensure-coverage/schemas/coverage-config.schema.json +67 -0
  86. package/skills/ensure-coverage/schemas/coverage-file.schema.json +140 -0
  87. package/skills/ensure-coverage/scripts/README.md +99 -0
  88. package/skills/ensure-coverage/scripts/adapters/nextjs-inventory.mjs +182 -0
  89. package/skills/ensure-coverage/scripts/adapters/nextjs-inventory.test.mjs +96 -0
  90. package/skills/ensure-coverage/scripts/check-quarantine-expiry.mjs +105 -0
  91. package/skills/ensure-coverage/scripts/check-quarantine-expiry.test.mjs +47 -0
  92. package/skills/ensure-coverage/scripts/ci-audit.mjs +137 -0
  93. package/skills/ensure-coverage/scripts/ci-audit.test.mjs +86 -0
  94. package/skills/ensure-coverage/scripts/coverage-ledger.mjs +674 -0
  95. package/skills/ensure-coverage/scripts/coverage-ledger.test.mjs +447 -0
  96. package/skills/ensure-coverage/scripts/design-parity.mjs +591 -0
  97. package/skills/ensure-coverage/scripts/design-parity.test.mjs +552 -0
  98. package/skills/ensure-coverage/scripts/lint-tests.mjs +282 -0
  99. package/skills/ensure-coverage/scripts/lint-tests.test.mjs +289 -0
  100. package/skills/ensure-coverage/scripts/mock-policy-config.mjs +176 -0
  101. package/skills/ensure-coverage/scripts/mock-policy-config.test.mjs +119 -0
  102. package/skills/ensure-coverage/scripts/package.json +19 -0
  103. package/skills/golden-path/LICENSE +3 -0
  104. package/skills/golden-path/SKILL.md +230 -0
  105. package/skills/golden-path/agents/openai.yaml +3 -0
  106. package/skills/golden-path/assets/golden-paths.example.json +57 -0
  107. package/skills/golden-path/references/contract.md +239 -0
  108. package/skills/golden-path/references/migration.md +111 -0
  109. package/skills/golden-path/release-check.mjs +93 -0
  110. package/skills/golden-path/scripts/golden-path-core.mjs +1779 -0
  111. package/skills/golden-path/scripts/golden-path.mjs +6 -0
  112. package/skills/golden-path/scripts/golden-path.test.mjs +1457 -0
  113. package/skills/harness-runtime/LICENSE +3 -0
  114. package/skills/harness-runtime/SKILL.md +19 -0
  115. package/skills/harness-runtime/agents/openai.yaml +6 -0
  116. package/skills/harness-runtime/bin/discover-models.mjs +4 -0
  117. package/skills/harness-runtime/bin/model-catalog.mjs +4 -0
  118. package/skills/harness-runtime/contracts.md +15 -0
  119. package/skills/harness-runtime/discover-models.mjs +392 -0
  120. package/skills/harness-runtime/discover-models.test.mjs +363 -0
  121. package/skills/harness-runtime/fixtures/native-question-schemas.json +33 -0
  122. package/skills/harness-runtime/fixtures/question-responses.json +54 -0
  123. package/skills/harness-runtime/harness-runtime.test.mjs +967 -0
  124. package/skills/harness-runtime/index.mjs +767 -0
  125. package/skills/harness-runtime/model-catalog-seed.test.mjs +829 -0
  126. package/skills/harness-runtime/model-catalog.mjs +787 -0
  127. package/skills/harness-runtime/model-catalog.test.mjs +366 -0
  128. package/skills/harness-runtime/native-question-contracts.md +37 -0
  129. package/skills/harness-runtime/references/model-catalog-seed.json +408 -0
  130. package/skills/harness-runtime/references/model-catalog.md +57 -0
  131. package/skills/harness-runtime/release-check.mjs +93 -0
  132. package/skills/resolve-issues/LICENSE +3 -0
  133. package/skills/resolve-issues/SKILL.md +250 -0
  134. package/skills/resolve-issues/agents/openai.yaml +9 -0
  135. package/skills/resolve-issues/plugin-hooks.json +17 -0
  136. package/skills/resolve-issues/references/canary.md +28 -0
  137. package/skills/resolve-issues/references/ci.md +105 -0
  138. package/skills/resolve-issues/references/done.md +25 -0
  139. package/skills/resolve-issues/references/dropbox.md +90 -0
  140. package/skills/resolve-issues/references/expire.md +318 -0
  141. package/skills/resolve-issues/references/exploration.md +202 -0
  142. package/skills/resolve-issues/references/implementation.md +303 -0
  143. package/skills/resolve-issues/references/preflight.md +445 -0
  144. package/skills/resolve-issues/references/review.md +228 -0
  145. package/skills/resolve-issues/references/shared-modules.md +44 -0
  146. package/skills/resolve-issues/references/task-plan.md +264 -0
  147. package/skills/resolve-issues/release-check.mjs +93 -0
  148. package/skills/resolve-issues/scripts/cleanup-runs.mjs +364 -0
  149. package/skills/resolve-issues/scripts/cleanup-runs.test.mjs +280 -0
  150. package/skills/resolve-issues/scripts/discover-models.mjs +9 -0
  151. package/skills/resolve-issues/scripts/dropbox.mjs +473 -0
  152. package/skills/resolve-issues/scripts/dropbox.test.mjs +346 -0
  153. package/skills/resolve-issues/scripts/findings-reuse.mjs +98 -0
  154. package/skills/resolve-issues/scripts/findings-reuse.test.mjs +88 -0
  155. package/skills/resolve-issues/scripts/github-reviews.mjs +384 -0
  156. package/skills/resolve-issues/scripts/github-reviews.test.mjs +264 -0
  157. package/skills/resolve-issues/scripts/install-hooks.mjs +135 -0
  158. package/skills/resolve-issues/scripts/install-hooks.test.mjs +79 -0
  159. package/skills/resolve-issues/scripts/issue-tree.mjs +162 -0
  160. package/skills/resolve-issues/scripts/issue-tree.test.mjs +107 -0
  161. package/skills/resolve-issues/scripts/manual-invocation.test.mjs +14 -0
  162. package/skills/resolve-issues/scripts/model-catalog.mjs +9 -0
  163. package/skills/resolve-issues/scripts/next-actions-capacity.test.mjs +149 -0
  164. package/skills/resolve-issues/scripts/next-actions.mjs +856 -0
  165. package/skills/resolve-issues/scripts/next-actions.test.mjs +915 -0
  166. package/skills/resolve-issues/scripts/plan-sync.mjs +269 -0
  167. package/skills/resolve-issues/scripts/plan-sync.test.mjs +156 -0
  168. package/skills/resolve-issues/scripts/preflight-models.mjs +736 -0
  169. package/skills/resolve-issues/scripts/preflight-models.test.mjs +448 -0
  170. package/skills/resolve-issues/scripts/ready-check.mjs +185 -0
  171. package/skills/resolve-issues/scripts/ready-check.test.mjs +217 -0
  172. package/skills/resolve-issues/scripts/rehydrate.mjs +98 -0
  173. package/skills/resolve-issues/scripts/rehydrate.test.mjs +91 -0
  174. package/skills/resolve-issues/scripts/review-verdict.mjs +509 -0
  175. package/skills/resolve-issues/scripts/review-verdict.test.mjs +1060 -0
  176. package/skills/resolve-issues/scripts/size-check.mjs +492 -0
  177. package/skills/resolve-issues/scripts/size-check.test.mjs +458 -0
  178. package/skills/resolve-release/LICENSE +3 -0
  179. package/skills/resolve-release/SKILL.md +215 -0
  180. package/skills/resolve-release/agents/openai.yaml +8 -0
  181. package/skills/resolve-release/flows/cloud-run-canary.md +13 -0
  182. package/skills/resolve-release/flows/cloud-run.md +7 -0
  183. package/skills/resolve-release/flows/root-tag-npm.md +13 -0
  184. package/skills/resolve-release/flows/workspace-npm.md +22 -0
  185. package/skills/resolve-release/references/canary.md +51 -0
  186. package/skills/resolve-release/references/candidate.md +41 -0
  187. package/skills/resolve-release/references/cut.md +131 -0
  188. package/skills/resolve-release/references/dark-launch.md +66 -0
  189. package/skills/resolve-release/references/flows.md +150 -0
  190. package/skills/resolve-release/references/preflight.md +154 -0
  191. package/skills/resolve-release/references/prepared-metadata.md +260 -0
  192. package/skills/resolve-release/references/promotion.md +82 -0
  193. package/skills/resolve-release/references/publish.md +232 -0
  194. package/skills/resolve-release/references/workspace-npm.md +103 -0
  195. package/skills/resolve-release/release-check.mjs +93 -0
  196. package/skills/resolve-release/scripts/apply.mjs +212 -0
  197. package/skills/resolve-release/scripts/apply.test.mjs +99 -0
  198. package/skills/resolve-release/scripts/dark-flags.mjs +134 -0
  199. package/skills/resolve-release/scripts/dark-flags.test.mjs +100 -0
  200. package/skills/resolve-release/scripts/flow.mjs +500 -0
  201. package/skills/resolve-release/scripts/flow.test.mjs +340 -0
  202. package/skills/resolve-release/scripts/green-head.mjs +231 -0
  203. package/skills/resolve-release/scripts/green-head.test.mjs +101 -0
  204. package/skills/resolve-release/scripts/npm-version-absence.mjs +138 -0
  205. package/skills/resolve-release/scripts/npm-version-absence.test.mjs +426 -0
  206. package/skills/resolve-release/scripts/plan-npm.test.mjs +659 -0
  207. package/skills/resolve-release/scripts/plan-toml-boundary.test.mjs +317 -0
  208. package/skills/resolve-release/scripts/plan-uv.test.mjs +291 -0
  209. package/skills/resolve-release/scripts/plan.mjs +806 -0
  210. package/skills/resolve-release/scripts/plan.test.mjs +428 -0
  211. package/skills/rush-issues/LICENSE +3 -0
  212. package/skills/rush-issues/SKILL.md +58 -0
  213. package/skills/rush-issues/agents/openai.yaml +8 -0
  214. package/skills/rush-issues/rehydrate.mjs +10 -0
  215. package/skills/rush-issues/release-check.mjs +93 -0
  216. package/skills/rush-release/LICENSE +3 -0
  217. package/skills/rush-release/SKILL.md +35 -0
  218. package/skills/rush-release/agents/openai.yaml +8 -0
  219. package/skills/rush-release/release-check.mjs +93 -0
  220. package/skills/test-quality/LICENSE +3 -0
  221. package/skills/test-quality/SKILL.md +79 -0
  222. package/skills/test-quality/references/audit.md +80 -0
  223. package/skills/test-quality/references/lint.md +24 -0
  224. package/skills/test-quality/references/principles.md +143 -0
  225. package/skills/test-quality/references/testing-conventions.md +9 -0
  226. package/skills/test-quality/release-check.mjs +93 -0
  227. package/skills/test-quality/scripts/lint-tests.mjs +574 -0
  228. package/skills/test-quality/scripts/lint-tests.test.mjs +591 -0
  229. package/skills/test-quality/scripts/mock-policy-config.mjs +176 -0
  230. package/skills/test-quality/scripts/mock-policy-config.test.mjs +119 -0
  231. package/skills/test-quality/scripts/persist-conventions-core.mjs +116 -0
  232. package/skills/test-quality/scripts/persist-conventions.mjs +17 -0
  233. package/skills/test-quality/scripts/persist-conventions.test.mjs +104 -0
@@ -0,0 +1,282 @@
1
+ // lint-tests — static GATE lints over test files. The decidable subset of the
2
+ // skills' test-authoring doctrine, turned into deterministic checks that don't
3
+ // need an LLM: fast, free, robust, run in CI on every PR.
4
+ //
5
+ // node lint-tests.mjs --diff <base> # PR mode: only violations ADDED in base...HEAD (CI default)
6
+ // node lint-tests.mjs [--files a,b] # specific files
7
+ // node lint-tests.mjs # whole-tree scan of discovered test files
8
+ // --rules no-skip,no-fixed-timeout # run a subset (default: all gate rules)
9
+ // --json # machine output
10
+ //
11
+ // (Named lint-tests, not test-lint, so node's --test runner doesn't glob it as a
12
+ // test file via its `test-*` pattern and execute the CLI mid-suite.)
13
+ //
14
+ // SCOPE — what belongs here vs. not:
15
+ // GATE (here): syntactically decidable, ~zero false positives → safe to BLOCK.
16
+ // A noisy blocking lint gets disabled, so only near-certain rules live here.
17
+ // LEAD (NOT here): heuristic/judgment — "is this assertion meaningful?",
18
+ // over-mocking, asserting on an error page. Those stay LEADS for the reviewer
19
+ // (the reviewer) and human/LLM judgment. Lint the
20
+ // decidable shell; leave the semantics to review.
21
+ //
22
+ // Adding a gate rule = append to RULES below (id + message + line patterns). Keep
23
+ // the false-positive bar high: if a legitimate test could trip it, it's a lead.
24
+
25
+ import fs from 'node:fs'
26
+ import path from 'node:path'
27
+ import { execSync } from 'node:child_process'
28
+ import { loadMockPolicyFromFile, extractMockTarget, classifyMockTarget } from './mock-policy-config.mjs'
29
+ import { isMainModule } from '../../engineering-runtime/scripts/main-module.mjs'
30
+
31
+ // Skip / focus forms. `.only`/focus silently disable every OTHER test;
32
+ // skip/fixme/todo disable this one. Unconditional forms only, the same set as
33
+ // test-quality's lint: a gate blocks only what a legitimate test can never trip.
34
+ // Conditional skips (skipif, a runtime `test.skip()` / `pytest.skip()`, xfail) can
35
+ // be legitimate (a platform skip CI still runs elsewhere, a strict xfail pinned to
36
+ // an open issue), so they are test-quality's `conditional-skip` lead, not a gate
37
+ // here (see references/process/test-strategy.md).
38
+ export const SKIP_PATTERNS = [
39
+ { kind: 'skip', re: /\b(?:test|it|describe|suite|context)\s*\.\s*skip\s*(?:\.\s*each\b|\(\s*['"`])/ },
40
+ { kind: 'only', re: /\b(?:test|it|describe|suite|context)\s*\.\s*only\b/ },
41
+ { kind: 'fixme', re: /\b(?:test|it)\s*\.\s*fixme\b/ },
42
+ { kind: 'todo', re: /\b(?:test|it)\s*\.\s*todo\s*\(/ },
43
+ { kind: 'skip', re: /\b(?:xit|xdescribe|xtest)\s*\(/ },
44
+ { kind: 'only', re: /\b(?:fit|fdescribe|ftest)\s*\(/ },
45
+ { kind: 'skip', re: /@(?:pytest\.mark\.)?skip\b/ },
46
+ { kind: 'skip', re: /@unittest\.skip\b/ },
47
+ ]
48
+
49
+ // Fixed sleeps — a timer instead of an explicit wait. The single biggest source of
50
+ // flake; doctrine is "never waitForTimeout()". Precise: these forms are ~never
51
+ // legitimate in a test (an aliased `cy.wait('@x')` or polling helper is not matched).
52
+ export const FIXED_TIMEOUT_PATTERNS = [
53
+ { kind: 'waitForTimeout', re: /\.waitForTimeout\s*\(/ },
54
+ { kind: 'cy.wait', re: /\bcy\.wait\s*\(\s*\d/ }, // numeric only; cy.wait('@alias') is fine
55
+ { kind: 'time.sleep', re: /\btime\.sleep\s*\(/ },
56
+ ]
57
+
58
+ // Empty test body — a `test`/`it` whose callback body is `{}`. A placeholder
59
+ // that passes vacuously and asserts nothing: the Missing-Assertion smell in its
60
+ // one decidable, ~zero-false-positive form. The BROADER "has statements but no
61
+ // assertion" case is NOT here — a test can assert through a helper, so a block
62
+ // with no `expect`/`assert` token may still assert; that stays a review LEAD
63
+ // (the reviewer) and the test-smells doctrine ([../references/depth/test-smells.md]).
64
+ // Matches only single-line empty bodies (`() => {}` / `function () {}`), incl.
65
+ // `.skip`/`.each(...)`/`.concurrent` chains and Playwright `async ({ page })`
66
+ // fixtures; `describe`/`suite` are excluded (an empty suite is not a fake test).
67
+ // A multi-line empty body is rarer and deliberately left to the lead, not
68
+ // false-blocked.
69
+ export const EMPTY_TEST_PATTERNS = [
70
+ { kind: 'empty-test', re: /\b(?:it|test)\s*(?:\.\s*\w+\s*(?:\([^)]*\)\s*)?)?\(\s*[`'"][^`'"]*[`'"]\s*,\s*(?:async\s+)?(?:function\s*\*?\s*)?\([^)]*\)\s*(?:=>\s*)?\{\s*\}\s*\)?/ },
71
+ ]
72
+
73
+ // Swallowed assertion — an assertion matcher whose rejection is eaten by a
74
+ // chained `.catch(...)`, so the assertion can NEVER fail the test. The vacuous
75
+ // form behind the #237 login regression: `expect(locator).not.toBeVisible().catch(() => {})`
76
+ // passed whether or not the button was actually visible. Decidable and
77
+ // ~zero-false-positive: a Playwright web-first matcher (`.toXxx(...)`) directly
78
+ // chained to `.catch(` is never legitimate — a real assertion's rejection must
79
+ // surface, not be discarded. (Synchronous Jest matchers don't return a promise,
80
+ // so `.toBe(x).catch()` only appears as a deliberate swallow.) The broader
81
+ // "assertion guarded by a try/catch that re-passes" case stays a review LEAD
82
+ // (the reviewer); only the directly-chained matcher form is gated here.
83
+ export const SWALLOWED_ASSERTION_PATTERNS = [
84
+ { kind: 'swallowed-catch', re: /\.to[A-Z]\w*\s*\([^)]*\)\s*\.catch\s*\(/ },
85
+ ]
86
+
87
+ export const RULES = [
88
+ { id: 'no-skip', message: 'test skipped/focused — seed/quarantine/route/delete instead (test-strategy.md)', patterns: SKIP_PATTERNS },
89
+ { id: 'no-fixed-timeout', message: 'fixed sleep — use an explicit wait (waitForResponse / expect.poll / web-first assertion), never a timer', patterns: FIXED_TIMEOUT_PATTERNS },
90
+ { id: 'no-empty-test', message: 'empty test body — a placeholder that asserts nothing (passes vacuously); write the behavior assertion or delete it (test-smells.md)', patterns: EMPTY_TEST_PATTERNS },
91
+ { id: 'no-swallowed-assertion', message: 'assertion failure swallowed by .catch() — the matcher can never fail (vacuous green); let it throw, or assert the real condition (test-smells.md)', patterns: SWALLOWED_ASSERTION_PATTERNS },
92
+ ]
93
+
94
+ // Default-on GATE for over-mocking — the decidable core of the depth axis
95
+ // (mock-policy.md), mechanized via the externals-allowlist inversion
96
+ // (mock-policy-config.mjs). A `match`-style rule (not a line pattern): it pulls
97
+ // the mock target, exempts declared externals, and flags a mock
98
+ // of a first-party internal seam. ZERO-TOLERANCE: default-on, no waiver, and
99
+ // never silently inert — over-mock is a hard gate (mock-policy.md), not an
100
+ // opt-in. `coverage.config.json` only *declares topology* (a monorepo's own
101
+ // package scope, generated dirs to exempt); it cannot turn the gate off. With
102
+ // no config the rule runs on conventional `@/`/`~/` defaults. Run it diff-scoped
103
+ // in the PR lane (catch new seams) AND whole-tree (no inherited seam is
104
+ // grandfathered — the tree stays red until they are removed).
105
+ export const MOCK_INTERNAL_SEAM_RULE = {
106
+ id: 'mock-internal-seam',
107
+ defaultOn: true,
108
+ message: 'mocks an internal seam — real internals, faked externals (mock-policy.md): replace it with a real-boundary test, or fake the external instead. No waivers; no inherited grace.',
109
+ match(raw, code, ctx) {
110
+ const target = extractMockTarget(code)
111
+ if (!target) return null
112
+ // classifyMockTarget falls back to DEFAULT_MOCK_POLICY when ctx has no
113
+ // policy, so the gate can never be silently disabled by omitting config.
114
+ const { internal, reason } = classifyMockTarget(target, ctx && ctx.policy)
115
+ if (!internal) return null
116
+ return { kind: 'internal-seam', detail: target, reason }
117
+ },
118
+ }
119
+
120
+ // Every known rule. RULES is the original authoring-gate set; ALL_RULES is the
121
+ // full registry. mock-internal-seam is default-on (defaultOn:true), so it is in
122
+ // the default selection too — it is a standard gate now, not an opt-in.
123
+ export const ALL_RULES = [...RULES, MOCK_INTERNAL_SEAM_RULE]
124
+
125
+ export function selectRules(ruleIds) {
126
+ if (ruleIds && ruleIds.length > 0) {
127
+ const set = new Set(ruleIds)
128
+ return ALL_RULES.filter((r) => set.has(r.id))
129
+ }
130
+ // Default: every rule that isn't explicitly opted out (defaultOn:false).
131
+ return ALL_RULES.filter((r) => r.defaultOn !== false)
132
+ }
133
+
134
+ // Strip line comments so a doc line or a commented-out example is not flagged.
135
+ // Best-effort (ignores strings/block comments) — live code has no leading `//`.
136
+ export function stripComment(line) {
137
+ return line.replace(/\/\/.*$/, '').replace(/(^|\s)#.*$/, '$1')
138
+ }
139
+
140
+ // Skips/timeouts only matter in tests; linting app code would false-flag a
141
+ // legitimate `.skip()`/`.only` array method or a real `sleep`.
142
+ export function isTestFile(p) {
143
+ if (!p) return false
144
+ return /\.(spec|test)\.[cm]?[jt]sx?$/.test(p)
145
+ || /(^|\/)(e2e|tests?|__tests__)\//.test(p)
146
+ || /(^|\/)test_[^/]*\.py$/.test(p)
147
+ || /_test\.py$/.test(p)
148
+ }
149
+
150
+ // Pure: run the selected rules over one line → findings (≤ one per rule). `ctx`
151
+ // carries the resolved mock policy (declared topology) for `match`-style rules;
152
+ // pattern rules ignore it. A `match` rule sees the raw line and the
153
+ // comment-stripped code (so a commented-out example never trips).
154
+ function scanLine(file, raw, lineNo, rules, ctx) {
155
+ const code = stripComment(raw)
156
+ const out = []
157
+ for (const rule of rules) {
158
+ if (typeof rule.match === 'function') {
159
+ const hit = rule.match(raw, code, ctx)
160
+ if (hit) {
161
+ out.push({
162
+ file, line: lineNo, rule: rule.id, kind: hit.kind || rule.id,
163
+ snippet: raw.trim().slice(0, 120),
164
+ ...(hit.detail ? { detail: hit.detail } : {}),
165
+ ...(hit.reason ? { reason: hit.reason } : {}),
166
+ })
167
+ }
168
+ continue
169
+ }
170
+ const hit = rule.patterns.find((p) => p.re.test(code))
171
+ if (hit) out.push({ file, line: lineNo, rule: rule.id, kind: hit.kind || rule.id, snippet: raw.trim().slice(0, 120) })
172
+ }
173
+ return out
174
+ }
175
+
176
+ export function scanLines(file, lines, ruleIds, ctx) {
177
+ const rules = selectRules(ruleIds)
178
+ const out = []
179
+ lines.forEach((raw, i) => out.push(...scanLine(file, raw, i + 1, rules, ctx)))
180
+ return out
181
+ }
182
+
183
+ export function scanText(file, text, ruleIds, ctx) {
184
+ return scanLines(file, (text || '').split(/\r?\n/), ruleIds, ctx)
185
+ }
186
+
187
+ // Pure: scan a unified diff, flagging only ADDED lines in test files (inherited
188
+ // violations on context lines are left alone — reviewer diff-discipline).
189
+ export function scanDiff(diffText, ruleIds, ctx) {
190
+ const rules = selectRules(ruleIds)
191
+ const out = []
192
+ let file = null
193
+ let newLine = 0
194
+ for (const raw of (diffText || '').split(/\r?\n/)) {
195
+ if (raw.startsWith('+++ ')) {
196
+ const m = raw.match(/^\+\+\+ (?:b\/)?(.+)$/)
197
+ file = m && m[1] !== '/dev/null' ? m[1] : null
198
+ continue
199
+ }
200
+ if (raw.startsWith('@@')) {
201
+ const m = raw.match(/\+(\d+)/)
202
+ newLine = m ? parseInt(m[1], 10) : 0
203
+ continue
204
+ }
205
+ if (raw.startsWith('+')) {
206
+ if (isTestFile(file)) out.push(...scanLine(file, raw.slice(1), newLine, rules, ctx))
207
+ newLine++
208
+ } else if (raw.startsWith('-') || raw.startsWith('\\')) {
209
+ // removed line / "No newline" marker — do not advance the new-file counter
210
+ } else {
211
+ newLine++ // context line
212
+ }
213
+ }
214
+ return out
215
+ }
216
+
217
+ // ---- CLI ----
218
+
219
+ function discover(dir, acc = []) {
220
+ let entries
221
+ try { entries = fs.readdirSync(dir, { withFileTypes: true }) } catch { return acc } // unreadable dir: skip, never crash the scan
222
+ for (const entry of entries) {
223
+ if (entry.name === 'node_modules' || entry.name.startsWith('.')) continue
224
+ const full = path.join(dir, entry.name)
225
+ if (entry.isDirectory()) discover(full, acc)
226
+ else if (isTestFile(full)) acc.push(full)
227
+ }
228
+ return acc
229
+ }
230
+
231
+ const USAGE = [
232
+ 'usage: lint-tests.mjs [--diff <base>] [--files a,b] [--rules a,b] [--config coverage.config.json] [--json]',
233
+ ' --diff <base> lint only what the diff base...HEAD ADDS (PR lane); without it, scan the whole tree from cwd',
234
+ ' --rules a,b subset of: no-skip, no-fixed-timeout, no-empty-test, no-swallowed-assertion, mock-internal-seam',
235
+ ].join('\n')
236
+
237
+ export function runCli(argv, { name = 'lint-tests' } = {}) {
238
+ if (argv.includes('--help') || argv.includes('-h')) { console.log(USAGE); return 0 }
239
+ const flags = {}
240
+ for (let i = 0; i < argv.length; i++) {
241
+ const a = argv[i]
242
+ if (a === '--json') flags.json = true
243
+ else if (a === '--diff') flags.diff = argv[++i]
244
+ else if (a === '--files') flags.files = argv[++i]
245
+ else if (a === '--rules') flags.rules = argv[++i].split(',').map((s) => s.trim()).filter(Boolean)
246
+ else if (a === '--config') flags.config = argv[++i]
247
+ }
248
+ const ruleIds = flags.rules || null
249
+ // Resolve the project's mock policy once — this only declares *topology*
250
+ // (first-party scopes, exempt externals); it cannot disable the gate.
251
+ // `--config <file>` reads THAT file; otherwise discover coverage.config.json
252
+ // in cwd; with neither, the conventional `@/`/`~/` defaults apply.
253
+ const ctx = { policy: loadMockPolicyFromFile(flags.config) }
254
+
255
+ let findings = []
256
+ if (flags.diff) {
257
+ const diff = execSync(`git diff ${flags.diff}...HEAD`, { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 })
258
+ findings = scanDiff(diff, ruleIds, ctx)
259
+ } else {
260
+ const files = flags.files
261
+ ? flags.files.split(',').map((s) => s.trim()).filter(Boolean)
262
+ : discover('.')
263
+ for (const f of files) {
264
+ if (fs.existsSync(f)) findings.push(...scanText(f, fs.readFileSync(f, 'utf8'), ruleIds, ctx))
265
+ }
266
+ }
267
+
268
+ if (flags.json) {
269
+ console.log(JSON.stringify({ ok: findings.length === 0, findings }, null, 2))
270
+ } else if (findings.length === 0) {
271
+ console.log(`${name}: ✓ no violations` + (flags.diff ? ' introduced in this change' : ' in scanned test files'))
272
+ } else {
273
+ console.log(`${name}: ✗ ${findings.length} violation(s):\n`)
274
+ for (const f of findings) {
275
+ const why = f.detail ? ` → ${f.detail}${f.reason ? ` (${f.reason})` : ''}` : ''
276
+ console.log(` ${f.file}:${f.line} [${f.rule}/${f.kind}] ${f.snippet}${why}`)
277
+ }
278
+ }
279
+ return findings.length === 0 ? 0 : 1
280
+ }
281
+
282
+ if (isMainModule(import.meta.url)) process.exit(runCli(process.argv.slice(2), { name: 'lint-tests' }))
@@ -0,0 +1,289 @@
1
+ // Tests for the lint-tests gate engine (pure core, no filesystem/git).
2
+ import { test } from 'node:test'
3
+ import assert from 'node:assert/strict'
4
+
5
+ import { scanText, scanDiff, selectRules, RULES, ALL_RULES, isTestFile, stripComment, runCli } from './lint-tests.mjs'
6
+ import { resolveMockPolicy } from './mock-policy-config.mjs'
7
+
8
+ test('default rules = all gate rules incl. the default-on mock-internal-seam', () => {
9
+ assert.deepEqual(
10
+ selectRules().map((r) => r.id).sort(),
11
+ ['mock-internal-seam', 'no-empty-test', 'no-fixed-timeout', 'no-skip', 'no-swallowed-assertion'],
12
+ )
13
+ assert.equal(RULES.length, 4) // the four authoring gates; mock-internal-seam lives in ALL_RULES
14
+ })
15
+
16
+ test('no-skip rule flags skip/only/xfail (carries rule + kind)', () => {
17
+ // non-empty bodies so this isolates no-skip from the no-empty-test rule
18
+ const f = scanText('a.spec.ts', 'test.skip("x", () => { go() })\ndescribe.only("y", () => { go() })')
19
+ assert.deepEqual(f.map((x) => [x.rule, x.kind]), [['no-skip', 'skip'], ['no-skip', 'only']])
20
+ })
21
+
22
+ test('no-fixed-timeout flags waitForTimeout / numeric cy.wait / time.sleep', () => {
23
+ const f = scanText('a.spec.ts', [
24
+ 'await page.waitForTimeout(500)',
25
+ "cy.wait(1000)",
26
+ 'time.sleep(2)',
27
+ ].join('\n'))
28
+ assert.deepEqual(f.map((x) => x.kind), ['waitForTimeout', 'cy.wait', 'time.sleep'])
29
+ assert.ok(f.every((x) => x.rule === 'no-fixed-timeout'))
30
+ })
31
+
32
+ test('no-fixed-timeout does NOT flag an aliased cy.wait (not a fixed sleep)', () => {
33
+ assert.deepEqual(scanText('a.spec.ts', "cy.wait('@getUser')"), [])
34
+ })
35
+
36
+ test('--rules selection runs only the chosen rule', () => {
37
+ const text = 'test.skip("x", () => {})\nawait page.waitForTimeout(500)'
38
+ const onlySkip = scanText('a.spec.ts', text, ['no-skip'])
39
+ assert.deepEqual(onlySkip.map((x) => x.rule), ['no-skip'])
40
+ const onlyTimeout = scanText('a.spec.ts', text, ['no-fixed-timeout'])
41
+ assert.deepEqual(onlyTimeout.map((x) => x.rule), ['no-fixed-timeout'])
42
+ })
43
+
44
+ test('a single line can trip two different rules', () => {
45
+ // contrived but valid: a skipped test on the same line as a timeout call
46
+ const f = scanText('a.spec.ts', 'test.skip("x", async () => { await page.waitForTimeout(1) })')
47
+ assert.deepEqual(f.map((x) => x.rule).sort(), ['no-fixed-timeout', 'no-skip'])
48
+ })
49
+
50
+ test('scanDiff flags only ADDED violations in test files, with new-file line numbers', () => {
51
+ const diff = [
52
+ '+++ b/e2e/x.spec.ts',
53
+ '@@ -10,2 +10,3 @@',
54
+ ' context',
55
+ '+await page.waitForTimeout(300)',
56
+ '-old line',
57
+ ].join('\n')
58
+ const f = scanDiff(diff)
59
+ assert.equal(f.length, 1)
60
+ assert.equal(f[0].rule, 'no-fixed-timeout')
61
+ assert.equal(f[0].line, 11)
62
+ })
63
+
64
+ test('scanDiff ignores violations added to NON-test files', () => {
65
+ const diff = ['+++ b/src/util.ts', '@@ -1,1 +1,2 @@', '+await sleepThing.waitForTimeout(5)'].join('\n')
66
+ assert.deepEqual(scanDiff(diff), [])
67
+ })
68
+
69
+ test('isTestFile is shared and recognizes spec/test paths, rejects app code', () => {
70
+ for (const p of ['e2e/a.spec.ts', 'src/x.test.tsx', 'tests/e2e/b.spec.js', 'api/test_views.py', 'pkg/foo_test.py', '__tests__/c.ts']) {
71
+ assert.equal(isTestFile(p), true, p)
72
+ }
73
+ for (const p of ['src/app/page.tsx', 'lib/util.ts', 'README.md']) {
74
+ assert.equal(isTestFile(p), false, p)
75
+ }
76
+ })
77
+
78
+ // ---- no-skip rule: richer cases (folded in from the former skip-lint suite) ----
79
+
80
+ test('no-skip leaves conditional skips to test-quality (a lead, not a gate)', () => {
81
+ // A runtime or annotated skip depends on a condition: legitimate for a platform
82
+ // CI still runs elsewhere, a hole otherwise. A gate cannot tell which.
83
+ const f = scanText('a.spec.ts', 'if (!user) test.skip();\ntest.skip(true, "https://github.com/o/r/issues/1")')
84
+ assert.equal(f.filter((x) => x.rule === 'no-skip').length, 0)
85
+ })
86
+
87
+ test('no-skip flags unconditional Python skips, not skipif/runtime skip/xfail', () => {
88
+ const text = [
89
+ '@pytest.mark.skip(reason="x")',
90
+ '@pytest.mark.skipif(cond)',
91
+ '@unittest.skip("x")',
92
+ ' pytest.skip("x")',
93
+ '@pytest.mark.xfail',
94
+ ].join('\n')
95
+ assert.deepEqual(scanText('test_x.py', text).filter((f) => f.rule === 'no-skip').map((f) => [f.line, f.kind]), [[1, 'skip'], [3, 'skip']])
96
+ })
97
+
98
+ test('no-skip flags declared-skipped and todo tests', () => {
99
+ const f = scanText('a.spec.ts', 'test.skip("later", () => { go() })\ntest.todo("write me")')
100
+ assert.deepEqual(f.filter((x) => x.rule === 'no-skip').map((x) => x.kind), ['skip', 'todo'])
101
+ })
102
+
103
+ test('no-skip does not flag a commented-out or doc mention', () => {
104
+ const text = [
105
+ '// never use test.skip() — banned',
106
+ '# doc: test.skip is not allowed',
107
+ 'const xs = items.skip(2) // unrelated array method',
108
+ ].join('\n')
109
+ assert.deepEqual(scanText('a.spec.ts', text), [])
110
+ })
111
+
112
+ test('no-skip does not flag .only/.skip method calls that are not test forms', () => {
113
+ assert.deepEqual(scanText('a.spec.ts', 'arr.skip(1); foo.only;'), [])
114
+ })
115
+
116
+ // ---- no-empty-test rule: the decidable floor of the Missing-Assertion smell ----
117
+
118
+ test('no-empty-test flags empty arrow/function/playwright/.each/.concurrent bodies', () => {
119
+ const cases = [
120
+ "test('a', () => {})",
121
+ 'it("b", async () => {})',
122
+ "test('c', function () {})",
123
+ "test('d', async ({ page }) => {})",
124
+ "it.each([1,2])('e', () => {})",
125
+ "test.concurrent('f', () => {})",
126
+ ]
127
+ for (const c of cases) {
128
+ const f = scanText('a.spec.ts', c, ['no-empty-test'])
129
+ assert.equal(f.length, 1, `should flag: ${c}`)
130
+ assert.equal(f[0].kind, 'empty-test')
131
+ }
132
+ })
133
+
134
+ test('no-empty-test does NOT flag a test that has a body', () => {
135
+ const cases = [
136
+ "test('a', () => { expect(1).toBe(1) })",
137
+ "it('b', async () => { await verifyDashboard(page) })", // asserts via helper — not empty, not flagged
138
+ "test('c', () => { doThing() })",
139
+ ]
140
+ for (const c of cases) assert.deepEqual(scanText('a.spec.ts', c, ['no-empty-test']), [], c)
141
+ })
142
+
143
+ test('no-empty-test does NOT flag describe/suite, look-alike identifiers, or 1-arg calls', () => {
144
+ const text = [
145
+ "describe('group', () => {})", // empty suite is not a fake test
146
+ "emit('evt', () => {})", // 'it' inside emit — word boundary protects
147
+ "submit('x', () => {})", // 'it' inside submit
148
+ "it('pending')", // no callback — not an empty-bodied test
149
+ 'const t = () => {}', // not a test call
150
+ ].join('\n')
151
+ assert.deepEqual(scanText('a.spec.ts', text, ['no-empty-test']), [])
152
+ })
153
+
154
+ test('no-empty-test leaves a multi-line empty body to the review lead (no false block)', () => {
155
+ // The opening line has no closing brace, so the single-line gate does not fire.
156
+ assert.deepEqual(scanText('a.spec.ts', "it('x', () => {\n})", ['no-empty-test']), [])
157
+ })
158
+
159
+ // ---- no-swallowed-assertion rule: the vacuous-green form behind #237 ----
160
+
161
+ test('no-swallowed-assertion flags a matcher whose rejection is eaten by .catch()', () => {
162
+ const cases = [
163
+ "await expect(page.locator('#cta')).not.toBeVisible().catch(() => {})", // the #237 form
164
+ "await expect(btn).toHaveText('Sign in').catch(() => null)",
165
+ 'await expect(x).toBe(1).catch(() => {})',
166
+ ]
167
+ for (const c of cases) {
168
+ const f = scanText('a.spec.ts', c, ['no-swallowed-assertion'])
169
+ assert.equal(f.length, 1, `should flag: ${c}`)
170
+ assert.equal(f[0].kind, 'swallowed-catch')
171
+ assert.equal(f[0].rule, 'no-swallowed-assertion')
172
+ }
173
+ })
174
+
175
+ test('no-swallowed-assertion does NOT flag a legitimate assertion or an unrelated .catch', () => {
176
+ const cases = [
177
+ "await expect(page.locator('#cta')).toBeVisible()", // real assertion, no swallow
178
+ "const v = await fetchThing().catch(() => fallback)", // .catch on setup, not a matcher
179
+ "promise.then(ok).catch(handleError)", // plain promise handling
180
+ ]
181
+ for (const c of cases) assert.deepEqual(scanText('a.spec.ts', c, ['no-swallowed-assertion']), [], c)
182
+ })
183
+
184
+ test('no-swallowed-assertion is a default gate and flags it in a PR diff', () => {
185
+ const diff = [
186
+ '+++ b/e2e/login.sweep.spec.ts',
187
+ '@@ -1,1 +1,2 @@',
188
+ ' context',
189
+ "+await expect(page.locator('#cta')).not.toBeVisible().catch(() => {})",
190
+ ].join('\n')
191
+ const f = scanDiff(diff) // default rule set, no explicit --rules
192
+ assert.equal(f.length, 1)
193
+ assert.equal(f[0].rule, 'no-swallowed-assertion')
194
+ })
195
+
196
+ test('stripComment removes // and # trailing comments', () => {
197
+ assert.equal(stripComment('code // test.skip()').includes('test.skip'), false)
198
+ assert.equal(stripComment('code # pytest.skip').includes('pytest.skip'), false)
199
+ })
200
+
201
+ test('scanDiff ignores a pre-existing skip on an unchanged (context) line', () => {
202
+ const diff = ['+++ b/e2e/x.spec.ts', '@@ -1,2 +1,3 @@', ' test.skip("inherited", () => {})', '+test("added clean", () => { ok() })'].join('\n')
203
+ assert.deepEqual(scanDiff(diff), [])
204
+ })
205
+
206
+ // ---- mock-internal-seam rule: the zero-tolerance, default-on over-mock gate ----
207
+
208
+ const SEAM_CTX = { policy: resolveMockPolicy({ firstPartyPackages: ['@agentier/'] }) }
209
+
210
+ test('mock-internal-seam is default-on: in ALL_RULES and in the default gate set', () => {
211
+ assert.ok(ALL_RULES.some((r) => r.id === 'mock-internal-seam'))
212
+ // zero-tolerance: it runs by default, no opt-in needed
213
+ assert.ok(selectRules().some((r) => r.id === 'mock-internal-seam'))
214
+ assert.deepEqual(
215
+ selectRules().map((r) => r.id).sort(),
216
+ ['mock-internal-seam', 'no-empty-test', 'no-fixed-timeout', 'no-skip', 'no-swallowed-assertion'],
217
+ )
218
+ })
219
+
220
+ test('mock-internal-seam cannot be opted out via config (enabled:false is ignored)', () => {
221
+ // the gate is defaultOn:true; selectRules does not consult policy.enabled
222
+ assert.ok(selectRules().some((r) => r.id === 'mock-internal-seam'))
223
+ // and naming a subset still resolves it from the registry
224
+ assert.deepEqual(selectRules(['mock-internal-seam']).map((r) => r.id), ['mock-internal-seam'])
225
+ })
226
+
227
+ test('mock-internal-seam flags a first-party alias mock (the studio incident)', () => {
228
+ const f = scanText('a.test.ts', "vi." + "mock('@/lib/org-allowlist-client')", ['mock-internal-seam'], SEAM_CTX)
229
+ assert.equal(f.length, 1)
230
+ assert.equal(f[0].rule, 'mock-internal-seam')
231
+ assert.equal(f[0].detail, '@/lib/org-allowlist-client')
232
+ })
233
+
234
+ test('mock-internal-seam exempts stdlib and third-party packages', () => {
235
+ const text = ["vi.mock('node:fs')", "jest.mock('react')", "vi.mock('@playwright/test')"].join('\n')
236
+ assert.deepEqual(scanText('a.test.ts', text, ['mock-internal-seam'], SEAM_CTX), [])
237
+ })
238
+
239
+ test('mock-internal-seam ignores an inline @mock-ok comment (no waivers)', () => {
240
+ const text = "vi." + "mock('@/lib/cp') // @mock-ok: covered by cp.real.test.ts"
241
+ const f = scanText('a.test.ts', text, ['mock-internal-seam'], SEAM_CTX)
242
+ assert.equal(f.length, 1) // still flagged — zero-tolerance, no escape hatch
243
+ assert.equal(f[0].detail, '@/lib/cp')
244
+ })
245
+
246
+ test('mock-internal-seam flags a declared first-party workspace package', () => {
247
+ const f = scanText('a.test.ts', "vi.mock('@agentier/shared')", ['mock-internal-seam'], SEAM_CTX)
248
+ assert.equal(f.length, 1)
249
+ assert.equal(f[0].detail, '@agentier/shared')
250
+ })
251
+
252
+ test('mock-internal-seam fires with NO ctx policy (never silently inert; @/ defaults apply)', () => {
253
+ // zero-tolerance: omitting config must not disable the gate — it falls back
254
+ // to DEFAULT_MOCK_POLICY, which flags conventional @/ first-party mocks.
255
+ const f = scanText('a.test.ts', "vi." + "mock('@/lib/x')", ['mock-internal-seam'])
256
+ assert.equal(f.length, 1)
257
+ assert.equal(f[0].detail, '@/lib/x')
258
+ })
259
+
260
+ test('mock-internal-seam flags an ADDED first-party mock in a PR diff (PR lane)', () => {
261
+ const diff = ['+++ b/src/__tests__/x.test.ts', '@@ -1,1 +1,2 @@', " import x", "+vi." + "mock('@/lib/cp')"].join('\n')
262
+ const f = scanDiff(diff, ['mock-internal-seam'], SEAM_CTX)
263
+ assert.equal(f.length, 1)
264
+ assert.equal(f[0].rule, 'mock-internal-seam')
265
+ })
266
+
267
+ test('mock-internal-seam flags an INHERITED (un-added) mock in a whole-tree scan (no grandfathering)', () => {
268
+ // whole-tree lane: scanText sees every line, not just diff additions, so the
269
+ // 781-style inherited debt is flagged until removed.
270
+ const f = scanText('src/__tests__/x.test.ts', "import x\nvi.mock('@/lib/cp')\n", ['mock-internal-seam'], SEAM_CTX)
271
+ assert.equal(f.length, 1)
272
+ assert.equal(f[0].detail, '@/lib/cp')
273
+ })
274
+
275
+ test('mock-internal-seam does not fire on a commented-out mock line', () => {
276
+ assert.deepEqual(scanText('a.test.ts', "// vi.mock('@/lib/x')", ['mock-internal-seam'], SEAM_CTX), [])
277
+ })
278
+
279
+ test('--help prints usage and exits 0 without scanning the tree', () => {
280
+ const lines = []
281
+ const orig = console.log
282
+ console.log = (s) => lines.push(String(s))
283
+ try {
284
+ assert.equal(runCli(['--help']), 0)
285
+ } finally {
286
+ console.log = orig
287
+ }
288
+ assert.match(lines.join('\n'), /usage: lint-tests\.mjs/)
289
+ })