Scheduled Auto-Update Implementation Plan
For Claude: REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
Goal: Keep CodeAlmanac updated automatically through a separate scheduled update task.
Architecture: services/automation owns scheduler job definitions for sync, garden, and update. services/updates owns package-update execution, scheduled-run policy, global update locking, active lifecycle-run detection, output logging, and smoke checks. Integrations stay thin: the package runner only runs commands, and launchd only installs scheduled jobs.
Tech Stack: Pydantic request/result models, launchd scheduled jobs, local filesystem lock/log files under ~/.codealmanac/, existing uv/pip package update runner, pytest and ruff gates.
Task 1: Add The Update Automation Task#
Files:
- Modify:
src/codealmanac/services/automation/models.py - Modify:
src/codealmanac/services/automation/defaults.py - Modify:
src/codealmanac/services/automation/definitions.py - Modify:
src/codealmanac/services/automation/jobs.py - Modify:
src/codealmanac/services/automation/selection.py - Test:
tests/test_automation_service.py - Test:
tests/test_cli.py
Steps:
- Add
AutomationTask.UPDATE = "update". - Add
DEFAULT_UPDATE_INTERVAL = timedelta(days=1)andUPDATE_LABEL = "com.codealmanac.update". - Add an update task definition with no working directory and
update.out.log/update.err.log. - Make the scheduled command
python -m codealmanac.cli.main update --scheduled. - Include update in default install/status/uninstall selections.
- Keep
--garden-offscoped to Garden only.
Task 2: Install Update Automation During Setup#
Files:
- Modify:
src/codealmanac/services/setup/planning.py - Modify:
src/codealmanac/services/setup/automation.py - Modify:
tests/test_setup_service.py - Modify:
tests/test_cli.py
Steps:
- Make setup recommendations include update automation by default.
- Make
setup --yesinstall sync, garden, and update automation. - Make uninstall remove sync, garden, and update by default.
- Keep explicit task requests explicit:
automation install updateinstalls only update.
Task 3: Add Scheduled Update Policy#
Files:
- Modify:
src/codealmanac/services/updates/models.py - Modify:
src/codealmanac/services/updates/requests.py - Modify:
src/codealmanac/services/updates/service.py - Create:
src/codealmanac/services/updates/lock.py - Create:
src/codealmanac/services/updates/activity.py - Test:
tests/test_update_service.py
Steps:
- Add scheduled-mode fields to
RunUpdateRequest. - Add
UpdateStatus.SKIPPED. - Add an atomic file lock at
~/.codealmanac/update.lock. - Treat stale update locks as removable after 30 minutes.
- Scan
~/.codealmanac/repos/*/runs/*.jsonfor queued or running run records. - In scheduled mode, skip unsupported editable/source installs without failing the scheduled job.
- In scheduled mode, skip when another update holds the lock or lifecycle runs are active.
Task 4: Add Logging And Smoke Checks#
Files:
- Modify:
src/codealmanac/services/updates/service.py - Modify:
src/codealmanac/services/updates/models.py - Modify:
src/codealmanac/integrations/updates/package.py - Test:
tests/test_update_service.py
Steps:
- Log scheduled update output under
~/.codealmanac/logs/. - Run smoke commands after a successful scheduled package update:
codealmanac --versioncodealmanac doctor --json
- Record smoke command outputs in the scheduled update result.
- Fix
codealmanac --versionif the current parser bug remains reproducible.
Task 5: Add The CLI Surface#
Files:
- Modify:
src/codealmanac/cli/parser/updates.py - Modify:
src/codealmanac/cli/dispatch/updates.py - Modify:
src/codealmanac/cli/render/updates.py - Test:
tests/test_cli.py - Test:
tests/test_public_contract.py
Steps:
- Add hidden
codealmanac update --scheduled. - Make scheduled skip statuses exit
0. - Keep manual unsupported update behavior as a non-zero exit.
- Preserve public local-only command contract.
Task 6: Documentation And Verification#
Files:
- Modify:
README.md - Modify:
docs/python-port-live-agreement.md - Modify:
almanac/architecture/lifecycle-runs.mdor add/update an automation page if needed. - Modify:
implementation-tickets.mdonly for stale config wording if needed.
Steps:
- Document that setup installs update automation by default.
- Document logs and scheduled task names.
- Run:
uv run pytest tests/test_automation_service.py tests/test_update_service.py tests/test_setup_service.py tests/test_cli.py tests/test_public_contract.py tests/test_architecture.py
uv run ruff check .
uv run pytest
uv run codealmanac validate
git diff --check