Skip to content

Commit ef8735a

Browse files
lavaman131codex
authored andcommitted
docs(skills): guide safe document revisions through MCP
Cover revision conflicts, exact idempotent retries, protected projections, replay metadata, and implementation graph release and reapproval. Check authoring instructions with and without update support. Co-authored-by: GPT-6 Astra <noreply@openai.com>
1 parent 8a1f125 commit ef8735a

5 files changed

Lines changed: 147 additions & 45 deletions

File tree

‎docs/local-agent-mcp.md‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,18 @@ Repeating the same idempotency key returns the original applied result, includin
107107
its source and revision, even after later edits or a server restart. A changed
108108
payload under that key returns `idempotency-conflict`. Use a new key for each new
109109
update, and keep the original arguments when retrying an uncertain response.
110-
111-
Source validation returns `issues`, as creation does. Existing Questionnaire,
112-
Decision, and Research projections cannot be dropped, altered, or forged.
113-
Copy them unchanged from the latest read or the update returns
114-
`protected-projection`. An active implementation run returns `document-locked`;
115-
an archived document returns `document-archived` for a new update.
110+
A replay's title and URL also reflect the original update. Read the document
111+
again for current metadata before handing off its canonical URL after a rename.
112+
113+
Initial source validation returns `issues`, as creation does. Existing
114+
Questionnaire, Decision, and Research projections cannot be dropped, altered,
115+
or forged. Copy them unchanged from the latest read or the update returns
116+
`protected-projection`. That code also covers later rewrite validation or
117+
reconciliation refusals, so it does not identify a particular changed projection.
118+
An active implementation run returns `document-locked`; an archived document
119+
returns `document-archived` for a new update. Changing source before an approved
120+
graph is claimed makes its plan revision stale; revise and reapprove the graph
121+
before starting implementation.
116122

117123
The accepted result includes `id`, `title`, canonical `source`, `revision`, and
118124
`url`, plus any existing creation brief and generated description. The MCP client
@@ -222,7 +228,8 @@ grant it.
222228

223229
Use the optional
224230
[creating-chopin-plans skill](../skills/creating-chopin-plans/SKILL.md) to turn a
225-
settled coding-agent conversation into one initial document. The
231+
settled coding-agent conversation into one initial document or safely revise an
232+
existing document after review. The
226233
[implementing-chopin-plans skill](../skills/implementing-chopin-plans/SKILL.md)
227234
applies only after an implementation graph has been approved through a future or
228235
operator-provided approval path. Current MCP initialization instructions and

‎skills/creating-chopin-plans/SKILL.md‎

Lines changed: 60 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
---
22
name: creating-chopin-plans
3-
description: Use when a coding-agent conversation has settled enough context to create a new Chopin document through the create_document MCP tool.
3+
description: Use when a coding-agent conversation has settled enough context to create a Chopin document, or when revising an existing document through update_document after review or new findings.
44
---
55

6-
# Creating a Chopin plan
6+
# Creating and revising a Chopin plan
77

88
Create one initial Chopin document from the useful outcome of the settled
9-
conversation. Chopin's current MCP instructions and tool descriptions are
10-
authoritative.
9+
conversation, then revise that same document as the plan develops. Chopin's
10+
current MCP instructions and tool descriptions are authoritative. If
11+
`update_document` is unavailable, report that limitation instead of creating a
12+
replacement document or trying to trigger the Planner.
1113

1214
## Prepare the brief
1315

@@ -28,16 +30,64 @@ expressions, raw HTML, arbitrary JSX, or component ids owned by Chopin.
2830
Generate one idempotency key for the attempt, then use the current
2931
`create_document` descriptor to submit the brief, provenance, title, and plan.
3032
If it reports validation issues, repair the relevant content and retry with the
31-
same key. Once creation succeeds, do not call `create_document` again. Later
32-
revisions of that same document use `update_document` against the revision
33-
returned by `read_document`, with a new idempotency key.
33+
same key. Once creation succeeds, do not call `create_document` again for that
34+
document. Follow the revision flow below to preserve its Conversation and
35+
Decisions.
36+
37+
## Revise an existing document
38+
39+
1. Read the supplied canonical document URL or UUID with `read_document`. Work
40+
from its latest `source` and `revision`, not a copied plan or an earlier tool
41+
result. Confirm that the requested change belongs to this document.
42+
2. Prepare the full replacement MDX in `plan`, including unchanged prose. Copy
43+
existing Questionnaire, Decision, and Research projections unchanged,
44+
including their ids and answers. Do not invent, remove, or rewrite those
45+
server-owned components to make the edit pass validation.
46+
3. Call `update_document` with `id`, the revision just read, the complete `plan`,
47+
and a new nonblank `idempotencyKey` of at most 128 characters. Keep the exact
48+
arguments until the outcome is known. The caller needs repository push or
49+
administration access; its MCP bearer does not acquire Planner ownership.
50+
4. If the response is lost or uncertain, retry with the same key and identical
51+
arguments, including the original URL or UUID. Do not switch identifiers or
52+
change the source during a retry. A replay returns the original applied
53+
source and revision, which may no longer be the latest document. Read again
54+
before planning another edit.
55+
56+
If the document already has an approved implementation graph, changing its
57+
source makes that graph's plan revision stale even before a run is claimed.
58+
Coordinate a graph revision and renewed approval before expecting implementation
59+
to start; a successful document update does not update or approve the graph.
60+
61+
Handle refusals without overwriting collaborators' work:
62+
63+
- `revision-conflict`: re-read the complete document, reconcile the requested
64+
edit with intervening changes, and submit a new update with a new key. Do not
65+
merely replace the revision number on stale source.
66+
- `idempotency-conflict`: the key was reused with different arguments. Recover
67+
the original request for an uncertain retry; use a new key only for an
68+
intentional new update after reading the current document.
69+
- `issues`: repair the reported validation problem. Treat changed arguments as
70+
a new update with a new key.
71+
- `protected-projection`: re-read and preserve the exact server-owned projections.
72+
This code also covers other rewrite validation or reconciliation refusals. If
73+
unchanged projections still fail, stop and report the refusal rather than
74+
repeatedly retrying or stripping components to get past it.
75+
- `document-locked`: stop document edits and follow the implementation's
76+
revision and graph-release process. Do not bypass the lock by creating a copy.
77+
- `document-archived`: stop and ask whether to restore the document; do not
78+
restore or replace it implicitly.
79+
- `repository-forbidden` or `document-unavailable`: report the access or
80+
availability problem instead of recreating the document.
3481

3582
## Hand off
3683

37-
Return the created document's human-readable `url` as the canonical handoff,
84+
Return the created or updated document's human-readable `url` as the canonical handoff,
3885
with its title. Treat the returned `id` as an internal MCP identifier: include it
3986
separately when useful, but never replace the `/documents/...` URL with a
4087
`/channels/<id>` link. Do not open it automatically.
88+
After an idempotent replay, use a fresh `read_document` result for the current
89+
title and canonical URL, since the stored response may predate a rename. Keep
90+
the replay's accepted revision distinct from the latest revision.
4191

42-
Use [prompt.md](prompt.md) as a starter when handing an already-settled
43-
conversation to an agent with this skill installed.
92+
Use [prompt.md](prompt.md) as a starter for creation or revision with this skill
93+
installed.

‎skills/creating-chopin-plans/contract.test.ts‎

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,47 @@ function creation(): CreateDocument<string> {
2323
};
2424
}
2525

26-
test("the MCP service publishes its creation contract without implementation guidance", async () => {
27-
let mcp = handler({
28-
caller: () => "operator",
29-
documents: {
30-
async list() {
31-
return [];
26+
test.each([false, true])(
27+
"authoring instructions with updates=%s",
28+
async updating => {
29+
let mcp = handler({
30+
caller: () => "operator",
31+
documents: {
32+
async list() {
33+
return [];
34+
},
35+
async read() {
36+
return undefined;
37+
},
3238
},
33-
async read() {
34-
return undefined;
35-
},
36-
},
37-
create: creation(),
38-
});
39-
let initialized = await mcp(request({
40-
jsonrpc: "2.0",
41-
id: 1,
42-
method: "initialize",
43-
params: {},
44-
}));
45-
let initialization = await initialized.json() as {
46-
result: { instructions?: string };
47-
};
48-
expect(initialization.result.instructions).toBe(
49-
[
50-
"Chopin's MCP contract and current tool descriptions are authoritative.",
51-
"create_document: Create a Chopin document from a structured brief and canonical plan.",
52-
].join("\n"),
53-
);
54-
});
39+
create: creation(),
40+
update: updating
41+
? {
42+
async update() {
43+
return { kind: "forbidden" };
44+
},
45+
}
46+
: undefined,
47+
});
48+
let initialized = await mcp(request({
49+
jsonrpc: "2.0",
50+
id: 1,
51+
method: "initialize",
52+
params: {},
53+
}));
54+
let initialization = await initialized.json() as {
55+
result: { instructions?: string };
56+
};
57+
expect(initialization.result.instructions).toBe(
58+
[
59+
"Chopin's MCP contract and current tool descriptions are authoritative.",
60+
"create_document: Create a Chopin document from a structured brief and canonical plan.",
61+
...(updating
62+
? [
63+
"update_document: Replace a Chopin document's canonical plan against the revision last read.",
64+
]
65+
: []),
66+
].join("\n"),
67+
);
68+
},
69+
);

‎skills/creating-chopin-plans/prompt.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,15 @@ Chopin MCP initialize instructions and tool descriptions.
99
...
1010

1111
</SETTLED_CONVERSATION>
12+
13+
## Revise an existing document
14+
15+
Use this prompt instead of the creation prompt when the document already exists:
16+
17+
Revise `<CANONICAL_CHOPIN_DOCUMENT_URL>` to incorporate `<REQUESTED_CHANGES>`.
18+
Follow the installed `creating-chopin-plans` skill and the current Chopin MCP
19+
instructions. Read the latest source and revision before calling
20+
`update_document`; preserve server-owned projections and do not create a second
21+
document. Reconcile revision conflicts with a fresh read, and retry uncertain
22+
responses only with identical arguments and the same idempotency key. Return
23+
the canonical document URL and summarize the accepted changes.

‎skills/implementing-chopin-plans/SKILL.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,24 @@ Re-read the implementation before every lifecycle action, then follow the servic
2525
- Perform a separate review pass after implementation. Prefer a fresh reviewer sub-agent; otherwise review independently after stepping away. Resolve in-scope findings and run focused checks.
2626
- Create exactly one pull request per task. Update that pull request if later verification returns the task to work.
2727

28+
## When the document needs revision
29+
30+
`update_document` is for document authoring, not an implementation lifecycle
31+
shortcut. An active implementation locks the document and returns
32+
`document-locked` for a new update. If scope, acceptance criteria, or dependencies
33+
must change, stop code work and follow the current `request_revision` contract
34+
to release the graph. A task blocker alone does not release that lock.
35+
36+
After release, hand the required document changes back to the authoring workflow.
37+
It should read the latest source and revision, preserve server-owned projections,
38+
and use a new revision-guarded update rather than recreate the document. Do not
39+
silently switch from implementing to rewriting or approving the plan. Resume
40+
implementation only after the service exposes an approved graph and a new claim
41+
succeeds against its current revisions and checkout context.
42+
Approval currently has no production UI or route. If no operator-provided
43+
approval path is available, report that blocker rather than promising an
44+
automatic resume.
45+
2846
## Verify the graph
2947

3048
After every task is complete, perform an independent whole-graph verification. Run all relevant checks and capture command names, outcomes, and limitations as evidence for every task. Submit that evidence through the current service contract and follow the returned lifecycle state; only an accepted passing result releases a successful implementation.

0 commit comments

Comments
 (0)