Skip to content

feat(patchy): agents read a published patch's log with patchy logs - #786

Merged
allisonmahmood merged 2 commits into
mainfrom
t3/patch-cli-log-access
Oct 19, 2026
Merged

allisonmahmood merged 2 commits into
mainfrom
t3/patch-cli-log-access

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

When someone reports a published tier 2 patch is broken, the agent that built it can't see why. The patch's log already holds each call's version, handler, outcome, ctx.log lines and the message and stack of anything a handler threw, but only the portal's Log tab reads it, so people copy entries out of the browser for their agent.

pnpm patchy logs now prints a page of that log:

2026-10-19T10:44:30.756Z · v1 · notes.list (query) · failure handler_failed · 109 ms · Ben Ortiz
  entry inv_5tnp… · correlation call_22j4…
  log: Cannot read properties of undefined (reading 'title')
    TypeError: Cannot read properties of undefined (reading 'title')
        at Object.handler (server.js:6759:28)
  • One read-only route, GET /api/patches/:patchId/log, in the patches group. It composes InvocationLog.page, the query behind the Log tab, and adds version numbers, people's names and connection handles. Readers are the same as the Log tab's: the current owner and company admins. Another member gets not_owner naming the owner.
  • No search. --failed is the only filter, because the query already has it and failures can be rare among successes. Everything else is grep or jq over the text or --json output. --before <next> pages; there's no follow mode.
  • Bounded pages: 10 entries by default, 25 at most. A page ends early rather than pass about 2 MiB, since 50-step trees with 32 KiB of log per nested handler could otherwise reach tens of megabytes. A cut page's next continues from its last entry.
  • Full step trees, successful steps included, since a write that landed before an action failed is often the story. Text prints each step under the handler that made it and stops near 2 MiB, pointing at --json for the rest.
  • Skills: patchy-server tells builder agents to read the log when a published patch misbehaves, fix it and publish. patchy-loop and the global skill list the command. The dev.log "local-only failure message/stack" wording is corrected, since production keeps them too.

Departures from #785: no [file] target, since tier 0 file patches never have log entries. --patch or the repo's id is enough.

Not covered: tier 1 browser errors aren't recorded anywhere. Production stacks point into the minified server bundle, so the message is the useful part; readable stacks are a follow-up.

Testing

  • Server tests: owner, admin, non-owner and unknown patch; cursor paging and --failed; the 2 MiB cut and its continuation. CLI tests: query flags, JSON and text output, the not_owner relay and local --limit refusal. Renderer tests: sibling handlers' steps nest correctly; deep stacks stop near 2 MiB with the footer kept. pnpm check passes.
  • In pnpm dev up team: Ada published a tier 2 guestbook whose list query crashed on an empty table. Ben opened it and saw "The handler failed." pnpm patchy logs as Ada showed the entry with v1, Ben, the message and the stack. A CLI logged in as Ben got Only Ada Park or an admin can read this patch's log., exit 2. Ada, as admin, read the empty log of a page Ben owns.
  • The environment's agent, told only "Ben says the guestbook tool is broken: when he opens it he just sees 'The handler failed. Use the correlation id to find its log.' Please fix it and publish the fix.", ran patchy logs --patch <id> --failed --json from the global skill, found the empty-table crash, changed the handler to rows.at(-1)?.title ?? "" and published v2 in 13 turns. Ben's page then loaded with no errors.

Closes #785

Made by Claude Opus 5.5 via Claude Code (T3 Code); reviewed with GPT-6.1-Sol.

A builder agent couldn't see why a published tier 2 patch failed: only the
portal's Log tab reads it, so people pasted entries to their agents.

`GET /api/patches/:patchId/log` serves one page of the log to its owner and
admins, composing InvocationLog.page as the portal does: full step trees,
version numbers, people's names, connection handles, `--failed`, a cursor,
10 entries by default and 25 at most, ending early before about 2 MiB.
`patchy logs` prints it as greppable lines or the JSON document.

Closes #785

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added area:server Touches the server area area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:docs Touches the docs area area:ui Portal and first-party browser pages, shared rendering and styles size:l 501-1,000 changed lines labels Oct 19, 2026
Runtime returns an entry's steps shallowest first, so a handler's calls
printed after its sibling handlers. Steps now print depth first under the
handler that made them.

Indenting every line of deep stacks could turn a 2 MiB page into tens of
megabytes of text. Lines are generated lazily and stop after about 2 MiB
with a line pointing at --json; details print as one line of JSON, and
--json no longer builds the text at all.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added size:xl Over 1,000 changed lines; review in multiple passes and removed size:l 501-1,000 changed lines labels Oct 19, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Review trail (GPT-6.1-Sol, xhigh):

  • Design review, before building: kept --failed, a visible cursor and no auto-walk. Asked for a 10/25 page with a ~2 MiB response bound, full step trees including successful steps, the route in the patches group composing InvocationLog, admins allowed, and logs in CliCommand. All applied.
  • Round 1 on this PR: two defects, both in the text renderer, fixed in a20dd00.
    1. Steps arrive shallowest first, so a handler's calls printed after its sibling handlers. They now print depth first under the handler that made them.
    2. Depth indentation on every stack line could turn a 1.6 MB page into ~46 MB of text. Text now stops near 2 MiB with a line pointing at --json, details print as one line of JSON, and --json skips rendering text.
  • Round 2: approve, no findings.

@allisonmahmood
allisonmahmood merged commit 6900c71 into main Oct 19, 2026
13 checks passed
@allisonmahmood
allisonmahmood deleted the t3/patch-cli-log-access branch October 19, 2026 11:26
allisonmahmood added a commit that referenced this pull request Oct 19, 2026
## What changed

Production deploys are frequent now, and migrations never roll back.
Nothing on a PR or at a deploy says whether rolling back past a change
is safe, so it gets found out during an incident.

- **PR template.** Release impact asks two questions beside Breaking:
what a revert leaves behind, and whether the release before it still
works with that.
- **`one-way` label.** It marks a PR whose second answer is no. It's
documented in `docs/agents/triage-labels.md` and created on GitHub.
- **AGENTS.md › Deploying.**
- The deploying agent pins the live commit from `/healthz/deep`. It
stops if any Deploy run hasn't finished, or the one updated last didn't
succeed, and checks again before dispatching.
- It reviews rollback safety across live..deploy, which is separate from
the What's new range.
  - It dispatches the exact reviewed commit with `-f revision=<sha>`.
- It ends the `docs(whats-new)` PR and the hand-off with one rollback
line.
  - Step 5 still merges the What's new PR once it's green.
- **OPERATIONS › Deploying** names the rollback line and the pinned
revision beside the runbook.

Closes #788

## How it was verified

This is docs, a template and a label, so there are no tests. Prettier
passes on the changed files.

**The dispatch, checked by reading.** `deploy.yml` sets `COMMIT` to
`inputs.revision || github.sha` and checks that commit out. It refuses
anything that isn't a full sha on `main`. Step 4 then builds the server
image from that commit. Deploy never uses `server-image.yml`'s artifact,
so a sha whose main CI hasn't finished still deploys. There is no "image
not built yet" case. ECR tags are immutable: a commit that was pushed
before must rebuild to the same digest, or the run fails.
`/healthz/deep` reports the same revision the app stack was given.

**Steps 1 and 3, dry run against production today.** This was a public
GET only, with no dispatch.

```
$ curl -s https://cloud.patchyhq.com/healthz/deep | jq -r .revision
03891e4
$ gh run list --workflow deploy.yml --limit 1000 --json status,conclusion,updatedAt,url --jq 'sort_by(.updatedAt) | last, (.[] | select(.status != "completed"))'
{"conclusion":"success","status":"completed","updatedAt":"2026-10-19T01:13:01Z","url":"https://github.com/allisonmahmood/patchy-cloud/actions/runs/39182309291"}
$ git log --first-parent --format='%h %s' 03891e4..origin/main
6900c71 feat(patchy): agents read a published patch's log with `patchy logs` (#786)
$ gh pr view 786 --json labels -q '[.labels[].name] | join(",")'
area:server,area:ci,area:cli,area:docs,area:ui,size:xl
$ git show 03891e4:packages/core/src/whatsNew.ts | grep -m1 'id:'
    id: 14,
```

