Skip to content

fix(kb): a collection appears on its first write, not with its entity (#19725) - #20684

Merged
mrveiss merged 5 commits into
mainfrom
issue-19725-lazy-collections
Nov 2, 2026
Merged

mrveiss merged 5 commits into
mainfrom
issue-19725-lazy-collections

Conversation

@mrveiss

@mrveiss mrveiss commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Thinking Path

#19725: most Chroma collections were empty because creating a work item, company, project or sprint made one straight away. Writers already use get_or_create_collection through the one name builder, and the readers cope with a missing collection (_peer_search, companies, ac_suggester, capability_indexer, decision_log, work_item_kb, rag_assembler). One didn't: sprint_summarizer matched on error text the adapter doesn't produce, so it now uses get_collection_or_none. So the eager calls only produced the empties.

The issue's open question about work_item_<id> against work_item:<id>: they are one name. The KB client maps : to _ because Chroma rejects : (kb_chroma_client in llc/kb/collections.py).

What Changed

  • Creating a work item, company, project or sprint no longer creates a collection.
  • A company create no longer fails, or rolls back, when Chroma is down. test_create_kb_failure_rolls_back_no_commit is removed because that failure can't happen now.
  • archive_collection logs a missing collection at debug, since that's now the usual case when a work item finishes.
  • work_item_kb and artifact_ingestor now pass the entity_type and entity_id metadata the old creator set, since it can't change after creation.
  • A guard pins both rules: no ensure_collection calls under llc/, and no hand-built work_item_{...} style names.

KbCollectionManager.ensure_collection now has no production caller and stays: the health-scan proposal on #19725 is its next caller.

Refs #19725. Still open, in follow-ups: the vector browser hiding empty collections, which adds a UI string and so waits for #20662, and the health scan's approval-gated proposal. Existing empties are untouched (#17038).

Verification

Tests pass locally across the new guard, test_sprint_summarizer, the company create and authz tests, test_kb_collection_names_19519, test_kb_collections, test_sprints_idor and test_suggest_ac_endpoint. Not run on a host. Reader tolerance was checked by reading each call site; only sprint_summarizer has a test for it.

Model Used

Claude Opus 5.5

@mrveiss mrveiss added the phase:M1.8 Knowledge base: upload, web sources and chat retrieval work end to end label Nov 2, 2026
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 47 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 58cbf98 and e17171d.

Files ignored due to path filters: 1
  • scripts/python_file_size_known_large.py is excluded by !scripts/python_file_size_known_large.py
Files selected for processing: 10
  • autobot-backend/llc/api/companies.py
  • autobot-backend/llc/api/sprints.py
  • autobot-backend/llc/api/work_items.py
  • autobot-backend/llc/kb/artifact_ingestor.py
  • autobot-backend/llc/kb/collections.py
  • autobot-backend/llc/kb/sprint_summarizer.py
  • autobot-backend/llc/kb/work_item_kb.py
  • autobot-backend/llc/tests/test_company_create_kb_and_list_n1_12323_12325.py
  • autobot-backend/llc/tests/test_kb_collections_lazy_19725.py
  • autobot-backend/llc/tests/test_sprint_summarizer.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@mrveiss

mrveiss commented Nov 2, 2026

Copy link
Copy Markdown
Owner Author

Code review on PR #20684 (head a9185a8): changes needed.

Read against the diff and main; nothing was run. The change is safe for stored data: nothing deletes a collection. Removing the rollback test is right, since that failure mode is gone.

Severity Where Finding Fix
High llc/kb/sprint_summarizer.py:205-227, _fetch_documents It treats a missing collection as empty only on "not found" or "does not exist". The adapter raises no such collection: {name} (async_chromadb_adapter.py:184), which matches neither. It was dormant because ensure_collection guaranteed the collection. Now a sprint with no writes makes summarize_and_merge abort, sprint_autoclose.py:271 only logs, and the summary and merge never run. Use get_collection_or_none, as rag_assembler.py:208 does. Test closing a sprint with no collection.
Medium work_item_kb.py:171, artifact_ingestor.py:103 These writers pass no metadata, while the old creator set entity_type and entity_id. No reader filters on them today, but metadata can't change after creation. Pass the same metadata, or state that it's dropped on purpose.
Medium collections.py:7-8, companies.py:303 Both still describe collections as created on entity creation. Update them.
Low Tests Nothing pins that creating a company, project, sprint or work item succeeds with the KB client raising. The new test only asserts a mock wasn't awaited. Add it.
Low test_kb_collections_lazy_19725.py The guard misses "work_item:" + id, .format(), and direct get_or_create_collection in a handler, and has no negative control. Widen it and add one.

ensure_collection: keep it for now, with an issue-linked reason. Tests still use it, no scripts do, and the open approval-gated health-scan proposal on #19725 is its natural caller. Deleting it isn't justified yet.

Not checked: what cli/doctor.py:82 does with list_collections, the vector browser, the health scan, and any host.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

✅ SSOT Configuration Compliance: Passing

🎉 No new hardcoded values of either class — ssot and other both block.

Known backlog in pipeline-scripts/hardcoded_values_baseline.txt is suppressed and tracked in #14371.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Notice: 29 open PRs — past the runaway threshold (25)

This is not a request to defer this PR. There is no cap on open PRs (#19397) -- nothing blocks opening or pushing a PR.

This notice only means the count is high enough to be worth a glance for a runaway — something opening PRs in a loop, or a merge pipeline that has stalled so nothing is draining.

Currently open:

If the queue is draining normally, ignore this. Otherwise:

  1. Check whether CI is dispatching at all — see the ci-dispatch-watchdog status on these PRs
  2. Approved PRs land through the merge train the coordinator sequences (merge commits, never squash) -- check the open chore(merge-train) PR is moving, not each PR on its own
  3. Look for a loop opening near-identical PRs

Warn-only runaway detector — .github/workflows/pr-queue-gate.yml. It never blocks a merge.

@mrveiss

mrveiss commented Nov 2, 2026

Copy link
Copy Markdown
Owner Author

Code review on PR #20684 (head a42688e): approve.

Covers the delta since a9185a8, read against the diff; tests not run. _fetch_documents now uses get_collection_or_none, with a test that a missing collection reads as empty. That covers the fetch step, not a full sprint close through summarize_and_merge, as the body says. Both writers pass entity_type and entity_id, the stale comments are fixed, and ensure_collection stays with a reason linked to #19725.

Left open, not blocking: the guard misses "work_item:" + id and .format() forms, and only the company create is pinned against a KB failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

phase:M1.8 Knowledge base: upload, web sources and chat retrieval work end to end

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant