Design: quiz only — standalone quizzes, and a code quiz every reviewer can see
Phase 2 of the spec chain for issue #557. Derives from
requirements.md, and is reviewed withtesting-plan.md. The author declareddesign-approvalskipped, so review happens on pull request #558.
The short version
The change has a small half and a new half.
The small half is renaming and deleting. The explainer row, its two experiments, the explainer template and the explainer prose all go. The two agent nodes are renamed, and one table of old names keeps in-flight work items walking.
The new half is a second, narrower door into the daemon. Today a comment from someone who is not an authorized user is dropped before any keyword is looked for. A reviewer's the-loop quiz-taken has to get through that, so the ingress recognises it before the authorization check and passes on a signal that carries the person's login and no text. One component, the banner writer, then rebuilds the table from recorded state and writes it into the pull request description.
Read first: The reviewer's reply under Architecture, then Security design. They hold the only decision that widens who can make the-loop act.
Interfaces
Phase selection
- One row,
quiz, ticked by default, in the place theexplainerrow holds. Its heading is "🎓 Quiz the author before code generation, and the author and reviewers before review?". The experiment rows and their sub-heading are gone. - Unticked, it declares the four quiz nodes skipped under the token
quiz. The confirmation comment says "Quizzes: off" or "Quizzes: on". explaineris read asquizin a reply-borne checklist and inthe-loop graph skip --node.explainer-slidesandexplainer-flashcardsare unknown rows, which the parser already ignores.
The graph
| Before | After |
|---|---|
skip set explainer | skip set quiz |
node spec-explainer, command explain | node spec-quiz-write, command quiz |
node code-explainer, command explain | node code-quiz-write, command quiz |
nodes spec-quiz, code-quiz (human) | unchanged ids and positions |
stage explainer | stage quiz |
Two edges are new, both on the outcome micro: spec-quiz-write → tasks-breakdown and reviewer-briefing → human-approval. They carry a work item past a quiz gate that has no quiz to ask about (see The micro bypass).
The graph file also declares its renamed ids: spec-explainer → spec-quiz-write, code-explainer → code-quiz-write, and the skip set explainer → quiz.
Slash commands
- New:
/the-loop:quiz <id>, the command the two writing nodes name. - Removed:
/the-loop:explain. No alias.
CLI
the-loop graph skip <id> --node quizdeclares the four nodes skipped.--node explainerdoes the same.the-loop checkshows amicrobypass with the note "no quiz (micro)" on the quiz gate's row. The gate counts as satisfied, and the note tells it from an attested pass and from a declared skip.the-loop events --typeslists the four new event types below.- No new verb. A session still has no verb that edits a pull request description; see Open questions.
Control keyword
the-loop quiz-taken, on a delivering pull request. It follows the existing parse rule: it must open the comment, alone on its line.- It is the first keyword in a new family, open keywords: accepted from any account, executed by the daemon, never forwarded to a session. It is kept out of the vocabulary of control commands, so it cannot reach the code that executes them, the Slack command surface or an operator's command binding.
- Acknowledged like any keyword: the completed reaction when recorded, the error reaction when the pull request has no code quiz, or when it was typed on the work item itself. A pull request that delivers no work item gets nothing at all.
Configuration
One new key in the CLI config, routing.control.keywords.quiz-taken. Its default is the-loop quiz-taken, and an empty string disables it, as for every other keyword. routing.control.enabled: false disables it with the rest.
Events
| Event | Fields | When |
|---|---|---|
graph.quiz_taken | work_item, pull_request, node, login, role | a reply was recorded (role is reviewer) |
graph.quiz_taken_refused | pull_request, reason | a reply was not recorded: no-quiz, unnamed-author, bad-login, not-confirmed |
graph.quiz_banner | work_item, pull_request, where, rows | the banner was written (where is description or comment) |
graph.quiz_banner_failed | work_item, pull_request, reason | a description write failed or was declined, or a source could not be read |
No event carries comment text. graph.quiz_refused and dispatch.quiz_gate are unchanged.
Persisted formats
- Evidence records.
evidence/spec-quiz.mdandevidence/code-quiz.mdreplaceevidence/spec-explainer.mdandevidence/explainer.md. Fields: Depth, Questions, Location (the committed file), Artifact (its URL, ornone). The code quiz record adds Part 1:carried over,regeneratedornone. - Quiz pages.
docs/specs/<id>/quiz/spec-quiz.htmlandcode-quiz.html. - The taken record. A new section,
quizTaken, of the work item's portable record, the daemon-side file that already holds its collaborators and channels. Per delivering pull request it holds everything the banner needs that GitHub cannot say: the quiz round, where the quiz can be opened, who attested as the author, the logins that replied with the time of each, and the id of the fallback comment when one exists. It is not checked in. - Work-item state. A passed quiz gate records who attested, beside its outcome, as it does today. A selection frozen after this change carries no
explainerExperiments. - Old names are read, never rewritten. State that names an old node id, an old skip token or
explainerExperimentsloads. A human quiz gate that finds only the old record name reads it.
The quiz page
One template, templates/quiz.html, for both quizzes. The agent writes one JSON block and the header's placeholders, and nothing else. The fixed script renders every string as text, shows or hides the parts, and picks the Part 1 note from two fixed sentences. The prototype is design/code-quiz.html.
| The block says | The page shows |
|---|---|
| a spec quiz | one list of questions |
| a code quiz with no Part 1 | one list of questions |
| a code quiz, Part 1 carried over | Part 1 with the "author can skip" note and a link to Part 2, then Part 2 |
| a code quiz, Part 1 regenerated | Part 1 with the "spec changed" note and no skip link, then Part 2 |
The banner
The banner is the text between <!-- the-loop:quiz-banner --> and <!-- /the-loop:quiz-banner -->. This is what it renders as:
🎓 Take the code quiz before you review. Author and every reviewer. Open it:
<artifact URL>· or locally:<gh one-liner>Author: tick the box on the-loop's quiz comment. Reviewers: replythe-loop quiz-takenwhen you're done.
Who Role Quiz @author author ✅ taken @reviewer-a reviewer ⏳ not yet @reviewer-b reviewer ✅ taken
Rows are ordered author first, then reviewers by login. At most 20 rows are shown for people who were never requested and never reviewed. The rest become one line, "and N more replied".
Templates and documentation
The skill ships one quiz page template, two quiz record templates and one quiz reference, each in place of its explainer counterpart. The briefing template carries the banner's two markers after The short version and drops the "Start here" line. Every document that describes the feature to a user follows: tasks.md lists them.
Architecture
Renaming without stranding anyone
Old names are translated when state is read, in one place. The graph file declares its renamed ids, and the state loader applies that table to everything in a work item's state that names a node or a skip token: the current node, the node history, the frozen selection and the skip records.
This matters because of two behaviours the runtime has today. A work item whose current node is not in the graph fails with a configuration error. And a skippable node missing from a frozen selection is skipped as not offered. Without the table, an item parked at spec-explainer would break, and an item frozen with the old ids would silently lose its quizzes.
The translation happens in memory. An in-flight item is written back with the new ids the next time the runtime saves it, as part of its normal walk. A finished item is never loaded for writing, so its files keep the old names (Requirement 10.6).
Three smaller reads complete the picture:
- A human quiz gate reads the new record name and falls back to the old one.
- The tick check accepts the attestation sentences that quiz comments used before this change, so a comment already on a ticket stays answerable.
explainerExperimentsis read and dropped.
The writing nodes
Each node writes questions, publishes one page twice, and leaves a record. The command /the-loop:quiz carries the procedure and reference/quiz.md the rules.
- Classify the depth, and write the questions and a
whyfor each. - Fill the one JSON block of the template.
- Run the redaction pass, commit the page under
quiz/, and push. - Publish the same file as its own artifact when an artifact tool exists.
- Write the record, commit it, and report the node done.
The node's exit keeps today's checks under their new names: the record has its section and a committed Location, and at spec-quiz-write the record's commit comes after the spec's last change.
Part 1 is a copy, and the same check decides when it must not be. At code-quiz-write the agent copies the questions out of the committed spec quiz page. If any spec file changed after the spec quiz's record was committed, it writes new Part 1 questions and records Part 1 as regenerated. The node's exit runs the "record postdates spec" check against the spec quiz's record: a record that claims carried over while the spec is newer blocks the node.
The micro bypass
A quiz with no questions routes around its gate from the node before it. A human node parks the moment it is entered and moves only on an event, so it cannot pass itself. The route-around is the pattern the graph already uses for a brainstorm that was never written.
A small check ends the exit chain of the node that precedes each gate: spec-quiz-write for the spec quiz, reviewer-briefing for the code quiz. It reads the quiz's record, and when the depth is micro it turns the node's outcome into micro. The new edges then lead past the gate. When the record is absent, because the quiz nodes were skipped, the check does nothing.
A code quiz is micro only when it has no questions in either part. A micro Part 2 with a Part 1 still has questions, so it takes the ordinary path (Requirement 3.4).
Two details follow from routing around a node instead of passing through it:
checkscores every node, the bypassed gate included. The gate's own check reports "no quiz (micro)" while the gate was never entered, so the node reads as satisfied with that note and not as waiting.- The route-around needs the node before the gate to run. If
reviewer-briefingis itself declared skipped,code-quizis entered with amicrorecord. The gate then posts a box that says there is no quiz and waits for a tick, so the work item is never stranded at a gate with nothing to answer.
The author's gate
Unchanged, with two additions. The entry hook posts the checkbox comment exactly as today, with the new wording and both ways to open the page. The exit hook attributes the tick through the edit history exactly as today.
- When the
code-quizentry hook has posted its comments, it writes the round and the quiz's links into the taken record, and asks the banner writer to refresh each delivering pull request. - When
code-quizpasses, it writes who attested into the taken record and asks for the same refresh. The attester is also in the work item's state, as today.
A failed refresh never changes the hook's result (Requirement 9.4).
The reviewer's reply
The ingress recognises the keyword before it checks authorization, and lets only the identity through. This is the same shape as the existing doorbell for a ticked quiz box, which is also taken before the actor check and carries no body.
Decisions inside it:
- Both ingresses, one signal. The webhook router and the poller's comment filter each test a comment once, after the self-authored check and before the authorization check. The poller already fetches every comment and filters afterwards, so it needs no new query.
- One path for everyone. An authorized user's
quiz-takentakes the same path. The keyword therefore never reaches the code that executes the authorized commands. - The signal has no body. It holds the pull request's ref, the comment's id and the author's login. Nothing later in the path can read the comment's text, so nothing can write it anywhere.
- The webhook path confirms the author. Before recording, the dispatcher reads the comment by id from GitHub and uses the author GitHub returns. The poller's comments already come from that API.
- A comment with two different keywords stays ambiguous. It is treated as it is today: refused for an authorized user, dropped for anyone else.
- Nothing reaches a session or the graph. The handler never calls the graph runtime and never delivers a prompt.
The banner writer
One component rebuilds the banner from sources and writes it only when it differs. Every trigger is just "refresh this pull request". No trigger says what changed.
Three decisions shape a refresh:
- The record is read before GitHub. A pull request on which no code quiz was posted costs no request, and a closed or merged one is left alone.
- Everything shown is derived. The rows come from the pull request's author, its requested reviewers and review authors, and the taken record; the links and the attester come from the taken record. Nothing comes from the event.
- The description is read again immediately before it is written, and written only when the result differs from what is there.
Placing the banner:
| The description has | The writer |
|---|---|
| exactly one marker pair | replaces the text between them |
| no markers, and a The short version heading | inserts the banner at the end of that section |
| no markers, and no such heading | inserts the banner at the top |
| one marker without its pair, or more than one pair | leaves the description alone and uses the fallback comment |
| a write that GitHub refuses | uses the fallback comment and records the failure |
The fallback comment is one the-loop comment per pull request, carrying its own marker and the loop-prevention marker. Its id is kept in the taken record, and later refreshes edit it in place. The ingress already drops an edit of a the-loop comment. The comment is found by that stored id, never by searching for the marker, and it is edited only while it still carries the-loop's own stamp. Once it exists it is kept current alongside the description, so the two never disagree.
A new quiz round empties the list. The taken record stores the round its logins belong to. When the code quiz is rewritten and posted again, the round changes, and the writer starts a fresh list for it (Requirement 8.10).
Reviewer changes ring the same bell. On the webhook, a review requested, a request removed or a review submitted yields a refresh signal, taken before the authorization check and separate from whether the event is also delivered to a session. On the poller, the pull request query gains the requested reviewers and the review authors. The poller keeps a fingerprint of the two lists per pull request and signals a refresh when it changes.
A banner write must not come back as work. The-loop writes the description under the operator's credentials, so GitHub reports each write as the pull request being edited by an authorized user, which the webhook ingress would deliver to the session. The router drops an edit whose only change is inside the banner block.
Two writers can still collide. A person, or a session posting its briefing, may edit the description while the writer does. GitHub offers no conditional update for a description, so the writer narrows the window by reading immediately before it writes. A lost banner is restored by the next refresh, because a missing banner always differs from the rendered one.
Where each new piece of state lives, and why
- The taken record is daemon-side, not checked in. An untrusted account must not be able to cause a commit in the repository, and a reply must not need a session.
- The attester and the quiz's links are copied into the taken record. A refresh is triggered from the daemon by events that carry no work-item checkout, so the writer must not need one. The gate's own record of who attested stays in the work item's state.
- Reviewers are never stored. They are read from GitHub on every refresh, so a missed event corrects itself.
Technology choices
| Choice | Chosen | Alternatives | Why |
|---|---|---|---|
| Renamed node ids | translate old ids when state is read, from a table in the graph file | keep the old ids; a one-off migration of state files | Old ids keep "explainer" in every state file and dashboard. A migration rewrites committed files of finished items, which Requirement 10.6 forbids. |
| The reply from an unauthorized account | a body-less signal taken before the authorization check | add reviewers to the authorized users; a new per-work-item allow-list | Both alternatives grant more than is wanted: an authorized user can answer gates, and a collaborator's text reaches a session. The signal grants one fixed act. |
| Where replies are stored | the portable record | work-item-state.json; derive from the comments on each refresh | Checked-in state would let any account cause a commit. Re-reading every comment on each refresh costs a full thread fetch per reviewer event. |
| Updating the table | rebuild from sources and compare | patch the row the event names | A rebuild is idempotent and order-independent, and it repairs a lost banner. |
| A quiz with no questions | route around the gate from the node before it | let a human node pass itself on entry | The route-around needs no change to the runtime, and the graph already uses it. |
| Page data | one JSON block rendered by a fixed script | the agent edits HTML sections per case | Every per-work-item string is then rendered as text, and the agent cannot forget to delete a section. |
| New dependencies | none | — | The GitHub client already makes arbitrary REST calls. |
Durable decisions to record under docs/decisions/: why the explainer page was removed, and why a reviewer's reply is accepted without authorization and what it can never do.
UI/UX design
The quiz page and the banner are the two surfaces a person sees. No designer is assigned, so the work item's owner plays that role on the pull request.
| Artifact | Type | Location / link | Covers (screen · requirement) | Status |
|---|---|---|---|---|
design/code-quiz.html | html-prototype | design/code-quiz.html | The quiz page, two-part code quiz · R2.4, R4 | draft |
| Banner | markdown, in this file | § The banner | The banner and table · R8 | draft |
- Flows & states: the four page forms in The quiz page. The prototype shows the third, the fullest. A reader answers a question and its feedback and
whyappear below it. Nothing is stored or sent. - Design system / tokens: the colours, type and question card of the current
templates/explainer.html, unchanged. The tabs, slides and flashcards are removed. - Accessibility & responsiveness: one column, 760 px at most, usable at phone width. Parts are labelled sections. Each question is a fieldset of radio buttons. Feedback is announced as a status. The jump to Part 2 is a link. Light and dark themes both pass the contrast the current template passed.
- Evidence:
design/screenshots/code-quiz-dark.png. Captures of all four forms, in both themes and at phone width, are taken at verification.
Security design
How each trust boundary from the requirements' Security considerations is enforced.
- AuthN/AuthZ:
- The gates. Unchanged.
quiz-attestedpasses only on a tick whose every editor is an authorized user, read from the edit history. - The open keyword. Identity is the comment author as GitHub's API reports it. No authorization is required to be recorded, and being recorded authorizes nothing. The handler has no code path to the graph runtime or to a session.
- The refresh signal. It needs no identity, because it carries no instruction: it names a pull request, and the writer derives everything else.
- The gates. Unchanged.
- Input validation & injection surfaces:
- Comment text → daemon. The parser is the existing anchored one. The signal built from a match has no body field, so the text stops at the ingress.
- Login → markdown. A login is written only when it fits the login grammar the collaborator keywords already enforce. That grammar has no character with meaning in markdown or HTML.
- Description → writer. The writer looks for two fixed marker strings and replaces only between one well-formed pair. It does not parse the description otherwise.
- Spec, diff and ticket text → HTML page. The agent writes one JSON block. The fixed script sets every string as text, and
<is written escaped inside the block, so a literal</script>cannot end it. This is today's rule with less surface: the page has no agent-written HTML sections any more. - Prompt injection. A reply reaches no prompt. Reviewer logins reach no prompt.
- Record location → shell one-liners. Unchanged: built from owner, repository, branch and path, each checked against the safe-character rule.
- Secrets handling: No new secret. The description is written with the token the daemon already holds. The quiz page is committed only after the redaction pass.
- Least privilege: The writer uses three GitHub operations: read a pull request with its reviewers, update a description, and create or edit the-loop's own comment. It never edits a comment it did not author: the fallback comment is addressed by the id the-loop stored when it created it.
- Fail-closed behaviour:
- The comment cannot be confirmed, or has no nameable author → nothing recorded.
- The pull request is not a delivering one → nothing recorded, nothing written, no reaction.
- The description cannot be read, or its markers are malformed → no description write.
- The taken record or the state cannot be read → the banner is left as it is.
- The edit history cannot be read → the gate keeps waiting, as today.
- Abuse-case coverage:
| # | Abuse case (requirements) | Mechanism | Negative test |
|---|---|---|---|
| 1 | unauthorized reply moves a gate | the handler never calls the graph | reply from a stranger; the work item stays at code-quiz |
| 2 | unauthorized tick | edit-history attribution, unchanged | existing quiz-gates scenario |
| 3 | extra text in the reply | body-less signal | reply with a table row, HTML and a marker; none appears in the description, comment or events |
| 4 | many accounts reply | one row per login, 20-row bound, write only on difference | 30 distinct repliers; 20 rows and a summary line. One repeat replier; no second write |
| 5 | forged markers | the self-authored check for comments; the one-pair rule for descriptions | a stranger's comment carrying the fallback marker is never edited; two marker pairs → fallback |
| 6 | login outside the grammar | grammar check before recording | signal with a malformed login → bad-login, nothing written |
| 7 | markup in the spec or diff | text-only rendering | template test with </script> and markup in every field |
| 8 | reply on an unrelated pull request | delivering-PR check first | reply on a pull request linked to no work item → no record, no reaction |
| 9 | own comment, or unconfirmed commenter | self-authored check; read-back by id | a marked comment with the keyword; a webhook whose sender differs from the comment's author |
Testing strategy
Unit tests cover each rule in isolation: the selection row and its alias, the rename table applied to state, the tick check's old sentences, the micro check, the banner's placement table and row rules, and the taken record. The template is tested by loading it with hostile strings and by the accessibility check issue-488 used.
Integration tests drive both ingresses end to end, with these scenarios:
- A reviewer who is not authorized is recorded and gates nothing
- A reply carrying extra text writes only the login
- A reply on a pull request with no code quiz is refused
- A reviewer request and its removal update the table on the poller
- A description with malformed markers falls back to a comment
- A refused description write falls back and does not block the gate
- A work item parked at
spec-explainercontinues atspec-quiz-write - A selection frozen with
explainerunticked skips the four quiz nodes
The quiz-gates and happy-path end-to-end scenarios are rewritten for the new node ids and records, and gain the micro bypass and the banner. The explainer-experiment tests are deleted with the feature. Evidence is the test output, the event log of an integration run, and rendered captures of the page. testing-plan.md has the detail.
Open questions
None blocks the testing plan. Two things are worth a reviewer's view:
- A session has no verb to write a pull request description. The banner does not need one: the daemon places it. A
the-loop pr editverb would let the briefing itself become the description, which is a separate change and is left out here. - The 20-row bound is a guess at what keeps a description readable. It is one constant.
Review comments
Appended by the-loop's
record-feedbackhook when a human gate approves with comments (issue-109). Append-only and attributed: an approval never silently discards a reviewer's suggestions, and the feedback travels with the document it concerns rather than living in a side-channel tracker.