Repository navigation
feat(api): search saved documents by title and content - #48
Conversation
Co-authored-by: OpenAI Codex <noreply@openai.com>
|
Offline evidence for document search at commit The backend gate lists the 24 new Backend gate output, 196 passedFrontend gate output, 15 passedOffline startup fixture and exact commandA temporary """Offline startup proof only. No live credentials or Slack calls."""
from datetime import datetime
from unittest.mock import patch
patch("slack_sdk.WebClient.auth_test", return_value={
"ok": True, "bot_id": "BTEST", "user_id": "UTEST", "team_id": "TTEST",
}).start()
patch("slack_sdk.WebClient.api_call", side_effect=AssertionError("Slack calls blocked")).start()
patch("slack_bolt.adapter.socket_mode.SocketModeHandler.start",
side_effect=AssertionError("Socket Mode blocked")).start()
from app.database import Base, Document, SessionLocal, engine
Base.metadata.create_all(bind=engine)
with SessionLocal() as db:
if not db.query(Document).count():
for title, content, source in [
("VPN guide", "Reset via IT portal.", "api"),
("Remote access", "VPN for new starters.", "api"),
("VPN notes", "Support-only reference.", "docs"),
("Budget", "100% complete. See setup_notes.", "docs"),
]:
db.add(Document(title=title, content=content, source=source,
created_at=datetime(2026, 1, 1, 9)))
db.commit()env -i HOME="$HOME" PATH="$PATH" UV_PYTHON=3.13 \
PYTHONPATH="$PWD/.tmp/proof/fixture:$PWD/backend" \
DATABASE_URL="sqlite:///$PWD/.tmp/proof/documents.sqlite3" \
SLACK_BOT_TOKEN=xoxb-fixture-only SLACK_SIGNING_SECRET=fixture-only \
mise run dev-backendObserved Request and response transcript |
Add optional
qsearch toGET /api/documentsso operators can find saved documents by a literal, case-insensitive substring in the title or full content. The trimmed search combines with the source filter before counting and pagination, with blank queries preserving the current behaviour.Part of #5. Closes #47.
Verification
All commands ran with an empty inherited environment apart from
HOMEandPATH. No.envor real tokens were read or changed.mise run installinitially failed because uv selected Python 3.14 and the pinned onnxruntime has no compatible wheel.UV_PYTHON=3.13 mise run installthen passed for all three dependency sets. Python 3.13 is the version declared inmise.toml. Incidental lockfile rewrites were discarded.UV_PYTHON=3.13 mise run test-backendpassed, 196 tests including 24 new document search cases. Existing dependency and lifecycle deprecation warnings remain.mise run test-frontendpassed, 15 tests and 92 assertions.UV_PYTHON=3.13 mise run dev-backendreachedApplication startup complete.and served HTTP 200 for/healthand all search requests below. Stopped after capture.git diff --checkpassed.Proof
Capture method (a) succeeded using the real FastAPI routes and a temporary local SQLite database seeded with four fixture documents. Slack
auth_testreturned a fixture response, while Slack API calls and Socket Mode startup were patched to raise. No model, embeddings, Chroma service, remote database or live Slack connection was used. No live Slack verification is needed for this endpoint.The complete test output, fixture setup and curl transcript are attached in the evidence comment. The curl transcript is also saved locally at
.tmp/proof/documents-search-curl.txt.Review notes
The API behaviour changed; the dashboard UI did not change. Screenshot capture is not applicable, and no capture path was blocked. Database tests and the startup transcript use SQLite, so PostgreSQL-specific collation behaviour and performance at production scale were not measured. This is substring filtering over saved records, not semantic retrieval; no migration is needed.