fix: unblock smoke run (gateway envelope + alembic + redis + MCP)

Four bugs surfaced by the 2026-05-11 smoke run, all on the path from
Main PM's first delegate to the cell PM accepting a subtask:

- gateway: TaskCompletenessError from _create_subtask_from_inputs leaked
  through Starlette as a 500; agents retried in a tight loop because
  they never saw field_hints. Wrap the call in _create_subtask_and_envelope,
  catch the error, return Envelope.incomplete_input with the
  interrogation-pattern reply the upfront completeness check produces.

- alembic: migration 012 used a 40-char revision id which exceeds
  alembic_version.version_num varchar(32). Upgrade fell back to create_all
  on every boot, silently skipping the migration. Rename to
  012_align_agentrole_foundation (30 chars). File rename + revision string.

- events/stream_bus: external Redis FLUSHALL while orchestrator is running
  (e.g. reset_runtime_state.sh) drops the consumer group; the listen loop
  then spams NOGROUP every block-cycle forever. Catch ResponseError with
  NOGROUP in the message and rebootstrap the group via
  _ensure_consumer_group, then continue. Self-heals without restart.

- mcp/flow_server: delegate took body: dict with no schema, so the LLM
  invented values like nature='standard' and the SDK threw 'unhashable
  type: dict' on nested args. Flatten to typed top-level parameters with
  docstring listing valid enum values for team / task_type / nature /
  estimated_complexity. PLR0913 per-file ignore added for roboco/mcp/**
  because MCP tool signatures ARE the LLM contract — bundling into a
  dataclass would hide the enum hints that prevent the invention bug.
This commit is contained in:
Renn F
2026-05-11 02:46:54 +02:00
parent 207aaecd72
commit 229797ffe3
5 changed files with 106 additions and 21 deletions
+5 -1
View File
@@ -158,7 +158,11 @@ select = [
# Lazy imports to avoid circular dependencies
[tool.ruff.lint.per-file-ignores]
"roboco/mcp/**/*.py" = ["PLC0415"]
# MCP tool surfaces ARE the LLM-facing contract — every parameter must be
# top-level + typed so the SDK exposes it as a discrete schema field with
# enum constraints. Bundling into a dataclass would hide enum hints from
# the LLM and bring back invented values like nature='standard'.
"roboco/mcp/**/*.py" = ["PLC0415", "PLR0913"]
"roboco/services/*.py" = ["PLC0415"]
"roboco/api/routes/*.py" = ["PLC0415"]
"roboco/runtime/*.py" = ["PLC0415"]