Skip to content

schedule register --refresh leaves a deleted entry's artifact installed and firing — prune orphans owned by this vault #410

Description

@kengio

Summary

Deleting an entry from onebrain.yml schedule: and running onebrain schedule register --refresh leaves that entry's OS artifact installed and loaded. The job keeps firing on its old cron. Neither --refresh nor --remove can reach it: every cleanup path derives labels from the current config, so an entry that is no longer in the config has no code path that touches its artifact.

This is the "entry deleted" arm of the bug #352 already records as still open ("editing a schedule entry's args leaves the old artifact installed and firing, unreachable by --remove"). Filing it separately as a concrete, reproducible sub-case with a narrow ask, so it can ship independently of the full ownership redesign if that's the faster route.

Reproduction (onebrain 3.4.25, macOS, launchd)

  1. onebrain.yml has six entries, including:
    - cron: 30 8 * * *
      skill: /digest
    schedule register --status shows all six ; launchctl list | grep onebrain shows six loaded, including com.onebrain.digest.
  2. Remove the /digest entry from onebrain.yml (five remain).
  3. onebrain schedule register --refresh

Observed

(--refresh: re-emitting plists with current vault path)
✓ Wrote ~/Library/LaunchAgents/com.onebrain.daily.plist
✓ Wrote ~/Library/LaunchAgents/com.onebrain.weekly.plist
✓ Wrote ~/Library/LaunchAgents/com.onebrain.recap.plist
✓ Wrote ~/Library/LaunchAgents/com.onebrain.onebrain-search-reindex.plist
✓ Wrote ~/Library/LaunchAgents/com.onebrain.sh--c-cd--Users-keng-onebrain-ob-1--1ddd50b9.plist

Registered and activated 5 schedule entries with launchd.
  • schedule register --statusRegistered schedules: 5 (looks clean)
  • ls ~/Library/LaunchAgents | grep onebrainsix plists, com.onebrain.digest.plist still present
  • launchctl list | grep onebrainsix jobs, com.onebrain.digest still loaded, exit 0

So --status reports the config, not the machine, and the removed job would have fired the next morning at 08:30 with nothing in the CLI's output hinting that it still existed.

  1. onebrain schedule register --remove at this point would remove the five current entries and still not touch com.onebrain.digest (remove_entries iterates config.schedule).

Workaround used

launchctl bootout gui/$(id -u)/com.onebrain.digest
rm ~/Library/LaunchAgents/com.onebrain.digest.plist

Where it happens

crates/onebrain-cli/src/commands/register_schedule.rs @ v3.4.25:

Expected

schedule register (at minimum --refresh, ideally every real register) should reconcile installed artifacts vs. config: enumerate the com.onebrain.* artifacts on disk, keep the ones whose label is in current_labels, and backend::remove the rest — but only after confirming the artifact belongs to this vault, per the ownership direction in #352 (its ProgramArguments / working directory already carry --vault <path>, so the check is available without any ledger). An artifact that points at a different vault must be left alone and, ideally, mentioned in the output.

Concretely:

  • --refresh removes an installed artifact whose label is absent from the config and whose args point at this vault; prints ✓ Removed schedule '…' (no longer in onebrain.yml).
  • Same sweep runs on a plain register (or document why refresh-only).
  • Deleting the whole schedule: block (empty entries) still runs the sweep instead of early-returning.
  • --status reports the on-disk/loaded state, or at least flags ⚠ installed but not in onebrain.yml: com.onebrain.digest so the drift is visible.
  • Cross-vault guard: an artifact for the same label owned by another vault is never removed (regression test — the vacuous one from the reverted ledger should not come back).
  • --remove --dry-run does not delete (from Scheduler: redesign the installed-labels ledger around artifact OWNERSHIP, not bookkeeping #352's list; worth fixing in the same pass since the sweep makes --dry-run more important).

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions