Skip to content

Commit 836e1ff

Browse files
committed
feat(spec): the confirmation hand-off carries a resume_run's run, names its service slot, and takes a person's signed-in session to decide
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5kZuoX9F5S7p84Dwue
1 parent c0ebf0c commit 836e1ff

3 files changed

Lines changed: 125 additions & 36 deletions

File tree

‎.changeset/33689-ai-action-confirmation-elicited.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
feat(spec)!: a declared-gated action on an AI door is confirmed by a person, elicited in the MCP client or handed off to the app, never by the caller's own `confirm: true`
66

7-
Clause-②: yes (narrowing) — once the doors implement the contract, a caller's `confirm: true` stops counting on an action declaring `ai.requiresConfirmation: true`; `@objectstack/spec/contracts` gains `AI_ACTION_CONFIRMATION_CAPABILITY`, `ACTION_CONFIRMATION_REFUSAL_REASONS`, `ActionConfirmationRefusalReason`, `ActionConfirmationHandOff`, `ActionConfirmationPending`, `IActionConfirmationService` and the optional `ActionConfirmationRequiredDetails.reason`.
7+
Clause-②: yes (narrowing) — once the doors implement the contract, a caller's `confirm: true` stops counting on an action declaring `ai.requiresConfirmation: true`; `@objectstack/spec/contracts` gains `AI_ACTION_CONFIRMATION_CAPABILITY`, `ACTION_CONFIRMATION_REFUSAL_REASONS`, `ActionConfirmationRefusalReason`, `ActionConfirmationHandOff`, `ActionConfirmationPending`, `IActionConfirmationService`, `ACTION_CONFIRMATION_SERVICE` and the optional `ActionConfirmationRequiredDetails.reason`.
88
Metadata-protocol: semantic
99
Skills-docs: follow-up — `skills/objectstack-ai/SKILL.md` (the MCP tool table: `run_action` / `resume_run` "refused with the same 428 unless the call sends `confirm: true`") teaches the member contract, which is still the door's behaviour in this release; it moves with the change that implements the doors, together with the MCP-served skill text (`packages/mcp/src/skill-md.ts`, `ui/apps/console/src/pages/developer/objectstack-skill.ts`) and the `ToolSchema` prescription in `packages/spec/src/ai/tool.zod.ts`.
1010

@@ -14,12 +14,12 @@ Skills-docs: follow-up — `skills/objectstack-ai/SKILL.md` (the MCP tool table:
1414

1515
⚠ In the release that carries this changeset nothing changes at any door: `run_action` and `resume_run` still run a declared-gated action on `confirm: true` and refuse it without, over stdio and Streamable HTTP alike. Keep sending `confirm: true` until a release's changelog says the doors confirm by elicitation. What ships now is the contract the doors move to, in `@objectstack/spec/contracts` (`AI_ACTION_CONFIRMATION_CAPABILITY`, `contracts/ai-service.ts`):
1616

17-
- After every admission gate (the subject load included) and before anything runs, the person is asked, in three steps: **elicit** when the client advertised `elicitation` at `initialize` and the door can carry it (one `elicitation/create`, form mode); otherwise **hand off** to the host's pending-confirmation service (`IActionConfirmationService`), answering `status: 'pending_confirmation'` with a pending id and a plain message, the person then approving or rejecting in the app, where the action runs as them with every gate and permission re-checked; **refuse** only when the host has no such service (`428 ACTION_CONFIRMATION_REQUIRED`, `details.reason: 'no_confirmation_service'`).
17+
- After every admission gate (the subject load included) and before anything runs, the person is asked, in three steps: **elicit** when the client advertised `elicitation` at `initialize` and the door can carry it (one `elicitation/create`, form mode); otherwise **hand off** to the host's pending-confirmation service (`IActionConfirmationService`, registered under `ACTION_CONFIRMATION_SERVICE` = `'ai.actionConfirmation'`), answering `status: 'pending_confirmation'` with a pending id and a plain message, the person the call ran as, and only they, then approving or rejecting in the app, where the action runs as them with every gate and permission re-checked; a handed-off `resume_run` carries its run id and values (`ActionConfirmationHandOff.run`), and approving it resumes that parked run, never a new one; **refuse** only when the host registers no such service (`428 ACTION_CONFIRMATION_REQUIRED`, `details.reason: 'no_confirmation_service'`).
1818
- An elicited `accept` runs the call once; `decline`, `cancel` (an error answer or a dropped connection included) and no answer within the door's bound are refused with reason `declined`, `cancelled` or `timed_out`. A call refused at confirmation may have read its subject and writes nothing.
19-
- The approve and reject doors of the pending-confirmation service refuse an AI identity.
19+
- The approve and reject doors of the pending-confirmation service take a person's signed-in session to the app and nothing else: they refuse an AI identity, and an API key, token or other service credential, whoever it resolves to. When a pending item lapses, and how the caller learns its outcome, are the host's to define.
2020
- The caller's `confirm` never counts on such a call.
2121
- An AI service account acting for itself is refused whatever it sends, unchanged (ADR-0151 D3 rule 3), with reason `service_account` on every door; it is neither elicited nor handed off.
22-
- An elicited `accept` proves the client answered, not that a person did; a hand-off is decided by a person in the app.
22+
- An elicited `accept` proves the client answered, not that a person did; an approved hand-off proves a signed-in session to the app answered, not that a person did.
2323
- Outside the amendment: the MCP `delete_record` and `delete_records` gates still read `confirm: true`, and REST `/actions` stays outside the gate for a person.
2424

2525
The semantic entry `action-requires-confirmation-elicited` carries the same notice, with the same timing, into the upgrade guide and `os migrate meta`.

‎packages/spec/src/contracts/action-confirmation-contract.pin.test.ts‎

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import { fileURLToPath } from 'node:url';
5252

5353
import {
5454
ACTION_CONFIRMATION_REFUSAL_REASONS,
55+
ACTION_CONFIRMATION_SERVICE,
5556
AI_ACTION_CONFIRMATION_CAPABILITY,
5657
AI_ACTION_CONFIRMATION_MEMBER,
5758
type AIActionConfirmation,
@@ -156,10 +157,12 @@ describe('action-confirmation contract — an unconfirmed gated action is refuse
156157
* 「3826 照建议(征询版)」, objectstack-ai/cloud#3826 item 6, as amended on
157158
* the card).
158159
*
159-
* Pinned here: the capability's spelling, the CLOSED refusal-reason set (a
160+
* Pinned here: the capability's spelling, the service slot the hand-off seam
161+
* is registered under, the CLOSED refusal-reason set (a
160162
* hand-off is not in it), that `details.reason` is typed to it and stays
161163
* optional while the member gates still answer without it, the pending
162-
* answer's discriminant and the hand-off seam's shape, that the amendment adds
164+
* answer's discriminant and the hand-off seam's shape (a `resume_run` call
165+
* carries its run), that the amendment adds
163166
* no second refusal code, and that the contract's own text names every reason,
164167
* every answer and the three steps, so the types and the prose cannot drift
165168
* apart. NOT pinned: any door behaviour, which the implementing change lands
@@ -184,6 +187,14 @@ describe('action-confirmation contract, as amended: a person confirms, elicited
184187
expect(AI_ACTION_CONFIRMATION_CAPABILITY).not.toBe(AI_ACTION_CONFIRMATION_MEMBER);
185188
});
186189

190+
it('the hand-off seam has ONE service slot a door and a host agree on', () => {
191+
expect(ACTION_CONFIRMATION_SERVICE).toBe('ai.actionConfirmation');
192+
// Step 3 turns on that slot, by name, and on nothing else.
193+
expect(capabilityProse()).toContain(
194+
'**Refuse**, only when the host registers no service under {@link ACTION_CONFIRMATION_SERVICE}',
195+
);
196+
});
197+
187198
it('the refusal reasons are a CLOSED set of exactly five', () => {
188199
expect([...ACTION_CONFIRMATION_REFUSAL_REASONS]).toEqual([
189200
'declined',
@@ -224,7 +235,7 @@ describe('action-confirmation contract, as amended: a person confirms, elicited
224235
expect(ACTION_CONFIRMATION_REFUSAL_REASONS).toContain(reason);
225236
});
226237

227-
it('a hand-off answers with the pending discriminant, through an optional host seam', () => {
238+
it('a hand-off answers with the pending discriminant, through an optional host seam', async () => {
228239
const pending: ActionConfirmationPending = {
229240
status: 'pending_confirmation',
230241
pendingId: 'pc_1',
@@ -246,10 +257,23 @@ describe('action-confirmation contract, as amended: a person confirms, elicited
246257
const handOff: ActionConfirmationHandOff = {
247258
actionName: 'archive_account', objectName: 'account', recordId: 'a1', params: {}, door: 'mcp',
248259
};
260+
// A `resume_run` hand-off carries the parked run and the screen's values,
261+
// so approving it resumes THAT run rather than starting a new one.
262+
const resumeHandOff: ActionConfirmationHandOff = {
263+
actionName: 'approve_discount', params: {}, door: 'mcp',
264+
run: { runId: 'run_7', values: { discount: 12 } },
265+
};
266+
const runWithoutValues: ActionConfirmationHandOff = {
267+
actionName: 'approve_discount', params: {}, door: 'mcp',
268+
// @ts-expect-error — the run leg carries the values it resumes with.
269+
run: { runId: 'run_7' },
270+
};
271+
expect(runWithoutValues.run?.runId).toBe('run_7');
249272
const service: IActionConfirmationService = {
250-
submit: async (h) => ({ pendingId: `pc_${h.actionName}` }),
273+
submit: async (h) => ({ pendingId: h.run ? `pc_resume_${h.run.runId}` : `pc_${h.actionName}` }),
251274
};
252-
return expect(service.submit(handOff, {} as never)).resolves.toEqual({ pendingId: 'pc_archive_account' });
275+
await expect(service.submit(handOff, {} as never)).resolves.toEqual({ pendingId: 'pc_archive_account' });
276+
await expect(service.submit(resumeHandOff, {} as never)).resolves.toEqual({ pendingId: 'pc_resume_run_7' });
253277
});
254278

255279
it('the amendment keeps ONE refusal code: no second code is registered for it', () => {
@@ -268,20 +292,37 @@ describe('action-confirmation contract, as amended: a person confirms, elicited
268292
for (const answer of ['`accept`', '`decline`', '`cancel`', 'timed out', 'then approved in the app', 'then rejected in the app']) {
269293
expect(prose, `the contract no longer says what ${answer} does`).toContain(answer);
270294
}
271-
for (const step of ['**Elicit**', '**Hand off**', '**Refuse**, only when the host has no pending-confirmation service']) {
295+
for (const step of ['**Elicit**', '**Hand off**', '**Refuse**, only when the host registers no service']) {
272296
expect(prose, `the contract dropped the step ${step}`).toContain(step);
273297
}
274-
expect(prose, 'the contract dropped the AI-identity refusal on the approve and reject doors').toMatch(
275-
/approve and reject doors of the pending-confirmation service refuse an AI identity/,
298+
expect(prose, 'the approve and reject doors no longer take only a person\'s signed-in session').toMatch(
299+
/approve and reject doors of the pending-confirmation service take a person's signed-in session to the app and nothing else/,
300+
);
301+
expect(prose, 'the contract dropped the AI-identity refusal on the approve and reject doors').toMatch(/They refuse an AI identity/);
302+
expect(prose, 'the approve and reject doors no longer refuse a credential that resolves to the person').toMatch(
303+
/also refuse an API key, a delegated or OAuth token and any other service credential, whoever it resolves to/,
304+
);
305+
expect(prose, 'the contract no longer says who decides a pending item').toMatch(
306+
/The person who approves or rejects is the person the call ran as .*and nobody else/,
307+
);
308+
expect(prose, 'the contract no longer leaves lapse and outcome delivery to the host').toMatch(
309+
/When a pending item lapses, and how the caller learns its outcome, are the host's to define and outside this contract/,
310+
);
311+
expect(prose, 'approving a handed-off resume_run no longer resumes the parked run').toMatch(
312+
/approving it resumes THAT parked run with the values the call carried, as the approver, who must be the run's owner as today; it never starts a new run/,
276313
);
277314
expect(prose, 'the contract dropped the re-check at approval').toMatch(/every gate and permission re-checked/);
278315
expect(prose, 'the contract dropped the trust bound of an elicited answer').toMatch(/proves that the CLIENT answered, not that a person did/);
316+
expect(prose, 'the contract dropped the trust bound of an approved hand-off').toMatch(
317+
/An approval of a hand-off proves that a signed-in session to the app answered, not that a person did/,
318+
);
319+
expect(prose, 'the contract claims a hand-off proves a person again').not.toMatch(/is the stronger of the two/);
279320
expect(prose, 'the contract claims a refused call read nothing again').not.toMatch(/no record was read/);
280321
expect(prose, 'the contract dropped "the caller\'s `confirm` never counts"').toMatch(/The caller's `confirm` never counts/);
281322
expect(prose, 'the contract dropped the unchanged AI service account rule').toMatch(
282323
/An AI service account: unchanged\*\* \(ADR-0151 D3 rule 3\)/,
283324
);
284-
expect(prose, 'the refusal for a client without elicitation no longer names the remedy').toMatch(
325+
expect(prose, 'the refusal for a host without the pending-confirmation service no longer names the remedy').toMatch(
285326
/use a client that supports confirmation, or to perform the action in the app/,
286327
);
287328
});

0 commit comments

Comments
 (0)