@sleep2agi/commhub-server 0.9.0-preview.256 → 0.9.0-preview.258
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/build-info.json +2 -2
- package/package.json +1 -1
- package/src/agent-acl-http.test.ts +5 -0
- package/src/agent-acl-slice3-http.test.ts +168 -0
- package/src/auth-abuse-counters.test.ts +125 -0
- package/src/auth-abuse-counters.ts +111 -0
- package/src/binding-generation-http.test.ts +10 -1
- package/src/clone-node.test.ts +7 -0
- package/src/create-node-blocked-gate.test.ts +9 -0
- package/src/daemon-provider-snapshots.test.ts +9 -1
- package/src/daemon-token-owner-http.test.ts +54 -0
- package/src/departments-agent-count.test.ts +7 -0
- package/src/expiry-counters.test.ts +14 -5
- package/src/expiry-counters.ts +77 -9
- package/src/expiry-evidence-db.test.ts +103 -0
- package/src/inbox-count-sse.test.ts +8 -0
- package/src/mcp-projects-events-http.test.ts +3 -0
- package/src/mcp-write-network-resolution.test.ts +15 -0
- package/src/network-scope.ts +24 -0
- package/src/node-daemon-bindings.test.ts +12 -2
- package/src/node-files-transport.test.ts +3 -0
- package/src/node-logs-transport.test.ts +3 -0
- package/src/node-security-write-gate.test.ts +72 -0
- package/src/provider-tools-shape.test.ts +16 -1
- package/src/requirement-participant-notify-http.test.ts +4 -0
- package/src/requirements-mcp.test.ts +17 -1
- package/src/rules-file-transport.test.ts +38 -4
- package/src/schedule-agent-mcp-http.test.ts +12 -1
- package/src/scheduled-requirement-wake-http.test.ts +5 -1
- package/src/server.ts +14 -5
- package/src/skillhub-http.test.ts +4 -2
- package/src/task-consumption.test.ts +6 -0
- package/src/task-idempotency-mcp.test.ts +6 -0
|
@@ -126,21 +126,45 @@ describe("app#225 rules file — read round trip", () => {
|
|
|
126
126
|
const n = await connect(asNode);
|
|
127
127
|
try {
|
|
128
128
|
const enq = await u.call("read_node_rules_file", { node_id: NODE_ID });
|
|
129
|
+
// #3275 批次 4 —— read 的外层三键(与 write 同形;本文件里 `enq` 被赋值 4 次,各归各的)
|
|
130
|
+
expect(Object.keys(enq).sort()).toEqual(["ok", "op", "request_id"]);
|
|
129
131
|
expect(enq).toMatchObject({ ok: true, op: "read" });
|
|
130
132
|
expect(enq.request_id).toMatch(/^rf_/);
|
|
131
133
|
|
|
132
|
-
|
|
134
|
+
// #3275 批次 4 —— 先接住再断言(同变量口径):外层是 pending 态的闭集。
|
|
135
|
+
const pending = await u.call("get_rules_file_result", { request_id: enq.request_id });
|
|
136
|
+
// #3275 批次 4 —— 实测 9 键(我按族推断的 7 键少了 node_id 与 age_ms,当场红)。
|
|
137
|
+
// `age_ms` 尤其不能少:pending 唯一的「还要等多久」信号;没有它,客户端只能盲轮询。
|
|
138
|
+
expect(Object.keys(pending).sort()).toEqual([
|
|
139
|
+
"age_ms", "error", "exists", "file_name", "node_id", "ok", "op", "request_id", "status",
|
|
140
|
+
]);
|
|
141
|
+
expect(pending).toMatchObject({ ok: true, status: "pending", op: "read" });
|
|
142
|
+
// read_node_rules_file 的外层(enq):
|
|
143
|
+
expect(Object.keys(enq).sort()).toEqual(["ok", "op", "request_id"]);
|
|
133
144
|
|
|
134
145
|
const pulled = await n.call("get_rules_file_request", {});
|
|
146
|
+
// #3309 分支 —— 有请求态的外层闭集 {ok, request}(与空态同形,但 request 非 null);
|
|
147
|
+
// 空态已在上一条钉过 ⇒ 两个出口各自有断言,而不是「一个断言代表两态」。
|
|
148
|
+
expect(Object.keys(pulled).sort()).toEqual(["ok", "request"]);
|
|
135
149
|
expect(pulled.ok).toBe(true);
|
|
136
150
|
expect(Object.keys(pulled.request).sort()).toEqual(["op", "request_id"]);
|
|
137
151
|
expect(pulled.request).toEqual({ request_id: enq.request_id, op: "read" });
|
|
138
152
|
// 第二次拉:已经 in_progress,不再重复下发
|
|
139
153
|
expect(await n.call("get_rules_file_request", {})).toEqual({ ok: true, request: null });
|
|
140
154
|
|
|
141
|
-
|
|
155
|
+
// #3275 批次 1 —— 同变量口径:这条断言必须测**这次调用的返回值**,而不是写在旁边的另一个值。
|
|
156
|
+
// 成功回执是闭集:{ok, request_id, status}。多一个键(例如 hint)客户端就会多一个没人知道的分支。
|
|
157
|
+
const acked = await n.call("ack_rules_file_request", {
|
|
142
158
|
request_id: enq.request_id, status: "done", file_name: "CLAUDE.md", exists: true, content: "# 规则\n",
|
|
143
|
-
})
|
|
159
|
+
});
|
|
160
|
+
expect(Object.keys(acked).sort()).toEqual(["ok", "request_id", "status"]);
|
|
161
|
+
// #3275 批次 1·b —— 重复 ack 走 already_terminal:**形状不一样**(多一个 current_status)。
|
|
162
|
+
const twice = await n.call("ack_rules_file_request", {
|
|
163
|
+
request_id: enq.request_id, status: "done", file_name: "CLAUDE.md", exists: true,
|
|
164
|
+
});
|
|
165
|
+
expect(Object.keys(twice).sort()).toEqual(["current_status", "ignored", "ok"]);
|
|
166
|
+
expect(twice).toMatchObject({ ok: true, ignored: "already_terminal" });
|
|
167
|
+
expect(acked).toMatchObject({ ok: true, status: "done", request_id: enq.request_id });
|
|
144
168
|
|
|
145
169
|
const res = await u.call("get_rules_file_result", { request_id: enq.request_id });
|
|
146
170
|
expect(res).toMatchObject({ ok: true, status: "done", op: "read", file_name: "CLAUDE.md", exists: true, content: "# 规则\n", error: null });
|
|
@@ -153,8 +177,13 @@ describe("app#225 rules file — read round trip", () => {
|
|
|
153
177
|
try {
|
|
154
178
|
const body = "# new rules\n\n- 不碰生产 DB\n";
|
|
155
179
|
const enq = await u.call("write_node_rules_file", { node_id: NODE_ID, content: body });
|
|
180
|
+
// #3275 批次 4 —— write 的外层与 read 同形(三键),但**必须各自钉**:
|
|
181
|
+
// 这个文件里 `enq` 被赋值 4 次,一条断言只属于它所在的那一次。
|
|
182
|
+
expect(Object.keys(enq).sort()).toEqual(["ok", "op", "request_id"]);
|
|
156
183
|
expect(enq).toMatchObject({ ok: true, op: "write" });
|
|
157
184
|
const pulled = await n.call("get_rules_file_request", {});
|
|
185
|
+
// get_rules_file_request 的空态:`request: null`(两态,闭集两键)
|
|
186
|
+
expect(Object.keys(pulled).sort()).toEqual(["ok", "request"]);
|
|
158
187
|
expect(pulled.request).toEqual({ request_id: enq.request_id, op: "write", content: body });
|
|
159
188
|
await n.call("ack_rules_file_request", { request_id: enq.request_id, status: "done", file_name: "CLAUDE.md", exists: true });
|
|
160
189
|
const res = await u.call("get_rules_file_result", { request_id: enq.request_id });
|
|
@@ -190,7 +219,12 @@ describe("app#225 rules file — SEC-1 and lifecycle", () => {
|
|
|
190
219
|
try {
|
|
191
220
|
const enq = await u.call("read_node_rules_file", { node_id: NODE_ID });
|
|
192
221
|
expect(await o.call("get_rules_file_request", {})).toEqual({ ok: true, request: null });
|
|
193
|
-
|
|
222
|
+
// #3275 批次 1·b —— 别的节点 ack 别人的请求:**忽略也是契约**。
|
|
223
|
+
// 形状是 {ok, ignored} 两键(不带 request_id/status —— 那是主分支的形状),
|
|
224
|
+
// 只写 toMatchObject 时,多塞一个 current_status 不会有任何东西变红。
|
|
225
|
+
const foreignAck = await o.call("ack_rules_file_request", { request_id: enq.request_id, status: "done", content: "stolen" });
|
|
226
|
+
expect(Object.keys(foreignAck).sort()).toEqual(["ignored", "ok"]);
|
|
227
|
+
expect(foreignAck).toEqual({ ok: true, ignored: "unknown_or_foreign_request" });
|
|
194
228
|
expect(db.get<{ status: string }>("SELECT status FROM node_rules_requests WHERE request_id = ?1", enq.request_id)?.status).toBe("pending");
|
|
195
229
|
} finally { await u.close(); await o.close(); }
|
|
196
230
|
}, 20_000);
|
|
@@ -135,7 +135,10 @@ describe("happy path from a node", () => {
|
|
|
135
135
|
"scheduled_for", "status", "task_id", "work_outcome", "work_outcome_node_id"]);
|
|
136
136
|
expect(runs.runs.map((x: any) => x.task_id)).toContain(r.taskId);
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
// #3275 批次 2 —— 先接住再断言(同变量口径);值本来就是闭集,缺的只是「它是一条断言的对象」。
|
|
139
|
+
const cancelled = await mcp(node.a.token, "schedule_cancel", { schedule_id: s.schedule_id });
|
|
140
|
+
expect(Object.keys(cancelled).sort()).toEqual(["ok", "status"]);
|
|
141
|
+
expect(cancelled).toEqual({ ok: true, status: "cancelled" });
|
|
139
142
|
expect((await mcp(node.a.token, "schedule_get", { schedule_id: s.schedule_id })).schedule.status).toBe("cancelled");
|
|
140
143
|
expect((await mcp(node.a.token, "schedule_run_now", { schedule_id: s.schedule_id })).error).toBe("schedule_cancelled");
|
|
141
144
|
});
|
|
@@ -160,6 +163,8 @@ describe("happy path from a node", () => {
|
|
|
160
163
|
|
|
161
164
|
test("a schedule for another node the caller can send_task to; the target can read it but not change it", async () => {
|
|
162
165
|
const c = await create("a", { target_node_id: node.b.id });
|
|
166
|
+
// 与外层同族但**各自钉**:同族不共享形状这件事今晚已经被 checklist_toggle 打过一次脸。
|
|
167
|
+
expect(Object.keys(c).sort()).toEqual(["ok", "schedule"]);
|
|
163
168
|
expect(c.ok).toBe(true);
|
|
164
169
|
const id = c.schedule.schedule_id;
|
|
165
170
|
expect((await mcp(node.b.token, "schedule_list")).schedules.map((x: any) => x.schedule_id)).toContain(id);
|
|
@@ -180,6 +185,8 @@ describe("happy path from a node", () => {
|
|
|
180
185
|
expect(r.status).toBe(201);
|
|
181
186
|
const id = r.body.schedule.schedule_id;
|
|
182
187
|
const got = await mcp(node.a.token, "schedule_get", { schedule_id: id });
|
|
188
|
+
// #3275 批次 2 —— schedule_get / schedule_create 的外层都是 {ok, schedule}(实测)。
|
|
189
|
+
expect(Object.keys(got).sort()).toEqual(["ok", "schedule"]);
|
|
183
190
|
expect(got.schedule.created_by_node_id).toBeNull();
|
|
184
191
|
expect((await mcp(node.a.token, "schedule_runs", { schedule_id: id })).ok).toBe(true);
|
|
185
192
|
expect((await mcp(node.a.token, "schedule_list")).schedules.map((x: any) => x.schedule_id)).toContain(id);
|
|
@@ -442,6 +449,10 @@ describe("#2935 排程周期诊断", () => {
|
|
|
442
449
|
name: `diag-${stamp}`, task: "t", target_node_id: node.a.id,
|
|
443
450
|
schedule: { type: "interval", every_seconds: 180 }, timezone: "Asia/Shanghai",
|
|
444
451
|
});
|
|
452
|
+
// #3275 批次 4 —— 上面那些 `create("a")` 断言其实**已经**钉住 schedule_create,
|
|
453
|
+
// 但调用在 helper 里、工具名不在同一行 ⇒ 统计口径归因不到。
|
|
454
|
+
// ⇒ 这里补一条**字面量直调**的:形状同外层,代价一次调用。
|
|
455
|
+
expect(Object.keys(c).sort()).toEqual(["ok", "schedule"]);
|
|
445
456
|
expect(c.ok).toBe(true);
|
|
446
457
|
const id = c.schedule.schedule_id;
|
|
447
458
|
// 造 3 条「一轮跑了 600 秒」的已完成 run(中位数 600s > 周期 180s)。
|
|
@@ -148,7 +148,11 @@ describe("#1279 authoritative scoped requirement-event wake over HTTP/MCP", () =
|
|
|
148
148
|
expect(created.ok).toBe(true); const id = created.schedule.schedule_id;
|
|
149
149
|
expect(created.schedule.schedule.requirement_wake.tag).toBe("ANet");
|
|
150
150
|
expect((await mcp(nodes.b.token, "schedule_update", { schedule_id: id, schedule: { type: "interval", every_seconds: 180, requirement_wake: null } })).ok).toBe(false);
|
|
151
|
-
|
|
151
|
+
const bi = await mcp(nodes.a.token, "schedule_batch_interval", { schedule_ids: [id], every_seconds: 180 });
|
|
152
|
+
// #3275 批次 4 —— 批量改间隔是**部分成功**语义:updated / failed / results 三个一起才有意义。
|
|
153
|
+
// 只断言 ok 时,「失败了几条」和「分别为什么」都拿不到 —— 而批量操作恰恰最需要这个。
|
|
154
|
+
expect(Object.keys(bi).sort()).toEqual(["failed", "ok", "results", "updated"]);
|
|
155
|
+
expect(bi.ok).toBe(true);
|
|
152
156
|
expect(state(id).requirement_wake_json).toBeTruthy();
|
|
153
157
|
expect((await mcp(nodes.a.token, "schedule_update", { schedule_id: id, name: "metadata" })).ok).toBe(true);
|
|
154
158
|
expect(state(id).requirement_wake_json).toBeTruthy();
|
package/src/server.ts
CHANGED
|
@@ -44,7 +44,7 @@ import { notifyExpiredTasks, type ExpiredTaskRow } from "./task-expiry-notice.js
|
|
|
44
44
|
import { expireStaleOpenTasks } from "./task-stale-open.js";
|
|
45
45
|
import { expireDeliveredToOfflineTargets } from "./task-offline-delivery.js";
|
|
46
46
|
import { flagOrphanTasks } from "./task-orphan.js";
|
|
47
|
-
import { addAgentNetworkScope, addHumanNetworkScope, addNetworkScope, addOwnTrafficScope, addAgentTimelineScope, canRestWriteNetwork, canRestWriteNetworkAsHuman, getUserNetworkIds, resolveRestNetworkScope, resolveRestWriteNetworkId, singleNetworkId, type RestNetworkScope } from "./network-scope.js";
|
|
47
|
+
import { addAgentNetworkScope, addHumanNetworkScope, addNetworkScope, addOwnTrafficScope, addAgentTimelineScope, canRestWriteNetwork, canRestWriteNetworkAsHuman, canRestWriteNodeSecurity, getUserNetworkIds, resolveRestNetworkScope, resolveRestWriteNetworkId, singleNetworkId, type RestNetworkScope } from "./network-scope.js";
|
|
48
48
|
import { withBusyElapsed } from "./scheduled-failure-code.js";
|
|
49
49
|
import { pickAliasNetwork } from "./rest-alias-network-fallback.js";
|
|
50
50
|
import { lifecycleProjections, lifecycleRequestResponse } from "./node-lifecycle-read.js";
|
|
@@ -123,6 +123,7 @@ import { parseHubTimestamp } from "./hub-timestamp";
|
|
|
123
123
|
import { logTaskRejection } from "./task-rejection-log.js";
|
|
124
124
|
import { taskRejectionCounters } from "./rejection-counters.js";
|
|
125
125
|
import { neverConsumedExpiryCounters, noteNeverConsumedExpiry, neverConsumeGate, persistentNeverConsumedExpiries } from "./expiry-counters.js";
|
|
126
|
+
import { authAbuseSnapshot, noteLoginIpRateLimited, noteLoginLocked, noteRegisterRateLimited } from "./auth-abuse-counters.js";
|
|
126
127
|
import { legacyLicenseField, licenseStateOf } from "./license-state.js";
|
|
127
128
|
import { AVATAR_FIELD, avatarUrl, inspectAvatarImage, isMultipart, isValidAvatarVersion, MAX_AVATAR_BYTES, MAX_AVATAR_STORAGE_BYTES } from "./user-avatar-image.js";
|
|
128
129
|
|
|
@@ -2363,6 +2364,7 @@ return Bun.serve({
|
|
|
2363
2364
|
if (url.pathname === "/api/auth/register" && req.method === "POST") {
|
|
2364
2365
|
const clientIP = req.headers.get("x-forwarded-for")?.split(",")[0]?.trim() || "unknown";
|
|
2365
2366
|
if (!checkRateLimit(clientIP, 30)) {
|
|
2367
|
+
noteRegisterRateLimited(clientIP);
|
|
2366
2368
|
return withCors(req, Response.json({ ok: false, error: "too many requests, try again later" }, { status: 429 }));
|
|
2367
2369
|
}
|
|
2368
2370
|
try {
|
|
@@ -2380,6 +2382,7 @@ return Bun.serve({
|
|
|
2380
2382
|
const ipRate = sharedLoginIpRateLimiter.check(clientIP || "unknown");
|
|
2381
2383
|
if (!ipRate.allowed) {
|
|
2382
2384
|
logAudit(null, null, "login_rate_limited", "auth", undefined, clientIP);
|
|
2385
|
+
noteLoginIpRateLimited(clientIP);
|
|
2383
2386
|
return withCors(req, Response.json(
|
|
2384
2387
|
{ ok: false, error: "rate_limited", message: "Too many login attempts. Try again later.", retry_after_ms: ipRate.retryAfterMs },
|
|
2385
2388
|
{ status: 429, headers: { "Retry-After": String(Math.ceil((ipRate.retryAfterMs ?? 1000) / 1000)) } }
|
|
@@ -2390,6 +2393,7 @@ return Bun.serve({
|
|
|
2390
2393
|
const lock = sharedLoginFailureLockout.check(body.username);
|
|
2391
2394
|
if (lock.locked) {
|
|
2392
2395
|
logAudit(null, body.username, "login_locked", "auth", undefined, `retry_after_ms=${lock.retryAfterMs ?? 0}`);
|
|
2396
|
+
noteLoginLocked(body.username);
|
|
2393
2397
|
return withCors(req, Response.json(
|
|
2394
2398
|
{ ok: false, error: "login_locked", message: "Too many failed login attempts. Try again later.", retry_after_ms: lock.retryAfterMs },
|
|
2395
2399
|
{ status: 429, headers: { "Retry-After": String(Math.ceil((lock.retryAfterMs ?? 1000) / 1000)) } }
|
|
@@ -3843,6 +3847,11 @@ return Bun.serve({
|
|
|
3843
3847
|
task_rejections: taskRejectionCounters(),
|
|
3844
3848
|
// #3271 —— 「到死都没被取走」按节点分桶。窗口用同一个 since。
|
|
3845
3849
|
task_expiries_never_consumed: neverConsumedExpiryCounters(),
|
|
3850
|
+
// #3314 B 类 —— 故意匿名的那两条路由(register / login)没有身份门,
|
|
3851
|
+
// 它们的健康度只能从「限流与锁定命中了几次、打到了几个不同来源」读出来。
|
|
3852
|
+
// 比值才是有意义的部分:命中数 ≫ 去重数 ⇒ 单点重试;两者接近 ⇒ 换 IP / 撒网。
|
|
3853
|
+
// 只给计数与去重数,不给 IP / 用户名的值(集合本身不出进程)。
|
|
3854
|
+
auth_abuse: authAbuseSnapshot(),
|
|
3846
3855
|
},
|
|
3847
3856
|
// 🔴 2026-10-31 —— 上面那个 counters 对象**不在匿名投影里**(PUBLIC_HEALTH_KEYS)。
|
|
3848
3857
|
// 而 #3271 交付时我把「观察它有没有 fire」写成了 `/health.counters.…` ——
|
|
@@ -4055,7 +4064,7 @@ return Bun.serve({
|
|
|
4055
4064
|
// 看不见这个节点(不在它的网络里)与不存在同一个 404。
|
|
4056
4065
|
if (!node || !node.network_id || (!role && !isAdmin)) return withCors(req, Response.json({ ok: false, error: "node_not_found" }, { status: 404 }));
|
|
4057
4066
|
// 节点主人、网络 owner / admin、Hub 管理员能改;部门负责人和别的成员不能(RFC-041 §2.3 / §2.4)。
|
|
4058
|
-
if (!
|
|
4067
|
+
if (!canRestWriteNodeSecurity(restAuth, node.owner_user_id, role, isAdmin)) {
|
|
4059
4068
|
return withCors(req, Response.json({ ok: false, error: "permission_denied", message: "only the node's owner or a network owner/admin can change its permission mode" }, { status: 403 }));
|
|
4060
4069
|
}
|
|
4061
4070
|
const previous = (node.permission_mode || "normal") as NodePermissionMode;
|
|
@@ -4228,7 +4237,7 @@ return Bun.serve({
|
|
|
4228
4237
|
"SELECT node_id, network_id, owner_user_id, tool_allowlist FROM nodes WHERE node_id = ?1", nodeRef3);
|
|
4229
4238
|
const role3 = node3?.network_id ? getUserNetworkRole(restAuth.userId, node3.network_id) : null;
|
|
4230
4239
|
if (!node3 || !node3.network_id || (!role3 && !isAdmin)) return withCors(req, Response.json({ ok: false, error: "node_not_found" }, { status: 404 }));
|
|
4231
|
-
if (!
|
|
4240
|
+
if (!canRestWriteNodeSecurity(restAuth, node3.owner_user_id, role3, isAdmin)) {
|
|
4232
4241
|
return withCors(req, Response.json({ ok: false, error: "permission_denied", message: "only the node's owner or a network owner/admin can change its tool allowlist" }, { status: 403 }));
|
|
4233
4242
|
}
|
|
4234
4243
|
const nextTools = tools.length ? JSON.stringify(tools) : null;
|
|
@@ -4262,7 +4271,7 @@ return Bun.serve({
|
|
|
4262
4271
|
"SELECT node_id, network_id, owner_user_id, rest_allowlist FROM nodes WHERE node_id = ?1", nodeRef4);
|
|
4263
4272
|
const role4 = node4?.network_id ? getUserNetworkRole(restAuth.userId, node4.network_id) : null;
|
|
4264
4273
|
if (!node4 || !node4.network_id || (!role4 && !isAdmin)) return withCors(req, Response.json({ ok: false, error: "node_not_found" }, { status: 404 }));
|
|
4265
|
-
if (!
|
|
4274
|
+
if (!canRestWriteNodeSecurity(restAuth, node4.owner_user_id, role4, isAdmin)) {
|
|
4266
4275
|
return withCors(req, Response.json({ ok: false, error: "permission_denied", message: "only the node's owner or a network owner/admin can change its REST allowlist" }, { status: 403 }));
|
|
4267
4276
|
}
|
|
4268
4277
|
const nextRoutes = routes.length ? JSON.stringify(routes) : null;
|
|
@@ -4303,7 +4312,7 @@ return Bun.serve({
|
|
|
4303
4312
|
"SELECT node_id, network_id, owner_user_id, peer_allowlist FROM nodes WHERE node_id = ?1", nodeRef2);
|
|
4304
4313
|
const role2 = node2?.network_id ? getUserNetworkRole(restAuth.userId, node2.network_id) : null;
|
|
4305
4314
|
if (!node2 || !node2.network_id || (!role2 && !isAdmin)) return withCors(req, Response.json({ ok: false, error: "node_not_found" }, { status: 404 }));
|
|
4306
|
-
if (!
|
|
4315
|
+
if (!canRestWriteNodeSecurity(restAuth, node2.owner_user_id, role2, isAdmin)) {
|
|
4307
4316
|
return withCors(req, Response.json({ ok: false, error: "permission_denied", message: "only the node's owner or a network owner/admin can change its peer allowlist" }, { status: 403 }));
|
|
4308
4317
|
}
|
|
4309
4318
|
const nextValue = peers.length ? JSON.stringify(peers) : null;
|
|
@@ -81,8 +81,10 @@ describe("SkillHub real Hub + SQLite", () => {
|
|
|
81
81
|
expect(Object.keys(nodeList).sort()).toEqual(["ok", "reviewer", "skills"]);
|
|
82
82
|
expect(nodeList.reviewer).toBe(false);
|
|
83
83
|
// 详情未找到:只有两个键;多一个键就意味着错误响应开始夹带上下文。
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
// #3275 批次 4 —— 同变量口径:先接住再断言(内联 `Object.keys(await f())` 在语义上一样,
|
|
85
|
+
// 但没有任何变量名可供归因;这条改完之后,它就是一次可被引用的形状断言)。
|
|
86
|
+
const missing = await tool(nodeToken, "get_skill", { network_id: networkId, skill_id: skillId });
|
|
87
|
+
expect(Object.keys(missing).sort()).toEqual(["error", "ok"]);
|
|
86
88
|
expect((await tool(nodeToken, "get_skill", { network_id: networkId, skill_id: skillId })).error).toBe("skill_not_found");
|
|
87
89
|
const ownerList = await tool(ownerToken, "list_skills", { network_id: networkId, include_pending: true });
|
|
88
90
|
expect(ownerList.reviewer).toBe(true);
|
|
@@ -118,6 +118,12 @@ describe("task consumed_at identity and lifecycle", () => {
|
|
|
118
118
|
);
|
|
119
119
|
const handler = toolsFor({ alias: NODE_A, nodeToken: true }).list_tasks;
|
|
120
120
|
const first = await call(handler, { from_node_id: `id_${NODE_A}`, durable_cursor: true, limit: 100 });
|
|
121
|
+
// #3309 分支 —— list_tasks 的两个成功出口不是同一形状:
|
|
122
|
+
// 非游标:{ok, tasks, …} (无 capability)
|
|
123
|
+
// 游标 :多一个 capability = "list_tasks.immutable-node-cursor.v1"
|
|
124
|
+
// 只断言 capability 的值时,「顺手把它也加到非游标那条」不会有东西变红。
|
|
125
|
+
// 实测五键:我按源码读成三键(漏了 count 与 stats)——又一次「按代码读会少」
|
|
126
|
+
expect(Object.keys(first).sort()).toEqual(["capability", "count", "next_cursor", "ok", "stats", "tasks"]);
|
|
121
127
|
expect(first.capability).toBe("list_tasks.immutable-node-cursor.v1");
|
|
122
128
|
expect(first.tasks).toHaveLength(100);
|
|
123
129
|
const second = await call(handler, { from_node_id: `id_${NODE_A}`, durable_cursor: true, limit: 100, ...first.next_cursor });
|
|
@@ -108,6 +108,12 @@ describe("send_task durable idempotency", () => {
|
|
|
108
108
|
const replay = await call(handler, args);
|
|
109
109
|
|
|
110
110
|
expect(first.ok).toBe(true);
|
|
111
|
+
// #3309 分支 —— send_task 的**第二个出口**(幂等重放)此前只有 toEqual 整体比较,
|
|
112
|
+
// 而工具名不在那一行(`call(handler, args)`)⇒ 归因不到。补一条同变量键集:
|
|
113
|
+
// 重放回执比新派单少 actual_to 之外的队列建议,多 idempotent_replay / task_status。
|
|
114
|
+
expect(Object.keys(replay).sort()).toEqual([
|
|
115
|
+
"actual_to", "idempotent_replay", "message_id", "ok", "task_id", "task_status",
|
|
116
|
+
]);
|
|
111
117
|
expect(replay).toEqual({
|
|
112
118
|
ok: true,
|
|
113
119
|
message_id: first.message_id,
|