feat(gateway): Wave 2 pre-gateway parity — structured note, sub_tasks, channels

Three Wave 2 gaps from the 2026-05-11 pre-gateway parity design:

G4 — note() decision/reflect now require structured fields at the gateway
(pre-gateway `Field(...)` parity). Returns `incomplete_input` envelope
with field-by-field hints when any required field is missing.
  - decision: context (str), options (list[{name,pros,cons}] min len 2),
    chosen (str), rationale (str). `consequences` and `next_steps` are
    now list[str] (was str). Renderer emits each option as a "### Name
    + Pros / Cons" block instead of a bullet — matches the pre-gateway
    DecisionOption sub-shape exposed in `roboco/mcp/schemas/__init__.py`
    at `254cc93`.
  - reflect: what_done, what_learned, what_struggled (each non-empty
    str). next_steps stays optional.
  - Bumped tests/unit/gateway/test_content_actions.py with explicit
    pass-with-N-options coverage (≥2 floor; 3-option case green).

G5 — i_will_plan now persists sub_tasks alongside approach / risks /
open_questions / technical_considerations. The Plan tab's Sub-Tasks
section was empty because the verb didn't accept the field. Choreographer
server-assigns id + order to each sub_task (pre-gateway build_plan_data
parity) and normalizes every list entry to the EXACT shape
`panel/src/types/index.ts::TaskPlan` consumes:
  - SubTask: {id, title, description, completed:false, order,
    estimated_hours:null, notes:null}
  - Risk: {description, mitigation, severity:null} — accepts the
    {risk, mitigation} pre-gateway shape too
  - OpenQuestion: {question, answer:null, answered_by:null,
    answered_at:null} — accepts a bare string fallback
The normalization lives in three small module-level helpers
(_normalize_sub_task / _normalize_risk / _normalize_open_question)
called from _build_panel_shaped_plan, keeping i_will_plan's branch
count under PLR0912.

G6 — new `channels()` verb returns the agent's readable + writable
channel slugs from foundation.policy.communications. Stops invented
slugs ("backend-dev", "backend") that we kept seeing in smoke runs.
Added to every role's manifest including auditor (read-only access).

Wired through:
- roboco/api/schemas/v2/do.py — list-typed consequences/next_steps,
  dict-typed options, ChannelsRequest
- roboco/api/schemas/v2/flow.py — IWillPlanRequest.sub_tasks
- roboco/api/routes/v2/do.py — /channels endpoint
- roboco/api/routes/v2/flow_*.py — pass sub_tasks through
- roboco/services/gateway/content_actions.py — channels() method;
  _check_scope_required_fields enforces decision/reflect structure;
  _render_option_block emits per-option markdown blocks
- roboco/services/gateway/choreographer/_impl.py — _build_panel_shaped_plan
  helper used by i_will_plan
- roboco/services/gateway/role_config.py — _CHANNEL_DISCOVERY tuple
  on every role
- roboco/mcp/do_server.py — channels() tool + note() signature with
  options as list[dict[str,str]]
- roboco/mcp/flow_server.py — i_will_plan signature with sub_tasks

Frontend: no code change. panel/src/types/index.ts already declares
the exact shape we now write; panel/src/components/tasks/task-detail/
{tab-plan,tab-progress,tab-sessions,tab-notes}.tsx already reads it.
The empty panels we observed were a backend write-side problem, not
a frontend read-side problem — Wave 1 + Wave 2 close it.

Quality: ruff + mypy clean. 505 unit tests pass (added 2 new tests on
decision-scope requirements, updated 3 existing tests to fit the
pre-gateway-parity contract).

Spec ref: docs/superpowers/specs/2026-05-11-pre-gateway-parity-design.md
This commit is contained in:
Renn F
2026-05-11 05:57:57 +02:00
parent 8408d761ca
commit 72e01a7f13
12 changed files with 423 additions and 41 deletions
+21 -9
View File
@@ -92,26 +92,27 @@ def note(
task_id: str | None = None,
title: str | None = None,
context: str | None = None,
options: list[str] | None = None,
options: list[dict[str, str]] | None = None,
chosen: str | None = None,
rationale: str | None = None,
consequences: str | None = None,
consequences: list[str] | None = None,
what_done: str | None = None,
what_learned: str | None = None,
what_struggled: str | None = None,
next_steps: str | None = None,
next_steps: list[str] | None = None,
) -> dict[str, Any]:
"""Write a journal entry. scope in note|decision|reflect|learning|struggle.
``text`` is always the short summary (one paragraph max). For ``decision``
and ``reflect`` scopes, fill the scope-specific structured fields so the
panel renders them as named sections — pre-gateway parity:
and ``reflect`` scopes the structured fields are REQUIRED — pre-gateway
parity. The gateway returns ``incomplete_input`` if any is missing.
- decision: ``context`` (the situation), ``options`` (list of strings,
one per alternative considered), ``chosen`` (the alternative you took),
``rationale`` (why), ``consequences`` (what this commits us to)
- decision: ``context`` (situation), ``options`` (list of ≥2 dicts
``{name, pros, cons}``), ``chosen`` (which option), ``rationale``
(why), ``consequences`` (list of strings — what this commits us to)
- reflect: ``what_done`` (literal output), ``what_learned`` (new info),
``what_struggled`` (where you got stuck), ``next_steps`` (follow-ups)
``what_struggled`` (where you got stuck), ``next_steps`` (list of
follow-up strings)
Other scopes (note / learning / struggle) just need ``text``.
"""
@@ -321,6 +322,16 @@ def notify_ack(notification_id: str) -> dict[str, Any]:
)
def channels() -> dict[str, Any]:
"""List the channel slugs you can read / write.
Use this BEFORE ``say(channel=...)`` if you're unsure of the slug —
inventing slugs returns ``Channel not found``. Returns
``{writable: [...], readable: [...]}``.
"""
return _post("/api/v2/do/channels", {})
# ---------- Tool registry ----------
#
# Maps the tool name an agent calls (matches manifest entries and the
@@ -339,6 +350,7 @@ _TOOLS: dict[str, Any] = {
"notify_list": notify_list,
"notify_get": notify_get,
"notify_ack": notify_ack,
"channels": channels,
}