fix(app): MCP discovery never blocks a turn; secrets masked as lines are written; TTS child gets no MCP secrets
- Discovery runs outside the MCP tool cache's lock (one at a time), so a turn reading the cached tools never waits for a slow server; a new conversation refreshes in the background. - The log hub masks secrets before a line is kept or written, so a key replaced or removed later stays hidden on the screen, in copies, files and exports, also after a restart. - The worker takes JARVIS_MCP_ENV out of its environment at start, before MeloTTS runs, and hands it to the brain. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -110,8 +110,11 @@ STT, LLM and TTS lines go to `stt`, `llm`, `tts` by their worker category), `bro
|
||||
- `export_zip(from, to, out)`: the log files of those days in a zip, at most 10 MB (Discord's file
|
||||
limit): when larger, the oldest lines by the time they were logged, across every tab's file, are
|
||||
left out and a note says how many.
|
||||
- Every copy and export runs through `redact`: each stored secret's value, and anything shaped like
|
||||
a Discord bot token (also with sentence dots around it), becomes `[비밀값]`.
|
||||
- Every line runs through `redact` before it is kept or written to a file, and every copy and
|
||||
export again: each stored secret's value, and anything shaped like a Discord bot token (also with
|
||||
sentence dots around it), becomes `[비밀값]`. So a secret replaced or removed later (the hub then
|
||||
no longer knows the old value) never shows on the screen, in a copy, a file or an export, also
|
||||
after a restart.
|
||||
- Errors the voice worker reports to the app (`error` messages: code and request id) are always
|
||||
logged, debug logging or not, so the log screen and the error report show them.
|
||||
|
||||
@@ -362,7 +365,8 @@ the TTS speed reaching the worker's arguments; features and MCP servers (read an
|
||||
the key, the feature tools named as the brain names them, only enabled servers in the brain's
|
||||
settings without values, stored values passed for enabled servers only, values of removed servers
|
||||
and names deleted, a value refused for an unsaved server, kept out of the settings file and masked
|
||||
in logs, also by a new app on the same folder); chat channel names and topics (only new or edited
|
||||
in logs, also by a new app on the same folder, and a value replaced or removed later still masked
|
||||
in lines written before); chat channel names and topics (only new or edited
|
||||
syncing channels sent, the topic limit refused before saving, Discord's form of the name written
|
||||
back, a missing permission failing with the reason and the text kept, a rate-limited edit pending
|
||||
and retried once with the latest text, a new channel never clearing Discord (also on its retry), a
|
||||
|
||||
@@ -91,7 +91,7 @@ impl LogHub {
|
||||
self.cleanup(Local::now().date_naive());
|
||||
}
|
||||
|
||||
/// The stored secrets' values, masked in every copy and export.
|
||||
/// The stored secrets' values, masked in every line from now on (and again in copies and exports).
|
||||
pub fn set_secrets(&self, values: Vec<String>) {
|
||||
self.state.lock().unwrap().secrets = values;
|
||||
}
|
||||
@@ -118,7 +118,10 @@ impl LogHub {
|
||||
|
||||
fn push_at(&self, at: DateTime<Local>, level: Level, tab: &str, text: &str) {
|
||||
let mut s = self.state.lock().unwrap();
|
||||
let line = LogLine { seq: s.next_seq, at_ms: at.timestamp_millis(), level, tab: tab.into(), text: text.into() };
|
||||
// Masked before it is kept or written, so a secret replaced or removed later (the hub then
|
||||
// no longer knows the old value) never shows on the screen, in a copy, a file or an export.
|
||||
let text = redact(text, &s.secrets);
|
||||
let line = LogLine { seq: s.next_seq, at_ms: at.timestamp_millis(), level, tab: tab.into(), text };
|
||||
s.next_seq += 1;
|
||||
if let Some(dir) = s.dir.clone() {
|
||||
let day = at.date_naive();
|
||||
@@ -479,6 +482,30 @@ mod tests {
|
||||
assert!(!all.contains("late on the first") && all.contains("early on the second"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_secret_is_masked_when_the_line_is_written_so_removing_or_replacing_it_later_shows_nothing() {
|
||||
let dir = temp_dir("logwrite");
|
||||
let hub = LogHub::new(Some(&dir));
|
||||
hub.set_secrets(vec!["old-api-key-1".into()]);
|
||||
hub.push_at(Local::now(), Level::Error, "llm", "server refused old-api-key-1");
|
||||
// The key is replaced (or its server removed): the hub no longer knows the old value.
|
||||
hub.set_secrets(vec!["new-api-key-2".into()]);
|
||||
let shown: String = hub.query(None, Level::Debug, None, None, 100).iter().map(|l| l.text.clone()).collect();
|
||||
assert!(shown.contains("server refused [비밀값]") && !shown.contains("old-api-key-1"), "{shown}");
|
||||
assert!(!hub.recent_error_report("0.1.0").unwrap().contains("old-api-key-1"));
|
||||
// After a restart a new hub reads the files: the value was never written.
|
||||
// Today's file (a new hub removes files older than the retention).
|
||||
let today = Local::now().date_naive();
|
||||
let file = std::fs::read_to_string(dir.join(format!("llm-{today}.log"))).unwrap();
|
||||
assert!(!file.contains("old-api-key-1"), "{file}");
|
||||
let out = dir.join("after.zip");
|
||||
LogHub::new(Some(&dir)).export_zip(today, today, &out).unwrap();
|
||||
let mut z = zip::ZipArchive::new(std::fs::File::open(&out).unwrap()).unwrap();
|
||||
let mut text = String::new();
|
||||
std::io::Read::read_to_string(&mut z.by_name(&format!("llm-{today}.log")).unwrap(), &mut text).unwrap();
|
||||
assert!(!text.contains("old-api-key-1"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_zip_stays_under_the_limit_by_leaving_out_the_oldest_lines() {
|
||||
let dir = temp_dir("logzip");
|
||||
|
||||
Reference in New Issue
Block a user