# 66 个产出物与 79 个真缺陷：AI 确定性代码生成系统的分层解剖与演进复盘

对 `metarch-truthsrc`（`scala-cqrs-play-service-v2`）全部 66 类产出物按架构分层、代码角色、所有权边界与规约来源做穷举盘点，并汇总**周五路演真 PRD 踩坑（Wave 4–8，13 个）+ Wave-9 深度审计（47 个）+ 差分/蜕变/真 JVM/演进探测（`0010`–`0023`，19 个）**累计 79 个实证真缺陷，作为持续迭代的工程知识底座（截至 2026-11-28）。

<div class="co-report co-taxonomy">

<div class="verdict">
<p><strong>核心判断：</strong>在 66 类产出物中，<strong>54 类（81.8%）落在只读生成区</strong>，<strong>8 类（12.1%）落在手写隔离区</strong>，<strong>4 类（6.1%）为锁死测试预言机</strong>；真正由 EARS 行为规约直接演变而来的仅 14 类（21.2%），其余 52 类（78.8%）源自结构模型与 Play/Akka 运行时契约。</p>
<p><strong>缺陷与路演实证：</strong>全周期 <strong>79 个真实缺陷全部发生在编译器门禁、代码生成器、只读生成区和验证工具链中</strong>。周五拿真实 PRD 试跑半路卡住的“数据血缘问题”，经查提交 <code>8950ba3</code> 并非 Truth 写错、也不是代码生成出错，而是<strong>编译器静态门禁 <code>lib/v2/lineage.mjs</code> 漏记事件触发 Policy 的 <code>@PROPAGATED</code> 消费</strong>导致的假阳性阻断。</p>
</div>

<section class="hero-strip" id="co-metrics" aria-label="核心统计指标">
<div>
<div class="metric-val">66</div>
<div class="metric-label"><code>scala-cqrs-play-service-v2</code> 产出物类型（生成区 54 · 隔离区 8 · 测试预言机 4）</div>
</div>
<div>
<div class="metric-val amber">79</div>
<div class="metric-label">全周期清出的实证真缺陷（周五路演 13 · Wave-9 47 · 差分/真 JVM 19）</div>
</div>
<div>
<div class="metric-val teal">13</div>
<div class="metric-label">周五真 PRD 路演（Wave 4–8，<code>1e87c6a</code>–<code>ab207e7</code>）当场暴露的真实工程雷区</div>
</div>
<div>
<div class="metric-val">100%</div>
<div class="metric-label">79 个缺陷均位于编译器/生成器/只读生成区——一次生成器失误会扇出污染所有下游服务</div>
</div>
</section>

<section class="sec" id="spatial-map">
<h2>三层 × 三角色 × 双区：66 类产出物的完整空间版图</h2>
<p>从内部工程视角看，<code>metarch-truthsrc</code> 为单个微服务生成的目标项目沿着两条正交轴切分：纵轴是 <strong>Domain / Application / Infrastructure（含 Interfaces 与 Controllers）</strong> 三个架构层，横轴是 <strong>结构骨架（Structural Skeleton）/ 胶水代码（Glue &amp; Wiring）/ 行为代码（Behavioral Logic）</strong> 三类职责，以及 <strong>只读生成区（<code>generated-scaffold/</code>）</strong> 与 <strong>手写隔离区（<code>handwritten/</code>）</strong> 两块所有权边界。</p>
<p><strong>行为代码并不是全部在手写隔离区</strong>。确定性 L1 领域规则、事件折叠（<code>EventHandler</code>）、不变量回放检查（<code>Axioms</code>）、ReadSide 投影处理和 Policy 状态机都由生成器直接产出到只读生成区；只有 L2 非确定性计算（<code>@host</code> / <code>ComputationsImpl</code>）、L3 跨端口应用编排（<code>*StoryImpl</code>）、外部连接器与鉴权适配器才落入受 <code>overwriteCloze: false</code> 保护的手写隔离区。</p>

<figure class="arch-fig">
<div class="fig-title">生成区承担 81.8% 的结构、胶水与确定性行为，隔离区仅承接 8 类受控扩展槽</div>
<img src="/assets/img/metarch-truthsrc-artifact-bug-taxonomy-architecture.jpg" alt="三层架构与只读生成区、手写隔离区切分示意图" width="1376" height="768"/>
<figcaption>示意：自上而下为 Domain、Application、Infrastructure &amp; Interfaces；左侧 80% 为只读 <code>generated-scaffold/</code>，右侧虚线外 20% 琥珀色槽位为 <code>handwritten/</code> 隔离区。数据口径：<code>metarch-truthsrc</code> v2 桥接层与 <code>catalog.json</code> 实盘盘点。</figcaption>
</figure>

