Skip to content

Commit 464e733

Browse files
committed
fix(spec): the amended confirmation contract hands an unelicitable call to the app before any refusal
A client that cannot be elicited is handed to the host's optional pending-confirmation service (IActionConfirmationService) and answered with a pending id; only a host without the service refuses. The person is asked after every admission gate, a confirmation-refused call may have read its subject, the reason set and pins follow the amended rule, and the semantic entry and changeset speak of the doors' switch conditionally. Claude-Session: https://claude.ai/code/session_01FEkQ5kZuoX9F5S7p84Dwue Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 85c411c commit 464e733

4 files changed

Lines changed: 301 additions & 134 deletions

File tree

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

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,29 @@
22
'@objectstack/spec': minor
33
---
44

5-
feat(spec)!: a declared-gated action on an AI door is confirmed by a person through MCP elicitation, never by the caller's own `confirm: true`
5+
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) — the contract stops counting a caller's `confirm: true` on an action declaring `ai.requiresConfirmation: true` and refuses an MCP client that did not advertise `elicitation`; `@objectstack/spec/contracts` gains `AI_ACTION_CONFIRMATION_CAPABILITY`, `ACTION_CONFIRMATION_REFUSAL_REASONS`, `ActionConfirmationRefusalReason` 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` and the optional `ActionConfirmationRequiredDetails.reason`.
88
Metadata-protocol: semantic
9-
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; 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`, which describe the door that runs today.
9+
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

1111
<!-- adr-0087: registered action-requires-confirmation-elicited -->
1212

13-
**BREAKING** for an MCP client, an agent or a script that runs an action declaring `ai.requiresConfirmation: true` through `run_action` or `resume_run` by sending `confirm: true` itself. Ruled by the account owner: 「3826 照建议(征询版)」.
13+
**BREAKING, when the implementing change ships**, for an MCP client, an agent or a script that runs an action declaring `ai.requiresConfirmation: true` through `run_action` or `resume_run` by sending `confirm: true` itself. Ruled by the account owner: 「3826 照建议(征询版)」, amended 「我开始重新接受你说的主流方案,就是推送到客户的手机端」 and 「比如最简单的我可以先推送到邮件」.
1414

15-
The contract in `@objectstack/spec/contracts` (`AI_ACTION_CONFIRMATION_CAPABILITY`, `contracts/ai-service.ts`) now says:
15+
⚠ 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-
- The server asks the person: after every other gate passes and before anything runs, it sends one MCP `elicitation/create` request (form mode) to the client the call arrived on, naming the action, the object and the record.
18-
- The door reads the `elicitation` capability the client sent at `initialize`. A client that did not advertise it is refused with `428 ACTION_CONFIRMATION_REQUIRED` and `details.reason: 'elicitation_unsupported'`; the message tells the person to use a client that supports confirmation, or to act in the app.
19-
- `accept` runs the call once, under the caller's permissions, and nothing is stored for the next call. `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`, and nothing runs.
20-
- The caller's `confirm` never counts on such a call, with or without an elicitation.
21-
- An AI service account acting for itself is refused whatever it sends, unchanged (ADR-0151 D3 rule 3), now with reason `service_account`; no elicitation is sent to it.
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'`).
18+
- 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.
20+
- The caller's `confirm` never counts on such a call.
21+
- 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.
2223
- 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.
2324

24-
The doors switch in the change that implements this contract; until then they still gate on the member, and a refusal without `details.reason` comes from such a door. The semantic entry `action-requires-confirmation-elicited` carries the same notice into the upgrade guide and `os migrate meta`.
25+
The semantic entry `action-requires-confirmation-elicited` carries the same notice, with the same timing, into the upgrade guide and `os migrate meta`.
2526

26-
What changes for a caller:
27+
What changes for a caller, from the release whose doors implement it:
2728

28-
- FROM confirm with the person yourself, then send `confirm: true` on `run_action` / `resume_run` TO advertise `elicitation` (form mode) at `initialize` and let the server ask the person; send no `confirm`.
29-
- FROM a script or agent that runs a gated action unattended with `confirm: true` TO no replacement: a person runs the action, in an elicitation-capable client or in the app, or the action's author declares `ai.requiresConfirmation: false` where it is safe unattended.
29+
- FROM confirm with the person yourself, then send `confirm: true` on `run_action` / `resume_run` TO advertise `elicitation` (form mode) at `initialize` and let the server ask the person, or, from a client that cannot, relay the pending answer's message and let the person decide in the app; `confirm` then confers nothing.
30+
- FROM a script or agent that runs a gated action unattended with `confirm: true` TO a pending answer the person decides in the app (or a refusal on a host with no pending-confirmation service); where the action is safe unattended, its author declares `ai.requiresConfirmation: false`.

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

Lines changed: 63 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,11 @@ import {
5555
AI_ACTION_CONFIRMATION_CAPABILITY,
5656
AI_ACTION_CONFIRMATION_MEMBER,
5757
type AIActionConfirmation,
58+
type ActionConfirmationHandOff,
59+
type ActionConfirmationPending,
5860
type ActionConfirmationRefusalReason,
5961
type ActionConfirmationRequiredDetails,
62+
type IActionConfirmationService,
6063
} from './ai-service';
6164

6265
/** The refusal code the contract names. */
@@ -146,18 +149,23 @@ describe('action-confirmation contract — an unconfirmed gated action is refuse
146149
});
147150

148151
/**
149-
* The amended contract: a person confirms a declared-gated action through MCP
150-
* elicitation, and the caller's own `confirm` never counts (ruling
151-
* 「3826 照建议(征询版)」, objectstack-ai/cloud#3826 item 6).
152+
* The amended contract: a person confirms a declared-gated action, through
153+
* MCP elicitation when the client can be asked and through a hand-off to the
154+
* host's pending-confirmation service otherwise, refused only when the host
155+
* has none; the caller's own `confirm` never counts (ruling
156+
* 「3826 照建议(征询版)」, objectstack-ai/cloud#3826 item 6, as amended on
157+
* the card).
152158
*
153-
* Pinned here: the capability's spelling, the CLOSED refusal-reason set, that
154-
* `details.reason` is typed to it and stays optional while the member gates
155-
* still answer without it, that the amendment adds no second refusal code,
156-
* and that the contract's own text names every reason and every elicitation
157-
* answer, so the tuple and the prose cannot drift apart. NOT pinned: any door
158-
* behaviour, which the implementing change lands and pins.
159+
* Pinned here: the capability's spelling, the CLOSED refusal-reason set (a
160+
* hand-off is not in it), that `details.reason` is typed to it and stays
161+
* 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
163+
* no second refusal code, and that the contract's own text names every reason,
164+
* every answer and the three steps, so the types and the prose cannot drift
165+
* apart. NOT pinned: any door behaviour, which the implementing change lands
166+
* and pins.
159167
*/
160-
describe('action-confirmation contract, as amended: a person confirms through elicitation', () => {
168+
describe('action-confirmation contract, as amended: a person confirms, elicited or handed off', () => {
161169
const HERE = dirname(fileURLToPath(import.meta.url));
162170
const CONTRACT_SOURCE = join(HERE, 'ai-service.ts');
163171

@@ -178,14 +186,18 @@ describe('action-confirmation contract, as amended: a person confirms through el
178186

179187
it('the refusal reasons are a CLOSED set of exactly five', () => {
180188
expect([...ACTION_CONFIRMATION_REFUSAL_REASONS]).toEqual([
181-
'elicitation_unsupported',
182189
'declined',
183190
'cancelled',
184191
'timed_out',
192+
'no_confirmation_service',
185193
'service_account',
186194
]);
187-
// Control: an accepted elicitation is not a refusal, so it is no reason.
188-
expect((ACTION_CONFIRMATION_REFUSAL_REASONS as readonly string[]).includes('accepted')).toBe(false);
195+
// Controls: an accepted elicitation and a hand-off are not refusals, and a
196+
// client that cannot elicit is handed off rather than refused for that.
197+
const reasons = ACTION_CONFIRMATION_REFUSAL_REASONS as readonly string[];
198+
for (const notARefusal of ['accepted', 'pending_confirmation', 'elicitation_unsupported']) {
199+
expect(reasons.includes(notARefusal), `${notARefusal} must not be a refusal reason`).toBe(false);
200+
}
189201
});
190202

191203
it('`details.reason` is typed to the closed set, and optional', () => {
@@ -212,6 +224,34 @@ describe('action-confirmation contract, as amended: a person confirms through el
212224
expect(ACTION_CONFIRMATION_REFUSAL_REASONS).toContain(reason);
213225
});
214226

227+
it('a hand-off answers with the pending discriminant, through an optional host seam', () => {
228+
const pending: ActionConfirmationPending = {
229+
status: 'pending_confirmation',
230+
pendingId: 'pc_1',
231+
message: 'A confirmation was sent to you.',
232+
actionName: 'archive_account',
233+
objectName: 'account',
234+
};
235+
expect(pending.status).toBe('pending_confirmation');
236+
const wrongStatus: ActionConfirmationPending = {
237+
// @ts-expect-error — the discriminant is one literal; the in-app chat's
238+
// older `pending_approval` envelope is not this answer.
239+
status: 'pending_approval',
240+
pendingId: 'pc_1',
241+
message: 'm',
242+
actionName: 'archive_account',
243+
};
244+
expect(String(wrongStatus.status)).toBe('pending_approval');
245+
246+
const handOff: ActionConfirmationHandOff = {
247+
actionName: 'archive_account', objectName: 'account', recordId: 'a1', params: {}, door: 'mcp',
248+
};
249+
const service: IActionConfirmationService = {
250+
submit: async (h) => ({ pendingId: `pc_${h.actionName}` }),
251+
};
252+
return expect(service.submit(handOff, {} as never)).resolves.toEqual({ pendingId: 'pc_archive_account' });
253+
});
254+
215255
it('the amendment keeps ONE refusal code: no second code is registered for it', () => {
216256
const all = Object.values(ERROR_CODE_LEDGER).flat() as string[];
217257
expect(all).toContain(CODE);
@@ -225,9 +265,18 @@ describe('action-confirmation contract, as amended: a person confirms through el
225265
for (const reason of ACTION_CONFIRMATION_REFUSAL_REASONS) {
226266
expect(prose, `the contract no longer states the \`${reason}\` case`).toContain(`\`${reason}\``);
227267
}
228-
for (const answer of ['`accept`', '`decline`', '`cancel`', 'Timed out']) {
268+
for (const answer of ['`accept`', '`decline`', '`cancel`', 'timed out', 'then approved in the app', 'then rejected in the app']) {
229269
expect(prose, `the contract no longer says what ${answer} does`).toContain(answer);
230270
}
271+
for (const step of ['**Elicit**', '**Hand off**', '**Refuse**, only when the host has no pending-confirmation service']) {
272+
expect(prose, `the contract dropped the step ${step}`).toContain(step);
273+
}
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/,
276+
);
277+
expect(prose, 'the contract dropped the re-check at approval').toMatch(/every gate and permission re-checked/);
278+
expect(prose, 'the contract dropped the trust bound of an elicited answer').toMatch(/proves that the CLIENT answered, not that a person did/);
279+
expect(prose, 'the contract claims a refused call read nothing again').not.toMatch(/no record was read/);
231280
expect(prose, 'the contract dropped "the caller\'s `confirm` never counts"').toMatch(/The caller's `confirm` never counts/);
232281
expect(prose, 'the contract dropped the unchanged AI service account rule').toMatch(
233282
/An AI service account: unchanged\*\* \(ADR-0151 D3 rule 3\)/,

0 commit comments

Comments
 (0)