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
@@ -427,48 +427,6 @@ export function createSidebarPageAiTargetRuntime(context) {
});
}
function pageAiOcrEligibleResourceKind(value) {
var normalized = String(value || '').trim().toLowerCase();
return normalized === 'image' || normalized === 'pdf' || normalized === 'attachment' || normalized === 'resource';
}
function pageAiOcrEligiblePath(value) {
var path = String(value || '').trim().toLowerCase();
return /\.(png|jpg|jpeg|webp|bmp|tif|tiff|pdf)$/.test(path);
}
function pageAiOcrBodyPreview(markdown) {
var body = String(markdown || '').replace(/^---\n[\s\S]*?\n---\n?/, '').trim();
return body.slice(0, 1600);
}
async function fetchPageAiOcrSidecarContext(editorTarget) {
return null;
}
async function pageAiEnrichOcrContextRefs(contextRefs, agentTargetPackage, editorTarget) {
var ocrContext = await fetchPageAiOcrSidecarContext(editorTarget);
if (!ocrContext) return { contextRefs, agentTargetPackage };
var nextRefs = pageAiNormalizeArray(contextRefs).map(function(ref) {
if (ref && ref.kind === 'active_editor') return Object.assign({}, ref, { ocrContext: ocrContext });
return ref;
});
var nextPackage = agentTargetPackage && typeof agentTargetPackage === 'object'
? Object.assign({}, agentTargetPackage, { ocrContext: ocrContext })
: agentTargetPackage;
if (nextPackage && nextPackage.currentFile && typeof nextPackage.currentFile === 'object') {
nextPackage.currentFile = Object.assign({}, nextPackage.currentFile, { ocrRootRelativePath: ocrContext.ocrRootRelativePath });
}
if (nextPackage && Array.isArray(nextPackage.targets)) {
nextPackage.targets = nextPackage.targets.map(function(target, index) {
return index === 0 && target && typeof target === 'object'
? Object.assign({}, target, { ocrContext: ocrContext })
: target;
});
}
return { contextRefs: nextRefs, agentTargetPackage: nextPackage };
}
function pageAiBuildAllowedRoots() {
return pageAiNormalizeArray(pageUiState.pageAiAllowedRoots).map(function(root) {
return {
@@ -790,7 +748,6 @@ export function createSidebarPageAiTargetRuntime(context) {
pageAiBuildAgentTargetPackage,
pageAiBuildAllowedRoots,
pageAiBuildContextRefs,
pageAiEnrichOcrContextRefs,
pageAiBuildRunTargetSnapshot,
pageAiCloneJson,
pageAiContextKindsFromRefs,