人手改的那一手真正落得下去;界面不撒谎那几处补齐

手改是**兜 AI 的错**的那一手 —— 这一轮把它从「摆在那儿但落不了地」做成真的:

件上就地改
· 保存**按地址收**,不看当下那张卡:载荷从前借道工单的 `blocks[i]` 取列名,
  于是熔断卡(没有 blocks)在屏上时,人补的那一格一个字都送不出去 ——
  而他要补的恰恰是把这一单卡住的那个必填格。授权面改由活动清单的台账声明把关。
· **能增删行**:错不止「这一格填错了」,还有「这一行不该在」与「漏了一行」。
  删挂记号不当场抹掉(看得见、可后悔),且**删要说出来**(`drops`)——
  「没回传就是删了」会把一次不完整的回传变成一次删表。
· **必填没填按不下提交**:与放行门 L1 同一个数同一套算法;闸上摆出差在哪一行哪一格。
· 只写真改了的那几行 —— 改一格却留「修订 4 行」的痕,那句话是假的。

判据与门
· 裁量判据带谓词时**谓词说了算**:「选填缺口已补齐」基座数得出来,
  人填好的目标价它照样判「客户未提供」的毛病由此消掉。
· 验收卡判据**读时现算** —— 人在成果件上补一格,判据跟着变。
· 放行门认「**办完了没有**」不认「有人写过」:从前写个 `false` 就把门推开,
  于是一单没打标就进了放行门。三个数全由基座现数。
· 拒回把「活没干完」说成「数或行对不上」的毛病:判据点名的表一行都没写时直说那一步没办。
  **指向两扇打不开的门,比不指还糟。**

界面不撒谎
· 日志只有三色:负责人绿 · 智能体蓝 · 系统灰(归侧五种是度量的分法,不是给人看的)。
· 验收收口答两件事:落了什么(按**交付物**点名,一份成果的几张表并成一行)、
  往哪儿去(转出哪一口、带过去哪些字段);一个口都没发就直说到此为止。
· 签完到收尾之间那一段有自己的话「字已签下,正在落地」—— 中间态本来就该说出来,只是要说对。
· 消息不再被内部事件刷屏:只有从通道进来的件才谈得上「无人认领」。
· 建客户公司与联系人**一次确认落两行**;联系人编码自增不问人;卡面摆表的人读名。

