Skip to content

fix(approvals) : « Toujours permettre » devient une règle du bot ; la barrière entre coéquipiers attend si la revue est éteinte - #447

Closed
jencryzthers wants to merge 8 commits into
mainfrom
fix/approvals-always-allowed
Closed

jencryzthers wants to merge 8 commits into
mainfrom
fix/approvals-always-allowed

Conversation

@jencryzthers

@jencryzthers jencryzthers commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Corps proposé (remplace la description actuelle). L’outil d’agent ne peut pas écraser une description écrite à la main ; le titre est déjà à jour. À coller dans la description de la PR.


Résumé

Deux correctifs de sécurité sur les approbations. La refonte de la carte (langage clair, reçu d’une ligne) est sortie de cette PR : PR brouillon #455.

  • « Toujours permettre » devient une règle du bot. Sur un appel MCP retenu par la barrière d’approbation, la règle était enregistrée seulement dans la conversation courante : l’écran Accès > Toujours permis restait vide et l’appel redemandait ailleurs. La règle est maintenant aussi enregistrée sur le bot, la barrière lit la liste du bot en plus de celle du fil, et retirer une règle dans Accès l’enlève de toutes les conversations.

  • Les outils entre coéquipiers passent la barrière Grok seulement si la revue entre bots est ACTIVE (coordinate_bots, ask_bot, delegate_bot, send_to_bot, post_to_room). C’est le réglage « Me demander avant de contacter d’autres bots » du serveur qui décide alors, avec sa propre carte et ses limites (profondeur, file, budget de salon). Si la revue est éteinte, l’appel est retenu à la barrière (on ferme par défaut). post_to_room est dans le même ensemble : ce n’est pas une lecture.

  • Un jeton interne de tour ne peut pas enregistrer une règle. POST /api/bots/:id/always-allow avec le Bearer d’une capacité interne répond 403 turn_cannot_self_approve. Le bot ne s’auto-approuve pas.

Pourquoi

Sur un appel vocal, coordinate_bots passait la barrière Grok sans condition. La revue entre bots éteinte, l’appel partait tout seul. Un jeton de tour pouvait aussi enregistrer « Toujours permettre ». Les deux trous sont fermés.

Granularité et portée (documentées, tests)

  • allowKey MCP (mcpAllowKey) : l’outil d’un serveur, n’importe quels arguments. mcp:agents__workspace_write répond à chaque appel suivant de cet outil, peu importe ce qu’on lui demande d’écrire. Les clés entre coéquipiers (ask_bot, delegate_bot, post_to_room) nomment l’action et l’id de la cible, pas le message (peerAllowKey).
  • Qui est couvert : la liste du bot est la règle permanente pour toutes les conversations de ce bot, peu importe qui parle (le propriétaire ou un membre avec qui le bot est partagé). Il n’y a pas de « Toujours permettre » par personne. Quelqu’un qui peut répondre à la carte mais pas modifier le bot garde la règle dans cette conversation seulement.
  • Révocation : retirer une clé dans Accès (revokeAlwaysAllow) l’enlève du bot et de chaque conversation. Les autres clés d’un fil restent. Une règle du fil seulement qui a la même clé disparaît aussi : Accès a dit que cet outil n’est plus toujours permis, nulle part.

Détail : docs/grok-approval-gate.md.

Preuve

Rouge d’abord (tests écrits, implémentation pas encore là), puis vert.

1. Revue éteinte : l’appel est retenu (unité)

 × server/drivers/acp/grok-approval-gate.test.ts > gateReadOnlyTools > revue off: holds teammate tools (coordinate_bots, ask_bot, delegate_bot, send_to_bot, post_to_room) 4ms
   → coordinate_bots must wait at the gate while peer review is off: expected [ 'list_bots', …(31) ] to not include 'coordinate_bots'

 FAIL  server/drivers/acp/grok-approval-gate.test.ts > gateReadOnlyTools > revue off: holds teammate tools (coordinate_bots, ask_bot, delegate_bot, send_to_bot, post_to_room)
AssertionError: coordinate_bots must wait at the gate while peer review is off: expected [ 'list_bots', …(31) ] to not include 'coordinate_bots'
 ❯ server/drivers/acp/grok-approval-gate.test.ts:53:84

 Test Files  1 failed (1)
      Tests  1 failed | 5 passed (6)
   Start at  11:55:47
   Duration  581ms

