Skip to content

Card gate: Bot-sent jobs card their manager, not Steve - #3

Closed
neotechnet wants to merge 2 commits into
stack/installed-0.2.6from
feat/card-gate
Closed

neotechnet wants to merge 2 commits into
stack/installed-0.2.6from
feat/card-gate

Conversation

@neotechnet

Copy link
Copy Markdown
Owner

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_mode reviews.

  • ask_user in such a turn is refused with no question created; the refusal names the manager and asks for a DECISION block.
  • exit_plan_mode in such a turn is refused by a tool guard, with the same routing.
  • A Main Bot message carrying PLAN-APPROVED turns 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.
  • Unchanged: Main Bots, turns Steve typed, requests whose audience is the user, a deploy to production card (with or without (Recommended)), and any job whose text carries CARD-IT-YOURSELF.
  • Kill switch: DSH_CARD_GATE=off.
  • Each refusal and relayed approval is one JSON line in <home>/logs/card-gate.log (bot, manager, tool, title, time).

Base

stack/installed-0.2.6 = v0.2.6 plus the ds-bot@0.2.6.patch installed in the desktop profile, verified 78 of 78 files byte for byte against the installed package.

Tests

  • New 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 carries CARD-IT-YOURSELF (it would otherwise be refused, by design).
  • Whole suite: branch 1444 tests, 1430 pass, 12 fail, 2 skipped. Base 1433 tests, 1419 pass, 12 fail, 2 skipped. The same 12 fail on the base (bot-messages hand-back tests, group-work, client bundle): the installed patch carries source but not its tests or src/client.
  • Lint: exit 0 (0 errors).

Draft. Not for merge.

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.
@neotechnet
neotechnet marked this pull request as ready for review November 3, 2026 00:27
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T00:29:31.058797Z 0d69df2 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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.`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +102 to 104
relayPlanApproval(rt, { fromId, toId, agent, text })
if (steer) agent.steer(message)
else agent.followup(message)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +63 to +65
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')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@neotechnet
neotechnet marked this pull request as draft November 3, 2026 00:35
…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.
@neotechnet

Copy link
Copy Markdown
Owner Author

Superseded by #4: this change is carried in stack/installed-0.2.7 (21eff5d), installed in the live profile and proven on 2026-11-03. Head was 9889b96.

@neotechnet neotechnet closed this Nov 3, 2026
@neotechnet
neotechnet deleted the feat/card-gate branch November 3, 2026 21:54
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.

1 participant