Skip to content

fix(knowledge): withdraw a queued generation when its Search KB turns dormant - #8445

Merged
waleedlatif1 merged 3 commits into
stagingfrom
fix/dormant-search-queued-generation
Sep 30, 2026
Merged

waleedlatif1 merged 3 commits into
stagingfrom
fix/dormant-search-queued-generation

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • A queued document worker whose knowledge base has become a dormant Search index now gives back its own queue generation before it skips. It clears processingQueuedAt and refunds the attempt its dispatch charged, as clearDocumentsQueued does, and keeps the token as the ownership marker
  • Before this change, the early return left the row pending with a live stamp and a spent attempt. Later dispatches treated the document as already queued until the 4-hour grace window passed, and each such skip used up one of the 5 processing attempts
  • The retirement migration clears stamps only for Search KBs in its frozen snapshot. A KB that becomes a Search index later, through legacy index adoption in ensureSearchKnowledgeBase, keeps any in-flight generations
  • The update is scoped to this invocation's exact generation and to pending rows, so a newer dispatch is never withdrawn or refunded. It is skipped when no generation was supplied
  • Follows up a review finding on v0.9.7: embeddings cleanup, search expansion, navigation and execution speedup #8439

Type of Change

  • Bug fix

Testing

  • dormant-search-processing.integration.ts (real Postgres via bun run test:integration):
    • A queued generation for a dormant KB loses its stamp and charged attempt and keeps its token. Red on the previous code
    • A worker from another generation leaves the current stamp and attempts untouched. Red with the generation guard removed
  • lib/knowledge/documents unit suite passes (320 tests)
  • bun run lint, bun run check:audits (52 audits), docs-manifest:check, and type-check pass

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Sep 30, 2026 2:30am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Adds logic to refund processing attempts when a knowledge base becomes dormant.

The PR appears safe to merge based on the reviewed changes.

Summary

The PR withdraws a pending document’s queued generation when its Search knowledge base becomes dormant, clearing the queue stamp and refunding a charged attempt. The follow-up change requires the worker’s timestamp to match the stored generation, and adds a regression case for a reused token.

Reviews (3) · Last reviewed commit: "fix(knowledge): withdraw only the exact ..."

Comment thread apps/sim/lib/knowledge/documents/service.ts

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread apps/sim/lib/knowledge/documents/service.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread apps/sim/lib/knowledge/documents/service.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit f7d0259 into staging Sep 30, 2026
23 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/dormant-search-queued-generation branch September 30, 2026 02:34

This branch was previously deployed

1 inactive deployment
Preview — 25a4c222 Deployed Sep 30, 2026 by vercel[bot]
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