openloops.job#
The periodic job: launchd runs ol sync, writes, and exits. No daemon.
ADR-003’s decision, applied to digests. A resident process would have to be kept alive,
and when it dies its output latches at whatever it last wrote — a confident, months-old
answer with nothing scheduled to correct it. A StartInterval job is self-healing by
construction: a tick that crashes is repaired by the next one, and the only thing to
supervise is launchd itself.
The environment is captured at install time and pinned into the plist, because launchd
hands a job a nearly empty environment. The interpreter is invoked directly rather than
by console-script name, for the same reason: a name resolved against a minimal PATH
is a lottery whose losing ticket is a job that dies instantly, every tick, silently.
macOS only. On Linux the equivalent is a systemd user timer or a crontab line running
the same command, and install() says so rather than pretending.
Module Attributes
launchd job label. |
|
Seconds between ticks. |
|
launchd label of the board-receiver job (ADR-011). |
|
Seconds between receiver ticks. |
|
no model, so it can run often; six hours keeps the board within a day of GitHub with margin. |
|
a reminder is armed on the channel up to three days ahead, so the tick only needs to catch loops entering that horizon and record the ones that fired. |
Functions
|
Install (or replace) the periodic sync job. |
|
Install (or replace) the reminder tick job. |
|
The reminder tick as data: |
|
Install (or replace) the board-receiver job. |
|
The receiver job as data: program arguments, environment, plist. |
|
Unload the job and remove its plist. |
|
Installed? loaded? and — the question that matters — when did it last write? |
|
The launchd property list, as text. |
- openloops.job.DFLT_INTERVAL = 900#
Seconds between ticks. A digest is a record of what a session said, so being a quarter of an hour behind costs nothing; running every few seconds would cost a full scan of the transcript directory for no gain.
- openloops.job.DFLT_LABEL = 'openloops.sync'#
launchd job label. Also the plist filename and the log filename.
- openloops.job.RECEIVER_INTERVAL = 300#
Seconds between receiver ticks. A tick that finds nothing pending costs a few HTTP calls and no model, so this can be as short as the phone board’s latency wants.
- openloops.job.RECEIVER_LABEL = 'openloops.board-receiver'#
launchd label of the board-receiver job (ADR-011).
- openloops.job.REMIND_INTERVAL = 3600#
a reminder is armed on the channel up to three days ahead, so the tick only needs to catch loops entering that horizon and record the ones that fired.
- Type:
Hourly
- openloops.job.REMIND_LABEL = 'openloops.remind-tick'#
no model, so it can run often; six hours keeps the board within a day of GitHub with margin.
- Type:
The board-rebuild job (
ol board-refreshon a timer; issue #39)
- openloops.job.install(*, label='openloops.sync', interval=900, dry_run=False)[source]#
Install (or replace) the periodic sync job. Returns the paths it wrote.
A smoke run follows the bootstrap, because a job that cannot start produces exactly the same silence as a job with nothing to do.
- openloops.job.install_receiver(work_dir, *, dry_run=False, **kwargs)[source]#
Install (or replace) the board-receiver job. Returns the paths it wrote.
kwargsare those ofreceiver_job_spec(). A dry run builds and returns the plist without touching launchd and without requiring the credentials file.
- openloops.job.install_remind(*, dry_run=False, **kwargs)[source]#
Install (or replace) the reminder tick job.
kwargsareremind_job_spec()’s.
- openloops.job.job_status(*, label='openloops.sync', env_file=PosixPath('~/.config/openloops/board-receiver.env'))[source]#
Installed? loaded? and — the question that matters — when did it last write?
launchctl listsays the job is registered, which is not the same as the job doing anything. The cache’s modification time is the only evidence that a tick completed, so it is reported alongside. For the receiver,last_checkis the last tick whose check succeeded (a stamp beside env_file) andlast_writethe last tick that had work (its log).
- openloops.job.plist_xml(*, label, program_args, env, interval, log_path, working_dir=None)[source]#
The launchd property list, as text. Pure, so it can be tested on any platform.
>>> xml = plist_xml(label='x', program_args=['a'], env={'HOME': '/h'}, ... interval=60, log_path=Path('/tmp/x.log')) >>> '<key>StartInterval</key>' in xml and '<integer>60</integer>' in xml True
- Return type:
- openloops.job.receiver_job_spec(work_dir, *, claude=None, model='sonnet', max_budget_usd=1.0, allowed_tools='Bash(gh:*) Bash(curl:*) Bash(python3:*) Bash(crowsnest:*) Bash(mkdir:*) Bash(date:*) Bash(set:*) Bash(umask:*) Bash(source:*) Bash(jq:*) Bash(cat:*) Bash(ls:*) Bash(shasum:*) Bash(vm_stat:*) Bash(sysctl:*) Read Write Edit Glob Grep Skill', env_file=PosixPath('~/.config/openloops/board-receiver.env'), interval=300, label='openloops.board-receiver', require_claude=True)[source]#
The receiver job as data: program arguments, environment, plist. Pure but for looking up where
claudeandnodeare, so it can be tested anywhere.The job runs
python -m openloops.receiver_tick, which asks the board store whether anything is pending and only then replaces itself withclaude -pand the packaged receiver prompt. The credentials stay in env_file; nothing about them is in the plist, the arguments or the environment (PASSED_THROUGHnames none). Withrequire_claude=False(a dry run) a missingclaudeis shown as a bare name instead of refused.
- openloops.job.remind_job_spec(*, interval=3600, label='openloops.remind-tick')[source]#
The reminder tick as data:
python -m openloops remind-tickeveryintervals.Pure, so it tests anywhere. The job carries no credential: the ntfy topic is resolved by correspond (
NTFY_TOPIC, else the Keychain), and the owner’s zone byOPENLOOPS_TZwhen set in the job’s environment.