Add ste-style.test.ts checks for the rule text and the block content #292

Closed
opened 2026-10-09 21:19:30 +00:00 by david · 1 comment
Owner

Summary

Add extensions/grillme/ste-style.test.ts. The suite checks that the authored guidance obeys the rules it states, and that the injected block carries the credit, the exemptions, the self-check, and no compliance claim.

Background

Depends on: #291

#291 creates extensions/grillme/ste-style.ts with the exports STE_RULE_CATEGORIES, STE_EXEMPTIONS, STE_SELF_CHECK, STE_CREDIT, and buildSteStyleBlock(). The wording of those constants must not change in this step.

The extension's tests run with node --test from extensions/grillme (npm test). The suite is dependency-free: bash-filter.test.ts and widget.test.ts already import only node:test, node:assert/strict, and a local .ts module, so node --test works with no node_modules present. Match that pattern exactly.

The rule categories themselves are the specification for this test, not the official standard: the text is a paraphrase, and the tests assert the paraphrase obeys its own rules.

Implementation Details

Create extensions/grillme/ste-style.test.ts, importing only node:test, node:assert/strict, and ./ste-style.ts.

1. Rule-text checks on our own guidance

Sentence length. Split each string in STE_RULE_CATEGORIES, STE_EXEMPTIONS, and STE_SELF_CHECK into sentences, then check each sentence against the limit for its kind:

  • instruction sentence → 20 words or fewer;
  • description sentence → 25 words or fewer.

Sentence splitting must be deterministic. Use a split on a sentence-ending ., !, or ? followed by whitespace, and count words by splitting on whitespace. A decimal point, an abbreviation, or a URL must not create a false sentence — if one of those appears, handle it explicitly rather than loosening the check.

Keep the kind of each string explicit in the test (for example an array of { text, kind } entries, or a small manifest), so a new string cannot be added without choosing a kind.

No -ing verb form. Scan the same joined text for words that end in ing. The scan needs an explicit allowlist — at minimum the literal `-ing` token inside rule 5, which is the rule that forbids -ing forms. Make the allowlist a named constant with a comment, and make the failure message name the offending word and the string it came from, so a new -ing form fails loudly instead of silently passing.

No banned phrasing pair. Define a small, maintained list of phrases that must not appear together (the same shape as the bash-filter corpus constant). Include the pair STE + compliant. Keep the list short and comment that it is maintained.

2. Block-content checks

Assert on the string returned by buildSteStyleBlock():

  • it includes STE_CREDIT and the https://www.asd-ste100.org link;
  • it names all three exemptions (assert each STE_EXEMPTIONS entry is present);
  • it includes STE_SELF_CHECK;
  • it never contains STE compliant (case-insensitive check is fine, but say which check you use).

3. Style notes

  • Use describe / test blocks with descriptive names, matching the existing files.
  • No snapshot files and no network access.
  • Do not weaken a check to make the current text pass; if a legitimate sentence breaks a rule, report it rather than widening the limit.

Acceptance Criteria

  • extensions/grillme/ste-style.test.ts exists and imports only node:test, node:assert/strict, and ./ste-style.ts.
  • A sentence-length test checks every sentence in STE_RULE_CATEGORIES, STE_EXEMPTIONS, and STE_SELF_CHECK against 20 words (instruction) or 25 words (description), with the kind explicit per string.
  • An -ing test fails on a new -ing form and carries a named allowlist that includes the literal `-ing` token from rule 5.
  • A banned-phrasing-pair test exists with a maintained list, and the list includes the STE + compliant pair.
  • Block-content tests assert the credit line, the https://www.asd-ste100.org link, all three exemptions, the self-check, and the absence of STE compliant.
  • cd extensions/grillme && npm test passes with the new file included, and bash-filter.test.ts and widget.test.ts still pass.

Test Plan

cd extensions/grillme
npm test

Expected: all three test files pass.

Prove the checks bite (then revert):

# add an over-long instruction sentence to STE_RULE_CATEGORIES, then:
cd extensions/grillme && npm test

Expected: the sentence-length test fails and names the offending sentence.

# add a word ending in "ing" (for example "Making the block short is useful.") to a rule, then:
cd extensions/grillme && npm test

Expected: the -ing test fails and names the offending word.

