【轻量拓展分析】 - 新增 gfa_core/extension_stage_lightweight/ 核心模块,支持用户上传代码/数据/原始命令 - 前端卡片式交互流程:候选核对 → 验证 → 结果审查 → 授权发布 → 运行 - Celery 不受限任务 + 轮询机制 + sessionStorage 操作恢复 - 启动脚本新增 BBAV5_LIGHTWEIGHT_* 环境变量 【WGS2GWAS 支持】 - 新增 13 个 WGS 阶段定义(QC → MAF/Missing Filter) - email_haplotype_region.py 新增 LTR-RT 分析功能 【结果区域重构】 - 单层折叠 → 三组双层折叠:RNA-seq / 基因家族 / WGS2GWAS - 结果按执行时间排序,保留最新尝试 【物种角色解析增强】 - 新增 _resolve_subfamily_request_species_roles() - 支持 reference 角色的识别 - 直接 stage 请求保留 intent 中的物种角色 【会话 Job 隔离】 - rebind_job() 跨 job 时创建新会话,返回新 conversation_id 【前端交互增强】 - RAG 文献问答模式 - NL 触发 config/samples 自动填写、亚家族确认表、基因家族成员确认表 - 执行状态从后端 resource_tasks 恢复 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
54 lines
2.0 KiB
Python
54 lines
2.0 KiB
Python
from pathlib import Path
|
|
|
|
from gfa_core.mas.agent_state_repository import SQLiteAgentStateRepository
|
|
from gfa_core.mas.persistent_conversation import PersistentConversationStore
|
|
|
|
|
|
def _store(tmp_path: Path) -> PersistentConversationStore:
|
|
repository = SQLiteAgentStateRepository(tmp_path / "agent-state.sqlite3")
|
|
repository.initialize()
|
|
return PersistentConversationStore(repository)
|
|
|
|
|
|
def test_rebind_to_different_job_creates_empty_conversation_and_preserves_old(tmp_path: Path) -> None:
|
|
store = _store(tmp_path)
|
|
old_turn = store.begin_turn(
|
|
session_id="old-session",
|
|
job_id="job_old",
|
|
query="旧 job 的问题",
|
|
client_history=[],
|
|
)
|
|
|
|
new_conversation_id = store.rebind_job(
|
|
session_id=old_turn.conversation_id,
|
|
job_id="job_new",
|
|
)
|
|
|
|
assert new_conversation_id != old_turn.conversation_id
|
|
old_conversation = store.repository.get_conversation(old_turn.conversation_id)
|
|
new_conversation = store.repository.get_conversation(new_conversation_id)
|
|
assert old_conversation is not None and old_conversation.job_id == "job_old"
|
|
assert new_conversation is not None and new_conversation.job_id == "job_new"
|
|
assert [message.content for message in store.repository.list_recent_messages(old_turn.conversation_id)] == ["旧 job 的问题"]
|
|
assert store.repository.list_recent_messages(new_conversation_id) == ()
|
|
ledger = store.repository.get_goal_ledger(new_conversation_id)
|
|
assert ledger is not None
|
|
assert ledger.user_terms == {"active_job_id": "job_new"}
|
|
|
|
|
|
def test_rebind_to_same_job_keeps_conversation_identity(tmp_path: Path) -> None:
|
|
store = _store(tmp_path)
|
|
turn = store.begin_turn(
|
|
session_id="same-session",
|
|
job_id="job_same",
|
|
query="当前 job 的问题",
|
|
client_history=[],
|
|
)
|
|
|
|
conversation_id = store.rebind_job(
|
|
session_id=turn.conversation_id,
|
|
job_id="job_same",
|
|
)
|
|
|
|
assert conversation_id == turn.conversation_id
|