Refactor document handling to JSON envelope

The `document.md` file has been replaced by `document.json`. This new
format acts as a JSON envelope, containing the original markdown content
along with metadata such as `covered_mtime`, `written_at`, and
`backend_id`.

This change addresses a bug where new recordings arriving during an LLM
analysis call could be ignored. The `covered_mtime` field in the new
JSON envelope ensures that the document's metadata accurately reflects
the state of recordings at the time of analysis, preventing incorrect
"analysis current" states.

Additionally, the `analysis_input.json` file is now removed upon
successful analysis, and a failure marker is used to indicate analysis
failures. This ensures that a case is re-analyzed if necessary.

The `analysis_idle_threshold_secs` configuration option has been
introduced to control the delay before a case in the `Required` state is
automatically promoted to `Idle` and enqueued for LLM analysis.
This commit is contained in:
2026-05-05 14:01:43 +02:00
parent c09a74cef3
commit 9e8db7518d
12 changed files with 180 additions and 38 deletions
+17 -2
View File
@@ -66,6 +66,7 @@ pub struct TestConfig {
whisper_url: Option<String>,
whisper_timeout_seconds: Option<u64>,
ollama_url: Option<String>,
idle_threshold_secs: Option<u64>,
label: &'static str,
}
@@ -85,6 +86,7 @@ impl TestConfig {
whisper_url: None,
whisper_timeout_seconds: None,
ollama_url: None,
idle_threshold_secs: None,
label: "common",
}
}
@@ -152,6 +154,15 @@ impl TestConfig {
self
}
/// Idle threshold in seconds: how long after the latest recording mtime
/// a `Required` case is auto-promoted to `Idle` (and enqueued). Default
/// is `Config::test_default()` (= `0`, eager). Tests that exercise the
/// "wait for quiet period" branch set a positive value.
pub fn with_idle_threshold(mut self, secs: u64) -> Self {
self.idle_threshold_secs = Some(secs);
self
}
/// Materialize the config alone. Bucket-B overrides (`with_llm`,
/// `with_whisper`, `with_ollama`) are silently dropped — call
/// [`build_pair`] when those need to take effect.
@@ -170,12 +181,16 @@ impl TestConfig {
.map(|u| (u.api_key.clone(), u.slug.clone()))
.collect();
let config = Arc::new(Config {
let mut config = Config {
data_path,
users: self.users,
api_keys,
..Config::test_default()
});
};
if let Some(v) = self.idle_threshold_secs {
config.analysis_idle_threshold_secs = v;
}
let config = Arc::new(config);
let mut settings = Settings::default();
// LLM-related fields used to live on `Settings`; with the multi-backend