backnotprop/pstack / skills/statechart
statechart
VerifiedCheck a TLA+ model of a system that moves between states, such as a product flow, a protocol, or a service, and draw it as a Mermaid statechart. The report gives the shortest path to each state that breaks a rule. Use for /statechart, or to show a bug as a path through states.
scripts/frontends/verdict.ts
View on GitHubimport { EC, type Part } from "../ir.ts";
import { textOf } from "./messages.ts";
export type Break =
| { kind: "deadlock" }
| { kind: "temporal" }
| { kind: "invariant" | "property"; name: string };
const NAMED = new Map<number, ["invariant" | "property", RegExp]>([
[EC.TLC_INVARIANT_VIOLATED_INITIAL, ["invariant", /^Invariant (.+) is violated by the initial/]],
[EC.TLC_INVARIANT_VIOLATED_BEHAVIOR, ["invariant", /^Invariant (.+) is violated\.$/m]],
[EC.TLC_PROPERTY_VIOLATED_INITIAL, ["property", /^Property (.+) is violated by the initial/]],
[EC.TLC_ACTION_PROPERTY_VIOLATED_BEHAVIOR, ["property", /^Action property (.+) is violated\.$/m]],
]);
const DISTINCT = new Map<number, RegExp>([
[EC.TLC_INIT_GENERATED1, /(\d+) distinct states? generated/],
[EC.TLC_INIT_GENERATED2, /with (\d+) of them distinct/],
[EC.TLC_STATS, /(\d+) distinct states found/],
]);
export function readVerdict(messages: Iterable<Part>) {
let broke: Break | undefined;
let distinct = 0;
let initial = 0;
for (const m of messages) {
if (typeof m === "string") continue;
const count = DISTINCT.get(m.code)?.exec(textOf(m));
if (count) distinct = Math.max(distinct, Number(count[1]));
if (m.code === EC.TLC_INIT_GENERATED1 || m.code === EC.TLC_INIT_GENERATED2)
initial = Number(/(\d+) (?:distinct )?states? generated/.exec(textOf(m))?.[1] ?? 0);
if (broke) continue;
if (m.code === EC.TLC_DEADLOCK_REACHED) broke = { kind: "deadlock" };
else if (m.code === EC.TLC_TEMPORAL_PROPERTY_VIOLATED) broke = { kind: "temporal" };
const named = NAMED.get(m.code);
const name = named?.[1].exec(textOf(m))?.[1];
if (named && name) broke = { kind: named[0], name };
}
return { broke, distinct, initial };
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 193k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 193k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 193k | Updated | Claude CodeCodex | Verified | Install |