feat(ssa): Complete QPER architecture - Query, Planner, Execute, Reflection layers
Implement the full QPER intelligent analysis pipeline: - Phase E+: Block-based standardization for all 7 R tools, DynamicReport renderer, Word export enhancement - Phase Q: LLM intent parsing with dynamic Zod validation against real column names, ClarificationCard component, DataProfile is_id_like tagging - Phase P: ConfigLoader with Zod schema validation and hot-reload API, DecisionTableService (4-dimension matching), FlowTemplateService with EPV protection, PlannedTrace audit output - Phase R: ReflectionService with statistical slot injection, sensitivity analysis conflict rules, ConclusionReport with section reveal animation, conclusion caching API, graceful R error classification End-to-end test: 40/40 passed across two complete analysis scenarios. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -195,12 +195,50 @@ ggplot(df, aes(x = .data[[var_x]], y = .data[[var_y]])) +
|
||||
if (final_method == "pearson" && !is.null(result$conf.int)) {
|
||||
output_results$conf_int <- as.numeric(result$conf.int)
|
||||
}
|
||||
|
||||
|
||||
# ===== 构建 report_blocks =====
|
||||
blocks <- list()
|
||||
|
||||
# Block 1: 分析概况
|
||||
blocks[[length(blocks) + 1]] <- make_kv_block(list(
|
||||
"变量 X" = var_x,
|
||||
"变量 Y" = var_y,
|
||||
"样本量" = as.character(n),
|
||||
"分析方法" = final_method
|
||||
), title = "分析概况")
|
||||
|
||||
# Block 2: 相关分析结果表
|
||||
ci_str <- if (final_method == "pearson" && !is.null(result$conf.int)) {
|
||||
sprintf("[%.3f, %.3f]", result$conf.int[1], result$conf.int[2])
|
||||
} else {
|
||||
"-"
|
||||
}
|
||||
corr_headers <- c("r 值", "P 值", "95% CI", "相关强度")
|
||||
corr_rows <- list(c(
|
||||
as.character(round(r_value, 4)),
|
||||
format_p_value(p_value),
|
||||
ci_str,
|
||||
r_interpretation
|
||||
))
|
||||
blocks[[length(blocks) + 1]] <- make_table_block(corr_headers, corr_rows, title = "相关分析结果")
|
||||
|
||||
# Block 3: 散点图
|
||||
if (!is.null(plot_base64)) {
|
||||
blocks[[length(blocks) + 1]] <- make_image_block(plot_base64, title = "散点图", alt = paste(var_x, "vs", var_y))
|
||||
}
|
||||
|
||||
# Block 4: 结论摘要
|
||||
conclusion_text <- glue(
|
||||
"**{var_x}** 与 **{var_y}** 的 {final_method} 相关系数为 r = {round(r_value, 3)} (P {format_p_value(p_value)}),相关强度为 **{r_interpretation}**。"
|
||||
)
|
||||
blocks[[length(blocks) + 1]] <- make_markdown_block(conclusion_text, title = "结论摘要")
|
||||
|
||||
return(list(
|
||||
status = "success",
|
||||
message = "分析完成",
|
||||
warnings = if (length(warnings_list) > 0) warnings_list else NULL,
|
||||
results = output_results,
|
||||
report_blocks = blocks,
|
||||
plots = if (!is.null(plot_base64)) list(plot_base64) else list(),
|
||||
trace_log = logs,
|
||||
reproducible_code = as.character(reproducible_code)
|
||||
|
||||
Reference in New Issue
Block a user