check-exercise-ends-with-task.yml
Diff-scoped check that fails a pull request which adds or edits an exercise that does not end with a question or an instruction. The lab’s rule (Ezra, 2026-11-09, psw#548) is that the last thing a reader meets in an exercise is its task.
The check looks at each exercise div (#exr-...). Its last block must be a paragraph with a task sentence: one that ends with a question mark, or starts with an imperative task verb such as Show, Find, Compute, Estimate, Explain, or Derive (the same test as check-exercise-question-paragraph). An exercise is reported when its last paragraph has no task, or when a figure, table, code block, or include shortcode comes after the last task.
Solutions, callouts such as hints, HTML comments, display math, lists, headings, and block quotes are not examined (they are skipped when finding the last block). A paragraph that opens in lowercase right after a display, such as where $x$ is ..., continues the sentence the display interrupted, so it is judged with the paragraph before the display, or, inside a list item, with the item’s sentence. The join stops at a capitalized paragraph, at any block between the paragraph, the display, and the follower (a solution or callout div included), and at the end of a list: a paragraph after the list does not continue a sentence inside it. <!-- ends-with-task-ok: reason --> inside an exercise exempts it.
An untouched exercise is never reflagged. With no base ref the check skips instead of scanning the whole tree; whole-tree measures a corpus. Measure a corpus with whole-tree before making the check blocking in a large repository.
Usage
Copy examples/check-exercise-ends-with-task.yml to .github/workflows/ in your repository.
Inputs
| Input | Default | Meaning |
|---|---|---|
base-ref |
(empty) | Git ref or SHA to diff against; empty skips the check unless whole-tree is set |
globs |
*.qmd |
Space-separated git pathspecs of tracked files to check |
fail |
true |
Fail the workflow on a finding; false gives warnings only |
whole-tree |
false |
Scan every exercise, not only a PR’s additions |
python-version |
3.x |
Python version to set up |