@quolu/lattice 0.84.1 → 0.85.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/README.ja.md +2 -1
- package/bin/lattice.mjs +11 -2
- package/docs/schemas/lattice.plan_create_input.v4.schema.json +1 -1
- package/docs/schemas/lattice.plan_create_input.v5.schema.json +1 -3
- package/docs/schemas/lattice.plan_revise_input.v1.schema.json +1 -1
- package/docs/schemas/lattice.todo_extraction.v3.schema.json +1 -1
- package/docs/schemas/lattice.todo_extraction.v4.schema.json +1 -1
- package/package.json +1 -1
- package/src/cli-help.mjs +7 -5
- package/src/cli-refusal-guidance.mjs +31 -3
- package/src/hooks-cli.mjs +6 -1
- package/src/plan-backchain.mjs +21 -3
- package/src/plan-revise.mjs +13 -4
- package/src/project-cli.mjs +42 -19
- package/src/runtime-errors.mjs +2 -2
- package/src/runtime-pull-intake.mjs +2 -2
- package/src/seam-proposal-contracts.mjs +2 -1
- package/src/setup-cli.mjs +1 -0
- package/src/todo-authoring-input.mjs +13 -3
- package/src/todo-cli.mjs +213 -80
- package/src/todo-independence-contracts.mjs +4 -1
- package/src/todo-independence-guidance.mjs +43 -38
- package/src/todo-store.mjs +14 -4
- package/src/windows-owner-only.mjs +33 -8
package/README.ja.md
CHANGED
|
@@ -249,7 +249,8 @@ lattice plan create --template --json # 作者が書くkeyだけの最
|
|
|
249
249
|
```
|
|
250
250
|
|
|
251
251
|
```bash
|
|
252
|
-
lattice plan create --
|
|
252
|
+
lattice plan create --template --json > plan.json # 書き換えてから作成する。project_id・plan_versionは機械が決める
|
|
253
|
+
lattice plan create --input plan.json
|
|
253
254
|
```
|
|
254
255
|
|
|
255
256
|
`invalid`をMarkdown fallbackへ丸めず、`next_action`に従ってstoreを診断してください。
|
package/bin/lattice.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import packageJson from '../package.json' with { type: 'json' };
|
|
|
7
7
|
|
|
8
8
|
installPipeCloseGuard();
|
|
9
9
|
|
|
10
|
-
const args = process.argv.slice(2);
|
|
10
|
+
const args = withImpliedJson(process.argv.slice(2));
|
|
11
11
|
// 作業ディレクトリを読まないsurface。cwdが消えた席(閉じたworktree)からでも動かす。
|
|
12
12
|
const CWD_FREE_COMMANDS = new Set(['runtime-errors', 'bridge', 'hooks', 'setup', 'factory-diagnostics']);
|
|
13
13
|
// 内部故障の観測(下のobserveInternalFailure)が終わるのを、exit前に待つための置き場。
|
|
@@ -77,7 +77,7 @@ if (help !== null) {
|
|
|
77
77
|
&& args[2] === '--template' && args[3] === '--json') {
|
|
78
78
|
const { projectCliFailure, runPlanCreateTemplate } = await import('../src/project-cli.mjs');
|
|
79
79
|
try {
|
|
80
|
-
process.exitCode = await runPlanCreateTemplate({ stdout: process.stdout });
|
|
80
|
+
process.exitCode = await runPlanCreateTemplate({ stdout: process.stdout, cwd: process.cwd() });
|
|
81
81
|
} catch (error) {
|
|
82
82
|
process.exitCode = projectCliFailure(process.stderr, error);
|
|
83
83
|
}
|
|
@@ -276,6 +276,15 @@ function observeInternalFailure(error, commandKind) {
|
|
|
276
276
|
}).catch(() => {});
|
|
277
277
|
}
|
|
278
278
|
|
|
279
|
+
// These reads and sensor commands only ever print JSON, so a missing --json is implied.
|
|
280
|
+
function withImpliedJson(argv) {
|
|
281
|
+
if (argv.includes('--json') || argv.some((word) => word.startsWith('-'))) return argv;
|
|
282
|
+
const implied = (argv.length === 1 && (argv[0] === 'status' || argv[0] === 'session-context'))
|
|
283
|
+
|| (argv.length === 3 && argv[0] === 'plan' && argv[1] === 'show')
|
|
284
|
+
|| (argv[0] === 'sensor' && (argv[1] === 'init' || argv[1] === 'sync') && argv.length <= 3);
|
|
285
|
+
return implied ? [...argv, '--json'] : argv;
|
|
286
|
+
}
|
|
287
|
+
|
|
279
288
|
function workingDirectory() {
|
|
280
289
|
try {
|
|
281
290
|
return process.cwd();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"$id": "https://github.com/kitepon/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. 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` と書いてください actor, recorded_at, input_digest and tasks[].design_memo may be omitted: the machine fills the seat actor, the current time and NO_PLAN, recomputes input_digest and sorts every list into canonical order.",
|
|
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 --plan-input <file> --review <scope-review.json> --json` (the review input: `lattice plan scope-review --schema --json`) and confirm that every task preserves an owner-supplied work specification without adding a product purpose. あなたがこのToDoに対して、何も考えていないならば、設計メモに `NO_PLAN` と書いてください actor, recorded_at, input_digest and tasks[].design_memo may be omitted: the machine fills the seat actor, the current time and NO_PLAN, recomputes input_digest and sorts every list into canonical order.",
|
|
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 (omitted, null or blank becomes NO_PLAN), and input_digest (recomputed). tasks, hard_dependencies, joins, phases and phase_accept_dependencies are sorted into canonical order and exact duplicates dropped before validation.",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"additionalProperties": false,
|
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"$id": "https://github.com/kitepon/Lattice/blob/main/docs/schemas/lattice.plan_create_input.v5.schema.json",
|
|
4
4
|
"title": "lattice.plan_create_input.v5",
|
|
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` と書いてください v5 adds the per-task authored `done_condition`: plain text (or null when the author states none) that Lattice records and shows but never evaluates, never assigns and never records as done. Builds lattice.todo_plan.v8. The author writes intent: ids, titles, phases and edges (see `lattice plan create --template --json`). Every key whose value is constant or null may be omitted and the machine fills it: schema (this version), actor (the seat actor), recorded_at (the current time; an ISO-8601 date-time with an explicit zone is normalised to UTC milliseconds), input_digest (recomputed), tasks[].design_memo (NO_PLAN), tasks[].lane (main), tasks[].narrative_ref, narrative_anchor, compile_binding, parent_task_id and done_condition (null), phases[].gate_policy (heavy), phases[].predecessor_phase_ids ([]), phases[].required_evidence_slots ([\"acceptance\"]), hard_dependencies, joins and phase_accept_dependencies ([]), and project_id/plan_key of an edge reference (this input's own). Every list is sorted into canonical order. A refusal lists every problem at once in detail.problems. Edge direction: from is the prerequisite; to starts after from is done.",
|
|
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 --plan-input <file> --review <scope-review.json> --json` (the review input: `lattice plan scope-review --schema --json`) and confirm that every task preserves an owner-supplied work specification without adding a product purpose. あなたがこのToDoに対して、何も考えていないならば、設計メモに `NO_PLAN` と書いてください v5 adds the per-task authored `done_condition`: plain text (or null when the author states none) that Lattice records and shows but never evaluates, never assigns and never records as done. Builds lattice.todo_plan.v8. The author writes intent: ids, titles, phases and edges (see `lattice plan create --template --json`). Every key whose value is constant or null may be omitted and the machine fills it: schema (this version), project_id (the store's project id; with no store yet, the repository directory name as a lower-case identifier; a different value is refused as project_id_mismatch), plan_version (v1; `lattice plan revise` uses the active plan's), actor (the seat actor), recorded_at (the current time; an ISO-8601 date-time with an explicit zone is normalised to UTC milliseconds), input_digest (recomputed), tasks[].design_memo (NO_PLAN), tasks[].lane (main), tasks[].narrative_ref, narrative_anchor, compile_binding, parent_task_id and done_condition (null), phases[].gate_policy (heavy), phases[].predecessor_phase_ids ([]), phases[].required_evidence_slots ([\"acceptance\"]), hard_dependencies, joins and phase_accept_dependencies ([]), and project_id/plan_key of an edge reference (this input's own). Every list is sorted into canonical order. A refusal lists every problem at once in detail.problems. Edge direction: from is the prerequisite; to starts after from is done.",
|
|
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 (omitted, null or blank becomes NO_PLAN), and input_digest (recomputed). v5 additionally accepts hard_dependencies, joins, each joins[].after, phase_accept_dependencies, phases, phases[].predecessor_phase_ids and phases[].required_evidence_slots in any order or with exact duplicates: they are sorted into canonical order and de-duplicated before validation. tasks are sorted by task_id. Entries with the same key but different content are still refused.",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"additionalProperties": false,
|
|
9
9
|
"required": [
|
|
10
|
-
"project_id",
|
|
11
10
|
"plan_key",
|
|
12
|
-
"plan_version",
|
|
13
11
|
"tasks",
|
|
14
12
|
"phases"
|
|
15
13
|
],
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"$ref": "lattice.plan_create_input.v5.schema.json"
|
|
23
23
|
}
|
|
24
24
|
],
|
|
25
|
-
"description": "同じ
|
|
25
|
+
"description": "同じplan_keyのcreate-v4またはv5入力。project_idとplan_versionは書かなければ現行planの値で機械が補う(project_idを書くなら現行planと同じ値)。actor・recorded_at・input_digest・空の設計メモは機械が補い、集合と配列の並びは正準化する。v5は終了条件done_conditionを持つ(plan v8を作る)。v4でも先行planがv8なら、書かない終了条件は先行planの値を引き継ぐ。plan_versionは入力形を保つために記載し、後継versionは機械算出値に置き換える。新taskはpending。消すtaskへの参照も明示的に取り除く。"
|
|
26
26
|
},
|
|
27
27
|
"continuity": {
|
|
28
28
|
"type": "array",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"$id": "https://github.com/kitepon/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. 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.",
|
|
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 --plan-input <file> --review <scope-review.json> --json` (the review input: `lattice plan scope-review --schema --json`) 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,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"$id": "https://github.com/kitepon/Lattice/blob/main/docs/schemas/lattice.todo_extraction.v4.schema.json",
|
|
4
4
|
"title": "lattice.todo_extraction.v4",
|
|
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. Runtime validation accepts at most one explicit, reasoned cross-plan dependency; an empty tasks array is reserved for that one dependency between existing tasks, with the top-level plan identity naming the source plan and both endpoint topology digests.",
|
|
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 --plan-input <file> --review <scope-review.json> --json` (the review input: `lattice plan scope-review --schema --json`) 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. Runtime validation accepts at most one explicit, reasoned cross-plan dependency; an empty tasks array is reserved for that one dependency between existing tasks, with the top-level plan identity naming the source plan and both endpoint topology digests.",
|
|
6
6
|
"$comment": "あなたがこのToDoに対して、何も考えていないならば、設計メモに `NO_PLAN` と書いてください。Runtime validation also enforces UTF-8 byte bounds, exact keys, strict sort order, referential integrity, disposition consistency, the cross-plan dependency limit, 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.
|
|
3
|
+
"version": "0.85.0",
|
|
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",
|
package/src/cli-help.mjs
CHANGED
|
@@ -101,7 +101,7 @@ Write commands:
|
|
|
101
101
|
# ToDoへ作業継続に必要な方針・調査結果・注意をappend-onlyで追記する
|
|
102
102
|
migrate --input <extraction.json> [--serialization-reviewed] [--json]
|
|
103
103
|
migrate --input <extraction.json> --dry-run --json [--serialization-reviewed]
|
|
104
|
-
# 既存storeへplanを追加する(plan create
|
|
104
|
+
# 既存storeへplanを追加する(extractionからの取り込み。新規planの作成はplan create)。
|
|
105
105
|
# pretty-print・digest未計算・repo内絶対pathは機械が直す。空の設計メモは拒否する。
|
|
106
106
|
# 結果へdispatch_shapeを載せる。--serialization-reviewedは互換のため受理するだけで門ではない
|
|
107
107
|
start --plan <key> --task <id> [--parallel-frontier|--override-reason <text> [--serial-confirmed]]
|
|
@@ -160,7 +160,8 @@ Write commands:
|
|
|
160
160
|
# 自動実行はしない(明示コマンドのみ)。--exceptで指定したplanは対象から除外する
|
|
161
161
|
|
|
162
162
|
Write commandsはLATTICE_TODO_ACTOR_HOST / SESSION / AGENTを受理する。
|
|
163
|
-
|
|
163
|
+
欠落、またはidentifierとして不正な値はunsetと同じに扱い(拒否しない)、host/session/agentのdefaultを使う。
|
|
164
|
+
agentのdefaultはLATTICE_SEAT_IDがあればその席id、なければOSのuser名。
|
|
164
165
|
|
|
165
166
|
storeだけを書き換えるcommandの末尾へ--commit-storeを付けると、共有Git lockを取得し、
|
|
166
167
|
生じた.lattice/todoの変更だけをcommitしてreceiptを返す。
|
|
@@ -172,8 +173,6 @@ ${TODO_INDEPENDENCE_WORKFLOW.join('\n')}
|
|
|
172
173
|
|
|
173
174
|
判定していない工程は「競合が無い」ではなく「未検査」として扱われ、
|
|
174
175
|
todo startのadvisoryとtodo independenceの投影が、その状況と次の一歩を返す。
|
|
175
|
-
記録があるのに対象工程が未宣言・失効なら todo start は拒否する。
|
|
176
|
-
next_ready が witness に無い independence compile も拒否する。
|
|
177
176
|
競合の同時起動は助言のまま。並列既定はstatusのdispatch_frontierとnext_actionが案内する。
|
|
178
177
|
`,
|
|
179
178
|
sensor: `Usage: lattice sensor <init|sync> [path] --json
|
|
@@ -306,7 +305,10 @@ const SUBCOMMAND_USAGE = Object.freeze({
|
|
|
306
305
|
'todo reopen': 'todo reopen --plan <key> --task <id> --reason <text> [--override-reason <text>]',
|
|
307
306
|
'todo evidence': 'todo evidence promote --plan <key> --task <id> --evidence <file>',
|
|
308
307
|
'todo evidence promote': 'todo evidence promote --plan <key> --task <id> --evidence <file>',
|
|
309
|
-
'todo dependency':
|
|
308
|
+
'todo dependency': [
|
|
309
|
+
'todo dependency connect --from-plan <key> --from-task <id> --to-plan <key> --to-task <id> --reason <text>',
|
|
310
|
+
'todo dependency disconnect --from-plan <key> --from-task <id> --to-plan <key> --to-task <id> --reason <text>',
|
|
311
|
+
].join('\n lattice '),
|
|
310
312
|
'todo dependency connect': 'todo dependency connect --from-plan <key> --from-task <id> --to-plan <key> --to-task <id> --reason <text>',
|
|
311
313
|
'todo dependency disconnect': 'todo dependency disconnect --from-plan <key> --from-task <id> --to-plan <key> --to-task <id> --reason <text>',
|
|
312
314
|
'todo split': 'todo split --plan <key> --input <file>',
|
|
@@ -18,10 +18,36 @@ const showTask = (detail, ctx) => `lattice todo show --plan ${planOf(detail, ctx
|
|
|
18
18
|
const startTask = (detail, ctx) => `lattice todo start --plan ${planOf(detail, ctx)} --task ${taskOf(detail, ctx)}`;
|
|
19
19
|
// a12: name the blocking task (seat contract), falling back to the refused task's own detail.
|
|
20
20
|
const blocker = (detail) => (Array.isArray(detail.blocking_tasks) ? detail.blocking_tasks.find(record) : undefined);
|
|
21
|
+
// a18: the step that moves the blocker on depends on its status (a pending one is started first).
|
|
21
22
|
const unfinishedFirst = (detail, ctx) => {
|
|
22
23
|
const first = blocker(detail);
|
|
23
24
|
if (first === undefined) return `Record done on its unfinished predecessors first (see \`${showTask(detail, ctx)}\`)`;
|
|
24
|
-
|
|
25
|
+
const name = `${first.plan_key}/${first.task_id} (${first.status})`;
|
|
26
|
+
const on = `--plan ${first.plan_key} --task ${first.task_id}`;
|
|
27
|
+
return ({
|
|
28
|
+
pending: `Start ${name} first with \`lattice todo start ${on}\`, then record done on it`,
|
|
29
|
+
blocked: `Unblock ${name} with \`lattice todo unblock ${on}\`, then record done on it`,
|
|
30
|
+
})[first.status] ?? `Record done on ${name} first with \`lattice todo done ${on} --message <text>\` (see \`lattice todo show ${on} --json\`)`;
|
|
31
|
+
};
|
|
32
|
+
const startState = (detail, ctx) => {
|
|
33
|
+
const on = `--plan ${planOf(detail, ctx)} --task ${taskOf(detail, ctx)}`;
|
|
34
|
+
return ({
|
|
35
|
+
blocked: `It is blocked: run \`lattice todo unblock ${on}\`; that resumes it (no start needed).`,
|
|
36
|
+
done: `It is done: to work on it again run \`lattice todo reopen ${on} --reason <text>\`.`,
|
|
37
|
+
'in-progress': `It is already in-progress under another seat; see \`${showTask(detail, ctx)}\`.`,
|
|
38
|
+
retired: `It is retired, which is permanent; see \`${showTask(detail, ctx)}\`.`,
|
|
39
|
+
})[detail.status] ?? `Only a pending task can start; check its status with \`${showTask(detail, ctx)}\`.`;
|
|
40
|
+
};
|
|
41
|
+
const cyclePath = (detail) => (Array.isArray(detail.cycle)
|
|
42
|
+
? detail.cycle.filter(record).map((node) => `${node.plan_key}/${node.task_id ?? `phase:${node.phase_id}`}`).join(' -> ')
|
|
43
|
+
: null);
|
|
44
|
+
const edgeName = (detail) => (record(detail.from) && record(detail.to)
|
|
45
|
+
? `${detail.from.plan_key}/${detail.from.task_id} -> ${detail.to.plan_key}/${detail.to.task_id}` : 'this dependency');
|
|
46
|
+
const dependencyCycle = {
|
|
47
|
+
repair: (detail) => {
|
|
48
|
+
const path = cyclePath(detail);
|
|
49
|
+
return `${edgeName(detail)} would close a cycle${path === null ? '' : ` (${path})`}: leave it out, or disconnect one edge of that path with \`lattice todo dependency disconnect\`.`;
|
|
50
|
+
},
|
|
25
51
|
};
|
|
26
52
|
|
|
27
53
|
/** The flag that carried the unreadable input: the one whose value is the refused path. */
|
|
@@ -120,7 +146,7 @@ const REGISTRY = {
|
|
|
120
146
|
repair: (detail, ctx) => ({
|
|
121
147
|
predecessor_unfinished: `${unfinishedFirst(detail, ctx)}, or start with --override-reason <text>.`,
|
|
122
148
|
acceptance_edge: phaseAcceptFirst(detail, ctx),
|
|
123
|
-
task_state:
|
|
149
|
+
task_state: startState(detail, ctx),
|
|
124
150
|
phase_state: 'Its phase is not active; check the phase status with `lattice todo status --json`.',
|
|
125
151
|
})[detail.cause] ?? `Check the task state with \`${showTask(detail, ctx)}\`, then rerun.`,
|
|
126
152
|
},
|
|
@@ -171,8 +197,10 @@ const REGISTRY = {
|
|
|
171
197
|
},
|
|
172
198
|
merged_cycle: {
|
|
173
199
|
pointer: '/hard_dependencies',
|
|
174
|
-
repair: () =>
|
|
200
|
+
repair: (detail) => `Remove one dependency (including cross-plan ones) that closes the cycle${cyclePath(detail) === null ? '' : ` ${cyclePath(detail)}`}, then rerun.`,
|
|
175
201
|
},
|
|
202
|
+
dependency_cycle: dependencyCycle,
|
|
203
|
+
cross_plan_dependency_cycle: dependencyCycle,
|
|
176
204
|
join_self_edge: {
|
|
177
205
|
pointer: '/joins',
|
|
178
206
|
repair: () => 'Remove the join whose `after` lists its own id, then rerun.',
|
package/src/hooks-cli.mjs
CHANGED
|
@@ -788,10 +788,15 @@ async function status(host, env, stdout, source, platform, testHooks) {
|
|
|
788
788
|
writeJson(stdout, statusResult(host, target, null, 'unreadable', 0, false, 0));
|
|
789
789
|
return 1;
|
|
790
790
|
}
|
|
791
|
-
if (platform === 'win32'
|
|
791
|
+
if (platform === 'win32') {
|
|
792
792
|
writeJson(stdout, statusResult(host, target, shell(argv), 'unreadable', 0, false, 0));
|
|
793
793
|
return 1;
|
|
794
794
|
}
|
|
795
|
+
// The AI is not installed in this HOME; install would refuse HOST_NOT_PRESENT, so name no next action.
|
|
796
|
+
if (await hostDirectory(env, host) === null) {
|
|
797
|
+
writeJson(stdout, { ...statusResult(host, target, shell(argv), 'host_absent', 0, false, 0), next_action: null });
|
|
798
|
+
return 1;
|
|
799
|
+
}
|
|
795
800
|
let config;
|
|
796
801
|
try { config = await readConfig(target); } catch {
|
|
797
802
|
writeJson(stdout, statusResult(host, target, shell(argv), 'unreadable', 0, false, 0));
|
package/src/plan-backchain.mjs
CHANGED
|
@@ -544,9 +544,26 @@ async function activeIntentUnchanged({ repoRoot, member, chain, authoring }) {
|
|
|
544
544
|
});
|
|
545
545
|
}
|
|
546
546
|
|
|
547
|
+
/**
|
|
548
|
+
* 公開前のmemberから、作業中taskごとに最新startの記録者を集める(task_id → actor)。
|
|
549
|
+
* 改訂後のrebind startがこの記録者を保つので、別の席が改訂しても`turn.own`は始めた席に残る(a16)。
|
|
550
|
+
* shortcut: このmemberにstartが無いtask(revise-phaseで運ばれたもの)は今の席で結び直す。古い版の
|
|
551
|
+
* journalまで遡る必要が出たらStoreの保持版readerを使う。
|
|
552
|
+
*/
|
|
553
|
+
export function carriedStartActors(member) {
|
|
554
|
+
const actors = new Map();
|
|
555
|
+
if (member === null || member === undefined) return actors;
|
|
556
|
+
const inProgress = new Set(member.tasks.filter(({ status }) => status === 'in-progress')
|
|
557
|
+
.map(({ task_id: taskId }) => taskId));
|
|
558
|
+
for (const event of member.journal.events) {
|
|
559
|
+
if (event.kind === 'start' && inProgress.has(event.task_id)) actors.set(event.task_id, event.actor);
|
|
560
|
+
}
|
|
561
|
+
return actors;
|
|
562
|
+
}
|
|
563
|
+
|
|
547
564
|
export async function rebindCarriedWork({ repoRoot, planKey, env,
|
|
548
565
|
reason = 'ゴール変更後のplan versionへ作業中ToDoを結び直す',
|
|
549
|
-
failureCode = 'BACKCHAIN_REBIND_PENDING' }) {
|
|
566
|
+
failureCode = 'BACKCHAIN_REBIND_PENDING', carriedActors = new Map() }) {
|
|
550
567
|
const store = await readTodoStore({ repoRoot });
|
|
551
568
|
const member = store.members.find(({ plan }) => plan.plan_key === planKey);
|
|
552
569
|
const rebound = [];
|
|
@@ -557,7 +574,7 @@ export async function rebindCarriedWork({ repoRoot, planKey, env,
|
|
|
557
574
|
const { rebindStart } = await import('./todo-cli.mjs');
|
|
558
575
|
try {
|
|
559
576
|
await rebindStart({ repoRoot, env, planKey, taskId: state.task_id,
|
|
560
|
-
reason });
|
|
577
|
+
reason, actor: carriedActors.get(state.task_id) ?? null });
|
|
561
578
|
} catch (error) {
|
|
562
579
|
throw new TodoStoreError(failureCode, 'carried_task_rebind_failed', undefined, {
|
|
563
580
|
task_id: state.task_id, plan_version: member.plan.plan_version,
|
|
@@ -658,7 +675,8 @@ export async function runPlanBackchain({ cwd, inputRef, stdout, dryRun = false,
|
|
|
658
675
|
};
|
|
659
676
|
}
|
|
660
677
|
const reboundTaskIds = unchanged || revision !== null
|
|
661
|
-
? await rebindCarriedWork({ repoRoot, planKey: chain.plan_key, env
|
|
678
|
+
? await rebindCarriedWork({ repoRoot, planKey: chain.plan_key, env,
|
|
679
|
+
carriedActors: carriedStartActors(member) }) : [];
|
|
662
680
|
const finalStore = await readTodoStore({ repoRoot });
|
|
663
681
|
const finalMember = finalStore.members.find(({ plan }) => plan.plan_key === chain.plan_key);
|
|
664
682
|
const result = {
|
package/src/plan-revise.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { gitSync } from './git-process.mjs';
|
|
|
6
6
|
import { completeCreateInput, readAuthoringJsonFile, resolveTodoActor } from './todo-authoring-input.mjs';
|
|
7
7
|
import { validatePlanCreateInput } from './project-cli.mjs';
|
|
8
8
|
import {
|
|
9
|
-
compileBackchainRevision, planSeed, readPlanBackchainBinding, rebindCarriedWork,
|
|
9
|
+
carriedStartActors, compileBackchainRevision, planSeed, readPlanBackchainBinding, rebindCarriedWork,
|
|
10
10
|
} from './plan-backchain.mjs';
|
|
11
11
|
import {
|
|
12
12
|
applyPhaseTodoRevision, buildTodoPlan, createTodoStoreWriter, readTodoStore, TodoStoreError,
|
|
@@ -174,7 +174,10 @@ export function resolvePlanRevision({ member, input, env = process.env, now = ne
|
|
|
174
174
|
fail('plan_revise_schema_invalid', '/', { expected: INPUT_SCHEMA });
|
|
175
175
|
}
|
|
176
176
|
if (input.schema !== INPUT_SCHEMA) fail('plan_revise_schema_invalid', '/', { expected: INPUT_SCHEMA });
|
|
177
|
-
|
|
177
|
+
// a17: 改訂は既存planの上で行うので、project_id・plan_versionは書かなければ現行planの値で埋まる。
|
|
178
|
+
const desired = completeCreateInput(input.desired, {
|
|
179
|
+
env, now, projectId: member?.plan.project_id, planVersion: member?.plan.plan_version,
|
|
180
|
+
});
|
|
178
181
|
try { validatePlanCreateInput(desired); }
|
|
179
182
|
catch (error) {
|
|
180
183
|
if (typeof error?.detail?.pointer === 'string') {
|
|
@@ -200,7 +203,13 @@ export function resolvePlanRevision({ member, input, env = process.env, now = ne
|
|
|
200
203
|
if (!['lattice.todo_plan.v7', 'lattice.todo_plan.v8'].includes(member.plan.schema)) {
|
|
201
204
|
fail('predecessor_plan_schema_unsupported', '/desired/plan_key');
|
|
202
205
|
}
|
|
203
|
-
if (desired.project_id !== member.plan.project_id
|
|
206
|
+
if (desired.project_id !== member.plan.project_id) {
|
|
207
|
+
fail('plan_revise_identity_mismatch', '/desired/project_id', {
|
|
208
|
+
expected: member.plan.project_id, actual: desired.project_id,
|
|
209
|
+
next_action: `Omit /desired/project_id (the machine fills "${member.plan.project_id}") or set it to "${member.plan.project_id}".`,
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
if (desired.plan_key !== member.plan.plan_key) {
|
|
204
213
|
fail('plan_revise_identity_mismatch', '/desired/plan_key');
|
|
205
214
|
}
|
|
206
215
|
const continuity = computeContinuity(member, input,
|
|
@@ -338,7 +347,7 @@ export async function applyPlanRevision({
|
|
|
338
347
|
try {
|
|
339
348
|
reboundTaskIds = await rebindCarriedWork({ repoRoot, planKey: revision.plan_key, env,
|
|
340
349
|
reason: '工程改訂後のplan versionへ作業中ToDoを結び直す',
|
|
341
|
-
failureCode: 'PLAN_REBIND_PENDING' });
|
|
350
|
+
failureCode: 'PLAN_REBIND_PENDING', carriedActors: carriedStartActors(member) });
|
|
342
351
|
} catch (error) {
|
|
343
352
|
// 公開後に起きたStoreの失敗は、改訂が確定済みであることを必ず報告する(2026-11-07
|
|
344
353
|
// 初回使用: rebind読込の素のbinding_staleが公開済み事実を隠した)
|
package/src/project-cli.mjs
CHANGED
|
@@ -200,7 +200,7 @@ async function summarizeIndependence({ repoRoot, store, todo }) {
|
|
|
200
200
|
.some(({ unknowns }) => unknowns.some(({ kind }) => kind === 'record_stale')),
|
|
201
201
|
conflictWithActive: projected.frontier.conflicts_with_active[0]?.severability ?? null,
|
|
202
202
|
conflictBetweenReady: projected.frontier.serialize_pairs[0]?.severability ?? null,
|
|
203
|
-
coordinationMode: member.coordination?.mode ?? null,
|
|
203
|
+
coordinationMode: member.coordination?.mode ?? null, planKey,
|
|
204
204
|
}),
|
|
205
205
|
unreadable_reason: null,
|
|
206
206
|
parallel_groups: projected.frontier.parallel_groups.map(({ task_ids: ids }) => [...ids]),
|
|
@@ -278,7 +278,7 @@ async function resolveProjectState({ cwd, cliVersion, diagnoseStructureArtifacts
|
|
|
278
278
|
store: { ref: STORE_REF, absolute_path: storeAbsolute },
|
|
279
279
|
active_plans: [], active_runs: [], can_create_plan: true,
|
|
280
280
|
next_action: {
|
|
281
|
-
command: 'lattice plan create --
|
|
281
|
+
command: 'lattice plan create --template --json',
|
|
282
282
|
input_schema: CURRENT_CREATE_INPUT_SCHEMA,
|
|
283
283
|
schema_command: CURRENT_CREATE_SCHEMA_COMMAND,
|
|
284
284
|
},
|
|
@@ -721,13 +721,34 @@ export function validatePlanCreateInput(input) {
|
|
|
721
721
|
});
|
|
722
722
|
}
|
|
723
723
|
|
|
724
|
+
/** a17: repo root名をtodo identifierへ寄せる。小文字化し、使えない文字は'-'へ、前後の記号は落とす。 */
|
|
725
|
+
function identifierFromRepoRoot(repoRoot, fallback) {
|
|
726
|
+
const name = path.basename(repoRoot).toLowerCase().replace(/[^0-9a-z._-]+/gu, '-')
|
|
727
|
+
.replace(/^[^0-9a-z]+|[^0-9a-z]+$/gu, '').slice(0, 128);
|
|
728
|
+
return isTodoIdentifier(name) ? name : fallback;
|
|
729
|
+
}
|
|
730
|
+
|
|
724
731
|
export async function runPlanCreate({
|
|
725
732
|
cwd, inputRef, stdout, inputValue = null, featureChain = null, env = process.env,
|
|
726
733
|
}) {
|
|
727
734
|
const repoRoot = resolveRepoRoot(cwd);
|
|
728
735
|
if (repoRoot === null) throw new TodoStoreError('REPO_UNRESOLVED', 'git_toplevel_unresolved');
|
|
729
|
-
const
|
|
730
|
-
|
|
736
|
+
const manifest = await lstat(path.join(repoRoot, MANIFEST_REF)).catch((error) => {
|
|
737
|
+
if (!['ENOENT', 'ENOTDIR'].includes(error?.code)) throw error;
|
|
738
|
+
return null;
|
|
739
|
+
});
|
|
740
|
+
// a17: project_idは機械が決める。storeがあればそのid、無ければrepo root名。
|
|
741
|
+
const projectId = manifest === null
|
|
742
|
+
? identifierFromRepoRoot(repoRoot, 'project') : (await readTodoStore({ repoRoot })).project_id;
|
|
743
|
+
const given = inputValue ?? await readCanonicalInput(repoRoot, inputRef);
|
|
744
|
+
if (manifest !== null && isPlainRecord(given) && given.project_id !== undefined
|
|
745
|
+
&& given.project_id !== null && given.project_id !== projectId) {
|
|
746
|
+
throw new TodoStoreError('INPUT_INVALID', 'project_id_mismatch', undefined, {
|
|
747
|
+
pointer: '/project_id', expected: projectId, actual: given.project_id,
|
|
748
|
+
next_action: `Omit project_id (the machine fills "${projectId}") or set it to "${projectId}".`,
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
const input = completeCreateInput(given, { env, now: new Date(), projectId, planVersion: 'v1' });
|
|
731
752
|
validatePlanCreateInput(input);
|
|
732
753
|
// dispatch_shapeは結果へ載せる観測であり、直列度では初期化を拒まない(ADR 0180)。
|
|
733
754
|
const dispatchShape = computeTodoDispatchShapeForPlan({
|
|
@@ -754,10 +775,6 @@ export async function runPlanCreate({
|
|
|
754
775
|
genesis: { actor: input.actor, recorded_at: input.recorded_at, provenance: null },
|
|
755
776
|
...(featureChain === null ? {} : { featureChain }),
|
|
756
777
|
};
|
|
757
|
-
const manifest = await lstat(path.join(repoRoot, MANIFEST_REF)).catch((error) => {
|
|
758
|
-
if (!['ENOENT', 'ENOTDIR'].includes(error?.code)) throw error;
|
|
759
|
-
return null;
|
|
760
|
-
});
|
|
761
778
|
const store = manifest === null
|
|
762
779
|
? await initializeAuthoredTodoStore({ ...options,
|
|
763
780
|
projectId: input.project_id, repositories: [{ repo_id: 'self', path: '.' }] })
|
|
@@ -812,15 +829,14 @@ export async function runPlanCreateSchema({ stdout, version = 5 }) {
|
|
|
812
829
|
}
|
|
813
830
|
|
|
814
831
|
/**
|
|
815
|
-
* `plan create --template --json`(a11)。作者が書くkeyだけの最小のv5入力を出す。
|
|
816
|
-
*
|
|
817
|
-
*
|
|
832
|
+
* `plan create --template --json`(a11・a17)。作者が書くkeyだけの最小のv5入力を出す。
|
|
833
|
+
* 機械が決めるkey(project_id・plan_version・actor・recorded_at・input_digest・定数のkey・辺のproject_id/plan_key)は載せない。
|
|
834
|
+
* plan_keyだけは、git repo内ならrepo root名から導いた値、repo外なら'main'。
|
|
835
|
+
* 決定的で、storeを読まない。id・題名を書き換えれば`plan create`がそのまま受理する。
|
|
818
836
|
*/
|
|
819
837
|
export const PLAN_CREATE_TEMPLATE = Object.freeze({
|
|
820
838
|
schema: DONE_CONDITION_CREATE_INPUT_SCHEMA,
|
|
821
|
-
|
|
822
|
-
plan_key: 'my-plan',
|
|
823
|
-
plan_version: 'v1',
|
|
839
|
+
plan_key: 'main',
|
|
824
840
|
phases: [
|
|
825
841
|
{ phase_id: 'p1', title: 'First phase' },
|
|
826
842
|
{ phase_id: 'p2', title: 'Second phase' },
|
|
@@ -834,8 +850,11 @@ export const PLAN_CREATE_TEMPLATE = Object.freeze({
|
|
|
834
850
|
hard_dependencies: [{ from: { task_id: 't1' }, to: { task_id: 't3' } }],
|
|
835
851
|
});
|
|
836
852
|
|
|
837
|
-
export async function runPlanCreateTemplate({ stdout }) {
|
|
838
|
-
|
|
853
|
+
export async function runPlanCreateTemplate({ stdout, cwd = process.cwd() }) {
|
|
854
|
+
const repoRoot = resolveRepoRoot(cwd);
|
|
855
|
+
const template = repoRoot === null ? PLAN_CREATE_TEMPLATE
|
|
856
|
+
: { ...PLAN_CREATE_TEMPLATE, plan_key: identifierFromRepoRoot(repoRoot, 'main') };
|
|
857
|
+
stdout.write(`${JSON.stringify(template)}\n`);
|
|
839
858
|
return 0;
|
|
840
859
|
}
|
|
841
860
|
|
|
@@ -869,15 +888,19 @@ export async function runPlanShow({ cwd, planKey, stdout }) {
|
|
|
869
888
|
|
|
870
889
|
// 依存の本数: このplanの中でそのtaskへ入ってくるhard_dependencies辺と、joinで
|
|
871
890
|
// 合流するafter辺の合計。cross-plan参照は数えない(plan showは単一planの投影のため)。
|
|
891
|
+
// retiredの端点を持つ辺は数えない(a13: retireは辺を除く。a18)。
|
|
892
|
+
const retired = (ref) => ref.plan_key === planKey && stateByTaskId.get(ref.task_id)?.status === 'retired';
|
|
872
893
|
const dependsOnCount = new Map(plan.tasks.map((task) => [task.task_id, 0]));
|
|
873
894
|
for (const edge of plan.hard_dependencies) {
|
|
874
|
-
if (edge.to.plan_key === planKey && dependsOnCount.has(edge.to.task_id)
|
|
895
|
+
if (edge.to.plan_key === planKey && dependsOnCount.has(edge.to.task_id)
|
|
896
|
+
&& !retired(edge.from) && !retired(edge.to)) {
|
|
875
897
|
dependsOnCount.set(edge.to.task_id, dependsOnCount.get(edge.to.task_id) + 1);
|
|
876
898
|
}
|
|
877
899
|
}
|
|
878
900
|
for (const join of plan.joins) {
|
|
879
|
-
if (join.before.plan_key === planKey && dependsOnCount.has(join.before.task_id)) {
|
|
880
|
-
dependsOnCount.set(join.before.task_id,
|
|
901
|
+
if (join.before.plan_key === planKey && dependsOnCount.has(join.before.task_id) && !retired(join.before)) {
|
|
902
|
+
dependsOnCount.set(join.before.task_id,
|
|
903
|
+
dependsOnCount.get(join.before.task_id) + join.after.filter((ref) => !retired(ref)).length);
|
|
881
904
|
}
|
|
882
905
|
}
|
|
883
906
|
|
package/src/runtime-errors.mjs
CHANGED
|
@@ -220,7 +220,7 @@ const windows = () => hostPlatform() === 'win32';
|
|
|
220
220
|
* フォルダは、その中身を信用できないので、絞らずに止める。
|
|
221
221
|
*/
|
|
222
222
|
function ensureWindowsDirOwnerOnly(dir) {
|
|
223
|
-
const sid = windowsSelfSid();
|
|
223
|
+
const sid = windowsSelfSid(dir);
|
|
224
224
|
const settled = (sddl) => daclIsOwnerOnly(sddl, sid) && daclIsProtected(sddl);
|
|
225
225
|
const current = readWindowsDacl(dir, dir);
|
|
226
226
|
if (settled(current)) return;
|
|
@@ -249,7 +249,7 @@ export function ensureSafeFile(path, scratchDir = dirname(path)) {
|
|
|
249
249
|
assertPosix(statSync(path), 0o600);
|
|
250
250
|
return;
|
|
251
251
|
}
|
|
252
|
-
const sid = windowsSelfSid();
|
|
252
|
+
const sid = windowsSelfSid(scratchDir);
|
|
253
253
|
// 出力fileを置くフォルダを他のaccountが書けるなら、読んだDACLを信用できない。先にそれを確かめる。
|
|
254
254
|
if (!daclIsOwnerOnly(readWindowsDacl(scratchDir, scratchDir), sid)
|
|
255
255
|
|| !daclIsOwnerOnly(readWindowsDacl(path, scratchDir), sid)) throw Error('store_unsafe');
|
|
@@ -347,7 +347,7 @@ async function pullPlanReadiness({ repoRoot, planKey }) {
|
|
|
347
347
|
&& witnessSet?.witness_set_digest === artifact.witness_set_digest;
|
|
348
348
|
return pullIntakeReadinessGuidance({
|
|
349
349
|
coordinationMode: member.coordination?.mode ?? null,
|
|
350
|
-
ready,
|
|
350
|
+
ready, planKey,
|
|
351
351
|
});
|
|
352
352
|
}
|
|
353
353
|
|
|
@@ -396,7 +396,7 @@ function pathTouches(boundary, changed) {
|
|
|
396
396
|
async function boundaryVerdict({ repoRoot, store, member, meta, taskId, intakeBase }) {
|
|
397
397
|
const pullRequired = pullIntakeReadinessGuidance({
|
|
398
398
|
coordinationMode: member.coordination?.mode ?? null,
|
|
399
|
-
ready: false,
|
|
399
|
+
ready: false, planKey: meta.plan_key,
|
|
400
400
|
});
|
|
401
401
|
let artifact;
|
|
402
402
|
let witnessSet;
|
|
@@ -335,7 +335,8 @@ function projectionGuidance(value, coverage, components) {
|
|
|
335
335
|
if (!exactRecord(value, ['code', 'message', 'next_action'])
|
|
336
336
|
|| !SEAM_PROPOSAL_GUIDANCE_CODES.includes(value.code)
|
|
337
337
|
|| !boundedText(value.message)
|
|
338
|
-
|| !
|
|
338
|
+
|| !(value.next_action === 'none'
|
|
339
|
+
|| (boundedText(value.next_action) && value.next_action.startsWith('lattice ')))) return false;
|
|
339
340
|
const unknownKinds = Array.isArray(components)
|
|
340
341
|
? components.flatMap((component) => (Array.isArray(component?.unknowns)
|
|
341
342
|
? component.unknowns.map((unknown) => unknown?.kind) : []))
|
package/src/setup-cli.mjs
CHANGED
|
@@ -47,6 +47,7 @@ async function configureHost(host, options, statusOnly) {
|
|
|
47
47
|
if (!statusOnly) action = await writeSetupFile(paths.mcp, before, updateMcpConfig(before.text, paths.format, desired));
|
|
48
48
|
const saved = (await readSetupFile(paths.mcp)).text;
|
|
49
49
|
const entry = mcpEntry(saved, paths.format);
|
|
50
|
+
if (!entry && statusOnly) throw setupError('MCP_NOT_REGISTERED', `LatticeのMCPは未登録です。lattice setup --host ${host} で登録します`);
|
|
50
51
|
if (!entry || entry.command !== desired.command || JSON.stringify(entry.args) !== JSON.stringify(desired.args)) {
|
|
51
52
|
throw setupError('MCP_REGISTRATION_DRIFT', 'MCP登録が現在のLattice実行体と一致しません');
|
|
52
53
|
}
|
|
@@ -231,12 +231,15 @@ function fillEach(next, key, fill) {
|
|
|
231
231
|
next[key] = next[key].map((entry) => (isRecord(entry) ? fill(entry) : entry));
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
-
|
|
234
|
+
// a17: project_id・plan_versionは機械が決める事実。書かなければ呼び出し側が渡した値(storeのid等)で埋める。
|
|
235
|
+
export function completeCreateInput(value, { env, now, projectId, planVersion }) {
|
|
235
236
|
if (!isRecord(value)) return value;
|
|
236
237
|
const next = { ...value };
|
|
237
238
|
// a11: schemaを書かなければ現行のcreate入力(v5)。他のschemaを持つ値は作成入力でないのでそのまま返す。
|
|
238
239
|
if (absent(next.schema)) next.schema = DEFAULT_CREATE_INPUT_SCHEMA;
|
|
239
240
|
if (typeof next.schema !== 'string' || !CREATE_INPUT_SCHEMA.test(next.schema)) return value;
|
|
241
|
+
if (absent(next.project_id) && projectId !== undefined) next.project_id = projectId;
|
|
242
|
+
if (absent(next.plan_version) && planVersion !== undefined) next.plan_version = planVersion;
|
|
240
243
|
const fillNode = (ref) => fillRef(ref, next.project_id, next.plan_key);
|
|
241
244
|
const phaseInput = next.schema !== 'lattice.plan_create_input.v1';
|
|
242
245
|
const memoInput = ['lattice.plan_create_input.v4', 'lattice.plan_create_input.v5'].includes(next.schema);
|
|
@@ -304,7 +307,10 @@ function looksLikeProse(value) {
|
|
|
304
307
|
|| (/\s/u.test(value) && !/[/\\]/u.test(value));
|
|
305
308
|
}
|
|
306
309
|
|
|
307
|
-
|
|
310
|
+
// allowOutsideRepo: 中身のJSONを読むだけのcallerはrepo外の絶対pathも受ける(a17)。git blobを求めるcallerは既定のまま拒む。
|
|
311
|
+
export async function resolveAuthoringInputPath(repoRoot, inputRef, {
|
|
312
|
+
inlineFlag = null, allowOutsideRepo = false,
|
|
313
|
+
} = {}) {
|
|
308
314
|
if (typeof inputRef !== 'string' || inputRef.length === 0) {
|
|
309
315
|
fail('INPUT_UNREADABLE', 'input_ref_invalid', { input_ref: inputRef });
|
|
310
316
|
}
|
|
@@ -328,6 +334,10 @@ export async function resolveAuthoringInputPath(repoRoot, inputRef, { inlineFlag
|
|
|
328
334
|
fail('INPUT_UNREADABLE', 'unsafe_input_path', { input_ref: inputRef });
|
|
329
335
|
}
|
|
330
336
|
const resolved = await realpath(candidate);
|
|
337
|
+
if (allowOutsideRepo && !within(canonicalRoot, resolved)) {
|
|
338
|
+
if (stats.size > MAX_AUTHORING_INPUT_BYTES) fail('INPUT_TOO_LARGE', 'input_size_limit_exceeded');
|
|
339
|
+
return { absolute: resolved, inputRef: resolved, maxBytes: MAX_AUTHORING_INPUT_BYTES };
|
|
340
|
+
}
|
|
331
341
|
if (!within(canonicalRoot, resolved) || resolved === canonicalRoot) {
|
|
332
342
|
fail('INPUT_UNREADABLE', 'input_path_outside_repo', {
|
|
333
343
|
input_ref: inputRef,
|
|
@@ -355,7 +365,7 @@ export async function readAuthoringJsonFile(repoRoot, inputRef, {
|
|
|
355
365
|
invalidCode = 'INVALID_JSON',
|
|
356
366
|
inlineFlag = null,
|
|
357
367
|
} = {}) {
|
|
358
|
-
const located = await resolveAuthoringInputPath(repoRoot, inputRef, { inlineFlag });
|
|
368
|
+
const located = await resolveAuthoringInputPath(repoRoot, inputRef, { inlineFlag, allowOutsideRepo: true });
|
|
359
369
|
const bytes = await readFile(located.absolute);
|
|
360
370
|
if (bytes.length > located.maxBytes) fail('INPUT_TOO_LARGE', 'input_size_limit_exceeded');
|
|
361
371
|
let text;
|