Skip to content

feat: auto-update incarnations on a configurable interval#579

Draft
peterbraden wants to merge 4 commits intomainfrom
feat/auto-update-incarnations
Draft

feat: auto-update incarnations on a configurable interval#579
peterbraden wants to merge 4 commits intomainfrom
feat/auto-update-incarnations

Conversation

@peterbraden
Copy link
Copy Markdown
Contributor

@peterbraden peterbraden commented May 6, 2026

NB: Speculative feature, not worth reviewing yet.

Summary

  • Adds auto_update_interval_seconds (integer, 0 = disabled) to the incarnation table, with a DB migration. No separate boolean needed — zero means off.
  • AutoUpdateService runs as an asyncio background task (started via a FastAPI lifespan handler). Each tick (60 s) it checks every incarnation whose interval has elapsed and calls create_change_merge_request with automerge=True, patch=True, targeting the latest commit on the incarnation's current branch or tag. Already-up-to-date and in-progress cases are handled gracefully.
  • The interval is exposed on all create/update/patch API endpoints and all response models.
  • The UI gains an Auto update toggle and an Update interval (minutes) input in the incarnation form, converting to/from seconds at the API boundary.

Test plan

  • poetry run pytest tests/services/test_auto_update.py — 6 unit tests covering: interval=0 skip, not-yet-due skip, due incarnation triggers change with correct args, ChangeRejectedDueToNoChanges swallowed and last-run updated, ChangeRejectedDueToPreviousUnfinishedChange does not update last-run
  • poetry run pytest — full suite passes
  • Manual: create an incarnation pointing to a branch, enable auto-update with a short interval, push a commit to the template branch, confirm an MR appears within one tick

🤖 Generated with Claude Code

Adds opt-in automatic template re-application per incarnation.
Setting auto_update_interval_seconds > 0 causes a background task
to periodically call create_change_merge_request (with automerge)
for that incarnation, targeting the latest commit on its current
branch or tag. 0 disables the feature.

Changes:
- DB: add auto_update_interval_seconds column to incarnation table
  (migration included); 0 = disabled, no separate boolean needed
- AutoUpdateService: asyncio background loop, in-memory last-run
  tracking per incarnation, skips if interval not elapsed or a
  previous change is still open
- App lifespan: starts/cancels the background loop on startup/shutdown;
  extracts build_hoster() helper shared with dependencies
- API: auto_update_interval_seconds on create/update/patch request
  models and all response models; set_auto_update_interval() on
  ChangeService threads the value to the incarnation table
- UI: Auto update toggle + Update interval (minutes) input in Form.tsx;
  field threaded through all TS types and converter functions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@peterbraden peterbraden requested a review from defreng as a code owner May 6, 2026 12:30
peterbraden and others added 3 commits May 6, 2026 14:40
Add missing `auto_update_interval_seconds=0` to `IncarnationInDB` constructor
in the incarnation repository test, and remove trailing commas from the last
properties of three object literals in `incarnations.ts` (ESLint comma-dangle rule).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove unsupported `type="number"` from TextField (only accepts text/textarea/search)
- Stringify the minutes value passed to TextField
- Add missing `auto_update_interval_seconds` to `updateTemplateVersion` API input

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…econds

Add `auto_update_interval_seconds` param to `ChangeServiceMock.create_incarnation()`
and include the field in the expected GET /incarnations response assertion.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@peterbraden peterbraden marked this pull request as draft May 6, 2026 13:07
@peterbraden peterbraden marked this pull request as draft May 6, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant