MSSQL spike: must-accept corpus #314

Closed
opened 2026-11-10 08:18:06 +00:00 by david · 1 comment
Owner

Summary

Write a labelled corpus of ordinary read-only T-SQL that the guard should accept.

Background

The spike picks the parser with zero false accepts on the reject corpus, then the maximum accepts on this corpus. There is no minimum accept rate. Like the reject corpus, this is stored as data and becomes a permanent test later.

Depends on: #313

Implementation Details

Create extensions/mssql/spike/corpus-accept.json (or .mjs exporting an array) in the same { "label", "sql" } shape as corpus-reject. Cover: simple SELECT, SELECT *, TOP n and TOP n PERCENT, DISTINCT, WHERE with AND/OR/IN/BETWEEN/LIKE/IS NULL, INNER/LEFT/RIGHT/FULL/CROSS JOIN, GROUP BY/HAVING, aggregates, ORDER BY with OFFSET ... FETCH, window functions (ROW_NUMBER() OVER (PARTITION BY ... ORDER BY ...)), subqueries (scalar, IN, EXISTS, derived tables), CTEs (single, multiple, recursive), UNION/UNION ALL/INTERSECT/EXCEPT, CASE, CAST/CONVERT, string and date functions (DATEADD, GETDATE), bracketed identifiers ([dbo].[My Table]), schema-qualified names, three-part names, comments in harmless places, and a trailing semicolon. Keep each case a single statement. Do not add parser code here.

Acceptance Criteria

  • The accept corpus exists as data with unique labels.
  • All categories above are represented, with at least 30 entries.
  • Every entry is one read-only statement (SELECT or WITH ... SELECT).
  • No entry overlaps a reject-corpus sql string (script-checked).
  • The file loads without error in Node.

Test Plan

Load both corpora in Node; assert no sql appears in both and print the entry counts.

## Summary Write a labelled corpus of ordinary read-only T-SQL that the guard should accept. ## Background The spike picks the parser with zero false accepts on the reject corpus, then the maximum accepts on this corpus. There is no minimum accept rate. Like the reject corpus, this is stored as data and becomes a permanent test later. **Depends on:** #313 ## Implementation Details Create `extensions/mssql/spike/corpus-accept.json` (or `.mjs` exporting an array) in the same `{ "label", "sql" }` shape as `corpus-reject`. Cover: simple `SELECT`, `SELECT *`, `TOP n` and `TOP n PERCENT`, `DISTINCT`, `WHERE` with `AND/OR/IN/BETWEEN/LIKE/IS NULL`, `INNER/LEFT/RIGHT/FULL/CROSS JOIN`, `GROUP BY`/`HAVING`, aggregates, `ORDER BY` with `OFFSET ... FETCH`, window functions (`ROW_NUMBER() OVER (PARTITION BY ... ORDER BY ...)`), subqueries (scalar, `IN`, `EXISTS`, derived tables), CTEs (single, multiple, recursive), `UNION`/`UNION ALL`/`INTERSECT`/`EXCEPT`, `CASE`, `CAST`/`CONVERT`, string and date functions (`DATEADD`, `GETDATE`), bracketed identifiers (`[dbo].[My Table]`), schema-qualified names, three-part names, comments in harmless places, and a trailing semicolon. Keep each case a single statement. Do not add parser code here. ## Acceptance Criteria - [ ] The accept corpus exists as data with unique labels. - [ ] All categories above are represented, with at least 30 entries. - [ ] Every entry is one read-only statement (`SELECT` or `WITH ... SELECT`). - [ ] No entry overlaps a reject-corpus `sql` string (script-checked). - [ ] The file loads without error in Node. ## Test Plan Load both corpora in Node; assert no `sql` appears in both and print the entry counts.
david closed this issue 2026-11-10 22:28:34 +00:00
Author
Owner

pi-loop opened and merged a pull request for this issue: #336

pi-loop opened and merged a pull request for this issue: https://git.excelera.net/david/pi-extensions-and-skills/pulls/336
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
david/pi-extensions-and-skills#314
No description provided.