@quolu/lattice 0.86.1 → 0.87.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/package.json +1 -1
- package/src/cli-help.mjs +4 -1
- package/src/todo-cli.mjs +65 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quolu/lattice",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.87.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
|
@@ -145,6 +145,8 @@ Write commands:
|
|
|
145
145
|
independence witness scaffold --template --plan <key> [--json] # 未完の工程を並べた下書きのひな形を出す
|
|
146
146
|
independence witness scaffold --schema --json # 下書き(lattice.todo_witness_draft.v2)のJSON Schema
|
|
147
147
|
independence witness scaffold --plan <key> --input <draft> # 下書きとfresh観測から宣言を書き出す
|
|
148
|
+
independence witness declare --plan <key> --task <id> [--owns <path>[,<path>...]] [--reads ...] [--writes ...]
|
|
149
|
+
# 1件のtaskの行だけを宣言する(a40)。readyが全部宣言済みならcompileまで行い、未宣言はwaiting_forに返す
|
|
148
150
|
structure input --plan <key> --input <file> --dry-run --json
|
|
149
151
|
# plan identity・topology・unfinished task coverage・baseline祖先を無変更で検査する
|
|
150
152
|
structure input --plan <key> --input <file>
|
|
@@ -302,7 +304,8 @@ const SUBCOMMAND_USAGE = Object.freeze({
|
|
|
302
304
|
'todo display source': 'todo display source [--json] # lattice.todo_store_display_source.v1(安い変更検知。変わった時だけreadする)',
|
|
303
305
|
'todo independence': 'todo independence [--plan <key>] [--json] | mode --plan <key> --set <witness|conversation> --reason <text>'
|
|
304
306
|
+ ' | compile --plan <key> --input <file> | compile --schema --json | witness migrate --plan <key>'
|
|
305
|
-
+ ' | witness scaffold --template --plan <key> [--json] | witness scaffold --schema --json | witness scaffold --plan <key> --input <draft>'
|
|
307
|
+
+ ' | witness scaffold --template --plan <key> [--json] | witness scaffold --schema --json | witness scaffold --plan <key> --input <draft>'
|
|
308
|
+
+ ' | witness declare --plan <key> --task <id> [--owns <path>[,<path>...]] [--reads ...] [--writes ...]',
|
|
306
309
|
'todo independence mode': 'todo independence mode --plan <key> --set <witness|conversation> --reason <text>',
|
|
307
310
|
'todo structure': 'todo structure --schema --json | [--plan <key>] --json | input --plan <key> --input <file> [--dry-run --json] | compile --plan <key> --input <file> | realize --plan <key> --task <id> (--planned|--realized <actual-structure.json>) [--commit <HEAD|sha>]... | realize --plan <key> --task <id> --input <full-realization.json> | finalize --plan <key> --json',
|
|
308
311
|
'todo seam-profile': 'todo seam-profile --plan <key> --file <path> [--json]',
|
package/src/todo-cli.mjs
CHANGED
|
@@ -173,7 +173,7 @@ import { applySeamProposal } from './seam-apply.mjs';
|
|
|
173
173
|
import { todoPlanPrecedences } from './seam-verification.mjs';
|
|
174
174
|
import {
|
|
175
175
|
WITNESS_DRAFT_SCHEMA, buildWitnessObservationQuerySet, buildWitnessSet, explainWitnessDraft, serializeWitnessSet,
|
|
176
|
-
witnessDraftTemplate,
|
|
176
|
+
validateWitnessDraft, witnessDraftTemplate,
|
|
177
177
|
} from './witness-scaffold.mjs';
|
|
178
178
|
import {
|
|
179
179
|
completePhaseTodoRevision, explainPhaseTodoRevision, explainTodoRevision, explainTodoRevisionSet,
|
|
@@ -348,6 +348,8 @@ const TODO_FLAG_SPECS = Object.freeze({
|
|
|
348
348
|
'independence compile': Object.freeze({ known: ['plan', 'input'], required: ['plan', 'input'] }),
|
|
349
349
|
'independence mode': Object.freeze({ known: ['plan', 'set', 'reason'], required: ['plan', 'set', 'reason'] }),
|
|
350
350
|
'independence witness scaffold': Object.freeze({ known: ['plan', 'input'], required: ['plan', 'input'] }),
|
|
351
|
+
'independence witness declare': Object.freeze({
|
|
352
|
+
known: ['plan', 'task', 'owns', 'reads', 'writes'], required: ['plan', 'task'] }),
|
|
351
353
|
show: Object.freeze({ known: ['plan', 'task', 'json'], required: ['plan', 'task'], booleans: ['json'] }),
|
|
352
354
|
'note list': Object.freeze({ known: ['plan', 'task', 'json'], required: ['plan'], booleans: ['json'] }),
|
|
353
355
|
'phase status': Object.freeze({ known: ['plan', 'json'], required: ['plan'], booleans: ['json'] }),
|
|
@@ -522,12 +524,12 @@ function supportsAtomicStoreCommit(argv) {
|
|
|
522
524
|
if (command === 'note') return argv[1] !== 'list';
|
|
523
525
|
if (command === 'independence') {
|
|
524
526
|
return argv[1] === 'mode'
|
|
525
|
-
|| (argv[1] === 'witness' && ['migrate', 'scaffold'].includes(argv[2]) && !argv.includes('--template'));
|
|
527
|
+
|| (argv[1] === 'witness' && ['migrate', 'scaffold', 'declare'].includes(argv[2]) && !argv.includes('--template'));
|
|
526
528
|
}
|
|
527
529
|
if (command === 'snapshot') return argv[1] === '--rebuild';
|
|
528
530
|
if (command === 'migrate') return !argv.includes('--dry-run') && !argv.includes('--schema');
|
|
529
531
|
if (['revise', 'split', 'revise-set', 'revise-phase', 'start', 'retract', 'block',
|
|
530
|
-
'unblock', 'retire', 'done', 'reopen'].includes(command)) return true;
|
|
532
|
+
'unblock', 'retire', 'done', 'reopen', 'add'].includes(command)) return true;
|
|
531
533
|
if (command === 'evidence') return argv[1] === 'promote';
|
|
532
534
|
if (command === 'phase') return argv[1] !== 'status';
|
|
533
535
|
return false;
|
|
@@ -3659,6 +3661,11 @@ async function witnessScaffold({ repoRoot, planKey, inputRef }) {
|
|
|
3659
3661
|
draft_plan_key: draft.plan_key, plan_key: planKey,
|
|
3660
3662
|
});
|
|
3661
3663
|
}
|
|
3664
|
+
return scaffoldWitnessDraft({ repoRoot, planKey, draft });
|
|
3665
|
+
}
|
|
3666
|
+
|
|
3667
|
+
/** The scaffold itself: fresh observation, wiring and digest for a checked draft, then the write. */
|
|
3668
|
+
async function scaffoldWitnessDraft({ repoRoot, planKey, draft }) {
|
|
3662
3669
|
const { queries, paths } = buildWitnessObservationQuerySet(draft);
|
|
3663
3670
|
const collected = await collectSensorEvidence({ cwd: repoRoot, querySet: { queries } });
|
|
3664
3671
|
const observationByPath = {};
|
|
@@ -3698,6 +3705,53 @@ async function witnessScaffold({ repoRoot, planKey, inputRef }) {
|
|
|
3698
3705
|
};
|
|
3699
3706
|
}
|
|
3700
3707
|
|
|
3708
|
+
/**
|
|
3709
|
+
* a40: one task's witness row, declared by its member. Rows nobody declared stay out (an empty row
|
|
3710
|
+
* would claim "touches nothing"); compile runs once every ready task is declared.
|
|
3711
|
+
*/
|
|
3712
|
+
async function witnessDeclare({ repoRoot, planKey, flags }) {
|
|
3713
|
+
const store = await readTodoStore({ repoRoot });
|
|
3714
|
+
const member = store.members.find(({ descriptor }) => descriptor.plan_key === planKey);
|
|
3715
|
+
if (member === undefined) throw new TodoStoreError('STORE_INCONSISTENT', 'plan_not_active', undefined, { plan_key: planKey });
|
|
3716
|
+
const taskId = flags.task;
|
|
3717
|
+
const state = member.tasks.find(({ task_id: id }) => id === taskId);
|
|
3718
|
+
if (state === undefined) {
|
|
3719
|
+
throw new TodoStoreError('TASK_NOT_FOUND', 'task_not_found', undefined, { requested_task_id: taskId });
|
|
3720
|
+
}
|
|
3721
|
+
if (['done', 'retired'].includes(state.status)) {
|
|
3722
|
+
throw new TodoStoreError('INPUT_INVALID', 'witness_declare_task_finished', undefined, {
|
|
3723
|
+
plan_key: planKey, task_id: taskId, status: state.status,
|
|
3724
|
+
next_action: `${planKey}/${taskId} is ${state.status}; only unfinished tasks are declared (see \`lattice todo status --json\`).`,
|
|
3725
|
+
});
|
|
3726
|
+
}
|
|
3727
|
+
const recorded = await readTodoWitnessSet({ repoRoot, planKey }).catch(() => null);
|
|
3728
|
+
const template = await witnessDraftTemplateFor({ repoRoot, planKey });
|
|
3729
|
+
const keep = new Set([...Object.keys(recorded?.plan_key === planKey ? recorded.manual_witness : {}), taskId]);
|
|
3730
|
+
const list = (value) => (typeof value === 'string' ? value.split(',').map((item) => item.trim()).filter(Boolean) : []);
|
|
3731
|
+
const row = { owns: list(flags.owns), reads: list(flags.reads), writes: list(flags.writes) };
|
|
3732
|
+
const draft = { ...template, tasks: Object.fromEntries(Object.entries(template.tasks)
|
|
3733
|
+
.filter(([id]) => keep.has(id)).map(([id, task]) => [id, id === taskId ? row : task])) };
|
|
3734
|
+
if (!validateWitnessDraft(draft)) {
|
|
3735
|
+
const { valid: _valid, reason, path: at, ...keys } = explainWitnessDraft(draft);
|
|
3736
|
+
throw new TodoStoreError('WITNESS_DRAFT_INVALID', reason, undefined, {
|
|
3737
|
+
pointer: at, ...keys, next_action: witnessRoute(planKey) });
|
|
3738
|
+
}
|
|
3739
|
+
const scaffolded = await scaffoldWitnessDraft({ repoRoot, planKey, draft });
|
|
3740
|
+
const waitingFor = projectTodoStatus(await readTodoStore({ repoRoot }), TODO_STATUS_DISPATCH_ONLY).next_ready
|
|
3741
|
+
.filter((task) => task.plan_key === planKey && !keep.has(task.task_id))
|
|
3742
|
+
.map(({ task_id: id }) => id).sort();
|
|
3743
|
+
const compile = waitingFor.length === 0
|
|
3744
|
+
? await independenceCompile({ repoRoot, planKey, inputRef: scaffolded.witness_ref }) : null;
|
|
3745
|
+
const result = {
|
|
3746
|
+
schema: 'lattice.todo_witness_declare_result.v1', project_id: member.plan.project_id, plan_key: planKey,
|
|
3747
|
+
task_id: taskId, ...row, witness_ref: scaffolded.witness_ref,
|
|
3748
|
+
witness_set_digest: scaffolded.witness_set_digest, compiled: compile !== null, waiting_for: waitingFor,
|
|
3749
|
+
compile, result_digest: '',
|
|
3750
|
+
};
|
|
3751
|
+
result.result_digest = todoSelfDigest(result, 'result_digest');
|
|
3752
|
+
return result;
|
|
3753
|
+
}
|
|
3754
|
+
|
|
3701
3755
|
/**
|
|
3702
3756
|
* 着地時に使うsurface名。提案が出すhash由来の仮名を、人が読む名前へ置き換える。
|
|
3703
3757
|
*
|
|
@@ -4396,7 +4450,7 @@ function writesTodoStore(argv) {
|
|
|
4396
4450
|
case 'migrate': return !argv.includes('--dry-run');
|
|
4397
4451
|
case 'snapshot': return argv.includes('--rebuild');
|
|
4398
4452
|
case 'independence': return second === 'compile' || second === 'mode'
|
|
4399
|
-
|| (second === 'witness' && ['migrate', 'scaffold'].includes(third) && !argv.includes('--template'));
|
|
4453
|
+
|| (second === 'witness' && ['migrate', 'scaffold', 'declare'].includes(third) && !argv.includes('--template'));
|
|
4400
4454
|
case 'structure': return ['compile', 'realize', 'finalize'].includes(second)
|
|
4401
4455
|
|| (second === 'input' && !argv.includes('--dry-run'));
|
|
4402
4456
|
case 'seam-proposal': return ['compile', 'apply', 'land'].includes(second);
|
|
@@ -4404,7 +4458,7 @@ function writesTodoStore(argv) {
|
|
|
4404
4458
|
case 'dependency': return ['connect', 'disconnect'].includes(second);
|
|
4405
4459
|
case 'phase': return second !== 'status';
|
|
4406
4460
|
case 'start': case 'retract': case 'block': case 'unblock': case 'retire': case 'done':
|
|
4407
|
-
case 'reopen': case 'split': case 'revise': case 'revise-phase': case 'revise-set':
|
|
4461
|
+
case 'reopen': case 'split': case 'revise': case 'revise-phase': case 'revise-set': case 'add':
|
|
4408
4462
|
return true;
|
|
4409
4463
|
default: return false;
|
|
4410
4464
|
}
|
|
@@ -4809,6 +4863,12 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4809
4863
|
if (flags !== null && isTodoIdentifier(flags.plan)) {
|
|
4810
4864
|
action = (repoRoot) => witnessDraftTemplateFor({ repoRoot, planKey: flags.plan });
|
|
4811
4865
|
}
|
|
4866
|
+
} else if (argv[0] === 'independence' && argv[1] === 'witness' && argv[2] === 'declare') {
|
|
4867
|
+
const flags = matchFlagCommand(argv, ['independence', 'witness', 'declare'],
|
|
4868
|
+
TODO_FLAG_SPECS['independence witness declare']);
|
|
4869
|
+
if (flags !== null && isTodoIdentifier(flags.plan) && isTodoIdentifier(flags.task)) {
|
|
4870
|
+
action = (repoRoot) => witnessDeclare({ repoRoot, planKey: flags.plan, flags });
|
|
4871
|
+
}
|
|
4812
4872
|
} else if (argv[0] === 'independence' && argv[1] === 'witness' && argv[2] === 'scaffold') {
|
|
4813
4873
|
const flags = matchFlagCommand(argv, ['independence', 'witness', 'scaffold'],
|
|
4814
4874
|
TODO_FLAG_SPECS['independence witness scaffold']);
|