@voidh4x0r/slopgate 0.1.6 → 0.1.8

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,30 @@ 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.8] - 2026-11-22
13
+
14
+ ### Fixed
15
+ - `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).
16
+ - 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.
17
+
18
+ ### Changed
19
+ - 252 tests, including the `bad-rule-config` CLI case, the engine rejection test, and helper-lookup coverage.
20
+ - 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: []`.
21
+ - Performance-guard recommendation for the large CPython corpus tightened from 10% to 5%.
22
+
23
+ ## [0.1.7] - 2026-11-22
24
+
25
+ ### Fixed
26
+ - `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).
27
+ - `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.
28
+
29
+ ### Added
30
+ - 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.
31
+
32
+ ### Changed
33
+ - 250 tests, including the `future-words` fixture and performance-guard unit tests.
34
+ - 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: []`.
35
+
12
36
  ## [0.1.6] - 2026-11-22
13
37
 
14
38
  ### 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.8 · 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
@@ -204,7 +204,7 @@ jobs:
204
204
  - uses: actions/checkout@v4
205
205
  - uses: actions/setup-node@v4
206
206
  with: { node-version: 22 }
207
- - run: npx --yes @voidh4x0r/slopgate@0.1.6 . --fail-on high
207
+ - run: npx --yes @voidh4x0r/slopgate@0.1.8 . --fail-on high
208
208
  ```
209
209
 
210
210
  For GitHub code scanning, use `--format sarif` and upload with `github/codeql-action/upload-sarif`.
@@ -212,7 +212,7 @@ For GitHub code scanning, use `--format sarif` and upload with `github/codeql-ac
212
212
  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
213
 
214
214
  ```yaml
215
- - run: npx --yes @voidh4x0r/slopgate@0.1.6 . --format github --fail-on high
215
+ - run: npx --yes @voidh4x0r/slopgate@0.1.8 . --format github --fail-on high
216
216
  ```
217
217
 
218
218
  Each finding becomes an `error` / `warning` / `notice` annotation on the exact line, followed by a summary notice.
@@ -265,7 +265,7 @@ We would rather miss a finding than teach you to ignore the tool. That is also w
265
265
  `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
266
 
267
267
  - 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
268
+ - 1,845 files / 991,705 lines (CPython standard library): **~11 s** in the benchmark run
269
269
  - 3 grammar files load once in **~35 ms**
270
270
  - Python: ~12 ms per 35 KB file
271
271
 
@@ -297,7 +297,7 @@ Issues and pull requests are welcome. Start with [CONTRIBUTING.md](https://githu
297
297
  git clone https://github.com/VoidH4x0r/slopgate
298
298
  cd slopgate
299
299
  npm install
300
- npm test # 245 tests; the tests themselves make no network or child-process calls
300
+ npm test # 252 tests; the tests themselves make no network or child-process calls
301
301
  npm run typecheck
302
302
  npm run verify # all release gates in one command
303
303
  ```
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();
114
+ /** Lightweight name → node index; assertion checks happen on demand. */
115
+ function localFunctionDefinitions(root) {
116
+ const definitions = new Map();
117
117
  for (const fn of descendantsOfType(root, ['function_definition'])) {
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,7 +315,14 @@ const noopTest = {
297
315
  if (isStubFile(ctx.file))
298
316
  return [];
299
317
  const drafts = [];
300
- const helpers = localAssertionHelpers(ctx.root);
318
+ // A test-dense file may have thousands of assertion-free tests. Build the
319
+ // name index once, and only assert-check the helper actually called.
320
+ let definitionIndex;
321
+ const definitions = () => {
322
+ definitionIndex ??= localFunctionDefinitions(ctx.root);
323
+ return definitionIndex;
324
+ };
325
+ const helperAssertions = new Map();
301
326
  for (const fn of descendantsOfType(ctx.root, ['function_definition'])) {
302
327
  const name = testFunctionName(fn);
303
328
  if (!name)
@@ -334,7 +359,7 @@ const noopTest = {
334
359
  }
335
360
  if (!hasAssertion(body)) {
336
361
  const delegatesToSelf = bodyCallsSelf(body);
337
- const delegatedTo = delegatesToLocalHelper(statements, helpers);
362
+ const delegatedTo = delegatesToLocalHelper(statements, definitions, helperAssertions);
338
363
  const parameters = fn.childForFieldName('parameters');
339
364
  const parameterCount = parameters
340
365
  ? parameters.namedChildren.filter((child) => child.type !== 'comment').length
@@ -514,14 +539,15 @@ function supportingCommentBetween(ctx, fromLine, toLine, handlerStartLine) {
514
539
  return ctx.comments.some((comment) => {
515
540
  if (!overlaps(comment, fromLine, toLine))
516
541
  return false;
517
- const text = commentText(ctx, comment);
518
- if (NOISE_COMMENT.test(text))
542
+ const positioned = isStandaloneComment(ctx, comment) || comment.startLine >= handlerStartLine;
543
+ if (!positioned)
519
544
  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;
545
+ const text = commentText(ctx, comment);
546
+ // A stated explanation wins over future-work wording: "the caller retries
547
+ // later, so we ignore this error" is an explanation, not a TODO.
548
+ if (isExplanationText(text))
549
+ return true;
550
+ return !NOISE_COMMENT.test(text);
525
551
  });
526
552
  }
527
553
  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.8",
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",