fix(notes): flush the appended note before reporting success

The note tool wrote through tokio's File and returned without flushing, so
the append could still be in flight on a blocking thread when the tool
reported "Note appended". Under parallel load the notes-symlink test read
the file before the bytes landed (2 of 4 runs of the approval/notes
filter). Flush before reporting success.

Tests: codewhale-tui filter `approval tool_call_budget constant_time
logout note project_overlay auth::` 483 passed / 1 failed, twice; the
note test passes in both. The one failure is
task_manager::tests::pending_approval_suspends_idle_and_timeout_denial_settles_failed,
a pre-existing race: runtime_threads tests set the process-global
TEST_APPROVAL_DECISION_TIMEOUT_MS that this test's drive reads; it passes
alone (1/0).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01R9rJEoMuUSRWznU6QjkE7h
This commit is contained in:
CodeWhale BotandClaude Opus 5.5 committed 2026-09-25 12:47:29 -07:00
1 parent 000ab6b65a
commit 133a8a205f
1 file changed
+5
+5
View File
@@ -6704,6 +6704,11 @@ impl ToolSpec for NoteTool {
file.write_all(format!("\n---\n{note_content}\n").as_bytes())
.await
.map_err(|e| ToolError::execution_failed(format!("Failed to write note: {e}")))?;
// tokio's File finishes a write on a background thread; report
// success only once the bytes reached the file.
file.flush()
.await
.map_err(|e| ToolError::execution_failed(format!("Failed to write note: {e}")))?;
Ok(ToolResult::success(format!(
"Note appended to {}",