Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions docs/plans/mcp-code-mode-autonomy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Operating Recoup Records through the API

A Recoup Records operator signs in with an ordinary Recoup account, selects a label workspace they can already access and gives the agent a job. The first write milestone records a `needs_changes` release-metadata review and independently reopens its receipt. The subsequent durable workflow opens private catalog correction cases for eligible recordings, continues after chat closure and verifies each saved case. Qualify both milestones on a disposable label containing synthetic recordings. [First verified write](https://github.com/recoupable/api/issues/1308) · [Durable API jobs](https://github.com/recoupable/api/issues/1315) · [Private case access](https://github.com/recoupable/api/issues/1316)

## Authority and instructions

| Component | Responsibility |
| --- | --- |
| Sign-in | Authenticate the existing Recoup account through the connection's supported flow. Preserve its organization membership, resource access, OAuth audience and granted scopes. On the existing REST surface the credential identifies the account. For organization-scoped work, carry the selected organization into the API call and validate membership and resource access there. The shared REST authentication helper returns no organization when none is supplied. The personal, one-hour `mcp:read` registration profile remains read-only. [REST authentication](../../lib/auth/validateAuthContext.ts) · [OAuth access](../../lib/oauth/resolveOAuthAccess.ts) · [Personal registration](../agent-registration.md) |
| MCP and agent | On a qualified host with native Skills enabled, the host lists the account’s permitted skills and makes their names and descriptions available to the agent before the first prompt. It can keep the file manifest locally. It reads the selected guide and any required files only when the task calls for them. On a host without native Skills, a topic `search` can surface the guide alongside the relevant API operation. Open it with `search({skill})`, or browse with `search({})`. Use `execute` to compose the permitted operations and return a compact answer. The host supplies authenticated context outside the generated program. The API alone decides business authorization, including any approval the underlying operation already requires. |
| Recoup API | Apply the existing account, workspace, entitlement, recipient, quote, spending and resource checks appropriate to each operation, on every entry point. Return an actionable denial, existing approval/quote requirement, or receipt for an accepted action. A host or downstream provider may also require interaction. Show the actual reason and continue through the supported flow. |
| Durable job | When an operation needs to outlive the chat, use an API-owned job or workflow that records the initiating account, workspace, admitted job, idempotency key, checkpoints and result. Before subsequent effects and on result access, enforce the owning operation's current permissions. If the supported authorization expires and cannot be refreshed or revalidated, pause and request reconnection. Establish what survived the restart using the original job record. |

A Recoup Records operator can say “check this week's releases” or designate an existing catalog handbook. For a handbook-guided job, the API records the assigning account, organization or workspace, assignment ID, source, document ID, authorized version and content digest. Retain an immutable snapshot or a retrievable immutable version. Before the first effect and after restart, resolve any host-supplied reference against this trusted assignment record and recheck the account's current access. Hold affected work if the reference, version or digest differs, the content cannot be verified, or its authorization is withdrawn. The assigning account can deliberately select a different handbook by updating the assignment. Optional recurring jobs can reuse these instructions. The owning API still decides access, spend and required approvals. [Job acceptance](https://github.com/recoupable/api/issues/1315)

## The durable catalog job

Ask the agent to open one private correction case for each recording whose current release evidence shows a missing recording identifier (ISRC). For example, if the fixture has three confirmed gaps, one already has a case, and another track's lookup failed, the expected change is two new cases. The two new cases cite their source versions, the existing case remains unique, and the failed lookup stays unresolved. The work involves no messages, provider registrations or spending.

Today Recoup distinguishes an observed missing ISRC from a failed lookup, partial coverage and stale source versions. Its existing REST Context route and standard MCP can save and reopen workspace-scoped cases with expected revisions and idempotency keys. A saved case is a private workpaper. The current delegated OAuth profile excludes case save, read and list. Ordinary sign-in identifies the user, and the existing credential and route still determine which operations work. An authenticated account alone does not prove that a particular connector already supports the job. [Release observations](../../lib/context/planning/readReleaseTrackObservations.ts) · [Case contract](../../lib/context/README.md#catalog-case-artifacts-catd-29) · [OAuth exclusions](../mcp-oauth-tool-qualification.md)

To qualify the direct connection, expose the authorized case operations for its normal sign-in path through the owning API. Reuse the scoped case processor, enforce workspace membership, validate recording and evidence versions, preserve revision conflicts, and keep withdrawal and redaction behavior on later reads. Document existing grants that lack the necessary access. Keep the OpenAI Directory's separately reviewed catalog surface within its published capabilities. Rights registration, distribution and collections each need their own API/provider operation and observed outcome.

## Installed end-to-end acceptance

1. Seed two isolated organizations and a catalog large enough to paginate. Include confirmed gaps, already-handled records, a failed lookup, conflicting evidence and a withdrawn source. Sign in with an ordinary test account that already has the pilot label's required access. Compare direct code mode with the same underlying REST operation on equivalent fixture state. Use named MCP as a control where its current credential is eligible. On a fresh native connection, verify that only permitted skill names and descriptions reach the agent before the first prompt, with zero file reads. Give the operator’s release-check request without naming a guide or prompting a search. Observe whether the agent selects the relevant guide from its description and reads it on demand. On the fallback host, search the same topic, verify distinct guide and operation previews, and open the exact guide with `search({skill})`. Repeat on both hosts outside the guide’s audience. The hidden entry must disappear and guide reads must produce zero business effects.
2. Create a real case through the direct connection with zero extra setup or prompts beyond sign-in for this already permitted private action. Independently reopen it through an account-authorized read path and verify workspace, recording, saved revision and source evidence. Count expected and actual new cases, unresolved findings, duplicates, wrong-tenant effects and human interruptions.
3. Close the initiating chat during a durable job, restart its worker, and submit a duplicate business key. An unchanged retry finds the original job; different work under the same key conflicts. Change a source version before a queued write and verify the job rechecks its evidence. Remove workspace access before another queued effect and verify that it stops. Preserve unknown external outcomes for reconciliation.
4. Exercise a separate existing operation with a real API-mandated approval or quote. Verify that the client receives the same requirement as an equivalent authorized API caller, and that it cannot cause the effect without satisfying that requirement. After the authorized approver records a decision at the owning API, check `execute({runId})` only observes. Explicit `execute({runId,resume:true})` can finish the exact approved outstanding step and continue the saved checkpoint. If the API applied it already, the run must reuse that receipt without another effect. Race two explicit resumes and independently verify one effect under the original decision. Record real host-imposed prompts separately from API decisions. Publish only sanitized task outcomes, receipt references, interruptions and cost per verified case.
5. Designate one of two valid handbooks in the same fixture organization. At initial dispatch and after restart, supply the other handbook, a different tenant's reference, a changed version and a withdrawn source. Each affected action stays pending or denied with zero writes. The originally designated, currently authorized version resumes successfully. Run an inline assignment separately to verify ordinary one-off work starts directly after sign-in.
Loading
Loading