Skip to content

M2 Boards + redaction (v0.3.0 milestone 2): agents talk and divide work through Tachyon; what they read has known secret shapes redacted, the human's view untouched - #5

Open
ayushap18 wants to merge 3 commits into
mainfrom
m2-boards

Conversation

@ayushap18

Copy link
Copy Markdown
Owner

Milestone 2 of the v0.3.0 plan, on top of #4 (M1). Base is m1-identity; GitHub retargets to main when #4 merges.

244 backend tests (was 211) · 55 frontend · zero warnings · redaction corpus 33 positives / 23 negatives / 0 wrong. agent.rs still has zero changed lines vs main; pty_write_internal still exactly 3 callers (coord.rs is in GREPPED with 0).

What

  • coord.rs — the boards as a plain data structure: no AppHandle, no tauri::, no async, no statics (a source-grep test pins all four). Message ring 500 with exact missed; tasks 64 active / 256 total, ids monotonic, 4th claim refused, update only by the holder, cancel by holder or creator; every other caller gets the unknown-id answer.
  • tasks.json v1 (frozen): 0600, atomic, corrupt = Err with bytes untouched and the task verbs refusing rather than overwriting; a crashed holder's task reopens on load without burning a claim; a failed save rolls back and never acks.
  • Seven tools under the message scope: post_message, read_messages, list_agents, create_task, claim_task, update_task, list_tasks. Attribution from the bearer only (a smuggled from is ignored, tested); update_task has no assignee field; two racing claims → one winner; every change is on disk before the reply and announced once on the message board; every successful result carries unread. run_command takes an optional task_id with a 20-proposal budget per task, refused before the bar.
  • Limits: per-agent token buckets (60 msgs/min, 30 task changes/min, reads 4 burst / 2 per s) with retry_after_ms; serve caps handler threads at max(16, 4×agents) with a per-agent share so one agent cannot starve another; the 17th connection gets 503 without a thread.
  • redact() — shape scans, no regex crate — on the agent-facing path only: read_journal, get_context, read_messages, list_tasks, run_command's own result, hub_state titles. The human's journal, term_write, ⌘B and the approval bar are byte-identical (tested), and a call-site test pins exactly where redact( may appear. Rust and JS mirrors read the same corpus; npm run eval:redact is a CI step.

Found by the adversaries and fixed

  • Task titles/details/notes bypassed redaction and reached other agents and the webview raw → redacted on the way out; a 64-hex run in task text is refused outright (that is what a token looks like).
  • run_command's result and await_decision's replay were unredacted → redacted before the cut; keys glued to escape sequences (\n, %3D, (B, SGR) now count as word starts; more prefixes (ghs_ ghu_ ghr_ xoxa- xapp- ASIA).
  • One agent could hold the whole handler cap → per-agent share.
  • Pre-existing, predates M2: a local process that promised >1024 body bytes and never sent them stalled the accept thread forever — no token needed. refuse() now answers such a request on its own thread.

One M1 function changed

PropGuard::settle now frees the approval slot before the verdict is visible to waiters (it was the source of a rare spurious BUSY and a flaky test). The gate itself — agent_propose, MIN_REVIEW, decision_stands, agent_decide, enter_approves — is unchanged; the record is briefly live with no claim, which only makes the budget stricter.

Known limits (documented in danger-gate.md)

A key folded across lines, cut by the 8 KiB output cap, or split by shell quoting gets through; password: x header form is not a rule. No entropy scan — known shapes only. Nothing here has run against a real MCP client.

… named in the bar, and no client call ever waits on a human

The hub had ONE bearer token and no identity, so the approval bar could only
say "external agent"; and run_command blocked the client's HTTP call until the
human pressed Enter — Codex and Cursor time out at ~60 s, so two of the three
target agents could not use the hub at all.

REGISTRY. AgentToken { name, token, scopes, worktree } with no Debug derive (a
derived one would put the token into panic messages). Scopes read | journal |
propose | message; journal is deliberately not a default. TOOL_SCOPES is the
authorization table: a tool absent from it is unreachable by anyone. The legacy
single token migrates to an agent named "default" — pure, idempotent, no read
path ever writes; downgrade fails closed (an old binary sees token:"" and
autostart refuses). resolve_bearer folds over every agent with no early exit
and refuses anything that is not 64 lowercase hex. A revoke is visible on the
next request.

IDENTITY. From the bearer only; no tool takes from/as/agent_id. A caller may act
only on its own proposals, and a foreign id answers exactly like an unknown id.
Names are [a-z0-9][a-z0-9_-]{0,31}; reserved words and an adversarial table
(bidi override, ·, whitespace, 33 chars, "run?") are refused by test, because
the name is rendered in the approval bar and must not be able to forge it. The
bar reads "codex · run? ⌘⏎ approve · esc deny"; an external proposal with an
empty agent is not approvable by any key.

ASYNC PROPOSALS. run_command { command, wait_ms } returns within a clamped 25 s
with today's result or a proposal_id; await_decision polls, idempotent, pending
on expiry. There is NO approval timeout: a shown proposal waits as long as the
human takes. The proposal record owns the AgentRunGuard for exactly its
lifetime, released at every terminal state including a panic path; an invariant
test pins PROPOSALS non-terminal <=> AgentState.running. Store bounded at 64.
Abuse limits: 30 s global deny cooldown, 1 pending per agent, 4 total, and a
refusal never emits agent-propose.

Also: a read-only multi-line command block above the bar so a long proposal is
readable in full (closes a documented danger-gate limitation); hub_state, a
read-only IPC command tested to contain no 64-hex substring; protocol hygiene
(2025-11-25, MCP-Protocol-Version, no Mcp-Session-Id); client handshake replays.

Found by the adversarial pass and fixed: initialize disclosed run_command to
every caller regardless of scope; the "chord rule byte-identical" test matched
its own source line and could not fail; a denial cooldown could be outrun by a
caller that read the budget before the Esc landed; the four-surface drift test
ignored descriptions.

agent.rs: zero changed lines. enter_approves, agent_propose, agent_decide,
decision_stands, MIN_REVIEW byte-identical. pty_write_internal: 3 callers, the
write still lexically after the approval check.

183 -> 211 backend tests, 49 -> 55 frontend.
…nd what they read has known secret shapes redacted while the human's view stays byte-identical

Agents that share the shell had no way to talk to each other or divide work,
and everything an agent read from the terminal came back raw — including any
key the human ever echoed.

COORD. src-tauri/src/coord.rs holds the boards as a plain data structure: no
AppHandle, no tauri::, no async, no statics — a source-grep test pins all four,
and the file joins GREPPED with zero pty_write_internal calls. Message ring 500
with a monotonic seq and an exact `missed` for a cursor older than the ring.
Tasks 64 active / 256 total, oldest terminal evicted, ids never reused; open →
claimed → done | failed | cancelled; the 4th claim refused; update by the
holder, cancel by holder or creator; every other caller gets the literal
unknown-id answer. One validator for every text field (control, bidi, empty,
length caps).

TASKS.JSON v1, frozen: read_config/write_config semantics (0600, atomic,
corrupt = Err with bytes untouched). A file that will not load leaves the board
broken — verbs refuse, nothing overwrites it. A crashed holder's task reopens
on load without burning a claim. A failed save rolls the change back and never
acks.

TOOLS under the message scope: post_message, read_messages, list_agents,
create_task, claim_task, update_task, list_tasks. Attribution from the bearer
only — a smuggled `from` is ignored (tested); update_task's schema has no
assignee field; two racing claims → exactly one winner; every board change is
on disk before the reply and announced once on the message board; every
successful tool result carries `unread`. run_command takes an optional task_id
with a 20-proposal budget per task, refused before the bar. parse_text_arg is
lifted from parse_run_args so every string-taking tool shares its refusals.

LIMITS. Per-agent token buckets: 60 messages/min, 30 task changes/min, reads a
burst of 4 refilled at 2/s — isError with retry_after_ms. serve() caps handler
threads at max(16, 4 × agents) with a per-agent share so one agent cannot
starve another; the 17th connection gets 503 without a thread.

REDACT. lib.rs redact(): shape scans, no regex crate — sk-/sk-ant-/gsk_/ghp_/
gho_/ghs_/ghu_/ghr_/github_pat_/xox[bpa]-/xapp-/AKIA/ASIA/AIza/JWT/PEM blocks/
Bearer/Authorization/URL userinfo/password=/token=/secret=/api_key= and their
_-suffixed names. Applied on the agent-facing path only: read_journal,
get_context, read_messages, list_tasks, run_command's own result, hub_state
titles. The human's journal, term_write, ⌘B and the approval bar are
byte-identical (tested); a call-site test pins exactly where redact( may
appear. evals/redaction-corpus.json is read by both the Rust test and the JS
mirror (npm run eval:redact, now a CI step), so the two cannot drift.

Found by the adversarial pass and fixed: task text bypassed redaction and
reached agents and the webview raw; run_command's result and await_decision's
replay were unredacted; keys glued to escape sequences (\n, %3D, (B, SGR)
slipped the word-boundary check; one agent could hold the whole handler cap.
Predating M2: a local process that promised more than 1024 body bytes and never
sent them stalled the accept thread forever, with no token — refuse() now
answers such a request on its own thread.

One M1 function changed: PropGuard::settle frees the approval slot before the
verdict is visible to waiters, which was the source of a rare spurious BUSY and
a flaky test. The gate — agent_propose, MIN_REVIEW, decision_stands,
agent_decide(bool), enter_approves — is unchanged; agent.rs has zero changed
lines; pty_write_internal has exactly 3 callers.

Known limits, documented: a key folded across lines, cut by the 8 KiB output
cap, or split by shell quoting gets through; no entropy scan.

211 -> 244 backend tests, 55 frontend, 0 warnings.
@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 243b15bc-d32b-4db5-bc72-5cce58bcd232


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ayushap18
ayushap18 changed the base branch from m1-identity to main September 23, 2026 10:42
@qodo-code-review

qodo-code-review Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Add agent coordination boards and agent-only secret redaction

✨ Enhancement 🐞 Bug fix 🧪 Tests 📝 Documentation ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Adds scoped per-agent MCP identities, asynchronous proposals, and protected handler concurrency.
• Introduces bounded message/task boards with atomic persistence, ownership rules, and proposal
 budgets.
• Redacts known credentials from agent outputs while preserving the human terminal view.
Diagram

graph TD
  A["MCP Agent"] -->|"Bearer request"| B["Scoped Gateway"] -->|"run command"| E["Proposal Store"] --> F["Approval UI"] -->|"approved command"| G["Live PTY"] --> H["Agent Redaction"] -->|"safe result"| A
  B -->|"message tools"| C["Shared Boards"] -->|"atomic save"| D[("tasks.json")]
  C -->|"outbound text"| H
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Use SQLite for coordination state
  • ➕ Provides transactional persistence for tasks and messages
  • ➕ Could support richer querying and durable message history
  • ➕ Avoids whole-file rewrites as the board grows
  • ➖ Adds schema migration and dependency complexity
  • ➖ Exceeds the needs of tightly bounded local boards
  • ➖ Makes corruption recovery and deployment behavior less transparent
2. Adopt a secret-scanning library
  • ➕ May cover more credential providers and evolving token formats
  • ➕ Reduces maintenance of custom shape detection
  • ➕ Could add entropy-based detection sooner
  • ➖ May increase binary size and runtime cost
  • ➖ False-positive behavior may be harder to control byte-for-byte
  • ➖ Rust and JavaScript evaluation behavior could become harder to keep identical
3. Move HTTP handling to an async server
  • ➕ Avoids one operating-system thread per admitted request
  • ➕ Offers stronger primitives for cancellation and connection timeouts
  • ➕ Could simplify future streaming or long-polling features
  • ➖ Requires a significant transport-layer rewrite
  • ➖ Introduces additional runtime integration risk with Tauri
  • ➖ The current quotas already bound the blocking server's resource usage

Recommendation: Keep the PR's bounded in-process boards, atomic JSON persistence, custom deterministic redaction, and capped blocking server for this milestone. These choices minimize dependencies and make security invariants directly testable; SQLite, a maintained scanner, or an async transport become worthwhile only if coordination volume, redaction coverage, or connection scale grows beyond the explicit bounds.

Files changed (14) +5333 / -285

Enhancement (6) +4929 / -223
coord.rsImplement bounded message and persistent task boards +856/-0

Implement bounded message and persistent task boards

• Introduces a runtime-independent coordination model with attributed messages, exact missed-message accounting, task ownership, claim and proposal budgets, and bounded retention. Task mutations use versioned atomic persistence with rollback, corruption protection, restart recovery, and concurrency stress coverage.

src-tauri/src/coord.rs

lib.rsAdd agent-facing credential redaction and hub wiring +280/-8

Add agent-facing credential redaction and hub wiring

• Adds a deterministic scanner for recognized credential shapes and corpus tests that pin its behavior and permitted call sites. Registers coordination and hub-state support while extending slash-command help for agent management.

src-tauri/src/lib.rs

mcp_server.rsBuild the scoped multi-agent coordination hub +3449/-193

Build the scoped multi-agent coordination hub

• Reworks MCP authentication around per-agent tokens and scopes, adds asynchronous proposal polling, denial and task budgets, board tools, live revocation, and fair handler limits. Integrates agent-only redaction, task persistence, hub state, client-specific setup output, and extensive protocol, security, race, and stress tests.

src-tauri/src/mcp_server.rs

main.cssStyle a wrapped read-only proposal panel +26/-0

Style a wrapped read-only proposal panel

• Adds an upward-growing, scrollable proposal block that preserves command spacing and wraps long arguments so approvers can inspect the command beyond the input width.

ui/assets/main.css

ai_bar.rsName external requesters and show full proposals +205/-17

Name external requesters and show full proposals

• Displays the bearer-derived agent name and renders pending commands in a dedicated read-only block. Unidentified external proposals fail closed and cannot be approved, while agent names are loaded for command completion.

ui/src/ai_bar.rs

complete.rsComplete MCP agent-management commands +113/-5

Complete MCP agent-management commands

• Adds slash rows, grammar slots, and registered-name suggestions for agent add, list, show, and revoke commands. Tests keep completion text synchronized with backend help and prevent tokens or invalid identity fields from entering completion state.

ui/src/complete.rs

Tests (3) +198 / -1
redact.mjsAdd a JavaScript mirror of credential redaction +130/-0

Add a JavaScript mirror of credential redaction

• Implements the Rust redaction shape scanner in JavaScript and verifies exact positive and negative outcomes against the shared corpus. The evaluator exits unsuccessfully on any mismatch.

evals/redact.mjs

redaction-corpus.jsonDefine the shared credential-redaction specification +63/-0

Define the shared credential-redaction specification

• Adds positive cases for provider tokens, JWTs, private keys, authorization values, named secrets, and URL passwords. Negative cases protect hashes, prose, certificates, variables, and ordinary encoded data from false positives.

evals/redaction-corpus.json

theme.rsVerify proposal panel theme coverage +5/-1

Verify proposal panel theme coverage

• Extends theme tests to require the approval proposal panel to use themed colors, ensuring readable command text over the terminal.

ui/src/theme.rs

Documentation (3) +202 / -61
README.mdDocument per-agent MCP registration commands +11/-5

Document per-agent MCP registration commands

• Documents agent add, list, show, and revoke commands. Updates server setup and approval-bar guidance for named, scoped agent identities and asynchronous decisions.

README.md

architecture.mdDescribe scoped MCP coordination and asynchronous proposals +98/-23

Describe scoped MCP coordination and asynchronous proposals

• Expands the MCP server architecture with bearer-derived identities, scoped tools, proposal polling, coordination boards, rate limits, handler quotas, and agent-only redaction. Documents the versioned task store and migration from the legacy single-token configuration.

docs/architecture.md

danger-gate.mdExpand the MCP server threat model and safeguards +93/-33

Expand the MCP server threat model and safeguards

• Documents named requesters, denial cooldowns, task ownership, board trust boundaries, credential redaction, and remaining secret-detection limitations. It also clarifies proposal display limits and the asynchronous approval lifecycle.

docs/danger-gate.md

Other (2) +4 / -0
ci.ymlRun the JavaScript redaction corpus in CI +3/-0

Run the JavaScript redaction corpus in CI

• Adds the JavaScript mirror of the credential-redaction corpus to the CI evaluation steps, preventing drift from the Rust implementation.

.github/workflows/ci.yml

package.jsonExpose the redaction corpus evaluator +1/-0

Expose the redaction corpus evaluator

• Adds the 'eval:redact' npm script used locally and by CI.

package.json

@ayushap18 ayushap18 closed this Sep 23, 2026
@ayushap18 ayushap18 reopened this Sep 23, 2026
@qodo-code-review

qodo-code-review Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (9) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Users run commands they cannot inspect 🐞 Bug ⛨ Security
Description
proposal_block truncates built-in-agent proposals after 4096 characters while the approval handler
still authorizes the original full command. When a model returns a longer command, the user can
press Enter and execute shell content hidden behind the “rest runs unseen” notice.
Code

ui/src/ai_bar.rs[R113-116]

+fn proposal_block(text: &str) -> String {
+    match text.char_indices().nth(MAX_COMMAND_CHARS) {
+        None => text.to_string(),
+        Some((i, _)) => format!("{}\n… cut at {MAX_COMMAND_CHARS} characters — the rest runs unseen", &text[..i]),
Evidence
The new block renders only the first 4096 characters, but the built-in proposal path has no
equivalent backend length check and writes its complete command to the PTY after approval. The MCP
parser's limit therefore does not protect built-in-agent commands.

ui/src/ai_bar.rs[102-117]
ui/src/ai_bar.rs[597-605]
src-tauri/src/agent.rs[336-360]
src-tauri/src/mcp_server.rs[827-837]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The approval bar hides command content beyond 4096 characters but still allows the complete built-in-agent command to execute.

## Fix Focus Areas
- ui/src/ai_bar.rs[102-124]
- ui/src/ai_bar.rs[411-426]
- src-tauri/src/agent.rs[336-360]

## Recommended Fix
Enforce the same maximum before creating any built-in-agent proposal and refuse oversized commands, ensuring every executable character is visible in the approval block.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Busy attempts exhaust task budgets 🐞 Bug ≡ Correctness
Description
call_tool commits charge_proposal before backend.run_command knows whether open_gate can
claim the terminal approval gate. A missing or unready terminal, a busy approval slot, or the second
proposal-budget check can reject the request before any approval record is created, allowing
repeated attempts to consume all 20 task allowances without presenting a proposal to the user.
Code

src-tauri/src/mcp_server.rs[R1119-1122]

+            if let Some(id) = task {
+                backend.board().lock().unwrap_or_else(|e| e.into_inner()).charge_proposal(&caller.name, &id)?;
+            }
+            backend.run_command(caller, &cmd, wait)
Evidence
The dispatch path commits the persisted task counter before invoking the backend, while open_gate
can still return on terminal-not-ready, busy approval-slot, or second budget-check paths before
proposals::propose creates an approval record. There is no refund path for that committed board
mutation, and the changed comment explicitly notes that a busy refusal currently spends quota.

src-tauri/src/mcp_server.rs[1113-1122]
src-tauri/src/mcp_server.rs[1484-1512]
src-tauri/src/coord.rs[258-273]
src-tauri/src/agent.rs[180-183]
src-tauri/src/mcp_server.rs[1106-1122]
src-tauri/src/mcp_server.rs[1484-1511]
src-tauri/src/coord.rs[258-274]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A task's proposal allowance is permanently charged before `run_command` knows whether it can open the approval gate and create an approval proposal. A missing or unready terminal, busy approval slot, or failed second budget check can therefore exhaust the task budget without presenting anything to the user.

## Fix Focus Areas
- src-tauri/src/mcp_server.rs[1106-1123]
- src-tauri/src/mcp_server.rs[1484-1512]
- src-tauri/src/coord.rs[255-274]

## Recommended Fix
Move the per-task charge into the successful gate-acquisition and proposal-creation transaction, after terminal readiness, approval-slot, and proposal-budget checks pass. Alternatively, add a guaranteed rollback for every `run_command` failure before a proposal record is created; keep the board mutation atomic and ensure only an actually created proposal consumes one task credit.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. New tokens inherit revoked proposals 🐞 Bug ⛨ Security
Description
proposals::forget retains every live proposal and proposal ownership is represented only by the
reusable agent name. If that name is revoked and re-added before or after the old proposal settles,
the replacement token can poll the predictable old identifier and receive the former token holder's
command result.
Code

src-tauri/src/mcp_server.rs[R409-410]

+    pub(super) fn forget(agent: &str) {
+        store().retain(|p| p.agent != agent || !p.state.terminal());
Evidence
Revocation removes terminal records only at that instant, while a retained live record later becomes
a terminal record under the same name. Proposal lookup compares only sequential ID and name, and
registration explicitly allows a revoked name to be created again with a new token.

src-tauri/src/mcp_server.rs[406-416]
src-tauri/src/mcp_server.rs[431-470]
src-tauri/src/mcp_server.rs[1855-1867]
src-tauri/src/mcp_server.rs[1938-1948]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Live proposals survive revocation and are authorized only by a reusable agent name, allowing a replacement token to retrieve an earlier token holder's proposal result.

## Fix Focus Areas
- src-tauri/src/mcp_server.rs[406-416]
- src-tauri/src/mcp_server.rs[431-470]
- src-tauri/src/mcp_server.rs[1855-1867]

## Recommended Fix
Give each registration an immutable generation identifier and store it on callers and proposals, then match both name and generation during polling; alternatively cancel and invalidate all proposals during revocation before allowing that name to be re-added.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View action required (2)
4. Invalid requests exhaust server threads 🐞 Bug ⛨ Security
Description
refuse spawns an uncapped operating-system thread for every rejected request whose body exceeds
1024 bytes or carries an Expect header. An unauthenticated local client can hold those request
bodies open indefinitely, bypassing handler_cap and exhausting process or system resources.
Code

src-tauri/src/mcp_server.rs[R1322-1327]

+fn refuse(rq: tiny_http::Request, status: u16) {
+    let buffered = rq.body_length().is_none_or(|n| n <= 1024) && !rq.headers().iter().any(|h| h.field.equiv("Expect"));
+    if buffered {
+        respond(rq, status, None);
+    } else {
+        std::thread::spawn(move || respond(rq, status, None));
Evidence
The refusal path explicitly creates a detached thread for requests likely to block while being
drained, whereas the global and per-agent counters are only incremented later for authenticated
handlers. Invalid credentials therefore reach an unbounded thread-creation path without consuming
any configured slot.

src-tauri/src/mcp_server.rs[1312-1328]
src-tauri/src/mcp_server.rs[1331-1347]
src-tauri/src/mcp_server.rs[1366-1399]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Rejected large or `Expect` requests spawn uncapped threads that can remain blocked while an unauthenticated client holds the body open, bypassing the server's handler limit.

## Fix Focus Areas
- src-tauri/src/mcp_server.rs[1312-1328]
- src-tauri/src/mcp_server.rs[1331-1399]

## Recommended Fix
Route refusal work through a bounded pool or semaphore included in the global connection cap, and impose a finite read/drain deadline so abandoned request bodies cannot retain threads indefinitely.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. Quoted secrets leak after escapes 🐞 Bug ⛨ Security
Description
The quoted branch in secret_at stops at every quote byte, including a quote preceded by a
backslash. A named secret such as password="abc\"def" is replaced only through the escaped quote,
leaving the remainder visible on agent-facing read paths.
Code

src-tauri/src/lib.rs[R1813-1815]

+    let end = match quote {
+        Some(q) => run_end(b, i, |c| c != q && c != b'\n'),
+        None => run_end(b, i, |c| !c.is_ascii_whitespace() && !b"&;\"'`".contains(&c)),
Evidence
The parser recognizes quoted values after a secret-shaped name, but its scan condition has no escape
handling. Once that early endpoint is returned, redact emits a replacement and resumes after it,
leaving the rest of the quoted value untouched.

src-tauri/src/lib.rs[1799-1817]
src-tauri/src/lib.rs[1635-1646]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Quoted `name=value` secret scanning treats an escaped quote as the closing delimiter. The redactor therefore emits part of a secret after an escaped quote instead of replacing the complete quoted value.

## Fix Focus Areas
- src-tauri/src/lib.rs[1799-1817]
- src-tauri/src/lib.rs[1635-1646]

## Recommended Fix
Replace the quoted-value `run_end` predicate with a scanner that skips a quote when it is escaped by an odd run of preceding backslashes, and terminates only at an unescaped matching quote or newline. Add corpus cases for escaped double- and single-quoted secret values.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

6. Corrupt task files bypass board limits 🐞 Bug ☼ Reliability
Description
Board::load_from installs deserialized version-one task records directly and only reopens claimed
entries, without validating canonical unique IDs, task text, participant names, holder/state
consistency, claim counters, or active and total task limits. Because Task supplies defaults for
missing fields, a syntactically valid malformed file can expose duplicate, empty, unreachable,
over-limit, or control-bearing records and cause later board mutations to silently evict tasks
rather than reject the corrupt board.
Code

src-tauri/src/coord.rs[R406-414]

+        let mut board = Board { tasks: file.tasks, ..Board::default() };
+        board.reopen_claimed();
+        // Ids are never reused, so the counter resumes above the highest one on disk.
+        board.last_task = board
+            .tasks
+            .iter()
+            .filter_map(|t| t.id.strip_prefix("t_").and_then(|n| n.parse::<u64>().ok()))
+            .max()
+            .unwrap_or(0);
Evidence
Task applies defaults to missing fields, and load_from assigns the deserialized task vector
before merely reopening claimed tasks and deriving an ID counter, without invoking the validators,
capacity checks, or normal state transitions used by task creation and other mutations. Listing then
exposes those records directly, while subsequent creation only observes that an already-invalid
board remains above its active ceiling, demonstrating that malformed on-disk records bypass runtime
invariants.

src-tauri/src/coord.rs[124-151]
src-tauri/src/coord.rs[276-364]
src-tauri/src/coord.rs[395-415]
src-tauri/src/coord.rs[276-313]
src-tauri/src/mcp_server.rs[1026-1032]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The task-file loader accepts every serde-deserializable version-1 record and restores it into the live board, bypassing the field, identity, state, claim-counter, and capacity invariants enforced for newly created tasks. Syntactically valid files can therefore place an over-limit or structurally invalid board into service.

## Fix Focus Areas
- src-tauri/src/coord.rs[124-168]
- src-tauri/src/coord.rs[276-364]
- src-tauri/src/coord.rs[395-415]

## Recommended Fix
Validate every deserialized task and the complete collection before assigning the tasks to or constructing `Board`: enforce field-length and character rules for task text and participant names, canonical unique IDs, valid holder/state combinations, valid claim counters, and active and total capacity limits. If any invariant fails, return a load error, mark the board broken, and leave the task file unchanged.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


7. Redaction corrupts working paths 🐞 Bug ≡ Correctness
Description
get_context applies redact indiscriminately to every serialized string field, including the
current working directory. A legitimate directory such as /tmp/password=foo is returned as
/tmp/password=[redacted:password], causing agents to construct commands against a path that does
not exist.
Code

src-tauri/src/mcp_server.rs[R1629-1632]

+        for field in v.as_object_mut().into_iter().flat_map(|o| o.values_mut()) {
+            if let Some(text) = field.as_str() {
+                *field = redact(text).into();
+            }
Evidence
The context loop processes every string with the assignment-oriented redactor, and ShellContext
includes cwd. The redactor recognizes a password= suffix regardless of whether it appears in
shell output, prose, or a filesystem path.

src-tauri/src/mcp_server.rs[1624-1635]
src-tauri/src/lib.rs[31-38]
src-tauri/src/lib.rs[1781-1817]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Shape-based redaction changes legitimate current-working-directory values, making the context response inaccurate and unusable for path construction.

## Fix Focus Areas
- src-tauri/src/mcp_server.rs[1624-1635]
- src-tauri/src/lib.rs[1781-1817]

## Recommended Fix
Apply field-aware redaction rather than scanning every context string uniformly; preserve structural path fields or redact only credential-shaped path components while retaining a usable canonical path value.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


8. Failed revokes erase proposal history 🐞 Bug ☼ Reliability
Description
revoke_agent deletes terminal proposal records and last-seen state before run_agent calls
persist to write and publish the modified registry. If write_config fails, the agent remains
registered with its old token authenticated while its pending, previously collectable proposal
results and decision-polling state have already been discarded.
Code

src-tauri/src/mcp_server.rs[R1945-1947]

+        AgentCmd::Revoke(name) => {
+            revoke_agent(&mut cfg, &name)?;
+            persist(&path, &cfg)?;
Evidence
The revoke helper performs process-global proposal and seen-state cleanup before its caller invokes
persist, while persist updates the live roster only after the fallible write_config succeeds.
Therefore, a write failure leaves the authenticated roster and old bearer token intact but removes
the ancillary proposal records and seen entries needed for later collection and decision polling.

src-tauri/src/mcp_server.rs[1855-1867]
src-tauri/src/mcp_server.rs[1945-1948]
src-tauri/src/mcp_server.rs[1416-1422]
src-tauri/src/lib.rs[1160-1181]
src-tauri/src/mcp_server.rs[1416-1421]
src-tauri/src/mcp_server.rs[690-705]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Revocation performs destructive in-memory cleanup before the roster update is durably saved. A failed registry write leaves the old token active while prematurely deleting its pending proposal results and last-seen state, making the failed revoke partially observable.

## Fix Focus Areas
- src-tauri/src/mcp_server.rs[1855-1867]
- src-tauri/src/mcp_server.rs[1945-1948]
- src-tauri/src/mcp_server.rs[1416-1422]

## Recommended Fix
Separate registry mutation, validation, and persistence from in-memory revocation cleanup. Persist and publish the updated roster first, then remove terminal proposal records and seen state only after persistence succeeds; if any write or persistence step fails, preserve or restore all existing in-memory state.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View review recommended (1)
9. Tasks can target nonexistent agents 🐞 Bug ≡ Correctness
Description
create_task parses and stores assignee without checking the live agent registry, unlike
post_message recipient handling. A typo or stale name is accepted and persisted as the suggested
owner even though list_agents cannot return anyone matching it.
Code

src-tauri/src/mcp_server.rs[R1006-1009]

+    let title = parse_text_arg(args, "title", coord::MAX_TITLE_CHARS)?;
+    let detail = parse_opt_text_arg(args, "detail", coord::MAX_DETAIL_CHARS)?;
+    let assignee = parse_opt_text_arg(args, "assignee", coord::MAX_NAME_CHARS)?;
+    task_verb(backend, caller, |b| b.create_task(&caller.name, &title, detail.as_deref(), assignee.as_deref()))
Evidence
The task path only performs text validation before forwarding the value to Board, which stores it
without registry access. The neighboring message path demonstrates that a live-registry check
already exists and is required when an argument is documented as a registered agent name.

src-tauri/src/mcp_server.rs[892-909]
src-tauri/src/mcp_server.rs[1005-1010]
src-tauri/src/coord.rs[276-305]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Task creation accepts arbitrary syntactically valid assignee names even though the API describes the field as a registered agent returned by `list_agents`.

## Fix Focus Areas
- src-tauri/src/mcp_server.rs[892-909]
- src-tauri/src/mcp_server.rs[1005-1010]
- src-tauri/src/coord.rs[276-305]

## Recommended Fix
Check a supplied assignee against the live registry before committing the task, using the same validation semantics as addressed messages and returning a clear tool error for unknown names.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
Review mode: 🧠 Deep: This is a high-density, security-sensitive change spanning concurrency, persistence, authorization, redaction, rate limiting, and many independent logic paths where redundant review could catch subtle defects.

Grey Divider

Tip of the day
💡 Did you know, you can keep summaries lean with Finding overflow, which tucks the rest behind 'View more'

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment on lines +1322 to +1327
fn refuse(rq: tiny_http::Request, status: u16) {
let buffered = rq.body_length().is_none_or(|n| n <= 1024) && !rq.headers().iter().any(|h| h.field.equiv("Expect"));
if buffered {
respond(rq, status, None);
} else {
std::thread::spawn(move || respond(rq, status, None));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Invalid requests exhaust server threads 🐞 Bug ⛨ Security

refuse spawns an uncapped operating-system thread for every rejected request whose body exceeds
1024 bytes or carries an Expect header. An unauthenticated local client can hold those request
bodies open indefinitely, bypassing handler_cap and exhausting process or system resources.
Agent Prompt
## Issue description
Rejected large or `Expect` requests spawn uncapped threads that can remain blocked while an unauthenticated client holds the body open, bypassing the server's handler limit.

## Fix Focus Areas
- src-tauri/src/mcp_server.rs[1312-1328]
- src-tauri/src/mcp_server.rs[1331-1399]

## Recommended Fix
Route refusal work through a bounded pool or semaphore included in the global connection cap, and impose a finite read/drain deadline so abandoned request bodies cannot retain threads indefinitely.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment thread ui/src/ai_bar.rs
Comment on lines +113 to +116
fn proposal_block(text: &str) -> String {
match text.char_indices().nth(MAX_COMMAND_CHARS) {
None => text.to_string(),
Some((i, _)) => format!("{}\n… cut at {MAX_COMMAND_CHARS} characters — the rest runs unseen", &text[..i]),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

2. Users run commands they cannot inspect 🐞 Bug ⛨ Security

proposal_block truncates built-in-agent proposals after 4096 characters while the approval handler
still authorizes the original full command. When a model returns a longer command, the user can
press Enter and execute shell content hidden behind the “rest runs unseen” notice.
Agent Prompt
## Issue description
The approval bar hides command content beyond 4096 characters but still allows the complete built-in-agent command to execute.

## Fix Focus Areas
- ui/src/ai_bar.rs[102-124]
- ui/src/ai_bar.rs[411-426]
- src-tauri/src/agent.rs[336-360]

## Recommended Fix
Enforce the same maximum before creating any built-in-agent proposal and refuse oversized commands, ensuring every executable character is visible in the approval block.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +1119 to +1122
if let Some(id) = task {
backend.board().lock().unwrap_or_else(|e| e.into_inner()).charge_proposal(&caller.name, &id)?;
}
backend.run_command(caller, &cmd, wait)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

3. Busy attempts exhaust task budgets 🐞 Bug ≡ Correctness

call_tool commits charge_proposal before backend.run_command knows whether open_gate can
claim the terminal approval gate. A missing or unready terminal, a busy approval slot, or the second
proposal-budget check can reject the request before any approval record is created, allowing
repeated attempts to consume all 20 task allowances without presenting a proposal to the user.
Agent Prompt
## Issue description
A task's proposal allowance is permanently charged before `run_command` knows whether it can open the approval gate and create an approval proposal. A missing or unready terminal, busy approval slot, or failed second budget check can therefore exhaust the task budget without presenting anything to the user.

## Fix Focus Areas
- src-tauri/src/mcp_server.rs[1106-1123]
- src-tauri/src/mcp_server.rs[1484-1512]
- src-tauri/src/coord.rs[255-274]

## Recommended Fix
Move the per-task charge into the successful gate-acquisition and proposal-creation transaction, after terminal readiness, approval-slot, and proposal-budget checks pass. Alternatively, add a guaranteed rollback for every `run_command` failure before a proposal record is created; keep the board mutation atomic and ensure only an actually created proposal consumes one task credit.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +409 to +410
pub(super) fn forget(agent: &str) {
store().retain(|p| p.agent != agent || !p.state.terminal());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

4. New tokens inherit revoked proposals 🐞 Bug ⛨ Security

proposals::forget retains every live proposal and proposal ownership is represented only by the
reusable agent name. If that name is revoked and re-added before or after the old proposal settles,
the replacement token can poll the predictable old identifier and receive the former token holder's
command result.
Agent Prompt
## Issue description
Live proposals survive revocation and are authorized only by a reusable agent name, allowing a replacement token to retrieve an earlier token holder's proposal result.

## Fix Focus Areas
- src-tauri/src/mcp_server.rs[406-416]
- src-tauri/src/mcp_server.rs[431-470]
- src-tauri/src/mcp_server.rs[1855-1867]

## Recommended Fix
Give each registration an immutable generation identifier and store it on callers and proposals, then match both name and generation during polling; alternatively cancel and invalidate all proposals during revocation before allowing that name to be re-added.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +1629 to +1632
for field in v.as_object_mut().into_iter().flat_map(|o| o.values_mut()) {
if let Some(text) = field.as_str() {
*field = redact(text).into();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

6. Redaction corrupts working paths 🐞 Bug ≡ Correctness

get_context applies redact indiscriminately to every serialized string field, including the
current working directory. A legitimate directory such as /tmp/password=foo is returned as
/tmp/password=[redacted:password], causing agents to construct commands against a path that does
not exist.
Agent Prompt
## Issue description
Shape-based redaction changes legitimate current-working-directory values, making the context response inaccurate and unusable for path construction.

## Fix Focus Areas
- src-tauri/src/mcp_server.rs[1624-1635]
- src-tauri/src/lib.rs[1781-1817]

## Recommended Fix
Apply field-aware redaction rather than scanning every context string uniformly; preserve structural path fields or redact only credential-shaped path components while retaining a usable canonical path value.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +1945 to +1947
AgentCmd::Revoke(name) => {
revoke_agent(&mut cfg, &name)?;
persist(&path, &cfg)?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

7. Failed revokes erase proposal history 🐞 Bug ☼ Reliability

revoke_agent deletes terminal proposal records and last-seen state before run_agent calls
persist to write and publish the modified registry. If write_config fails, the agent remains
registered with its old token authenticated while its pending, previously collectable proposal
results and decision-polling state have already been discarded.
Agent Prompt
## Issue description
Revocation performs destructive in-memory cleanup before the roster update is durably saved. A failed registry write leaves the old token active while prematurely deleting its pending proposal results and last-seen state, making the failed revoke partially observable.

## Fix Focus Areas
- src-tauri/src/mcp_server.rs[1855-1867]
- src-tauri/src/mcp_server.rs[1945-1948]
- src-tauri/src/mcp_server.rs[1416-1422]

## Recommended Fix
Separate registry mutation, validation, and persistence from in-memory revocation cleanup. Persist and publish the updated roster first, then remove terminal proposal records and seen state only after persistence succeeds; if any write or persistence step fails, preserve or restore all existing in-memory state.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +1006 to +1009
let title = parse_text_arg(args, "title", coord::MAX_TITLE_CHARS)?;
let detail = parse_opt_text_arg(args, "detail", coord::MAX_DETAIL_CHARS)?;
let assignee = parse_opt_text_arg(args, "assignee", coord::MAX_NAME_CHARS)?;
task_verb(backend, caller, |b| b.create_task(&caller.name, &title, detail.as_deref(), assignee.as_deref()))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

8. Tasks can target nonexistent agents 🐞 Bug ≡ Correctness

create_task parses and stores assignee without checking the live agent registry, unlike
post_message recipient handling. A typo or stale name is accepted and persisted as the suggested
owner even though list_agents cannot return anyone matching it.
Agent Prompt
## Issue description
Task creation accepts arbitrary syntactically valid assignee names even though the API describes the field as a registered agent returned by `list_agents`.

## Fix Focus Areas
- src-tauri/src/mcp_server.rs[892-909]
- src-tauri/src/mcp_server.rs[1005-1010]
- src-tauri/src/coord.rs[276-305]

## Recommended Fix
Check a supplied assignee against the live registry before committing the task, using the same validation semantics as addressed messages and returning a clear tool error for unknown names.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment thread src-tauri/src/lib.rs
Comment on lines +1813 to +1815
let end = match quote {
Some(q) => run_end(b, i, |c| c != q && c != b'\n'),
None => run_end(b, i, |c| !c.is_ascii_whitespace() && !b"&;\"'`".contains(&c)),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

5. Quoted secrets leak after escapes 🐞 Bug ⛨ Security

The quoted branch in secret_at stops at every quote byte, including a quote preceded by a
backslash. A named secret such as password="abc\"def" is replaced only through the escaped quote,
leaving the remainder visible on agent-facing read paths.
Agent Prompt
## Issue description
Quoted `name=value` secret scanning treats an escaped quote as the closing delimiter. The redactor therefore emits part of a secret after an escaped quote instead of replacing the complete quoted value.

## Fix Focus Areas
- src-tauri/src/lib.rs[1799-1817]
- src-tauri/src/lib.rs[1635-1646]

## Recommended Fix
Replace the quoted-value `run_end` predicate with a scanner that skips a quote when it is escaped by an odd run of preceding backslashes, and terminates only at an unescaped matching quote or newline. Add corpus cases for escaped double- and single-quoted secret values.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment thread src-tauri/src/coord.rs
Comment on lines +406 to +414
let mut board = Board { tasks: file.tasks, ..Board::default() };
board.reopen_claimed();
// Ids are never reused, so the counter resumes above the highest one on disk.
board.last_task = board
.tasks
.iter()
.filter_map(|t| t.id.strip_prefix("t_").and_then(|n| n.parse::<u64>().ok()))
.max()
.unwrap_or(0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

9. Corrupt task files bypass board limits 🐞 Bug ☼ Reliability

Board::load_from installs deserialized version-one task records directly and only reopens claimed
entries, without validating canonical unique IDs, task text, participant names, holder/state
consistency, claim counters, or active and total task limits. Because Task supplies defaults for
missing fields, a syntactically valid malformed file can expose duplicate, empty, unreachable,
over-limit, or control-bearing records and cause later board mutations to silently evict tasks
rather than reject the corrupt board.
Agent Prompt
## Issue description
The task-file loader accepts every serde-deserializable version-1 record and restores it into the live board, bypassing the field, identity, state, claim-counter, and capacity invariants enforced for newly created tasks. Syntactically valid files can therefore place an over-limit or structurally invalid board into service.

## Fix Focus Areas
- src-tauri/src/coord.rs[124-168]
- src-tauri/src/coord.rs[276-364]
- src-tauri/src/coord.rs[395-415]

## Recommended Fix
Validate every deserialized task and the complete collection before assigning the tasks to or constructing `Board`: enforce field-length and character rules for task text and participant names, canonical unique IDs, valid holder/state combinations, valid claim counters, and active and total capacity limits. If any invariant fails, return a load error, mark the board broken, and leave the task file unchanged.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

…trands most of them

CI's Ubuntu leg failed one_agent_holding_its_share_does_not_starve_another
("codex was never held to its share") and a rerun then hung in the backend
tests for the job's whole life. macOS passed every time. Reproduced in an
Ubuntu container: 2 of 7 runs failed.

Root cause is in tiny_http 0.12's TaskPool, not in Tachyon. `spawn` queues a
task onto "waiting" workers whenever waiting_tasks > 0, but a worker that has
been notified and not yet woken still counts as waiting, so a burst of
connections is queued onto the same handful of idle workers over and over.
Each worker wakes, pops ONE connection and runs it for the life of that
connection; every task past the first per worker sits in the queue until some
unrelated connection closes. A 40-line program against bare tiny_http on Linux
showed it: 17 connections opened at once, and in 14 of 20 rounds fewer reached
incoming_requests, as few as 4 (MIN_THREADS). Three MCP clients handshaking
together is exactly that burst; the maintained fork (tiny_http_dh) has the same
line.

The fix is one condition: spawn a thread when the queue already has a task per
waiting worker (`waiting_tasks <= queue.len()`), so a queued task always has a
distinct worker to wake. The crate is vendored at src-tauri/vendor/tiny_http —
the crates.io release plus that line, features/benches/examples/dev-deps
dropped, upstream's own lints allowed — and applied through [patch.crates-io].

a_burst_of_connections_all_reach_the_accept_loop pins it: 17 held connections,
all must reach the accept loop within 3 s, five rounds. On unpatched tiny_http
it fails on Linux in most runs; macOS wakes threads fast enough to hide it, so
the Ubuntu leg is the one that guards it. The formerly flaky test passed 9/9 on
Linux with the fix.

CI jobs get timeout-minutes: 20 so a hung test fails the job instead of sitting
on the 6 h default.
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