Archived
M5/M6 修复串:判据 ③ 全链路跑通 —— 六处「声明与引擎对不上」
判据 ③ 现在从入站到 released 一路走通:步序推进 → LLM 步(密钥是占位符,
按声明降级为人兜底)→ 台账草稿层 → D1 条件跳步 → S4 工具 → S5 DMN 三分类
(LM358DR → Type A · 直接快答)→ 验收放行 → 草稿合并正式版 2 行 → 输出口
intake 发射 → 终态 released。
沿路修掉的六处,每一处都是「声明是这么写的,引擎不这么读」:
1. 人兜底卡只问一个笼统「结果」框 → 改问**这一步声明的出参字段**。
出参契约属于步、不属于执行者:同一步谁做完,落进作用域的形状都得一样。
2. 人事件的载荷是回传协议壳 `{mode,workOrderId,values}`,
引擎把整个壳当出参写 → 取 `values`。
3. 引擎作用域是 `{'域.对象': 行数组}`,而所有活动的步声明写的都是裸字段名 →
任务视图三层铺开:起单入参在底、各对象最新行的字段铺顶层、地址式整表保留。
4. 起单入参从不落库、也进不了作用域 → task 存 `input_data`,断点续跑后仍在。
5. 步出参无法声明**写哪一行** → 出参加 `key`(主键列 → 作用域路径);
六个活动包的每处出参补上键。台账几乎都有主键,不声明键就只能写无主键行。
6. `tick` 不处理 `finished`:谱走完仍按 running 一拍拍推,把预算烧到 exhausted,
把「没人裁」误报成「跑爆了」→ 放行通过则落地收敛后 released;未放行则挂起等人。
`flow.advance` 据末步验收裁决报 released —— **完成只出自放行通过**。
另两处装配缺口:
· `release.land()` 实现完整却无人调用 —— 放行后从不落地。经 LandingGateway 接上。
· `process.onTaskTerminal()` 实现完整却无人调用 —— 任务终态报不到流程层,
流就停在那个节点上,既不流转也不走失败走向。task 在 L6 不得反向依赖 L7,
这一跳由 app 缝合(延后绑定,同 container 里 TriggerMatcher 的手法)。
还有一处版本化缺陷:资产播种恒用 v1,`shouldSeedAsset` 一比就跳过 ——
只有**第一个**包版本的资产此生有效,之后装什么都跑旧的。改为播下一版;
进化管线放行出的更高版仍不被盖过;同版重复安装不再播种。
gates: tsc / eslint / depcruise(317 模块)/ api-report / 393 测试 全绿
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KeDBx2PHLavbURXB8LJJ7m
This commit is contained in:
@@ -9,7 +9,7 @@ import {
|
||||
mayTakeEffect,
|
||||
shouldSeedAsset,
|
||||
} from '../internal/domain/versioning.ts';
|
||||
import type { AssetVersion, PackageVersion, ReplayCase } from '../internal/domain/versioning.ts';
|
||||
import type { AssetKind, AssetVersion, PackageVersion, ReplayCase } from '../internal/domain/versioning.ts';
|
||||
import { scanArtifact } from '../internal/domain/static-audit.ts';
|
||||
|
||||
const pkg: PackageVersion = {
|
||||
@@ -150,3 +150,31 @@ describe('scanArtifact —— 活动包零环境能力(ADR-004)', () => {
|
||||
expect(scanArtifact('import fs from "node:fs";').capabilities).toContain('node:fs');
|
||||
});
|
||||
});
|
||||
|
||||
describe('包新版携带的资产:播下一版,不恒播 v1', () => {
|
||||
const asset = (kind: AssetKind, version: number): AssetVersion => ({
|
||||
activityId: 'a1',
|
||||
kind,
|
||||
version,
|
||||
effective: version === 1,
|
||||
source: 'package-seed',
|
||||
createdAt: '2026-07-27T00:00:00.000Z',
|
||||
});
|
||||
|
||||
it('库里已有 v1 时,新包的资产应播 v2 —— 否则只有首版资产此生有效', () => {
|
||||
const existing = [asset('business-model', 1)];
|
||||
expect(shouldSeedAsset(existing, 'business-model', 2)).toBe(true);
|
||||
// 恒播 v1 就会被这条挡掉,新包的业务模型永远进不来
|
||||
expect(shouldSeedAsset(existing, 'business-model', 1)).toBe(false);
|
||||
});
|
||||
|
||||
it('进化管线放行出的更高版不被播种盖过', () => {
|
||||
const existing = [asset('business-model', 1), asset('business-model', 5)];
|
||||
expect(shouldSeedAsset(existing, 'business-model', 2)).toBe(false);
|
||||
expect(shouldSeedAsset(existing, 'business-model', 6)).toBe(true);
|
||||
});
|
||||
|
||||
it('库里没有该类资产时从 v1 起播', () => {
|
||||
expect(shouldSeedAsset([], 'dmn', 1)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@ import { activityAssetTable, activityPackageTable, assetIncrementTable } from '.
|
||||
export function createRegistryStore(db: Db): RegistryStore {
|
||||
return {
|
||||
async savePackage(manifest: ActivityManifest, artifact: string) {
|
||||
await db
|
||||
const inserted = await db
|
||||
.insert(activityPackageTable)
|
||||
.values({
|
||||
activityId: manifest.identity.activityId,
|
||||
@@ -25,7 +25,10 @@ export function createRegistryStore(db: Db): RegistryStore {
|
||||
state: 'active',
|
||||
enabled: true,
|
||||
})
|
||||
.onConflictDoNothing();
|
||||
.onConflictDoNothing()
|
||||
.returning({ version: activityPackageTable.version });
|
||||
// 回报是否**真的新增了这一版**:重复安装同版不该再播一次资产
|
||||
return inserted.length > 0;
|
||||
},
|
||||
|
||||
async listPackages(activityId) {
|
||||
|
||||
@@ -89,22 +89,34 @@ export function createRegistryService(deps: RegistryServiceDeps): ActivityRegist
|
||||
if (!verdict.accepted) throw new InstallRejectedError(verdict);
|
||||
|
||||
// 安装恒为新增、版本并存;在途任务按其启动时版本跑完
|
||||
await deps.store.savePackage(manifest, artifact);
|
||||
const isNewPackageVersion = await deps.store.savePackage(manifest, artifact);
|
||||
|
||||
// 资产初始版随包播种 —— **不覆盖已有更高的资产版**
|
||||
/*
|
||||
* 资产初始版随包播种。
|
||||
*
|
||||
* 播的是**下一个**资产版,不是恒定的 v1:包版本与资产版本是两条序列,
|
||||
* 但新包携带的初始资产同样过了安装两审,理应可用 —— 若恒播 v1,
|
||||
* 就只有第一个包版本的资产此生有效,之后再装什么都跑旧的。
|
||||
* 「不覆盖已有更高的资产版」仍然成立:进化管线放行出来的版本号更高,播种不会盖过它。
|
||||
* 同版重复安装不再播种;在途任务按启动时版本跑完,不受影响。
|
||||
*/
|
||||
const existing = await deps.store.listAssets(manifest.identity.activityId);
|
||||
const now = deps.clock.now().toISOString();
|
||||
for (const kind of SEED_KINDS) {
|
||||
if (!shouldSeedAsset(existing, kind, 1)) continue;
|
||||
const asset: AssetVersion = {
|
||||
activityId: manifest.identity.activityId,
|
||||
kind,
|
||||
version: 1,
|
||||
effective: true,
|
||||
source: 'package-seed',
|
||||
createdAt: now,
|
||||
};
|
||||
await deps.store.saveAsset(asset, serializeAsset(manifest, kind));
|
||||
if (isNewPackageVersion) {
|
||||
for (const kind of SEED_KINDS) {
|
||||
const highest = existing.filter((a) => a.kind === kind).reduce((max, a) => Math.max(max, a.version), 0);
|
||||
const seedVersion = highest + 1;
|
||||
if (!shouldSeedAsset(existing, kind, seedVersion)) continue;
|
||||
const asset: AssetVersion = {
|
||||
activityId: manifest.identity.activityId,
|
||||
kind,
|
||||
version: seedVersion,
|
||||
effective: true,
|
||||
source: 'package-seed',
|
||||
createdAt: now,
|
||||
};
|
||||
await deps.store.saveAsset(asset, serializeAsset(manifest, kind));
|
||||
}
|
||||
}
|
||||
|
||||
return verdict;
|
||||
|
||||
@@ -8,7 +8,8 @@ export type Clock = { now(): Date };
|
||||
export type IdGenerator = { next(): string };
|
||||
|
||||
export type RegistryStore = {
|
||||
savePackage(manifest: ActivityManifest, artifact: string): Promise<void>;
|
||||
/** 返回是否新增了这一包版本(同版重复安装返回 false) */
|
||||
savePackage(manifest: ActivityManifest, artifact: string): Promise<boolean>;
|
||||
listPackages(activityId?: string): Promise<PackageVersion[]>;
|
||||
manifest(activityId: string, packageVersion?: string): Promise<ActivityManifest | undefined>;
|
||||
artifact(activityId: string, packageVersion: string): Promise<string | undefined>;
|
||||
|
||||
Reference in New Issue
Block a user