Skip to content

perf(decode): skip strings a word at a time and allocate slices once - #158

Merged
ThomasK33 merged 64 commits into
mainfrom
perf/scan-and-slices
Nov 21, 2026
Merged

ThomasK33 merged 64 commits into
mainfrom
perf/scan-and-slices

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Why

Part of #125 (Decoding item 3). After #156 the fast decoders spent most of their time in the scanner skipping strings byte by byte, and every decoded slice grew by doubling. This is the last step of the hill-climb on the recorded traffic of #148; with it the stack reads that traffic 75.8% faster than main with 83.5% fewer allocations.

What changed

  • jsonscan.go: skipString finds the next quote a word at a time (the first 16 bytes) and with bytes.IndexByte after that, and counts the backslashes before it. Same results as the byte loop on every input, JSON or not.
  • decode_fast.go: fastSlice and fastItems keep the items' spans in a 64-slot stack buffer and allocate the slice once at its length. Values equal; capacity may differ, as it already could.
  • decode_fast_test.go: the leaf fuzz comparator allows whitespace between a key and its colon ({"" :"","" :{}} failed it although Meta rightly declines the repeated key).

Blast Radius

Every fast decode. No API change.

Verification

  • BenchmarkInbound/corpus against fix(decode)!: reject an object that repeats one of its properties #157: CPU 21.6 ms to 19.0 ms (-12.1%, p=0.000, 10 runs), allocs -2.3%; stream bursts -4%, pipe inbound -11.5%.
  • The whole stack against main (12 alternating runs, -cpu 1): CPU median 78.1 ms (range 76.9 to 85.1) to 18.9 ms (18.7 to 19.3), -75.8%; allocs 307.7k to 50.7k, -83.5%; pipe pair 14.2k to 29.9k msgs/s, inbound 21.2k to 93.9k. Every corpus message decodes as on main. Runs, the limiter and the hill-climb log.
  • TestJSONScan_Corpus and the byte-loop reference test at every offset; FuzzJSONScan 2.29M execs; FuzzFastDecode_Slices and the message fuzz target 4.37M execs; FuzzFastDecode_Leaves 60 s.
  • make check, make test, go test -race ./...: pass. G2 failures.txt equal to main. rust-diff: RUST PASS (73 cases). G3: 15 of 15.

Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: xhigh

The benchmarks read a corpus of real traffic the way a Connection reads
what its peer sends: the scenario fixtures of the Claude and Codex
adapters (pinned commits, Apache-2.0, converted to acpwire transcript
lines by internal/benchcorpus), the G3 journeys, and the G2 transcripts.

- BenchmarkInbound/corpus: every message once per op.
- BenchmarkInboundStream: the agent_message_chunk and tool_call_update
  bursts.
- BenchmarkConnectionPipe: session/update notifications through a
  Connection pair over io.Pipe, and through the client side alone.

scripts/bench (make bench BASE=<commit>) builds both sides with the same
benchmark file and corpus, checks that both decode every message to the
same outcome (TestInboundCorpus), alternates the runs and prints
benchstat. It is not part of make test.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
On a shared machine the wall time of a run grows while other processes
hold the CPU. The process's user and system time does not, so the
benchmarks also report cpu-ns/op (Unix only).

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
The Rust SDK reads an integer of format uint64 as a u64, int32 as an i32,
and so on. These tests pin that range at both ends, with a recorded
Claude session (claude-g5-1.jsonl) and with the outcomes that the
rust-diff probe recorded for agent-client-protocol-schema 1.18.0.

On main 13 rows of TestIntegers_ReadTheRangeOfTheirFormat and
TestClientSideConnection_ReadsAUint64AboveMaxInt64 fail: a uint64 above
2^63-1 fails to decode or reads as absent, an ErrorCode outside int32
decodes, -0 decodes as 0, and a uint32 out of range in
StringPropertySchema or a uint16 out of range in a result decodes.

The ten control/integer-* rust-diff cases hold the same values.

Part of #141 (items 7 and 8)

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
Since #120 an integer of format uint32 or uint64 was an int64, and one
of format int32 or uint16 an int, and #138 checked each format's range
in Validate and in the lenient shapes. An int64 cannot hold a uint64
above 2^63-1, so a usage_update or a token count that Rust reads failed
to decode, and the range lived in two places that each site had to
reach: responses, the Other variant of ErrorCode and an optional
integer that cannot be null had none.

integerType now gives each format the Go type of the Rust type that it
names (formatTypes): int32, int64, uint16, uint32, uint64, and int
without a format. encoding/json fails a value out of that range, as
serde_json does, at every site and in every direction, so Validate and
the shapes keep only a minimum or maximum that is narrower than the Go
type (ownRange). No schema from 1.18.0 through 1.33.0 has one, so the
generated Validate methods lose every range check, and the six lenient
decoders that checked a shape only for the range no longer do.

shape.go reads a uint64 above math.MaxInt64 as within a range that has
no upper bound. The examples and the verification harness clamp the
uint32 line and limit through uint64, and MIGRATION_v0.21.md lists each
field that changes type, with before and after code.

Part of #141 (items 7 and 8)

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
An optional integer whose schema does not allow null is not a pointer,
so an absent member reads as 0. Its Go type holds the range of its
format, so a value out of it fails to decode, but checkPlan gives the
field no minimum or maximum check. No integer of schema 1.18.0 through
1.33.0 has this form, so a synthetic schema stands for one.

On the parent commit the four rows with a bound fail: level 11, offset
-6 and 6 pass Validate, and so does a value built with level 11.

Part of #141 (item 7)

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
checkPlan skipped every optional member whose Go type is not a
pointer, because an absent one reads as its zero value. For a struct or
union that stays right: a zero value cannot say whether it was sent. An
integer can: 0 is the value an absent member reads as, so Validate now
checks the minimum and maximum of such an integer when it is not 0,
through a nonZero container of the eachHeld walker. An explicit 0
outside the bounds passes as absent, as encoding/json cannot tell the
two apart. The range of the integer's format needs no check since the
parent commit: its Go type holds it.

No schema from 1.18.0 through 1.33.0 has such an integer, so the
generated code does not change.

Part of #141 (item 7)

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
- scripts/bench stops when the two sides decode a message differently,
  unless ALLOW_OUTCOME_DIFF=1, because they would not time the same work.
- It truncates base.txt and head.txt before the first run, so a reused
  BENCH_OUT does not mix samples of an earlier run.
- The G2 transcripts are optional for the corpus: the module the Go proxy
  serves leaves out .agents (a module of its own), and TestInboundCorpus
  must pass there. The corpus digest still tells the corpora apart.
- internal/benchcorpus writes a fixture only under a local file name.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
The generated decoders call encoding/json again on each nested value, so
the bytes of a deep message are scanned once per level. jsonscan.go reads
the members of an object and the items of an array, and skips a value,
without decoding it or allocating. It expects JSON that encoding/json
accepts and never panics or loops on other input.

TestJSONScan_Corpus and FuzzJSONScan compare it with json.Decoder.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
shapeID.accepts decoded every hinted value again into an any (maps,
slices, strings) and walked the result with fits. On the inbound
benchmark corpus that is 80823 allocations of BenchmarkInbound/corpus.

accepts now walks the raw JSON with the scanner in jsonscan.go: scan
checks the same rules as fits on the bytes and returns yes, no, or
unknown. The rules of a shape combine as the least verdict, anyOf as
the greatest, and not swaps yes and no. When scan cannot tell,
accepts decodes as before (acceptsDecoded, which the tests also use as
the reference). scan cannot tell for a string that a values rule
compares when it holds an escape or bytes that are not UTF-8, for an
object key that does, for an object with more than 16 members, and
past 1000 levels of value and shape. Of duplicate keys it checks only
the last, which encoding/json keeps.

Every one of the 3756 hinted values that the corpus decodes is a
value in its messages, and scan decides all of them without
allocating. shape_test.go checks scan and accepts against fits for
every value in every corpus message and every shape, for seeds on the
edges above, and in FuzzShapeScan.
Each generated union UnmarshalJSON decoded its input into a
map[string]json.RawMessage only to read the discriminator or the keys
that pick a variant, and then decoded the input again into the variant.
It now calls readUnionObject (union.go), which scans the object with the
memberIter of jsonscan.go: no map, no copied values, no validation pass.
get looks a key up with last-wins, tag reads a plain ASCII
discriminator without json.Unmarshal.

The scan does not validate. A variant decodes only valid JSON, so input
that is not JSON reaches the end of the decoder, where unionError returns
the syntax error that the map decode used to return first. An escaped
key or an object the scanner cannot read falls back to the map decode.
The dead []map decode of the array step is now emitted only for unions
with array variants matched by item keys.

stablecheck treats unionObject.get and tag as side-effect free, so that
a union that gains a discriminator still passes as an addition.
TestUnionObject_DecodesLikeAMap and FuzzUnionObject compare every union
against the map path (unionsByMap) on the corpus values, changed copies
of them, and fuzzed input: same variant, value, encoding, and error.
The generated dispatcher decoded each request's and notification's params
with json.Unmarshal, and SendRequest did the same for a response's result.
Every one of those types has an UnmarshalJSON method. For such a type
json.Unmarshal validates the input, scans the value again to find its end,
and only then calls UnmarshalJSON with the value without the whitespace
around it. It adds no context to that error at the top level.

decodeJSON (decode.go) does the same in one pass. It validates the input
with json.Valid, which uses a pooled scanner, trims the whitespace, and
calls UnmarshalJSON. Input that is not one JSON value (empty, trailing
data, a syntax error) goes to json.Unmarshal, which returns its exact
error and leaves the value as it is. So does a type without UnmarshalJSON.
Per call this saves the second scan and four allocations: the escaping
decodeState and the growth of its scanner's stack.

TestDecodeJSON_MatchesUnmarshal, TestDecodeJSON_Corpus and FuzzDecodeJSON
compare decodeJSON with json.Unmarshal on edge cases, on every corpus
params and result, and on fuzzed input. They check a struct with
UnmarshalJSON, unions, a plain struct and json.RawMessage, fresh and
already holding data, for the same error (deeply equal) and value.
Every generated UnmarshalJSON called json.Unmarshal on its own input, and
each nested type, union variant, and lenient field did it again on its
part, so a byte at depth d was validated and decoded about 4d times.

Each generated type now has an unexported decodeFast, emitted into
decode_fast_gen.go by cmd/generate/internal/emit/fast.go. It walks the
object's members once with the scanner of jsonscan.go, decodes each value
straight into its field with the helpers of decode_fast.go, and calls the
decodeFast of the types it holds. UnmarshalJSON runs it first (tryFast):
only on a zero value, for valid JSON without whitespace around it. When
decodeFast returns true, the exact decoder, which is unchanged, would
return nil with the identical value; on false it runs as before, so every
error comes from it. A fast decoder declines a repeated key, an escaped or
non-ASCII key, a key that matches a field only in another case, and any
value that does not decode.

Custom-decoded fields, required members, defaults and additionalProperties
follow decodeStmt and emitRequireMembers on the member spans that the walk
keeps. Unions select a variant with readUnionObject and the predicates of
emitUnion, and decode it with fastOrExact, whose answer is exact, so a
variant that fails passes the turn to the next as before. With
GOEXPERIMENT=jsonv2 the fast path is off.

Tests compare the fast path with the exact one (fastDecode off): every
corpus message, every corpus value decoded into a reused value, seeds
against all 355 types, and fuzz targets for messages, types and leaves.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
decodeJSON checked its input with json.Valid, whose scanner makes an
indirect call per byte. validJSON is a recursive-descent validator that
returns exactly what json.Valid returns: the same number grammar, string
escapes, control characters invalid, invalid UTF-8 valid, whitespace
rules and the 10000-level nesting limit. Strings are most of the bytes
of ACP traffic, so it finds the next quote, backslash or control
character eight bytes at a time with a zero-byte bit test.

