@voidh4x0r/slopgate 0.1.15 → 0.1.17

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,28 @@ 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.17] - 2026-11-22
13
+
14
+ ### Added
15
+ - `slopgate init --strict` writes `confidence: "medium"` and `failOn: "medium"` into `.slopgate.json` and generates a workflow with `--confidence medium --fail-on medium`, matching the AI-code audit recipe. Default `init` remains high/high for human-maintained repositories.
16
+ - README “Auditing AI-written code” section with the baseline-first medium recipe, explaining that implementation stubs are medium by design while test theatre is high.
17
+ - `py/stub-body` and `ts/stub-function` docs now state that most real AI-stub findings are at medium confidence.
18
+
19
+ ### Changed
20
+ - 271 tests, including `init --strict` config and workflow assertions.
21
+ - Benchmark 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: []`.
22
+
23
+ ## [0.1.16] - 2026-11-22
24
+
25
+ ### Fixed
26
+ - `py/swallowed-exception` classifies the caught type independently of an `as name` binding: `except Exception as error:`, `except BaseException as e:`, `except (Exception,) as e:` and `except* Exception as e:` are high confidence again, with the broad “swallows the error” message instead of “specific error type”.
27
+ - Tuples containing `Exception`/`BaseException` are treated as broad; `(ValueError, RuntimeError)` remains specific/medium.
28
+
29
+ ### Changed
30
+ - 270 tests, including `as-binding` and `as-binding-more` fixtures covering bindings, `except*`, single-element and mixed tuples.
31
+ - Docs note that human-written benchmark corpora rarely exercise AI-specific `except … as e: pass` shapes; regression fixtures cover them until the 0.2.0 AI corpus.
32
+ - Benchmark 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
+
12
34
  ## [0.1.15] - 2026-11-22
13
35
 
14
36
  ### Fixed
@@ -66,7 +88,7 @@ All notable changes to this project are documented here. The format follows [Kee
66
88
  ### Changed
67
89
  - **Behavior change:** a baseline written by an older version inside a scanned subdirectory is no longer found automatically; move it to the repository root or pass `--baseline`.
68
90
  - 259 tests, including repo-root config applying to directory/file scans and default-baseline read/write at the root.
69
- - The performance guard now ignores corpora under 500 ms, so 5% comparisons target the CPython/ESLint-scale scans rather than startup noise.
91
+ - The performance guard now ignores corpora under 1000 ms, so 5% comparisons target the CPython-scale scan rather than JavaScript startup noise.
70
92
  - Benchmark 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: []`.
71
93
 
72
94
  ## [0.1.10] - 2026-11-22
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.15 · 4 files · 39ms
17
+ slopgate 0.1.17 · 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
@@ -172,6 +172,20 @@ npx @voidh4x0r/slopgate . --fail-on high
172
172
  npx @voidh4x0r/slopgate . --diff origin/main --fail-on high
173
173
  ```
174
174
 
175
+ ### Auditing AI-written code
176
+
177
+ The defaults are tuned for human-maintained code: an interface stub in a library is often deliberate, so class-method stubs and documented `pass` bodies are `medium`. AI-generated code has the opposite prior — an unimplemented method is usually unfinished — so audit it with the medium threshold:
178
+
179
+ ```bash
180
+ # 1. Absorb the existing medium-confidence debt once.
181
+ npx @voidh4x0r/slopgate . --confidence medium --fail-on medium --write-baseline
182
+
183
+ # 2. Gate NEW implementation stubs and test theatre at medium.
184
+ npx @voidh4x0r/slopgate . --confidence medium --fail-on medium
185
+ ```
186
+
187
+ `slopgate init --strict` writes this policy into `.slopgate.json` and the generated GitHub Actions workflow. Keep the default `init` for human-maintained repositories.
188
+
175
189
  ### Use it from a coding agent (MCP)
176
190
 
177
191
  `slopgate` ships a Model Context Protocol server over stdio, so Claude Code, Codex and other MCP clients can check their own diff **before** saying "done".
@@ -210,7 +224,7 @@ jobs:
210
224
  - uses: actions/checkout@v4
211
225
  - uses: actions/setup-node@v4
212
226
  with: { node-version: 22 }
213
- - run: npx --yes @voidh4x0r/slopgate@0.1.15 . --fail-on high
227
+ - run: npx --yes @voidh4x0r/slopgate@0.1.17 . --fail-on high
214
228
  ```
