diff --git a/.tmp/proof/document-reindex-api.txt b/.tmp/proof/document-reindex-api.txt new file mode 100644 index 0000000..ece0c55 --- /dev/null +++ b/.tmp/proof/document-reindex-api.txt @@ -0,0 +1,55 @@ +Offline fixture capture, local SQLite and Chroma, fixed embeddings. +Slack authentication mocked; Slack API calls and Socket Mode blocked. + +document-reindex-retrieval-before.json +POST /api/retrieval/preview {"question":"How do I reset VPN?"} +{"question":"How do I reset VPN?","channel_id":null,"top_k":5,"max_distance":null,"items":[]} + +document-reindex-retrieval-after.json +POST /api/retrieval/preview {"question":"How do I reset VPN?"} +{"question":"How do I reset VPN?","channel_id":null,"top_k":5,"max_distance":null,"items":[{"content":"Reset VPN via IT portal.","metadata":{"chunk":0,"document_id":1,"source":"offline fixture","title":"VPN recovery guide"},"distance":1.0}]} + +$ ['curl', '--max-time', '5', '-sS', '-i', 'http://127.0.0.1:18053/health'] +HTTP/1.1 200 OK +date: Mon, 16 Nov 2026 02:16:49 GMT +server: uvicorn +content-length: 20 +content-type: application/json + +{"status":"healthy"} + +$ ['curl', '--max-time', '5', '-sS', '-i', 'http://127.0.0.1:18053/api/documents?limit=20&offset=0'] +HTTP/1.1 200 OK +date: Mon, 16 Nov 2026 02:16:49 GMT +server: uvicorn +content-length: 195 +content-type: application/json + +{"items":[{"id":1,"title":"VPN recovery guide","source":"offline fixture","created_at":"2026-11-16T01:35:07.372068","content_preview":"Reset VPN via IT portal."}],"total":1,"limit":20,"offset":0} + +$ ['curl', '--max-time', '5', '-sS', '-i', 'http://127.0.0.1:18053/api/documents/1'] +HTTP/1.1 200 OK +date: Mon, 16 Nov 2026 02:16:50 GMT +server: uvicorn +content-length: 185 +content-type: application/json + +{"id":1,"title":"VPN recovery guide","content":"Reset VPN via IT portal.","source":"offline fixture","created_at":"2026-11-16T01:35:07.372068","updated_at":"2026-11-16T01:35:07.372085"} + +$ ['curl', '--max-time', '5', '-sS', '-i', '-X', 'POST', 'http://127.0.0.1:18053/api/documents/1/index'] +HTTP/1.1 200 OK +date: Mon, 16 Nov 2026 02:16:50 GMT +server: uvicorn +content-length: 50 +content-type: application/json + +{"id":1,"message":"Document indexed successfully"} + +$ ['curl', '--max-time', '5', '-sS', '-i', 'http://127.0.0.1:18053/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 02:16:50 GMT +server: uvicorn +content-length: 241 +content-type: application/json + +{"question":"How do I reset VPN?","channel_id":null,"top_k":5,"max_distance":null,"items":[{"content":"Reset VPN via IT portal.","metadata":{"chunk":0,"document_id":1,"source":"offline fixture","title":"VPN recovery guide"},"distance":1.0}]} diff --git a/.tmp/proof/document-reindex-backend-tests.txt b/.tmp/proof/document-reindex-backend-tests.txt new file mode 100644 index 0000000..c033fd5 --- /dev/null +++ b/.tmp/proof/document-reindex-backend-tests.txt @@ -0,0 +1,280 @@ +[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/spiffy-catfish/backend/.venv/bin/python +cachedir: .pytest_cache +rootdir: /Users/johnny/.paseo/worktrees/0x03bguv/spiffy-catfish/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 209 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 [ 5%] +tests/test_file_extraction_units.py::test_typescript_file_extraction PASSED [ 5%] +tests/test_file_extraction_units.py::test_shell_script_extraction PASSED [ 6%] +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 [ 7%] +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 [ 8%] +tests/test_logging_config.py::test_error_hash_not_stack PASSED [ 8%] +tests/test_logging_config.py::test_wide_event_one_per_request PASSED [ 9%] +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 [ 10%] +tests/test_logging.py::test_text_format_and_configured_level PASSED [ 10%] +tests/test_logging.py::test_api_keeps_backend_service_when_importing_bot PASSED [ 11%] +tests/test_agent_runtime.py::test_transport_retry_keeps_request_id PASSED [ 11%] +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 [ 12%] +tests/test_rules.py::TestMatching::test_contains_is_case_insensitive PASSED [ 12%] +tests/test_rules.py::TestMatching::test_contains_needs_the_keyword PASSED [ 13%] +tests/test_rules.py::TestMatching::test_any_keyword_can_match PASSED [ 13%] +tests/test_rules.py::TestMatching::test_exact_needs_the_whole_question PASSED [ 14%] +tests/test_rules.py::TestMatching::test_regex_match PASSED [ 14%] +tests/test_rules.py::TestMatching::test_blank_question_never_matches PASSED [ 15%] +tests/test_rules.py::TestMatching::test_no_rules_is_a_no_op PASSED [ 15%] +tests/test_rules.py::TestOrderingAndEnabled::test_higher_priority_wins PASSED [ 16%] +tests/test_rules.py::TestOrderingAndEnabled::test_config_order_breaks_priority_ties PASSED [ 16%] +tests/test_rules.py::TestOrderingAndEnabled::test_disabled_rule_never_matches PASSED [ 17%] +tests/test_rules.py::TestConfigLoading::test_parse_valid_rules PASSED [ 17%] +tests/test_rules.py::TestConfigLoading::test_parse_skips_invalid_entries PASSED [ 18%] +tests/test_rules.py::TestConfigLoading::test_parse_skips_bad_regex PASSED [ 18%] +tests/test_rules.py::TestConfigLoading::test_parse_rejects_non_list PASSED [ 19%] +tests/test_rules.py::TestConfigLoading::test_load_from_json_text PASSED [ 19%] +tests/test_rules.py::TestConfigLoading::test_load_invalid_json_is_empty PASSED [ 20%] +tests/test_rules.py::TestConfigLoading::test_load_from_file_and_file_wins PASSED [ 20%] +tests/test_rules.py::TestConfigLoading::test_load_missing_file_is_empty PASSED [ 21%] +tests/test_rules.py::TestConfigLoading::test_from_settings_reads_both_fields PASSED [ 21%] +tests/test_rules.py::TestRagShortCircuit::test_matched_question_skips_retrieval_and_generation PASSED [ 22%] +tests/test_rules.py::TestRagShortCircuit::test_unmatched_question_still_uses_generation PASSED [ 22%] +tests/test_rules.py::TestSlackShortCircuit::test_matched_slack_question_skips_retrieval_and_carries_pinned_answer PASSED [ 22%] +tests/test_rules.py::TestSlackShortCircuit::test_unmatched_slack_question_uses_retrieval_without_pinned_answer PASSED [ 23%] +tests/test_conversations.py::TestListConversations::test_lists_summaries_most_recent_first PASSED [ 23%] +tests/test_conversations.py::TestListConversations::test_summary_counts_and_preview PASSED [ 24%] +tests/test_conversations.py::TestListConversations::test_pagination PASSED [ 24%] +tests/test_conversations.py::TestListConversations::test_channel_filter PASSED [ 25%] +tests/test_conversations.py::TestListConversations::test_channel_filter_scopes_preview_for_shared_conversation[C1] PASSED [ 25%] +tests/test_conversations.py::TestListConversations::test_channel_filter_scopes_preview_for_shared_conversation[C2] PASSED [ 26%] +tests/test_conversations.py::TestListConversations::test_unfiltered_preview_includes_latest_turn_across_channels PASSED [ 26%] +tests/test_conversations.py::TestListConversations::test_scoped_preview_breaks_timestamp_ties_by_latest_id PASSED [ 27%] +tests/test_conversations.py::TestListConversations::test_invalid_pagination_rejected PASSED [ 27%] +tests/test_conversations.py::TestListConversations::test_empty_database PASSED [ 28%] +tests/test_conversations.py::TestConversationDetail::test_returns_turns_in_chronological_order PASSED [ 28%] +tests/test_conversations.py::TestConversationDetail::test_detail_pagination PASSED [ 29%] +tests/test_conversations.py::TestConversationDetail::test_missing_conversation_is_404 PASSED [ 29%] +tests/test_conversations.py::TestConversationDetail::test_detail_invalid_pagination_rejected PASSED [ 30%] +tests/test_documents.py::TestListDocuments::test_lists_documents_most_recent_first PASSED [ 30%] +tests/test_documents.py::TestListDocuments::test_preview_and_fields PASSED [ 31%] +tests/test_documents.py::TestListDocuments::test_pagination PASSED [ 31%] +tests/test_documents.py::TestListDocuments::test_source_filter PASSED [ 32%] +tests/test_documents.py::TestListDocuments::test_invalid_pagination_rejected PASSED [ 32%] +tests/test_documents.py::TestListDocuments::test_empty_database PASSED [ 33%] +tests/test_documents.py::TestSearchDocuments::test_matches_title_case_insensitively_and_trims_query[vpn] PASSED [ 33%] +tests/test_documents.py::TestSearchDocuments::test_matches_title_case_insensitively_and_trims_query[VpN] PASSED [ 33%] +tests/test_documents.py::TestSearchDocuments::test_matches_title_case_insensitively_and_trims_query[ \tVPN\n ] PASSED [ 34%] +tests/test_documents.py::TestSearchDocuments::test_matches_content_beyond_the_preview PASSED [ 34%] +tests/test_documents.py::TestSearchDocuments::test_filters_before_counting_and_paginating PASSED [ 35%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[title-%] PASSED [ 35%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[title-_] PASSED [ 36%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[title-/] PASSED [ 36%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[title-100%] PASSED [ 37%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[title-setup_notes] PASSED [ 37%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[title-a/b] PASSED [ 38%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[title-' OR 1=1 --] PASSED [ 38%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[content-%] PASSED [ 39%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[content-_] PASSED [ 39%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[content-/] PASSED [ 40%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[content-100%] PASSED [ 40%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[content-setup_notes] PASSED [ 41%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[content-a/b] PASSED [ 41%] +tests/test_documents.py::TestSearchDocuments::test_treats_sql_wildcards_and_escape_characters_literally[content-' OR 1=1 --] PASSED [ 42%] +tests/test_documents.py::TestSearchDocuments::test_blank_query_preserves_source_filter_and_existing_list[] PASSED [ 42%] +tests/test_documents.py::TestSearchDocuments::test_blank_query_preserves_source_filter_and_existing_list[ \t\n ] PASSED [ 43%] +tests/test_documents.py::TestSearchDocuments::test_blank_query_preserves_source_filter_and_existing_list[\u2003\xa0] PASSED [ 43%] +tests/test_documents.py::TestSearchDocuments::test_no_matches_return_an_empty_page[params0] PASSED [ 44%] +tests/test_documents.py::TestSearchDocuments::test_no_matches_return_an_empty_page[params1] PASSED [ 44%] +tests/test_documents.py::TestDocumentDetail::test_returns_full_content PASSED [ 44%] +tests/test_documents.py::TestDocumentDetail::test_missing_document_is_404 PASSED [ 45%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[-title] PASSED [ 45%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[-content] PASSED [ 46%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[-source] PASSED [ 46%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[ \n\t -title] PASSED [ 47%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[ \n\t -content] PASSED [ 47%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[ \n\t -source] PASSED [ 48%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[\u2003\xa0-title] PASSED [ 48%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[\u2003\xa0-content] PASSED [ 49%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[\u2003\xa0-source] PASSED [ 49%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[None-title] PASSED [ 50%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[None-content] PASSED [ 50%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[None-source] PASSED [ 51%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[123-title] PASSED [ 51%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[123-content] PASSED [ 52%] +tests/test_documents.py::TestCreateDocument::test_rejects_invalid_fields_without_writes_or_indexing[123-source] PASSED [ 52%] +tests/test_documents.py::TestCreateDocument::test_rejects_missing_required_fields[title] PASSED [ 53%] +tests/test_documents.py::TestCreateDocument::test_rejects_missing_required_fields[content] PASSED [ 53%] +tests/test_documents.py::TestCreateDocument::test_creates_readable_document_and_indexes_preserved_content[None] PASSED [ 54%] +tests/test_documents.py::TestCreateDocument::test_creates_readable_document_and_indexes_preserved_content[ \tdocs\n ] PASSED [ 54%] +tests/test_retrieval.py::test_invalid_chunk_settings_are_rejected[config0] PASSED [ 55%] +tests/test_retrieval.py::test_invalid_chunk_settings_are_rejected[config1] PASSED [ 55%] +tests/test_retrieval.py::test_invalid_chunk_settings_are_rejected[config2] PASSED [ 55%] +tests/test_retrieval.py::test_invalid_chunk_settings_are_rejected[config3] PASSED [ 56%] +tests/test_retrieval.py::test_invalid_chunk_settings_are_rejected[config4] PASSED [ 56%] +tests/test_retrieval.py::test_valid_chunk_settings_are_accepted[1000-200] PASSED [ 57%] +tests/test_retrieval.py::test_valid_chunk_settings_are_accepted[1-0] PASSED [ 57%] +tests/test_retrieval.py::test_valid_chunk_settings_are_accepted[10-0] PASSED [ 58%] +tests/test_retrieval.py::test_valid_chunk_settings_are_accepted[10-9] PASSED [ 58%] +tests/test_retrieval.py::test_document_chunks_stop_after_covering_content[-5-2-expected0] PASSED [ 59%] +tests/test_retrieval.py::test_document_chunks_stop_after_covering_content[a-5-2-expected1] PASSED [ 59%] +tests/test_retrieval.py::test_document_chunks_stop_after_covering_content[abcd-5-2-expected2] PASSED [ 60%] +tests/test_retrieval.py::test_document_chunks_stop_after_covering_content[abcde-5-2-expected3] PASSED [ 60%] +tests/test_retrieval.py::test_document_chunks_stop_after_covering_content[abcdef-5-2-expected4] PASSED [ 61%] +tests/test_retrieval.py::test_document_chunks_stop_after_covering_content[abcdefgh-5-2-expected5] PASSED [ 61%] +tests/test_retrieval.py::test_document_chunks_stop_after_covering_content[abcdefghi-5-2-expected6] PASSED [ 62%] +tests/test_retrieval.py::test_document_chunks_stop_after_covering_content[abcdefghij-5-0-expected7] PASSED [ 62%] +tests/test_retrieval.py::test_document_chunks_stop_after_covering_content[abcdef-5-4-expected8] PASSED [ 63%] +tests/test_retrieval.py::test_document_chunks_stop_after_covering_content[abc-1-0-expected9] PASSED [ 63%] +tests/test_retrieval.py::test_document_indexing_avoids_redundant_tail_chunks PASSED [ 64%] +tests/test_retrieval.py::test_repeated_thread_indexing_preserves_distinct_top_k PASSED [ 64%] +tests/test_retrieval.py::test_thread_reindex_updates_content_and_embedding PASSED [ 65%] +tests/test_retrieval.py::test_thread_chunk_ids_are_scoped_by_channel PASSED [ 65%] +tests/test_retrieval.py::test_thread_indexing_omits_absent_optional_metadata PASSED [ 66%] +tests/test_retrieval.py::test_thread_indexing_uses_last_duplicate_in_batch PASSED [ 66%] +tests/test_retrieval.py::test_thread_indexing_skips_unusable_messages[messages0] PASSED [ 66%] +tests/test_retrieval.py::test_thread_indexing_skips_unusable_messages[messages1] PASSED [ 67%] +tests/test_retrieval.py::test_thread_indexing_skips_unusable_messages[messages2] PASSED [ 67%] +tests/test_retrieval.py::test_thread_indexing_skips_unusable_messages[messages3] PASSED [ 68%] +tests/test_retrieval.py::test_thread_indexing_skips_unusable_messages[messages4] PASSED [ 68%] +tests/test_retrieval.py::test_thread_indexing_skips_unusable_messages[messages5] PASSED [ 69%] +tests/test_retrieval.py::test_thread_indexing_skips_unusable_messages[messages6] PASSED [ 69%] +tests/test_retrieval.py::test_search_empty_collection_returns_no_matches[None-None] PASSED [ 70%] +tests/test_retrieval.py::test_search_empty_collection_returns_no_matches[None-CTARGET] PASSED [ 70%] +tests/test_retrieval.py::test_search_empty_collection_returns_no_matches[1.0-None] PASSED [ 71%] +tests/test_retrieval.py::test_search_empty_collection_returns_no_matches[1.0-CTARGET] PASSED [ 71%] +tests/test_retrieval.py::test_first_document_can_be_indexed_and_retrieved PASSED [ 72%] +tests/test_retrieval.py::test_missing_adapter_still_raises[add] PASSED [ 72%] +tests/test_retrieval.py::test_missing_adapter_still_raises[search] PASSED [ 73%] +tests/test_retrieval.py::test_channel_filter_runs_before_top_k PASSED [ 73%] +tests/test_retrieval.py::test_unscoped_search_preserves_global_ranking_and_explicit_k PASSED [ 74%] +tests/test_retrieval.py::test_distance_cutoff_is_inclusive_and_preserves_channel_scope PASSED [ 74%] +tests/test_retrieval.py::test_zero_distance_cutoff_keeps_only_exact_vector_matches PASSED [ 75%] +tests/test_retrieval.py::test_invalid_distance_config_is_rejected[-1] PASSED [ 75%] +tests/test_retrieval.py::test_invalid_distance_config_is_rejected[nan] PASSED [ 76%] +tests/test_retrieval.py::test_invalid_distance_config_is_rejected[inf] PASSED [ 76%] +tests/test_retrieval.py::test_invalid_distance_config_is_rejected[-inf] PASSED [ 77%] +tests/test_retrieval.py::test_invalid_distance_config_is_rejected[invalid] PASSED [ 77%] +tests/test_retrieval.py::test_distance_config_accepts_unset_or_nonnegative_finite_values[None] PASSED [ 77%] +tests/test_retrieval.py::test_distance_config_accepts_unset_or_nonnegative_finite_values[0] PASSED [ 78%] +tests/test_retrieval.py::test_distance_config_accepts_unset_or_nonnegative_finite_values[1.5] PASSED [ 78%] +tests/test_retrieval.py::test_empty_channel_does_not_fall_back_to_global_results PASSED [ 79%] +tests/test_retrieval.py::test_rag_payload_uses_scoped_matches[None-2-api] PASSED [ 79%] +tests/test_retrieval.py::test_rag_payload_uses_scoped_matches[None-2-slack] PASSED [ 80%] +tests/test_retrieval.py::test_rag_payload_uses_scoped_matches[1.0-1-api] PASSED [ 80%] +tests/test_retrieval.py::test_rag_payload_uses_scoped_matches[1.0-1-slack] PASSED [ 81%] +tests/test_retrieval.py::test_rag_payload_uses_scoped_matches[0.0-0-api] PASSED [ 81%] +tests/test_retrieval.py::test_rag_payload_uses_scoped_matches[0.0-0-slack] PASSED [ 82%] +tests/test_thread_indexing.py::test_saved_thread_includes_root_and_replies_in_timestamp_order PASSED [ 82%] +tests/test_thread_indexing.py::test_saved_root_only_thread_is_indexed_once[None] PASSED [ 83%] +tests/test_thread_indexing.py::test_saved_root_only_thread_is_indexed_once[1700000000.000001] PASSED [ 83%] +tests/test_thread_indexing.py::test_saved_replies_can_be_indexed_without_a_saved_root PASSED [ 84%] +tests/test_thread_indexing.py::test_missing_saved_thread_returns_404_without_indexing[CTARGET-1700000098.000001] PASSED [ 84%] +tests/test_thread_indexing.py::test_missing_saved_thread_returns_404_without_indexing[CEMPTY-1700000000.000001] PASSED [ 85%] +tests/test_thread_indexing.py::test_saved_thread_channel_filter_also_applies_to_root_lookup PASSED [ 85%] +tests/test_thread_indexing.py::test_saved_thread_indexing_failure_remains_500 PASSED [ 86%] +tests/test_thread_indexing.py::test_saved_thread_retrieval_includes_original_question PASSED [ 86%] +tests/test_retrieval_preview.py::test_preview_returns_ranked_chunks_metadata_distances_and_settings PASSED [ 87%] +tests/test_retrieval_preview.py::test_preview_applies_channel_scope_before_top_k PASSED [ 87%] +tests/test_retrieval_preview.py::test_preview_exposes_inclusive_distance_cutoff_with_transcript PASSED [ 88%] +tests/test_retrieval_preview.py::test_preview_returns_success_for_empty_results[collection] PASSED [ 88%] +tests/test_retrieval_preview.py::test_preview_returns_success_for_empty_results[channel] PASSED [ 88%] +tests/test_retrieval_preview.py::test_preview_returns_success_for_empty_results[cutoff] PASSED [ 89%] +tests/test_retrieval_preview.py::test_preview_rejects_invalid_input_before_search[payload0] PASSED [ 89%] +tests/test_retrieval_preview.py::test_preview_rejects_invalid_input_before_search[payload1] PASSED [ 90%] +tests/test_retrieval_preview.py::test_preview_rejects_invalid_input_before_search[payload2] PASSED [ 90%] +tests/test_retrieval_preview.py::test_preview_rejects_invalid_input_before_search[payload3] PASSED [ 91%] +tests/test_retrieval_preview.py::test_preview_rejects_invalid_input_before_search[payload4] PASSED [ 91%] +tests/test_retrieval_preview.py::test_preview_rejects_invalid_input_before_search[payload5] PASSED [ 92%] +tests/test_retrieval_preview.py::test_preview_rejects_invalid_input_before_search[payload6] PASSED [ 92%] +tests/test_retrieval_preview.py::test_preview_trims_question_and_channel PASSED [ 93%] +tests/test_retrieval_preview.py::test_preview_reports_unavailable_retrieval_without_exposing_error PASSED [ 93%] +tests/test_document_indexing.py::test_create_and_retry_keep_one_owned_chunk_and_preserve_saved_record PASSED [ 94%] +tests/test_document_indexing.py::test_retry_recovers_saved_document_after_embedding_failure_with_transcript PASSED [ 94%] +tests/test_document_indexing.py::test_retry_rechunks_and_removes_only_obsolete_owned_chunks PASSED [ 95%] +tests/test_document_indexing.py::test_retry_reads_latest_saved_content_title_and_source PASSED [ 95%] +tests/test_document_indexing.py::test_retry_failure_keeps_previous_chunks_and_saved_content[lookup] PASSED [ 96%] +tests/test_document_indexing.py::test_retry_failure_keeps_previous_chunks_and_saved_content[embed] PASSED [ 96%] +tests/test_document_indexing.py::test_retry_failure_keeps_previous_chunks_and_saved_content[upsert] PASSED [ 97%] +tests/test_document_indexing.py::test_cleanup_failure_is_reported_and_retry_finishes_without_duplicates PASSED [ 97%] +tests/test_document_indexing.py::test_missing_saved_document_does_not_initialise_vector_store PASSED [ 98%] +tests/test_document_indexing.py::test_invalid_legacy_document_is_rejected_without_changing_chunks[content- \n\t ] PASSED [ 98%] +tests/test_document_indexing.py::test_invalid_legacy_document_is_rejected_without_changing_chunks[content-None] PASSED [ 99%] +tests/test_document_indexing.py::test_invalid_legacy_document_is_rejected_without_changing_chunks[title-] PASSED [ 99%] +tests/test_document_indexing.py::test_invalid_legacy_document_is_rejected_without_changing_chunks[source-None] PASSED [100%] + +=============================== warnings summary =============================== +app/main.py:97 + /Users/johnny/.paseo/worktrees/0x03bguv/spiffy-catfish/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/spiffy-catfish/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/spiffy-catfish/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/spiffy-catfish/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/spiffy-catfish/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/spiffy-catfish/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 + /Users/johnny/.paseo/worktrees/0x03bguv/spiffy-catfish/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/spiffy-catfish/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 + /Users/johnny/.paseo/worktrees/0x03bguv/spiffy-catfish/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 +================ 209 passed, 928 warnings in 141.54s (0:02:21) ================= diff --git a/.tmp/proof/document-reindex-browser-failure.txt b/.tmp/proof/document-reindex-browser-failure.txt new file mode 100644 index 0000000..f1cfdbb --- /dev/null +++ b/.tmp/proof/document-reindex-browser-failure.txt @@ -0,0 +1,26 @@ +### Result +#25 [POST] http://127.0.0.1:18053/api/documents/1/index + + General + status: [503] Service Unavailable + duration: 123ms + type: fetch + mimeType: application/json + + Request headers + sec-ch-ua-platform: "macOS" + referer: http://127.0.0.1:3053/ + 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: 83 + date: Mon, 16 Nov 2026 01:36:29 GMT + content-type: application/json + server: uvicorn + access-control-allow-credentials: true + +Run `response-body 25` to read the response body. +{"detail":{"message":"Document saved but indexing is unavailable","document_id":1}} diff --git a/.tmp/proof/document-reindex-browser-success.txt b/.tmp/proof/document-reindex-browser-success.txt new file mode 100644 index 0000000..2bee580 --- /dev/null +++ b/.tmp/proof/document-reindex-browser-success.txt @@ -0,0 +1,26 @@ +### Result +#26 [POST] http://127.0.0.1:18053/api/documents/1/index + + General + status: [200] OK + duration: 90ms + type: fetch + mimeType: application/json + + Request headers + sec-ch-ua-platform: "macOS" + referer: http://127.0.0.1:3053/ + 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 01:36:46 GMT + content-type: application/json + server: uvicorn + access-control-allow-credentials: true + +Run `response-body 26` to read the response body. +{"id":1,"message":"Document indexed successfully"} diff --git a/.tmp/proof/document-reindex-error.png b/.tmp/proof/document-reindex-error.png new file mode 100644 index 0000000..aa7239f Binary files /dev/null and b/.tmp/proof/document-reindex-error.png differ diff --git a/.tmp/proof/document-reindex-frontend-tests.txt b/.tmp/proof/document-reindex-frontend-tests.txt new file mode 100644 index 0000000..b477ccd --- /dev/null +++ b/.tmp/proof/document-reindex-frontend-tests.txt @@ -0,0 +1,51 @@ +[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 [329.42ms] +(pass) document client encodes literal search text, keeps source filters, and omits blank queries [0.26ms] +(pass) documents show loading, retry the submitted query after a list error, and distinguish empty searches [28.26ms] +(pass) documents render saved content as text and retry detail failures without losing results [60.22ms] +(pass) documents ignore stale successful and failed list responses after a newer search [20.04ms] +(pass) documents ignore late details after another selection, a page change, and clearing a search [198.86ms] +(pass) documents abort requests on leaving the tab and ignore late responses when reopened [21.95ms] + +tests/document-indexing.test.tsx: +(pass) re-indexing requires an explicit click, posts the saved ID once while pending, and keeps the content visible [50.22ms] +(pass) re-indexing reports a safe failure for 404 and retries the same saved document [307.03ms] +(pass) re-indexing reports a safe failure for 422 and retries the same saved document [70.49ms] +(pass) re-indexing reports a safe failure for 503 and retries the same saved document [21.88ms] +(pass) re-indexing reports a safe failure for network and retries the same saved document [23.60ms] +(pass) re-indexing ignores a late success after a selection change [63.04ms] +(pass) re-indexing ignores a late failure after a selection change [109.90ms] +(pass) re-indexing ignores a late success after a search change [52.82ms] +(pass) re-indexing ignores a late failure after a search change [42.73ms] +(pass) re-indexing ignores a late success after a page change [263.83ms] +(pass) re-indexing ignores a late failure after a page change [98.40ms] +(pass) re-indexing ignores a late success after a tab change [42.44ms] +(pass) re-indexing ignores a late failure after a tab change [37.68ms] + +tests/retrieval.test.tsx: +(pass) retrieval waits for a non-blank question and submits trimmed optional scope [13.61ms] +(pass) retrieval omits blank scope, preserves rank and raw distances, and shows an unset cutoff [7.13ms] +(pass) retrieval disables inputs and duplicate submissions while loading [6.24ms] +(pass) retrieval shows an empty result and a zero distance cutoff [27.24ms] +(pass) retrieval replaces a failed request with a successful retry [14.17ms] +(pass) retrieval clears old results when the question or channel changes [387.87ms] +(pass) retrieval aborts on leaving the tab and ignores late responses after reopening [40.56ms] +(pass) retrieval renders chunk and metadata markup as text [14.04ms] + +tests/conversations.test.tsx: +(pass) loads only on opening the tab and paginates summaries and chronological turns independently [169.04ms] +(pass) shows loading, an empty page and a list error with a working retry [6.52ms] +(pass) retries missing conversation details without discarding the list [48.23ms] +(pass) ignores stale detail responses after selecting another conversation [25.13ms] +(pass) ignores stale errors after leaving and reopening the tab [14.87ms] +(pass) renders stored markup as text and supports missing metadata [18.46ms] +(pass) encodes conversation IDs in detail request paths [1.76ms] + + 35 pass + 0 fail + 261 expect() calls +Ran 35 tests across 4 files. [3.41s] diff --git a/.tmp/proof/document-reindex-mobile.png b/.tmp/proof/document-reindex-mobile.png new file mode 100644 index 0000000..86d0090 Binary files /dev/null and b/.tmp/proof/document-reindex-mobile.png differ diff --git a/.tmp/proof/document-reindex-runtime-tests.txt b/.tmp/proof/document-reindex-runtime-tests.txt new file mode 100644 index 0000000..e25e231 --- /dev/null +++ b/.tmp/proof/document-reindex-runtime-tests.txt @@ -0,0 +1,22 @@ +[test-runtime] $ node --test +✔ real Pi SQLite storage preserves answers, deduplicates retries, and retains conversation history (139.641791ms) +✔ outbox resumes after restart without regenerating answer; retry admits only one job (7.461334ms) +Warning: Detected unsettled top-level await at file:///Users/johnny/.paseo/worktrees/0x03bguv/spiffy-catfish/runtime/fixtures/interrupted.mjs:12 +await answerJob(JSON.parse(process.argv[3]), { +^ + + + +✔ a process killed during generation resumes the admitted Pi submission (607.205292ms) +✔ pinned operator answer is delivered without calling the model (2.92625ms) +✔ model failure sends a persisted Slack failure notification (0.764ms) +✔ runtime starts with openai catalog and protects job routes (2035.927208ms) +✔ runtime starts with mimo catalog and protects job routes (878.3355ms) +ℹ tests 7 +ℹ suites 0 +ℹ pass 7 +ℹ fail 0 +ℹ cancelled 0 +ℹ skipped 0 +ℹ todo 0 +ℹ duration_ms 3118.980458 diff --git a/.tmp/proof/document-reindex-sitecustomize.py b/.tmp/proof/document-reindex-sitecustomize.py new file mode 100644 index 0000000..4c0dde3 --- /dev/null +++ b/.tmp/proof/document-reindex-sitecustomize.py @@ -0,0 +1,45 @@ +"""Local proof process only: deny Slack and use fixture Chroma embeddings.""" +from pathlib import Path +from slack_sdk import WebClient +from slack_bolt.adapter.socket_mode import SocketModeHandler + + +def blocked(*args, **kwargs): + raise AssertionError("Live Slack calls and Socket Mode are forbidden in this proof process") + + +WebClient.auth_test = lambda *args, **kwargs: { + "ok": True, "bot_id": "BTEST", "user_id": "UTEST", "team_id": "TTEST", +} +WebClient.api_call = blocked +SocketModeHandler.start = blocked + +import chromadb +from chromadb.config import Settings as ChromaSettings +from chromadb.telemetry.product.posthog import Posthog +from langchain_community.vectorstores import Chroma +from langchain_core.embeddings import Embeddings +from app.vector_store import vector_store + +Posthog.capture = lambda *args, **kwargs: None +proof_dir = Path(__file__).resolve().parent + + +class FixedEmbeddings(Embeddings): + def embed_documents(self, texts): + # A marker file injects a recoverable provider failure for the transcript. + if (proof_dir / "fail-embedding").exists(): + raise RuntimeError("Fixture embedding outage") + return [[float(len("Reset VPN via IT portal.") - len(text) + 1), 1.0] for text in texts] + + def embed_query(self, text): + return [0.0, 1.0] + + +vector_store.vector_store = Chroma( + client=chromadb.PersistentClient( + path=str(proof_dir / "chroma"), settings=ChromaSettings(anonymized_telemetry=False), + ), + collection_name="document-retry-proof", embedding_function=FixedEmbeddings(), +) +vector_store._initialized = True diff --git a/.tmp/proof/document-reindex-success.png b/.tmp/proof/document-reindex-success.png new file mode 100644 index 0000000..1590110 Binary files /dev/null and b/.tmp/proof/document-reindex-success.png differ diff --git a/docs/retrieval.md b/docs/retrieval.md index f8b4341..0f11321 100644 --- a/docs/retrieval.md +++ b/docs/retrieval.md @@ -89,6 +89,13 @@ result at a width of 390 pixels. ## Retry saved document indexing +In the dashboard, open **Documents**, select a saved document and choose +**Re-index document**. Its content stays visible while indexing runs. The action +shows success or a retryable error and does not create another document. The +list shows saved records, not a persistent indexing status. Leaving the detail +view stops waiting for the result; work already started on the backend may still +finish. The configured embedding provider can charge for this operation. + `POST /api/documents/{document_id}/index` indexes the saved title, content and source without creating or modifying a database record. Find the ID with `GET /api/documents`. A missing record returns HTTP 404; invalid legacy title, diff --git a/frontend/components/documents-panel.tsx b/frontend/components/documents-panel.tsx index d62adf9..aa9de5e 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, type DocumentDetail, type DocumentListResponse } from '@/lib/api' +import { 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,6 +11,41 @@ function formatDate(value?: string | null) { return new Date(value).toLocaleDateString('en-AU', { day: 'numeric', month: 'short', year: 'numeric' }) } +function DocumentIndexAction({ documentId }: { documentId: number }) { + const [attempt, setAttempt] = useState(0) + const [phase, setPhase] = useState<'idle' | 'pending' | 'success' | 'error'>('idle') + + useEffect(() => { + if (!attempt) return + let cancelled = false + const controller = new AbortController() + reindexDocument(documentId, controller.signal) + .then(() => { if (!cancelled) setPhase('success') }) + .catch(() => { if (!cancelled) setPhase('error') }) + return () => { cancelled = true; controller.abort() } + }, [attempt, documentId]) + + return ( +
Re-index this saved content for retrieval. This uses the configured embedding provider and may incur a cost.
+ ++ {phase === 'pending' && 'Indexing saved content...'} + {phase === 'success' && 'Document indexed successfully.'} +
+ {phase === 'error' &&Could not index this document. Your saved content is unchanged. Check that the document is still available and the indexing service is running, then try again.
} +Leaving this view stops waiting for the result. Indexing already started may still finish.
+- Indexed documents used for retrieval-augmented generation. Select one to read its full content. + Saved documents for retrieval-augmented generation. Select one to read or re-index its content.