Skip to content

cosmotron_mcp.gates

authorise_gate

authorise_gate(session_dir: str, gate_id: str, decision: str, note: str = '') -> dict

Record the HUMAN's decision on an open human gate (results/gates/<gate_id>.json).

This is the ONLY tool that can close a gate opened by pipeline code (write_plan's plan-approval gate, build_systematics_evidence on a FAILing check, ingest_to_session on a registry reuse or registration decision, a cost/cores fan-out gate). It is permission: ask in cosmotron.md — opencode SUSPENDS this call and shows the user a confirmation dialogue with these exact arguments before it runs. That is what makes it unforgeable: the approval is a decision made by a DIFFERENT PROCESS, not a string this model writes.

Every previous attempt to gate a human decision put the check INSIDE the model's own output, and every one was eventually defeated:

  1. Prose ("never override without an explicit human answer") — ignored.
  2. A mandatory reason — the orchestrator authored "GLASS synthetic mock simulation — large B-mode excess is a known simulation feature" and overrode 9 failing checks (ses_05bf, and again 2026-07-28).
  3. A mandatory user_reply, meant to hold the human's verbatim words — the model wrote one IN THE USER'S VOICE and the gate passed (2026-07-29).

decision MUST be one of the gate's own recorded options (returned in the needs_input payload that opened it) — an enum, not free text, so a misleading string cannot be smuggled through the dialogue the way a forged reason/user_reply was. override_systematics_gate no longer exists as a callable tool: a systematics gate's "override" decision is applied by this function internally, only after the dialogue.

Parameters:

Name Type Description Default
session_dir str

Session directory.

required
gate_id str

The gate's id, from the needs_input/gate_id that opened it (e.g. "plan-approval", "registry-lens.fits", "systematics-bmode_BB").

required
decision str

One of the gate's recorded options — never invented text.

required
note str

Optional free-text note from the human, recorded alongside the decision (not itself an authorisation).

''

Returns:

Type Description
dict

{"gate_id", "gate_status": "resolved", "decision"}, or a

dict

needs_input payload if gate_id doesn't exist or decision

dict

doesn't match the gate's options.

Source code in cosmotron_mcp/server.py
@mcp.tool()
@sync_budget_guard
def authorise_gate(
    session_dir: str,
    gate_id: str,
    decision: str,
    note: str = "",
) -> dict:
    """Record the HUMAN's decision on an open human gate (``results/gates/<gate_id>.json``).

    This is the ONLY tool that can close a gate opened by pipeline code
    (``write_plan``'s plan-approval gate, ``build_systematics_evidence`` on a
    FAILing check, ``ingest_to_session`` on a registry reuse or registration
    decision, a cost/cores fan-out gate). It is
    ``permission: ask`` in ``cosmotron.md`` — opencode SUSPENDS this call and
    shows the user a confirmation dialogue with these exact arguments before
    it runs. That is what makes it unforgeable: the approval is a decision
    made by a DIFFERENT PROCESS, not a string this model writes.

    Every previous attempt to gate a human decision put the check INSIDE the
    model's own output, and every one was eventually defeated:

    1. Prose ("never override without an explicit human answer") — ignored.
    2. A mandatory ``reason`` — the orchestrator authored *"GLASS synthetic
       mock simulation — large B-mode excess is a known simulation feature"*
       and overrode 9 failing checks (ses_05bf, and again 2026-07-28).
    3. A mandatory ``user_reply``, meant to hold the human's verbatim words —
       the model wrote one IN THE USER'S VOICE and the gate passed
       (2026-07-29).

    ``decision`` MUST be one of the gate's own recorded ``options`` (returned
    in the ``needs_input`` payload that opened it) — an enum, not free text,
    so a misleading string cannot be smuggled through the dialogue the way a
    forged ``reason``/``user_reply`` was. `override_systematics_gate` no
    longer exists as a callable tool: a `systematics` gate's `"override"`
    decision is applied by this function internally, only after the dialogue.

    Args:
        session_dir: Session directory.
        gate_id: The gate's id, from the ``needs_input``/``gate_id`` that
            opened it (e.g. ``"plan-approval"``, ``"registry-lens.fits"``,
            ``"systematics-bmode_BB"``).
        decision: One of the gate's recorded options — never invented text.
        note: Optional free-text note from the human, recorded alongside the
            decision (not itself an authorisation).

    Returns:
        ``{"gate_id", "gate_status": "resolved", "decision"}``, or a
        ``needs_input`` payload if ``gate_id`` doesn't exist or ``decision``
        doesn't match the gate's options.
    """
    # Deliberately NOT plan-gated: the plan-approval gate itself is closed
    # through this tool, so requiring an approved plan here would deadlock.
    result = _authorise_gate(session_dir, gate_id, decision, note=note)
    _log_tool_call(session_dir, "authorise_gate",
                   {"gate_id": gate_id, "decision": decision})
    return _compact_result(result)