pub fn acquire_job_singleton(
job_type: JobType,
namespace: &str,
wait_seconds: Option<u64>,
) -> Result<File, AppError>Expand description
Acquires a process-wide singleton lock for a heavy job type and namespace.
G28-B (v1.0.68): ensures at most one enrich, ingest --mode claude-code, or ingest --mode codex runs at a time per namespace.
A second invocation in the same namespace either:
- Returns immediately with
AppError::JobSingletonLocked { job_type, namespace }whenwait_secondsisNoneorSome(0). - Polls every
JOB_SINGLETON_POLL_INTERVAL_MSms until the lock drops or the deadline expires, returning the same error on timeout.
The returned File MUST be kept alive until the process exits;
dropping it releases the singleton for the next invocation.