9e8db7518d
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.
31 lines
1.4 KiB
Rust
31 lines
1.4 KiB
Rust
//! Re-exports of case-directory artefact filenames from their
|
|
//! canonical source-of-truth locations.
|
|
//!
|
|
//! Tests that need to read, write, or assert the absence of per-case
|
|
//! artefacts (`oneliner.json`, `.closed`, `document.json`,
|
|
//! `analysis_input.json`) pull these names from here instead of
|
|
//! inlining string literals. If the server renames a sidecar in the
|
|
//! future, test call-sites fail to compile instead of silently
|
|
//! asserting against the old name.
|
|
|
|
use std::path::Path;
|
|
|
|
pub use doctate_common::ONELINER_FILENAME;
|
|
pub use doctate_server::analyze::{ANALYSIS_INPUT_FILE, DOCUMENT_FILE, Document};
|
|
pub use doctate_server::paths::CLOSE_MARKER;
|
|
|
|
/// Seed a `document.json` for tests. `covered_mtime` is the RFC3339
|
|
/// snapshot mtime the document is supposed to "cover" — for tests that
|
|
/// don't care about the auto-trigger state machine, pass any RFC3339
|
|
/// string (e.g. `"1970-01-01T00:00:00Z"`).
|
|
pub fn write_document_for_test(case_dir: &Path, content_md: &str, covered_mtime: &str) {
|
|
let doc = Document {
|
|
covered_mtime: covered_mtime.to_owned(),
|
|
written_at: doctate_common::timestamp::now_rfc3339(),
|
|
backend_id: "test".to_owned(),
|
|
content_md: content_md.to_owned(),
|
|
};
|
|
let bytes = serde_json::to_vec_pretty(&doc).expect("serialize test Document");
|
|
std::fs::write(case_dir.join(DOCUMENT_FILE), bytes).expect("write test document.json");
|
|
}
|