@suifei/dsh-ai-team 0.4.33 → 0.4.35
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 +18 -0
- package/index.js +14 -7
- package/lib/host/people-view.js +7 -1
- package/lib/host/service.js +12 -12
- package/lib/ledger/namespace.js +74 -0
- package/lib/ledger/writer.js +7 -0
- package/lib/skillopt/review-runner.js +2 -2
- package/lib/skillopt/reviewer.js +7 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.35 - 2026-11-12
|
|
4
|
+
|
|
5
|
+
**中危批次 5:命名空间、poison 恢复、多数决、并发认领**
|
|
6
|
+
|
|
7
|
+
- **profile 命名空间解析**:桌面启动器按**位置参数**传 profile 目录(`… <dsh-root> …\.dsh\profiles\desktop …`),旧解析只认 `--profile <name>`,于是 desktop profile 的账本全落进 `ai-team/default/`。现在 `--profile x` / `--profile=x` / 位置路径 / `DSH_PROFILE` 都认。
|
|
8
|
+
- **一次性、可回退的命名空间搬迁**:只修解析会让既有数据留在 `default/`(界面上团队凭空消失)。启动时若旧命名空间的数据明显多于目标命名空间,则把旧目录整体改名迁入,目标原有内容改名 `*.superseded-<ts>` 保留,不删除任何文件。
|
|
9
|
+
- **poison 之后有恢复路径**:回滚失败会把 writer 置为 poisoned,错误信息建议「close and open it again」,但生产代码没有调用点。`repair()` 现在按磁盘真相重建后**解除 poison**(返回 `recoveredFromPoison`),不必等重启。
|
|
10
|
+
- **评审改判多数决**:评审通道原本要求**全票**才判定,与 `decideByMajority` 的最少有效票契约相反——漏一票就要空等 30 分钟再判 failed。现在按「应投数量的半数(向上取整)」为门槛,`required` 也按应投数量算(此前按已收票数算,2/3 时会退化成 1 票定案)。
|
|
11
|
+
- **task 命令串行化**:`claim/submit/accept/...` 等 12 个写命令此前不在 `runExclusive` 内,「读投影 → 判定 → 追加」可被并发双双通过,同一成员能同时持有两张 in_progress 卡(破坏 INV-05,且投影不会自愈)。
|
|
12
|
+
- 测试:`node --test` **229/229**(新增 `namespace` 4 例、poison 恢复 1 例、多数决 1 例、并发认领 1 例;并发那条已用对照组确认「撤掉修复即失败」)。
|
|
13
|
+
|
|
14
|
+
## 0.4.34 - 2026-11-12
|
|
15
|
+
|
|
16
|
+
**同人绑定:合并后显示目标名**
|
|
17
|
+
|
|
18
|
+
- 人员池按名字聚合同一人(同名跨项目合成一行);「同人绑定」把**不同名字**并到一起。上一版修好了归一化,但合并行的名字取自「遍历顺序里第一个成员」——把「百里」绑到「白砚」后,两行确实合成了一行,显示的名字却是「百里」。现在合并行一律以**别名目标**为准:`X → 白砚` 合成的那一行叫「白砚」,与遍历顺序无关。
|
|
19
|
+
- 测试:`node --test` **222/222**(新增 1 例:被绑定名排在前面时仍显示目标名)。
|
|
20
|
+
|
|
3
21
|
## 0.4.33 - 2026-11-12
|
|
4
22
|
|
|
5
23
|
**中危批次 4:验收门禁、权限沿革、技能过滤、job 原子写**
|
package/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import { existsSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
|
15
15
|
import z from '@deepseek-ai/schemastery';
|
|
16
16
|
import { ProjectRuntime } from './lib/host/project-runtime.js';
|
|
17
17
|
import { ProjectRegistry } from './lib/host/project-registry.js';
|
|
18
|
+
import { migrateLegacyNamespace, resolveProfileName } from './lib/ledger/namespace.js';
|
|
18
19
|
import { ids } from './lib/domain/ids.js';
|
|
19
20
|
import { MemberRuntime, validatePermissionProfile } from './lib/runtime/member-runtime.js';
|
|
20
21
|
import { ensureHostAgent } from './lib/runtime/host-agent.js';
|
|
@@ -154,12 +155,10 @@ function dshHome() {
|
|
|
154
155
|
}
|
|
155
156
|
|
|
156
157
|
function profileName() {
|
|
157
|
-
//
|
|
158
|
-
//
|
|
159
|
-
//
|
|
160
|
-
|
|
161
|
-
if (index >= 0 && typeof process.argv[index + 1] === 'string') return process.argv[index + 1];
|
|
162
|
-
return process.env.DSH_PROFILE || 'default';
|
|
158
|
+
// 桌面启动器不导出 DSH_PROFILE,而是把 profile 目录作为**位置参数**传进来
|
|
159
|
+
// (… <dsh-root> C:\Users\…\.dsh\profiles\desktop …)。解析规则抽到
|
|
160
|
+
// lib/ledger/namespace.js:`--profile x`、`--profile=x`、位置路径与 env 都要认。
|
|
161
|
+
return resolveProfileName(process.argv, process.env);
|
|
163
162
|
}
|
|
164
163
|
|
|
165
164
|
/**
|
|
@@ -169,6 +168,11 @@ function profileName() {
|
|
|
169
168
|
*/
|
|
170
169
|
async function boot(diag) {
|
|
171
170
|
const dataDir = join(dshHome(), 'ai-team', profileName());
|
|
171
|
+
// 旧版本把 desktop profile 的数据写进了 `ai-team/default/`(profile 名只认
|
|
172
|
+
// `--profile`,而桌面启动器按位置参数传)。这里做一次性、数据驱动、可回退的
|
|
173
|
+
// 搬迁:只有旧命名空间的数据明显更多时才搬,目标原有内容改名保留、不删除。
|
|
174
|
+
const legacyDir = join(dshHome(), 'ai-team', 'default');
|
|
175
|
+
if (dataDir !== legacyDir) migrateLegacyNamespace({ fromDir: legacyDir, toDir: dataDir, diag });
|
|
172
176
|
const registry = ProjectRegistry.load(dataDir);
|
|
173
177
|
const runtimes = new Map();
|
|
174
178
|
for (const project of registry.list()) {
|
|
@@ -1226,7 +1230,10 @@ export function apply(ctx, config = {}) {
|
|
|
1226
1230
|
if (runtime === undefined) continue;
|
|
1227
1231
|
const collected = collectReview({ service: runtime.service, job });
|
|
1228
1232
|
const expected = collected.expected ?? job.reviewOrders?.length ?? 3;
|
|
1229
|
-
|
|
1233
|
+
// 与 decideByMajority 的最少有效票契约一致:等「多数」而不是「全票」。
|
|
1234
|
+
// 等全票时,评审官漏回一票就要空等 30 分钟再判 failed。
|
|
1235
|
+
const minValid = Math.max(1, Math.ceil(expected / 2));
|
|
1236
|
+
if (collected.votes.length < minValid || collected.decision?.verdict === 'inconclusive') {
|
|
1230
1237
|
// 评审通道被 reconcileJobs 明确排除,没有 TTL 兜底:评审官不回帖
|
|
1231
1238
|
// 时 job 会永久停在 judging、评审卡永久 active。这里补超时终态。
|
|
1232
1239
|
if (isJobExpired(job, Date.now(), REVIEW_JOB_TTL_MS)) {
|
package/lib/host/people-view.js
CHANGED
|
@@ -30,6 +30,12 @@ export function aggregatePeople(registryEntries, runtimes, options = {}) {
|
|
|
30
30
|
if (alias.startsWith('person:') || alias.startsWith('name:')) return alias;
|
|
31
31
|
return `name:${alias}`;
|
|
32
32
|
};
|
|
33
|
+
// 合并出来的那一行必须叫**目标**的名字:它由遍历顺序里第一个成员创建,若直接用
|
|
34
|
+
// 该成员的原始名字,「百里 → 白砚」会合成一行却显示成「百里」。
|
|
35
|
+
const displayNameOf = (name) => {
|
|
36
|
+
const alias = aliases !== null && Object.prototype.hasOwnProperty.call(aliases, name) ? aliases[name] : null;
|
|
37
|
+
return typeof alias === 'string' && alias.startsWith('name:') ? alias.slice('name:'.length) : name;
|
|
38
|
+
};
|
|
33
39
|
for (const runtime of runtimes) {
|
|
34
40
|
const projectName = registryEntries.find((project) => project.id === runtime.id)?.name ?? runtime.id;
|
|
35
41
|
const state = runtime.service?.state;
|
|
@@ -59,7 +65,7 @@ export function aggregatePeople(registryEntries, runtimes, options = {}) {
|
|
|
59
65
|
const memberName = member.name || member.id;
|
|
60
66
|
const bucket = bucketOf(memberName);
|
|
61
67
|
const entry = people.get(bucket) ?? {
|
|
62
|
-
name: memberName,
|
|
68
|
+
name: displayNameOf(memberName),
|
|
63
69
|
role: member.role ?? '',
|
|
64
70
|
projects: [],
|
|
65
71
|
failures: 0,
|
package/lib/host/service.js
CHANGED
|
@@ -410,18 +410,18 @@ export class TeamService {
|
|
|
410
410
|
case 'member.skill': return await this.addMemberSkill(command, payload);
|
|
411
411
|
case 'member.config.update': return await this.updateMemberConfig(command, payload);
|
|
412
412
|
case 'member.retry': return await this.retryMember(command, payload);
|
|
413
|
-
case 'task.create': return await this.createTask(command, payload);
|
|
414
|
-
case 'task.claim': return await this.taskCommand(command, 'claim');
|
|
415
|
-
case 'task.release': return await this.taskCommand(command, 'release');
|
|
416
|
-
case 'task.assign': return await this.taskCommand(command, 'assign');
|
|
417
|
-
case 'task.submit': return await this.taskCommand(command, 'submit');
|
|
418
|
-
case 'task.accept': return await this.taskCommand(command, 'accept');
|
|
419
|
-
case 'task.request_changes': return await this.taskCommand(command, 'request_changes');
|
|
420
|
-
case 'task.cancel': return await this.taskCommand(command, 'cancel');
|
|
421
|
-
case 'task.reopen': return await this.taskCommand(command, 'reopen');
|
|
422
|
-
case 'task.reassign': return await this.taskCommand(command, 'reassign');
|
|
423
|
-
case 'task.delete': return await this.taskCommand(command, 'delete');
|
|
424
|
-
case 'task.convert': return await this.convert(command, payload);
|
|
413
|
+
case 'task.create': return await this.runExclusive(() => this.createTask(command, payload));
|
|
414
|
+
case 'task.claim': return await this.runExclusive(() => this.taskCommand(command, 'claim'));
|
|
415
|
+
case 'task.release': return await this.runExclusive(() => this.taskCommand(command, 'release'));
|
|
416
|
+
case 'task.assign': return await this.runExclusive(() => this.taskCommand(command, 'assign'));
|
|
417
|
+
case 'task.submit': return await this.runExclusive(() => this.taskCommand(command, 'submit'));
|
|
418
|
+
case 'task.accept': return await this.runExclusive(() => this.taskCommand(command, 'accept'));
|
|
419
|
+
case 'task.request_changes': return await this.runExclusive(() => this.taskCommand(command, 'request_changes'));
|
|
420
|
+
case 'task.cancel': return await this.runExclusive(() => this.taskCommand(command, 'cancel'));
|
|
421
|
+
case 'task.reopen': return await this.runExclusive(() => this.taskCommand(command, 'reopen'));
|
|
422
|
+
case 'task.reassign': return await this.runExclusive(() => this.taskCommand(command, 'reassign'));
|
|
423
|
+
case 'task.delete': return await this.runExclusive(() => this.taskCommand(command, 'delete'));
|
|
424
|
+
case 'task.convert': return await this.runExclusive(() => this.convert(command, payload));
|
|
425
425
|
case 'task.follow': return await this.follow(command, payload);
|
|
426
426
|
case 'thread.post': return await this.postThread(command, payload);
|
|
427
427
|
case 'inbox.ack': return await this.ack(command, payload);
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profile 命名空间解析与一次性的旧命名空间迁移。
|
|
3
|
+
*
|
|
4
|
+
* 背景:桌面启动器不导出 `DSH_PROFILE`,而是把 profile 目录作为**位置参数**传给
|
|
5
|
+
* 宿主(`… <dsh-root> C:\Users\…\.dsh\profiles\desktop …`)。旧解析只认
|
|
6
|
+
* `--profile <name>`,于是 desktop profile 的账本全部落进 `ai-team/default/`,
|
|
7
|
+
* 两个 profile 共用一个命名空间。
|
|
8
|
+
*
|
|
9
|
+
* 但只修解析会把已经落在 `default/` 的数据留在原地(界面上团队凭空消失),
|
|
10
|
+
* 因此配一条**数据驱动、一次性、可回退**的迁移规则:只有当旧命名空间的数据
|
|
11
|
+
* 明显多于目标命名空间时才搬迁,并把目标原有内容改名保留,不删除任何东西。
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { existsSync, readdirSync, renameSync, statSync } from 'node:fs';
|
|
15
|
+
import { join } from 'node:path';
|
|
16
|
+
|
|
17
|
+
/** 从启动参数/env 解析 profile 名。 */
|
|
18
|
+
export function resolveProfileName(argv = process.argv, env = process.env) {
|
|
19
|
+
const list = Array.isArray(argv) ? argv.map(String) : [];
|
|
20
|
+
const flagAt = list.indexOf('--profile');
|
|
21
|
+
if (flagAt >= 0 && typeof list[flagAt + 1] === 'string' && list[flagAt + 1] !== '') return list[flagAt + 1];
|
|
22
|
+
const inline = list.find((arg) => arg.startsWith('--profile='));
|
|
23
|
+
if (inline !== undefined) {
|
|
24
|
+
const value = inline.slice('--profile='.length);
|
|
25
|
+
if (value !== '') return value;
|
|
26
|
+
}
|
|
27
|
+
// 位置参数形态:…/profiles/<name>(Windows 反斜杠与 POSIX 斜杠都要认)。
|
|
28
|
+
for (const arg of list) {
|
|
29
|
+
const match = /[\\/]profiles[\\/]([^\\/]+)[\\/]?$/.exec(arg);
|
|
30
|
+
if (match !== null) return match[1];
|
|
31
|
+
}
|
|
32
|
+
return env?.DSH_PROFILE || 'default';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** 目录下所有文件的总字节数;目录不存在按 0 计。 */
|
|
36
|
+
export function dirBytes(dir) {
|
|
37
|
+
if (!existsSync(dir)) return 0;
|
|
38
|
+
let total = 0;
|
|
39
|
+
const walk = (current) => {
|
|
40
|
+
let entries = [];
|
|
41
|
+
try { entries = readdirSync(current, { withFileTypes: true }); } catch { return; }
|
|
42
|
+
for (const entry of entries) {
|
|
43
|
+
const full = join(current, entry.name);
|
|
44
|
+
if (entry.isDirectory()) { walk(full); continue; }
|
|
45
|
+
try { total += statSync(full).size; } catch { /* vanished */ }
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
walk(dir);
|
|
49
|
+
return total;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 旧命名空间有明显更多数据时搬迁到目标命名空间。
|
|
54
|
+
* @returns {'migrated'|'kept'|'none'} migrated=已搬迁,kept=目标更新/一样大,none=没有旧数据
|
|
55
|
+
*/
|
|
56
|
+
export function migrateLegacyNamespace({ fromDir, toDir, diag = null, now = Date.now }) {
|
|
57
|
+
if (fromDir === toDir) return 'none';
|
|
58
|
+
if (!existsSync(join(fromDir, 'projects.json'))) return 'none';
|
|
59
|
+
const legacyBytes = dirBytes(fromDir);
|
|
60
|
+
const targetBytes = dirBytes(toDir);
|
|
61
|
+
if (legacyBytes <= targetBytes) return 'kept';
|
|
62
|
+
try {
|
|
63
|
+
if (existsSync(toDir)) {
|
|
64
|
+
// 目标原有内容改名保留(不删除),便于回退与人工核对。
|
|
65
|
+
renameSync(toDir, `${toDir}.superseded-${now()}`);
|
|
66
|
+
}
|
|
67
|
+
renameSync(fromDir, toDir);
|
|
68
|
+
diag?.append?.({ ev: 'ledger.namespace.migrated', from: fromDir, to: toDir, legacyBytes, targetBytes });
|
|
69
|
+
return 'migrated';
|
|
70
|
+
} catch (error) {
|
|
71
|
+
diag?.append?.({ ev: 'ledger.namespace.migrate.fail', from: fromDir, to: toDir, message: error?.message ?? String(error) });
|
|
72
|
+
return 'kept';
|
|
73
|
+
}
|
|
74
|
+
}
|
package/lib/ledger/writer.js
CHANGED
|
@@ -342,9 +342,14 @@ export class LedgerWriter {
|
|
|
342
342
|
if (!this._opened || this._closed) {
|
|
343
343
|
throw new LedgerError('E_LEDGER_CLOSED', 'ledger is not open');
|
|
344
344
|
}
|
|
345
|
+
const wasPoisoned = this._poisoned;
|
|
345
346
|
const scan = this._scan({ repairTail: true });
|
|
346
347
|
this._adoptScan(scan);
|
|
347
348
|
this._syncCurrentFromScan(scan);
|
|
349
|
+
// repair 会按磁盘真相重建 head/ids/segments,因此 poison(回滚失败留下的
|
|
350
|
+
// 不一致内存态)在此刻已经不再成立。不解除的话,错误信息里建议的
|
|
351
|
+
// 「close and open it again」在生产代码里没有任何调用点,writer 只能等重启。
|
|
352
|
+
this._poisoned = null;
|
|
348
353
|
if (scan.repair) this._repairs.push(scan.repair);
|
|
349
354
|
this._openResult = {
|
|
350
355
|
...this._openResult,
|
|
@@ -360,6 +365,8 @@ export class LedgerWriter {
|
|
|
360
365
|
head: { ...this._head },
|
|
361
366
|
eventCount: this._eventCount,
|
|
362
367
|
segments: scan.segments.map((segment) => segment.name),
|
|
368
|
+
recoveredFromPoison: wasPoisoned !== null && wasPoisoned !== undefined,
|
|
369
|
+
...(wasPoisoned === null || wasPoisoned === undefined ? {} : { poisonError: wasPoisoned }),
|
|
363
370
|
};
|
|
364
371
|
}
|
|
365
372
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
2
|
* 评审执行:把 A/B 盲评投递给**专用评审成员**,从评审卡的 thread 回帖收票。
|
|
3
3
|
*
|
|
4
4
|
* 通道依据:`member.message`(Human→成员)会写账本并触发 waker 唤醒成员,
|
|
@@ -104,5 +104,5 @@ export function collectReview({ service, job }) {
|
|
|
104
104
|
aIsAfter: order?.aIsAfter === true,
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
|
-
return { votes, decision: decideReviewVotes(votes), expected: orders.length };
|
|
107
|
+
return { votes, decision: decideReviewVotes(votes, orders.length), expected: orders.length };
|
|
108
108
|
}
|
package/lib/skillopt/reviewer.js
CHANGED
|
@@ -65,13 +65,18 @@ export function parseReviewReplies(entries, reviewerId) {
|
|
|
65
65
|
* @param {Array<{better:string, margin:string, aIsAfter:boolean}>} votes
|
|
66
66
|
* @returns {{verdict:'keep'|'revert'|'inconclusive', better:number, worse:number, ties:number, valid:number}}
|
|
67
67
|
*/
|
|
68
|
-
export function decideReviewVotes(votes) {
|
|
68
|
+
export function decideReviewVotes(votes, expected = 0) {
|
|
69
69
|
const mapped = votes.map((vote) => {
|
|
70
70
|
if (vote.better === 'tie') return 'tie';
|
|
71
71
|
const afterWon = (vote.better === 'A' && vote.aIsAfter === true) || (vote.better === 'B' && vote.aIsAfter === false);
|
|
72
72
|
return afterWon ? 'better' : 'worse';
|
|
73
73
|
});
|
|
74
|
-
|
|
74
|
+
// 门槛按**应投数量**算,不按已收到的票数:后者会让 2/3 票时 required=1,
|
|
75
|
+
// 一张票就能定案。与 decideByMajority 的最少有效票契约保持一致。
|
|
76
|
+
const options = Number.isSafeInteger(expected) && expected > 0
|
|
77
|
+
? { minValid: Math.max(1, Math.ceil(expected / 2)) }
|
|
78
|
+
: {};
|
|
79
|
+
return decideByMajority(mapped, options);
|
|
75
80
|
}
|
|
76
81
|
|
|
77
82
|
/** 评审所需的投递数量(奇数,默认 3)。 */
|
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.35",
|
|
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",
|