@voidh4x0r/slopgate 0.1.14 → 0.1.16

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.16] - 2026-11-22
13
+
14
+ ### Fixed
15
+ - `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”.
16
+ - Tuples containing `Exception`/`BaseException` are treated as broad; `(ValueError, RuntimeError)` remains specific/medium.
17
+
18
+ ### Changed
19
+ - 270 tests, including `as-binding` and `as-binding-more` fixtures covering bindings, `except*`, single-element and mixed tuples.
20
+ - 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.
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.15] - 2026-11-22
24
+
25
+ ### Fixed
26
+ - MCP `scan_path` now normalizes findings to MCP-root-relative paths inside `defaultMcpDeps.scan` before applying the root baseline, so a baseline written by `slopgate . --write-baseline` suppresses findings for subdirectory and single-file scans too. `scan_diff` is unchanged because it scans the root (empty prefix).
27
+ - Removed the duplicate path prefixing from `scan_path`; normalization has one owner and cannot double-prefix.
28
+
29
+ ### Changed
30
+ - 267 tests, including root-baseline suppression for MCP directory/file/root scans and no-double-prefix coverage.
31
+ - Documented that the MCP server root must be the repository root; select subdirectories with `scan_path`.
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.14] - 2026-11-22
13
35
 
14
36
  ### Fixed
@@ -55,7 +77,7 @@ All notable changes to this project are documented here. The format follows [Kee
55
77
  ### Changed
56
78
  - **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`.
57
79
  - 259 tests, including repo-root config applying to directory/file scans and default-baseline read/write at the root.
58
- - The performance guard now ignores corpora under 500 ms, so 5% comparisons target the CPython/ESLint-scale scans rather than startup noise.
80
+ - The performance guard now ignores corpora under 1000 ms, so 5% comparisons target the CPython-scale scan rather than JavaScript startup noise.
59
81
  - 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: []`.
60
82
 
61
83
  ## [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.14 · 4 files · 39ms
17
+ slopgate 0.1.16 · 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
@@ -190,7 +190,7 @@ npx @voidh4x0r/slopgate . --diff origin/main --fail-on high
190
190
  | `scan_path` | findings in a file or directory |
191
191
  | `list_rules` | the rule table, so the agent knows what is checked |
192
192
 
193
- Reports are compact text: `file:line:col severity confidence rule-id message`, evidence included, capped at 50 findings per call. Paths are relative to the MCP server root, and config is resolved per requested path with the same nearest-config rule as the CLI. The server reads `.slopgate.json` and `.slopgate-baseline.json` like the CLI does, so an agent never re-reports debt you already accepted. It runs locally, makes no network calls, and writes nothing to disk.
193
+ Reports are compact text: `file:line:col severity confidence rule-id message`, evidence included, capped at 50 findings per call. Paths are relative to the MCP server root, and config is resolved per requested path with the same nearest-config rule as the CLI. Point the MCP server at the repository root; use `scan_path` to select subdirectories. The server reads `.slopgate.json` and `.slopgate-baseline.json` like the CLI does, so an agent never re-reports debt you already accepted. It runs locally, makes no network calls, and writes nothing to disk.
194
194
 
195
195
  Full details: [docs/mcp.md](https://github.com/VoidH4x0r/slopgate/blob/main/docs/mcp.md).
196
196
 
@@ -210,7 +210,7 @@ jobs:
210
210
  - uses: actions/checkout@v4
211
211
  - uses: actions/setup-node@v4
212
212
  with: { node-version: 22 }
213
- - run: npx --yes @voidh4x0r/slopgate@0.1.14 . --fail-on high
213
+ - run: npx --yes @voidh4x0r/slopgate@0.1.16 . --fail-on high
214
214
  ```
215
215
 
216
216
  For GitHub code scanning, use `--format sarif` and upload with `github/codeql-action/upload-sarif`.
@@ -218,7 +218,7 @@ For GitHub code scanning, use `--format sarif` and upload with `github/codeql-ac
218
218
  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
219
 
220
220
  ```yaml
221
- - run: npx --yes @voidh4x0r/slopgate@0.1.14 . --format github --fail-on high
221
+ - run: npx --yes @voidh4x0r/slopgate@0.1.16 . --format github --fail-on high
222
222
  ```
223
223
 
224
224
  Each finding becomes an `error` / `warning` / `notice` annotation on the exact line, followed by a summary notice.
@@ -303,7 +303,7 @@ Issues and pull requests are welcome. Start with [CONTRIBUTING.md](https://githu
303
303
  git clone https://github.com/VoidH4x0r/slopgate
304
304
  cd slopgate
305
305
  npm install
306
- npm test # 266 tests; the tests themselves make no network or child-process calls
306
+ npm test # 270 tests; the tests themselves make no network or child-process calls
307
307
  npm run typecheck
308
308
  npm run verify # all release gates in one command
309
309
  ```
package/dist/mcp.js CHANGED
@@ -133,13 +133,7 @@ export function createMcpServer(deps) {
133
133
  return textResult(`No files matched under ${target} (check include/exclude patterns)`, true);
134
134
  }
135
135
  const visible = result.findings.filter((finding) => meetsConfidence(finding.confidence, confidence));
136
- const targetInfo = await stat(target).catch(() => undefined);
137
- const base = targetInfo?.isFile() ? path.dirname(target) : target;
138
- const prefix = prefixForRoot(deps.root, base);
139
- const output = prefix
140
- ? visible.map((finding) => ({ ...finding, file: `${prefix}/${finding.file}` }))
141
- : visible;
142
- return textResult(formatFindings(output, result, deps.version, max));
136
+ return textResult(formatFindings(visible, result, deps.version, max));
143
137
  }
144
138
  if (name === 'scan_diff') {
145
139
  const base = typeof params.base === 'string' && params.base.length > 0 ? params.base : 'HEAD';
@@ -230,11 +224,22 @@ export function defaultMcpDeps(root, version) {
230
224
  async scan(scanRoot) {
231
225
  const config = await configFor(scanRoot);
232
226
  const result = await scanProject({ root: scanRoot, config });
227
+ // Findings and baseline fingerprints are MCP-root-relative. Normalize
228
+ // here, before partitioning, so a root baseline matches subdirectory and
229
+ // single-file scans too.
230
+ const target = path.resolve(scanRoot);
231
+ const info = await stat(target).catch(() => undefined);
232
+ const base = info?.isFile() ? path.dirname(target) : target;
233
+ const prefix = prefixForRoot(root, base);
234
+ const normalized = prefix
235
+ ? result.findings.map((finding) => ({ ...finding, file: `${prefix}/${finding.file}` }))
236
+ : result.findings;
233
237
  // Respect a baseline if one exists, so agents do not re-report known debt.
234
238
  const baseline = await loadBaseline(path.join(root, '.slopgate-baseline.json'));
235
- if (baseline)
236
- return { ...result, findings: partitionByBaseline(result.findings, baseline).fresh };
237
- return result;
239
+ if (baseline) {
240
+ return { ...result, findings: partitionByBaseline(normalized, baseline).fresh };
241
+ }
242
+ return { ...result, findings: normalized };
238
243
  },
239
244
  diff: diffSince,
240
245
  };
@@ -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.14",
3
+ "version": "0.1.16",
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",