Skip to content

Expose retry lineage in MCP and OpenAPI and document idempotency contracts #3485

Closed

Description

@integry

Problem

Retry lineage and idempotency are implemented but only partly visible:

  • Replacement lineage (attemptNumber, replacesTaskId, replacedByTaskId, attemptLineage[]) is returned by REST GET /api/task/:taskId/history and propr task get --json, but not by MCP get_task / list_tasks. Over MCP it is visible only inside raw get_task_events metadata.
  • In OpenAPI, TaskHistory.taskInfo is a loose object, so the lineage fields are neither pinned by the conformance test nor present in the generated client types.
  • A task submission has two task pointers (task_id = first execution, latest_task_id = latest attempt); only one is returned and the relation to replacement attempts is undocumented.
  • Three idempotency key contracts exist (MCP idempotencyKey 8-128 chars [\w.-]; REST Idempotency-Key up to 255 chars, required for submissions and goals; optional for automation runs) and create_task rewrites the key to mcp-{operationId} for the REST layer. None of this is documented in one place, and the goal Idempotency-Key contract is absent from OpenAPI.

What to build

  1. MCP task reads. get_task returns lineage: { attemptNumber, rootTaskId, replacesTaskId, replacedByTaskId, replacementCause, replacementState, attempts: [{taskId, attemptNumber, replacementCause, state, createdAt}] } (attempts only when more than one). list_tasks rows gain attemptNumber, replacesTaskId, replacedByTaskId (omit when the task is a first and only attempt, to keep rows small). Reuse packages/api/routes/taskAttemptLineage.ts.
  2. Submission reads. get_task_submission / list_task_submissions and REST GET /api/task-submissions/:key return both firstTaskId and latestTaskId (keep taskId as it is today for compatibility and document which one it is).
  3. OpenAPI. Give TaskHistory.taskInfo an explicit schema including the lineage fields and attemptLineage; keep it tolerant of extra fields only where needed so existing responses still conform. Document the goal create Idempotency-Key header and its 409 conflict in the route docs. Regenerate the spec and client types.
  4. Docs. One section "Idempotency and retries" in docs/mcp.md and the API reference covering: the three key contracts and their formats; same key + same payload replays, same key + different payload conflicts; OUTCOME_UNKNOWN; how an MCP key maps to the REST submission key; IMPLEMENTATION_ALREADY_REQUESTED for implement_plan; how to follow a submission through replacement attempts (latestTaskId, lineage); which task kinds are replaced (issue tasks only, never goal tasks) and the replacement causes and skip reasons.

Out of scope

No change to idempotency or replacement behaviour, key formats, or caps.

Acceptance criteria

  • get_task on a replaced task and on its replacement returns consistent lineage in both directions; a task with a single attempt returns attemptNumber: 1 and no attempts array.
  • list_tasks rows expose the three fields for replacement attempts and stay within the tool result budget.
  • Submission reads return both task pointers; a test covers a submission whose task was replaced.
  • The OpenAPI conformance test now pins the lineage fields; generated client types include them.
  • mcpObservableSurface, mcpDocs, mcpToolInputBudget, OpenAPI coverage/conformance tests pass; committed spec matches the generator.
  • The docs section exists in both places and names only real tools and codes.

Implementation

  1. MCP: extend packages/api/mcp/goalTaskDetail.ts / listSummaries.ts and the get_task / list_tasks projections in packages/api/mcp/tools.ts using taskAttemptLineage.ts.
  2. Submissions: submissionResult in packages/api/mcp/toolsTaskSubmissions.ts, the public shape in packages/api/routes/taskSubmissionRoutes.ts.
  3. OpenAPI: schema in packages/api/openapi/schemas.ts, goal route docs, npm run gen:openapi.
  4. Tests: packages/api/test/mcpTaskSubmissions.test.ts, a new MCP lineage test, taskHistoryRoutes.test.ts, packages/cli/src/commands/taskCommands.test.ts if output changes.
  5. Docs in docs/mcp.md, docs/mcp-coverage.md, docs/docs/operations/api-reference.md; allow-list any new non-tool backticked tokens in packages/api/test/mcpObservableSurface.test.ts.

Notes

Lineage storage: packages/core/src/db/migrations/20261006000000_add_task_replacement_lineage.js. Existing lineage docs: docs/docs/architecture/worker.md, docs/docs/operations/troubleshooting.md.

Activity

  1. propr-dev commented on Nov 13, 2026

    @propr-dev
    Contributor

    🤖 AI processing has started for this issue using claude agent with claude-opus-5-5 model.

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

    Processing Details:

    • Agent: claude
    • Model: claude-opus-5-5
    • Branch: 3485/claude-opus-5-5-expose-retry-lineage-in-m-20261113-0031-wu6
    • Base Branch: 3482-epic-integration-signals-100
    • Worktree: issue-3485-20261113-0031-claude-opus-5-5-wu6

    🔍 Track Task Execution

  2. added a commit that references this issue on Nov 13, 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