Après le correctif (gateReadOnlyTools ne joint PEER_REVIEWED_AGENT_TOOL_NAMES que si peerReviewActive === true) :

 ✓ server/drivers/acp/grok-approval-gate.test.ts > gateReadOnlyTools > revue off: holds teammate tools (coordinate_bots, ask_bot, delegate_bot, send_to_bot, post_to_room) 0ms
 ✓ server/drivers/acp/grok-approval-gate.test.ts > gateReadOnlyTools > lets the teammate tools through only when peer review is active: the bot's peer card decides them 0ms

 Test Files  3 passed (3)
      Tests  166 passed (166)
   Start at  12:03:26
   Duration  2.62s

(les 166 : grok-approval-gate.test.ts, store.test.ts, approval-describe.test.ts)

2. Jeton interne de tour + revue éteinte (e2e, serveur réel, faux moteur ACP)

Rouge — le jeton enregistrait la règle (200 au lieu de 403) et coordinate_bots partait sans carte :

 FAIL  server/gate-allow-rule.e2e.test.ts > Always allow on a gated MCP call is a rule of the bot > shows the rule in the bot's Always allowed, stops asking in every conversation, and asks again once removed
AssertionError: … expected 200 to be 403 // Object.is equality

- Expected
+ Received

- 403
+ 200

 ❯ server/gate-allow-rule.e2e.test.ts:144:66
    142|     const { token } = await minted.json() as { token: string };
    143|     const selfApprove = await api("POST", `/api/bots/${bot.id}/always-…
    144|     expect(selfApprove.status, JSON.stringify(selfApprove.body)).toBe(…

 FAIL  server/gate-allow-rule.e2e.test.ts > revue off: a teammate call is held at the Grok gate > holds coordinate_bots when Ask me before contacting other bots is off
AssertionError: coordinate_bots ran unasked while peer review was off:
…
[omb-turn] bot=3616ec01-f6c6-4851-8ecc-e900019cf57c text="ping the team" images=0 depth=0 card=false
[turn-latency] grokAgent thread=5d4d5d91 path=spawn queue=56ms setup=72ms ttfa=207ms ttft=207ms tools=0 total=292ms …
: expected null not to be null
 ❯ server/gate-allow-rule.e2e.test.ts:211:107

 Test Files  1 failed (1)
      Tests  2 failed (2)
   Start at  12:00:42
   Duration  34.46s

Vert — 403 turn_cannot_self_approve, et coordinate_bots est retenu :

 ✓ server/gate-allow-rule.e2e.test.ts > Always allow on a gated MCP call is a rule of the bot > shows the rule in the bot's Always allowed, stops asking in every conversation, and asks again once removed 1310ms
 ✓ server/gate-allow-rule.e2e.test.ts > revue off: a teammate call is held at the Grok gate > holds coordinate_bots when Ask me before contacting other bots is off 620ms

 Test Files  1 passed (1)
      Tests  2 passed (2)
   Start at  12:03:43
   Duration  5.70s

3. Règle du bot pour tous les membres, granularité, révocation

 ✓ shared/approval-describe.test.ts > allow rules > an MCP Allow rule is the tool of one server, any arguments 0ms
 ✓ shared/approval-describe.test.ts > allow rules > the bot's Always allow answers in every conversation, whoever is speaking 0ms
 ✓ server/store.test.ts > Store > revoking Always allow drops that key on every conversation and leaves other thread keys 4ms
 ✓ server/store.test.ts > Store > the bot's Always allow answers in a conversation opened for another person even when that conversation copied none of it 2ms

pnpm lint, pnpm typecheck et pnpm i18n:check ont passé au pre-push.

Jean-Christophe Proulx and others added 4 commits October 13, 2026 12:49
…eammate tools pass the Grok gate

JC report 2026-10-13 (Cryptic on Grok, GOX): during a voice call the
approval gate asked before agents__coordinate_bots although the bot talks
to its teammates without confirmation, and "Always allow" said "Added to
your Allow rules" while Access > Always allowed stayed empty and the call
asked again in other conversations.

Root causes:
- The Grok approval gate (Approve for me, per-bot flag) held every agents
  tool that is not a reviewed read, the teammate tools included. Those
  are the bot's own "Ask me before contacting other bots" setting's to
  decide on the server, with its own card and the server's depth, queue
  and room budgets. They now pass the gate (PEER_REVIEWED_AGENT_TOOL_NAMES).
- POST /api/bots/:id/always-allow saved the rule on the one thread only.
  It now also saves it on the bot (for whoever may edit the bot), the
  gate reads the bot's list as well as the thread's, and removing a rule
  in Access strips it from every conversation (store.revokeAlwaysAllow).
- A gate card and a safety hold said "The provider requires your
  approval"; they now say why in plain words (approval.held.gate,
  approval.held.safety), in every locale.

Test: server/gate-allow-rule.e2e.test.ts (red before, green after).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…answered

JC (2026-10-13): "visuellement c'est affreux". The agents__coordinate_bots
card read as the tool id, three UUIDs and raw JSON under an amber
"The provider requires your approval", and every answered card stayed
full size in the chat.

- A teammate tool (coordinate_bots, ask_bot, delegate_bot, send_to_bot)
  reads as "Cryptic wants to write to 3 bots": the teammates by name and
  avatar, the message quoted and cut at a few lines (Show all).
- The gate's "<tool> {json}" subtitle is the arguments, never the line:
  it stays behind "View the full request".
- A routine note (provider or gate) is no longer shown; the notes that
  change the decision (sends on your behalf, sandbox, safety review,
  undelivered) are one quiet line instead of an amber box.
- Buttons: Deny (neutral, danger on hover), Always allow, Allow (primary).
- An answered or expired tool approval is a one-line receipt
  ("Always allowed · Write to 3 bots"), in history too, that opens on the
  request, the saved rule as a small success line, a working Edit rule for
  the asking bot (ChatView passes its id), and the full request.
- The agents server is the bot itself: no "in Agents" in action phrases.
- approval-preview.html?scene=coordinate shows the cases (expand=1 opens
  the receipts).

All locales via i18n. Tests: ApprovalCard.peer.test.ts (happy-dom for the
receipt and Edit rule clicks), existing card tests updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ew is on

PEER_REVIEWED_AGENT_TOOL_NAMES (coordinate_bots, ask_bot, delegate_bot,
send_to_bot, post_to_room) pass the gate only while peerReviewRequired is
true, so the server's own card decides them. With the revue off they wait.

A live turn token cannot POST /always-allow (403 turn_cannot_self_approve).

The bot's Always allow remains the standing rule for every conversation
and every speaker. An MCP allowKey is the tool of one server, any
arguments; revoke of that key drops it everywhere and leaves other
thread keys.
@cursor cursor Bot changed the title fix(approvals) : « Toujours permettre » devient une règle du bot, carte d'approbation en langage clair fix(approvals) : « Toujours permettre » devient une règle du bot ; la barrière entre coéquipiers attend si la revue est éteinte Oct 14, 2026
@pulsatrixtechnologies pulsatrixtechnologies deleted a comment from cursor Bot Oct 14, 2026
cursoragent and others added 4 commits October 14, 2026 12:24
Keep main's locale catalogs: the approval.held.gate and
approval.held.safety copy belongs on the card PR.
…o_bot has its own peer card

A connectors, computer or data capability, an originless owner-trust
POST while the bot is working, and PATCH alwaysAllow with a turn Bearer
were still treated as the operator. send_to_bot now raises its own peer
card (post_to_room already did). Gate and safety card wording leave this
branch for the plain-language card.
…ve turn

The create_bot card still refuses a standing grant with 409. Without
Origin, owner-trust loopback during a live turn is 403 self-approve.
…épondue (#455)

* feat(approvals): plain-language approval card, one-line receipt once answered

JC (2026-10-13): "visuellement c'est affreux". The agents__coordinate_bots
card read as the tool id, three UUIDs and raw JSON under an amber
"The provider requires your approval", and every answered card stayed
full size in the chat.

- A teammate tool (coordinate_bots, ask_bot, delegate_bot, send_to_bot)
  reads as "Cryptic wants to write to 3 bots": the teammates by name and
  avatar, the message quoted and cut at a few lines (Show all).
- The gate's "<tool> {json}" subtitle is the arguments, never the line:
  it stays behind "View the full request".
- A routine note (provider or gate) is no longer shown; the notes that
  change the decision (sends on your behalf, sandbox, safety review,
  undelivered) are one quiet line instead of an amber box.
- Buttons: Deny (neutral, danger on hover), Always allow, Allow (primary).
- An answered or expired tool approval is a one-line receipt
  ("Always allowed · Write to 3 bots"), in history too, that opens on the
  request, the saved rule as a small success line, a working Edit rule for
  the asking bot (ChatView passes its id), and the full request.
- The agents server is the bot itself: no "in Agents" in action phrases.
- approval-preview.html?scene=coordinate shows the cases (expand=1 opens
  the receipts).

All locales via i18n. Tests: ApprovalCard.peer.test.ts (happy-dom for the
receipt and Edit rule clicks), existing card tests updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(approvals): cover send_to_bot and post_to_room on the plain-language card

Harness-native peer-review cards (bare tool name + allowKey) and Grok-gate
MCP cards both read as who the bot writes to or which room it posts in.

---------

Co-authored-by: Jean-Christophe Proulx <jencryzthers@Jean-Christophes-Macbook-Pro.local>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Cursor Agent <199161495+cursoragent@users.noreply.github.com>
@jencryzthers

Copy link
Copy Markdown
Member Author

Fermée : tout son contenu (jusqu'à f7a5926) est entré dans main par #455, qui l'avait fusionnée. Rien à fusionner une deuxième fois.

@jencryzthers
jencryzthers deleted the fix/approvals-always-allowed branch October 14, 2026 14:29
jencryzthers added a commit that referenced this pull request Oct 15, 2026
…rte d'autorisation (#566)

Retours desktop de JC du 2026-10-15 (`DESKTOP-FEEDBACK-2026-10-15.md`),
pour la 0.5.5. Aucun changement de version, de notes de version ni
d'`ios/`.

## 1. « Nouveau fil » depuis la barre latérale

**Cause** : la simplification des menus (#518) avait retiré toute façon
de démarrer un fil depuis la barre latérale (le menu d'un bot n'avait
plus « Nouveau fil », la ligne n'avait pas de bouton).

**Correctif** (`src/components/Sidebar.tsx`) :
- « Nouveau fil » / « New thread » (clé existante `task.newShort`) est
la **première entrée** du menu d'un bot, au premier niveau (pas sous «
Plus »), aussi dans le menu du client distant.
- Bouton « + » sur la ligne du bot, à côté du « … » : visible au survol
et au focus clavier, visible en tactile (`touch:`), comme le « + » des
salons.
- Les deux envoient `newTask` pour ce bot (qui sélectionne aussi le
bot). Fils désactivés dans les réglages : rien, comme avant.

## 2. Demande d'autorisation affichée deux fois

**Cause** : pour une demande d'outil, `ApprovalCard` dessinait une carte
complète dans le fil (titre, risque, détail, « En attente de votre
réponse ci-dessous ») en plus de la boîte au-dessus du composer
(`PendingApprovalBox`) qui porte les boutons. Le reçu d'une ligne de
#455 n'était jamais arrivé sur main (fusionné dans
`fix/approvals-always-allowed`, PR #447 fermée).

**Correctif** (`src/components/ApprovalCard.tsx`) :
- En attente : le fil n'a plus qu'une ligne d'étape discrète (`StepRow`)
« En attente de votre autorisation » (ou l'attente d'un admin). La seule
carte est celle au-dessus du composer.
- Répondue ou expirée : reçu d'une ligne (« Toujours autorisé ·
Consulter… », « Autorisé une fois », « Refusé », « Expiré ») qui s'ouvre
sur la demande, la règle enregistrée (avec Modifier la règle) et les
détails techniques.
- Les propositions (routine, compétence, profil, équipe) gardent leur
carte : ce qui change, et pour quel bot, se relit là.

**« Toujours autoriser » (#517)** : vérifié dans le code serveur
(`saveOwnerRuleFromCard` puis `ownerDecision`). La règle est enregistrée
pour le propriétaire du bot, ce bot et la portée de la carte ; la même
demande passe ensuite sans carte. Nouveau test sur le cas de JC (lecture
Twilio Accounts) : règle par personne et par portée, relue après
redémarrage, même demande sans carte, autre ressource / autre bot /
autre personne redemandent.

## i18n

Nouvelle clé `approval.status.waitingApproval` en/fr (vouvoiement),
`node scripts/generate-locale.mjs fr --accept`, `pnpm i18n:check` vert.

## Tests

- `pnpm exec vitest run` sur ApprovalCard*, PendingApproval*, Sidebar*,
SidebarBot*, BotContextMenu*, PrimaryBot, `touch-actions`,
OptionsCardRow, `server/owner-approval.test.ts` : 46 fichiers, 461
tests, exit 0
- Nouveau `ApprovalCard.single-card.test.ts` (happy-dom) : ligne
d'attente seule, reçu qui s'ouvre sur la règle
- `Sidebar.simple-mode.test.ts` : le menu et le bouton « + » démarrent
un fil (`newTask`)
- `pnpm lint`, `pnpm typecheck`, `pnpm i18n:check` : exit 0 (hook
pre-push vert)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Jean-Christophe Proulx <jencryzthers@Jean-Christophes-Macbook-Pro.local>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants