Skip to content

test(coderd): stamp chat message fixtures with the current content version - #30996

Merged
ibetitsmike merged 9 commits into
mainfrom
mike/chatprompt-current-format-fixtures
Oct 28, 2026
Merged

ibetitsmike merged 9 commits into
mainfrom
mike/chatprompt-current-format-fixtures

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

Chat prompt tests built most of their stored-message fixtures in the legacy content format (content_version 0), so they exercised the legacy decoder instead of the current one. This PR changes tests only: it stamps those fixtures with ContentVersionV1 and builds them with MarshalParts, so they keep passing after the legacy decoder is removed later in this stack. Tests of the version 0 decoder itself keep their version 0 rows until the layers above remove that decoder.

Why it is safe

  • mustMarshalContent and mustMarshalToolResult now build current parts (PartFromContent, ChatMessageToolResult) and encode them with MarshalParts, the production write path.
  • TestMixedFormatConversation becomes TestConvertMessagesWithFiles_Conversation and uses current-format rows only.
  • TestParseContent_BackwardCompat does not change. Migration 000434 stamped every existing row with version 0, so its six cases of current-format parts in version 0 rows still cover the version 0 heuristics. refactor(coderd)!: retire the V0 chat message content decoder #30998 moves those six cases to version 1 rows when it removes that decoder.
  • TestProviderExecutedResult_LegacyToolRow calls the legacy writers (MarshalContent, MarshalToolResult) directly, so its provider-executed tool row still goes through the legacy tool-row decoder.
  • TestParseContent_ErrorPaths runs its malformed-input cases on version 1 rows, and runs the same input on version 0 rows of each role (v0/<role>/malformed_json), so a version 0 parser that accepts malformed content still fails the suite. refactor(coderd)!: retire the V0 chat message content decoder #30998 deletes the version 0 cases with that decoder.
  • I ran the 17 mutants listed below, each a go test -overlay edit of the current decode and prompt-conversion code in chatprompt.go, against the chatprompt and db2sdk tests on main and on this branch. Every mutant main catches is still caught. Two more are caught here: mutant 3, because TestParseContent_ErrorPaths/system/malformed_json used to hit the legacy system decoder, and mutant 14, by the new JSON null case of TestConvertMessagesWithFiles_NormalizesAssistantToolCallInput. Mutants 4 and 8 survive those tests on both. The chatd test TestOrganizationSkillsFollowChatOwnerAccess catches mutant 4, so 8 is an existing gap.
  • Mutants of the version 0 decoder fail on main and on this branch: version 0 assistant or user rows always take the envelope path, their current-format parts are dropped, legacy tool rows lose provider_executed, or a version 0 parser accepts malformed JSON.
  • With the version 0 case removed from ParseContent by an overlay, only tests of version 0 rows fail. test(coderd/x/chatd/chatprompt): drop tests of the legacy content codec #30997 deletes them, except the six TestParseContent_BackwardCompat cases, which refactor(coderd)!: retire the V0 chat message content decoder #30998 moves, and the version 0 cases of TestParseContent_ErrorPaths, which refactor(coderd)!: retire the V0 chat message content decoder #30998 deletes.
The 17 mutants
  1. ParseContent returns no parts for a V1 row.
  2. V1 decoding skips NUL restoration (decodeNulInParts).
  3. The V1 parse error says "decode" instead of "parse".
  4. Tool error string extraction is off (toolResultPartToMessagePart). Only a chatd test catches it.
  5. Tool call input is dropped.
  6. Tool call ProviderExecuted is dropped when reading.
  7. Resolved file data is dropped.
  8. The file media type fallback is dropped (partsToMessageParts). Survives.
  9. User file IDs are not collected for resolution.
  10. Text provider metadata is dropped.
  11. File reference text is replaced by the raw content.
  12. System messages are dropped.
  13. Tool call ProviderExecuted is dropped when writing (PartFromContent).
  14. normalizeToolCallInput keeps a JSON null input instead of {}. Survives on main only.
  15. Text tool result ProviderExecuted is dropped.
  16. Tool result IDs are dropped.
  17. Assistant file IDs are resolved like user file IDs.

Review focus

The rewritten conversation test in chatprompt_test.go. It checks the same prompt shape as before, but every row is in the current format. In the same file, TestProviderExecutedResult_LegacyToolRow keeps its legacy rows, TestParseContent_ErrorPaths checks malformed input on both content versions, and the input normalization table gains a JSON null case. The other changed test files only switch fixtures to the current format: coderd/x/chatd/chatprompt/file_inline_test.go (+4/-16), coderd/database/db2sdk/db2sdk_test.go (+11/-13), coderd/x/chatd/message_conversion_test.go (+3/-2) and coderd/x/chatd/quickgen_internal_test.go (+1).

Validation

  • go test ./coderd/x/chatd/... ./coderd/database/db2sdk/ -count=1 -p 4 -parallel 4: ok
  • go vet on the touched packages and golangci-lint run --fix=false ./coderd/x/chatd/chatprompt/...: clean
  • pre-commit hook: passed

Stack

This stack retires chatd compatibility paths for chat data that older Coder versions stored.

  1. test(coderd): stamp chat message fixtures with the current content version #30996 stamp chat message fixtures with the current content version (this PR)
  2. test(coderd/x/chatd/chatprompt): drop tests of the legacy content codec #30997 drop tests of the legacy content codec
  3. refactor(coderd)!: retire the V0 chat message content decoder #30998 retire the V0 chat message content decoder
  4. refactor(coderd/x/chatd): inline the model config provider identity #31000 inline the model config provider identity
  5. refactor(coderd/x/chatd)!: retire the close_agent tool alias #31005 retire the close_agent tool alias

Xum, an AI agent, opened this PR for @ibetitsmike and wrote this description.

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum, an AI agent, posted this comment for @ibetitsmike.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T18:14:26.263111Z d3096ae 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. Swish!

Reviewed commit: da5ab5c7f8

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

@ibetitsmike
ibetitsmike removed this pull request from stack #30999 October 18, 2026 19:27
@ibetitsmike
ibetitsmike added this pull request to stack #31006 October 18, 2026 19:28
@ibetitsmike
ibetitsmike marked this pull request as ready for review October 19, 2026 12:16

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

ContentVersion: chatprompt.CurrentContentVersion,

P2 Badge Pin the V1 helper to ContentVersionV1

The helper is named and documented as constructing a V1 row, but it uses the moving CurrentContentVersion alias. When a V2 codec is introduced, TestParseContent_V1 and every compatibility test using this helper will silently switch to V2 and stop covering V1 decoding. Assign chatprompt.ContentVersionV1 here, or rename and separate current-version fixtures from version-specific tests.

AGENTS.md reference: AGENTS.md:L86-L86

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

…coder exists

Moving every fixture to the current format dropped coverage of the
version 0 decoder, which this layer still ships:

- TestParseContent_BackwardCompat and TestParseContent_V1 stay as on
  main, so the cases with current-format parts in version 0 rows still
  exercise the version 0 heuristics. The decoder removal moves them to
  version 1 rows.
- TestProviderExecutedResult_LegacyToolRow writes its rows with the
  legacy writers again, so its provider-executed tool row goes through
  the legacy tool-row decoder.

The tool call input normalization table also gains a JSON null input,
which no test covered.
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum, an AI agent, posted this comment for @ibetitsmike.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b5485db00c

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

Moving the malformed-input cases of TestParseContent_ErrorPaths to
version 1 rows left the version 0 parsers, which this layer still
ships, with no malformed-input test. Run the same input on version 0
rows of each role too, so a legacy parser that accepts malformed
content fails the suite.
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum, an AI agent, posted this comment for @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 6c9c3854da

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

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum, an AI agent, posted this comment for @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

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

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum, an AI agent, posted this comment for @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 8a34f80d4c

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

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum, an AI agent, posted this comment for @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 4a16fbce51

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

@linear-code

linear-code Bot commented Oct 21, 2026

Copy link
Copy Markdown

CODAGT-1445

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum, an AI agent, posted this comment for @ibetitsmike.

1 similar comment
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum, an AI agent, posted this comment for @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 1774554a4d

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

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum, an AI agent, posted this comment for @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: d3096ae34e

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

@ibetitsmike
ibetitsmike merged commit 7f6ce9c into main Oct 28, 2026
27 checks passed
@ibetitsmike
ibetitsmike deleted the mike/chatprompt-current-format-fixtures branch October 28, 2026 19:45
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants