test(7836): the client's link states are pinned to what a read returns
CI & Build / TypeScript typecheck (push) Canceled after 0s
CI & Build / Plugin hooks (push) Canceled after 0s
CI & Build / Python lint (push) Canceled after 0s
CI & Build / Python tests (push) Canceled after 0s
CI & Build / integration (push) Canceled after 0s
CI & Build / Build & push image (push) Canceled after 0s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 06:07:32 -05:00
co-authored by Claude Opus 5.5
parent 1a8c02bfe5
commit ff3fca6a94
2 changed files with 8 additions and 5 deletions
+6 -2
View File
@@ -64,6 +64,10 @@ _REMOVED_NOTE = "removed from the lesson's rules by an update"
# of that answer's reason.
_NO_RULE_NOTE = "no rule fits: "
# The link states a read returns, in the order it lists them: a judgment,
# never a suggestion.
READ_STATES = (CONFIRMED, REJECTED)
# What `rule_judgment` reads on a lesson payload — the three answers.
LINKED, NO_RULE, UNJUDGED = "linked", "no_rule", "unjudged"
@@ -279,7 +283,7 @@ async def rules_for_lessons(user_id: int, lesson_ids) -> dict[int, list[dict]]:
out: dict[int, list[dict]] = {i: [] for i in ids}
if not ids:
return out
order = {CONFIRMED: 0, REJECTED: 1}
order = {s: n for n, s in enumerate(READ_STATES)}
async with async_session() as session:
rows = (await session.execute(
select(LessonRuleLink, Rule)
@@ -306,7 +310,7 @@ async def lessons_for_rule(user_id: int, rule_id: int) -> list[dict]:
"""
from grimoire.services.access import readable_notes_clause
order = {CONFIRMED: 0, REJECTED: 1}
order = {s: n for n, s in enumerate(READ_STATES)}
async with async_session() as session:
rows = (await session.execute(
select(LessonRuleLink, Note)