Materialize instances when a quest definition is created

create_quest_definition persisted the rule, definition, assignees and
windows but never called regenerate_for_definition, unlike edit, assign,
unassign and activate. A new task therefore had no quest_instances rows
and stayed off the panel board until an unrelated write regenerated it.

Call regenerate_for_definition after the DAO write, using the host
clock and the default horizon, and add a test that a created weekly
definition has only today-or-later instances.

Update test fixtures that relied on create writing no instances: close
the seeded one-day rules with end_date, clear the table before the gated
materialize walk, and adjust the admin regenerate tests to the new
create behaviour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-25 07:17:56 -04:00
co-authored by Claude Opus 5.5
parent 64a56389ad
commit 62c9f67093
7 changed files with 83 additions and 18 deletions
@@ -235,6 +235,11 @@ async def create_quest_definition(
transaction, so the returned bundle is a consistent creation
snapshot. Raises ValueError on any rejected argument; a rejected or
failed create persists nothing.
After the write, :func:`~.materialize.regenerate_for_definition`
materializes the new definition's instances over the rolling horizon
(host clock, :data:`~.const.DEFAULT_HORIZON_DAYS`), so it reaches the
board without waiting for an unrelated write.
"""
name = _validate_text(title, "title", required=True)
assert name is not None
@@ -269,6 +274,9 @@ async def create_quest_definition(
) from error
raise
decoded_rule = schedule_rule_from_storage(storage)
await regenerate_for_definition(database, snapshot.definition.id)
return CreatedQuestDefinition(
definition=snapshot.definition,
rule=decoded_rule,