Repository navigation
M0 Foundations (v0.3.0 milestone 0): non-vacuous security guards, crash log, dead-thread banner, beta channel, N-client harness, agent.rs - #3
Conversation
…le thread death, a beta channel, an N-client harness, and agent.rs Foundations for the v0.3.0 multi-agent hub. No feature, no behaviour change: generate_handler! is byte-identical to v0.2.9 and every function moved into agent.rs is byte-identical apart from pub(crate) visibility (verified by extracting each body from v0.2.9 and comparing). STAB-1 Several source-grep security tests would have PASSED with the guarded code deleted — a grep for zero bad occurrences passes on an empty file. Each now asserts a floor (commands > 20, callers == 3) over one shared GREPPED list that spans lib.rs and agent.rs, and evals/rust-source.mjs takes a file list. Proven by deleting a #[tauri::command] and a pty_write_internal( site and watching the guard go red. STAB-4 A panic hook writes "version ts payload" to config_dir()/crash.log, truncated past 64 KB, never over the network. /crash prints the tail. STAB-5 An EmitOnDrop guard at the top of the PTY reader and painter threads: a dead reader emits pty-exit, a dead painter emits paint-dead and the frontend paints a banner, so a hung terminal says so instead of freezing silently. STAB-6 The prerelease channel verified and documented: a -beta tag is --prerelease and never --latest, so the updater endpoint (releases/latest) cannot serve a beta to a stable copy. release.test.mjs pins the shape. STAB-2 An N-client harness drives the real listener with a Stub backend: 8 simultaneous run_command -> exactly one reaches the backend, seven get isError; 8 sequential -> peak concurrency 1; a panicking holder frees the slot. A separate race test throws 8 threads at agent_claim on one AgentState and proves exactly one wins — and goes red if the swap becomes load-then-store. STAB-3 agent.rs: AgentState, agent_claim/decide/abort, MIN_REVIEW, decision_stands, agent_propose, AgentRunGuard, agent_loop, AI_AGENT, render_tools, parse_agent_reply moved out of lib.rs. Task, is_dangerous, one_line and ai_call stay. Marked SIGN-OFF #2 in the plan: the only non-move lines are `use super::*;` and one pub(crate) re-export of SeqCst. Also: the two fake-shell tests could flake under a parallel run (ETXTBSY on a just-written script); they now serialise on a mutex. 177 -> 183 backend tests.
|
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 QodoHarden crash diagnostics, security guards, and agent concurrency
AI Description
Diagram
High-Level Assessment
Files changed (9)
|
Code Review by Qodo
1. Crash logs can exceed their disk cap
|
| if std::fs::metadata(path).is_ok_and(|m| m.len() > CRASH_LOG_CAP) { | ||
| let _ = std::fs::remove_file(path); |
There was a problem hiding this comment.
1. Crash logs can exceed their disk cap 🐞 Bug ☼ Reliability
crash_line passes the complete sanitized one_line(payload) to append_crash, which checks only the pre-write file size before appending the unbounded entry and does not serialize concurrent writers. An oversized panic payload or simultaneous panics can push crash.log far beyond 64 KiB, and /crash then reads the entire oversized file before selecting its tail.
Agent Prompt
## Issue description
The crash logger checks the existing file size but does not bound the incoming formatted entry or serialize concurrent panic hooks, so a single large payload or concurrent writes can exceed the advertised 64 KiB cap and leave `/crash` reading an oversized file.
## Fix Focus Areas
- src-tauri/src/lib.rs[2017-2052]
- src-tauri/src/lib.rs[2839-2861]
## Recommended Fix
Serialize the size-check and append operation, and bound each formatted crash entry while accounting for the version, timestamp, and newline. Reset or truncate the file based on the projected post-write size so both oversized and normal entries preserve `CRASH_LOG_CAP`, keep `/crash` operating on the bounded file, and extend the tests with an oversized entry and concurrent writers that assert the resulting file never exceeds the cap.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| // `[0-9.]+` stopped at the hyphen, so on a prerelease version it captured nothing at all and | ||
| // this test failed with an empty list however the README was written — it could not be | ||
| // satisfied by a beta. The suffix is part of the filename, so it is part of the capture. | ||
| const NAMED_IN_README = /Tachyon_(\d+\.\d+\.\d+(?:-[0-9A-Za-z.]+)?)_/g; |
There was a problem hiding this comment.
2. Valid beta versions fail release checks 🐞 Bug ≡ Correctness
NAMED_IN_README permits dots and alphanumeric characters after the first prerelease hyphen but stops when another hyphen appears. A version accepted by both production release gates, such as 0.3.0-beta-rc.1, is therefore captured as 0.3.0-beta and fails the README version assertion before release.
Agent Prompt
## Issue description
The README filename parser rejects prerelease suffixes containing more than one hyphen even though the release workflow and script accept them.
## Fix Focus Areas
- scripts/release.test.mjs[164-175]
- scripts/release.mjs[5-9]
- .github/workflows/release.yml[43-48]
## Recommended Fix
Allow hyphens throughout the prerelease capture while preserving the filename delimiter, and add a test using a version such as `0.3.0-beta-rc.1`. Keep the accepted version grammar aligned with the workflow and release script.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| const GREPPED: &[(&str, &str)] = &[ | ||
| ("lib.rs", include_str!("lib.rs")), | ||
| ("agent.rs", include_str!("agent.rs")), | ||
| ("mcp_server.rs", include_str!("mcp_server.rs")), |
There was a problem hiding this comment.
3. One command module escapes the guard 🐞 Bug ⚙ Maintainability
GREPPED omits local_models.rs even though that module defines a command registered in the application handler list. Moving or adding a Task argument there would evade task_is_never_an_ipc_argument, while the coarse command-count floor would still pass using commands from the listed files.
Agent Prompt
## Issue description
The generalized command security scan omits a module that already contains a registered bridge command, leaving the guard incomplete despite its non-vacuity floor.
## Fix Focus Areas
- src-tauri/src/lib.rs[2412-2416]
- src-tauri/src/lib.rs[2362-2397]
- src-tauri/src/lib.rs[4296-4313]
- src-tauri/src/local_models.rs[225-228]
## Recommended Fix
Add `local_models.rs` to the scanned source list and make the guard verify coverage against the commands registered in `generate_handler!`, rather than relying only on a total-count floor that cannot detect an omitted module.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| for (event, text) in [ | ||
| ("pty-exit", "[process exited]"), | ||
| ("paint-dead", "[tachyon] repaint thread died — the screen is frozen; restart tachyon"), | ||
| ] { | ||
| let term = term.clone(); | ||
| listen("pty-exit", move |_| { | ||
| listen(event, move |_| { | ||
| let t = term.borrow(); | ||
| let row = (t.cursor.line + 1).min(t.rows.saturating_sub(1)); | ||
| let (x, y, _, _) = t.cell_px(0, row); | ||
| t.ctx.set_font(&format!("{}px {}", t.font_px, t.font_family)); | ||
| t.ctx.set_fill_style_str(crate::theme::tokens(&settings_theme()).err); | ||
| let _ = t.ctx.fill_text("[process exited]", x, y); | ||
| let _ = t.ctx.fill_text(text, x, y); |
There was a problem hiding this comment.
4. Thread-failure warnings can disappear 🐞 Bug ☼ Reliability
The new paint-dead listeners call fill_text directly on the canvas without storing the warning in terminal state or reserving a row that redraw preserves. If the painter dies before the mount-time full repaint arrives, a grid-damage event is delivered later, or the window is resized or refitted, the canvas is redrawn only from buffered terminal cells and the sole indication that the still-frozen backend is dead is removed.
Agent Prompt
## Issue description
Dead-thread warnings exist only as transient canvas pixels, so later full or damaged redraws—including mount-time repaint, grid damage, resize, and refit—can remove the warning while the backend remains dead.
## Fix Focus Areas
- ui/src/terminal.rs[265-283]
- ui/src/terminal.rs[426-429]
- ui/src/terminal.rs[630-641]
- ui/src/terminal.rs[729-745]
- ui/src/terminal.rs[769-776]
## Recommended Fix
Store the active backend-thread failure banner in terminal UI state and render it as an overlay after every full or damaged redraw. Have the event listener update that state before requesting a redraw instead of calling `fill_text` as a one-off operation, and keep the banner visible until the terminal is restarted or a new PTY lifecycle explicitly clears it.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Milestone 0 of the v0.3.0 plan. Foundations only — no feature, no behaviour change. Ships to everyone as v0.2.10.
183 backend tests (was 177) · 49 frontend · zero warnings.
generate_handler!byte-identical to v0.2.9.crash.log(64 KB cap, never networked) +/crash.-betatags are--prerelease, never--latest, so the updater cannot serve a beta to stable copies.agent_claimadmits exactly one of 8 threads.agent.rs. Every moved body verified byte-identical to v0.2.9 modulopub(crate); the only non-move lines areuse super::*;and one re-export.Also fixes a rare ETXTBSY flake in the two fake-shell tests (serialised).
Not verified
The dead-thread banner and
/crashhave not been seen in the running app.