Riapplica la fase 5 di aKode (86e7c72e) sulla base ripulita:
- crate codex-* -> akode-*, codex-rs -> akode-rs, codex-cli -> akode-cli, binario e ausiliari akode;
- ~/.codex -> ~/.akode, CODEX_HOME -> AKODE_HOME, variabili CODEX_* -> AKODE_*, .codex/ -> .akode/ di progetto;
nessun fallback a ~/.codex o a CODEX_*;
- testi per l'utente "Codex" -> "aKode"; testi verso il modello e istruzioni di sistema invariati;
- snapshot insta rinominati (non ancora rigenerati).
I conflitti con la base ripulita sono stati risolti riapplicando la rinomina ai file senza le
funzioni di imeAI (script di mappa dei token per file).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
102 lines
3.1 KiB
Rust
102 lines
3.1 KiB
Rust
//! A Guardian board seeded with the same routed originals the housekeeper writes.
|
|
|
|
use crate::board_host::Host;
|
|
use crate::retrieval_host;
|
|
use akode_guardian_v3::EvidenceId;
|
|
use akode_guardian_v3::local_board;
|
|
use akode_history::RolloutItem;
|
|
use akode_message_board::AppendRequest;
|
|
use akode_message_board::LocalAgentMessageBoard;
|
|
use akode_message_board::PostDestination;
|
|
use akode_message_board::UpsertChannelRequest;
|
|
use akode_protocol::AgentPath;
|
|
use akode_protocol::ThreadId;
|
|
use akode_protocol::models::FunctionCallOutputPayload;
|
|
use akode_protocol::models::ResponseItem;
|
|
use akode_state::SqliteConfig;
|
|
use serde::Serialize;
|
|
use std::sync::Arc;
|
|
use tempfile::TempDir;
|
|
|
|
pub(super) struct EvidenceBoard {
|
|
pub host: Arc<Host>,
|
|
pub writer: LocalAgentMessageBoard,
|
|
owner: ThreadId,
|
|
_directory: TempDir,
|
|
}
|
|
|
|
impl EvidenceBoard {
|
|
pub async fn new(
|
|
owner: ThreadId,
|
|
reviewer: ThreadId,
|
|
channels: &[&str],
|
|
) -> anyhow::Result<Self> {
|
|
let path = AgentPath::root()
|
|
.join("reviewer")
|
|
.map_err(anyhow::Error::msg)?;
|
|
let host = retrieval_host([(owner, AgentPath::root()), (reviewer, path)]);
|
|
let directory = tempfile::tempdir()?;
|
|
let writer = local_board(
|
|
SqliteConfig::new_for_testing(directory.path().to_path_buf().try_into()?),
|
|
owner.into(),
|
|
)
|
|
.read_write()
|
|
.open(host.clone())
|
|
.await?;
|
|
for &channel in channels {
|
|
writer
|
|
.upsert_channel(
|
|
owner,
|
|
UpsertChannelRequest {
|
|
channel_name: channel.into(),
|
|
description: String::new().try_into()?,
|
|
},
|
|
)
|
|
.await?;
|
|
}
|
|
Ok(Self {
|
|
host,
|
|
writer,
|
|
owner,
|
|
_directory: directory,
|
|
})
|
|
}
|
|
|
|
pub async fn append(&self, ordinal: u64, channel: &str, output: &str) -> anyhow::Result<()> {
|
|
self.writer
|
|
.append(
|
|
self.owner,
|
|
AppendRequest {
|
|
request_id: serde_json::to_string(&(ordinal, channel))?,
|
|
destination: PostDestination::Channel(channel.into()),
|
|
text: serde_json::to_string(&routed_original(ordinal, output))?,
|
|
},
|
|
)
|
|
.await?;
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
pub(super) fn routed_original(ordinal: u64, output: &str) -> impl Serialize {
|
|
// Preserve the housekeeper's field order as well as the original wire contents.
|
|
#[derive(Serialize)]
|
|
struct RoutedSource {
|
|
id: EvidenceId,
|
|
original: RolloutItem,
|
|
}
|
|
RoutedSource {
|
|
id: EvidenceId { ordinal },
|
|
original: RolloutItem::ResponseItem(
|
|
ResponseItem::FunctionCallOutput {
|
|
id: None,
|
|
call_id: None,
|
|
name: None,
|
|
namespace: None,
|
|
output: FunctionCallOutputPayload::from_text(output.to_owned()),
|
|
internal_chat_message_metadata_passthrough: None,
|
|
}
|
|
.into(),
|
|
),
|
|
}
|
|
}
|