From 486320203729d2e457c4bcad89b47d9c305db9b4 Mon Sep 17 00:00:00 2001 From: poteto <1390709+poteto@users.noreply.github.com> Date: Mon, 30 Nov 2026 18:27:12 +0000 Subject: [PATCH] docs(pstack): tighten statechart skill prose --- .../claude-code/.claude-plugin/plugin.json | 2 +- harness/pstack/claude-code/plugin.json | 2 +- .../claude-code/skills/statechart/SKILL.md | 134 +++++++++--------- .../skills/statechart/references/render.md | 12 +- pstack/.cursor-plugin/plugin.json | 2 +- pstack/plugin.json | 2 +- pstack/skills/statechart/SKILL.md | 134 +++++++++--------- pstack/skills/statechart/references/render.md | 12 +- 8 files changed, 148 insertions(+), 152 deletions(-) diff --git a/harness/pstack/claude-code/.claude-plugin/plugin.json b/harness/pstack/claude-code/.claude-plugin/plugin.json index cab24a3db9..1e3a086274 100644 --- a/harness/pstack/claude-code/.claude-plugin/plugin.json +++ b/harness/pstack/claude-code/.claude-plugin/plugin.json @@ -1,7 +1,7 @@ { "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json", "name": "pstack", - "version": "0.15.49", + "version": "0.15.50", "description": "if you want to go fast, go deep first. pstack helps you write less, but higher quality code. rigorous agent workflows you can parallelize with confidence.", "author": { "name": "Lauren Tan" diff --git a/harness/pstack/claude-code/plugin.json b/harness/pstack/claude-code/plugin.json index cab24a3db9..1e3a086274 100644 --- a/harness/pstack/claude-code/plugin.json +++ b/harness/pstack/claude-code/plugin.json @@ -1,7 +1,7 @@ { "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json", "name": "pstack", - "version": "0.15.49", + "version": "0.15.50", "description": "if you want to go fast, go deep first. pstack helps you write less, but higher quality code. rigorous agent workflows you can parallelize with confidence.", "author": { "name": "Lauren Tan" diff --git a/harness/pstack/claude-code/skills/statechart/SKILL.md b/harness/pstack/claude-code/skills/statechart/SKILL.md index dbc7446a82..700c456cc9 100644 --- a/harness/pstack/claude-code/skills/statechart/SKILL.md +++ b/harness/pstack/claude-code/skills/statechart/SKILL.md @@ -1,138 +1,138 @@ --- name: statechart -description: "Check a TLA+ model or a Lean 4 proof and draw it as Mermaid. For TLA+, checks rules with TLC and shows shortest bug paths. For Lean 4, draws lemma dependencies and proof trees in plain English, flagging unproven gaps, failing steps, native code, and custom axioms. Use for /statechart." +description: "Check a TLA+ model with TLC or a Lean 4 proof and draw it as Mermaid. Report shortest bug paths for TLA+, and plain-English lemma graphs, proof trees, gaps, failing steps, native code, and custom axioms for Lean 4. Use for /statechart." disable-model-invocation: true --- # Statechart -The chart shows how a TLA+ system moves between states or how a Lean 4 theorem is proved, in the words of the operator who must decide whether the behavior or proof is right. +Draw how a TLA+ system moves between states or how a Lean 4 proof works, in the operator's words. ## Run -`scripts/statechart.ts` is TypeScript, so run it with a runtime that executes TypeScript. `scripts/statechart` is a POSIX shell script that picks Node 22.18 to 22.x, Node 23.6 or later, Bun 1.1.5 or later, or Deno 2.0 or later. On native Windows, run `node --disable-warning=ExperimentalWarning /scripts/statechart.ts` with Node 22.18 to 22.x, or Node 23.6 or later. - -The CLI auto-dispatches on the first positional argument. +`scripts/statechart` runs `scripts/statechart.ts` with Node 22.18 to 22.x, Node 23.6 or later, Bun 1.1.5 or later, or Deno 2.0 or later. On native Windows, run `node --disable-warning=ExperimentalWarning /scripts/statechart.ts` with Node 22.18 to 22.x, or Node 23.6 or later. The first positional argument picks TLA+ or Lean 4 mode. `--out DIR` must be new or empty in both modes. ### TLA+ models -Work in a scratch folder outside the repo. Write a TLA+ spec and its config. Then run: +Work in a scratch folder outside the repo, write a TLA+ spec and its config, and run: ```sh /scripts/statechart SPEC.tla [--config FILE] [--view FILE] [--out DIR] ``` -The first TLA+ run installs TLC and Java with mise and needs the network. `--tactics` applies only to `.lean` files and exits 2 on `.tla` inputs. +The first TLA+ run installs TLC and Java with mise and needs network access. `--tactics` applies only to `.lean` files and exits 2 on `.tla` inputs. ### Lean 4 proofs -Run against any `.lean` file pinned to Lean `v4.34.1` (or a standalone `.lean` file with no `lean-toolchain`): +Run against a `.lean` file pinned to Lean `v4.34.1`, or a standalone `.lean` file with no `lean-toolchain`: ```sh /scripts/statechart FILE.lean THEOREM [--view FILE] [--tactics] [--out DIR] ``` -- `THEOREM` accepts a full declaration name or a unique dotted suffix in `FILE.lean`. Unsafe declarations and non-theorem definitions exit 2. -- Pass `--out` to a scratch folder outside the repo so generated charts stay out of your checkout. Without `--out`, the output goes to `-proof` beside `FILE.lean`. The folder must be new or empty. +- `THEOREM` takes a full declaration name or a unique dotted suffix in `FILE.lean`. Unsafe declarations and non-theorem definitions exit 2. +- Point `--out` at a scratch folder outside the repo so charts stay out of your checkout. Without `--out`, output goes to `-proof` beside `FILE.lean`. - `--view FILE` applies a plain-English view module to `lemmas.mmd` and `proof.mmd`. -- `--tactics` adds raw Lean tactic lines back inside `proof.mmd` boxes for Lean authors. Without it, boxes show claims, new local assumptions, invoked lemmas, and proof outcomes, while `report.md` keeps the full hypotheses and tactic scripts. +- `--tactics` shows raw Lean tactic lines inside `proof.mmd` boxes. - `--config` applies only to TLA+ specs and exits 2 on `.lean` inputs. -- Toolchain lookup checks `LEAN_SYSROOT`, then `lean` and `lake` on `PATH` from the package root, then a pinned `mise` `http:lean` install for `v4.34.1`. Every resolved binary must report `v4.34.1`; any other pin or binary version exits 2. -- Interactive runs call `lake setup-file` in place, which writes the gitignored `.lake/` folder and may create `lake-manifest.json` if the package has none. Tests copy packages into temporary folders so the checkout stays clean. +- Toolchain lookup checks `LEAN_SYSROOT`, then `lean` and `lake` on `PATH` from the package root, then a pinned `mise` `http:lean` install for `v4.34.1`. Every resolved binary must report `v4.34.1`. Any other pin or version exits 2. +- Runs on a Lake package call `lake setup-file` in place. `lake setup-file` writes the gitignored `.lake/` folder and may create `lake-manifest.json` when the package has none. Copy the Lake package into a temporary folder first so `.lake/` stays out of your checkout. ## TLA+ workflow ### Write the spec -- Write each rule that the operator agrees to as an INVARIANT. A rule can be about a screen, a result, a stored value, or a message. If the model has no variable for a rule, add the variable. Never weaken a rule to make it hold. -- Write `Next` as a disjunction of the actions, such as `YouPressPlay \/ YouPressStop`. If you do not, TLC names every step `Next`. -- A state with no step out breaks `NoDeadlock`, also when it is a correct end state. When an INVARIANT or a PROPERTY already has that name, the rule is `CHECK_DEADLOCK`. Add to `Next` an action that is true only in the end states and changes nothing, such as `Done == phase \in {"paid", "failed"} /\ UNCHANGED vars`, and give it a label in `step()`. +- Write each rule the operator agrees to as an `INVARIANT`. A rule can check a screen, a result, a stored value, or a message. Add any variable a rule needs, and never weaken a rule to make it hold. +- Write `Next` as a disjunction of actions, such as `YouPressPlay \/ YouPressStop`. Otherwise TLC names every step `Next`. +- A state with no step out breaks `NoDeadlock`, even when it is a valid end state. If an `INVARIANT` or `PROPERTY` already uses `NoDeadlock`, the rule name is `CHECK_DEADLOCK`. Add a no-op end-state action to `Next`, such as `Done == phase \in {"paid", "failed"} /\ UNCHANGED vars`, and label it in `step()`. ### Pick the TLA+ chart -You do the work that needs judgment: the words on each state and arrow, the phases and their colors, the title, and the report to the operator. Put your work in a view module, and give it with `--view`. - -To show the operator's words, the view exports `state(vars)`. The value that `state()` returns picks the form: +Put the operator's state labels, arrow labels, phases, colors, and title in a `--view FILE` module. Its `state(vars)` export picks the chart shape: -- A string gives a flat chart: `export const state = (v) => (v.paid ? "Paid" : "Paying");` -- An array gives parent states: `export const state = (v) => v.main.split(".");` -- An object gives one parallel region for each key: `export const state = (v) => ({ Playback: v.playback, Volume: v.volume });` +- A string draws a flat chart: `export const state = (v) => (v.paid ? "Paid" : "Paying");` +- An array draws parent states: `export const state = (v) => v.main.split(".");` +- An object draws one parallel region per key: `export const state = (v) => ({ Playback: v.playback, Volume: v.volume });` -Label each state with what the operator can see or cares about, such as "Paying" or "Lease held, write pending". Keep variable names out of labels. In `vars`, a TLA+ sequence is an object with keys from 1, so `v.pc[1]` is `pc[1]`. A set is an array. +Label states with what the operator sees or cares about, such as "Paying" or "Lease held, write pending", without variable names. In `vars`, a TLA+ sequence is an object keyed from 1, so `v.pc[1]` is `pc[1]`. A set is an array. -The view can also export `step(action, from, to)`. It gets the TLC action name and the values before and after the step, and it returns the label of the arrow. Write each step label as the operator sees it happen, such as "you press play" or "the connect fails". Do not name the code or the TLA+ action. Two actions that end the same in the chart get the same label, so that they share one arrow. +Export `step(action, from, to)` to label arrows from the TLC action name and the before and after `vars`. Write what the operator sees happen, such as "you press play" or "the connect fails", without code or TLA+ action names. Give two actions the same label when they produce the same chart transition so they share one arrow. -When a step can occur only in some conditions, end its label with the condition in brackets, in the operator's words, such as `you press play [while the file loads]`. In a regions chart, the command writes the condition on the other regions on the arrow, in the words of their labels, such as `[when Offline]`. Your brackets replace it, and two arrows from one state can then look the same. So in a regions chart, do not write brackets for a condition on another region. When a value that no label shows decides where a step goes, name the result in the label, such as "the roster read fails". +When a step requires a condition, append it in brackets in the operator's words, such as `you press play [while the file loads]`. In a regions chart, omit brackets for other regions. The command adds other-region conditions automatically, such as `[when Offline]`, and custom brackets overwrite them. When an unlabeled value decides the target state, name the outcome in the label, such as "the roster read fails". -The view can also export these: +The view can also export three optional properties: -- `group(vars)` returns the name of a phase. Each chart state gets the color of its group. When the model states behind one chart state are in different groups, that state gets no color. -- `colors` gives each group name a color class. -- `title` is a string that the chart shows at the top. +- `group(vars)` returns a phase name. A chart state gets no color when its model states belong to different groups. +- `colors` maps each group name to `blue`, `orange`, `purple`, `yellow`, `teal`, `tan`, or `pink`. +- `title` sets the chart heading. -The command calls `state()` and `group()` at most once for each model state, and `step()` at most once for each step. The chart and the report both use those answers. Make each function depend only on its arguments. +Make `state()`, `group()`, and `step()` depend only on their arguments. The command calls `state()` and `group()` at most once per model state, calls `step()` at most once per step, and reuses those answers for both the chart and `report.md`. -The chart does not draw a step that stays in one label. Split a label when the operator must see such a step. +The chart omits steps that stay inside one state label. Split a label when the operator must see such a step. -Aim for about 20 arrows or fewer, because a busier chart is hard to read. First return coarser labels from `state()`. Give one label to values that act the same, and leave out a detail that the operator does not need, such as a call in flight whose return changes nothing. Keep each state of a bug path, and keep each mark. When a merge changes a `breaks` state to `mayBreak`, it hides where a rule breaks. Do not merge two states that break different rules, because the operator then cannot see which rule breaks where. If the chart is still too busy, return `null` from `step()` for the steps that the operator does not need, such as a reset that every state has, or a step whose arrow repeats what other arrows show. Obey these rules when you hide steps: +Aim for 20 arrows or fewer. First coarsen `state()` labels. Merge values that behave alike, and drop details the operator does not need, such as an in-flight call whose return changes nothing. Keep every bug-path state and every mark. Never turn a `breaks` state into `mayBreak` or merge states that break different rules. If the chart is still too busy, return `null` from `step()` for unneeded steps, such as a universal reset or a duplicate arrow. When you hide steps, follow four rules: -- Keep each chart state reachable by arrows from a start state. -- Keep at least one arrow out of each chart state that has a step out in the model. -- Hide all the steps of an arrow, or none of them. When you hide only some, its condition gets narrower. -- In the hand-off, say which steps the chart hides. +- Keep every chart state reachable by arrows from a start state. +- Keep at least one outgoing arrow from every chart state that can step in the model. +- Hide all steps behind an arrow, or none of them, so you do not narrow its condition. +- List the hidden steps in the hand-off. ### Read the TLA+ report -- In the chart, a state that breaks a rule has the class `breaks`. When only some model states behind it break the rule, it has the class `mayBreak`. The Legend names the rules of each mark. When two rules break, it names both on one mark, so say in the hand-off which state breaks which rule. In a regions chart, a state gets a mark when each combination of region states that includes it can break a rule. When a combination can break a rule and none of its states has a mark, each state in that combination gets a mark. -- TLC goes past a state that breaks a rule, so the chart shows the states after a bug. -- Because TLC goes past bugs, a model with no limit on its states can run without end. Keep the constants small, or add a CONSTRAINT. -- With a VIEW or a SYMMETRY, TLC counts states that it treats as the same as one state, and the chart draws that one state. An arrow can lead to it rather than to the state that the step reaches, and the report says so. -- TLC checks the rules in each state past a CONSTRAINT or an ACTION_CONSTRAINT, but it does not explore that state or check it for deadlock. When TLC's shortest path for a rule ends in such a state, the chart draws that state, and the report gives that path. The chart does not draw the other states past the bound. A deadlock in such a state does not show. TLC also checks the rules after each step that an ACTION_CONSTRAINT excludes, also when it reaches the next state another way. When TLC's shortest path for a rule ends with such a step, the chart draws that step. -- The command checks the rules with TLC on the config as written, with one worker. When a rule breaks, the command removes that rule and runs TLC again, until no rule breaks. After the first break, each run stops at 100,000 distinct states, so that a large model does not run without end. When a run reaches that bound or stops on an error, the report lists the rules that it did not check under "Rules not checked", and the chart does not mark them. A rule that is not checked can hold or break. To check it, remove the rules that break from the config, or make the model smaller. The bound adds a module that changes TLC's order of the variables, so for a property TLC can find a different counterexample than a run without the bound. -- `tlc.out` is what TLC printed on the config as written. When the chart does not show the bug path of a rule that breaks, `tlc-RULE.out` is what TLC printed for the run that found it. When TLC repeats its first warning, plain TLC prints it twice, but `tlc.out` shows it once, because TLC leaves the second copy out of the output that this command reads. That happens only when Java runs with `-XX:+UseParallelGC`, since otherwise TLC's first warning is its advice to pass that flag, which it prints once. +- A state gets `breaks` when every model state behind it breaks a rule, and `mayBreak` when only some do. The Legend lists broken rules per mark and merges multiple rules onto one mark, so state in the hand-off which state breaks which rule. In a regions chart, a state gets a mark when every combination of region states that includes it can break a rule. When a combination can break a rule and none of its states has a mark, every state in that combination gets a mark. +- TLC explores past broken states, so the chart includes post-bug states and an unbounded model can run forever. Keep constants small or add a `CONSTRAINT`. +- With `VIEW` or `SYMMETRY`, TLC collapses equivalent states into one representative. An arrow can point to that representative instead of the state the step reached, and `report.md` notes when it does. +- TLC checks rules on states past a `CONSTRAINT` or `ACTION_CONSTRAINT`, but does not explore them or check them for deadlock. The chart draws a past-bound state only when a shortest bug path ends there, and `report.md` gives that path. TLC also checks rules after steps excluded by `ACTION_CONSTRAINT`, even when another path reaches the next state. The chart draws an excluded step only when a shortest bug path ends with it. +- The command runs TLC with one worker on the config as written. When a rule breaks, it drops that rule and reruns TLC until no rule breaks. Reruns after the first break stop at 100,000 distinct states. If a rerun hits that cap or stops on an error, `report.md` lists skipped rules under "Rules not checked" and the chart leaves them unmarked. Those rules may hold or break. Remove broken rules from the config or shrink the model to check them. Because the cap module changes TLC's variable order, a `PROPERTY` rerun can return a different counterexample. +- `tlc.out` holds TLC's output on the config as written. When the chart omits a broken rule's bug path, `tlc-RULE.out` holds the output of the run that found it. When Java runs with `-XX:+UseParallelGC` and TLC repeats its first warning, `tlc.out` records that warning once because TLC omits the duplicate from `-tool` output. ## Lean 4 workflow -One command elaborates `FILE.lean` once and writes up to four files into `--out`: +One run elaborates `FILE.lean` once and writes up to four files into `--out`: -- `lemmas.mmd`: Angle 1 theorem dependency flowchart (`flowchart TD`), capped at 60 nodes. By default, each lemma leads with its docstring summary (clipped on word or clause boundaries) above its short name, and the legend notes `Arrows mean uses`. Solid edges cross compiler auxiliaries only. Dotted `via def` edges cross user definitions, opaques, or inductives. Thick edges trace shortest unproven paths. -- `proof.mmd`: Angle 2 proof tree (`flowchart TD`), written when the theorem has tactic steps and capped at 40 blocks. By default, boxes omit type and binder preambles, omit raw tactic scripts, translate standard Lean case tags (`mp`, `mpr`, `inl`, `inr`, `zero`, `succ`, `nil`, `cons`, `true`, `false`) into plain English, strip repeated parent prefixes like `mp.` from nested splits, and show claims, new local assumptions, invoked lemmas, and outcomes (`Proven`, `Unproven gap (sorry)`, `Failing step`, `Depends on unproven gap`). Pass `--tactics` to show raw tactic lines inside boxes. -- `report.md`: Audit verdict, shortest unproven paths, full axiom list, untruncated hypotheses, goals, and tactic scripts per block, lemma statements, and Lean diagnostics scoped to the target theorem. -- `facts.json`: Versioned JSON (`format: 1`) written by `scripts/lean/Extract.lean`. +- `lemmas.mmd` draws the theorem dependency `flowchart TD`, capped at 60 nodes. Each lemma leads with its docstring summary, clipped on word or clause boundaries, above its short name, and the legend notes `Arrows mean uses`. Solid edges cross compiler auxiliaries only. Dotted `via def` edges cross user definitions, opaques, or inductives. Thick edges trace shortest unproven paths. +- `proof.mmd` draws the proof tree `flowchart TD` when the theorem has tactic steps, capped at 40 blocks. Boxes omit type and binder preambles and strip repeated parent prefixes like `mp.` from nested splits. They translate the standard Lean case tags `mp`, `mpr`, `inl`, `inr`, `zero`, `succ`, `nil`, `cons`, `true`, and `false` into plain English. Without `--tactics`, boxes omit raw tactic scripts and show claims, new local assumptions, invoked lemmas, and outcomes: `Proven`, `Unproven gap (sorry)`, `Failing step`, `Open goal`, or `Depends on unproven gap`. +- `report.md` lists the audit verdict, shortest unproven paths, full axiom list, untruncated hypotheses, goals, and tactic scripts per block, lemma statements, and Lean diagnostics scoped to the target theorem. +- `facts.json` stores `format: 1` JSON from `scripts/lean/Extract.lean`. -### Write a Lean `--view` for non-math readers +### Write a Lean 4 view -For an operator who is not a Lean author, lead with the plain-English `lemmas.mmd` chart and treat `proof.mmd` as an optional drill-down. Put plain-English titles, claim summaries, group names, and branch descriptions in a `--view FILE` module: +Put plain-English titles, claim summaries, group names, and branch descriptions in a `--view FILE` module: -- `title`: a string, or `{ lemmas?: string, proof?: string }`. -- `lemma(info)`: returns a plain-English string, `{ label, group?, hide? }`, `null` (to hide a clean low-level plumbing lemma), or `undefined`. -- `group(info)`: returns a plain-English subgraph title (replacing raw module names), `null`, or `undefined`. -- `branch(info)`: returns a plain-English string or `{ label, detail? }` for a proof-tree node. `info` carries stable `id` (`"root"`, `"root.0"`, ...), `goal`, `newHyps`, `tactics`, `lemmas`, `status`, `caseTag`, `rawCaseTag`, `depth`, `isRoot`, `isLeaf`, and `times`. When `times > 1` folds branches with different goals, `info.goal` is `""` and `info.newHyps` is empty. -- `caseLabel(tag, info)`: returns a plain-English edge label for a split branch, or `undefined`. +- `title` is a string or `{ lemmas?: string, proof?: string }`. +- `lemma(info)` returns a plain-English string, `{ label, group?, hide? }`, `null` to hide a clean supporting lemma, or `undefined`. +- `group(info)` returns a plain-English subgraph title to replace raw module names, `null`, or `undefined`. +- `branch(info)` returns a plain-English string or `{ label, detail? }` for a proof-tree node. `info` carries stable `id` values like `"root"` and `"root.0"`, plus `goal`, `newHyps`, `tactics`, `lemmas`, `status`, `caseTag`, `rawCaseTag`, `depth`, `isRoot`, `isLeaf`, and `times`. When `times > 1` folds branches with different goals, `info.goal` is `""` and `info.newHyps` is empty. +- `caseLabel(tag, info)` returns a plain-English edge label for a split branch, or `undefined`. -Soundness rules enforced by the compiler: +The compiler enforces three soundness rules: -- A view can never hide the target theorem, any node with `sorry`, any node with a failing step, any custom axiom, any native computation node, or any lemma that depends on an unproven gap or axiom. Attempting to hide one exits 2. +- A view can never hide the target theorem, any node with `sorry` or a failing step, any custom axiom, any native computation node, or any lemma that depends on an unproven gap or axiom. If a view tries to hide one, the command exits 2. - A view can never change trust classes or turn an unproven branch green. Status classes, red or amber shapes, thick edges, and trust badges always come from Lean facts. -- When a view hides a clean supporting lemma, the compiler bridges transitive dependency edges across it, preserves all axioms so `checkAxioms` still agrees with `Lean.collectAxioms`, and notes the hidden count in both the chart legend and `report.md`. Say in the hand-off which supporting lemmas the view hides. +- When a view hides a clean supporting lemma, the compiler bridges transitive dependency edges across it, preserves all axioms so `checkAxioms` still agrees with `Lean.collectAxioms`, and records the hidden count in the chart legend and `report.md`. ### Exit codes and trust boundary -- Exit `0`: closed proof resting on `propext`, `Classical.choice`, and `Quot.sound` at most. -- Exit `1`: audit finding (`sorry`, failing step in the target theorem, open goal, unchecked native code such as `native_decide` or `Lean.ofReduceBool`, or a custom axiom). -- Exit `2`: invalid arguments, bad `--view` export or soundness violation, unsupported Lean pin, `module`-header file, missing or ambiguous theorem, or a hard invariant failure (`checkAxioms` or `checkTree`). -- Exit `130` or `143`: `SIGINT` or `SIGTERM` stopped the run, killed the worker process group, and wrote nothing. +- Exit `0` means a closed proof that uses at most `propext`, `Classical.choice`, and `Quot.sound`. +- Exit `1` means an audit finding: `sorry`, a failing step in the target theorem, an open goal, unchecked native code such as `native_decide` or `Lean.ofReduceBool`, or a custom axiom. +- Exit `2` means invalid arguments, a bad `--view` export or soundness violation, an unsupported Lean pin, a `module`-header file, a missing or ambiguous theorem, or a `checkAxioms` or `checkTree` invariant failure. +- Exit `130` or `143` means `SIGINT` or `SIGTERM` stopped the run, killed the worker process group, and wrote nothing. -Because tactic extraction elaborates package code, Lean charts explain proofs and do not replace a standalone build or axiom verification gate. +Tactic extraction elaborates package code, so Lean charts explain proofs and do not replace a standalone build or axiom verification gate. ## Show the chart -Show `chart.mmd` (for TLA+) or `lemmas.mmd` (leading for non-math readers) and `proof.mmd` (for Lean 4) to the operator as `mermaid` code blocks. For TLA+, the chart has a budget of 500 states, counted by TLC on the config as written. Above that, the chart draws only the paths to the rules that break, and when no rule breaks, the command writes no `chart.mmd`. It still checks each rule, and the report gives the state count and each bug path. To see the whole graph, make the model smaller. +Show `chart.mmd` for TLA+, or `lemmas.mmd` first with `proof.mmd` as an optional drill-down for Lean 4, as `mermaid` code blocks. -Render charts with Pele. When the operator asks for an image, or a chart is too large to read as text, follow `references/render.md`. Do not use a different renderer unless the operator asks for it. +For TLA+, the chart budget is 500 states counted by TLC on the config as written. Above 500 states, the command draws only bug paths and writes no `chart.mmd` when no rule breaks. It still checks each rule, and `report.md` gives the state count and each bug path. Shrink the model to draw the whole graph. + +Render charts with Pele per `references/render.md` when the operator asks for an image or a chart is too large to read as text. Do not use another renderer unless the operator asks for it. ## Hand off -Give each chart and its Mermaid text to the operator who must decide. For TLA+, add one line for each bug: the rule, the operator's sentence for that rule, and the path as the report numbers it. Say what the model leaves out. For Lean 4, lead with the plain-English lemma chart, include `proof.mmd` as an optional drill-down, list each unproven path and exit verdict from `report.md`, and note any supporting lemmas hidden by `--view`. Give the command that makes the files again, with a new `--out` folder. +Give the operator each chart, its Mermaid text, and the command to regenerate the files into a new `--out` folder. + +- For TLA+, add one line per bug with the rule, the operator's sentence for that rule, and the numbered path from `report.md`. State what the model leaves out and any steps hidden by `--view`. +- For Lean 4, lead with the plain-English lemma chart `lemmas.mmd` and include `proof.mmd` as an optional drill-down. List each unproven path and the exit verdict from `report.md`, and note any supporting lemmas hidden by `--view`. -When a TLA+ model describes code, replay each bug path against the real code, as a test or a live repro, one step for each action. If a bug does not occur, treat the model as wrong until you show that it is not. +When a TLA+ model describes code, replay each bug path against the real code as a test or live repro, one step per action. If a bug does not occur, treat the model as wrong until you prove otherwise. diff --git a/harness/pstack/claude-code/skills/statechart/references/render.md b/harness/pstack/claude-code/skills/statechart/references/render.md index aaa98d6cd9..e7174ac7f6 100644 --- a/harness/pstack/claude-code/skills/statechart/references/render.md +++ b/harness/pstack/claude-code/skills/statechart/references/render.md @@ -1,18 +1,16 @@ # Render a chart -Render each `.mmd` file that you show with the npm package `pele@1.9.0`, and give the operator the SVG. Install Pele once, outside the repo. Write each SVG next to its `.mmd` file, with the same name. The API is at https://pele.run/api. Pass `{ limit: 1_000_000, outputLimit: 8_000_000, maxEdges: 10_000 }` as the options of `render`. Pele's defaults are smaller than a chart of 500 states can be. When Pele throws a `PeleError`, show the operator the Mermaid text and the error. +Install the npm package `pele@1.9.0` once outside the repo. Use Pele to render each `.mmd` file you show, and write each SVG beside its `.mmd` file with the same base name. Give each SVG to the operator. See the [Pele API](https://pele.run/api). Pass `{ limit: 1_000_000, outputLimit: 8_000_000, maxEdges: 10_000 }` to `render`, because Pele's defaults are too small for a 500-state chart. When Pele throws a `PeleError`, show the operator the Mermaid text and the error. ## Colors -Pele ignores Mermaid `theme` and `themeVariables`. Set its `--pele-*` CSS variables on `.pele`. https://pele.run/theming lists them. +Pele ignores Mermaid `theme` and `themeVariables`. Set `--pele-*` CSS variables on `.pele`, as listed in the [Pele theming reference](https://pele.run/theming). -For TLA+ statecharts (`stateDiagram-v2`), the command gives each state the color class of its group, such as `class sN teal`. It marks each bad state with `class sN breaks` or `class sN mayBreak`, each state on the shortest path to a bug with `class sN bugPath`, and each state that a PROPERTY counterexample repeats forever with `class sN repeats`. The `.mmd` file has a `classDef` line for `breaks` and for `mayBreak`, and none for the group colors, `bugPath`, or `repeats`. +For TLA+ `stateDiagram-v2` charts, each state gets its group color class, such as `class sN teal`. Bad states get `breaks` or `mayBreak`, shortest bug paths get `bugPath`, and states repeated forever by a `PROPERTY` counterexample get `repeats`. Only `breaks` and `mayBreak` have `classDef` lines in the `.mmd` file. -For Lean 4 proof charts (`flowchart TD`), `lemmas.mmd` and `proof.mmd` emit `classDef` and `class` assignments for `target`, `goalRoot`, `subRoot`, `termRoot`, `closed`, `sorry`, `error`, `open`, `axiom`, `native`, `restsOn`, `doubtPath`, `folded`, `stub`, and `note`. Flowchart nodes render as `rect`, `polygon`, or `circle` depending on shape, so the CSS rules below target all three elements. +For Lean 4 `flowchart TD` charts, `lemmas.mmd` and `proof.mmd` emit `classDef` and `class` lines for `target`, `goalRoot`, `subRoot`, `termRoot`, `closed`, `sorry`, `error`, `open`, `axiom`, `native`, `restsOn`, `doubtPath`, `folded`, `stub`, and `note`. Flowchart nodes render as `rect`, `polygon`, or `circle`, so the CSS rules below match all three. -Pele writes each `classDef` color as an inline `style` attribute on the node, and a `style` attribute wins over a normal CSS rule. The mark rules below therefore use `!important` so dark themes override the light `classDef` colors. Put the mark rules after the group colors so a mark shows over a group color. - -Put this `