Repository navigation
Card gate: Bot-sent jobs card their manager, not Steve - #3
neotechnet wants to merge 2 commits into
Conversation
In a turn another Bot opened, a Bot that is not a Main Bot can no longer show the user a question card or a plan review. ask_user is refused and exit_plan_mode is refused by a guard; both refusals name the sender and tell the Bot to send it a DECISION instead. Still allowed: Main Bots, turns the user typed, requests whose audience is the user, a 'deploy to production' card (the production guard reads only the runner's own transcript), and a job carrying CARD-IT-YOURSELF. A Main Bot message carrying PLAN-APPROVED turns plan mode off in the Bot it reaches (queued when a turn is open). DSH_CARD_GATE=off turns all of it off. Each refusal and relayed approval is one JSON line in <home>/logs/card-gate.log.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0d69df2110
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| export const cardRefusal = manager => `This job came from ${manager}. Do not card Steve: end your turn with a DECISION block for ${manager} (question, 2 to 4 options, the recommended one marked with its reason, Hold). ${manager} cards Steve and relays his answer.` | ||
|
|
||
| export const planRefusal = manager => `This job came from ${manager}. Do not open a plan review for Steve here: send the full plan to ${manager} as a DECISION (Approve plan (Recommended) / Change it / Hold). When ${manager} relays approval with ${PLAN_APPROVED}, plan mode turns off for you.` |
There was a problem hiding this comment.
Route plan approvals through a manager authorized to apply them
When a non-Main Bot delegates to another non-Main Bot, the recipient's plan review is blocked and this refusal promises that its manager can relay PLAN-APPROVED. However, relayPlanApproval explicitly ignores approvals from non-Main Bots. The unrestricted chat delegation path in tools.js permits this scenario, so following the refusal's instructions leaves the recipient in plan mode even after the manager obtains user approval. Route the decision through a Main Bot, or provide an authorized approval path for the actual manager.
Useful? React with 👍 / 👎.
| relayPlanApproval(rt, { fromId, toId, agent, text }) | ||
| if (steer) agent.steer(message) | ||
| else agent.followup(message) |
There was a problem hiding this comment.
Apply relayed approval when its message is consumed
If a Main Bot sends an approval with send_message(..., when: 'queue') while the recipient is working, this call changes plan mode before the approval message is queued with agent.followup. The current turn can therefore leave plan mode even though the approval belongs to work it will only read after that turn finishes; a pending mode change at the next step does not preserve the queue boundary either. Apply the approval when the corresponding message is consumed, so queued approvals cannot change the permissions of the currently running task.
Useful? React with 👍 / 👎.
| const texts = triggers.flatMap(({ info: item, text }) => { | ||
| const record = (state.exchanges ?? []).find(other => other.id === item?.exchangeId) | ||
| return [text, record?.text].filter(value => typeof value === 'string') |
There was a problem hiding this comment.
Preserve card-routing markers when messages become attachments
For jobs longer than MESSAGE_INLINE_MAX (20,000 characters), tools.js passes the result of attachLong to delivery: only the first 1,000 characters remain inline, and the rest becomes an attachment. Both strings inspected here then contain only that shortened representation, so a CARD-IT-YOURSELF instruction later in the job is silently ignored and the explicitly delegated question or plan review is refused. Preserve the routing flag from the original message before truncation, or inspect the complete attached job rather than only its preview.
Useful? React with 👍 / 👎.
…ith it off
Two faults kept Bots stuck in plan mode:
1. DSH's shipped presets (standard, ptc, cordis) pin plan mode on for every
new Session (defaultActive: true). DS Bot makes every Bot chat, group
Session and handoff part on `standard`, so each one started in plan mode.
2. Under a preset, plan mode lives in an isolated group (isolate.planMode),
so rt.ctx.get('planMode') found nothing and a relayed PLAN-APPROVED was a
silent no-op. The lookup now reads agentPresets.serviceFor(agent,
'planMode') first, as parts.js already does for compaction.
ensurePlanOff switches a Bot Session out of plan mode once (recorded in
state.planDefaultOff), on creation, on resume and on first delivery. A later
/plan in that chat stays on. A Bot with planMode 'on', or named in
<home>/plan-mode-keep.json, is left alone. DSH_PLAN_DEFAULT_OFF=off turns it
off. Every attempt is logged to card-gate.log with its outcome.
What
Card gate: in a turn another Bot opened (a hidden Bot-to-Bot turn), a Bot that is not a Main Bot no longer shows Steve a question card or a plan review. Measured 2026-11-02: 13 cards were raised by sub-agent Bots in manager-opened turns, 12 of them
exit_plan_modereviews.ask_userin such a turn is refused with no question created; the refusal names the manager and asks for a DECISION block.exit_plan_modein such a turn is refused by a tool guard, with the same routing.PLAN-APPROVEDturns plan mode off in the Bot it reaches (ctx.planMode.set(agent, false), queued when a turn is open). No effect when plan mode is not composed, or the sender is not a Main Bot.deploy to productioncard (with or without(Recommended)), and any job whose text carriesCARD-IT-YOURSELF.DSH_CARD_GATE=off.<home>/logs/card-gate.log(bot, manager, tool, title, time).Base
stack/installed-0.2.6=v0.2.6plus theds-bot@0.2.6.patchinstalled in the desktop profile, verified 78 of 78 files byte for byte against the installed package.Tests
test/card-gate.test.js: 11 cases, all pass; with the source change removed, 4 fail (the refusal and relay cases) and the 7 allow/no-op cases pass.test/questions.test.js: the hidden-turn dock case now carriesCARD-IT-YOURSELF(it would otherwise be refused, by design).src/client.Draft. Not for merge.