A2-A7 全部补齐到验收线;顺手把几处「门拦住却不给路」的坑填了

活动:A2 选型 / A3 寻源 / A4 定价 / A6 议价 / A7 归档五件各补成真活动包 ——
契约宽进(input.required 空,归一在活动内)、台账必填声明(含行级 requiredWhen)、
入场哨兵与 L1/L2 判据一律读基座数、两份件(在办可编辑 + 办结静态快照)、
三案例常备、包内自测。e2e 各三案例 released、行动被拒 0、发口正确、提交闸每单真拦。

基座(共享面,改一处影响所有活动,故每处都带回归):
· 重发判断走在站上场之前 —— 人答完那步常已收掉,readyToWork 先抛「不能再往它上面挂活」,
  于是「重发已答过的卡 = 无事发生」这条唯一活路在最需要时够不着,A1 基线当场熔断;
· 决策卡补幂等兜底(与执行工单同一把尺):头两次无事发生,第三次起才算被拒;
· 输出没成形先就地重问一次,原话进工作日志、不再摆上卡面;
· 工具调用读数 tool_<名>_calls —— 「机检只读基座数」这条纪律第一次覆盖到工具;
· 执行卡 steps/standard 补进出参 schema(从前能到卡面全靠厂商 JSON 模式宽松);
· 件的就地更新改逐节点 morph,保存先把新值镜像进只读那份 —— 不闪、不等回声。

A1(基线,全程守住):措辞三档对齐(必填/建议/选填)、禁止拿历史价当客户目标价、
卡骨架从步骤剧本搬进说明书(压成一拍连做时剧本没摊开,会发出没有指导书的裸卡)。

契约两处**新增可选字段**(非破坏):FieldDeclaration.requiredWhen、工单 finalHtml;
api-report 同批更新。docs/adr 与 docs/archive 的 13 份文件在工作树里不见了,
本次予以恢复而非提交删除。

门禁:typecheck / lint / depcruise / test(1366)全绿。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-03 12:28:31 +08:00
co-authored by Claude Opus 5
parent 85466e815f
commit ade0fa5a94
90 changed files with 17969 additions and 2316 deletions
+44 -8
View File
@@ -497,8 +497,11 @@ async function applyBoundTableEdits(
* (都走 `missingReadings`)。同源是要紧的:两处各算各的,就会出现
* 「卡上说能交、放行门说不行」——那种矛盾人是判不出对错的。
*
* 只对**绑了台账表**的执行卡出闸:算得出才拦,算不出(卡上没绑表)就不给闸,
* 按钮照常能按 —— **没有依据的时候不拦人**。
* 看哪几张表:卡上绑了表就看绑的那几张;**卡上没绑表就回落到必交付物的台账声明**
* (`requiredDeliverables` 的 `ledgers`/`ledger`)—— 执行卡零输入之后(2026-08-02
* 用户定:「填写全去工作区」)卡面不再绑 blocks,闸若只认卡上的表就整个失效,
* 缺着必填照样交得回来,一路走到放行门才被 L1 拦住(那正是当初立这道闸要治的病)。
* 两条路都算不出(连交付物都没声明台账)才不给闸 —— **没有依据的时候不拦人**。
*/
async function submitGate(
container: Container,
@@ -506,13 +509,13 @@ async function submitGate(
order: WorkOrder,
): Promise<{ ready: boolean; why: string; blanks: string[] } | undefined> {
if (order.mode !== 'execution' || order.done !== undefined) return undefined;
const addresses = (order.blocks ?? [])
.filter((b): b is Extract<ViewBlock, { t: 'table' }> => b.t === 'table' && typeof b.ledger === 'string')
.map((b) => b.ledger as string);
const task = await container.task.get(taskId).catch(() => undefined);
if (task === undefined) return undefined;
const manifest = await container.registry.manifestOf(task.activityId).catch(() => undefined);
if (manifest === undefined) return undefined;
const addresses = gateAddressesOf(order.blocks, manifest.contract.requiredDeliverables);
if (addresses.length === 0) return undefined;
const declarations = await declarationsOf(container, taskId);
if (declarations === undefined) return undefined;
const watched = declarations.filter((l) => addresses.includes(`${l.domain}.${l.object}`));
const watched = manifest.declarations.ledger.filter((l) => addresses.includes(`${l.domain}.${l.object}`));
if (watched.length === 0) return undefined;
// 本单写下的行 —— 与任务视图同一约定(`mine:域.对象`)
@@ -523,6 +526,23 @@ async function submitGate(
return gateOf(missingReadings(mine, watched), watched);
}
/**
* 闸看哪几张表:卡上绑了表就看绑的那几张;没绑(执行卡零输入之后是常态)
* 回落到**必交付物的台账声明**(`ledgers` 全表,老清单退 `ledger` 单张)。
* 两边都空才真的没有依据。抽成纯函数是为了钉测 —— 回落断了闸就整个失效,
* 而失效的闸在页面上看不出来(按钮照常绿着)。
*/
export function gateAddressesOf(
blocks: ReadonlyArray<ViewBlock> | undefined,
deliverables: ReadonlyArray<{ ledger?: string | undefined; ledgers?: ReadonlyArray<string> | undefined }>,
): string[] {
const bound = (blocks ?? [])
.filter((b): b is Extract<ViewBlock, { t: 'table' }> => b.t === 'table' && typeof b.ledger === 'string')
.map((b) => b.ledger as string);
if (bound.length > 0) return bound;
return deliverables.flatMap((d) => [...(d.ledgers ?? (d.ledger === undefined ? [] : [d.ledger]))]);
}
/**
* 读数 → 闸。**数与名单都来自基座的读数**,这里只负责说人话。
*
@@ -913,6 +933,22 @@ export function registerDeskRoutes(app: Hono<AppEnv>, container: Container): voi
}
}
const outcome = await container.humanTool.replyWorkOrder(parsed.data, staff.id);
/*
* **办结那一刻,把当时的件原样存进这张工单**(2026-08-02 用户:「HTML UI、
* 数据、内容、布局都要 1:1 地从待处理转换为静态报告放到工作成果」)。
* 成果页渲的是这份快照 —— 不再渲「当下」的任务视图(随后续推进会变),
* 更不退回卡壳。快照失败不拦办结(留痕即可,人已交卷)。
*/
try {
const shot = await container.interaction.viewOf(outcome.taskId);
if (shot?.html !== undefined) {
await container.db.execute(
sql`update sys.work_order set payload = jsonb_set(payload, '{finalHtml}', ${JSON.stringify(shot.html)}::jsonb) where id = ${parsed.data.workOrderId}`,
);
}
} catch {
/* 件还没推过就没有快照 —— 成果页会退回旧路,不拦人交卷 */
}
/*
* **绑台账的可编辑表:人改了什么,基座当场写回草稿层**(2026-08-01)。
*