@quolu/lattice 0.80.0 → 0.82.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 +8 -3
- package/bin/lattice.mjs +28 -0
- package/docs/schemas/lattice.plan_revise_input.v1.schema.json +32 -0
- package/package.json +3 -2
- package/src/bridge-cli.mjs +16 -4
- package/src/bridge-config.mjs +6 -7
- package/src/bridge-detached-supervisor.mjs +204 -0
- package/src/bridge-startup-folder.mjs +7 -4
- package/src/cli-help.mjs +3 -0
- package/src/plan-backchain.mjs +11 -8
- package/src/plan-binding-carry.mjs +60 -0
- package/src/plan-revise.mjs +175 -0
- package/src/project-cli.mjs +28 -12
- package/src/runtime-multi-epoch-store.mjs +53 -13
- package/src/runtime-os-observation.mjs +39 -1
- package/src/seat-identity.mjs +23 -0
- package/src/store-lock.mjs +4 -2
- package/src/todo-authoring-input.mjs +1 -0
- package/src/todo-cli.mjs +5 -3
- package/src/todo-note-store.mjs +7 -2
- package/src/todo-revision.mjs +7 -5
- package/src/todo-store-view.mjs +58 -0
- package/src/todo-store.mjs +107 -68
package/src/todo-store-view.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* Pure projections shared by Store and Plan; no I/O or lifecycle mutation. */
|
|
2
|
+
import { canonicalizeTodoArtifact } from './todo-contracts.mjs';
|
|
2
3
|
|
|
3
4
|
export function isPhaseTodoPlanSchema(schema) {
|
|
4
5
|
return ['lattice.todo_plan.v4', 'lattice.todo_plan.v5', 'lattice.todo_plan.v7'].includes(schema);
|
|
@@ -45,3 +46,60 @@ export function projectTodoCrossPlanDependencies(members) {
|
|
|
45
46
|
return key(left) < key(right) ? -1 : key(left) > key(right) ? 1 : 0;
|
|
46
47
|
});
|
|
47
48
|
}
|
|
49
|
+
|
|
50
|
+
function mappedNodeRef(ref, plan, idMap) {
|
|
51
|
+
if (ref.project_id !== plan.project_id || ref.plan_key !== plan.plan_key) return ref;
|
|
52
|
+
return { ...ref, task_id: idMap.get(ref.task_id) ?? ref.task_id };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function localTaskRef(ref, plan, taskId) {
|
|
56
|
+
return ref.project_id === plan.project_id && ref.plan_key === plan.plan_key
|
|
57
|
+
&& ref.task_id === taskId;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function removedTaskRef(ref, plan, removedTaskIds) {
|
|
61
|
+
return ref.project_id === plan.project_id && ref.plan_key === plan.plan_key
|
|
62
|
+
&& removedTaskIds.has(ref.task_id);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function todoTaskCarrySemantics(plan, taskId, idMap, {
|
|
66
|
+
reconciliationMetadata = false, includeDesignMemo = false, removedTaskIds = new Set(),
|
|
67
|
+
} = {}) {
|
|
68
|
+
const task = plan.tasks.find(({ task_id }) => task_id === taskId);
|
|
69
|
+
if (!task) return null;
|
|
70
|
+
const mapId = (id) => id === null ? null : idMap.get(id) ?? id;
|
|
71
|
+
const normalizedTask = reconciliationMetadata ? {
|
|
72
|
+
task_id: mapId(task.task_id), title: task.title, lane: task.lane,
|
|
73
|
+
compile_binding: task.compile_binding,
|
|
74
|
+
} : {
|
|
75
|
+
task_id: mapId(task.task_id), title: task.title, lane: task.lane,
|
|
76
|
+
...(includeDesignMemo ? { design_memo: task.design_memo } : {}),
|
|
77
|
+
narrative_ref: task.narrative_ref, narrative_anchor: task.narrative_anchor ?? null,
|
|
78
|
+
compile_binding: task.compile_binding, parent_task_id: mapId(task.parent_task_id ?? null),
|
|
79
|
+
};
|
|
80
|
+
const edges = plan.hard_dependencies
|
|
81
|
+
.filter(({ from, to }) => !removedTaskRef(from, plan, removedTaskIds)
|
|
82
|
+
&& !removedTaskRef(to, plan, removedTaskIds)
|
|
83
|
+
&& (localTaskRef(from, plan, taskId) || localTaskRef(to, plan, taskId)))
|
|
84
|
+
.map(({ from, to }) => ({ from: mappedNodeRef(from, plan, idMap), to: mappedNodeRef(to, plan, idMap) }))
|
|
85
|
+
.sort((left, right) => canonicalizeTodoArtifact(left) < canonicalizeTodoArtifact(right) ? -1 : 1);
|
|
86
|
+
const joins = plan.joins
|
|
87
|
+
.flatMap((join) => {
|
|
88
|
+
if (removedTaskRef(join.before, plan, removedTaskIds)) return [];
|
|
89
|
+
const after = join.after.filter((ref) => !removedTaskRef(ref, plan, removedTaskIds));
|
|
90
|
+
if (after.length === 0 || (!localTaskRef(join.before, plan, taskId)
|
|
91
|
+
&& !after.some((ref) => localTaskRef(ref, plan, taskId)))) return [];
|
|
92
|
+
return [{ ...join,
|
|
93
|
+
after: after.map((ref) => mappedNodeRef(ref, plan, idMap))
|
|
94
|
+
.sort((left, right) => canonicalizeTodoArtifact(left) < canonicalizeTodoArtifact(right) ? -1 : 1),
|
|
95
|
+
before: mappedNodeRef(join.before, plan, idMap),
|
|
96
|
+
}];
|
|
97
|
+
}).sort((left, right) => left.id < right.id ? -1 : 1);
|
|
98
|
+
const phaseAcceptDependencies = isDecoupledPhaseTodoPlanSchema(plan.schema)
|
|
99
|
+
? plan.phase_accept_dependencies
|
|
100
|
+
.filter(({ to }) => localTaskRef(to, plan, taskId))
|
|
101
|
+
.map(({ from, to }) => ({ from, to: mappedNodeRef(to, plan, idMap) }))
|
|
102
|
+
.sort((left, right) => canonicalizeTodoArtifact(left) < canonicalizeTodoArtifact(right) ? -1 : 1)
|
|
103
|
+
: [];
|
|
104
|
+
return { task: normalizedTask, hard_dependencies: edges, joins, phase_accept_dependencies: phaseAcceptDependencies };
|
|
105
|
+
}
|
package/src/todo-store.mjs
CHANGED
|
@@ -3,12 +3,16 @@ import {
|
|
|
3
3
|
isPhaseTodoPlanSchema,
|
|
4
4
|
isPhaselessTodoPlanSchema,
|
|
5
5
|
projectTodoCrossPlanDependencies,
|
|
6
|
+
localTaskRef,
|
|
7
|
+
removedTaskRef,
|
|
8
|
+
todoTaskCarrySemantics as taskSemantics,
|
|
6
9
|
} from './todo-store-view.mjs';
|
|
7
10
|
export {
|
|
8
11
|
isDecoupledPhaseTodoPlanSchema,
|
|
9
12
|
isPhaseTodoPlanSchema,
|
|
10
13
|
isPhaselessTodoPlanSchema,
|
|
11
14
|
projectTodoCrossPlanDependencies,
|
|
15
|
+
todoTaskCarrySemantics,
|
|
12
16
|
} from './todo-store-view.mjs';
|
|
13
17
|
import { randomBytes } from 'node:crypto';
|
|
14
18
|
import { fsyncDirectory } from './fs-dir-sync.mjs';
|
|
@@ -85,6 +89,7 @@ const TODO_REVISION_SCHEMAS = Object.freeze([
|
|
|
85
89
|
const PHASE_TODO_REVISION_SCHEMAS = Object.freeze([
|
|
86
90
|
'lattice.phase_todo_revision.v1', 'lattice.phase_todo_revision.v2',
|
|
87
91
|
'lattice.phase_todo_revision.v3', 'lattice.phase_todo_revision.v4',
|
|
92
|
+
'lattice.phase_todo_revision.v5',
|
|
88
93
|
]);
|
|
89
94
|
|
|
90
95
|
export class TodoStoreError extends Error {
|
|
@@ -866,12 +871,9 @@ function snapshotFor(plan, events, tasks) {
|
|
|
866
871
|
return snapshot;
|
|
867
872
|
}
|
|
868
873
|
|
|
869
|
-
function validateMergedGraph(members, crossPlanDependencies =
|
|
870
|
-
//
|
|
871
|
-
//
|
|
872
|
-
// コマンド自身も load を要するため、扉が無いと修理経路が存在しない(実被弾 2026-08-29:
|
|
873
|
-
// evidence-2 改訂で store 全体が読めなくなり、disconnect も同エラーで詰んだ)。
|
|
874
|
-
// 許容するのは digest 不一致だけで、dangling / missing は修理扉でも fail する。
|
|
874
|
+
function validateMergedGraph(members, crossPlanDependencies = projectTodoCrossPlanDependencies(members), options = {}) {
|
|
875
|
+
// Only disconnect and the locked identity-preserving repair tolerate stale digests.
|
|
876
|
+
// Missing endpoints and bindings remain invalid on both repair paths.
|
|
875
877
|
const tolerateStale = options.tolerateStaleBindings === true;
|
|
876
878
|
const tasks = new Map();
|
|
877
879
|
for (const member of members) for (const task of member.plan.tasks) {
|
|
@@ -2040,6 +2042,100 @@ async function appendPlanScopedEvent({ repoRoot, member, input }) {
|
|
|
2040
2042
|
};
|
|
2041
2043
|
}
|
|
2042
2044
|
|
|
2045
|
+
/** Rebind existing connections to a carried source without changing their endpoints. */
|
|
2046
|
+
export async function rebindTodoCrossPlanDependencies(options = {}) {
|
|
2047
|
+
requireWriter(options.writer, 'g5-authoring');
|
|
2048
|
+
if (typeof options.validateBindingCarry !== 'function'
|
|
2049
|
+
|| !isTodoIdentifier(options.planKey) || !isTodoIdentifier(options.sourcePlanKey)
|
|
2050
|
+
|| !isTodoDigest(options.expectedManifestDigest)
|
|
2051
|
+
|| !isTodoDigest(options.expectedPlanScopedHeadDigest)
|
|
2052
|
+
|| !Array.isArray(options.eventDigests) || options.eventDigests.length === 0
|
|
2053
|
+
|| !options.eventDigests.every(isTodoDigest)
|
|
2054
|
+
|| new Set(options.eventDigests).size !== options.eventDigests.length
|
|
2055
|
+
|| typeof options.reason !== 'string' || options.reason.length === 0) {
|
|
2056
|
+
throw new TypeError('dependency rebind requires exact bindings and a Plan carry validator');
|
|
2057
|
+
}
|
|
2058
|
+
const repoRoot = path.resolve(options.repoRoot ?? process.cwd());
|
|
2059
|
+
return withLock(repoRoot, async () => {
|
|
2060
|
+
// The repair read must not publish derived state before the complete strict graph check.
|
|
2061
|
+
const store = await readTodoStoreView({ repoRoot, now: options.now,
|
|
2062
|
+
tolerateStaleBindings: true });
|
|
2063
|
+
const owner = store.members.find(({ plan }) => plan.plan_key === options.planKey);
|
|
2064
|
+
const source = store.members.find(({ plan }) => plan.plan_key === options.sourcePlanKey);
|
|
2065
|
+
if (store.manifest.manifest_digest !== options.expectedManifestDigest
|
|
2066
|
+
|| owner?.plan_scoped.events.at(-1)?.event_digest !== options.expectedPlanScopedHeadDigest) {
|
|
2067
|
+
fail('STORE_WRITE_CONFLICT', 'dependency_rebind_binding_changed');
|
|
2068
|
+
}
|
|
2069
|
+
if (!source || source === owner) fail('DEPENDENCY_INVALID', 'dependency_rebind_source_invalid');
|
|
2070
|
+
const dependencies = projectTodoCrossPlanDependencies(store.members)
|
|
2071
|
+
.filter(({ event_digest: digest }) => options.eventDigests.includes(digest));
|
|
2072
|
+
if (dependencies.length !== options.eventDigests.length || dependencies.some(({ from, to, event_digest: digest }) => (
|
|
2073
|
+
from.project_id !== source.plan.project_id || from.plan_key !== source.plan.plan_key
|
|
2074
|
+
|| from.expected_topology_digest === source.plan.topology_digest
|
|
2075
|
+
|| to.project_id !== owner.plan.project_id || to.plan_key !== owner.plan.plan_key
|
|
2076
|
+
|| !owner.plan_scoped.events.some((event) => event.event_digest === digest)
|
|
2077
|
+
))) fail('DEPENDENCY_INVALID', 'dependency_rebind_original_mismatch');
|
|
2078
|
+
const predecessorBinding = source.revision?.predecessor;
|
|
2079
|
+
if (!predecessorBinding) fail('DEPENDENCY_INVALID', 'dependency_rebind_predecessor_missing');
|
|
2080
|
+
const predecessor = await readArtifact(repoRoot,
|
|
2081
|
+
`${STORE_ROOT_REF}/plans/${source.plan.plan_key}/${predecessorBinding.plan_version}/plan.json`, {
|
|
2082
|
+
code: 'STORE_INCONSISTENT', maxBytes: TODO_LIMITS.snapshotBytes, validate: validateTodoPlan,
|
|
2083
|
+
});
|
|
2084
|
+
if (predecessor.project_id !== source.plan.project_id || predecessor.plan_key !== source.plan.plan_key
|
|
2085
|
+
|| predecessor.plan_version !== predecessorBinding.plan_version
|
|
2086
|
+
|| predecessor.plan_digest !== predecessorBinding.plan_digest) {
|
|
2087
|
+
fail('STORE_INCONSISTENT', 'dependency_rebind_predecessor_mismatch');
|
|
2088
|
+
}
|
|
2089
|
+
const validation = await options.validateBindingCarry({ store, source, dependencies,
|
|
2090
|
+
predecessor: { plan_version: predecessor.plan_version, plan_digest: predecessor.plan_digest,
|
|
2091
|
+
topology_digest: predecessor.topology_digest } });
|
|
2092
|
+
if (validation?.ok === false) {
|
|
2093
|
+
if (typeof validation.code !== 'string' || typeof validation.detail?.reason !== 'string') {
|
|
2094
|
+
throw new TypeError('binding carry validator must return a typed refusal');
|
|
2095
|
+
}
|
|
2096
|
+
const { reason, ...detail } = validation.detail;
|
|
2097
|
+
fail(validation.code, reason, detail);
|
|
2098
|
+
}
|
|
2099
|
+
if (validation?.ok !== true) throw new TypeError('binding carry validator must return an ok result');
|
|
2100
|
+
const staged = { ...owner, plan_scoped: { ...owner.plan_scoped,
|
|
2101
|
+
events: [...owner.plan_scoped.events] } };
|
|
2102
|
+
const replacements = [];
|
|
2103
|
+
for (const dependency of dependencies) {
|
|
2104
|
+
for (const input of [
|
|
2105
|
+
{ kind: 'cross_plan_dependency_removed', payload: {
|
|
2106
|
+
target_event_digest: dependency.event_digest, reason: options.reason,
|
|
2107
|
+
} },
|
|
2108
|
+
{ kind: 'cross_plan_dependency', payload: {
|
|
2109
|
+
from: { ...dependency.from, expected_topology_digest: source.plan.topology_digest },
|
|
2110
|
+
to: dependency.to, reason: dependency.reason,
|
|
2111
|
+
} },
|
|
2112
|
+
]) {
|
|
2113
|
+
const event = buildPlanScopedEvent(staged, { ...input, actor: options.actor,
|
|
2114
|
+
recorded_at: options.recordedAt ?? new Date().toISOString() });
|
|
2115
|
+
const bytes = planScopedEventBytes(staged, event);
|
|
2116
|
+
staged.plan_scoped.events.push(event);
|
|
2117
|
+
staged.plan_scoped.activeBytes = Buffer.concat([staged.plan_scoped.activeBytes, bytes]);
|
|
2118
|
+
}
|
|
2119
|
+
replacements.push({ original_event_digest: dependency.event_digest,
|
|
2120
|
+
replacement_event_digest: staged.plan_scoped.events.at(-1).event_digest });
|
|
2121
|
+
}
|
|
2122
|
+
const prospective = store.members.map((member) => member === owner ? staged : member);
|
|
2123
|
+
const projected = projectTodoCrossPlanDependencies(prospective);
|
|
2124
|
+
const edgeKeys = projected.map(({ from, to }) => `${mergedTaskKey(from)}\0${mergedTaskKey(to)}`);
|
|
2125
|
+
if (new Set(edgeKeys).size !== edgeKeys.length) {
|
|
2126
|
+
fail('DEPENDENCY_EXISTS', 'cross_plan_dependency_duplicate');
|
|
2127
|
+
}
|
|
2128
|
+
validateMergedGraph(prospective, projected);
|
|
2129
|
+
await protocolStage(options, 'dependency_rebind_validated');
|
|
2130
|
+
await atomicWrite(path.resolve(repoRoot, owner.plan_scoped.ref), staged.plan_scoped.activeBytes);
|
|
2131
|
+
await protocolStage(options, 'dependency_rebind_published');
|
|
2132
|
+
return { schema: 'lattice.todo_dependency_rebind_result.v1', project_id: store.project_id,
|
|
2133
|
+
plan_key: owner.plan.plan_key, source_plan_key: source.plan.plan_key,
|
|
2134
|
+
source_topology_digest: source.plan.topology_digest, replacements,
|
|
2135
|
+
plan_scoped_head_digest: staged.plan_scoped.events.at(-1).event_digest };
|
|
2136
|
+
});
|
|
2137
|
+
}
|
|
2138
|
+
|
|
2043
2139
|
export function buildTodoPlan(input) {
|
|
2044
2140
|
const plan = { ...input, topology_digest: '', plan_digest: '' };
|
|
2045
2141
|
plan.topology_digest = digestTodoArtifact({
|
|
@@ -3263,69 +3359,12 @@ export async function verifyPhaseTodoRevisionSources(options = {}) {
|
|
|
3263
3359
|
return true;
|
|
3264
3360
|
}
|
|
3265
3361
|
|
|
3266
|
-
function mappedNodeRef(ref, plan, idMap) {
|
|
3267
|
-
if (ref.project_id !== plan.project_id || ref.plan_key !== plan.plan_key) return ref;
|
|
3268
|
-
return { ...ref, task_id: idMap.get(ref.task_id) ?? ref.task_id };
|
|
3269
|
-
}
|
|
3270
|
-
|
|
3271
|
-
function localTaskRef(ref, plan, taskId) {
|
|
3272
|
-
return ref.project_id === plan.project_id && ref.plan_key === plan.plan_key
|
|
3273
|
-
&& ref.task_id === taskId;
|
|
3274
|
-
}
|
|
3275
|
-
|
|
3276
3362
|
function removedTaskIdsFor(revision) {
|
|
3277
3363
|
return new Set(revision.task_migration
|
|
3278
3364
|
.filter(({ to_task_id, state_policy }) => to_task_id === 'removed' && state_policy === 'removed')
|
|
3279
3365
|
.map(({ from_task_id }) => from_task_id));
|
|
3280
3366
|
}
|
|
3281
3367
|
|
|
3282
|
-
function removedTaskRef(ref, plan, removedTaskIds) {
|
|
3283
|
-
return ref.project_id === plan.project_id && ref.plan_key === plan.plan_key
|
|
3284
|
-
&& removedTaskIds.has(ref.task_id);
|
|
3285
|
-
}
|
|
3286
|
-
|
|
3287
|
-
function taskSemantics(plan, taskId, idMap, {
|
|
3288
|
-
reconciliationMetadata = false, includeDesignMemo = false, removedTaskIds = new Set(),
|
|
3289
|
-
} = {}) {
|
|
3290
|
-
const task = plan.tasks.find(({ task_id }) => task_id === taskId);
|
|
3291
|
-
if (!task) return null;
|
|
3292
|
-
const mapId = (id) => id === null ? null : idMap.get(id) ?? id;
|
|
3293
|
-
const normalizedTask = reconciliationMetadata ? {
|
|
3294
|
-
task_id: mapId(task.task_id), title: task.title, lane: task.lane,
|
|
3295
|
-
compile_binding: task.compile_binding,
|
|
3296
|
-
} : {
|
|
3297
|
-
task_id: mapId(task.task_id), title: task.title, lane: task.lane,
|
|
3298
|
-
...(includeDesignMemo ? { design_memo: task.design_memo } : {}),
|
|
3299
|
-
narrative_ref: task.narrative_ref, narrative_anchor: task.narrative_anchor ?? null,
|
|
3300
|
-
compile_binding: task.compile_binding, parent_task_id: mapId(task.parent_task_id ?? null),
|
|
3301
|
-
};
|
|
3302
|
-
const edges = plan.hard_dependencies
|
|
3303
|
-
.filter(({ from, to }) => !removedTaskRef(from, plan, removedTaskIds)
|
|
3304
|
-
&& !removedTaskRef(to, plan, removedTaskIds)
|
|
3305
|
-
&& (localTaskRef(from, plan, taskId) || localTaskRef(to, plan, taskId)))
|
|
3306
|
-
.map(({ from, to }) => ({ from: mappedNodeRef(from, plan, idMap), to: mappedNodeRef(to, plan, idMap) }))
|
|
3307
|
-
.sort((left, right) => canonicalizeTodoArtifact(left) < canonicalizeTodoArtifact(right) ? -1 : 1);
|
|
3308
|
-
const joins = plan.joins
|
|
3309
|
-
.flatMap((join) => {
|
|
3310
|
-
if (removedTaskRef(join.before, plan, removedTaskIds)) return [];
|
|
3311
|
-
const after = join.after.filter((ref) => !removedTaskRef(ref, plan, removedTaskIds));
|
|
3312
|
-
if (after.length === 0 || (!localTaskRef(join.before, plan, taskId)
|
|
3313
|
-
&& !after.some((ref) => localTaskRef(ref, plan, taskId)))) return [];
|
|
3314
|
-
return [{ ...join,
|
|
3315
|
-
after: after.map((ref) => mappedNodeRef(ref, plan, idMap))
|
|
3316
|
-
.sort((left, right) => canonicalizeTodoArtifact(left) < canonicalizeTodoArtifact(right) ? -1 : 1),
|
|
3317
|
-
before: mappedNodeRef(join.before, plan, idMap),
|
|
3318
|
-
}];
|
|
3319
|
-
}).sort((left, right) => left.id < right.id ? -1 : 1);
|
|
3320
|
-
const phaseAcceptDependencies = isDecoupledPhaseTodoPlanSchema(plan.schema)
|
|
3321
|
-
? plan.phase_accept_dependencies
|
|
3322
|
-
.filter(({ to }) => localTaskRef(to, plan, taskId))
|
|
3323
|
-
.map(({ from, to }) => ({ from, to: mappedNodeRef(to, plan, idMap) }))
|
|
3324
|
-
.sort((left, right) => canonicalizeTodoArtifact(left) < canonicalizeTodoArtifact(right) ? -1 : 1)
|
|
3325
|
-
: [];
|
|
3326
|
-
return { task: normalizedTask, hard_dependencies: edges, joins, phase_accept_dependencies: phaseAcceptDependencies };
|
|
3327
|
-
}
|
|
3328
|
-
|
|
3329
3368
|
function phaseV3CarrySemantics(plan, taskId, taskIdMap, phaseIdMap,
|
|
3330
3369
|
{ reconciliationMetadata = false, includeDesignMemo = false, removedTaskIds = new Set() } = {}) {
|
|
3331
3370
|
const task = plan.tasks.find(({ task_id: id }) => id === taskId);
|
|
@@ -4516,7 +4555,7 @@ async function applyPhaseTodoRevisionV3(options, revision, repoRoot) {
|
|
|
4516
4555
|
const stateMigration = stateMigrationFor(previous, revision);
|
|
4517
4556
|
const phaseStateMigration = phaseStateMigrationFor(previous, revision);
|
|
4518
4557
|
validateMergedGraph(store.members.map((member) => member === previous
|
|
4519
|
-
? { ...member, plan: revision.desired_plan } : member));
|
|
4558
|
+
? { ...member, plan: revision.desired_plan, plan_scoped: null } : member));
|
|
4520
4559
|
const candidateGenesis = buildPhaseRevisionGenesis(revision.desired_plan, {
|
|
4521
4560
|
previous_digest: revision.predecessor.journal_head_digest, actor: options.actor,
|
|
4522
4561
|
recorded_at: options.recordedAt, provenance: options.provenance ?? null,
|
|
@@ -4687,7 +4726,7 @@ export async function applyPhaseTodoRevision(options = {}) {
|
|
|
4687
4726
|
const stateMigration = stateMigrationFor(previous, revision);
|
|
4688
4727
|
const phaseStateMigration = phaseStateMigrationFor(previous, revision);
|
|
4689
4728
|
const prospective = store.members.map((member) => member === previous
|
|
4690
|
-
? { ...member, plan: revision.desired_plan } : member);
|
|
4729
|
+
? { ...member, plan: revision.desired_plan, plan_scoped: null } : member);
|
|
4691
4730
|
validateMergedGraph(prospective);
|
|
4692
4731
|
const candidateGenesis = buildPhaseRevisionGenesis(revision.desired_plan, {
|
|
4693
4732
|
previous_digest: revision.predecessor.journal_head_digest,
|
|
@@ -4834,7 +4873,7 @@ export async function applyTodoRevision(options = {}) {
|
|
|
4834
4873
|
verifyPlanNarrativeAnchors(repoRoot, revision.desired_plan, previous.plan);
|
|
4835
4874
|
const stateMigration = stateMigrationFor(previous, revision);
|
|
4836
4875
|
const prospective = store.members.map((member) => member === previous
|
|
4837
|
-
? { ...member, plan: revision.desired_plan } : member);
|
|
4876
|
+
? { ...member, plan: revision.desired_plan, plan_scoped: null } : member);
|
|
4838
4877
|
validateMergedGraph(prospective);
|
|
4839
4878
|
|
|
4840
4879
|
const candidateGenesis = buildRevisionGenesis(revision.desired_plan, {
|
|
@@ -5107,7 +5146,7 @@ export async function applyTodoRevisionSet(options = {}) {
|
|
|
5107
5146
|
const desiredByPlan = new Map(prepared.map((entry) => [entry.revision.plan_key,
|
|
5108
5147
|
entry.revision.desired_plan]));
|
|
5109
5148
|
validateMergedGraph(store.members.map((member) => desiredByPlan.has(member.descriptor.plan_key)
|
|
5110
|
-
? { ...member, plan: desiredByPlan.get(member.descriptor.plan_key) } : member));
|
|
5149
|
+
? { ...member, plan: desiredByPlan.get(member.descriptor.plan_key), plan_scoped: null } : member));
|
|
5111
5150
|
|
|
5112
5151
|
await ensureSafeStoreDirectory(repoRoot, transaction);
|
|
5113
5152
|
const mixedPhaseSet = prepared.some(({ revision }) => ([
|
|
@@ -5300,7 +5339,7 @@ export async function createSuccessorTodoPlan(options = {}) {
|
|
|
5300
5339
|
const genesis = buildPlanGenesis(plan, {
|
|
5301
5340
|
...options.genesis, previous_digest: previous.journal.events.at(-1).event_digest,
|
|
5302
5341
|
});
|
|
5303
|
-
const prospective = store.members.map((member) => member === previous ? { ...member, plan } : member);
|
|
5342
|
+
const prospective = store.members.map((member) => member === previous ? { ...member, plan, plan_scoped: null } : member);
|
|
5304
5343
|
validateMergedGraph(prospective);
|
|
5305
5344
|
const base = `${STORE_ROOT_REF}/plans/${plan.plan_key}/${plan.plan_version}`;
|
|
5306
5345
|
const planRef = `${base}/plan.json`; const journalRef = `${base}/journal/active.jsonl`; const snapshotRef = `${base}/snapshot.json`;
|