AGENT SKILL

verify-jstack

Drive jstack's commands (jbus, jmerge, jgauge, install.sh) the way a user does, inside a throwaway sandbox with stand-ins for T3 Code and GitHub, and keep the evidence. Use to prove a change to jstack works in the real commands and not only in its tests, before a pull request claims it does.

License 许可
MIT
最近更新
2026-11-15
Stars
★ 1
Forks
0

01 前言 Front Matter

name
verify-jstack
description
Drive jstack's commands (jbus, jmerge, jgauge, install.sh) the way a user does, inside a throwaway sandbox with stand-ins for T3 Code and GitHub, and keep the evidence. Use to prove a change to jstack works in the real commands and not only in its tests, before a pull request claims it does.

02 资源文件 10

03 SKILL.md 正文

verify-jstack

jstack has no server and no screen. A user touches it in two ways: the commands jbus, jmerge, jgauge, jbriefs and install.sh, and the skills an agent loads. This skill drives the commands. Each drive runs in a sandbox that launch.sh makes: its own HOME, its own jbus config and state, a demo repo, and local stand-ins for T3 Code, gh and notify-send.

The live jstack on this machine is one shared instance: the queue in ~/.local/state/jbus, the briefs in ~/.local/state/home, the systemd timer and the real T3 threads. Never drive it. In a shell that has not sourced a sandbox's env.sh, jbus and jmerge are the live ones and act on live state: run Doctor first, every time.

What this skill cannot drive, so do not report it as verified: a real T3 thread (jbus t3 login, jbus t3 launch-test), a real merge (the stand-in gh refuses gh pr merge, so jmerge is driven with --check only), the systemd units, and what a skill makes an agent do inside a thread. The tests cover the merge against a temporary origin (features/home/tests/test_home_merge.py).

Run every command below from the root of this checkout unless it says otherwise. Read features/verify-jstack/project-skill/map.md before a drive, then the file of the feature you are proving: its features/<name>/verify.md, or its page in testing/verify/.

Set up by a stand-in

A sandbox is a stand-in for the machine jstack runs on. Each line below is a setup step that launch.sh or a stand-in did, and that the real machine does another way. A drive proves what the commands do after these steps, never the steps. They stay unverified until a run on the real machine covers them.

  • fake-gh answers gh pr list from gh/*.json, which Launch writes and a drive edits, and gives fixed answers to the rest: main for repo view, sandbox-owner as the repo's owner, no comment or review on a pull request, no pull request for pr list --base, nothing for api --paginate, a commit's check runs from gh/checks.json (none until a drive writes some) and a job's log from gh/logs/<job id>. The real machine asks GitHub through a signed-in gh, gets GitHub's own JSON, and can merge.
  • fake-gh gives a list of open pull requests a page at a time, as gh and GitHub do: gh pr list gives at most its --limit (30 untold), and gh api .../pulls?state=open one page of per_page (30 untold, at most 100) at page, so a drive with more open pull requests than a command's cap sees the cap. The real machine asks GitHub, which gives its lists the same way.
  • fake-gh answers gh pr edit <number> --base <branch> by changing that pull request's baseRefName in gh/open.json. The real machine asks GitHub, which also reruns the pull request's checks against the new base.
  • fake-gh answers gh api repos/{owner}/{repo}/compare/<base>...<head> with GitHub's status alone (identical, ahead, behind or diverged), read with git from the sandbox's origin.git, and a commit the origin lacks is not found. So a drive that wants a compare answered pushes real commits there, and gh pr view of a pull request gives it from gh/open.json as OPEN, or else from gh/merged.json as MERGED. The real machine asks GitHub, whose compare also gives the commits and the files between the two.
  • fake-gh answers gh pr revert <address> of a pull request in gh/merged.json by reverting its mergeCommit onto its base in origin.git, on the branch revert-<number>-<its branch>, adding that branch's pull request to gh/open.json with the next number and no check yet, and printing its address. It refuses a merge whose revert changes nothing, and a branch already open. The real machine asks GitHub, which makes the revert and its pull request itself, and runs the pull request's checks.
  • fake_t3.py is the T3 Code server and takes a token Launch made up and wrote to config/t3.json. The real machine signs in with jbus t3 login, approved in T3 Code.
  • fake_t3.py answers t3_thread_launch with a thread id, and makes no worktree and starts no agent. On the real machine T3 Code does both.
  • fake_t3.py answers t3_thread_configure with what it keeps for the thread: the selection the launch or the last move gave it, or a made-up one, and it moves no run and has no limits of its own. On the real machine T3 Code keeps the selection, and a usage limit ends a run because the provider says so.
  • fake_t3.py answers orchestrator_capabilities with each instance of t3/capabilities.json and its constraints, none until a drive writes some, and t3_thread_read with the recentRuns a drive keeps on the thread in t3/threads.json. On the real machine T3 Code lists each instance it has, and gives one Provider is not authenticated. when its provider's sign-in lapsed.
  • fake_t3.py answers t3_project_list with the projects of t3/projects.json, none until a drive writes some, and t3_project_update by setting or clearing that project's archivedAt there. On the real machine T3 Code lists every project it has, and an archived one leaves its sidebar.
  • fake_t3.py takes each wake jbus sends the home thread, mcp:sandbox-home, and writes the lines of its items to t3/wake.jsonl. On the real machine the wake queues in the project's home thread, which T3 Code can refuse.
  • notify-send is a script that appends to notify.log. The real machine shows a notification on a desktop session.
  • fake-systemctl is systemctl. It says the manager reads the sandbox's HOME, makes and removes the links systemd makes on enable and disable of a linked unit, writes each call to systemctl.log, and starts no unit. On the real machine systemd loads the units and the timer runs the pass.
  • fake-launchctl is launchctl, for a run on macOS. It loads and boots out agents in the gui domain as launchd does, answers print and list with launchd's words and exit codes, writes each call to launchctl.log, and runs no agent.
  • uv tool install is the real one, with UV_TOOL_DIR in the sandbox and the host's cache and Pythons. On the real machine uv keeps its tools under the user's HOME.
  • A release is a wheel make dist built from this checkout, served by a local web server named in JSTACK_RELEASE_URL, and the uv installer install.sh fetches when uv is missing is a stand-in named in JSTACK_UV_INSTALLER. On the real machine both come from GitHub's release and astral.sh, over the network.
  • PROC and LIMITS name files Launch wrote: an idle machine and a plan at 10% of its limits. The real machine reads /proc and the plan's own limits.
  • config/config.toml is written by Launch: one project, dispatch = true, max_running = 1, and home_thread = "mcp:sandbox-home", so wakes go to that thread of the stand-in. On the real machine the user writes ~/.config/jbus/config.toml.
  • The demo repo's origin is a bare directory beside it, and HOME is new and empty. On the real machine the origin is GitHub and HOME is the user's.
  • The commands come from this checkout's .venv/bin after uv sync, and jbus poll is typed. The real machine has them from uv tool install --editable, and a systemd timer runs the pass.

Name these as unverified wherever a drive is reported: in the evidence, in a pull request, in a Result. record writes this list at the top of every record file, from this section, so add a step here when a stand-in gains one.

Launch

There is nothing to keep alive but the stand-in for T3 Code. Launch installs this checkout's commands with uv sync, makes the sandbox from nothing (the demo repo, the config, the seed files a drive edits), starts the stand-in, and prints one line when it is ready: ready: . <sandbox>/env.sh.

Ready means a drive can run, not that the stand-in answers. Before that line, Launch runs two real commands the way a drive does, with env.sh sourced: jbus --project demo queue show must succeed, and jmerge --check must succeed in the demo checkout and ask the stand-in gh. When either fails there is no ready: line: Launch prints launch.sh: not ready: <the command> failed in the sandbox with what the command said, tears down what it made, and exits 1. It removes the gh call its own probe made, so a drive starts with no gh/calls.log.

ready=$(features/verify-jstack/project-skill/scripts/launch.sh) && echo "$ready"
. "${ready#ready: . }"

Source that env.sh again in every new shell: an agent's shell does not keep variables from one call to the next. It sets HOME, JBUS_CONFIG_DIR, JBUS_STATE_DIR, JBUS_HOME_DIR, PROC, LIMITS and PATH, defines record, and changes to the demo repo's main checkout, $VERIFY_JSTACK_SANDBOX/demo. Each launch has its own directory and its own port, so sandboxes run side by side: use a new one for each feature. Launch from a shell that has sourced no env.sh: inside a sandbox launch.sh prints launch.sh: this shell is in the sandbox <path>: launch from a new shell and exits 1.

Teardown is Cleanup, below.

Doctor

One read-only check. Run it first, and again whenever anything looks off. Drive only when its last line is doctor: ok.

"$VERIFY_JSTACK_SCRIPTS/doctor.sh"

It prints one ok or bad line for each thing a drive leans on: HOME and jbus's three directories are in the sandbox, gh, notify-send and systemctl are the stand-ins, jbus, jmerge, jgauge and jbriefs are this checkout's build, the stand-in for T3 Code is the process this sandbox started and answers for it, jbus reads the sandbox's config, and the evidence directory is outside the sandbox. Its build line is the commit under test and how many files are uncommitted.

It also checks the seed, feature by feature. Each file in features/ has a Needs: line that lists the seed its journey relies on, and Doctor prints ok <feature>: seed has <the list>, or bad <feature>: seed lacks <x> for each one this sandbox does not have. A seed lacks line makes the last line doctor: not ok, as every bad line does, so nothing is driven in that sandbox. The feature the line names is also reported as failed, with that line as the reason, and the reason is written in the feature's Gotchas. A feature whose own line is ok has not failed: clean up, and drive it in a new sandbox. That helps only when a drive removed the seed. Launch makes every seed, so a new sandbox with a seed lacks line is a fault in launch.sh or in the feature file's Needs: line, and nothing is driven until it is fixed. The check is of what Launch made and every recipe keeps (the file is there, a JSON file is still a list), so it holds at the end of a drive that edited the seed. Never weaken the journey to make it pass: do not drop the step that needs the seed, do not write the seed by hand to get past Doctor, and do not report the rest of the recipe as the feature.

Drive

The harness is the shell. Type the commands a user types, with record in front of each one that is part of the proof. record <name> <command> runs the command, prints what it printed, and appends the command, its output and its exit code to $VERIFY_JSTACK_EVIDENCE/<name>.txt. A command that reads stdin gets it through record.

One feature, start to finish: a row of the jbus queue from add to a launched thread. The other features are in each features/<name>/verify.md, and the shared test tooling's in testing/verify/.

printf '# alpha: a demo task\nTask: alpha, a demo task\nWhy: the sandbox needs a row the queue takes\nDone when:\n- the demo works\nProves it: the demo test\nSize: S\nWhere: `src/alpha/`\nDesign: none, a demo\nReview: none\nPlaybook: feature\nSkills: tdd\nPull request: none\nHome: uncategorized\n' | record queue-row jbus queue add alpha --priority 1
printf '{"mcp:sandbox-chat": [{"itemId": "turn-item:message:m1", "messageId": "m1", "text": "go", "type": "user_message", "createdBy": "user", "updatedAt": "%s"}]}\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" > "$VERIFY_JSTACK_SANDBOX/t3/messages.json"
word=$(record queue-row jbus word --to demo --message mcp:sandbox-chat/m1 | awk '{print $NF}')
record queue-row jbus queue approve alpha --word "$word"
record queue-row jbus poll
record queue-row jbus queue show
record queue-row jbus status

jbus poll prints launched alpha: mcp:sandbox-thread-1, and the row's status and thread columns then say so.

To stop that thread on a usage limit, give the crew's role a pool of two instances before the launch, launch the row as above, then fail its run between passes. Each block below is whole, from a new sandbox, so it carries the launch again. The next jbus poll prints failover alpha: five_hour limit until ..., and t3/calls.jsonl has the t3_thread_configure that moved it and the queued carry-on. The open pull request makes the pass ask GitHub who owns the repo, and it prints no line that GitHub did not say.

mkdir -p "$VERIFY_JSTACK_SANDBOX/home/.config/jstack"
echo 'crew: claudeAgent claude-sonnet-5-5 claudeAgent,claudeAgent_sandbox' > "$VERIFY_JSTACK_SANDBOX/home/.config/jstack/roles"
printf '# alpha: a demo task\nTask: alpha, a demo task\nWhy: the sandbox needs a row the queue takes\nDone when:\n- the demo works\nProves it: the demo test\nSize: S\nWhere: `src/alpha/`\nDesign: none, a demo\nReview: none\nPlaybook: feature\nSkills: tdd\nPull request: none\nHome: uncategorized\n' | record usage-limit jbus queue add alpha --priority 1
printf '{"mcp:sandbox-chat": [{"itemId": "turn-item:message:m1", "messageId": "m1", "text": "go", "type": "user_message", "createdBy": "user", "updatedAt": "%s"}]}\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" > "$VERIFY_JSTACK_SANDBOX/t3/messages.json"
word=$(record usage-limit jbus word --to demo --message mcp:sandbox-chat/m1 | awk '{print $NF}')
record usage-limit jbus queue approve alpha --word "$word"
record usage-limit jbus poll
T="$VERIFY_JSTACK_SANDBOX/t3"
notice="run-1:usage-limit:five_hour:$(($(date +%s) + 3600))"
jq --arg id "$notice" '."mcp:sandbox-thread-1" = [{runId: "run-1", itemId: $id, type: "system_notice", text: ""}]' "$T/messages.json" > "$T/m" && mv "$T/m" "$T/messages.json"
jq 'map(.status = "failed" | .latestRunId = "run-1")' "$T/threads.json" > "$T/t" && mv "$T/t" "$T/threads.json"
"$VERIFY_JSTACK_SCRIPTS/open-pull.sh" alpha src/alpha/a.py
record usage-limit jbus poll

To stop that thread on a login lapse instead, launch the row with no roles file, then sign its instance out and fail its run with the provider's words. The run ends ten minutes before the pass, since a pass counts an instance a run failed to sign in on less than five minutes ago (failover.HOLD) as signed out whatever T3 Code says, and so only the constraint holds the thread here. Each jbus poll while the constraint is there sends the thread nothing, and the first prints signed out: claudeAgent cannot sign in, ... once. Once the drive clears the constraint, the next pass prints failover alpha: claudeAgent could not sign in, carry-on on claudeAgent, ..., and t3/calls.jsonl has its one t3_thread_send keyed lapse|mcp:sandbox-thread-1|run-1. A pass after it sends nothing more. Leave the pull request out of this drive: a pass tells the crew of a green one, and that send is not the carry-on.

printf '# alpha: a demo task\nTask: alpha, a demo task\nWhy: the sandbox needs a row the queue takes\nDone when:\n- the demo works\nProves it: the demo test\nSize: S\nWhere: `src/alpha/`\nDesign: none, a demo\nReview: none\nPlaybook: feature\nSkills: tdd\nPull request: none\nHome: uncategorized\n' | record login-lapse jbus queue add alpha --priority 1
printf '{"mcp:sandbox-chat": [{"itemId": "turn-item:message:m1", "messageId": "m1", "text": "go", "type": "user_message", "createdBy": "user", "updatedAt": "%s"}]}\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" > "$VERIFY_JSTACK_SANDBOX/t3/messages.json"
word=$(record login-lapse jbus word --to demo --message mcp:sandbox-chat/m1 | awk '{print $NF}')
record login-lapse jbus queue approve alpha --word "$word"
record login-lapse jbus poll
T="$VERIFY_JSTACK_SANDBOX/t3"
ended=$(perl -MPOSIX -e 'print strftime("%Y-%m-%dT%H:%M:%SZ", gmtime(time - 600))')
jq --arg at "$ended" '."mcp:sandbox-thread-1" = [{runId: "run-1", itemId: "run-1:error", type: "error", text: "Not logged in · Please run /login", updatedAt: $at}]' "$T/messages.json" > "$T/m" && mv "$T/m" "$T/messages.json"
jq --arg at "$ended" 'map(.status = "failed" | .latestRunId = "run-1" | .recentRuns = [{runId: "run-1", ordinal: 1, status: "failed", providerInstanceId: "claudeAgent", model: "claude-sandbox", requestedAt: $at, startedAt: $at, completedAt: $at}])' "$T/threads.json" > "$T/t" && mv "$T/t" "$T/threads.json"
jq '.claudeAgent = ["Provider is not authenticated."]' "$T/capabilities.json" > "$T/c" && mv "$T/c" "$T/capabilities.json"
record login-lapse jbus poll
record login-lapse jbus poll
jq '.claudeAgent = []' "$T/capabilities.json" > "$T/c" && mv "$T/c" "$T/capabilities.json"
record login-lapse jbus poll
record login-lapse jbus poll
jq -c 'select(.tool == "t3_thread_send") | .arguments.clientRequestId' "$T/calls.jsonl"

What a drive sets up and reads, all under $VERIFY_JSTACK_SANDBOX:

Path What it is A drive
gh/open.json, gh/merged.json, gh/commits.json, gh/checks.json, gh/logs/ what GitHub would answer edits them (open-pull.sh writes open.json)
gh/calls.log every gh call jbus and jmerge made reads it
t3/threads.json the threads T3 Code has, each with its modelSelection and its recentRuns edits a thread's status, latestRunId, recentRuns or settled between passes
t3/capabilities.json each provider instance T3 Code lists, by its id, with its constraints gives an instance Provider is not authenticated. to sign it out, and clears it to sign it in
t3/messages.json a thread's items, by thread id: the user's messages that jbus word --message <thread>/<message> reads, and the items of a run a pass reads for a usage limit writes one before a drive keeps the user's word or stops a thread on a limit
t3/calls.jsonl every tool call jbus made, with its arguments reads it
t3/wake.jsonl every wake sent to a home thread, with the thread and the lines it carried reads it
machine/proc/loadavg, machine/limits the load and the plan limits jgauge room reads edits them
home/.local/state/home/demo/tasks/ the demo repo's briefs writes briefs, reads the Thread: line jbus adds
state/ jbus's queue, outbox, launch records and status.json reads it, never writes it by hand
notify.log what notify-send was asked to show reads it

Reach state through the command a user has for it (jbus queue add, not an edit of queue.json). The files above marked "edits" are the outside world, which the user does not control with a jstack command.

Evidence

Evidence goes to $VERIFY_JSTACK_EVIDENCE, which is /tmp/verify-jstack-evidence/<the sandbox's name> (under $TMPDIR when that is set). It is outside the sandbox and Cleanup keeps it. /tmp is emptied on a reboot: copy the directory elsewhere if the proof must outlive one.

record keeps the action. Keep the resulting state too, by copying what the commands changed:

cp "$VERIFY_JSTACK_SANDBOX/t3/calls.jsonl" "$VERIFY_JSTACK_SANDBOX/t3/wake.jsonl" "$VERIFY_JSTACK_SANDBOX/gh/calls.log" "$VERIFY_JSTACK_EVIDENCE/"
cp "$HOME/.local/state/home/demo/tasks/alpha.md" "$VERIFY_JSTACK_EVIDENCE/brief-alpha.md"
cp "$JBUS_STATE_DIR/demo/queue.json" "$VERIFY_JSTACK_EVIDENCE/"
"$VERIFY_JSTACK_SCRIPTS/doctor.sh" > "$VERIFY_JSTACK_EVIDENCE/doctor.txt"

The standards a proof is held to:

  • Drive the real command, as built from this checkout (doctor.txt names the commit). Do not call a Python function, and do not write jbus's state files by hand.
  • Keep the action and the state it left: the record file, and a second view of the result (jbus queue show after jbus poll, the brief's Thread: line, status.json).
  • Verify the side effects, not only the printout. A launch is a t3_thread_launch line in t3/calls.jsonl. A wake is a line in t3/wake.jsonl. A message to the desk is a line in notify.log.
  • The stand-ins are the only mocks, and each sits where jstack already ends: T3 Code's MCP endpoint, gh, notify-send, and the machine readings jgauge room takes from PROC and LIMITS.
  • Do not trust jmerge --check by its name. gh/calls.log shows what it asked GitHub, and has no pr merge line.
  • Name the feature file and the entry point with each artifact. An entry point that was not driven is reported as not driven, with the reason.
  • Every record file starts with the list from "Set up by a stand-in". Leave it there, and say the same beside any claim the evidence backs: those steps are not verified.

Keep the config out of the evidence: config/config.toml and config/t3.json hold the sandbox's made-up key and token, which open nothing, and still do not belong in a pull request.

Cleanup

"$VERIFY_JSTACK_SCRIPTS/cleanup.sh"

It stops the stand-in for T3 Code by the pid Launch wrote down, and only while that pid is still this sandbox's stand-in. Then it removes the sandbox directory, and prints the evidence directory and its files, which it keeps. With no env.sh sourced, name the sandbox: features/verify-jstack/project-skill/scripts/cleanup.sh /tmp/verify-jstack.<its six characters>. It refuses a directory that does not hold the marker file Launch writes first, .verify-jstack-sandbox. It refuses a path that does not start with /, too. Never stop a process by its name: another agent's sandbox may be running beside this one.

Run it after a failed drive too. Then confirm the evidence is still there:

ls -l "${TMPDIR:-/tmp}/verify-jstack-evidence/"

Helpers

All in features/verify-jstack/project-skill/scripts/, which $VERIFY_JSTACK_SCRIPTS names once env.sh is sourced.

Script Run it as What it does
launch.sh features/verify-jstack/project-skill/scripts/launch.sh makes a sandbox, starts the stand-in, runs jbus and jmerge in it, prints ready: . <sandbox>/env.sh
doctor.sh "$VERIFY_JSTACK_SCRIPTS/doctor.sh" the read-only check, each feature's seed included, doctor: ok or exit 1
record.sh record <name> <command> (the function env.sh defines) runs a command and keeps it in $VERIFY_JSTACK_EVIDENCE/<name>.txt, under the list of what a stand-in set up
open-pull.sh "$VERIFY_JSTACK_SCRIPTS/open-pull.sh" beta src/beta/a.py gives the sandbox's GitHub one open pull request, number 7, and prints its head commit
cleanup.sh "$VERIFY_JSTACK_SCRIPTS/cleanup.sh" stops the stand-in, removes the sandbox, keeps the evidence
fake_t3.py started by launch.sh, never by hand the stand-in for T3 Code's MCP endpoint ($VERIFY_JSTACK_URL/mcp), which keeps each wake in t3/wake.jsonl
fake-gh linked as gh on the sandbox's PATH, never run by hand the stand-in for gh: answers from gh/*.json, exits 64 on pr merge
fake-systemctl linked as systemctl on the sandbox's PATH, never run by hand the stand-in for systemctl --user: answers for the sandbox's HOME, links and unlinks as systemd does, starts nothing
fake-launchctl linked as launchctl on the sandbox's PATH, never run by hand the stand-in for launchctl on macOS: loads and boots out agents as launchd does, starts nothing

After a change to these scripts, run the two deterministic end-to-end scripts in features/verify-jstack/e2e/, each with bash <script> from a shell in no sandbox. Each ends e2e: ok and prints the same lines on a rerun.

When jstack changes, the feature files are what go stale first. /maintain-verification-skill finds this skill through skills.json, where projectSkills names it, but it reads a feature map only from the skill's own features/ folder, which this skill does not have: on jstack it stops at no feature map.

Each feature file also has a Paths: list, the paths it owns, and a Tests: list, the tests that read it in a way no import shows, and the map a Cross-cutting: list, each one entry per line: scripts/select_tests.py <base> <head> reads them, with the imports of the tree, to name the tests a diff needs, and testing/tests/test_select_tests_rules.py fails on a path the map leaves out.

04 同仓库更多 Skills