SurfSense/surfsense_backend/tests/unit
CREDO23 6671c91841 multi_agent_chat/permissions: persist 'always' decisions to trusted-tools list
Until now an "Always Allow" reply only updated the in-memory runtime
ruleset, evaporating after the session ended. Persist it to the
existing connector.config['trusted_tools'] list so the next session's
fetch_user_allowlist_rulesets picks it up and the user is never asked
again for the same (connector, tool) pair.

- TrustedToolSaver + make_trusted_tool_saver(user_id) in
  user_tool_allowlist: opens its own session via async_session_maker
  per call, logs and swallows failures (in-memory promotion is the
  canonical "always" path, durable persistence is opportunistic).

- PermissionMiddleware._process is now pure: returns
  (state_update, list[_AlwaysPromotion]). aafter_model awaits the
  saver for each promotion; after_model discards them. Promotions are
  only emitted for tools whose metadata exposes mcp_connector_id, so
  native tools and KB FS ops are correctly skipped.

- main_agent factory builds the saver once per turn and stashes it in
  dependencies["trusted_tool_saver"]; pack_subagent and the KB
  middleware stack forward it through build_permission_mw.

- Renamed pm._process(state, None) call sites in two existing tests to
  pm.after_model(state, None) so they exercise the public hook
  contract instead of the now-tuple-returning private method.
2026-05-15 14:07:08 +02:00
..
adapters test: bootstrap pytest environment for backend 2026-02-24 18:19:56 +02:00
agents multi_agent_chat/permissions: persist 'always' decisions to trusted-tools list 2026-05-15 14:07:08 +02:00
connector_indexers Fix test mocks for vision_llm kwarg 2026-04-10 18:20:49 +02:00
connectors chore: ran linting 2026-04-07 05:55:39 +05:30
db feat: improved agent streaming 2026-04-29 07:20:31 -07:00
e2e_fakes test(backend): enhance Drive file filtering and add unit tests for _drive_list_files 2026-05-06 17:58:58 +05:30
etl_pipeline fix: update LlamaCloud test assertions to reflect new parse modes 2026-04-16 01:32:42 -07:00
google_unification chore: ran linting 2026-05-09 05:28:09 +05:30
indexing_pipeline feat: made agent file sytem optimized 2026-03-28 16:39:46 -07:00
middleware fix(test): pin enable_kb_planner_runnable=false for KB-search planner tests 2026-05-05 02:00:34 +02:00
observability chore: cleaned comments slop 2026-04-28 23:52:37 -07:00
routes feat: fixed vision/image provider specific errors and fixed podcast/video streaming 2026-05-02 19:18:53 -07:00
services feat: improved document, folder mentions rendering 2026-05-09 22:15:51 -07:00
tasks chat/stream_resume: salt thinking-step prefix with turn_id to avoid duplicate React keys 2026-05-13 21:15:51 +02:00
utils test(backend): add OAuth state security unit tests 2026-05-06 17:18:31 +05:30
__init__.py test: bootstrap pytest environment for backend 2026-02-24 18:19:56 +02:00
test_error_contract.py chore: linting 2026-04-22 01:05:31 -07:00
test_obsidian_plugin_indexer.py chore: linting 2026-04-27 14:04:50 -07:00
test_stream_new_chat_contract.py feat: moved chat persistance to Server Side 2026-05-04 03:06:15 -07:00