Repository navigation
Propose the knowledge database - #125
Conversation
nlundee
left a comment
There was a problem hiding this comment.
Solid work, and good that it rests on the spikes. I agree with the direction, but it's not ready to approve yet. These need to be settled first:
- Deletion shouldn't follow absence (
0039:28). A missing catalog entry triggersknowledge.drop, so a wrongPGHOSTor an old restore could delete every dataset. Delete from an explicit deletion record that the handler re-checks. - Erasure (
0040:73-82,:154). Marker getscache=trueand keeps every PDF; ids with paths end up in tombstones and jobs; restores bring withdrawn documents back; no pg-boss retention; ADR 0011 needs amending. The tombstone title is also described two ways. - Run lifecycle (
0039:31,:52). Admission never expires on runs that can stay open for nights, and the needed statuses (queued, waiting, cancelled) don't exist yet. Our current 6-hour stale-run sweep would also kill these runs. - #108 solves the same issue (#107) with different ownership rules: there a disabled pipeline loses its documents, deletion happens as a side effect of a sibling's run, and the first run after the upgrade drops unattributed documents. @bdb-dd, could #108 follow 0040's rules as an interim step on today's tables (disabled keeps documents, explicit removal run, refuse instead of dropping)? Then 0040 can reference it.
- What it commits us to: full Kudos corpus, removing the shared Typesense (#150), Kudos
global(#131), and a 64 GiB server with standby. I'd like these as explicit decisions with cost, not implied by issues.
Smaller: the reader role's grants on pgboss; that #123/#120 rules apply in the worker; residency for server, backups and Blob; evidence links pointing at tags; and ADR numbers (0039/0040 collide with #100, #109 and #117).
Could 0039 (pg-boss) go in on its own first? It's the smallest piece and fixes real problems we have today.
35c5612 to
6fbfb7c
Compare
|
Thanks, all fair. I've split it as you suggested, and fixed the rest in the knowledge record. Split. Durable jobs is now its own record and PR: ADR 0041 in #179, with the
Smaller:
|
36c6b6e to
c5c0fc4
Compare
6fbfb7c to
bef4fba
Compare
There was a problem hiding this comment.
Every point from the last review is answered, and the record is much stronger for it: deletion only from a deletion version that the drop reads again, the server bound to its platform server, withdrawals logged where a restore can't undo them, queued and waiting runs with admission that runs out, ownership per pipeline, and the commitments moved to #175 with real prices. Fine to merge as a proposed record once #179 is in.
The record also finds three defects on main today. They shouldn't wait for the build, and they already have their own issues: #128 (autovacuum beside HNSW writes on pgvector 0.8.2), #127 (the Marker client's cache=true and five-minute timeout) and #129 (the reranker's residency). Worth doing those first.
One suggestion: the tombstones and the withdrawal log keep a plain sha256 of the id. For guessable ids, such as folder paths with a name in them, anyone with the table can confirm a guess, and the same document gives the same hash in every dataset. An HMAC with a key per dataset costs nothing extra and closes both.
Approving.
bef4fba to
bd51b15
Compare
|
Thanks. The HMAC is in 2058e37: tombstones and It isn't quite free: the key can never be rotated, since the ids are gone and old entries can't be hashed again, and it must outlive every dataset, or withdrawn documents come back on the next run. A check value on the platform server turns a lost or replaced key into a readiness failure for the worker and a refusal for withdrawals. Chunk ids stay plain hashes, since the answers that keep them also keep the title and excerpts. The branch is rebased onto main now that #179 is merged. #186, #187 and #188 were already tracked as #128 (draft PR #183), #127 and #129, so I closed them as duplicates and moved the one new check from #186, rebuilding indexes already damaged on test and production, into #128. |
Squashed from the branch's earlier commits: - Propose the knowledge database and durable jobs on pg-boss - Count Kudos pages from the KUDOS listing in ADR 0040 - Give the API and the worker their own logins, and let a switch into the knowledge database follow jobs - Draw how the knowledge database's parts meet and how a dataset moves in - Move the knowledge jobs into ADR 0042, delete only from a record and leave the Kudos commitments to their own decisions - Let the API only send jobs on the platform server
A plain sha256 of a listed or guessable id lets anyone holding the withdrawal log, a backup or the Blob copy confirm which documents were withdrawn, and matches the same document across datasets. HMAC under a key per dataset, derived from one Key Vault secret that neither database holds, closes both. A stored check value makes a lost or replaced key fail readiness instead of letting withdrawn documents back in.
bd51b15 to
2058e37
Compare
nlundee
left a comment
There was a problem hiding this comment.
Makes sense. A leaked key only takes us back to the plain-hash baseline, so not rotating it is fine, and purge protection on the vault covers losing it. Approved as is.
What and why
Kudos is too large for today's pgvector setup: every run rebuilds a whole generation in tables shared with every dataset on the platform database, and nothing between the source and the index is kept. ADR 0042 sets out how genki keeps its own knowledge data instead. Nothing in the code changes yet. It runs on the job queue that ADR 0041 proposes (#179, merged).
Standard_D2ds_v5with no standby and bound to its platform server. The API and the worker log in with their own identities; the API reads only throughSECURITY DEFINERfunctions and has no rights on the job tables there.queuedandwaitingbeside today's states; a listed source deletes only after two complete listings; a change brake on large runs.GLOSSARY.md, and the README row.The evidence is at the tags
evidence/knowledge-spikes,evidence/kudos-pilotandevidence/ingestion-benchmark.GLOSSARY.mdalso comes with #100; this adds its Knowledge section. ADR numbers are settled at merge, since #100 and #117 both claim 0040.Part of digdir/kunnskapsassistenten#151. The build is in #127 to #151.
How it was tested
Checked the record against the code it names and the records it touches, through three reviews, the change request on this PR, and a review of the choices made in answer to it. Every finding is fixed or decided in the text.
Spikes in
pgvector/pgvector:0.8.2-pg17containers: attach 18.5 ms and detach 7.3 ms under full search load; recall 0.995 after 20 rounds of 1 % in-place changes; reads through definer functions take 0.09 to 0.12 ms on 301 partitions.Read pg-boss 12.38.0's
statelypolicy in its source: one job per state per key, so a second send in the same state returns nothing. The run queue therefore lives in the run records, not in pg-boss.Costs in Decide what moving Kudos into the knowledge database commits us to #175 from the Azure Retail Prices API.
npx prettier --check docs/adr GLOSSARY.md.npm run checkpasses (docs only)Checklist
packages/providers-*docs/architecture/modulesare updated if a contract, boundary or module changed