215
229
 
216
230
  For GitHub code scanning, use `--format sarif` and upload with `github/codeql-action/upload-sarif`.
@@ -218,7 +232,7 @@ For GitHub code scanning, use `--format sarif` and upload with `github/codeql-ac
218
232
  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):
219
233
 
220
234
  ```yaml
221
- - run: npx --yes @voidh4x0r/slopgate@0.1.15 . --format github --fail-on high
235
+ - run: npx --yes @voidh4x0r/slopgate@0.1.17 . --format github --fail-on high
222
236
  ```
223
237
 
224
238
  Each finding becomes an `error` / `warning` / `notice` annotation on the exact line, followed by a summary notice.
@@ -303,7 +317,7 @@ Issues and pull requests are welcome. Start with [CONTRIBUTING.md](https://githu
303
317
  git clone https://github.com/VoidH4x0r/slopgate
304
318
  cd slopgate
305
319
  npm install
306
- npm test # 267 tests; the tests themselves make no network or child-process calls
320
+ npm test # 271 tests; the tests themselves make no network or child-process calls
307
321
  npm run typecheck
308
322
  npm run verify # all release gates in one command
309
323
  ```
package/dist/cli.js CHANGED
@@ -24,7 +24,7 @@ Usage:
24
24
  slopgate [path] [options] scan a directory or file (default: .)
25
25
  slopgate rules list every rule
26
26
  slopgate mcp [path] run as an MCP server on stdio
27
- slopgate init add config + GitHub Action
27
+ slopgate init [--strict] add config + GitHub Action
28
28
  slopgate --version | --help
29
29
 
30
30
  Options:
@@ -41,6 +41,7 @@ Options:
41
41
  --quiet only print the summary
42
42
  --verbose print warnings and per-file details
43
43
  --force overwrite files in \`init\`
44
+ --strict \`init\`: medium confidence + fail-on medium
44
45
  -h, --help show this help
45
46
  -V, --version print the version
46
47
 
@@ -77,6 +78,7 @@ function defaultOptions() {
77
78
  quiet: false,
78
79
  verbose: false,
79
80
  force: false,
81
+ strict: false,
80
82
  };
81
83
  }
82
84
  const VALUE_FLAGS = new Set([
@@ -137,6 +139,10 @@ function parseArgs(argv) {
137
139
  options.force = true;
138
140
  continue;
139
141
  }
142
+ if (token === '--strict') {
143
+ options.strict = true;
144
+ continue;
145
+ }
140
146
  const equals = token.indexOf('=');
141
147
  const rawName = (equals === -1 ? token : token.slice(0, equals)).replace(/^--?/, '');
142
148
  if (!VALUE_FLAGS.has(rawName))
@@ -265,7 +271,10 @@ const INIT_CONFIG = {
265
271
  confidence: 'high',
266
272
  failOn: 'high',
267
273
  };
268
- const INIT_WORKFLOW = (version, target) => `name: slopgate
274
+ function initConfig(strict) {
275
+ return strict ? { ...INIT_CONFIG, confidence: 'medium', failOn: 'medium' } : INIT_CONFIG;
276
+ }
277
+ const INIT_WORKFLOW = (version, target, strict) => `name: slopgate
269
278
 
270
279
  on:
271
280
  push:
@@ -285,7 +294,7 @@ jobs:
285
294
  with:
286
295
  node-version: 22
287
296
  - name: Scan for AI slop
288
- run: npx --yes @voidh4x0r/slopgate@${version} ${target} --fail-on high --format pretty
297
+ run: npx --yes @voidh4x0r/slopgate@${version} ${target} ${strict ? '--confidence medium --fail-on medium' : '--fail-on high'} --format pretty
289
298
  `;
