Rinomina: crate akode-*, cartelle akode-rs/ e akode-cli/, binario akode, ~/.akode, AKODE_* (A)

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>
This commit is contained in:
andrea.difonzo
2026-11-17 12:37:52 +01:00
parent e37a0deba9
commit 7c1c6dfa8d
10306 changed files with 748026 additions and 748088 deletions

View File

@@ -0,0 +1,125 @@
//! Stateless selection of original host-verified question/answer records.
//! Omit a record atomically when it cannot fit; never truncate a restriction out of a grant.
use akode_history::RetainedContext;
use akode_history::RetainedContextEntry;
use akode_history::VerifiedAnswer;
use crate::GuardianRootMessage;
use crate::retained_instructions::source_order_labels;
/// Request-bounded answers and whether they are complete enough for cached fast approval.
pub struct RenderedVerifiedAnswers {
pub fragments: Vec<String>,
pub complete: bool,
}
/// Renders each response with its original source roles and the existing approximate per-answer budget.
pub fn render_verified_answers(context: &RetainedContext) -> RenderedVerifiedAnswers {
let mut complete = context.verified_answers_complete();
let mut fragments = Vec::new();
for (order, entry) in source_order_labels(context) {
let RetainedContextEntry::VerifiedAnswer(answer) = entry else {
continue;
};
if let Some(text) = render_verified_answer(answer) {
// The bounded order label is framing, not part of the existing answer budget.
fragments.push(format!("Retained source order: {order}\n{text}"));
} else {
complete = false;
}
}
if !complete {
fragments.insert(
/*index*/ 0,
GuardianRootMessage::IncompleteVerifiedAnswers.render(),
);
}
RenderedVerifiedAnswers {
fragments,
complete,
}
}
/// Selects one complete response, preserving both sides of every question/answer pair.
/// Returning None means the caller must account for missing evidence, not partial permission.
pub fn render_verified_answer(answer: &VerifiedAnswer) -> Option<String> {
let text = render_original_verified_answer(answer);
answer_fits(text.len()).then_some(text)
}
/// Renders original question/answer bodies without making a request-selection decision.
pub fn render_original_verified_answer(answer: &VerifiedAnswer) -> String {
answer
.questions
.iter()
.map(|pair| {
format!(
"{}{}",
GuardianRootMessage::Assistant(pair.question.clone()).render(),
GuardianRootMessage::User(pair.answer.clone()).render()
)
})
.collect::<String>()
}
/// One role-labeled answer or host framing, with original answer cost when not yet admitted.
#[derive(Clone, PartialEq)]
pub struct TrustedUserAnswer {
pub(crate) text: String,
pub(crate) protected: bool,
pub(crate) answer_bytes: Option<usize>,
}
impl std::fmt::Debug for TrustedUserAnswer {
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter
.debug_struct("TrustedUserAnswer")
.field("answer_bytes", &self.answer_bytes)
.finish_non_exhaustive()
}
}
impl From<String> for TrustedUserAnswer {
fn from(text: String) -> Self {
let protected = text == crate::authorization::TRUSTED_ANSWERS_START
|| text == ">>> TRUSTED USER ANSWERS END\n"
|| text == GuardianRootMessage::IncompleteVerifiedAnswers.render();
Self {
text,
protected,
answer_bytes: None,
}
}
}
impl From<&str> for TrustedUserAnswer {
fn from(text: &str) -> Self {
text.to_owned().into()
}
}
/// Collects originals for sync preparation without applying the per-answer request limit.
pub fn collect_verified_answer_candidates(context: &RetainedContext) -> Vec<TrustedUserAnswer> {
let mut items = Vec::new();
if !context.verified_answers_complete() {
items.push(
GuardianRootMessage::IncompleteVerifiedAnswers
.render()
.into(),
);
}
for (order, entry) in source_order_labels(context) {
if let RetainedContextEntry::VerifiedAnswer(answer) = entry {
let text = render_original_verified_answer(answer);
items.push(TrustedUserAnswer {
protected: false,
answer_bytes: Some(text.len()),
text: format!("Retained source order: {order}\n{text}"),
});
}
}
items
}
pub(crate) use crate::preparation::answer_fits;