Files
codex/codex-rs/ext/agent-message-board/examples/configure_board.rs
T
Dmitriy Kovalenko 480ab2d006 Add managed enforcement of DELETE journaling on NFS (#57225)
## Why

Existing databases retain their journal mode, so selecting `DELETE` for new NFS databases leaves existing WAL databases unchanged.

## What changed

- Add the managed `unsafe_enforce_sqlite_journal_mode` requirement to migrate existing NFS databases before opening writable pools and require `DELETE` on each connection.
- Share migration code between startup and `codex migrate-nfs-db`, preserving WAL backups and resuming interrupted replacements, including lazily opened databases.
- Hold the migration lock through pool initialization and keep migration failures out of automatic corruption recovery.
- Preserve local logs behavior and skip legacy NFS logs cleanup when enforcement is enabled.

## Testing

Add coverage for requirement precedence, database settings, data and backup preservation across restarts, interrupted replacement recovery, refusal of active WAL databases, migration lock waiting, and local logs remaining in WAL mode.

GitOrigin-RevId: da41ec1b58b1ee8092591cdf8b358280928ff9d4
2026-10-26 20:10:45 +00:00

30 lines
1.2 KiB
Rust

//! Operator-only setup for local experiments; no administrative agent tools.
use codex_agent_message_board_extension::local_board_options;
use codex_message_board::LocalBoardSetup;
use codex_message_board::configure_local_board;
use codex_protocol::SessionId;
use codex_state::SqliteConfig;
use std::path::PathBuf;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let args: Vec<_> = std::env::args_os().collect();
let [_, sqlite_home, board, input] = args.as_slice() else {
return Err("Usage: configure_board <sqlite-home> <board-session-id> <setup.json>".into());
};
let sqlite = SqliteConfig::from_sqlite_home_with_nfs_enforcement(
std::path::absolute(PathBuf::from(sqlite_home))?.try_into()?,
/*enforce_delete_on_nfs*/ false,
);
let board = SessionId::from_string(board.to_str().ok_or("invalid board ID")?)?;
let input = tokio::fs::read(input).await?;
if input.len() > 64 * 1024 {
return Err("setup file exceeds 64 KiB".into());
}
let setup: LocalBoardSetup = serde_json::from_slice(&input)?;
configure_local_board(&sqlite, &local_board_options(), board, setup).await?;
println!("Configured local board {board}");
Ok(())
}