@jjchill/probity-rules 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 (71) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/GLOSSARY.template.md +33 -0
  3. package/README.md +96 -0
  4. package/dist/index.d.ts +20 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.js +20 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/presets/js.d.ts +63 -0
  9. package/dist/presets/js.d.ts.map +1 -0
  10. package/dist/presets/js.js +112 -0
  11. package/dist/presets/js.js.map +1 -0
  12. package/dist/presets/kmp.d.ts +27 -0
  13. package/dist/presets/kmp.d.ts.map +1 -0
  14. package/dist/presets/kmp.js +253 -0
  15. package/dist/presets/kmp.js.map +1 -0
  16. package/dist/presets/kotlin.d.ts +40 -0
  17. package/dist/presets/kotlin.d.ts.map +1 -0
  18. package/dist/presets/kotlin.js +172 -0
  19. package/dist/presets/kotlin.js.map +1 -0
  20. package/dist/presets/swift.d.ts +10 -0
  21. package/dist/presets/swift.d.ts.map +1 -0
  22. package/dist/presets/swift.js +285 -0
  23. package/dist/presets/swift.js.map +1 -0
  24. package/dist/rules/acceptance-language.d.ts +95 -0
  25. package/dist/rules/acceptance-language.d.ts.map +1 -0
  26. package/dist/rules/acceptance-language.js +443 -0
  27. package/dist/rules/acceptance-language.js.map +1 -0
  28. package/dist/rules/gates.d.ts +125 -0
  29. package/dist/rules/gates.d.ts.map +1 -0
  30. package/dist/rules/gates.js +285 -0
  31. package/dist/rules/gates.js.map +1 -0
  32. package/dist/rules/kotlin.d.ts +323 -0
  33. package/dist/rules/kotlin.d.ts.map +1 -0
  34. package/dist/rules/kotlin.js +722 -0
  35. package/dist/rules/kotlin.js.map +1 -0
  36. package/dist/rules/ports-and-adapters.d.ts +86 -0
  37. package/dist/rules/ports-and-adapters.d.ts.map +1 -0
  38. package/dist/rules/ports-and-adapters.js +366 -0
  39. package/dist/rules/ports-and-adapters.js.map +1 -0
  40. package/dist/rules/scoping.d.ts +68 -0
  41. package/dist/rules/scoping.d.ts.map +1 -0
  42. package/dist/rules/scoping.js +93 -0
  43. package/dist/rules/scoping.js.map +1 -0
  44. package/dist/rules/spec-test-parity.d.ts +164 -0
  45. package/dist/rules/spec-test-parity.d.ts.map +1 -0
  46. package/dist/rules/spec-test-parity.js +456 -0
  47. package/dist/rules/spec-test-parity.js.map +1 -0
  48. package/dist/rules/swift.d.ts +50 -0
  49. package/dist/rules/swift.d.ts.map +1 -0
  50. package/dist/rules/swift.js +50 -0
  51. package/dist/rules/swift.js.map +1 -0
  52. package/dist/rules/ubiquitous-language.d.ts +36 -0
  53. package/dist/rules/ubiquitous-language.d.ts.map +1 -0
  54. package/dist/rules/ubiquitous-language.js +140 -0
  55. package/dist/rules/ubiquitous-language.js.map +1 -0
  56. package/dist/scripts/scope-report.d.ts +3 -0
  57. package/dist/scripts/scope-report.d.ts.map +1 -0
  58. package/dist/scripts/scope-report.js +184 -0
  59. package/dist/scripts/scope-report.js.map +1 -0
  60. package/kiro/README.md +20 -0
  61. package/kiro/kiro-agent.template.json +45 -0
  62. package/kiro/kiro-transcript-to-claude.py +183 -0
  63. package/kiro/probity-kiro-translate.py +132 -0
  64. package/kiro/probity-kiro.sh +87 -0
  65. package/kiro/skill-activation-forced-eval.sh +45 -0
  66. package/package.json +68 -0
  67. package/probity.config.kmp.ts +40 -0
  68. package/probity.config.kotlin.ts +37 -0
  69. package/probity.config.swift.ts +38 -0
  70. package/probity.config.ts +43 -0
  71. package/scripts/spec-parity.mjs +345 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kotlin.js","sourceRoot":"","sources":["../../rules/kotlin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,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ated enforcement of the `ports-and-adapters` skill: the
4
+ * Dependency Rule (core imports nothing from adapters, frameworks,
5
+ * vendors, or OS I/O), thin adapters (no business conditionals), and
6
+ * ports as the only test seam.
7
+ *
8
+ * Applies to: write actions. Scope it with a `{ files, rules }` block
9
+ * to the code you care about — every matching write costs an AI call.
10
+ * Pair it with `forbidContentPattern` blocks for known-bad imports so
11
+ * the obvious violations are caught deterministically and free.
12
+ *
13
+ * @param options.instructions — overrides or extends the default
14
+ * boundary rules text. Pass a string to replace it, or a function
15
+ * `(defaults) => ...` to extend it (e.g. name your project's core
16
+ * and adapter directories so the validator infers roles precisely).
17
+ * @param options.glossaryPath — absolute path to the project's
18
+ * ubiquitous-language glossary. When set and readable, the
19
+ * glossary is included in the validator's prompt and port/domain
20
+ * names that conflict with recorded terms become violations.
21
+ * @param options.maxGlossaryChars — truncate the glossary beyond
22
+ * this length when building the prompt (default 8000).
23
+ *
24
+ * @example
25
+ * { files: ['src/core/**', 'src/domain/**'], rules: [enforcePortsBoundary()] }
26
+ *
27
+ * @example
28
+ * enforcePortsBoundary({
29
+ * instructions: (defaults) =>
30
+ * `${defaults}\n\n### Project layout\n\nCore lives in src/core; adapters in src/infra.`,
31
+ * })
32
+ */
33
+ export declare function enforcePortsBoundary(options?: {
34
+ instructions?: string | ((defaults: string) => string);
35
+ glossaryPath?: string;
36
+ maxGlossaryChars?: number;
37
+ }): Rule;
38
+ /**
39
+ * AI-validated companion to `enforcePortsBoundary`, judging the
40
+ * opposite concern: adapters must be thin, but not blind. A new
41
+ * adapter code path performing external I/O with no boundary
42
+ * observability — no structured event, no tap/recording decorator, no
43
+ * span — is blocked; pure mappers, wiring, tests, and untouched
44
+ * legacy paths pass (delta-based).
45
+ *
46
+ * Applies to: write actions. Scope it to adapter paths only (e.g.
47
+ * `**\/adapter\/**`, `**\/infra\/**`) — every matching write costs an
48
+ * AI call.
49
+ *
50
+ * @param options.conventionHint — appended to the validator prompt to
51
+ * name the project's telemetry/tap convention (e.g. "structured
52
+ * Logger.event(tag, event, fields); port taps wired in the demo
53
+ * flavor's Koin module"), so the verdict and its fix suggestion
54
+ * speak the project's language.
55
+ * @param options.instructions — replaces or extends the default rules
56
+ * text (string, or `(defaults) => ...`).
57
+ */
58
+ export declare function enforceAdapterObservability(options?: {
59
+ conventionHint?: string;
60
+ instructions?: string | ((defaults: string) => string);
61
+ }): Rule;
62
+ /**
63
+ * Deterministic companion to `enforcePortsBoundary`: blocks test
64
+ * writes that introduce `jest.mock()` / `vi.mock()` calls with a
65
+ * relative specifier — mocking the team's own modules instead of
66
+ * substituting a fake at a port ("Ports Are the Only Test Seam").
67
+ *
68
+ * Only newly introduced mocks are blocked: a specifier already mocked
69
+ * in the file on disk doesn't re-trigger on later edits, so existing
70
+ * suites can be migrated incrementally. Mocks of bare (package)
71
+ * specifiers are ignored — vendor modules are the adapter's problem,
72
+ * and adapter tests may legitimately isolate them.
73
+ *
74
+ * Applies to: write actions. No AI call; free to run broadly.
75
+ *
76
+ * @param options.allow — specifier pattern(s) exempt from the rule
77
+ * (literal substring or RegExp against the mocked path), e.g. a
78
+ * sanctioned test-helper module.
79
+ *
80
+ * @example
81
+ * { files: ['**\/*.test.*', '**\/*.spec.*'], rules: [forbidInternalModuleMocks()] }
82
+ */
83
+ export declare function forbidInternalModuleMocks(options?: {
84
+ allow?: string | RegExp;
85
+ }): Rule;
86
+ //# sourceMappingURL=ports-and-adapters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ports-and-adapters.d.ts","sourceRoot":"","sources":["../../rules/ports-and-adapters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,IAAI,EAA2B,MAAM,gBAAgB,CAAA;AAmJ3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,GAAE;IACP,YAAY,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC,CAAA;IACtD,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAA;CACrB,GACL,IAAI,CAuCN;AA6DD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,GAAE;IACP,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,YAAY,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC,CAAA;CAClD,GACL,IAAI,CAoCN;AAcD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAO,GACxC,IAAI,CAkCN"}
@@ -0,0 +1,366 @@
1
+ // reason comes FIRST in the shape: an autoregressive model commits to
2
+ // each field in order, so kind-first forces the verdict before the
3
+ // analysis — observed live producing a "violation" whose reason
4
+ // reasoned its way to "Passing." Reason-first lets the model conclude,
5
+ // then label.
6
+ const RESPONSE_SPEC = `## Response format
7
+
8
+ Respond with a single JSON object of exactly this shape:
9
+ {"reason":"<your analysis>","kind":"pass"|"violation"}
10
+ Write reason FIRST and set kind to the conclusion your reason reached —
11
+ the two must agree. Keep reason brief on a clear pass ("" is fine).
12
+ Return JSON only. No prose, no code fences.`;
13
+ const PROCESS_INSTRUCTIONS = `## Role
14
+
15
+ You are an architecture-boundary validator. Judge whether the pending
16
+ write respects the ports-and-adapters (hexagonal) rules below.
17
+
18
+ ## Inputs
19
+
20
+ You will see two or three inputs:
21
+
22
+ 1. "Current file content" — what's on disk right now at the file the
23
+ agent is about to write. May be a parenthesized marker (e.g.
24
+ \`(file does not exist)\`).
25
+ 2. "Pending action" — the file path and what the agent is about to
26
+ write. Content may be raw file text or a patch/diff.
27
+
28
+ ## What you judge
29
+
30
+ Judge the change this write makes (the difference between the current
31
+ file content and the pending action), not the resulting file as a
32
+ whole. Infer the file's architectural role — core/domain, inbound or
33
+ outbound adapter, composition root, or test — from its path and
34
+ content.
35
+
36
+ A transient file state is never itself a violation: an unresolved
37
+ symbol, a dead definition, a half-finished multi-step change. Whether
38
+ the file compiles or runs is checked by the test suite, not by you.
39
+
40
+ A block recorded earlier in the session is a past verdict, not a rule.
41
+ Re-derive your judgment from the rules below. When the user tells you
42
+ in the session to let this change through, treat it as authoritative
43
+ and pass.
44
+
45
+ The bar for blocking is a clear violation of a rule below. Boundary
46
+ placement often involves judgment the agent can defend (composition
47
+ roots wire vendors by design; pure computation libraries need no
48
+ port); when the call is genuinely ambiguous, pass.`;
49
+ const DEFAULT_BOUNDARY_RULES = `## Ports-and-adapters rules
50
+
51
+ The strict rule of this codebase: **an adapter is required for every
52
+ dependency the team doesn't own, and every dependency that isn't
53
+ deployed and released together with this code** — UI toolkits, web and
54
+ application frameworks, databases, third-party APIs and SDKs, message
55
+ brokers, other teams' services, and the operating system itself
56
+ (clock, filesystem, environment, randomness, network).
57
+
58
+ ### The Dependency Rule (core code)
59
+
60
+ Core/domain/use-case code depends only on ports: interfaces the team
61
+ defines, named in the language of the domain, shaped by what the core
62
+ needs.
63
+
64
+ - Core files import NOTHING from adapters, frameworks, vendor SDKs,
65
+ ORMs, or OS I/O modules. \`new Date()\`, \`Date.now()\`,
66
+ \`Math.random()\`, \`process.env\`, filesystem or network access in
67
+ core code are violations — clock, config, randomness, and storage
68
+ are ports.
69
+ - Port signatures use core types only. A vendor type (a Stripe
70
+ object, an ORM entity, an HTTP request/response) appearing in a
71
+ port is a leaked boundary.
72
+ - A module in the same repo and the same deployable unit needs no
73
+ port; a dependency owned by another team or released on its own
74
+ schedule does, even when "it's internal".
75
+
76
+ ### Adapters must be thin
77
+
78
+ An adapter's only job is translation: port call → vendor call, vendor
79
+ result/error → core type. An adapter contains no conditional that
80
+ expresses a business rule. Mapping a vendor error code to a domain
81
+ error is translation; deciding what to do about it is core logic.
82
+ Retry policies, fallback decisions, caching rules, and validation
83
+ belong in the core behind the port — block adapter writes that add
84
+ them. Inbound adapters are equally thin: a route handler parses, calls
85
+ one use-case port, serializes the result.
86
+
87
+ ### Ports are the only test seam
88
+
89
+ Test doubles are substituted at ports and nowhere else. Block test
90
+ writes that introduce module-mocking of the team's own code
91
+ (\`jest.mock('./our-module')\`, \`vi.mock('../internal')\`),
92
+ monkey-patching, or spying on internals — the substitute belongs at a
93
+ port, as an in-memory fake. Faking at a port (an \`InMemoryOrderStore\`
94
+ implementing the \`OrderStore\` port, a controlled \`Clock\`) is the
95
+ intended pattern and always passes.
96
+
97
+ ### Always allowed
98
+
99
+ - Composition roots and factory/wiring modules importing both core
100
+ and adapters to assemble the system.
101
+ - Adapter files importing their own vendor (that is their job).
102
+ - Deleting code. Renames and moves that don't change dependencies.
103
+ - Pure computation libraries with no external effects used directly.`;
104
+ const GLOSSARY_RULES = `### Ubiquitous language
105
+
106
+ A glossary is provided below. Ports, domain types, use cases, and
107
+ their members name domain concepts with the glossary's terms
108
+ verbatim — one term per concept. Naming a recorded concept with a
109
+ synonym or conflicting term is a violation; a concept the glossary
110
+ does not cover is not a violation by itself.`;
111
+ function formatBefore(before) {
112
+ switch (before.kind) {
113
+ case 'present':
114
+ return before.content;
115
+ case 'absent':
116
+ return '(file does not exist)';
117
+ case 'unknown':
118
+ return '(current file content unavailable)';
119
+ }
120
+ }
121
+ function buildPrompt(rules, glossary, before, action) {
122
+ const sections = [PROCESS_INSTRUCTIONS, rules];
123
+ if (glossary) {
124
+ sections.push(GLOSSARY_RULES, `## Glossary\n\n${glossary}`);
125
+ }
126
+ sections.push(`## Current file content\n\n${formatBefore(before)}`, `## Pending action\n\nFile: ${action.path}\n\n${action.content}`, RESPONSE_SPEC);
127
+ return sections.join('\n\n');
128
+ }
129
+ /**
130
+ * AI-validated enforcement of the `ports-and-adapters` skill: the
131
+ * Dependency Rule (core imports nothing from adapters, frameworks,
132
+ * vendors, or OS I/O), thin adapters (no business conditionals), and
133
+ * ports as the only test seam.
134
+ *
135
+ * Applies to: write actions. Scope it with a `{ files, rules }` block
136
+ * to the code you care about — every matching write costs an AI call.
137
+ * Pair it with `forbidContentPattern` blocks for known-bad imports so
138
+ * the obvious violations are caught deterministically and free.
139
+ *
140
+ * @param options.instructions — overrides or extends the default
141
+ * boundary rules text. Pass a string to replace it, or a function
142
+ * `(defaults) => ...` to extend it (e.g. name your project's core
143
+ * and adapter directories so the validator infers roles precisely).
144
+ * @param options.glossaryPath — absolute path to the project's
145
+ * ubiquitous-language glossary. When set and readable, the
146
+ * glossary is included in the validator's prompt and port/domain
147
+ * names that conflict with recorded terms become violations.
148
+ * @param options.maxGlossaryChars — truncate the glossary beyond
149
+ * this length when building the prompt (default 8000).
150
+ *
151
+ * @example
152
+ * { files: ['src/core/**', 'src/domain/**'], rules: [enforcePortsBoundary()] }
153
+ *
154
+ * @example
155
+ * enforcePortsBoundary({
156
+ * instructions: (defaults) =>
157
+ * `${defaults}\n\n### Project layout\n\nCore lives in src/core; adapters in src/infra.`,
158
+ * })
159
+ */
160
+ export function enforcePortsBoundary(options = {}) {
161
+ const rules = typeof options.instructions === 'function'
162
+ ? options.instructions(DEFAULT_BOUNDARY_RULES)
163
+ : (options.instructions ?? DEFAULT_BOUNDARY_RULES);
164
+ const maxGlossaryChars = options.maxGlossaryChars ?? 8000;
165
+ return async function enforcePortsBoundary(action, ctx) {
166
+ if (action.kind !== 'write')
167
+ return { kind: 'pass' };
168
+ if (!ctx?.agent) {
169
+ return {
170
+ kind: 'violation',
171
+ reason: 'enforcePortsBoundary: no AI agent available; configure Config.ai or use a vendor that ships one.',
172
+ };
173
+ }
174
+ let glossary;
175
+ if (options.glossaryPath && ctx.readFile) {
176
+ const file = await ctx.readFile(options.glossaryPath);
177
+ if (file.kind === 'present') {
178
+ glossary =
179
+ file.content.length > maxGlossaryChars
180
+ ? `${file.content.slice(0, maxGlossaryChars)}\n(...glossary truncated...)`
181
+ : file.content;
182
+ }
183
+ }
184
+ const before = (await ctx.readFile?.(action.path)) ?? {
185
+ kind: 'unknown',
186
+ };
187
+ const verdict = await ctx.agent.reason(buildPrompt(rules, glossary, before, action));
188
+ if (verdict.kind === 'violation') {
189
+ return { kind: 'violation', reason: verdict.reason };
190
+ }
191
+ return { kind: 'pass', reason: verdict.reason };
192
+ };
193
+ }
194
+ const ADAPTER_OBS_INSTRUCTIONS = `## Role
195
+
196
+ You are an adapter-observability validator. Adapters are the
197
+ integration points of this codebase, and an uninstrumented
198
+ integration point is undiagnosable in the field. Judge whether the
199
+ pending write keeps new adapter code observable, per the rules below.
200
+
201
+ ## Inputs
202
+
203
+ 1. "Current file content" — what's on disk right now (may be a marker
204
+ like \`(file does not exist)\`).
205
+ 2. "Pending action" — the file path and what the agent is about to
206
+ write.
207
+
208
+ ## What you judge
209
+
210
+ Judge only the change this write makes (before → after), never
211
+ pre-existing code. A transient state (unresolved import, half-built
212
+ class) is never itself a violation. A block recorded earlier in the
213
+ session is a past verdict, not a rule; when the user says to let a
214
+ change through, treat that as authoritative and pass.
215
+
216
+ ## Adapter observability rules
217
+
218
+ A NEW adapter code path that performs external I/O — a network or SDK
219
+ call, database access, filesystem, platform service — must carry
220
+ boundary observability on that path: at least one structured telemetry
221
+ event (call made / outcome / retry, with machine-readable fields), a
222
+ recording tap/decorator around the port, or a span. The point: when
223
+ the integration misbehaves, someone can see what was sent and what
224
+ came back without attaching a debugger.
225
+
226
+ Always pass:
227
+ - Pure type mappers and translators with no external effect.
228
+ - Composition roots and DI wiring (including wiring a tap decorator
229
+ — that IS the observability).
230
+ - Test code and test fixtures/fakes.
231
+ - Edits that only touch existing uninstrumented paths without adding
232
+ new external calls (delta-based: legacy migrates incrementally).
233
+ - Files that are clearly not adapters despite the path.
234
+
235
+ Do not demand a specific API: any structured, greppable event or
236
+ tap/trace convention counts. Never punish redaction (omitting payload
237
+ fields for secrecy) — presence of an event is what matters. You judge
238
+ presence, not field safety: whether a logged field is itself too
239
+ sensitive (a uid, PII) is review's job, not yours. When genuinely
240
+ ambiguous, pass.
241
+
242
+ ## When you block
243
+
244
+ Phrase the remediation concretely: name the exact call to add and
245
+ where. If a "Project convention" section is provided below, use its
246
+ vocabulary verbatim in the remediation (its API or tap pattern, not a
247
+ generic "add logging"). And remind the agent that under this
248
+ codebase's TDD gate, instrumentation should be ASSERTED in the failing
249
+ test first (a fake/recording telemetry collector) — that way the TDD
250
+ validator accepts the event as tested behavior instead of flagging it
251
+ as over-implementation.`;
252
+ /**
253
+ * AI-validated companion to `enforcePortsBoundary`, judging the
254
+ * opposite concern: adapters must be thin, but not blind. A new
255
+ * adapter code path performing external I/O with no boundary
256
+ * observability — no structured event, no tap/recording decorator, no
257
+ * span — is blocked; pure mappers, wiring, tests, and untouched
258
+ * legacy paths pass (delta-based).
259
+ *
260
+ * Applies to: write actions. Scope it to adapter paths only (e.g.
261
+ * `**\/adapter\/**`, `**\/infra\/**`) — every matching write costs an
262
+ * AI call.
263
+ *
264
+ * @param options.conventionHint — appended to the validator prompt to
265
+ * name the project's telemetry/tap convention (e.g. "structured
266
+ * Logger.event(tag, event, fields); port taps wired in the demo
267
+ * flavor's Koin module"), so the verdict and its fix suggestion
268
+ * speak the project's language.
269
+ * @param options.instructions — replaces or extends the default rules
270
+ * text (string, or `(defaults) => ...`).
271
+ */
272
+ export function enforceAdapterObservability(options = {}) {
273
+ const base = typeof options.instructions === 'function'
274
+ ? options.instructions(ADAPTER_OBS_INSTRUCTIONS)
275
+ : (options.instructions ?? ADAPTER_OBS_INSTRUCTIONS);
276
+ const rules = options.conventionHint
277
+ ? `${base}\n\n### Project convention\n\n${options.conventionHint}`
278
+ : base;
279
+ return async function enforceAdapterObservability(action, ctx) {
280
+ if (action.kind !== 'write')
281
+ return { kind: 'pass' };
282
+ if (!ctx?.agent) {
283
+ return {
284
+ kind: 'violation',
285
+ reason: 'enforceAdapterObservability: no AI agent available; configure Config.ai or use a vendor that ships one.',
286
+ };
287
+ }
288
+ const before = (await ctx.readFile?.(action.path)) ?? {
289
+ kind: 'unknown',
290
+ };
291
+ const verdict = await ctx.agent.reason([
292
+ rules,
293
+ `## Current file content\n\n${formatBefore(before)}`,
294
+ `## Pending action\n\nFile: ${action.path}\n\n${action.content}`,
295
+ RESPONSE_SPEC,
296
+ ].join('\n\n'));
297
+ if (verdict.kind === 'violation') {
298
+ return { kind: 'violation', reason: verdict.reason };
299
+ }
300
+ return { kind: 'pass', reason: verdict.reason };
301
+ };
302
+ }
303
+ const MODULE_MOCK_PATTERN = /\b(?:jest|vi)\.(?:mock|doMock)\(\s*(['"`])(\.\.?\/[^'"`]+)\1/g;
304
+ function relativeMockSpecifiers(content) {
305
+ const specifiers = new Set();
306
+ for (const match of content.matchAll(MODULE_MOCK_PATTERN)) {
307
+ const specifier = match[2];
308
+ if (specifier)
309
+ specifiers.add(specifier);
310
+ }
311
+ return specifiers;
312
+ }
313
+ /**
314
+ * Deterministic companion to `enforcePortsBoundary`: blocks test
315
+ * writes that introduce `jest.mock()` / `vi.mock()` calls with a
316
+ * relative specifier — mocking the team's own modules instead of
317
+ * substituting a fake at a port ("Ports Are the Only Test Seam").
318
+ *
319
+ * Only newly introduced mocks are blocked: a specifier already mocked
320
+ * in the file on disk doesn't re-trigger on later edits, so existing
321
+ * suites can be migrated incrementally. Mocks of bare (package)
322
+ * specifiers are ignored — vendor modules are the adapter's problem,
323
+ * and adapter tests may legitimately isolate them.
324
+ *
325
+ * Applies to: write actions. No AI call; free to run broadly.
326
+ *
327
+ * @param options.allow — specifier pattern(s) exempt from the rule
328
+ * (literal substring or RegExp against the mocked path), e.g. a
329
+ * sanctioned test-helper module.
330
+ *
331
+ * @example
332
+ * { files: ['**\/*.test.*', '**\/*.spec.*'], rules: [forbidInternalModuleMocks()] }
333
+ */
334
+ export function forbidInternalModuleMocks(options = {}) {
335
+ const allowed = (specifier) => {
336
+ if (options.allow === undefined)
337
+ return false;
338
+ if (typeof options.allow === 'string')
339
+ return specifier.includes(options.allow);
340
+ return options.allow.test(specifier);
341
+ };
342
+ return async function forbidInternalModuleMocks(action, ctx) {
343
+ if (action.kind !== 'write')
344
+ return { kind: 'pass' };
345
+ const pending = relativeMockSpecifiers(action.content);
346
+ if (pending.size === 0)
347
+ return { kind: 'pass' };
348
+ const before = await ctx?.readFile?.(action.path);
349
+ const existing = before?.kind === 'present'
350
+ ? relativeMockSpecifiers(before.content)
351
+ : new Set();
352
+ const introduced = [...pending].filter((specifier) => !existing.has(specifier) && !allowed(specifier));
353
+ if (introduced.length === 0)
354
+ return { kind: 'pass' };
355
+ return {
356
+ kind: 'violation',
357
+ reason: `This write introduces module-mocking of our own code (${introduced
358
+ .map((s) => `'${s}'`)
359
+ .join(', ')}). Ports are the only test seam: substitute an ` +
360
+ 'in-memory fake at the port the module sits behind instead of ' +
361
+ 'mocking the module. If no port exists yet, that is the missing ' +
362
+ 'design step — see the ports-and-adapters skill.',
363
+ };
364
+ };
365
+ }
366
+ //# sourceMappingURL=ports-and-adapters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ports-and-adapters.js","sourceRoot":"","sources":["../../rules/ports-and-adapters.ts"],"names":[],"mappings":"AAIA,sEAAsE;AACtE,mEAAmE;AACnE,gEAAgE;AAChE,uEAAuE;AACvE,cAAc;AACd,MAAM,aAAa,GAAG;;;;;;4CAMsB,CAAA;AAE5C,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mDAmCsB,CAAA;AAEnD,MAAM,sBAAsB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uEAsDwC,CAAA;AAEvE,MAAM,cAAc,GAAG;;;;;;6CAMsB,CAAA;AAE7C,SAAS,YAAY,CAAC,MAAmB;IACvC,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,SAAS;YACZ,OAAO,MAAM,CAAC,OAAO,CAAA;QACvB,KAAK,QAAQ;YACX,OAAO,uBAAuB,CAAA;QAChC,KAAK,SAAS;YACZ,OAAO,oCAAoC,CAAA;IAC/C,CAAC;AACH,CAAC;AAED,SAAS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E,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAC/D,CAAA;QACD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;QACpD,OAAO;YACL,IAAI,EAAE,WAAW;YACjB,MAAM,EACJ,yDAAyD,UAAU;iBAChE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC;iBACpB,IAAI,CAAC,IAAI,CAAC,iDAAiD;gBAC9D,+DAA+D;gBAC/D,iEAAiE;gBACjE,iDAAiD;SACpD,CAAA;IACH,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,68 @@
1
+ import type { Action, RuleBlock, RuleEntry } from '@nizos/probity';
2
+ /**
3
+ * Replica of Probity's glob-scoping internals, for the tooling in
4
+ * this template set — the workflow eval and `scripts/scope-report.ts`
5
+ * — which must resolve `{ files, rules }` blocks exactly the way the
6
+ * real engine does. Hand-mirrored scoping predicates were the eval's
7
+ * main blind spot: a template glob edit could silently diverge from
8
+ * what the eval exercised.
9
+ *
10
+ * Probity implements these in `src/rules/utils/match-paths.ts`
11
+ * (`buildMatcher`, `actionMatchesFilesScope`) and `src/config.ts`
12
+ * (`anchorGlob` inside `loadConfig`), but its package `exports` map
13
+ * (".", "./types", "./rules") does not expose them, so they are
14
+ * ported here verbatim — same picomatch options, same anchoring
15
+ * convention. Pinned against @nizos/probity 1.10.0: on a Probity
16
+ * upgrade, diff this file against those two sources; if upstream
17
+ * starts exporting them, delete this file and import instead.
18
+ *
19
+ * picomatch is Probity's own matcher dependency, so the same version
20
+ * resolves here in any project with @nizos/probity installed; if your
21
+ * package manager doesn't hoist it, add it: `npm install -D picomatch`.
22
+ */
23
+ /** A `Config.rules` entry that carries a `files` scope. */
24
+ export declare function isRuleBlock(entry: RuleEntry): entry is RuleBlock;
25
+ /**
26
+ * The non-empty glob list `RuleBlock.files` requires. A plain
27
+ * `string[]` (even one built from a non-empty literal) is NOT
28
+ * assignable to it — TS can't prove non-emptiness for a general array
29
+ * type — so preset option types and any `files:` glob list built up
30
+ * before use should be typed `Globs`, not `string[]`.
31
+ */
32
+ export type Globs = NonNullable<RuleBlock['files']>;
33
+ /**
34
+ * Builds a path matcher from include/exclude patterns. Patterns
35
+ * prefixed with `!` are negations (picomatch's `ignore` option);
36
+ * everything else is an include. An all-negations list gets `**` as
37
+ * the default include. `dot: true` so `*`/`**` traverse dot-prefixed
38
+ * segments — without it a scoped rule silently skips dotfiles.
39
+ *
40
+ * Port of @nizos/probity `src/rules/utils/match-paths.ts#buildMatcher`.
41
+ */
42
+ export declare function buildMatcher(patterns: readonly string[]): (path: string) => boolean;
43
+ /**
44
+ * Whether a `{ files, rules }` block applies to an action. Empty
45
+ * `files` matches nothing; non-write actions (commands) pass the
46
+ * block-level filter and rules self-filter by action kind; write
47
+ * actions are matched against `files`.
48
+ *
49
+ * Port of @nizos/probity
50
+ * `src/rules/utils/match-paths.ts#actionMatchesFilesScope`.
51
+ */
52
+ export declare function actionMatchesFilesScope(files: readonly string[], action: Action): boolean;
53
+ /**
54
+ * `**`-prefixed globs are intentional "match anywhere" patterns;
55
+ * anchoring them at the config dir would defeat the user's intent.
56
+ * Negations carry the same convention through the `!` prefix.
57
+ *
58
+ * Port of @nizos/probity `src/config.ts#anchorGlob`.
59
+ */
60
+ export declare function anchorGlob(glob: string, root: string): string;
61
+ /**
62
+ * Anchors every block's relative globs against `root`, the way
63
+ * Probity's `loadConfig` anchors them against the config file's
64
+ * directory — so paths in `Action.path` (absolute POSIX) match
65
+ * regardless of where the session is rooted. Flat rules pass through.
66
+ */
67
+ export declare function anchorEntries(entries: readonly RuleEntry[], root: string): RuleEntry[];
68
+ //# sourceMappingURL=scoping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scoping.d.ts","sourceRoot":"","sources":["../../rules/scoping.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAElE;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,2DAA2D;AAC3D,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,GAAG,KAAK,IAAI,SAAS,CAEhE;AAED;;;;;;GAMG;AACH,MAAM,MAAM,KAAK,GAAG,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;AAEnD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,SAAS,MAAM,EAAE,GAC1B,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAW3B;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,MAAM,EAAE,MAAM,GACb,OAAO,CAIT;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAI7D;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,SAAS,SAAS,EAAE,EAC7B,IAAI,EAAE,MAAM,GACX,SAAS,EAAE,CAMb"}