@cueloop/daemon 0.1.0-alpha.9 → 0.1.0-alpha.90
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/package.json +39 -22
- package/src/api.test.ts +1060 -65
- package/src/api.ts +1398 -89
- package/src/capabilities.test.ts +57 -0
- package/src/capabilities.ts +89 -0
- package/src/client.test.ts +24 -0
- package/src/client.ts +669 -86
- package/src/curate.ts +109 -0
- package/src/daemon-version.test.ts +142 -0
- package/src/diff-hot-reload.test.ts +419 -0
- package/src/diff-watcher.ts +293 -0
- package/src/gh.test.ts +59 -0
- package/src/gh.ts +74 -0
- package/src/ghostty-thread-surface-store.test.ts +49 -0
- package/src/ghostty-thread-surface-store.ts +101 -0
- package/src/ghostty-thread-surface.test.ts +398 -0
- package/src/ghostty-thread-surface.ts +267 -0
- package/src/harness-delivery.test.ts +268 -0
- package/src/harness-state-store.test.ts +93 -0
- package/src/harness-state-store.ts +213 -0
- package/src/herdr-split.test.ts +106 -0
- package/src/herdr-split.ts +92 -0
- package/src/herdr-thread-surface-store.test.ts +81 -0
- package/src/herdr-thread-surface-store.ts +64 -0
- package/src/herdr-thread-surface.test.ts +411 -0
- package/src/herdr-thread-surface.ts +355 -0
- package/src/index.ts +8 -9
- package/src/interruptible-wait.test.ts +127 -0
- package/src/interruptible-wait.ts +66 -0
- package/src/jj-working-tree.ts +131 -0
- package/src/main.ts +4 -1
- package/src/paths.ts +49 -0
- package/src/pr-poller.test.ts +102 -0
- package/src/pr-poller.ts +73 -0
- package/src/project-files.test.ts +124 -0
- package/src/project-files.ts +56 -0
- package/src/protocol.ts +79 -7
- package/src/retention.test.ts +191 -0
- package/src/retention.ts +123 -0
- package/src/server.test.ts +453 -42
- package/src/server.ts +433 -88
- package/src/share-blob.test.ts +112 -0
- package/src/share-blob.ts +55 -0
- package/src/single-instance.test.ts +162 -13
- package/src/store.conformance.test.ts +41 -0
- package/src/store.jsonl.test.ts +159 -0
- package/src/store.ts +264 -34
- package/src/testing/store-conformance.ts +194 -0
- package/src/thread-review.test.ts +483 -0
- package/src/thread-review.ts +398 -0
- package/src/thread-surface-config.test.ts +63 -0
- package/src/thread-surface-config.ts +61 -0
- package/src/validate.test.ts +282 -37
- package/src/validate.ts +398 -33
- package/src/vcs-source.test.ts +180 -0
- package/src/vcs-source.ts +228 -0
- package/src/version.ts +6 -0
- package/src/working-tree.ts +149 -0
- package/src/review.test.ts +0 -167
- package/src/review.ts +0 -174
package/src/validate.test.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import * as v from "valibot";
|
|
2
3
|
import { mkdtempSync, rmSync } from "node:fs";
|
|
3
4
|
import { tmpdir } from "node:os";
|
|
4
5
|
import { join } from "node:path";
|
|
@@ -9,23 +10,26 @@ import {
|
|
|
9
10
|
AnnotationSchema,
|
|
10
11
|
ArtifactMetaSchema,
|
|
11
12
|
ArtifactSchema,
|
|
13
|
+
IdentitySchema,
|
|
12
14
|
RevisionSchema,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
ThreadRecordSchema,
|
|
16
|
+
MessageSchema,
|
|
15
17
|
WorkspaceSchema,
|
|
16
18
|
isKnownMethod,
|
|
17
19
|
parseParams,
|
|
18
|
-
|
|
20
|
+
validateThreadRecord,
|
|
19
21
|
} from "./validate";
|
|
20
22
|
import {
|
|
23
|
+
ARTIFACT_TYPES,
|
|
21
24
|
SCHEMA_VERSION,
|
|
22
25
|
type Anchor,
|
|
23
26
|
type Annotation,
|
|
24
27
|
type Artifact,
|
|
25
28
|
type ArtifactMeta,
|
|
26
|
-
type
|
|
29
|
+
type Identity,
|
|
30
|
+
type Thread,
|
|
27
31
|
type Revision,
|
|
28
|
-
type
|
|
32
|
+
type Message,
|
|
29
33
|
type WorkspaceKey,
|
|
30
34
|
} from "@cueloop/schema";
|
|
31
35
|
|
|
@@ -38,11 +42,14 @@ describe("method allowlist", () => {
|
|
|
38
42
|
|
|
39
43
|
describe("parseParams", () => {
|
|
40
44
|
test("accepts a well-formed create and defaults meta", () => {
|
|
41
|
-
|
|
45
|
+
// Act
|
|
46
|
+
const params = parseParams("session.create", {
|
|
42
47
|
workspace: { repoRoot: "/repo", branch: "main" },
|
|
43
48
|
artifact: { type: "plan", content: "# P" },
|
|
44
49
|
});
|
|
45
|
-
|
|
50
|
+
|
|
51
|
+
// Assert
|
|
52
|
+
expect(params.artifact.meta).toEqual({});
|
|
46
53
|
});
|
|
47
54
|
|
|
48
55
|
test("rejects a missing workspace with a pathed message", () => {
|
|
@@ -51,11 +58,48 @@ describe("parseParams", () => {
|
|
|
51
58
|
throw new Error("should have thrown");
|
|
52
59
|
} catch (err) {
|
|
53
60
|
expect(err).toBeInstanceOf(DaemonError);
|
|
54
|
-
|
|
55
|
-
|
|
61
|
+
if (err instanceof DaemonError) {
|
|
62
|
+
expect(err.code).toBe("invalid_params");
|
|
63
|
+
expect(err.message).toContain("session.create: workspace");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test("accepts every artifact type in the schema union", () => {
|
|
69
|
+
for (const type of ARTIFACT_TYPES) {
|
|
70
|
+
const params = parseParams("session.create", {
|
|
71
|
+
workspace: { repoRoot: "/repo", branch: "main" },
|
|
72
|
+
artifact: { type, content: "body" },
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
expect(params.artifact.type).toBe(type);
|
|
56
76
|
}
|
|
57
77
|
});
|
|
58
78
|
|
|
79
|
+
test.each([
|
|
80
|
+
[
|
|
81
|
+
[
|
|
82
|
+
{ start: 2, end: 4, quote: "ab" },
|
|
83
|
+
{ start: 1, end: 2, quote: "c" },
|
|
84
|
+
],
|
|
85
|
+
],
|
|
86
|
+
[
|
|
87
|
+
[
|
|
88
|
+
{ start: 1, end: 4, quote: "abc" },
|
|
89
|
+
{ start: 3, end: 5, quote: "de" },
|
|
90
|
+
],
|
|
91
|
+
],
|
|
92
|
+
[[{ start: 1, end: 4, quote: "ab" }]],
|
|
93
|
+
])("rejects malformed text Cut provenance", (textCuts) => {
|
|
94
|
+
expect(() =>
|
|
95
|
+
parseParams("session.setWorkingCopy", {
|
|
96
|
+
id: "ses_1",
|
|
97
|
+
workingCopy: "remaining",
|
|
98
|
+
textCuts,
|
|
99
|
+
}),
|
|
100
|
+
).toThrow("text Cuts must be ordered, non-overlapping, and match their quote lengths");
|
|
101
|
+
});
|
|
102
|
+
|
|
59
103
|
test("rejects an unknown artifact type", () => {
|
|
60
104
|
expect(() =>
|
|
61
105
|
parseParams("session.create", {
|
|
@@ -72,21 +116,40 @@ describe("parseParams", () => {
|
|
|
72
116
|
test("defaults and clamps the wait timeout", () => {
|
|
73
117
|
expect(parseParams("session.wait", { id: "ses_1" }).timeoutMs).toBe(60_000);
|
|
74
118
|
expect(() => parseParams("session.wait", { id: "ses_1", timeoutMs: -5 })).toThrow();
|
|
75
|
-
expect(() =>
|
|
119
|
+
expect(() =>
|
|
120
|
+
parseParams("session.wait", { id: "ses_1", timeoutMs: 99 * 60 * 60 * 1000 }),
|
|
121
|
+
).toThrow();
|
|
76
122
|
});
|
|
77
123
|
|
|
78
|
-
test("
|
|
79
|
-
expect(parseParams("session.
|
|
80
|
-
expect(() => parseParams("session.
|
|
124
|
+
test("message kinds are closed", () => {
|
|
125
|
+
expect(parseParams("session.sendMessage", { id: "s", outcome: "approved" }).summary).toBe("");
|
|
126
|
+
expect(() => parseParams("session.sendMessage", { id: "s", outcome: "lgtm" })).toThrow(
|
|
127
|
+
/outcome/,
|
|
128
|
+
);
|
|
81
129
|
});
|
|
82
130
|
|
|
83
131
|
test("annotation kinds stay open (extension kinds are allowed)", () => {
|
|
84
|
-
|
|
132
|
+
// Act
|
|
133
|
+
const params = parseParams("session.annotate", {
|
|
85
134
|
id: "s",
|
|
86
135
|
annotation: { id: "a1", kind: "praise", anchor: { quote: "x" }, body: "nice" },
|
|
87
136
|
});
|
|
88
|
-
|
|
89
|
-
|
|
137
|
+
|
|
138
|
+
// Assert
|
|
139
|
+
expect(params.annotation.kind).toBe("praise");
|
|
140
|
+
expect(params.annotation.anchor.prefix).toBe("");
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test("setViewed takes a full path list and rejects non-string entries", () => {
|
|
144
|
+
expect(
|
|
145
|
+
parseParams("session.setViewed", { id: "s", viewedPaths: ["src/a.ts", "src/b.ts"] })
|
|
146
|
+
.viewedPaths,
|
|
147
|
+
).toEqual(["src/a.ts", "src/b.ts"]);
|
|
148
|
+
expect(parseParams("session.setViewed", { id: "s", viewedPaths: [] }).viewedPaths).toEqual([]);
|
|
149
|
+
expect(() => parseParams("session.setViewed", { id: "s", viewedPaths: [1] })).toThrow(
|
|
150
|
+
/viewedPaths/,
|
|
151
|
+
);
|
|
152
|
+
expect(() => parseParams("session.setViewed", { id: "s" })).toThrow(/viewedPaths/);
|
|
90
153
|
});
|
|
91
154
|
|
|
92
155
|
test("null params are treated as empty", () => {
|
|
@@ -94,7 +157,7 @@ describe("parseParams", () => {
|
|
|
94
157
|
});
|
|
95
158
|
});
|
|
96
159
|
|
|
97
|
-
describe("
|
|
160
|
+
describe("validateThreadRecord", () => {
|
|
98
161
|
const record = {
|
|
99
162
|
schemaVersion: SCHEMA_VERSION,
|
|
100
163
|
id: "ses_1",
|
|
@@ -102,72 +165,227 @@ describe("validateSessionRecord", () => {
|
|
|
102
165
|
artifact: { type: "plan", content: "# P", meta: {} },
|
|
103
166
|
revisions: [{ revision: 1, content: "# P", submittedAt: "now" }],
|
|
104
167
|
annotations: [],
|
|
105
|
-
|
|
168
|
+
message: null,
|
|
106
169
|
status: "pending",
|
|
107
170
|
createdAt: "now",
|
|
108
171
|
};
|
|
109
172
|
|
|
110
173
|
test("accepts a valid record", () => {
|
|
111
|
-
expect(
|
|
174
|
+
expect(validateThreadRecord(record).ok).toBe(true);
|
|
112
175
|
});
|
|
113
176
|
|
|
114
177
|
test("rejects a foreign schema version with a readable reason", () => {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
178
|
+
// Act
|
|
179
|
+
const result = validateThreadRecord({ ...record, schemaVersion: "99" });
|
|
180
|
+
|
|
181
|
+
// Assert
|
|
182
|
+
expect(result.ok).toBe(false);
|
|
183
|
+
if (!result.ok) expect(result.error).toContain("schemaVersion");
|
|
118
184
|
});
|
|
119
185
|
|
|
120
186
|
test("rejects a structurally broken record", () => {
|
|
121
|
-
|
|
122
|
-
|
|
187
|
+
// Act
|
|
188
|
+
const result = validateThreadRecord({ ...record, revisions: "nope" });
|
|
189
|
+
|
|
190
|
+
// Assert
|
|
191
|
+
expect(result.ok).toBe(false);
|
|
123
192
|
});
|
|
124
193
|
});
|
|
125
194
|
|
|
126
195
|
/**
|
|
127
|
-
* Wire pins
|
|
196
|
+
* Wire pins: every schema's entries must cover exactly the keys of the
|
|
128
197
|
* schema type it mirrors. Runtime complement to the compile-time EntriesOf
|
|
129
198
|
* check - the samples are fully populated and typed, so a new field in
|
|
130
199
|
* @cueloop/schema shows up here too.
|
|
131
200
|
*/
|
|
132
201
|
describe("wire pins", () => {
|
|
133
|
-
const keys = (
|
|
202
|
+
const keys = <Subject extends object>(subject: Subject) => Object.keys(subject).sort();
|
|
134
203
|
const entryKeys = (schema: { entries: object }) => Object.keys(schema.entries).sort();
|
|
135
204
|
|
|
136
205
|
const fullMeta: Required<ArtifactMeta> = {
|
|
206
|
+
workflow: "plan",
|
|
137
207
|
cwd: "/repo",
|
|
208
|
+
vcs: "jj",
|
|
209
|
+
vcsChangeId: "change",
|
|
210
|
+
vcsRevisionId: "revision",
|
|
138
211
|
agent: "claude-code",
|
|
139
212
|
agentSessionId: "sess-1",
|
|
140
213
|
planPath: "/repo/plan.md",
|
|
214
|
+
prototypePath: "/repo/proto.html",
|
|
141
215
|
pr: "org/repo#1",
|
|
216
|
+
prBrief: "# PR",
|
|
217
|
+
prBaseSha: "base",
|
|
218
|
+
prHeadSha: "head",
|
|
219
|
+
prRefreshBaseSha: "next-base",
|
|
220
|
+
prRefreshHeadSha: "next",
|
|
221
|
+
prUrl: "https://github.com/org/repo/pull/1",
|
|
142
222
|
herdrPane: "%7",
|
|
143
223
|
title: "Plan",
|
|
224
|
+
workbench: false,
|
|
225
|
+
snapshot: false,
|
|
226
|
+
};
|
|
227
|
+
const fullAnchor: Required<Anchor> = {
|
|
228
|
+
quote: "q",
|
|
229
|
+
prefix: "p",
|
|
230
|
+
suffix: "s",
|
|
231
|
+
blockIndex: 0,
|
|
232
|
+
endBlockIndex: 0,
|
|
233
|
+
start: 0,
|
|
234
|
+
end: 1,
|
|
235
|
+
selector: "div.card",
|
|
144
236
|
};
|
|
145
|
-
const fullAnchor: Required<Anchor> = { quote: "q", prefix: "p", suffix: "s", blockIndex: 0, start: 0, end: 1 };
|
|
146
237
|
const fullAnnotation: Required<Annotation> = {
|
|
147
238
|
id: "a1",
|
|
148
239
|
kind: "comment",
|
|
149
240
|
anchor: fullAnchor,
|
|
241
|
+
target: { kind: "file", path: "src/x.ts", rev: "worktree" },
|
|
150
242
|
body: "b",
|
|
151
243
|
orphan: false,
|
|
244
|
+
author: "SHA256:abc",
|
|
245
|
+
reviewComment: {
|
|
246
|
+
severity: "p1",
|
|
247
|
+
title: "Finding",
|
|
248
|
+
path: "src/x.ts",
|
|
249
|
+
line: 1,
|
|
250
|
+
startLine: 1,
|
|
251
|
+
startAnchor: fullAnchor,
|
|
252
|
+
side: "RIGHT",
|
|
253
|
+
suggestion: "replacement",
|
|
254
|
+
prompt: "fix it",
|
|
255
|
+
},
|
|
256
|
+
replyTo: "a0",
|
|
257
|
+
resolution: { revision: 2, source: "agent" },
|
|
152
258
|
createdAt: "now",
|
|
153
259
|
};
|
|
154
|
-
const fullArtifact: Required<Artifact> = {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
260
|
+
const fullArtifact: Required<Artifact> = {
|
|
261
|
+
type: "plan",
|
|
262
|
+
content: "# P",
|
|
263
|
+
meta: fullMeta,
|
|
264
|
+
files: [{ path: "src/a.ts", oldContents: "old\n", newContents: "new\n", status: "modified" }],
|
|
265
|
+
};
|
|
266
|
+
const fullMessage: Required<Message> = {
|
|
267
|
+
id: "msg_1",
|
|
268
|
+
outcome: "approved",
|
|
269
|
+
summary: "",
|
|
270
|
+
body: "",
|
|
271
|
+
annotations: [fullAnnotation],
|
|
272
|
+
sentAt: "now",
|
|
273
|
+
};
|
|
274
|
+
const fullRevision: Required<Revision> = {
|
|
275
|
+
revision: 1,
|
|
276
|
+
content: "# P",
|
|
277
|
+
submittedAt: "now",
|
|
278
|
+
source: { vcs: "jj", changeId: "change", revisionId: "revision" },
|
|
279
|
+
files: [{ path: "a.ts", oldContents: "a", newContents: "b", status: "modified" }],
|
|
280
|
+
};
|
|
281
|
+
const fullWorkspace: Required<WorkspaceKey> = {
|
|
282
|
+
repoRoot: "/repo",
|
|
283
|
+
branch: "main",
|
|
284
|
+
rootCommit: "11e7abbcf507a13ae5e4e7559c4b42dbb52237fe",
|
|
285
|
+
remote: "git@github.com:acme/repo.git",
|
|
286
|
+
};
|
|
287
|
+
const fullIdentity: Required<Identity> = {
|
|
288
|
+
id: "SHA256:abc",
|
|
289
|
+
provider: "ssh",
|
|
290
|
+
name: "Al",
|
|
291
|
+
handle: "abc",
|
|
292
|
+
};
|
|
293
|
+
const fullSession: Required<Thread> = {
|
|
159
294
|
schemaVersion: SCHEMA_VERSION,
|
|
160
295
|
id: "ses_1",
|
|
161
296
|
workspace: fullWorkspace,
|
|
162
297
|
artifact: fullArtifact,
|
|
163
298
|
revisions: [fullRevision],
|
|
164
299
|
annotations: [fullAnnotation],
|
|
165
|
-
|
|
166
|
-
|
|
300
|
+
history: {
|
|
301
|
+
entries: [
|
|
302
|
+
{
|
|
303
|
+
id: "e1",
|
|
304
|
+
parentId: null,
|
|
305
|
+
type: "revision",
|
|
306
|
+
by: "agent",
|
|
307
|
+
content: "# P",
|
|
308
|
+
createdAt: "now",
|
|
309
|
+
},
|
|
310
|
+
{ id: "e2", parentId: "e1", type: "comment", annotationId: "a1", createdAt: "now" },
|
|
311
|
+
{ id: "e3", parentId: "e2", type: "comment-removed", annotationId: "a1", createdAt: "now" },
|
|
312
|
+
{ id: "e4", parentId: "e3", type: "message", message: fullMessage, createdAt: "now" },
|
|
313
|
+
{
|
|
314
|
+
id: "e5",
|
|
315
|
+
parentId: "e4",
|
|
316
|
+
type: "branch-summary",
|
|
317
|
+
text: "tried a thing",
|
|
318
|
+
abandoned: ["e3"],
|
|
319
|
+
createdAt: "now",
|
|
320
|
+
},
|
|
321
|
+
],
|
|
322
|
+
tips: { main: "e5" },
|
|
323
|
+
branch: "main",
|
|
324
|
+
labels: { e1: "start" },
|
|
325
|
+
},
|
|
326
|
+
curation: [{ path: "src/a.ts", hunkIndex: 0, changeIndex: 1 }],
|
|
327
|
+
shelvedAnnotations: [fullAnnotation],
|
|
328
|
+
parentSessionId: "ses_0",
|
|
329
|
+
shareBranch: "main",
|
|
330
|
+
workingCopy: "# ",
|
|
331
|
+
textCuts: [{ start: 2, end: 3, quote: "P" }],
|
|
332
|
+
viewedPaths: ["src/a.ts"],
|
|
333
|
+
message: fullMessage,
|
|
167
334
|
status: "pending",
|
|
168
335
|
createdAt: "now",
|
|
336
|
+
shares: [
|
|
337
|
+
{
|
|
338
|
+
id: "p_abc123xy",
|
|
339
|
+
name: "review link",
|
|
340
|
+
requireAuth: true,
|
|
341
|
+
allowlist: ["octocat"],
|
|
342
|
+
owner: "SHA256:owner",
|
|
343
|
+
shareBranch: "main",
|
|
344
|
+
},
|
|
345
|
+
],
|
|
346
|
+
shareId: "p_abc123xy",
|
|
347
|
+
owner: "SHA256:owner",
|
|
348
|
+
access: { githubLogins: ["octocat"] },
|
|
349
|
+
participants: [fullIdentity],
|
|
169
350
|
};
|
|
170
351
|
|
|
352
|
+
test("a history whose tree is broken is refused even when every entry is well-formed", () => {
|
|
353
|
+
// Arrange: a parent cycle
|
|
354
|
+
const record = {
|
|
355
|
+
...fullSession,
|
|
356
|
+
history: {
|
|
357
|
+
entries: [
|
|
358
|
+
{ id: "a", parentId: "b", type: "revision", by: "agent", content: "x", createdAt: "now" },
|
|
359
|
+
{ id: "b", parentId: "a", type: "comment", annotationId: "a1", createdAt: "now" },
|
|
360
|
+
],
|
|
361
|
+
tips: { main: "b" },
|
|
362
|
+
branch: "main",
|
|
363
|
+
labels: {},
|
|
364
|
+
},
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
// Act
|
|
368
|
+
const parsed = validateThreadRecord(record);
|
|
369
|
+
|
|
370
|
+
// Assert
|
|
371
|
+
expect(parsed.ok).toBe(false);
|
|
372
|
+
if (!parsed.ok) expect(parsed.error).toContain("history:");
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
test("a persisted Thread with stale text Cut provenance is refused", () => {
|
|
376
|
+
const result = validateThreadRecord({
|
|
377
|
+
...fullSession,
|
|
378
|
+
workingCopy: "# P",
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
expect(result.ok).toBe(false);
|
|
382
|
+
if (!result.ok) {
|
|
383
|
+
expect(result.error).toContain(
|
|
384
|
+
"text Cuts do not match the submitted artifact and working copy",
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
|
|
171
389
|
test("schema key sets match the schema types", () => {
|
|
172
390
|
expect(entryKeys(WorkspaceSchema)).toEqual(keys(fullWorkspace));
|
|
173
391
|
expect(entryKeys(ArtifactMetaSchema)).toEqual(keys(fullMeta));
|
|
@@ -175,27 +393,54 @@ describe("wire pins", () => {
|
|
|
175
393
|
expect(entryKeys(AnchorSchema)).toEqual(keys(fullAnchor));
|
|
176
394
|
// wire annotations arrive without createdAt; the daemon stamps it
|
|
177
395
|
const { createdAt: _stamped, ...wireAnnotation } = fullAnnotation;
|
|
396
|
+
|
|
178
397
|
expect(entryKeys(AnnotationSchema)).toEqual(keys(wireAnnotation));
|
|
179
398
|
expect(entryKeys(RevisionSchema)).toEqual(keys(fullRevision));
|
|
180
|
-
expect(entryKeys(
|
|
181
|
-
expect(entryKeys(
|
|
399
|
+
expect(entryKeys(MessageSchema)).toEqual(keys(fullMessage));
|
|
400
|
+
expect(entryKeys(IdentitySchema)).toEqual(keys(fullIdentity));
|
|
401
|
+
expect(entryKeys(ThreadRecordSchema)).toEqual(keys(fullSession));
|
|
182
402
|
// persisted annotations carry the stamped createdAt
|
|
183
|
-
const stored =
|
|
403
|
+
const stored = ThreadRecordSchema.entries.annotations.item;
|
|
404
|
+
|
|
184
405
|
expect(entryKeys(stored)).toEqual(keys(fullAnnotation));
|
|
185
406
|
});
|
|
186
407
|
|
|
187
408
|
test("a fully-populated meta survives validation and DaemonCore unchanged", () => {
|
|
188
409
|
const home = mkdtempSync(join(tmpdir(), "cueloop-val-"));
|
|
410
|
+
|
|
189
411
|
try {
|
|
412
|
+
// Arrange
|
|
190
413
|
const params = parseParams("session.create", {
|
|
191
414
|
workspace: fullWorkspace,
|
|
192
415
|
artifact: { type: "plan", content: "# P", meta: fullMeta },
|
|
193
416
|
});
|
|
194
417
|
const core = new DaemonCore(home);
|
|
418
|
+
|
|
419
|
+
// Act
|
|
195
420
|
const created = core.sessionCreate(params);
|
|
421
|
+
|
|
422
|
+
// Assert
|
|
196
423
|
expect(core.sessionGet(created.id).artifact.meta).toEqual(fullMeta);
|
|
197
424
|
} finally {
|
|
198
425
|
rmSync(home, { recursive: true, force: true });
|
|
199
426
|
}
|
|
200
427
|
});
|
|
201
428
|
});
|
|
429
|
+
|
|
430
|
+
describe("IdentitySchema provider", () => {
|
|
431
|
+
test("accepts a verified github identity", () => {
|
|
432
|
+
const parsed = v.safeParse(IdentitySchema, {
|
|
433
|
+
id: "SHA256:abc",
|
|
434
|
+
provider: "github",
|
|
435
|
+
name: "markus",
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
expect(parsed.success).toBe(true);
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
test("rejects an unknown provider", () => {
|
|
442
|
+
const parsed = v.safeParse(IdentitySchema, { id: "SHA256:abc", provider: "email" });
|
|
443
|
+
|
|
444
|
+
expect(parsed.success).toBe(false);
|
|
445
|
+
});
|
|
446
|
+
});
|