feat(rag): harden post-LightRAG runtime

Retire legacy OCR/media/evidence fallbacks, add local-folder event bus and Page Aggregate guards, and archive completed design checklists.

Validation: cargo test -p mnote-web -- --test-threads=1; cargo test --workspace -- --test-threads=1; git diff --check; codegraph sync .; codegraph_status.
This commit is contained in:
lix-2026
2026-06-07 10:35:21 +08:00
parent 22a92edcda
commit 9551d4c1dc
59 changed files with 4053 additions and 5249 deletions
+56 -5
View File
@@ -2,7 +2,8 @@ use crate::app::AppConfig;
use crate::context::RequestContext;
use crate::error::WebError;
use bridge_runtime::{
build_runtime_command_artifact_plan, RuntimeCommandArtifactPlan, RuntimeCommandExecutionPlan,
build_runtime_command_artifact_plan, retired_command_transport_function_name,
retired_query_transport_function_name, RuntimeCommandArtifactPlan, RuntimeCommandExecutionPlan,
RuntimeQueryExecutionPlan,
};
use serde_json::Value;
@@ -48,9 +49,15 @@ fn load_query_fixture(
.with_header("x-error-phase", "fixture_parse")
})?;
Ok(fixtures
.as_object()
.and_then(|map| map.get(plan.function_name.as_str()))
let Some(map) = fixtures.as_object() else {
return Ok(None);
};
if let Some(fixture) = map.get(plan.function_name.as_str()) {
return Ok(Some(fixture.clone()));
}
Ok(retired_query_transport_function_name(&plan.query_name)
.ok()
.and_then(|legacy_name| map.get(legacy_name))
.cloned())
}
@@ -88,7 +95,51 @@ fn load_mutation_fixture(
context: &RequestContext,
plan: &RuntimeCommandExecutionPlan,
) -> Result<Option<Value>, WebError> {
load_mutation_fixture_by_name(config, context, plan.function_name.as_str())
if let Some(fixture) =
load_mutation_fixture_by_name(config, context, plan.function_name.as_str())?
{
return Ok(Some(fixture));
}
if let Some(legacy_name) = resource_lifecycle_transport_function_name(plan) {
if let Some(fixture) = load_mutation_fixture_by_name(config, context, legacy_name)? {
return Ok(Some(fixture));
}
}
retired_command_transport_function_name(&plan.command_name)
.ok()
.map(|legacy_name| load_mutation_fixture_by_name(config, context, legacy_name))
.transpose()
.map(|fixture| fixture.flatten())
}
fn resource_lifecycle_transport_function_name(
plan: &RuntimeCommandExecutionPlan,
) -> Option<&'static str> {
let action = match plan.command_name.as_str() {
"tree.resource.archive" => "archive",
"tree.resource.restore" => "restore",
"tree.resource.purge" => "purge",
"tree.resource.rename" => "rename",
_ => return None,
};
let resource_kind = plan
.args_json
.get("resourceLifecyclePlan")
.and_then(|value| value.get("resourceKind"))
.or_else(|| plan.args_json.get("resourceKind"))
.and_then(Value::as_str)?;
match (action, resource_kind) {
("archive" | "restore" | "rename", "file" | "media") => Some("mediaAssets:patchById"),
("purge", "file" | "media") => Some("mediaAssets:purgeById"),
("archive", "mindmap") => Some("mindmaps:softDelete"),
("restore", "mindmap") => Some("mindmaps:restore"),
("purge", "mindmap") => Some("mindmaps:purge"),
("archive", "table") => Some("tables:remove"),
("restore", "table") => Some("tables:restore"),
("purge", "table") => Some("tables:purge"),
("rename", "table") => Some("tables:update"),
_ => None,
}
}
pub async fn execute_retired_query_plan(