Mechanisms over intentions: request-time lesson delivery, self-referential rules, enforced question dialog
ci / tests (macos-latest, python 3.10) (push) Canceled after 0s
ci / tests (macos-latest, python 3.11) (push) Canceled after 0s
ci / tests (macos-latest, python 3.13) (push) Canceled after 0s
ci / tests (macos-latest, python 3.9) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.10) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.11) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.13) (push) Canceled after 0s

sisi prompt hands the matching recipe and lessons to the agent when the
human's request arrives. Every rule ends with the command that prints its
reasons, history, lessons and enforcement; sisi rule lists what enforces each
rule. Ending a turn by asking in reply text instead of the question dialog is
sent back. Rulebook budget raised to 200 lines and 12,000 characters.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-23 08:22:57 -07:00
1 parent f7bc6eded1
commit 11be8e3664
21 files changed
+1087 -44

No files matched your search

+28 -9
View File
@@ -20,7 +20,7 @@ in an owner-only (0700) folder, each with its source file's permissions.
Wiring is always by reference: an import line, a symlink to the generated rulebook
(`~/.local/share/sisi/generated/core.md`), hook entries that run `sisi tick --tool NAME` /
`sisi gate --tool NAME`, or a small generated plugin/extension (recognised by its exact
`sisi prompt --tool NAME` / `sisi gate --tool NAME`, or a small generated plugin/extension (recognised by its exact
`sisi:generated …` first line, never by the words appearing anywhere else in the file). Every registered
shell hook command first checks the sisi launcher still exists, so deleting the sisi folder without
uninstalling makes hooks exit silently instead of erroring on every turn. The per-tool translation
@@ -32,13 +32,20 @@ state. Hooks fail open: any error lets the agent finish. Where a tool's hook inp
## Claude Code
Fully wired, as before: an `@import` line in `~/.claude/CLAUDE.md`, `SessionStart` → `sisi tick`,
`UserPromptSubmit` → `sisi prompt` (the matching recipe and lessons for the human's request, as
added context; silent when nothing strictly matches, and never able to block a turn),
`Stop`/`SubagentStop` → `sisi gate` (blocking), and `PreToolUse`/`PostToolUse` with matcher `Bash` →
`sisi watch` (before/after tree measurement) in `~/.claude/settings.json`. Nothing for you to do.
`sisi watch` (before/after tree measurement) in `~/.claude/settings.json`. The gate also enforces
the question-dialog rule here: `AskUserQuestion` exists and the transcript is readable, so ending a
turn by asking in reply text without using the dialog is sent back once. Evidence: the hooks
reference documents `UserPromptSubmit` and its added-context output. Nothing for you to do.
## Codex CLI
Rulebook symlink at `~/.codex/AGENTS.md` (or `$CODEX_HOME/AGENTS.md`), plus hooks in
`~/.codex/hooks.json`: `SessionStart` → tick, `Stop`/`SubagentStop` → gate,
`~/.codex/hooks.json`: `SessionStart` → tick, `UserPromptSubmit` → prompt (the hooks page documents
the event and its added-context output; it needs the same one-time trust below),
`Stop`/`SubagentStop` → gate,
`PreToolUse`/`PostToolUse` (matcher `Bash`) → `sisi watch`, blocking with
`{"decision":"block","reason":...}`. One step is yours: Codex only runs hooks you have trusted, by exact
definition hash. After `sisi install`, open Codex, run `/hooks`, and trust the sisi hooks; repeat after
@@ -52,7 +59,8 @@ file path.
## Gemini CLI
Rulebook symlink at `~/.gemini/GEMINI.md`, hooks merged into `~/.gemini/settings.json`: `SessionStart`
→ tick (lessons injected as `additionalContext`), `AfterAgent` → gate, `BeforeTool`/`AfterTool` →
→ tick (lessons injected as `additionalContext`), `BeforeAgent` → prompt (the documented
before-turn event, carrying the request text), `AfterAgent` → gate, `BeforeTool`/`AfterTool` →
`sisi watch` (`{"decision":"deny","reason":...}`
rejects the response and forces a retry). Built from the hooks reference; Gemini is not installed on the
development machine, so this has not run live. Gemini has no subagent-stop event in its hook list, so
@@ -61,7 +69,8 @@ only the main turn is gated.
## GitHub Copilot CLI
Rulebook symlink at `~/.copilot/copilot-instructions.md` (or under `$COPILOT_HOME`), hooks in
`~/.copilot/hooks/sisi.json`: `sessionStart` → tick (`additionalContext`), `agentStop`/`subagentStop` →
`~/.copilot/hooks/sisi.json`: `sessionStart` → tick (`additionalContext`),
`userPromptSubmitted` → prompt (the documented before-prompt event), `agentStop`/`subagentStop` →
gate (`{"decision":"block","reason":...}` forces another turn), `preToolUse`/`postToolUse` → `sisi watch`. Verified end to end in a throwaway home:
a secret planted in session-start context was answered by the model, and a blocking `agentStop` visibly
forced a second turn. The cloud coding agent only runs hooks committed in the repository
@@ -75,14 +84,20 @@ Rulebook symlink at `~/.qwen/QWEN.md`, hooks merged into `~/.qwen/settings.json`
first run, so run Qwen once before `sisi install`. Verified: the session-start hook was observed firing
with its documented payload (a full turn needs an auth type configured). Qwen's question tool is named
`ask_user_question` (the rulebook still names Claude Code's dialog; generalising that wording is future
work). Qwen's before/after tool event names are not confirmed, so sisi registers no watch hooks there:
work). The gate's question-dialog check is wired for Qwen the same way as for Claude Code, but
Qwen's transcript shape is unconfirmed, so the check reads nothing — and therefore sends nothing
back — until that shape is verified. No prompt hook is registered either: Qwen's prompt-submission
event name is not confirmed in its hooks reference excerpts or in the installed package's text, and
sisi does not guess event names into a config. Qwen's before/after tool event names are not confirmed, so sisi registers no watch hooks there:
shell edits in Qwen are still judged from the command text.
## Pi
Rulebook symlink at `~/.pi/agent/AGENTS.md` (or `$PI_CODING_AGENT_DIR/AGENTS.md`; skipped if you already
have your own file there) plus a generated extension at `~/.pi/agent/extensions/sisi.ts`. The extension
runs `sisi tick` on `session_start` and injects the lessons at `before_agent_start`, and runs the gate on
runs `sisi tick` on `session_start` and injects the lessons at `before_agent_start`, runs
`sisi prompt` there too with the request text that event carries (the installed extension docs
confirm the event and its message injection; a missing text field leaves it silent), and runs the gate on
`agent_before_settle`, forcing one continuation with the failure report when checks fail (capped by the
gate's own three send-backs). Verified: the extension loads in real Pi and tick runs; the blocking
continuation could not be exercised end to end without a model login in the throwaway home. Pi gets no
@@ -92,7 +107,9 @@ still judged from the command text.
## Cursor
Hooks merged into `~/.cursor/hooks.json`: `sessionStart` → tick (lessons as `additional_context`),
`stop`/`subagentStop` → gate, `preToolUse`/`postToolUse` → `sisi watch`. Cursor cannot veto a stop; instead a non-empty `followup_message` is
`stop`/`subagentStop` → gate, `preToolUse`/`postToolUse` → `sisi watch`. No prompt hook: Cursor's
documented `beforeSubmitPrompt` event can allow or stop a submission, but no channel for injecting
added context is documented for it, so there is nothing for `sisi prompt` to print into. Cursor cannot veto a stop; instead a non-empty `followup_message` is
auto-submitted as the next user message, which is how the gate sends the agent back (Cursor caps this at
5 per script by default; sisi's own cap is 3). Only completed (not aborted/error) stops are gated.
There is no confirmed user-global instruction *file* for Cursor, so sisi wires no global rulebook there;
@@ -108,7 +125,9 @@ client prompt API where one exists. Be clear about the limits: `session.idle` fi
finished and cannot veto anything, and on OpenCode v2.3.2 no plugin event delivery or lesson injection
could be confirmed in headless runs (the plugin itself is loaded — verified — and the v1-style hooks and
v2 `setup()` registration are both attempted, all fail-open). Treat OpenCode enforcement as unproven
until it is observed on your version; `sisi doctor` says `unknown` on purpose. OpenCode gets no watch
until it is observed on your version; `sisi doctor` says `unknown` on purpose. It also gets no
prompt hook: a per-message plugin callback exists, but the transform that would inject added
context is unconfirmed on the installed version. OpenCode gets no watch
hooks either, so shell edits there are still judged from the command text.
## Muse Code
+32 -5
View File
@@ -41,7 +41,16 @@ what "done" means, verifying, or being sent back by the gate.
out) for the agent to open with `sisi lessons show ID`. Being printed or listed counts as
*listed*; opening counts as *read* — the two are reported separately, because "listed many times,
never read, still recurs" means the heading is bad, and the cycle brief says so. `sisi verifiers
show` and the gate's send-back message keep the older single strong-match block. Draft recipe notes
show` and the gate's send-back message keep the older single strong-match block. The same strict
part-one test also runs at the moment the human's request arrives: where the tool documents a
prompt-submission event with a context channel, `sisi prompt` injects the best-matching recipe's
"done means" list in short form plus the matching lessons' short lines, each with the command
that prints it in full (`sisi done ID`, `sisi lessons show ID`), within a 2,000-character cap.
A recipe counts only when at least two distinct non-generic request words hit its title,
applies-to or id (matched on stems, so "tag" meets "tagging"); trivial messages (a bare yes or
no, a slash command, a short question) and unmatched requests inject nothing at all. These
showings count as *listed* at place `prompt`. The hook never blocks a turn: any error exits
silently. Draft recipe notes
appear in `sisi done for` when their words match. Lesson text is always framed as information to
weigh, not as commands, and text from a lesson is never executed. One-line headings — the
other-lessons list, session-start notes, `sisi backlog` and `sisi lessons` — use the short
@@ -59,8 +68,8 @@ what "done" means, verifying, or being sent back by the gate.
5. **Recurring lessons get stronger.** Each lesson has a strength: 1 (a note), 2 (a candidate rule),
3 (enforced). A recurrence after at least two showings since the last promotion moves it up one
step — each step needs its own fresh evidence. A strength-2 lesson
becomes a real rule only through consolidation (below), because the rulebook has hard budgets of
120 lines and 7,200 characters and must not grow. A strength-3 lesson needs a check the gate can run; a folded lesson
becomes a real rule only through consolidation (below), because the rulebook has hard budgets in
lines and characters (`sisi canon cost` prints them), and must not grow without shortening. A strength-3 lesson needs a check the gate can run; a folded lesson
shown 20 times with no recurrence is retired from the notes (it stays in history); a lesson that
still recurs at strength 3 is withdrawn, and the same wording will not be learned again.
6. **Consolidation happens in a cycle**, run by whichever agent is working — see below.
@@ -129,8 +138,9 @@ when present: folded lessons no longer count toward the learned-notes limit, whi
`sisi cycle apply FILE` checks the file before writing anything: every lesson id exists, the base
version is still current, changed rules keep their id and their Why, named `sisi` commands and
enforced programs exist, and the resulting rulebook is inside both budgets (120 lines and 7,200
characters) and no longer in characters than before unless `shortens` names what was removed.
enforced programs exist, and the resulting rulebook is inside both budgets (lines and
characters, printed by `sisi canon cost`) and no longer in characters than before
unless `shortens` names what was removed.
Rules are re-wrapped to 100 characters on apply. The base version covers only what a cycle may
change (lesson content and status, short lines and topics, rules, notes, enforced checks), not
listed/read counters, and
@@ -148,6 +158,23 @@ contract-requirement fails a contract that touches its subject without a check o
a command check runs in the project like a contract check, and only in projects already on the trust
list.
## Every rule points at its own detail (`sisi rule`)
The generated rulebook ends each rule with one generated line — `More: sisi rule N` — so a rule an
agent is reading names the command that explains it. `sisi rule` with no argument tables every rule
in the effective rulebook with how it is enforced, in plain words, derived from what the code does
(which hooks are wired, whether the floors and the gate checks exist): a rule with no mechanism
says so ("not enforced: depends on the agent") instead of implying otherwise. `sisi rule N` (or
`sisi rule ID`) prints the rule in full with its reasons, how it is enforced, whether the text is
base or overlay, which learning rounds changed it, and the lessons folded into it, each with
`sisi lessons show ID`. One rule gained a mechanism this way: where the tool has a question dialog
and a readable transcript (Claude Code; Qwen Code is wired the same way but its transcript shape is
unconfirmed, so the check may find nothing to read there), the end-of-turn gate sends the agent back
once when its final message ends by asking the human a question in reply text and no dialog was
used in that turn — the last sentence ending in a question mark outside code blocks, quotes and
known rhetorical forms. Subagents and dialog-less tools are exempt, and the same message is never
sent back twice.
## What has been learned, in plain words
`sisi lessons digest` is for the human, not for agents. Its first line says how much has been
+1 -1
View File
@@ -45,7 +45,7 @@ Ids: rules are `## 1. Title {#rule-id}` in `canon/core.md`; verifiers and recipe
Commands: `sisi overlay list | diff | add-rule | replace-rule | disable-rule | enable-rule` (and the same for
`verifier` and `recipe`), `sisi overlay revert COMMIT`. Each change is one commit and rebuilds the rulebook.
The generated rulebook may not exceed 120 lines: a change that would pass it is refused, so a rule is added
The generated rulebook may not exceed its line and character budgets: a change that would pass it is refused, so a rule is added
by shortening or replacing another. `sisi canon cost` prints the always-loaded size.
On `sisi update` the overlay is applied to the new product. A replacement whose base item changed keeps the