Merged in feature/chatbot1 (pull request #223)

Chatbot functionality

* baseline working

* missing test file

* more tests
This commit is contained in:
Jay Brown
2026-05-07 20:56:18 +00:00
parent 17fc813823
commit 72de690894
62 changed files with 19150 additions and 445 deletions
+23
View File
@@ -81,6 +81,29 @@ SELECT
FROM documents d
WHERE d.id = $1;
-- name: GetDocumentEnrichedForClient :one
-- Chatbot-scoped read: same column set as GetDocumentEnriched, but adds a
-- clientId filter so cross-client lookups miss with pgx.ErrNoRows.
-- Plan §5 mandates a clientId filter on every chatbot document/folder
-- read so document scope cannot leak between clients. documents.clientId
-- is the unquoted (lowercased) varchar column from migration 5.
SELECT
d.id,
d.clientId,
d.hash,
d.folderId,
d.filename,
d.originalPath,
d.file_size_bytes,
d.custom_schema_id,
EXISTS(
SELECT 1 FROM document_custom_metadata
WHERE document_id = d.id
) AS has_custom_metadata
FROM documents d
WHERE d.id = @id
AND d.clientId = @client_id;
-- name: LockDocumentForLegacyExtractionWrite :one
-- Milestone 2.5 parent-row lock acquired by CreateFieldExtraction as the
-- FIRST DML statement inside its transaction. Serializes with AssignSchema