Remove the knowledge modules #118 left unreachable - #124
Conversation
…pilotKit#118) CopilotKit#118 asked for the knowledge/ modules and the three tables to be dropped in a change that says so. This is the half that can be done now. server/src/knowledge/acl.ts, repository.ts and types.ts have no importer outside their own two test files. InMemoryKnowledgeRepository holds documents, chunks and ACLs in a Map in the process, which is the shape CopilotKit#21 took back, and canRead(actor, entries[]) filters ACL rows already pulled into memory rather than in SQL. Neither is a starting point for anything CopilotKit#119 describes. The three tables stay for now. PR CopilotKit#97 has not merged, so connectors/sync-persistence.ts still imports documents, chunks, document_acls, connector_cursors and sync_runs and writes to all of them; dropping the tables breaks typecheck there. It is already orphaned at runtime, its only caller being its own integration test, so this is a typecheck dependency rather than a live one, but it is CopilotKit#97's to remove. Left alone deliberately: connector_instances, which server/src/connectors.ts writes to from production code; connector_cursors and sync_runs, which are connector-side and go with CopilotKit#97; and webhook_subscriptions, which is referenced nowhere at all and wants its own change. Docs that describe pgvector holding knowledge records stay accurate while the tables exist and belong in the commit that drops them.
davidmckayv
left a comment
There was a problem hiding this comment.
Verified against origin/main, and every claim in the description holds.
Nothing outside the two deleted test files imports knowledge/acl, knowledge/repository or knowledge/types in any .ts, .tsx, .md, .json or .yaml in the tree. createSyncPersistence and runConnector each have exactly one caller and it is their own test, so sync-persistence.ts is a typecheck dependency on those three tables rather than a live writer. webhookSubscriptions is declared at core.ts:347 and appears nowhere else outside the migration SQL and the snapshots. All five checks pass.
You were right not to keep either module as a reference. InMemoryKnowledgeRepository holds the corpus in a process-local Map, which is the thing #21 took back, and canRead filters ACL rows in application memory when the predicate belongs in SQL. Pointing the next person at the version that has to be thrown away is worse than pointing them at nothing.
On your question: option 1. Wait for #97. It is open and it removes sync-persistence.ts and the worker runner, which is exactly the blocker you identified. Taking that file into the drop commit would overlap Guido's diff for no gain, and given the tables have no live writer there is nothing to be gained by hurrying.
Two things for whoever writes that commit. The data-loss note is right and belongs in the migration itself, plainly worded, plus an Upgrading entry. And the docs at docs/architecture.md:22 and README.md:221 go stale in the same commit that drops the tables, so they change there.
webhook_subscriptions and knowledge-agent.ts: flagging rather than sweeping up was the right call. Both are worth their own change.
Only CHANGELOG.md conflicted, in Upgrading and in Fixed, and both sides were entries added independently. Kept both. The knowledge modules main deleted in #124 are not referenced here, and this branch removes sync-persistence.ts and the worker connector runner, which was the only thing still importing the document tables. The migration chain needed no renumbering: main ends at 0007 and this adds 0008 and 0009.
What this changes
Removes the
knowledge/modules that #118 left with no importer, and records why the three tables have to wait.#118 closed with:
This is the half that can be done at
f1701d8.What went
server/src/knowledge/acl.ts,repository.ts,types.ts— the directory is goneserver/tests/knowledge-acl.test.ts(3 tests) andserver/tests/knowledge-repository.test.ts(2 tests), which were the only importersAcross every
.ts,.tsx,.md,.yamland.jsonin the repo, nothing else referenced them.They are also not a head start on anything #119 wants.
InMemoryKnowledgeRepositoryholds documents, chunks and ACLs in aMapin the server process — the shape #21 took back, for the reason #21 gives.canRead(actor, entries[])filters ACL rows already pulled into memory, where the rule this repo follows is that the predicate belongs in SQL. Keeping either as a reference would point the next person at the version that has to be thrown away.Why the tables are still here
#97 has not merged.
server/src/connectors/sync-persistence.tsstill importsdocuments,chunks,document_acls,connector_cursorsandsync_runsand writes to all of them, so dropping the tables and their schema exports failstypecheckin that file. #118's scope note assumed #97 had landed; only the first half of that condition holds today.Worth adding, because it decides how urgent this is:
sync-persistence.tsis already orphaned at runtime.createSyncPersistence's only caller is its own integration test (server/tests/sync-persistence.integration.test.ts:53), and nothing inserver/srcwires it up. Same forrunConnector, called only fromworker/tests/connector-runner.test.ts. So this is a typecheck dependency, not a live one — nothing is writing to those tables in a running deployment.Two ways to finish it, and it is your call which:
sync-persistence.tsand the worker runner. The drop then becomes a clean schema-only commit, which is what Do not search documents out of our own database #118 described.sync-persistence.tsinto that commit, which removes more than the tables and overlaps Answer from Google Drive, as the person asking #97's diff.Happy to do either. The second overlaps #97's diff, which is the reason this PR stops at the modules.
Adjacent, and deliberately left
connector_instances— live.server/src/connectors.tsselects, updates and inserts against it from production code.connector_cursors,sync_runs— referenced only bysync-persistence.tsandschema.test.ts. Connector-side rather than document-index, so they go or stay with Answer from Google Drive, as the person asking #97.webhook_subscriptions(core.ts:347) — referenced nowhere at all, not even a test. Genuinely dead, but it is connector plumbing rather than the document index, and removing it here would be scope creep on my own reading. Flagging it instead.server/src/agents/knowledge-agent.ts— also has no caller but its own test, and it sits inagents/rather thanknowledge/, so it is outside what Do not search documents out of our own database #118 named. It takes an injectedsearchport, which is at least the shape K3 — Search is a tool call, and retrieval belongs over the tools #119 endorses. Mentioning it rather than quietly deleting it.docs/architecture.md:22andREADME.md:221describe pgvector holding "knowledge records", which stays true while the tables exist. Those paragraphs become wrong in the same commit that drops them, so they belong there.Where it runs
All five answers are none. No new state outliving a request, nothing different on a second replica, nothing serialised, nothing fanned out to a browser, no new listener, port or schedule. This deletes in-memory modules that had no callers.
Boundary and audit
Changelog
No entry. Nothing runtime-reachable changed and no schema moved, so no deployment behaves differently. #118's existing
Unreleased → Changedentry already states the direction and names the three tables.For whoever writes the commit that drops them: it destroys data.
DROP TABLE documents CASCADEtakes the chunk and ACL rows with it, and any deployment that connected a source before #113 was reverted has real rows there. That needs a plainly worded comment in the migration and an "Upgrading" entry, because rollback cannot recover it.Proof
No migration and no schema change, so the
migrationsjob has nothing to react to. Both of its steps run clean and leave the tree alone:Against unmodified
mainatf1701d8on this machine:mainbun run testbunx biome lint .format:check/typecheck/buildThe whole difference is the 5 tests in the 2 deleted files. The 112 failures are the Postgres integration set, unchanged; there is no database and no Docker here and they fail the same way on a clean checkout, which is what the CI
testsjob runs pgvector for. 1033 is well clear of the 400-test floor inscripts/test-ci.ts.