@quolu/lattice 0.85.1 → 0.85.3
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.mjs +1 -1
- package/docs/schemas/lattice.plan_create_input.v4.schema.json +1 -1
- package/docs/schemas/lattice.plan_create_input.v5.schema.json +1 -1
- package/docs/schemas/lattice.plan_revise_input.v1.schema.json +1 -1
- package/docs/schemas/lattice.plan_scope_review.v1.schema.json +3 -3
- package/docs/schemas/lattice.todo_witness_draft.v2.schema.json +86 -0
- package/docs/schemas/lattice.todo_witness_set.v5.schema.json +400 -0
- package/package.json +3 -1
- package/src/cli-help.mjs +24 -15
- package/src/cli-refusal-guidance.mjs +48 -4
- package/src/hooks-cli.mjs +4 -1
- package/src/plan-backchain.mjs +48 -8
- package/src/plan-revise.mjs +43 -3
- package/src/plan-scope-review.mjs +40 -14
- package/src/project-cli.mjs +98 -8
- package/src/runtime-cli.mjs +4 -1
- package/src/seat-identity.mjs +10 -2
- package/src/sensor-cli.mjs +8 -2
- package/src/sensor-diff.mjs +8 -0
- package/src/setup-cli.mjs +3 -1
- package/src/todo-cli.mjs +225 -78
- package/src/todo-independence-guidance.mjs +3 -2
- package/src/todo-readiness.mjs +13 -3
- package/src/todo-store.mjs +6 -0
- package/src/witness-scaffold.mjs +58 -21
package/src/witness-scaffold.mjs
CHANGED
|
@@ -51,28 +51,65 @@ function reject(reasons) {
|
|
|
51
51
|
return { witnessSet: null, queries: [], reasons: sortedUnique(reasons) };
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (
|
|
54
|
+
const DRAFT_TOP_LEVEL_KEYS = Object.freeze(['schema', 'project_id', 'plan_key', 'capacity', 'tasks']);
|
|
55
|
+
const plainObject = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
56
|
+
const refList = (value) => value === undefined || (Array.isArray(value) && value.every(isTodoRef));
|
|
57
|
+
|
|
58
|
+
/** 1 taskの下書きの最初の違反(相対path)、無ければnull。validateWitnessDraftと同じ規則。 */
|
|
59
|
+
function explainDraftTask(task, schema) {
|
|
60
|
+
if (!plainObject(task)) return { reason: 'not_an_object', path: '' };
|
|
61
|
+
if (draftOwnEntries(task, schema) === null) return { reason: 'invalid_owns', path: '/owns' };
|
|
62
|
+
for (const key of ['reads', 'writes']) {
|
|
63
|
+
if (!refList(task[key])) return { reason: 'invalid_repo_relative_paths', path: `/${key}` };
|
|
64
|
+
}
|
|
65
|
+
if (task.unknowns !== undefined && !(Array.isArray(task.unknowns) && task.unknowns.every((entry) => plainObject(entry)
|
|
66
|
+
&& isTodoIdentifier(entry.kind) && typeof entry.ref === 'string' && entry.ref.length > 0))) {
|
|
67
|
+
return { reason: 'invalid_unknowns', path: '/unknowns' };
|
|
68
|
+
}
|
|
69
|
+
if (task.concern_anchors !== undefined && !(Array.isArray(task.concern_anchors)
|
|
70
|
+
&& task.concern_anchors.every((anchor) => plainObject(anchor) && isTodoRef(anchor.within)
|
|
71
|
+
&& Array.isArray(anchor.symbols) && anchor.symbols.length > 0 && anchor.symbols.every(isTodoIdentifier)))) {
|
|
72
|
+
return { reason: 'invalid_concern_anchors', path: '/concern_anchors' };
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 下書きの形。AIが書く欄だけを持ち、観測で埋まる欄は持たない。
|
|
79
|
+
* a32: 拒否は最初に落ちた欄(JSON pointer)と理由、topの欠けたkeyを名指す。
|
|
80
|
+
*/
|
|
81
|
+
export function explainWitnessDraft(value) {
|
|
82
|
+
const reject = (reason, at, extra = {}) => ({ valid: false, reason, path: at, ...extra });
|
|
83
|
+
if (!plainObject(value)) return reject('not_an_object', '/');
|
|
84
|
+
const missing = DRAFT_TOP_LEVEL_KEYS.filter((key) => !Object.hasOwn(value, key));
|
|
85
|
+
if (missing.length > 0) return reject('missing_top_level_keys', '/', { missing_keys: missing });
|
|
86
|
+
if (!DRAFT_SCHEMAS.includes(value.schema)) return reject('schema_mismatch', '/schema', { expected: DRAFT_SCHEMAS });
|
|
87
|
+
if (!isTodoIdentifier(value.project_id)) return reject('invalid_identifier', '/project_id');
|
|
88
|
+
if (!isTodoIdentifier(value.plan_key)) return reject('invalid_identifier', '/plan_key');
|
|
89
|
+
if (!plainObject(value.capacity) || !Number.isSafeInteger(value.capacity.executors) || value.capacity.executors < 1) {
|
|
90
|
+
return reject('invalid_capacity', '/capacity/executors');
|
|
91
|
+
}
|
|
92
|
+
if (!plainObject(value.tasks)) return reject('not_an_object', '/tasks');
|
|
62
93
|
const entries = Object.entries(value.tasks);
|
|
63
|
-
if (entries.length === 0) return
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
94
|
+
if (entries.length === 0) return reject('empty_tasks', '/tasks');
|
|
95
|
+
for (const [taskId, task] of entries) {
|
|
96
|
+
if (!isTodoIdentifier(taskId)) return reject('invalid_identifier', `/tasks/${taskId}`);
|
|
97
|
+
const failure = explainDraftTask(task, value.schema);
|
|
98
|
+
if (failure !== null) return reject(failure.reason, `/tasks/${taskId}${failure.path}`);
|
|
99
|
+
}
|
|
100
|
+
return { valid: true };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function validateWitnessDraft(value) {
|
|
104
|
+
return explainWitnessDraft(value).valid;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** a32: the starting draft for a plan: every task still to do, with nothing declared yet. */
|
|
108
|
+
export function witnessDraftTemplate({ projectId, planKey, taskIds }) {
|
|
109
|
+
return {
|
|
110
|
+
schema: WITNESS_DRAFT_SCHEMA_V2, project_id: projectId, plan_key: planKey, capacity: { executors: 1 },
|
|
111
|
+
tasks: Object.fromEntries([...taskIds].sort(compareText).map((taskId) => [taskId, { owns: [], reads: [], writes: [] }])),
|
|
112
|
+
};
|
|
76
113
|
}
|
|
77
114
|
|
|
78
115
|
function queryIdFor(index) {
|