Skip to content

M4 Main agent (v0.3.0 milestone 4): a configured model plans, assigns and verifies through the ordinary gate — and can never execute anything itself - #7

Open
ayushap18 wants to merge 10 commits into
mainfrom
m4-manager

Conversation

@ayushap18

Copy link
Copy Markdown
Owner

Milestone 4 of the v0.3.0 plan, on top of #6 (M3) — the diff collapses once #4, #5 and #6 merge.

335 backend tests (was 281) · 56 frontend · zero warnings · Linux 3/3 full-suite runs green. agent.rs has zero changed lines vs M3; pty_write_internal still 3 callers (manager.rs is in GREPPED with 0); exactly one verify_gate( in manager.rs.

How it works

/route manager <provider> [model], then /manager <goal>:

  1. Plan — the model answers in TASK: <agent> | <title> | <verify command> lines. parse_plan refuses unknown/reserved agents, trivial checks (true, :, exit 0, echo ok), control/bidi text (via run_command's own parse_run_args), duplicates and too many tasks.
  2. Approve — the plan is printed (never through the PTY) and awaited on a second instance of the fail-closed oneshot: rx.await.unwrap_or(false) with agent::decision_stands reused, so MIN_REVIEW applies. /manager approve|reject → manager_decide(bool), its only writer. Reject leaves the board untouched.
  3. Work — tasks land on the board as manager; only the named assignee can claim one.
  4. Verify — when a worker reports done, the frozen check string goes through the ordinary gate as reserved agent verify — the bar reads verify · run? ⌘⏎ approve · esc deny. Exit 0 → Verified; anything else → FailedVerify. The check string is never shown to a worker.
  5. Supervise — driven by board events, not a timer (zero model calls when nothing changes). Closed verbs ASSIGN DROP NOTE REPLAN DONE WAIT — no RUN, no TASK after approval; REPLAN needs a new approval. Board text is bounded and fenced as untrusted DATA.
  6. Budgets & report — tasks 8, model calls 40, reassignments 2, wall clock 30 min, plans 3, claim timeout 5 min (manager.json; corrupt = refuse to start). The final report is computed from board state, never from model prose.

Found by the adversaries and fixed

  • A worker could read the check string from read_journal → check Blocks are dropped from every agent-facing journal read.
  • Any agent could claim a manager task and fail it to burn the reassignment budget → assignee-only claims.
  • Board chatter could spend the model-call budget → message-only rounds held back 120 s.
  • A worker's code could print a forged OSC 133;D and make a failing check read as exit 0 → the check runs as ( <check> ); echo tachyon-check-<nonce>=$? with a fresh random nonce, and only that echo, as the very last output, counts.
  • A check queued behind an endless command could hold the run forever → stop and wall clock are checked before every retry.

Known limits (documented)

Shell history (zsh INC_APPEND_HISTORY) can hand the nonce to code under test; aliases/functions reach into the check's subshell; fish has no $?, so its checks fail closed. Not run against a real model or real workers yet.

… 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.
…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.
…s queue with leases, a worker's commands run visibly in its worktree, and a live foreground command is never handed on

Today a second agent's run_command got BUSY and retried blind; the
AgentRunGuard was owned by each Proposal record.

TURNLOCK. coord.rs gains a pure TurnLock over an injected clock (no
Instant::now, no lock(), no tauri — the module grep test now forbids all of
them): FIFO queue of 8, a 9th refused; tickets monotonic and never reused;
holder states Idle | AwaitingHuman | Running | Unknown. The lease measures
agent silence only — LEASE_IDLE 60 s and MAX_TURN 10 min count Idle time, both
clocks frozen in every other state, so there is no approval timeout and a
holder in Unknown is never handed on by the lock. Silent waiters pruned at
90 s. set_state is keyed by ticket so a late Block from a released turn cannot
idle the agent's next one. Every op returns events; the lock never sees a
guard.

GUARD PAIR (sign-off #1, second instance). mcp_server.rs holds static TURN and
static TURN_GUARD; one function, apply(), is the only place a guard is taken
(Granted → agent_claim) or dropped (Revoked/Pruned), grep-asserted. The
Proposal record now carries the ticket it ran under. R11 is a test on every
transition including a panic in run_gated and a cancel while AwaitingHuman,
which drops the parked sender so agent_propose answers false with no PTY
write. agent.rs changes by exactly one line: agent_start calls
preempt_if_idle() first, so ⌘J takes the shell back from an idle remote holder
and fails fast in every other state.

TOOLS. request_turn { wait_ms } and release_turn (propose scope; a non-holder's
release answers like "no turn"). BUSY is gone: run_command auto-requests a
turn, returns { position, holder, holder_state, retry_after_ms } as isError
when not granted inside its wait, and auto-releases on the Block — never from
Unknown. hub_state.turn = { holder, state, since_ms, queue, expires_in_ms }.
sweep runs on every lock op and every hub_state read; no timer thread.

WORKTREES. A registry worktree wraps the command as `( cd <wt> && <cmd> )` in
call_tool, before parse_run_args, so is_dangerous, the bar, the PTY write and
the exit-mark matcher see one string. /mcp agent add --worktree and /mcp agent
worktree <name> <path|off>; a path with a quote, space, $, backtick, ;,
backslash, control or invisible char, or a relative path, is refused (table
test). No tool has a worktree argument.

SURFACE. agent-done is per proposal {agent, proposal_id}; the bar tracks the
owner it shows so a done for X cannot clear a bar showing Y; run_gated no
longer emits "thinking… (0/12)". /mcp turn and /mcp turn release across all
four surfaces (SLASH_ROWS 25 → 28); release is refused while Running and
allowed from Unknown with a warning. initialize states the turn contract.

Found by the adversarial pass and fixed: a forged OSC 133;D in an approved
command's output could end the turn while the process still held the
foreground, and the next waiter's approved command would have gone into its
stdin — wait_end now requires the Block AND the shell back in the foreground
(tcgetpgrp on the master vs shell_pid; unknown answers "not ended"), for the
first wait and the late one. Under ⌘J a granted waiter whose claim failed was
dropped, breaking FIFO — requeued at the head. "keep the turn" was inferred
from the reply — now recorded at request time. A preempted agent got no
signal — its next request answers `preempted` once, before any proposal.

C12a stress: 8 threads for 5 s over the real statics, ≤1 holder per
observation, every grant matched by one release or revoke, holder ⇔ running at
every observation, a crashed holder freed after the lease, the N-client harness
rerun with queueing.

pty_write_internal: 3 callers. enter_approves, agent_propose, MIN_REVIEW,
decision_stands, agent_decide byte-identical. 244 → 280 backend tests,
55 → 56 frontend, 0 warnings.
…il it

eight_agents_for_five_seconds_break_no_bound wrote tasks.json on every task
change while eight threads hammered the board. On CI's Ubuntu runner, under
the rest of the suite, that paced the run to 305 messages in 5 s, and the
assertion that the run reached every ceiling (ring 500, 64 active, 256 total —
there so the bounds tests cannot pass vacuously) failed. macOS's disk was fast
enough to hide it.

The bounds are the board's, not the disk's. The threads now run against an
in-memory board; the file is written once afterwards and reloaded, which is
the kill-and-reload half of the test and the only part that needs a path.
…-read

r11_one_holder_one_guard_at_every_transition failed once on CI's Ubuntu leg
("a grant with no guard was left holding the shell") and passed 10/10 in
isolation there. The turn lock is process-global: a handler thread that an
earlier test left behind can `touch` it in the gap between take_turn returning
and the test's re-read, and that grants the queued r11c with THAT test's claim
— a legitimate grant, with a guard, that the old assertion mistook for a
holder without one.

The busy payload is built inside the critical section, so it is the one
reading no other thread can disturb: it now must say no holder AND r11c at
position 1. Outside the lock the test asserts R11 itself — a holder iff a
guard — and that ⌘J's own claim was untouched.
…ing and grants nobody

In the full suite on Linux r11_one_holder_one_guard_at_every_transition
failed at "preempt refused while AwaitingHuman": the lock had a holder, the
test's own approval slot was free. Since M3 every tools/call runs
touch(caller), and touch — like every lock op — swept first, and a sweep
grants the head of the queue. So an M2 board test running in parallel
(post_message from a stub that never asked for the shell) was the thread that
granted r11c, with ITS stub's claim; the test then found a holder whose guard
belonged to nobody it knew.

In the app there is one claim, so the grant itself would have been right; the
flaw is in who makes it. An agent reading the board is not waiting for the
shell, and its message is not the moment to re-read leases and hand the shell
on. A stale ticket's settle — a command's late Block for a released turn — is
the same kind of non-event. Both now return no events and touch nothing.
Waiters re-ask every retry_after_ms and every hub_state read sweeps, so a
lapsed lease is still noticed by someone who wants the shell.

set_state_is_keyed_by_ticket pins both: with the shell free and a waiter at
the head, a stale settle and a stranger's touch each grant nobody. agree() now
names the holder it found, so the next such failure says who.
…ed ones

the_17th_held_connection_gets_503_and_no_thread failed in 2 of 6 full-suite
runs on Linux and 0 of 17 alone. Under load a poll was in flight when the
last of the 16 holds reached the accept loop, so for that instant the cap was
full and the HELD request was the one refused — 15 parked, and every later
poll answered 200 until the deadline.

A refused hold is not silent: it hears a 503 on its socket, while a parked
one hears nothing. The poll loop now peeks each held socket with a 1 ms read
timeout and re-opens any that was answered, so the 503 it waits for is always
the one that means sixteen are parked.
…signs them, and verifies results through the ordinary gate — and can never execute anything itself

Agents could share the shell, talk and divide work, but a human had to write
every task. Now `/route manager <provider> [model]` picks a model and
`/manager <goal>` makes it the main agent.

THE MANAGER CANNOT EXECUTE (R10). src-tauri/src/manager.rs contains none of
pty_write_internal, agent_claim, run_command or McpPool::call, and exactly one
call to mcp_server::verify_gate — a grep test counts all of it, and manager.rs
joins GREPPED with zero PTY writes. agent.rs has zero changed lines.

PLAN, THEN ONE HUMAN DECISION. MANAGER_PLAN asks for lines of
`TASK: <agent> | <title> | <verify command>`; parse_plan refuses wrong arity,
unregistered or reserved agents, empty or trivial checks (true, :, exit 0,
echo ok), control/bidi text through run_command's own parse_run_args,
duplicates and too many tasks — one retry with the error, then stop. The plan
is printed through the display path, never the PTY, and awaited on a second
INSTANCE of the fail-closed oneshot: rx.await.unwrap_or(false), with
agent::decision_stands reused so MIN_REVIEW applies. manager_decide is its one
writer, behind /manager approve|reject (webview-reachable exactly like
agent_decide, documented). Dropped sender, double decide, stop → deny. Reject
leaves the board untouched; approve creates the tasks as "manager".

VERIFY THROUGH THE GATE. A check string is frozen at plan approval (a newtype
built only in parse_plan, no mutator) and never shown to a worker. When a
worker reports done, verify_gate takes a turn as the reserved agent "verify"
— no token can be that caller — wraps the check in the assignee's worktree
and goes through the same open_gate/run_gated/wait_end as any external
proposal: the bar reads "verify · run? ⌘⏎ approve · esc deny", MIN_REVIEW,
cooldown and the turn lock all apply. Exit 0 → Verified; anything else,
denial or no answer → FailedVerify. Reported is never Verified.

SUPERVISE. A pure Supervisor driven by board events (a message cursor and
task-state diffs), never by a timer: zero model calls when nothing changes.
Closed verbs ASSIGN, DROP, NOTE, REPLAN, DONE, WAIT — no RUN, no TASK after
approval; REPLAN needs a new approval and is capped. render_board is bounded
per field and at 6000 bytes, fenced as untrusted DATA; a forged TASK:/ASSIGN
in a note moves nothing. Identical replies twice force WAIT. Budgets from
manager.json (max_tasks 8, model calls 40, reassignments 2, wall clock
1800 s, plans 3, claim timeout 300 s; corrupt = refuse to start), each tripping
with a named reason. The final report is computed from board state, never
from model prose.

Found by the adversarial pass and fixed:
- A worker could read the check string from read_journal after the verify run
  → journal_json drops every check Block; a worker sees none of them.
- Any registered agent could claim a manager task and fail it to burn the
  reassignment budget → a manager task can be claimed only by its assignee.
- Board chatter could spend the model-call budget → message-only rounds are
  held back for 120 s; task events still call the model at once.
- A worker's code could print a forged OSC 133;D and have the check read as
  exit 0 → the check runs as `( <check> ); echo tachyon-check-<nonce>=$?`
  with a fresh 16-hex nonce, and only that echo, as the very last output,
  counts; a Block closed early carries no mark and fails.
- A check queued behind an endless command could hold the run forever → stop
  and the wall-clock budget are asked before every retry.

Known limits, documented: shell history (zsh INC_APPEND_HISTORY) can hand the
nonce to code under test; aliases and functions reach into the check's
subshell; fish has no $? so its checks fail closed.

281 -> 335 backend tests, 56 frontend, 0 warnings. eval:manager:selftest runs
8 scripted runs from evals/manager-runs.json, read by the Rust test too, in CI.
@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: bffef570-5bca-4c04-9f63-a53078878583


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.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Add gated main-agent planning, assignment, and verification

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

Grey Divider

AI Description

• Adds a model-driven manager that plans and supervises without direct execution.
• Routes approved verification commands through the existing human-controlled shell gate.
• Adds bounded coordination, redaction, evaluations, and safer concurrent HTTP handling.
Diagram

sequenceDiagram
    actor Human
    participant UI as Command UI
    participant Manager
    participant Model
    participant Board as Task Board
    participant Worker
    participant Gate as Safety Gate
    participant Shell
    Human->>UI: /manager goal
    UI->>Manager: Start run
    Manager->>Model: Request plan
    Model-->>Manager: Tasks and checks
    Manager-->>Human: Show full plan
    Human->>Manager: Approve or reject
    Manager->>Board: Publish assignments
    Worker->>Board: Claim and report
    Board-->>Manager: Emit changes
    Manager->>Gate: Verify as reserved agent
    Gate-->>Human: Request command approval
    Human->>Gate: Approve or deny
    Gate->>Shell: Run approved check
    Shell-->>Gate: Return nonce-marked status
    Gate-->>Manager: Verification verdict
    Manager->>Board: Reassign or report
Loading
High-Level Assessment

Separating model planning, board coordination, and the existing execution gate is the safest fit for the architecture. Direct manager execution or a parallel verification runner would create another shell path or inconsistent policy enforcement; reusing the ordinary gate preserves the established trust boundary.

Files changed (40) +9558 / -135

Enhancement (7) +4723 / -54
agent.rsLet the built-in agent preempt idle remote turns +1/-0

Let the built-in agent preempt idle remote turns

• Preempts an idle external holder before the built-in agent claims the approval slot.

src-tauri/src/agent.rs

coord.rsAdd bounded message, task, and shell-turn coordination +1484/-0

Add bounded message, task, and shell-turn coordination

• Introduces validated message and persistent task boards plus a FIFO shell-turn state machine with leases, preemption, and concurrency tests.

src-tauri/src/coord.rs

lib.rsWire manager routing, redaction, commands, and state +331/-19

Wire manager routing, redaction, commands, and state

• Registers manager coordination, adds manager model routing and slash commands, exposes hub state, and implements credential redaction.

src-tauri/src/lib.rs

manager.rsImplement the gated main-agent supervisor +2471/-0

Implement the gated main-agent supervisor

• Adds plan approval, assignment, event-driven supervision, frozen verification, bounded replanning, and state-derived reports. Tests enforce that the manager cannot execute directly.

src-tauri/src/manager.rs

main.cssStyle the full-command approval preview +26/-0

Style the full-command approval preview

• Adds a wrapped, scrollable proposal panel above the AI bar.

ui/assets/main.css

ai_bar.rsHarden and identify external approval prompts +254/-23

Harden and identify external approval prompts

• Names requesters, rejects unidentified approvals, correlates completion events, and displays commands in a read-only block.

ui/src/ai_bar.rs

complete.rsComplete manager, registry, turn, and routing commands +156/-12

Complete manager, registry, turn, and routing commands

• Extends completion for manager actions, agent operations, registered names, turns, and manager model routing.

ui/src/complete.rs

Bug fix (1) +145 / -0
task_pool.rsFix worker allocation for burst connections +145/-0

Fix worker allocation for burst connections

• Accounts for queued work when allocating workers, preventing burst connections from remaining unread.

src-tauri/vendor/tiny_http/src/util/task_pool.rs

Tests (5) +408 / -1
manager-runs.jsonDefine scripted manager supervision scenarios +116/-0

Define scripted manager supervision scenarios

• Adds fixtures covering verification, failed checks, claim timeouts, reassignment, completion, and every manager budget.

evals/manager-runs.json

manager.mjsAdd the manager evaluation harness +94/-0

Add the manager evaluation harness

• Validates fixture coverage against the Rust budget schema and runs the real supervisor state-machine test.

evals/manager.mjs

redact.mjsAdd a JavaScript mirror of credential redaction +130/-0

Add a JavaScript mirror of credential redaction

• Mirrors the Rust redaction rules and checks exact corpus results to detect cross-language drift.

evals/redact.mjs

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

Define the credential-redaction specification

• Adds positive credential cases and false-positive controls shared by Rust and JavaScript tests.

evals/redaction-corpus.json

theme.rsRequire theme coverage for proposal previews +5/-1

Require theme coverage for proposal previews

• Ensures the approval proposal panel defines required themed colors.

ui/src/theme.rs

Documentation (3) +454 / -78
README.mdDocument manager workflows and multi-agent MCP commands +26/-10

Document manager workflows and multi-agent MCP commands

• Adds the main-agent feature, manager routing, agent registry, turn commands, and evaluation instructions.

README.md

architecture.mdDescribe multi-agent coordination and manager architecture +209/-27

Describe multi-agent coordination and manager architecture

• Documents identity, scopes, redaction, asynchronous proposals, task persistence, shell turns, manager verification, and budgets.

docs/architecture.md

danger-gate.mdExpand the threat model for agents, turns, and verification +219/-41

Expand the threat model for agents, turns, and verification

• Documents fail-closed plan approval, scoped identities, proposal limits, turn invariants, verification hardening, and known limitations.

docs/danger-gate.md

Other (24) +3828 / -2
ci.ymlRun manager and redaction evaluations in bounded CI jobs +9/-0

Run manager and redaction evaluations in bounded CI jobs

• Adds a 20-minute job timeout and runs the redaction corpus and scripted manager self-test in CI.

.github/workflows/ci.yml

package.jsonExpose redaction and manager evaluation scripts +2/-0

Expose redaction and manager evaluation scripts

• Adds npm commands for the redaction corpus and scripted manager self-test.

package.json

Cargo.lockResolve tiny_http from the vendored source +0/-2

Resolve tiny_http from the vendored source

• Removes crates.io source metadata because tiny_http now resolves through the local patch.

src-tauri/Cargo.lock

Cargo.tomlPatch tiny_http to the vendored implementation +5/-0

Patch tiny_http to the vendored implementation

• Directs tiny_http to the local copy containing the connection-burst fix.

src-tauri/Cargo.toml

Cargo.tomlDefine the vendored tiny_http package +25/-0

Define the vendored tiny_http package

• Adds a reduced tiny_http 0.12.0 manifest and documents the local thread-pool fix.

src-tauri/vendor/tiny_http/Cargo.toml

LICENSE-APACHEInclude tiny_http's Apache license +201/-0

Include tiny_http's Apache license

• Adds the Apache 2.0 license for the vendored dependency.

src-tauri/vendor/tiny_http/LICENSE-APACHE

LICENSE-MITInclude tiny_http's MIT license +25/-0

Include tiny_http's MIT license

• Adds the MIT license for the vendored dependency.

src-tauri/vendor/tiny_http/LICENSE-MIT

client.rsVendor tiny_http client connection parsing +309/-0

Vendor tiny_http client connection parsing

• Adds upstream request parsing, keep-alive, timeout, pipelining, and error-response handling.

src-tauri/vendor/tiny_http/src/client.rs

common.rsVendor tiny_http protocol primitives +440/-0

Vendor tiny_http protocol primitives

• Adds upstream HTTP status, header, method, and protocol-version types.

src-tauri/vendor/tiny_http/src/common.rs

connection.rsVendor tiny_http socket abstractions +194/-0

Vendor tiny_http socket abstractions

• Adds upstream TCP and Unix listener and connection wrappers.

src-tauri/vendor/tiny_http/src/connection.rs

lib.rsVendor the tiny_http server implementation +445/-0

Vendor the tiny_http server implementation

• Adds the upstream server API, accept loop, connection dispatch, request queue, and shutdown behavior.

src-tauri/vendor/tiny_http/src/lib.rs

request.rsVendor tiny_http request handling +518/-0

Vendor tiny_http request handling

• Adds upstream request construction, body framing, protocol upgrades, response dispatch, and cleanup.

src-tauri/vendor/tiny_http/src/request.rs

response.rsVendor tiny_http response handling +574/-0

Vendor tiny_http response handling

• Adds upstream response serialization, transfer-encoding selection, body streaming, and constructors.

src-tauri/vendor/tiny_http/src/response.rs

ssl.rsVendor tiny_http TLS backend selection +20/-0

Vendor tiny_http TLS backend selection

• Adds feature-gated exports for the OpenSSL and Rustls implementations.

src-tauri/vendor/tiny_http/src/ssl.rs

openssl.rsVendor tiny_http OpenSSL support +110/-0

Vendor tiny_http OpenSSL support

• Adds upstream OpenSSL certificate loading, handshakes, synchronized streams, and lifecycle handling.

src-tauri/vendor/tiny_http/src/ssl/openssl.rs

rustls.rsVendor tiny_http Rustls support +120/-0

Vendor tiny_http Rustls support

• Adds upstream Rustls key loading, server connections, synchronized I/O, and shutdown handling.

src-tauri/vendor/tiny_http/src/ssl/rustls.rs

test.rsVendor tiny_http request test utilities +127/-0

Vendor tiny_http request test utilities

• Adds the upstream TestRequest builder for in-memory HTTP requests.

src-tauri/vendor/tiny_http/src/test.rs

custom_stream.rsVendor split read-write stream adapter +39/-0

Vendor split read-write stream adapter

• Adds the upstream utility combining independent readers and writers.

src-tauri/vendor/tiny_http/src/util/custom_stream.rs

equal_reader.rsVendor fixed-length body reader +131/-0

Vendor fixed-length body reader

• Adds the upstream bounded reader that consumes or drains an exact body length.

src-tauri/vendor/tiny_http/src/util/equal_reader.rs

fused_reader.rsVendor fused EOF reader +48/-0

Vendor fused EOF reader

• Adds the upstream reader that permanently transitions to EOF.

src-tauri/vendor/tiny_http/src/util/fused_reader.rs

messages_queue.rsVendor tiny_http's blocking message queue +96/-0

Vendor tiny_http's blocking message queue

• Adds the synchronized queue with blocking, timeout, non-blocking, and unblock operations.

src-tauri/vendor/tiny_http/src/util/messages_queue.rs

mod.rsVendor tiny_http utility exports +64/-0

Vendor tiny_http utility exports

• Registers the stream, reader, queue, sequencing, parsing, and task-pool utilities.

src-tauri/vendor/tiny_http/src/util/mod.rs

refined_tcp_stream.rsVendor split socket lifecycle handling +152/-0

Vendor split socket lifecycle handling

• Adds the HTTP/TLS stream abstraction and independently closable read and write halves.

src-tauri/vendor/tiny_http/src/util/refined_tcp_stream.rs

sequential.rsVendor pipelined I/O ordering utilities +174/-0

Vendor pipelined I/O ordering utilities

• Adds reader and writer sequencing primitives that preserve HTTP pipeline order.

src-tauri/vendor/tiny_http/src/util/sequential.rs

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Action required

1. Failed checks become verified 🐞 Bug ≡ Correctness
Description
is_trivial_verify examines only the final pipe or semicolon segment and therefore accepts checks
such as false | tee /tmp/log whose final command returns zero independently. When that approved
check runs after a worker reports completion, verdict converts its zero status into Verified
despite the failed test.
Code

src-tauri/src/manager.rs[R1162-1163]

+    let last = cmd.rsplit([';', '|']).find(|s| !s.trim().is_empty()).unwrap_or("");
+    last.split("&&").all(noop)
Evidence
The parser accepts a verification command after applying an explicitly incomplete trivial-command
check, while the final verdict trusts only the resulting exit status. The implementation comment
itself identifies x | tee log as an accepted always-passing form.

src-tauri/src/manager.rs[1152-1164]
src-tauri/src/manager.rs[1189-1204]
src-tauri/src/manager.rs[337-344]

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

## Issue description
Verification validation accepts pipelines and conditionals whose final command succeeds even when the actual test fails, causing failed work to be recorded as verified.

## Fix Focus Areas
- src-tauri/src/manager.rs[1152-1164]
- src-tauri/src/manager.rs[1189-1196]
- src-tauri/src/manager.rs[337-344]

## Recommended Fix
Replace the partial final-segment denylist with validation that rejects shell lists, pipelines, and conditionals capable of masking a failed check, including `||` and success-producing pipeline tails. Add tests proving examples such as `false | tee /tmp/log` and `false || echo passed` cannot enter a plan.

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


2. Runs outlive wall-clock budgets 🐞 Bug ☼ Reliability
Description
manager_run records started before planning, but model requests and plan_approved do not check
the resulting deadline before waiting for approval or placing tasks. An undecided initial or
replacement plan can keep the manager active indefinitely, while approval after wall_clock_secs
has elapsed still reaches place_plan and creates tasks before supervise detects the expired
budget and cancels them.
Code

src-tauri/src/manager.rs[230]

+        let ok = rx.await.unwrap_or(false);
Evidence
The cited flow captures the run start time before the initial model call, but neither planning nor
the shared approval helper receives or checks the deadline, and plan_approved performs an
unbounded receive for both initial and replacement plans. After approval, placement occurs
immediately, while the first wall-clock check is deferred until the supervision loop, proving that
an approval wait can exceed the budget and that a late approval can still create tasks before they
are cancelled.

src-tauri/src/manager.rs[140-164]
src-tauri/src/manager.rs[216-236]
src-tauri/src/manager.rs[846-873]
src-tauri/src/manager.rs[914-920]
src-tauri/src/manager.rs[216-261]
src-tauri/src/manager.rs[910-929]

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 configured wall-clock budget does not bound initial or replacement planning and plan-approval waits. Approval after the deadline can still place assigned tasks on the board before supervision detects the expired budget and cancels them.

## Fix Focus Areas
- src-tauri/src/manager.rs[140-164]
- src-tauri/src/manager.rs[216-261]
- src-tauri/src/manager.rs[219-236]
- src-tauri/src/manager.rs[851-873]
- src-tauri/src/manager.rs[914-920]

## Recommended Fix
Pass the run deadline into initial planning, replacement planning, and `plan_approved`. Race each model request and approval wait against the remaining deadline, fail closed if it expires while waiting or immediately before `place_plan`, and do not create board tasks after the deadline. Ensure expiration follows the run’s normal cleanup and emits the normal final budget report.

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


3. Dropped tasks keep running 🐞 Bug ☼ Reliability
Description
OnBoard::drop_task discards the result of the persistent board cancellation, while
Supervisor::apply marks the corresponding slot dropped unconditionally. If task persistence is
broken or unwritable, the board rolls back the cancellation but the manager forgets the still-open
or claimed task and no longer supervises it.
Code

src-tauri/src/manager.rs[R466-469]

+    fn drop_task(&mut self, id: &str) {
+        // best effort: a dropped task is the manager's to forget whether or not the board
+        // took the cancel
+        let _ = Self::cancel(&mut self.board.lock().unwrap_or_else(|e| e.into_inner()), id, "dropped by the manager");
Evidence
The concrete board adapter suppresses update_task errors, while DROP, replacement, and final
cleanup all assume the void operation succeeded. Board commits restore their previous state when
persistence fails, leaving the task active.

src-tauri/src/manager.rs[425-470]
src-tauri/src/manager.rs[765-800]
src-tauri/src/coord.rs[215-228]

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

## Issue description
Manager task cleanup ignores persistent cancellation failures and updates supervisor state as though the task was removed.

## Fix Focus Areas
- src-tauri/src/manager.rs[381-389]
- src-tauri/src/manager.rs[425-432]
- src-tauri/src/manager.rs[466-470]
- src-tauri/src/manager.rs[765-800]

## Recommended Fix
Change `BoardView::drop_task` to return `Result`. Only mark a slot dropped after cancellation succeeds, propagate failures through replacement and final cleanup, and report any task IDs that could not be cancelled instead of claiming they came off the board.

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


View action required (3)
4. Board secrets reach model providers 🐞 Bug ⛨ Security
Description
render_board redacts task fields through task_out but inserts msg.text directly after clipping
it, explicitly omitting the redaction boundary. Whenever a message containing a credential is
included in the next supervision context, Supervisor::ask sends that plaintext to the configured
manager model provider.
Code

src-tauri/src/manager.rs[R1006-1008]

+    for msg in messages.iter().rev().filter(|m| m.from != mcp_server::SYSTEM_AUTHOR) {
+        let to = msg.to.as_deref().map(|to| format!(" to {}", clip(to, coord::MAX_NAME_CHARS))).unwrap_or_default();
+        body.push_str(&format!("message {} from {}{to}\n  text: {}\n", msg.id(), msg.from, clip(&msg.text, SHOWN_TEXT)));
Evidence
The manager renderer explicitly states message text is not redacted and then interpolates it
directly. The rendered board becomes part of the context passed to the manager model, while the new
security documentation confirms agent-written messages are placed before that model.

src-tauri/src/manager.rs[981-1009]
src-tauri/src/manager.rs[711-734]
docs/danger-gate.md[409-416]
src-tauri/src/lib.rs[1622-1655]

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

## Issue description
Agent-authored board messages are copied into manager model prompts without the redaction applied to other agent-facing data.

## Fix Focus Areas
- src-tauri/src/manager.rs[981-1009]
- src-tauri/src/manager.rs[711-734]
- src-tauri/src/lib.rs[1622-1655]

## Recommended Fix
Run each message body through `redact` before clipping and inserting it into `render_board`. Add a test with recognized API keys and authorization values proving the rendered manager context contains only redaction markers.

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


5. YAML secrets reach other agents 🐞 Bug ⛨ Security
Description
secret_at handles a colon only as the separator in a URL password and returns before applying
SECRET_NAMES to ordinary colon assignments. Values in password: hunter2, token: value, or
similar board and terminal text therefore remain plaintext on the newly redacted agent-facing read
paths.
Code

src-tauri/src/lib.rs[R1810-1813]

+        [.., b':'] => {
+            let user_start = i - 1 - pre[..i - 1].iter().rev().take_while(|&&c| !b"/@: \t\r\n".contains(&c)).count();
+            let end = run_end(b, i, |c| !b"@/ \t\r\n".contains(&c));
+            return (pre[..user_start].ends_with(b"://") && b.get(end) == Some(&b'@')).then_some((i, end, "url-password"));
Evidence
The colon branch returns None for every non-URL form, and secret-name matching occurs only after
the equals-sign branches. The PR describes redaction as protecting board messages and task text
while documenting that YAML and JSON colon assignments currently pass through unchanged.

src-tauri/src/lib.rs[1788-1824]
src-tauri/src/lib.rs[1622-1636]
evals/redact.mjs[86-108]
docs/danger-gate.md[433-444]

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 new agent-facing redactor does not redact common YAML and configuration secret assignments that use a colon instead of an equals sign.

## Fix Focus Areas
- src-tauri/src/lib.rs[1778-1824]
- evals/redact.mjs[86-108]
- evals/redaction-corpus.json[1-63]

## Recommended Fix
After excluding valid URL-password syntax, parse colon-separated names using the same normalized `SECRET_NAMES` matching as equals assignments and redact their values, including quoted JSON/YAML values. Mirror the behavior in the JavaScript evaluator and add positive corpus cases for password, token, API-key, and secret-key colon forms.

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


6. Large clock limit crashes manager 🐞 Bug ☼ Reliability
Description
wall_clock_secs accepts every u64 from manager.json, then supervise adds its duration to
Instant with unchecked +. A sufficiently large valid value overflows the platform Instant,
panics the spawned manager task, and bypasses finish, which is responsible for cancelling
unfinished tasks and publishing the final report.
Code

src-tauri/src/manager.rs[929]

+        let deadline = started + Duration::from_secs(budgets.wall_clock_secs);
Evidence
Budget deserialization imposes no upper bound on the u64 duration. The deadline calculation uses
unchecked addition inside the supervision loop, while cleanup and reporting occur only after that
loop exits normally.

src-tauri/src/manager.rs[41-60]
src-tauri/src/manager.rs[910-956]
src-tauri/src/manager.rs[876-885]
src-tauri/src/manager.rs[123-134]

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 syntactically valid but very large `wall_clock_secs` value can overflow `Instant` arithmetic during verification. The panic exits before manager cleanup and reporting run.

Fix Focus Areas
- src-tauri/src/manager.rs[41-60]
- src-tauri/src/manager.rs[910-956]
- src-tauri/src/manager.rs[876-885]

Recommended Fix
Validate `wall_clock_secs` to a representable operational maximum when loading budgets, or construct the deadline with `checked_add` and stop the run cleanly on overflow. Ensure the error path still calls `finish`.

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



Remediation recommended

7. Zero plan budget still plans 🐞 Bug ≡ Correctness
Description
manager_run calls make_plan unconditionally, although max_plans is documented to include the
first plan. A valid manager.json with max_plans: 0 therefore still invokes the model and can
place an initial plan; only later REPLAN requests consult replan_room.
Code

src-tauri/src/manager.rs[147]

+    let plan = match make_plan(&goal, "", budgets.max_tasks, &mut model).await {
Evidence
The budget comment defines the first plan as included, but the initial call is unconditional. The
only max_plans guard is in replan_room, which is called exclusively from the REPLAN path.

src-tauri/src/manager.rs[46-55]
src-tauri/src/manager.rs[80-90]
src-tauri/src/manager.rs[140-150]
src-tauri/src/manager.rs[851-861]

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 initial planning path bypasses `max_plans`, despite that budget explicitly including the first plan. A zero-plan configuration must prevent the initial model call and task placement.

Fix Focus Areas
- src-tauri/src/manager.rs[80-90]
- src-tauri/src/manager.rs[140-150]

Recommended Fix
Before invoking `make_plan` for the initial plan, reject the run when `max_plans` is zero using the same budget reason used by replanning. Keep the initial and replan budget semantics consistent.

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


8. Task creation can overflow IDs 🐞 Bug ☼ Reliability
Description
Board::load_from accepts a persisted t_18446744073709551615 identifier and assigns its numeric
suffix to last_task, while create increments that value with += 1. On the next task creation
this panics in checked builds or wraps in release builds, allowing a valid-looking tasks.json to
crash creation or reuse an identifier.
Code

src-tauri/src/coord.rs[R299-301]

+        self.last_task += 1;
+        let task = Task {
+            id: format!("t_{}", self.last_task),
Evidence
The loader derives last_task directly from the maximum parseable numeric task suffix, including
u64::MAX. Creation subsequently increments that field before producing the new ID, without a
checked-add or an exhaustion error.

src-tauri/src/coord.rs[276-313]
src-tauri/src/coord.rs[402-422]

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 persisted task-ID counter can be loaded at `u64::MAX`, but creating the next task increments it without overflow handling. This can panic or reuse a task ID.

Fix Focus Areas
- src-tauri/src/coord.rs[276-313]
- src-tauri/src/coord.rs[402-422]

Recommended Fix
Use `checked_add` when allocating the next task ID and return a board error when the counter is exhausted. Optionally reject `u64::MAX` during load, but preserve the no-ID-reuse invariant in either path.

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


9. Completed runs retain check commands 🐞 Bug ☼ Reliability
Description
verify_task always puts each command back into ManagerState.verify, including after a successful
final verification, and neither finish nor ManagerRunGuard clears that map. Each completed
manager run therefore retains its approved command strings indefinitely, so repeated runs grow the
application’s memory use even though old task checks can no longer be used.
Code

src-tauri/src/manager.rs[R361-362]

+    let ran = mcp_server::verify_gate(app, id, &cmd, &stopped);
+    m.verify.lock().unwrap_or_else(|e| e.into_inner()).insert(id.to_string(), cmd);
Evidence
The verification helper removes a command solely for the gated call and unconditionally reinserts it
afterward. Normal cleanup cancels board tasks and reports status but does not clear the verification
map; the run guard only resets the running flag and approval sender.

src-tauri/src/manager.rs[347-364]
src-tauri/src/manager.rs[876-885]
src-tauri/src/manager.rs[123-134]

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

Issue description
Approved verification commands remain in `ManagerState.verify` after their task and manager run have completed. Repeated runs retain otherwise unreachable command strings indefinitely.

Fix Focus Areas
- src-tauri/src/manager.rs[347-364]
- src-tauri/src/manager.rs[876-885]
- src-tauri/src/manager.rs[123-134]

Recommended Fix
Retain a command only while its task can still be reassigned, then remove it after a terminal verified or dropped outcome. Also clear any remaining run-owned verification entries during manager shutdown/finish.

ⓘ 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-risk, security-sensitive orchestration change with substantial new logic across multiple independent backend, UI, evaluation, and integration paths, creating many opportunities for subtle defects that redundant review could catch.

Grey Divider

Tip of the day
💡 Did you know, you can reply 'qodo' on any finding to push back, ask questions, or dig deeper

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread src-tauri/src/manager.rs
Comment on lines +1162 to +1163
let last = cmd.rsplit([';', '|']).find(|s| !s.trim().is_empty()).unwrap_or("");
last.split("&&").all(noop)

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. Failed checks become verified 🐞 Bug ≡ Correctness

is_trivial_verify examines only the final pipe or semicolon segment and therefore accepts checks
such as false | tee /tmp/log whose final command returns zero independently. When that approved
check runs after a worker reports completion, verdict converts its zero status into Verified
despite the failed test.
Agent Prompt
## Issue description
Verification validation accepts pipelines and conditionals whose final command succeeds even when the actual test fails, causing failed work to be recorded as verified.

## Fix Focus Areas
- src-tauri/src/manager.rs[1152-1164]
- src-tauri/src/manager.rs[1189-1196]
- src-tauri/src/manager.rs[337-344]

## Recommended Fix
Replace the partial final-segment denylist with validation that rejects shell lists, pipelines, and conditionals capable of masking a failed check, including `||` and success-producing pipeline tails. Add tests proving examples such as `false | tee /tmp/log` and `false || echo passed` cannot enter a plan.

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

Comment thread src-tauri/src/manager.rs
return false;
}
show();
let ok = rx.await.unwrap_or(false);

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. Runs outlive wall-clock budgets 🐞 Bug ☼ Reliability

manager_run records started before planning, but model requests and plan_approved do not check
the resulting deadline before waiting for approval or placing tasks. An undecided initial or
replacement plan can keep the manager active indefinitely, while approval after wall_clock_secs
has elapsed still reaches place_plan and creates tasks before supervise detects the expired
budget and cancels them.
Agent Prompt
## Issue description
The configured wall-clock budget does not bound initial or replacement planning and plan-approval waits. Approval after the deadline can still place assigned tasks on the board before supervision detects the expired budget and cancels them.

## Fix Focus Areas
- src-tauri/src/manager.rs[140-164]
- src-tauri/src/manager.rs[216-261]
- src-tauri/src/manager.rs[219-236]
- src-tauri/src/manager.rs[851-873]
- src-tauri/src/manager.rs[914-920]

## Recommended Fix
Pass the run deadline into initial planning, replacement planning, and `plan_approved`. Race each model request and approval wait against the remaining deadline, fail closed if it expires while waiting or immediately before `place_plan`, and do not create board tasks after the deadline. Ensure expiration follows the run’s normal cleanup and emits the normal final budget report.

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

Comment thread src-tauri/src/manager.rs
Comment on lines +466 to +469
fn drop_task(&mut self, id: &str) {
// best effort: a dropped task is the manager's to forget whether or not the board
// took the cancel
let _ = Self::cancel(&mut self.board.lock().unwrap_or_else(|e| e.into_inner()), id, "dropped by the manager");

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. Dropped tasks keep running 🐞 Bug ☼ Reliability

OnBoard::drop_task discards the result of the persistent board cancellation, while
Supervisor::apply marks the corresponding slot dropped unconditionally. If task persistence is
broken or unwritable, the board rolls back the cancellation but the manager forgets the still-open
or claimed task and no longer supervises it.
Agent Prompt
## Issue description
Manager task cleanup ignores persistent cancellation failures and updates supervisor state as though the task was removed.

## Fix Focus Areas
- src-tauri/src/manager.rs[381-389]
- src-tauri/src/manager.rs[425-432]
- src-tauri/src/manager.rs[466-470]
- src-tauri/src/manager.rs[765-800]

## Recommended Fix
Change `BoardView::drop_task` to return `Result`. Only mark a slot dropped after cancellation succeeds, propagate failures through replacement and final cleanup, and report any task IDs that could not be cancelled instead of claiming they came off the board.

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

Comment thread src-tauri/src/manager.rs
Comment on lines +1006 to +1008
for msg in messages.iter().rev().filter(|m| m.from != mcp_server::SYSTEM_AUTHOR) {
let to = msg.to.as_deref().map(|to| format!(" to {}", clip(to, coord::MAX_NAME_CHARS))).unwrap_or_default();
body.push_str(&format!("message {} from {}{to}\n text: {}\n", msg.id(), msg.from, clip(&msg.text, SHOWN_TEXT)));

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. Board secrets reach model providers 🐞 Bug ⛨ Security

render_board redacts task fields through task_out but inserts msg.text directly after clipping
it, explicitly omitting the redaction boundary. Whenever a message containing a credential is
included in the next supervision context, Supervisor::ask sends that plaintext to the configured
manager model provider.
Agent Prompt
## Issue description
Agent-authored board messages are copied into manager model prompts without the redaction applied to other agent-facing data.

## Fix Focus Areas
- src-tauri/src/manager.rs[981-1009]
- src-tauri/src/manager.rs[711-734]
- src-tauri/src/lib.rs[1622-1655]

## Recommended Fix
Run each message body through `redact` before clipping and inserting it into `render_board`. Add a test with recognized API keys and authorization values proving the rendered manager context contains only redaction markers.

ⓘ 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 +1810 to +1813
[.., b':'] => {
let user_start = i - 1 - pre[..i - 1].iter().rev().take_while(|&&c| !b"/@: \t\r\n".contains(&c)).count();
let end = run_end(b, i, |c| !b"@/ \t\r\n".contains(&c));
return (pre[..user_start].ends_with(b"://") && b.get(end) == Some(&b'@')).then_some((i, end, "url-password"));

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. Yaml secrets reach other agents 🐞 Bug ⛨ Security

secret_at handles a colon only as the separator in a URL password and returns before applying
SECRET_NAMES to ordinary colon assignments. Values in password: hunter2, token: value, or
similar board and terminal text therefore remain plaintext on the newly redacted agent-facing read
paths.
Agent Prompt
## Issue description
The new agent-facing redactor does not redact common YAML and configuration secret assignments that use a colon instead of an equals sign.

## Fix Focus Areas
- src-tauri/src/lib.rs[1778-1824]
- evals/redact.mjs[86-108]
- evals/redaction-corpus.json[1-63]

## Recommended Fix
After excluding valid URL-password syntax, parse colon-separated names using the same normalized `SECRET_NAMES` matching as equals assignments and redact their values, including quoted JSON/YAML values. Mirror the behavior in the JavaScript evaluator and add positive corpus cases for password, token, API-key, and secret-key colon forms.

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

Comment thread src-tauri/src/manager.rs
let started = Instant::now();
let say = |text: String| term_write(app.clone(), app.state::<PtyState>(), text);
let mut model = Metered { inner: LiveModel, calls: 0, max: budgets.max_model_calls };
let plan = match make_plan(&goal, "", budgets.max_tasks, &mut model).await {

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. Zero plan budget still plans 🐞 Bug ≡ Correctness

manager_run calls make_plan unconditionally, although max_plans is documented to include the
first plan. A valid manager.json with max_plans: 0 therefore still invokes the model and can
place an initial plan; only later REPLAN requests consult replan_room.
Agent Prompt
Issue description
The initial planning path bypasses `max_plans`, despite that budget explicitly including the first plan. A zero-plan configuration must prevent the initial model call and task placement.

Fix Focus Areas
- src-tauri/src/manager.rs[80-90]
- src-tauri/src/manager.rs[140-150]

Recommended Fix
Before invoking `make_plan` for the initial plan, reject the run when `max_plans` is zero using the same budget reason used by replanning. Keep the initial and replan budget semantics consistent.

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

Comment thread src-tauri/src/manager.rs
}
// Checks first: a report the worker made before the model's reply is not thrown away
// by a DROP or REPLAN written without knowing it passed.
let deadline = started + Duration::from_secs(budgets.wall_clock_secs);

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

6. Large clock limit crashes manager 🐞 Bug ☼ Reliability

wall_clock_secs accepts every u64 from manager.json, then supervise adds its duration to
Instant with unchecked +. A sufficiently large valid value overflows the platform Instant,
panics the spawned manager task, and bypasses finish, which is responsible for cancelling
unfinished tasks and publishing the final report.
Agent Prompt
Issue description
A syntactically valid but very large `wall_clock_secs` value can overflow `Instant` arithmetic during verification. The panic exits before manager cleanup and reporting run.

Fix Focus Areas
- src-tauri/src/manager.rs[41-60]
- src-tauri/src/manager.rs[910-956]
- src-tauri/src/manager.rs[876-885]

Recommended Fix
Validate `wall_clock_secs` to a representable operational maximum when loading budgets, or construct the deadline with `checked_add` and stop the run cleanly on overflow. Ensure the error path still calls `finish`.

ⓘ 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 +299 to +301
self.last_task += 1;
let task = Task {
id: format!("t_{}", self.last_task),

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. Task creation can overflow ids 🐞 Bug ☼ Reliability

Board::load_from accepts a persisted t_18446744073709551615 identifier and assigns its numeric
suffix to last_task, while create increments that value with += 1. On the next task creation
this panics in checked builds or wraps in release builds, allowing a valid-looking tasks.json to
crash creation or reuse an identifier.
Agent Prompt
Issue description
The persisted task-ID counter can be loaded at `u64::MAX`, but creating the next task increments it without overflow handling. This can panic or reuse a task ID.

Fix Focus Areas
- src-tauri/src/coord.rs[276-313]
- src-tauri/src/coord.rs[402-422]

Recommended Fix
Use `checked_add` when allocating the next task ID and return a board error when the counter is exhausted. Optionally reject `u64::MAX` during load, but preserve the no-ID-reuse invariant in either path.

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

Comment thread src-tauri/src/manager.rs
Comment on lines +361 to +362
let ran = mcp_server::verify_gate(app, id, &cmd, &stopped);
m.verify.lock().unwrap_or_else(|e| e.into_inner()).insert(id.to_string(), cmd);

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. Completed runs retain check commands 🐞 Bug ☼ Reliability

verify_task always puts each command back into ManagerState.verify, including after a successful
final verification, and neither finish nor ManagerRunGuard clears that map. Each completed
manager run therefore retains its approved command strings indefinitely, so repeated runs grow the
application’s memory use even though old task checks can no longer be used.
Agent Prompt
Issue description
Approved verification commands remain in `ManagerState.verify` after their task and manager run have completed. Repeated runs retain otherwise unreachable command strings indefinitely.

Fix Focus Areas
- src-tauri/src/manager.rs[347-364]
- src-tauri/src/manager.rs[876-885]
- src-tauri/src/manager.rs[123-134]

Recommended Fix
Retain a command only while its task can still be reassigned, then remove it after a terminal verified or dropped outcome. Also clear any remaining run-owned verification entries during manager shutdown/finish.

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

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