Files
magpie/docs
yetoneandggbdpq 45b8c725cf gateway: a legacy /responses/compact carrying another account's native compaction goes to that account, or is refused saying why (#2727, ggbdpq)
codexBackend's /responses/compact relayed to Codex's sign-in (or, with the
sign-in paused, compactOn's account) before any seal check, so a compact
whose input carries a compaction magpie recorded another account as the
writer of reached an account that can't read it, and Codex got the
backend's bare 400. Now sealedCompact judges it, as /responses already is
(codexSealedFor -> serve, #2642): the writer on in magpie answers it,
signed as the writer (codexUpstreamOn); a writer gone (signed out, lapsed,
paused, switched off, kept from the model) is refused 400 with
checkpointError's reason; the sign-in's own seal, a key's seal, a request
naming its own chatgpt-account-id, and a sign-in state magpie can't read
relay as before. Two Team seats of one email still read as one (the
record holds the email).

Review fix on top of ggbdpq's 781381f4: a gateway key held to some
accounts (#905) was checked (compactSigninHeld) against the sign-in before
the compact was handed to the writer, so a key held to me@ spent the
writer biz@ (acct-2 asked, 200), and a key held to biz@ was refused 403
"goes through the account Codex is signed in to" though the compact
would go to biz@. The hold is now asked of the account the compact goes
to; a writer the key may not use gets 403 sealedCompactHeldError naming
the writer, with nothing asked. The test's fake backend now records under
a lock.

Reviewed and run (reviewer, at this commit with the #2739 commit under
it, on 89521b03d; rebased after onto origin/main, see the last line):
- Each fix broken by hand, TestNativeCompactionCompactJudgesItsWriter:
  M0 codex_backend.go as on main: 3 subtests red (writer answers, gone
  refused, compactOn gone). M1 the key '#' skip dropped: "a seal a key
  wrote is not judged" red (400). M2 the chatgpt-account-id skip
  dropped: its subtest red (400). M3 the writer never relayed to: the
  healthy-writer subtest red (backend saw ""). M4 gone never refused:
  2 red. M5 judged after compactOn's relay: the compactOn subtest red
  (backend saw acct-2). Each green with the code restored.
- TestNativeCompactionCompactKeepsTheKeysAccounts (new) on ggbdpq's
  781381f4: red both ways ("200, the backend saw acct-2" for a key held
  to me@; 403 "goes through the account Codex is signed in to" for a key
  held to biz@). Red again with the hold put back on the sign-in; green
  with this change. TestGatewayKeyAccountsHoldCodexCompact and
  TestGatewayKeyCompactOnCodexAPIKey still pass.
- -race -count=3 on both tests: ok.
- gofmt -l clean; go vet ./... and -tags nogui (darwin), GOOS=linux and
  GOOS=windows go vet -tags nogui ./...: clean; go build, GOOS=linux go
  build -tags nogui, GOOS=windows go build: ok.
- Full suite, set -o pipefail, go test -tags nogui -count=1 -timeout 45m
  ./... at 519bcc843 (both changes, on 89521b03d), load ~300: exit 0,
  66 packages ok (internal/agent 2246s, internal/gateway 2040s,
  internal/provider 786s); none timed out.
- Not run: a real Team-seat pair or a real sealed compaction through a
  ChatGPT account.
- After the rebase onto origin/main 1e643ba7e (a doc-line conflict in
  gateway-routing.md resolved by hand, main's text kept): go build,
  darwin/linux/windows go vet -tags nogui of internal/gateway and
  internal/provider, and the NativeCompaction|Compact|Checkpoint|
  GoesZstd|StayPlain|TestGatewayKey and TestCodexCompressed tests: ok.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-17 23:02:36 +08:00
..