@claudexor/daemon 1.0.0 → 2.1.2
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/dist/client.d.ts +29 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +24 -4
- package/dist/client.js.map +1 -1
- package/dist/command-authority.d.ts +11 -0
- package/dist/command-authority.d.ts.map +1 -0
- package/dist/command-authority.js +15 -0
- package/dist/command-authority.js.map +1 -0
- package/dist/command-retention.d.ts +5 -0
- package/dist/command-retention.d.ts.map +1 -0
- package/dist/command-retention.js +18 -0
- package/dist/command-retention.js.map +1 -0
- package/dist/command-store.d.ts +41 -0
- package/dist/command-store.d.ts.map +1 -0
- package/dist/command-store.js +197 -0
- package/dist/command-store.js.map +1 -0
- package/dist/events.d.ts +2 -3
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +2 -3
- package/dist/events.js.map +1 -1
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/dist/interactions.d.ts +32 -22
- package/dist/interactions.d.ts.map +1 -1
- package/dist/interactions.js +183 -56
- package/dist/interactions.js.map +1 -1
- package/dist/journal-events.d.ts +4 -0
- package/dist/journal-events.d.ts.map +1 -0
- package/dist/journal-events.js +23 -0
- package/dist/journal-events.js.map +1 -0
- package/dist/journal-manager.d.ts +72 -0
- package/dist/journal-manager.d.ts.map +1 -0
- package/dist/journal-manager.js +463 -0
- package/dist/journal-manager.js.map +1 -0
- package/dist/journal-projection.d.ts +11 -0
- package/dist/journal-projection.d.ts.map +1 -0
- package/dist/journal-projection.js +2 -0
- package/dist/journal-projection.js.map +1 -0
- package/dist/journal-recovery-files.d.ts +27 -0
- package/dist/journal-recovery-files.d.ts.map +1 -0
- package/dist/journal-recovery-files.js +209 -0
- package/dist/journal-recovery-files.js.map +1 -0
- package/dist/operator-decisions.d.ts +30 -0
- package/dist/operator-decisions.d.ts.map +1 -0
- package/dist/operator-decisions.js +137 -0
- package/dist/operator-decisions.js.map +1 -0
- package/dist/project-partitions.d.ts +167 -0
- package/dist/project-partitions.d.ts.map +1 -0
- package/dist/project-partitions.js +365 -0
- package/dist/project-partitions.js.map +1 -0
- package/dist/projects.d.ts +29 -0
- package/dist/projects.d.ts.map +1 -0
- package/dist/projects.js +180 -0
- package/dist/projects.js.map +1 -0
- package/dist/quota-registry.d.ts +75 -0
- package/dist/quota-registry.d.ts.map +1 -0
- package/dist/quota-registry.js +208 -0
- package/dist/quota-registry.js.map +1 -0
- package/dist/resource-store.d.ts +22 -0
- package/dist/resource-store.d.ts.map +1 -0
- package/dist/resource-store.js +272 -0
- package/dist/resource-store.js.map +1 -0
- package/dist/run-events.d.ts +15 -0
- package/dist/run-events.d.ts.map +1 -0
- package/dist/run-events.js +29 -0
- package/dist/run-events.js.map +1 -0
- package/dist/server.d.ts +33 -33
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +231 -238
- package/dist/server.js.map +1 -1
- package/dist/spec-sessions.d.ts +72 -0
- package/dist/spec-sessions.d.ts.map +1 -0
- package/dist/spec-sessions.js +301 -0
- package/dist/spec-sessions.js.map +1 -0
- package/dist/terminate.d.ts +52 -0
- package/dist/terminate.d.ts.map +1 -0
- package/dist/terminate.js +111 -0
- package/dist/terminate.js.map +1 -0
- package/dist/thread-head-ping.d.ts +35 -0
- package/dist/thread-head-ping.d.ts.map +1 -0
- package/dist/thread-head-ping.js +67 -0
- package/dist/thread-head-ping.js.map +1 -0
- package/dist/thread-lifecycle.d.ts +5 -0
- package/dist/thread-lifecycle.d.ts.map +1 -0
- package/dist/thread-lifecycle.js +57 -0
- package/dist/thread-lifecycle.js.map +1 -0
- package/dist/thread-store-support.d.ts +37 -0
- package/dist/thread-store-support.d.ts.map +1 -0
- package/dist/thread-store-support.js +94 -0
- package/dist/thread-store-support.js.map +1 -0
- package/dist/threads.d.ts +59 -13
- package/dist/threads.d.ts.map +1 -1
- package/dist/threads.js +254 -141
- package/dist/threads.js.map +1 -1
- package/dist/token.d.ts +13 -4
- package/dist/token.d.ts.map +1 -1
- package/dist/token.js +134 -29
- package/dist/token.js.map +1 -1
- package/dist/writer-lease.d.ts +21 -0
- package/dist/writer-lease.d.ts.map +1 -0
- package/dist/writer-lease.js +94 -0
- package/dist/writer-lease.js.map +1 -0
- package/package.json +5 -4
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { hashJson, newId, nowIso } from "@claudexor/util";
|
|
2
|
+
import { commandProjection } from "./command-store.js";
|
|
3
|
+
import { JournalManager } from "./journal-manager.js";
|
|
4
|
+
import { interactionProjection } from "./interactions.js";
|
|
5
|
+
import { operatorDecisionProjection, } from "./operator-decisions.js";
|
|
6
|
+
import { runEventProjection } from "./run-events.js";
|
|
7
|
+
import { specSessionProjection } from "./spec-sessions.js";
|
|
8
|
+
import { threadProjection, } from "./threads.js";
|
|
9
|
+
export class ProjectPartitions {
|
|
10
|
+
rootDir;
|
|
11
|
+
projects;
|
|
12
|
+
globalCommands;
|
|
13
|
+
globalInteractions;
|
|
14
|
+
globalDecisions;
|
|
15
|
+
globalRunEvents;
|
|
16
|
+
globalThreads;
|
|
17
|
+
headPing;
|
|
18
|
+
partitions = new Map();
|
|
19
|
+
constructor(rootDir, projects, globalCommands, globalInteractions, globalDecisions, globalRunEvents, globalThreads,
|
|
20
|
+
/** Global-partition `thread.head.updated` sink, threaded into every project ThreadStore. */
|
|
21
|
+
headPing) {
|
|
22
|
+
this.rootDir = rootDir;
|
|
23
|
+
this.projects = projects;
|
|
24
|
+
this.globalCommands = globalCommands;
|
|
25
|
+
this.globalInteractions = globalInteractions;
|
|
26
|
+
this.globalDecisions = globalDecisions;
|
|
27
|
+
this.globalRunEvents = globalRunEvents;
|
|
28
|
+
this.globalThreads = globalThreads;
|
|
29
|
+
this.headPing = headPing;
|
|
30
|
+
this.sync();
|
|
31
|
+
}
|
|
32
|
+
all() {
|
|
33
|
+
return [
|
|
34
|
+
this.globalCommands.current(),
|
|
35
|
+
...this.healthy().map((entry) => entry.commands.current()),
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
interactionStores() {
|
|
39
|
+
return [
|
|
40
|
+
this.globalInteractions.current(),
|
|
41
|
+
...this.healthy().map((entry) => entry.interactions.current()),
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
interactionsForRequest(params) {
|
|
45
|
+
const commandStore = this.forRequest(params);
|
|
46
|
+
if (commandStore === this.globalCommands.current())
|
|
47
|
+
return this.globalInteractions.current();
|
|
48
|
+
const entry = this.healthy().find((candidate) => candidate.commands.current() === commandStore);
|
|
49
|
+
if (!entry)
|
|
50
|
+
throw new Error("command partition has no interaction authority");
|
|
51
|
+
return entry.interactions.current();
|
|
52
|
+
}
|
|
53
|
+
operatorDecision(params, runId) {
|
|
54
|
+
return this.decisionStoreForRequest(params).get(runId);
|
|
55
|
+
}
|
|
56
|
+
recordOperatorDecision(params, decision, idempotency) {
|
|
57
|
+
return this.decisionStoreForRequest(params).record(decision, idempotency);
|
|
58
|
+
}
|
|
59
|
+
recordRunEvent(params, event) {
|
|
60
|
+
return this.runEventStoreForRequest(params).record(event);
|
|
61
|
+
}
|
|
62
|
+
specsForRequest(params) {
|
|
63
|
+
const input = record(params);
|
|
64
|
+
const scope = record(input.scope);
|
|
65
|
+
if (scope.kind !== "project")
|
|
66
|
+
throw Object.assign(new Error("spec sessions require a project"), { status: 400 });
|
|
67
|
+
return this.partitionForRoot(stringField(scope, "root")).specs.current();
|
|
68
|
+
}
|
|
69
|
+
specStoreForSession(id) {
|
|
70
|
+
return this.healthy()
|
|
71
|
+
.map((entry) => entry.specs.current())
|
|
72
|
+
.find((store) => store.get(id));
|
|
73
|
+
}
|
|
74
|
+
listSpecSessions() {
|
|
75
|
+
return this.healthy().flatMap((entry) => entry.specs.current().list());
|
|
76
|
+
}
|
|
77
|
+
forRequest(params) {
|
|
78
|
+
const input = record(params);
|
|
79
|
+
const threadId = stringField(input, "threadId");
|
|
80
|
+
if (threadId) {
|
|
81
|
+
const store = this.threadStoreForThread(threadId);
|
|
82
|
+
if (store)
|
|
83
|
+
return this.commandStoreForThreadStore(store);
|
|
84
|
+
}
|
|
85
|
+
const scope = record(input.scope);
|
|
86
|
+
if (scope.kind !== "project")
|
|
87
|
+
return this.globalCommands.current();
|
|
88
|
+
const root = stringField(scope, "root");
|
|
89
|
+
return this.partitionForRoot(root).commands.current();
|
|
90
|
+
}
|
|
91
|
+
findById(id) {
|
|
92
|
+
return this.all().find((store) => store.get(id));
|
|
93
|
+
}
|
|
94
|
+
beginDelivery(params, input) {
|
|
95
|
+
const store = this.forRequest(params);
|
|
96
|
+
const accepted = store.accept({
|
|
97
|
+
id: newId("delivery"),
|
|
98
|
+
params,
|
|
99
|
+
idempotencyKey: input.key,
|
|
100
|
+
clientId: input.client,
|
|
101
|
+
operation: `delivery.${input.operation}`,
|
|
102
|
+
idempotencyParams: input.request,
|
|
103
|
+
});
|
|
104
|
+
const record = accepted.reused
|
|
105
|
+
? accepted.record
|
|
106
|
+
: store.update(accepted.record.id, { state: "running", startedAt: nowIso() });
|
|
107
|
+
return { ...record, reused: accepted.reused };
|
|
108
|
+
}
|
|
109
|
+
completeDelivery(id, result) {
|
|
110
|
+
const store = this.findById(id);
|
|
111
|
+
if (!store)
|
|
112
|
+
throw new Error(`delivery authority lost command ${id}`);
|
|
113
|
+
store.update(id, { state: "succeeded", result, finishedAt: nowIso() });
|
|
114
|
+
}
|
|
115
|
+
failDelivery(id, error) {
|
|
116
|
+
const store = this.findById(id);
|
|
117
|
+
if (!store)
|
|
118
|
+
throw new Error(`delivery authority lost command ${id}`);
|
|
119
|
+
const value = error && typeof error === "object" ? error : {};
|
|
120
|
+
store.update(id, {
|
|
121
|
+
state: "failed",
|
|
122
|
+
error: error instanceof Error ? error.message : String(error),
|
|
123
|
+
errorCode: typeof value["code"] === "string" ? value["code"] : undefined,
|
|
124
|
+
result: {
|
|
125
|
+
status: typeof value["status"] === "number" ? value["status"] : 500,
|
|
126
|
+
code: typeof value["code"] === "string" ? value["code"] : null,
|
|
127
|
+
},
|
|
128
|
+
finishedAt: nowIso(),
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
registerProject(input) {
|
|
132
|
+
const project = this.projects.current().register(input);
|
|
133
|
+
this.ensure(project.id);
|
|
134
|
+
return project;
|
|
135
|
+
}
|
|
136
|
+
relinkProject(id, root) {
|
|
137
|
+
const project = this.projects.current().relink(id, root);
|
|
138
|
+
this.ensure(id).threads.current().relinkProjectRoot(project.root);
|
|
139
|
+
return project;
|
|
140
|
+
}
|
|
141
|
+
journal(partition) {
|
|
142
|
+
if (!partition.startsWith("project:"))
|
|
143
|
+
throw unknownPartition(partition);
|
|
144
|
+
const id = partition.slice("project:".length);
|
|
145
|
+
if (!id || !this.projects.current().get(id))
|
|
146
|
+
throw unknownPartition(partition);
|
|
147
|
+
return this.ensure(id).manager;
|
|
148
|
+
}
|
|
149
|
+
createThread(input) {
|
|
150
|
+
if (input.repoRoot && !this.projects.current().findByRoot(input.repoRoot)) {
|
|
151
|
+
this.registerProject({
|
|
152
|
+
root: input.repoRoot,
|
|
153
|
+
idempotencyKey: `thread-auto-register-${hashJson(input.repoRoot)}`,
|
|
154
|
+
clientId: "thread-create",
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
return this.threadStoreForRoot(input.repoRoot).createThread(input);
|
|
158
|
+
}
|
|
159
|
+
listThreads() {
|
|
160
|
+
// Each store sorts ITS threads by recency, but the stores concatenate —
|
|
161
|
+
// without a merge-sort a fresh project thread lands below every global
|
|
162
|
+
// one (dogfood: the fresh thread sank to the bottom). One global recency order.
|
|
163
|
+
return this.threadStores()
|
|
164
|
+
.flatMap((store) => store.listThreads())
|
|
165
|
+
.sort((a, b) => (a.updated_at < b.updated_at ? 1 : a.updated_at > b.updated_at ? -1 : 0));
|
|
166
|
+
}
|
|
167
|
+
getThread(id) {
|
|
168
|
+
return this.threadStoreForThread(id)?.getThread(id);
|
|
169
|
+
}
|
|
170
|
+
turnsFor(id) {
|
|
171
|
+
return this.threadStoreForThread(id)?.turnsFor(id) ?? [];
|
|
172
|
+
}
|
|
173
|
+
sessionsForThread(id) {
|
|
174
|
+
return this.threadStoreForThread(id)?.sessionsForThread(id) ?? [];
|
|
175
|
+
}
|
|
176
|
+
createTurn(id, prompt, input = {}) {
|
|
177
|
+
return this.requireThreadStore(id).createTurn(id, prompt, input);
|
|
178
|
+
}
|
|
179
|
+
updateThread(id, patch) {
|
|
180
|
+
return this.requireThreadStore(id).updateThread(id, patch);
|
|
181
|
+
}
|
|
182
|
+
trashThread(id) {
|
|
183
|
+
return this.requireThreadStore(id).trashThread(id);
|
|
184
|
+
}
|
|
185
|
+
restoreThread(id) {
|
|
186
|
+
return this.requireThreadStore(id).restoreThread(id);
|
|
187
|
+
}
|
|
188
|
+
purgeThread(id) {
|
|
189
|
+
return this.requireThreadStore(id).purgeThread(id);
|
|
190
|
+
}
|
|
191
|
+
setThreadWorktree(id, path, baseSha, deliveredThroughRunId) {
|
|
192
|
+
this.requireThreadStore(id).setThreadWorktree(id, path, baseSha, deliveredThroughRunId);
|
|
193
|
+
}
|
|
194
|
+
assertKnownIds(threadId, turnId) {
|
|
195
|
+
const id = typeof threadId === "string" && threadId ? threadId : undefined;
|
|
196
|
+
const turn = typeof turnId === "string" && turnId ? turnId : undefined;
|
|
197
|
+
const store = id
|
|
198
|
+
? this.requireThreadStore(id)
|
|
199
|
+
: turn
|
|
200
|
+
? this.requireTurnStore(turn)
|
|
201
|
+
: this.globalThreads.current();
|
|
202
|
+
return store.assertKnownIds(threadId, turnId);
|
|
203
|
+
}
|
|
204
|
+
getTurn(id) {
|
|
205
|
+
return this.threadStoreForTurn(id)?.getTurn(id);
|
|
206
|
+
}
|
|
207
|
+
bindTurnRun(id, runId) {
|
|
208
|
+
this.requireTurnStore(id).bindTurnRun(id, runId);
|
|
209
|
+
}
|
|
210
|
+
setTurnEnqueueError(id, message, code = null, retryable = true) {
|
|
211
|
+
this.requireTurnStore(id).setTurnEnqueueError(id, message, code, retryable);
|
|
212
|
+
}
|
|
213
|
+
resumeMap(id, profileId = null) {
|
|
214
|
+
return this.requireThreadStore(id).resumeMap(id, profileId);
|
|
215
|
+
}
|
|
216
|
+
recordSession(id, harnessId, nativeSessionId, observedModel, profileId = null) {
|
|
217
|
+
this.requireThreadStore(id).recordSession(id, harnessId, nativeSessionId, observedModel, profileId);
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Run-terminal invalidation (the W12 path with no store mutation to ride):
|
|
221
|
+
* a terminal changes the thread's presented state (needs-me, outcome), so
|
|
222
|
+
* the daemon pings the owning store's head directly.
|
|
223
|
+
*/
|
|
224
|
+
pingThreadHead(id) {
|
|
225
|
+
this.threadStoreForThread(id)?.pingHead(id);
|
|
226
|
+
}
|
|
227
|
+
close() {
|
|
228
|
+
for (const entry of this.partitions.values())
|
|
229
|
+
entry.manager.close();
|
|
230
|
+
this.partitions.clear();
|
|
231
|
+
}
|
|
232
|
+
sync() {
|
|
233
|
+
const ids = new Set(this.projects
|
|
234
|
+
.current()
|
|
235
|
+
.list()
|
|
236
|
+
.map((project) => project.id));
|
|
237
|
+
for (const id of ids)
|
|
238
|
+
this.ensure(id);
|
|
239
|
+
for (const [id, entry] of this.partitions) {
|
|
240
|
+
if (ids.has(id))
|
|
241
|
+
continue;
|
|
242
|
+
entry.manager.close();
|
|
243
|
+
this.partitions.delete(id);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
ensure(projectId) {
|
|
247
|
+
const existing = this.partitions.get(projectId);
|
|
248
|
+
if (existing)
|
|
249
|
+
return existing;
|
|
250
|
+
const manager = new JournalManager(this.rootDir, { partition: `project:${projectId}` });
|
|
251
|
+
const commands = manager.registerProjection(commandProjection());
|
|
252
|
+
const interactions = manager.registerProjection(interactionProjection());
|
|
253
|
+
const decisions = manager.registerProjection(operatorDecisionProjection());
|
|
254
|
+
const runEvents = manager.registerProjection(runEventProjection());
|
|
255
|
+
const specs = manager.registerProjection(specSessionProjection());
|
|
256
|
+
const threads = manager.registerProjection(threadProjection(this.headPing));
|
|
257
|
+
manager.start();
|
|
258
|
+
const entry = { manager, commands, interactions, decisions, runEvents, specs, threads };
|
|
259
|
+
this.partitions.set(projectId, entry);
|
|
260
|
+
return entry;
|
|
261
|
+
}
|
|
262
|
+
healthy() {
|
|
263
|
+
this.sync();
|
|
264
|
+
return [...this.partitions.values()].filter((entry) => entry.manager.ready());
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Canonical roots whose partition journal is READY — the set whose thread
|
|
268
|
+
* lineage / job records are trustworthy. Retention (W3.6) fails CLOSED on a
|
|
269
|
+
* quarantined partition: its runs are protected, never GC'd against an empty
|
|
270
|
+
* reference set (a non-ready partition contributes nothing to listThreads,
|
|
271
|
+
* so its referenced runs would otherwise look unreferenced).
|
|
272
|
+
*/
|
|
273
|
+
healthyProjectRoots() {
|
|
274
|
+
this.sync();
|
|
275
|
+
const registry = this.projects.current();
|
|
276
|
+
const roots = [];
|
|
277
|
+
for (const [id, entry] of this.partitions) {
|
|
278
|
+
if (!entry.manager.ready())
|
|
279
|
+
continue;
|
|
280
|
+
const root = registry.get(id)?.root;
|
|
281
|
+
if (root)
|
|
282
|
+
roots.push(root);
|
|
283
|
+
}
|
|
284
|
+
return roots;
|
|
285
|
+
}
|
|
286
|
+
partitionForRoot(root) {
|
|
287
|
+
const project = this.projects.current().findByRoot(root);
|
|
288
|
+
if (!project) {
|
|
289
|
+
throw Object.assign(new Error(`project is not registered: ${root}`), {
|
|
290
|
+
code: "project_not_registered",
|
|
291
|
+
status: 404,
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
return this.ensure(project.id);
|
|
295
|
+
}
|
|
296
|
+
threadStores() {
|
|
297
|
+
return [
|
|
298
|
+
this.globalThreads.current(),
|
|
299
|
+
...this.healthy().map((entry) => entry.threads.current()),
|
|
300
|
+
];
|
|
301
|
+
}
|
|
302
|
+
threadStoreForRoot(root) {
|
|
303
|
+
return root ? this.partitionForRoot(root).threads.current() : this.globalThreads.current();
|
|
304
|
+
}
|
|
305
|
+
threadStoreForThread(id) {
|
|
306
|
+
return this.threadStores().find((store) => store.getThread(id));
|
|
307
|
+
}
|
|
308
|
+
threadStoreForTurn(id) {
|
|
309
|
+
return this.threadStores().find((store) => store.getTurn(id));
|
|
310
|
+
}
|
|
311
|
+
requireThreadStore(id) {
|
|
312
|
+
const store = this.threadStoreForThread(id);
|
|
313
|
+
if (!store)
|
|
314
|
+
throw Object.assign(new Error(`no such thread: ${id}`), { status: 404 });
|
|
315
|
+
return store;
|
|
316
|
+
}
|
|
317
|
+
requireTurnStore(id) {
|
|
318
|
+
const store = this.threadStoreForTurn(id);
|
|
319
|
+
if (!store)
|
|
320
|
+
throw Object.assign(new Error(`no such turn: ${id}`), { status: 404 });
|
|
321
|
+
return store;
|
|
322
|
+
}
|
|
323
|
+
commandStoreForThreadStore(store) {
|
|
324
|
+
if (store === this.globalThreads.current())
|
|
325
|
+
return this.globalCommands.current();
|
|
326
|
+
const entry = this.healthy().find((candidate) => candidate.threads.current() === store);
|
|
327
|
+
if (!entry)
|
|
328
|
+
throw new Error("thread partition has no command authority");
|
|
329
|
+
return entry.commands.current();
|
|
330
|
+
}
|
|
331
|
+
decisionStoreForRequest(params) {
|
|
332
|
+
const commands = this.forRequest(params);
|
|
333
|
+
if (commands === this.globalCommands.current())
|
|
334
|
+
return this.globalDecisions.current();
|
|
335
|
+
const entry = this.healthy().find((candidate) => candidate.commands.current() === commands);
|
|
336
|
+
if (!entry)
|
|
337
|
+
throw new Error("command partition has no operator-decision authority");
|
|
338
|
+
return entry.decisions.current();
|
|
339
|
+
}
|
|
340
|
+
runEventStoreForRequest(params) {
|
|
341
|
+
const commands = this.forRequest(params);
|
|
342
|
+
if (commands === this.globalCommands.current())
|
|
343
|
+
return this.globalRunEvents.current();
|
|
344
|
+
const entry = this.healthy().find((candidate) => candidate.commands.current() === commands);
|
|
345
|
+
if (!entry)
|
|
346
|
+
throw new Error("command partition has no run-event authority");
|
|
347
|
+
return entry.runEvents.current();
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
function record(value) {
|
|
351
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
352
|
+
? value
|
|
353
|
+
: {};
|
|
354
|
+
}
|
|
355
|
+
function stringField(value, key) {
|
|
356
|
+
const field = value[key];
|
|
357
|
+
return typeof field === "string" ? field : "";
|
|
358
|
+
}
|
|
359
|
+
function unknownPartition(partition) {
|
|
360
|
+
return Object.assign(new Error(`no such journal partition: ${partition}`), {
|
|
361
|
+
code: "journal_partition_not_found",
|
|
362
|
+
status: 404,
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
//# sourceMappingURL=project-partitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-partitions.js","sourceRoot":"","sources":["../src/project-partitions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAqB,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,cAAc,EAA8B,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAyB,MAAM,mBAAmB,CAAC;AACjF,OAAO,EACL,0BAA0B,GAG3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAsB,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAyB,MAAM,oBAAoB,CAAC;AAElF,OAAO,EACL,gBAAgB,GAMjB,MAAM,cAAc,CAAC;AAatB,MAAM,OAAO,iBAAiB;IAIT;IACA;IACA;IACA;IACA;IACA;IACA;IAEA;IAXF,UAAU,GAAG,IAAI,GAAG,EAA4B,CAAC;IAElE,YACmB,OAAe,EACf,QAA6C,EAC7C,cAAmD,EACnD,kBAA2D,EAC3D,eAA6D,EAC7D,eAAqD,EACrD,aAAiD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CAAC,EAAE,CAAC;AACT,CAAC;AAED,SAAS,WAAW,CAAC,KAA8B,EAAE,GAAW;IAC9D,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,gBAAgB,CAAC,SAAiB;IACzC,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,8BAA8B,SAAS,EAAE,CAAC,EAAE;QACzE,IAAI,EAAE,6BAA6B;QACnC,MAAM,EAAE,GAAG;KACZ,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { DurableJournal } from "@claudexor/journal";
|
|
2
|
+
import { type Project } from "@claudexor/schema";
|
|
3
|
+
/** Global-journal authority for the deliberately empty v2 project registry. */
|
|
4
|
+
export declare class ProjectStore {
|
|
5
|
+
private readonly journal;
|
|
6
|
+
private readonly projects;
|
|
7
|
+
private readonly projectIdByRoot;
|
|
8
|
+
private readonly registrationByKey;
|
|
9
|
+
constructor(journal: DurableJournal);
|
|
10
|
+
list(): Project[];
|
|
11
|
+
get(id: string): Project | undefined;
|
|
12
|
+
findByRoot(root: string): Project | undefined;
|
|
13
|
+
register(input: {
|
|
14
|
+
root: string;
|
|
15
|
+
idempotencyKey: string;
|
|
16
|
+
clientId: string;
|
|
17
|
+
}): Project;
|
|
18
|
+
relink(id: string, rootInput: string): Project;
|
|
19
|
+
validateProjection(): void;
|
|
20
|
+
private replay;
|
|
21
|
+
private commit;
|
|
22
|
+
private apply;
|
|
23
|
+
}
|
|
24
|
+
export declare function projectProjection(): {
|
|
25
|
+
name: string;
|
|
26
|
+
create: (journal: DurableJournal) => ProjectStore;
|
|
27
|
+
validate: (store: ProjectStore) => void;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=projects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projects.d.ts","sourceRoot":"","sources":["../src/projects.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAA4C,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAiB3F,+EAA+E;AAC/E,qBAAa,YAAY;IAQX,OAAO,CAAC,QAAQ,CAAC,OAAO;IAPpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA8B;IACvD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA6B;IAC7D,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAG9B;gBAEyB,OAAO,EAAE,cAAc;IAIpD,IAAI,IAAI,OAAO,EAAE;IAIjB,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAIpC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAK7C,QAAQ,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO;IAoCpF,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO;IAiB9C,kBAAkB,IAAI,IAAI;IAY1B,OAAO,CAAC,MAAM;IAQd,OAAO,CAAC,MAAM;IAMd,OAAO,CAAC,KAAK;CAmBd;AAED,wBAAgB,iBAAiB;;sBAGX,cAAc;sBACd,YAAY;EAEjC"}
|
package/dist/projects.js
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { lstatSync, realpathSync } from "node:fs";
|
|
2
|
+
import { isAbsolute } from "node:path";
|
|
3
|
+
import { Project as ProjectSchema, SCHEMA_VERSION } from "@claudexor/schema";
|
|
4
|
+
import { hashJson, newId, nowIso } from "@claudexor/util";
|
|
5
|
+
const REGISTERED = "project.registered";
|
|
6
|
+
const RELINKED = "project.relinked";
|
|
7
|
+
/** Global-journal authority for the deliberately empty v2 project registry. */
|
|
8
|
+
export class ProjectStore {
|
|
9
|
+
journal;
|
|
10
|
+
projects = new Map();
|
|
11
|
+
projectIdByRoot = new Map();
|
|
12
|
+
registrationByKey = new Map();
|
|
13
|
+
constructor(journal) {
|
|
14
|
+
this.journal = journal;
|
|
15
|
+
this.replay();
|
|
16
|
+
}
|
|
17
|
+
list() {
|
|
18
|
+
return [...this.projects.values()].sort((a, b) => a.created_at.localeCompare(b.created_at));
|
|
19
|
+
}
|
|
20
|
+
get(id) {
|
|
21
|
+
return this.projects.get(id);
|
|
22
|
+
}
|
|
23
|
+
findByRoot(root) {
|
|
24
|
+
const id = this.projectIdByRoot.get(canonicalRoot(root));
|
|
25
|
+
return id ? this.projects.get(id) : undefined;
|
|
26
|
+
}
|
|
27
|
+
register(input) {
|
|
28
|
+
validateKey(input.idempotencyKey);
|
|
29
|
+
const root = canonicalRoot(input.root);
|
|
30
|
+
const keyDigest = hashJson({
|
|
31
|
+
client: input.clientId,
|
|
32
|
+
partition: "global",
|
|
33
|
+
operation: "project.register",
|
|
34
|
+
key: input.idempotencyKey,
|
|
35
|
+
});
|
|
36
|
+
const requestDigest = hashJson({ root });
|
|
37
|
+
const prior = this.registrationByKey.get(keyDigest);
|
|
38
|
+
if (prior) {
|
|
39
|
+
if (prior.requestDigest !== requestDigest)
|
|
40
|
+
throw conflict();
|
|
41
|
+
const project = this.projects.get(prior.projectId);
|
|
42
|
+
if (!project)
|
|
43
|
+
throw new Error("project registration points to a missing project");
|
|
44
|
+
return project;
|
|
45
|
+
}
|
|
46
|
+
const existingId = this.projectIdByRoot.get(root);
|
|
47
|
+
const existing = existingId ? this.projects.get(existingId) : undefined;
|
|
48
|
+
const now = nowIso();
|
|
49
|
+
const project = existing ??
|
|
50
|
+
ProjectSchema.parse({
|
|
51
|
+
schema_version: SCHEMA_VERSION,
|
|
52
|
+
id: newId("prj"),
|
|
53
|
+
root,
|
|
54
|
+
created_at: now,
|
|
55
|
+
updated_at: now,
|
|
56
|
+
});
|
|
57
|
+
this.commit(REGISTERED, {
|
|
58
|
+
project,
|
|
59
|
+
registration: { keyDigest, requestDigest, projectId: project.id },
|
|
60
|
+
});
|
|
61
|
+
return project;
|
|
62
|
+
}
|
|
63
|
+
relink(id, rootInput) {
|
|
64
|
+
const current = this.projects.get(id);
|
|
65
|
+
if (!current)
|
|
66
|
+
throw Object.assign(new Error(`no such project: ${id}`), { status: 404 });
|
|
67
|
+
const root = canonicalRoot(rootInput);
|
|
68
|
+
const owner = this.projectIdByRoot.get(root);
|
|
69
|
+
if (owner && owner !== id) {
|
|
70
|
+
throw Object.assign(new Error(`project root is already registered to ${owner}`), {
|
|
71
|
+
code: "project_root_conflict",
|
|
72
|
+
status: 409,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
if (root === current.root)
|
|
76
|
+
return current;
|
|
77
|
+
const project = ProjectSchema.parse({ ...current, root, updated_at: nowIso() });
|
|
78
|
+
this.commit(RELINKED, { project });
|
|
79
|
+
return project;
|
|
80
|
+
}
|
|
81
|
+
validateProjection() {
|
|
82
|
+
for (const project of this.projects.values())
|
|
83
|
+
ProjectSchema.parse(project);
|
|
84
|
+
if (this.projectIdByRoot.size !== this.projects.size) {
|
|
85
|
+
throw new Error("project registry contains duplicate roots");
|
|
86
|
+
}
|
|
87
|
+
for (const binding of this.registrationByKey.values()) {
|
|
88
|
+
if (!this.projects.has(binding.projectId)) {
|
|
89
|
+
throw new Error("project registration idempotency index is dangling");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
replay() {
|
|
94
|
+
for (const record of this.journal.records()) {
|
|
95
|
+
if (record.type !== REGISTERED && record.type !== RELINKED)
|
|
96
|
+
continue;
|
|
97
|
+
this.apply(parseMutation(record.payload));
|
|
98
|
+
}
|
|
99
|
+
this.validateProjection();
|
|
100
|
+
}
|
|
101
|
+
commit(type, mutation) {
|
|
102
|
+
const parsed = parseMutation(mutation);
|
|
103
|
+
this.journal.append(type, parsed);
|
|
104
|
+
this.apply(parsed);
|
|
105
|
+
}
|
|
106
|
+
apply(mutation) {
|
|
107
|
+
const previous = this.projects.get(mutation.project.id);
|
|
108
|
+
if (previous && previous.root !== mutation.project.root)
|
|
109
|
+
this.projectIdByRoot.delete(previous.root);
|
|
110
|
+
const rootOwner = this.projectIdByRoot.get(mutation.project.root);
|
|
111
|
+
if (rootOwner && rootOwner !== mutation.project.id) {
|
|
112
|
+
throw new Error("conflicting project root history");
|
|
113
|
+
}
|
|
114
|
+
this.projects.set(mutation.project.id, mutation.project);
|
|
115
|
+
this.projectIdByRoot.set(mutation.project.root, mutation.project.id);
|
|
116
|
+
if (mutation.registration) {
|
|
117
|
+
const { keyDigest, requestDigest, projectId } = mutation.registration;
|
|
118
|
+
const prior = this.registrationByKey.get(keyDigest);
|
|
119
|
+
if (prior && (prior.requestDigest !== requestDigest || prior.projectId !== projectId)) {
|
|
120
|
+
throw new Error("conflicting project registration history");
|
|
121
|
+
}
|
|
122
|
+
this.registrationByKey.set(keyDigest, { requestDigest, projectId });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
export function projectProjection() {
|
|
127
|
+
return {
|
|
128
|
+
name: "projects",
|
|
129
|
+
create: (journal) => new ProjectStore(journal),
|
|
130
|
+
validate: (store) => store.validateProjection(),
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function canonicalRoot(input) {
|
|
134
|
+
if (!isAbsolute(input))
|
|
135
|
+
throw Object.assign(new Error("project root must be absolute"), { status: 400 });
|
|
136
|
+
let root;
|
|
137
|
+
try {
|
|
138
|
+
root = realpathSync(input);
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
throw Object.assign(new Error(`project root does not exist: ${input}`), { status: 400 });
|
|
142
|
+
}
|
|
143
|
+
if (!lstatSync(root).isDirectory()) {
|
|
144
|
+
throw Object.assign(new Error(`project root is not a directory: ${input}`), { status: 400 });
|
|
145
|
+
}
|
|
146
|
+
return root;
|
|
147
|
+
}
|
|
148
|
+
function parseMutation(value) {
|
|
149
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
150
|
+
throw new Error("invalid project mutation");
|
|
151
|
+
}
|
|
152
|
+
const input = value;
|
|
153
|
+
const registration = input.registration;
|
|
154
|
+
if (registration !== undefined &&
|
|
155
|
+
(!registration ||
|
|
156
|
+
typeof registration.keyDigest !== "string" ||
|
|
157
|
+
typeof registration.requestDigest !== "string" ||
|
|
158
|
+
typeof registration.projectId !== "string")) {
|
|
159
|
+
throw new Error("invalid project registration binding");
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
project: ProjectSchema.parse(input.project),
|
|
163
|
+
...(registration ? { registration: { ...registration } } : {}),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function validateKey(key) {
|
|
167
|
+
if (!key || key.length > 256) {
|
|
168
|
+
throw Object.assign(new Error("Idempotency-Key must contain 1-256 characters"), {
|
|
169
|
+
code: "invalid_idempotency_key",
|
|
170
|
+
status: 400,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function conflict() {
|
|
175
|
+
return Object.assign(new Error("idempotency key was already used with a different request"), {
|
|
176
|
+
code: "idempotency_conflict",
|
|
177
|
+
status: 409,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=projects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projects.js","sourceRoot":"","sources":["../src/projects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,cAAc,EAAgB,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAA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