<div class="article-table">
<table>
<thead>
<tr>
<th>架构层与产出物分组</th>
<th>代码角色</th>
<th>所有权区</th>
<th>来源</th>
<th>数量</th>
<th>具体 Artifact 清单（共 66 类）</th>
</tr>
</thead>
<tbody>
<tr class="group-row"><td colspan="6">Domain 层（共 11 类：只读生成区 9 · 手写隔离区 2）</td></tr>
<tr>
<td>内核与值对象类型</td>
<td>结构骨架</td>
<td>只读生成区</td>
<td class="tag-struct">结构模型</td>
<td class="num">4</td>
<td><code>CommonTypes</code>、<code>CborSerializable</code>、<code>ValueObject / ExactType (Money/Decimal)</code>、<code>ExternalPayload</code></td>
</tr>
<tr>
<td>实体状态、协议与参数</td>
<td>结构骨架</td>
<td>只读生成区</td>
<td class="tag-struct">结构模型</td>
<td class="num">2</td>
<td><code>&lt;Agg&gt;Entity (State/Event)</code>、<code>&lt;Agg&gt;RuleParams</code></td>
</tr>
<tr>
<td>领域计算端口与外部事件桥</td>
<td>胶水代码</td>
<td>只读生成区</td>
<td class="tag-ears">EARS + 结构</td>
<td class="num">1</td>
<td><code>&lt;Agg&gt;Computations</code>（声明 L2 命令与 <code>@host</code> 函数签名）</td>
</tr>
<tr>
<td>确定性 L1 规则、折叠与不变量</td>
<td>行为代码</td>
<td>只读生成区</td>
<td class="tag-ears">EARS 演变</td>
<td class="num">2</td>
<td><code>&lt;Agg&gt;Rules</code>（守卫与 postcondition）、<code>&lt;Agg&gt;EventHandler</code> + <code>&lt;Agg&gt;Axioms</code>（合并计 2 类：规则/折叠+公理）</td>
</tr>
<tr>
<td>L2 非确定性领域计算槽</td>
<td>行为代码</td>
<td class="tag-cloze">手写隔离区</td>
<td class="tag-ears">EARS 演变</td>
<td class="num">2</td>
<td><code>&lt;Agg&gt;ComputationsImpl</code>（<code>@host</code> 与非 L1 命令实现）、<code>&lt;Target&gt;Impl</code>（L2 <code>@cloze</code> 行为实现）</td>
</tr>
<tr class="group-row"><td colspan="6">Application 层（共 15 类：只读生成区 14 · 手写隔离区 1）</td></tr>
<tr>
<td>用例端口、契约与读模型视图</td>
<td>结构骨架</td>
<td>只读生成区</td>
<td class="tag-struct">结构 + EARS</td>
<td class="num">5</td>
<td><code>&lt;Story&gt;Port</code>、<code>CallerContractSpec</code>、<code>&lt;View&gt;</code>、<code>&lt;Readside&gt;Repository</code>（Port）、<code>&lt;Stem&gt;Table</code></td>
</tr>
<tr>
<td>聚合 Actor、查询与外部连接口</td>
<td>胶水代码</td>
<td>只读生成区</td>
<td class="tag-struct">运行时契约</td>
<td class="num">5</td>
<td><code>&lt;Agg&gt;Aggregate</code>（Akka EventSourcedBehavior）、<code>&lt;View&gt;QueryService</code>、<code>OutboundConnectors</code>、<code>ToolGatePort</code>、<code>&lt;Flow&gt;InvocationFace</code></td>
</tr>
<tr>
<td>投影、Policy 与 Saga 编排壳</td>
<td>行为代码</td>
<td>只读生成区</td>
<td class="tag-ears">EARS + 编排</td>
<td class="num">4</td>
<td><code>&lt;Readside&gt;ProjectionHandler</code> + <code>Projection</code>、<code>PolicyMachine</code> + <code>&lt;Policy&gt;</code>、<code>&lt;Flow&gt;SagaModule / FixtureHost / CompositionHost</code>、<code>&lt;Eff&gt;EffectFace</code></td>
</tr>
<tr>
<td>L3 应用用例编排槽</td>
<td>行为代码</td>
<td class="tag-cloze">手写隔离区</td>
<td class="tag-ears">EARS 演变</td>
<td class="num">1</td>
<td><code>&lt;Story&gt;Impl</code>（跨端口鉴权、<code>extern</code> 校验、派发聚合与响应组装）</td>
</tr>
<tr class="group-row"><td colspan="6">Infrastructure &amp; Interfaces 层（共 36 类：只读生成区 31 · 手写隔离区 5）</td></tr>
<tr>
<td>Proto3 协议、DDL 与构建配置</td>
<td>结构骨架</td>
<td>只读生成区</td>
<td class="tag-struct">结构 + 构建</td>
<td class="num">10</td>
<td><code>&lt;agg&gt;.proto</code>、<code>shared_value_objects.proto</code>、<code>&lt;flow&gt;_host.proto</code>、<code>&lt;eff&gt;_effect.proto</code>、<code>&lt;Readside&gt;Schema</code>（DDL）、<code>build.sbt</code>、<code>plugins.sbt</code>、<code>service.conf</code>、<code>dev.conf</code>、<code>routes</code></td>
</tr>
<tr>
<td>Play Controller、路由与 API DSL</td>
<td>胶水代码</td>
<td>只读生成区</td>
<td class="tag-ears">EARS + 契约</td>
<td class="num">7</td>
<td><code>ApiDto</code>、<code>&lt;Story&gt;Controller</code>、<code>HttpRouter</code>、<code>PlayHttpBridge</code>、<code>&lt;Story&gt;PlayController</code>、<code>AggregateStateApiController</code>、<code>AuthEndpointDsl / CommandDsl / HttpStatusMapper</code></td>
</tr>
<tr>
<td>序列化、转换器与持久化仓储</td>
<td>胶水代码</td>
<td>只读生成区</td>
<td class="tag-struct">运行时契约</td>
<td class="num">8</td>
<td><code>SharedValueProtoConverters</code>、<code>&lt;Agg&gt;ProtoConverter</code>、<code>DomainConverters</code>、<code>DomainProtoSerializer</code>、<code>&lt;Flow&gt;HostSerializer</code>、<code>&lt;Eff&gt;EffectSerializer</code>、<code>&lt;Readside&gt;RepositoryImpl</code>、<code>ScalikeJdbcProjectionSession / InMemoryStore / PolicyDlqBury</code></td>
</tr>
<tr>
<td>Guice DI 与 Bootstrap 启动链</td>
<td>胶水代码</td>
<td>只读生成区</td>
<td class="tag-struct">运行时契约</td>
<td class="num">6</td>
<td><code>BootstrapModule</code>、<code>GeneratedBindingsModule</code>、<code>OnionBootstrap</code>、<code>OrchestrationModule</code>、<code>&lt;Readside&gt;Bootstrap / ProjectionModule</code>、<code>SagaCoordinatorBootstrap / ProcessBootstrap / EffectBootstrap</code></td>
</tr>
<tr>
<td>基础设施与外部集成隔离槽</td>
<td>行为 + 胶水</td>
<td class="tag-cloze">手写隔离区</td>
<td class="tag-struct">运行时契约</td>
<td class="num">5</td>
<td><code>HandwrittenBindingsModule</code>、<code>AuthorizationPortImpl</code>（PDP）、<code>ServerSnapshotProviderImpl</code>、<code>&lt;Port&gt;ConnectorImpl</code>、<code>&lt;Eff&gt;EffectPortImpl / &lt;Stem&gt;ApplyEventSemanticsImpl</code></td>
</tr>
<tr class="group-row"><td colspan="6">跨层治理与锁死测试预言机（共 4 类：只读锁死区 4）</td></tr>
<tr>
<td>Z3 锁死测试与溯源清单</td>
<td>行为预言机</td>
<td>锁死测试区</td>
<td class="tag-ears">EARS 演变</td>
<td class="num">4</td>
<td><code>&lt;Agg&gt;&lt;Cmd&gt;EarsSpec</code>（ScalaTest）、<code>&lt;Story&gt;EarsSpec</code>（应用+HTTP 路由测试）、<code>locked-tests.manifest.json</code>、<code>canonical-v2.json / knowledge.sqlite</code></td>
</tr>
</tbody>
</table>
</div>
</section>

<section class="sec" id="friday-roadshow">
<h2>周五路演实测复盘（Wave 4–8）：13 个真 PRD 踩坑与“数据血缘误报”解剖</h2>
<p>2026 年 11 月 27 日（周五）用真实业务 PRD 端到端试跑时半路卡住，连续触发了 <strong>5 个波次（Wave 4–8，提交 <code>1e87c6a</code> → <code>ab207e7</code>）、共 13 个真实缺陷</strong>。这批问题与后来的静态审计和差分测试完全不同：它们来自<strong>未经剪裁的真实业务表达</strong>（多聚合事件联动、嵌套容器、改包名重构、GET 强类型参数），集中暴露了“内部演示用例测不到的真实用户路径”。</p>

<div class="split">
<div><h3>数据血缘问题定性：既非 Truth 写错，也非代码生成出错</h3></div>
<div>
<p>提交 <code>8950ba3</code>（Wave-6）记录的正是路演中卡住的数据血缘缺陷。PRD 中写了一条合法的<strong>事件触发 Policy（<code>WHEN Event ... SHALL dispatch TargetAgg.Cmd</code>）</strong>，事件字段通过 <code>@PROPAGATED</code> 自动透传给下游命令参数——<strong>Truth 规约本身完全正确</strong>。</p>
<p>真正出问题的是<strong>编译器静态校验层 <code>lib/v2/lineage.mjs</code></strong>：Check 3（<code>verifyDispatchLineage</code>）此前漏掉了将事件触发规则消费的事件字段登记进 <code>consumedEventFields</code>，导致 Check 4 误报 <code>V2_LINEAGE_UNCONSUMED_*</code> 错误，直接阻断了编译。修复本身只有 3 行代码，但教训极其深刻：<strong>静态治理门禁一旦出现假阳性（False Positive），对真实用户的杀伤力和编译崩溃一样大</strong>。</p>
</div>
</div>

<div class="cols-3">
<div class="col-item">
<h3>血缘门禁 · 硬阻断（默认 <code>error</code>）</h3>
<ul class="clean">
<li><code>post:</code> 与 ReadModel 引用的 <code>eventField:</code> / <code>stateField:</code> 不存在或类型冲突。</li>
<li><code>dispatch</code> 同名参数类型与上游输入不兼容。</li>
<li><code>V2_LINEAGE_UNCONSUMED_NUMERIC_FIELD</code>（默认 <code>failClosedNumeric = true</code>，数值事件字段无人消费直接阻断）。</li>
</ul>
</div>
<div class="col-item">
<h3>血缘门禁 · 软提醒（默认 <code>warning</code>）</h3>
<ul class="clean">
<li><strong>定义了没读</strong>：<code>DEAD_STATE_FIELD</code>、<code>WRITE_ONLY_STATE_FIELD</code>、<code>UNCONSUMED_EVENT_FIELD</code>。</li>
<li><strong>下游缺上游输出</strong>：<code>DISPATCH_UNBOUND_PARAM</code>、<code>UNWRITTEN_STATE_FIELD</code>、<code>UNSOURCED_READMODEL_FIELD</code>。</li>
<li>需显式开启 <code>strictLineage = true</code> 才升级为硬阻断（合法只写/配置字段用 <code>waiveLineage</code> 豁免）。</li>
</ul>
</div>
<div class="col-item">
<h3>血缘门禁 · 三个真盲区（假阴性）</h3>
<ul class="clean">
<li><strong><code>@cloze</code> 手写体内部</strong>：不解析 Scala 手写体，<code>DISPATCH_UNBOUND_PARAM</code> 假定由手写槽合成，漏传须靠锁死测试与变异测试兜底。</li>
<li><strong>跨服务异步事件</strong>：仅覆盖单 BC（或合并子域），无法静态证明远端上游产出。</li>
<li><strong>同名异义字段</strong>：<code>@PROPAGATED</code> 按名称+类型对齐，同名同类型（如订单 <code>id</code> 与用户 <code>id</code>）无法区分业务语义。</li>
</ul>
</div>
</div>

<div class="cols-3">
<div class="col-item">
<h3>Wave 4–5：嵌套数据结构与重命名演进（5 项）</h3>
<ul class="clean">
<li><code>1e87c6a</code>：Proto3 嵌套容器缺 <code>BoxPO</code> 包装与转换器（Infra Proto）；<code>PlayController</code> 漏传 principal entitlements/attributes 及属性大小写敏感（Infra Play）。</li>
<li><code>93a6350</code>：二维嵌套 <code>Map[String, Map[String, VO]]</code> 的 SMT/witness/代码生成与 <code>encVal/encBool</code> 互递归爆栈（Domain SMT）；手写隔离类缺非破坏性方法同步（工具链）；包名重构后未清理旧 starter 残留文件（治理）。</li>
</ul>
</div>
<div class="col-item">
<h3>Wave 6–7：血缘假阳性、Optional 与 GET 强类型（6 项）</h3>
<ul class="clean">
<li><code>8950ba3</code>：事件触发 Policy <code>@PROPAGATED</code> 血缘消费漏记（编译器门禁）；<code>Optional[VO]</code> 成员访问在 Scala &amp; TS 缺 null-safe 展开（Domain 翻译）。</li>
<li><code>cf4545a</code>：<code>Optional[T]</code> 流敏感收窄与 OR 边界 witness（M24）；<code>forall + sum</code> 耦合 LIA 公理缺失（M26）；Schema 驱动 GET Query 强类型转换（M25）；<code>check-v2 --sync</code> 暴露包名变更后的 stale 手写文件（M27）。</li>
</ul>
</div>
<div class="col-item">
<h3>Wave 8：多 BC 跨界与 ReadSide 包装（2 项）</h3>
<ul class="clean">
<li><code>ab207e7</code>（M28）：多 BC <code>#46 external-event-bridge</code> 缺少强类型 Payload VO 与完整 <code>slotMembers</code> / <code>identityKey</code>（App/Orchestration）。</li>
<li><code>ab207e7</code>（M30）：<code>#26 ApplyEvent</code> 与 <code>#28 ReadsideProjectionHandler</code> 将非 Optional 事件字段写入 Optional ReadModel 列时漏包 <code>Some(...)</code>（Infra ReadSide）。</li>
</ul>
</div>
</div>
</section>

<section class="sec" id="bug-distribution">
<h2>79 个全周期缺陷的空间分布：三波战役如何接力扫清盲区</h2>
<p>将 <strong>周五路演（Wave 4–8，13 个）</strong>、<strong>Wave-9 深度审计（<code>0001</code>–<code>0007</code>，47 个）</strong> 与 <strong>差分/蜕变/真 <code>scalac</code>+JVM/ReadSide-Saga 探测（<code>0010</code>–<code>0023</code>，19 个）</strong> 合并为 <strong>79 个实证缺陷</strong>后，三个阶段的互补性一目了然：周五真 PRD 路演率先炸出编译器门禁假阳性、嵌套容器和包名重构盲区；Wave-9 审计系统性扫清了 Play 生产启动链、Guice/Authz/DLQ 与门禁漏洞；而差分+真 JVM 探测则专门打穿了肉眼和单测根本看不见的 SMT↔Scala 跨阶段语义漂移。</p>

<figure class="chart-fig">
<div class="fig-title">Domain 语义翻译（31 个）与 Infra 胶水/持久化（29 个）合占全部 79 个缺陷的 75.9%</div>
<svg viewBox="0 0 700 400" width="100%" role="img" aria-label="79个真实缺陷在5个架构空间中按三阶段来源（周五路演13、Wave-9审计47、差分与真JVM探测19）的堆叠条形图">
<line x1="220" y1="40" x2="220" y2="322" class="svg-axis"/>
<line x1="330" y1="40" x2="330" y2="322" class="svg-grid"/>
<line x1="440" y1="40" x2="440" y2="322" class="svg-grid"/>
<line x1="550" y1="40" x2="550" y2="322" class="svg-grid"/>

<text x="220" y="344" text-anchor="middle" font-size="13" class="svg-mono">0</text>
<text x="330" y="344" text-anchor="middle" font-size="13" class="svg-mono">10</text>
<text x="440" y="344" text-anchor="middle" font-size="13" class="svg-mono">20</text>
<text x="550" y="344" text-anchor="middle" font-size="13" class="svg-mono">30</text>
<text x="412" y="370" text-anchor="middle" font-size="13" class="svg-sub">已验证并修复的真实缺陷数量（全周期总计 79）</text>

<rect x="170" y="10" width="13" height="13" class="svg-bar-roadshow"/>
<text x="189" y="21" font-size="13" class="svg-label">周五路演 Wave 4–8 (13)</text>
<rect x="355" y="10" width="13" height="13" class="svg-bar-wave9"/>
<text x="374" y="21" font-size="13" class="svg-label">Wave-9 审计 (47)</text>
<rect x="500" y="10" width="13" height="13" class="svg-bar-diff"/>
<text x="519" y="21" font-size="13" class="svg-label">差分 / 真 JVM (19)</text>

<text x="210" y="76" text-anchor="end" font-size="14" font-weight="600" class="svg-label">Domain 行为 / SMT 翻译</text>
<rect x="220" y="56" width="44" height="28" class="svg-bar-roadshow"/>
<rect x="264" y="56" width="154" height="28" class="svg-bar-wave9"/>
<rect x="418" y="56" width="143" height="28" class="svg-bar-diff"/>
<text x="242" y="75" text-anchor="middle" font-size="13" class="svg-on-bar">4</text>
<text x="341" y="75" text-anchor="middle" font-size="13" class="svg-on-bar">14</text>
<text x="489" y="75" text-anchor="middle" font-size="13" class="svg-on-bar">13</text>
<text x="571" y="75" font-size="14" class="svg-val">31 (39.2%)</text>

<text x="210" y="132" text-anchor="end" font-size="14" font-weight="600" class="svg-label">Infra 胶水 / Play / 鉴权</text>
<rect x="220" y="112" width="22" height="28" class="svg-bar-roadshow"/>
<rect x="242" y="112" width="176" height="28" class="svg-bar-wave9"/>
<rect x="418" y="112" width="11" height="28" class="svg-bar-diff"/>
<text x="231" y="131" text-anchor="middle" font-size="12" class="svg-on-bar">2</text>
<text x="330" y="131" text-anchor="middle" font-size="13" class="svg-on-bar">16</text>
<text x="439" y="131" font-size="14" class="svg-val">19 (24.1%)</text>

<text x="210" y="188" text-anchor="end" font-size="14" font-weight="600" class="svg-label">编译器门禁 / 血缘 / 治理</text>
<rect x="220" y="168" width="44" height="28" class="svg-bar-roadshow"/>
<rect x="264" y="168" width="77" height="28" class="svg-bar-wave9"/>
<text x="242" y="187" text-anchor="middle" font-size="13" class="svg-on-bar">4</text>
<text x="302" y="187" text-anchor="middle" font-size="13" class="svg-on-bar">7</text>
<text x="351" y="187" font-size="14" class="svg-val">11 (13.9%)</text>

<text x="210" y="244" text-anchor="end" font-size="14" font-weight="600" class="svg-label">Infra ReadSide / SQL</text>
<rect x="220" y="224" width="22" height="28" class="svg-bar-roadshow"/>
<rect x="242" y="224" width="55" height="28" class="svg-bar-wave9"/>
<rect x="297" y="224" width="33" height="28" class="svg-bar-diff"/>
<text x="231" y="243" text-anchor="middle" font-size="12" class="svg-on-bar">2</text>
<text x="269" y="243" text-anchor="middle" font-size="13" class="svg-on-bar">5</text>
<text x="313" y="243" text-anchor="middle" font-size="13" class="svg-on-bar">3</text>
<text x="340" y="243" font-size="14" class="svg-val">10 (12.7%)</text>

<text x="210" y="300" text-anchor="end" font-size="14" font-weight="600" class="svg-label">Application / Saga / BC</text>
<rect x="220" y="280" width="11" height="28" class="svg-bar-roadshow"/>
<rect x="231" y="280" width="55" height="28" class="svg-bar-wave9"/>
<rect x="286" y="280" width="22" height="28" class="svg-bar-diff"/>
<text x="258" y="299" text-anchor="middle" font-size="13" class="svg-on-bar">5</text>
<text x="297" y="299" text-anchor="middle" font-size="12" class="svg-on-bar">2</text>
<text x="318" y="299" font-size="14" class="svg-val">8 (10.1%)</text>
</svg>
<figcaption>统计口径：<code>1e87c6a</code>（Wave-4）至 <code>0e8df64</code>（<code>0023</code>）全部 79 个已核实修复；注：Infra 胶水行末端琥珀段为 1（<code>PolicyMachine $aggType·</code>），Application 行首端青色段为 1（M28 多 BC 桥接）。</figcaption>
</figure>
</section>

<div class="ed-band" id="ai-root-causes">
<h2>AI Engineering Coding 归因：这 79 个缺陷是如何系统性形成的</h2>
<p>在 AI 深度参与编译器、桥接层和代码生成器开发的实践里，这 79 个问题高度集中在 <strong>5 类结构性 AI 编码失效模式</strong>上——与 <a href="https://www.computer.org/csdl/proceedings-article/icse/2025/056900a717/251mH51B1AY">Wang 等人（ICSE 2025）对 557 个 LLM 代码生成错误的实证分类</a> 高度吻合（语义与契约错位远多于基础语法错）：</p>

<div class="cols-2">
<div class="col-item">
<h3>1. 跨阶段语义漂移（Cross-Stage Semantic Drift）</h3>
<p><code>metarch-truthsrc</code> 横跨 Parser → Binder → <code>smt-encoder</code> → <code>witness-materialize</code> → <code>ears-simplify / v1-strict-scala</code> 五个独立模块。AI 在单次上下文里新增特性时，往往只打通前 2 个阶段、漏掉后 3 个阶段——例如 <code>Seq/Map is empty</code>、<code>Record ==</code> 未预注册、二维 <code>Map[String, Map[String, VO]]</code> 互递归、<code>@host</code> 漏声明 <code>Computations</code> 方法。</p>
</div>
<div class="col-item">
<h3>2. 配置即运行时的错觉（Config-Equals-Runtime Illusion）</h3>
<p>AI 极易把“配置文件或模板里写了某行声明”等同于“运行时真正生效”。典型案例：<code>service.conf</code> 写了 <code>CSRFFilter</code> 却在真 Play 进程里未拦截（<code>0021</code> 首次黑盒跑真服务即抓出）；<code>v1-strict-orchestration</code> 登记了 <code>strict-saga-module</code> 却产出假桩；<code>PolicyMachine</code> 的 <code>s"$aggType·"</code> 与 Ubuntu CI 的 <code>apt-get install scala</code>（2.11 冒充 2.12）。</p>
</div>
<div class="col-item">
<h3>3. 防御性静默降级偏好（Fail-Open / Silent Fallback Bias）</h3>
<p>为了“不崩”，AI 天然偏爱写 <code>.getOrElse(Zero)</code>、<code>Try(...).toOption</code>、<code>Boolean(val)</code>。结果把致命语义错全部静默吞掉：<code>Money.create(0.01, "id_2").getOrElse(Money.Zero)</code> 把测试金额静默归零；<code>coerceTypedValue('false', bool)</code> 静默返回 <code>true</code>；ReadSide <code>Optional</code> 列把损坏 JSON 静默吞成 <code>None</code>。</p>
</div>
<div class="col-item">
<h3>4. 组合爆炸与静态门禁假阳性（Interaction &amp; Gate-FP Blindness）</h3>
<p>单维单测会掩盖两因子交互缺陷（<code>Optional[Record] × post:</code>、<code>2D Map × Axioms</code>），符合 <a href="https://nvlpubs.nist.gov/nistpubs/legacy/sp/nistspecialpublication800-142.pdf">NIST SP 800-142</a> 交互规律；同时，静态治理门禁（如 <code>lineage.mjs</code> 漏记事件 Policy <code>@PROPAGATED</code>、<code>docs/artifacts</code> 248 项存量目录漂移）若缺乏真实 PRD 回归，就会以假阳性卡死真实用户。</p>
</div>
</div>
</div>

<section class="sec" id="whitebox-vs-blackbox">
<h2>白盒 vs 黑盒发现矩阵：不同空间必须匹配不同武器</h2>
<p>实战证明，<strong>没有任何单一测试手段能覆盖超过 40% 的真缺陷</strong>：真实 PRD 路演擅长抓门禁假阳性与演进摩擦；静态审计擅长扫显式架构违背；Pairwise + 蜕变 + 真 JVM 轨迹专打跨阶段语义漂移；而真 Play 黑盒 E2E 是校验 transport 与安全拦截的唯一真凭实据。</p>

<figure class="chart-fig">
<div class="fig-title">六种验证手段在五个缺陷空间中严格互补，必须按空间组合编排</div>
<svg viewBox="0 0 700 390" width="100%" role="img" aria-label="5个缺陷空间与6种黑白盒验证手段的发现效力热力矩阵图">
<text x="245" y="28" text-anchor="middle" font-size="13" font-weight="600" class="svg-label">静态 Lint</text>
<text x="245" y="45" text-anchor="middle" font-size="12" class="svg-mono">白盒</text>

<text x="325" y="28" text-anchor="middle" font-size="13" font-weight="600" class="svg-label">单测 / 变异</text>
<text x="325" y="45" text-anchor="middle" font-size="12" class="svg-mono">白盒</text>

<text x="405" y="28" text-anchor="middle" font-size="13" font-weight="600" class="svg-label">Pairwise</text>
<text x="405" y="45" text-anchor="middle" font-size="12" class="svg-mono">黑盒组合</text>

