Make propose_lore_relationships campaign-scoped — entries without a linked session get no relationship suggestions #289
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Follow-up to #286, which moved relationship-proposal scheduling from lore-pipeline completion (where the task structurally could not see the new entries) to proposal approval.
The remaining gap
propose_lore_relationshipstakes asession_id, but it only uses it to resolve the campaign — it loads the session purely to readsession.campaign_id, then queries every approved entry in that campaign (reminder_tasks.py:3889-3945). The work itself is campaign-scoped; the session parameter is vestigial.Scheduling from approval means passing the approved entry's
linked_session_id. When that is NULL, nothing is scheduled —lore_service.schedule_relationship_proposalsreturns early. That is correct given the current signature, and it is tested, but it means:Fix direction
Change the task to take a
campaign_id. That removes the vestigial lookup, makes the trigger work for every approved entry regardless of provenance, and simplifies the debounce key inlore_service._RELATIONSHIP_DEBOUNCE_SECONDSscheduling from per-session to per-campaign — which is arguably more correct anyway, since two sessions in the same campaign approving entries concurrently currently schedule two passes over the same entry set.Points to touch:
propose_lore_relationships/_propose_lore_relationships_asyncsignature and the session lookuplore_service.schedule_relationship_proposals— passentry.campaign_id, drop the NULL guardlore_rel_pending:{session_id}→ campaign)create_bot_relationship_proposalsif it records a session linkage worth preserving — check before assuming it does notWorth confirming whether relationship proposals should carry a "discovered in session X" attribution. If so the session id is still wanted as optional context rather than as the lookup key, and the signature should take both.
Acceptance
linked_session_idstill schedules a relationship passtest_relationship_proposal_trigger.pyupdated — the "entry without a linked session is skipped" test inverts to "is still scheduled"Labels: backend
Verified against the acceptance criteria before closing. All met.
linked_session_idstill schedules a pass — task signature is nowpropose_lore_relationships(campaign_id)(reminder_tasks.py:4087), no session lookup remains, NULL guard gone. Tested bytest_entry_without_a_linked_session_is_still_scheduled(tests/test_relationship_proposal_trigger.py:201) — literally the inverted case this issue asked for.lore_rel_pending:{campaign_id}(lore_service.py:489). Tested bytest_approvals_in_different_campaigns_are_scheduled_separately.The issue's open question about
create_bot_relationship_proposalsstill taking asession_idwas answered rather than ignored: it is explicitly passedNonewith a comment notingLoreRelationshiphas no such column and the parameter is otherwise dead (reminder_tasks.py:4240-4249).Closing. Part of a full acceptance-criteria pass across the v4.0.0 milestone.