Skip to content

feat(dev): pnpm dev transcript shows a CLI change before and after - #804

Merged
allisonmahmood merged 4 commits into
mainfrom
dev/792-transcript
Oct 19, 2026
Merged

allisonmahmood merged 4 commits into
mainfrom
dev/792-transcript

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

What changed

A CLI change has no screenshots to show. Its output, flags, errors and exit codes are its interface, and reviewing one meant running it. Now pnpm dev transcript <script> runs a script of CLI lines on both evidence instances (#725), as each one's signed-in CLI, and puts the comparison in the PR body. Each line shows after's output, plus a diff when before differs; a line with no change folds away.

Nothing secret should reach the PR. One sanitizer, shared with trial (#793), redacts what it collected before anything is written.

Closes #792

Look at

1. This PR's own transcript, published with --pr. This branch changes no CLI command, so the run uses --base 6900c71~1, the commit before #786 added patchy logs. Before, patchy logs is an unknown command; after, it reads the patch's log. The login lines show no code, the credentials file no token, and the last line logs in and out within one bash -c without leaking its code. patchy login --json and the credentials file count as changed only through their timestamps. Normalizing replaces only origins and paths, so an id or time that changes stays visible.

Transcript logs-and-login

Before is 03891e4 (--base 6900c71~1) and after is e79c9a0 (dev/792-transcript), both on the brightline scenario, from pnpm dev transcript.

Each line ran in its own bash -c from the side's agent workspace, as the scenario's signed-in CLI, with stdin closed. Each side's origin reads <origin>, its environment folder <env>, its checkout <checkout> and the home folder ~; nothing else is normalized. Redacted before writing: tokens and login codes from each side's CLI state; strings shaped like login codes.

3 of 7 lines changed.

Reading a published patch's log

Changed. Before, exit 1 in 0.3 s; after, exit 0 in 0.4 s.

$ cd new-business && patchy logs --limit 1
2026-10-19T17:08:02.153Z · v1 · sample.load (mutation) · success · 66 ms · Allison Mahmood
  entry inv_dr7r0xipit197fyjm0kd436x · correlation call_heq7bampf4f8un62sy9dfhjm
  - tables.insertMany deals · as the patch · success · 10 ms · 17 rows
  - tables.insertMany activity · as the patch · success · 20 ms · 79 rows
-DESCRIPTION
-  Build patch repos and publish patches to a Patchy Cloud instance.
-
-USAGE
-  patchy <subcommand> [flags]
-
-GLOBAL FLAGS
-  --help, -h                                                          Show help information
-  --version, -v                                                       Show version information
-  --wizard                                                            Start wizard mode for a command
-  --completions <bash|zsh|fish|sh>                                    Print shell completion script (choices: bash, zsh, fish, sh)
-  --log-level <all|trace|debug|info|warn|warning|error|fatal|none>    Sets the minimum log level (choices: all, trace, debug, info, warn, warning, error, fatal, none)
-  --json                                                              Print the result as one JSON document on stdout
-  --api-url string                                                    The Patchy Cloud instance to talk to (its API base URL)
-
-SUBCOMMANDS
-  login       Log this machine in; relay the URL and code, then use --complete [code].
-  logout      Forget this machine's publishing key, then revoke it as a courtesy.
-  auth        Manage CLI authentication.
-  whoami      Check the configured Patchy Cloud credentials.
@@ 18 lines cut @@
-Unknown subcommand "logs" for "patchy"
-
-  Did you mean this?
-    login
-    look
-Unrecognized flag: --limit in command patchy
+2026-10-19T17:08:02.153Z · v1 · sample.load (mutation) · success · 66 ms · Allison Mahmood
+  entry inv_dr7r0xipit197fyjm0kd436x · correlation call_heq7bampf4f8un62sy9dfhjm
+  - tables.insertMany deals · as the patch · success · 10 ms · 17 rows
+  - tables.insertMany activity · as the patch · success · 20 ms · 79 rows

18 of 48 lines are cut from the middle. --json has it all.

Signing in, then out
$ patchy login: no change, exit 0 in 0.3 s
$ patchy login
Sign in: <origin>/login/device?code=[redacted]
Code: [redacted]
Expires in about 10 minutes, at 19:18
Not waiting because stdin is not a terminal.
Then run: patchy login --complete [redacted]

Changed. Before, exit 0 in 0.3 s; after, exit 0 in 0.3 s.

$ patchy login --json
{"ok":true,"status":"pending","userCode":"[redacted]","expiresAt":"2026-10-19T17:18:24.354Z","next":"patchy login --complete [redacted]","agentNextSteps":"Show the person the URL and the code and ask them to confirm it in a browser where they are signed in. Do not open a browser yourself. Then run the next command; it waits up to a minute and says pending if they have not confirmed yet."}
-{"ok":true,"status":"pending","userCode":"[redacted]","expiresAt":"2026-10-19T17:18:22.016Z","next":"patchy login --complete [redacted]","agentNextSteps":"Show the person the URL and the code and ask them to confirm it in a browser where they are signed in. Do not open a browser yourself. Then run the next command; it waits up to a minute and says pending if they have not confirmed yet."}
+{"ok":true,"status":"pending","userCode":"[redacted]","expiresAt":"2026-10-19T17:18:24.354Z","next":"patchy login --complete [redacted]","agentNextSteps":"Show the person the URL and the code and ask them to confirm it in a browser where they are signed in. Do not open a browser yourself. Then run the next command; it waits up to a minute and says pending if they have not confirmed yet."}

Changed. Before, exit 0 in 0.0 s; after, exit 0 in 0.0 s.

$ cat "$PATCHY_STATE_DIR/credentials.json"
{"hosts":{"<origin>":{"token":"[redacted]","updatedAt":"2026-10-19T17:07:55.531Z","source":"auth-set"}}}
-{"hosts":{"<origin>":{"token":"[redacted]","updatedAt":"2026-10-19T17:07:53.267Z","source":"auth-set"}}}
+{"hosts":{"<origin>":{"token":"[redacted]","updatedAt":"2026-10-19T17:07:55.531Z","source":"auth-set"}}}
$ patchy logout: no change, exit 0 in 0.3 s
$ patchy logout
Logged out on this machine from <origin>.
$ patchy whoami: no change, exit 1 in 0.3 s
$ patchy whoami
[stderr]
No publishing key is stored for <origin>.
Run: patchy login
Both on one line
$ patchy login && patchy logout: no change, exit 0 in 0.7 s
$ patchy login && patchy logout
Sign in: <origin>/login/device?code=[redacted]
Code: [redacted]
Expires in about 10 minutes, at 19:18
Not waiting because stdin is not a terminal.
Then run: patchy login --complete [redacted]
Logged out on this machine from <origin>.

2. The login code a logout cleared. patchy login saves a pending login holding its device code and user code, and patchy logout deletes it with the stored token. The sanitizer reads both sides' CLI state before the run, every 100ms while a line runs, and after it. It keeps every value until the last write, so both are still known when the section is written. Anything shaped like a login code is redacted too, in case a line makes one and clears it between two reads. Above, every login line reads [redacted] where the code was, and credentials.json shows "token":"[redacted]". The focused tests are:

  • still redacts a login code after a logout cleared it from the CLI state (scripts/dev/src/sanitize.test.ts);
  • redacts a secret a line wrote to the CLI state and cleared before it ended (scripts/dev/src/transcript.test.ts), which fails with the mid-line read turned off.

How it was verified

  • Focused tests, pnpm exec vitest run scripts/dev (12 files, 63 tests). The new ones cover:

    • which variable and key names mark a secret;
    • redaction: values of any length replaced whole, inside URLs and JSON, and pp_… and login-code shapes anywhere, with an app_… id left alone. Overlapping matches merge, so a one-letter secret can't break up a token, and redacting twice changes nothing;
    • the --json report staying valid JSON when a secret is 0;
    • the login-then-logout case above against a real state dir, and a secret written and cleared within one line;
    • script parsing, and a table of refused and allowed lines;
    • real bash -c runs: exit code, both streams, stdin closed, only the given variables, a timeout killing the line, and a background process not holding the line open;
    • normalizing where a path ends, the diff's hunks, the section's layout and cuts, and the note when outputs pass the comparison limit.
  • Real runs, on brightline with --base 6900c71~1, on a shared Linux machine:

    Run Took What it showed
    First run, fresh checkouts about 1 min 25 s patchy logs exit 1 before and 0 after. Two bugs, fixed: an origin before a full stop wasn't normalized, and cutting from the top hid the base's error, so cuts now keep the first 20 and last 10 lines
    --json, checkouts reused 41 s Grepped the section and the JSON. The user-code shape, pp_…, the scenario token, /home/ and the username matched nowhere. Only the JSON's before.apiUrl and after.apiUrl keep the local origins, which the section replaces
    --pr 804 57 s The section went in before the attribution line
    After Sol round 1, with patchy login && patchy logout on one line, --json then --pr 804 49 s The section replaced itself in place. The chained line's code was redacted, caught from the CLI state mid-line. The same greps matched nothing
    After Sol round 2, --json then --pr 804 (above) under a minute The --json output parsed as valid JSON, and the same greps matched nothing
  • Failure paths, run for real:

    $ pnpm --silent dev transcript .local/transcripts/refused.txt
    Line 2 runs `patchy setup`, which writes to your own machine: lines run as you, with your HOME, and `pnpm dev down` undoes none of it. Remove it.
    exit 1
    $ pnpm --silent dev transcript .local/transcripts/slow.txt --scenario team --timeout 2
    …the section, printed and not published…
    Line 2 of the script timed out after 2 s on this branch, so nothing was published; the section is above. Fix the line or raise --timeout.
    exit 1
    

    After each run, only the reusable checkouts and the lock folder remained: no environment folder, instance state or sleep process.

  • Ctrl-C mid-line. I sent SIGINT to the run's process group, as a terminal's Ctrl-C does, while the base side ran sleep 300. Both instances were taken down and the line's process group ended. No runner process, environment folder, instance state or lock entry was left.

  • pnpm verify --changed on 8290de3:

    • format, lint, synth and 1,983 tests passed;
    • typecheck failed on an Effect rule against JSON.stringify in a new test; that's fixed, and pnpm typecheck passes.

    After Sol's fixes I reran the runner's tests, its typecheck, the test typecheck and lint.

  • CI is green on e79c9a0. test (26) failed once there in packages/runtime: workerd exited at startup, which this PR doesn't touch. The rerun of the failed job passed, and it's filed as flaky: supervised workerd diagnostics case fails when workerd exits at startup on Node 26 #805.

  • Hit every surface:

    • The dev loop: docs/DEVELOPMENT.md (the command table and "Showing a change in a PR") and the patchy-dev-loop skill, which now shows a script. The seed and the vitest template are unchanged.
    • The evidence skill: pr-evidence gains a transcript entry in its Shows, Make, Costs and Gotchas shape. Command output loses the throwaway-checkout recipe dev: PRs show what changed, with before/after screenshots and recordings #725 parked there and keeps plain output for what transcript doesn't run. "Not built yet" lists only trial.
    • Reverse states: transcript uses the same evidence checkouts that pnpm dev down deletes. A line's background processes end with its process group, and its files go when the environment is taken down.
    • Doesn't apply: the wire contract, the CLI in packages/patchy (no command changed), migrations, company resources, served pages, the repo layout and vocabulary.
  • Reviewed by GPT 6.1 Sol over three rounds:

    • round 1: 2 blocking, 3 should-fix and 1 nit;
    • round 2: 1 blocking and 2 should-fix, all introduced by round 1's fixes;
    • round 3: no findings.

    All are fixed; the summaries are in the comments.

  • Not checked:

    • macOS;
    • for real: a base whose environment folder isn't where this checkout looks (it shows after only, by the same path as compare's), and a real pp_ token in output (unit-tested only).
  • Done means: both parts are shown above. A CLI change's lines appear before and after with nothing secret in them, using feat(patchy): agents read a published patch's log with patchy logs #786's change through --base, since this branch changes no command. The login-then-logout script published no login code.

Release impact

Tick exactly one.

  • Breaking — requires action from anyone already running this

  • Not breaking — dev tooling and docs; nothing ships to production

  • What does a revert leave behind? Transcript sections already in PR bodies. The evidence checkouts are dev: PRs show what changed, with before/after screenshots and recordings #725's, and the older pnpm dev down still deletes them.

  • Does the release before it still work with that? Yes. Nothing here runs in production.

Made by Claude Opus 5.5 in Claude Code, running in T3 Code.

A CLI change has no screenshots: its output, flags, errors and exit codes are
its interface. `pnpm dev transcript <script>` runs a script of shell lines on
both evidence instances, as each one's signed-in CLI, and lays the lines out
for the PR: after's output, a diff when before differs, and "no change"
folded away when it doesn't.

Lines run in their own `bash -c` in the runner's closed environment, from the
side's agent workspace, with stdin closed and a timeout. Only each instance's
origin and paths are normalized. A sanitizer, shared with `trial` (#793),
collects secrets from both sides' CLI state before the run and after every
line, plus machine-token shapes and secret-named variables, and redacts them
from everything written.

Closes #792

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added area:ci CI, shared testing infrastructure, development scripts and tooling area:docs Touches the docs area size:xl Over 1,000 changed lines; review in multiple passes labels Oct 19, 2026
allisonmahmood and others added 2 commits October 19, 2026 18:41
Sol round 1. A line like `patchy login && patchy logout` printed its code and
cleared it before the after-line read, so the code could reach the section.
The sanitizer now also matches the login-code shape, and reads the CLI state
every 100ms while a line runs. Every non-empty collected value is redacted,
however short.

Also: the line's process group is force-killed on cleanup too, not only on a
timeout; the workspace guard catches flags before `setup` and
`--location=global`; the section says when outputs were compared on their
first 1,000 lines only; and DEVELOPMENT says scenarios with sample data need
Chromium.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allisonmahmood

Copy link
Copy Markdown
Owner Author

GPT 6.1 Sol review, round 1 (on 8290de3): 2 blocking, 3 should-fix, 1 nit. All fixed in 8880d0d.

  • Blocking: a login code made and cleared within one line. patchy login && patchy logout printed the code and cleared it before the after-line read. Two fixes:

    • The sanitizer now also redacts anything shaped like a login code, as it does pp_….
    • It reads the CLI state every 100ms while a line runs.

    A test writes a secret to the state and deletes it within one line; it fails with the mid-line read turned off. The published transcript now ends with exactly that line, redacted.

  • Blocking: secrets under 8 characters were dropped. Every non-empty value from a secret field or variable is now redacted, even if that cuts into other words.

  • Should-fix: no force-kill on scope cleanup. The spawned line now carries forceKillAfter, so a process ignoring SIGTERM is killed however the line ends.

  • Should-fix: guard bypasses. patchy --json setup and npm install --location=global got through. The guard now looks from the program to the next |, ; or &, and knows --location=global, yarn global and short-flag clusters such as -gD. It is table-tested, and DEVELOPMENT says it catches the plain forms, not every way to write them.

  • Should-fix: a silent comparison limit. Changes past the first 1,000 lines weren't disclosed when earlier lines also changed. The note now appears whenever either side passes the limit.

  • Nit: Chromium. DEVELOPMENT now says a scenario with sample data, such as brightline, needs Chromium as its side comes up.

Sol round 2. Literal values were replaced one after another, so a short
collected value could break up a machine token or login code before its
shape was matched. Every match is now found in the original text, overlaps
merge, and an existing `[redacted]` counts as one, so redacting twice changes
nothing. The `--json` report is redacted string by string before it is
encoded, so a short secret can't break the JSON. The `patchy setup` guard
matches the subcommand after patchy's global flags, not any `setup` argument.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allisonmahmood

Copy link
Copy Markdown
Owner Author

GPT 6.1 Sol review, round 2 (on 8880d0d): it confirmed round 1's fixes and found 1 blocking issue and 2 should-fix ones that those fixes introduced. All fixed in e79c9a0.

  • Blocking: a short collected value could break up a token's shape. With every length now counted, a collected p was replaced before the pp_… shape was matched, which left the token's body behind. The sanitizer now finds every match in the original text, merges overlaps, and replaces them once. An existing [redacted] counts as a match, so redacting twice changes nothing. Tested with p and B against a machine token and a login code.
  • Should-fix: the --json report could become invalid. A secret like 0 would have redacted "exitCode": 0. The report is now redacted string by string before encoding. Tested.
  • Should-fix: false positives in the setup guard. patchy init setup-demo and patchy publish setup.html were refused. setup now counts only as patchy's subcommand after its global flags. Both are in the allowed table, with npm install global-agent.

The transcript above was republished at e79c9a0. Its --json run parsed as valid JSON, and the same greps matched nothing.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

GPT 6.1 Sol review, round 3 (on e79c9a0): no findings, no blocking issue. It confirmed that round 2's fixes merge overlapping spans and credit matched sources correctly, keep --json valid, and tell setup the subcommand from setup as an argument. It found no new regressions.

@allisonmahmood
allisonmahmood merged commit ba5f9cb into main Oct 19, 2026
25 of 26 checks passed
@allisonmahmood
allisonmahmood deleted the dev/792-transcript branch October 19, 2026 17:26
allisonmahmood added a commit that referenced this pull request Oct 19, 2026
…connection (#814)

Release 15's What's new entry, written from `9e4b0df`. It covers
everything merged since release 14's `through` (`7694bab`), and sets the
`patchy` release to `0.15.0` (`packages/patchy/package.json` and
`CURRENT_RELEASE`).

| Change | PRs |
| --- | --- |
| New: Your agent can read a tool's log | #786 |
| Fixed: Tools with server code keep one steady connection | #798 |
| Behind the scenes: an unused open tool lets its server rest | #802 |

#783 is release 14's own entry, so it's left out. #795, #796, #797,
#799, #803, #804, #806 and #807 are agent docs, CI and dev tooling, with
no line.

None of the PRs in the range are `one-way`; #786 and #798 predate the
rollback questions, and their diffs leave nothing an older release can't
run with (a new read-only route and CLI command, and the load balancer's
stickiness setting, which the older commit restores).

If this release misbehaves, roll back to `03891e4` (release 14).

Made by Claude Opus 5.5 via Claude Code.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI, shared testing infrastructure, development scripts and tooling area:docs Touches the docs area size:xl Over 1,000 changed lines; review in multiple passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dev: pnpm dev transcript shows a CLI change before and after

1 participant