@quolu/lattice 0.79.4 → 0.80.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-dashboard.mjs +6 -5
- package/bin/lattice-mcp.mjs +2 -1
- package/docs/bridge-setup.md +8 -0
- package/docs/schemas/lattice.plan_create_input.v4.schema.json +8 -4
- package/docs/schemas/lattice.todo_extraction.v3.schema.json +5 -3
- package/docs/schemas/lattice.todo_extraction.v4.schema.json +5 -3
- package/package.json +1 -1
- package/sensor/dist/mcp/index.d.ts +3 -1
- package/sensor/dist/mcp/index.d.ts.map +1 -1
- package/sensor/dist/mcp/index.js +7 -2
- package/sensor/dist/mcp/index.js.map +1 -1
- package/sensor/dist/mcp/proxy.d.ts +2 -0
- package/sensor/dist/mcp/proxy.d.ts.map +1 -1
- package/sensor/dist/mcp/proxy.js +9 -3
- package/sensor/dist/mcp/proxy.js.map +1 -1
- package/sensor/dist/mcp/session.d.ts +7 -0
- package/sensor/dist/mcp/session.d.ts.map +1 -1
- package/sensor/dist/mcp/session.js +4 -1
- package/sensor/dist/mcp/session.js.map +1 -1
- package/sensor/dist/mcp/transport.d.ts +5 -5
- package/sensor/dist/mcp/transport.d.ts.map +1 -1
- package/sensor/dist/mcp/transport.js +14 -6
- package/sensor/dist/mcp/transport.js.map +1 -1
- package/src/dashboard-lifecycle-journal.mjs +3 -1
- package/src/fs-publish.mjs +9 -0
- package/src/mcp-startup-receipt.mjs +99 -0
- package/src/project-cli.mjs +2 -2
- package/src/runtime-os-observation.mjs +18 -1
- package/src/setup-config.mjs +7 -3
- package/src/store-lock.mjs +250 -0
- package/src/todo-cli.mjs +6 -0
- package/src/todo-contracts.mjs +95 -50
- package/src/todo-migration.mjs +35 -10
- package/src/todo-note-store.mjs +45 -12
- package/src/todo-readiness.mjs +154 -0
- package/src/todo-status.mjs +4 -33
- package/src/todo-store-cache.mjs +50 -6
- package/src/todo-store-git-transaction.mjs +11 -6
- package/src/todo-store-view.mjs +47 -0
- package/src/todo-store.mjs +597 -398
- package/src/artifact-contracts-v2.mjs +0 -325
- package/src/boundary-compiler.mjs +0 -712
- package/src/bounded-seam.mjs +0 -230
- package/src/control-compiler.mjs +0 -532
- package/src/rc1-black-box-oracle.mjs +0 -906
- package/src/rc1-comparison.mjs +0 -154
- package/src/rc1-evidence-bundle.mjs +0 -456
- package/src/rc1-v4-campaign.mjs +0 -708
- package/src/rc1-v4-transform.mjs +0 -467
- package/src/rc1-v5-artifact-set.mjs +0 -855
- package/src/rc1-v5-behavior-evidence.mjs +0 -594
- package/src/rc1-v5-campaign.mjs +0 -797
- package/src/rc1-v5-transform.mjs +0 -421
- package/src/rc1-v6-artifact-set.mjs +0 -807
- package/src/rc1-v6-behavior-evidence.mjs +0 -273
- package/src/rc1-v6-campaign.mjs +0 -623
- package/src/rc1-v6-causal-binding.mjs +0 -473
- package/src/rc1-v6-measurement.mjs +0 -313
- package/src/rc2-artifact-set.mjs +0 -1584
- package/src/rc2-campaign.mjs +0 -1495
- package/src/rc2-delivery-policy-front-end.mjs +0 -1079
- package/src/rc2-delivery-policy-oracle.mjs +0 -134
- package/src/rc2-delivery-policy-transform.mjs +0 -1127
- package/src/rc2-rc1-transfer-front-end.mjs +0 -511
- package/src/rc3-actual-dogfood.mjs +0 -652
- package/src/rc3-dogfood-scaffold.mjs +0 -315
- package/src/rc3-scripted-campaign.mjs +0 -1383
- package/src/rc4-stage1-dogfood.mjs +0 -673
- package/src/runtime-scripted-executor.mjs +0 -163
- package/src/runtime-worktree-executor.mjs +0 -199
- package/src/seam-transform.mjs +0 -554
- package/src/treatment-compiler.mjs +0 -728
- package/src/treatment-runner.mjs +0 -656
package/src/todo-store-cache.mjs
CHANGED
|
@@ -13,13 +13,40 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { createHash } from 'node:crypto';
|
|
16
|
-
import { readFile } from 'node:fs/promises';
|
|
16
|
+
import { readFile, stat } from 'node:fs/promises';
|
|
17
17
|
import path from 'node:path';
|
|
18
18
|
|
|
19
19
|
import { readTodoStoreStable } from './todo-store.mjs';
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
const MANIFEST_REF = '.lattice/todo/manifest.json';
|
|
22
|
+
const READ_FAILURE = Symbol('store read failure');
|
|
23
|
+
|
|
24
|
+
/** Finite diagnostics only; keep the original exception and its errno intact. */
|
|
25
|
+
export function todoStoreReadFailurePhase(error) {
|
|
26
|
+
if (error?.[READ_FAILURE]) return error[READ_FAILURE];
|
|
27
|
+
if (['EACCES', 'EPERM'].includes(error?.code)) return 'store_access_denied';
|
|
28
|
+
if (error?.code === 'EIO') return 'store_io_failed';
|
|
29
|
+
if (error?.code === 'STORE_INCONSISTENT' && error.detail?.ref === MANIFEST_REF
|
|
30
|
+
&& ['schema_invalid', 'artifact_truncated_or_trailing_bytes', 'non_canonical_or_duplicate_key',
|
|
31
|
+
'size_limit_exceeded', 'artifact_eol_converted'].includes(error.detail.reason)) {
|
|
32
|
+
return 'store_manifest_invalid';
|
|
33
|
+
}
|
|
34
|
+
return 'store_read_failed';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function manifestContentDigest(repoRoot) {
|
|
38
|
+
try {
|
|
39
|
+
return createHash('sha256').update(await readFile(path.join(repoRoot, MANIFEST_REF))).digest('hex');
|
|
40
|
+
} catch (error) {
|
|
41
|
+
if (error.code === 'ENOENT') {
|
|
42
|
+
try {
|
|
43
|
+
if ((await stat(repoRoot)).isDirectory()) error[READ_FAILURE] = 'store_manifest_missing';
|
|
44
|
+
} catch (rootError) {
|
|
45
|
+
if (rootError.code === 'ENOENT') error[READ_FAILURE] = 'store_root_missing';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
23
50
|
}
|
|
24
51
|
|
|
25
52
|
/**
|
|
@@ -30,14 +57,31 @@ export function createTodoStoreCache({ readStable = readTodoStoreStable } = {})
|
|
|
30
57
|
const cache = new Map();
|
|
31
58
|
return {
|
|
32
59
|
async read(repoRoot) {
|
|
33
|
-
const
|
|
34
|
-
const digest = await manifestContentDigest(manifestRef);
|
|
60
|
+
const digest = await manifestContentDigest(repoRoot);
|
|
35
61
|
const cached = cache.get(repoRoot);
|
|
36
62
|
if (cached?.digest === digest) return cached.store;
|
|
37
63
|
// Read before caching: a failure here (including the store's own inconsistency
|
|
38
64
|
// detection) must not populate the cache, so the very next call re-reads instead
|
|
39
65
|
// of serving a poisoned entry.
|
|
40
|
-
|
|
66
|
+
let store;
|
|
67
|
+
try { store = await readStable({ repoRoot }); }
|
|
68
|
+
catch (error) {
|
|
69
|
+
const ref = error?.detail?.ref;
|
|
70
|
+
const absolute = typeof ref === 'string' ? path.resolve(repoRoot, ref) : null;
|
|
71
|
+
if (error?.code === 'STORE_INCONSISTENT' && error.detail?.reason === 'artifact_missing'
|
|
72
|
+
&& ref !== MANIFEST_REF && absolute?.startsWith(`${path.resolve(repoRoot, '.lattice/todo')}${path.sep}`)) {
|
|
73
|
+
// The store's legacy artifact_missing also covers lstat I/O errors.
|
|
74
|
+
try { await stat(absolute); }
|
|
75
|
+
catch (artifactError) {
|
|
76
|
+
if (artifactError.code === 'ENOENT') {
|
|
77
|
+
let currentDigest;
|
|
78
|
+
try { currentDigest = await manifestContentDigest(repoRoot); } catch { /* concurrent removal stays unknown */ }
|
|
79
|
+
if (currentDigest === digest) error[READ_FAILURE] = 'store_artifact_missing';
|
|
80
|
+
} else error[READ_FAILURE] = todoStoreReadFailurePhase(artifactError);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
41
85
|
cache.set(repoRoot, { digest, store });
|
|
42
86
|
return store;
|
|
43
87
|
},
|
|
@@ -15,6 +15,11 @@ import {
|
|
|
15
15
|
|
|
16
16
|
const execFileAsync = promisify(execFile);
|
|
17
17
|
const STORE_REF = '.lattice/todo';
|
|
18
|
+
const STORE_PATHS = [STORE_REF,
|
|
19
|
+
':(exclude,glob).lattice/todo/**/.write.lock*',
|
|
20
|
+
':(exclude,glob).lattice/todo/**/.write.lock*/**',
|
|
21
|
+
':(exclude,glob).lattice/todo/.cross-plan-recovery/**',
|
|
22
|
+
];
|
|
18
23
|
const LOCK_NAME = 'lattice-todo-store-commit.lock';
|
|
19
24
|
|
|
20
25
|
export class TodoStoreGitTransactionError extends Error {
|
|
@@ -104,7 +109,7 @@ async function headTarget(repoRoot, env) {
|
|
|
104
109
|
|
|
105
110
|
async function storeStatus(repoRoot, env) {
|
|
106
111
|
const result = await git(repoRoot,
|
|
107
|
-
['status', '--porcelain=v1', '-z', '--untracked-files=all', '--',
|
|
112
|
+
['status', '--porcelain=v1', '-z', '--untracked-files=all', '--', ...STORE_PATHS], { env });
|
|
108
113
|
return fields(result.stdout);
|
|
109
114
|
}
|
|
110
115
|
|
|
@@ -142,13 +147,13 @@ async function prepareSharedIndex({ repoRoot, commitSha, env }) {
|
|
|
142
147
|
await lockHandle.close();
|
|
143
148
|
lockHandle = null;
|
|
144
149
|
const isolatedEnv = { ...env, GIT_INDEX_FILE: lockPath };
|
|
145
|
-
await git(repoRoot, ['reset', '--quiet', commitSha, '--',
|
|
150
|
+
await git(repoRoot, ['reset', '--quiet', commitSha, '--', ...STORE_PATHS], { env: isolatedEnv });
|
|
146
151
|
const indexCompared = await git(repoRoot,
|
|
147
|
-
['diff', '--quiet', '--cached', commitSha, '--',
|
|
152
|
+
['diff', '--quiet', '--cached', commitSha, '--', ...STORE_PATHS], {
|
|
148
153
|
env: isolatedEnv, allowExitCodes: [0, 1],
|
|
149
154
|
});
|
|
150
155
|
const worktreeCompared = await git(repoRoot,
|
|
151
|
-
['diff', '--quiet', commitSha, '--',
|
|
156
|
+
['diff', '--quiet', commitSha, '--', ...STORE_PATHS], {
|
|
152
157
|
env: isolatedEnv, allowExitCodes: [0, 1],
|
|
153
158
|
});
|
|
154
159
|
if (indexCompared.exitCode !== 0 || worktreeCompared.exitCode !== 0) {
|
|
@@ -221,9 +226,9 @@ async function buildDetachedCommit({ repoRoot, commonDir, headBefore, message, e
|
|
|
221
226
|
GIT_INDEX_FILE: indexPath,
|
|
222
227
|
};
|
|
223
228
|
await git(repoRoot, ['read-tree', headBefore], { env: isolatedEnv });
|
|
224
|
-
await git(repoRoot, ['add', '-A', '--',
|
|
229
|
+
await git(repoRoot, ['add', '-A', '--', ...STORE_PATHS], { env: isolatedEnv });
|
|
225
230
|
const changed = fields((await git(repoRoot,
|
|
226
|
-
['diff', '--cached', '--name-only', '-z', '--',
|
|
231
|
+
['diff', '--cached', '--name-only', '-z', '--', ...STORE_PATHS], { env: isolatedEnv })).stdout);
|
|
227
232
|
if (changed.length === 0) fail('STORE_COMMIT_NO_CHANGES', 'todo_store_mutation_changed_no_paths');
|
|
228
233
|
if (changed.some((ref) => ref !== STORE_REF && !ref.startsWith(`${STORE_REF}/`))) {
|
|
229
234
|
fail('STORE_COMMIT_SCOPE_VIOLATION', 'todo_store_commit_contains_outside_path', {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/* Pure projections shared by Store and Plan; no I/O or lifecycle mutation. */
|
|
2
|
+
|
|
3
|
+
export function isPhaseTodoPlanSchema(schema) {
|
|
4
|
+
return ['lattice.todo_plan.v4', 'lattice.todo_plan.v5', 'lattice.todo_plan.v7'].includes(schema);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function isDecoupledPhaseTodoPlanSchema(schema) {
|
|
8
|
+
return ['lattice.todo_plan.v5', 'lattice.todo_plan.v7'].includes(schema);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// CLI側(migrate/plan create/最後のdone)が「終端重監査が要る」ことを通知するために
|
|
12
|
+
// 同じ判定を再利用する。判定基準を二重管理しないよう、ここから公開する。
|
|
13
|
+
export function isPhaselessTodoPlanSchema(schema) {
|
|
14
|
+
return !isPhaseTodoPlanSchema(schema);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* active plan群へ接続済みのplan跨ぎ依存線を投影する。
|
|
19
|
+
*
|
|
20
|
+
* eventはconsumer(to)planのplan-scoped chainへ積まれる。自動発見も暗黙補完もせず、
|
|
21
|
+
* 記録された線だけを返す。順序はtask identityで固定し、status/Ganttが同じ入力を見る。
|
|
22
|
+
*/
|
|
23
|
+
export function projectTodoCrossPlanDependencies(members) {
|
|
24
|
+
// 除去tombstoneを先に集め、指された接続を線として数えない(歴史は両eventとも残る)
|
|
25
|
+
const removed = new Set();
|
|
26
|
+
for (const member of members) for (const event of member.plan_scoped?.events ?? []) {
|
|
27
|
+
if (event.kind === 'cross_plan_dependency_removed') removed.add(event.payload.target_event_digest);
|
|
28
|
+
}
|
|
29
|
+
const dependencies = [];
|
|
30
|
+
for (const member of members) for (const event of member.plan_scoped?.events ?? []) {
|
|
31
|
+
if (event.kind !== 'cross_plan_dependency') continue;
|
|
32
|
+
if (removed.has(event.event_digest)) continue;
|
|
33
|
+
dependencies.push({
|
|
34
|
+
from: event.payload.from,
|
|
35
|
+
to: event.payload.to,
|
|
36
|
+
reason: event.payload.reason,
|
|
37
|
+
connected_by: event.actor,
|
|
38
|
+
connected_at: event.recorded_at,
|
|
39
|
+
event_digest: event.event_digest,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return dependencies.sort((left, right) => {
|
|
43
|
+
const key = (entry) => `${entry.from.project_id}\0${entry.from.plan_key}\0${entry.from.task_id}`
|
|
44
|
+
+ `\0${entry.to.project_id}\0${entry.to.plan_key}\0${entry.to.task_id}\0${entry.event_digest}`;
|
|
45
|
+
return key(left) < key(right) ? -1 : key(left) > key(right) ? 1 : 0;
|
|
46
|
+
});
|
|
47
|
+
}
|