## Summary Add `extensions/grillme/ste-style.test.ts`. The suite checks that the authored guidance obeys the rules it states, and that the injected block carries the credit, the exemptions, the self-check, and no compliance claim. ## Background **Depends on:** #291 `#291` creates `extensions/grillme/ste-style.ts` with the exports `STE_RULE_CATEGORIES`, `STE_EXEMPTIONS`, `STE_SELF_CHECK`, `STE_CREDIT`, and `buildSteStyleBlock()`. The wording of those constants must not change in this step. The extension's tests run with `node --test` from `extensions/grillme` (`npm test`). The suite is dependency-free: `bash-filter.test.ts` and `widget.test.ts` already import only `node:test`, `node:assert/strict`, and a local `.ts` module, so `node --test` works with no `node_modules` present. Match that pattern exactly. The rule categories themselves are the specification for this test, not the official standard: the text is a paraphrase, and the tests assert the paraphrase obeys its own rules. ## Implementation Details Create `extensions/grillme/ste-style.test.ts`, importing only `node:test`, `node:assert/strict`, and `./ste-style.ts`. ### 1. Rule-text checks on our own guidance **Sentence length.** Split each string in `STE_RULE_CATEGORIES`, `STE_EXEMPTIONS`, and `STE_SELF_CHECK` into sentences, then check each sentence against the limit for its kind: - instruction sentence → 20 words or fewer; - description sentence → 25 words or fewer. Sentence splitting must be deterministic. Use a split on a sentence-ending `.`, `!`, or `?` followed by whitespace, and count words by splitting on whitespace. A decimal point, an abbreviation, or a URL must not create a false sentence — if one of those appears, handle it explicitly rather than loosening the check. Keep the kind of each string explicit in the test (for example an array of `{ text, kind }` entries, or a small manifest), so a new string cannot be added without choosing a kind. **No `-ing` verb form.** Scan the same joined text for words that end in `ing`. The scan needs an explicit allowlist — at minimum the literal `` `-ing` `` token inside rule 5, which is the rule that forbids `-ing` forms. Make the allowlist a named constant with a comment, and make the failure message name the offending word and the string it came from, so a new `-ing` form fails loudly instead of silently passing. **No banned phrasing pair.** Define a small, maintained list of phrases that must not appear together (the same shape as the `bash-filter` corpus constant). Include the pair `STE` + `compliant`. Keep the list short and comment that it is maintained. ### 2. Block-content checks Assert on the string returned by `buildSteStyleBlock()`: - it includes `STE_CREDIT` and the `https://www.asd-ste100.org` link; - it names all three exemptions (assert each `STE_EXEMPTIONS` entry is present); - it includes `STE_SELF_CHECK`; - it never contains `STE compliant` (case-insensitive check is fine, but say which check you use). ### 3. Style notes - Use `describe` / `test` blocks with descriptive names, matching the existing files. - No snapshot files and no network access. - Do not weaken a check to make the current text pass; if a legitimate sentence breaks a rule, report it rather than widening the limit. ## Acceptance Criteria - [ ] `extensions/grillme/ste-style.test.ts` exists and imports only `node:test`, `node:assert/strict`, and `./ste-style.ts`. - [ ] A sentence-length test checks every sentence in `STE_RULE_CATEGORIES`, `STE_EXEMPTIONS`, and `STE_SELF_CHECK` against 20 words (instruction) or 25 words (description), with the kind explicit per string. - [ ] An `-ing` test fails on a new `-ing` form and carries a named allowlist that includes the literal `` `-ing` `` token from rule 5. - [ ] A banned-phrasing-pair test exists with a maintained list, and the list includes the `STE` + `compliant` pair. - [ ] Block-content tests assert the credit line, the `https://www.asd-ste100.org` link, all three exemptions, the self-check, and the absence of `STE compliant`. - [ ] `cd extensions/grillme && npm test` passes with the new file included, and `bash-filter.test.ts` and `widget.test.ts` still pass. ## Test Plan ```bash cd extensions/grillme npm test ``` Expected: all three test files pass. Prove the checks bite (then revert): ```bash # add an over-long instruction sentence to STE_RULE_CATEGORIES, then: cd extensions/grillme && npm test ``` Expected: the sentence-length test fails and names the offending sentence. ```bash # add a word ending in "ing" (for example "Making the block short is useful.") to a rule, then: cd extensions/grillme && npm test ``` Expected: the `-ing` test fails and names the offending word.
david self-assigned this 2026-10-09 21:19:30 +00:00
david closed this issue 2026-10-09 21:44:09 +00:00
Author
Owner

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

pi-loop opened and merged a pull request for this issue: https://git.excelera.net/david/pi-extensions-and-skills/pulls/302
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#292
No description provided.