<text x="485" y="28" text-anchor="middle" font-size="13" font-weight="600" class="svg-label">蜕变差分</text>
<text x="485" y="45" text-anchor="middle" font-size="12" class="svg-mono">黑盒等价</text>

<text x="565" y="28" text-anchor="middle" font-size="13" font-weight="600" class="svg-label">真 JVM</text>
<text x="565" y="45" text-anchor="middle" font-size="12" class="svg-mono">跨运行时</text>

<text x="645" y="28" text-anchor="middle" font-size="13" font-weight="600" class="svg-label">Play E2E</text>
<text x="645" y="45" text-anchor="middle" font-size="12" class="svg-mono">黑盒真进程</text>

<line x1="20" y1="58" x2="685" y2="58" class="svg-axis"/>

<text x="195" y="96" text-anchor="end" font-size="14" font-weight="600" class="svg-label">Domain 行为 / SMT</text>
<rect x="210" y="70" width="70" height="42" class="svg-hm-low"/><text x="245" y="96" text-anchor="middle" font-size="13" class="svg-hm-low-t">低</text>
<rect x="290" y="70" width="70" height="42" class="svg-hm-mid"/><text x="325" y="96" text-anchor="middle" font-size="13" class="svg-hm-mid-t">中</text>
<rect x="370" y="70" width="70" height="42" class="svg-hm-main"/><text x="405" y="96" text-anchor="middle" font-size="13" class="svg-hm-hi-t">主力</text>
<rect x="450" y="70" width="70" height="42" class="svg-hm-main"/><text x="485" y="96" text-anchor="middle" font-size="13" class="svg-hm-hi-t">主力</text>
<rect x="530" y="70" width="70" height="42" class="svg-hm-main"/><text x="565" y="96" text-anchor="middle" font-size="13" class="svg-hm-hi-t">主力</text>
<rect x="610" y="70" width="70" height="42" class="svg-hm-low"/><text x="645" y="96" text-anchor="middle" font-size="13" class="svg-hm-low-t">低</text>

<text x="195" y="152" text-anchor="end" font-size="14" font-weight="600" class="svg-label">Application / Saga</text>
<rect x="210" y="126" width="70" height="42" class="svg-hm-mid"/><text x="245" y="152" text-anchor="middle" font-size="13" class="svg-hm-mid-t">中</text>
<rect x="290" y="126" width="70" height="42" class="svg-hm-main"/><text x="325" y="152" text-anchor="middle" font-size="13" class="svg-hm-hi-t">主力</text>
<rect x="370" y="126" width="70" height="42" class="svg-hm-mid"/><text x="405" y="152" text-anchor="middle" font-size="13" class="svg-hm-mid-t">中</text>
<rect x="450" y="126" width="70" height="42" class="svg-hm-mid"/><text x="485" y="152" text-anchor="middle" font-size="13" class="svg-hm-mid-t">中</text>
<rect x="530" y="126" width="70" height="42" class="svg-hm-mid"/><text x="565" y="152" text-anchor="middle" font-size="13" class="svg-hm-mid-t">中</text>
<rect x="610" y="126" width="70" height="42" class="svg-hm-crit"/><text x="645" y="152" text-anchor="middle" font-size="13" class="svg-hm-hi-t">关键</text>

<text x="195" y="208" text-anchor="end" font-size="14" font-weight="600" class="svg-label">Infra ReadSide / Proto</text>
<rect x="210" y="182" width="70" height="42" class="svg-hm-main"/><text x="245" y="208" text-anchor="middle" font-size="13" class="svg-hm-hi-t">主力</text>
<rect x="290" y="182" width="70" height="42" class="svg-hm-mid"/><text x="325" y="208" text-anchor="middle" font-size="13" class="svg-hm-mid-t">中</text>
<rect x="370" y="182" width="70" height="42" class="svg-hm-mid"/><text x="405" y="208" text-anchor="middle" font-size="13" class="svg-hm-mid-t">中</text>
<rect x="450" y="182" width="70" height="42" class="svg-hm-low"/><text x="485" y="208" text-anchor="middle" font-size="13" class="svg-hm-low-t">低</text>
<rect x="530" y="182" width="70" height="42" class="svg-hm-mid"/><text x="565" y="208" text-anchor="middle" font-size="13" class="svg-hm-mid-t">中</text>
<rect x="610" y="182" width="70" height="42" class="svg-hm-crit"/><text x="645" y="208" text-anchor="middle" font-size="13" class="svg-hm-hi-t">关键</text>

<text x="195" y="264" text-anchor="end" font-size="14" font-weight="600" class="svg-label">Infra Play / 鉴权 / CSRF</text>
<rect x="210" y="238" width="70" height="42" class="svg-hm-mid"/><text x="245" y="264" text-anchor="middle" font-size="13" class="svg-hm-mid-t">中</text>
<rect x="290" y="238" width="70" height="42" class="svg-hm-low"/><text x="325" y="264" text-anchor="middle" font-size="13" class="svg-hm-low-t">低</text>
<rect x="370" y="238" width="70" height="42" class="svg-hm-low"/><text x="405" y="264" text-anchor="middle" font-size="13" class="svg-hm-low-t">低</text>
<rect x="450" y="238" width="70" height="42" class="svg-hm-low"/><text x="485" y="264" text-anchor="middle" font-size="13" class="svg-hm-low-t">低</text>
<rect x="530" y="238" width="70" height="42" class="svg-hm-low"/><text x="565" y="264" text-anchor="middle" font-size="13" class="svg-hm-low-t">低</text>
<rect x="610" y="238" width="70" height="42" class="svg-hm-crit"/><text x="645" y="264" text-anchor="middle" font-size="13" class="svg-hm-hi-t">唯一解</text>

