scheduler/gateway: carry skill identity structurally, not in action_log

Skill bodies prefixed their own `category.name` into `ActionResult.action_log`,
which duplicated the runner's deterministic summary prefix and leaked the name
into the text the gateways speak. Identity is not data for the output string.

- bodies (seeds, canned replies, housekeeping meta skills) write only the real
  result; the runner already owns the `category.name:` summary prefix
- `run_queue`/`submit_request`/`answer` now return a structured `SchedulerReply`
  (status, text, run_id, skill_ref, result); the gateway reads `skill_ref` and
  `result` from it instead of regex-parsing them back out of the summary
- drop the gateway's `_SKILL_REF`/`_LEADING_RUN_ID` parsing helpers
- fix a latent double-prefix when a failed run had an empty action_log
- CODEGEN.md: generated bodies must not prefix the skill name
This commit is contained in:
gabby committed 2026-10-07 00:30:37 +00:00
1 parent d0c1dccffd
commit e9a7fc73ee
22 files changed
+248 -200

No files matched your search

+20 -12
View File
@@ -435,6 +435,18 @@ def _print_approvals(scheduler: Scheduler) -> None:
print(f"[approval] {item['id']} new {item['kind']} {target}: {item['description']}")
def _print_reply(reply, show_run_id: bool = False) -> None:
"""Print a scheduler reply, optionally keeping its run id visible."""
label = f"[{reply.run_id}] " if (show_run_id and reply.run_id) else ""
print(f"[{reply.status}] {label}{reply.text}")
def _drain_queue(scheduler: Scheduler) -> None:
"""Run queued work, printing each outcome with its run id."""
for reply in scheduler.run_queue():
_print_reply(reply, show_run_id=True)
def _fatal_exit(scheduler: Scheduler) -> int | None:
"""If the scheduler hit a fatal engine failure, print it and return non-zero.
@@ -518,8 +530,7 @@ def repl(scheduler: Scheduler, config: dict) -> int:
print(f"[{status}] {detail}")
_answer_questions(scheduler)
_answer_approvals(scheduler)
for result_status, result_detail in scheduler.run_queue():
print(f"[{result_status}] {result_detail}")
_drain_queue(scheduler)
continue
if lower.startswith("relabel "):
parts = line.split()
@@ -587,19 +598,16 @@ def repl(scheduler: Scheduler, config: dict) -> int:
scheduler.busy(line[5:].strip())
print("current process set (busy).")
continue
status, detail = scheduler.submit(line)
print(f"[{status}] {detail}")
_print_reply(scheduler.submit(line))
if _fatal_exit(scheduler) is not None:
return 1
while scheduler.pending is not None:
hint = "" if scheduler.pending.pre_act else " [leave empty to skip]"
answer = input(f"{scheduler.pending.question}{hint} ")
status, detail = scheduler.answer(answer)
print(f"[{status}] {detail}")
_print_reply(scheduler.answer(answer))
if _fatal_exit(scheduler) is not None:
return 1
for result_status, result_detail in scheduler.run_queue():
print(f"[{result_status}] {result_detail}")
_drain_queue(scheduler)
if _fatal_exit(scheduler) is not None:
return 1
_answer_questions(scheduler)
@@ -612,12 +620,12 @@ def scripted(scheduler: Scheduler, path: str) -> int:
print(try_warm(scheduler))
rows = [json.loads(line) for line in Path(path).read_text().splitlines() if line.strip()]
for row in rows:
status, detail = scheduler.submit(str(row["text"]), source=row.get("source", "scripted"))
print(f"[{status}] {detail}")
_print_reply(
scheduler.submit(str(row["text"]), source=row.get("source", "scripted"))
)
if _fatal_exit(scheduler) is not None:
return 1
for result_status, result_detail in scheduler.run_queue():
print(f"[{result_status}] {result_detail}")
_drain_queue(scheduler)
return _fatal_exit(scheduler) or 0