- 1. Feature Context
- 2. Actor Flows (CDSL)
- 3. Processes / Business Logic (CDSL)
- 4. States (CDSL)
- 5. Definitions of Done
- 6. Acceptance Criteria
- 7. Additional Context (optional)
-
p1- ID:cpt-ex-ovwa-featstatus-launchagent-autostart -
-
cpt-ex-ovwa-feature-launchagent-autostart
This feature defines how the tool is started automatically on user login using a macOS user LaunchAgent, and how the CLI installs and uninstalls that LaunchAgent.
Key assumptions:
- Autostart is implemented using user-level LaunchAgents only.
- The daemon remains a CLI-launched process; there is no custom UI.
Acceptance criteria:
- Installing autostart MUST be idempotent (running install twice results in a single installed LaunchAgent).
- Uninstalling autostart MUST be idempotent (running uninstall when not installed succeeds with a clear message).
- After a successful install, the daemon MUST start automatically at the next user login.
Allow the user to opt into login-time autostart so tracking can run continuously in the background.
cpt-ex-ovwa-actor-usercpt-ex-ovwa-actor-login-runnercpt-ex-ovwa-actor-macos
- Overall Design: DESIGN.md
- ADRs:
cpt-ex-ovwa-adr-cli-daemon-launchagent-no-menubar
- ID:
cpt-ex-ovwa-flow-launchagent-autostart-install
Actors:
cpt-ex-ovwa-actor-user
- -
p1- User runsoverwork-alert install-autostart-inst-run-install - -
p1- IF LaunchAgent already installed: ensure it matches expected content and continue -inst-install-idempotent - -
p1- CLI builds LaunchAgent plist content usingcpt-ex-ovwa-algo-launchagent-autostart-build-plist-inst-build-plist - -
p1- CLI writes plist to the user LaunchAgents directory -inst-write-plist - -
p1- IF plist cannot be written: RETURN error -inst-write-plist-error - -
p1- CLI loads/starts LaunchAgent via launchctl -inst-launchctl-load - -
p1- IF launchctl fails: RETURN error -inst-launchctl-load-error
- ID:
cpt-ex-ovwa-flow-launchagent-autostart-uninstall
Actors:
cpt-ex-ovwa-actor-user
- -
p1- User runsoverwork-alert uninstall-autostart-inst-run-uninstall - -
p1- IF LaunchAgent is not installed: RETURN ok (idempotent) -inst-uninstall-idempotent - -
p1- CLI stops/unloads LaunchAgent via launchctl -inst-launchctl-unload - -
p1- IF launchctl fails: continue to plist deletion and RETURN warning -inst-launchctl-unload-warn - -
p1- CLI deletes the LaunchAgent plist -inst-delete-plist - -
p1- IF plist cannot be deleted: RETURN error -inst-delete-plist-error
- ID:
cpt-ex-ovwa-algo-launchagent-autostart-build-plist
- -
p1- Choose a stable LaunchAgent label for the tool -inst-choose-label - -
p1- Set ProgramArguments to run the daemon start command -inst-set-args - -
p1- Set RunAtLoad=true and KeepAlive=true -inst-set-options - -
p1- Set launchd restart throttling options to avoid rapid crash loops -inst-set-throttle - -
p1- RETURN plist text content -inst-return-plist
- ID:
cpt-ex-ovwa-state-launchagent-autostart-installation
- -
p1- FROM NOT_INSTALLED TO INSTALLED WHEN plist is written and launchctl load succeeds -inst-transition-installed - -
p1- FROM INSTALLED TO NOT_INSTALLED WHEN launchctl unload succeeds and plist is removed -inst-transition-removed
-
p1- ID:cpt-ex-ovwa-dod-launchagent-autostart-install-and-run
The user can install a LaunchAgent that starts the daemon at login. The user can also uninstall the LaunchAgent to disable autostart.
Implementation details:
- Component:
cpt-ex-ovwa-component-launchagent-manager - Component:
cpt-ex-ovwa-component-cli - Data:
cpt-ex-ovwa-dbtable-config
Implements:
-
p1-cpt-ex-ovwa-flow-launchagent-autostart-install -
p1-cpt-ex-ovwa-flow-launchagent-autostart-uninstall -
p1-cpt-ex-ovwa-algo-launchagent-autostart-build-plist
Covers (PRD):
-
cpt-ex-ovwa-fr-autostart -
cpt-ex-ovwa-nfr-privacy-local-only
Covers (DESIGN):
-
cpt-ex-ovwa-principle-local-only-minimal-state -
cpt-ex-ovwa-constraint-macos-cli-only -
cpt-ex-ovwa-component-launchagent-manager -
cpt-ex-ovwa-component-cli -
cpt-ex-ovwa-seq-run-and-alert -
cpt-ex-ovwa-dbtable-config
- Installing autostart is idempotent.
- Uninstalling autostart is idempotent.
- After successful install, the daemon starts automatically at next user login.
The exact LaunchAgent label and ProgramArguments are implementation details; they must remain stable so install/uninstall behaves predictably.
Out of scope / not applicable (v1):
- No system-wide (root) daemon installation.
- No automatic self-update or signed installer packaging.
- No network access and no privileged escalation.