@quolu/lattice 0.59.0 → 0.59.1
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.mjs +20 -0
- package/docs/schemas/lattice.executor_packet.v1.schema.json +2 -2
- package/docs/schemas/lattice.plan_create_input.v4.schema.json +1 -1
- package/docs/schemas/lattice.plan_scope_review.v1.schema.json +55 -0
- package/docs/schemas/lattice.todo_extraction.v3.schema.json +1 -1
- package/package.json +2 -1
- package/src/cli-help.mjs +1 -0
- package/src/plan-scope-review.mjs +211 -0
- package/src/runtime-contracts.mjs +1 -1
- package/src/runtime-engine.mjs +3 -11
- package/src/runtime-work-order-contracts.mjs +1 -1
package/bin/lattice.mjs
CHANGED
|
@@ -73,6 +73,26 @@ if (sensorRelaunchStatus !== null) {
|
|
|
73
73
|
} catch (error) {
|
|
74
74
|
process.exitCode = projectCliFailure(process.stderr, error);
|
|
75
75
|
}
|
|
76
|
+
} else if (args.length === 7 && args[0] === 'plan' && args[1] === 'scope-review'
|
|
77
|
+
&& args[2] === '--plan-input' && args[4] === '--review' && args[6] === '--json') {
|
|
78
|
+
const { runPlanScopeReview } = await import('../src/plan-scope-review.mjs');
|
|
79
|
+
const { projectCliFailure } = await import('../src/project-cli.mjs');
|
|
80
|
+
try {
|
|
81
|
+
process.exitCode = await runPlanScopeReview({
|
|
82
|
+
cwd: process.cwd(), planInputRef: args[3], reviewRef: args[5], stdout: process.stdout,
|
|
83
|
+
});
|
|
84
|
+
} catch (error) {
|
|
85
|
+
process.exitCode = projectCliFailure(process.stderr, error);
|
|
86
|
+
}
|
|
87
|
+
} else if (args.length === 4 && args[0] === 'plan' && args[1] === 'scope-review'
|
|
88
|
+
&& args[2] === '--schema' && args[3] === '--json') {
|
|
89
|
+
const { runPlanScopeReviewSchema } = await import('../src/plan-scope-review.mjs');
|
|
90
|
+
const { projectCliFailure } = await import('../src/project-cli.mjs');
|
|
91
|
+
try {
|
|
92
|
+
process.exitCode = await runPlanScopeReviewSchema({ stdout: process.stdout });
|
|
93
|
+
} catch (error) {
|
|
94
|
+
process.exitCode = projectCliFailure(process.stderr, error);
|
|
95
|
+
}
|
|
76
96
|
} else if (args.length === 2 && args[0] === 'factory-diagnostics' && args[1] === '--json') {
|
|
77
97
|
const { buildFactoryDiagnostics } = await import('../src/factory-diagnostics.mjs');
|
|
78
98
|
const diagnostics = await buildFactoryDiagnostics();
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
},
|
|
40
40
|
"forbidden_operations": {
|
|
41
41
|
"type": "array",
|
|
42
|
-
"minItems": 1,
|
|
43
42
|
"maxItems": 256,
|
|
44
|
-
"items": { "type": "string" }
|
|
43
|
+
"items": { "type": "string" },
|
|
44
|
+
"description": "Compatibility field. Lattice-produced packets use an empty array; operation authority belongs to the host."
|
|
45
45
|
},
|
|
46
46
|
"context_content_digest": { "$ref": "#/$defs/digest" },
|
|
47
47
|
"packet_digest": { "$ref": "#/$defs/digest" }
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"$id": "https://github.com/kitepon-rgb/Lattice/blob/main/docs/schemas/lattice.plan_create_input.v4.schema.json",
|
|
4
4
|
"title": "lattice.plan_create_input.v4",
|
|
5
|
-
"description": "Canonical initial authoring input for a phase-audited plan. Every task requires a design memo. あなたがこのToDoに対して、何も考えていないならば、設計メモに `NO_PLAN` と書いてください",
|
|
5
|
+
"description": "Canonical initial authoring input for a phase-audited plan. Every task requires a design memo. After the complete plan is written, run `lattice plan scope-review` and confirm that every task preserves an owner-supplied work specification without adding a product purpose. あなたがこのToDoに対して、何も考えていないならば、設計メモに `NO_PLAN` と書いてください",
|
|
6
6
|
"$comment": "Runtime validation additionally enforces canonical JSON+LF bytes, sorted identifiers and edges, unique ids, combined task/phase acyclicity, byte bounds, non-empty design_memo, and input_digest.",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"additionalProperties": false,
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://github.com/kitepon-rgb/Lattice/blob/main/docs/schemas/lattice.plan_scope_review.v1.schema.json",
|
|
4
|
+
"title": "lattice.plan_scope_review.v1",
|
|
5
|
+
"description": "AI-authored review performed after the complete plan is written and before it is registered. Every planned task is judged against the owner-supplied work specifications; task splitting and parallelization are allowed, but a new product purpose is not.",
|
|
6
|
+
"$comment": "Lattice validates complete task coverage, known work-spec references, verdict consistency, and digest binding. The operating AI owns the semantic judgment.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"required": [
|
|
10
|
+
"schema", "authoring_digest", "work_specs", "task_assessments", "verdict", "review_digest"
|
|
11
|
+
],
|
|
12
|
+
"properties": {
|
|
13
|
+
"schema": { "const": "lattice.plan_scope_review.v1" },
|
|
14
|
+
"authoring_digest": { "$ref": "#/$defs/digest" },
|
|
15
|
+
"work_specs": {
|
|
16
|
+
"type": "array", "minItems": 1, "maxItems": 512,
|
|
17
|
+
"description": "The owner-supplied work specifications. Do not add inferred improvements as work specifications.",
|
|
18
|
+
"items": { "$ref": "#/$defs/workSpec" }
|
|
19
|
+
},
|
|
20
|
+
"task_assessments": {
|
|
21
|
+
"type": "array", "minItems": 1, "maxItems": 512,
|
|
22
|
+
"description": "Exactly one assessment for every task that will be registered. Use out_of_scope when the task creates a purpose not required by any work specification.",
|
|
23
|
+
"items": { "$ref": "#/$defs/taskAssessment" }
|
|
24
|
+
},
|
|
25
|
+
"verdict": { "enum": ["scope_preserved", "scope_mismatch"] },
|
|
26
|
+
"review_digest": { "$ref": "#/$defs/digest" }
|
|
27
|
+
},
|
|
28
|
+
"$defs": {
|
|
29
|
+
"identifier": { "type": "string", "pattern": "^[0-9A-Za-z](?:[0-9A-Za-z._-]{0,127})$" },
|
|
30
|
+
"digest": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
|
|
31
|
+
"text": { "type": "string", "minLength": 1, "maxLength": 16384, "pattern": "\\S" },
|
|
32
|
+
"workSpec": {
|
|
33
|
+
"type": "object", "additionalProperties": false,
|
|
34
|
+
"required": ["work_spec_id", "requirement", "acceptance"],
|
|
35
|
+
"properties": {
|
|
36
|
+
"work_spec_id": { "$ref": "#/$defs/identifier" },
|
|
37
|
+
"requirement": { "$ref": "#/$defs/text" },
|
|
38
|
+
"acceptance": { "$ref": "#/$defs/text" }
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"taskAssessment": {
|
|
42
|
+
"type": "object", "additionalProperties": false,
|
|
43
|
+
"required": ["task_id", "work_spec_ids", "judgment", "reason"],
|
|
44
|
+
"properties": {
|
|
45
|
+
"task_id": { "$ref": "#/$defs/identifier" },
|
|
46
|
+
"work_spec_ids": {
|
|
47
|
+
"type": "array", "maxItems": 512, "uniqueItems": true,
|
|
48
|
+
"items": { "$ref": "#/$defs/identifier" }
|
|
49
|
+
},
|
|
50
|
+
"judgment": { "enum": ["required", "out_of_scope"] },
|
|
51
|
+
"reason": { "$ref": "#/$defs/text" }
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"$id": "https://github.com/kitepon-rgb/Lattice/blob/main/docs/schemas/lattice.todo_extraction.v3.schema.json",
|
|
4
4
|
"title": "lattice.todo_extraction.v3",
|
|
5
|
-
"description": "AI-authored ToDo migration artifact. Every task carries a non-blank Markdown design_memo. If no plan exists, write NO_PLAN explicitly.",
|
|
5
|
+
"description": "AI-authored ToDo migration artifact. Every task carries a non-blank Markdown design_memo. After the complete plan is written, run `lattice plan scope-review` and confirm that every registered task preserves an owner-supplied work specification without adding a product purpose. If no plan exists, write NO_PLAN explicitly.",
|
|
6
6
|
"$comment": "あなたがこのToDoに対して、何も考えていないならば、設計メモに `NO_PLAN` と書いてください。Runtime validation also enforces UTF-8 byte bounds, exact keys, strict sort order, referential integrity, disposition consistency, and the canonical self-digest.",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"additionalProperties": false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quolu/lattice",
|
|
3
|
-
"version": "0.59.
|
|
3
|
+
"version": "0.59.1",
|
|
4
4
|
"description": "Schedulability compiler for multi-agent development: observe real code boundaries, refactor the conflicting seam, recompile the plan for parallel execution",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Quo / クオ at kitepon.dev",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"docs/schemas/lattice.plan_create_input.v2.schema.json",
|
|
30
30
|
"docs/schemas/lattice.plan_create_input.v3.schema.json",
|
|
31
31
|
"docs/schemas/lattice.plan_create_input.v4.schema.json",
|
|
32
|
+
"docs/schemas/lattice.plan_scope_review.v1.schema.json",
|
|
32
33
|
"docs/schemas/lattice.todo_revision.v2.schema.json",
|
|
33
34
|
"docs/schemas/lattice.todo_revision_set.v3.schema.json",
|
|
34
35
|
"docs/schemas/lattice.phase_todo_revision.v3.schema.json",
|
package/src/cli-help.mjs
CHANGED
|
@@ -202,6 +202,7 @@ const SUBCOMMAND_USAGE = Object.freeze({
|
|
|
202
202
|
'session-context': 'session-context --json',
|
|
203
203
|
'plan create': 'plan create --input <file> [--serialization-reviewed] | --schema --json | --schema-version <1|2|3|4> --json',
|
|
204
204
|
'plan show': 'plan show <plan_key> --json',
|
|
205
|
+
'plan scope-review': 'plan scope-review --plan-input <plan-create-or-extraction.json> --review <scope-review.json> --json | --schema --json',
|
|
205
206
|
'plan compile': 'plan compile --request <request.json> | --schema --json',
|
|
206
207
|
'plan verify': 'plan verify --request <request.json> --plan <plan.json>',
|
|
207
208
|
'run start': 'run start --request <request.json> --executor <adapter>'
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { constants as fsConstants } from 'node:fs';
|
|
2
|
+
import { lstat, open, realpath, readFile } from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
|
|
5
|
+
import { gitSync } from './git-process.mjs';
|
|
6
|
+
import {
|
|
7
|
+
exactRecord,
|
|
8
|
+
isTodoDigest,
|
|
9
|
+
isTodoIdentifier,
|
|
10
|
+
isTodoRef,
|
|
11
|
+
todoSelfDigest,
|
|
12
|
+
} from './todo-contracts.mjs';
|
|
13
|
+
import { TodoStoreError } from './todo-store.mjs';
|
|
14
|
+
|
|
15
|
+
const REVIEW_SCHEMA = 'lattice.plan_scope_review.v1';
|
|
16
|
+
const RESULT_SCHEMA = 'lattice.plan_scope_review_result.v1';
|
|
17
|
+
const PLAN_CREATE_SCHEMA = 'lattice.plan_create_input.v4';
|
|
18
|
+
const TODO_EXTRACTION_SCHEMA = 'lattice.todo_extraction.v3';
|
|
19
|
+
const MAX_INPUT_BYTES = 8_388_608;
|
|
20
|
+
const JUDGMENTS = new Set(['required', 'out_of_scope']);
|
|
21
|
+
|
|
22
|
+
function boundedText(value) {
|
|
23
|
+
return typeof value === 'string' && value.trim().length > 0
|
|
24
|
+
&& Buffer.byteLength(value) <= 16_384;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function sortedStrictly(values, key = (value) => value) {
|
|
28
|
+
return values.every((value, index) => index === 0 || key(values[index - 1]) < key(value));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function within(root, candidate) {
|
|
32
|
+
return candidate.startsWith(`${root}${path.sep}`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function resolveRepoRoot(cwd) {
|
|
36
|
+
try {
|
|
37
|
+
return path.resolve(gitSync(['rev-parse', '--show-toplevel'], {
|
|
38
|
+
cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'],
|
|
39
|
+
}).replace(/\r?\n$/u, ''));
|
|
40
|
+
} catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function readJsonWithinRepo(repoRoot, inputRef) {
|
|
46
|
+
if (!isTodoRef(inputRef)) {
|
|
47
|
+
throw new TodoStoreError('INPUT_UNREADABLE', 'input_path_outside_repo', undefined,
|
|
48
|
+
{ input_ref: inputRef });
|
|
49
|
+
}
|
|
50
|
+
const canonicalRoot = await realpath(repoRoot);
|
|
51
|
+
const absolute = path.resolve(canonicalRoot, inputRef);
|
|
52
|
+
if (!within(canonicalRoot, absolute)) {
|
|
53
|
+
throw new TodoStoreError('INPUT_UNREADABLE', 'input_path_outside_repo', undefined,
|
|
54
|
+
{ input_ref: inputRef });
|
|
55
|
+
}
|
|
56
|
+
let stats;
|
|
57
|
+
try { stats = await lstat(absolute); } catch {
|
|
58
|
+
throw new TodoStoreError('INPUT_UNREADABLE', 'input_unreadable', undefined,
|
|
59
|
+
{ input_ref: inputRef });
|
|
60
|
+
}
|
|
61
|
+
if (!stats.isFile() || stats.isSymbolicLink() || stats.size > MAX_INPUT_BYTES
|
|
62
|
+
|| await realpath(absolute) !== absolute) {
|
|
63
|
+
throw new TodoStoreError('INPUT_UNREADABLE', 'input_path_unsafe', undefined,
|
|
64
|
+
{ input_ref: inputRef });
|
|
65
|
+
}
|
|
66
|
+
let value;
|
|
67
|
+
try { value = JSON.parse(await readFile(absolute, 'utf8')); } catch {
|
|
68
|
+
throw new TodoStoreError('INPUT_INVALID', 'input_json_invalid', undefined,
|
|
69
|
+
{ input_ref: inputRef });
|
|
70
|
+
}
|
|
71
|
+
return value;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function authoredPlan(value) {
|
|
75
|
+
const digestField = value?.schema === PLAN_CREATE_SCHEMA ? 'input_digest'
|
|
76
|
+
: value?.schema === TODO_EXTRACTION_SCHEMA ? 'extraction_digest' : null;
|
|
77
|
+
if (digestField === null) {
|
|
78
|
+
throw new TodoStoreError('PLAN_SCOPE_REVIEW_INVALID', 'authoring_schema_unsupported', undefined, {
|
|
79
|
+
pointer: '/schema', expected: [PLAN_CREATE_SCHEMA, TODO_EXTRACTION_SCHEMA],
|
|
80
|
+
actual: typeof value?.schema === 'string' ? value.schema : null,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
if (!isTodoDigest(value[digestField])
|
|
84
|
+
|| value[digestField] !== todoSelfDigest(value, digestField)) {
|
|
85
|
+
throw new TodoStoreError('PLAN_SCOPE_REVIEW_INVALID', 'authoring_digest_mismatch', undefined, {
|
|
86
|
+
pointer: `/${digestField}`,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
const selected = value.schema === TODO_EXTRACTION_SCHEMA
|
|
90
|
+
? value.tasks?.filter((task) => typeof task?.disposition === 'string'
|
|
91
|
+
&& task.disposition.startsWith('register_'))
|
|
92
|
+
: value.tasks;
|
|
93
|
+
if (!Array.isArray(selected) || selected.length === 0
|
|
94
|
+
|| selected.some((task) => !isTodoIdentifier(task?.task_id))) {
|
|
95
|
+
throw new TodoStoreError('PLAN_SCOPE_REVIEW_INVALID', 'authoring_tasks_invalid', undefined, {
|
|
96
|
+
pointer: '/tasks',
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
const taskIds = selected.map(({ task_id: taskId }) => taskId).sort();
|
|
100
|
+
if (new Set(taskIds).size !== taskIds.length) {
|
|
101
|
+
throw new TodoStoreError('PLAN_SCOPE_REVIEW_INVALID', 'authoring_task_ids_duplicate', undefined, {
|
|
102
|
+
pointer: '/tasks',
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
return { schema: value.schema, digest: value[digestField], taskIds };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function invalid(reason, pointer, detail = {}) {
|
|
109
|
+
throw new TodoStoreError('PLAN_SCOPE_REVIEW_INVALID', reason, undefined, { pointer, ...detail });
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function validateReview(review, authored) {
|
|
113
|
+
if (!exactRecord(review, [
|
|
114
|
+
'schema', 'authoring_digest', 'work_specs', 'task_assessments', 'verdict', 'review_digest',
|
|
115
|
+
]) || review.schema !== REVIEW_SCHEMA) invalid('review_schema_invalid', '/schema');
|
|
116
|
+
if (!isTodoDigest(review.authoring_digest) || review.authoring_digest !== authored.digest) {
|
|
117
|
+
invalid('review_authoring_digest_mismatch', '/authoring_digest', {
|
|
118
|
+
expected: authored.digest, actual: review.authoring_digest ?? null,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
if (!isTodoDigest(review.review_digest)
|
|
122
|
+
|| review.review_digest !== todoSelfDigest(review, 'review_digest')) {
|
|
123
|
+
invalid('review_digest_mismatch', '/review_digest');
|
|
124
|
+
}
|
|
125
|
+
if (!Array.isArray(review.work_specs) || review.work_specs.length === 0
|
|
126
|
+
|| !review.work_specs.every((spec) => exactRecord(spec, [
|
|
127
|
+
'work_spec_id', 'requirement', 'acceptance',
|
|
128
|
+
]) && isTodoIdentifier(spec.work_spec_id) && boundedText(spec.requirement)
|
|
129
|
+
&& boundedText(spec.acceptance))
|
|
130
|
+
|| !sortedStrictly(review.work_specs, ({ work_spec_id: id }) => id)) {
|
|
131
|
+
invalid('work_specs_invalid', '/work_specs');
|
|
132
|
+
}
|
|
133
|
+
const workSpecIds = new Set(review.work_specs.map(({ work_spec_id: id }) => id));
|
|
134
|
+
if (!Array.isArray(review.task_assessments)
|
|
135
|
+
|| !review.task_assessments.every((assessment) => exactRecord(assessment, [
|
|
136
|
+
'task_id', 'work_spec_ids', 'judgment', 'reason',
|
|
137
|
+
]) && isTodoIdentifier(assessment.task_id) && Array.isArray(assessment.work_spec_ids)
|
|
138
|
+
&& assessment.work_spec_ids.every(isTodoIdentifier)
|
|
139
|
+
&& sortedStrictly(assessment.work_spec_ids) && JUDGMENTS.has(assessment.judgment)
|
|
140
|
+
&& boundedText(assessment.reason)
|
|
141
|
+
&& (assessment.judgment === 'required'
|
|
142
|
+
? assessment.work_spec_ids.length > 0 : assessment.work_spec_ids.length === 0)
|
|
143
|
+
&& assessment.work_spec_ids.every((id) => workSpecIds.has(id)))
|
|
144
|
+
|| !sortedStrictly(review.task_assessments, ({ task_id: id }) => id)) {
|
|
145
|
+
invalid('task_assessments_invalid', '/task_assessments');
|
|
146
|
+
}
|
|
147
|
+
const assessedTaskIds = review.task_assessments.map(({ task_id: id }) => id);
|
|
148
|
+
if (assessedTaskIds.length !== authored.taskIds.length
|
|
149
|
+
|| assessedTaskIds.some((id, index) => id !== authored.taskIds[index])) {
|
|
150
|
+
invalid('task_assessments_incomplete', '/task_assessments', {
|
|
151
|
+
expected_task_ids: authored.taskIds, actual_task_ids: assessedTaskIds,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
const outOfScopeTaskIds = review.task_assessments
|
|
155
|
+
.filter(({ judgment }) => judgment === 'out_of_scope')
|
|
156
|
+
.map(({ task_id: id }) => id);
|
|
157
|
+
const covered = new Set(review.task_assessments.flatMap(({ work_spec_ids: ids }) => ids));
|
|
158
|
+
const uncoveredWorkSpecIds = [...workSpecIds].filter((id) => !covered.has(id));
|
|
159
|
+
const expectedVerdict = outOfScopeTaskIds.length === 0 && uncoveredWorkSpecIds.length === 0
|
|
160
|
+
? 'scope_preserved' : 'scope_mismatch';
|
|
161
|
+
if (review.verdict !== expectedVerdict) {
|
|
162
|
+
invalid('review_verdict_inconsistent', '/verdict', {
|
|
163
|
+
expected: expectedVerdict, actual: review.verdict ?? null,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return { outOfScopeTaskIds, uncoveredWorkSpecIds };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export function evaluatePlanScopeReview(planInput, review) {
|
|
170
|
+
const authored = authoredPlan(planInput);
|
|
171
|
+
const findings = validateReview(review, authored);
|
|
172
|
+
const result = {
|
|
173
|
+
schema: RESULT_SCHEMA,
|
|
174
|
+
authoring_schema: authored.schema,
|
|
175
|
+
authoring_digest: authored.digest,
|
|
176
|
+
work_spec_count: review.work_specs.length,
|
|
177
|
+
reviewed_task_count: review.task_assessments.length,
|
|
178
|
+
verdict: review.verdict,
|
|
179
|
+
accepted: review.verdict === 'scope_preserved',
|
|
180
|
+
out_of_scope_task_ids: findings.outOfScopeTaskIds,
|
|
181
|
+
uncovered_work_spec_ids: findings.uncoveredWorkSpecIds,
|
|
182
|
+
review_digest: review.review_digest,
|
|
183
|
+
result_digest: '',
|
|
184
|
+
};
|
|
185
|
+
result.result_digest = todoSelfDigest(result, 'result_digest');
|
|
186
|
+
return result;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export async function runPlanScopeReview({ cwd, planInputRef, reviewRef, stdout }) {
|
|
190
|
+
const repoRoot = resolveRepoRoot(cwd);
|
|
191
|
+
if (repoRoot === null) throw new TodoStoreError('REPO_UNRESOLVED', 'git_toplevel_unresolved');
|
|
192
|
+
const [planInput, review] = await Promise.all([
|
|
193
|
+
readJsonWithinRepo(repoRoot, planInputRef), readJsonWithinRepo(repoRoot, reviewRef),
|
|
194
|
+
]);
|
|
195
|
+
const result = evaluatePlanScopeReview(planInput, review);
|
|
196
|
+
stdout.write(`${JSON.stringify(result)}\n`);
|
|
197
|
+
return result.accepted ? 0 : 1;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export async function runPlanScopeReviewSchema({ stdout }) {
|
|
201
|
+
const schemaUrl = new URL('../docs/schemas/lattice.plan_scope_review.v1.schema.json', import.meta.url);
|
|
202
|
+
const handle = await open(schemaUrl, fsConstants.O_RDONLY);
|
|
203
|
+
try {
|
|
204
|
+
const schema = JSON.parse(await handle.readFile('utf8'));
|
|
205
|
+
if (schema?.title !== REVIEW_SCHEMA) throw new TypeError('bundled plan scope review schema invalid');
|
|
206
|
+
stdout.write(`${JSON.stringify(schema)}\n`);
|
|
207
|
+
return 0;
|
|
208
|
+
} finally {
|
|
209
|
+
await handle.close();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
@@ -642,7 +642,7 @@ export function validateExecutorPacket(value) {
|
|
|
642
642
|
&& identifier(packet.plan_ref)
|
|
643
643
|
&& nonNegativeInteger(packet.plan_epoch)
|
|
644
644
|
&& boundedArray(packet.verifier_refs, (entry) => typeof entry === 'string')
|
|
645
|
-
&& boundedArray(packet.forbidden_operations, (entry) => typeof entry === 'string'
|
|
645
|
+
&& boundedArray(packet.forbidden_operations, (entry) => typeof entry === 'string')
|
|
646
646
|
&& packet.context_content_digest === computeContextContentDigest(packet)
|
|
647
647
|
&& selfDigestValid(packet, 'packet_digest')
|
|
648
648
|
));
|
package/src/runtime-engine.mjs
CHANGED
|
@@ -32,18 +32,10 @@ import {
|
|
|
32
32
|
|
|
33
33
|
const ENGINE_ACTOR = 'lattice-runtime';
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* `commit`は含めない。自分の隔離worktreeでdetached HEADへ進めるcommitは、canonical branchを
|
|
38
|
-
* 動かさず外部へ効果を出さない一方で、進行中の成果を耐久化し、diff観測が生み出した木そのものを
|
|
39
|
-
* 縛れるようにする(ADR 0139)。
|
|
40
|
-
*
|
|
41
|
-
* 禁止のままにするのは、HEADをbaseの子孫から外す操作と、外部へ効果を出す操作である。
|
|
42
|
-
* 前者は観測の前提を壊し、後者は承認なしに行わないという公開契約に当たる。
|
|
35
|
+
* v1 packetの互換field。操作権限はhostへ委ね、Latticeからは禁止操作を配らない。
|
|
36
|
+
* worktree観測に必要な前提は、実際のHEADとdiffを観測して判定する(ADR 0178)。
|
|
43
37
|
*/
|
|
44
|
-
const FORBIDDEN_OPERATIONS = Object.freeze([
|
|
45
|
-
'push', 'branch', 'merge', 'rebase', 'reset', 'stash',
|
|
46
|
-
]);
|
|
38
|
+
const FORBIDDEN_OPERATIONS = Object.freeze([]);
|
|
47
39
|
|
|
48
40
|
function fail(reason) {
|
|
49
41
|
throw new TypeError(`runtime engine契約違反: ${reason}`);
|
|
@@ -57,7 +57,7 @@ export function validateRunWorkOrder(value) {
|
|
|
57
57
|
&& GIT_SHA1.test(value.base_sha ?? '')
|
|
58
58
|
&& stringArray(value.scope_writes, { paths: true })
|
|
59
59
|
&& stringArray(value.verifier_refs)
|
|
60
|
-
&& stringArray(value.forbidden_operations
|
|
60
|
+
&& stringArray(value.forbidden_operations)
|
|
61
61
|
&& SHA256.test(value.packet_digest ?? '')
|
|
62
62
|
&& SHA256.test(value.order_digest ?? '')
|
|
63
63
|
&& selfDigest(value, 'order_digest') === value.order_digest;
|