290
299
  async function runInit(options, io, version) {
291
300
  const requested = path.resolve(options.paths[0] ?? '.');
@@ -303,7 +312,7 @@ async function runInit(options, io, version) {
303
312
  warn(io, options, `${path.relative(process.cwd(), configPath)} already exists (use --force to overwrite)`);
304
313
  }
305
314
  else {
306
- await writeFile(configPath, JSON.stringify(INIT_CONFIG, null, 2) + '\n', 'utf8');
315
+ await writeFile(configPath, JSON.stringify(initConfig(options.strict), null, 2) + '\n', 'utf8');
307
316
  writeOut(io, `created ${path.relative(process.cwd(), configPath)}`);
308
317
  }
309
318
  if (!options.force && (await exists(workflowPath))) {
@@ -311,10 +320,13 @@ async function runInit(options, io, version) {
311
320
  }
312
321
  else {
313
322
  await mkdir(path.dirname(workflowPath), { recursive: true });
314
- await writeFile(workflowPath, INIT_WORKFLOW(version, workflowTarget), 'utf8');
323
+ await writeFile(workflowPath, INIT_WORKFLOW(version, workflowTarget, options.strict), 'utf8');
315
324
  writeOut(io, `created ${path.relative(process.cwd(), workflowPath)}`);
316
325
  }
317
- writeOut(io, `next: npx @voidh4x0r/slopgate ${workflowTarget} --write-baseline, then commit the baseline`);
326
+ const policy = options.strict
327
+ ? '--confidence medium --fail-on medium'
328
+ : '--fail-on high';
329
+ writeOut(io, `next: npx @voidh4x0r/slopgate ${workflowTarget} ${policy} --write-baseline, then commit the baseline`);
318
330
  return 0;
319
331
  }
320
332
  async function runMcp(options) {
@@ -561,6 +561,20 @@ function isDocumentedNoopDirectory(ctx) {
561
561
  return false;
562
562
  return NOOP_MODULE_DOC.test(moduleDocstring(ctx.root) ?? '');
563
563
  }
564
+ /** Broad even when the expression is a tuple containing a catch-all type. */
565
+ function isBroadExceptionType(text) {
566
+ if (/^\(?\s*(Exception|BaseException)\s*,?\s*\)?$/.test(text))
567
+ return true;
568
+ if (text.startsWith('(') && text.endsWith(')')) {
569
+ const parts = text
570
+ .slice(1, -1)
571
+ .split(',')
572
+ .map((part) => collapseWhitespace(part))
573
+ .filter((part) => part.length > 0);
574
+ return parts.some((part) => part === 'Exception' || part === 'BaseException');
575
+ }
576
+ return false;
577
+ }
564
578
  const swallowedException = {
565
579
  meta: {
566
580
  id: 'py/swallowed-exception',
@@ -617,8 +631,11 @@ const swallowedException = {
617
631
  continue;
618
632
  const commented = above ||
619
633
  supportingCommentBetween(ctx, betweenStart, handlerEndRow + 1, clause.startPosition.row + 1);
634
+ // `except Exception as error:` binds the exception; the binding name
635
+ // says nothing about the caught type.
636
+ const baseType = typeText.replace(/\s+as\s+\S+$/, '').trim();
620
637
  const bare = typeText.length === 0;
621
- const broad = bare || /^(\(?\s*)?(Exception|BaseException)(\s*\))?$/.test(typeText);
638
+ const broad = bare || isBroadExceptionType(baseType);
622
639
  const cleanup = insideCleanupFunction(clause);
623
640
  const confidence = broad && !commented && !cleanup ? 'high' : 'medium';
624
641
  drafts.push({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voidh4x0r/slopgate",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
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",