@quolu/lattice 0.50.1 → 0.52.0
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/bin/lattice-work-order-adapter.mjs +20 -0
- package/docs/schemas/lattice.runtime_adapter_capabilities.v2.schema.json +55 -0
- package/docs/schemas/lattice.runtime_adapter_registration_input.v2.schema.json +86 -0
- package/package.json +5 -2
- package/src/boundary-observation-compiler-v2.mjs +1 -1
- package/src/cli-help.mjs +33 -2
- package/src/rc3-actual-dogfood.mjs +6 -2
- package/src/rc3-scripted-campaign.mjs +37 -10
- package/src/rc4-stage1-dogfood.mjs +6 -2
- package/src/runtime-adapter-registry.mjs +21 -7
- package/src/runtime-cli.mjs +476 -34
- package/src/runtime-contracts.mjs +59 -13
- package/src/runtime-controller-protocol.mjs +48 -3
- package/src/runtime-decision-verifier.mjs +70 -0
- package/src/runtime-diff-observer.mjs +66 -4
- package/src/runtime-direct-os-observer.mjs +25 -8
- package/src/runtime-driver-state.mjs +162 -0
- package/src/runtime-engine.mjs +37 -6
- package/src/runtime-front-end.mjs +39 -1
- package/src/runtime-managed-supervisor.mjs +80 -14
- package/src/runtime-multi-epoch-store.mjs +87 -14
- package/src/runtime-pull-intake.mjs +1188 -0
- package/src/runtime-work-order-contracts.mjs +91 -0
- package/src/runtime-work-order-controller.mjs +1167 -0
- package/src/seam-proposal-queries.mjs +1 -1
- package/src/todo-cli.mjs +273 -7
- package/src/todo-contracts.mjs +19 -2
- package/src/todo-gantt-html-independence.mjs +3 -2
- package/src/todo-gantt-html-shared.mjs +1 -2
- package/src/todo-gantt-html-style.mjs +13 -0
- package/src/todo-gantt-html.mjs +15 -2
- package/src/todo-gantt-layout.mjs +75 -1
- package/src/todo-gantt-nested.mjs +263 -0
- package/src/todo-gantt-svg.mjs +80 -5
- package/src/todo-independence-contracts.mjs +73 -7
- package/src/todo-independence-guidance.mjs +30 -1
- package/src/todo-independence.mjs +89 -7
- package/src/todo-revision.mjs +1 -1
- package/src/todo-split.mjs +472 -0
- package/src/todo-status.mjs +10 -1
- package/src/todo-store-git-transaction.mjs +418 -0
- package/src/todo-store.mjs +144 -4
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
|
|
3
|
+
import { selfDigest } from './runtime-contracts.mjs';
|
|
4
|
+
|
|
5
|
+
const SHA256 = /^[0-9a-f]{64}$/u;
|
|
6
|
+
const GIT_SHA1 = /^[0-9a-f]{40}$/u;
|
|
7
|
+
const ID = /^[0-9A-Za-z](?:[0-9A-Za-z._-]{0,127})$/u;
|
|
8
|
+
const MAX_ITEMS = 256;
|
|
9
|
+
|
|
10
|
+
function plain(value) {
|
|
11
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
12
|
+
&& Object.getPrototypeOf(value) === Object.prototype;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function exact(value, fields) {
|
|
16
|
+
if (!plain(value)) return false;
|
|
17
|
+
const actual = Object.keys(value).sort();
|
|
18
|
+
const expected = [...fields].sort();
|
|
19
|
+
return actual.length === expected.length
|
|
20
|
+
&& actual.every((field, index) => field === expected[index]);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function safeWritePath(value) {
|
|
24
|
+
return typeof value === 'string'
|
|
25
|
+
&& value.length > 0
|
|
26
|
+
&& value === path.posix.normalize(value)
|
|
27
|
+
&& !path.posix.isAbsolute(value)
|
|
28
|
+
&& value !== '..'
|
|
29
|
+
&& !value.startsWith('../')
|
|
30
|
+
&& !value.includes('\\0')
|
|
31
|
+
&& !['.git', '.lattice'].includes(value.split('/')[0]);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function stringArray(value, { min = 0, paths = false } = {}) {
|
|
35
|
+
return Array.isArray(value)
|
|
36
|
+
&& value.length >= min
|
|
37
|
+
&& value.length <= MAX_ITEMS
|
|
38
|
+
&& value.every((entry) => paths ? safeWritePath(entry) : typeof entry === 'string');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function validateRunWorkOrder(value) {
|
|
42
|
+
return exact(value, [
|
|
43
|
+
'schema',
|
|
44
|
+
'todo_id',
|
|
45
|
+
'worktree_path',
|
|
46
|
+
'base_sha',
|
|
47
|
+
'scope_writes',
|
|
48
|
+
'verifier_refs',
|
|
49
|
+
'forbidden_operations',
|
|
50
|
+
'packet_digest',
|
|
51
|
+
'order_digest',
|
|
52
|
+
])
|
|
53
|
+
&& value.schema === 'lattice.run_work_order.v1'
|
|
54
|
+
&& ID.test(value.todo_id ?? '')
|
|
55
|
+
&& typeof value.worktree_path === 'string'
|
|
56
|
+
&& path.isAbsolute(value.worktree_path)
|
|
57
|
+
&& GIT_SHA1.test(value.base_sha ?? '')
|
|
58
|
+
&& stringArray(value.scope_writes, { paths: true })
|
|
59
|
+
&& stringArray(value.verifier_refs)
|
|
60
|
+
&& stringArray(value.forbidden_operations, { min: 1 })
|
|
61
|
+
&& SHA256.test(value.packet_digest ?? '')
|
|
62
|
+
&& SHA256.test(value.order_digest ?? '')
|
|
63
|
+
&& selfDigest(value, 'order_digest') === value.order_digest;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function createRunWorkOrder({ packet, worktreePath } = {}) {
|
|
67
|
+
const value = {
|
|
68
|
+
schema: 'lattice.run_work_order.v1',
|
|
69
|
+
todo_id: packet?.todo_id,
|
|
70
|
+
worktree_path: worktreePath,
|
|
71
|
+
base_sha: packet?.base_sha,
|
|
72
|
+
scope_writes: Array.isArray(packet?.scope?.writes) ? [...packet.scope.writes] : null,
|
|
73
|
+
verifier_refs: Array.isArray(packet?.verifier_refs) ? [...packet.verifier_refs] : null,
|
|
74
|
+
forbidden_operations: Array.isArray(packet?.forbidden_operations)
|
|
75
|
+
? [...packet.forbidden_operations] : null,
|
|
76
|
+
packet_digest: packet?.packet_digest,
|
|
77
|
+
order_digest: '',
|
|
78
|
+
};
|
|
79
|
+
value.order_digest = selfDigest(value, 'order_digest');
|
|
80
|
+
if (!validateRunWorkOrder(value)) throw new TypeError('INVALID_RUN_WORK_ORDER');
|
|
81
|
+
return value;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function validateRunWorkReport(value) {
|
|
85
|
+
return exact(value, ['schema', 'packet_digest', 'state', 'worker_pid'])
|
|
86
|
+
&& value.schema === 'lattice.run_work_report.v1'
|
|
87
|
+
&& SHA256.test(value.packet_digest ?? '')
|
|
88
|
+
&& ['working', 'done'].includes(value.state)
|
|
89
|
+
&& Number.isSafeInteger(value.worker_pid)
|
|
90
|
+
&& value.worker_pid > 0;
|
|
91
|
+
}
|