@quolu/lattice 0.81.0 → 0.83.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-bridge-supervisor.mjs +18 -3
- package/bin/lattice-dashboard.mjs +3 -18
- package/bin/lattice-mcp.mjs +6 -3
- package/bin/lattice.mjs +29 -1
- package/docs/schemas/lattice.plan_create_input.v5.schema.json +375 -0
- package/docs/schemas/lattice.plan_revise_input.v1.schema.json +35 -0
- package/package.json +4 -2
- package/sensor/dist/db/index.d.ts +1 -0
- package/sensor/dist/db/index.d.ts.map +1 -1
- package/sensor/dist/db/index.js +13 -0
- package/sensor/dist/db/index.js.map +1 -1
- package/sensor/dist/index.d.ts.map +1 -1
- package/sensor/dist/index.js +12 -2
- package/sensor/dist/index.js.map +1 -1
- package/sensor/dist/mcp/answer-freshness.js +1 -1
- package/sensor/dist/mcp/answer-freshness.js.map +1 -1
- package/sensor/dist/mcp/engine.d.ts +11 -0
- package/sensor/dist/mcp/engine.d.ts.map +1 -1
- package/sensor/dist/mcp/engine.js +83 -4
- package/sensor/dist/mcp/engine.js.map +1 -1
- package/sensor/dist/mcp/index-repair.d.ts +7 -0
- package/sensor/dist/mcp/index-repair.d.ts.map +1 -0
- package/sensor/dist/mcp/index-repair.js +93 -0
- package/sensor/dist/mcp/index-repair.js.map +1 -0
- package/sensor/dist/mcp/index.d.ts.map +1 -1
- package/sensor/dist/mcp/index.js +12 -7
- package/sensor/dist/mcp/index.js.map +1 -1
- package/sensor/dist/mcp/tools.d.ts +4 -0
- package/sensor/dist/mcp/tools.d.ts.map +1 -1
- package/sensor/dist/mcp/tools.js +29 -9
- package/sensor/dist/mcp/tools.js.map +1 -1
- package/src/bridge-cli.mjs +16 -4
- package/src/bridge-detached-supervisor.mjs +204 -0
- package/src/bridge-hub-server.mjs +46 -9
- package/src/bridge-startup-folder.mjs +7 -4
- package/src/cli-help.mjs +5 -2
- package/src/dashboard-lifecycle-journal.mjs +42 -20
- package/src/plan-backchain.mjs +31 -12
- package/src/plan-binding-carry.mjs +60 -0
- package/src/plan-revise.mjs +276 -0
- package/src/project-cli.mjs +50 -22
- package/src/project-identity.mjs +14 -0
- package/src/runtime-cli.mjs +31 -18
- package/src/runtime-control-store.mjs +22 -1
- package/src/runtime-decision-verifier.mjs +27 -8
- package/src/runtime-engine.mjs +34 -5
- package/src/runtime-hold-recompile.mjs +19 -15
- package/src/runtime-kept-worktree.mjs +136 -0
- package/src/runtime-lifecycle-lock.mjs +118 -30
- package/src/runtime-managed-supervisor.mjs +10 -10
- package/src/runtime-os-observation.mjs +39 -1
- package/src/runtime-pull-intake.mjs +87 -43
- package/src/store-lock.mjs +146 -59
- package/src/todo-authoring-input.mjs +57 -2
- package/src/todo-cli.mjs +173 -45
- package/src/todo-contracts.mjs +22 -6
- package/src/todo-dashboard-registry.mjs +31 -4
- package/src/todo-gantt-display.mjs +260 -0
- package/src/todo-gantt-html-independence.mjs +8 -1
- package/src/todo-gantt-html-shared.mjs +2 -1
- package/src/todo-gantt-html.mjs +4 -2
- package/src/todo-gantt-layout.mjs +7 -36
- package/src/todo-gantt-live.mjs +6 -3
- package/src/todo-note-store.mjs +13 -5
- package/src/todo-readiness.mjs +29 -8
- package/src/todo-revision.mjs +9 -8
- package/src/todo-split.mjs +6 -3
- package/src/todo-status.mjs +53 -9
- package/src/todo-store-cache.mjs +1 -1
- package/src/todo-store-view.mjs +21 -2
- package/src/todo-store.mjs +642 -172
package/src/todo-cli.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { validateProspectiveEvent } from './todo-readiness.mjs';
|
|
1
|
+
import { retireStateConflict, validateProspectiveEvent } from './todo-readiness.mjs';
|
|
2
2
|
import { cliCommandKind } from './cli-command-kind.mjs';
|
|
3
3
|
import { cliFailureClass } from './cli-failure-class.mjs';
|
|
4
4
|
import { readTaskBackchainContext } from './plan-backchain.mjs';
|
|
@@ -39,12 +39,16 @@ import {
|
|
|
39
39
|
removeTodoDashboardProject,
|
|
40
40
|
} from './todo-dashboard-registry.mjs';
|
|
41
41
|
import { readOrCreateTerminalIdSync, terminalPublicLabel } from './terminal-identity.mjs';
|
|
42
|
-
import { readProjectExternalPane, resolveProjectIdentity } from './project-identity.mjs';
|
|
42
|
+
import { readProjectExternalPane, readRegisteredProjectId, resolveProjectIdentity } from './project-identity.mjs';
|
|
43
43
|
import { layoutTodoGantt } from './todo-gantt-layout.mjs';
|
|
44
44
|
import { TODO_GANTT_SCOPES } from './todo-gantt-scope.mjs';
|
|
45
45
|
import { loadTodoGanttPresentation } from './todo-gantt-presentation.mjs';
|
|
46
46
|
import { loadTodoStructurePresentation } from './todo-structure-presentation.mjs';
|
|
47
47
|
import { startTodoGanttLiveServer } from './todo-gantt-live.mjs';
|
|
48
|
+
import {
|
|
49
|
+
createTodoGanttDisplayReader, degradedBannerHtml, displayHeadDigest, displayResultBinding,
|
|
50
|
+
emptyStateHtml, projectUnverifiedStore,
|
|
51
|
+
} from './todo-gantt-display.mjs';
|
|
48
52
|
import {
|
|
49
53
|
renderTodoGanttHtml,
|
|
50
54
|
TODO_GANTT_RENDERER_VERSION,
|
|
@@ -191,8 +195,8 @@ const ACTOR_ENV_KEYS = Object.freeze([
|
|
|
191
195
|
]);
|
|
192
196
|
|
|
193
197
|
/**
|
|
194
|
-
* `revise` / `revise-set` / `revise-phase` / `migrate
|
|
195
|
-
* Schema
|
|
198
|
+
* `revise` / `revise-set` / `revise-phase` / `migrate`が配布する名前付き入力契約のJSON
|
|
199
|
+
* Schemaを読む入口。受理するartifact版すべての列挙ではない(`project-cli.mjs`の`runPlanCreateSchema`と同じ作法)。
|
|
196
200
|
*
|
|
197
201
|
* schemaを取る手段がCLIに無いと、AIはsrcを読んで必須keyを数えるしかなくなる
|
|
198
202
|
* (実運用で`phase_todo_revision.v3`の必須12 keyを試行錯誤で当てた)。storeは読まない
|
|
@@ -703,6 +707,7 @@ async function mutate({
|
|
|
703
707
|
advisory: resolvedAdvisory,
|
|
704
708
|
...(includesNoteContext ? {
|
|
705
709
|
design_memo: designMemoProjection(authoredTask),
|
|
710
|
+
done_condition: authoredTask.done_condition ?? null,
|
|
706
711
|
note_context: noteContext,
|
|
707
712
|
structure_context: structureContext,
|
|
708
713
|
...(featureContext === null ? {} : { feature_context: featureContext }),
|
|
@@ -713,6 +718,47 @@ async function mutate({
|
|
|
713
718
|
return result;
|
|
714
719
|
}
|
|
715
720
|
|
|
721
|
+
/**
|
|
722
|
+
* 恒久除去(u12)。pending/blocked/doneから`{reason, prior_status}`で閉じる。
|
|
723
|
+
* in-progressはRuntimeに解放経路が無いので従来どおり拒否する(先にretract/blockする)。
|
|
724
|
+
* 既にretiredなら成功を返しeventは足さない(応答を失った再試行をエラーにしない)。
|
|
725
|
+
*/
|
|
726
|
+
async function retireTask({ repoRoot, env, planKey, taskId, reason }) {
|
|
727
|
+
const store = await readTodoStore({ repoRoot });
|
|
728
|
+
const member = store.members.find(({ descriptor }) => descriptor.plan_key === planKey);
|
|
729
|
+
const state = member?.tasks.find(({ task_id: current }) => current === taskId);
|
|
730
|
+
if (state === undefined) {
|
|
731
|
+
// 未知のplan/taskはStoreの既存の拒否をそのまま通す。
|
|
732
|
+
return mutate({ repoRoot, env, planKey, taskId, kind: 'retire', payload: { reason }, evidenceRef: null });
|
|
733
|
+
}
|
|
734
|
+
if (state.status === 'retired') {
|
|
735
|
+
const events = member.journal.events;
|
|
736
|
+
const recorded = events.findLast((event) => event.kind === 'retire' && event.task_id === taskId)
|
|
737
|
+
?? events.at(-1);
|
|
738
|
+
const result = {
|
|
739
|
+
schema: 'lattice.todo_mutation_result.v2',
|
|
740
|
+
project_id: member.plan.project_id, plan_key: planKey, plan_version: member.plan.plan_version,
|
|
741
|
+
task_id: taskId, kind: 'retire', sequence: recorded.sequence, event_digest: recorded.event_digest,
|
|
742
|
+
journal_head_digest: events.at(-1).event_digest, snapshot_digest: member.snapshot.snapshot_digest,
|
|
743
|
+
status: 'retired', advisory: null, unchanged: true, result_digest: '',
|
|
744
|
+
};
|
|
745
|
+
result.result_digest = todoSelfDigest(result, 'result_digest');
|
|
746
|
+
return result;
|
|
747
|
+
}
|
|
748
|
+
if (state.status === 'in-progress') {
|
|
749
|
+
throw new TodoStoreError('STORE_INCONSISTENT', 'invalid_retire_transition', undefined, {
|
|
750
|
+
task_id: taskId, status: state.status,
|
|
751
|
+
next_action: `lattice todo retract --plan ${planKey} --task ${taskId} --reason <text>`,
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
try {
|
|
755
|
+
return await mutate({ repoRoot, env, planKey, taskId, kind: 'retire',
|
|
756
|
+
payload: { reason, prior_status: state.status }, evidenceRef: null });
|
|
757
|
+
} catch (error) {
|
|
758
|
+
throw retireStateConflict(error, { planKey, taskId, priorStatus: state.status });
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
|
|
716
762
|
async function startStructureContext({ repoRoot, store, planKey, taskId }) {
|
|
717
763
|
const member = store.members.find(({ descriptor }) => descriptor.plan_key === planKey);
|
|
718
764
|
if (member === undefined) throw new TodoStoreError('STORE_INCONSISTENT', 'plan_not_active');
|
|
@@ -1184,8 +1230,7 @@ async function dependencyConnect({
|
|
|
1184
1230
|
async function dependencyDisconnect({
|
|
1185
1231
|
repoRoot, env, fromPlanKey, fromTaskId, toPlanKey, toTaskId, reason,
|
|
1186
1232
|
}) {
|
|
1187
|
-
|
|
1188
|
-
const store = await readTodoStore({ repoRoot, tolerateStaleBindings: true });
|
|
1233
|
+
const store = await readTodoStore({ repoRoot });
|
|
1189
1234
|
const live = projectTodoCrossPlanDependencies(store.members).filter((dependency) => (
|
|
1190
1235
|
dependency.from.plan_key === fromPlanKey && dependency.from.task_id === fromTaskId
|
|
1191
1236
|
&& dependency.to.plan_key === toPlanKey && dependency.to.task_id === toTaskId
|
|
@@ -1202,7 +1247,6 @@ async function dependencyDisconnect({
|
|
|
1202
1247
|
const { event } = await appendTodoEvent({
|
|
1203
1248
|
validateProspectiveEvent,
|
|
1204
1249
|
repoRoot, writer: createTodoStoreWriter({ caller: 'g5-authoring' }), planKey: owner.plan.plan_key,
|
|
1205
|
-
tolerateStaleBindings: true,
|
|
1206
1250
|
event: {
|
|
1207
1251
|
kind: 'cross_plan_dependency_removed', actor: mutationActor(env),
|
|
1208
1252
|
payload: { target_event_digest: target.event_digest, reason },
|
|
@@ -1838,7 +1882,8 @@ async function todoDetail({ repoRoot, planKey, taskId }) {
|
|
|
1838
1882
|
project_id: store.project_id,
|
|
1839
1883
|
plan_key: planKey,
|
|
1840
1884
|
plan_version: member.plan.plan_version,
|
|
1841
|
-
task
|
|
1885
|
+
// v7以前のtaskは欄を持たないのでnullで投影する(u12)。
|
|
1886
|
+
task: { ...task, done_condition: task.done_condition ?? null },
|
|
1842
1887
|
design_memo: designMemoProjection(task),
|
|
1843
1888
|
state,
|
|
1844
1889
|
note_context: context,
|
|
@@ -3469,20 +3514,25 @@ async function seamProposalsForGantt({ repoRoot, store }) {
|
|
|
3469
3514
|
|
|
3470
3515
|
export async function renderTodoGanttForProject({
|
|
3471
3516
|
repoRoot, stable = false, displayName = null, env = process.env, readModel = null,
|
|
3472
|
-
scope = DEFAULT_GANTT_SCOPE,
|
|
3517
|
+
scope = DEFAULT_GANTT_SCOPE, degraded = false,
|
|
3473
3518
|
}) {
|
|
3474
3519
|
const store = readModel
|
|
3475
3520
|
?? (stable ? await readTodoStoreStable({ repoRoot }) : await readTodoStore({ repoRoot }));
|
|
3476
3521
|
const identity = displayName === null
|
|
3477
3522
|
? await resolveProjectIdentity({ repoRoot, projectId: store.project_id, env })
|
|
3478
3523
|
: { displayName };
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3524
|
+
// degraded (display of an unverified/last_verified store): every current-file overlay is
|
|
3525
|
+
// omitted, since computing one can reach strict Store validation.
|
|
3526
|
+
const presentation = degraded ? null
|
|
3527
|
+
: await loadTodoGanttPresentation({ repoRoot, readModel: store });
|
|
3528
|
+
const [independence, seamProposals, notes, structures] = degraded
|
|
3529
|
+
? [null, null, { contexts: null, warnings: [], headBindings: [] }, null]
|
|
3530
|
+
: await Promise.all([
|
|
3531
|
+
independenceForGantt({ repoRoot, store }),
|
|
3532
|
+
seamProposalsForGantt({ repoRoot, store }),
|
|
3533
|
+
notesForGantt({ repoRoot, store }),
|
|
3534
|
+
loadTodoStructurePresentation({ repoRoot, readModel: store }),
|
|
3535
|
+
]);
|
|
3486
3536
|
const layout = layoutTodoGantt(store, { scope, independence, seamProposals });
|
|
3487
3537
|
// When the diagram hides history, the page also carries the full diagram so
|
|
3488
3538
|
// the reader can bring it back in place. Nothing is hidden under `all`.
|
|
@@ -3490,8 +3540,9 @@ export async function renderTodoGanttForProject({
|
|
|
3490
3540
|
? null : layoutTodoGantt(store, {
|
|
3491
3541
|
scope: 'all', independence, seamProposals,
|
|
3492
3542
|
});
|
|
3493
|
-
const narrative =
|
|
3494
|
-
|
|
3543
|
+
const narrative = degraded ? { narratives: [], bindings: [] }
|
|
3544
|
+
: await loadNarratives(store, repoRoot);
|
|
3545
|
+
const anchorOutcomes = degraded ? [] : verifyNarrativeAnchors({
|
|
3495
3546
|
readModel: store,
|
|
3496
3547
|
narratives: narrative.narratives,
|
|
3497
3548
|
});
|
|
@@ -3506,16 +3557,16 @@ export async function renderTodoGanttForProject({
|
|
|
3506
3557
|
const memberBindings = store.members.map((member) => ({
|
|
3507
3558
|
plan_key: member.descriptor.plan_key,
|
|
3508
3559
|
topology_digest: member.plan.topology_digest,
|
|
3509
|
-
journal_head_digest: member.journal.events.at(-1)
|
|
3560
|
+
journal_head_digest: member.journal.events.at(-1)?.event_digest ?? null,
|
|
3510
3561
|
}));
|
|
3511
3562
|
const metadata = {
|
|
3512
3563
|
manifest_digest: store.manifest.manifest_digest,
|
|
3513
3564
|
member_bindings: memberBindings,
|
|
3514
3565
|
narrative_bindings_digest: digestTodoArtifact(narrativeBindings),
|
|
3515
|
-
presentation_digest: presentation
|
|
3566
|
+
presentation_digest: presentation?.presentation_digest ?? null,
|
|
3516
3567
|
layout_digest: digestTodoArtifact(layout),
|
|
3517
3568
|
note_bindings_digest: digestTodoArtifact(notes.headBindings),
|
|
3518
|
-
structure_projection_digest: structures
|
|
3569
|
+
structure_projection_digest: structures?.projection_digest ?? null,
|
|
3519
3570
|
renderer_version: TODO_GANTT_RENDERER_VERSION,
|
|
3520
3571
|
project_display_name: identity.displayName,
|
|
3521
3572
|
folded_task_count: layout.scope.folded_task_count,
|
|
@@ -3535,32 +3586,101 @@ export async function renderTodoGanttForProject({
|
|
|
3535
3586
|
return { store, metadata, memberBindings, rendered };
|
|
3536
3587
|
}
|
|
3537
3588
|
|
|
3589
|
+
/**
|
|
3590
|
+
* The two serving paths (public daemon, local live gantt) render the Store's typed
|
|
3591
|
+
* display result: a read-only view refuses nothing, so an inconsistent store is shown
|
|
3592
|
+
* as a banner state, never a 500. One-shot CLI renders keep their strict reads.
|
|
3593
|
+
*/
|
|
3594
|
+
export function createTodoGanttDisplayServing({
|
|
3595
|
+
repoRoot, projectId, scope = DEFAULT_GANTT_SCOPE, env = process.env, reader = null, ...readers
|
|
3596
|
+
}) {
|
|
3597
|
+
reader ??= createTodoGanttDisplayReader({ repoRoot, ...readers });
|
|
3598
|
+
return {
|
|
3599
|
+
render: async ({ displayName }) => {
|
|
3600
|
+
const result = await reader.read();
|
|
3601
|
+
const { html, banner_html: bannerHtml = null } = await renderGanttDisplayResult({
|
|
3602
|
+
repoRoot, result, displayName, scope, env,
|
|
3603
|
+
});
|
|
3604
|
+
return { html, banner_html: bannerHtml, head_digest: await ganttDisplayHead({ repoRoot, result }),
|
|
3605
|
+
// 配信のたびに読む。外部ペインを差した/外した側にdaemon再起動を要求しない。
|
|
3606
|
+
external_pane: result.state === 'unavailable' ? null
|
|
3607
|
+
: await readProjectExternalPane({ repoRoot, projectId }) };
|
|
3608
|
+
},
|
|
3609
|
+
readHead: async () => ganttDisplayHead({ repoRoot, result: await reader.read() }),
|
|
3610
|
+
};
|
|
3611
|
+
}
|
|
3612
|
+
|
|
3613
|
+
async function ganttDisplayHead({ repoRoot, result }) {
|
|
3614
|
+
return displayHeadDigest(result, result.state === 'verified'
|
|
3615
|
+
? await ganttLiveHeadDigest({ repoRoot, store: result.store }) : null);
|
|
3616
|
+
}
|
|
3617
|
+
|
|
3618
|
+
async function renderGanttDisplayResult({ repoRoot, result, displayName, scope, env }) {
|
|
3619
|
+
const render = async (store, state, dropped) => {
|
|
3620
|
+
const { rendered } = await renderTodoGanttForProject({
|
|
3621
|
+
repoRoot, stable: true, displayName, scope, env, readModel: store, degraded: true,
|
|
3622
|
+
});
|
|
3623
|
+
return { html: rendered.html, banner_html: degradedBannerHtml({
|
|
3624
|
+
state, verifiedAt: result.verified_at, inconsistency: result.inconsistency, dropped }) };
|
|
3625
|
+
};
|
|
3626
|
+
const storeDropped = Array.isArray(result.dropped_members) ? result.dropped_members : [];
|
|
3627
|
+
switch (result.state) {
|
|
3628
|
+
case 'verified': {
|
|
3629
|
+
const { rendered } = await renderTodoGanttForProject({
|
|
3630
|
+
repoRoot, stable: true, displayName, scope, env, readModel: result.store,
|
|
3631
|
+
});
|
|
3632
|
+
return { html: rendered.html };
|
|
3633
|
+
}
|
|
3634
|
+
case 'unverified': {
|
|
3635
|
+
const { store, dropped } = projectUnverifiedStore(result.store);
|
|
3636
|
+
const all = [...storeDropped, ...dropped];
|
|
3637
|
+
if (store.members.length === 0) {
|
|
3638
|
+
return { html: emptyStateHtml({ inconsistency: result.inconsistency, dropped: all }) };
|
|
3639
|
+
}
|
|
3640
|
+
return render(store, 'unverified', all);
|
|
3641
|
+
}
|
|
3642
|
+
case 'last_verified': return render(result.store, 'last_verified', storeDropped);
|
|
3643
|
+
case 'unavailable':
|
|
3644
|
+
return { html: emptyStateHtml({ inconsistency: result.inconsistency, dropped: storeDropped }) };
|
|
3645
|
+
default:
|
|
3646
|
+
throw new TypeError(`unknown Store display state: ${result.state}`);
|
|
3647
|
+
}
|
|
3648
|
+
}
|
|
3649
|
+
|
|
3650
|
+
// Reached only when the display read carries no project id (unavailable) and the repository
|
|
3651
|
+
// registered none: the empty state is still served, under this fixed route id.
|
|
3652
|
+
const UNREGISTERED_PROJECT_ID = 'unregistered-project';
|
|
3653
|
+
|
|
3654
|
+
/**
|
|
3655
|
+
* Start the local live gantt from the display read, so an inconsistent store does not stop it
|
|
3656
|
+
* from starting (the same stop the typed states remove from the page itself).
|
|
3657
|
+
*/
|
|
3658
|
+
export async function startTodoGanttDisplayLive({
|
|
3659
|
+
repoRoot, port = 0, env = process.env, scope = DEFAULT_GANTT_SCOPE, onShutdown = null, ...readers
|
|
3660
|
+
}) {
|
|
3661
|
+
const reader = createTodoGanttDisplayReader({ repoRoot, ...readers });
|
|
3662
|
+
const { projectId: carried, planKeys } = displayResultBinding(await reader.read());
|
|
3663
|
+
const projectId = carried ?? await readRegisteredProjectId({ repoRoot }) ?? UNREGISTERED_PROJECT_ID;
|
|
3664
|
+
let identity = { displayName: projectId };
|
|
3665
|
+
try { identity = await resolveProjectIdentity({ repoRoot, projectId, env }); } catch (error) {
|
|
3666
|
+
if (carried !== null) throw error; // a readable store keeps the strict identity contract
|
|
3667
|
+
}
|
|
3668
|
+
const live = await startTodoGanttLiveServer({
|
|
3669
|
+
projectId, displayName: identity.displayName, port, onShutdown,
|
|
3670
|
+
...createTodoGanttDisplayServing({ repoRoot, projectId, scope, env, reader }),
|
|
3671
|
+
});
|
|
3672
|
+
return { live, planKeys };
|
|
3673
|
+
}
|
|
3674
|
+
|
|
3538
3675
|
async function serveGantt({ repoRoot, port, stdout, env, scope = DEFAULT_GANTT_SCOPE }) {
|
|
3539
|
-
const initialStore = await readTodoStoreStable({ repoRoot });
|
|
3540
|
-
const identity = await resolveProjectIdentity({ repoRoot, projectId: initialStore.project_id, env });
|
|
3541
3676
|
let stop;
|
|
3542
3677
|
const stopped = new Promise((resolve) => { stop = resolve; });
|
|
3543
|
-
const live = await
|
|
3544
|
-
|
|
3545
|
-
displayName: identity.displayName,
|
|
3546
|
-
port,
|
|
3547
|
-
render: async () => {
|
|
3548
|
-
const store = await readTodoStoreStable({ repoRoot });
|
|
3549
|
-
const { rendered } = await renderTodoGanttForProject({
|
|
3550
|
-
repoRoot, stable: true, displayName: identity.displayName, scope, readModel: store,
|
|
3551
|
-
});
|
|
3552
|
-
return { html: rendered.html, head_digest: await ganttLiveHeadDigest({ repoRoot, store }),
|
|
3553
|
-
// ローカルの動的dashboardも公開daemonと同じ口を通す(毎描画で読むので差し外しが即反映される)。
|
|
3554
|
-
external_pane: await readProjectExternalPane({ repoRoot, projectId: store.project_id }) };
|
|
3555
|
-
},
|
|
3556
|
-
readHead: async () => ganttLiveHeadDigest({
|
|
3557
|
-
repoRoot, store: await readTodoStoreStable({ repoRoot }),
|
|
3558
|
-
}),
|
|
3559
|
-
onShutdown: process.platform === 'win32' ? stop : null,
|
|
3678
|
+
const { live, planKeys } = await startTodoGanttDisplayLive({
|
|
3679
|
+
repoRoot, port, env, scope, onShutdown: process.platform === 'win32' ? stop : null,
|
|
3560
3680
|
});
|
|
3561
3681
|
const result = { schema: 'lattice.todo_gantt_live_result.v3', project_id: live.projectId,
|
|
3562
3682
|
resource_scope: 'project', selection_scope: scope,
|
|
3563
|
-
included_plan_keys:
|
|
3683
|
+
included_plan_keys: planKeys,
|
|
3564
3684
|
media_type: 'text/html; charset=utf-8', dynamic: true,
|
|
3565
3685
|
host: live.host, port: live.port, project_path: live.projectPath,
|
|
3566
3686
|
url: live.url, events_url: live.eventsUrl };
|
|
@@ -3677,6 +3797,7 @@ async function verify({ repoRoot, requestedPlanKey }) {
|
|
|
3677
3797
|
case 'lattice.phase_todo_revision.v2':
|
|
3678
3798
|
case 'lattice.phase_todo_revision.v3':
|
|
3679
3799
|
case 'lattice.phase_todo_revision.v4':
|
|
3800
|
+
case 'lattice.phase_todo_revision.v5':
|
|
3680
3801
|
verifiedSourceInventories.set(member.descriptor.plan_key,
|
|
3681
3802
|
await verifyEffectivePhaseTodoRevisionSources({ repoRoot, member }));
|
|
3682
3803
|
break;
|
|
@@ -3689,7 +3810,8 @@ async function verify({ repoRoot, requestedPlanKey }) {
|
|
|
3689
3810
|
const reconciled = member.revision !== null;
|
|
3690
3811
|
const sourceInventory = verifiedSourceInventories.get(member.descriptor.plan_key) ?? null;
|
|
3691
3812
|
const phaseRevision = ['lattice.phase_todo_revision.v1', 'lattice.phase_todo_revision.v2',
|
|
3692
|
-
'lattice.phase_todo_revision.v3', 'lattice.phase_todo_revision.v4'
|
|
3813
|
+
'lattice.phase_todo_revision.v3', 'lattice.phase_todo_revision.v4',
|
|
3814
|
+
'lattice.phase_todo_revision.v5']
|
|
3693
3815
|
.includes(member.revision?.schema);
|
|
3694
3816
|
return {
|
|
3695
3817
|
plan_key: member.descriptor.plan_key,
|
|
@@ -4199,9 +4321,8 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4199
4321
|
known: ['plan', 'task', 'reason'], required: ['plan', 'task', 'reason'],
|
|
4200
4322
|
});
|
|
4201
4323
|
if (flags !== null && isTodoIdentifier(flags.plan) && isTodoIdentifier(flags.task)) {
|
|
4202
|
-
action = (repoRoot) =>
|
|
4203
|
-
repoRoot, env, planKey: flags.plan, taskId: flags.task,
|
|
4204
|
-
kind: 'retire', payload: { reason: flags.reason }, evidenceRef: null,
|
|
4324
|
+
action = (repoRoot) => retireTask({
|
|
4325
|
+
repoRoot, env, planKey: flags.plan, taskId: flags.task, reason: flags.reason,
|
|
4205
4326
|
});
|
|
4206
4327
|
}
|
|
4207
4328
|
} else if (argv[0] === 'unblock') {
|
|
@@ -4245,6 +4366,13 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
4245
4366
|
}
|
|
4246
4367
|
}
|
|
4247
4368
|
if (action === null) {
|
|
4369
|
+
// 書込みの出力は常にJSONなので、`--json`は結果を変えない旗として受ける(seat契約)。
|
|
4370
|
+
// 読めなかった時だけ外して読み直すので、既に`--json`を文法に持つ命令は変わらない。
|
|
4371
|
+
const withoutJson = argv.filter((value) => value !== '--json');
|
|
4372
|
+
if (withoutJson.length < argv.length && writesTodoStore(withoutJson)) {
|
|
4373
|
+
return runTodoCli({ argv: atomicCommit ? [...withoutJson, '--commit-store'] : withoutJson,
|
|
4374
|
+
cwd, stdout, stderr, env, onInternalFailure });
|
|
4375
|
+
}
|
|
4248
4376
|
const command = typeof argv[0] === 'string' ? argv[0] : null;
|
|
4249
4377
|
if (command !== null && !TODO_COMMAND_NAMES.includes(command)) {
|
|
4250
4378
|
return typedArgumentFailure(stderr, 'UNKNOWN_SUBCOMMAND', 'todo_subcommand_unknown', {
|
package/src/todo-contracts.mjs
CHANGED
|
@@ -376,6 +376,14 @@ function taskV6(value) {
|
|
|
376
376
|
&& isTodoIdentifier(value.phase_id);
|
|
377
377
|
}
|
|
378
378
|
|
|
379
|
+
function taskV8(value) {
|
|
380
|
+
const { done_condition: doneCondition, ...rest } = value ?? {};
|
|
381
|
+
return exactRecord(value, [
|
|
382
|
+
'task_id', 'title', 'lane', 'design_memo', 'narrative_ref', 'narrative_anchor',
|
|
383
|
+
'compile_binding', 'parent_task_id', 'phase_id', 'done_condition',
|
|
384
|
+
]) && taskV6(rest) && (doneCondition === null || isTodoDesignMemo(doneCondition));
|
|
385
|
+
}
|
|
386
|
+
|
|
379
387
|
function phaseV1(value) {
|
|
380
388
|
return exactRecord(value, [
|
|
381
389
|
'phase_id', 'title', 'gate_policy', 'predecessor_phase_ids', 'required_evidence_slots',
|
|
@@ -445,14 +453,16 @@ export function explainTodoPlan(value) {
|
|
|
445
453
|
: value?.schema === 'lattice.todo_plan.v3' ? taskV3
|
|
446
454
|
: ['lattice.todo_plan.v4', 'lattice.todo_plan.v5'].includes(value?.schema) ? taskV4
|
|
447
455
|
: value?.schema === 'lattice.todo_plan.v6' ? taskV5
|
|
448
|
-
: value?.schema === 'lattice.todo_plan.v7' ? taskV6
|
|
456
|
+
: value?.schema === 'lattice.todo_plan.v7' ? taskV6
|
|
457
|
+
: value?.schema === 'lattice.todo_plan.v8' ? taskV8 : null;
|
|
449
458
|
const planKeys = [
|
|
450
459
|
'schema', 'project_id', 'plan_key', 'plan_version', 'predecessor_plan_digest',
|
|
451
460
|
'tasks', 'hard_dependencies', 'joins', 'topology_digest', 'plan_digest',
|
|
452
461
|
];
|
|
453
|
-
const phased = ['lattice.todo_plan.v4', 'lattice.todo_plan.v5', 'lattice.todo_plan.v7'
|
|
462
|
+
const phased = ['lattice.todo_plan.v4', 'lattice.todo_plan.v5', 'lattice.todo_plan.v7',
|
|
463
|
+
'lattice.todo_plan.v8'].includes(value?.schema);
|
|
464
|
+
const decoupled = ['lattice.todo_plan.v5', 'lattice.todo_plan.v7', 'lattice.todo_plan.v8']
|
|
454
465
|
.includes(value?.schema);
|
|
455
|
-
const decoupled = ['lattice.todo_plan.v5', 'lattice.todo_plan.v7'].includes(value?.schema);
|
|
456
466
|
if (phased) planKeys.push('phases');
|
|
457
467
|
if (decoupled) planKeys.push('phase_accept_dependencies');
|
|
458
468
|
if (!exactRecord(value, planKeys)) return reject('unexpected_or_missing_keys', '/');
|
|
@@ -485,7 +495,7 @@ export function explainTodoPlan(value) {
|
|
|
485
495
|
if (!isTodoDigest(value[field])) return reject('digest_invalid', `/${field}`);
|
|
486
496
|
}
|
|
487
497
|
if (['lattice.todo_plan.v3', 'lattice.todo_plan.v4', 'lattice.todo_plan.v5',
|
|
488
|
-
'lattice.todo_plan.v6', 'lattice.todo_plan.v7'].includes(value.schema)
|
|
498
|
+
'lattice.todo_plan.v6', 'lattice.todo_plan.v7', 'lattice.todo_plan.v8'].includes(value.schema)
|
|
489
499
|
&& !validParentGraph(value.tasks)) return reject('parent_graph_invalid', '/tasks');
|
|
490
500
|
if (phased) {
|
|
491
501
|
if (!Array.isArray(value.phases) || value.phases.length === 0
|
|
@@ -591,7 +601,12 @@ function validPayload(event) {
|
|
|
591
601
|
if (event.kind === 'unblock') return exactRecord(payload, []);
|
|
592
602
|
// retire: 消費計画が消えた工程の恒久除去(ADR 0147系の状態遷移に足す軽量kind・2026-08-29オーナー裁定)。
|
|
593
603
|
// 理由必須。blocked_reasonのfieldを理由の置き場として再利用し、state recordの形を変えない。
|
|
594
|
-
if (event.kind === 'retire')
|
|
604
|
+
if (event.kind === 'retire') {
|
|
605
|
+
return (exactRecord(payload, ['reason'])
|
|
606
|
+
|| (exactRecord(payload, ['reason', 'prior_status'])
|
|
607
|
+
&& ['pending', 'blocked', 'in-progress', 'done'].includes(payload.prior_status)))
|
|
608
|
+
&& nullableText(payload.reason) && payload.reason !== null;
|
|
609
|
+
}
|
|
595
610
|
if (event.kind === 'done' && payload?.done_mode === 'authored') {
|
|
596
611
|
return (exactRecord(payload, ['done_mode', 'imported', 'evidence'])
|
|
597
612
|
|| exactRecord(payload, ['done_mode', 'imported', 'evidence', 'test_result']))
|
|
@@ -662,7 +677,8 @@ function validCarriedState(value) {
|
|
|
662
677
|
if (value.status === 'blocked') return value.done_at === null && value.blocked_reason !== null
|
|
663
678
|
&& activeEvidenceValid && testResult === null;
|
|
664
679
|
// retired: 実行されないまま恒久に閉じた工程。理由はblocked_reasonが持ち、証拠・試験結果は持たない。
|
|
665
|
-
|
|
680
|
+
// done_at is kept only when retired from done (u12).
|
|
681
|
+
if (value.status === 'retired') return value.blocked_reason !== null
|
|
666
682
|
&& value.evidence === null && testResult === null;
|
|
667
683
|
return value.blocked_reason === null && value.evidence !== null
|
|
668
684
|
// importedは完了状態の来歴を表す。evidence_promotion後もtrueを維持するため、
|
|
@@ -87,6 +87,33 @@ function validateRegistry(value) {
|
|
|
87
87
|
return value;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
const QUARANTINE_KEEP = 3;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* u03 D22: the registry is rebuilt by every `todo start/done` and `dashboard ensure`, so an
|
|
94
|
+
* invalid one (not JSON, wrong schema, duplicate project) is moved aside as
|
|
95
|
+
* `projects.json.invalid-<UTC>` (newest 3 kept) and read as empty instead of stopping the
|
|
96
|
+
* dashboard. A failed move leaves the file; the next read retries.
|
|
97
|
+
*/
|
|
98
|
+
async function readRegistry(ref) {
|
|
99
|
+
try {
|
|
100
|
+
return validateRegistry(await readJson(ref, { schema: REGISTRY_SCHEMA, projects: [] }));
|
|
101
|
+
} catch (error) {
|
|
102
|
+
if (error?.code !== 'DASHBOARD_REGISTRY_INVALID') throw error;
|
|
103
|
+
}
|
|
104
|
+
// The random tail keeps two moves in the same millisecond from overwriting each other.
|
|
105
|
+
const stamp = `${new Date().toISOString().replace(/[:.]/gu, '-')}-${randomBytes(4).toString('hex')}`;
|
|
106
|
+
try {
|
|
107
|
+
await rename(ref, `${ref}.invalid-${stamp}`);
|
|
108
|
+
process.emitWarning(`dashboard registry was invalid and moved aside: ${ref}.invalid-${stamp}`,
|
|
109
|
+
{ code: 'LATTICE_DASHBOARD_REGISTRY_QUARANTINED' });
|
|
110
|
+
const prefix = `${path.basename(ref)}.invalid-`;
|
|
111
|
+
const names = (await readdir(path.dirname(ref))).filter((name) => name.startsWith(prefix)).sort().reverse();
|
|
112
|
+
for (const name of names.slice(QUARANTINE_KEEP)) await rm(path.join(path.dirname(ref), name), { force: true });
|
|
113
|
+
} catch { /* best-effort: the next read tries again */ }
|
|
114
|
+
return { schema: REGISTRY_SCHEMA, projects: [] };
|
|
115
|
+
}
|
|
116
|
+
|
|
90
117
|
async function readJson(ref, missing) {
|
|
91
118
|
let bytes;
|
|
92
119
|
try { bytes = await readFile(ref, 'utf8'); } catch (error) {
|
|
@@ -152,7 +179,7 @@ async function withLock(lockRef, action) {
|
|
|
152
179
|
|
|
153
180
|
export async function readActiveTodoDashboardProjects({ env = process.env, now = Date.now() } = {}) {
|
|
154
181
|
const ref = paths(env).registry;
|
|
155
|
-
const document =
|
|
182
|
+
const document = await readRegistry(ref);
|
|
156
183
|
return document.projects.filter((entry) => now - Date.parse(entry.last_seen_at) <= TODO_DASHBOARD_STALE_MS)
|
|
157
184
|
.sort((left, right) => left.display_name.localeCompare(right.display_name, 'ja')
|
|
158
185
|
|| left.project_id.localeCompare(right.project_id, 'en'));
|
|
@@ -163,7 +190,7 @@ export async function readVisibleTodoDashboardProjects({
|
|
|
163
190
|
} = {}) {
|
|
164
191
|
if (typeof projectHasActiveRun !== 'function') throw new TypeError('projectHasActiveRun required');
|
|
165
192
|
const ref = paths(env).registry;
|
|
166
|
-
const document =
|
|
193
|
+
const document = await readRegistry(ref);
|
|
167
194
|
const visible = [];
|
|
168
195
|
for (const entry of document.projects) {
|
|
169
196
|
if (now - Date.parse(entry.last_seen_at) <= TODO_DASHBOARD_STALE_MS
|
|
@@ -226,7 +253,7 @@ export async function registerTodoDashboardActivity({
|
|
|
226
253
|
await mkdir(refs.root, { recursive: true, mode: 0o700 });
|
|
227
254
|
const pruned = [];
|
|
228
255
|
await withLock(refs.lock, async () => {
|
|
229
|
-
const current =
|
|
256
|
+
const current = await readRegistry(refs.registry);
|
|
230
257
|
const existing = current.projects.find((entry) => entry.project_id === projectId);
|
|
231
258
|
if (existing !== undefined && existing.repo_root !== canonicalRoot && !adopt) {
|
|
232
259
|
const error = new Error('project id is already owned by another canonical root');
|
|
@@ -266,7 +293,7 @@ export async function removeTodoDashboardProject({ projectId, env = process.env
|
|
|
266
293
|
const refs = paths(env);
|
|
267
294
|
await mkdir(refs.root, { recursive: true, mode: 0o700 });
|
|
268
295
|
await withLock(refs.lock, async () => {
|
|
269
|
-
const current =
|
|
296
|
+
const current = await readRegistry(refs.registry);
|
|
270
297
|
const projects = current.projects.filter((entry) => entry.project_id !== projectId);
|
|
271
298
|
if (projects.length === current.projects.length) {
|
|
272
299
|
const error = new Error('dashboard project is not registered');
|