Skip to content

feat(cage): add bot taint kind and untrusted botInput wrapper - #134

Merged
juancguerrerodev merged 1 commit into
DojoCodingLabs:mainfrom
santinofuentesAI:feat/bot-taint-kind
Nov 27, 2026
Merged

juancguerrerodev merged 1 commit into
DojoCodingLabs:mainfrom
santinofuentesAI:feat/bot-taint-kind

Conversation

@santinofuentesAI

Copy link
Copy Markdown
Contributor

What and why

Closes #85

Adds "bot" to TaintSource["kind"] and implements botInput(botId, text, id, at) so messages from another bot enter turns as untrusted <untrusted source="bot:..." seal="..."> data and taint the session in the cage.

  • packages/core/src/types.ts: adds "bot" to TaintSource["kind"].
  • packages/agent/src/untrusted.ts & packages/agent/test/untrusted.test.ts: adds botInput(), sanitizing botId against source="..." attribute breakout and verifying closing/opening tag forgery fails.
  • packages/agent/src/loop.ts, packages/runtime/src/hermit.ts, packages/night/src/act.ts: adds "bot" wording to TAINT_WORDS, SCREEN_TAINT_WARNING, and TAINT_WARNING, leaving OTHERS_WORDS unchanged (["messages_read", "mail_read"]).
  • packages/copy/locales/en.json & es-419.json: adds HM-APPR-01.taintFrom.bot in both locales.
  • packages/cage/test/modes.test.ts & policy.test.ts: verifies a "bot"-tainted session never treats links or searches from another bot as the user's own words, and denies spend / credential in every mode even with configurable rules opened (allowAll).

Vision fit

Serves Principle 3 ("The model proposes. Code decides": another bot's text is untrusted data, never the user's words) and Principle 5 ("Spanish and English, first-class": adds matching approval-sheet copy in both es-419 and en).

Non-negotiables

  • This keeps every non-negotiable in AGENTS.md as it is.
  • Or it changes one, and this is the accepted RFC: #

Checklist

  • It closes one issue, linked above, or it's a small fix (a typo, a broken link, a wrong comment). A feature has an accepted proposal.
  • I wrote the failing test first. It fails without this change and passes with it.
  • These pass: pnpm check:privacy, pnpm typecheck, pnpm lint, pnpm test and node scripts/guard/check.mjs --patterns scripts/guard/patterns.txt.
  • No new network call, telemetry, analytics, ads or crash reporting. (A new request in an app adapter is explained below, with its host, skill and risk.)
  • No new dependency, or the reason for each one is below.
  • Every UI string is in packages/copy, in es-419 and en, with matching keys and placeholders, and no em or en dashes.
  • Tests, fixtures and screenshots use made-up data only.

Model path

  • This doesn't touch the model path: packages/model, agent, skills or eval, the prompt, the router, tool descriptions, normalizers, examples or the model file.
  • It does. The eval numbers from before and after are below, run as docs/evals.md says. No held-out case was tuned on.

This touches packages/agent (loop.ts and untrusted.ts), though no prompt, router, tool description, normalizer, or model file changed. mac-eval.ts and mac-eval.ts --set va were NOT run locally because llama-server and Node 24 are not installed on this machine; opened as a draft until those before/after eval numbers are attached.

Screenshots

  • No UI change.
  • UI change. Each changed screen is below, in both themes and both languages, with made-up data.

Note: apps/mobile/src/approval-view.ts already resolves HM-APPR-01.taintFrom.<kind> dynamically, and apps/mobile/src/approval-view.test.ts passes with "bot".

New dependencies and network calls

n/a

AI agents

  • No AI agent wrote any part of this.
  • An AI agent helped. Which one, and what it did: Antigravity wrote the tests and implementation, ran all five local gates against origin/main (4ed90aa), and drafted this PR description.
  • I read and ran everything in this pull request, and I can explain it.

@dbejarano820 dbejarano820 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, Santino. This is a good start and it follows #85 closely. The copy matches the issue's table word for word in both locales, OTHERS_WORDS stays messages and mail, every wording table falls back to inbound_message, and the hard-limit tests run against an allow-all rule set in every mode, which is the evidence we ask for near the cage. A bot taint is exactly as strict as the existing kinds, and no mode is loosened, so no RFC is needed. I ran every gate locally on 874c00e and they all pass.

Since it's a draft, here's what it needs before it's ready:

  1. Eval numbers. This touches packages/agent, so the issue's Done when needs the first-win set and the VA set, before and after, with the same model file and settings (the two mac-eval.ts commands in the issue). Thanks for saying plainly they weren't run. If you can't get llama-server and Node 24 running, say so in the issue and a maintainer can run them.
  2. The "I read and ran everything in this pull request, and I can explain it" box needs checking once that's true, as with #133.

Notes, not blocking:

  • packages/cage/test/modes.test.ts:221, :260 and packages/cage/test/policy.test.ts:67: good tests to keep. With the source reverted they still pass at runtime and fail only at typecheck, because decide() treats any taint the same way whatever its kind. That's the behavior we want, so they're regression guards against a future kind-specific exception rather than tests that fail first. A line in the PR body saying so would be enough.
  • Nothing notices a missing HM-APPR-01.taintFrom.bot: the copy test passes without it. A small test that every TaintSource["kind"] has a taintFrom key in both locales would catch the next new kind too.
  • packages/agent/src/untrusted.ts:22: botInput(botId, text, id, at) takes three strings in a row, which are easy to swap. An options object ({ botId, text, seal, at }) would make future bus code harder to get wrong. Your call.
  • packages/agent/src/untrusted.ts:26: the wrapper uses the cleaned safeId while ref keeps the raw botId. That looks intended; a short comment would stop someone from "fixing" it.

I also checked that this merges cleanly with #133. Thanks!

@juancguerrerodev

Copy link
Copy Markdown
Contributor

I'm running the before and after evals for this on the Mac lab now, as #85 asks: the first-win set and the VA set, with the shipped profile botpsy-q4-native-think256. I'll post the numbers here and merge if they hold. 🦀

@juancguerrerodev

Copy link
Copy Markdown
Contributor

Before and after on the Mac lab (docs/evals.md), as #85 asks: same model file, same server, and this pull request's commit applied on the same main.

Set Before After Model file and settings
First-win, core 40 40/40 (es 20, en 20) 40/40 (es 20, en 20) BotPsy-0.8B Q4_K_M, SHA-256 482db2df…; llama-server -c 8192 -np 1 -t 4 --cache-ram 0; profile botpsy-q4-native-think256
VA, 124 122/124 (es 61, en 61) 122/124 (es 61, en 61) same

The same two VA cases miss in both runs (es-mem-8, en-msg-1), and the model saw the same prompts: 21,158 and 53,265 prompt tokens, the same cache reuse and the same number of calls before and after. The core run's median time differs (3.9 s before, 12.4 s after) only because the shared Mac was busy during the second run. The scores hold, so I'm merging it. Thanks! 🦀

@juancguerrerodev
juancguerrerodev marked this pull request as ready for review November 27, 2026 20:27
@juancguerrerodev
juancguerrerodev self-requested a review as a code owner November 27, 2026 20:27
…dingLabs#85)

Signed-off-by: Santino Fuentes <santinofuentesAI@users.noreply.github.com>
@juancguerrerodev
juancguerrerodev merged commit aca734a into DojoCodingLabs:main Nov 27, 2026
3 checks passed
@juancguerrerodev

Copy link
Copy Markdown
Contributor

Merged. One note so nothing surprises you: #135 had changed HM-APPR-01.approve to Approve with {biometric} on main, right below where you added HM-APPR-01.taintFrom.bot, so the rebase conflicted in both locale files. I kept main's new button text and your new key, in en and es-419; everything else is exactly as you wrote it. 🦀

@santinofuentesAI

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed review @dbejarano820 and for running the Mac lab evals @juancguerrerodev! I followed up on your review notes in two small PRs:

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.

Bots: add the bot taint kind for another bot's words

3 participants