Skip to content

Commit dad64dc

Browse files
committed
fix: hydrate triples during workbench backfill
1 parent 349f26a commit dad64dc

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

application/engine/services/query_service.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
logger = logging.getLogger(__name__)
3333

34-
_WORKBENCH_CONTEXT_BACKFILL_ATTEMPTED_KEY = "_workbench_context_backfill_attempted"
34+
_WORKBENCH_CONTEXT_BACKFILL_ATTEMPTED_KEY = "_workbench_context_backfill_v2_attempted"
3535

3636
# 守护进程经 _update_shared_state 写入、/status 需透出的运行时字段(不在 NovelState 模型内)
3737
_RUNTIME_STATUS_KEYS: tuple[str, ...] = (
@@ -562,6 +562,7 @@ def get_workbench_context(self, novel_id: str) -> WorkbenchContextResponse:
562562
plot_arc = self._shared.get_plot_arc(novel_id)
563563
knowledge = self._shared.get_knowledge(novel_id)
564564
foreshadows = self._shared.get_foreshadows(novel_id)
565+
triples = self._shared.get_triples(novel_id)
565566
chapters = self._shared.get_chapters(novel_id)
566567

567568
# 如果共享内存中没有数据,降级到数据库查询
@@ -577,12 +578,20 @@ def get_workbench_context(self, novel_id: str) -> WorkbenchContextResponse:
577578
novel_id in self._workbench_context_backfill_attempted
578579
or bool(raw_state.get(_WORKBENCH_CONTEXT_BACKFILL_ATTEMPTED_KEY))
579580
)
580-
needs_backfill = not chronicles or plot_arc is None or knowledge is None or not foreshadows
581+
needs_backfill = (
582+
not chronicles
583+
or plot_arc is None
584+
or knowledge is None
585+
or not foreshadows
586+
or not triples
587+
)
581588
if needs_backfill and not backfill_attempted:
582589
try:
583590
from application.engine.services.state_bootstrap import StateBootstrap
584591

585592
bootstrap = StateBootstrap()
593+
if not triples:
594+
triples = bootstrap._load_triples(novel_id)
586595
if not foreshadows:
587596
foreshadows = bootstrap._load_foreshadows(novel_id)
588597
if plot_arc is None:

0 commit comments

Comments
 (0)