Skip to content

Document the observable MCP surface and add an end-to-end regression covering receipts, errors, overview, docs and previews #2609

Closed

Description

@propr-dev

Context

The previous issues change the MCP contract in several places: a structured error envelope, operation lifecycle and list_operations, ultrafix progress, publish recovery, submission progress, get_work_overview, optional expectedHead, specific merge preconditions, docs tools, visual preview tools, plan revision causes, refinement validation, trigger access settings and find_setting. The operator guide (docs/mcp.md), the capability matrix (docs/mcp-coverage.md), the operator surface scaffold (docs/mcp-operator-surface.md), the MCP prompts (operator_briefing, check_progress, diagnose_failure in packages/api/mcp/server.ts) and the agent skill (packages/cli/dist/skill/propr/SKILL.md source under packages/cli/skill/propr/) must describe the new behaviour, and one regression test should exercise the combined flow so later refactors cannot silently break it.

Requirements

  1. docs/mcp.md:
    • New section "Errors": the envelope fields, stage values, retryable semantics (including why mutations may return OUTCOME_UNKNOWN with a cause), and the table of stable codes introduced by this epic (INVALID_INPUT, GITHUB_*, UPSTREAM_*, DATABASE_BUSY, PLAN_INVALID, PUBLISH_FAILED, PUBLISH_PARTIAL, PULL_REQUEST_ALREADY_MERGED, PULL_REQUEST_CLOSED, PULL_REQUEST_DRAFT, CHECKS_FAILING, CHECKS_PENDING, REVIEW_REQUIRED, CHANGES_REQUESTED, BRANCH_BEHIND_BASE, MERGE_CONFLICT, BRANCH_PROTECTION_BLOCKED, MERGE_STATE_UNKNOWN, MERGE_REJECTED, COMMAND_NOT_PICKED_UP, ULTRAFIX_CYCLE_FAILED, REFINEMENT_OUTPUT_INVALID, DOCS_UNAVAILABLE, DOC_NOT_FOUND, PREVIEW_NOT_FOUND, PREVIEW_NOT_RENDERABLE, PREVIEW_TOO_LARGE, SETTING_ENVIRONMENT_MANAGED, CONFIRMATION_REQUIRED).
    • New section "Did it actually happen? Following a receipt": lifecycle states, timestamps, artifacts, ultrafix progress and outcomes, list_operations examples ("what did I start in the last hour").
    • Update the walkthrough: step 1 can use get_work_overview; step 4 uses optional expectedHead; add "Follow a one-off task" with get_task_submission.progress; add "Look at the result" with list_visual_previews/get_visual_preview; add "Ask ProPR about itself" with search_docs/get_doc/find_setting.
  2. docs/mcp-coverage.md: add rows for every new tool, update PR command rows (expectedHead optional), plan rows (revision causes, refinement validation, publish resume), and a new dated reconciliation section listing the local validation commands and results.
  3. docs/mcp-operator-surface.md: add capability bullets 5–8 (receipts & errors, docs, visual previews, configuration reachability).
  4. MCP prompts in server.ts: check_progress recommends get_work_overview then get_operation/list_operations; diagnose_failure tells the model to read error.code, error.stage, error.retryable, error.cause and relay them; operator_briefing mentions search_docs for product questions.
  5. Agent skill: add a short "Receipts and errors" section and "Asking about ProPR" (use search_docs) to the skill source.
  6. New regression packages/api/test/mcpObservableSurface.test.ts (added to test:mcp), using the real catalog with fakes only at GitHub/queue boundaries:
    1. create_task → get_task_submission.progress.stage === 'queued' → seed task running → get_operation.lifecycle.state === 'running' → seed completed with PR 42 → completed, artifacts.pullRequest.number === 42.
    2. get_work_overview returns that task joined with PR 42 (one GraphQL call).
    3. run_ultrafix without expectedHead → receipt resolvedHead set → seed cycle history → progress.cycle === 2 → seed cycles_exhausted → completed with the goal-missed summary; list_operations({ tool: 'run_ultrafix' }) shows it.
    4. merge_pull_request on a merged PR → failed receipt with PULL_REQUEST_ALREADY_MERGED and currentState.mergedAt.
    5. publish_plan with GitHub 422 on the first issue → PUBLISH_FAILED with cause.code === 'GITHUB_REJECTED'; plan released.
    6. search_docs('ultrafix') returns a page; find_setting('bot whitelist') returns the bot entry.
    7. An envelope in any failure contains no token-like strings.

Implementation Specification

  • Edit docs/mcp.md, docs/mcp-coverage.md, docs/mcp-operator-surface.md, packages/api/mcp/server.ts (prompt text only), the agent skill source.
  • New packages/api/test/mcpObservableSurface.test.ts; register in the test:mcp script.

Acceptance Criteria

  • npm run test:mcp passes including the new regression.
  • The docs site builds; list_docs shows the updated MCP guide under mcp/guide.
  • Every tool named in the docs exists in tools/list for an admin principal (add a small assertion in the regression that greps docs/mcp.md for `tool_name` tokens matching ^[a-z_]+$ and checks the catalog, skipping an explicit allowlist of non-tool words).
  • No doc still states that expectedHead is required on append-only commands.

Created by ProPR AI Planner

Activity

  1. propr-dev commented on Sep 28, 2026

    @propr-dev
    ContributorAuthor

    Suggested Implementation:

    Implementation Approach

    Documentation is part of this epic's deliverable: the whole point is that an agent can explain outcomes and ProPR's capabilities to the user, and the docs are now served to agents through get_doc. We therefore update the guides and the prompts in the same PR as a regression test that exercises the combined flow, and we add a cheap consistency check (every tool named in docs/mcp.md exists) so docs and catalog cannot drift apart unnoticed.

    File: docs/mcp.md

    Why this file: The operator/agent guide; also served as mcp/guide by get_doc.

    ## Errors
    
    Every failed tool call returns `isError: true` with the same envelope in the
    text block (`{"error": ...}`) and in `structuredContent.error`:
    
    | Field | Meaning |
    |---|---|
    | `code` | Stable UPPER_SNAKE identifier. Branch on this, not on `message`. |
    | `message` | Human-readable sentence you can relay to the user. |
    | `stage` | `validation`, `authorization`, `precondition`, `github`, `queue`, `database`, `workflow`, `transport`, `internal`, or `null`. |
    | `retryable` | Whether calling again with a **new** `idempotencyKey` is safe and may succeed. |
    | `details` | Structured, secret-free detail (e.g. `currentState` of a pull request). |
    | `cause` | Only with `OUTCOME_UNKNOWN`: what actually failed underneath. |
    
    A mutation that failed after it may have reached GitHub reports
    `OUTCOME_UNKNOWN` with `retryable: false`, plus `stage` and `cause`
    (for example `GITHUB_REJECTED: Validation Failed`). Inspect the target before
    issuing a new action. Tokens, credentialed URLs, signed URLs and local paths
    are always redacted.
    
    (code table as listed in the issue, one line per code with meaning and retryable)
    
    ## Did it actually happen? Following a receipt
    
    Every mutation returns an `operationId`. `get_operation` returns
    `lifecycle.state`:
    
    - `accepted` — recorded and handed to the backend (a comment was posted, a job queued);
    - `running` — execution was observed (a worker picked up the task / command);
    - `completed`, `failed`, `cancelled` — terminal, with `finishedAt`;
    - `unknown` — the outcome could not be established; `failure` explains why.
    
    `lifecycle.artifacts` lists what the operation produced (task, issues, pull
    request, comment). For `run_ultrafix`, `lifecycle.progress` reports the cycle,
    last score, goal and, when finished, `outcome`: `goal_reached`,
    `cycles_exhausted` (the loop ran correctly but missed the goal), `stopped` or
    `failed`, with a one-line `summary`.
    
    Lost the ids? `list_operations({ tool: "run_ultrafix", sinceMinutes: 60 })`
    lists your receipts with their persisted lifecycle.

    Walkthrough updates (keep the existing structure):

    **1. What is happening right now.** ... For running work *and* the review state
    of each pull request in one call, use `get_work_overview` (default
    `state: "active"`).
    
    **Follow a one-off task.** After `create_task`, read
    `get_task_submission` — `progress.stage` moves `submitted → issue_created →
    queued → running → completed|failed`, with the task id and, once opened, the
    pull request.
    
    **Look at the result.** `list_visual_previews({ repository, taskId })` lists
    published screenshots and videos; `get_visual_preview` returns an image
    (downscaled to at most 1568 px and 750 KiB). Videos are metadata only.
    
    **Ask ProPR about itself.** `search_docs("ultrafix")` → `get_doc(path, section)`
    reads the documentation shipped with this instance. `find_setting("bot
    whitelist")` says where any setting lives and how to change it.

    File: packages/api/mcp/server.ts (prompt text)

    Why this file: Prompts steer agents toward the new one-call tools and toward relaying structured errors.

    // check_progress
    'Call get_work_overview for running work and the state of each pull request. For a specific action you started, call get_operation with its operationId; use list_operations if you lost it. Report lifecycle.state and, for ultrafix, lifecycle.progress.summary verbatim.'
    // diagnose_failure
    'When a call fails, read error.code, error.stage, error.retryable and error.cause (if present) and tell the user in one sentence what failed and whether retrying is safe. Never retry OUTCOME_UNKNOWN without inspecting the target.'
    // operator_briefing (append)
    'For questions about what ProPR can do or how a feature works, use search_docs and get_doc instead of guessing from tool names.'

    File: packages/api/test/mcpObservableSurface.test.ts (new file)

    Why this file: One end-to-end regression over the real catalog tying the epic together.

    // Fixture: copy the setup from mcpOperatorSurface.test.ts (migrated in-memory SQLite, stubbed configured repos,
    // agent registry stub, GitHub REST/GraphQL fakes, lease Redis), plus PROPR_DOCS_DIR pointing at the repo docs/.
    // Steps (each asserting the fields named in the issue):
    //  1 create_task -> get_task_submission.progress.stage 'queued'; seed tasks/task_history for 'processing' then
    //    'completed' with pr_number 42 -> get_operation lifecycle running -> completed; artifacts.pullRequest.number 42.
    //  2 get_work_overview -> item for the task with pullRequest.reviewDecision; graphql fake called once for acme/repo.
    //  3 run_ultrafix without expectedHead -> result.resolvedHead === fake head; seed review/fix history for cycles 1-2
    //    -> progress.cycle 2; seed ultrafixOutcome 'cycles_exhausted' -> lifecycle completed, summary /did not reach goal/.
    //    list_operations({ tool: 'run_ultrafix' }).operations.length === 1.
    //  4 merge_pull_request on PR fake with merged: true -> result.error.code 'PULL_REQUEST_ALREADY_MERGED'.
    //  5 publish_plan with POST /issues -> 422 on first call -> error.code 'PUBLISH_FAILED', error.details.cause.code
    //    'GITHUB_REJECTED'; task_drafts.status restored.
    //  6 search_docs('ultrafix').results.length > 0; find_setting('bot whitelist').results[0].id 'trigger.bot_allowlist'.
    //  7 JSON.stringify of every error seen does not match /gh[pousr]_|github_pat_|Bearer\s/.
    //  8 Docs/catalog consistency: every `snake_case_name` in docs/mcp.md that looks like a tool exists in the catalog
    //    (skip a small allowlist such as `idempotency_key`, `expected_head`).
    
    import { test } from 'node:test';
    test('observable MCP surface end to end', async () => { /* implement per the steps above */ });

    File: docs/mcp-coverage.md, docs/mcp-operator-surface.md, agent skill

    Why these files: Capability matrix and scaffold are the audit baseline; the skill is what external agents load first.

    • Add matrix rows: list_operations, get_work_overview, list_task_submissions, list_docs/get_doc/search_docs/find_setting, list_visual_previews/get_visual_preview, get_trigger_access_configuration/update_trigger_access_configuration.
    • Update PR command rows: "expectedHead optional (resolved head returned)"; merge row: "specific precondition codes with current state".
    • Planning rows: "revision causes", "publish resume", "refinement output validated".
    • Add a dated "Observable surface reconciliation" section with the exact commands run (npm run test:mcp, npm run typecheck -w @propr/api, npm run build, docs build) and their results, following the format of the existing reconciliation sections — record real results, do not pre-fill.
    • mcp-operator-surface.md: bullets 5 (receipts, lifecycle and structured errors), 6 (documentation access), 7 (visual previews), 8 (configuration reachability).
    • Skill: two short sections "Receipts and errors" and "Asking about ProPR" mirroring the prompt text above.
  2. propr-dev commented on Sep 30, 2026

    @propr-dev
    ContributorAuthor

    🤖 AI processing has started for this issue using codex agent with gpt-5.6-sol model.

    I'll analyze the problem and work on a solution. This may take a few minutes.

    Processing Details:

    • Agent: codex
    • Model: gpt-5.6-sol
    • Branch: 2609/gpt-5.6-sol-document-the-observable-m-20260930-0244-sl1
    • Base Branch: 2593-epic-mcp-observability-cf6
    • Worktree: issue-2609-20260930-0244-gpt-5.6-sol-sl1

    🔍 Track Task Execution

  3. added a commit that references this issue on Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions