@quolu/lattice 0.88.0 → 0.89.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 +5 -2
- package/README.md +7 -3
- package/package.json +1 -1
- package/src/cli-refusal-guidance.mjs +11 -5
- package/src/todo-cli.mjs +13 -3
- package/src/todo-store.mjs +51 -3
package/README.ja.md
CHANGED
|
@@ -156,12 +156,15 @@ lattice bridge status --json
|
|
|
156
156
|
## Release
|
|
157
157
|
|
|
158
158
|
Latticeのreleaseはこのrepoから行います。`package.json`と`CHANGELOG.md`を更新し、製品gateを通し、
|
|
159
|
-
release commitを既定branchへ着地・push
|
|
160
|
-
|
|
159
|
+
release commitを既定branchへ着地・pushします。そのpushでCIが成功すると`publish.yml`が自動で起動し、
|
|
160
|
+
試験済みの同じ木を検査の再実行なしで公開します(registryに未公開で`latest`より新しい版だけ)。
|
|
161
|
+
その後、同じ版の実installを確認します。`prepublishOnly`はdirty treeとremote既定branchへ未着地のcommitを
|
|
162
|
+
拒否します。`gh workflow run publish.yml`は、`main`先頭のCIが成功済みの時の手動再試行です。
|
|
161
163
|
|
|
162
164
|
```bash
|
|
163
165
|
npm run ci
|
|
164
166
|
npm run verify:release-commit
|
|
167
|
+
# 公開はCI成功後に自動で始まる。次は手動の再試行
|
|
165
168
|
gh workflow run publish.yml --repo kitepon/Lattice --ref main
|
|
166
169
|
npm install -g @quolu/lattice@<version>
|
|
167
170
|
lattice --version
|
package/README.md
CHANGED
|
@@ -324,13 +324,17 @@ AI登録の診断は`lattice setup status --json`。`--host <AI>`で対象を限
|
|
|
324
324
|
## Release
|
|
325
325
|
|
|
326
326
|
Maintainers release Lattice from this repository. Update `package.json` and `CHANGELOG.md`, pass the
|
|
327
|
-
product gate, land and push the release commit on the default branch
|
|
328
|
-
|
|
329
|
-
|
|
327
|
+
product gate, land and push the release commit on the default branch. When `CI` succeeds on that
|
|
328
|
+
push, `publish.yml` publishes the same tree without re-running the suite (only a version that is not on
|
|
329
|
+
the registry and newer than `latest`); then verify that version from the registry. `prepublishOnly`
|
|
330
|
+
rejects a dirty tree or a commit not landed on the remote default branch. `gh workflow run publish.yml`
|
|
331
|
+
remains the manual retry once `CI` is green on the `main` tip
|
|
332
|
+
([flow](https://github.com/kitepon/Lattice/blob/main/docs/architecture/dfd-release-publish.md)).
|
|
330
333
|
|
|
331
334
|
```bash
|
|
332
335
|
npm run ci
|
|
333
336
|
npm run verify:release-commit
|
|
337
|
+
# publication starts by itself after CI; this is the manual retry
|
|
334
338
|
gh workflow run publish.yml --repo kitepon/Lattice --ref main
|
|
335
339
|
npm install -g @quolu/lattice@<version>
|
|
336
340
|
lattice setup --json
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quolu/lattice",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.89.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",
|
|
@@ -24,6 +24,11 @@ const run = (ctx, ...tail) => ['lattice', ctx.family ?? 'todo', ctx.command, ...
|
|
|
24
24
|
const schemaCommand = (ctx) => run(ctx, '--schema', '--json');
|
|
25
25
|
const showTask = (detail, ctx) => `lattice todo show --plan ${planOf(detail, ctx)} --task ${taskOf(detail, ctx)} --json`;
|
|
26
26
|
const startTask = (detail, ctx) => `lattice todo start --plan ${planOf(detail, ctx)} --task ${taskOf(detail, ctx)}`;
|
|
27
|
+
// The --message an enforced plan's done gate (ADR 0200 gate 4) accepts; the gate's own next_action uses it too.
|
|
28
|
+
export const ENFORCED_DONE_MESSAGE = '"<PR URL or merged commit sha>"';
|
|
29
|
+
// A done hint that the done gate accepts: on an enforced plan (ctx.enforcedPlans) it names the change, else `rest`.
|
|
30
|
+
const doneCommand = (planKey, taskId, ctx, rest = '') => `lattice todo done --plan ${planKey} --task ${taskId}${
|
|
31
|
+
strings(ctx.enforcedPlans).includes(planKey) ? ` --message ${ENFORCED_DONE_MESSAGE}` : rest}`;
|
|
27
32
|
// a12: name the blocking task (seat contract), falling back to the refused task's own detail.
|
|
28
33
|
const blocker = (detail) => (Array.isArray(detail.blocking_tasks) ? detail.blocking_tasks.find(record) : undefined);
|
|
29
34
|
// a18: the step that moves the blocker on depends on its status (a pending one is started first).
|
|
@@ -35,7 +40,7 @@ const unfinishedFirst = (detail, ctx) => {
|
|
|
35
40
|
return ({
|
|
36
41
|
pending: `Start ${name} first with \`lattice todo start ${on}\`, then record done on it`,
|
|
37
42
|
blocked: `Unblock ${name} with \`lattice todo unblock ${on}\`, then record done on it`,
|
|
38
|
-
})[first.status] ?? `Record done on ${name} first with
|
|
43
|
+
})[first.status] ?? `Record done on ${name} first with \`${doneCommand(first.plan_key, first.task_id, ctx, ' --message <text>')}\` (see \`lattice todo show ${on} --json\`)`;
|
|
39
44
|
};
|
|
40
45
|
// a36: a start without LATTICE_SEAT_ID is recorded under the OS user; after the seat sets its id that
|
|
41
46
|
// start looks like another seat's. Say so and give the seat contract's one-time fix.
|
|
@@ -46,7 +51,7 @@ const inProgressHolder = (detail, ctx, on) => {
|
|
|
46
51
|
return `It is in-progress under '${holder}', the name a start gets without LATTICE_SEAT_ID: most likely this seat's own`
|
|
47
52
|
+ ` start from before it set LATTICE_SEAT_ID. One-time fix (seat contract): with LATTICE_SEAT_ID unset, undo that start`
|
|
48
53
|
+ ` with \`lattice todo retract ${on} --reason <text>\` and start it again here, or finish it there first with`
|
|
49
|
-
+ `
|
|
54
|
+
+ ` \`${doneCommand(planOf(detail, ctx), taskOf(detail, ctx), ctx, ' --message <text>')}\`.`;
|
|
50
55
|
}
|
|
51
56
|
return `It is already in-progress under ${holder === null ? 'another seat' : `seat '${holder}'`}; see \`${showTask(detail, ctx)}\`.`
|
|
52
57
|
+ ` To move it to this seat run \`lattice todo start ${on} --rebind --reason <text>\`.`;
|
|
@@ -228,11 +233,12 @@ const REGISTRY = {
|
|
|
228
233
|
// a32: only a done task can be reopened; say the state and the step that fits it.
|
|
229
234
|
repair: (detail, ctx) => {
|
|
230
235
|
const on = `--plan ${planOf(detail, ctx)} --task ${taskOf(detail, ctx)}`;
|
|
236
|
+
const done = doneCommand(planOf(detail, ctx), taskOf(detail, ctx), ctx);
|
|
231
237
|
return `Only a done task can be reopened; ${planOf(detail, ctx)}/${taskOf(detail, ctx)} is ${detail.status ?? 'not done'}. ` + ({
|
|
232
238
|
// a35: retract undoes only an authored start; a reopened task has none.
|
|
233
239
|
'in-progress': detail.opened_by === 'start'
|
|
234
|
-
? `It is still open: finish it with
|
|
235
|
-
: `It is still open${openedByText(detail)}: finish it with
|
|
240
|
+
? `It is still open: finish it with \`${done}\`, or undo the start with \`lattice todo retract ${on} --reason <text>\`.`
|
|
241
|
+
: `It is still open${openedByText(detail)}: finish it with \`${done}\`.`,
|
|
236
242
|
pending: `It has not started: run \`lattice todo start ${on}\`.`,
|
|
237
243
|
blocked: `It is blocked: resume it with \`lattice todo unblock ${on}\`.`,
|
|
238
244
|
retired: `Retire is permanent, so it stays closed; see \`${showTask(detail, ctx)}\`.`,
|
|
@@ -265,7 +271,7 @@ const REGISTRY = {
|
|
|
265
271
|
// a35: say why there is nothing to retract and the step that closes the task instead.
|
|
266
272
|
repair: (detail, ctx) => `retract undoes only a start recorded by \`lattice todo start\`; `
|
|
267
273
|
+ `${planOf(detail, ctx)}/${taskOf(detail, ctx)} is in progress${openedByText(detail)}, so there is no start to undo. `
|
|
268
|
-
+ `Finish it with
|
|
274
|
+
+ `Finish it with \`${doneCommand(planOf(detail, ctx), taskOf(detail, ctx), ctx)}\`.`,
|
|
269
275
|
},
|
|
270
276
|
reopen_has_started_successor: {
|
|
271
277
|
repair: (detail, ctx) => `A successor of ${taskOf(detail, ctx)} has already started: to reopen it anyway run \`lattice todo reopen --plan ${planOf(detail, ctx)} --task ${taskOf(detail, ctx)} --reason <text> --override-reason <text>\`.`,
|
package/src/todo-cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
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
|
-
import { FLAG_PLACEHOLDER, publicRefusalCode, withRefusalGuidance } from './cli-refusal-guidance.mjs';
|
|
4
|
+
import { ENFORCED_DONE_MESSAGE, FLAG_PLACEHOLDER, publicRefusalCode, withRefusalGuidance } from './cli-refusal-guidance.mjs';
|
|
5
5
|
import { readTaskBackchainContext } from './plan-backchain.mjs';
|
|
6
6
|
import { auditPendingNextCommands, phaseAuditRequired } from './todo-audit-pending.mjs';
|
|
7
7
|
import { gitSync } from './git-process.mjs';
|
|
@@ -265,6 +265,16 @@ function guidanceContext(argv, env = {}) {
|
|
|
265
265
|
};
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
+
/** Enforced plans, so a refusal's done hint names the change their done gate needs; none when the store is unreadable. */
|
|
269
|
+
async function enforcedPlanKeys(cwd) {
|
|
270
|
+
try {
|
|
271
|
+
const { members } = await readTodoStore({ repoRoot: resolveRepoRoot(cwd) });
|
|
272
|
+
return members.filter((member) => member.coordination?.mode === 'enforced').map(({ descriptor }) => descriptor.plan_key);
|
|
273
|
+
} catch {
|
|
274
|
+
return [];
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
268
278
|
/**
|
|
269
279
|
* An error that reached here is, by definition, one none of the typed
|
|
270
280
|
* TodoStoreError/TypeError branches recognized — the one case where the
|
|
@@ -1451,7 +1461,7 @@ async function enforcedDoneGate({ repoRoot, planKey, flags }) {
|
|
|
1451
1461
|
}
|
|
1452
1462
|
throw new TodoStoreError('TODO_TRANSITION_REFUSED', 'enforced_done_reference_missing', undefined, {
|
|
1453
1463
|
plan_key: planKey, task_id: flags.task,
|
|
1454
|
-
next_action: `Name the adopted change: \`lattice todo done --plan ${planKey} --task ${flags.task} --message
|
|
1464
|
+
next_action: `Name the adopted change: \`lattice todo done --plan ${planKey} --task ${flags.task} --message ${ENFORCED_DONE_MESSAGE}\` (a sha must be in HEAD).`,
|
|
1455
1465
|
});
|
|
1456
1466
|
}
|
|
1457
1467
|
|
|
@@ -5219,7 +5229,7 @@ export async function runTodoCli({ argv, cwd, stdout, stderr, env = process.env,
|
|
|
5219
5229
|
} catch (error) {
|
|
5220
5230
|
if (error instanceof TodoStoreError || (typeof error?.code === 'string'
|
|
5221
5231
|
&& error.detail !== null && typeof error.detail === 'object')) {
|
|
5222
|
-
return typedFailure(stderr, error, guidanceContext(argv, env));
|
|
5232
|
+
return typedFailure(stderr, error, { ...guidanceContext(argv, env), enforcedPlans: await enforcedPlanKeys(cwd) });
|
|
5223
5233
|
}
|
|
5224
5234
|
// 漏れた`fetch failed`もTypeErrorで届く。呼び出し側の契約違反と答えず、内部故障として観測口へ渡す。
|
|
5225
5235
|
if (error instanceof TypeError && cliFailureClass(error) !== 'transport') {
|
package/src/todo-store.mjs
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
import path from 'node:path';
|
|
25
25
|
import {
|
|
26
26
|
TODO_COORDINATION_MODES,
|
|
27
|
+
TODO_EVENT_KINDS,
|
|
27
28
|
TODO_LIMITS,
|
|
28
29
|
TODO_PLAN_SCOPED_EVENT_KINDS,
|
|
29
30
|
canonicalizeTodoArtifact,
|
|
@@ -62,6 +63,7 @@ import {
|
|
|
62
63
|
collectTodoStructureGitProvenance,
|
|
63
64
|
} from './todo-structure-git-adapter.mjs';
|
|
64
65
|
import { sha256Bytes, verifyLinearHashChain } from './hash-chain.mjs';
|
|
66
|
+
import packageJson from '../package.json' with { type: 'json' };
|
|
65
67
|
import { gitCatFileBatch, gitSync } from './git-process.mjs';
|
|
66
68
|
import { matchesTodoSourceLineDigest } from './todo-source-line-eol.mjs';
|
|
67
69
|
import {
|
|
@@ -111,17 +113,55 @@ function fail(code, reason, detail) {
|
|
|
111
113
|
throw new TodoStoreError(code, reason, reason, detail);
|
|
112
114
|
}
|
|
113
115
|
|
|
116
|
+
const upgradeAction = (what) => `${what} was written by a newer Lattice than ${packageJson.version}. The record is`
|
|
117
|
+
+ ` not corrupt: do not repair or delete it. Upgrade Lattice on this host to a version newer than`
|
|
118
|
+
+ ` ${packageJson.version}, then run the command again.`;
|
|
119
|
+
|
|
114
120
|
function rejectUnsupportedRevisionSchema(value, { family, supportedSchemas }) {
|
|
115
121
|
const schema = value?.schema;
|
|
116
122
|
if (typeof schema === 'string'
|
|
117
123
|
&& new RegExp(`^lattice\\.${family}\\.v[1-9]\\d*$`, 'u').test(schema)
|
|
118
124
|
&& !supportedSchemas.includes(schema)) {
|
|
119
125
|
fail('UNSUPPORTED_SCHEMA', 'unsupported_revision_schema', {
|
|
120
|
-
schema, supported_schemas: [...supportedSchemas],
|
|
126
|
+
schema, supported_schemas: [...supportedSchemas], next_action: upgradeAction(`Schema ${schema}`),
|
|
121
127
|
});
|
|
122
128
|
}
|
|
123
129
|
}
|
|
124
130
|
|
|
131
|
+
// Reader registration (newer-value-says-upgrade): the newest schema of each Store record family this
|
|
132
|
+
// reader knows. Bump it in the same diff that teaches the validator a new version.
|
|
133
|
+
export const NEWEST_KNOWN_TODO_SCHEMA = Object.freeze({ todo_event: 4, todo_plan: 8, todo_manifest: 2 });
|
|
134
|
+
const NEWER_SCHEMA_FAMILY = new Map([[validateTodoPlan, 'todo_plan'], [validateTodoManifest, 'todo_manifest']]);
|
|
135
|
+
const vocabularyWord = (value) => typeof value === 'string' && /^[a-z][a-z0-9_-]{0,63}$/u.test(value);
|
|
136
|
+
|
|
137
|
+
function newerSchema(value, family) {
|
|
138
|
+
const match = typeof value?.schema === 'string' ? value.schema.match(/^lattice\.([a-z_]+)\.v([1-9]\d{0,5})$/u) : null;
|
|
139
|
+
return match !== null && match[1] === family && Number(match[2]) > NEWEST_KNOWN_TODO_SCHEMA[family]
|
|
140
|
+
? { pointer: '/schema', value: value.schema } : null;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// An event this reader cannot validate is "newer", not corrupt, when it names a higher event schema, or
|
|
144
|
+
// when it is intact (its own digest matches: the bytes are what a writer wrote) and names an event kind
|
|
145
|
+
// or coordination mode this reader does not know. Everything else stays STORE_CORRUPT.
|
|
146
|
+
function newerEventValue(event) {
|
|
147
|
+
const schema = newerSchema(event, 'todo_event');
|
|
148
|
+
if (schema !== null) return schema;
|
|
149
|
+
let intact = false;
|
|
150
|
+
try { intact = isTodoDigest(event?.event_digest) && event.event_digest === todoSelfDigest(event, 'event_digest'); } catch { /* not intact */ }
|
|
151
|
+
if (!intact) return null;
|
|
152
|
+
if (vocabularyWord(event.kind) && !TODO_EVENT_KINDS.includes(event.kind)) return { pointer: '/kind', value: event.kind };
|
|
153
|
+
const mode = event.kind === 'coordination_mode' ? event.payload?.mode : undefined;
|
|
154
|
+
return vocabularyWord(mode) && !TODO_COORDINATION_MODES.includes(mode) ? { pointer: '/payload/mode', value: mode } : null;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function failNewer({ pointer, value }, ref) {
|
|
158
|
+
fail('UNSUPPORTED_SCHEMA', 'newer_lattice_value', {
|
|
159
|
+
...(ref === null ? {} : { ref }), pointer, value, reader_version: packageJson.version,
|
|
160
|
+
required_version: `>${packageJson.version}`,
|
|
161
|
+
next_action: upgradeAction(`The value '${value}' at ${pointer}${ref === null ? '' : ` in ${ref}`}`),
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
125
165
|
function requireWriter(writer, caller) {
|
|
126
166
|
if (!exactRecord(writer, ['schema', 'caller']) || writer.schema !== 'lattice.todo_store_writer.v1'
|
|
127
167
|
|| writer.caller !== caller) throw new TypeError(`writer capability for ${caller} required`);
|
|
@@ -169,7 +209,11 @@ function parseCanonicalJsonLine(bytes, { code, reason, maxBytes, validate, ref =
|
|
|
169
209
|
let expected;
|
|
170
210
|
try { expected = `${canonicalizeTodoArtifact(value)}\n`; } catch { fail(code, reason, detail); }
|
|
171
211
|
if (text !== expected) fail(code, 'non_canonical_or_duplicate_key', detail);
|
|
172
|
-
if (!validate(value))
|
|
212
|
+
if (!validate(value)) {
|
|
213
|
+
const newer = NEWER_SCHEMA_FAMILY.has(validate) ? newerSchema(value, NEWER_SCHEMA_FAMILY.get(validate)) : null;
|
|
214
|
+
if (newer !== null) failNewer(newer, ref);
|
|
215
|
+
fail(code, 'schema_invalid', detail);
|
|
216
|
+
}
|
|
173
217
|
return value;
|
|
174
218
|
}
|
|
175
219
|
|
|
@@ -208,7 +252,11 @@ function parseJournalSegment(bytes, ref = null) {
|
|
|
208
252
|
let canonical;
|
|
209
253
|
try { canonical = canonicalizeTodoArtifact(event); } catch { fail('STORE_CORRUPT', 'journal_schema_invalid'); }
|
|
210
254
|
if (line !== canonical) fail('STORE_CORRUPT', 'journal_non_canonical_or_duplicate_key');
|
|
211
|
-
if (!validateTodoEvent(event))
|
|
255
|
+
if (!validateTodoEvent(event)) {
|
|
256
|
+
const newer = newerEventValue(event);
|
|
257
|
+
if (newer !== null) failNewer(newer, ref);
|
|
258
|
+
fail('STORE_CORRUPT', 'journal_schema_invalid');
|
|
259
|
+
}
|
|
212
260
|
return event;
|
|
213
261
|
});
|
|
214
262
|
}
|