Archived
工作成果里摆着别单的资料:「这一单产出的」认本单碰过的行
放行存档(archiveAssetFiles)与在办列单(assetFilesOf)取行都用 taskView(where:{}) ——
那是「正式版全表 + 本单草稿」的合并视图,而资料常落在主数据上,整表里躺着别单放行过的行。
抽 assetRowsOf 两处同用,touched 为必填入参;e2e 补份数断言。
顺手清两笔:wake.test.ts 的 as unknown as(lint 红)、wake 契约的 api-report 快照(api:check 红)。
This commit is contained in:
@@ -1294,6 +1294,22 @@
|
||||
的 card-sent 也算隔开),一句话只领一张卡。3 测(26 → 全绿)。**同一症状两条独立的路**
|
||||
(时钟偏 / 并卡误认),治完一条要把另一条也走一遍 —— 这是 08-23 灰底那课的第二次。
|
||||
|
||||
- **工作成果里摆着别单的资料:「这一单产出的」被算成了「这张表里所有的行」**(2026-08-25
|
||||
柴浩:「这个工作成果怎么有 4 个资料,这单的需求只会产出一个」):那一单只写了
|
||||
`CT-2026-0004` 一行(三笔留痕全指着它、放行合并 3 行),而工作成果里摆着四份 ——
|
||||
另外三份是**品牌内容库里历次跑出来的资产**。病根一处、抄了两遍:放行存档
|
||||
(`archiveAssetFiles`)与在办列单(`assetFilesOf`)取行都用 `taskView(where:{})` ——
|
||||
那是「正式版全表 + 本单草稿」的合并视图,而资料常落在**主数据**上(`content.asset`),
|
||||
整表里躺着别单放行过的行。台账契约本就把这两件事分得清清楚楚(`taskDrafts` 的注释:
|
||||
「引擎求值要区分『这一单的事实』与『别人放行后的事实』」),视图模版也一律绑 `mine:`
|
||||
——只有资料这两处忘了。修:抽一段 `assetRowsOf` 存档与列单同用,认**本单碰过的行**
|
||||
(草稿键),值仍取叠加行(改过一格的行按落库后的样子造文件);`touched` 是必填入参 ——
|
||||
「哪几行是这一单的」每个调用方都得回答得出来。e2e 补**份数断言**(存档份数 =
|
||||
本单写下的资产行数,多一份也判失败 —— 从前只断「取得回、渲得出」,多摆几份照样全绿)。
|
||||
用户那一单误存的三份已删,工作成果现摆 1 份、点开即那份 .docx。5 测。
|
||||
顺手清两笔:`wake.test.ts` 的 `as unknown as`(§12.5 禁止清单,lint 红)、
|
||||
`wake` 契约的 api-report 快照(上一轮没入库,api:check 一直红)。
|
||||
|
||||
## 文档权威地图
|
||||
|
||||
| 层 | 文件 | 说明 |
|
||||
|
||||
@@ -85,6 +85,13 @@ export type TaskService = {
|
||||
/** 控制三语义:暂停 / 叫停 / 终止 */
|
||||
control(taskId: TaskId, semantic: ControlSemantic, by: StaffId, reason?: string): Promise<ControlOutcome>;
|
||||
resume(taskId: TaskId, by: StaffId): Promise<Task>;
|
||||
/**
|
||||
* **人答复落库那一刻就把「在办事」写进投影**(2026-08-25):不等派发器投递、推进器
|
||||
* 抢到租约再翻 —— 那几秒里对话区(卡状态已落)与工作区(读 runtime)说两句相反的话。
|
||||
* 只在挂起等人 / 等外部时翻;已终结、暂停(suspended)、已在跑的原样不动。
|
||||
* 返回翻没翻 —— 调用方据此决定要不要广播。
|
||||
*/
|
||||
wake(taskId: TaskId): Promise<boolean>;
|
||||
/** 改派:在途任务的负责人变更,**留痕并通知双方** */
|
||||
reassign(taskId: TaskId, to: StaffId, by: StaffId): Promise<Task>;
|
||||
/** 终态裁定 —— 完成由框架裁定,终态由系统命名 */
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { TaskId } from '@contracts';
|
||||
import { archiveAssetFiles, keyText } from '../asset-archive.ts';
|
||||
import { archiveAssetFiles, assetRowsOf, keyText } from '../asset-archive.ts';
|
||||
|
||||
const TASK = 't-1' as TaskId;
|
||||
|
||||
@@ -54,6 +54,11 @@ describe('keyText —— 主键拼法必须稳定', () => {
|
||||
});
|
||||
});
|
||||
|
||||
/** 本单碰过的行 —— `ledger.taskDrafts()` 那一份的形状 */
|
||||
function touch(...ids: string[]) {
|
||||
return ids.map((content_id) => ({ domain: 'content', object: 'asset', key: { content_id } }));
|
||||
}
|
||||
|
||||
describe('archiveAssetFiles —— 存哪些、不存哪些', () => {
|
||||
it('一行一份,存下来的是真字节(存几份就写几笔)', async () => {
|
||||
const db = fakeDb();
|
||||
@@ -62,6 +67,7 @@ describe('archiveAssetFiles —— 存哪些、不存哪些', () => {
|
||||
taskId: TASK,
|
||||
ids,
|
||||
declarations: [ASSET],
|
||||
touched: touch('CT-1', 'CT-2'),
|
||||
rowsOfAddress: async () => [
|
||||
{ content_id: 'CT-1', title: '白皮书', body_md: '# 白皮书\n\n正文', file_format: 'docx' },
|
||||
{ content_id: 'CT-2', title: '对照表', body_md: '| a | b |\n| - | - |\n| 1 | 2 |', file_format: 'xlsx' },
|
||||
@@ -72,6 +78,56 @@ describe('archiveAssetFiles —— 存哪些、不存哪些', () => {
|
||||
expect(db.writes.join()).toContain('白皮书');
|
||||
});
|
||||
|
||||
/*
|
||||
* 2026-08-25 柴浩实测:「工作成果怎么有 4 个资料,这单只会产出一个」——
|
||||
* 资料落在**主数据**上,整表里躺着历次跑出来的资产,前三份都是别单的成果。
|
||||
*/
|
||||
it('**别单放行过的行不算这一单产出的** —— 整表四行,本单只碰过一行,就只存一份', async () => {
|
||||
const db = fakeDb();
|
||||
const saved = await archiveAssetFiles({
|
||||
db,
|
||||
taskId: TASK,
|
||||
ids,
|
||||
declarations: [ASSET],
|
||||
touched: touch('CT-2026-0004'),
|
||||
rowsOfAddress: async () => [
|
||||
{ content_id: 'CT-2026-0001', title: '白皮书', body_md: '别单的正文', file_format: 'docx' },
|
||||
{ content_id: 'CT-2026-0002', title: '白皮书 2026', body_md: '别单的正文', file_format: 'docx' },
|
||||
{ content_id: 'CT-2026-0003', title: '产品介绍书', body_md: '别单的正文', file_format: 'docx' },
|
||||
{ content_id: 'CT-2026-0004', title: '白皮书 E04 定制版', body_md: '这一单写的正文', file_format: 'docx' },
|
||||
],
|
||||
});
|
||||
expect(saved).toBe(1);
|
||||
expect(db.writes.join()).toContain('CT-2026-0004');
|
||||
expect(db.writes.join()).not.toContain('CT-2026-0001');
|
||||
});
|
||||
|
||||
it('这一单一行也没碰过:表里再多行也存 0 份', async () => {
|
||||
const db = fakeDb();
|
||||
const saved = await archiveAssetFiles({
|
||||
db,
|
||||
taskId: TASK,
|
||||
ids,
|
||||
declarations: [ASSET],
|
||||
touched: [],
|
||||
rowsOfAddress: async () => [{ content_id: 'CT-1', title: 'T', body_md: '正文', file_format: 'md' }],
|
||||
});
|
||||
expect(saved).toBe(0);
|
||||
});
|
||||
|
||||
it('别的表碰过不算这张表碰过 —— 地址得对上', async () => {
|
||||
const db = fakeDb();
|
||||
const saved = await archiveAssetFiles({
|
||||
db,
|
||||
taskId: TASK,
|
||||
ids,
|
||||
declarations: [ASSET],
|
||||
touched: [{ domain: 'content_brand', object: 'requirement', key: { content_id: 'CT-1' } }],
|
||||
rowsOfAddress: async () => [{ content_id: 'CT-1', title: 'T', body_md: '正文', file_format: 'md' }],
|
||||
});
|
||||
expect(saved).toBe(0);
|
||||
});
|
||||
|
||||
it('**没正文的行不存** —— 一份空壳存进去,人点开只会看见一张白纸', async () => {
|
||||
const db = fakeDb();
|
||||
const saved = await archiveAssetFiles({
|
||||
@@ -79,6 +135,7 @@ describe('archiveAssetFiles —— 存哪些、不存哪些', () => {
|
||||
taskId: TASK,
|
||||
ids,
|
||||
declarations: [ASSET],
|
||||
touched: touch('CT-1'),
|
||||
rowsOfAddress: async () => [{ content_id: 'CT-1', title: '还没写', body_md: ' ', file_format: 'md' }],
|
||||
});
|
||||
expect(saved).toBe(0);
|
||||
@@ -92,6 +149,7 @@ describe('archiveAssetFiles —— 存哪些、不存哪些', () => {
|
||||
taskId: TASK,
|
||||
ids,
|
||||
declarations: [ASSET],
|
||||
touched: touch(''),
|
||||
rowsOfAddress: async () => [{ content_id: '', title: 'T', body_md: '正文', file_format: 'md' }],
|
||||
});
|
||||
expect(saved).toBe(0);
|
||||
@@ -104,6 +162,7 @@ describe('archiveAssetFiles —— 存哪些、不存哪些', () => {
|
||||
taskId: TASK,
|
||||
ids,
|
||||
declarations: [{ ...ASSET, file: undefined }],
|
||||
touched: touch('CT-1'),
|
||||
rowsOfAddress: async () => [{ content_id: 'CT-1', title: 'T', body_md: '正文', file_format: 'md' }],
|
||||
});
|
||||
expect(saved).toBe(0);
|
||||
@@ -116,6 +175,7 @@ describe('archiveAssetFiles —— 存哪些、不存哪些', () => {
|
||||
taskId: TASK,
|
||||
ids,
|
||||
declarations: [ASSET],
|
||||
touched: touch('CT-1'),
|
||||
rowsOfAddress: async () => [{ content_id: 'CT-1', title: 'T', body_md: '正文', file_format: 'pdf' }],
|
||||
});
|
||||
expect(saved).toBe(1);
|
||||
@@ -125,7 +185,32 @@ describe('archiveAssetFiles —— 存哪些、不存哪些', () => {
|
||||
it('大多数活动不产资料 —— 一张带 file 段的表都没有时返回 0,不报错', async () => {
|
||||
const db = fakeDb();
|
||||
expect(
|
||||
await archiveAssetFiles({ db, taskId: TASK, ids, declarations: [], rowsOfAddress: async () => [] }),
|
||||
await archiveAssetFiles({ db, taskId: TASK, ids, declarations: [], touched: [], rowsOfAddress: async () => [] }),
|
||||
).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('assetRowsOf —— 存档与工作成果同一段', () => {
|
||||
it('值取合并行那一份:这轮只改了标题,正文仍按落库后的样子造', () => {
|
||||
const picked = assetRowsOf(
|
||||
ASSET,
|
||||
[{ content_id: 'CT-1', title: '改过的标题', body_md: '早先写下的正文', file_format: 'docx' }],
|
||||
touch('CT-1'),
|
||||
);
|
||||
expect(picked).toEqual([
|
||||
{
|
||||
address: 'content.asset',
|
||||
key: { content_id: 'CT-1' },
|
||||
title: '改过的标题',
|
||||
format: 'docx',
|
||||
markdown: '早先写下的正文',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('标题空着:退主键,不摆一份没名字的资料', () => {
|
||||
const picked = assetRowsOf(ASSET, [{ content_id: 'CT-1', title: ' ', body_md: '正文' }], touch('CT-1'));
|
||||
expect(picked[0]?.title).toBe('CT-1');
|
||||
expect(picked[0]?.format).toBe('md');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
* 不存这一份,试跑单一放行,人在工作成果里就什么都点不开了。
|
||||
*
|
||||
* 一单一行一份,重复放行覆盖(不留两份说法不一的档)。
|
||||
*
|
||||
* **「这一单产出的」认的是本单碰过的行**,不是这张表里现有的所有行 ——
|
||||
* 见 `assetRowsOf` 的病根记档。
|
||||
*/
|
||||
import { sql } from 'drizzle-orm';
|
||||
import type { TaskId } from '@contracts';
|
||||
@@ -35,6 +38,71 @@ function rowsOf<T>(result: unknown): T[] {
|
||||
return Array.isArray(rows) ? (rows as T[]) : [];
|
||||
}
|
||||
|
||||
/** 一张台账表的声明 —— 带 `file` 段的才产资料;这份声明同时是授权面 */
|
||||
export type AssetDeclaration = {
|
||||
readonly domain: string;
|
||||
readonly object: string;
|
||||
readonly fields: ReadonlyArray<{ name: string; primaryKey?: boolean }>;
|
||||
readonly file?: { titleColumn: string; bodyColumn: string; formatColumn: string } | undefined;
|
||||
};
|
||||
|
||||
/** 本单碰过的一行(`ledger.taskDrafts()` 那一份的形状) */
|
||||
export type TouchedKey = {
|
||||
readonly domain: string;
|
||||
readonly object: string;
|
||||
readonly key: Readonly<Record<string, unknown>>;
|
||||
};
|
||||
|
||||
/** 这一单产出的一份资料 —— 还没造成字节的那一步 */
|
||||
export type AssetRow = {
|
||||
readonly address: string;
|
||||
readonly key: Record<string, string>;
|
||||
readonly title: string;
|
||||
readonly format: FileFormat;
|
||||
readonly markdown: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* 这一单**产出的**资料行 —— 存档与工作成果两处同一段,不各写一份。
|
||||
*
|
||||
* 「产出的」认的是**本单碰过的行**(草稿键),不是这张表里现有的所有行。
|
||||
* 病根记档(2026-08-25 柴浩实测:「工作成果怎么有 4 个资料,这单只会产出一个」):
|
||||
* 两处从前都拿 `taskView` 的整页,而那是「正式版全表 + 本单草稿」的合并视图 ——
|
||||
* 资料常落在**主数据**上(品牌内容库 `content.asset`,历次跑出来的资产都躺在里面),
|
||||
* 于是一单产 1 份、工作成果里摆 4 份:前三份是别单的成果,冒充这一单交出去的东西。
|
||||
* 台账契约本就把这两件事分得很清楚(`taskDrafts` 的注释:「引擎求值要区分
|
||||
* 『这一单的事实』与『别人放行后的事实』」),视图模版也一律绑 `mine:` ——
|
||||
* 只有资料这两处忘了。
|
||||
*
|
||||
* 值仍取合并视图那一份(正式现值 + 本单草稿叠加):改过一格的行要按
|
||||
* 「落库后的样子」造文件,只拿草稿会缺掉这轮没碰过的那几列(与 `touched:` 同一道理)。
|
||||
*/
|
||||
export function assetRowsOf(
|
||||
declared: AssetDeclaration,
|
||||
rows: ReadonlyArray<Record<string, unknown>>,
|
||||
touched: ReadonlyArray<TouchedKey>,
|
||||
): AssetRow[] {
|
||||
const spec = declared.file;
|
||||
if (spec === undefined) return []; // 没声明 `file` 段的表不产资料 —— 存档与列表都认这道授权面
|
||||
const keys = declared.fields.filter((f) => f.primaryKey === true).map((f) => f.name);
|
||||
if (keys.length === 0) return [];
|
||||
const mine = touched.filter((t) => t.domain === declared.domain && t.object === declared.object);
|
||||
const address = `${declared.domain}.${declared.object}`;
|
||||
const out: AssetRow[] = [];
|
||||
for (const row of rows) {
|
||||
const key: Record<string, string> = {};
|
||||
for (const k of keys) key[k] = String(row[k] ?? '');
|
||||
if (Object.values(key).some((v) => v === '')) continue; // 主键不全的行认不出来,存了也取不回
|
||||
if (!mine.some((t) => keys.every((k) => String(t.key[k] ?? '') === key[k]))) continue; // 别单的成果不算这一单的
|
||||
const markdown = String(row[spec.bodyColumn] ?? '').trim();
|
||||
if (markdown === '') continue; // 没正文的行不是资料,别摆一份空壳
|
||||
const title = String(row[spec.titleColumn] ?? '').trim() || Object.values(key).join('-');
|
||||
const rawFormat = String(row[spec.formatColumn] ?? '').trim().toLowerCase();
|
||||
out.push({ address, key, title, format: isFileFormat(rawFormat) ? rawFormat : 'md', markdown });
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* 主键 → 一个**稳定的**字符串(按列名排序后拼)。
|
||||
* 稳定是要害:存的时候与取的时候拼法不一样,那一行就永远对不上。
|
||||
@@ -111,7 +179,7 @@ export async function readArchived(
|
||||
* 把这一单产出的资料**全部存一份**。放行落地之前调 —— 那时草稿还在、人的修订也已落回,
|
||||
* 存下来的正是他签字那一刻的样子。
|
||||
*
|
||||
* 返回存了几份;一份都没有(活动没声明 `file` 段、或一行都没写)时返回 0,不报错 ——
|
||||
* 返回存了几份;一份都没有(活动没声明 `file` 段、或这一单一行也没写)时返回 0,不报错 ——
|
||||
* 大多数活动本来就不产资料文件。
|
||||
*/
|
||||
export async function archiveAssetFiles(input: {
|
||||
@@ -119,40 +187,25 @@ export async function archiveAssetFiles(input: {
|
||||
readonly taskId: TaskId;
|
||||
readonly ids: { next(): string };
|
||||
/** 活动清单声明的台账对象(带 `file` 段的才算) */
|
||||
readonly declarations: ReadonlyArray<{
|
||||
domain: string;
|
||||
object: string;
|
||||
fields: ReadonlyArray<{ name: string; primaryKey?: boolean }>;
|
||||
file?: { titleColumn: string; bodyColumn: string; formatColumn: string } | undefined;
|
||||
}>;
|
||||
/** 本单在该地址写下的行(正式版 + 本单草稿) */
|
||||
readonly declarations: ReadonlyArray<AssetDeclaration>;
|
||||
/**
|
||||
* **本单碰过的行** —— `ledger.taskDrafts()` 那一份。
|
||||
* 「哪几行是这一单产出的」只有这一个答案:表里现有的行不作数(见 `assetRowsOf`)。
|
||||
*/
|
||||
readonly touched: ReadonlyArray<TouchedKey>;
|
||||
/** 该地址的合并行(正式现值 + 本单草稿)—— 值按「落库后的样子」造文件 */
|
||||
readonly rowsOfAddress: (address: { domain: string; object: string }) => Promise<Array<Record<string, unknown>>>;
|
||||
}): Promise<number> {
|
||||
let saved = 0;
|
||||
for (const declared of input.declarations) {
|
||||
const spec = declared.file;
|
||||
if (spec === undefined) continue;
|
||||
const keys = declared.fields.filter((f) => f.primaryKey === true).map((f) => f.name);
|
||||
if (keys.length === 0) continue;
|
||||
|
||||
if (declared.file === undefined) continue; // 整张表不产资料,连取行都免了
|
||||
const rows = await input.rowsOfAddress({ domain: declared.domain, object: declared.object });
|
||||
for (const row of rows) {
|
||||
const markdown = String(row[spec.bodyColumn] ?? '').trim();
|
||||
if (markdown === '') continue; // 没正文的行不是资料,别存一份空壳
|
||||
const key: Record<string, string> = {};
|
||||
for (const k of keys) key[k] = String(row[k] ?? '');
|
||||
if (Object.values(key).some((v) => v === '')) continue; // 主键不全的行认不出来,存了也取不回
|
||||
|
||||
const title = String(row[spec.titleColumn] ?? '').trim() || Object.values(key).join('-');
|
||||
const rawFormat = String(row[spec.formatColumn] ?? '').trim().toLowerCase();
|
||||
const format: FileFormat = isFileFormat(rawFormat) ? rawFormat : 'md';
|
||||
const composed = composeFile({ title, markdown, format });
|
||||
const address = `${declared.domain}.${declared.object}`;
|
||||
|
||||
for (const asset of assetRowsOf(declared, rows, input.touched)) {
|
||||
const composed = composeFile({ title: asset.title, markdown: asset.markdown, format: asset.format });
|
||||
await input.db.execute(sql`
|
||||
insert into sys.task_asset_file (id, task_id, address, row_key, title, format, name, bytes, size)
|
||||
values (${input.ids.next()}, ${input.taskId}, ${address}, ${JSON.stringify(key)}::jsonb,
|
||||
${title}, ${format}, ${composed.fileName}, ${Buffer.from(composed.bytes)}, ${composed.bytes.length})
|
||||
values (${input.ids.next()}, ${input.taskId}, ${asset.address}, ${JSON.stringify(asset.key)}::jsonb,
|
||||
${asset.title}, ${asset.format}, ${composed.fileName}, ${Buffer.from(composed.bytes)}, ${composed.bytes.length})
|
||||
on conflict (task_id, address, row_key) do update set
|
||||
title = excluded.title, format = excluded.format, name = excluded.name,
|
||||
bytes = excluded.bytes, size = excluded.size, created_at = now()`);
|
||||
|
||||
@@ -28,7 +28,7 @@ import {
|
||||
} from '@contracts';
|
||||
import { ReplyRejectedError } from '@modules/human-tool';
|
||||
import { advanceOrder } from '@modules/process';
|
||||
import { keyText, listArchived, readArchived } from '../asset-archive.ts';
|
||||
import { assetRowsOf, keyText, listArchived, readArchived } from '../asset-archive.ts';
|
||||
import { composeFile, isFileFormat, MIME_OF, safeFileName, type FileFormat } from '../file-compose.ts';
|
||||
import { toFileDoc } from '../file-doc.ts';
|
||||
import { displayLog } from './log-lines.ts';
|
||||
@@ -510,6 +510,9 @@ async function landingOf(
|
||||
* 两个来源,**存档优先**:放行之后那一份已经冻住(归档件点开的必须是他签字那一刻
|
||||
* 的那一份);在办期间还没有存档,就照台账现列 —— 人在审的那几份也该看得见。
|
||||
* 认行一律 `address + key`,与件上 `data-file` 那一串同一形状:点开走同一条路。
|
||||
*
|
||||
* 在办这一路挑哪几行与存档同一段(`assetRowsOf`):认**本单碰过的行**,
|
||||
* 不是这张表里现有的所有行 —— 两处各写一份的下场见那段的病根记档。
|
||||
*/
|
||||
async function assetFilesOf(
|
||||
container: Container,
|
||||
@@ -529,12 +532,11 @@ async function assetFilesOf(
|
||||
}
|
||||
|
||||
const declarations = await declarationsOf(container, taskId);
|
||||
// 本单碰过的行 —— 「这一单产出的」只有这一个答案(整表里还躺着别单放行过的资产)
|
||||
const touched = await container.ledger.taskDrafts(taskId).catch(() => []);
|
||||
const out: Array<{ address: string; key: string; title: string; format: string; name: string; archived: boolean }> = [];
|
||||
for (const declared of declarations ?? []) {
|
||||
const spec = declared.file;
|
||||
if (spec === undefined) continue;
|
||||
const keys = declared.fields.filter((f) => f.primaryKey).map((f) => f.name);
|
||||
if (keys.length === 0) continue;
|
||||
if (declared.file === undefined) continue;
|
||||
const page = await container.ledger
|
||||
.taskView(taskId, {
|
||||
address: { domain: declared.domain, object: declared.object },
|
||||
@@ -544,21 +546,13 @@ async function assetFilesOf(
|
||||
offset: 0,
|
||||
})
|
||||
.catch(() => ({ rows: [] as Array<Record<string, unknown>> }));
|
||||
for (const row of page.rows) {
|
||||
// 没正文的行不是资料 —— 摆出来点开只会落一句「还没产出」
|
||||
if (String(row[spec.bodyColumn] ?? '').trim() === '') continue;
|
||||
const key: Record<string, string> = {};
|
||||
for (const k of keys) key[k] = String(row[k] ?? '');
|
||||
if (Object.values(key).some((v) => v === '')) continue;
|
||||
const rawFormat = String(row[spec.formatColumn] ?? '').trim().toLowerCase();
|
||||
const format = isFileFormat(rawFormat) ? rawFormat : 'md';
|
||||
const title = String(row[spec.titleColumn] ?? '').trim() || Object.values(key).join('-');
|
||||
for (const asset of assetRowsOf(declared, page.rows as Array<Record<string, unknown>>, touched)) {
|
||||
out.push({
|
||||
address: `${declared.domain}.${declared.object}`,
|
||||
key: keyText(key),
|
||||
title,
|
||||
format,
|
||||
name: safeFileName(title, format),
|
||||
address: asset.address,
|
||||
key: keyText(asset.key),
|
||||
title: asset.title,
|
||||
format: asset.format,
|
||||
name: safeFileName(asset.title, asset.format),
|
||||
archived: false,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2277,6 +2277,8 @@ export function wireEngines(deps: EngineWiringDeps): EngineWiring {
|
||||
taskId: input.taskId,
|
||||
ids,
|
||||
declarations: manifest.declarations.ledger,
|
||||
// 「这一单产出的」= 本单碰过的行:整表里躺着历次跑出来的资产,不是这一单的成果
|
||||
touched: await deps.ledger.taskDrafts(input.taskId),
|
||||
rowsOfAddress: async (address) =>
|
||||
(
|
||||
await deps.ledger.taskView(input.taskId, { address, where: {}, orderBy: [], limit: 500, offset: 0 })
|
||||
|
||||
@@ -4,24 +4,26 @@
|
||||
* 租约、开跑前那一刻才翻;那几秒里对话区与工作区读到的是两份相反的事实。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { StaffId, TaskId } from '@contracts';
|
||||
import type { LandedFacts, Task } from '../contract.ts';
|
||||
import { createTaskService } from '../internal/usecase/task-service.ts';
|
||||
import type { TaskServiceDeps } from '../internal/usecase/task-service.ts';
|
||||
|
||||
function harness(runtime: Task['runtime'], terminal?: Task['terminal']) {
|
||||
const phases: string[] = [];
|
||||
const task = {
|
||||
id: 't-1',
|
||||
const task: Task = {
|
||||
id: 't-1' as TaskId,
|
||||
activityId: 'e04',
|
||||
ownerId: 's-1',
|
||||
ownerId: 's-1' as StaffId,
|
||||
title: 'x',
|
||||
runtime,
|
||||
terminal,
|
||||
...(terminal === undefined ? {} : { terminal }),
|
||||
envelope: {},
|
||||
data: {},
|
||||
caps: { steps: 40, tokens: 200000, humanCalls: 2, activeMinutes: 60 },
|
||||
used: { steps: 0, tokens: 0, humanCalls: 0, activeMs: 0 },
|
||||
startedAt: '2026-08-25T00:00:00.000Z',
|
||||
} as unknown as Task;
|
||||
};
|
||||
const tasks = new Map<string, Task>([[task.id, task]]);
|
||||
const deps: TaskServiceDeps = {
|
||||
store: {
|
||||
|
||||
@@ -1023,3 +1023,37 @@ S1 被收了两遍(两条 rationale 只差一个标点,是两次独立采样)。
|
||||
「抄名单逐条核对,一家都不能多」看着(实测这半边模型守得住;漏家那半边守不住,
|
||||
所以才立的机检)。真要机检集合相等,得让基座出「A 表某列的值集 ⊆ B 表某列的值集」
|
||||
这类读数 —— 等第二次真踩到再立,别为想象中的路修桥。
|
||||
|
||||
## 2026-08-25 · CI 接上了主干,PR 之前仍是空门
|
||||
|
||||
**已接**(`.gitea/workflows/ci.yml`,host 模式 runner、label `ubuntu-latest`):push 到
|
||||
`mvp-foundation` 时跑 五道门禁 → 生成物漂移检查 → 建一次性库并从空库跑完整条迁移链 →
|
||||
单元与集成测试 → 三份生产构建(api / web / 活动包)。取代码是纯 git,**一个第三方 action
|
||||
都不依赖**;包与镜像源走 npmmirror。实测本地全程约 30 秒(静态门禁 14s、迁移 1s、
|
||||
1705 条测试 7s、三份构建 6s)。
|
||||
|
||||
**还欠三处**:
|
||||
|
||||
① **PR 合并之前不跑**(用户当场定的口径:「只允许主支推送或合并进主支才触发」)——
|
||||
坏代码得先进了主干才发现,`docs/编码规范.md` §12.7 写的「合入前五门禁全绿」这道要求
|
||||
在机器那一侧仍然没人看着。要改成合并前把关,`on:` 下补一段
|
||||
`pull_request: branches: [mvp-foundation]` 即可,别的一行不用动。
|
||||
|
||||
② **活动 e2e 不进 CI**(`tools/e2e-a2.mjs` 那八套):要真模型密钥、单案例 20 分钟封顶、
|
||||
一跑几十万 token。也就是说「E04 / I01 跑不跑得通」这件事**没有任何自动化在看着**,
|
||||
仍然靠人手工跑。要接的话它该是另一条手动/定时的 workflow,不是 PR 门禁。
|
||||
|
||||
③ **构建产物不归档**:上传要 `actions/upload-artifact`,又是一个得出网拉的第三方 action;
|
||||
本轮口径是能不用就不用。要归档时再加。
|
||||
|
||||
**另记一处失败开口**:`tools/api-report.mjs` 的 git 比对一旦抛错(换 uid 后的
|
||||
dubious ownership 之类),`catch` 里印一句「非 git 仓库,跳过比对」然后 **exit 0** ——
|
||||
契约门禁当场变成空门。CI 侧已由「生成物无漂移」那一步(跑完自己再 `git status` 一遍)
|
||||
堵住,**本地 `pnpm gates` 仍然是开口的**:谁在一个 git 出问题的环境里跑,它会安静地放行。
|
||||
|
||||
**顺带一条实测账(接 CI 时踩的)**:`createdb` 出来的空库**直接 `pnpm db:migrate` 迁不动** ——
|
||||
`db/migrations/0026_object_meta.sql` 往 `ledger.__object_meta` 建表,而迁移链只会替自己
|
||||
建 `sys`(drizzle 的 `migrationsSchema`)。四个 schema 一直是 docker-compose 把
|
||||
`db/init/` 挂进 `/docker-entrypoint-initdb.d`、在**首次起卷**时灌的 —— 换任何一条不经
|
||||
compose 的路子建库,都得自己先灌一遍。`tools/ci.mjs db-create` 已经这么做(灌的是
|
||||
`db/init/` 那份文件本身,不另抄一份)。
|
||||
|
||||
+13
-3
@@ -739,20 +739,30 @@ async function assertAssetFiles(taskId, spec) {
|
||||
}
|
||||
seen.add(format);
|
||||
}
|
||||
return { ok: true, formats: seen, note: `${rows.length} 份资料全部取得回、渲得出(格式:${[...seen].join(' / ')})` };
|
||||
return { ok: true, formats: seen, count: rows.length, note: `${rows.length} 份资料全部取得回、渲得出(格式:${[...seen].join(' / ')})` };
|
||||
}
|
||||
|
||||
/**
|
||||
* 收工之后再看一眼:那几份资料**存档了没有、点得开吗**。
|
||||
* 查的是工作台任务详情里那一摞(`assetFiles`,工作成果那一屏摆的就是它),
|
||||
* 逐份按同一条路取回来 —— 与人在界面上点它是同一个接口。
|
||||
*
|
||||
* **份数也得对上**(2026-08-25 柴浩:「工作成果怎么有 4 个资料,这单只会产出一个」)——
|
||||
* 资料落在主数据上,整表里躺着历次跑出来的资产;从前存档拿的是整表,
|
||||
* 于是这一摞里混着别单的成果。多一份也是错:签字的人会以为那是他交出去的东西。
|
||||
*/
|
||||
async function assertArchived(taskId) {
|
||||
async function assertArchived(taskId, expected) {
|
||||
const { body } = await api(`/api/desk/tasks/${taskId}`);
|
||||
const files = body.assetFiles ?? [];
|
||||
if (files.length === 0) return { ok: false, note: '工作成果里一份资料都没有 —— 放行时没存档' };
|
||||
const live = files.filter((f) => !f.archived);
|
||||
if (live.length > 0) return { ok: false, note: `${live.length} 份还标着「在办中」—— 放行那一刻没冻住` };
|
||||
if (expected !== undefined && files.length !== expected) {
|
||||
return {
|
||||
ok: false,
|
||||
note: `工作成果里 ${files.length} 份,而这一单只产出 ${expected} 份 —— 多出来的是别单的成果(${files.map((f) => f.title).join(' / ')})`,
|
||||
};
|
||||
}
|
||||
for (const f of files) {
|
||||
const url = `/api/desk/tasks/${taskId}/file?address=${encodeURIComponent(f.address)}&key=${encodeURIComponent(f.key)}`;
|
||||
let got;
|
||||
@@ -1057,7 +1067,7 @@ async function runCase(suite, kase) {
|
||||
* 资料落在主数据上,而试跑单放行时主数据不落正式表:不存档的话这一刻全是 404
|
||||
* (这正是 2026-08-23 之前的实情)。所以这条断言查的是**存档**,不是台账。
|
||||
*/
|
||||
const archived = await assertArchived(taskId);
|
||||
const archived = await assertArchived(taskId, fileCheck?.count);
|
||||
console.log(` 资料存档:${archived.note}`);
|
||||
if (!archived.ok) ok = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user