diff --git a/.tmp/proof/dashboard-delete-api.txt b/.tmp/proof/dashboard-delete-api.txt new file mode 100644 index 0000000..caf30d3 --- /dev/null +++ b/.tmp/proof/dashboard-delete-api.txt @@ -0,0 +1,69 @@ +Local fixture data only. SQLite, local Chroma and fixed embeddings; Slack API calls and Socket Mode blocked. +Before dashboard deletion: +$ curl -sS -i http://127.0.0.1:18057/api/documents?limit=20&offset=0 +HTTP/1.1 200 OK +date: Mon, 16 Nov 2026 10:22:10 GMT +server: uvicorn +content-length: 445 +content-type: application/json + +{"items":[{"id":2,"title":"Office hours","source":"fixture docs","created_at":"2026-11-16T10:21:52.115878","content_preview":"The service desk is available from 9am to 5pm, Monday to Friday."},{"id":1,"title":"VPN access guide","source":"fixture docs","created_at":"2026-11-16T10:21:52.045466","content_preview":"Reset VPN access through the IT portal. Contact the service desk if access is still unavailable."}],"total":2,"limit":20,"offset":0} +$ curl -sS -i http://127.0.0.1:18057/api/documents/1 +HTTP/1.1 200 OK +date: Mon, 16 Nov 2026 10:22:10 GMT +server: uvicorn +content-length: 252 +content-type: application/json + +{"id":1,"title":"VPN access guide","content":"Reset VPN access through the IT portal. Contact the service desk if access is still unavailable.","source":"fixture docs","created_at":"2026-11-16T10:21:52.045466","updated_at":"2026-11-16T10:21:52.045472"} +$ ['curl', '-sS', '-i', 'http://127.0.0.1:18057/api/retrieval/preview', '-H', 'Content-Type: application/json', '-d', '{"question":"How do I reset VPN?"}'] +HTTP/1.1 200 OK +date: Mon, 16 Nov 2026 10:22:34 GMT +server: uvicorn +content-length: 494 +content-type: application/json + +{"question":"How do I reset VPN?","channel_id":null,"top_k":5,"max_distance":null,"items":[{"content":"The service desk is available from 9am to 5pm, Monday to Friday.","metadata":{"chunk":0,"document_id":2,"source":"fixture docs","title":"Office hours"},"distance":1521.0},{"content":"Reset VPN access through the IT portal. Contact the service desk if access is still unavailable.","metadata":{"chunk":0,"document_id":1,"source":"fixture docs","title":"VPN access guide"},"distance":5041.0}]} +After dashboard confirmation with fixture fail-delete marker: DELETE returned 503 (see browser request log). Saved record remains readable. +$ curl -sS -i http://127.0.0.1:18057/api/documents/1 +HTTP/1.1 200 OK +date: Mon, 16 Nov 2026 10:23:24 GMT +server: uvicorn +content-length: 252 +content-type: application/json + +{"id":1,"title":"VPN access guide","content":"Reset VPN access through the IT portal. Contact the service desk if access is still unavailable.","source":"fixture docs","created_at":"2026-11-16T10:21:52.045466","updated_at":"2026-11-16T10:21:52.045472"} +After retrying Confirm deletion in the dashboard (fixture outage removed): +$ curl -sS -i http://127.0.0.1:18057/api/documents?limit=20&offset=0 +HTTP/1.1 200 OK +date: Mon, 16 Nov 2026 10:23:44 GMT +server: uvicorn +content-length: 226 +content-type: application/json + +{"items":[{"id":2,"title":"Office hours","source":"fixture docs","created_at":"2026-11-16T10:21:52.115878","content_preview":"The service desk is available from 9am to 5pm, Monday to Friday."}],"total":1,"limit":20,"offset":0} +$ curl -sS -i http://127.0.0.1:18057/api/documents/1 +HTTP/1.1 404 Not Found +date: Mon, 16 Nov 2026 10:23:44 GMT +server: uvicorn +content-length: 31 +content-type: application/json + +{"detail":"Document not found"} +$ curl -sS -i http://127.0.0.1:18057/api/documents/2 +HTTP/1.1 200 OK +date: Mon, 16 Nov 2026 10:23:44 GMT +server: uvicorn +content-length: 216 +content-type: application/json + +{"id":2,"title":"Office hours","content":"The service desk is available from 9am to 5pm, Monday to Friday.","source":"fixture docs","created_at":"2026-11-16T10:21:52.115878","updated_at":"2026-11-16T10:21:52.115881"} +$ ['curl', '-sS', '-i', 'http://127.0.0.1:18057/api/retrieval/preview', '-H', 'Content-Type: application/json', '-d', '{"question":"How do I reset VPN?"}'] +HTTP/1.1 200 OK +date: Mon, 16 Nov 2026 10:23:44 GMT +server: uvicorn +content-length: 275 +content-type: application/json + +{"question":"How do I reset VPN?","channel_id":null,"top_k":5,"max_distance":null,"items":[{"content":"The service desk is available from 9am to 5pm, Monday to Friday.","metadata":{"chunk":0,"document_id":2,"source":"fixture docs","title":"Office hours"},"distance":1521.0}]} +Assertions passed: only document 2 remains saved and retrievable. Raw distances use fixed fixture vectors and do not measure production relevance. diff --git a/.tmp/proof/dashboard-delete-backend-start.txt b/.tmp/proof/dashboard-delete-backend-start.txt new file mode 100644 index 0000000..26f22df --- /dev/null +++ b/.tmp/proof/dashboard-delete-backend-start.txt @@ -0,0 +1,59 @@ +[dev-backend] $ uv run uvicorn app.main:app --reload --host 127.0.0.1 --port 18… +/Users/johnny/.paseo/worktrees/0x03bguv/peaceful-whale/.tmp/offline-dashboard-delete/sitecustomize.py:39: LangChainDeprecationWarning: The class `Chroma` was deprecated in LangChain 0.2.9 and will be removed in 1.0. An updated version of the class exists in the `langchain-chroma package and should be used instead. To use it run `pip install -U `langchain-chroma` and import as `from `langchain_chroma import Chroma``. + vector_store.vector_store = Chroma( +INFO: Will watch for changes in these directories: ['/Users/johnny/.paseo/worktrees/0x03bguv/peaceful-whale/backend'] +INFO: Uvicorn running on http://127.0.0.1:18057 (Press CTRL+C to quit) +INFO: Started reloader process [45710] using WatchFiles +/Users/johnny/.paseo/worktrees/0x03bguv/peaceful-whale/.tmp/offline-dashboard-delete/sitecustomize.py:39: LangChainDeprecationWarning: The class `Chroma` was deprecated in LangChain 0.2.9 and will be removed in 1.0. An updated version of the class exists in the `langchain-chroma package and should be used instead. To use it run `pip install -U `langchain-chroma` and import as `from `langchain_chroma import Chroma``. + vector_store.vector_store = Chroma( +/Users/johnny/.paseo/worktrees/0x03bguv/peaceful-whale/.tmp/offline-dashboard-delete/sitecustomize.py:39: LangChainDeprecationWarning: The class `Chroma` was deprecated in LangChain 0.2.9 and will be removed in 1.0. An updated version of the class exists in the `langchain-chroma package and should be used instead. To use it run `pip install -U `langchain-chroma` and import as `from `langchain_chroma import Chroma``. + vector_store.vector_store = Chroma( +INFO: Started server process [45729] +INFO: Waiting for application startup. +{"timestamp": "2026-11-16T10:21:32.220426+00:00", "level": "INFO", "service_name": "wingman-backend", "environment": "development", "service_version": "0.1.0", "logger": "app.main", "message": "Starting Wingman backend...", "event_type": "log", "request_id": null, "trace_id": null} +{"timestamp": "2026-11-16T10:21:32.234534+00:00", "level": "INFO", "service_name": "wingman-backend", "environment": "development", "service_version": "0.1.0", "logger": "app.main", "message": "Database initialized", "event_type": "log", "request_id": null, "trace_id": null} +INFO: Application startup complete. +INFO: 127.0.0.1:55662 - "GET /health HTTP/1.1" 200 OK +{"timestamp": "2026-11-16T10:21:51.977355+00:00", "level": "INFO", "service_name": "wingman-backend", "environment": "development", "service_version": "0.1.0", "logger": "wingman.wide_event", "message": "http_request", "event_type": "http_request", "request_id": "8c9c32616c3e456096938959b574932a", "trace_id": "8c9c32616c3e456096938959b574932a", "request_method": "GET", "request_path": "/health", "route": "/health", "status_code": 200, "duration_ms": 3.16, "error_class": null, "error_message": null, "sample_reason": "RANDOM"} +INFO: 127.0.0.1:55667 - "POST /api/documents HTTP/1.1" 200 OK +{"timestamp": "2026-11-16T10:21:52.102182+00:00", "level": "INFO", "service_name": "wingman-backend", "environment": "development", "service_version": "0.1.0", "logger": "wingman.wide_event", "message": "http_request", "event_type": "http_request", "request_id": "0ef1cb262eed4c29bcf2cdee05dcf589", "trace_id": "0ef1cb262eed4c29bcf2cdee05dcf589", "request_method": "POST", "request_path": "/api/documents", "route": "/api/documents", "status_code": 200, "duration_ms": 100.1, "error_class": null, "error_message": null, "sample_reason": "RANDOM"} +INFO: 127.0.0.1:55669 - "POST /api/documents HTTP/1.1" 200 OK +{"timestamp": "2026-11-16T10:21:52.120299+00:00", "level": "INFO", "service_name": "wingman-backend", "environment": "development", "service_version": "0.1.0", "logger": "wingman.wide_event", "message": "http_request", "event_type": "http_request", "request_id": "ec6ac3c91f1c4ec381fc54a27fd02a1a", "trace_id": "ec6ac3c91f1c4ec381fc54a27fd02a1a", "request_method": "POST", "request_path": "/api/documents", "route": "/api/documents", "status_code": 200, "duration_ms": 4.94, "error_class": null, "error_message": null, "sample_reason": "RANDOM"} +INFO: 127.0.0.1:55735 - "GET /api/documents?limit=20&offset=0 HTTP/1.1" 200 OK +{"timestamp": "2026-11-16T10:22:11.180480+00:00", "level": "INFO", "service_name": "wingman-backend", "environment": "development", "service_version": "0.1.0", "logger": "wingman.wide_event", "message": "http_request", "event_type": "http_request", "request_id": "f80e6280bb404f18ab4cbf29ef5d92cd", "trace_id": "f80e6280bb404f18ab4cbf29ef5d92cd", "request_method": "GET", "request_path": "/api/documents", "route": "/api/documents", "status_code": 200, "duration_ms": 29.27, "error_class": null, "error_message": null, "sample_reason": "RANDOM"} +INFO: 127.0.0.1:55736 - "GET /api/documents?limit=20&offset=0 HTTP/1.1" 200 OK +{"timestamp": "2026-11-16T10:22:11.181765+00:00", "level": "INFO", "service_name": "wingman-backend", "environment": "development", "service_version": "0.1.0", "logger": "wingman.wide_event", "message": "http_request", "event_type": "http_request", "request_id": "9b3292b8e7744a5a8decd3a4147a2f00", "trace_id": "9b3292b8e7744a5a8decd3a4147a2f00", "request_method": "GET", "request_path": "/api/documents", "route": "/api/documents", "status_code": 200, "duration_ms": 1.55, "error_class": null, "error_message": null, "sample_reason": "RANDOM"} +INFO: 127.0.0.1:55740 - "GET /api/documents?limit=20&offset=0 HTTP/1.1" 200 OK +{"timestamp": "2026-11-16T10:22:11.621889+00:00", "level": "INFO", "service_name": "wingman-backend", "environment": "development", "service_version": "0.1.0", "logger": "wingman.wide_event", "message": "http_request", "event_type": "http_request", "request_id": "07c365dfb0204094b09fd731f0620d44", "trace_id": "07c365dfb0204094b09fd731f0620d44", "request_method": "GET", "request_path": "/api/documents", "route": "/api/documents", "status_code": 200, "duration_ms": 2.19, "error_class": null, "error_message": null, "sample_reason": "RANDOM"} +INFO: 127.0.0.1:55741 - "GET /api/documents/1 HTTP/1.1" 200 OK +{"timestamp": "2026-11-16T10:22:11.645831+00:00", "level": "INFO", "service_name": "wingman-backend", "environment": "development", "service_version": "0.1.0", "logger": "wingman.wide_event", "message": "http_request", "event_type": "http_request", "request_id": "332ef0a3877e475eb4779618b7380487", "trace_id": "332ef0a3877e475eb4779618b7380487", "request_method": "GET", "request_path": "/api/documents/1", "route": "/api/documents/1", "status_code": 200, "duration_ms": 2.89, "error_class": null, "error_message": null, "sample_reason": "RANDOM"} +INFO: 127.0.0.1:55824 - "GET /api/documents/1 HTTP/1.1" 200 OK +{"timestamp": "2026-11-16T10:22:21.947560+00:00", "level": "INFO", "service_name": "wingman-backend", "environment": "development", "service_version": "0.1.0", "logger": "wingman.wide_event", "message": "http_request", "event_type": "http_request", "request_id": "32ed5dfb52964b758167d2c84e343172", "trace_id": "32ed5dfb52964b758167d2c84e343172", "request_method": "GET", "request_path": "/api/documents/1", "route": "/api/documents/1", "status_code": 200, "duration_ms": 2.07, "error_class": null, "error_message": null, "sample_reason": "RANDOM"} +{"timestamp": "2026-11-16T10:22:34.681912+00:00", "level": "WARNING", "service_name": "wingman-backend", "environment": "development", "service_version": "0.1.0", "logger": "chromadb.segment.impl.vector.local_persistent_hnsw", "message": "Number of requested results 5 is greater than number of elements in index 2, updating n_results = 2", "event_type": "log", "request_id": "156aac0401cf4418a5b850519dfe7f6f", "trace_id": "156aac0401cf4418a5b850519dfe7f6f"} +INFO: 127.0.0.1:55855 - "POST /api/retrieval/preview HTTP/1.1" 200 OK +{"timestamp": "2026-11-16T10:22:34.685230+00:00", "level": "INFO", "service_name": "wingman-backend", "environment": "development", "service_version": "0.1.0", "logger": "wingman.wide_event", "message": "http_request", "event_type": "http_request", "request_id": "156aac0401cf4418a5b850519dfe7f6f", "trace_id": "156aac0401cf4418a5b850519dfe7f6f", "request_method": "POST", "request_path": "/api/retrieval/preview", "route": "/api/retrieval/preview", "status_code": 200, "duration_ms": 6.57, "error_class": null, "error_message": null, "sample_reason": "RANDOM"} +INFO: 127.0.0.1:55974 - "OPTIONS /api/documents/1 HTTP/1.1" 200 OK +{"timestamp": "2026-11-16T10:22:57.910347+00:00", "level": "ERROR", "service_name": "wingman-backend", "environment": "development", "service_version": "0.1.0", "logger": "app.main", "message": "Deleting saved document 1 failed", "event_type": "log", "request_id": "666ef22b403d4905aff9d7a211e39107", "trace_id": "666ef22b403d4905aff9d7a211e39107", "error_class": "RuntimeError", "error_message": "Fixture Chroma deletion outage", "error_stack_hash": "78e8be9781eb075d"} +INFO: 127.0.0.1:55974 - "DELETE /api/documents/1 HTTP/1.1" 503 Service Unavailable +{"timestamp": "2026-11-16T10:22:57.912094+00:00", "level": "INFO", "service_name": "wingman-backend", "environment": "development", "service_version": "0.1.0", "logger": "wingman.wide_event", "message": "http_request", "event_type": "http_request", "request_id": "666ef22b403d4905aff9d7a211e39107", "trace_id": "666ef22b403d4905aff9d7a211e39107", "request_method": "DELETE", "request_path": "/api/documents/1", "route": "/api/documents/1", "status_code": 503, "duration_ms": 6.77, "error_class": null, "error_message": null, "sample_reason": "ERROR"} +INFO: 127.0.0.1:56075 - "GET /api/documents/1 HTTP/1.1" 200 OK +{"timestamp": "2026-11-16T10:23:24.808294+00:00", "level": "INFO", "service_name": "wingman-backend", "environment": "development", "service_version": "0.1.0", "logger": "wingman.wide_event", "message": "http_request", "event_type": "http_request", "request_id": "eaec2398806241b89fdbe5907f57fb87", "trace_id": "eaec2398806241b89fdbe5907f57fb87", "request_method": "GET", "request_path": "/api/documents/1", "route": "/api/documents/1", "status_code": 200, "duration_ms": 2.08, "error_class": null, "error_message": null, "sample_reason": "RANDOM"} +INFO: 127.0.0.1:56087 - "DELETE /api/documents/1 HTTP/1.1" 200 OK +{"timestamp": "2026-11-16T10:23:25.563519+00:00", "level": "INFO", "service_name": "wingman-backend", "environment": "development", "service_version": "0.1.0", "logger": "wingman.wide_event", "message": "http_request", "event_type": "http_request", "request_id": "a5c74eba8a7544cea3d9de591630a8ec", "trace_id": "a5c74eba8a7544cea3d9de591630a8ec", "request_method": "DELETE", "request_path": "/api/documents/1", "route": "/api/documents/1", "status_code": 200, "duration_ms": 10.45, "error_class": null, "error_message": null, "sample_reason": "RANDOM"} +INFO: 127.0.0.1:56087 - "GET /api/documents?limit=20&offset=0 HTTP/1.1" 200 OK +{"timestamp": "2026-11-16T10:23:25.575573+00:00", "level": "INFO", "service_name": "wingman-backend", "environment": "development", "service_version": "0.1.0", "logger": "wingman.wide_event", "message": "http_request", "event_type": "http_request", "request_id": "cd701f742a364f3a9db6311f6db182c0", "trace_id": "cd701f742a364f3a9db6311f6db182c0", "request_method": "GET", "request_path": "/api/documents", "route": "/api/documents", "status_code": 200, "duration_ms": 5.2, "error_class": null, "error_message": null, "sample_reason": "RANDOM"} +INFO: 127.0.0.1:56151 - "GET /api/documents?limit=20&offset=0 HTTP/1.1" 200 OK +{"timestamp": "2026-11-16T10:23:45.473032+00:00", "level": "INFO", "service_name": "wingman-backend", "environment": "development", "service_version": "0.1.0", "logger": "wingman.wide_event", "message": "http_request", "event_type": "http_request", "request_id": "baabca86fb684e5e850d6d54034e6595", "trace_id": "baabca86fb684e5e850d6d54034e6595", "request_method": "GET", "request_path": "/api/documents", "route": "/api/documents", "status_code": 200, "duration_ms": 2.28, "error_class": null, "error_message": null, "sample_reason": "RANDOM"} +INFO: 127.0.0.1:56152 - "GET /api/documents/1 HTTP/1.1" 404 Not Found +{"timestamp": "2026-11-16T10:23:45.485340+00:00", "level": "INFO", "service_name": "wingman-backend", "environment": "development", "service_version": "0.1.0", "logger": "wingman.wide_event", "message": "http_request", "event_type": "http_request", "request_id": "f093d34b9b334c6f8bf7bec438cd2a5a", "trace_id": "f093d34b9b334c6f8bf7bec438cd2a5a", "request_method": "GET", "request_path": "/api/documents/1", "route": "/api/documents/1", "status_code": 404, "duration_ms": 1.1, "error_class": null, "error_message": null, "sample_reason": "RANDOM"} +INFO: 127.0.0.1:56153 - "GET /api/documents/2 HTTP/1.1" 200 OK +{"timestamp": "2026-11-16T10:23:45.498522+00:00", "level": "INFO", "service_name": "wingman-backend", "environment": "development", "service_version": "0.1.0", "logger": "wingman.wide_event", "message": "http_request", "event_type": "http_request", "request_id": "550287a7ad3647a39dbe9c41efa19ee6", "trace_id": "550287a7ad3647a39dbe9c41efa19ee6", "request_method": "GET", "request_path": "/api/documents/2", "route": "/api/documents/2", "status_code": 200, "duration_ms": 1.03, "error_class": null, "error_message": null, "sample_reason": "RANDOM"} +{"timestamp": "2026-11-16T10:23:45.510444+00:00", "level": "WARNING", "service_name": "wingman-backend", "environment": "development", "service_version": "0.1.0", "logger": "chromadb.segment.impl.vector.local_persistent_hnsw", "message": "Number of requested results 5 is greater than number of elements in index 1, updating n_results = 1", "event_type": "log", "request_id": "9c2211f72aec4463a40a063e02582e18", "trace_id": "9c2211f72aec4463a40a063e02582e18"} +INFO: 127.0.0.1:56154 - "POST /api/retrieval/preview HTTP/1.1" 200 OK +{"timestamp": "2026-11-16T10:23:45.511866+00:00", "level": "INFO", "service_name": "wingman-backend", "environment": "development", "service_version": "0.1.0", "logger": "wingman.wide_event", "message": "http_request", "event_type": "http_request", "request_id": "9c2211f72aec4463a40a063e02582e18", "trace_id": "9c2211f72aec4463a40a063e02582e18", "request_method": "POST", "request_path": "/api/retrieval/preview", "route": "/api/retrieval/preview", "status_code": 200, "duration_ms": 2.7, "error_class": null, "error_message": null, "sample_reason": "RANDOM"} +INFO: Shutting down +INFO: Waiting for application shutdown. +{"timestamp": "2026-11-16T10:24:31.839773+00:00", "level": "INFO", "service_name": "wingman-backend", "environment": "development", "service_version": "0.1.0", "logger": "app.main", "message": "Shutting down Wingman backend...", "event_type": "log", "request_id": null, "trace_id": null} +INFO: Application shutdown complete. +INFO: Finished server process [45729] +INFO: Stopping reloader process [45710] diff --git a/.tmp/proof/dashboard-delete-backend-tests.txt b/.tmp/proof/dashboard-delete-backend-tests.txt new file mode 100644 index 0000000..25af3ea --- /dev/null +++ b/.tmp/proof/dashboard-delete-backend-tests.txt @@ -0,0 +1,294 @@ +[test-backend] $ uv run pytest tests/test_file_extraction_units.py tests/test_l… +============================= test session starts ============================== +platform darwin -- Python 3.13.13, pytest-9.0.2, pluggy-1.6.0 -- /Users/johnny/.paseo/worktrees/0x03bguv/peaceful-whale/backend/.venv/bin/python +cachedir: .pytest_cache +rootdir: /Users/johnny/.paseo/worktrees/0x03bguv/peaceful-whale/backend +configfile: pytest.ini (WARNING: ignoring pytest config in pyproject.toml!) +plugins: langsmith-0.5.2, anyio-4.12.0, asyncio-1.3.0 +asyncio: mode=Mode.STRICT, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function +collecting ... collected 221 items + +tests/test_file_extraction_units.py::test_extract_plain_text PASSED [ 0%] +tests/test_file_extraction_units.py::test_extract_markdown PASSED [ 0%] +tests/test_file_extraction_units.py::test_extract_python_file PASSED [ 1%] +tests/test_file_extraction_units.py::test_extract_json PASSED [ 1%] +tests/test_file_extraction_units.py::test_extract_csv PASSED [ 2%] +tests/test_file_extraction_units.py::test_extract_html PASSED [ 2%] +tests/test_file_extraction_units.py::test_extract_html_removes_scripts PASSED [ 3%] +tests/test_file_extraction_units.py::test_extract_with_encoding_errors PASSED [ 3%] +tests/test_file_extraction_units.py::test_extract_xml PASSED [ 4%] +tests/test_file_extraction_units.py::test_extract_yaml PASSED [ 4%] +tests/test_file_extraction_units.py::test_javascript_file_extraction PASSED [ 4%] +tests/test_file_extraction_units.py::test_typescript_file_extraction PASSED [ 5%] +tests/test_file_extraction_units.py::test_shell_script_extraction PASSED [ 5%] +tests/test_file_extraction_units.py::TestConversationIds::test_thread_conversation_id_format PASSED [ 6%] +tests/test_file_extraction_units.py::TestConversationIds::test_dm_conversation_id_format PASSED [ 6%] +tests/test_file_extraction_units.py::TestConversationIds::test_mention_conversation_id_format PASSED [ 7%] +tests/test_logging_config.py::test_json_schema_and_redaction_variants PASSED [ 7%] +tests/test_logging_config.py::test_error_hash_not_stack PASSED [ 8%] +tests/test_logging_config.py::test_wide_event_one_per_request PASSED [ 8%] +tests/test_logging.py::test_json_stdout_preserves_controls_and_avoids_duplicate_handlers[wingman-backend] PASSED [ 9%] +tests/test_logging.py::test_json_stdout_preserves_controls_and_avoids_duplicate_handlers[wingman-bot] PASSED [ 9%] +tests/test_logging.py::test_text_format_and_configured_level PASSED [ 9%] +tests/test_logging.py::test_api_keeps_backend_service_when_importing_bot PASSED [ 10%] +tests/test_agent_runtime.py::test_transport_retry_keeps_request_id PASSED [ 10%] +tests/test_agent_runtime.py::test_rag_routes_retrieved_context_and_stable_slack_identity PASSED [ 11%] +tests/test_agent_runtime.py::test_failed_job_surfaces_error PASSED [ 11%] +tests/test_rules.py::TestMatching::test_contains_is_case_insensitive PASSED [ 12%] +tests/test_rules.py::TestMatching::test_contains_needs_the_keyword PASSED [ 12%] +tests/test_rules.py::TestMatching::test_any_keyword_can_match PASSED [ 13%] +tests/test_rules.py::TestMatching::test_exact_needs_the_whole_question PASSED [ 13%] +tests/test_rules.py::TestMatching::test_regex_match PASSED [ 14%] +tests/test_rules.py::TestMatching::test_blank_question_never_matches PASSED [ 14%] +tests/test_rules.py::TestMatching::test_no_rules_is_a_no_op PASSED [ 14%] +tests/test_rules.py::TestOrderingAndEnabled::test_higher_priority_wins PASSED [ 15%] +tests/test_rules.py::TestOrderingAndEnabled::test_config_order_breaks_priority_ties PASSED [ 15%] +tests/test_rules.py::TestOrderingAndEnabled::test_disabled_rule_never_matches PASSED [ 16%] +tests/test_rules.py::TestConfigLoading::test_parse_valid_rules PASSED [ 16%] +tests/test_rules.py::TestConfigLoading::test_parse_skips_invalid_entries PASSED [ 17%] +tests/test_rules.py::TestConfigLoading::test_parse_skips_bad_regex PASSED [ 17%] +tests/test_rules.py::TestConfigLoading::test_parse_rejects_non_list PASSED [ 18%] +tests/test_rules.py::TestConfigLoading::test_load_from_json_text PASSED [ 18%] +tests/test_rules.py::TestConfigLoading::test_load_invalid_json_is_empty PASSED [ 19%] +tests/test_rules.py::TestConfigLoading::test_load_from_file_and_file_wins PASSED [ 19%] +tests/test_rules.py::TestConfigLoading::test_load_missing_file_is_empty PASSED [ 19%] +tests/test_rules.py::TestConfigLoading::test_from_settings_reads_both_fields PASSED [ 20%] +tests/test_rules.py::TestRagShortCircuit::test_matched_question_skips_retrieval_and_generation PASSED [ 20%] +tests/test_rules.py::TestRagShortCircuit::test_unmatched_question_still_uses_generation PASSED [ 21%] +tests/test_rules.py::TestSlackShortCircuit::test_matched_slack_question_skips_retrieval_and_carries_pinned_answer PASSED [ 21%] +tests/test_rules.py::TestSlackShortCircuit::test_unmatched_slack_question_uses_retrieval_without_pinned_answer PASSED [ 22%] +tests/test_conversations.py::TestListConversations::test_lists_summaries_most_recent_first PASSED [ 22%] +tests/test_conversations.py::TestListConversations::test_summary_counts_and_preview PASSED [ 23%] +tests/test_conversations.py::TestListConversations::test_pagination PASSED [ 23%] +tests/test_conversations.py::TestListConversations::test_channel_filter PASSED [ 23%] +tests/test_conversations.py::TestListConversations::test_channel_filter_scopes_preview_for_shared_conversation[C1] PASSED [ 24%] +tests/test_conversations.py::TestListConversations::test_channel_filter_scopes_preview_for_shared_conversation[C2] PASSED [ 24%] +tests/test_conversations.py::TestListConversations::test_unfiltered_preview_includes_latest_turn_across_channels PASSED [ 25%] +tests/test_conversations.py::TestListConversations::test_scoped_preview_breaks_timestamp_ties_by_latest_id PASSED [ 25%] +tests/test_conversations.py::TestListConversations::test_invalid_pagination_rejected PASSED [ 26%] +tests/test_conversations.py::TestListConversations::test_empty_database PASSED [ 26%] +tests/test_conversations.py::TestConversationDetail::test_returns_turns_in_chronological_order PASSED [ 27%] +tests/test_conversations.py::TestConversationDetail::test_detail_pagination PASSED [ 27%] +tests/test_conversations.py::TestConversationDetail::test_missing_conversation_is_404 PASSED [ 28%] +tests/test_conversations.py::TestConversationDetail::test_detail_invalid_pagination_rejected PASSED [ 28%] +tests/test_documents.py::TestListDocuments::test_lists_documents_most_recent_first PASSED [ 28%] +tests/test_documents.py::TestListDocuments::test_preview_and_fields PASSED [ 29%] +tests/test_documents.py::TestListDocuments::test_pagination PASSED [ 29%] +tests/test_documents.py::TestListDocuments::test_source_filter PASSED [ 30%] +tests/test_documents.py::TestListDocuments::test_invalid_pagination_rejected PASSED [ 30%] +tests/test_documents.py::TestListDocuments::test_empty_database PASSED [ 31%] +tests/test_documents.py::TestSearchDocuments::test_matches_title_case_insensitively_and_trims_query[vpn] PASSED [ 31%] +tests/test_documents.py::TestSearchDocuments::test_matches_title_case_insensitively_and_trims_query[VpN] PASSED [ 32%] +tests/test_documents.py::TestSearchDocuments::test_matches_title_case_insensitively_and_trims_query[ \tVPN\n ] PASSED [ 32%] +tests/test_documents.py::TestSearchDocuments::test_matches_content_beyond_the_preview PASSED [ 33%] +tests/test_documents.py::TestSearchDocuments::test_filters_before_counting_and_paginating PASSED [ 33%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[title-%] PASSED [ 33%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[title-_] PASSED [ 34%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[title-/] PASSED [ 34%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[title-100%] PASSED [ 35%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[title-setup_notes] PASSED [ 35%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[title-a/b] PASSED [ 36%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[title-' OR 1=1 --] PASSED [ 36%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[content-%] PASSED [ 37%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[content-_] PASSED [ 37%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[content-/] PASSED [ 38%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[content-100%] PASSED [ 38%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[content-setup_notes] PASSED [ 38%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[content-a/b] PASSED [ 39%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[content-' OR 1=1 --] PASSED [ 39%] +tests/test_documents.py::TestSearchDocuments::test_blank_query_preserves_source_filter_and_existing_list[] PASSED [ 40%] +tests/test_documents.py::TestSearchDocuments::test_blank_query_preserves_source_filter_and_existing_list[ \t\n ] PASSED [ 40%] +tests/test_documents.py::TestSearchDocuments::test_blank_query_preserves_source_filter_and_existing_list[\u2003\xa0] PASSED [ 41%] +tests/test_documents.py::TestSearchDocuments::test_no_matches_return_an_empty_page[params0] PASSED [ 41%] +tests/test_documents.py::TestSearchDocuments::test_no_matches_return_an_empty_page[params1] PASSED [ 42%] +tests/test_documents.py::TestDocumentDetail::test_returns_full_content PASSED [ 42%] +tests/test_documents.py::TestDocumentDetail::test_missing_document_is_404 PASSED [ 42%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[-title] PASSED [ 43%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[-content] PASSED [ 43%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[-source] PASSED [ 44%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[ \n\t -title] PASSED [ 44%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[ \n\t -content] PASSED [ 45%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[ \n\t -source] PASSED [ 45%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[\u2003\xa0-title] PASSED [ 46%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[\u2003\xa0-content] PASSED [ 46%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[\u2003\xa0-source] PASSED [ 47%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[None-title] PASSED [ 47%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[None-content] PASSED [ 47%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[None-source] PASSED [ 48%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[123-title] PASSED [ 48%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[123-content] PASSED [ 49%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[123-source] PASSED [ 49%] +tests/test_documents.py::TestCreateDocument::test_rejects_missing_required_fields[title] PASSED [ 50%] +tests/test_documents.py::TestCreateDocument::test_rejects_missing_required_fields[content] PASSED [ 50%] +tests/test_documents.py::TestCreateDocument::test_creates_readable_document_and_indexes_preserved_content[None] PASSED [ 51%] +tests/test_documents.py::TestCreateDocument::test_creates_readable_document_and_indexes_preserved_content[ \tdocs\n ] PASSED [ 51%] +tests/test_retrieval.py::test_invalid_chunk_settings_are_rejected[config0] PASSED [ 52%] +tests/test_retrieval.py::test_invalid_chunk_settings_are_rejected[config1] PASSED [ 52%] +tests/test_retrieval.py::test_invalid_chunk_settings_are_rejected[config2] PASSED [ 52%] +tests/test_retrieval.py::test_invalid_chunk_settings_are_rejected[config3] PASSED [ 53%] +tests/test_retrieval.py::test_invalid_chunk_settings_are_rejected[config4] PASSED [ 53%] +tests/test_retrieval.py::test_valid_chunk_settings_are_accepted[1000-200] PASSED [ 54%] +tests/test_retrieval.py::test_valid_chunk_settings_are_accepted[1-0] PASSED [ 54%] +tests/test_retrieval.py::test_valid_chunk_settings_are_accepted[10-0] PASSED [ 55%] +tests/test_retrieval.py::test_valid_chunk_settings_are_accepted[10-9] PASSED [ 55%] +tests/test_retrieval.py::test_document_chunks_stop_after_covering_content[-5-2-expected0] PASSED [ 56%] +tests/test_retrieval.py::test_document_chunks_stop_after_covering_content[a-5-2-expected1] PASSED [ 56%] +tests/test_retrieval.py::test_document_chunks_stop_after_covering_content[abcd-5-2-expected2] PASSED [ 57%] +tests/test_retrieval.py::test_document_chunks_stop_after_covering_content[abcde-5-2-expected3] PASSED [ 57%] +tests/test_retrieval.py::test_document_chunks_stop_after_covering_content[abcdef-5-2-expected4] PASSED [ 57%] +tests/test_retrieval.py::test_document_chunks_stop_after_covering_content[abcdefgh-5-2-expected5] PASSED [ 58%] +tests/test_retrieval.py::test_document_chunks_stop_after_covering_content[abcdefghi-5-2-expected6] PASSED [ 58%] +tests/test_retrieval.py::test_document_chunks_stop_after_covering_content[abcdefghij-5-0-expected7] PASSED [ 59%] +tests/test_retrieval.py::test_document_chunks_stop_after_covering_content[abcdef-5-4-expected8] PASSED [ 59%] +tests/test_retrieval.py::test_document_chunks_stop_after_covering_content[abc-1-0-expected9] PASSED [ 60%] +tests/test_retrieval.py::test_document_indexing_avoids_redundant_tail_chunks PASSED [ 60%] +tests/test_retrieval.py::test_repeated_thread_indexing_preserves_distinct_top_k PASSED [ 61%] +tests/test_retrieval.py::test_thread_reindex_updates_content_and_embedding PASSED [ 61%] +tests/test_retrieval.py::test_thread_chunk_ids_are_scoped_by_channel PASSED [ 61%] +tests/test_retrieval.py::test_thread_indexing_omits_absent_optional_metadata PASSED [ 62%] +tests/test_retrieval.py::test_thread_indexing_uses_last_duplicate_in_batch PASSED [ 62%] +tests/test_retrieval.py::test_thread_indexing_skips_unusable_messages[messages0] PASSED [ 63%] +tests/test_retrieval.py::test_thread_indexing_skips_unusable_messages[messages1] PASSED [ 63%] +tests/test_retrieval.py::test_thread_indexing_skips_unusable_messages[messages2] PASSED [ 64%] +tests/test_retrieval.py::test_thread_indexing_skips_unusable_messages[messages3] PASSED [ 64%] +tests/test_retrieval.py::test_thread_indexing_skips_unusable_messages[messages4] PASSED [ 65%] +tests/test_retrieval.py::test_thread_indexing_skips_unusable_messages[messages5] PASSED [ 65%] +tests/test_retrieval.py::test_thread_indexing_skips_unusable_messages[messages6] PASSED [ 66%] +tests/test_retrieval.py::test_search_empty_collection_returns_no_matches[None-None] PASSED [ 66%] +tests/test_retrieval.py::test_search_empty_collection_returns_no_matches[None-CTARGET] PASSED [ 66%] +tests/test_retrieval.py::test_search_empty_collection_returns_no_matches[1.0-None] PASSED [ 67%] +tests/test_retrieval.py::test_search_empty_collection_returns_no_matches[1.0-CTARGET] PASSED [ 67%] +tests/test_retrieval.py::test_first_document_can_be_indexed_and_retrieved PASSED [ 68%] +tests/test_retrieval.py::test_missing_adapter_still_raises[add] PASSED [ 68%] +tests/test_retrieval.py::test_missing_adapter_still_raises[search] PASSED [ 69%] +tests/test_retrieval.py::test_channel_filter_runs_before_top_k PASSED [ 69%] +tests/test_retrieval.py::test_unscoped_search_preserves_global_ranking_and_explicit_k PASSED [ 70%] +tests/test_retrieval.py::test_distance_cutoff_is_inclusive_and_preserves_channel_scope PASSED [ 70%] +tests/test_retrieval.py::test_zero_distance_cutoff_keeps_only_exact_vector_matches PASSED [ 71%] +tests/test_retrieval.py::test_invalid_distance_config_is_rejected[-1] PASSED [ 71%] +tests/test_retrieval.py::test_invalid_distance_config_is_rejected[nan] PASSED [ 71%] +tests/test_retrieval.py::test_invalid_distance_config_is_rejected[inf] PASSED [ 72%] +tests/test_retrieval.py::test_invalid_distance_config_is_rejected[-inf] PASSED [ 72%] +tests/test_retrieval.py::test_invalid_distance_config_is_rejected[invalid] PASSED [ 73%] +tests/test_retrieval.py::test_distance_config_accepts_unset_or_nonnegative_finite_values[None] PASSED [ 73%] +tests/test_retrieval.py::test_distance_config_accepts_unset_or_nonnegative_finite_values[0] PASSED [ 74%] +tests/test_retrieval.py::test_distance_config_accepts_unset_or_nonnegative_finite_values[1.5] PASSED [ 74%] +tests/test_retrieval.py::test_empty_channel_does_not_fall_back_to_global_results PASSED [ 75%] +tests/test_retrieval.py::test_rag_payload_uses_scoped_matches[None-2-api] PASSED [ 75%] +tests/test_retrieval.py::test_rag_payload_uses_scoped_matches[None-2-slack] PASSED [ 76%] +tests/test_retrieval.py::test_rag_payload_uses_scoped_matches[1.0-1-api] PASSED [ 76%] +tests/test_retrieval.py::test_rag_payload_uses_scoped_matches[1.0-1-slack] PASSED [ 76%] +tests/test_retrieval.py::test_rag_payload_uses_scoped_matches[0.0-0-api] PASSED [ 77%] +tests/test_retrieval.py::test_rag_payload_uses_scoped_matches[0.0-0-slack] PASSED [ 77%] +tests/test_thread_indexing.py::test_saved_thread_includes_root_and_replies_in_timestamp_order PASSED [ 78%] +tests/test_thread_indexing.py::test_saved_root_only_thread_is_indexed_once[None] PASSED [ 78%] +tests/test_thread_indexing.py::test_saved_root_only_thread_is_indexed_once[1700000000.000001] PASSED [ 79%] +tests/test_thread_indexing.py::test_saved_replies_can_be_indexed_without_a_saved_root PASSED [ 79%] +tests/test_thread_indexing.py::test_missing_saved_thread_returns_404_without_indexing[CTARGET-1700000098.000001] PASSED [ 80%] +tests/test_thread_indexing.py::test_missing_saved_thread_returns_404_without_indexing[CEMPTY-1700000000.000001] PASSED [ 80%] +tests/test_thread_indexing.py::test_saved_thread_channel_filter_also_applies_to_root_lookup PASSED [ 80%] +tests/test_thread_indexing.py::test_saved_thread_indexing_failure_remains_500 PASSED [ 81%] +tests/test_thread_indexing.py::test_saved_thread_retrieval_includes_original_question PASSED [ 81%] +tests/test_retrieval_preview.py::test_preview_returns_ranked_chunks_metadata_distances_and_settings PASSED [ 82%] +tests/test_retrieval_preview.py::test_preview_applies_channel_scope_before_top_k PASSED [ 82%] +tests/test_retrieval_preview.py::test_preview_exposes_inclusive_distance_cutoff_with_transcript PASSED [ 83%] +tests/test_retrieval_preview.py::test_preview_returns_success_for_empty_results[collection] PASSED [ 83%] +tests/test_retrieval_preview.py::test_preview_returns_success_for_empty_results[channel] PASSED [ 84%] +tests/test_retrieval_preview.py::test_preview_returns_success_for_empty_results[cutoff] PASSED [ 84%] +tests/test_retrieval_preview.py::test_preview_rejects_invalid_input_before_search[payload0] PASSED [ 85%] +tests/test_retrieval_preview.py::test_preview_rejects_invalid_input_before_search[payload1] PASSED [ 85%] +tests/test_retrieval_preview.py::test_preview_rejects_invalid_input_before_search[payload2] PASSED [ 85%] +tests/test_retrieval_preview.py::test_preview_rejects_invalid_input_before_search[payload3] PASSED [ 86%] +tests/test_retrieval_preview.py::test_preview_rejects_invalid_input_before_search[payload4] PASSED [ 86%] +tests/test_retrieval_preview.py::test_preview_rejects_invalid_input_before_search[payload5] PASSED [ 87%] +tests/test_retrieval_preview.py::test_preview_rejects_invalid_input_before_search[payload6] PASSED [ 87%] +tests/test_retrieval_preview.py::test_preview_trims_question_and_channel PASSED [ 88%] +tests/test_retrieval_preview.py::test_preview_reports_unavailable_retrieval_without_exposing_error PASSED [ 88%] +tests/test_document_indexing.py::test_create_and_retry_keep_one_owned_chunk_and_preserve_saved_record PASSED [ 89%] +tests/test_document_indexing.py::test_retry_recovers_saved_document_after_embedding_failure_with_transcript PASSED [ 89%] +tests/test_document_indexing.py::test_retry_rechunks_and_removes_only_obsolete_owned_chunks PASSED [ 90%] +tests/test_document_indexing.py::test_retry_reads_latest_saved_content_title_and_source PASSED [ 90%] +tests/test_document_indexing.py::test_retry_failure_keeps_previous_chunks_and_saved_content[lookup] PASSED [ 90%] +tests/test_document_indexing.py::test_retry_failure_keeps_previous_chunks_and_saved_content[embed] PASSED [ 91%] +tests/test_document_indexing.py::test_retry_failure_keeps_previous_chunks_and_saved_content[upsert] PASSED [ 91%] +tests/test_document_indexing.py::test_cleanup_failure_is_reported_and_retry_finishes_without_duplicates PASSED [ 92%] +tests/test_document_indexing.py::test_missing_saved_document_does_not_initialise_vector_store PASSED [ 92%] +tests/test_document_indexing.py::test_invalid_legacy_document_is_rejected_without_changing_chunks[content- \n\t ] PASSED [ 93%] +tests/test_document_indexing.py::test_invalid_legacy_document_is_rejected_without_changing_chunks[content-None] PASSED [ 93%] +tests/test_document_indexing.py::test_invalid_legacy_document_is_rejected_without_changing_chunks[title-] PASSED [ 94%] +tests/test_document_indexing.py::test_invalid_legacy_document_is_rejected_without_changing_chunks[source-None] PASSED [ 94%] +tests/test_document_deletion.py::test_delete_removes_only_owned_chunks_with_retrieval_transcript PASSED [ 95%] +tests/test_document_deletion.py::test_missing_or_invalid_delete_does_not_initialise_vector_store[999-404] PASSED [ 95%] +tests/test_document_deletion.py::test_missing_or_invalid_delete_does_not_initialise_vector_store[-1-404] PASSED [ 95%] +tests/test_document_deletion.py::test_missing_or_invalid_delete_does_not_initialise_vector_store[invalid-422] PASSED [ 96%] +tests/test_document_deletion.py::test_missing_or_invalid_delete_does_not_initialise_vector_store[1.5-422] PASSED [ 96%] +tests/test_document_deletion.py::test_delete_unindexed_legacy_record_needs_no_valid_content_or_embeddings PASSED [ 97%] +tests/test_document_deletion.py::test_vector_delete_failure_retains_saved_record_and_allows_retry[initialise] PASSED [ 97%] +tests/test_document_deletion.py::test_vector_delete_failure_retains_saved_record_and_allows_retry[delete] PASSED [ 98%] +tests/test_document_deletion.py::test_vector_delete_failure_retains_saved_record_and_allows_retry[lost-acknowledgement] PASSED [ 98%] +tests/test_document_deletion.py::test_database_delete_failure_rolls_back_saved_record_and_can_retry[delete] PASSED [ 99%] +tests/test_document_deletion.py::test_database_delete_failure_rolls_back_saved_record_and_can_retry[commit] PASSED [ 99%] +tests/test_document_deletion.py::test_delete_still_requires_an_initialised_adapter PASSED [100%] + +=============================== warnings summary =============================== +app/main.py:97 + /Users/johnny/.paseo/worktrees/0x03bguv/peaceful-whale/backend/app/main.py:97: PydanticDeprecatedSince20: Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.12/migration/ + class MessageResponse(BaseModel): + +app/main.py:124 + /Users/johnny/.paseo/worktrees/0x03bguv/peaceful-whale/backend/app/main.py:124: PydanticDeprecatedSince20: Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.12/migration/ + class ConversationTurn(BaseModel): + +app/main.py:161 + /Users/johnny/.paseo/worktrees/0x03bguv/peaceful-whale/backend/app/main.py:161: PydanticDeprecatedSince20: Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.12/migration/ + class DocumentDetail(BaseModel): + +app/main.py:174 + /Users/johnny/.paseo/worktrees/0x03bguv/peaceful-whale/backend/app/main.py:174: DeprecationWarning: + on_event is deprecated, use lifespan event handlers instead. + + Read more about it in the + [FastAPI docs for Lifespan Events](https://fastapi.tiangolo.com/advanced/events/). + + @app.on_event("startup") + +.venv/lib/python3.13/site-packages/fastapi/applications.py:4576 +.venv/lib/python3.13/site-packages/fastapi/applications.py:4576 + /Users/johnny/.paseo/worktrees/0x03bguv/peaceful-whale/backend/.venv/lib/python3.13/site-packages/fastapi/applications.py:4576: DeprecationWarning: + on_event is deprecated, use lifespan event handlers instead. + + Read more about it in the + [FastAPI docs for Lifespan Events](https://fastapi.tiangolo.com/advanced/events/). + + return self.router.on_event(event_type) + +app/main.py:187 + /Users/johnny/.paseo/worktrees/0x03bguv/peaceful-whale/backend/app/main.py:187: DeprecationWarning: + on_event is deprecated, use lifespan event handlers instead. + + Read more about it in the + [FastAPI docs for Lifespan Events](https://fastapi.tiangolo.com/advanced/events/). + + @app.on_event("shutdown") + +tests/test_documents.py: 4 warnings +tests/test_thread_indexing.py: 92 warnings +tests/test_document_indexing.py: 31 warnings +tests/test_document_deletion.py: 16 warnings + /Users/johnny/.paseo/worktrees/0x03bguv/peaceful-whale/backend/.venv/lib/python3.13/site-packages/sqlalchemy/sql/schema.py:3624: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC). + return util.wrap_callable(lambda ctx: fn(), fn) # type: ignore + +tests/test_retrieval.py::test_document_chunks_stop_after_covering_content[-5-2-expected0] + /Users/johnny/.paseo/worktrees/0x03bguv/peaceful-whale/backend/tests/test_retrieval.py:122: LangChainDeprecationWarning: The class `Chroma` was deprecated in LangChain 0.2.9 and will be removed in 1.0. An updated version of the class exists in the `langchain-chroma package and should be used instead. To use it run `pip install -U `langchain-chroma` and import as `from `langchain_chroma import Chroma``. + store.vector_store = Chroma( + +tests/test_retrieval.py: 384 warnings +tests/test_thread_indexing.py: 27 warnings +tests/test_retrieval_preview.py: 216 warnings +tests/test_document_indexing.py: 166 warnings +tests/test_document_deletion.py: 89 warnings + /Users/johnny/.paseo/worktrees/0x03bguv/peaceful-whale/backend/.venv/lib/python3.13/site-packages/chromadb/types.py:144: PydanticDeprecatedSince211: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0. + return self.model_fields # pydantic 2.x + +-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html +====================== 221 passed, 1033 warnings in 9.12s ====================== diff --git a/.tmp/proof/dashboard-delete-browser-failure.txt b/.tmp/proof/dashboard-delete-browser-failure.txt new file mode 100644 index 0000000..cea5f4c --- /dev/null +++ b/.tmp/proof/dashboard-delete-browser-failure.txt @@ -0,0 +1,25 @@ +### Result +#25 [DELETE] http://127.0.0.1:18057/api/documents/1 + + General + status: [503] Service Unavailable + duration: 11ms + type: fetch + mimeType: application/json + + Request headers + sec-ch-ua-platform: "macOS" + referer: http://127.0.0.1:13057/ + user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/157.0.0.0 Safari/537.36 + sec-ch-ua: "Not-A.Brand";v="99", "Google Chrome";v="157", "Chromium";v="157" + sec-ch-ua-mobile: ?0 + + Response headers + access-control-allow-origin: * + content-length: 73 + date: Mon, 16 Nov 2026 10:22:57 GMT + content-type: application/json + server: uvicorn + access-control-allow-credentials: true + +Run `response-body 25` to read the response body. diff --git a/.tmp/proof/dashboard-delete-browser-requests.txt b/.tmp/proof/dashboard-delete-browser-requests.txt new file mode 100644 index 0000000..65de35d --- /dev/null +++ b/.tmp/proof/dashboard-delete-browser-requests.txt @@ -0,0 +1,9 @@ +### Result +22. [GET] http://127.0.0.1:18057/api/documents?limit=20&offset=0 => [FAILED] net::ERR_ABORTED +23. [GET] http://127.0.0.1:18057/api/documents?limit=20&offset=0 => [200] OK +24. [GET] http://127.0.0.1:18057/api/documents/1 => [200] OK +25. [DELETE] http://127.0.0.1:18057/api/documents/1 => [503] Service Unavailable +26. [DELETE] http://127.0.0.1:18057/api/documents/1 => [200] OK +27. [GET] http://127.0.0.1:18057/api/documents?limit=20&offset=0 => [200] OK + +Note: 21 static requests not shown, run with --static option to see them. diff --git a/.tmp/proof/dashboard-delete-browser-success.txt b/.tmp/proof/dashboard-delete-browser-success.txt new file mode 100644 index 0000000..497aac9 --- /dev/null +++ b/.tmp/proof/dashboard-delete-browser-success.txt @@ -0,0 +1,25 @@ +### Result +#26 [DELETE] http://127.0.0.1:18057/api/documents/1 + + General + status: [200] OK + duration: 19ms + type: fetch + mimeType: application/json + + Request headers + sec-ch-ua-platform: "macOS" + referer: http://127.0.0.1:13057/ + user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/157.0.0.0 Safari/537.36 + sec-ch-ua: "Not-A.Brand";v="99", "Google Chrome";v="157", "Chromium";v="157" + sec-ch-ua-mobile: ?0 + + Response headers + access-control-allow-origin: * + content-length: 50 + date: Mon, 16 Nov 2026 10:23:25 GMT + content-type: application/json + server: uvicorn + access-control-allow-credentials: true + +Run `response-body 26` to read the response body. diff --git a/.tmp/proof/dashboard-delete-confirm.png b/.tmp/proof/dashboard-delete-confirm.png new file mode 100644 index 0000000..8b2e1fd Binary files /dev/null and b/.tmp/proof/dashboard-delete-confirm.png differ diff --git a/.tmp/proof/dashboard-delete-error.png b/.tmp/proof/dashboard-delete-error.png new file mode 100644 index 0000000..5992f48 Binary files /dev/null and b/.tmp/proof/dashboard-delete-error.png differ diff --git a/.tmp/proof/dashboard-delete-frontend-start.txt b/.tmp/proof/dashboard-delete-frontend-start.txt new file mode 100644 index 0000000..789f0a0 --- /dev/null +++ b/.tmp/proof/dashboard-delete-frontend-start.txt @@ -0,0 +1,10 @@ +[dev-frontend] $ bun run dev --hostname 127.0.0.1 --port 13057 +$ next dev --hostname "127.0.0.1" --port "13057" +▲ Next.js 16.1.1 (Turbopack) +- Local: http://127.0.0.1:13057 +- Network: http://127.0.0.1:13057 + +✓ Starting... +✓ Ready in 531ms +○ Compiling / ... + GET / 200 in 3.4s (compile: 3.2s, render: 162ms) diff --git a/.tmp/proof/dashboard-delete-frontend-tests.txt b/.tmp/proof/dashboard-delete-frontend-tests.txt new file mode 100644 index 0000000..1d44fdd --- /dev/null +++ b/.tmp/proof/dashboard-delete-frontend-tests.txt @@ -0,0 +1,69 @@ +[test-frontend] $ bun run test +$ bun test --preload ./tests/setup.ts +bun test v1.3.5 (1e86cebd) + +tests/documents.test.tsx: +(pass) documents load on opening the tab, search only on submit, and retain the applied query while paging [154.61ms] +(pass) document client encodes literal search text, keeps source filters, and omits blank queries +(pass) documents show loading, retry the submitted query after a list error, and distinguish empty searches [16.56ms] +(pass) documents render saved content as text and retry detail failures without losing results [22.92ms] +(pass) documents ignore stale successful and failed list responses after a newer search [7.59ms] +(pass) documents ignore late details after another selection, a page change, and clearing a search [37.33ms] +(pass) documents abort requests on leaving the tab and ignore late responses when reopened [8.81ms] + +tests/document-deletion.test.tsx: +(pass) deletion requires confirmation of the selected document and cancellation sends no mutation [19.78ms] +(pass) confirmed deletion handles HTTP %s by refreshing page one of the applied search [42.34ms] +(pass) confirmed deletion handles HTTP %s by refreshing page one of the applied search [35.68ms] +(pass) deletion reports an uncertain outcome after 503 and retries the same ID [22.45ms] +(pass) deletion reports an uncertain outcome after 403 and retries the same ID [21.65ms] +(pass) deletion reports an uncertain outcome after network and retries the same ID [21.67ms] +(pass) a deletion failure can be cancelled and re-indexing blocks deletion until it finishes [22.24ms] +(pass) a failed list refresh after deletion offers a list retry without repeating DELETE [20.57ms] +(pass) deletion ignores late success after a selection change [20.21ms] +(pass) deletion ignores late failure after a selection change [19.06ms] +(pass) deletion ignores late success after a search change [22.40ms] +(pass) deletion ignores late failure after a search change [23.20ms] +(pass) deletion ignores late success after a page change [23.01ms] +(pass) deletion ignores late failure after a page change [29.12ms] +(pass) deletion ignores late success after a tab change [25.28ms] +(pass) deletion ignores late failure after a tab change [23.86ms] + +tests/document-indexing.test.tsx: +(pass) re-indexing requires an explicit click, posts the saved ID once while pending, and keeps the content visible [15.07ms] +(pass) re-indexing reports a safe failure for 404 and retries the same saved document [17.20ms] +(pass) re-indexing reports a safe failure for 422 and retries the same saved document [16.87ms] +(pass) re-indexing reports a safe failure for 503 and retries the same saved document [19.33ms] +(pass) re-indexing reports a safe failure for network and retries the same saved document [20.39ms] +(pass) re-indexing ignores a late success after a selection change [24.00ms] +(pass) re-indexing ignores a late failure after a selection change [23.05ms] +(pass) re-indexing ignores a late success after a search change [25.93ms] +(pass) re-indexing ignores a late failure after a search change [26.56ms] +(pass) re-indexing ignores a late success after a page change [25.89ms] +(pass) re-indexing ignores a late failure after a page change [26.62ms] +(pass) re-indexing ignores a late success after a tab change [29.21ms] +(pass) re-indexing ignores a late failure after a tab change [27.60ms] + +tests/retrieval.test.tsx: +(pass) retrieval waits for a non-blank question and submits trimmed optional scope [9.71ms] +(pass) retrieval omits blank scope, preserves rank and raw distances, and shows an unset cutoff [9.12ms] +(pass) retrieval disables inputs and duplicate submissions while loading [5.27ms] +(pass) retrieval shows an empty result and a zero distance cutoff [5.10ms] +(pass) retrieval replaces a failed request with a successful retry [10.45ms] +(pass) retrieval clears old results when the question or channel changes [10.14ms] +(pass) retrieval aborts on leaving the tab and ignores late responses after reopening [8.53ms] +(pass) retrieval renders chunk and metadata markup as text [7.46ms] + +tests/conversations.test.tsx: +(pass) loads only on opening the tab and paginates summaries and chronological turns independently [103.76ms] +(pass) shows loading, an empty page and a list error with a working retry [6.92ms] +(pass) retries missing conversation details without discarding the list [16.28ms] +(pass) ignores stale detail responses after selecting another conversation [13.29ms] +(pass) ignores stale errors after leaving and reopening the tab [7.49ms] +(pass) renders stored markup as text and supports missing metadata [8.24ms] +(pass) encodes conversation IDs in detail request paths [1.57ms] + + 51 pass + 0 fail + 370 expect() calls +Ran 51 tests across 5 files. [1.55s] diff --git a/.tmp/proof/dashboard-delete-install.txt b/.tmp/proof/dashboard-delete-install.txt new file mode 100644 index 0000000..f5da5ab --- /dev/null +++ b/.tmp/proof/dashboard-delete-install.txt @@ -0,0 +1,182 @@ +[install-frontend] $ bun install +[install-backend] $ uv sync +[install-runtime] $ bun install --frozen-lockfile --ignore-scripts +[install-frontend] bun install v1.3.5 (1e86cebd) +[install-runtime] bun install v1.3.5 (1e86cebd) +[install-backend] Using CPython 3.13.13 +[install-backend] Creating virtual environment at: .venv +[install-runtime] +[install-runtime] + @earendil-works/chord@1.3.0 +[install-runtime] + @earendil-works/pi-ai@1.3.0 +[install-runtime] + @earendil-works/pi-durable@1.3.0 +[install-runtime] +[install-runtime] 91 packages installed [1092.00ms] +[install-runtime] Finished in 1.12s +[install-backend] Resolved 143 packages in 1.30s +[install-backend] warning: `numpy==2.4.0` is yanked (reason: "Backward compatibility bug") +[install-backend] Building wingman @ file:///Users/johnny/.paseo/worktrees/0x03bguv/peaceful-whale/backend +[install-frontend] +[install-frontend] + @tailwindcss/postcss@4.1.18 +[install-frontend] + @testing-library/react@16.3.3 +[install-frontend] + @types/bun@1.4.4 +[install-frontend] + eslint@9.39.2 +[install-frontend] + eslint-config-next@16.1.1 +[install-frontend] + happy-dom@21.0.4 +[install-frontend] + tailwindcss@4.1.18 +[install-frontend] + @types/node@25.0.3 +[install-frontend] + @types/react@19.2.7 +[install-frontend] + @types/react-dom@19.2.3 +[install-frontend] + axios@1.13.2 +[install-frontend] + next@16.1.1 +[install-frontend] + react@19.2.3 +[install-frontend] + react-dom@19.2.3 +[install-frontend] + swr@2.3.8 +[install-frontend] + typescript@5.9.3 +[install-frontend] +[install-frontend] 382 packages installed [1.70s] +[install-frontend] Finished in 1.73s +[install-backend] Built wingman @ file:///Users/johnny/.paseo/worktrees/0x03bguv/peaceful-whale/backend +[install-backend] Prepared 1 package in 443ms +[install-backend] Installed 140 packages in 578ms +[install-backend] + aiohappyeyeballs==2.6.1 +[install-backend] + aiohttp==3.13.2 +[install-backend] + aiosignal==1.4.0 +[install-backend] + alembic==1.17.2 +[install-backend] + annotated-doc==0.0.4 +[install-backend] + annotated-types==0.7.0 +[install-backend] + anyio==4.12.0 +[install-backend] + asgiref==3.11.0 +[install-backend] + attrs==25.4.0 +[install-backend] + backoff==2.2.1 +[install-backend] + bcrypt==5.0.0 +[install-backend] + build==1.3.0 +[install-backend] + cachetools==6.2.4 +[install-backend] + certifi==2025.11.12 +[install-backend] + charset-normalizer==3.4.4 +[install-backend] + chroma-hnswlib==0.7.6 +[install-backend] + chromadb==0.6.3 +[install-backend] + click==8.3.1 +[install-backend] + coloredlogs==15.0.1 +[install-backend] + dataclasses-json==0.6.7 +[install-backend] + distro==1.9.0 +[install-backend] + durationpy==0.10 +[install-backend] + fastapi==0.128.0 +[install-backend] + filelock==3.20.1 +[install-backend] + flatbuffers==25.12.19 +[install-backend] + frozenlist==1.8.0 +[install-backend] + fsspec==2025.12.0 +[install-backend] + google-auth==2.45.0 +[install-backend] + googleapis-common-protos==1.72.0 +[install-backend] + grpcio==1.76.0 +[install-backend] + h11==0.16.0 +[install-backend] + hf-xet==1.2.0 +[install-backend] + httpcore==1.0.9 +[install-backend] + httptools==0.7.1 +[install-backend] + httpx==0.28.1 +[install-backend] + httpx-sse==0.4.3 +[install-backend] + huggingface-hub==0.36.0 +[install-backend] + humanfriendly==10.0 +[install-backend] + idna==3.11 +[install-backend] + importlib-metadata==8.7.1 +[install-backend] + importlib-resources==6.5.2 +[install-backend] + iniconfig==2.3.0 +[install-backend] + jiter==0.12.0 +[install-backend] + jsonpatch==1.33 +[install-backend] + jsonpointer==3.0.0 +[install-backend] + kubernetes==34.1.0 +[install-backend] + langchain==1.2.0 +[install-backend] + langchain-classic==1.0.1 +[install-backend] + langchain-community==0.4.1 +[install-backend] + langchain-core==1.2.5 +[install-backend] + langchain-openai==1.1.6 +[install-backend] + langchain-text-splitters==1.1.0 +[install-backend] + langgraph==1.0.5 +[install-backend] + langgraph-checkpoint==3.0.1 +[install-backend] + langgraph-prebuilt==1.0.5 +[install-backend] + langgraph-sdk==0.3.1 +[install-backend] + langsmith==0.5.2 +[install-backend] + lxml==6.0.2 +[install-backend] + mako==1.3.10 +[install-backend] + markdown-it-py==4.0.0 +[install-backend] + markupsafe==3.0.3 +[install-backend] + marshmallow==3.26.2 +[install-backend] + mdurl==0.1.2 +[install-backend] + mmh3==5.2.0 +[install-backend] + mpmath==1.3.0 +[install-backend] + multidict==6.7.0 +[install-backend] + mypy-extensions==1.1.0 +[install-backend] + numpy==2.4.0 +[install-backend] + oauthlib==3.3.1 +[install-backend] + onnxruntime==1.23.2 +[install-backend] + openai==2.14.0 +[install-backend] + opentelemetry-api==1.39.1 +[install-backend] + opentelemetry-exporter-otlp-proto-common==1.39.1 +[install-backend] + opentelemetry-exporter-otlp-proto-grpc==1.39.1 +[install-backend] + opentelemetry-instrumentation==0.60b1 +[install-backend] + opentelemetry-instrumentation-asgi==0.60b1 +[install-backend] + opentelemetry-instrumentation-fastapi==0.60b1 +[install-backend] + opentelemetry-proto==1.39.1 +[install-backend] + opentelemetry-sdk==1.39.1 +[install-backend] + opentelemetry-semantic-conventions==0.60b1 +[install-backend] + opentelemetry-util-http==0.60b1 +[install-backend] + orjson==3.11.5 +[install-backend] + ormsgpack==1.12.1 +[install-backend] + overrides==7.7.0 +[install-backend] + packaging==25.0 +[install-backend] + pluggy==1.6.0 +[install-backend] + posthog==7.4.2 +[install-backend] + propcache==0.4.1 +[install-backend] + protobuf==6.33.2 +[install-backend] + psycopg2-binary==2.9.11 +[install-backend] + pyasn1==0.6.1 +[install-backend] + pyasn1-modules==0.4.2 +[install-backend] + pydantic==2.12.5 +[install-backend] + pydantic-core==2.41.5 +[install-backend] + pydantic-settings==2.12.0 +[install-backend] + pygments==2.19.2 +[install-backend] + pypdf==6.5.0 +[install-backend] + pypika==0.48.9 +[install-backend] + pyproject-hooks==1.2.0 +[install-backend] + pytest==9.0.2 +[install-backend] + pytest-asyncio==1.3.0 +[install-backend] + python-dateutil==2.9.0.post0 +[install-backend] + python-docx==1.2.0 +[install-backend] + python-dotenv==1.2.1 +[install-backend] + pyyaml==6.0.3 +[install-backend] + regex==2025.11.3 +[install-backend] + requests==2.32.5 +[install-backend] + requests-oauthlib==2.0.0 +[install-backend] + requests-toolbelt==1.0.0 +[install-backend] + rich==14.2.0 +[install-backend] + rsa==4.9.1 +[install-backend] + shellingham==1.5.4 +[install-backend] + six==1.17.0 +[install-backend] + slack-bolt==1.27.0 +[install-backend] + slack-sdk==3.42.0 +[install-backend] + sniffio==1.3.1 +[install-backend] + sqlalchemy==2.0.45 +[install-backend] + starlette==0.50.0 +[install-backend] + sympy==1.14.0 +[install-backend] + tenacity==9.1.2 +[install-backend] + tiktoken==0.12.0 +[install-backend] + tokenizers==0.22.1 +[install-backend] + tqdm==4.67.1 +[install-backend] + typer==0.21.0 +[install-backend] + typing-extensions==4.15.0 +[install-backend] + typing-inspect==0.9.0 +[install-backend] + typing-inspection==0.4.2 +[install-backend] + urllib3==2.3.0 +[install-backend] + uuid-utils==0.12.0 +[install-backend] + uvicorn==0.40.0 +[install-backend] + uvloop==0.22.1 +[install-backend] + watchfiles==1.1.1 +[install-backend] + websocket-client==1.9.0 +[install-backend] + websockets==15.0.1 +[install-backend] + wingman==1.1.0 (from file:///Users/johnny/.paseo/worktrees/0x03bguv/peaceful-whale/backend) +[install-backend] + wrapt==1.17.3 +[install-backend] + xxhash==3.6.0 +[install-backend] + yarl==1.22.0 +[install-backend] + zipp==3.23.0 +[install-backend] + zstandard==0.25.0 +[install-backend] Finished in 2.58s +Finished in 2.59s diff --git a/.tmp/proof/dashboard-delete-mobile.png b/.tmp/proof/dashboard-delete-mobile.png new file mode 100644 index 0000000..10e8d60 Binary files /dev/null and b/.tmp/proof/dashboard-delete-mobile.png differ diff --git a/.tmp/proof/dashboard-delete-runtime-tests.txt b/.tmp/proof/dashboard-delete-runtime-tests.txt new file mode 100644 index 0000000..d26f501 --- /dev/null +++ b/.tmp/proof/dashboard-delete-runtime-tests.txt @@ -0,0 +1,16 @@ +[test-runtime] $ node --test +✔ real Pi SQLite storage preserves answers, deduplicates retries, and retains conversation history (35.92325ms) +✔ outbox resumes after restart without regenerating answer; retry admits only one job (4.354417ms) +✔ a process killed during generation resumes the admitted Pi submission (223.651542ms) +✔ pinned operator answer is delivered without calling the model (0.918458ms) +✔ model failure sends a persisted Slack failure notification (0.343208ms) +✔ runtime starts with openai catalog and protects job routes (602.294209ms) +✔ runtime starts with mimo catalog and protects job routes (460.6495ms) +ℹ tests 7 +ℹ suites 0 +ℹ pass 7 +ℹ fail 0 +ℹ cancelled 0 +ℹ skipped 0 +ℹ todo 0 +ℹ duration_ms 1130.932625 diff --git a/.tmp/proof/dashboard-delete-success.png b/.tmp/proof/dashboard-delete-success.png new file mode 100644 index 0000000..99e01af Binary files /dev/null and b/.tmp/proof/dashboard-delete-success.png differ diff --git a/docs/retrieval.md b/docs/retrieval.md index 1fa6ff1..a3a6eeb 100644 --- a/docs/retrieval.md +++ b/docs/retrieval.md @@ -139,7 +139,20 @@ then its saved database record. Success returns HTTP 200 with `id` and `message`. The record disappears from document lists and detail reads. Deleting the same ID again returns HTTP 404, as does re-indexing it. A missing record returns HTTP 404 without accessing Chroma; a non-integer ID returns HTTP 422. -This API action has no dashboard button yet. +In the dashboard, open **Documents**, select a saved document and choose +**Delete document**. The confirmation names the document and its ID; **Cancel +deletion** leaves it alone. **Confirm deletion** removes it and refreshes page +one of the applied search. Unsubmitted search edits remain in the input. +An already absent record (HTTP 404) also refreshes the results. A failed list +refresh offers a list retry without sending another deletion request. + +Deletion and re-indexing cannot overlap within the current detail view. Other +users and views are not coordinated, so wait for their indexing to finish +before confirming deletion. Failures keep the confirmation open for retry or +cancellation; some chunks may already have been removed. Leaving the view stops +waiting and ignores late results, but deletion may still finish on the backend. +Refresh the document list to check its status. This action does not send a Slack +message or erase historical unowned chunks or previous answers. ```sh curl -sS -X DELETE http://localhost:8000/api/documents/1 diff --git a/frontend/components/documents-panel.tsx b/frontend/components/documents-panel.tsx index aa9de5e..6535f57 100644 --- a/frontend/components/documents-panel.tsx +++ b/frontend/components/documents-panel.tsx @@ -1,7 +1,7 @@ 'use client' -import { useEffect, useState } from 'react' -import { getDocument, listDocuments, reindexDocument, type DocumentDetail, type DocumentListResponse } from '@/lib/api' +import { useCallback, useEffect, useRef, useState } from 'react' +import { deleteDocument, getDocument, listDocuments, reindexDocument, type DocumentDetail, type DocumentListResponse } from '@/lib/api' const PAGE_SIZE = 20 const buttonClass = 'min-h-11 rounded-lg border border-gray-300 px-4 py-2 text-sm text-gray-700 hover:bg-gray-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600 disabled:opacity-40 disabled:cursor-not-allowed' @@ -11,9 +11,18 @@ function formatDate(value?: string | null) { return new Date(value).toLocaleDateString('en-AU', { day: 'numeric', month: 'short', year: 'numeric' }) } -function DocumentIndexAction({ documentId }: { documentId: number }) { +function DocumentActions({ documentId, title, onDeleted }: { documentId: number; title: string; onDeleted: () => void }) { const [attempt, setAttempt] = useState(0) const [phase, setPhase] = useState<'idle' | 'pending' | 'success' | 'error'>('idle') + const [deletePhase, setDeletePhase] = useState<'idle' | 'confirm' | 'pending' | 'error'>('idle') + const [deleteAttempt, setDeleteAttempt] = useState(0) + const deleteButton = useRef(null) + const previousDeletePhase = useRef(deletePhase) + + useEffect(() => { + if (previousDeletePhase.current !== 'idle' && deletePhase === 'idle') deleteButton.current?.focus() + previousDeletePhase.current = deletePhase + }, [deletePhase]) useEffect(() => { if (!attempt) return @@ -25,12 +34,22 @@ function DocumentIndexAction({ documentId }: { documentId: number }) { return () => { cancelled = true; controller.abort() } }, [attempt, documentId]) + useEffect(() => { + if (!deleteAttempt) return + let cancelled = false + const controller = new AbortController() + deleteDocument(documentId, controller.signal) + .then(() => { if (!cancelled) onDeleted() }) + .catch(() => { if (!cancelled) setDeletePhase('error') }) + return () => { cancelled = true; controller.abort() } + }, [deleteAttempt, documentId, onDeleted]) + return (

Re-index this saved content for retrieval. This uses the configured embedding provider and may incur a cost.

- + {deletePhase !== 'idle' && ( +
+

Delete “{title}” (ID {documentId})?

+

This permanently removes the saved document and its owned retrieval chunks. Historical chunks without an owner and previous answers may still contain this content.

+

Wait for any indexing of this document in other views or by other users to finish before deleting.

+ {deletePhase === 'error' &&

Could not confirm deletion. Some retrieval chunks may already be removed. Retry to finish, or cancel and refresh the document list to check its status.

} +
+ + +
+ {deletePhase === 'pending' &&

Deleting saved document...

} +

Leaving this view stops waiting. Deletion already started may still finish; refresh the list to check.

+
+ )} +
) } @@ -54,6 +99,8 @@ export default function DocumentsPanel() { const [selection, setSelection] = useState<{ id: number } | null>(null) const [detail, setDetail] = useState(null) const [detailError, setDetailError] = useState(false) + const [notice, setNotice] = useState('') + const heading = useRef(null) useEffect(() => { let cancelled = false @@ -74,14 +121,21 @@ export default function DocumentsPanel() { return () => { cancelled = true; controller.abort() } }, [selection]) - function load(query: string, offset = 0) { + const load = useCallback((query: string, offset = 0) => { setList(null) setListError(false) setSelection(null) setDetail(null) setDetailError(false) + setNotice('') setRequest({ query, offset }) - } + }, []) + + const onDeleted = useCallback(() => { + load(request.query) + setNotice('Document is no longer saved.') + heading.current?.focus() + }, [load, request.query]) function select(id: number) { setDetail(null) @@ -91,9 +145,9 @@ export default function DocumentsPanel() { return (
-

Knowledge Base Documents

+

Knowledge Base Documents

- Saved documents for retrieval-augmented generation. Select one to read or re-index its content. + Saved documents for retrieval-augmented generation. Select one to read, re-index or delete it.

{ event.preventDefault(); load(draft.trim()) }} className="mb-6"> @@ -108,6 +162,8 @@ export default function DocumentsPanel() {
+ {notice &&

{notice}

} + {listError ? (

Could not load documents. Check the backend is running and try again.

@@ -161,7 +217,7 @@ export default function DocumentsPanel() {

{detail.title}

{detail.source}{formatDate(detail.created_at) && ` - ${formatDate(detail.created_at)}`}

{detail.content}

- +
)}
diff --git a/frontend/lib/api.ts b/frontend/lib/api.ts index 5220698..fc18bbb 100644 --- a/frontend/lib/api.ts +++ b/frontend/lib/api.ts @@ -189,6 +189,15 @@ export async function reindexDocument(id: number, signal?: AbortSignal): Promise return response.json() } +export async function deleteDocument(id: number, signal?: AbortSignal): Promise { + const response = await fetch(`${API_BASE_URL}/api/documents/${id}`, { + method: 'DELETE', + signal, + }) + // A retry can find the record already removed after a lost acknowledgement. + if (!response.ok && response.status !== 404) throw new Error(`API error: ${response.status}`) +} + export async function addDocument(doc: DocumentRequest): Promise<{ id: number; message: string }> { const response = await fetch(`${API_BASE_URL}/api/documents`, { method: 'POST', diff --git a/frontend/tests/document-deletion.test.tsx b/frontend/tests/document-deletion.test.tsx new file mode 100644 index 0000000..0df63ab --- /dev/null +++ b/frontend/tests/document-deletion.test.tsx @@ -0,0 +1,179 @@ +import { afterEach, expect, test } from 'bun:test' +import { act, cleanup, fireEvent, render, screen } from '@testing-library/react' +import Home from '../app/page' + +const originalFetch = globalThis.fetch +const requests: Array<{ url: URL; method?: string; signal?: AbortSignal | null; body?: BodyInit | null }> = [] +const saved = (id: number) => ({ id, title: `Guide ${id}`, source: 'docs', created_at: '2026-11-16T09:00:00Z', content: `Saved content ${id}` }) +const json = (data: unknown, status = 200) => new Response(JSON.stringify(data), { status }) +const deletes = () => requests.filter((request) => request.method === 'DELETE') + +function mockApi(remove: () => Response | Promise, options: { index?: () => Promise; list?: (url: URL) => Response } = {}) { + globalThis.fetch = (async (input: string | URL | Request, init?: RequestInit) => { + const url = new URL(String(input)) + requests.push({ url, method: init?.method, signal: init?.signal, body: init?.body }) + if (init?.method === 'DELETE') return remove() + if (url.pathname.endsWith('/index') && options.index) return options.index() + if (url.pathname === '/api/documents') return options.list?.(url) ?? json({ items: [saved(1), saved(2)], total: 21, limit: 20, offset: 0 }) + if (url.pathname === '/api/documents/1') return json(saved(1)) + if (url.pathname === '/api/documents/2') return json(saved(2)) + throw new Error(`Unexpected request ${url.pathname}`) + }) as typeof fetch +} + +async function openDocument() { + render() + fireEvent.click(screen.getByRole('button', { name: 'Documents' })) + fireEvent.click(await screen.findByRole('button', { name: /^Guide 1 / })) + await screen.findByText('Saved content 1') +} + +function confirm() { + fireEvent.click(screen.getByRole('button', { name: 'Delete document' })) + fireEvent.click(screen.getByRole('button', { name: 'Confirm deletion' })) +} + +afterEach(() => { + cleanup() + globalThis.fetch = originalFetch + requests.length = 0 +}) + +test('deletion requires confirmation of the selected document and cancellation sends no mutation', async () => { + mockApi(() => json({ id: 1 })) + await openDocument() + expect(deletes()).toHaveLength(0) + fireEvent.click(screen.getByRole('button', { name: 'Delete document' })) + expect(screen.getByRole('group', { name: 'Confirm document deletion' }).textContent).toContain('Delete “Guide 1” (ID 1)?') + expect(screen.getByText(/Historical chunks without an owner/)).toBeTruthy() + expect(document.activeElement).toBe(screen.getByRole('button', { name: 'Cancel deletion' })) + expect((screen.getByRole('button', { name: 'Re-index document' }) as HTMLButtonElement).disabled).toBe(true) + expect(deletes()).toHaveLength(0) + fireEvent.click(screen.getByRole('button', { name: 'Cancel deletion' })) + expect(screen.queryByRole('group', { name: 'Confirm document deletion' })).toBeNull() + expect(document.activeElement).toBe(screen.getByRole('button', { name: 'Delete document' })) + expect((screen.getByRole('button', { name: 'Re-index document' }) as HTMLButtonElement).disabled).toBe(false) + expect(deletes()).toHaveLength(0) +}) + +test.each([200, 404])('confirmed deletion handles HTTP %s by refreshing page one of the applied search', async (status) => { + let removed = false + let resolve!: (response: Response) => void + mockApi(() => new Promise((done) => { resolve = done }), { + list: (url) => json({ items: removed ? [saved(2)] : url.searchParams.get('offset') === '20' ? [saved(1)] : [saved(1), saved(2)], total: removed ? 1 : 21, limit: 20, offset: Number(url.searchParams.get('offset')) }), + }) + await openDocument() + fireEvent.change(screen.getByLabelText('Search documents'), { target: { value: 'Guide' } }) + fireEvent.click(screen.getByRole('button', { name: 'Search' })) + await screen.findByText('21 matching documents for “Guide”') + fireEvent.click(screen.getByRole('button', { name: 'Next documents' })) + await screen.findByText('21-21 of 21') + fireEvent.click(screen.getByRole('button', { name: /^Guide 1 / })) + await screen.findByText('Saved content 1') + fireEvent.change(screen.getByLabelText('Search documents'), { target: { value: 'unsent edit' } }) + confirm() + const pending = screen.getByRole('button', { name: 'Deleting...' }) as HTMLButtonElement + expect(pending.disabled).toBe(true) + expect((screen.getByRole('button', { name: 'Cancel deletion' }) as HTMLButtonElement).disabled).toBe(true) + expect((screen.getByRole('button', { name: 'Re-index document' }) as HTMLButtonElement).disabled).toBe(true) + fireEvent.click(pending) + fireEvent.click(screen.getByRole('button', { name: 'Re-index document' })) + expect(deletes()).toHaveLength(1) + expect(deletes()[0]).toMatchObject({ method: 'DELETE', body: undefined }) + expect(deletes()[0].url.pathname).toBe('/api/documents/1') + expect(requests.filter((request) => request.method === 'POST')).toHaveLength(0) + expect(screen.getByText('Saved content 1')).toBeTruthy() + removed = true + await act(async () => { resolve(json({}, status)) }) + await screen.findByText('1 matching document for “Guide”') + expect(screen.getByText('Document is no longer saved.')).toBeTruthy() + expect(screen.queryByRole('region', { name: 'Document content' })).toBeNull() + expect(screen.queryByRole('button', { name: /^Guide 1 / })).toBeNull() + expect(requests.at(-1)?.url.searchParams.get('q')).toBe('Guide') + expect(requests.at(-1)?.url.searchParams.get('offset')).toBe('0') + expect((screen.getByLabelText('Search documents') as HTMLInputElement).value).toBe('unsent edit') + expect(document.activeElement).toBe(screen.getByRole('heading', { name: 'Knowledge Base Documents' })) +}) + +test.each(['503', '403', 'network'] as const)('deletion reports an uncertain outcome after %s and retries the same ID', async (failure) => { + let fail = true + mockApi(() => { + if (!fail) return json({ id: 1 }) + if (failure === 'network') return Promise.reject(new Error('private credentials')) + return json({ detail: 'private credentials' }, Number(failure)) + }) + await openDocument() + confirm() + expect((await screen.findByRole('alert')).textContent).toContain('Some retrieval chunks may already be removed.') + expect(screen.queryByText(/private credentials/)).toBeNull() + expect(screen.getByText('Saved content 1')).toBeTruthy() + expect(screen.queryByText('Document is no longer saved.')).toBeNull() + fail = false + fireEvent.click(screen.getByRole('button', { name: 'Confirm deletion' })) + await screen.findByText('Document is no longer saved.') + expect(deletes().map((request) => request.url.pathname)).toEqual(['/api/documents/1', '/api/documents/1']) +}) + +test('a deletion failure can be cancelled and re-indexing blocks deletion until it finishes', async () => { + let resolve!: (response: Response) => void + mockApi(() => json({}, 503), { index: () => new Promise((done) => { resolve = done }) }) + await openDocument() + confirm() + await screen.findByRole('alert') + fireEvent.click(screen.getByRole('button', { name: 'Cancel deletion' })) + fireEvent.click(screen.getByRole('button', { name: 'Re-index document' })) + expect((screen.getByRole('button', { name: 'Delete document' }) as HTMLButtonElement).disabled).toBe(true) + fireEvent.click(screen.getByRole('button', { name: 'Delete document' })) + expect(screen.queryByRole('group', { name: 'Confirm document deletion' })).toBeNull() + await act(async () => { resolve(json({ id: 1 })) }) + await screen.findByText('Document indexed successfully.') + expect((screen.getByRole('button', { name: 'Delete document' }) as HTMLButtonElement).disabled).toBe(false) +}) + +test('a failed list refresh after deletion offers a list retry without repeating DELETE', async () => { + let removed = false + let listFails = true + mockApi(() => { removed = true; return json({ id: 1 }) }, { + list: () => removed && listFails ? json({}, 503) : json({ items: removed ? [] : [saved(1)], total: removed ? 0 : 1, limit: 20, offset: 0 }), + }) + await openDocument() + confirm() + await screen.findByRole('alert') + expect(screen.getByText('Document is no longer saved.')).toBeTruthy() + expect(screen.queryByRole('region', { name: 'Document content' })).toBeNull() + listFails = false + fireEvent.click(screen.getByRole('button', { name: 'Retry documents' })) + await screen.findByText('No saved documents on this page.') + expect(deletes()).toHaveLength(1) +}) + +for (const destination of ['selection', 'search', 'page', 'tab'] as const) { + test.each(['success', 'failure'] as const)(`deletion ignores late %s after a ${destination} change`, async (outcome) => { + let resolve!: (response: Response) => void + let reject!: (error: Error) => void + mockApi(() => new Promise((done, fail) => { resolve = done; reject = fail })) + await openDocument() + confirm() + if (destination === 'selection') fireEvent.click(screen.getByRole('button', { name: /^Guide 2 / })) + if (destination === 'search') fireEvent.click(screen.getByRole('button', { name: 'Search' })) + if (destination === 'page') fireEvent.click(screen.getByRole('button', { name: 'Next documents' })) + if (destination === 'tab') { + fireEvent.click(screen.getByRole('button', { name: 'Ask Question' })) + fireEvent.click(screen.getByRole('button', { name: 'Documents' })) + } + expect(deletes()[0].signal?.aborted).toBe(true) + if (destination !== 'selection') fireEvent.click(await screen.findByRole('button', { name: /^Guide 1 / })) + const content = destination === 'selection' ? 'Saved content 2' : 'Saved content 1' + await screen.findByText(content) + const count = requests.length + await act(async () => { + if (outcome === 'success') resolve(json({ id: 1 })) + else reject(new Error('late failure')) + }) + expect(screen.getByText(content)).toBeTruthy() + expect(screen.queryByText('Document is no longer saved.')).toBeNull() + expect(screen.queryByRole('alert')).toBeNull() + expect(requests).toHaveLength(count) + expect(screen.queryByRole('group', { name: 'Confirm document deletion' })).toBeNull() + }) +}