本文へ移動
cccskills
無料GitHub で公開日本語紹介

statechart

TLA+モデルや合意済みの状態図からMermaidの状態遷移図を作り、規則に反するバグを番号付きの経路として示して、検討や修正の根拠をまとめます。

原文原文の説明を見る

Draw how any system moves between states, such as a product flow, a protocol, or a service, as a Mermaid statechart from a TLA+ model. Each bug is a numbered path with blue borders to a state that breaks a rule. Use for /statechart, to show a bug as a path through states, or to turn an agreed chart into a TLA+ skeleton.

実行スコア 未検証

インストール方法を見る

こんなときに便利

  • バグに至る状態遷移を図で示したいとき
  • サービスやプロダクトの動作を合意したいとき
  • TLA+仕様と既存コードを照合したいとき
  • 合意済みの状態図から仕様のひな型を作りたいとき

日本語での紹介

できること

システムがどの状態からどの状態へ移るかを、読み手が理解しやすい言葉で表したMermaidの状態遷移図にします。TLA+モデルがある場合はそこから図を作り、規則に反する状態へ至る経路を番号付きで示します。各状態には画面表示や利用者が気にする状況を、遷移にはタップや要求処理など状態を変える出来事を記します。図のルールは読み手が合意した文章を不変条件として扱い、破れた場合はバグとして報告します。コードをモデル化した場合は、経路を実際のコードやテストと照合し、提案された修正が問題を解消するかも確認します。モデルがないときは、合意済みの図からTLA+のひな型を作れます。

こんなときに便利

プロダクトの画面フロー、通信プロトコル、サービスの状態変化を関係者と確認したいときに使えます。設計段階でルール違反の経路を見つけたい場合や、既存のTLA+仕様とコードの挙動を照らし合わせたい場合にも役立ちます。図とともに、バグの経路、再現状況、モデルが対象外とする内容を引き継ぎ資料にまとめます。

使い方の例

  • 「このTLA+モデルから、バグに至る経路が分かる状態遷移図を作ってください」
  • 「合意した状態図をTLA+のひな型に変換してください」
  • 「この仕様をコードと照合し、ルール違反を確認してください」

注意点

実行にはJavaとTLCが必要です。初回実行時はmise経由でJavaとTLCをインストールし、約305MBをネットワークからダウンロードします。既にあるJavaとTLCを使う方法も案内されています。

この紹介文は、公開されている SKILL.md をもとに AI(OpenAI Codex)が作成しました。正確な仕様は下の原文を確認してください。

含まれるファイル(27)

  • SKILL.md7.5 KB
  • scripts/bug-states.mjs3.0 KB
  • scripts/chart-edges.mjs2.4 KB
  • scripts/chart-parts.mjs612 B
  • scripts/chart-to-tla.mjs7.7 KB
  • scripts/compare-charts.mjs2.2 KB
  • scripts/lib.mjs33.4 KB
  • scripts/map-view.mjs3.4 KB
  • scripts/property-loop.mjs2.3 KB
  • scripts/read-check.mjs2.8 KB
  • scripts/regions-chart.mjs10.7 KB
  • scripts/render.mjs18.7 KB
  • scripts/rule-book.mjs3.3 KB
  • scripts/second-replay.mjs4.7 KB
  • scripts/snapshot.mjs2.0 KB
  • scripts/spec-text.mjs5.7 KB
  • scripts/statechart-help.mjs25.9 KB
  • scripts/statechart.mjs35.3 KB
  • scripts/test/band.mmd316 B
  • scripts/test/regions.mmd2.4 KB
  • scripts/test/statechart.test.mjs254.5 KB
  • scripts/test/sync.mmd597 B
  • scripts/test/upload.mmd507 B
  • scripts/tlc-to-chart-args.mjs2.1 KB
  • scripts/tlc-to-chart.mjs29.4 KB
  • scripts/tlc-tools.mjs3.3 KB
  • scripts/ways-in.mjs3.0 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Statechart

