Refactor analysis file names

The versioning of analysis input and document files
(`analysis_input_v{N}.json`, `document_v{N}.md`) has been removed. All
analysis inputs will now use `analysis_input.json` and generated
documents will use `document.md`.

This simplifies file management, as there's no longer a need to track
and manage multiple versions of these files within a case directory. The
analysis worker will now overwrite the existing `document.md` if it
exists, ensuring that the latest analysis result is always present. The
`version` field has also been removed from `AnalyzeJob` and
`AnalysisInput`.
This commit is contained in:
2026-04-16 01:56:55 +02:00
parent 928c0659c1
commit 8c6b2eeaa4
9 changed files with 111 additions and 281 deletions
+6 -9
View File
@@ -5,7 +5,7 @@ use std::time::Duration;
use tokio::io::AsyncWriteExt;
use tracing::{error, info, warn};
use super::{llm, prompt, AnalysisInput, AnalyzeReceiver};
use super::{llm, prompt, AnalysisInput, AnalyzeReceiver, ANALYSIS_INPUT_FILE, DOCUMENT_FILE};
use crate::config::Config;
use crate::{BusyGuard, WorkerBusy};
@@ -23,7 +23,7 @@ pub async fn run(
while let Some(job) = rx.recv().await {
let _guard = BusyGuard::new(worker_busy.clone());
process(&job.case_dir, job.version, &config, &client, timeout).await;
process(&job.case_dir, &config, &client, timeout).await;
}
warn!("Analyze worker stopped (channel closed)");
@@ -31,13 +31,12 @@ pub async fn run(
async fn process(
case_dir: &Path,
version: u32,
config: &Config,
client: &reqwest::Client,
timeout: Duration,
) {
let input_path = case_dir.join(format!("analysis_input_v{version}.json"));
let document_path = case_dir.join(format!("document_v{version}.md"));
let input_path = case_dir.join(ANALYSIS_INPUT_FILE);
let document_path = case_dir.join(DOCUMENT_FILE);
// If the document already exists, the job is obsolete (e.g. recovery
// re-enqueued a finished case during a race). Skip silently.
@@ -69,7 +68,7 @@ async fn process(
if let Err(e) = tokio::fs::remove_file(&input_path).await {
warn!(path = %input_path.display(), error = %e, "removing analysis input failed");
}
info!(case = %case_dir.display(), version, "analysis done (stub, no recordings)");
info!(case = %case_dir.display(), "analysis done (stub, no recordings)");
return;
}
@@ -77,7 +76,6 @@ async fn process(
let total_chars = user_content.chars().count();
info!(
case = %case_dir.display(),
version,
recording_count = input.recordings.len(),
total_chars,
"sending to llm"
@@ -106,7 +104,7 @@ async fn process(
Err(e) => {
// Do not log the response body — LlmError::Display is already
// redacted, but reinforce the rule here for future readers.
error!(case = %case_dir.display(), version, error = %e, "llm call failed");
error!(case = %case_dir.display(), error = %e, "llm call failed");
return;
}
};
@@ -125,7 +123,6 @@ async fn process(
info!(
case = %case_dir.display(),
version,
bytes = document.len(),
"analysis done"
);