Skip to content

chore(deps): move to Effect 4.0.6 - #974

Open
allisonmahmood wants to merge 3 commits into
deps/latest-non-majorfrom
deps/effect-4.0.6
Open

allisonmahmood wants to merge 3 commits into
deps/latest-non-majorfrom
deps/effect-4.0.6

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

What changed

Dependabot's patch group #949 failed 10 checks. Its Effect 4.0.6 changes five things underneath us, and this PR moves the five Effect packages together with the fixes. One fix changes what clients see: a streamed request body over a route's cap now answers 413, the same as a declared one, instead of having its connection cut.

Stacked on #973, which carries #949's turbo, pglite and vite. Together they replace #949.

Look at

Why #949 is red. There were no flakes; the failures come from five breaks.

  1. @patchy/company-database stopped building, and lint, image, cli-smoke, release-tarball, tier2-smoke and browser all build first. SqlClient.make now requires a driver name (Effect #9222):
    src/PgliteCompanyDatabases.ts(195,44): error TS2345: … Property 'driver' is missing in type '{ acquirer: …; compiler: Compiler; spanAttributes: never[]; }' but required in type 'MakeOptions'.
    
    ConnectionTiming and the retained PGlite lease pass the driver of the client they wrap, and the retained Postgres lease passes "pg" beside PgClient.makeCompiler(). Two test clients get the same.
  2. Refusals answered 400 whatever their status. That caused most of the test-job failures: 37 in PatchesApi.test.ts alone, plus ApiGuard, SdkApi, ConnectionsApi, LookApi and the auth suites:
    AssertionError: expected 400 to equal 413
    AssertionError: expected [ 201, 400 ] to deeply equal [ 201, 403 ]
    
    HttpApiSchema.status now stores the status as a key annotation, so one schema reused at several statuses stays one OpenAPI component. refuse in packages/api/src/respond.ts read only the plain httpApiStatus annotation and fell back to 400. It now reads the status the way HttpApi does, plain annotation first. Effect's own resolver is @internal, so there is no public helper to call.
  3. docs/API.md changed: a consequence of (2) that improves the doc. RuntimeFailure and its eight copies, RuntimeFailure_1 to _8, collapse into one component (net −144 lines). Regenerated with pnpm --filter @patchy/api render-docs.
  4. A failing migration step fails with MigrationError (kind: "Failed") instead of dying (Effect #9598). migrate's callers already handle MigrationError for duplicate ids and foreign ledgers, so only the sql.test.ts assertion and a supervisor comment change.
  5. patchy list typed its requirements as any. Client methods are now generic over a streaming payload's services. An inline call inside Effect.all([...]) infers them from Effect.all's Effect<any, any, any> parameter:
    src/Discovery.ts(264,43): error TS28: This has any in the requirements channel which is not recommended.
    
    Effect.zip(a, b, { concurrent: true }) makes the same two concurrent requests and infers cleanly. Effect 4.0.7 fixes the inference upstream (NoInfer<PayloadR>).

The 413. Node servers now drain a body that passes MaxBodySize and fail the read with RequestParseError reason BodyTooLarge, where before they destroyed the socket (Effect 3934c0c). The four socket tests that expected a cut connection got a 400 instead, because readBody called every failed read malformed, and the execution management test, which allowed either, got a 400. A new isBodyTooLarge in @patchy/api lets readBody, the device login form and the OAuth token request answer a streamed overflow with the 413 they already give a declared one. The tests now send both framings and expect the same 413, including a new socket test for the token request (400 without the fix), and the API descriptions say "An oversized body answers 413, declared or streamed" where they said streamed bodies are cut off. The other capped form handlers never answered 413; an oversized streamed form now gets whatever they answer for an unreadable one, where it used to get a cut connection.

Not taken: Effect 4.0.7, which npm published at 03:36 UTC today, inside the workspace's one-day minimumReleaseAge.

How it was verified

  • On build(deps): bump the patch-updates group across 1 directory with 8 updates #949's versions before the fixes: pnpm typecheck failed on (1) and (5); the suites above failed as on CI.
  • After: pnpm typecheck 24/24 and pnpm lint clean. A targeted run of packages/auth, packages/sql, packages/api, packages/company-database, packages/integrations, PatchesApi, Server, QueryRollups, cliRepo and cliRepoBuild passes 740/740 tests in 72 files.
  • pnpm verify, first run on 8736a69: format, lint, typecheck, synth, postgres-concurrency, cli-smoke, install, tier2-smoke and browser passed. test failed on the management test above, now fixed, and six timeouts under machine load that pass when rerun alone. Second run, on aa6c0e6: all ten suites pass (2,500 unit tests, 81 browser tests). 5ffc522 after it only adds BodyTooLarge's optional cause and a comment; typecheck, lint, the api/auth/patches/serving suites and CI cover it.
  • Lockfile: pnpm install --frozen-lockfile passes, --lockfile-only changes nothing, pnpm dedupe --check is clean. The diff is the five Effect packages, @effect/platform-node-shared and undici 8.12.3 under platform-node.

Release impact

  • Breaking — requires action from anyone already running this
  • Not breaking — no action required

A dependency patch release. The one client-visible difference is a 413 response where an oversized streamed body used to get a reset connection; a client that treated the reset as failure still sees a failure, now with a reason. Every other status, body and schema is unchanged; the doc change is one shared component instead of nine copies.

  • What does a revert leave behind? Nothing: no schema, data or contract change.
  • Does the release before it still work with that? Yes.

Built by Claude Opus 5.5 (xhigh) in Claude Code on T3 Code; reviewed and accepted by GPT-6.1-Sol (xhigh).

The effect group moves together to 4.0.6. What it changed underneath us:

- SqlClient.make requires a driver name; the hand-built company clients pass
  their source's.
- HttpApiSchema.status stores the status as a key annotation, so refuse reads
  it where HttpApi does instead of answering 400. One OpenAPI component now
  serves every status of RuntimeFailure, which shrinks docs/API.md.
- A failing migration step fails with MigrationError instead of dying.
- Node servers drain a body past MaxBodySize and fail the read as
  BodyTooLarge rather than cutting the socket, so readBody, the device form
  and the OAuth token request answer a streamed overflow with the same 413
  as a declared one.
- HttpApiClient methods infer a streaming payload's services, which picks up
  any from Effect.all's parameter; patchy list uses Effect.zip (4.0.7 fixes
  the inference upstream).

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:m 100-500 changed lines labels Oct 28, 2026
- statusOf honours a present httpApiStatus annotation even when undefined,
  as HttpApi does.
- The OAuth token request gets socket coverage for a declared and a
  streamed oversized body, both 413 invalid_request.
- The management body test expects the streamed 413 that drained bodies
  now get, not a 400 or a closed connection.
- Comments on BodyTooLarge and RuntimeApi's body reader say what 4.0.6
  does: a streamed body is refused at the cap, and Node discards up to
  256 KiB of the unread rest after the response.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added size:l 501-1,000 changed lines and removed size:m 100-500 changed lines labels Oct 28, 2026
BodyTooLarge carries the HttpServerError that passed the cap, as the
service conventions ask, and is absent for a declared length refused
unread. TrustedProxies stops saying Effect's xForwardedHeaders has no
allow-list, which 4.0.6 added.

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

Copy link
Copy Markdown
Owner Author

Review: GPT-6.1-Sol (xhigh), two rounds over the stack (#973 + #974)

Round 1, on 8736a69: nothing blocking.

  • should-fix, respond.ts statusOf: ?? revived the key-annotation status when a plain httpApiStatus annotation was present but undefined; Effect's resolver checks presence. Fixed in aa6c0e6: presence check, then resolveAt<number>, as HttpApi does.
  • should-fix, the OAuth token request's streamed overflow had no socket coverage. Fixed in aa6c0e6: a NodeHttpServer.layerTest case sends a declared and a streamed oversized token request and expects 413 invalid_request. It answers 400 with the mapping reverted.
  • nit, the BodyTooLarge and RuntimeApi.forEachBodyChunk comments described pre-4.0.6 body handling. Fixed in aa6c0e6.
  • nit, chore(deps): catch up on minor and patch releases #973's description named the dropped dedupe versions ambiguously. Fixed in the description.

Also from pnpm verify run 1: Management.test.ts expected 400 or a closed connection for a streamed oversized management body, which is now 413. Fixed in aa6c0e6.

Round 2, on aa6c0e6: nothing blocking.

  • should-fix, the streamed-overflow BodyTooLarge dropped the HttpServerError it translated. Fixed in 5ffc522: optional cause, absent for a declared length refused unread.
  • nit, TrustedProxies.ts said Effect's xForwardedHeaders has no allow-list; 4.0.6 added trustedProxies. Fixed in 5ffc522: the comparison is gone, and the blanket-trust explanation stays.

The review loop stops here: round 2 found nothing blocking.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Acceptance: PASS with notes

Checked 5ffc522349db20ddb8ed62854f60807c2d1bf58a (stacked base a87434e425d5671ef03d267f5dc9549498fb0ac0, deps/latest-non-major) on fresh team and brightline instances, by GPT-6.1-Sol (xhigh) in the Codex harness on T3 Code. The PR has no linked issue; its What changed supplies the claims below. The checkout was clean at the pinned head.

Done means

  • Effect packages move together and the compatibility fixes work: passed. Frozen-lockfile install succeeded; 751 focused tests in 59 files passed on Node 26.12.1. These cover API/auth, company databases (Postgres and PGlite), SQL, patches, serving, execution, SDK and integration API refusals, query rollups and the assembled server. The head's CI also passes lint/build/typechecking, tests on Node 22/24/26, browser, live Clerk, packed CLI/tier 2 and Postgres concurrency.
  • Refusals keep their intended status and wire body: passed through those suites and independent instance requests returning 400, 401 and 413; sharing and lifecycle commands also succeed.
  • Oversized bodies answer 413 in either framing: passed on real sockets for device start, device poll, the device confirmation form and OAuth token exchange. JSON at exactly 4,096 bytes and a token form at exactly 8,192 bytes reach normal validation; malformed bounded JSON remains 400. Separate connections carrying 600,000-byte chunked bodies also receive 413. The focused socket suites check rejected requests leave their state unchanged.
  • Migration failures stay typed and atomic: passed. The SQL suite checks MigrationError with kind: "Failed", unchanged tables and the unchanged ledger after a failed batch. Fresh scenario startup also applies the full migration record successfully.
  • CLI discovery keeps working after the inference fix: passed. The installed scenario release's whoami, list and list --json succeed; JSON retains both patches and connections arrays.

Golden journeys

  • Sign in — passed. Team: the signed-out company door answers 401; Ben signs in and receives 200; sign-out returns to the door. The real Clerk journey also passes in head CI.
  • Log a machine in — passed. Team: the installed CLI prints its URL/code, Ada confirms, and whoami names the new machine. Logout removes its access.
  • Publish a page — passed. Brightline: Allison's CLI publishes a disposable page; Jordan reads its content and finds it on Home. Retire replaces it with the retired notice; restore serves the original content at the same address.
  • Share and unshare — passed. The kickoff brief changes from anonymous 401 to 200 with public, max-age=60 and no cookie, then back to company-only 401.
  • Find and open a tool — passed. Jordan's Home lists the studio tools; searching for Kudos returns one match and opens its frame.
  • Use a tier 1 tool live — passed. Jordan gives Priya kudos; the message appears on Priya's already-open wall without navigation or reload.
  • Use a tier 2 tool — passed. New Business loads sample deals; Jordan moves Verdant Grocers from Lead to Discovery, and Allison's open board updates without reload. Jordan moves it back. A direct authenticated Spend self-approval returns own_approval; a subsequent query confirms the request remains submitted.
  • Invite and join — passed. Team: Ada invites a new scenario address; it signs in, joins Acme and reaches Home. Revoking a separate pending invite and submitting deactivation/reactivation confirmation forms also succeed. Persona invitations send no mail.

Rollback answers: They match the diff. No migration record, persisted format, stored-data deletion or infrastructure changes are introduced. A revert restores the earlier dependency and HTTP behavior without leaving state the earlier release cannot read; no one-way label is needed. The head's rollback-rehearsal check is green; this diff does not change its migration/descriptor triggers.

Not run

  • Attio live: its informational CI check is still pending at verdict time; this run did not contact the probe workspace.
  • Live Clerk and Pidgeon were not repeated locally; their checks on this exact head passed in CI.

Notes

  • All completed checks inspected are green. The pending Attio result is the reason for “with notes.”
Independent local evidence
Test Files  59 passed (59)
     Tests  751 passed (751)

/api/login/device: declared and chunked overflow -> 413
/api/login/device/token: declared and chunked overflow -> 413
/login/device: declared and chunked overflow -> 413
/oauth/token: declared and chunked overflow -> 413
Exact JSON/form caps: admitted to normal validation (201/400) for both framings
Chunked bodies well beyond the drain budget: 413 reaches the client
Malformed bounded JSON: 400
CLI whoami, list and list --json: pass (4 seeded patches)
Share/unshare: anonymous 401 -> public 200 with cache headers -> company 401
Publish/Home/retire/restore: page -> retired notice -> page at the same address
Spend: direct self-approval -> own_approval; request remains submitted
Team machine login: URL/code -> Ada confirms -> whoami names machine -> logout removes access
Team membership: invite -> join -> Home; revoke, deactivate and reactivate passed

All instance data was generated from the scenarios in the acceptance checkout. No production or existing developer instance was used.

allisonmahmood added a commit that referenced this pull request Oct 30, 2026
## What changed

When an agent passed a bad flag with `--json`, `patchy` printed the
command's help to stdout before the JSON failure on stderr, so stdout
held usage text where an agent expects nothing or a result. A parse
error under `--json` now leaves stdout empty: one failure document on
stderr, exit 1. Help that is asked for still prints, with or without
`--json`.

Closes #1072

## Look at

**Where the help came from.** On a parse error, Effect 4.0.5's
`Command.runWith` logs the help doc with `Console.log`, then the errors
with `Console.error` (`showHelp` in `effect/cli/Command.ts`). An
explicit `--help` goes through the same `formatHelpDoc` + `Console.log`,
so the formatter alone can't tell the two apart. `formatErrors` has one
caller, the invalid-invocation branch, which makes it the signal.

**The fix, in `packages/patchy/src/index.ts`.** Under `--json` only:

- `formatHelpDoc` holds the help and returns an empty string. A console
wrapper skips that lone empty line.
- `formatErrors` drops the held help.
- When the run ends, any help still held is printed. That covers
`--help`, `-h`, and commands without a handler such as bare `patchy` or
`patchy auth`. The output is byte-identical to before.

Without `--json`, a command's own parse errors still print usage, then
the one line.

**Two more paths review found.**

- **A global flag's own bad value.** For example `--log-level loud` or
`--completions nope`. These fail with a raw `InvalidValue` outside
Effect's usage path, so the runtime printed an error and stack on
stdout, with or without `--json`. The entrypoint now catches that tag
and writes it through the same renderer: one line, or one document under
`--json`. It exits 1 through `Output.Failed`, which is now exported.
- **How `--json` is read before parsing.** It was
`argv.includes("--json")`. Now `jsonRequested`, beside `JsonFlag` in
`Output.ts`, reads it the way Effect does: the first `--json`,
`--json=<b>`, `-json=<b>`, `--json <b>` or `--no-json` before `--`
decides, reading past a `--no-json <b>` that Effect refuses.

**Docs.** ADR-0004's "Parse errors" bullet now states the contract
instead of the exception. `packages/patchy/README.md` says the same in
one line. The global `patchy` skill drops its "usage on stdout" warning,
since its general failure contract now covers parse errors, and
`skills-lock.json` carries the new hash.

**Later.** Effect 4.0.7 adds `CliOutput.Presenter`, which receives an
`InvalidInvocation` separately from `Help`. Once the Effect bump (#974,
then 4.0.7) lands, about ten lines of `Presenter` replace the held-help
state. The comment in `index.ts` says so.

<!-- patchy-dev:transcript:json-parse-errors -->

#### Transcript `json-parse-errors`

Before is `e778152` (where this branch left main) and after is `f1841dd`
(fix/1072-json-parse-error-stdout), both on the `team` 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.
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).

7 of 10 lines changed.

##### Under --json, a bad flag value: stdout

**Changed.** Before, exit 1 in 0.2 s; after, exit 1 in 0.2 s.

```console
$ patchy init notes --tier 7 --json 2>/dev/null
```

```diff
-DESCRIPTION
-  Create a patch repo at tier 1 by default, or tier 2 with server handlers.
-
-USAGE
-  patchy init [flags] [<dir>]
-
-ARGUMENTS
-  dir string    Directory for the new repo; defaults to the current directory (optional)
-
-FLAGS
-  --tier choice       Runtime tier for the new repo; defaults to 1 (choices: 1, 2)
-  --purpose string    What this patch is for; required for agent, --json and non-terminal calls; otherwise prompted
-
-GLOBAL FLAGS
-  --help, -h                                                          Show help information
-  --version, -v                                                       Show version information
-  --wizard                                                            Start wizard mode for a command
-  --completions <bash|zsh|fish|powershell|sh|pwsh>                    Print shell completion script (choices: bash, zsh, fish, powershell, sh, pwsh)
-  --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)
```

##### ...and stderr, with its exit code

<details><summary><code>$ patchy init notes --tier 7 --json 2&gt;&amp;1
&gt;/dev/null</code>: no change, exit 1 in 0.2 s</summary>

```console
$ patchy init notes --tier 7 --json 2>&1 >/dev/null
{"ok":false,"error":"Invalid value for flag --tier: \"7\". Expected: \"1\" | \"2\"","kind":"local"}
```

</details>

##### An unknown flag and a missing required flag: stdout

**Changed.** Before, exit 1 in 0.2 s; after, exit 1 in 0.2 s.

```console
$ patchy publish --bogus --json 2>/dev/null
```

```diff
-DESCRIPTION
-  Publish the current patch repo, or a single self-contained HTML file.
-
-USAGE
-  patchy publish [flags] [<file>]
-
-ARGUMENTS
-  file string    HTML file path (optional)
-
-FLAGS
-  --name string           Set the patch's name in its company
-  --patch string          Update an existing patch only; never creates a patch
-  --share choice          Who can open the patch: your company or anyone with the link (choices: company, public)
-  --description string    Set the description when publishing an HTML file
-  --force                 Accept the reported dependant or source breakage; ask the person first
-  --new                   Always create a new patch
-
-GLOBAL FLAGS
-  --help, -h                                                          Show help information
-  --version, -v                                                       Show version information
-  --wizard                                                            Start wizard mode for a command
-  --completions <bash|zsh|fish|powershell|sh|pwsh>                    Print shell completion script (choices: bash, zsh, fish, powershell, sh, pwsh)
-  --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)
```

**Changed.** Before, exit 1 in 0.2 s; after, exit 1 in 0.2 s.

```console
$ patchy look publish ./x --json 2>/dev/null
```

```diff
-DESCRIPTION
-  Admins: publish a look folder (look.css, LOOK.md, optional logo.svg) as the company's next revision.
-
-USAGE
-  patchy look publish [flags] <dir>
-
-ARGUMENTS
-  dir string    The look folder to publish
-
-FLAGS
-  --note string    Why this revision, such as darker green (required)
-
-GLOBAL FLAGS
-  --help, -h                                                          Show help information
-  --version, -v                                                       Show version information
-  --wizard                                                            Start wizard mode for a command
-  --completions <bash|zsh|fish|powershell|sh|pwsh>                    Print shell completion script (choices: bash, zsh, fish, powershell, sh, pwsh)
-  --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)
```

##### Effect's other spellings of the flag count too

**Changed.** Before, exit 1 in 0.2 s; after, exit 1 in 0.2 s.

```console
$ patchy init notes --tier 7 --json=true 2>/dev/null
```

```diff
-DESCRIPTION
-  Create a patch repo at tier 1 by default, or tier 2 with server handlers.
-
-USAGE
-  patchy init [flags] [<dir>]
-
-ARGUMENTS
-  dir string    Directory for the new repo; defaults to the current directory (optional)
-
-FLAGS
-  --tier choice       Runtime tier for the new repo; defaults to 1 (choices: 1, 2)
-  --purpose string    What this patch is for; required for agent, --json and non-terminal calls; otherwise prompted
-
-GLOBAL FLAGS
-  --help, -h                                                          Show help information
-  --version, -v                                                       Show version information
-  --wizard                                                            Start wizard mode for a command
-  --completions <bash|zsh|fish|powershell|sh|pwsh>                    Print shell completion script (choices: bash, zsh, fish, powershell, sh, pwsh)
-  --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)
```

**Changed.** Before, exit 1 in 0.2 s; after, exit 1 in 0.2 s.

```console
$ patchy init notes --tier 7 -json=true 2>/dev/null
```

```diff
-DESCRIPTION
-  Create a patch repo at tier 1 by default, or tier 2 with server handlers.
-
-USAGE
-  patchy init [flags] [<dir>]
-
-ARGUMENTS
-  dir string    Directory for the new repo; defaults to the current directory (optional)
-
-FLAGS
-  --tier choice       Runtime tier for the new repo; defaults to 1 (choices: 1, 2)
-  --purpose string    What this patch is for; required for agent, --json and non-terminal calls; otherwise prompted
-
-GLOBAL FLAGS
-  --help, -h                                                          Show help information
-  --version, -v                                                       Show version information
-  --wizard                                                            Start wizard mode for a command
-  --completions <bash|zsh|fish|powershell|sh|pwsh>                    Print shell completion script (choices: bash, zsh, fish, powershell, sh, pwsh)
-  --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)
```

##### A global flag's bad value, with and without --json: stdout, then
stderr

**Changed.** Before, exit 1 in 0.2 s; after, exit 1 in 0.2 s.

```console
$ patchy whoami --log-level loud --json 2>/dev/null
```

```diff
-[00:51:45.914] ERROR (#1): ~effect/cli/CliError/InvalidValue: Invalid value for flag --log-level: "loud". Expected: "all" | "trace" | "debug" | "info" | "warn" | "warning" | "error" | "fatal" | "none"
-    at file://<env>/cli/node_modules/patchy/dist/index.js:63778:73
-    at file://<env>/cli/node_modules/patchy/dist/index.js:4003:95
```

**Changed.** Before, exit 1 in 0.2 s; after, exit 1 in 0.2 s.

```console
$ patchy whoami --log-level loud 2>&1 >/dev/null
Invalid value for flag --log-level: "loud". Expected: "all" | "trace" | "debug" | "info" | "warn" | "warning" | "error" | "fatal" | "none"
```

```diff
+Invalid value for flag --log-level: "loud". Expected: "all" | "trace" | "debug" | "info" | "warn" | "warning" | "error" | "fatal" | "none"
```

##### Help asked for under --json still prints

<details><summary><code>$ patchy init --help --json | head -4</code>: no
change, exit 0 in 0.2 s</summary>

```console
$ patchy init --help --json | head -4
DESCRIPTION
  Create a patch repo at tier 1 by default, or tier 2 with server handlers.

USAGE
```

</details>

##### Without --json, usage still prints before the one-line error

<details><summary><code>$ patchy init notes --tier 7 2&gt;&amp;1 | tail
-4</code>: no change, exit 0 in 0.2 s</summary>

```console
$ patchy init notes --tier 7 2>&1 | tail -4
  --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)
Invalid value for flag --tier: "7". Expected: "1" | "2"
```

</details>

<!-- /patchy-dev:transcript:json-parse-errors -->

## How it was verified

- **The focused test.** `cli.test.ts` › help › "under --json, a parse
error is one document on stderr, and help still prints" covers:
  - a bad value, under `--json`, `--json=true` and `-json=true`
  - an unknown flag, a missing flag and a missing argument
  - `--log-level loud`

Each must have empty stdout and exactly one document line on stderr.
With `--no-json`, the text error and usage must be back, and
`--log-level loud` without `--json` must be one stderr line. `init
--help --json` and `auth --json` must print the same stdout as without
`--json`. It fails against main's `index.ts` (21 lines of help on
stdout) and passes with the fix.
- **The old assertion.** `cliRepoPublish.test.ts` asserted the old help
on stdout for `init --tier 0 --json`. It now asserts empty stdout.
- **Review.** Three GPT 6.1 Sol (xhigh) passes. Every finding is fixed
in the later commits: global flag values, the `--json=true` and
`-json=true` spellings, a refused `--no-json false` before `-json=true`,
and `catchTag` → `catchTags`.
- **Checks.** `pnpm check` format, lint, typecheck and synth pass, and
`pnpm typecheck` is 24/24. On this shared dev machine, offline CLI
stub-server tests failed in a rotating set from the host's stray `GET /`
probes. Each either passes when run alone or fails the same way with
main's `index.ts`. CI decides.

## Release impact

- [ ] **Breaking** — requires action from anyone already running this
- [x] **Not breaking** — no action required

Under `--json`, a parse error's stdout loses the help text that nothing
read as a result. Without `--json`, a global flag's bad value is one
stderr line instead of a stack on stdout. Exit codes are unchanged.

- **What does a revert leave behind?** Nothing: no schema, data or wire
change.
- **Does the release before it still work with that?** Yes.

Built by Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, through T3
Code.

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

No deployments
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:l 501-1,000 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant