补齐 AI 任务与历史清理的内存边界 (#206)
Project CI / Repository checks (push) Successful in 15m42s
Project CI / Frontend tests (push) Successful in 19m8s
Project CI / Backend tests (push) Successful in 27m3s
Project CI / Native shell tests (push) Successful in 29m15s

基于当前 master(含 #204)移植未进入 #203 的内存边界修复。

- 补齐外部生成历史清理 procedure 的 SATS tuple 解析与回归测试
- 限制 AI 流式文本每阶段 chunk 数量并分批释放明细
- 修正进程内失败收口的容量检查顺序
- 分批删除外部生成审计事件并同步更新契约文档

验证:
- cargo test -p module-ai -p spacetime-module
- cargo check -p api-server
- npm run test -- scripts/spacetime-migration-common.test.ts
- npm run check:spacetime-schema
- npm run check:production-ops
- npm run check:encoding
- git diff --check

Reviewed-on: http://192.168.35.82/git/GenarrativeAI/Genarrative/pulls/206
Co-authored-by: kdletters <kdletters@qq.com>
Co-committed-by: kdletters <kdletters@qq.com>
This commit was merged in pull request #206.
This commit is contained in:
2026-08-27 22:18:16 +08:00
committed by 段舒康
parent 458371a73d
commit 19a32f537b
10 changed files with 287 additions and 33 deletions
+18
View File
@@ -427,6 +427,24 @@ function normalizeSatsProduct(value, procedureName) {
};
}
if (
procedureName === 'prune_external_generation_job_history_and_return' &&
value.length === 10
) {
return {
ok: normalizeSatsValue(value[0]),
dry_run: normalizeSatsValue(value[1]),
scanned_count: normalizeSatsValue(value[2]),
selected_count: normalizeSatsValue(value[3]),
deleted_job_count: normalizeSatsValue(value[4]),
deleted_summary_count: normalizeSatsValue(value[5]),
deleted_event_count: normalizeSatsValue(value[6]),
next_cursor_job_id: normalizeSatsOption(value[7]),
has_more: normalizeSatsValue(value[8]),
error_message: normalizeSatsOption(value[9]),
};
}
if (value.length === 3) {
return {
ok: normalizeSatsValue(value[0]),
@@ -223,4 +223,35 @@ describe('SpacetimeDB CLI SATS option encoding', () => {
expect(objectResult.batch_sha256).toBe('d'.repeat(64));
expect(objectResult).not.toHaveProperty('batch_sha_256');
});
it('normalizes external generation history prune tuple results', () => {
const result = parseProcedureResult(
JSON.stringify([
true,
false,
25,
2,
2,
2,
10,
[0, 'job-25'],
true,
[0, '清理失败'],
]),
'prune_external_generation_job_history_and_return',
);
expect(result).toEqual({
ok: true,
dry_run: false,
scanned_count: 25,
selected_count: 2,
deleted_job_count: 2,
deleted_summary_count: 2,
deleted_event_count: 10,
next_cursor_job_id: 'job-25',
has_more: true,
error_message: '清理失败',
});
});
});