The chart shows how a system moves between states, in the words of the person who reads it. The scripts call that person the reader, as in readerActions and reader steps. The reader decides whether the behavior is right. The reader can be a PM who reads a product flow, an engineer who reads a protocol or a service, or a reviewer who reads a design. Label each state with what the reader can observe or cares about, such as "Paying" in an app or "Lease held, write pending" in a lock service. Label each step with the event that moves the system, such as "tap Pay" in an app, "the request reads the count" in a service, or "the lease expires" in a lock service. Keep variable and action names out of labels.

Run node <skill dir>/scripts/statechart.mjs --help for the commands and for how to read a chart. Work in a scratch folder outside the repo. The command writes its files next to its input. The first run installs TLC and Java with mise, which downloads about 305 MB and needs the network. The help's TLC section tells how to use a TLC and Java that you have.

Pick the direction

Use from-spec when a TLA+ model exists, or when the code or design is concrete enough to model. Use from-chart when there is no model, and the people who own the behavior should agree on it before anyone builds or changes it.

If the code already has a TLA+ spec, start from a copy of that spec. Add the variables that the labels and rules need, and keep the spec's existing invariants. To audit the code against that spec, make the copy model what the code does, and pass the spec unchanged as --against. Check it with the config that its authors say it passes, and pass that config as --against-config unless it has the spec's file name. One mapping labels both models, so label states and steps from variables that both have. A label that reads a variable that only the copy has must test "name" in v first, and label the spec's states another way. When a model describes code, tie every variable and action to code that a reviewer can open, and take its name from that code. Make each action one indivisible step in the code. Put the file and line of the code that checks each condition of an action in a comment on that condition, as in \* pay.ts:120.

Spec to chart

  1. Choose the chart's states. When the reader cares about something that a label would hide, put it in the label, such as "Paying, charged twice" when the screen still says "Paying" after a second charge. Start with few states. Split a state when the split separates two bugs, or when the reader must see a step that leaves the label the same, such as a request that reads a count, because the chart does not draw such a step.
  2. Write each rule that the reader agrees to as one invariant, with the reader's sentence as its comment. A rule can be about any state in the model: what a screen shows, what a request returns, a stored value, or a message between parts. When the model describes code, the rule also names the code that can change that state. If the model has no variable for what a rule is about, add the variable. Do not drop the rule. For a rule that applies once everything settles, define Settled == ~ENABLED System, where System is the disjunction of the actions that happen without the reader. For a rule that applies at a narrower point, such as after each request finishes, write a predicate for that point and make the rule hold where it is true. For a goal that the system must be able to reach, write a rule that says the goal never happens, and pass that rule with --expect-broken. The path that breaks it is then a way to the goal. The chart still draws the goal as a state that breaks a rule, and stories.md tells it as a bug, so name each goal rule in the hand-off. Report each other broken rule as a bug. Never weaken a rule to make the chart pass.
  3. Run from-spec, then fill in the mapping file it writes. Put the labels in state and step. When the chart must separate what the reader does from what happens around the reader, list the reader's actions in readerActions by action name. Leave the list empty when every action counts the same. When the overview is too large to read, add --cover. The overview then keeps only the shortest path to each settled state, plus every bug path, and the command lists what it leaves out. When two bugs end in the same state for different reasons, add cause and make it name each reason. To color the states by what the reader cares about, such as "Order shipped", return that group from group. The legend names the groups, and in the PNG a state that breaks a rule is red in place of its group color.
  4. If there is a proposed fix, model it and pass that model as --fixed.
  5. Render each chart with --png and look at every PNG. Check that each numbered path reads in order. If a label reads like code, fix state or step and run the command again.
  6. When the model describes code, replay each bug's story against the real code, as a test or a live repro, one step per model action. Drive only entry points that a user, a client, or another part of the system reaches, and assert only what they can observe. A test that asserts a flag that it sets, or that searches the source text, proves nothing. When a run proves part of the story and reading the code proves the rest, say which part each proves. When the test copies code that it cannot import, give the commit and line range of the copy, and list what the copy leaves out. If a bug does not reproduce, assume the model is wrong until you show otherwise. Fix the model, not the rule. For a design with no code yet, the TLC trace is the evidence, and the hand-off must say so.

