Skip to content

Discard conversation titles that arrive after deletion - #926

Open
rudycelekli wants to merge 1 commit into
CopilotKit:mainfrom
rudycelekli:fix/summary-deleted-during-model-20261031
Open

rudycelekli wants to merge 1 commit into
CopilotKit:mainfrom
rudycelekli:fix/summary-deleted-during-model-20261031

Conversation

@rudycelekli

Copy link
Copy Markdown

What this changes

Conversation naming checks whether a channel was deleted before asking the model. If deletion happens while that model call is pending, the final write can still add a summary to the soft-deleted row and announce it to the channel's members. A hard-deleted channel is also reported as successfully named even though no row changed.

Recheck deletedAt in the conditional write. If no row changes, distinguish a surviving channel another writer named from a channel that is gone. Both settle their queue item, while a deleted channel gets no new summary, timestamp, or summary announcement.

Where it runs

  • New state that outlives a request? None. Existing channel and work-queue rows remain in shared Postgres.
  • What happens on the second replica? The conditional database write checks the channel's current deletion state, whichever replica performed the deletion or generated the title.
  • Anything serialised? Existing queue claims and the conditional channel update remain authoritative. The no-op check uses the same transaction connection.
  • Anything fanned out to a browser? An actual summary write retains its existing commit-time notification. A deleted channel produces no successful summary event.
  • New listener, port, or schedule? None.

Boundary and audit

  • Channel access, deletion, and queue boundaries are unchanged.
  • No new refusal or failure category is introduced. Missing or deleted targets use the existing settled/skipped path; model failures retain their existing retry handling.
  • No new client-supplied trust or permissions.

Changelog

  • Added an Unreleased entry.

Proof

Base 743649efc3f21d7bf0badbe6af2bcd5daedd97ce, head c0f3c577ccbabe91d7d1f0740d4cfce1c62e265d.

Two regressions pause the model with a promise barrier while the real worker holds a queue claim, perform a soft or hard deletion in Postgres, then release the title. Before: both fail. A real LISTEN connection captures the late summary announcement after soft deletion; hard deletion is incorrectly listed as written. After: the deleted row is unchanged or absent, neither job reports a successful name, both jobs finish, and no summary announcement is emitted. A commit-ordered NOTIFY marker confirms the listener observed the completed transaction; no timing sleeps or live model calls are used.

The full channel-summary file passes 19 tests and 47 assertions. All 10 channel and work-queue files pass together: 206 tests, 503 assertions. Controls retain another writer's existing title, ordinary naming, concurrent claims, delayed transcripts, model-failure retries, and notification size limits.

Format, lint, workspace typecheck, the test-typecheck baseline guard, and build pass on this exact head.

The full suite was not run on this head. A separate routing candidate (d428f669f10e21700b6d5eb1fb14e90c9cc59cfe) on the same base ran full test:ci: 11,017 passed, 210 skipped, two failed (routine-sweep concurrency expectation and recorder held-steps service-worker timing). Both passed when isolated on unchanged base and that routing candidate; full-suite order/timing causality remains unresolved.

The tests use a dedicated disposable PostgreSQL 15 database (hosted CI uses 17), with no application data or live provider calls. PRs #917 and #918 change task-brief unwrapping in a different part of this file; they do not change this final write.

AI assistance: implemented and locally validated with OpenAI Codex. Hosted CI and maintainer review remain required.

Implemented and locally validated with OpenAI Codex assistance.

@auditbenchai auditbenchai 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.

Open in Audit Bench Ai

🤖 Automated review by Audit Bench Ai, not a personal review. It was posted through the GitHub account connected to Audit Bench Ai. Install the Audit Bench Ai GitHub App to have reviews posted by a separate bot account.

Findings: 1, listed in the fix prompt below (they couldn't be placed as inline comments).

Merge risk: 🟢 Low · up to c0f3c57

The change adds a check for deleted channels within the existing summary transaction without altering existing queue or channel access boundaries.

Merge readiness: 🟡 Ready to merge, with notes

Pre-merge checks: ✅ 9 · ⚠️ 1

⚠️ Checks to review: 1 warning

Check name Status Explanation Resolution
CI checks ⚠️ No CI checks ran on this commit. Add CI so every PR is built and tested.
✅ Passed checks: 9 passed
Check name Status Explanation
Merge conflicts ✅ Merges cleanly into main.
Secrets ✅ No keys, passwords or tokens in the changed code.
Blocking issues ✅ No critical or high-severity issues in the changed lines.
Tests ✅ Tests were changed alongside the code.
PR size ✅ 101 lines changed.
Title check ✅ The title clearly describes the bug fix and intended behavior.
Description check ✅ The description provides comprehensive details on the problem, solution, concurrency behavior, and proof.
Linked issues check ✅ No specific issue numbers are linked in the description.
Out of scope changes check ✅ All changes are directly scoped to handling channel deletions during the summary workflow.
📝 Walkthrough

This PR prevents conversation summaries from being saved or announced if a channel is soft- or hard-deleted while an AI model call is in progress. The database update now verifies that the channel has not been deleted, distinguishing between existing channels updated by concurrent workers and channels that were removed. Queue items are still settled properly without emitting stale summary notifications.

File Changes
server/src/channels/summary.ts Verifies channel deletion status during conditional updates and avoids emitting events if the channel was deleted.
server/tests/channel-summary.integration.test.ts Adds integration tests verifying soft and hard deletions during asynchronous channel naming do not write summaries or emit events.
ℹ️ Review info
  • Commit: c0f3c57
  • Verdict: ✅ Pass
  • Findings: 1 low
  • Review: local checks plus AI review of the changed lines
  • Scope: Reviewed 2/2 selected files (of 2 total): 2 reviewed by AI, 0 from cache, 0 passed local checks with nothing risky enough to send to AI. Found 1 finding(s), No secrets found.
🤖 Prompt to fix review comments
Verify each finding against the current code and only fix it if it still applies.

In `@server/src/channels/summary.ts` around line 114: High cyclomatic complexity: summariseClaimedChannels(). Complexity of 13 makes this function harder to test and reason about. Suggested fix: Split into smaller functions with single responsibilities.

💬 Reply to any inline comment and Audit Bench Ai will recheck that code and answer in the thread. Mention @auditbench in the conversation to ask about the whole PR.

🛠️ Open the full report and fix with AI

Thanks for using Audit Bench Ai! Free pull request reviews for open source: paste any public PR at auditbenchai.com/scan.

Reviewed by Audit Bench Ai · AI code review for security, logic and performance · Review any public PR free

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.

2 participants