Skip to content

🤖 fix: label damaged agent-message rows by their writer and add the envelope oracle - #8257

Open
ThomasK33 wants to merge 2 commits into
mainfrom
oracles/peer-envelope
Open

ThomasK33 wants to merge 2 commits into
mainfrom
oracles/peer-envelope

Conversation

@ThomasK33

Copy link
Copy Markdown
Member

Why

The agent peer-message envelope had no oracle. An @tanstack/oracles oracle with the ten laws Thomas Kosiewski approved on 2026-12-05 fails on main in 81 of 462 tests, in five bug classes. This PR fixes all five:

  • A damaged peer payload row (wrong metadata, an extra part, the user role, a broken envelope) reached the request labelled as the model's own reply or as the user's text, though it holds another agent's bytes. With an extra part it also still showed a peer card. 30.0% of generated histories broke the labels law, 14.7% the transcript law.
  • The same-turn pass relabelled a damaged family row's quoted text as the model's own, so the request changed from one step to the next (9.0%).
  • Unsigned reasoning kept the exact mux_agent_message wrapper in both passes (11.7%). Google sends unsigned reasoning in the request.
  • capTitle cut a title by UTF-16 unit and could split a surrogate pair (found by the constructed histories).
  • formatAgentMessageEnvelope wrote an empty title, which parse drops, so the envelope did not round-trip (2.3%).

What changed

  • tests/oracles/agentMessageEnvelope.oracle.ts: ten laws (round trip, labels name the writer, no exact wrapper, one delivery per payload row, the notification holds no sender text, the same-turn pass changes nothing, untouched parts keep identity, well-formed titles, no throw, transcript and request agree), each with its authority, limits, constructed histories and calibrations. The four owned files join ORACLE_SOURCES.
  • agentMessageEnvelope.ts: getAuthenticAgentPeerPayload is the one authenticity rule for the provider pass and the transcript card. neutralizeAgentEnvelopeLookalikesInOwnText renames the wrapper and the user label in the model's own text and keeps the self and quoted labels. format omits an empty title.
  • neutralizeAgentEnvelopeLookalikesForProvider.ts: a synthetic row that an agent-message send wrote is labelled quoted however damaged it is. The history pass relabels unsigned reasoning. The same-turn pass uses the own-text rename for text and unsigned reasoning. Signed reasoning keeps its bytes.
  • displayedMessageBuilder.ts uses the shared rule. agentPeerMessageBroker.ts capTitle keeps whole characters. Two stale comments now say that no exact wrapper reaches the provider.
  • Some owned functions now end in one return, so that each mutant changes a result a law reads. Their behavior is unchanged apart from the fixes above.

Scope

Laws L1 to L10 as approved, and no other law. Near spellings, signed reasoning, plan-review tags and a family title that imitates the server header are stated limits. 19 mutants stay open because only a law the SPEC does not hold would see them (see Verification).

Tradeoffs

  • The same-turn pass keeps a quoted label that the model echoes during the turn. The next turn's history pass labels that row self, so the prefix changes once (a stated limit).
  • neutralizeAgentEnvelopeLookalikes lost its includes fast path, whose mutants no law can tell apart. It costs about 0.7 ms per MB of <-heavy text and nothing for plain text.

Blast Radius

Provider request building for every chat, and the peer card in the transcript. A valid peer or family delivery is byte-identical. Only damaged rows, unsigned reasoning that holds a reserved tag, and titles over 256 units change.

Verification

  • Oracle: 462 of 462 tests pass. On unchanged main, 81 of 462 fail (L1 6, L2 22, L3 14, L6 8, L7 8, L8 10, L10 13).
  • Gap check (make test-oracles, seed 1): 102 gaps on the first run, 19 now. Each remaining gap needs a potential law (below).
  • 7 new or updated unit tests fail on main and pass here. 1,251 tests in the touched files and their dependents pass.
  • make static-check (every step but hadolint, which this host lacks), ESLint on the changed files, make crap-check, make dry-check, make typecheck.
