@voidh4x0r/slopgate 0.1.6 → 0.1.9

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.
package/CHANGELOG.md CHANGED
@@ -9,6 +9,42 @@ All notable changes to this project are documented here. The format follows [Kee
9
9
  - Go and Rust grammars.
10
10
  - VS Code diagnostics.
11
11
 
12
+ ## [0.1.9] - 2026-11-22
13
+
14
+ ### Changed
15
+ - Documented that a config `include` replaces the default Python/TS/JS pattern set, while CLI `--include` appends to it. `--verbose` now prints the effective include count so a reduced file set is visible.
16
+ - `py/noop-test` reuses the `function_definition` list already collected by the rule instead of walking the tree a second time for the helper index.
17
+ - Added `include-semantics` coverage: default 3 files, config `src/**` 2 files, CLI `--include src/**` 3 files, and verbose shows 11 patterns.
18
+
19
+ ### Unchanged
20
+ - No runtime behavior change to include handling; this is documentation and visibility only.
21
+ - Benchmark remains **29 high-confidence findings across 991,705 lines of CPython, 96.6% labeled precision (28/29), 14/14 seeded defects, 0 high findings on 601 JavaScript files**; `staleLabels: []`, `unlabeledHigh: []`.
22
+ - 255 tests.
23
+
24
+ ## [0.1.8] - 2026-11-22
25
+
26
+ ### Fixed
27
+ - `py/noop-test` now looks up only the local helper called by the test’s last statement. The name→node map is a light single walk; `hasAssertion` runs once per called helper and is cached. Test-heavy files no longer scan every function body, and the full CPython benchmark returns to ≈10.98 s (from 11.72 s).
28
+ - Unknown rule ids in `.slopgate.json` are now configuration errors (exit 2, MCP tool error), matching `--rule py/nope` and the README exit-code table. `--quiet` no longer hides the message.
29
+
30
+ ### Changed
31
+ - 252 tests, including the `bad-rule-config` CLI case, the engine rejection test, and helper-lookup coverage.
32
+ - Benchmark findings unchanged at **29 high-confidence findings across 991,705 lines of CPython, 96.6% labeled precision (28/29), 14/14 seeded defects, 0 high findings on 601 JavaScript files**; `staleLabels: []`, `unlabeledHigh: []`.
33
+ - Performance-guard recommendation for the large CPython corpus tightened from 10% to 5%.
34
+
35
+ ## [0.1.7] - 2026-11-22
36
+
37
+ ### Fixed
38
+ - `py/noop-test` builds its local-helper index lazily, only when a test actually lacks an assertion. This removes the unconditional full-tree walk introduced in 0.1.6 and restores the rule’s scan cost (≈10.4 s → 9.9 s for `--rule py/noop-test` on the full CPython corpus).
39
+ - `py/swallowed-exception` checks whether a comment is a real explanation before applying future-work noise. “The caller retries later, so we ignore this error” demotes, while “refactor this later” stays high.
40
+
41
+ ### Added
42
+ - Benchmark performance guard: `--max-regression <percent>` compares per-corpus `durationMs` with the previous results file, ignores corpora under 100 ms, and exits 1 on a regression. Intended for same-machine runs.
43
+
44
+ ### Changed
45
+ - 250 tests, including the `future-words` fixture and performance-guard unit tests.
46
+ - Benchmark findings unchanged at **29 high-confidence findings across 991,705 lines of CPython, 96.6% labeled precision (28/29), 14/14 seeded defects, 0 high findings on 601 JavaScript files**; `staleLabels: []`, `unlabeledHigh: []`.
47
+
12
48
  ## [0.1.6] - 2026-11-22
13
49
 
14
50
  ### Fixed
package/README.md CHANGED
@@ -14,7 +14,7 @@ AI writes code that *looks* right. `slopgate` finds the parts that only look rig
14
14
  ```console
15
15
  $ npx @voidh4x0r/slopgate .
16
16
 
17
- slopgate 0.1.6 · 4 files · 39ms
17
+ slopgate 0.1.9 · 4 files · 39ms
18
18
 
19
19
  app.py
20
20
  4:1 error high py/phantom-import `helper` is imported but not declared in any manifest and not present in this repository
@@ -144,11 +144,13 @@ slopgate [path] [options]
144
144
  }
145
145
  ```
146
146
 
147
- - `include` / `exclude` — globs relative to the project root; the defaults cover Python and TS/JS sources.
147
+ - `include` / `exclude` — globs relative to the project root. **A config `include` replaces the default pattern set** (the ten Python/TS/JS globs); list every extension you still want. The CLI `--include` **appends** to the effective set, so `--include "src/**"` keeps the defaults.
148
148
  - `ignoreModules` — top-level modules to always treat as declared (dynamic imports, private packages).
149
149
  - `rules` — `"off"` or an explicit severity (`"error"`, `"warning"`, `"info"`).
150
150
  - `confidence` / `failOn` — same meaning as the CLI flags; CLI flags win.
151
151
 
152
+ For example, `{"include": ["src/**"]}` scans only files under `src/`; it does **not** keep the default Python/TS/JS coverage. Add the patterns you need, or use the CLI flag to append one pattern to the defaults.
153
+
152
154
  `slopgate init` writes a minimal config plus a GitHub Actions workflow.
153
155
 
154
156
  ### Adopting it on an existing repository
@@ -204,7 +206,7 @@ jobs:
204
206
  - uses: actions/checkout@v4
205
207
  - uses: actions/setup-node@v4
206
208
  with: { node-version: 22 }
207
- - run: npx --yes @voidh4x0r/slopgate@0.1.6 . --fail-on high
209
+ - run: npx --yes @voidh4x0r/slopgate@0.1.9 . --fail-on high
208
210
  ```
209
211
 
210
212
  For GitHub code scanning, use `--format sarif` and upload with `github/codeql-action/upload-sarif`.
@@ -212,7 +214,7 @@ For GitHub code scanning, use `--format sarif` and upload with `github/codeql-ac
212
214
  For inline pull-request annotations **without** code scanning, use `--format github`, which emits [workflow commands](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions):
213
215
 
214
216
  ```yaml
215
- - run: npx --yes @voidh4x0r/slopgate@0.1.6 . --format github --fail-on high
217
+ - run: npx --yes @voidh4x0r/slopgate@0.1.9 . --format github --fail-on high
216
218
  ```
217
219
 
218
220
  Each finding becomes an `error` / `warning` / `notice` annotation on the exact line, followed by a summary notice.
@@ -265,7 +267,7 @@ We would rather miss a finding than teach you to ignore the tool. That is also w
265
267
  `slopgate` parses with tree-sitter compiled to WebAssembly and reuses one parser per language. Scanning never spawns a subprocess. `--diff` and the MCP `scan_diff` tool invoke `git`, so those two paths need git on `PATH` and a sandbox that permits child processes:
266
268
 
267
269
  - 20 files / ~3k lines: **~125 ms** end to end (Windows laptop, cold start)
268
- - 1,845 files / 991,705 lines (CPython standard library): **~12 s** in the benchmark run
270
+ - 1,845 files / 991,705 lines (CPython standard library): **~11 s** in the benchmark run
269
271
  - 3 grammar files load once in **~35 ms**
270
272
  - Python: ~12 ms per 35 KB file
271
273
 
@@ -297,7 +299,7 @@ Issues and pull requests are welcome. Start with [CONTRIBUTING.md](https://githu
297
299
  git clone https://github.com/VoidH4x0r/slopgate
298
300
  cd slopgate
299
301
  npm install
300
- npm test # 245 tests; the tests themselves make no network or child-process calls
302
+ npm test # 255 tests; the tests themselves make no network or child-process calls
301
303
  npm run typecheck
302
304
  npm run verify # all release gates in one command
303
305
  ```
package/dist/cli.js CHANGED
@@ -428,7 +428,7 @@ async function runScan(options, io) {
428
428
  quiet: options.quiet,
429
429
  }));
430
430
  if (options.verbose) {
431
- writeOut(io, ` config: ${configFile ?? '(none)'} baseline: ${baseline ? path.relative(process.cwd(), baselinePath) : '(none)'}` +
431
+ writeOut(io, ` config: ${configFile ?? '(none)'} include: ${merged.include.length} pattern(s) baseline: ${baseline ? path.relative(process.cwd(), baselinePath) : '(none)'}` +
432
432
  (onlyDiff > 0 ? ` diff-only: ${onlyDiff} finding(s) outside the diff were ignored` : '') +
433
433
  '\n');
434
434
  }
package/dist/engine.js CHANGED
@@ -49,8 +49,9 @@ export async function scanProject(options) {
49
49
  const warnings = [];
50
50
  const { config } = options;
51
51
  for (const ruleId of Object.keys(config.rules)) {
52
- if (!RULE_BY_ID.has(ruleId))
53
- warnings.push(`unknown rule in config: ${ruleId}`);
52
+ if (!RULE_BY_ID.has(ruleId)) {
53
+ throw new Error(`unknown rule in config: ${ruleId} (run \`slopgate rules\` to list the ${ALL_RULES.length} rule ids)`);
54
+ }
54
55
  }
55
56
  const deps = await loadProjectDeps(root);
56
57
  deps.ignoredModules = new Set(config.ignoreModules);
@@ -111,23 +111,21 @@ function bodyCallsSelf(body) {
111
111
  });
112
112
  return found;
113
113
  }
114
- /** Module-local helpers whose bodies contain an assertion. */
115
- function localAssertionHelpers(root) {
116
- const helpers = new Map();
117
- for (const fn of descendantsOfType(root, ['function_definition'])) {
114
+ /** Lightweight name → node index; assertion checks happen on demand. */
115
+ function localFunctionDefinitions(functions) {
116
+ const definitions = new Map();
117
+ for (const fn of functions) {
118
118
  if (fn.parent?.type === 'class_definition')
119
119
  continue;
120
120
  const name = fn.childForFieldName('name')?.text;
121
121
  if (!name || testFunctionName(fn))
122
122
  continue;
123
- const body = fn.childForFieldName('body');
124
- if (body && hasAssertion(body))
125
- helpers.set(name, fn);
123
+ definitions.set(name, fn);
126
124
  }
127
- return helpers;
125
+ return definitions;
128
126
  }
129
- /** The last statement calling a local helper can carry the assertions. */
130
- function delegatesToLocalHelper(statements, helpers) {
127
+ /** Name of the bare local call in the test's last statement, if any. */
128
+ function lastLocalCallName(statements) {
131
129
  const last = statements[statements.length - 1];
132
130
  if (!last)
133
131
  return undefined;
@@ -137,7 +135,27 @@ function delegatesToLocalHelper(statements, helpers) {
137
135
  if (call?.type !== 'call')
138
136
  return undefined;
139
137
  const name = collapseWhitespace(call.childForFieldName('function')?.text ?? '');
140
- return /^[A-Za-z_]\w*$/.test(name) && helpers.has(name) ? name : undefined;
138
+ return /^[A-Za-z_]\w*$/.test(name) ? name : undefined;
139
+ }
140
+ /**
141
+ * Only check the helper the last statement actually calls. The definition map
142
+ * is built on first hit and each helper's assertion result is cached, so a
143
+ * test-heavy file does not run `hasAssertion` over every function.
144
+ */
145
+ function delegatesToLocalHelper(statements, definitions, assertionCache) {
146
+ const name = lastLocalCallName(statements);
147
+ if (!name)
148
+ return undefined;
149
+ const helper = definitions().get(name);
150
+ if (!helper)
151
+ return undefined;
152
+ let asserts = assertionCache.get(name);
153
+ if (asserts === undefined) {
154
+ const body = helper.childForFieldName('body');
155
+ asserts = body !== null && hasAssertion(body);
156
+ assertionCache.set(name, asserts);
157
+ }
158
+ return asserts ? name : undefined;
141
159
  }
142
160
  function placeholderForm(block) {
143
161
  const statements = statementsOf(block);
@@ -297,8 +315,17 @@ const noopTest = {
297
315
  if (isStubFile(ctx.file))
298
316
  return [];
299
317
  const drafts = [];
300
- const helpers = localAssertionHelpers(ctx.root);
301
- for (const fn of descendantsOfType(ctx.root, ['function_definition'])) {
318
+ // A test-dense file may have thousands of assertion-free tests. Reuse the
319
+ // function list the rule already collected; build the name index once, and
320
+ // only assert-check the helper actually called.
321
+ const functions = descendantsOfType(ctx.root, ['function_definition']);
322
+ let definitionIndex;
323
+ const definitions = () => {
324
+ definitionIndex ??= localFunctionDefinitions(functions);
325
+ return definitionIndex;
326
+ };
327
+ const helperAssertions = new Map();
328
+ for (const fn of functions) {
302
329
  const name = testFunctionName(fn);
303
330
  if (!name)
304
331
  continue;
@@ -334,7 +361,7 @@ const noopTest = {
334
361
  }
335
362
  if (!hasAssertion(body)) {
336
363
  const delegatesToSelf = bodyCallsSelf(body);
337
- const delegatedTo = delegatesToLocalHelper(statements, helpers);
364
+ const delegatedTo = delegatesToLocalHelper(statements, definitions, helperAssertions);
338
365
  const parameters = fn.childForFieldName('parameters');
339
366
  const parameterCount = parameters
340
367
  ? parameters.namedChildren.filter((child) => child.type !== 'comment').length
@@ -514,14 +541,15 @@ function supportingCommentBetween(ctx, fromLine, toLine, handlerStartLine) {
514
541
  return ctx.comments.some((comment) => {
515
542
  if (!overlaps(comment, fromLine, toLine))
516
543
  return false;
517
- const text = commentText(ctx, comment);
518
- if (NOISE_COMMENT.test(text))
544
+ const positioned = isStandaloneComment(ctx, comment) || comment.startLine >= handlerStartLine;
545
+ if (!positioned)
519
546
  return false;
520
- // A comment on the `pass` line is unambiguously about that handler, so it
521
- // may be inline. Comments before the handler must start their own line:
522
- // a trailing comment on a previous statement often describes that
523
- // statement, not the exception.
524
- return isStandaloneComment(ctx, comment) || comment.startLine >= handlerStartLine;
547
+ const text = commentText(ctx, comment);
548
+ // A stated explanation wins over future-work wording: "the caller retries
549
+ // later, so we ignore this error" is an explanation, not a TODO.
550
+ if (isExplanationText(text))
551
+ return true;
552
+ return !NOISE_COMMENT.test(text);
525
553
  });
526
554
  }
527
555
  const NOOP_DIR_PREFIX = /^(dummy|noop|no_op|no-op)[-_]/;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voidh4x0r/slopgate",
3
- "version": "0.1.6",
3
+ "version": "0.1.9",
4
4
  "description": "The slop gate for AI-written code. Precision-first structural linting for Python and TypeScript.",
5
5
  "type": "module",
6
6
  "license": "MIT",