#786 has no answers because it predates the questions, so I read its
diff. It adds a route and a CLI command, with no migration. Release 14
would answer the new route with a 404 and keep working. Today's line
would be: "If this release misbehaves, roll back to `03891e4` (release
14)."

**What can only be shown after merge.** GitHub serves the template from
`main`, so the first PR to carry both questions will be one opened after
this merges. This PR answers them by hand below. The next deploy will be
the first one dispatched with an exact revision, and the first whose
hand-off names a rollback commit or boundary.

## Release impact

- [ ] **Breaking** — requires action from anyone already running this
- [x] **Not breaking** — docs, the PR template and a GitHub label

- **What does a revert leave behind?** The `one-way` label on GitHub,
and any answers PRs have already written. Nothing in production.
- **Does the release before it still work with that?** Yes. Nothing here
ships to production.

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
allisonmahmood added a commit that referenced this pull request Oct 19, 2026
)

## 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.

<!-- patchy-dev:transcript:logs-and-login -->

#### 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.

```console
$ 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
```

```diff
-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

<details><summary><code>$ patchy login</code>: no change, exit 0 in 0.3
s</summary>

```console
$ 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]
```

</details>

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

```console
$ 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."}
```

```diff
-{"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.

```console
$ cat "$PATCHY_STATE_DIR/credentials.json"
{"hosts":{"<origin>":{"token":"[redacted]","updatedAt":"2026-10-19T17:07:55.531Z","source":"auth-set"}}}
```

```diff
-{"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"}}}
```

<details><summary><code>$ patchy logout</code>: no change, exit 0 in 0.3
s</summary>

```console
$ patchy logout
Logged out on this machine from <origin>.
```

</details>

<details><summary><code>$ patchy whoami</code>: no change, exit 1 in 0.3
s</summary>

```console
$ patchy whoami
[stderr]
No publishing key is stored for <origin>.
Run: patchy login
```

</details>

##### Both on one line

<details><summary><code>$ patchy login &amp;&amp; patchy logout</code>:
no change, exit 0 in 0.7 s</summary>

```console
$ 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>.
```

</details>

<!-- /patchy-dev:transcript:logs-and-login -->

**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.
- **`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 #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 #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 #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
- [x] **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 #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.

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
allisonmahmood added a commit that referenced this pull request Oct 19, 2026
…er (#806)

## What changed

People's agents use the CLI and the Patchy skill, and when something is
awkward they fumble: they guess flags, retry, read help or give up.
Until now we only saw that when someone's agent hit it. Now `pnpm dev
trial "<task>"` gives a task to a fresh agent on both evidence instances
(#725), the base and the head, and puts how each attempt went in the PR.

The agent is each side's own `agent` launcher: Claude Code as the
scenario's publisher, with the release's Patchy skill and no personal
instructions or settings. It runs without a person, within 30 turns and
10 minutes by default. Only a filtered log is kept: whether it finished,
its answer in a sentence or two, its commands with exit codes, one line
per failure, and the counts. #792's sanitizer reads each side's CLI
state after every tool call and redacts everything before it's written.

Closes #793

## Look at

**1. This PR's own trial, published with `--pr`.** This branch changes
no CLI command, so the trial uses `--base 6900c71~1`, the commit before
#786 added `patchy logs`, with the task "Show me the last few lines of
the new-business patch's log." On this PR's head, after's agent found
`patchy logs` through `--help` and read the log. Before's had no `patchy
logs`, tried `pnpm patchy dev logs` and reported "No dev log yet."

One run is a smell test, not a measurement. Over seven `brightline` runs
of this task, after's agent found `patchy logs` five times and before's
never did. In the other two, both agents took "log lines" to mean a log
file and gave up.

<!-- patchy-dev:trial:show-me-the-last-few-lines -->

#### Trial `show-me-the-last-few-lines`

> Show me the last few lines of the new-business patch's log.

Before is `03891e4` (--base 6900c71~1) and after is `ebe3966`
(dev/793-trial), both on the `brightline` scenario, from `pnpm dev
trial`.

Each side gave the task to a fresh agent: the environment's `agent`
launcher, Claude Code on `claude-sonnet-5-5` as the scenario's
publisher, with the release's Patchy skill and no personal instructions
or settings, run without a person within 30 turns and 10 minutes. The
log keeps each tool call, commands with their exit codes, and one line
per failure; not the agent's reasoning or what its commands printed.
Nothing in it matched a collected secret (each side's CLI state,
machine-token and login-code shapes, email addresses outside the
scenarios' example domains, secret-named variables, and any accounts the
run acts as).

One run is a smell test, not a measurement.

| | Before | After |
| --- | --- | --- |
| Finished | Yes | Yes |
| Commands | 9 | 10 |
| Failures | 3 | 2 |
| Help lookups | 1 | 4 |
| Minutes | 0.4 | 0.3 |

**Before** answered: “The new-business patch has no log yet. `pnpm
patchy dev logs` returned "No dev log yet." The log only exists once the
local dev session has run.”

**After** answered: “The new-business patch's log has only one entry.
It's the newest, and I asked for 5.”

<details><summary>Before's log: 9 commands, 3 failures</summary>

```console
denied  $ cd <env> && ls -la workspace trial-tmp; find . -iname '*new-business*' -o -iname '*new_business*' -o -iname '*.log' 2>/dev/null | head -50
        This Bash command contains multiple operations. The following part requires approval: cd <env> && ls -la workspace trial-tmp; find . -iname '*new-business*' -o -iname '*new_business*' -o -iname '*.log…
denied  $ find <env> -iname '*new-business*' -o -iname '*new_business*' -o -iname '*.log'
        find in '<env>' was blocked. For security, Claude Code may only search files in the allowed working directories for this session: '<env>/workspace', '<env>/trial-tmp'.
exit 0  $ find <env>/workspace <env>/trial-tmp
exit 0  $ find <env>/workspace/new-business -path '*/node_modules' -prune -o \( -iname '*.log' -o -iname '*log*' \) -print
exit 0  $ ls -la <env>/workspace/new-business <env>/workspace/new-business/patchy
exit 0  $ cd <env>/workspace/new-business && ls -laR .patchy server | head -40; cat package.json patchy.json
exit 0  $ grep -n -i -B1 -A3 'log' AGENTS.md; ls node_modules/.bin | grep -i patchy
denied  $ node_modules/.bin/patchy --help
        This command requires approval
skill   patchy
exit 0  $ pnpm patchy dev logs 2>&1 | tail -n 15
```

</details>

<details><summary>After's log: 10 commands, 2 failures</summary>

```console
exit 0  $ ls -la && find . <env>/trial-tmp -maxdepth 3 -ipath '*new-business*' 2>/dev/null | head -50
exit 0  $ cd <env>/workspace/new-business && ls -la .patchy; find . -path ./node_modules -prune -o \( -iname '*.log' -o -iname '*log*' \) -print | head
exit 0  $ ls -la .patchy/publish; grep -n -i 'log' AGENTS.md patchy.json package.json | head -20
exit 0  $ ls -laR .patchy/publish; cat patchy.json; grep -n -i -B1 -A3 'log\|history' AGENTS.md | head -30
denied  $ grep -n '"scripts"' -A12 package.json; npx --no-install patchy --help 2>&1 | head -30
        This Bash command contains multiple operations. The following part requires approval: grep -n '"scripts"' -A12 package.json; npx --no-install patchy --help 2>&1
exit 0  $ grep -n '"scripts"' -A12 package.json
denied  $ ./node_modules/.bin/patchy --help 2>&1 | head -30
        This Bash command contains multiple operations. The following part requires approval: ./node_modules/.bin/patchy --help 2>&1
exit 0  $ pnpm patchy --help
exit 0  $ pnpm patchy logs --help
exit 0  $ pnpm patchy logs --limit 5
```

</details>

<!-- /patchy-dev:trial:show-me-the-last-few-lines -->

**2. What leaves the machine.** The log keeps each tool call and nothing
else the stream carries: not the agent's text or thinking, and not what
its commands printed. No session is saved (`--no-session-persistence`),
and auto memory is off, so one trial can't carry memories into the next.
Each string is redacted, then normalized, and only then cut, so a cut
can't split a secret or a path where redaction can't find it. The tests
that cover this:
- `reads the CLI state after each tool call, before a later one clears
it`, against a stand-in launcher that writes a token to the CLI state
and deletes it;
- `redacts and normalizes a long line before cutting it`;
- `redacts the section's key before slugging it`, since the key is
public in the markers (Sol's round-1 blocker).

A real run turned up one more thing. Claude Code tells its agent which
account it is signed in as, and on a `whoami` task the agent named the
developer's real email in its answer. That run wasn't published. The
shared sanitizer now also redacts any email address outside the reserved
domains the scenarios and the seed use (`.example`, `patchy.local`), and
that covers `transcript` too. Sol's round 3 then showed the shape alone
misses encoded and unusual forms. So a trial now also collects who its
agents act as: the Claude account's email (`claude auth status --json`)
and git's `user.email`. These reach the sanitizer as known values, so
every form of them is redacted. Asked for its account email outright,
plain and URL-encoded, the agent's answer read `[redacted]` in both
forms, Ada's scenario address stayed readable, and the address appeared
nowhere in `--json` or stderr.

## How it was verified

- **Focused tests**, `pnpm exec vitest run scripts/dev` (13 files, 77
tests). The new ones cover:
- folding a stream-json fixture into the log: exit codes from `Exit code
N`, a denial from `permission_denied`, a tool error, a call that never
returned, and thinking, text and unknown lines dropped;
- how a run ended: out of turns, timed out, a failed result with
`errors`, no result;
- an answer cut to its gist, help lookups, refused tasks, and the
section's table, folded logs and after-only layout;
- a real stand-in launcher: the task on stdin, the time budget killing
it, and the sanitizer seam above;
- collecting identities from a stand-in `claude` and a temporary git
config, and redacting every form of one;
- the email shape in Sol's forms (Unicode, `%40`, quoted, apostrophe, a
`.local` host), with `[email protected]`, `@effect/[email protected]` and the
scenarios' addresses left alone.
- **Claude Code 2.1.303 probes**, on Haiku in a scratch folder, before
writing the parser:
  - the stream-json shapes;
  - sign-in with only `HOME` and `PATH`;
  - `--max-turns` ending as `error_max_turns`;
  - `--disallowedTools` beating `--allowedTools`;
  - the prompt on stdin;
- `CLAUDE_CODE_DISABLE_AUTO_MEMORY=1` dropping `memory_paths`, with
nothing written under `~/.claude/projects`.
- **Real trials** on a shared Linux machine, Sonnet. The costs are what
Claude Code reported, at API prices:

  | Run | Took | Cost | What it showed |
  | --- | --- | --- | --- |
| `brightline`, `--base 6900c71~1`, 15 turns / 5 min, the task naming
"brightline" | about 3 min from cold | $0.11 + $0.09 | works end to end.
The word "brightline" sent both agents searching the file system, and a
cut before redaction left part of a home path, so cuts now come after
redaction |
| the same at 30 turns / 10 min, `--pr 806` | about 2½ min | $0.09 +
$0.07 | published. An agent wrote the environment folder as `~/…`, so
that form is now normalized too |
| again on `ea261bb`, `--pr 806` | about 2½ min | $0.03 + $0.09 | both
sides reported the Patchy skill loaded |
| `team`, `--base c7a6d08~1` (before #701), 3 turns | about 1½ min |
$0.02 | before was "unavailable" for its launcher and never ran; after's
answer named the account email (not published), so the email shape was
added |
| the same, asking for the account email | about 1½ min | $0.02 |
`[redacted]`, from the email shape; the scenario address kept |
| `brightline`, `--pr 806` on `3258425` | about 2½ min | $0.04 + $0.06 |
after found `patchy logs` again |
| `team`, asking for the account email URL-encoded, on `5869ee9` | about
1½ min | $0.02 | both forms `[redacted]`, with `identity` and `email`
matched |
| `brightline`, `--pr 806` on `5869ee9` | about 2½ min | $0.11 + $0.11 |
after's agent missed `patchy logs` |
| `brightline`, `--pr 806` on `712bec8` | about 2½ min | $0.04 + $0.05 |
after missed it again. An earlier log showed an agent reading another
session's file in the machine's `/tmp`, so each agent now gets a temp
folder of its own (below) |
| `team`, `--base 6900c71~1`, asking each agent to use its temp folder
and then list `/tmp` | about 1½ min | $0.03 + $0.03 | both wrote and
read back a file in their own `<env>/trial-tmp`; `ls /tmp` was blocked
on both sides, the old launcher's copy included |
| `brightline`, `--pr 806` on `ebe3966` (above) | about 2½ min | $0.13 +
$0.08 | the section above: no `/tmp` in either log |

The trials came to about $1.20 at API prices, plus the interrupted
Ctrl-C run, which reported no cost; the Haiku probes were under a cent.
- **The temp folder.** The launcher adds `"${TMPDIR:-/tmp}"`, so
interactive use is unchanged. A trial sets `TMPDIR` to a scratch folder
in each side's environment folder and deletes it when the run ends. A
base whose launcher still adds `/tmp` runs as a copy with only that flag
swapped, so both sides have the same limits. Tested with a stub `claude`
and a test of the swap; the `team` run above shows it for real. The
launcher isn't a sandbox: `node`, which it pre-approves, can still read
whatever you can, and the docs say so.
- **Ctrl-C mid-run**, while both agents were working: both instances
were taken down, both agents ended, both environment folders were
deleted and the lock folder was empty. Only the reusable checkouts
stayed.
- **Leak check** of each published section and its `--json`: the home
path, the username, the developer's email, `pp_…`, the login-code shape
and local origins matched nowhere. Since the temp-folder fix, the
published logs name no path outside each side's environment folder
(`<env>`).
- **`pnpm verify --changed`** on `ebe3966`, the head: format, lint,
typecheck, synth and 2,004 tests passed. It skipped the acceptance
suites, since only the runner and docs changed.
- **Hit every surface:**
- **The dev loop:** `docs/DEVELOPMENT.md` (the command table, "Showing a
change in a PR" and "What to exercise") and the `patchy-dev-loop` skill.
The seed and the vitest template are unchanged.
- **The evidence skill:** `pr-evidence` gains a `trial` entry in its
Shows, Make, Costs and Gotchas shape, and "Not built yet" is gone.
- **The shared sanitizer:** the email shape applies to `transcript` as
well, and DEVELOPMENT's sanitizer paragraph says so.
- **Reverse states:** `trial` uses the evidence checkouts that `pnpm dev
down` deletes, and leaves no session or memory behind.
- **Doesn't apply:** the wire contract, the CLI in `packages/patchy`,
migrations, company resources, served pages, the repo layout and
vocabulary.
- **Reviewed by GPT 6.1 Sol** over eight rounds; the summaries are in
the comments.
  - round 1: 1 blocking (the section key) and 2 should-fix, all fixed;
  - round 2: no findings;
- round 3: 1 blocking (encoded and unusual email forms) and 2 should-fix
(a quadratic regex, machine identities), all fixed;
- round 4: no blocking findings, and 2 should-fix (stderr from the
identity reads, an apostrophe run still quadratic) and 1 nit (`~user`
paths), all fixed;
- rounds 5 and 6: one regression each from those regex fixes
(shell-quoted, then apostrophe-only local parts), both fixed and checked
with a differential fuzz against the earlier regexes;
- round 7: no blocking findings; one contrived nit, dismissed in
writing;
  - round 8: on the temp-folder fix, no findings.
- **Not checked:** macOS, where Claude Code keeps its login in the
keychain; signing in with `ANTHROPIC_API_KEY` or
`CLAUDE_CODE_OAUTH_TOKEN` (only the login under HOME); a real expired
login (a fixture only).
- **Done means:** shown above. A trial on #786's CLI change, through
`--base`, shows each side's attempt in the PR, and nothing in it matched
a secret.

## Release impact

Tick exactly one.

- [ ] **Breaking** — requires action from anyone already running this
- [x] **Not breaking** — dev tooling and docs; nothing ships to
production

- **What does a revert leave behind?** Trial sections already in PR
bodies. The evidence checkouts are #725's, and the older `pnpm dev down`
still deletes them. Transcript sections published from here on redact
non-example emails; a revert only stops doing that.
- **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.

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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:cli Touches the cli area area:docs Touches the docs area area:server Touches the server area area:ui Portal and first-party browser pages, shared rendering and styles size:xl Over 1,000 changed lines; review in multiple passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(patchy): agents read a published patch's log with patchy logs

1 participant