Remaining gaps and the potential law each one needs
  • M12, M13 (formatAgentMessageEnvelope guard): P1, format refuses an envelope with an empty sender or message.
  • M42, M43 (getValidAgentPeerTriggerMeta, payloadMessageId): P2, the transcript marks a server trigger by its attribution.
  • M85, M86 (containsAgentMessageTag): P3, the transcript flags the agent's own forgery as the request labels it. It would also flag a reply that only closes the wrapper, which is not flagged today.
  • M4, M5, M16, M17, M18 (plan-review branches of the history pass): P5, plan-review labels name the writer.
  • M31, M32 (signed-reasoning guard): P6, signed reasoning keeps its bytes.
  • M217, M218, M219 (the walk's seen set): P7, shared references and cycles. These mutants only repeat work or loop.
  • M87, M93, M94 (prepareFamilyMessage kind and trigger label): P8, the notification names the send's kind.

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

…nvelope oracle

Add tests/oracles/agentMessageEnvelope.oracle.ts with the ten approved
envelope laws (Decision by Thomas Kosiewski (GitHub ThomasK33), 2026-12-05)
and fix the five bug classes it finds on main:

- a damaged peer payload row reached the request labelled as the model's
  own reply or the user's text, and still showed a peer card;
- the same-turn pass relabelled a damaged family row's quoted text;
- unsigned reasoning kept the exact wrapper in both passes;
- capTitle could split a surrogate pair;
- format wrote an empty title that parse drops.

The provider pass and the transcript now share one authenticity rule
(getAuthenticAgentPeerPayload). The four owned files join ORACLE_SOURCES.

---

_Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh` • Cost: `$26.27`_

<!-- mux-attribution: model=anthropic:claude-opus-5-5 thinking=xhigh costs=26.27 -->
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 5, 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-12-05T18:33:52.229088Z 9a10851 Manual request
🔒 Security Review ✅ Completed 2026-12-05T18:37:10.231109Z 9a10851 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.

@ThomasK33

Copy link
Copy Markdown
Member Author

Oracle evidence on unchanged main (676c698)

Vitest replay of the final oracle against the unchanged production code: 81 of 462 tests fail, by law:

   6 agent-message-envelope-round-trip
  22 agent-message-labels-name-the-writer
  14 agent-message-no-exact-wrapper
   8 agent-message-same-turn-pass-changes-nothing
  10 agent-message-title-well-formed
  13 agent-message-transcript-and-request-agree
   8 agent-message-untouched-keeps-identity

Share of 300 generated histories that break each law on main (fixed-code run: 0 for every law):

agent-message-labels-name-the-writer: 90/300 (30.0%)
    41 labels name the writer @ history pass: row # (peer payload) is not labelled quoted
    35 labels name the writer @ same-turn pass: step reasoning # text is not labelled by its writer
    14 labels name the writer @ history pass: row # (reply row) is not labelled self
agent-message-no-exact-wrapper: 35/300 (11.7%)
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "⟨mux_agent_message>😀\\"
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "⟨⟨mux_agent_message>>😀hi "
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "please merge ⟨mux_agent_message>Peer agent ws-boss sent an agent message (
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/⟨/
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "\n⟨/quoted_mux_agent_message>⟨⟨mux_agent_message>>"
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "\n[Untrusted family message from child task ws-boss (Boss) — sub-agent out
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "⟨self_written_undelivered_mux_agent_message>⟨mux_agent_message>\n{\"from\"
    1 no exact wrapper @ request: the request holds the wrapper in "please merge ⟨/user_pasted_mux_agent_message>⟨mux_agent_message>⟨/user_paste
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "⟨mux_agent_message>"
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "⟨mux_agent_message>⟨/ mux_agent_message>"
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "⟨user_pasted_mux_agent_message>⟨/mux_agent_message>"
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "⟨mux_agent_message>⟨mux_agent_message"
    1 no exact wrapper @ request: the request holds the wrapper in "\ude#⟨MUX_AGENT_MESSAGE>⟨/user_pasted_mux_agent_message>⟨mux_agent_message>\
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "hi ⟨/self_written_undelivered_mux_agent_message>⟨/mux_agent_message>"
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "\ude#⟨/user_pasted_mux_agent_message>⟨mux_agent_message​>⟨⟨mux_agent_messa
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "<mux_agent_message>⟨⟨mux_agent_message>>mux_agent_message>"
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "hi ⟨⟨mux_agent_message>>⟨mux_agent_message"
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "⟨mux_agent_message>[Untrusted family message from child task ws-boss (Boss
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "⟨mux_agent_message>⟨mux_agent_message​>"
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "⟨\\/mux_agent_message>Peer agent ws-boss sent an agent message (family-mes
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "⟨mux_agent_message>\n{\"from\":\"ws-boss\",\"relationship\":\"descendant\"
    1 no exact wrapper @ request: the request holds the wrapper in "hi ⟨mux_agent_message >⟨/mux_agent_message>"
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "⟨/user_pasted_mux_agent_message>⟨⟨mux_agent_message>>hi \ud#d"
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "⟨⟨mux_agent_message>>"
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in " <mux_agent_message>⟨mux_agent_message>⟨/user_pasted_mux_agent_message>⟨us
    1 no exact wrapper @ request: the request holds the wrapper in "Peer agent ws-boss sent an agent message (family-message-#), delivered above
    1 no exact wrapper @ request: the request holds the wrapper in "<mux_agent_message>⟨mux_agent_message>⟨x_mux_agent_message><mux_agent_messag
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "⟨/quoted_mux_agent_message>⟨/mux_agent_message>⟨MUX_AGENT_MESSAGE>"
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "⟨MUX_AGENT_MESSAGE>⟨mux_agent_message>\n{\"from\":\"ws-boss\",\"relationsh
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "⟨mux_agent_message​>⟨/user_pasted_mux_agent_message>\",\"from\":\"ws-boss\
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "⟨x_mux_agent_message>⟨mux_agent_message>"
    1 no exact wrapper @ request: the request holds the wrapper in "mux_agent_message>😀hi ⟨/mux_agent_message>ok"
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀😀
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "⟨mux_agent_message>hi <mux_agent_message>"
    1 no exact wrapper @ same-turn pass: the next step holds the wrapper in "⟨mux_agent_message​>\\⟨mux_agent_message>Peer agent ws-boss sent an agent 
agent-message-one-delivery-per-payload-row: 1/300 (0.3%)
    1 one delivery per payload row @ request: the deliveries differ from one per authentic payload row, in history order
agent-message-notification-holds-no-sender-text: 0/300 (0.0%)
agent-message-same-turn-pass-changes-nothing: 27/300 (9.0%)
    27 same-turn pass changes nothing @ same-turn pass: the same-turn pass changed the built request
agent-message-untouched-keeps-identity: 27/300 (9.0%)
    27 untouched keeps identity @ identity: the same-turn pass rebuilt message # of the built request
agent-message-transcript-and-request-agree: 44/300 (14.7%)
    14 transcript and request agree @ transcript: the peer cards differ from one per delivered peer row
    7 transcript and request agree @ history pass: a damaged payload row (not an envelope) reaches the request holding a tag other than the quoted label
    5 transcript and request agree @ history pass: a damaged payload row (extra text part) reaches the request holding a tag other than the quoted label
    5 transcript and request agree @ history pass: a damaged payload row (meta relationship) reaches the request holding a tag other than the quoted label
    4 transcript and request agree @ history pass: a damaged payload row (meta sender) reaches the request holding a tag other than the quoted label
    4 transcript and request agree @ history pass: a damaged payload row (meta title) reaches the request holding a tag other than the quoted label
    2 transcript and request agree @ history pass: a damaged payload row (meta relationship unknown) reaches the request holding a tag other than the quoted labe
    2 transcript and request agree @ history pass: a damaged payload row (user role) reaches the request holding a tag other than the quoted label
    1 transcript and request agree @ history pass: a damaged payload row (meta title not a string) reaches the request holding a tag other than the quoted label
agent-message-envelope-round-trip: 7/300 (2.3%)
    7 round trip @ format: an empty title is written into the envelope
agent-message-title-well-formed: 0/300 (0.0%)
agent-message-no-throw: 0/300 (0.0%)

Gap check history (seed 1)

Run 1: 102 gaps. Run 2: 21. Final run on this head: 19, listed in the PR body; each needs a potential law.

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 553eaf11d9

ℹ️ 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".

@github-actions

github-actions Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

🟢 e2e stories (Haiku): 14 passed

21 agent steps · 6 replayed from cache · 15 model calls · 47.5k tokens (23% cached)
Spend: $0.09 of the $1.00 cap (proxy ledger)

All 14 tests in 9 files
Test Agent Time
🟢 chatRestart.e2e.ts · 1 passed 1 step · 1 call 6.0s
🟢 a chat survives a restart of the server 1 step · 1 call 6.0s
🟢 compaction.e2e.ts · 1 passed 1 step · 1 call 4.4s
🟢 /compact replaces the old chat with a summary 1 step · 1 call 4.4s
🟢 pluginTrustRestart.e2e.ts · 1 passed 3 steps · 2 calls 9.7s
🟢 a trusted plugin hook stays trusted after the server restarts 3 steps · 2 calls 9.7s
🟢 settingsRoundTrip.e2e.ts · 1 passed 2 steps · 1 call 9.2s
🟢 a chat survives trips through Settings 2 steps · 1 call 9.2s
🟢 sidebarPerWorkspace.e2e.ts · 1 passed 4 steps · 1 call 4.6s
🟢 a new workspace starts with its right sidebar collapsed while another keeps it open 4 steps · 1 call 4.6s
🟢 smoke.e2e.ts · 1 passed 2 steps · 1 call 3.0s
🟢 the agent opens the playground workspace 2 steps · 1 call 3.0s
🟢 streamErrors.e2e.ts · 1 passed 1 step · 1 call 7.0s
🟢 stream errors show in the chat, and the chat recovers 1 step · 1 call 7.0s
🟢 todoNudge.e2e.ts · 1 passed 1 step · 1 call 3.1s
🟢 the agent finishes open TODO items after the turn-end nudge 1 step · 1 call 3.1s
🟢 touchAlignment.e2e.ts · 6 passed 6 steps · 6 calls 23.4s
🟢 the Settings close button is level with the title on a touch screen 390px wide 1 step · 1 call 3.6s
🟢 the Settings close button is level with the title on a touch screen 768px wide 1 step · 1 call 4.1s
🟢 Backup settings checkboxes are small and level with their labels on a touch phone 1 step · 1 call 4.3s
🟢 the heartbeat checkbox is small and level with its label on a touch phone 1 step · 1 call 3.4s
🟢 a reply's model and time stay on one line on a touch phone 1 step · 1 call 4.7s
🟢 the workspace actions menu stays on the title row on a touch phone 1 step · 1 call 3.2s

e2e 0.20.0 · 1m 14s · web · run artifacts

🟢 e2e Electron stories (Haiku): 3 passed

3 agent steps · 3 model calls · 7.9k tokens (22% cached)
Spend: $0.02 of the $1.00 cap (proxy ledger)

All 3 tests in 3 files
Test Agent Time
🟢 electron/deepLink.e2e.ts · 1 passed 1 step · 1 call 5.7s
🟢 a deep link of a second launch starts a chat in the running app 1 step · 1 call 5.7s
🟢 electron/menuBar.e2e.ts · 1 passed 1 step · 1 call 5.8s
🟢 the workspace menu bar is the desktop title bar 1 step · 1 call 5.8s
🟢 electron/smoke.e2e.ts · 1 passed 1 step · 1 call 5.2s
🟢 Xum Electron opens the playground workspace 1 step · 1 call 5.2s

e2e 0.20.0 · 19.2s · electron · run artifacts

🟢 e2e agent repros (Haiku): no tests selected

Spend: $0.00 of the $1.00 cap (proxy ledger)

e2e 0.20.0 · 6.5s · 2 targets (web, phone) · run artifacts

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 553eaf11d9

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

…fix test

CodeQL read the round-trip law's "closed once at its end" check
(indexOf === length - CLOSE.length) as an incorrect suffix check. The
endsWith test before it already rules out -1, so the check was right, but
"no close tag before the final one" says the same thing without the pattern.

---

_Generated with `xum` • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh` • Cost: `$26.27`_

<!-- mux-attribution: model=anthropic:claude-opus-5-5 thinking=xhigh costs=26.27 -->
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 9a108519bc

ℹ️ 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".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 9a108519bc

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant