Skip to content

chore(coderd/x/chatd): address generation review items - #26517

Merged
hugodutka merged 1 commit into
mainfrom
fix-chatd-generation-review
Jul 6, 2026
Merged

hugodutka merged 1 commit into
mainfrom
fix-chatd-generation-review

Conversation

@hugodutka

@hugodutka hugodutka commented Jun 18, 2026 •

Copy link
Copy Markdown
Collaborator

Addresses the deferred coderd/x/chatd/generation.go review comments from PR #26109: required generation dependencies, scoped chat variables, generation state error handling, generation attempt return values, generation fence verification, and chatdebug outcome recording.

This makes generation task dependencies explicit, packages generation attempt episode state into a struct, and centralizes generation task fence checks for generation transitions.

Generated by Coder Agents, closely reviewed by Hugo.

@github-actions github-actions Bot added the stale This issue is like stale bread. label Jun 28, 2026
@github-actions github-actions Bot closed this Jul 2, 2026
@hugodutka hugodutka reopened this Jul 6, 2026
@hugodutka
hugodutka force-pushed the fix-chatd-generation-review branch 5 times, most recently from 45ef169 to 3af342c Compare July 6, 2026 12:42
@hugodutka hugodutka changed the title refactor(coderd/x/chatd): address generation review items chore(coderd/x/chatd): address generation review items Jul 6, 2026
@hugodutka
hugodutka marked this pull request as ready for review July 6, 2026 12:46
@hugodutka

Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

@coder-agents-review

coder-agents-review Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Chat: Review posted | View chat
Requested: 2026-07-06 12:46 UTC by @hugodutka
Spend: $37.59 / $100.00

Review history
  • R1 (2026-07-06): 14 reviewers, 3 Nit, 3 Note, 4 P3, COMMENT. Review

deep-review v0.9.0 | Round 1 | b21e071..3af342c

Last posted: Round 1, 10 findings (4 P3, 3 Nit, 3 Note), COMMENT. Review

Finding inventory

Findings

# Sev Status Location Summary Round Reviewer Posted
CRF-1 P3 Open auto_archive.go:150 newChatWorker accepts nil server but archive path dereferences unconditionally R1 Chopper P3, Hisoka P3, Mafuuu P3, Meruem P3, Ryosuke P3, Knov P3, Bisky Note Yes
CRF-2 P3 Open generation.go:734 generationAttemptSession doc comment claims struct contains buffer key; it does not R1 Gon P2, Leorio Nit, Mafuuu Nit Yes
CRF-3 P3 Open generation.go:896 recordGenerationFinishFailure has zero direct test coverage R1 Bisky P3 Yes
CRF-4 P3 Open (commit message) Commit subject "code cleanup" is uninformative for 6 structural changes R1 Leorio P3 Yes
CRF-5 Nit Open tasks.go:247 locked vs chat naming inconsistency across tasks.go and generation.go R1 Gon Nit Yes
CRF-6 Nit Open generation.go:737 Exported fields on unexported generationAttemptSession type R1 Ryosuke Nit Yes
CRF-7 Nit Open tasks_test.go:1074 taskRecordingPubsub uses old manual wrapping pattern that PR removed from recordingPubsub R1 Robin Nit Yes
CRF-8 Note Open auto_archive_internal_test.go:304 Inline server construction duplicates newTestServer helper R1 Robin Note Yes
CRF-9 Note Open generation.go:874 loadChatForGeneration accepts unused attempt parameter when fence not required R1 Meruem Note Yes
CRF-10 Note Open tasks.go:458 StartAbandon is only task entry point not using loadChatForTask R1 Chopper Nit, Ryosuke Note Yes

Round log

Round 1

Panel. 4 P3, 3 Nit, 3 Note. Reviewed against b21e071..3af342c. Netero: no findings. Panel: Bisky, Chopper, Ging-Go, Gon, Hisoka, Komugi, Leorio, Mafu-san, Mafuuu, Meruem, Pariston, Robin, Ryosuke, Knov.

About deep-review

CRF = Coder Review Finding (P0-P4, Nit, Note)

Reviewer Focus
Bisky tests
Chopper ops/errors
Churn-guard change verification
Ging language modernization
Gon naming
Hisoka edge cases
Killua perf
Kite change integrity
Knov contracts
Knuckle SQL
Komugi flake/determinism
Kurapika security
Law decomposition
Leorio docs
Luffy product
Mafu-san process
Mafuuu contracts
Melody dispatch/pairing
Meruem structural
Nami frontend
Netero mechanical checks
Pariston premise testing
Pen-botter product gaps
Razor verification
Robin duplication
Ryosuke Go arch
Takumi concurrency
Zoro shape

🤖 Managed by Coder Agents.

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Clean refactoring that delivers on all six review items from #26109. loadChatForTask eliminates a whole class of "forgot the fence check" bugs. The generationAttemptSession struct is a nice improvement over the 5-return-value function. recordGenerationFinishFailure fills a real gap in debug signal quality.

Severity counts: 4 P3, 3 Nit, 3 Note.

The main gap is that the nil-server-at-construction invariant is enforced at newTaskStarter but not at newChatWorker, while the archive path now dereferences w.server unconditionally. Six reviewers converged on this independently.

"The invariant 'server is always present' should be enforced at newChatWorker, not just at newTaskStarter." — Ryosuke


coderd/x/chatd/tasks_test.go:1074

Nit [CRF-7] taskRecordingPubsub still wraps an inner dbpubsub.Pubsub field and manually delegates Publish and SubscribeWithErr. This PR updated recordingPubsub in helpers_test.go to embed dbpubsub.Pubsub directly and drop the explicit delegation. Both types serve the same purpose in the same package. Embedding would match the convention the PR established.

(Robin Nit)

🤖

coderd/x/chatd/tasks.go:458

Note [CRF-10] StartAbandon is the only task entry point that does not use loadChatForTask. The divergence is justified: it needs the mismatch side-channel for cleanup routing and uses ownedByTask + verifyTaskFence with allowArchived: true and input.Status, which is structurally different from the standard pattern. If the fence check logic changes, this path must be updated separately.

(Chopper Nit, Ryosuke Note)

🤖

🤖 This review was automatically generated with Coder Agents.

Comment thread coderd/x/chatd/auto_archive.go Resolved
Comment thread coderd/x/chatd/generation.go Resolved
Comment thread coderd/x/chatd/generation.go Resolved
Comment thread coderd/x/chatd/generation.go Resolved
Comment thread coderd/x/chatd/generation.go Resolved
Comment thread coderd/x/chatd/tasks.go Resolved
Comment thread coderd/x/chatd/generation.go Resolved
@hugodutka
hugodutka force-pushed the fix-chatd-generation-review branch from 3af342c to 2238996 Compare July 6, 2026 15:08
@hugodutka hugodutka removed the stale This issue is like stale bread. label Jul 6, 2026
@hugodutka
hugodutka requested a review from mafredri July 6, 2026 15:16

@mafredri mafredri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Writing critique: three findings on prose in this PR (two on description/commit, one inline on a code comment). Full enumeration of 20 units in the diff; 17 passed.

Commit headline (chore(coderd/x/chatd): code cleanup): "Code cleanup" is a label, not a description. The PR makes three named structural changes and two feature removals. The headline tells a git-blame reader nothing and is inconsistent with the PR title ("address generation review items"). Suggested replacement: match the PR title.

PR body summary: The second paragraph lists three structural changes but omits two operational removals: (1) InsertChatMessages no longer populates provider_response_id (and the ClearChatMessageProviderResponseIDsByChatID query is deleted); (2) the chain_broken label is removed from coderd_chatd_stream_retries_total. Both affect data consumers and monitoring. Suggested addition: "It also stops populating provider_response_id on new chat messages and removes the chain_broken label from the coderd_chatd_stream_retries_total metric."

🤖 This review was automatically generated with Coder Agents.

Comment thread coderd/x/chatd/generation.go Resolved

@mafredri mafredri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice cleanup! One minor suggestion, dealers choice.

Comment thread coderd/x/chatd/generation.go Resolved
@hugodutka
hugodutka force-pushed the fix-chatd-generation-review branch from 2238996 to cba93af Compare July 6, 2026 16:24
@hugodutka
hugodutka enabled auto-merge (squash) July 6, 2026 16:27
@hugodutka
hugodutka merged commit 96130e2 into main Jul 6, 2026
28 of 29 checks passed
@hugodutka
hugodutka deleted the fix-chatd-generation-review branch July 6, 2026 16:37
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 6, 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