<text x="195" y="320" text-anchor="end" font-size="14" font-weight="600" class="svg-label">门禁 / 血缘 / 隔离区</text>
<rect x="210" y="294" width="70" height="42" class="svg-hm-mid"/><text x="245" y="320" text-anchor="middle" font-size="13" class="svg-hm-mid-t">中</text>
<rect x="290" y="294" width="70" height="42" class="svg-hm-main"/><text x="325" y="320" text-anchor="middle" font-size="13" class="svg-hm-hi-t">主力</text>
<rect x="370" y="294" width="70" height="42" class="svg-hm-low"/><text x="405" y="320" text-anchor="middle" font-size="13" class="svg-hm-low-t">低</text>
<rect x="450" y="294" width="70" height="42" class="svg-hm-low"/><text x="485" y="320" text-anchor="middle" font-size="13" class="svg-hm-low-t">低</text>
<rect x="530" y="294" width="70" height="42" class="svg-hm-main"/><text x="565" y="320" text-anchor="middle" font-size="13" class="svg-hm-hi-t">主力</text>
<rect x="610" y="294" width="70" height="42" class="svg-hm-road"/><text x="645" y="320" text-anchor="middle" font-size="13" class="svg-hm-hi-t">路演</text>

<text x="350" y="368" text-anchor="middle" font-size="13" class="svg-sub">蓝色 = 主力手段 · 琥珀 = 不可替代的真运行时证据 · 青色 = 真实 PRD 演练</text>
</svg>
<figcaption>基于 Wave-4 至 <code>0023</code> 全部 79 个缺陷的实际捕获路径整理。</figcaption>
</figure>

<div class="article-table">
<table>
<thead>
<tr>
<th>代码空间</th>
<th>典型缺陷现象（含路演实证）</th>
<th>白盒发现策略</th>
<th>黑盒 / 跨运行时策略</th>
<th>开发期前置防呆改进</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Domain 行为与 SMT 翻译</strong>（生成区）</td>
<td>集合判空/Record 相等未预注册、<code>Option.copy</code> 与 2D Map 编译失败、<code>Optional[VO]</code> 空安全与流敏感收窄、<code>Money.Zero</code> 静默归零</td>
<td>AST 穷举单测、<code>smt-encoder</code> 预注册不变量检查、禁止 <code>.getOrElse(Zero)</code> 静默兜底 lint</td>
<td>2-wise Pairwise + 蜕变等价 + 真 <code>scalac 2.13</code>/JVM 执行 + 900 步多命令有状态轨迹</td>
<td>新增任何 EARS 语法节点时，强制同步过 <strong>5 阶段契约清单</strong>（Parser / Bind / SMT / Materialize / Scala）</td>
</tr>
<tr>
<td><strong>Application 编排与 Saga</strong>（生成区）</td>
<td>Saga 假桩冒充 <code>saga-core</code>、重放非幂等、跨上下文序列化器 ID 撞车、多 BC <code>#46</code> 缺强类型 Payload VO</td>
<td>复用 1.0 <code>emitter/families/#40–#43</code> 的 <code>checkInput</code> 强校验、跨 BC 合并冲突单测</td>
<td>多子域 BC 合并编译、重复事件与终态回放测试、Play 路由黑盒压测</td>
<td>禁止在 <code>familiesUsed</code> 虚报未调用家族；优先桥接已认证的 1.0 <code>saga-core</code> 家族而非手写简化模板</td>
</tr>
<tr>
<td><strong>Infra ReadSide / SQL / Proto</strong>（生成区）</td>
<td>局部事件覆盖清空历史列、Optional 损坏列静默吞错、漏包 <code>Some(...)</code>、Proto3 嵌套缺 <code>BoxPO</code>、分页 <code>Int</code> 溢出</td>
<td><code>npm run test:proto-compat</code>（&lt;1s 二进制演进检查）、SQL 保留字/fail-fast 静态正则回归</td>
<td>真实 PostgreSQL 容器跑连续多事件投影 + 损坏列注入 + 历史 Proto 字节回放</td>
<td>ReadSide 投影统一为“先 <code>findById</code> 合并旧行再 <code>upsert</code>”；将 <code>proto-compat</code> 设为 CI 阻断门禁</td>
</tr>
<tr>
<td><strong>Infra Play / HTTP / Authz / CSRF</strong>（生成区）</td>
<td>配置写了 CSRF 却未生效、principal entitlements 漏传、GET query 强类型转换错位、401/403 错序、Ubuntu CI 装错 Scala 2.11</td>
<td>静态 lint（禁止孤儿 <code>app/</code>、禁止 fallback <code>userId</code>）、CI 工具链版本显式锁定（2.13.14）</td>
<td><strong>每个 transport 断言必须配真 Play 进程运行时证据</strong>（401 / 403 / 无 CSRF 403 / 畸形 JSON 400 / 跨租户越权）</td>
<td>建立 <strong>Transport Patch 自检清单</strong>：凡改路由、Filter、Authz、Guice 绑定，必须在 <code>e2e-play-smoke</code> 增加对应的真 HTTP 断言</td>
</tr>
<tr>
<td><strong>编译器门禁、血缘与隔离区</strong>（工具链 + <code>handwritten/</code>）</td>
<td>事件 Policy <code>@PROPAGATED</code> 血缘误报卡死编译、增量重生成漏同步 <code>@host</code> 方法、改包名残留 stale starter 文件</td>
<td><code>guard-write</code>、<code>overwriteCloze: false</code> + <code>syncMissingScalaMethods</code> 回归、100% 变异测试门禁</td>
<td>锁死 <code>*EarsSpec</code> 预言机 + 真实 PRD 端到端演练（含改包名、增删事件与多聚合 Policy）</td>
<td>每条静态门禁规则必须配正/反双测（防假阴性也防假阳性），并在 <code>check-v2 --sync</code> 显式报告 stale 隔离文件</td>
</tr>
</tbody>
</table>
</div>

<blockquote class="pull">
“0021 的 e2e 强断言把‘配置里有 CSRF’变成了‘运行时真的拦’；而周五 8950ba3 的血缘误报提醒我们，静态门禁既要防假阴性，也要防假阳性卡死真实 PRD。”
</blockquote>
</section>

<section class="sec" id="industry-literature">
<h2>业界工程实践与学术论文对照：可复用的长期演进指南</h2>
<p>我们在这轮 79 个缺陷的排雷里沉淀出的“<strong>真实 PRD 路演 + 形式化模型 + Pairwise 组合 + 蜕变等价 + 跨运行时真 JVM 差分 + 真进程黑盒证据</strong>”，与工业界和学术界最成熟的编译器/自动化推理验证体系高度同构：</p>

<div class="split">
<div><h3>工业界标杆：AWS Cedar 的验证驱动开发</h3></div>
<div>
<p>AWS 构建 Cedar 授权引擎时采用 <strong>Verification-Guided Development</strong> 双轨范式（<a href="https://www.amazon.science/blog/how-we-built-cedar-with-automated-reasoning-and-differential-testing">AWS Science, 2023</a>）：先用 Dafny 形式化证明安全属性，再用 <strong>Differential Random Testing（DRT）</strong> 每晚跑上亿次输入比对 Dafny 模型与 Rust 生产引擎。AWS 特别强调纯随机输入会过度集中在报错分支、漏掉核心逻辑，必须构造“策略与数据一致的生成器”——这与我们用 Pairwise + Z3 witness 驱动真 JVM 执行的架构完全一致。</p>
</div>
</div>

<div class="split">
<div><h3>编译器与翻译器验证的四大经典基石</h3></div>
<div>
<ul class="clean">
<li><strong>差分测试</strong>：<a href="https://www.semanticscholar.org/paper/Differential-Testing-for-Software-McKeeman/fc881e8d0432ea8e4dd5fda4979243cac5e4b9e3">McKeeman (1998)</a> 提出将同一输入喂给多个独立实现，靠结果分歧直接暴露静默语义错误。</li>
<li><strong>无未定义行为的程序生成（Csmith）</strong>：<a href="https://www.flux.utah.edu/paper/yang-pldi11/">Yang, Chen, Eide &amp; Regehr (PLDI 2011)</a> 在 GCC/LLVM 抓出 325+ 未知缺陷，证明静默生成错误代码（wrong-code）比崩溃更隐蔽致命。</li>
<li><strong>蜕变测试与等价模输入（EMI / Semantic Fusion）</strong>：<a href="https://people.inf.ethz.ch/suz/publications/emi.pdf">Le, Afshari &amp; Su (PLDI 2014)</a> 靠语义等价变换在 GCC/LLVM 抓出 600+ 缺陷；<a href="https://cs.hku.hk/~tse/Papers/2010s/hlmtCSUR.html">Chen 等人 (ACM Computing Surveys 2018)</a> 总结了蜕变关系破解预言机难题的范式；<a href="https://testsmt.github.io/papers/winterer-zhang-su-pldi20.pdf">Winterer, Zhang &amp; Su (PLDI 2020)</a> 用语义融合（YinYang）验证 SMT 求解器。</li>
<li><strong>组合交互测试</strong>：<a href="https://nvlpubs.nist.gov/nistpubs/legacy/sp/nistspecialpublication800-142.pdf">Kuhn, Kacker &amp; Lei (NIST SP 800-142)</a> 确立了两因子交互规律，解释了为何 2-wise Pairwise 能以极低成本抓出绝大部分组合缺陷。</li>
</ul>
</div>
</div>

<div class="split">
<div><h3>AI 编程缺陷与持续迭代机制</h3></div>
<div>
<p><a href="https://www.computer.org/csdl/proceedings-article/icse/2025/056900a717/251mH51B1AY">Wang 等人 (ICSE 2025)</a> 对 557 个 LLM 代码生成错误的研究表明，语法合法但语义/契约错位是 AI 编码的常态。因此，这份报告本身也应当作为<strong>活文档（Living Post-Mortem）</strong>随后续每个波次持续更新：每当真实 PRD、PostgreSQL 压测、跨聚合 Saga 桥接（<code>#40</code>–<code>#43</code>）或双语 EARS 暴露出新缺陷，就将其归入对应的“层 × 角色 × 区”格子，并把对应的防呆断言沉淀到白盒或黑盒门禁中。</p>
</div>
</div>
</section>

<section class="sources-sec" id="references">
<h2>参考资料</h2>
<ol class="refs">
<li>William M. McKeeman (1998). <a href="https://www.semanticscholar.org/paper/Differential-Testing-for-Software-McKeeman/fc881e8d0432ea8e4dd5fda4979243cac5e4b9e3">Differential Testing for Software</a>. <em>Digital Technical Journal</em>, 10(1), 100–107.</li>
<li>D. Richard Kuhn, Raghu N. Kacker, &amp; Yu Lei (2010). <a href="https://nvlpubs.nist.gov/nistpubs/legacy/sp/nistspecialpublication800-142.pdf">Practical Combinatorial Testing</a>. <em>NIST Special Publication 800-142</em>.</li>
<li>Xuejun Yang, Yang Chen, Eric Eide, &amp; John Regehr (2011). <a href="https://www.flux.utah.edu/paper/yang-pldi11/">Finding and Understanding Bugs in C Compilers</a>. <em>Proc. ACM SIGPLAN PLDI 2011</em>, 283–294.</li>
<li>Vu Le, Mehrdad Afshari, &amp; Zhendong Su (2014). <a href="https://people.inf.ethz.ch/suz/publications/emi.pdf">Compiler Validation via Equivalence Modulo Inputs</a>. <em>Proc. ACM SIGPLAN PLDI 2014</em>.</li>
<li>Tsong Yueh Chen, Fei-Ching Kuo, Huai Liu, Pak-Lok Poon, Dave Towey, T. H. Tse, &amp; Zhi Quan Zhou (2018). <a href="https://cs.hku.hk/~tse/Papers/2010s/hlmtCSUR.html">Metamorphic Testing: A Review of Challenges and Opportunities</a>. <em>ACM Computing Surveys</em>, 51(1), Article 4.</li>
<li>Dominik Winterer, Chengyu Zhang, &amp; Zhendong Su (2020). <a href="https://testsmt.github.io/papers/winterer-zhang-su-pldi20.pdf">Validating SMT Solvers via Semantic Fusion</a>. <em>Proc. ACM SIGPLAN PLDI 2020</em>.</li>
<li>Amazon Science / AWS Automated Reasoning Group (2023). <a href="https://www.amazon.science/blog/how-we-built-cedar-with-automated-reasoning-and-differential-testing">How we built Cedar with automated reasoning and differential testing</a>.</li>
<li>Zhijie Wang et al. (2025). <a href="https://www.computer.org/csdl/proceedings-article/icse/2025/056900a717/251mH51B1AY">Towards Understanding the Characteristics of Code Generation Errors Made by Large Language Models</a>. <em>Proc. IEEE/ACM ICSE 2025</em>.</li>
</ol>
</section>

</div>
