@aperant/framework 0.19.0 → 0.20.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/CHANGELOG.md +109 -0
- package/agents/apt-executor.md +6 -0
- package/agents/apt-planner.md +3 -2
- package/bin/features-reconcile-check.mjs +77 -0
- package/dist/cli/artifacts/self-stage.d.mts.map +1 -1
- package/dist/cli/artifacts/self-stage.mjs +2 -1
- package/dist/cli/artifacts/self-stage.mjs.map +1 -1
- package/dist/cli/cli-wrappers/features-reconcile.d.mts +2 -0
- package/dist/cli/cli-wrappers/features-reconcile.d.mts.map +1 -0
- package/dist/cli/cli-wrappers/features-reconcile.mjs +9 -0
- package/dist/cli/cli-wrappers/features-reconcile.mjs.map +1 -0
- package/dist/cli/commands/features-reconcile.d.mts +2 -0
- package/dist/cli/commands/features-reconcile.d.mts.map +1 -0
- package/dist/cli/commands/features-reconcile.mjs +143 -0
- package/dist/cli/commands/features-reconcile.mjs.map +1 -0
- package/dist/cli/commands/health-check.d.mts +2 -2
- package/dist/cli/commands/health-check.mjs +2 -2
- package/dist/cli/dispatch.mjs +2 -2
- package/dist/cli/dispatch.mjs.map +1 -1
- package/dist/cli/features/area-shape.d.mts +11 -0
- package/dist/cli/features/area-shape.d.mts.map +1 -0
- package/dist/cli/features/area-shape.mjs +141 -0
- package/dist/cli/features/area-shape.mjs.map +1 -0
- package/dist/cli/features/delta.d.mts +78 -0
- package/dist/cli/features/delta.d.mts.map +1 -0
- package/dist/cli/features/delta.mjs +591 -0
- package/dist/cli/features/delta.mjs.map +1 -0
- package/dist/cli/features/reconcile.d.mts +236 -0
- package/dist/cli/features/reconcile.d.mts.map +1 -0
- package/dist/cli/features/reconcile.mjs +1126 -0
- package/dist/cli/features/reconcile.mjs.map +1 -0
- package/dist/cli/features/surface-map.d.mts +63 -0
- package/dist/cli/features/surface-map.d.mts.map +1 -0
- package/dist/cli/features/surface-map.mjs +191 -0
- package/dist/cli/features/surface-map.mjs.map +1 -0
- package/dist/cli/{commands/features-audit.d.mts → features/write-root.d.mts} +4 -3
- package/dist/cli/features/write-root.d.mts.map +1 -0
- package/dist/cli/features/write-root.mjs +137 -0
- package/dist/cli/features/write-root.mjs.map +1 -0
- package/dist/cli/gate/gates/features-reconciled.d.mts +36 -0
- package/dist/cli/gate/gates/features-reconciled.d.mts.map +1 -0
- package/dist/cli/gate/gates/features-reconciled.mjs +67 -0
- package/dist/cli/gate/gates/features-reconciled.mjs.map +1 -0
- package/dist/cli/gate/gates/index.mjs +1 -0
- package/dist/cli/gate/gates/index.mjs.map +1 -1
- package/dist/cli/help.mjs +1 -1
- package/dist/cli/release-notes/ship-autodraft.mjs +2 -2
- package/dist/cli/variant/gallery.d.mts.map +1 -1
- package/dist/cli/variant/gallery.mjs +7 -3
- package/dist/cli/variant/gallery.mjs.map +1 -1
- package/dist/plugin/.claude-plugin/plugin.json +1 -1
- package/dist/plugin/agents/apt-executor.md +6 -0
- package/dist/plugin/agents/apt-planner.md +3 -2
- package/dist/plugin/skills/apt-close-task/SKILL.md +2 -2
- package/dist/plugin/skills/apt-debug/SKILL.md +8 -0
- package/dist/plugin/skills/apt-execute/SKILL.md +35 -26
- package/dist/plugin/skills/apt-mockup/SKILL.md +1 -1
- package/dist/plugin/skills/apt-quick/SKILL.md +13 -11
- package/dist/plugin/skills/apt-review/SKILL.md +14 -11
- package/dist/plugin/skills/apt-run/SKILL.md +9 -3
- package/dist/plugin/skills/apt-ship/SKILL.md +27 -5
- package/dist/plugin/skills/apt-watch-ci/SKILL.md +2 -0
- package/dist/schemas/feature-registry.d.ts.map +1 -1
- package/dist/schemas/feature-registry.js +34 -3
- package/dist/schemas/feature-registry.js.map +1 -1
- package/dist/types/config.d.ts +8 -5
- package/dist/types/config.d.ts.map +1 -1
- package/package.json +1 -1
- package/skills/apt-close-task/SKILL.md +2 -2
- package/skills/apt-debug/SKILL.md +8 -0
- package/skills/apt-execute/SKILL.md +35 -26
- package/skills/apt-mockup/SKILL.md +1 -1
- package/skills/apt-quick/SKILL.md +13 -11
- package/skills/apt-review/SKILL.md +14 -11
- package/skills/apt-run/SKILL.md +9 -3
- package/skills/apt-ship/SKILL.md +27 -5
- package/skills/apt-watch-ci/SKILL.md +2 -0
- package/src/cli/artifacts/self-stage.mjs +2 -1
- package/src/cli/cli-wrappers/features-reconcile.mjs +9 -0
- package/src/cli/commands/features-reconcile.mjs +157 -0
- package/src/cli/commands/health-check.mjs +2 -2
- package/src/cli/dispatch.mjs +2 -2
- package/src/cli/features/area-shape.mjs +140 -0
- package/src/cli/features/delta.mjs +625 -0
- package/src/cli/features/reconcile.mjs +1169 -0
- package/src/cli/features/surface-map.mjs +192 -0
- package/src/cli/features/write-root.mjs +140 -0
- package/src/cli/gate/gates/features-reconciled.mjs +70 -0
- package/src/cli/gate/gates/index.mjs +1 -0
- package/src/cli/help.mjs +1 -1
- package/src/cli/release-notes/ship-autodraft.mjs +2 -2
- package/src/cli/variant/gallery.mjs +7 -3
- package/templates/aperant-claude-md-appendix.md +2 -2
- package/workflows/scan-features.md +17 -11
- package/dist/cli/cli-wrappers/features-audit.d.mts +0 -2
- package/dist/cli/cli-wrappers/features-audit.d.mts.map +0 -1
- package/dist/cli/cli-wrappers/features-audit.mjs +0 -8
- package/dist/cli/cli-wrappers/features-audit.mjs.map +0 -1
- package/dist/cli/commands/features-audit.d.mts.map +0 -1
- package/dist/cli/commands/features-audit.mjs +0 -293
- package/dist/cli/commands/features-audit.mjs.map +0 -1
- package/dist/cli/features/registry-audit.d.mts +0 -56
- package/dist/cli/features/registry-audit.d.mts.map +0 -1
- package/dist/cli/features/registry-audit.mjs +0 -264
- package/dist/cli/features/registry-audit.mjs.map +0 -1
- package/src/cli/cli-wrappers/features-audit.mjs +0 -8
- package/src/cli/commands/features-audit.mjs +0 -302
- package/src/cli/features/registry-audit.mjs +0 -254
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* delta.mjs — the features-reconcile delta-ledger contract: file shape,
|
|
3
|
+
* fail-closed validation, the ID-17 canonicalization/hashing seam, and the
|
|
4
|
+
* ID-02 conflict-matrix merge.
|
|
5
|
+
*
|
|
6
|
+
* Dependency-free: node:-builtins only — this module sits inside the
|
|
7
|
+
* bare-node CI entry's import closure (ID-08).
|
|
8
|
+
*
|
|
9
|
+
* DELTA FILE SHAPE (`.aperant/features/deltas/<task-id>[-<subtask-id>].json`):
|
|
10
|
+
*
|
|
11
|
+
* {
|
|
12
|
+
* task_id: string, // writer identity (rides into the receipt)
|
|
13
|
+
* subtask_id?: string,
|
|
14
|
+
* base?: string, // diff base ref used at draft time
|
|
15
|
+
* created_at?: string,
|
|
16
|
+
* files: [{
|
|
17
|
+
* path, change: added|modified|deleted|renamed,
|
|
18
|
+
* previous_path?, previous_blob_sha?, // renamed only (required there)
|
|
19
|
+
* blob_sha, // REQUIRED (ID-01): added|modified|renamed →
|
|
20
|
+
* // HEAD blob of path at emit; deleted → BASE blob
|
|
21
|
+
* area, // null in a draft = writer must assign;
|
|
22
|
+
* // strict (write/check) fails closed on null
|
|
23
|
+
* disposition: upsert|remove|wiring-transition|no-semantic-change
|
|
24
|
+
* | needs-disposition (DRAFT-ONLY sentinel),
|
|
25
|
+
* reason?
|
|
26
|
+
* }],
|
|
27
|
+
* operations: [{
|
|
28
|
+
* op: upsert|patch-sub-feature|remove|add-group,
|
|
29
|
+
* area, feature_id, sub_feature_id?,
|
|
30
|
+
* expected_hash?, // sha256 over canonical JSON of the TARGETED
|
|
31
|
+
* // entity (sub_feature for patch-sub-feature,
|
|
32
|
+
* // feature group for add-group collisions)
|
|
33
|
+
* expected_from?, // wiring-transition: prior `wired` value
|
|
34
|
+
* value? | patch?
|
|
35
|
+
* }]
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* ID-17 CANONICALIZATION (the single hashing seam — AC21):
|
|
39
|
+
* canonical JSON = UTF-8, LF, recursively sorted object keys, arrays
|
|
40
|
+
* order-preserving, `undefined` values OMITTED (never serialized as null),
|
|
41
|
+
* NO default-filling before hashing (hash what the author wrote).
|
|
42
|
+
* `expected_hash` / entity hashes = sha256 over canonical JSON of the
|
|
43
|
+
* targeted entity. Delta content hashes + receipt area_hashes hash on-disk
|
|
44
|
+
* BYTES (`sha256Bytes`). Git blob fingerprints (`blob_sha`) are git's own
|
|
45
|
+
* hashes — the two hash families NEVER mix.
|
|
46
|
+
*
|
|
47
|
+
* ID-02 CONFLICT MATRIX (mergeDeltas — fail-closed, never last-writer-wins):
|
|
48
|
+
* (a) same ID + byte-equal normalized value → dedupe
|
|
49
|
+
* (b) disjoint field patches on the same expected base → merge
|
|
50
|
+
* (c) same-field-different-value → hard conflict
|
|
51
|
+
* (d) remove-vs-upsert on the same ID → hard conflict
|
|
52
|
+
* (e) wiring-transition requires expected_from; fails when the current
|
|
53
|
+
* registry value differs → hard conflict
|
|
54
|
+
* (f) expected_hash addressing a MISSING entity → hard conflict
|
|
55
|
+
* (a stale expected_hash — entity exists but hash differs — is the
|
|
56
|
+
* same fail-closed class)
|
|
57
|
+
* (g) explicit feature_id/sub_feature_id required — the materializer NEVER
|
|
58
|
+
* auto-generates ids; duplicate-id collisions across deltas resolve per
|
|
59
|
+
* this same table (byte-equal dedupe, else hard conflict)
|
|
60
|
+
*/
|
|
61
|
+
import { createHash } from 'node:crypto';
|
|
62
|
+
import { readFileSync } from 'node:fs';
|
|
63
|
+
// ---------------------------------------------------------------------------
|
|
64
|
+
// ID-17 canonicalization + hashing
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
function sortValue(v) {
|
|
67
|
+
if (Array.isArray(v)) {
|
|
68
|
+
// Order-preserving; undefined entries omitted (never serialized as null).
|
|
69
|
+
return v.filter((item) => item !== undefined).map(sortValue);
|
|
70
|
+
}
|
|
71
|
+
if (v && typeof v === 'object') {
|
|
72
|
+
const out = {};
|
|
73
|
+
for (const k of Object.keys(v).sort()) {
|
|
74
|
+
if (v[k] === undefined)
|
|
75
|
+
continue;
|
|
76
|
+
out[k] = sortValue(v[k]);
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
return v;
|
|
81
|
+
}
|
|
82
|
+
/** Canonical JSON string per ID-17. No default-filling — hash what was written. */
|
|
83
|
+
export function canonicalJson(value) {
|
|
84
|
+
return JSON.stringify(sortValue(value));
|
|
85
|
+
}
|
|
86
|
+
/** sha256 hex over the canonical JSON of a value (entity hashing). */
|
|
87
|
+
export function sha256Canonical(value) {
|
|
88
|
+
return createHash('sha256').update(canonicalJson(value), 'utf-8').digest('hex');
|
|
89
|
+
}
|
|
90
|
+
/** sha256 hex over raw bytes (delta file content, area file bytes). */
|
|
91
|
+
export function sha256Bytes(data) {
|
|
92
|
+
return createHash('sha256').update(data).digest('hex');
|
|
93
|
+
}
|
|
94
|
+
/** expected_hash for a targeted entity — alias making the call sites read clearly. */
|
|
95
|
+
export function hashEntity(entity) {
|
|
96
|
+
return sha256Canonical(entity);
|
|
97
|
+
}
|
|
98
|
+
// ---------------------------------------------------------------------------
|
|
99
|
+
// Closed value sets
|
|
100
|
+
// ---------------------------------------------------------------------------
|
|
101
|
+
const ISO_DATETIME_RE = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(Z|[+-]\d{2}:\d{2})$/;
|
|
102
|
+
/**
|
|
103
|
+
* Shape + SEMANTIC ISO 8601 datetime validation (ST11). The regex alone
|
|
104
|
+
* accepted '2026-99-99T99:99:99Z' and '2026-02-30T12:00:00Z' — both could
|
|
105
|
+
* max-sort above real dates and stamp an invalid last_scanned. After the
|
|
106
|
+
* shape passes, the components are verified deterministically: month 1-12,
|
|
107
|
+
* a REAL calendar day via UTC round-trip (leap years included), hours<24,
|
|
108
|
+
* minutes<60, seconds<60 (offsets too).
|
|
109
|
+
*/
|
|
110
|
+
export function isValidIsoDatetime(value) {
|
|
111
|
+
if (typeof value !== 'string')
|
|
112
|
+
return false;
|
|
113
|
+
const m = ISO_DATETIME_RE.exec(value);
|
|
114
|
+
if (!m)
|
|
115
|
+
return false;
|
|
116
|
+
const y = Number(m[1]);
|
|
117
|
+
const mo = Number(m[2]);
|
|
118
|
+
const d = Number(m[3]);
|
|
119
|
+
if (mo < 1 || mo > 12)
|
|
120
|
+
return false;
|
|
121
|
+
const dt = new Date(Date.UTC(y, mo - 1, d));
|
|
122
|
+
if (dt.getUTCFullYear() !== y || dt.getUTCMonth() + 1 !== mo || dt.getUTCDate() !== d) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
if (Number(m[4]) > 23 || Number(m[5]) > 59 || Number(m[6]) > 59)
|
|
126
|
+
return false;
|
|
127
|
+
if (m[7] !== 'Z') {
|
|
128
|
+
if (Number(m[7].slice(1, 3)) > 23 || Number(m[7].slice(4, 6)) > 59)
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
export const CHANGE_KINDS = Object.freeze(['added', 'modified', 'deleted', 'renamed']);
|
|
134
|
+
export const DISPOSITIONS = Object.freeze([
|
|
135
|
+
'upsert',
|
|
136
|
+
'remove',
|
|
137
|
+
'wiring-transition',
|
|
138
|
+
'no-semantic-change',
|
|
139
|
+
]);
|
|
140
|
+
/** Draft-only sentinel — NEVER valid at --write/--check time. */
|
|
141
|
+
export const DRAFT_ONLY_DISPOSITION = 'needs-disposition';
|
|
142
|
+
export const OP_KINDS = Object.freeze(['upsert', 'patch-sub-feature', 'remove', 'add-group']);
|
|
143
|
+
const WIRED_VALUES = new Set([true, false, 'stubbed', 'partial']);
|
|
144
|
+
const ID_RE = /^[a-z0-9-]+$/;
|
|
145
|
+
// ---------------------------------------------------------------------------
|
|
146
|
+
// Fail-closed delta validation
|
|
147
|
+
// ---------------------------------------------------------------------------
|
|
148
|
+
function isNonEmptyString(v) {
|
|
149
|
+
return typeof v === 'string' && v.trim().length > 0;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Validate a parsed delta object. `mode: 'draft'` relaxes exactly two rules:
|
|
153
|
+
* the `needs-disposition` sentinel is allowed, and `area: null` is allowed
|
|
154
|
+
* (writer-must-assign). Everything else is identical.
|
|
155
|
+
*
|
|
156
|
+
* @returns {{ ok: boolean, errors: string[] }}
|
|
157
|
+
*/
|
|
158
|
+
export function validateDelta(delta, { mode = 'strict' } = {}) {
|
|
159
|
+
const errors = [];
|
|
160
|
+
const draft = mode === 'draft';
|
|
161
|
+
if (!delta || typeof delta !== 'object' || Array.isArray(delta)) {
|
|
162
|
+
return { ok: false, errors: ['delta must be a JSON object'] };
|
|
163
|
+
}
|
|
164
|
+
const files = delta.files;
|
|
165
|
+
if (!Array.isArray(files)) {
|
|
166
|
+
errors.push('files must be an array');
|
|
167
|
+
}
|
|
168
|
+
const operations = delta.operations ?? [];
|
|
169
|
+
if (!Array.isArray(operations)) {
|
|
170
|
+
errors.push('operations must be an array');
|
|
171
|
+
}
|
|
172
|
+
// created_at is optional, but when present it must be a REAL ISO 8601
|
|
173
|
+
// datetime (shape + calendar semantics — isValidIsoDatetime) because the
|
|
174
|
+
// materializer's deterministic last_scanned stamp max-sorts these strings.
|
|
175
|
+
if (delta.created_at !== undefined && !isValidIsoDatetime(delta.created_at)) {
|
|
176
|
+
errors.push('created_at: must be a real ISO 8601 datetime when present (shape + calendar semantics)');
|
|
177
|
+
}
|
|
178
|
+
// Areas whose files[] declare a wiring-transition — every wired-touching
|
|
179
|
+
// operation in those areas must be individually guarded (ID-02 e, PER-OP).
|
|
180
|
+
const wiringAreas = new Set();
|
|
181
|
+
for (const [i, f] of (Array.isArray(files) ? files : []).entries()) {
|
|
182
|
+
const at = `files[${i}]`;
|
|
183
|
+
if (!f || typeof f !== 'object') {
|
|
184
|
+
errors.push(`${at}: must be an object`);
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
if (!isNonEmptyString(f.path))
|
|
188
|
+
errors.push(`${at}.path: required non-empty string`);
|
|
189
|
+
if (!CHANGE_KINDS.includes(f.change)) {
|
|
190
|
+
errors.push(`${at}.change: must be one of ${CHANGE_KINDS.join('|')} (got ${JSON.stringify(f.change)})`);
|
|
191
|
+
}
|
|
192
|
+
// ID-01 blob fingerprints — missing/blank blob_sha rejects the delta.
|
|
193
|
+
if (!isNonEmptyString(f.blob_sha)) {
|
|
194
|
+
errors.push(`${at}.blob_sha: required non-empty blob fingerprint (ID-01)`);
|
|
195
|
+
}
|
|
196
|
+
if (f.change === 'renamed') {
|
|
197
|
+
if (!isNonEmptyString(f.previous_path)) {
|
|
198
|
+
errors.push(`${at}.previous_path: required for change "renamed"`);
|
|
199
|
+
}
|
|
200
|
+
if (!isNonEmptyString(f.previous_blob_sha)) {
|
|
201
|
+
errors.push(`${at}.previous_blob_sha: required for change "renamed"`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
// Area: null means writer-must-assign — draft-only.
|
|
205
|
+
if (!isNonEmptyString(f.area)) {
|
|
206
|
+
if (!draft) {
|
|
207
|
+
errors.push(`${at}.area: null/missing area — the writer must assign it (fail-closed)`);
|
|
208
|
+
}
|
|
209
|
+
else if (f.area !== null && f.area !== undefined && !isNonEmptyString(f.area)) {
|
|
210
|
+
errors.push(`${at}.area: must be a non-empty string or null`);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
// Disposition: closed set; sentinel is draft-only.
|
|
214
|
+
const d = f.disposition;
|
|
215
|
+
if (d === DRAFT_ONLY_DISPOSITION) {
|
|
216
|
+
if (!draft) {
|
|
217
|
+
errors.push(`${at}.disposition: "${DRAFT_ONLY_DISPOSITION}" is a draft-only sentinel — fill a real disposition before write/check`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
else if (!DISPOSITIONS.includes(d)) {
|
|
221
|
+
errors.push(`${at}.disposition: must be one of ${DISPOSITIONS.join('|')} (got ${JSON.stringify(d)})`);
|
|
222
|
+
}
|
|
223
|
+
// ADDED qualifying files MUST register (the benchmark.json failure mode).
|
|
224
|
+
if (f.change === 'added' && d === 'no-semantic-change') {
|
|
225
|
+
errors.push(`${at}: change "added" cannot carry disposition "no-semantic-change" — added files MUST register`);
|
|
226
|
+
}
|
|
227
|
+
if (!draft && d === 'no-semantic-change' && !isNonEmptyString(f.reason)) {
|
|
228
|
+
errors.push(`${at}.reason: required for disposition "no-semantic-change"`);
|
|
229
|
+
}
|
|
230
|
+
if (d === 'wiring-transition' && isNonEmptyString(f.area))
|
|
231
|
+
wiringAreas.add(f.area);
|
|
232
|
+
}
|
|
233
|
+
// Per-area tally: a wiring-transition area needs ≥1 wired-changing op (ID-02 e).
|
|
234
|
+
const wiredChangingAreas = new Set();
|
|
235
|
+
for (const [i, op] of (Array.isArray(operations) ? operations : []).entries()) {
|
|
236
|
+
const at = `operations[${i}]`;
|
|
237
|
+
if (!op || typeof op !== 'object') {
|
|
238
|
+
errors.push(`${at}: must be an object`);
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
if (!OP_KINDS.includes(op.op)) {
|
|
242
|
+
errors.push(`${at}.op: must be one of ${OP_KINDS.join('|')} (got ${JSON.stringify(op.op)})`);
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
if (!isNonEmptyString(op.area)) {
|
|
246
|
+
if (!draft || (op.area !== null && op.area !== undefined)) {
|
|
247
|
+
errors.push(`${at}.area: required non-empty string${draft ? ' or null (draft)' : ''}`);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
// (g) explicit ids — the materializer never auto-generates ids.
|
|
251
|
+
if (!isNonEmptyString(op.feature_id) || !ID_RE.test(op.feature_id)) {
|
|
252
|
+
errors.push(`${at}.feature_id: required id matching ${ID_RE} — ids are always explicit (ID-02 g)`);
|
|
253
|
+
}
|
|
254
|
+
if (op.sub_feature_id !== undefined &&
|
|
255
|
+
(!isNonEmptyString(op.sub_feature_id) || !ID_RE.test(op.sub_feature_id))) {
|
|
256
|
+
errors.push(`${at}.sub_feature_id: must match ${ID_RE} when present`);
|
|
257
|
+
}
|
|
258
|
+
if (op.op === 'patch-sub-feature') {
|
|
259
|
+
if (!isNonEmptyString(op.sub_feature_id)) {
|
|
260
|
+
errors.push(`${at}.sub_feature_id: required for op "patch-sub-feature" (ID-02 g)`);
|
|
261
|
+
}
|
|
262
|
+
if (!op.patch ||
|
|
263
|
+
typeof op.patch !== 'object' ||
|
|
264
|
+
Array.isArray(op.patch) ||
|
|
265
|
+
Object.keys(op.patch).length === 0) {
|
|
266
|
+
errors.push(`${at}.patch: required non-empty object for op "patch-sub-feature"`);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
if (op.op === 'upsert' || op.op === 'add-group') {
|
|
270
|
+
if (!op.value || typeof op.value !== 'object' || Array.isArray(op.value)) {
|
|
271
|
+
errors.push(`${at}.value: required object for op "${op.op}"`);
|
|
272
|
+
}
|
|
273
|
+
else if (op.value.id !== op.feature_id) {
|
|
274
|
+
errors.push(`${at}.value.id: must equal feature_id "${op.feature_id}" (got ${JSON.stringify(op.value.id)})`);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
if (op.expected_hash !== undefined && !isNonEmptyString(op.expected_hash)) {
|
|
278
|
+
errors.push(`${at}.expected_hash: must be a non-empty string when present`);
|
|
279
|
+
}
|
|
280
|
+
if (op.expected_from !== undefined) {
|
|
281
|
+
if (!WIRED_VALUES.has(op.expected_from)) {
|
|
282
|
+
errors.push(`${at}.expected_from: must be a wired value (true|false|"stubbed"|"partial")`);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
// (e) PER-OPERATION guard — never delta-global. A patch that changes
|
|
286
|
+
// `wired` must ITSELF carry expected_from; one guarded op cannot vouch
|
|
287
|
+
// for another op's wired change. Upserts/add-groups carry NO blanket
|
|
288
|
+
// validation requirement — validation is registry-state-independent;
|
|
289
|
+
// the merge verifies a REPLACE that flips an existing wired value
|
|
290
|
+
// per-op against the current registry (creation needs no guard because
|
|
291
|
+
// there is no existing value to flip — ST10 corrected contract).
|
|
292
|
+
const changesWired = op.patch && typeof op.patch === 'object' && 'wired' in op.patch;
|
|
293
|
+
if (op.op === 'patch-sub-feature' && changesWired && op.expected_from === undefined) {
|
|
294
|
+
errors.push(`${at}.expected_from: required — the patch changes "wired" and every wiring-transition op is individually guarded (ID-02 e)`);
|
|
295
|
+
}
|
|
296
|
+
if (isNonEmptyString(op.area) && (changesWired || op.expected_from !== undefined)) {
|
|
297
|
+
wiredChangingAreas.add(op.area);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
// (e) per-area completeness: a wiring-transition FILE entry requires ≥1
|
|
301
|
+
// wired-changing op in that area (a guarded patch-sub-feature, or an
|
|
302
|
+
// expected_from-carrying upsert) — NOT that every op in the area is guarded.
|
|
303
|
+
for (const area of wiringAreas) {
|
|
304
|
+
if (!wiredChangingAreas.has(area)) {
|
|
305
|
+
errors.push(`files declare a "wiring-transition" in area "${area}" but no operation in that area changes "wired" (add a guarded patch-sub-feature or an expected_from-carrying upsert) (ID-02 e)`);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return { ok: errors.length === 0, errors };
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Read + parse + validate a delta file. Never throws.
|
|
312
|
+
*
|
|
313
|
+
* @returns {{ ok: boolean, delta?: Record<string, any>, errors: string[], path: string }}
|
|
314
|
+
*/
|
|
315
|
+
export function parseDeltaFile(path, { mode = 'strict' } = {}) {
|
|
316
|
+
let raw;
|
|
317
|
+
try {
|
|
318
|
+
raw = readFileSync(path, 'utf-8');
|
|
319
|
+
}
|
|
320
|
+
catch (e) {
|
|
321
|
+
return { ok: false, errors: [`cannot read delta file: ${e.message}`], path };
|
|
322
|
+
}
|
|
323
|
+
let delta;
|
|
324
|
+
try {
|
|
325
|
+
delta = JSON.parse(raw);
|
|
326
|
+
}
|
|
327
|
+
catch (e) {
|
|
328
|
+
return { ok: false, errors: [`invalid JSON: ${e.message}`], path };
|
|
329
|
+
}
|
|
330
|
+
const { ok, errors } = validateDelta(delta, { mode });
|
|
331
|
+
return ok ? { ok, delta, errors: [], path } : { ok, errors, path };
|
|
332
|
+
}
|
|
333
|
+
// ---------------------------------------------------------------------------
|
|
334
|
+
// ID-02 conflict-matrix merge
|
|
335
|
+
// ---------------------------------------------------------------------------
|
|
336
|
+
function entityKey(op) {
|
|
337
|
+
return `${op.area} ${op.feature_id} ${op.sub_feature_id ?? ''}`;
|
|
338
|
+
}
|
|
339
|
+
/** Canonical form of an op for byte-equality (drops source annotation). */
|
|
340
|
+
function opCanonical(op) {
|
|
341
|
+
const { op: kind, area, feature_id, sub_feature_id, expected_hash, expected_from, value, patch, } = op;
|
|
342
|
+
return canonicalJson({
|
|
343
|
+
op: kind,
|
|
344
|
+
area,
|
|
345
|
+
feature_id,
|
|
346
|
+
sub_feature_id,
|
|
347
|
+
expected_hash,
|
|
348
|
+
expected_from,
|
|
349
|
+
value,
|
|
350
|
+
patch,
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* ID-03 replay carve-out: an op whose effect is ALREADY fully present in the
|
|
355
|
+
* registry (a crash-before-receipt re-run) is idempotent — the expected_from /
|
|
356
|
+
* expected_hash base guards must not fire on it, or deltas could never
|
|
357
|
+
* "replay deterministically" after a step-4 crash.
|
|
358
|
+
*/
|
|
359
|
+
function isReplayApplied(op, lookup) {
|
|
360
|
+
if (op.op === 'patch-sub-feature') {
|
|
361
|
+
const sub = lookup.getSubFeature(op.area, op.feature_id, op.sub_feature_id);
|
|
362
|
+
if (!sub || !op.patch)
|
|
363
|
+
return false;
|
|
364
|
+
return Object.entries(op.patch).every(([k, v]) => canonicalJson(sub[k]) === canonicalJson(v));
|
|
365
|
+
}
|
|
366
|
+
if (op.op === 'upsert' || op.op === 'add-group') {
|
|
367
|
+
const feature = lookup.getFeature(op.area, op.feature_id);
|
|
368
|
+
return !!feature && canonicalJson(feature) === canonicalJson(op.value);
|
|
369
|
+
}
|
|
370
|
+
return false;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Merge validated deltas per the ID-02 conflict matrix.
|
|
374
|
+
*
|
|
375
|
+
* @param {Array<{source: string, delta: object}>} sources — validated deltas
|
|
376
|
+
* annotated with their file path (conflicts name BOTH writers).
|
|
377
|
+
* @param {{ getFeature: (area, featureId) => object|null,
|
|
378
|
+
* getSubFeature: (area, featureId, subId) => object|null }} lookup
|
|
379
|
+
* — reads against the CURRENT registry pre-image (rules e/f).
|
|
380
|
+
* @returns {{ ok: true, operations: Array<Record<string, any>>, files: Array<Record<string, any>> }
|
|
381
|
+
* | { ok: false, conflicts: Array<{kind: string, message: string, sources: string[]}> }}
|
|
382
|
+
*/
|
|
383
|
+
export function mergeDeltas(sources, lookup) {
|
|
384
|
+
const conflicts = [];
|
|
385
|
+
const allFiles = [];
|
|
386
|
+
const annotated = [];
|
|
387
|
+
for (const { source, delta } of sources) {
|
|
388
|
+
for (const f of delta.files ?? [])
|
|
389
|
+
allFiles.push({ ...f, source });
|
|
390
|
+
for (const op of delta.operations ?? [])
|
|
391
|
+
annotated.push({ ...op, source });
|
|
392
|
+
}
|
|
393
|
+
// Areas any delta declares as wiring-transition — a group REPLACE in these
|
|
394
|
+
// areas that flips an existing wired value must be guarded per-op (ID-02 e).
|
|
395
|
+
const wiringAreas = new Set(allFiles
|
|
396
|
+
.filter((f) => f?.disposition === 'wiring-transition' && typeof f.area === 'string' && f.area)
|
|
397
|
+
.map((f) => f.area));
|
|
398
|
+
// Registry-state rules (e)/(f) — per op, against the pre-image. An op whose
|
|
399
|
+
// effect is already fully applied replays cleanly (ID-03 carve-out above).
|
|
400
|
+
for (const op of annotated) {
|
|
401
|
+
if (isReplayApplied(op, lookup))
|
|
402
|
+
continue;
|
|
403
|
+
if (op.expected_hash !== undefined) {
|
|
404
|
+
const entity = op.op === 'patch-sub-feature'
|
|
405
|
+
? lookup.getSubFeature(op.area, op.feature_id, op.sub_feature_id)
|
|
406
|
+
: lookup.getFeature(op.area, op.feature_id);
|
|
407
|
+
if (!entity) {
|
|
408
|
+
conflicts.push({
|
|
409
|
+
kind: 'expected-hash-missing-entity',
|
|
410
|
+
message: `${op.source}: expected_hash addresses missing entity ${op.area}/${op.feature_id}${op.sub_feature_id ? `/${op.sub_feature_id}` : ''} (ID-02 f)`,
|
|
411
|
+
sources: [op.source],
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
else if (hashEntity(entity) !== op.expected_hash) {
|
|
415
|
+
conflicts.push({
|
|
416
|
+
kind: 'expected-hash-stale',
|
|
417
|
+
message: `${op.source}: expected_hash for ${op.area}/${op.feature_id}${op.sub_feature_id ? `/${op.sub_feature_id}` : ''} does not match the current registry entity (stale base)`,
|
|
418
|
+
sources: [op.source],
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
if (op.op === 'patch-sub-feature' && op.expected_from !== undefined) {
|
|
423
|
+
// (e) verified PER-OPERATION against the CURRENT registry value.
|
|
424
|
+
const sub = op.sub_feature_id
|
|
425
|
+
? lookup.getSubFeature(op.area, op.feature_id, op.sub_feature_id)
|
|
426
|
+
: null;
|
|
427
|
+
if (!sub) {
|
|
428
|
+
conflicts.push({
|
|
429
|
+
kind: 'wiring-transition-missing-entity',
|
|
430
|
+
message: `${op.source}: wiring-transition targets missing sub_feature ${op.area}/${op.feature_id}/${op.sub_feature_id ?? '(none)'} (ID-02 e)`,
|
|
431
|
+
sources: [op.source],
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
else if (sub.wired !== op.expected_from) {
|
|
435
|
+
conflicts.push({
|
|
436
|
+
kind: 'wiring-transition-base-mismatch',
|
|
437
|
+
message: `${op.source}: wiring-transition expected wired=${JSON.stringify(op.expected_from)} but registry has wired=${JSON.stringify(sub.wired)} for ${op.area}/${op.feature_id}/${op.sub_feature_id}`,
|
|
438
|
+
sources: [op.source],
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
if (op.op === 'upsert' && wiringAreas.has(op.area)) {
|
|
443
|
+
// (e) ST10 corrected contract: an upsert into a wiring-transition
|
|
444
|
+
// area is checked ONLY when it REPLACES an existing group AND its
|
|
445
|
+
// payload flips an existing sub_feature's wired value — then it must
|
|
446
|
+
// itself carry expected_from matching the current value of every sub
|
|
447
|
+
// it changes. Creation (group absent) needs no guard: there is no
|
|
448
|
+
// existing value to flip. add-group is pure creation — an existing
|
|
449
|
+
// id routes through the duplicate/collision conflict paths instead.
|
|
450
|
+
const group = lookup.getFeature(op.area, op.feature_id);
|
|
451
|
+
if (group) {
|
|
452
|
+
const changed = (group.sub_features ?? []).filter((sub) => {
|
|
453
|
+
if (!sub || !isNonEmptyString(sub.id))
|
|
454
|
+
return false;
|
|
455
|
+
const next = (op.value?.sub_features ?? []).find((n) => n?.id === sub.id);
|
|
456
|
+
return next !== undefined && next.wired !== sub.wired;
|
|
457
|
+
});
|
|
458
|
+
if (changed.length > 0) {
|
|
459
|
+
if (op.expected_from === undefined) {
|
|
460
|
+
conflicts.push({
|
|
461
|
+
kind: 'wiring-transition-unguarded-replace',
|
|
462
|
+
message: `${op.source}: upsert into wiring-transition area ${op.area} flips wired on ${changed.map((c) => `${op.feature_id}/${c.id}`).join(', ')} without expected_from (ID-02 e)`,
|
|
463
|
+
sources: [op.source],
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
const mismatched = changed.filter((sub) => sub.wired !== op.expected_from);
|
|
468
|
+
if (mismatched.length > 0) {
|
|
469
|
+
conflicts.push({
|
|
470
|
+
kind: 'wiring-transition-base-mismatch',
|
|
471
|
+
message: `${op.source}: upsert expected wired=${JSON.stringify(op.expected_from)} but registry has ${mismatched.map((c) => `${c.id}=${JSON.stringify(c.wired)}`).join(', ')} in ${op.area}/${op.feature_id}`,
|
|
472
|
+
sources: [op.source],
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
// Cross-delta rules (a)-(d)/(g), grouped per entity key.
|
|
481
|
+
const byKey = new Map();
|
|
482
|
+
for (const op of annotated) {
|
|
483
|
+
const key = entityKey(op);
|
|
484
|
+
if (!byKey.has(key))
|
|
485
|
+
byKey.set(key, []);
|
|
486
|
+
byKey.get(key).push(op);
|
|
487
|
+
}
|
|
488
|
+
const merged = [];
|
|
489
|
+
for (const [, ops] of byKey) {
|
|
490
|
+
const removes = ops.filter((o) => o.op === 'remove');
|
|
491
|
+
const writes = ops.filter((o) => o.op !== 'remove');
|
|
492
|
+
// (d) remove-vs-upsert (or any write) on the same ID → hard conflict.
|
|
493
|
+
if (removes.length > 0 && writes.length > 0) {
|
|
494
|
+
conflicts.push({
|
|
495
|
+
kind: 'remove-vs-upsert',
|
|
496
|
+
message: `remove and ${writes[0].op} target the same entity ${writes[0].area}/${writes[0].feature_id}${writes[0].sub_feature_id ? `/${writes[0].sub_feature_id}` : ''} (ID-02 d)`,
|
|
497
|
+
sources: [...new Set([...removes, ...writes].map((o) => o.source))],
|
|
498
|
+
});
|
|
499
|
+
continue;
|
|
500
|
+
}
|
|
501
|
+
if (removes.length > 0) {
|
|
502
|
+
// (a) multiple identical removes dedupe.
|
|
503
|
+
merged.push(removes[0]);
|
|
504
|
+
continue;
|
|
505
|
+
}
|
|
506
|
+
const upserts = writes.filter((o) => o.op === 'upsert' || o.op === 'add-group');
|
|
507
|
+
const patches = writes.filter((o) => o.op === 'patch-sub-feature');
|
|
508
|
+
if (upserts.length > 0) {
|
|
509
|
+
// (a)/(c)/(g): byte-equal → dedupe; else hard conflict.
|
|
510
|
+
const canon = opCanonical(upserts[0]);
|
|
511
|
+
const divergent = upserts.filter((o) => opCanonical(o) !== canon);
|
|
512
|
+
if (divergent.length > 0) {
|
|
513
|
+
conflicts.push({
|
|
514
|
+
kind: 'duplicate-id-divergent-value',
|
|
515
|
+
message: `${upserts[0].op} collision on ${upserts[0].area}/${upserts[0].feature_id} with different values (ID-02 c/g)`,
|
|
516
|
+
sources: [...new Set(upserts.map((o) => o.source))],
|
|
517
|
+
});
|
|
518
|
+
continue;
|
|
519
|
+
}
|
|
520
|
+
merged.push(upserts[0]);
|
|
521
|
+
if (patches.length > 0) {
|
|
522
|
+
// A patch alongside an upsert of the SAME entity key is a same-target
|
|
523
|
+
// double-write — fail closed rather than pick an application order.
|
|
524
|
+
conflicts.push({
|
|
525
|
+
kind: 'patch-vs-upsert',
|
|
526
|
+
message: `patch-sub-feature and ${upserts[0].op} target the same entity ${upserts[0].area}/${upserts[0].feature_id}${patches[0].sub_feature_id ? `/${patches[0].sub_feature_id}` : ''}`,
|
|
527
|
+
sources: [...new Set([...upserts, ...patches].map((o) => o.source))],
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
continue;
|
|
531
|
+
}
|
|
532
|
+
if (patches.length === 1) {
|
|
533
|
+
merged.push(patches[0]);
|
|
534
|
+
continue;
|
|
535
|
+
}
|
|
536
|
+
// (b)/(c): multiple patches on the same target.
|
|
537
|
+
const bases = new Set(patches.map((o) => o.expected_hash).filter((h) => h !== undefined));
|
|
538
|
+
if (bases.size > 1) {
|
|
539
|
+
conflicts.push({
|
|
540
|
+
kind: 'patch-base-divergence',
|
|
541
|
+
message: `patches on ${patches[0].area}/${patches[0].feature_id}/${patches[0].sub_feature_id} carry different expected bases (ID-02 b)`,
|
|
542
|
+
sources: [...new Set(patches.map((o) => o.source))],
|
|
543
|
+
});
|
|
544
|
+
continue;
|
|
545
|
+
}
|
|
546
|
+
const mergedPatch = {};
|
|
547
|
+
const fieldSource = new Map();
|
|
548
|
+
let conflicted = false;
|
|
549
|
+
for (const p of patches) {
|
|
550
|
+
for (const [field, val] of Object.entries(p.patch ?? {})) {
|
|
551
|
+
if (field in mergedPatch) {
|
|
552
|
+
if (canonicalJson(mergedPatch[field]) !== canonicalJson(val)) {
|
|
553
|
+
// (c) same-field-different-value → hard conflict naming both writers.
|
|
554
|
+
conflicts.push({
|
|
555
|
+
kind: 'same-field-different-value',
|
|
556
|
+
message: `field "${field}" of ${p.area}/${p.feature_id}/${p.sub_feature_id} set to different values (ID-02 c)`,
|
|
557
|
+
sources: [...new Set([fieldSource.get(field), p.source])],
|
|
558
|
+
});
|
|
559
|
+
conflicted = true;
|
|
560
|
+
}
|
|
561
|
+
// (a) byte-equal same-field → dedupe (keep first).
|
|
562
|
+
continue;
|
|
563
|
+
}
|
|
564
|
+
mergedPatch[field] = val;
|
|
565
|
+
fieldSource.set(field, p.source);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
if (conflicted)
|
|
569
|
+
continue;
|
|
570
|
+
// (b) disjoint patches merge into one op.
|
|
571
|
+
const first = patches[0];
|
|
572
|
+
merged.push({
|
|
573
|
+
...first,
|
|
574
|
+
patch: mergedPatch,
|
|
575
|
+
source: [...new Set(patches.map((o) => o.source))].join(','),
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
if (conflicts.length > 0)
|
|
579
|
+
return { ok: false, conflicts };
|
|
580
|
+
// Deterministic application order: group writes, then patches, then removes,
|
|
581
|
+
// each sorted by (area, feature_id, sub_feature_id).
|
|
582
|
+
const rank = { upsert: 0, 'add-group': 0, 'patch-sub-feature': 1, remove: 2 };
|
|
583
|
+
merged.sort((a, b) => {
|
|
584
|
+
const r = rank[a.op] - rank[b.op];
|
|
585
|
+
if (r !== 0)
|
|
586
|
+
return r;
|
|
587
|
+
return entityKey(a) < entityKey(b) ? -1 : entityKey(a) > entityKey(b) ? 1 : 0;
|
|
588
|
+
});
|
|
589
|
+
return { ok: true, operations: merged, files: allFiles };
|
|
590
|
+
}
|
|
591
|
+
//# sourceMappingURL=delta.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delta.mjs","sourceRoot":"","sources":["../../../src/cli/features/delta.mjs"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,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