trellis 1.0.8 → 2.0.5
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/LICENSE +21 -0
- package/README.md +533 -82
- package/bin/trellis.mjs +2 -0
- package/dist/cli/index.js +4718 -0
- package/dist/core/index.js +12 -0
- package/dist/decisions/index.js +19 -0
- package/dist/embeddings/index.js +43 -0
- package/dist/index-1j1anhmr.js +4038 -0
- package/dist/index-3s0eak0p.js +1556 -0
- package/dist/index-8pce39mh.js +272 -0
- package/dist/index-a76rekgs.js +67 -0
- package/dist/index-cy9k1g6v.js +684 -0
- package/dist/index-fd4e26s4.js +69 -0
- package/dist/{store/eav-store.js → index-gkvhzm9f.js} +4 -6
- package/dist/index-gnw8d7d6.js +51 -0
- package/dist/index-vkpkfwhq.js +817 -0
- package/dist/index.js +118 -2876
- package/dist/links/index.js +55 -0
- package/dist/transformers-m9je15kg.js +32491 -0
- package/dist/vcs/index.js +110 -0
- package/logo.png +0 -0
- package/logo.svg +9 -0
- package/package.json +79 -76
- package/src/cli/index.ts +2340 -0
- package/src/core/index.ts +35 -0
- package/src/core/kernel/middleware.ts +44 -0
- package/src/core/persist/backend.ts +64 -0
- package/src/core/store/eav-store.ts +467 -0
- package/src/decisions/auto-capture.ts +136 -0
- package/src/decisions/hooks.ts +163 -0
- package/src/decisions/index.ts +261 -0
- package/src/decisions/types.ts +103 -0
- package/src/embeddings/chunker.ts +327 -0
- package/src/embeddings/index.ts +41 -0
- package/src/embeddings/model.ts +95 -0
- package/src/embeddings/search.ts +305 -0
- package/src/embeddings/store.ts +313 -0
- package/src/embeddings/types.ts +85 -0
- package/src/engine.ts +1083 -0
- package/src/garden/cluster.ts +330 -0
- package/src/garden/garden.ts +306 -0
- package/src/garden/index.ts +29 -0
- package/src/git/git-exporter.ts +286 -0
- package/src/git/git-importer.ts +329 -0
- package/src/git/git-reader.ts +189 -0
- package/src/git/index.ts +22 -0
- package/src/identity/governance.ts +211 -0
- package/src/identity/identity.ts +224 -0
- package/src/identity/index.ts +30 -0
- package/src/identity/signing-middleware.ts +97 -0
- package/src/index.ts +20 -0
- package/src/links/index.ts +49 -0
- package/src/links/lifecycle.ts +400 -0
- package/src/links/parser.ts +484 -0
- package/src/links/ref-index.ts +186 -0
- package/src/links/resolver.ts +314 -0
- package/src/links/types.ts +108 -0
- package/src/mcp/index.ts +22 -0
- package/src/mcp/server.ts +1278 -0
- package/src/semantic/csharp-parser.ts +493 -0
- package/src/semantic/go-parser.ts +585 -0
- package/src/semantic/index.ts +34 -0
- package/src/semantic/java-parser.ts +456 -0
- package/src/semantic/python-parser.ts +659 -0
- package/src/semantic/ruby-parser.ts +446 -0
- package/src/semantic/rust-parser.ts +784 -0
- package/src/semantic/semantic-merge.ts +210 -0
- package/src/semantic/ts-parser.ts +681 -0
- package/src/semantic/types.ts +175 -0
- package/src/sync/index.ts +32 -0
- package/src/sync/memory-transport.ts +66 -0
- package/src/sync/reconciler.ts +237 -0
- package/src/sync/sync-engine.ts +258 -0
- package/src/sync/types.ts +104 -0
- package/src/vcs/blob-store.ts +124 -0
- package/src/vcs/branch.ts +150 -0
- package/src/vcs/checkpoint.ts +64 -0
- package/src/vcs/decompose.ts +469 -0
- package/src/vcs/diff.ts +409 -0
- package/src/vcs/engine-context.ts +26 -0
- package/src/vcs/index.ts +23 -0
- package/src/vcs/issue.ts +800 -0
- package/src/vcs/merge.ts +425 -0
- package/src/vcs/milestone.ts +124 -0
- package/src/vcs/ops.ts +59 -0
- package/src/vcs/types.ts +213 -0
- package/src/vcs/vcs-middleware.ts +81 -0
- package/src/watcher/fs-watcher.ts +217 -0
- package/src/watcher/index.ts +9 -0
- package/src/watcher/ingestion.ts +116 -0
- package/dist/ai/index.js +0 -688
- package/dist/cli/server.js +0 -3321
- package/dist/cli/tql.js +0 -5282
- package/dist/client/tql-client.js +0 -108
- package/dist/graph/index.js +0 -2248
- package/dist/kernel/logic-middleware.js +0 -179
- package/dist/kernel/middleware.js +0 -0
- package/dist/kernel/operations.js +0 -32
- package/dist/kernel/schema-middleware.js +0 -34
- package/dist/kernel/security-middleware.js +0 -53
- package/dist/kernel/trellis-kernel.js +0 -2239
- package/dist/kernel/workspace.js +0 -91
- package/dist/persist/backend.js +0 -0
- package/dist/persist/sqlite-backend.js +0 -123
- package/dist/query/index.js +0 -1643
- package/dist/server/index.js +0 -3309
- package/dist/workflows/index.js +0 -3160
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VCS Op Decomposition
|
|
3
|
+
*
|
|
4
|
+
* Converts high-level VcsOps into primitive EAV store operations
|
|
5
|
+
* (addFacts, addLinks, deleteFacts, deleteLinks).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { Fact, Link } from '../core/store/eav-store.js';
|
|
9
|
+
import type { VcsOp } from './types.js';
|
|
10
|
+
import {
|
|
11
|
+
fileEntityId,
|
|
12
|
+
dirEntityId,
|
|
13
|
+
issueEntityId,
|
|
14
|
+
criterionEntityId,
|
|
15
|
+
decisionEntityId,
|
|
16
|
+
} from './types.js';
|
|
17
|
+
import { dirname } from 'path';
|
|
18
|
+
|
|
19
|
+
export interface DecomposedOp {
|
|
20
|
+
addFacts: Fact[];
|
|
21
|
+
addLinks: Link[];
|
|
22
|
+
deleteFacts: Fact[];
|
|
23
|
+
deleteLinks: Link[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Decomposes a VcsOp into primitive store operations.
|
|
28
|
+
*/
|
|
29
|
+
export function decompose(op: VcsOp): DecomposedOp {
|
|
30
|
+
const result: DecomposedOp = {
|
|
31
|
+
addFacts: [],
|
|
32
|
+
addLinks: [],
|
|
33
|
+
deleteFacts: [],
|
|
34
|
+
deleteLinks: [],
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const vcs = op.vcs;
|
|
38
|
+
if (!vcs) return result;
|
|
39
|
+
|
|
40
|
+
switch (op.kind) {
|
|
41
|
+
case 'vcs:fileAdd': {
|
|
42
|
+
if (!vcs.filePath) break;
|
|
43
|
+
const eid = fileEntityId(vcs.filePath);
|
|
44
|
+
const dir = dirname(vcs.filePath);
|
|
45
|
+
const did = dirEntityId(dir === '.' ? '' : dir);
|
|
46
|
+
|
|
47
|
+
result.addFacts.push(
|
|
48
|
+
{ e: eid, a: 'type', v: 'FileNode' },
|
|
49
|
+
{ e: eid, a: 'path', v: vcs.filePath },
|
|
50
|
+
);
|
|
51
|
+
if (vcs.contentHash) {
|
|
52
|
+
result.addFacts.push({ e: eid, a: 'contentHash', v: vcs.contentHash });
|
|
53
|
+
}
|
|
54
|
+
if (vcs.size !== undefined) {
|
|
55
|
+
result.addFacts.push({ e: eid, a: 'size', v: vcs.size });
|
|
56
|
+
}
|
|
57
|
+
if (vcs.language) {
|
|
58
|
+
result.addFacts.push({ e: eid, a: 'language', v: vcs.language });
|
|
59
|
+
}
|
|
60
|
+
result.addFacts.push({ e: eid, a: 'lastModified', v: op.timestamp });
|
|
61
|
+
|
|
62
|
+
// Ensure directory entity exists
|
|
63
|
+
result.addFacts.push(
|
|
64
|
+
{ e: did, a: 'type', v: 'DirectoryNode' },
|
|
65
|
+
{ e: did, a: 'path', v: dir === '.' ? '' : dir },
|
|
66
|
+
);
|
|
67
|
+
result.addLinks.push({ e1: did, a: 'contains', e2: eid });
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
case 'vcs:fileModify': {
|
|
72
|
+
if (!vcs.filePath) break;
|
|
73
|
+
const eid = fileEntityId(vcs.filePath);
|
|
74
|
+
|
|
75
|
+
// Delete old contentHash/size facts, add new ones
|
|
76
|
+
if (vcs.oldContentHash) {
|
|
77
|
+
result.deleteFacts.push({
|
|
78
|
+
e: eid,
|
|
79
|
+
a: 'contentHash',
|
|
80
|
+
v: vcs.oldContentHash,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
if (vcs.contentHash) {
|
|
84
|
+
result.addFacts.push({ e: eid, a: 'contentHash', v: vcs.contentHash });
|
|
85
|
+
}
|
|
86
|
+
if (vcs.size !== undefined) {
|
|
87
|
+
// We approximate: delete old size by marking for update
|
|
88
|
+
result.addFacts.push({ e: eid, a: 'size', v: vcs.size });
|
|
89
|
+
}
|
|
90
|
+
result.addFacts.push({ e: eid, a: 'lastModified', v: op.timestamp });
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
case 'vcs:fileDelete': {
|
|
95
|
+
if (!vcs.filePath) break;
|
|
96
|
+
const eid = fileEntityId(vcs.filePath);
|
|
97
|
+
const dir = dirname(vcs.filePath);
|
|
98
|
+
const did = dirEntityId(dir === '.' ? '' : dir);
|
|
99
|
+
|
|
100
|
+
// Remove file entity facts
|
|
101
|
+
result.deleteFacts.push(
|
|
102
|
+
{ e: eid, a: 'type', v: 'FileNode' },
|
|
103
|
+
{ e: eid, a: 'path', v: vcs.filePath },
|
|
104
|
+
);
|
|
105
|
+
if (vcs.contentHash) {
|
|
106
|
+
result.deleteFacts.push({
|
|
107
|
+
e: eid,
|
|
108
|
+
a: 'contentHash',
|
|
109
|
+
v: vcs.contentHash,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
result.deleteLinks.push({ e1: did, a: 'contains', e2: eid });
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
case 'vcs:fileRename': {
|
|
117
|
+
if (!vcs.filePath || !vcs.oldFilePath) break;
|
|
118
|
+
const eid = fileEntityId(vcs.oldFilePath); // identity preserved
|
|
119
|
+
const oldDir = dirname(vcs.oldFilePath);
|
|
120
|
+
const newDir = dirname(vcs.filePath);
|
|
121
|
+
const oldDid = dirEntityId(oldDir === '.' ? '' : oldDir);
|
|
122
|
+
const newDid = dirEntityId(newDir === '.' ? '' : newDir);
|
|
123
|
+
|
|
124
|
+
// Update path fact
|
|
125
|
+
result.deleteFacts.push({ e: eid, a: 'path', v: vcs.oldFilePath });
|
|
126
|
+
result.addFacts.push({ e: eid, a: 'path', v: vcs.filePath });
|
|
127
|
+
result.addFacts.push({ e: eid, a: 'lastModified', v: op.timestamp });
|
|
128
|
+
|
|
129
|
+
// Update directory links
|
|
130
|
+
result.deleteLinks.push({ e1: oldDid, a: 'contains', e2: eid });
|
|
131
|
+
|
|
132
|
+
// Ensure new directory exists
|
|
133
|
+
result.addFacts.push(
|
|
134
|
+
{ e: newDid, a: 'type', v: 'DirectoryNode' },
|
|
135
|
+
{ e: newDid, a: 'path', v: newDir === '.' ? '' : newDir },
|
|
136
|
+
);
|
|
137
|
+
result.addLinks.push({ e1: newDid, a: 'contains', e2: eid });
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
case 'vcs:branchCreate': {
|
|
142
|
+
if (!vcs.branchName) break;
|
|
143
|
+
const bid = `branch:${vcs.branchName}`;
|
|
144
|
+
result.addFacts.push(
|
|
145
|
+
{ e: bid, a: 'type', v: 'Branch' },
|
|
146
|
+
{ e: bid, a: 'name', v: vcs.branchName },
|
|
147
|
+
{ e: bid, a: 'createdAt', v: op.timestamp },
|
|
148
|
+
{ e: bid, a: 'createdBy', v: op.agentId },
|
|
149
|
+
);
|
|
150
|
+
if (vcs.targetOpHash) {
|
|
151
|
+
result.addFacts.push({ e: bid, a: 'headOpHash', v: vcs.targetOpHash });
|
|
152
|
+
}
|
|
153
|
+
if (vcs.baseBranch) {
|
|
154
|
+
result.addLinks.push({
|
|
155
|
+
e1: bid,
|
|
156
|
+
a: 'forkedFrom',
|
|
157
|
+
e2: `branch:${vcs.baseBranch}`,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
case 'vcs:branchDelete': {
|
|
164
|
+
if (!vcs.branchName) break;
|
|
165
|
+
const bid = `branch:${vcs.branchName}`;
|
|
166
|
+
result.deleteFacts.push(
|
|
167
|
+
{ e: bid, a: 'type', v: 'Branch' },
|
|
168
|
+
{ e: bid, a: 'name', v: vcs.branchName },
|
|
169
|
+
);
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
case 'vcs:branchAdvance': {
|
|
174
|
+
if (!vcs.branchName || !vcs.targetOpHash) break;
|
|
175
|
+
const bid = `branch:${vcs.branchName}`;
|
|
176
|
+
// Update head pointer
|
|
177
|
+
result.addFacts.push({ e: bid, a: 'headOpHash', v: vcs.targetOpHash });
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
case 'vcs:milestoneCreate': {
|
|
182
|
+
if (!vcs.milestoneId) break;
|
|
183
|
+
const mid = vcs.milestoneId;
|
|
184
|
+
result.addFacts.push(
|
|
185
|
+
{ e: mid, a: 'type', v: 'Milestone' },
|
|
186
|
+
{ e: mid, a: 'createdAt', v: op.timestamp },
|
|
187
|
+
{ e: mid, a: 'createdBy', v: op.agentId },
|
|
188
|
+
);
|
|
189
|
+
if (vcs.message) {
|
|
190
|
+
result.addFacts.push({ e: mid, a: 'message', v: vcs.message });
|
|
191
|
+
}
|
|
192
|
+
if (vcs.fromOpHash) {
|
|
193
|
+
result.addFacts.push({ e: mid, a: 'fromOpHash', v: vcs.fromOpHash });
|
|
194
|
+
}
|
|
195
|
+
if (vcs.toOpHash) {
|
|
196
|
+
result.addFacts.push({ e: mid, a: 'toOpHash', v: vcs.toOpHash });
|
|
197
|
+
}
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
case 'vcs:checkpointCreate': {
|
|
202
|
+
const cid = `checkpoint:${op.hash}`;
|
|
203
|
+
result.addFacts.push(
|
|
204
|
+
{ e: cid, a: 'type', v: 'Checkpoint' },
|
|
205
|
+
{ e: cid, a: 'createdAt', v: op.timestamp },
|
|
206
|
+
{ e: cid, a: 'atOpHash', v: op.hash },
|
|
207
|
+
);
|
|
208
|
+
if (vcs.trigger) {
|
|
209
|
+
result.addFacts.push({ e: cid, a: 'trigger', v: vcs.trigger });
|
|
210
|
+
}
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// ----- Issue tracking -----
|
|
215
|
+
|
|
216
|
+
case 'vcs:issueCreate': {
|
|
217
|
+
if (!vcs.issueId) break;
|
|
218
|
+
const eid = issueEntityId(vcs.issueId);
|
|
219
|
+
result.addFacts.push(
|
|
220
|
+
{ e: eid, a: 'type', v: 'Issue' },
|
|
221
|
+
{ e: eid, a: 'status', v: vcs.issueStatus ?? 'backlog' },
|
|
222
|
+
{ e: eid, a: 'createdAt', v: op.timestamp },
|
|
223
|
+
{ e: eid, a: 'createdBy', v: op.agentId },
|
|
224
|
+
);
|
|
225
|
+
if (vcs.issueTitle) {
|
|
226
|
+
result.addFacts.push({ e: eid, a: 'title', v: vcs.issueTitle });
|
|
227
|
+
}
|
|
228
|
+
if (vcs.issueDescription) {
|
|
229
|
+
result.addFacts.push({
|
|
230
|
+
e: eid,
|
|
231
|
+
a: 'description',
|
|
232
|
+
v: vcs.issueDescription,
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
if (vcs.issuePriority) {
|
|
236
|
+
result.addFacts.push({ e: eid, a: 'priority', v: vcs.issuePriority });
|
|
237
|
+
}
|
|
238
|
+
if (vcs.issueLabels && vcs.issueLabels.length > 0) {
|
|
239
|
+
result.addFacts.push({
|
|
240
|
+
e: eid,
|
|
241
|
+
a: 'labels',
|
|
242
|
+
v: vcs.issueLabels.join(','),
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
if (vcs.issueAssignee) {
|
|
246
|
+
result.addFacts.push({ e: eid, a: 'assignee', v: vcs.issueAssignee });
|
|
247
|
+
}
|
|
248
|
+
if (vcs.parentIssueId) {
|
|
249
|
+
result.addLinks.push({
|
|
250
|
+
e1: eid,
|
|
251
|
+
a: 'childOf',
|
|
252
|
+
e2: issueEntityId(vcs.parentIssueId),
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
case 'vcs:issueUpdate': {
|
|
259
|
+
if (!vcs.issueId) break;
|
|
260
|
+
const eid = issueEntityId(vcs.issueId);
|
|
261
|
+
if (vcs.issueStatus) {
|
|
262
|
+
result.addFacts.push({ e: eid, a: 'status', v: vcs.issueStatus });
|
|
263
|
+
}
|
|
264
|
+
if (vcs.issuePriority) {
|
|
265
|
+
result.addFacts.push({ e: eid, a: 'priority', v: vcs.issuePriority });
|
|
266
|
+
}
|
|
267
|
+
if (vcs.issueLabels) {
|
|
268
|
+
result.addFacts.push({
|
|
269
|
+
e: eid,
|
|
270
|
+
a: 'labels',
|
|
271
|
+
v: vcs.issueLabels.join(','),
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
if (vcs.issueTitle) {
|
|
275
|
+
result.addFacts.push({ e: eid, a: 'title', v: vcs.issueTitle });
|
|
276
|
+
}
|
|
277
|
+
if (vcs.issueAssignee) {
|
|
278
|
+
result.addFacts.push({ e: eid, a: 'assignee', v: vcs.issueAssignee });
|
|
279
|
+
}
|
|
280
|
+
if (vcs.issueDescription !== undefined) {
|
|
281
|
+
result.addFacts.push({
|
|
282
|
+
e: eid,
|
|
283
|
+
a: 'description',
|
|
284
|
+
v: vcs.issueDescription,
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
case 'vcs:issueStart': {
|
|
291
|
+
if (!vcs.issueId) break;
|
|
292
|
+
const eid = issueEntityId(vcs.issueId);
|
|
293
|
+
result.addFacts.push(
|
|
294
|
+
{ e: eid, a: 'status', v: 'in_progress' },
|
|
295
|
+
{ e: eid, a: 'startedAt', v: op.timestamp },
|
|
296
|
+
);
|
|
297
|
+
if (vcs.issueAssignee) {
|
|
298
|
+
result.addFacts.push({ e: eid, a: 'assignee', v: vcs.issueAssignee });
|
|
299
|
+
}
|
|
300
|
+
if (vcs.branchName) {
|
|
301
|
+
result.addLinks.push({
|
|
302
|
+
e1: eid,
|
|
303
|
+
a: 'trackedOn',
|
|
304
|
+
e2: `branch:${vcs.branchName}`,
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
case 'vcs:issuePause': {
|
|
311
|
+
if (!vcs.issueId) break;
|
|
312
|
+
const eid = issueEntityId(vcs.issueId);
|
|
313
|
+
result.addFacts.push(
|
|
314
|
+
{ e: eid, a: 'status', v: 'paused' },
|
|
315
|
+
{ e: eid, a: 'pausedAt', v: op.timestamp },
|
|
316
|
+
);
|
|
317
|
+
if (vcs.pauseNote) {
|
|
318
|
+
result.addFacts.push({ e: eid, a: 'pauseNote', v: vcs.pauseNote });
|
|
319
|
+
}
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
case 'vcs:issueResume': {
|
|
324
|
+
if (!vcs.issueId) break;
|
|
325
|
+
const eid = issueEntityId(vcs.issueId);
|
|
326
|
+
result.addFacts.push(
|
|
327
|
+
{ e: eid, a: 'status', v: 'in_progress' },
|
|
328
|
+
{ e: eid, a: 'resumedAt', v: op.timestamp },
|
|
329
|
+
{ e: eid, a: 'pauseNote', v: '' },
|
|
330
|
+
);
|
|
331
|
+
break;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
case 'vcs:issueClose': {
|
|
335
|
+
if (!vcs.issueId) break;
|
|
336
|
+
const eid = issueEntityId(vcs.issueId);
|
|
337
|
+
result.addFacts.push(
|
|
338
|
+
{ e: eid, a: 'status', v: 'closed' },
|
|
339
|
+
{ e: eid, a: 'closedAt', v: op.timestamp },
|
|
340
|
+
);
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
case 'vcs:issueReopen': {
|
|
345
|
+
if (!vcs.issueId) break;
|
|
346
|
+
const eid = issueEntityId(vcs.issueId);
|
|
347
|
+
result.addFacts.push({ e: eid, a: 'status', v: 'queue' });
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
case 'vcs:criterionAdd': {
|
|
352
|
+
if (!vcs.criterionId || !vcs.issueId) break;
|
|
353
|
+
const ceid = vcs.criterionId;
|
|
354
|
+
result.addFacts.push(
|
|
355
|
+
{ e: ceid, a: 'type', v: 'Criterion' },
|
|
356
|
+
{ e: ceid, a: 'status', v: 'pending' },
|
|
357
|
+
{ e: ceid, a: 'createdAt', v: op.timestamp },
|
|
358
|
+
);
|
|
359
|
+
if (vcs.criterionDescription) {
|
|
360
|
+
result.addFacts.push({
|
|
361
|
+
e: ceid,
|
|
362
|
+
a: 'description',
|
|
363
|
+
v: vcs.criterionDescription,
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
if (vcs.criterionCommand) {
|
|
367
|
+
result.addFacts.push({
|
|
368
|
+
e: ceid,
|
|
369
|
+
a: 'command',
|
|
370
|
+
v: vcs.criterionCommand,
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
result.addLinks.push({
|
|
374
|
+
e1: ceid,
|
|
375
|
+
a: 'criterionOf',
|
|
376
|
+
e2: issueEntityId(vcs.issueId),
|
|
377
|
+
});
|
|
378
|
+
break;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
case 'vcs:criterionUpdate': {
|
|
382
|
+
if (!vcs.criterionId) break;
|
|
383
|
+
const ceid = vcs.criterionId;
|
|
384
|
+
if (vcs.criterionStatus) {
|
|
385
|
+
result.addFacts.push({ e: ceid, a: 'status', v: vcs.criterionStatus });
|
|
386
|
+
}
|
|
387
|
+
if (vcs.criterionOutput) {
|
|
388
|
+
result.addFacts.push({
|
|
389
|
+
e: ceid,
|
|
390
|
+
a: 'lastOutput',
|
|
391
|
+
v: vcs.criterionOutput,
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
result.addFacts.push({ e: ceid, a: 'lastRunAt', v: op.timestamp });
|
|
395
|
+
break;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// ----- Issue blocking -----
|
|
399
|
+
|
|
400
|
+
case 'vcs:issueBlock': {
|
|
401
|
+
if (!vcs.issueId || !vcs.blockedByIssueId) break;
|
|
402
|
+
const eid = issueEntityId(vcs.issueId);
|
|
403
|
+
const blockerEid = issueEntityId(vcs.blockedByIssueId);
|
|
404
|
+
result.addLinks.push({ e1: eid, a: 'blockedBy', e2: blockerEid });
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
case 'vcs:issueUnblock': {
|
|
409
|
+
if (!vcs.issueId || !vcs.blockedByIssueId) break;
|
|
410
|
+
const eid = issueEntityId(vcs.issueId);
|
|
411
|
+
const blockerEid = issueEntityId(vcs.blockedByIssueId);
|
|
412
|
+
result.deleteLinks.push({ e1: eid, a: 'blockedBy', e2: blockerEid });
|
|
413
|
+
break;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// ----- Decision traces -----
|
|
417
|
+
|
|
418
|
+
case 'vcs:decisionRecord': {
|
|
419
|
+
if (!vcs.decisionId) break;
|
|
420
|
+
const did = decisionEntityId(vcs.decisionId);
|
|
421
|
+
result.addFacts.push(
|
|
422
|
+
{ e: did, a: 'type', v: 'Decision' },
|
|
423
|
+
{ e: did, a: 'createdAt', v: op.timestamp },
|
|
424
|
+
{ e: did, a: 'createdBy', v: op.agentId },
|
|
425
|
+
);
|
|
426
|
+
if (vcs.decisionToolName) {
|
|
427
|
+
result.addFacts.push({
|
|
428
|
+
e: did,
|
|
429
|
+
a: 'toolName',
|
|
430
|
+
v: vcs.decisionToolName,
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
if (vcs.decisionToolInput) {
|
|
434
|
+
result.addFacts.push({
|
|
435
|
+
e: did,
|
|
436
|
+
a: 'toolInput',
|
|
437
|
+
v: vcs.decisionToolInput,
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
if (vcs.decisionToolOutput) {
|
|
441
|
+
result.addFacts.push({
|
|
442
|
+
e: did,
|
|
443
|
+
a: 'outputSummary',
|
|
444
|
+
v: vcs.decisionToolOutput,
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
if (vcs.decisionContext) {
|
|
448
|
+
result.addFacts.push({ e: did, a: 'context', v: vcs.decisionContext });
|
|
449
|
+
}
|
|
450
|
+
if (vcs.decisionRationale) {
|
|
451
|
+
result.addFacts.push({
|
|
452
|
+
e: did,
|
|
453
|
+
a: 'rationale',
|
|
454
|
+
v: vcs.decisionRationale,
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
if (vcs.decisionAlternatives) {
|
|
458
|
+
result.addFacts.push({
|
|
459
|
+
e: did,
|
|
460
|
+
a: 'alternatives',
|
|
461
|
+
v: vcs.decisionAlternatives,
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
break;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
return result;
|
|
469
|
+
}
|