mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-18 14:12:00 +00:00
证据接入按 W1-a、W1-c 的实际接口对齐:复算就是真的 app.analysis.recompute——load 交查询快照工件的原内容、load_result 交上一层结论(只认封存范围内交回过的查询、台账记过的结论,取不回照实说取不回哪一份),方法升没升版按结论里的 method 和现在的 contract.METHODS 比(升了版、复算成立的写结果同不同,现在的方法复算不了的写明原因),去掉为算子没落地准备的那一套;关键数的代入式按真的具名的数写(乘积拆解补上,波动基线按变化率比的按百分比写,负数加括号)。口径卡指标上的可比性结论(不进台账、只从卡上引用)点得开:证据面板的指标步骤带它整条出处链(判定 → 方法 → 计算 → 输入 → 复算 → 封存,封存按卡上记的 sha256 认),报告导出收在一个可展开的块里,可验证报告随附带的卡一起附上、④ 按已核对的卡认它、数字详情里展示各项检查和服务端复算;裁判的指标摘录、写作目录照卡上记的判定语写。现查结果分清按运行当天现算的界、一列一个值都没有、表的范围;可验证报告里分析工具的 tool.end、分析卡的 analysis.end 和结论同一个认法才带内容,输入的角色写叫法。测试改用真算的结论(run 交的输入照分析入口的写法,复算交工件原内容),下钻、总数闭合、方法升版、可比性端到端都过真的复算
This commit is contained in:
@@ -27,6 +27,9 @@
|
||||
下钻的上一层结论;任一份输入快照只给 id(证明不了没碰遮罩列)的,结论本身也只给 id——结果表里的维度值取自输入快照,
|
||||
这份文件宁可多挡。浏览器只核哈希、核判定语和数是不是结论里写的那些,不在页面里重算统计:结论随文件附带时,服务端在
|
||||
导出时按封存的输入复算一遍(engine/evidence.analysis_recheck),结果记在这份工件的条目上(recheck),页面照它展示。
|
||||
口径卡指标上的可比性结论(口径卡执行时自动做的,不进台账、只从卡上引用)随附带的卡一起附上,规则同上,引用链(④)
|
||||
按「已核对的口径卡记着的可比性」认它。分析工具的 tool.end(预览里是结论的前一截)、分析卡一项的 analysis.end(带着
|
||||
判定语)和结论本身同一个认法:结论随文件附带得了才带规范字符串。
|
||||
- 报告文档带着系统写的「分析范围」(analysis_scope)的,页面在正文后面照它渲染,编号点得开那条结论。
|
||||
- 封存之后追加的事件(按需裁判、审批质询这类批注)单列:类型、序号、内容摘要,不进清单。
|
||||
|
||||
@@ -63,7 +66,7 @@ from urllib.parse import quote
|
||||
from app.analysis.contract import ARTIFACT_KIND, LEDGER_KIND, NODE_TYPE as ANALYSIS_NODE, is_result
|
||||
from app.core.artifact_store import canonical_json, content_hash
|
||||
from app.core.events import EventType
|
||||
from app.engine.evidence import analysis_input_snapshot, analysis_recheck, iter_units, query_entry_fields
|
||||
from app.engine.evidence import analysis_recheck, iter_units, query_entry_fields
|
||||
from app.engine.lineage import in_scope, scoped_id
|
||||
from app.engine.masking import OPAQUE_SQL, SYSTEM_SCHEMAS, indirect_reads
|
||||
from app.engine.merge_query import MERGE_SOURCE
|
||||
@@ -93,6 +96,8 @@ _SHOWN_EVENTS = frozenset({EventType.RUN_STARTED, EventType.REPORT_CHECKED, Even
|
||||
_CITED_KINDS = {"metric": "metric_set", "query": "query", LEDGER_KIND: ARTIFACT_KIND}
|
||||
#: 下钻的上一层结论最多跟几层(同分析设置里下钻层数的上限)
|
||||
_PARENT_DEPTH = 6
|
||||
#: 分析卡里一项做完的事件(core/events.EventType.ANALYSIS_END):带着那一项的判定、判定语和结论工件(analysis_artifact)
|
||||
_ANALYSIS_END = "analysis.end"
|
||||
|
||||
#: 没挂在工作流上的运行(画布、问数据当场搭的):老数据叫「临时图」,新的叫「未保存的工作流」,也可能是空的。
|
||||
#: 和前端 lib/terms.ts 的 runName 同一个规则
|
||||
@@ -1066,6 +1071,17 @@ def _analysis_inputs(result: Any) -> list[tuple[str, str]]:
|
||||
return list(out.items())
|
||||
|
||||
|
||||
def _card_comparability(card: Any) -> list[str]:
|
||||
"""口径卡指标上记着的可比性结论(contract.MetricComparability 的 artifact),按先后、去重。这份结论不进台账,只从卡上
|
||||
引用:卡随文件附带时一并附上,引用链(④)按「已核对的口径卡记着的可比性」认它。"""
|
||||
out: list[str] = []
|
||||
for metric in (card.get("metrics") or []) if isinstance(card, dict) else []:
|
||||
found = metric.get("comparability") if isinstance(metric, dict) else None
|
||||
if isinstance(found, dict) and isinstance(found.get("artifact"), str) and found["artifact"]:
|
||||
out.append(found["artifact"])
|
||||
return list(dict.fromkeys(out))
|
||||
|
||||
|
||||
def _card_input_queries(card: Any) -> list[tuple[str, str | None]]:
|
||||
"""口径卡记着的输入引用的查询快照:(工件 id, 输入来自的节点),按先后、按工件去重。
|
||||
|
||||
@@ -1169,7 +1185,7 @@ def _recheck(result: dict[str, Any], store: _Store) -> dict[str, Any]:
|
||||
"""导出时服务端按封存的输入把这份分析结论复算一遍(engine/evidence.analysis_recheck,和证据面板同一个函数):输入快照、
|
||||
上一层结论只认这份文件里哈希对得上的原字节。页面照这个结果写「导出时服务端的复算」,不在浏览器里重算统计。"""
|
||||
def load(artifact: str) -> Any:
|
||||
return analysis_input_snapshot(store.content(artifact), artifact) if store.intact(artifact) else None
|
||||
return store.content(artifact) if store.intact(artifact) else None
|
||||
|
||||
def load_result(artifact: str) -> Any:
|
||||
content = store.content(artifact) if store.intact(artifact) else None
|
||||
@@ -1209,10 +1225,24 @@ def _shows_content(etype: str, node_id: str | None, data: Any, node_types: Mappi
|
||||
if etype == EventType.TOOL_END:
|
||||
# 查询类:把查询快照的 id 和运行记录连起来。预览里是查询结果的前一截,数据源带遮罩的只给哈希
|
||||
artifact = data.get("query_artifact") if isinstance(data, dict) else None
|
||||
return isinstance(artifact, str) and bool(artifact) and not store.masked(artifact)
|
||||
if isinstance(artifact, str) and artifact:
|
||||
return not store.masked(artifact)
|
||||
# 分析工具:预览里是结论的前一截(判定语、具名的数、结果表),和结论本身同一个认法
|
||||
found = data.get("analysis_artifact") if isinstance(data, dict) else None
|
||||
return isinstance(found, str) and bool(found) and _result_shown(found, store)
|
||||
if etype == _ANALYSIS_END:
|
||||
# 分析卡的一项:带着判定、判定语,结论随文件附带得了(输入没碰遮罩列)才带
|
||||
found = data.get("analysis_artifact") if isinstance(data, dict) else None
|
||||
return isinstance(found, str) and bool(found) and _result_shown(found, store)
|
||||
return False
|
||||
|
||||
|
||||
def _result_shown(artifact: str, store: _Store) -> bool:
|
||||
"""一份分析结论的内容能不能出现在页面上(事件里带着它的判定语、预览):文件在、认得出是分析结论、输入都没碰遮罩列
|
||||
(_Store.analysis_masked)。和这份结论随文件附带时同一个认法。"""
|
||||
return store.raw(artifact) is not None and not store.analysis_masked(artifact)
|
||||
|
||||
|
||||
def _card_shown(data: Any, store: _Store, masked_run: bool, events: Sequence[tuple[int, str, str | None, Any]],
|
||||
forced: frozenset[str] = frozenset()) -> bool:
|
||||
"""口径卡的节点完成事件带不带规范字符串。预览里逐条写着「指标(名称)= 值」(metrics 节点的 text),赋了变量的另有
|
||||
@@ -1248,7 +1278,7 @@ def _analysis_shown(data: Any, store: _Store) -> bool:
|
||||
results = [str(e["artifact"]) for e in data.get("evidence") or []
|
||||
if isinstance(e, dict) and e.get("kind") == LEDGER_KIND and isinstance(e.get("artifact"), str)
|
||||
and e["artifact"]]
|
||||
return bool(results) and all(store.raw(a) is not None and not store.analysis_masked(a) for a in results)
|
||||
return bool(results) and all(_result_shown(a, store) for a in results)
|
||||
|
||||
|
||||
def _masked_cards(doc: dict[str, Any]) -> set[str]:
|
||||
@@ -1420,6 +1450,11 @@ def build_bundle(
|
||||
if kind == "metric_set" and item is not None and "b64" in item and store.intact(artifact):
|
||||
for query, query_owner in _card_input_queries(store.content(artifact)):
|
||||
artifacts.add(query, "query", query_owner)
|
||||
# 指标上的可比性结论(口径卡执行时自动做的,不进台账、只从卡上引用)同样附上:它的输入快照、服务端的复算
|
||||
# 跟着它(_attach_analysis),输入带遮罩的照旧只给 id
|
||||
for found in _card_comparability(store.content(artifact)):
|
||||
_attach_analysis(artifacts, store, artifacts.add(found, ARTIFACT_KIND, owner), found, owner,
|
||||
cited_queries)
|
||||
|
||||
masked_run = _masked_run(sealed, store, cited_queries, source_masks or {})
|
||||
shown_events = []
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
* 分析结论(判定语 [[a:A3]]、具名的数 [[a:A3.键]]、结果表的格 [[v:A3.r0.列]])在 ③ ④ 里和查询快照一样核哈希、核引用链
|
||||
* (它的输入快照按「已核对的分析结论的输入」认);⑤ 里核正文显示的判定语、数是不是结论里写的那几个字(同服务端的渲染
|
||||
* 规则)。本页不重算统计:结论随文件附带时,出处面板展示导出时服务端按封存的输入复算的结论(工件条目上的 recheck)。
|
||||
* 口径卡指标上的可比性结论不进台账、只从卡上引用:④ 按「已核对的口径卡记着的可比性」认它,指标的数字详情里展示它。
|
||||
* 报告文档带着系统写的「分析范围」(analysis_scope)的,正文后面照它渲染,编号点得开那条结论。
|
||||
* 每项给出通过 / 不通过 / 无法核对和原因。服务端导出时不会出现的状态(被引用的工件不在清单里、检索快照这类工件标着
|
||||
* 遮罩)一律算不通过:只可能是文件被改过。报告文档的证据目录里写着取自遮罩列的指标的值时,服务端只给它的哈希
|
||||
@@ -67,7 +68,8 @@
|
||||
'node.failed': '节点失败', 'node.skipped': '节点跳过', 'edge.taken': '分支走向', 'llm.start': '模型调用开始',
|
||||
'llm.end': '模型调用结束', 'llm.thinking': '模型思考', 'tool.start': '工具调用', 'tool.end': '工具返回',
|
||||
'tool.error': '工具出错', 'tool.gated': '门控判定', 'retrieve.end': '知识检索', 'memory.end': '记忆读写',
|
||||
'merge.end': '合并查询', 'sandbox.start': '沙箱开始', 'sandbox.end': '沙箱结束', 'agent.step.start': 'Agent 步骤开始',
|
||||
'merge.end': '合并查询', 'analysis.end': '分析卡的一项',
|
||||
'sandbox.start': '沙箱开始', 'sandbox.end': '沙箱结束', 'agent.step.start': 'Agent 步骤开始',
|
||||
'agent.step.end': 'Agent 步骤结束', 'agent.route.start': '调度决策开始', 'agent.route.end': '调度决策结束',
|
||||
'human.requested': '请求人工审批', 'human.resolved': '人工审批结果', 'approval.inquiry': '审批质询',
|
||||
'issuance': '出具判定', 'caliber.upgrade': '口径卡升版处置', 'catalog.drift': '数据目录变化',
|
||||
@@ -259,6 +261,11 @@
|
||||
recheckBy: '导出时服务端按封存的输入复算的结论;本页只核哈希,不在浏览器里重算统计',
|
||||
recheckNone: '导出时没有复算(结论未随文件附带)',
|
||||
analysisInput: (role, alias) => `${role}${alias ? ` · ${alias}` : ''}`,
|
||||
// 分析结论输入的角色(analysis.contract.AnalysisInput.role),同证据面板的叫法
|
||||
roleLabel: { data: '数据', base: '基期', target: '本期', headline_base: '基期总数', headline_target: '本期总数',
|
||||
parent: '上一层拆解' },
|
||||
dComparability: '两期可比性', comparabilityLabel: { comparable: '两期可比', conditional: '两期有条件可比', incomparable: '两期不可比' },
|
||||
dJudged: '判定', dChecks: '各项检查', comparabilityNotAttached: '可比性结论未随文件附带(见核对明细 ③ ④),这里按口径卡的记录展示',
|
||||
scopeTitle: '分析范围', scopeNote: '这一段由系统按这次运行的分析结论写成,写作者改不了;点开编号看判定语、判定标准、输入和复算。',
|
||||
scopeMissing: '没拆', scopeAll: '候选维度都拆过了', scopeUnknown: '候选维度核对不了', scopeTests: '检验',
|
||||
scopeTestsText: (n) => `这次做了 ${n} 次差异检验`, scopeParent: (alias) => `下钻自 ${alias}`, scopeDims: (dims) => `按${dims}`,
|
||||
@@ -1378,6 +1385,13 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
// 指标上的可比性结论不进台账、只从卡上引用(卡记着它的 sha256):已核对的卡记着的,同卡的输入一样认
|
||||
for (const metric of Array.isArray(item.json.metrics) ? item.json.metrics : []) {
|
||||
const c = isObj(metric) && isObj(metric.comparability) ? metric.comparability : null
|
||||
if (c && typeof c.artifact === 'string' && c.artifact) {
|
||||
push(byCard, c.artifact, { card: item, metric: metric.id })
|
||||
}
|
||||
}
|
||||
}
|
||||
// 已核对的分析结论记着的输入 → 输入快照、下钻的上一层结论。同口径卡:结论本身核过哈希,它记的输入和文档的证据目录
|
||||
// 同一个分量;没核对过的(哈希对不上)不认
|
||||
@@ -1958,6 +1972,7 @@
|
||||
}
|
||||
parts.push(kv([[T.dRecompute, metric.recompute_ok == null ? T.recomputeNone
|
||||
: metric.recompute_ok ? T.recomputeOk : T.recomputeBad]]))
|
||||
if (isObj(metric.comparability)) parts.push(...comparabilityBlock(metric.comparability))
|
||||
}
|
||||
const snap = number.snapshot
|
||||
if (snap) parts.push(...snapshotBlock(snap, number.row, number.column,
|
||||
@@ -1966,6 +1981,42 @@
|
||||
return parts
|
||||
}
|
||||
|
||||
/** 口径卡指标上的可比性(口径卡执行时自动做的可比性检查):卡上记的判定和原因;那份结论随文件附带、核对通过的,再给
|
||||
* 判定标准、方法与版本、各项检查和导出时服务端的复算。没附带的照卡上的记录写,说明为什么没有更多 */
|
||||
function comparabilityBlock(c) {
|
||||
const why = Array.isArray(c.reasons) && c.reasons.length ? `:${c.reasons.map(String).join(';')}` : ''
|
||||
const label = own(T.comparabilityLabel, c.verdict) || String(c.phrase || '—')
|
||||
const artifact = typeof c.artifact === 'string' && c.artifact ? c.artifact : null
|
||||
const art = artifact ? view.out.arts.get(artifact) : null
|
||||
const ok = art && art.result === PASS && view.out.chained && view.out.chained.has(artifact)
|
||||
const result = ok && isObj(art.json) ? art.json : null
|
||||
const parts = [h('p', { class: 'sub' }, T.dComparability), kv([
|
||||
[T.dJudged, `${label}${c.verdict === 'comparable' ? '' : why}`],
|
||||
artifact ? [T.dArtifact, [h('code', {}, short(artifact)), artifactState(artifact)]] : null,
|
||||
])]
|
||||
if (!result) {
|
||||
if (artifact) parts.push(h('p', { class: 'note' }, T.comparabilityNotAttached))
|
||||
return parts
|
||||
}
|
||||
parts.push(kv([
|
||||
result.criterion ? [T.dCriterion, String(result.criterion)] : null,
|
||||
[T.dMethod, String(result.method || '—')],
|
||||
]))
|
||||
const table = isObj(result.table) ? result.table : null
|
||||
const columns = table && Array.isArray(table.columns) ? table.columns.map(String) : []
|
||||
const labels = table && isObj(table.labels) ? table.labels : {}
|
||||
if (columns.length && Array.isArray(table.rows) && table.rows.length) {
|
||||
parts.push(h('p', { class: 'sub' }, T.dChecks), h('div', { class: 'table-wrap' }, h('table', {},
|
||||
h('thead', {}, h('tr', {}, columns.map((col) => h('th', {}, String(own(labels, col) || col))))),
|
||||
h('tbody', {}, table.rows.filter(Array.isArray).map((row) => h('tr', {},
|
||||
columns.map((_, i) => h('td', {}, row[i] == null ? '—' : textOf(row[i])))))))))
|
||||
}
|
||||
const recheck = isObj(art.a.recheck) ? art.a.recheck : null
|
||||
parts.push(kv([[T.dRecheck, recheck
|
||||
? [String(recheck.text || '—'), h('span', { class: 'muted' }, `(${T.recheckBy})`)] : T.recheckNone]]))
|
||||
return parts
|
||||
}
|
||||
|
||||
/** 数字详情里分析结论一节:判定语、判定标准、方法与版本、附带说明、Agent 写的假设、输入(各自的核对状态)、导出时服务端
|
||||
* 的复算结论。结论没随文件附带(遮罩、文件不在)时只写复算一句 */
|
||||
function analysisBlock(number) {
|
||||
@@ -1987,7 +2038,8 @@
|
||||
const inputs = (Array.isArray(result.inputs) ? result.inputs : []).filter((i) => isObj(i) && typeof i.artifact === 'string')
|
||||
if (inputs.length) {
|
||||
parts.push(h('p', { class: 'sub' }, T.dAnalysisInputs), h('ul', { class: 'items' }, inputs.map((i) => h('li', {},
|
||||
h('span', { class: 'what' }, [T.analysisInput(String(i.role || ''), view.out.queryAliases.get(i.artifact)), ' ',
|
||||
h('span', { class: 'what' }, [T.analysisInput(own(T.roleLabel, i.role) || String(i.role || ''),
|
||||
view.out.queryAliases.get(i.artifact)), ' ',
|
||||
h('code', {}, short(i.artifact))]), artifactState(i.artifact)))))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user