Repository navigation
Conversation
… 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.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 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. Comment |
PR Summary by QodoAdd agent coordination boards and agent-only secret redaction
AI Description
Diagram
High-Level Assessment
Files changed (14)
|
Code Review by Qodo
1. Users run commands they cannot inspect
|
| 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)); |
There was a problem hiding this comment.
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
| 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]), |
There was a problem hiding this comment.
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
| 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) |
There was a problem hiding this comment.
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
| pub(super) fn forget(agent: &str) { | ||
| store().retain(|p| p.agent != agent || !p.state.terminal()); |
There was a problem hiding this comment.
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
| 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(); | ||
| } |
There was a problem hiding this comment.
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
| AgentCmd::Revoke(name) => { | ||
| revoke_agent(&mut cfg, &name)?; | ||
| persist(&path, &cfg)?; |
There was a problem hiding this comment.
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
| 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())) |
There was a problem hiding this comment.
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
| 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)), |
There was a problem hiding this comment.
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
| 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); |
There was a problem hiding this comment.
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.
Milestone 2 of the v0.3.0 plan, on top of #4 (M1). Base is
m1-identity; GitHub retargets tomainwhen #4 merges.244 backend tests (was 211) · 55 frontend · zero warnings · redaction corpus 33 positives / 23 negatives / 0 wrong.
agent.rsstill has zero changed lines vs main;pty_write_internalstill exactly 3 callers (coord.rs is inGREPPEDwith 0).What
coord.rs— the boards as a plain data structure: noAppHandle, notauri::, noasync, no statics (a source-grep test pins all four). Message ring 500 with exactmissed; 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.jsonv1 (frozen): 0600, atomic, corrupt =Errwith 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.messagescope:post_message,read_messages,list_agents,create_task,claim_task,update_task,list_tasks. Attribution from the bearer only (a smuggledfromis ignored, tested);update_taskhas noassigneefield; two racing claims → one winner; every change is on disk before the reply and announced once on the message board; every successful result carriesunread.run_commandtakes an optionaltask_idwith a 20-proposal budget per task, refused before the bar.retry_after_ms;servecaps handler threads atmax(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_statetitles. The human's journal,term_write, ⌘B and the approval bar are byte-identical (tested), and a call-site test pins exactly whereredact(may appear. Rust and JS mirrors read the same corpus;npm run eval:redactis a CI step.Found by the adversaries and fixed
run_command's result andawait_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).refuse()now answers such a request on its own thread.One M1 function changed
PropGuard::settlenow 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: xheader form is not a rule. No entropy scan — known shapes only. Nothing here has run against a real MCP client.