@sleep2agi/commhub-server 0.9.0-preview.278 → 0.9.0-preview.279

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schema": 1,
3
- "commit": "82fefe28222663a2752b2bbd06abf9693f16c6e1",
3
+ "commit": "d45e3b04f79ae33cc3a9d1ff09183124925c47e4",
4
4
  "dirty": false,
5
- "built_at": "2026-11-09T11:17:20.402Z",
5
+ "built_at": "2026-11-09T11:41:59.929Z",
6
6
  "source": "git"
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sleep2agi/commhub-server",
3
- "version": "0.9.0-preview.278",
3
+ "version": "0.9.0-preview.279",
4
4
  "description": "CommHub Server — AI Agent communication hub with MCP protocol, multi-network isolation, user auth, and MCP tools (17 collaboration-core + node/provider ops tools; authoritative list: docs-site/docs/api/mcp-tools.md).",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -192,10 +192,13 @@ test("acknowledged adoption is a management relation, not canonical-directory or
192
192
  });
193
193
 
194
194
  test("freshness uses Hub receipt times and currently valid immutable node credentials", () => {
195
- for (const offset of ["-2 minutes", "+2 minutes"]) {
195
+ for (const offset of ["-5 minutes", "+2 minutes"]) {
196
196
  db.run("UPDATE sessions SET last_seen_at=datetime('now',?1) WHERE resume_id='issuer_source'", [offset]);
197
197
  expect(inspect()).toEqual({ ok: false, error: "source_evidence_stale" });
198
198
  }
199
+ // Within one 3-minute status heartbeat: alive (75 s used to call this stale).
200
+ db.run("UPDATE sessions SET last_seen_at=datetime('now','-2 minutes') WHERE resume_id='issuer_source'");
201
+ expect((inspect() as any).error).not.toBe("source_evidence_stale");
199
202
  db.run("UPDATE sessions SET last_seen_at=datetime('now') WHERE resume_id='issuer_source'");
200
203
  for (const tokenId of [sourceToken.token_id!, daemonToken.token_id!]) {
201
204
  db.run("UPDATE api_tokens SET revoked_at=datetime('now') WHERE token_id=?1", [tokenId]);
@@ -18,6 +18,12 @@ export type SourceIssuerCode = "source_selection_invalid" | "source_auth_require
18
18
  | "source_read_forbidden" | "insufficient_role_for_create_node" | "daemon_not_found"
19
19
  | "daemon_cannot_create_nodes" | "source_runtime_unsupported" | "source_daemon_unverified"
20
20
  | "source_daemon_mismatch" | "source_evidence_stale" | "source_evidence_unavailable";
21
+ /** Liveness window for source and daemon Hub receipt times. Nodes and daemons report
22
+ * status every 3 min (STATUS_HEARTBEAT_MS / node-server heartbeat), so the former
23
+ * 75 s window made a healthy pair look stale for ~60% of each cycle and the app's
24
+ * fork returned 403 almost always. One heartbeat + jitter. Still liveness only,
25
+ * not a generation lease (the daemon's live evidence read is the proof). */
26
+ export const SOURCE_LIVENESS_MS = 4 * 60_000;
21
27
  export type SourceIssuerRefusal = { ok: false; error: SourceIssuerCode };
22
28
  export class SourceIssuerError extends Error {
23
29
  constructor(public readonly code: SourceIssuerCode) { super(code); this.name = "SourceIssuerError"; }
@@ -99,7 +105,7 @@ function readEvidence(p: Permissions): SourceEvidenceRead | SourceIssuerRefusal
99
105
  WHERE node_id=?1 AND network_id=?2 ORDER BY last_seen_at DESC LIMIT 1`, nodeId, s.network_id);
100
106
  const time = parseDbTimestampMs(seen?.last_seen_at ?? "");
101
107
  const age = Date.now() - time;
102
- if (!Number.isFinite(time) || age < 0 || age > 75_000) return fail("source_evidence_stale");
108
+ if (!Number.isFinite(time) || age < 0 || age > SOURCE_LIVENESS_MS) return fail("source_evidence_stale");
103
109
  const tokens = db.all<{ token_id: string; user_id: string }>(`SELECT t.token_id,t.user_id FROM api_tokens t JOIN users u ON u.user_id=t.user_id
104
110
  JOIN network_members m ON m.user_id=t.user_id AND m.network_id=t.network_id
105
111
  WHERE t.bound_node_id=?1 AND t.network_id=?2 AND t.scope='network' AND t.revoked_at IS NULL