Over every message of the inbound corpus validJSON takes 612 us per pass
and json.Valid 3458 us (median of 6, -cpu 1), with no allocations.
FuzzValidJSON compares the two on arbitrary bytes.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
tryFast checked its input with json.Valid before running a fast decoder.
validJSON returns the same answer (FuzzValidJSON) about 5.6 times faster.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
tryFast in decode_fast.go now calls validJSON, so the package that
TestWriteTypesJen_* builds from the generated code needs validjson.go
next to decode_fast.go.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
The Rust SDK fails an object that holds one of its struct's fields
twice ("duplicate field"), and the Go SDK keeps the last value (#141).
These tests pin the Rust behavior: a repeated property fails the decode
with a *json.UnmarshalTypeError that names the struct, the property
and the field's type; a union whose variant repeats a property selects
no variant; a lenient property reads such a value as its default; an
inbound request gets -32602 without a handler call, a notification is
dropped and logged, and a result fails the call with -32603. Members
that are no property, keys of a map and the discriminator of a
catch-all variant keep the last value, as in Rust.

The fast decoders get seeds with repeated members, so that the fast and
the exact decoders must agree on them, and the Rust probe gets the
dup/... cases: rust-diff fails on them until the fix.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
Every generated UnmarshalJSON now checks, in its exact path and after
encoding/json has decoded b, that the object holds each property of
its struct at most once (rejectDuplicateMembers in duplicate.go). A key
counts by its name without escapes. A repeat fails with a
*json.UnmarshalTypeError, as a missing member does:

  json: cannot unmarshal duplicate member into Go struct field
  SessionNotification.sessionId of type acp.SessionId

So a request that repeats a property gets -32602, a notification is
dropped and logged, and a result fails the call with -32603, as the
Rust SDK fails "duplicate field" (#141). Unions reject through their
variant structs, which hold the discriminator; lenient properties read
such a value as their default. A member that is no property, a key of
a map, and the discriminator of a catch-all variant, which the Rust
SDK reads into a map, still keep the last value.

The fast decoders are unchanged: they already decline a key that
repeats, so a repeat always reaches the exact path.

Generator: ElicitationAcceptAction, the one struct with a property and
no UnmarshalJSON, gets one. stablecheck keeps a stable property's name
in a call's arguments when a nested type of the merged run adds a
field with that name, and the range test of the emitter no longer
repeats a member to override it.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
skipString stepped through a string one byte at a time and switched on
each byte. The fast decoders skip every nested value once per object
level, so this loop was the largest share of their CPU time.

It now looks for the next quote and then counts the backslashes right
before it: the quote ends the string when that run is even. It reads
the first two 8-byte words itself, because most strings in ACP traffic
are under 16 bytes, and calls bytes.IndexByte for the rest. It returns
what the byte loop returned on every input, JSON or not.

The tests keep the byte loop as a reference and compare skipString and
skipValue with it at every offset of each corpus message, seed and fuzz
input. New seeds put escapes and backslash runs at every byte of the
words skipString reads. BenchmarkSkipValue skips every corpus value and
every value nested in one.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
fastSlice and fastItems (and so fastLenientItems and the patch variants)
grew their slice by append from empty, so a slice of n items was
allocated about log2(n)+1 times and copied each time. They now collect
the items' bytes first, in a 64-entry buffer on the stack (append moves
it to the heap past 64), then make the slice at its length and decode
each item in place. The scan does the same work as before: the iterator
already finds each item's end once, and the items are read from the
buffer instead of the iterator. fastItems decodes into the next free
place and keeps kept[:n]; fastLenient leaves its place zero on false,
which its comment now says.

Outcomes are unchanged: [] is an empty non-nil slice, null is nil, a
dropped lenient item leaves no gap, a decline returns before *dst is
written. Capacity now equals decodeItems' (the item count).

TestFastDecode_Slices and FuzzFastDecode_Slices compare fastItems with
decodeItems and fastSlice with json.Unmarshal on edge cases, arrays past
the buffer, and every array of the corpus. BenchmarkFastSlices reads the
corpus arrays of the seven element types the corpus reads most.

BenchmarkInbound/corpus: 51858 -> 50683 allocs/op, 4062 -> 3831 kB/op.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
FuzzFastDecode_Leaves requires that a leaf decoder declines only where
json.Unmarshal fails, except for values with an object key, which a map
decoder declines when the key repeats. It recognized a key by the bytes
'":' and so failed on {"" :"","" :{}}: Meta declines the repeated key, as
it should. The check now allows whitespace between the key and its colon.
The input is kept as a seed.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
@ThomasK33

Copy link
Copy Markdown
Member Author

Evidence: the whole stack against main, the limiter, and the hill-climb log

Final: this branch (e9498fd) against main (50da019, the harness of #148)

RUNS=12 scripts/bench 50da019: 12 runs per side, alternating, -cpu 1, Go 1.26.3, AMD EPYC 9454P, load average 5 to 10. "outcomes: every message decodes as on base" (1543 messages, 60 rejected on both sides: extension and unknown methods, and the G3 error journeys).

BenchmarkInbound/corpus CPU per op: main median 78.11 ms (min 76.87, max 85.11), head 18.94 ms (min 18.74, max 19.29).

                                  │  cpu-sec/op  │ cpu-sec/op   vs base                │
Inbound/corpus                       78.11m ± 1%   18.94m ± 1%  -75.75% (p=0.000 n=12)
InboundStream/agent_message_chunk   2620.8µ ± 2%   740.5µ ± 0%  -71.75% (p=0.000 n=12)
InboundStream/tool_call_update       5.434m ± 2%   1.534m ± 1%  -71.78% (p=0.000 n=12)
ConnectionPipe/pair                  66.12m ± 3%   31.40m ± 2%  -52.52% (p=0.000 n=12)
ConnectionPipe/inbound              44.251m ± 2%   9.987m ± 0%  -77.43% (p=0.000 n=12)
geomean                              20.07m        5.832m       -70.94%
                                  │  allocs/op   │  allocs/op   vs base                │
Inbound/corpus                      307.75k ± 0%   50.68k ± 0%  -83.53% (p=0.000 n=12)
InboundStream/agent_message_chunk   15.899k ± 0%   3.539k ± 0%  -77.74% (p=0.000 n=12)
InboundStream/tool_call_update      27.536k ± 0%   6.116k ± 0%  -77.79% (p=0.000 n=12)
ConnectionPipe/pair                 231.93k ± 0%   90.21k ± 0%  -61.10% (p=0.000 n=12)
ConnectionPipe/inbound              174.04k ± 0%   29.23k ± 0%  -83.21% (p=0.000 n=12)
geomean                              88.53k        19.60k       -77.86%
                                  │     B/op      │     B/op      vs base                │
Inbound/corpus                      21.017Mi ± 0%   3.586Mi ± 0%  -82.94% (p=0.000 n=12)
InboundStream/agent_message_chunk    838.7Ki ± 0%   202.6Ki ± 0%  -75.84% (p=0.000 n=12)
InboundStream/tool_call_update      1837.4Ki ± 0%   440.0Ki ± 0%  -76.06% (p=0.000 n=12)
ConnectionPipe/pair                 18.869Mi ± 0%   8.194Mi ± 0%  -56.58% (p=0.000 n=12)
ConnectionPipe/inbound              12.967Mi ± 0%   2.302Mi ± 0%  -82.25% (p=0.000 n=12)
geomean                              5.966Mi        1.419Mi       -76.22%
                       │   msgs/s    │   msgs/s     vs base                 │
ConnectionPipe/pair      14.17k ± 3%   29.86k ± 2%  +110.79% (p=0.000 n=12)
ConnectionPipe/inbound   21.16k ± 2%   93.86k ± 0%  +343.47% (p=0.000 n=12)
geomean                  17.32k        52.94k       +205.74%

Stop predicate

Target: at least 40% better than main on the primary metric (total time and allocations of BenchmarkInbound/corpus, median of at least 10 runs), at least 10 iterations, BenchmarkInboundStream and BenchmarkConnectionPipe no worse. Met: -75.8% CPU, -83.5% allocs, 10 iterations (7 kept, 3 reverted), stream -72%, pipe pair -52.5% CPU per op (+111% msgs/s), pipe inbound -77.4% (+343% msgs/s).

Limiter

CPU profile of this branch (4 s, not a reported run): encoding/json.checkValid 23% and (*decodeState).skip 17% cumulative. That is encoding/json scanning the JSON-RPC envelope (json.Unmarshal into anyMessage, as connection.go reads each line) and decoding results the way SendRequest did on main; the benchmark mirrors both and this stack does not change them (SendRequest itself now uses decodeJSON, so the benchmark is conservative there). The fast decoders' own scanner is next (memberIter.next 19%, skipValue 14%), then the shape checks (8%) and allocation (8%).

Hill-climb log (decision.tsv)

Each row is one hypothesis, measured with scripts/bench <previous head> (10 alternating runs, -cpu 1, CPU time per op) and kept only when the primary metric moved past noise with every gate green. Commits are named as on the working branch; the PRs carry the same changes.

id	hypothesis	change	before	after	delta	tests	verdict	note
0	baseline (main 6c4769e + harness)	none	-	82.75ms cpu, 82.74ms wall, 307.7k allocs, 21.0MiB	-	A/A: no sig. diff (p>=0.48)	baseline	sensitivity: accepts-off -16% cpu/-26% allocs; double decodeField +50%/+83%
H2	Do not decode hinted values into any: check shapes on raw bytes	shape.go scan() over jsonscan iterators, fallback to decode (ca292b3)	77.07ms cpu, 307.7k allocs, 21.02MiB	71.00ms cpu, 226.9k allocs, 13.80MiB	-7.9% cpu (p=0.000), -26.3% allocs, -34.3% B	outcomes identical; G2 failures equal; go test ok; differential 2.5M pairs + fuzz 1.16M	kept	chunk +5.3% cpu on untouched path = A/A layout bias; pipe inbound +7.6% msgs/s
H1	Do not decode a union into a map to choose its variant	union.go readUnionObject scans members in place; emitter + stablecheck inert calls (1e00406)	69.81ms cpu, 226.9k allocs, 13.80MiB	61.98ms cpu, 177.3k allocs, 11.03MiB	-11.2% cpu (p=0.000), -21.9% allocs; chunk -25%, tcu -21%	outcomes identical; G2 equal; gen tests ok; fuzz 3.7M execs	kept	pipe pair +13%, inbound +20% msgs/s; profile: checkValid now 42% (limiter)
H5	Do not validate and skip params twice: call UnmarshalJSON directly after one json.Valid	decode.go decodeJSON in dispatcher + SendRequest result (f0d4b9c)	68.51ms cpu, 177.3k allocs	66.57ms cpu, 172.7k allocs	-2.8% cpu (p=0.089, n.s.), -2.6% allocs (exact); chunk -8.3% (p=0.002), tcu -6.4% (p=0.015)	outcomes identical; G2 equal; race ok; fuzz 370k	kept	kept on allocs (part of primary) + stream gains; corpus time within noise
H3	Do not scan a value again at every level: generated decodeFast per type, exact decoder as fallback	emit/fast.go + decode_fast.go + decode_fast_gen.go; tryFast in each UnmarshalJSON (21cdc0b)	66.34ms cpu, 172.7k allocs, 10.80MiB	29.75ms cpu, 51.86k allocs, 3.82MiB	-55.2% cpu (p=0.000), -70.0% allocs, -64.6% B	outcomes identical; G2 equal; race ok; gen clean; fuzz 8.4M execs; 0/1543 fallbacks	kept	pipe pair +68%, inbound +141% msgs/s; cumulative vs main -64% cpu, -83% allocs
H7	Validate cheaper: hand-written validJSON (== json.Valid) in decodeJSON and tryFast	validjson.go + decode.go (d573754) + tryFast (a2eceac)	26.67ms cpu, 51.86k allocs	21.51ms cpu, 51.86k allocs	-19.3% cpu (p=0.000)	outcomes identical; G2 equal; FuzzValidJSON 35M execs; 117-case table	kept	validJSON 612us vs json.Valid 3458us per corpus pass (5.65x)
H8	Do not validate params twice: decodeJSON runs decodeFast itself	decode.go (25d8c2e)	22.79ms cpu, 51.86k allocs	22.20ms cpu, 51.88k allocs	-2.6% cpu (p=0.353, n.s.), +17 allocs	outcomes identical; G2 equal; fuzz 744k	reverted	after H7 the second validation costs ~3% (validJSON 0.6ms/pass), below noise; reverted by 87418f1
H9	Skip strings faster: find quotes a word at a time (SWAR) + IndexByte, count backslashes	jsonscan.go skipString (4b8ee43)	22.35ms cpu, 51.86k allocs	20.18ms cpu, 51.86k allocs	-9.7% cpu (p=0.000)	outcomes identical; G2 equal; FuzzJSONScan 2.29M; byte-loop reference test	kept	BenchmarkSkipValue 4793->2232us (-53%); pipe inbound -8.6% cpu
H10	Read a union object once: record selection keys during readUnionObject	union.go + emit/fast.go + stablecheck (e7f20e3)	19.58ms cpu	19.24ms cpu	-1.7% cpu (p=0.280, n.s.); chunk -3.8%, tcu -3.1% (p<0.01)	outcomes identical; G2 equal; fuzz 6.9M	reverted	primary within noise; touched another owner module (stablecheck) and grew unionObject 200B; stream gain 3-4% noted
H12	Check a hinted value shape in one walk: read object members once for shape+ref+anyOf+not	shape.go scanObject/check (392f741)	19.04ms cpu	18.71ms cpu	-1.7% cpu (p=0.143, n.s.)	outcomes identical; G2 equal; FuzzShapeScan 5.1M	reverted	micro-bench of accepts -16.5% but accepts is ~7% of a pass, so ~1% expected: below noise
H11	Allocate each decoded slice once at its length (64-slot stack buffer of item spans)	decode_fast.go fastSlice/fastItems (c815d95)	18.88ms cpu, 51.86k allocs, 3.81MiB	18.96ms cpu, 50.68k allocs, 3.59MiB	cpu n.s. (p=0.436); -2.3% allocs, -5.8% B (p=0.000)	outcomes identical; G2 equal; fuzz 4.37M + slices fuzz	kept	kept on allocs (part of primary); pipe pair/inbound -1.2%/-1.1% cpu (p<0.02)

Stack: #148 harness, #155 (H2 H1 H5), #156 (H3 H7), #157 duplicate members, this PR (H9 H11).

Best next idea: decoders that return where their value ends, so an object level no longer skips its members' bytes before decoding them (the 33% in memberIter.next and skipValue), and reading the JSON-RPC envelope with the same scanner in connection.go.


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: xhigh

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T16:53:09.754701Z 75310bb Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: e9498fd4e9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ThomasK33

Copy link
Copy Markdown
Member Author

Independent verification of the stack's performance numbers (main 6c4769e → e9498fd): PASS+NOTES

Every claimed number reproduces to within about 2%. Allocation counts match exactly. The H3 and H7 spot checks reproduce. Benchmarks outside the corpus show no regression. Note: the benchmark understates the gain, because it still decodes results the way main's SendRequest did.

BenchmarkInbound and friends, -cpu 1, 12 alternating runs claimed measured (RUNS=12 make bench BASE=6c4769e)
corpus CPU per pass 78.11 → 18.94 ms (−75.8%) 78.03 → 19.06 ms (−75.58%, p=0.000)
corpus allocs 307.7k → 50.7k (−83.5%) 307.75k → 50.68k (−83.53%)
corpus B/op 21.0 MiB → 3.59 MiB 21.017 → 3.588 MiB (−82.93%)
stream agent_message_chunk / tool_call_update CPU −71.75% / −71.78% −71.23% / −71.49%
pipe pair msgs/s 14.17k → 29.86k 14.25k → 29.76k (+108.8%)
pipe inbound msgs/s 21.16k → 93.86k 21.50k → 93.75k (+336.1%)
outcomes 1543 messages identical, 60 rejected on both sides the same

An out-of-process check agrees: child wait4 rusage, (cpu(101 ops) − cpu(1 op)) / 100, 10 alternating runs, gave main 79.76 ms and head 19.60 ms per pass (−75.4%).

Noise floor (same decoder code on both sides, 12 runs each): A/A at #158 had no significant difference on any benchmark. Corpus CPU varied ±7%/±2% and medians differed by 0.4%. A/A on main (6c4769e vs 50da019) had none either: corpus CPU ±3%/±2%, ConnectionPipe/pair wall up to ±99% against CPU ±22%. The −75% effect is about 10× the worst A/A interval.

Notes

  1. The benchmark understates the head by 12%. resultOf decodes results with json.Unmarshal, while SendRequest uses decodeJSON since perf(decode): read union members and hinted values without decoding them again #155 (owner's note). Switching only that line to decodeJSON (outcomes identical, 10 alternating runs) took the corpus from 19.27 to 16.94 ms CPU (−12.1%, p=0.000) and allocs from 50.68k to 49.36k. What the connection really does is therefore about −78% against main, not −75.8%. Calling one shared helper would keep the benchmark in step with SendRequest.
  2. The msgs/s figures are wall-time based. They matched the claim in a calm window (load 3 to 14). Under load ~48 they spread ±86%. The matching cpu-sec/op figures (pair −52.1%, inbound −77.1%) are the steadier evidence.
Spot checks of decision.tsv (PR commits, RUNS=10 scripts/bench <before>)
row before → after claimed measured
H3 fast decoders f0d4b9c → ea4bf7a 66.34 → 29.75 ms (−55.2%), 172.7k → 51.86k allocs 61.27 → 26.18 ms (−57.27%, p=0.000), 172.65k → 51.86k allocs (load ~10). A run at load ~48 gave 77.65 → 32.71 ms (−57.87%).
H7 validJSON ea4bf7a → 41d1177 26.67 → 21.51 ms (−19.3%), allocs unchanged 27.83 → 22.44 ms (−19.34%, p=0.000), allocs unchanged (load ~24 to 48)

Both kept iterations reproduce in direction and size. Both runs printed "outcomes: every message decodes as on base". Absolute numbers move with host load (+27% for the same commit at load 48 vs 10). Deltas within one alternating run do not.

Benchmarks outside the corpus (main vs e9498fd, 10 alternating runs, -cpu 1)

The only benchmark that exists on both sides is BenchmarkUnmarshalJSON_HintedValues. I added a verifier-only file, not committed, with encode benchmarks (json.Marshal of the corpus's 935 session notifications, and of a PromptRequest) and plain round trips (ClientSideConnection.Prompt and NewSession against an AgentSideConnection over io.Pipe).

benchmark main head delta
HintedValues/session/new_response 276.1 µs 53.5 µs −80.6%
HintedValues/initialize_response 75.3 µs 16.7 µs −77.9%
HintedValues/tool_call_update 44.8 µs 9.4 µs −79.1%
HintedValues/session_list 133.8 µs 30.0 µs −77.6%
HintedValues/plan 51.6 µs 10.3 µs −80.1%
HintedValues/agent_message_chunk 10.5 µs 2.4 µs −77.2%
Encode/session_notifications (CPU) 20.68 ms 20.49 ms ~ (p=0.28), allocs equal
Encode/prompt_request (CPU) 6.59 µs 6.39 µs ~ (p=0.33), allocs equal
RoundTrip/prompt (CPU) 31.50 µs 17.74 µs −43.7%, allocs 150 → 107
RoundTrip/new_session (CPU) 23.55 µs 13.93 µs −40.8%, allocs 103 → 77

Encoding is unchanged, and every decode path got faster. I found no regression.

Gates and setup
  • At e9498fd, make check and make test passed (10 packages ok). The worktree stayed clean.
  • Go 1.26.3, GOTOOLCHAIN=local, AMD EPYC 9454P, one shared host. Another verifier was fuzzing at the same time (load 3 to 48 during my runs), so every comparison uses cpu-sec/op from alternating runs. Wall time is shown only where noted.
  • I did not check decoder correctness beyond the benchmark's outcome comparison. Another verifier covers that.

Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

A union drops an untitled alternative that is a string, a const, an
enum, a number, a boolean or an array, under anyOf and oneOf, so such a
value does not decode. Under oneOf, the constructor of a titled string
alternative, or of a $ref to a string type, builds a composite literal
that does not compile, and a oneOf of consts beside an open string
becomes a union instead of an open enum.

These tests generate one union per kind of alternative under both
keywords, plus the real unions ElicitationContentValue and
SessionConfigSelectOptions of schema 1.32.0 with and without titles,
and round-trip their G2 transcript values. They fail on main.

Part of #141 (item 4)

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
fieldCheckFor returned for a lenient field before mustHoldDefault ran,
so a default outside its bounds or format still reached setDefault
(Codex r4645610192). Run the check first.

load reads a default as a float64, so a default of 2^53 or beyond may
be rounded, and planFor would write the rounded fallback (Codex
r4645610179). Stop with a message that says so instead of the range
error that the rounded value gives. Keeping the exact text would need
load to decode numbers as json.Number everywhere, for a form that no
schema has.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
fieldCheckFor returns for a const property before mustHoldDefault runs
(Codex r4645713059). Expect the panic for it too.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
fieldCheckFor returns early for a const property, so mustHoldDefault
missed a const integer's default (Codex r4645713059), as it had missed
a lenient one. planFor handles every default, before it writes the
fallback that setDefault decodes, so check the default there and drop
the call from fieldCheckFor.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
{"const": "a", "allOf": [{"$ref": "#/$defs/Label"}]} is a $ref
alternative (variantRef), and its const is dropped: the union takes
every Label, and its oneOf constructor takes any Label. On main the
old scalarConstOf checked it.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
variantRef reads {"const": "a", "allOf": [{"$ref": ...}]} as a $ref
alternative, and values returned none for it, so the union took every
value of the $ref type. unionAlternatives now records the values an
alternative names (named) and the schema of its Go type (value) for a
$ref alternative with its own const too, and values checks both kinds.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
mustHoldDefault returns for a default that load did not read as a
float64, so "default": "5" or true on an integer passes generation and
setDefault leaves 0 (Codex r4645771578). Expect the panic for both.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
mustHoldDefault skipped a default that load did not read as a float64,
so "default": "5" or true on an integer generated a fallback that
setDefault failed to decode, leaving 0 (Codex r4645771578). Panic on
it. planFor passes only a field that holds the integer itself or
through a pointer, because the default of an array or a map of
integers is not an integer; null never reaches it.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
Arithmetic among changed fields compiles and can now wrap (Size - Used),
so the compiler does not report each use of a changed field. A code above
MaxInt32 in RequestError reads fine on a 64-bit platform; only Rust and a
32-bit SDK fail. The signed -0 list gains IntegerPropertySchema.maximum and
.default.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
A const beside a $ref to {"enum": ["a", "b"]} stops generation, though
main generated it. A number const on a $ref to an integer enum, whose Go
type is a string type, generates code that go vet rejects.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
The own const of a $ref alternative was checked against the JSON type of
the $defs entry. An entry with an enum is a Go string type whatever its
JSON type (jenTypeFor), so a string const on an untyped enum now builds,
and a number const on an integer enum fails generation instead of vet.
An entry with no JSON type gets its own panic message.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
ErrorCodeOther(70000) stays 70000: it wraps only past int32, so the 4464
example names ProtocolVersion alone. The Rust SDK leaves a -0
IntegerPropertySchema.default unset, as with ResourceLink.size, rather than
rejecting it.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
A uint32 minimum above its max, or a signed maximum below its min, now
records an out-of-type constant, and the check does not compile.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
A minimum above the greatest value of a field's Go type, or a maximum below
its least, left an empty range whose check did not compile. ownRange now
panics with the bound and the type. Fixes Codex r4646051333.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
…und panic

The guide's wrap example now uses an int variable, since the constant
conversion does not compile. The emit README lists the new ownRange panic.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
The panic advised giving the type a JSON type, which does not fit a $ref to
a oneOf of consts, the form of every ACP enum. It now names the problem.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
Merges af6272d (main 2a4cf5c with #153) into #159's head 7cbc478, so
that #159 lands on the tree main will have once #153 lands.

Resolutions:
- emit/types.go unionVariant: keep main's fieldType (#149) and #159's
  isStruct and value. emitUnion keeps fieldType: b.fieldType in the
  variant literal and #159's isStruct and one-value handling.
- emit/README.md: the edits touch different lines. Keep main's
  name-registration sentence and its alias bullet (#153), #159's
  open-enum, alternative-kind and constructor sentences, and main's
  Validate bullet.
- #153 x #159: a union alternative that refers to an alias (isRefAlias)
  now reads the entry that the alias names (aliasTarget). isStruct gives
  an alias of a struct the struct constructor that main generates, and
  an alias of a string a value constructor, where main built
  &LabelAlias{}, which does not compile. An own const on a $ref to an
  alias is checked against that entry's Go type instead of panicking.
  Test: PickAlias and PickRefAliasConst in
  TestWriteTypesJen_UnionKeepsEveryKindOfAlternative, red before the
  fix (panic, then a constructor that takes the value).

The generated files at schema 1.32.0 do not change.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
Merges R159 (af6272d, main 2a4cf5c with #153, then #159) into #150's
head 76407db.

Resolutions:
- emit/types.go integerType: #150's formatType version. #159's
  wideInteger is gone with formatRange, and the math import stays for
  #159's values.
- #159 x #150, the union fit check: values checks an integer const or
  enum value against the Go type of its format with the new holdsInteger
  (ranges.go), instead of #159's int-or-int64 test on formatRange. An
  int64 or uint64 value above int32 is still taken, an int beyond int32
  still panics (it does not compile for GOARCH=386), and a value outside
  int32, uint16, uint32 or uint64 now panics, where a plain port of
  wideInteger generated code that does not compile. New rows in
  TestWriteTypesJen_PanicsOnAValueTheAlternativeCannotHold (uint16
  65536, uint32 -1, uint64 enum -1, uint32 $ref 4294967296) fail on that
  port and pass here; int32 2147483648 panics on both. PickFormatConsts
  takes each format's limit.
- MIGRATION_v0.21.md: #150's "Integer types and ranges" and "Connection
  constructors and limits" rows and sections, then main's "Log
  attributes" and "Null in a tool call update", in section order. The
  sentence that lists the Validate methods of the old range checks goes,
  as #150 removes those methods.
- README.md: #150's Integers bullet before main's Patch fields bullet.
- emit/README.md: #150's integer and Validate text merged word by word
  with main's #149 and #147 edits, and #159's panic list names
  holdsInteger.

types_gen.go is regenerated; its diff from R159 equals #150's own diff.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
Merges R150 (main 2a4cf5c with #153, #159 and #150) into #152's head
6ca095a. #152's own change is 7bc1936..6ca095a, since its stack
merged #150 at 7bc1936.

Resolutions:
- emit/structs.go planFor: main's #149 made fieldType a method that
  adds a pointer for an indirect member, and planFor already holds that
  type in p.goType, so mustHoldDefault's check peels p.goType instead
  of the gone package-level fieldType(field).
- emit/ranges_test.go: keep #150's TestWriteTypesJen_PanicsOnABoundNoValueCanMeet
  (82a9443, newer than #152's base) and #152's optional-integer and
  default tests; both only add functions after the same test.
- emit/README.md: #152's Validate text merged word by word with main's
  #149 edits and #159's alternative-kind sentence.

The generated files at schema 1.32.0 do not change from R150.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
Applies #148's own patch (6c4769e..50da019) onto land/pr152 (d092f3a),
which holds main 2a4cf5c plus #153, #159, #150 and #152.

Resolutions:
- inbound_bench_test.go: #153 made handleCancelRequest take the params of
  the $/cancel_request (the receive loop finds them with
  cancelRequestParams), so the harness passes msg.Params instead of &msg.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
Applies #155's own patch (50da019..f0d4b9c) onto the merge of #148
(land/pr148), and regenerates *_gen.go.

Resolutions:
- connection.go: #153 split SendRequest into sendRequest and
  sentRequest.wait; wait now returns the raw result, so the decodeJSON
  call moves to where SendRequest decodes it.
- proxy.go: proxyRequest decodes a result as SendRequest does, so it
  calls decodeJSON too; proxy_gen.go (regenerated) decodes params with
  decodeJSON through jUnmarshalValidate, as agent_gen.go does.
- shape.go: #150 lets an integer shape hold a uint64 above
  math.MaxInt64 (intRange.holds). scan checked ints with ParseInt alone
  and said fitNo where fits says yes (FuzzShapeScan seed#16 and
  TestWriteTypesJen_ValidateChecksIntegerRanges failed), so scan calls
  holds too.
- verify-notification-barrier and verify-session-cancel: both check.sh
  pass every config; fingerprints re-recorded for SendRequest and the
  regenerated agent_gen.go cases. The connection.go edit stays on its line
  (git diff -U0: -1007 +1007), so no SKILL.md line citation moves.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
Applies #156's own patch (f0d4b9c..ce64625) onto the merge of #155
(land/pr155), and regenerates *_gen.go. A fast decoder must decline or
read a value exactly as the exact decoder does, so fast.go follows each
rule that the exact decoders gained on main.

Resolutions:
- emit/types.go: #159 replaced isPhantomVariant's branches with
  alternativeKind: the empty fast decoder goes on nullAlt and emptyAlt,
  rawAliases gets extensionAlt, and valueAlt declares its fast decoder
  with the Go type of alt.value. #149 dropped the validated memo map.
- emit/fast.go, union alternatives (#159): scalarConst is gone; a value
  variant takes only its values (unionAlternative.values). takesValue
  builds that check for the exact decoder and for the fast one, which
  checks it in the ordered tries only, as the exact decoder does. Before,
  ErrorCode read 0 and -0 as ParseError.
- emit/fast.go, null as unset (#147): a patch field without a clear reads
  null as absent (absentIfNull, or a present check that leaves out
  null), as decodeStmt does. Before, the 20 fields read null as PatchNull.
- emit/types.go, aliases (#153): an alias of an alias of json.RawMessage
  is a raw alias too (aliasTarget), or its field would call a decodeFast
  that json.RawMessage lacks. An alias of a struct shares its methods.
- emit/fast.go, integer formats (#150): int32 reads with fastInt, and
  uint16, uint32 and uint64 with fastUint (decode_fast.go: fastUint,
  parseUint, which takes no sign, as strconv.ParseUint). They went to
  fastExact, which is exact but decodes with encoding/json.
- #149 members held through a pointer: declType reads p.goType, which
  holds the pointer, so fastPtr decodes them; no change.
- stablecheck: a decodeFast is not compared (fastDecoder). The fast
  decoder of Tags, once it gains additionalProperties, keeps an unnamed
  member where the stable one skips it; TestCompare_AllowsAdditions
  failed on that. What a caller sees changes only in the exact decoder.
- decode_fast_test.go: fastTypes lists the decoders of #153's
  UnstableProxySuccessorNotification and UnstableProxySuccessorRequest.
- New tests: decode_fast_semantics_test.go mutates seeds of the types
  that hold these fields (each member and item replaced by null, integer
  bounds and one past them, -0, 1e0, 1.5, the ErrorCode codes, or
  repeated) and compares both decoders; emit/fast_test.go compares them on
  a schema with recursive pointer members, aliases, scalar alternatives
  of each kind and every integer format, on amd64 and 386.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
Applies #157's own patch (ce64625..d7908fa) onto the merge of #156
(land/pr156), and regenerates *_gen.go.

Resolutions:
- emit/types.go: the typesBuilder literal keeps main's fields (#149
  dropped validated) and gains #157's repeatable map.
- MIGRATION_v0.21.md: the summary table keeps main's rows and adds the
  Duplicate members row after them; the Duplicate members section follows
  main's Null in a tool call update section. #157's hunk carried the old
  "These types get a Validate method" line, which #150 removed; it stays
  removed.
- verify-schema-bump SKILL.md: the cases.jsonl sentence names both the
  five 141/... null cases (#147) and the dup/... cases (#157);
  cases.jsonl keeps both sets of cases.
- duplicate_member_test.go: UnstableMcpError.code is an int32 since #150,
  so its repeated-property error names int32.
- The fast decoders decline a key that repeats (fastObject.once, skip,
  keep), so the exact decoder rejects it; no fast.go change.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
Applies #158's own patch (d7908fa..75310bb) onto the merge of #157
(land/pr157), and regenerates *_gen.go.

Resolutions: none. The patch applies cleanly, and regenerating changes
nothing.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
@ThomasK33
ThomasK33 changed the base branch from fix/reject-duplicate-members to main November 21, 2026 09:55
@ThomasK33

Copy link
Copy Markdown
Member Author

Verifier verdict for integration land/pr158 (9d9dbef): PASS+NOTES

I checked the merge of this PR's head (75310bb) onto land/pr157 (00ce5b0).

  • Merge redo: it merges with no conflict, and 9d9dbef has the same tree as git merge-tree --write-tree 00ce5b0 75310bb. All 11 files have the same patch-id as this PR's own patch (d7908fa..75310bb).

  • Gates at 9d9dbef: all pass:

    • regenerating gives no diff
    • make check and make test
    • go test -race ./..., in the root and in cmd/generate
    • GOARCH=386 go test ./..., in both modules
    • TLC: session-cancel 7 of 7 configs and barrier 10 of 10, with both fingerprints matching
  • Differential sweep: 0 differences between the fast and exact decoders in 519M comparisons, on amd64 and 386 (details on perf(decode): decode each value once with generated fast decoders #156).

  • Bench: scripts/bench d092f3a ran 10 alternating runs, and every corpus message decodes as on base.

    Benchmark d092f3a R158 Change
    Inbound/corpus, CPU 80.24 ms/op 19.09 ms/op -76.2%
    Inbound/corpus, allocations 306.8k/op 50.7k/op -83.5%
    ConnectionPipe/inbound 46.56 ms/op 9.89 ms/op -78.8%
  • Module zip: x/mod/zip CreateFromVCS on a clone, and CreateFromDir, both give 762,477 B, with no testdata/bench file. In the extracted zip, the bench tests skip as intended.

  • fix(generate): check the bounds of an optional integer that is not null #152: R158 merges with 4bee8a7 with no conflict. The result differs from R158 only in MIGRATION_v0.21.md, where 112 becomes 114. The 114 is right at R158: there are 80 Validate methods at v0.20.0 and 194 at R158.

Notes

  • go test . in the extracted module zip fails one test, TestUnion_MarshalJSON_RoundTripsTheG2Transcripts. It reads .agents/skills/verify-schema-bump/.../transcripts, which the zip leaves out (that skill has its own go.mod). This fails the same way at d092f3a, so it comes from main (fix(generate): name the union when MarshalJSON has no variant to encode #143), not from this stack. It does defeat the goal of this PR's zip commits, which is that go test passes in the module zip. A follow-up should skip that test as the bench tests skip.

Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

Keeps the verified tree of 9d9dbef plus main's changes since 00ce5b0, which do not overlap it.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
@ThomasK33
ThomasK33 merged commit b3cb910 into main Nov 21, 2026
5 checks passed
@ThomasK33
ThomasK33 deleted the perf/scan-and-slices branch November 21, 2026 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant