ReMe/tests/unit
celanwang 681cc85fb5
fix(auto-memory): serialize session transcript writes per session (#633)
* fix(auto-memory): serialize session transcript writes per session

_save_session_messages ran its read-merge-write on the per-session
JSONL transcript without any lock. Concurrent HTTP requests saving the
same session could interleave: two writers both appending against a
stale snapshot write overlapping history twice, and an append racing
a full rewrite can be overwritten by the rewriter's stale merge,
losing messages.

Hold get_path_lock(path) across the whole read, merge, and write,
consistent with the existing session image handling in the same file.
Merge, ordering, and can_append logic are unchanged.

Add deterministic regression tests that gate one writer's read between
snapshot capture and write: concurrent appends must merge disjoint
messages in created_at order, and an appended message must survive a
concurrent full rewrite. Both tests fail without the lock.

Closes #622

* test(auto-memory): make session-lock regression tests deterministic

Replace fixed sleeps with explicit synchronization: a shared operation
log records lock/read/write progress per writer, and writer A holds its
post-read pause until writer B is queued on the transcript lock. The
tests now assert the serialization order from the log (B reads only
after A's write completed) in addition to transcript content, so they
no longer depend on IO timing.

Also fix pylint findings from CI: use from-import for the auto_memory
module and drop unused tmp_path parameters.
2026-10-19 16:13:42 +08:00
..
__init__.py init: reme version 0.4.0 (#284) 2026-06-22 15:41:19 +08:00
auto_resource_test_plugin.py feat(auto_resource): interpret image resources into daily notes (#500) 2026-09-07 12:00:38 +08:00
auto_resource_test_support.py feat(auto-resource): unify text and image auto-resource using agentwrapper (#555) 2026-09-23 10:20:35 +08:00
test_agent_state_io.py fix(agent): preserve Unicode separators in saved state (#594) 2026-10-05 11:25:37 +08:00
test_app_config_step.py feat: add workspace web APIs and star growth report (#416) 2026-08-05 18:03:37 +08:00
test_application_config.py feat: add entry-point plugin system and extract Auto Fin (#459) 2026-08-19 17:23:23 +08:00
test_as_classifier.py feat(classifier): add optional Jev component and service demo (#619) 2026-10-14 17:49:49 +08:00
test_as_embedding_lazy.py fix(embedding): isolate caches by vector space (#442) 2026-08-10 22:42:16 +08:00
test_as_llm_lazy.py feat(docker): add container deployment and multi-platform release workflow (#582) 2026-10-03 23:54:58 +08:00
test_auto_dream.py fix(auto-dream): checkpoint scanned source versions (#618) 2026-10-16 12:13:48 +08:00
test_auto_image_steps.py feat(auto-resource): unify text and image auto-resource using agentwrapper (#555) 2026-09-23 10:20:35 +08:00
test_auto_memory_cc.py feat(evolve): tag auto-dream outputs (#538) 2026-09-11 14:08:29 +08:00
test_auto_memory_direct_images.py feat(auto-memory): save session images with source links (#574) 2026-10-09 17:42:13 +08:00
test_auto_memory_session_messages.py fix(auto-memory): serialize session transcript writes per session (#633) 2026-10-19 16:13:42 +08:00
test_auto_resource_agent_inputs.py feat(auto-resource): unify text and image auto-resource using agentwrapper (#555) 2026-09-23 10:20:35 +08:00
test_auto_resource_batch_lookup.py feat(auto-resource): unify text and image auto-resource using agentwrapper (#555) 2026-09-23 10:20:35 +08:00
test_auto_resource_review_regressions.py feat(auto-resource): unify text and image auto-resource using agentwrapper (#555) 2026-09-23 10:20:35 +08:00
test_auto_tag.py feat: auto-tag plugin-generated reports (#534) 2026-09-11 11:52:52 +08:00
test_background_steps.py fix(chunker): restore malformed JSON text fallback (#557) 2026-10-14 14:43:27 +08:00
test_base_agent_wrapper.py feat: refine local-first research and memory workflows (#444) 2026-08-11 23:32:34 +08:00
test_base_component.py feat(core): support live component replacement (#505) 2026-08-28 16:04:02 +08:00
test_bm25_live_length.py perf(bm25): maintain live document length incrementally (#590) 2026-10-03 22:38:11 +08:00
test_cc_agent_wrapper.py feat(evaluation): track job calls and agent token usage in benchmarks (#406) 2026-08-04 11:42:18 +08:00
test_classifier_config.py feat(classifier): add optional Jev component and service demo (#619) 2026-10-14 17:49:49 +08:00
test_classifier_demo.py feat(classifier): add optional Jev component and service demo (#619) 2026-10-14 17:49:49 +08:00
test_codex_agent_wrapper.py fix(codex): retain tool constraints until threads unload (#630) 2026-10-16 16:46:02 +08:00
test_codex_plugin_mcp.py feat(integrations): add automatic memory plugins for Claude Code and Codex (#575) 2026-10-12 20:12:47 +08:00
test_codex_plugin_runtime.py feat(integrations): add automatic memory plugins for Claude Code and Codex (#575) 2026-10-12 20:12:47 +08:00
test_coding_agent_plugins.py feat(integrations): add automatic memory plugins for Claude Code and Codex (#575) 2026-10-12 20:12:47 +08:00
test_common_steps.py fix(python-execute): rename the timeout parameter to survive CLI client kwargs (#587) 2026-10-09 16:49:05 +08:00
test_component_registry.py feat: add entry-point plugin system and extract Auto Fin (#459) 2026-08-19 17:23:23 +08:00
test_compressor_step.py feat(benchmark): enhance session memory retrieval and isolate benchmark assets (#409) 2026-08-05 19:23:42 +08:00
test_config_parser.py fix(search): accept CLI queries that look like numbers (#612) 2026-10-16 10:36:05 +08:00
test_cookbook_config.py refactor(auto-fin): one note per topic, merged by a separate digest step (#558) 2026-09-20 14:52:56 +08:00
test_crud_steps.py refactor(stat): consolidate answer assertions and shorten docs (#627) 2026-10-15 21:04:27 +08:00
test_daily_note_links.py feat(auto_resource): reuse parsed resource ownership per batch (#529) 2026-09-14 16:55:42 +08:00
test_daily_steps.py fix(auto-memory): preserve message timestamps (#310) 2026-07-01 17:15:07 +08:00
test_default_file_chunker.py fix(chunker): treat default file chunks as plain text (#624) 2026-10-19 12:30:35 +08:00
test_docker_runtime.py feat(docker): add container deployment and multi-platform release workflow (#582) 2026-10-03 23:54:58 +08:00
test_dream_checkpoint_versions.py fix(auto-dream): checkpoint scanned source versions (#618) 2026-10-16 12:13:48 +08:00
test_embedded_consumer_compat.py feat(docker): add container deployment and multi-platform release workflow (#582) 2026-10-03 23:54:58 +08:00
test_evaluation_interface.py feat(evaluation): track job calls and agent token usage in benchmarks (#406) 2026-08-04 11:42:18 +08:00
test_evolve_utils.py feat: auto-tag plugin-generated reports (#534) 2026-09-11 11:52:52 +08:00
test_faiss_index_maintenance.py feat(tags): add configurable tag indexing and filtered hybrid search (#530) 2026-09-10 18:01:09 +08:00
test_file_catalog.py feat(core): support live component replacement (#505) 2026-08-28 16:04:02 +08:00
test_file_graph.py fix(persistence): avoid duplicate index dumps (#489) 2026-08-26 16:51:00 +08:00
test_file_store_consistency.py feat(tags): add configurable tag indexing and filtered hybrid search (#530) 2026-09-10 18:01:09 +08:00
test_frontmatter_steps.py refactor(auto-fin): one note per topic, merged by a separate digest step (#558) 2026-09-20 14:52:56 +08:00
test_graph_snapshot_step.py feat: add frontend-ready wikilink graph APIs (#414) 2026-08-05 16:45:50 +08:00
test_hermes_agent_integration.py fix(hermes): preserve profile context and reset invalid provider state (#554) 2026-09-16 16:01:15 +08:00
test_http_client.py feat(service): support explicit wildcard network binds (#547) 2026-09-15 14:26:33 +08:00
test_http_web_workspace.py feat(jobs): add a unified enabled switch for all job types (#580) 2026-09-30 18:30:36 +08:00
test_injected_job_kwargs.py feat: auto-tag plugin-generated reports (#534) 2026-09-11 11:52:52 +08:00
test_job.py feat(jobs): add a unified enabled switch for all job types (#580) 2026-09-30 18:30:36 +08:00
test_json_file_chunker.py fix(chunker): restore malformed JSON text fallback (#557) 2026-10-14 14:43:27 +08:00
test_jsonl_file_chunker.py feat: add Auto Fin cookbook and managed outbound proxy support (#392) 2026-07-25 18:09:39 +08:00
test_keyword_index.py feat(tags): add configurable tag indexing and filtered hybrid search (#530) 2026-09-10 18:01:09 +08:00
test_line_anchor.py feat: simplify wikilink semantics and support line anchors (#412) 2026-08-05 11:47:50 +08:00
test_link_expansion.py feat: simplify wikilink semantics and support line anchors (#412) 2026-08-05 11:47:50 +08:00
test_local_embedding_store.py fix(embedding): retry 429 rate-limit errors instead of dropping the batch (#525) 2026-09-07 14:31:48 +08:00
test_logging_config.py feat: add Auto Fin cookbook and managed outbound proxy support (#392) 2026-07-25 18:09:39 +08:00
test_logo_utils.py feat(service): support explicit wildcard network binds (#547) 2026-09-15 14:26:33 +08:00
test_markdown_file_chunker.py fix(chunker): treat default file chunks as plain text (#624) 2026-10-19 12:30:35 +08:00
test_mcp_client.py feat(service): support explicit wildcard network binds (#547) 2026-09-15 14:26:33 +08:00
test_outbound_proxy.py feat: add Auto Fin cookbook and managed outbound proxy support (#392) 2026-07-25 18:09:39 +08:00
test_package_versions.py chore: release 0.4.2.0 and simplify publishing workflows (#631) 2026-10-16 16:53:52 +08:00
test_packaging.py init: reme version 0.4.0 (#284) 2026-06-22 15:41:19 +08:00
test_path_permission.py feat(Step tools): add white/black path prefix permission filtering to read, edit, write (#391) 2026-07-27 17:20:21 +08:00
test_plugin.py Separate benchmark judge plugins (#535) 2026-09-10 20:16:46 +08:00
test_plugin_cli.py fix(release): harden embedding store and plugins for ReMe 0.4.1.9 (#503) 2026-08-28 11:35:04 +08:00
test_prepared_search_filter.py perf(search): prepare search filters once per query (#591) 2026-10-14 18:14:21 +08:00
test_proactive_refresh.py feat(proactive): separate proactive refresh from auto dream (#488) 2026-09-07 17:23:37 +08:00
test_prompt_handler.py fix(prompt): default omitted conditional flags to false (#424) 2026-08-06 16:22:59 +08:00
test_qwen_token_tools.py feat(token counter): add Qwen token counting utility with fallback (#616) 2026-10-16 11:58:35 +08:00
test_read_image_steps.py docs: rename vault_dir to workspace_dir in documentation and examples (#286) 2026-06-22 16:58:57 +08:00
test_read_with_neighbors.py feat: simplify wikilink semantics and support line anchors (#412) 2026-08-05 11:47:50 +08:00
test_reindex.py fix(reindex): return a readable summary so Studio stops showing a placeholder (#565) 2026-10-14 11:25:48 +08:00
test_reme_cli.py fix(python-execute): rename the timeout parameter to survive CLI client kwargs (#587) 2026-10-09 16:49:05 +08:00
test_runtime_context.py feat(benchmark): add lme benchmark steps (#326) 2026-07-07 18:53:39 +09:00
test_search_step.py fix(search): accept CLI queries that look like numbers (#612) 2026-10-16 10:36:05 +08:00
test_service.py feat(jobs): add a unified enabled switch for all job types (#580) 2026-09-30 18:30:36 +08:00
test_service_utils.py feat(docker): add container deployment and multi-platform release workflow (#582) 2026-10-03 23:54:58 +08:00
test_session_image_assets.py feat(auto-memory): save session images with source links (#574) 2026-10-09 17:42:13 +08:00
test_shell_step.py feat(core): add shell execution and runtime memory status (#344) 2026-07-14 16:31:41 +08:00
test_source_format_merge.py refactor: derive dialog paths from session_dir (#421) 2026-08-06 17:07:14 +08:00
test_status_step.py fix: skip dependency bindings in status memory walk (#510) 2026-08-31 16:24:41 +08:00
test_sync_qwenpaw_agentscope.py ci: sync AgentScope pin with QwenPaw (#569) 2026-10-12 17:16:01 +08:00
test_tag_index.py feat: auto-tag plugin-generated reports (#534) 2026-09-11 11:52:52 +08:00
test_token_usage.py feat(evaluation): track job calls and agent token usage in benchmarks (#406) 2026-08-04 11:42:18 +08:00
test_tokenizer.py init: reme version 0.4.0 (#284) 2026-06-22 15:41:19 +08:00
test_tushare.py refactor: rebuild auto-fin and daily-paper cookbooks on structured-output agents (#432) 2026-08-07 23:53:14 +08:00
test_utils.py feat(evaluation): track job calls and agent token usage in benchmarks (#406) 2026-08-04 11:42:18 +08:00
test_wikilink_utils.py feat: simplify wikilink semantics and support line anchors (#412) 2026-08-05 11:47:50 +08:00
test_workspace_web_steps.py feat(backend): improve workspace support for web clients (#420) 2026-08-07 23:52:56 +08:00
test_write_metadata_lock.py init: reme version 0.4.0 (#284) 2026-06-22 15:41:19 +08:00
test_zvec_file_store.py feat(tags): add configurable tag indexing and filtered hybrid search (#530) 2026-09-10 18:01:09 +08:00