Capture a delivery-relevant snapshot of the firing job inside
cron.execution_identity.enter_cron_execution so delivery_platforms() with
job_id=None answers from the run that is actually firing even when the
saved job is edited or deleted mid-run, while explicit job_id lookups
remain previews of the stored job.
Add PluginContext.cron_delivery_platforms(job_id=None) (and tuple
preservation in RemotePluginContext) so hooks running under
plugins.isolation: host read the firing run's delivery platforms in the
gateway in the calling hook's context. Re-export
CronSchedulerRegistrationError from cron.plugin_api so plugins can catch
it without a private core import, and update the plugin guide example
and tests accordingly.
Addresses Greptile review feedback on PR #159657.
- `home` was expanded for `~` only, while core's profile bind also
expands environment variables. For a directory whose path holds a
literal `$NAME` with NAME set, the job was stored in the literal
directory while its settings (time zone) were read from the expanded
one, which the bind also created. `home` is now read the way Hermes
reads a home path, once, for the existence check, the bind and the
cron store.
- A failed registration raised `CronSchedulerRegistrationError` for a
new job but the provider's raw error for a job that already existed,
so a second attempt against an unreachable provider raised a
different type. Both now raise `CronSchedulerRegistrationError`
carrying the saved job.
- Docs: `delivery_platforms` answers for the normal delivery lane; a
`failure_deliver` override is not consulted.
`ensure_named_job` looked the name up with `list_jobs`, which also reads
every job's latest and live run from the executions ledger and adds
`latest_execution` / `live_execution` to each record. So an existing job
came back with two keys a newly created job does not have, and every call
paid for a ledger read it never used. The lookup now reads the job store
and returns the same record shape either way.
Docs for `delivery_platforms`:
- With no job id it answers for the cron run bound in the calling
process. A hook of a plugin running in a plugin host has no run bound
there, so the guide and its example now name the job with
`ctx.current_cron_execution().job_id`, which answers in both modes.
- The answer is the stored job's: an edit saved while a run is in flight
shows up, though that run delivers with the settings it started with.
- `home` naming the process's own profile runs no external secret source;
only another profile's first call does.
A plugin can now create one named follow-up job in a profile, once, with
`ensure_named_job`, and ask which platforms cron will deliver a job's output
to with `delivery_platforms`, without importing cron.jobs, cron.scheduler,
cron.scheduler_provider or private helpers of cron.scheduler_delivery.
Both functions forward to the code cron already runs (job creation with
scheduler registration, the provider's register_job, and cron's own
delivery-target resolver) and add no rule of their own. `home` runs the
call with that profile bound whole, the way core binds a profile (its
Hermes home, secrets and terminal policy) plus its cron store. A profile
other than the process's own also runs under multiplex semantics, as a
cron fire for it does, so its own time zone sets a schedule and its home
channels and provider credentials are the ones read. `~` is expanded, and
the caller's state is restored afterwards, also when the call raises. A
`home` that is not an existing directory is never created:
`ensure_named_job` raises FileNotFoundError and `delivery_platforms`
returns None. A hosted activity cannot act for a profile, so binding
`home` is refused there.
`AmbiguousJobReference` is re-exported for the duplicate-name case.
`ensure_named_job` refuses, with ValueError and before any lookup, a name
that is not a non-empty string free of leading and trailing whitespace:
cron could never find such a name again, so every call would add a job.
The module is listed as a whole in plugin_api.json, documented in the
plugin guide, and covered by tests against a real cron store.