E04 修到零被拒线,harness 补七刀:跨进程租约与广播桥、原子写、引用墙、对话区按序号排

活动侧(E04 2.1.0 → 2.1.9,I01 1.2.2):
- 覆盖闭合成为机检:基座新增 distinct 读数,「计划盖住的客户数 = 候选行数」钉进
  S3 收步 / S4 哨兵 / 放行 L2;人加的候选客户不再被整单无视
- 「关键人待识别」占位句式全链退役:查无联系人先发数据录入卡收人;契约新增 refersTo,
  计划/回执的 contact_code 只许引用真实存在的联系人(安装期核引用目标)
- 台账更新确认摆全落库面:客户档案/联系人档案两张落库预览(touched: 数据源,
  正式现值 + 草稿叠加),可补改、可加行(自增主键由基座续号);姓名升必填
- 更新明细:update_key 位置键 + 「同一处只留一条」L2;依据写人话不带机器键;
  标题旁不摆单号;判据与文案不夹字段名;行标识去掉单标识那一段
- 回执骨架 = 计划行数钉进 S3 收步与 S4 哨兵;重做分支不许删计划凑数
- 阶段刻度对齐文档 7 步;起单样例预填满

基座侧:
- 两个后端连同一个库:task-claim 跨进程租约(迁移 0030)+ Postgres LISTEN/NOTIFY
  广播桥;对话区按任务内记忆序号排,不按墙上时钟;并卡「刚说过话」按记忆序列判紧邻
- 多行 write 整批先验后写(dryRun),被拒 = 一行都没落
- 决策卡意见与本单草稿字面比对,归属以观察进轨迹(note-anchors)
- 括号栈补「补闭括号」两形(少一个 } / 行对象没关直接跟下一行)
- 件上加行:空着的自增主键直进续号,不从别的行借号;未落下的行点名回给前端
- 人答复落库那一刻就把 runtime 翻 running(task.wake),两块同帧变脸
- 试跑单可落真库(land_master,迁移 0031,默认开);数据域按活动分组;
  JSON 列不再是 [object Object];按钮键感 + 在办进度条 + 防抖
- 报价链 A1–A7 从系统卸载(只卸不删源码),种子只装 E04/I01

契约变更(api-report 已刷新):FieldDeclaration.distinct / refersTo,
objectDeclaration.file,landMaster,unkeyed,assetFiles,ledgerByActivityRoute。
1700 测 / typecheck / lint / depcruise / api:check 绿。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EEJX8Z7CHejvwmDQyPQuBX
This commit is contained in:
xcs
2026-08-25 01:23:30 +08:00
co-authored by Claude Fable 5
parent 92dd729c36
commit f3397a60ef
91 changed files with 3919 additions and 350 deletions
@@ -107,6 +107,15 @@ describe('判据谓词的名字必须绑得上', () => {
expect(codes(manifest({ predicate: 'disposition = "照原价报"', fields: ['disposition'] }))).toEqual([]);
});
it('`distinct` 声明出的名字也绑得上 —— 覆盖闭合判据的落点(2026-08-24)', () => {
const bound = manifest({ predicate: 'd_record_distinct_customer_code = d_record_rows', fields: ['customer_code'] });
(bound.declarations.ledger[0]!.fields[0] as { distinct?: boolean }).distinct = true;
expect(codes(bound)).toEqual([]);
// 没标 distinct,这个名字就不存在 —— 拒装,别让判据指着一个永远为假的读数
const unbound = manifest({ predicate: 'd_record_distinct_customer_code = d_record_rows', fields: ['customer_code'] });
expect(codes(unbound)).toEqual(['acceptance-predicate-unbound']);
});
it('L3 不机检 —— 没谓词也不报', () => {
expect(codes(manifest({ level: 'L3', predicate: undefined }))).toEqual([]);
});
@@ -295,3 +304,47 @@ describe('工具调用读数绑得上', () => {
expect(withTool('tool_erp_write_calls > 0').length).toBeGreaterThan(0);
});
});
/* ── refersTo 的引用目标必须声明过(2026-08-24)──────────────────────── */
import { referenceFindings } from '../internal/domain/static-audit.ts';
const REF_LEDGER = (refersTo: string) => ({
declarations: {
ledger: [
{
domain: 'crm_coverage',
object: 'plan',
kind: 'record' as const,
caseKey: 'round_ref',
label: '计划',
fields: [
{ name: 'round_ref', type: 'text' as const, primaryKey: true, masked: false },
{ name: 'contact_code', type: 'text' as const, primaryKey: true, masked: false, refersTo },
],
},
{
domain: 'customer',
object: 'contact',
kind: 'master' as const,
label: '联系人',
fields: [{ name: 'contact_code', type: 'text' as const, primaryKey: true, masked: false }],
},
],
},
});
describe('refersTo 目标要在本活动的声明里 —— 写错的地址会变成永远查无此值的死墙', () => {
it('指向声明过的对象与列 —— 放行', () => {
expect(referenceFindings(REF_LEDGER('customer.contact.contact_code'))).toEqual([]);
});
it('表名写错 —— 拒装', () => {
const found = referenceFindings(REF_LEDGER('customer.contacts.contact_code'));
expect(found.map((f) => f.code)).toEqual(['reference-target-unbound']);
});
it('列名写错 —— 拒装', () => {
const found = referenceFindings(REF_LEDGER('customer.contact.code'));
expect(found.map((f) => f.code)).toEqual(['reference-target-unbound']);
});
});
@@ -290,6 +290,12 @@ function boundNames(manifest: AcceptanceAuditInput): ReadonlySet<string> {
const slug = value.toLowerCase().replace(/[^a-z0-9_]/g, '');
if (slug !== '') out.add(`${table.domain}_${table.object}_${field.name}_${slug}`);
}
/*
* 不同值计数读数 `域_对象_distinct_<列>`(2026-08-24 起)——
* 「每家候选客户都进了计划」这类**覆盖闭合**判据的落点:
* 计划行数 ≠ 客户数,闭合要成为机检就得有「有几家不同客户」这个基座数。
*/
if (field.distinct === true) out.add(`${table.domain}_${table.object}_distinct_${field.name}`);
}
}
/*
@@ -413,6 +419,7 @@ export function staticAudit(manifest: ActivityManifest, external: ExternalChecks
out.push(...danglingListeners(manifest));
out.push(...deliverableAddressFindings(manifest));
out.push(...referenceFindings(manifest));
out.push(...ledgerKindFindings(manifest));
out.push(...acceptanceLevelFindings(manifest));
out.push(...loopFindings(manifest));
@@ -420,6 +427,36 @@ export function staticAudit(manifest: ActivityManifest, external: ExternalChecks
return out;
}
/**
* `refersTo` 的引用目标必须是**本活动声明过的对象与列**(2026-08-24 立)。
*
* 引用检查在写入那一刻执行 —— 目标地址写错(表名手滑、列名不存在)的话,
* 那道墙就成了「永远查无此值」的死墙,活动装上就跑不动。与判据谓词绑定同一个道理:
* 这种错只有跑到写入那一刻才炸,必须拦在安装期。
*/
export function referenceFindings(manifest: LedgerAuditInput): StaticAuditFinding[] {
const out: StaticAuditFinding[] = [];
for (const table of manifest.declarations.ledger) {
for (const field of table.fields) {
if (field.refersTo === undefined) continue;
const [rd, ro, rc] = field.refersTo.split('.');
const referenced = manifest.declarations.ledger.find((l) => l.domain === rd && l.object === ro);
const column = referenced?.fields.find((f) => f.name === rc);
if (referenced !== undefined && column !== undefined) continue;
out.push({
code: 'reference-target-unbound',
severity: 'error',
message:
`${table.domain}.${table.object}.${field.name} 的 refersTo 指向 \`${field.refersTo}\`,` +
`而本活动的台账声明里${referenced === undefined ? '没有这张表' : '这张表没有这一列'} —— ` +
'引用检查会变成「永远查无此值」的死墙,装上就跑不动。改成声明里真实存在的 域.对象.列。',
at: `declarations.ledger ${table.domain}.${table.object}.${field.name}`,
});
}
}
return out;
}
export function auditPassed(findings: readonly StaticAuditFinding[]): boolean {
return !findings.some((f) => f.severity === 'error');
}