@suifei/dsh-ai-team 0.4.34 → 0.4.36
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 +22 -0
- package/index.js +14 -7
- package/lib/host/service.js +25 -13
- package/lib/ledger/fold.js +3 -2
- package/lib/ledger/namespace.js +74 -0
- package/lib/ledger/writer.js +7 -0
- package/lib/runtime/skill-provider.js +5 -10
- 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,27 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.36 - 2026-11-12
|
|
4
|
+
|
|
5
|
+
**中危批次 6:PMO tick 崩溃、重复决策、接管不污染验收资格、退役终态**
|
|
6
|
+
|
|
7
|
+
- **PMO tick 不再每轮抛 TypeError**:`autoAnswerDecisions` 在 Human 缺失时返回数字 `0`,调用方按数组迭代直接 TypeError,整个 tick 被打断且每轮重复。改为返回 `[]`。
|
|
8
|
+
- **重复决策被拒**:`answerDecision` 没有终态前置,对已 `resolved`/`dismissed`/`superseded` 的决策项再次提交会被接受,重复写 Thread 回复、ack 回来的还是旧答案。
|
|
9
|
+
- **接管不再污染验收资格**(INV-07):`task/taken-over` 把继任者写进 `claimHistory`,而 `isReviewCandidate` 会排除 `claimHistory` 里的人——继任者因此永久没有资格验收自己名下的卡。接管事实改由既有的 `takeoverHistory` 记录。
|
|
10
|
+
- **退役是终态**:`member.fail` 与迟到的 `recordMemberFailure` 都不再接受退役成员(此前 retired 会被改写成 failed,随后 `member.bind` 能把成员复活)。
|
|
11
|
+
- **删除死代码**:`installFileSkillProvider` 按「`registerProvider` 可能返回 invalidate」处理,而 SDK 契约只返回 disposer——该分支永远不可达,已按契约收敛。
|
|
12
|
+
- 测试:`node --test` **231/231**(新增 3 例;另按 INV-07 更新 1 处既有断言)。
|
|
13
|
+
|
|
14
|
+
## 0.4.35 - 2026-11-12
|
|
15
|
+
|
|
16
|
+
**中危批次 5:命名空间、poison 恢复、多数决、并发认领**
|
|
17
|
+
|
|
18
|
+
- **profile 命名空间解析**:桌面启动器按**位置参数**传 profile 目录(`… <dsh-root> …\.dsh\profiles\desktop …`),旧解析只认 `--profile <name>`,于是 desktop profile 的账本全落进 `ai-team/default/`。现在 `--profile x` / `--profile=x` / 位置路径 / `DSH_PROFILE` 都认。
|
|
19
|
+
- **一次性、可回退的命名空间搬迁**:只修解析会让既有数据留在 `default/`(界面上团队凭空消失)。启动时若旧命名空间的数据明显多于目标命名空间,则把旧目录整体改名迁入,目标原有内容改名 `*.superseded-<ts>` 保留,不删除任何文件。
|
|
20
|
+
- **poison 之后有恢复路径**:回滚失败会把 writer 置为 poisoned,错误信息建议「close and open it again」,但生产代码没有调用点。`repair()` 现在按磁盘真相重建后**解除 poison**(返回 `recoveredFromPoison`),不必等重启。
|
|
21
|
+
- **评审改判多数决**:评审通道原本要求**全票**才判定,与 `decideByMajority` 的最少有效票契约相反——漏一票就要空等 30 分钟再判 failed。现在按「应投数量的半数(向上取整)」为门槛,`required` 也按应投数量算(此前按已收票数算,2/3 时会退化成 1 票定案)。
|
|
22
|
+
- **task 命令串行化**:`claim/submit/accept/...` 等 12 个写命令此前不在 `runExclusive` 内,「读投影 → 判定 → 追加」可被并发双双通过,同一成员能同时持有两张 in_progress 卡(破坏 INV-05,且投影不会自愈)。
|
|
23
|
+
- 测试:`node --test` **229/229**(新增 `namespace` 4 例、poison 恢复 1 例、多数决 1 例、并发认领 1 例;并发那条已用对照组确认「撤掉修复即失败」)。
|
|
24
|
+
|
|
3
25
|
## 0.4.34 - 2026-11-12
|
|
4
26
|
|
|
5
27
|
**同人绑定:合并后显示目标名**
|
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/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);
|
|
@@ -710,6 +710,8 @@ export class TeamService {
|
|
|
710
710
|
if (command.actor.kind !== 'human') fail(ERRORS.UNAUTHORIZED, 'only Human may mark a member failed');
|
|
711
711
|
const member = this.state.members?.[payload.memberId];
|
|
712
712
|
if (member === undefined) fail(ERRORS.NOT_FOUND, `member ${String(payload.memberId)} not found`);
|
|
713
|
+
// 退役是终态:把 retired 改成 failed 会让 member.bind 之后把 ta 复活。
|
|
714
|
+
if (member.status === 'retired') fail(ERRORS.INVALID_STATE, `member ${member.id} is retired`);
|
|
713
715
|
await this.append(command, 'member/failed', { memberId: member.id, reason: payload.reason ?? '' });
|
|
714
716
|
return { member: { ...member, status: 'failed', failure: payload.reason ?? '' } };
|
|
715
717
|
}
|
|
@@ -939,6 +941,9 @@ export class TeamService {
|
|
|
939
941
|
async recordMemberFailure(memberId, failure, projectId = Object.keys(this.state.projects ?? {})[0]) {
|
|
940
942
|
const member = this.state.members?.[memberId];
|
|
941
943
|
if (member === undefined) fail(ERRORS.NOT_FOUND, `member ${String(memberId)} not found`);
|
|
944
|
+
// 退役成员不该被迟到的 LLM 失败改成 failed(fold 对这条事件没有 retired 守卫,
|
|
945
|
+
// 之后 member.bind 就能把 ta 复活)。直接忽略,不写事件。
|
|
946
|
+
if (member.status === 'retired') return null;
|
|
942
947
|
const attempt = Number.isSafeInteger(failure.attempt) ? failure.attempt : (member.lastFailure?.attempt ?? 0) + 1;
|
|
943
948
|
const fatal = failure.category === 'auth' || failure.category === 'billing' || failure.category === 'policy' || failure.category === 'unknown';
|
|
944
949
|
// Tool-argument and provider dumps can run to kilobytes; the ledger and
|
|
@@ -1270,7 +1275,9 @@ export class TeamService {
|
|
|
1270
1275
|
/** PMO: answer all pending structured questions with the max-value policy. */
|
|
1271
1276
|
async autoAnswerDecisions(projectId = Object.keys(this.state.projects ?? {})[0]) {
|
|
1272
1277
|
const humanId = this.humanId();
|
|
1273
|
-
|
|
1278
|
+
// 合同是「返回回答列表」:这里曾返回数字 0,调用方按数组迭代时抛 TypeError,
|
|
1279
|
+
// 整个 PMO tick 被打断且每个 tick 都重复失败。
|
|
1280
|
+
if (humanId === null || humanId === undefined) return [];
|
|
1274
1281
|
const items = Object.values(this.state.inbox ?? {}).filter((item) =>
|
|
1275
1282
|
item.memberId === humanId
|
|
1276
1283
|
&& item.type === 'decision_required'
|
|
@@ -1393,6 +1400,11 @@ export class TeamService {
|
|
|
1393
1400
|
}
|
|
1394
1401
|
const humanId = command.actor.memberId;
|
|
1395
1402
|
if (item.memberId !== humanId) fail(ERRORS.UNAUTHORIZED, 'decision belongs to another member');
|
|
1403
|
+
// 终态前置:已 resolved/dismissed/superseded 的决策项再次提交过去会被接受,
|
|
1404
|
+
// 于是同一决策重复写 Thread 回复,ack 回来的 item 还是旧答案。
|
|
1405
|
+
if (['resolved', 'dismissed', 'superseded'].includes(item.state)) {
|
|
1406
|
+
fail(ERRORS.INVALID_STATE, `decision ${String(item.id)} is already ${String(item.state)}`);
|
|
1407
|
+
}
|
|
1396
1408
|
const answers = (Array.isArray(payload.answers) ? payload.answers : [])
|
|
1397
1409
|
.map((answer, index) => ({
|
|
1398
1410
|
id: typeof answer?.id === 'string' && answer.id !== '' ? answer.id : `q${index + 1}`,
|
package/lib/ledger/fold.js
CHANGED
|
@@ -452,14 +452,15 @@ function applyTaskEvent(state, event, payload) {
|
|
|
452
452
|
case 'task/taken-over': {
|
|
453
453
|
const to = textOr(payload.toMemberId, null);
|
|
454
454
|
if (to === null) return advance(state, event);
|
|
455
|
-
|
|
455
|
+
// INV-07:只有 claim 能进 claimHistory。接管曾把继任者写进去,而
|
|
456
|
+
// isReviewCandidate 会排除所有在 claimHistory 里的人——继任者因此永久
|
|
457
|
+
// 没有资格验收自己名下的这张卡。接管事实由 takeoverHistory 记录。
|
|
456
458
|
const takeoverHistory = Array.isArray(task.takeoverHistory) ? task.takeoverHistory : [];
|
|
457
459
|
return patch({
|
|
458
460
|
...task,
|
|
459
461
|
accountableOwnerId: to,
|
|
460
462
|
ownerId: to,
|
|
461
463
|
assigneeId: to,
|
|
462
|
-
claimHistory: history.includes(to) ? history : [...history, to],
|
|
463
464
|
takeoverHistory: [...takeoverHistory, {
|
|
464
465
|
from: textOr(payload.fromMemberId, task.assigneeId ?? task.ownerId ?? null),
|
|
465
466
|
to,
|
|
@@ -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
|
|
|
@@ -194,17 +194,12 @@ export function createFileSkillProvider({ dshHome, projectCwd, bundledDir } = {}
|
|
|
194
194
|
export function installFileSkillProvider(skills, options) {
|
|
195
195
|
if (!skills || typeof skills.registerProvider !== 'function') return () => {};
|
|
196
196
|
const provider = createFileSkillProvider(options);
|
|
197
|
+
// SDK 契约(dsh-skill.md):`registerProvider` 同步注册、**返回 disposer**,
|
|
198
|
+
// 没有 invalidate 这一档。旧实现按「可能返回 { dispose, invalidate }」处理,
|
|
199
|
+
// invalidate 分支永远不可达,属于死代码——这里只保留真实的两种返回形态。
|
|
197
200
|
const control = skills.registerProvider(() => provider);
|
|
198
|
-
|
|
199
|
-
// control:直接把它当函数调用会在 teardown 里抛错(provider 泄漏),且从不
|
|
200
|
-
// invalidate 会让技能目录一直停在注册时的快照。
|
|
201
|
-
if (typeof control === 'function') {
|
|
202
|
-
return () => {
|
|
203
|
-
try { control(); } catch { /* already disposed */ }
|
|
204
|
-
};
|
|
205
|
-
}
|
|
201
|
+
const dispose = typeof control === 'function' ? control : control?.dispose;
|
|
206
202
|
return () => {
|
|
207
|
-
try {
|
|
208
|
-
try { control?.dispose?.(); } catch { /* already disposed */ }
|
|
203
|
+
try { dispose?.(); } catch { /* already disposed */ }
|
|
209
204
|
};
|
|
210
205
|
}
|
|
@@ -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.36",
|
|
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",
|