@suifei/dsh-ai-team 0.4.51 → 0.4.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/index.js +20 -2
- package/lib/host/service.js +3 -0
- package/lib/ledger/writer.js +14 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.52 - 2026-11-12
|
|
4
|
+
|
|
5
|
+
**批 17:reconcile 项目级互斥 + 修复区间上报**
|
|
6
|
+
|
|
7
|
+
- **同一项目的 reconcile 互斥**:PMO tick 与 `skillopt_jobs` 工具会同时收割同一批 job,两边都在「读 job 状态 → 写回」,并发时后到的一次判断会覆盖前一次的结果(`done` 冻结与原子写只是兜底)。现在按项目目录加锁,被跳过的一侧记 `skillopt.reconcile.skip`(`reason: in-flight`),不再静默。
|
|
8
|
+
- **`ledger.repair()` 报告恢复区间**:返回 `acceptedRange: { from, to }` 与 `seqGaps[]`(最多 20 条)。一次失败的 `appendMany` 可能把前缀留在盘上,只说「修好了」不够——运维需要知道接受到哪个 seq、有没有洞。`project.repair` 命令一并透传。
|
|
9
|
+
- 测试:`node --test` **253 通过 / 1 跳过**(新增 1 例:健康账本的 `project.repair` 返回空缺口)。
|
|
10
|
+
|
|
3
11
|
## 0.4.51 - 2026-11-12
|
|
4
12
|
|
|
5
13
|
**批 16:卸载闸门(teardown 不再被在途异步链穿透)**
|
package/index.js
CHANGED
|
@@ -563,6 +563,20 @@ export function apply(ctx, config = {}) {
|
|
|
563
563
|
// PMO tick 是 fire-and-forget:慢 tick(模型/IO)会被下一分钟的定时器再入,
|
|
564
564
|
// 造成 autoAnswerDecisions/reconcileJobs 并发执行同一条账本。按 Project 去重。
|
|
565
565
|
const pmoBusy = new Set();
|
|
566
|
+
// 同一项目目录的 reconcile 互斥:PMO tick 与 skillopt_jobs 工具会同时收割同一批
|
|
567
|
+
// job,两边都在「读 job 状态 → 写回」,并发时后到的一次判断会覆盖前一次的结果。
|
|
568
|
+
const reconcileBusy = new Set();
|
|
569
|
+
const reconcileWithLock = async (projectDir, options) => {
|
|
570
|
+
const key = typeof projectDir === 'string' ? projectDir : '';
|
|
571
|
+
if (key !== '' && reconcileBusy.has(key)) return false;
|
|
572
|
+
if (key !== '') reconcileBusy.add(key);
|
|
573
|
+
try {
|
|
574
|
+
await reconcileJobs(options);
|
|
575
|
+
return true;
|
|
576
|
+
} finally {
|
|
577
|
+
if (key !== '') reconcileBusy.delete(key);
|
|
578
|
+
}
|
|
579
|
+
};
|
|
566
580
|
// 本次请求的连续失败计数(按成员会话、10 分钟窗口)。
|
|
567
581
|
const requestAttempts = new Map();
|
|
568
582
|
const activationTasks = new Map();
|
|
@@ -776,7 +790,7 @@ export function apply(ctx, config = {}) {
|
|
|
776
790
|
// 两阶段异步优化 job 收割:与任务派发无关,放在停止门之前——
|
|
777
791
|
// Human 启动的 job 必须在任意运行态下收敛(生成/评审/落盘)。
|
|
778
792
|
try {
|
|
779
|
-
await
|
|
793
|
+
const reconciled = await reconcileWithLock(projectRuntime.dir, {
|
|
780
794
|
ctx,
|
|
781
795
|
// job 归属项目数据目录(与 skillopt_optimize 写入处一致):
|
|
782
796
|
// 与工作区/激活项目无关,保证任意 tick 都能找到待收割 job。
|
|
@@ -805,6 +819,7 @@ export function apply(ctx, config = {}) {
|
|
|
805
819
|
} catch (error) {
|
|
806
820
|
diag.append({ ev: 'skillopt.job.tick.fail', message: error?.message ?? String(error) });
|
|
807
821
|
}
|
|
822
|
+
if (reconciled === false) diag.append({ ev: 'skillopt.reconcile.skip', projectId: projectRuntime.id, reason: 'in-flight' });
|
|
808
823
|
// 门禁必须在 await 之后重新取:reconcileJobs 可能耗时数秒,期间 Human
|
|
809
824
|
// 可能已经停用 PMO / 归档 / 停止项目,用 await 之前的快照会继续写账本。
|
|
810
825
|
const project = projectRuntime.service.state.projects?.[projectRuntime.id];
|
|
@@ -1250,7 +1265,7 @@ export function apply(ctx, config = {}) {
|
|
|
1250
1265
|
for (const jobRoot of jobRoots) {
|
|
1251
1266
|
if (typeof jobRoot !== 'string' || jobRoot === '') continue;
|
|
1252
1267
|
try {
|
|
1253
|
-
await
|
|
1268
|
+
const reconciledHere = await reconcileWithLock(jobRoot, {
|
|
1254
1269
|
ctx,
|
|
1255
1270
|
projectDir: jobRoot,
|
|
1256
1271
|
deps: {
|
|
@@ -1273,6 +1288,9 @@ export function apply(ctx, config = {}) {
|
|
|
1273
1288
|
} catch (error) {
|
|
1274
1289
|
diag.append({ ev: 'skillopt.jobs.step.fail', message: error?.message ?? String(error), jobRoot });
|
|
1275
1290
|
}
|
|
1291
|
+
if (reconciledHere === false) {
|
|
1292
|
+
diag.append({ ev: 'skillopt.reconcile.skip', projectId: jobRoot, reason: 'in-flight' });
|
|
1293
|
+
}
|
|
1276
1294
|
}
|
|
1277
1295
|
const roots = jobRoots.length > 0 ? jobRoots : [process.cwd()];
|
|
1278
1296
|
const jobs = roots.flatMap((jobRoot) => listJobs(jobRoot));
|
package/lib/host/service.js
CHANGED
|
@@ -554,6 +554,9 @@ export class TeamService {
|
|
|
554
554
|
repairs: Array.isArray(result?.repairs) ? result.repairs : [],
|
|
555
555
|
events: result?.events ?? null,
|
|
556
556
|
stateLastSeq: result?.stateLastSeq ?? null,
|
|
557
|
+
// 恢复区间与缺口:一次失败的批次可能把前缀留在盘上,调用方要能看出来。
|
|
558
|
+
acceptedRange: result?.acceptedRange ?? null,
|
|
559
|
+
seqGaps: Array.isArray(result?.seqGaps) ? result.seqGaps : [],
|
|
557
560
|
};
|
|
558
561
|
}
|
|
559
562
|
async changeProjectWorkspace(command, payload) {
|
package/lib/ledger/writer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
2
|
* 单项目账本写入器:append-only JSONL、分段、fsync、单写者锁、尾撕裂修复。
|
|
3
3
|
*
|
|
4
4
|
* 对应 03-架构设计报告 §6.5 / §6.6 / §8.1、附录 B §B.3.6:
|
|
@@ -1235,11 +1235,24 @@ export function openLedger(options = {}) {
|
|
|
1235
1235
|
state = fold(events);
|
|
1236
1236
|
eventsSinceCheckpoint = 0;
|
|
1237
1237
|
if (checkpointOptions) saveCheckpointNow();
|
|
1238
|
+
// 恢复区间与缺口:一次失败的 appendMany 可能把「前缀」留在盘上,光说
|
|
1239
|
+
// 「修好了」不够——运维需要知道接受到了哪个 seq、有没有洞。
|
|
1240
|
+
const gaps = [];
|
|
1241
|
+
for (let index = 0; index < events.length; index += 1) {
|
|
1242
|
+
if (events[index]?.seq !== index + 1) {
|
|
1243
|
+
gaps.push({ at: index, seq: events[index]?.seq ?? null });
|
|
1244
|
+
if (gaps.length >= 20) break;
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1238
1247
|
return {
|
|
1239
1248
|
...result,
|
|
1240
1249
|
refolded: true,
|
|
1241
1250
|
events: events.length,
|
|
1242
1251
|
stateLastSeq: state.lastSeq ?? null,
|
|
1252
|
+
acceptedRange: events.length === 0
|
|
1253
|
+
? null
|
|
1254
|
+
: { from: events[0].seq ?? null, to: events[events.length - 1].seq ?? null },
|
|
1255
|
+
seqGaps: gaps,
|
|
1243
1256
|
};
|
|
1244
1257
|
},
|
|
1245
1258
|
close() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suifei/dsh-ai-team",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.52",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "文渊阁 (Wenyuan Pavilion) — AI Team mode for DeepSeek Harness: concurrent projects, owned tasks, threads, inbox and an append-only team ledger",
|
|
6
6
|
"license": "MIT",
|