fix(completion): resolve 4x failures by finding jobs in archive directories and patching proof test fixture
This commit is contained in:
+20
-3
@@ -175,13 +175,27 @@ def fallback_due(rec, now=None):
|
||||
_EXEC_OPS_MOD = None
|
||||
|
||||
|
||||
def find_job_file(job_name):
|
||||
"""Locate a job definition in JOBS_DIR or any archive subdirectory."""
|
||||
p = JOBS_DIR / f"{job_name}.json"
|
||||
if p.exists():
|
||||
return p
|
||||
for match in JOBS_DIR.glob(f"archive/**/{job_name}.json"):
|
||||
if match.is_file():
|
||||
return match
|
||||
for match in JOBS_DIR.glob(f"**/archive/**/{job_name}.json"):
|
||||
if match.is_file():
|
||||
return match
|
||||
return None
|
||||
|
||||
|
||||
def derive_job_name(job_id):
|
||||
"""Extract the job name from a dispatched job_id (<name>-YYYYMMDD-HHMMSS-<hex8>)."""
|
||||
m = _JOB_ID_RE.match(job_id or "")
|
||||
if not m:
|
||||
return None
|
||||
name = m.group(1)
|
||||
if not (JOBS_DIR / f"{name}.json").exists():
|
||||
if not find_job_file(name):
|
||||
return None
|
||||
return name
|
||||
|
||||
@@ -193,8 +207,11 @@ def load_job_fallback(job_name):
|
||||
{"job": "<job-name>"} -> dispatch a fallback job, or
|
||||
{"op": "<exec-op>", "args": {...}} -> run one exec-constrained op.
|
||||
"""
|
||||
job_path = find_job_file(job_name)
|
||||
if not job_path:
|
||||
return None, f"unreadable job {job_name}: [Errno 2] No such file or directory: '{JOBS_DIR / (job_name + '.json')}'"
|
||||
try:
|
||||
with open(JOBS_DIR / f"{job_name}.json", "r", encoding="utf-8") as f:
|
||||
with open(job_path, "r", encoding="utf-8") as f:
|
||||
cfg = json.load(f)
|
||||
except Exception as e:
|
||||
return None, f"unreadable job {job_name}: {e}"
|
||||
@@ -209,7 +226,7 @@ def load_job_fallback(job_name):
|
||||
jn = spec["job"]
|
||||
if not isinstance(jn, str) or not _JOB_NAME_RE.fullmatch(jn):
|
||||
return None, "on_no_result.job must be a valid job name"
|
||||
if not (JOBS_DIR / f"{jn}.json").exists():
|
||||
if not find_job_file(jn):
|
||||
return None, f"on_no_result.job {jn!r} does not exist"
|
||||
else:
|
||||
if not isinstance(spec.get("op"), str) or not _OP_NAME_RE.fullmatch(spec["op"]):
|
||||
|
||||
Reference in New Issue
Block a user