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
@@ -9,7 +9,7 @@
* 所以归型放在写进草稿那一刻:归得了就归,归不了当场拒(理由喂回下一拍)。
*/
import { describe, expect, it } from 'vitest';
import { coerceToColumn, localStamp, missingReadings, rowReadings, rowKeyList, tallyReadings, toolCallReadings } from '../wiring/engines.ts';
import { coerceToColumn, distinctReadings, localStamp, missingReadings, rowLabel, rowReadings, rowKeyList, tallyReadings, toolCallReadings, touchedRows } from '../wiring/engines.ts';
describe('空值 = 这一列没有值(不写)', () => {
it('空串 / 全空白 / null / undefined 一律不写 —— 「原文没写的不要补」的数据面落点', () => {
@@ -381,3 +381,108 @@ describe('工具调用读数', () => {
]);
});
});
/**
* 不同值计数 `域_对象_distinct_<列>` —— 覆盖闭合判据的落点(2026-08-24 柴浩实测:
* 人在覆盖范围确认卡上加了一家客户,计划行数照样 > 0,「盖没盖住每一家」没有数说得出来)。
*/
describe('distinctReadings —— 这一列有几个不同的值,基座数', () => {
const DECL = [
{
domain: 'crm_coverage',
object: 'plan',
fields: [{ name: 'customer_code', distinct: true }, { name: 'contact_code' }],
},
];
it('计划行数 ≠ 客户数:一家客户几位关键人就几行,distinct 数的是客户', () => {
const rows = [
{ customer_code: 'CU-0142', contact_code: 'CU-0142-01' },
{ customer_code: 'CU-0142', contact_code: 'CU-0142-02' },
{ customer_code: 'cu-1111', contact_code: 'cu-1111-00' },
];
expect(distinctReadings({ 'mine:crm_coverage.plan': rows }, DECL)).toEqual({
crm_coverage_plan_distinct_customer_code: 2,
});
});
it('没标 distinct 的列不出读数;标了的零行也铺 0 —— 未绑定的名字参与比较求值为假', () => {
const out = distinctReadings({ 'mine:crm_coverage.plan': [] }, DECL);
expect(out).toEqual({ crm_coverage_plan_distinct_customer_code: 0 });
});
it('空值不算一种 —— 「没写」不是一个取值', () => {
const rows = [{ customer_code: 'CU-0142' }, { customer_code: '' }, { customer_code: ' ' }, {}];
expect(distinctReadings({ 'mine:crm_coverage.plan': rows }, DECL)).toEqual({
crm_coverage_plan_distinct_customer_code: 1,
});
});
});
/**
* `touched:域.对象` —— 落库预览的数据源(2026-08-24 柴浩实测:绑 mine: 的话
* Itelma 既有的客户类型/行业整片空白,像是数据丢了)。
*/
describe('touchedRows —— 本轮碰过的行,以叠加后全貌摆出来', () => {
const merged = [
{ customer_code: 'CU-0142', name: 'Itelma', cust_type: 'Tier1 OEM', industry: '车规电子' },
{ customer_code: 'CU-0087', name: '深圳精密', cust_type: '模组厂' },
{ customer_code: 'CU-2039', name: '测试11111' },
];
it('按草稿键挑行:碰过的行带着正式现值的全部列,没碰的行不出现', () => {
const out = touchedRows(merged, [{ customer_code: 'CU-0142' }, { customer_code: 'CU-2039' }]);
expect(out).toHaveLength(2);
// 关键在这一列:草稿里没写过 cust_type,叠加行里必须有 —— 这正是回显的来源
expect((out[0] as Record<string, unknown>)['cust_type']).toBe('Tier1 OEM');
expect((out[1] as Record<string, unknown>)['name']).toBe('测试11111');
});
it('草稿新增的行(正式表没有)也在 —— 叠加视图本就含它;键对不上的丢弃不报错', () => {
const withNew = [...merged, { customer_code: 'CU-NEW', contact_code: 'CU-NEW-01', name: '新人' }];
const out = touchedRows(withNew, [
{ customer_code: 'CU-NEW', contact_code: 'CU-NEW-01' },
{ customer_code: '查无此人', contact_code: 'X' },
]);
expect(out).toHaveLength(1);
expect((out[0] as Record<string, unknown>)['name']).toBe('新人');
});
it('数值键与字符串键按字面等值比(pg 回来的是 number,草稿键常是 string)', () => {
const out = touchedRows([{ seq: 3, name: '三号' }], [{ seq: '3' }]);
expect(out).toHaveLength(1);
});
});
/**
* 摆给人看的行标识去掉单标识(2026-08-25 用户:「COV-…/CU-0142-01 只保留斜杠右边」)。
*/
describe('rowLabel —— 主键去掉单号那一段', () => {
it('单据表:round_ref + contact_code → 只留 contact_code', () => {
expect(rowLabel({ round_ref: 'COV-20260825002227', contact_code: 'CU-0142-01' }, 'round_ref')).toBe('CU-0142-01');
});
it('主数据表没有单标识:全部保留', () => {
expect(rowLabel({ customer_code: 'CU-0142', contact_code: 'CU-0142-01' }, undefined)).toBe('CU-0142/CU-0142-01');
});
it('主键只有单号:去完一段都不剩就退回整段,不摆空串', () => {
expect(rowLabel({ round_ref: 'COV-1' }, 'round_ref')).toBe('COV-1');
});
it('缺项名单走同一把尺 —— 红带 / 提交闸 / 拒回都不再带单号', () => {
const out = missingReadings({ 'mine:crm_coverage.receipt': [{ round_ref: 'COV-1', contact_code: 'CU-0142-01' }] }, [
{
domain: 'crm_coverage',
object: 'receipt',
caseKey: 'round_ref',
fields: [
{ name: 'round_ref', primaryKey: true },
{ name: 'contact_code', primaryKey: true },
{ name: 'completion_status', primaryKey: false, required: true, label: '完成状态' },
],
},
]);
expect(out['crm_coverage_receipt_missing_keys']).toBe('CU-0142-01 缺完成状态');
});
});