优化:未分类连续维护与柏拉图预汇总,同步已发布修复

This commit is contained in:
2026-11-01 12:40:50 +08:00
parent 572873c6b8
commit 38290f5fec
135 changed files with 17613 additions and 663 deletions
+20 -3
View File
@@ -54,9 +54,26 @@ function visualBinding(turn: Data, result: Data): Data | undefined {
* or reuse the mutable current session context for an older turn. */
export function analysisScopeText(turn: Data): string {
const result = record(turn.result), plan = record(turn.plan || result.plan);
const contexts = [record(plan.context), record(plan.frozenContext), record(result.context), record(turn.context)];
const durable = Object.keys(result).length ? result : turn;
const historyReport = durable.completionMethod === 'confirmed_history_report';
let historyContext: Data | undefined;
if (historyReport) {
const sources = new Set((Array.isArray(durable.historySources) ? durable.historySources : [])
.map(record).filter(source => source.available === true).map(source => source.turnId));
const frames = (Array.isArray(durable.historySections) ? durable.historySections : []).map(record)
.filter(section => sources.has(section.sourceTurnId) && analysisPeriodText(section.period))
.map(section => ({ ...record(section.filters), period: section.period,
...(section.comparisonPeriod ? { comparisonPeriod: section.comparisonPeriod } : {}),
...(section.stage ? { stage: section.stage } : {}), view: 'overall' }));
// A multi-scope report describes each source beside its own table. The
// chat's current query context must not label the whole report as one month
// or one organization.
if (!frames.length || new Set(frames.map(canonical)).size !== 1) return '';
historyContext = frames[0];
}
const contexts = historyReport ? [historyContext!] : [record(plan.context), record(plan.frozenContext), record(result.context), record(turn.context)];
const context = contexts.find(value => BINDING_KEYS.some(key => meaningful(value[key])));
const visual = visualBinding(turn, result);
const visual = historyReport ? undefined : visualBinding(turn, result);
const visualContext = visual ? { ...visual, ...record(visual.period) } : undefined;
const compatible = context && visualContext && BINDING_KEYS.filter(key => meaningful(context[key]))
.every(key => key === 'stage' && ['all', 'combined'].includes(String(context.stage)) && !meaningful(visualContext.stage)
@@ -64,7 +81,7 @@ export function analysisScopeText(turn: Data): string {
const binding = compatible ? { ...context, ...visual } : context || visual;
if (!binding) return '';
if (meaningful(binding.exclusions) && !isValidAnalysisExclusions(binding.exclusions)) return '';
const semantic = record(plan.semantic);
const semantic = historyReport ? {} : record(plan.semantic);
const period = analysisPeriodText(binding.period || binding);
// Legacy semantic plans store a comparison query in priorContext only when
// compare is explicitly true; an unmarked previous context is not evidence.