gateway: answer spoken approvals, route off-gate results

New-skill authoring via the voice gateway never completed: STT emits
"Approve." / "Yes." / "retry." with sentence punctuation, but the
approval/repair maps were matched with an exact lookup, so a spoken
answer fell through to submit_request while the pending approval timed
out and nothing was registered.

- gateway/service: normalize the reply before the action lookup
  (`_normalize_action`: lowercase, strip edge punctuation, first-word
  fallback) and broaden the approval/repair vocabularies, so a spoken
  "Approve." / "Yes." / "retry." matches like a typed one.
- scheduler: buffer the replies of a background drain (the codegen
  worker's post-authoring re-run, a repair retry) in an outbox instead
  of returning them into a thread that discards them; a front end's
  `drain_outbox()` routes them, so the answer to the user's own request
  is no longer swallowed.
- cli/dashboard: drain the outbox alongside the queue.
- tests: normalization + spoken approval/repair routing, outbox
  routing, and the async requeue assertion.
This commit is contained in:
gabby committed 2026-10-12 08:14:42 +00:00
1 parent 3a5b90b1cb
commit b15a9e1b45
7 files changed
+269 -29

No files matched your search

+10 -2
View File
@@ -1700,12 +1700,20 @@ def test_async_skill_write_materializes_merges_and_requeues(tmp_path):
assert not upgraded.is_noop()
assert callable(upgraded.act)
# The worker drains the queue when idle (run_queue), so an empty queue
# is a valid end state; the requeue trace proves the push happened.
# The worker drains the queue when idle (run_queue_buffered), so an empty
# queue is a valid end state; the requeue trace proves the push happened.
events = [e["kind"] for e in scheduler.trace.read()]
assert "skill_requeued" in events
assert "skill_testing" in events
assert "skill_ready" in events
# The off-gate re-run's reply is buffered for a front end, not swallowed:
# the worker must not consume the answer to the user's own request.
deadline = time.monotonic() + 5
while time.monotonic() < deadline and not scheduler._outbox:
time.sleep(0.02)
buffered = scheduler.drain_outbox()
assert buffered, "the post-authoring re-run must be routable by a front end"
assert buffered[0].run_id == request.id
# The full deliverable set landed in the skill folder.
directory = scheduler.body_store.dir("tracking", "track_live")
assert sorted(p.name for p in directory.iterdir() if not p.name.startswith("__")) == [