A1 三案例端到端全 released:全 A 类直通 12 拍 / 客户点名跳一条 10 拍 / 新客户缺必填 14 拍。
五道门禁全绿(971 passed)。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JsTDjoHovERXyy6Wmw1ALp
This commit is contained in:
2026-08-02 13:41:44 +08:00
co-authored by Claude Opus 5
parent 94f1c7a4ef
commit 259192f736
228 changed files with 27850 additions and 2847 deletions
@@ -0,0 +1,271 @@
/**
* 判据谓词的名字必须在台账上 —— 安装期就挡下,别等跑到放行那一刻才炸。
*
* 这条门是拿血换来的:A2/A3/A4/A6/A7 五个活动的机检判据全都引用了
* 台账里根本不存在的名字(`candidatesConfirmed` / `unquoted` / `unpriced`
* / `missingQuoteFields` / `reasonLogged` ……)。S-FEEL 对未绑定的名字求值为假,
* 于是这些判据**永远达不了标**:Agent 把活办得再干净也过不了 submit 门,
* 连拒五拍熔断 —— MVP 整条流三轮都卡死在 A2,而清单本身语法挑不出毛病。
*/
import { describe, expect, it } from 'vitest';
import type { ActivityManifest } from '@contracts';
/* 两条审读的入参已在 domain 收窄到字段级 —— 这里直接用它,不拼假清单 */
type PredicateInput = Parameters<typeof acceptanceLevelFindings>[0];
type LedgerTable = ActivityManifest['declarations']['ledger'][number];
type Deliverable = ActivityManifest['contract']['requiredDeliverables'][number];
import { acceptanceLevelFindings } from '../internal/domain/static-audit.ts';
/** 一份最小可用清单 —— 只摆本测试关心的三处:判据 / 台账 / 案卷 */
function manifest(over: {
predicate?: string | undefined;
level?: 'L1' | 'L2' | 'L3';
fields?: string[];
caseItems?: string[];
inputProps?: string[];
}): PredicateInput {
const fields = over.fields ?? ['line_total'];
const caseItems = over.caseItems ?? [];
const inputProps = over.inputProps ?? [];
return {
contract: {
input: {
data: {
type: 'object',
properties: Object.fromEntries(inputProps.map((k) => [k, { type: 'string' }])),
},
},
acceptanceCriteria: [
{
key: 'k',
label: '测试判据',
level: over.level ?? 'L2',
...(over.predicate === undefined ? {} : { predicate: over.predicate }),
},
],
},
declarations: {
ledger: [
{
domain: 'd',
object: 'record',
kind: 'record' as const,
caseKey: 'rfq_ref',
label: '表',
fields: fields.map((name) => ({
name,
type: 'integer' as const,
primaryKey: false,
masked: false,
})),
},
],
},
assets: {
businessModel: {
cmmnXml: caseItems.map((id) => `<caseFileItem id="${id}" name="x"/>`).join(''),
},
},
};
}
const codes = (m: PredicateInput) => acceptanceLevelFindings(m).map((f) => f.code);
describe('判据谓词的名字必须绑得上', () => {
it('台账有这一列 —— 放行', () => {
expect(codes(manifest({ predicate: 'line_total > 0' }))).toEqual([]);
});
it('台账没有这个名字 —— 拒装', () => {
const found = acceptanceLevelFindings(manifest({ predicate: 'candidatesConfirmed >= 2' }));
expect(found.map((f) => f.code)).toContain('acceptance-predicate-unbound');
// 报错要指名道姓:说清是哪个名字绑不上,不然改的人还得自己猜
expect(found[0]?.message).toContain('candidatesConfirmed');
});
it('案卷项也算绑得上 —— 案卷项 id 就是任务视图里的键名', () => {
expect(codes(manifest({ predicate: 'benchmark_total > 0', caseItems: ['benchmark_total'] }))).toEqual([]);
});
it('起单入参也算绑得上', () => {
expect(codes(manifest({ predicate: 'eau > 0', inputProps: ['eau'] }))).toEqual([]);
});
it('两个名字里错一个,也要报出那一个', () => {
const found = acceptanceLevelFindings(
manifest({ predicate: 'alt_request_total = type_c_total', fields: ['alt_request_total'] }),
);
expect(found).toHaveLength(1);
expect(found[0]?.message).toContain('type_c_total');
});
it('保留字与字面量不当作台账名', () => {
expect(codes(manifest({ predicate: 'need_sourcing = true and line_total > 0', fields: ['need_sourcing', 'line_total'] }))).toEqual([]);
});
it('字符串字面量里的词不当作台账名', () => {
expect(codes(manifest({ predicate: 'disposition = "照原价报"', fields: ['disposition'] }))).toEqual([]);
});
it('L3 不机检 —— 没谓词也不报', () => {
expect(codes(manifest({ level: 'L3', predicate: undefined }))).toEqual([]);
});
it('L2 没谓词照旧报等级谎报,且不误报绑定', () => {
const found = codes(manifest({ level: 'L2', predicate: undefined }));
expect(found).toEqual(['acceptance-level-misreported']);
});
});
/**
* 必交付物必须给产出地址 —— 不给的话放行门永远拒。
*
* 预检数的是「本单在这张表上写了几行」;地址不给,它退回拿 key 去任务视图里找,
* 而 key 是 `benchmark-table` 这样的短横线别名 —— 视图里永远没有这个键。
* A2/A3/A4/A6/A7 五个活动全没给,活办完了也放不了行(实测 A2 死于此)。
*/
import { deliverableAddressFindings } from '../internal/domain/static-audit.ts';
type DeliverableInput = Parameters<typeof deliverableAddressFindings>[0];
const LEDGER: LedgerTable[] = [
{ domain: 'quote_alternative', object: 'benchmark', kind: 'record' as const, caseKey: 'rfq_ref', label: '表', fields: [] },
];
function withDeliverables(items: Deliverable[]): DeliverableInput {
return { contract: { requiredDeliverables: items }, declarations: { ledger: LEDGER } };
}
describe('必交付物的产出地址', () => {
it('地址指向真实台账表 —— 放行', () => {
const found = deliverableAddressFindings(
withDeliverables([{ key: 'benchmark-table', label: '对标表', ledger: 'quote_alternative.benchmark' }]),
);
expect(found).toEqual([]);
});
it('没给地址 —— 拒装', () => {
const found = deliverableAddressFindings(withDeliverables([{ key: 'benchmark-table', label: '对标表' }]));
expect(found.map((f) => f.code)).toEqual(['deliverable-address-unbound']);
expect(found[0]?.message).toContain('对标表');
});
it('地址指向不存在的表 —— 拒装,并把声明过的表摆出来', () => {
const found = deliverableAddressFindings(
withDeliverables([{ key: 'k', label: '对标表', ledger: 'quote_alternative.nope' }]),
);
expect(found.map((f) => f.code)).toEqual(['deliverable-address-unbound']);
expect(found[0]?.message).toContain('quote_alternative.benchmark');
});
it('多件里错一件,只报那一件', () => {
const found = deliverableAddressFindings(
withDeliverables([
{ key: 'a', label: '对标表', ledger: 'quote_alternative.benchmark' },
{ key: 'b', label: '初筛清单' },
]),
);
expect(found).toHaveLength(1);
expect(found[0]?.message).toContain('初筛清单');
});
});
/**
* 台账性质要核得住 —— 这条门是拿一次真实的数据丢失换来的。
*
* A4 的报价草案本该一单一份,主键却只有 `pn`:第二单报同一个料号就 upsert 覆盖上一单。
* 跑了四轮 A4,`quote_pricing.draft` 只剩最后一轮的 3 行;
* 而主键带单号的 `quote_intake.record` 是 61 行 / 20 单,一单不少。
* **作者没决定这张表是单据还是主数据,主键就写歪了** —— 而清单语法挑不出毛病。
*/
import { ledgerKindFindings } from '../internal/domain/static-audit.ts';
type LedgerInput = Parameters<typeof ledgerKindFindings>[0];
type Kind = 'record' | 'master' | 'derived';
function table(over: { kind?: Kind; caseKey?: string; pk?: string[]; cols?: string[] }): LedgerInput {
const cols = over.cols ?? ['rfq_ref', 'pn'];
const pk = over.pk ?? ['rfq_ref', 'pn'];
return {
declarations: {
ledger: [
{
domain: 'd',
object: 'o',
label: '表',
kind: over.kind ?? 'record',
...(over.caseKey === undefined ? {} : { caseKey: over.caseKey }),
fields: cols.map((name) => ({
name,
type: 'text' as const,
primaryKey: pk.includes(name),
masked: false,
})),
},
],
},
};
}
const kindCodes = (m: LedgerInput) => ledgerKindFindings(m).map((f) => f.code);
describe('台账性质', () => {
it('单据:指明单标识且它在主键里 —— 放行', () => {
expect(kindCodes(table({ kind: 'record', caseKey: 'rfq_ref' }))).toEqual([]);
});
/* 这一条就是 A4 那次数据丢失的机检形态 */
it('单据没指明单标识 —— 拒装', () => {
const found = ledgerKindFindings(table({ kind: 'record', cols: ['pn'], pk: ['pn'] }));
expect(found.map((f) => f.code)).toContain('ledger-kind-invalid');
expect(found[0]?.message).toContain('caseKey');
});
it('单标识不在主键里 —— 拒装(单标识不进主键等于没有)', () => {
const found = ledgerKindFindings(table({ kind: 'record', caseKey: 'rfq_ref', pk: ['pn'] }));
expect(found.map((f) => f.code)).toEqual(['ledger-kind-invalid']);
expect(found[0]?.message).toContain('不是主键的一部分');
});
it('单标识不在自己字段里 —— 拒装', () => {
const found = ledgerKindFindings(table({ kind: 'record', caseKey: 'nope' }));
expect(found[0]?.message).toContain('不在它自己的字段里');
});
it('主数据:按业务实体分行,不要单标识 —— 放行', () => {
expect(kindCodes(table({ kind: 'master', cols: ['customer_code'], pk: ['customer_code'] }))).toEqual([]);
});
it('主数据却带着单标识 —— 拒装:它多半其实是单据,归错了类', () => {
const found = ledgerKindFindings(table({ kind: 'master', caseKey: 'rfq_ref' }));
expect(found.map((f) => f.code)).toEqual(['ledger-kind-invalid']);
expect(found[0]?.message).toContain('归错了类');
});
it('派生:按周期分行,不要单标识 —— 放行', () => {
expect(kindCodes(table({ kind: 'derived', cols: ['period'], pk: ['period'] }))).toEqual([]);
});
it('一个主键列都没有 —— 拒装:合并与去重无从谈起', () => {
const found = ledgerKindFindings(table({ kind: 'master', cols: ['a'], pk: [] }));
expect(found[0]?.message).toContain('主键列');
});
});
/**
* 行数读数 `域_对象_rows` —— 基座数出来的那一边。
*
* 它不是活动写得出的列,却必须是**绑得上的名字**:判据的两边不能都由活动自报,
* 否则活动数错一次就两边一起错、一起「对上」(实测:条目数报 9、表里躺着 10,
* 派单数与三类条数同源同错,`2 = 2` 顺利过关)。
* 但也不能一律放行 —— 对象名手滑写错,照旧要在装的时候拒。
*/
describe('行数读数认得出,写错的照旧拒装', () => {
it('声明过的表 → `域_对象_rows` 绑得上', () => {
expect(codes(manifest({ predicate: 'd_record_rows = line_total' }))).toEqual([]);
});
it('没声明过的表 → 照旧拒装(手滑一个字母,判据就永远达不了标)', () => {
expect(codes(manifest({ predicate: 'd_recrod_rows = line_total' }))).toContain('acceptance-predicate-unbound');
});
});