Chart to spec

  1. Draw the chart that the reader agrees to. Use one region for each part that changes independently, such as a device's connection and the job that the device runs. Add one %% never line per rule, with the reader's sentence. Draw an event that stops or restarts a part, such as "the app closes" or "the process restarts", as an edge to the state that comes next. Run render CHART.mmd to get a PNG of the chart for the reader.
  2. Run from-chart. If a rule breaks, the agreed chart has a design bug. Take the bug to the people who agreed to the chart.
  3. Add the real code's guards and variables to the spec that from-chart wrote, and run from-chart again. For each difference it prints, ask the reader whether the code is wrong or the chart needs a correction.

Hand off

Give the PNG and the Mermaid source of each chart to the person who must decide. Add one line per bug with the rule it breaks, its steps as the chart numbers them, whether it reproduced, and whether the proposed fix fixes it. A broken PROPERTY has no path on the chart, so give the TLC counterexample that stories.md names for it. With --against, also say whether the spec already lists it: in the configs that stories.md names, in the spec's notes on what the model leaves out, or not at all. When the model describes code, do not report that a rule holds while the command lists conditions with no file and line. Take every count you quote from summary.json. Attach stories.md and the command that regenerates everything. Say what the model leaves out.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

architect

無料概要あり

実装に入る前に型や関数の形、モジュール構成を複数案から設計し、選んだ設計を実装中も基準にして、形が合わなければ設計から見直すスキルです。

  • 機能実装前に型や構成を設計したいとき
  • 複数の設計案を比較したいとき
  • 実装中の回避策が増え設計を見直したいとき
backnotprop/pstack2,7652026年10月24日 更新

arena

無料概要あり

同じ依頼に複数の案を並行して作り、基準に沿って比較したうえで、最良案に他案の優れた部分を統合し、成果物を検証します。

  • 複数の設計案を比較したいとき
  • 大きな成果物の方向性を決めたいとき
  • 複数の草案から長所を組み合わせたいとき
backnotprop/pstack2,7652026年10月24日 更新

automate-me

無料概要あり

利用者の仕事の進め方や好みを整理し、エージェントが従う個人用の「-mode」スキルを作成・更新します。

  • 仕事の好みを個人用スキルにまとめたいとき
  • 既存の-modeスキルを更新したいとき
  • 応答や確認の習慣を記録したいとき
backnotprop/pstack2,7652026年10月24日 更新

benchmark-checklist

無料概要あり

ベンチマークの速度差を報告する前に、ボトルネック、条件、誤り、再現性、実際に処理が行われたかを証拠に基づいて点検します。

  • 変更前後の性能差を報告したいとき
  • 性能低下の測定結果を点検したいとき
  • ライブラリや設定を測定値で比較するとき
backnotprop/pstack2,7652026年10月24日 更新

blast-radius

無料概要あり

変更差分の外にある影響先や見落としやすい破損リスクを調べ、実際のコードを動かして安全性の根拠を確かめます。

  • 変更の影響範囲を出す前に調べたいとき
  • 小さな差分の安全性に不安があるとき
  • 検索では見えない下流への影響を確認したいとき
backnotprop/pstack2,7652026年10月24日 更新

bro

無料概要あり

直前の返答を、専門用語を避けた短く自然な言葉に言い換えます。説明が難しく感じるときや、要点を人同士の会話のように伝え直したいときに使えます。

  • 技術説明を平易に言い直したいとき
  • 直前の返答を短くしたいとき
  • 専門用語を使わず伝えたいとき
backnotprop/pstack2,7652026年10月24日 更新

backnotprop のスキルをすべて見る

このスキルの問題を報告する