arkgate 4.8.5 → 4.8.7
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 +56 -2
- package/README.md +16 -9
- package/bin/ark-mcp-runtime.mjs +8 -2
- package/bin/lib/analysis-engine.mjs +5 -5
- package/bin/lib/ark-order-invariants.mjs +163 -14
- package/bin/lib/ark-order-types.mjs +3 -0
- package/bin/lib/diagnostic-catalog.mjs +5 -4
- package/bin/lib/doctor-human.mjs +9 -0
- package/bin/lib/doctor-plan.mjs +5 -1
- package/bin/lib/html-report.mjs +4 -2
- package/bin/lib/layer-description.mjs +27 -0
- package/bin/lib/prepare-write.mjs +7 -1
- package/bin/lib/remediation.mjs +11 -5
- package/dist/{configTypes-dy5PfTqS.d.ts → configTypes-0eHpocR3.d.ts} +4 -0
- package/dist/{diagnosticCatalog-DMO30svh.d.ts → diagnosticCatalog-wDAH08gH.d.ts} +3 -3
- package/dist/eslint/index.cjs +1 -1
- package/dist/eslint/index.d.ts +1 -1
- package/dist/eslint/index.js +1 -1
- package/dist/index.cjs +19 -19
- package/dist/index.d.ts +5 -4
- package/dist/index.js +20 -20
- package/dist/nestjs/index.cjs +5 -5
- package/dist/nestjs/index.d.ts +3 -3
- package/dist/nestjs/index.js +5 -5
- package/dist/order/index.cjs +1 -1
- package/dist/order/index.d.ts +61 -10
- package/dist/order/index.js +1 -1
- package/dist/runtime/index.cjs +11 -11
- package/dist/runtime/index.d.ts +6 -6
- package/dist/runtime/index.js +11 -11
- package/dist/{types-BuM8WNqe.d.ts → types-BK47clMl.d.ts} +1 -1
- package/dist/{types-CzE6LMaW.d.ts → types-CwZ_oz1N.d.ts} +22 -7
- package/docs/README.md +5 -4
- package/docs/agent-guide.md +2 -0
- package/docs/ai-gates.md +5 -2
- package/docs/arkorder.md +32 -14
- package/docs/configuration.md +28 -5
- package/docs/develop.md +7 -2
- package/docs/diagnostics.md +15 -5
- package/docs/package-surface.md +18 -12
- package/docs/product-voice.md +3 -3
- package/docs/use.md +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/templates/agent-skills/README.md +1 -1
- package/templates/agent-skills/ark-adopt/SKILL.md +22 -5
- package/templates/agent-skills/ark-architect/SKILL.md +1 -1
- package/templates/agent-skills/ark-autopilot/SKILL.md +4 -4
- package/templates/agent-skills/ark-contract/SKILL.md +1 -1
- package/templates/agent-skills/ark-coverage/SKILL.md +3 -2
- package/templates/agent-skills/ark-explain/SKILL.md +3 -2
- package/templates/agent-skills/ark-explore/SKILL.md +3 -2
- package/templates/agent-skills/ark-fix/SKILL.md +1 -1
- package/templates/agent-skills/ark-loop/SKILL.md +1 -1
- package/templates/agent-skills/ark-place/SKILL.md +25 -12
- package/templates/agent-skills/ark-runtime/SKILL.md +3 -0
- package/templates/agent-skills/ark-think/SKILL.md +2 -2
- package/templates/agent-skills/ark-upgrade/SKILL.md +2 -2
- package/templates/skills/ark-adopt.md +22 -5
- package/templates/skills/ark-architect.md +1 -1
- package/templates/skills/ark-autopilot.md +4 -4
- package/templates/skills/ark-contract.md +1 -1
- package/templates/skills/ark-coverage.md +3 -2
- package/templates/skills/ark-explain.md +3 -2
- package/templates/skills/ark-explore.md +3 -2
- package/templates/skills/ark-fix.md +1 -1
- package/templates/skills/ark-loop.md +1 -1
- package/templates/skills/ark-place.md +25 -12
- package/templates/skills/ark-runtime.md +3 -0
- package/templates/skills/ark-think.md +2 -2
- package/templates/skills/ark-upgrade.md +2 -2
|
@@ -9,9 +9,17 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { ArkOrderError } from './ark-order-error.mjs';
|
|
12
|
-
import { DEFAULT_MAX_XI_KEYS } from './ark-order-types.mjs';
|
|
12
|
+
import { CAPACITY_OPS, DEFAULT_MAX_XI_KEYS } from './ark-order-types.mjs';
|
|
13
13
|
import { deterministicHash, stableSerialize } from './stableHash';
|
|
14
14
|
export { DEFAULT_MAX_XI_KEYS };
|
|
15
|
+
/** D7: consumer still owns handlers — this only names the travel verb. */
|
|
16
|
+
export function ingestTravelAction(residual) {
|
|
17
|
+
if (residual.kind === 'absorb')
|
|
18
|
+
return 'send';
|
|
19
|
+
if (residual.kind === 'escalate_up' && residual.target === 'human')
|
|
20
|
+
return 'raises';
|
|
21
|
+
return 'none';
|
|
22
|
+
}
|
|
15
23
|
const FORBIDDEN_PLANE_METHODS = ['update', 'patch', 'set', 'mutate'];
|
|
16
24
|
export function isForbiddenPlaneMethod(name) {
|
|
17
25
|
return FORBIDDEN_PLANE_METHODS.includes(name);
|
|
@@ -70,9 +78,39 @@ export function assertXiSchema(xi, schema) {
|
|
|
70
78
|
}
|
|
71
79
|
}
|
|
72
80
|
}
|
|
73
|
-
|
|
81
|
+
function catalogDigestFor(xi, catalogDigest) {
|
|
82
|
+
if (typeof catalogDigest !== 'string')
|
|
83
|
+
return undefined;
|
|
84
|
+
if (!Object.prototype.hasOwnProperty.call(xi, 'catalogReleaseId'))
|
|
85
|
+
return undefined;
|
|
86
|
+
return catalogDigest;
|
|
87
|
+
}
|
|
88
|
+
export function hashReleasePayload(xi, sigma, catalogDigest) {
|
|
89
|
+
const digest = catalogDigestFor(xi, catalogDigest);
|
|
90
|
+
if (digest !== undefined)
|
|
91
|
+
return deterministicHash(stableSerialize({ xi, sigma, catalogDigest: digest }));
|
|
74
92
|
return deterministicHash(stableSerialize({ xi, sigma }));
|
|
75
93
|
}
|
|
94
|
+
export function hashXiIdentity(xi, catalogDigest) {
|
|
95
|
+
const digest = catalogDigestFor(xi, catalogDigest);
|
|
96
|
+
if (digest !== undefined)
|
|
97
|
+
return deterministicHash(stableSerialize({ xi, catalogDigest: digest }));
|
|
98
|
+
return deterministicHash(stableSerialize({ xi }));
|
|
99
|
+
}
|
|
100
|
+
export function hashSigmaIdentity(sigma) {
|
|
101
|
+
return deterministicHash(stableSerialize({ sigma }));
|
|
102
|
+
}
|
|
103
|
+
export function xiRecordsEqual(left, right) {
|
|
104
|
+
return stableSerialize(left) === stableSerialize(right);
|
|
105
|
+
}
|
|
106
|
+
/** D1: after the first freeze, a later release() may not change ξ. */
|
|
107
|
+
export function assertUnvalvedRelease(current, nextXi) {
|
|
108
|
+
if (!current)
|
|
109
|
+
return;
|
|
110
|
+
if (xiRecordsEqual(current.xi, nextXi))
|
|
111
|
+
return;
|
|
112
|
+
throw new ArkOrderError('ARKORDER_UNVALVED_RELEASE', 'ξ is frozen; change the pattern with proposeRelease then apply(ProposeResult)');
|
|
113
|
+
}
|
|
76
114
|
export function createFrozenRelease(input) {
|
|
77
115
|
assertXiKeyCap(input.xi, input.maxXiKeys);
|
|
78
116
|
const xi = freezeRecord(input.xi, 'ξ');
|
|
@@ -81,13 +119,28 @@ export function createFrozenRelease(input) {
|
|
|
81
119
|
const sigma = freezeRecord(input.sigma ?? {}, 'σ');
|
|
82
120
|
const release = Object.freeze({
|
|
83
121
|
version: input.version,
|
|
84
|
-
hash: hashReleasePayload(xi, sigma),
|
|
122
|
+
hash: hashReleasePayload(xi, sigma, input.catalogDigest),
|
|
123
|
+
xiHash: hashXiIdentity(xi, input.catalogDigest),
|
|
124
|
+
sigmaHash: hashSigmaIdentity(sigma),
|
|
85
125
|
xi,
|
|
86
126
|
sigma,
|
|
87
127
|
releasedAt: input.now,
|
|
88
128
|
});
|
|
89
129
|
return release;
|
|
90
130
|
}
|
|
131
|
+
/** D2: refresh σ without minting a pattern. xiHash must not change. */
|
|
132
|
+
export function refreshSigmaRecord(input) {
|
|
133
|
+
const sigma = freezeRecord(input.sigma, 'σ');
|
|
134
|
+
return Object.freeze({
|
|
135
|
+
version: input.current.version,
|
|
136
|
+
hash: hashReleasePayload(input.current.xi, sigma, input.catalogDigest),
|
|
137
|
+
xiHash: input.current.xiHash,
|
|
138
|
+
sigmaHash: hashSigmaIdentity(sigma),
|
|
139
|
+
xi: input.current.xi,
|
|
140
|
+
sigma,
|
|
141
|
+
releasedAt: input.now,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
91
144
|
const XI_TTL_KEY_RE = /^(ttl|freshUntil|fresh_until|maxAge|max_age)$/i;
|
|
92
145
|
export function assertXiHasNoTtl(xi) {
|
|
93
146
|
for (const key of Object.keys(xi)) {
|
|
@@ -121,28 +174,101 @@ export function assertSigmaFresh(input) {
|
|
|
121
174
|
throw new ArkOrderError('ARKORDER_STALE_SIGMA', 'σ is older than sigmaMaxAgeMs; ξ does not TTL');
|
|
122
175
|
}
|
|
123
176
|
}
|
|
124
|
-
export function
|
|
177
|
+
export function fieldEventIdentity(event) {
|
|
178
|
+
return deterministicHash(stableSerialize({ kind: event.kind, payload: event.payload ?? null }));
|
|
179
|
+
}
|
|
180
|
+
function bindResidual(event, xiHash) {
|
|
181
|
+
return { event, xiHash, eventId: fieldEventIdentity(event) };
|
|
182
|
+
}
|
|
183
|
+
const CAPACITY_OP_SET = new Set(CAPACITY_OPS);
|
|
184
|
+
function isCapacityOp(value) {
|
|
185
|
+
return typeof value === 'string' && CAPACITY_OP_SET.has(value);
|
|
186
|
+
}
|
|
187
|
+
function numericLeaf(value) {
|
|
188
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
189
|
+
}
|
|
190
|
+
function compareCapacity(left, op, right) {
|
|
191
|
+
if (op === 'lte')
|
|
192
|
+
return left <= right;
|
|
193
|
+
if (op === 'lt')
|
|
194
|
+
return left < right;
|
|
195
|
+
if (op === 'gte')
|
|
196
|
+
return left >= right;
|
|
197
|
+
return left > right;
|
|
198
|
+
}
|
|
199
|
+
function packHasFunction(value) {
|
|
200
|
+
if (typeof value === 'function')
|
|
201
|
+
return true;
|
|
202
|
+
if (value === null || typeof value !== 'object')
|
|
203
|
+
return false;
|
|
204
|
+
if (Array.isArray(value))
|
|
205
|
+
return value.some(packHasFunction);
|
|
206
|
+
return Object.values(value).some(packHasFunction);
|
|
207
|
+
}
|
|
208
|
+
function evaluateCapacity(event, sigma, pack) {
|
|
209
|
+
const rows = pack.capacity ?? [];
|
|
210
|
+
for (const row of rows) {
|
|
211
|
+
if (packHasFunction(row) || !isCapacityOp(row.op))
|
|
212
|
+
return 'pack';
|
|
213
|
+
if (row.kind !== event.kind)
|
|
214
|
+
continue;
|
|
215
|
+
const payload = event.payload && typeof event.payload === 'object' && !Array.isArray(event.payload)
|
|
216
|
+
? numericLeaf(event.payload[row.payloadKey])
|
|
217
|
+
: undefined;
|
|
218
|
+
const limit = numericLeaf(sigma[row.sigmaKey]);
|
|
219
|
+
if (payload === undefined || limit === undefined)
|
|
220
|
+
return 'pack';
|
|
221
|
+
if (!compareCapacity(payload, row.op, limit))
|
|
222
|
+
return 'capacity';
|
|
223
|
+
}
|
|
224
|
+
return 'ok';
|
|
225
|
+
}
|
|
226
|
+
export function classifyIngest(projection, event, packs = [], xiHash = '', sigma = Object.freeze({})) {
|
|
125
227
|
const kind = event.kind;
|
|
228
|
+
const bound = bindResidual(event, xiHash);
|
|
126
229
|
for (const pack of packs) {
|
|
230
|
+
if (packHasFunction(pack.capacity) || packHasFunction(pack.escalateKinds)) {
|
|
231
|
+
return {
|
|
232
|
+
...bound,
|
|
233
|
+
kind: 'hold',
|
|
234
|
+
reasonCode: 'pack',
|
|
235
|
+
reason: `pack ${pack.id} is not data-only; user predicates are forbidden`,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
127
238
|
if (pack.escalateKinds?.includes(kind)) {
|
|
128
239
|
const target = pack.escalateTarget ?? 'human';
|
|
129
240
|
return {
|
|
130
|
-
|
|
131
|
-
|
|
241
|
+
...bound,
|
|
242
|
+
kind: 'escalate_up',
|
|
243
|
+
reasonCode: 'pack',
|
|
132
244
|
reason: `pack ${pack.id} slaves kind ${JSON.stringify(kind)} to a pattern change`,
|
|
133
245
|
target,
|
|
134
246
|
};
|
|
135
247
|
}
|
|
136
248
|
}
|
|
137
|
-
if (projection.allowedKinds.includes(kind)) {
|
|
138
|
-
return {
|
|
249
|
+
if (!projection.allowedKinds.includes(kind)) {
|
|
250
|
+
return {
|
|
251
|
+
...bound,
|
|
252
|
+
kind: 'escalate_up',
|
|
253
|
+
reasonCode: 'not-in-pattern',
|
|
254
|
+
reason: `kind ${JSON.stringify(kind)} is not allowed by h(ξ); field cannot rewrite the pattern`,
|
|
255
|
+
target: 'human',
|
|
256
|
+
};
|
|
139
257
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
258
|
+
for (const pack of packs) {
|
|
259
|
+
const cap = evaluateCapacity(event, sigma, pack);
|
|
260
|
+
if (cap === 'ok')
|
|
261
|
+
continue;
|
|
262
|
+
return {
|
|
263
|
+
...bound,
|
|
264
|
+
kind: 'hold',
|
|
265
|
+
reasonCode: cap,
|
|
266
|
+
reason: cap === 'capacity'
|
|
267
|
+
? `pack ${pack.id} capacity ${JSON.stringify(event.kind)} does not hold`
|
|
268
|
+
: `pack ${pack.id} capacity is not numeric data`,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
return { ...bound, kind: 'absorb' };
|
|
146
272
|
}
|
|
147
273
|
export function blastRadiusOf(previous, next) {
|
|
148
274
|
const prev = new Set(previous.allowedKinds);
|
|
@@ -179,6 +305,7 @@ export function proposePatternChange(input) {
|
|
|
179
305
|
now: input.now,
|
|
180
306
|
maxXiKeys: input.maxXiKeys,
|
|
181
307
|
xiSchema: input.xiSchema,
|
|
308
|
+
catalogDigest: input.catalogDigest,
|
|
182
309
|
});
|
|
183
310
|
if (candidate.hash === input.current.hash) {
|
|
184
311
|
throw new ArkOrderError('ARKORDER_EMPTY_BLAST', 'delta does not change ξ; that is not a pattern change');
|
|
@@ -195,3 +322,25 @@ export function proposePatternChange(input) {
|
|
|
195
322
|
invalidations,
|
|
196
323
|
};
|
|
197
324
|
}
|
|
325
|
+
/** D1 valve: freeze ProposeResult.nextXi. Empty blast still fails. */
|
|
326
|
+
export function applyProposedRelease(input) {
|
|
327
|
+
const candidate = createFrozenRelease({
|
|
328
|
+
xi: { ...input.proposal.nextXi },
|
|
329
|
+
sigma: { ...input.current.sigma },
|
|
330
|
+
version: input.current.version + 1,
|
|
331
|
+
now: input.now,
|
|
332
|
+
maxXiKeys: input.maxXiKeys,
|
|
333
|
+
xiSchema: input.xiSchema,
|
|
334
|
+
catalogDigest: input.catalogDigest,
|
|
335
|
+
});
|
|
336
|
+
if (xiRecordsEqual(candidate.xi, input.current.xi)) {
|
|
337
|
+
throw new ArkOrderError('ARKORDER_EMPTY_BLAST', 'delta does not change ξ; that is not a pattern change');
|
|
338
|
+
}
|
|
339
|
+
const previous = input.projector(input.current, input.current.sigma);
|
|
340
|
+
const next = input.projector(candidate, candidate.sigma);
|
|
341
|
+
const { blastRadius } = blastRadiusOf(previous, next);
|
|
342
|
+
if (blastRadius.length === 0) {
|
|
343
|
+
throw new ArkOrderError('ARKORDER_EMPTY_BLAST', 'pattern change has empty blast radius; that key is not an order parameter');
|
|
344
|
+
}
|
|
345
|
+
return candidate;
|
|
346
|
+
}
|
|
@@ -9,3 +9,6 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
export const DEFAULT_MAX_XI_KEYS = 7;
|
|
12
|
+
export const INGEST_RESIDUAL_KINDS = ['absorb', 'escalate_up', 'hold'];
|
|
13
|
+
export const INGEST_REASON_CODES = ['not-in-pattern', 'stale-sigma', 'pack', 'capacity'];
|
|
14
|
+
export const CAPACITY_OPS = ['lte', 'lt', 'gte', 'gt'];
|
|
@@ -67,13 +67,14 @@ export const DIAGNOSTIC_CATALOG = Object.freeze([
|
|
|
67
67
|
entry('ARKRUN_TRANSPORT_BYPASS', 'arkrun', 'Homemade broker or emitter import', 'A managed layer imports a closed broker/queue/emitter specifier (EventEmitter, queue clients, …) instead of the ArkRun kernel transport.', 'Send through the ArkRun kernel transport instead of importing that broker or emitter, then preflight again. Never mechanical-safe — homemade buses stay judgment.'),
|
|
68
68
|
entry('ARKORDER_MISSING_PLANE', 'arkorder', 'No createOrderPlane in plane roots', 'The ArkOrder extra is on but no createOrderPlane factory was found in arkOrder.planeRoots, so agents can skip the pattern plane while the write gate stays green.', 'Import createOrderPlane from arkgate/order and call it in a plane root listed in arkOrder.planeRoots, then preflight again. Never mechanical-safe — factory placement is a design decision.'),
|
|
69
69
|
entry('ARKORDER_KERNEL_IN_DOMAIN', 'arkorder', 'Domain-role layer imports the order plane', 'A Domain-role layer imports arkgate/order. Domain stays plane-free; planeRoots own the factory.', 'Move the arkgate/order import out of the Domain-role layer into a plane root or adapter, then preflight again. Never mechanical-safe.'),
|
|
70
|
-
entry('ARKORDER_GENERIC_UPDATE', 'arkorder', 'Generic update of ξ', 'A call to update/patch/set on the order plane rewrites the slow pattern. Haken slaving forbids generic ξ mutation.', 'Use release()
|
|
70
|
+
entry('ARKORDER_GENERIC_UPDATE', 'arkorder', 'Generic update of ξ', 'A call to update/patch/set on the order plane rewrites the slow pattern. Haken slaving forbids generic ξ mutation.', 'Use release() for the first freeze of ξ. Later pattern change is proposeRelease then apply(ProposeResult). Never update/patch/set. Never mechanical-safe.'),
|
|
71
71
|
entry('ARKORDER_TOO_MANY_PARAMS', 'arkorder', 'Too many slow keys', 'ξ has more keys than arkOrder.maxXiKeys. Haken requires a few slow modes, not a dump of microstate.', 'Cut ξ to the slow keys that actually slave the rest, then preflight again. Never mechanical-safe.'),
|
|
72
|
-
entry('ARKORDER_INGEST_WRITES_XI', 'arkorder', 'ingest assigned into ξ', 'An ingest() result is written into a Release or ξ store. ingest may absorb or
|
|
73
|
-
entry('ARKORDER_XI_FIELD_WRITE', 'arkorder', 'Slow key written around the order plane', 'A managed-layer file imports a persistence driver and writes a declared arkOrder.xiKeys name. Field events absorb or escalate; they do not PATCH the slow pattern.', 'Keep invoices, seats, hours, and logs on ingest. Change the slow key with proposeRelease
|
|
72
|
+
entry('ARKORDER_INGEST_WRITES_XI', 'arkorder', 'ingest assigned into ξ', 'An ingest() result is written into a Release or ξ store. ingest may absorb, escalate_up, or hold; it never mints a pattern.', 'Keep ingest results as absorb/escalate_up/hold only. Change ξ with proposeRelease then apply(ProposeResult). Never mechanical-safe.'),
|
|
73
|
+
entry('ARKORDER_XI_FIELD_WRITE', 'arkorder', 'Slow key written around the order plane', 'A managed-layer file imports a persistence driver and writes a declared arkOrder.xiKeys name. Field events absorb or escalate; they do not PATCH the slow pattern.', 'Keep invoices, seats, hours, and logs on ingest. Change the slow key with proposeRelease then apply(ProposeResult), then preflight again. Never mechanical-safe.'),
|
|
74
74
|
entry('ARKORDER_INFORMATION_BUDGET', 'arkorder', 'Projection observes a forbidden kind', 'h(ξ) allowedKinds includes a kind listed in informationBudget.cannotObserve. A scale may not look at what it was told not to see.', 'Cut that kind from the projector or from cannotObserve, then preflight again. Never mechanical-safe.'),
|
|
75
75
|
entry('ARKORDER_XI_TTL', 'arkorder', 'Slow key carries a freshness field', 'ξ named ttl/freshUntil/maxAge. Freshness belongs on σ. A slow parameter that expires per transaction is not slow.', 'Move freshness onto σ (freshUntil) and keep ξ stable, then preflight again. Never mechanical-safe.'),
|
|
76
|
-
entry('ARKORDER_STALE_SIGMA', 'arkorder', 'σ is stale', 'ingest ran after σ.freshUntil (or sigmaMaxAgeMs). ξ does not TTL.', '
|
|
76
|
+
entry('ARKORDER_STALE_SIGMA', 'arkorder', 'σ is stale', 'ingest ran after σ.freshUntil (or sigmaMaxAgeMs). ξ does not TTL.', 'Call refreshSigma and ingest again, or proposeRelease then apply(ProposeResult) if the pattern changed. Never mechanical-safe.'),
|
|
77
|
+
entry('ARKORDER_UNVALVED_RELEASE', 'arkorder', 'Unvalved second freeze of ξ', 'release() ran after a pattern was already frozen and the new ξ differs. First freeze is release(); later pattern change is proposeRelease then apply.', 'Change ξ with proposeRelease then apply(ProposeResult). release() is only the first freeze. Never mechanical-safe.'),
|
|
77
78
|
// ── atomic preflight / change set ────────────────────────────────────────
|
|
78
79
|
entry('INVALID_CHANGE_PATH', 'preflight', 'Unsafe change path', 'A change set entry is not a safe, non-empty project-relative path (absolute, escape, empty, or NUL).', 'Use canonical project-relative paths only in the atomic change set, then preflight again.'),
|
|
79
80
|
entry('DUPLICATE_CHANGE_PATH', 'preflight', 'Duplicate path in change set', 'The atomic change set lists more than one operation for the same path.', 'Collapse to one create/update/delete per path, then preflight again.'),
|
package/bin/lib/doctor-human.mjs
CHANGED
|
@@ -118,6 +118,9 @@ export function printDoctorCompactHuman(view) {
|
|
|
118
118
|
? ok
|
|
119
119
|
: warn;
|
|
120
120
|
line(govMark, `Governed: ${cov.governed.percent}% (${cov.governed.classifiedFiles}/${cov.governed.totalFiles} files)`);
|
|
121
|
+
for (const row of cov.layers ?? []) {
|
|
122
|
+
if (row.description) line(' ', `${row.name} — ${row.description}`);
|
|
123
|
+
}
|
|
121
124
|
|
|
122
125
|
const hostRed =
|
|
123
126
|
gatesMissing.length > 0 ||
|
|
@@ -230,6 +233,12 @@ export function printDoctorDetailsHuman(view) {
|
|
|
230
233
|
);
|
|
231
234
|
}
|
|
232
235
|
if (cov.suggestions.length === 0 && cov.emptyLayers.length === 0) line(ok, 'Every layer classifies files; no empty layers');
|
|
236
|
+
const captioned = (cov.layers ?? []).filter((row) => row.description);
|
|
237
|
+
if (captioned.length > 0) {
|
|
238
|
+
console.log('');
|
|
239
|
+
console.log(color.bold('Layers'));
|
|
240
|
+
for (const row of captioned) line(' ', `${row.name} — ${row.description}`);
|
|
241
|
+
}
|
|
233
242
|
|
|
234
243
|
if (packageVersionTruth?.dualTruth) {
|
|
235
244
|
console.log('');
|
package/bin/lib/doctor-plan.mjs
CHANGED
|
@@ -15,6 +15,7 @@ import { describePackageVersionDualTruth } from './field-install.mjs';
|
|
|
15
15
|
import { detectAgentHomeGaps } from './agent-homes.mjs';
|
|
16
16
|
import { collectDoctorNextActions } from './doctor-next-actions.mjs';
|
|
17
17
|
import { printDoctorCompactHuman, printDoctorDetailsHuman } from './doctor-human.mjs';
|
|
18
|
+
import { placementDescriptionFields } from './layer-description.mjs';
|
|
18
19
|
export { printDoctorCompactHuman, printDoctorDetailsHuman };
|
|
19
20
|
export { summarizeRulesUnderContract };
|
|
20
21
|
|
|
@@ -117,6 +118,7 @@ export function computeCoverage(root, config, files, rules) {
|
|
|
117
118
|
name: layer.name,
|
|
118
119
|
patterns: layer.patterns ?? [],
|
|
119
120
|
files: counts.get(layer.name) ?? 0,
|
|
121
|
+
...placementDescriptionFields(layer),
|
|
120
122
|
}));
|
|
121
123
|
// A layer whose patterns match zero files is dead config — it enforces nothing, usually a
|
|
122
124
|
// wrong glob (the #1 monorepo mistake). A layer with no rule edge can import anything.
|
|
@@ -171,7 +173,8 @@ export function runCoverage(root, config, files, rules, asJson) {
|
|
|
171
173
|
console.log(` ${pad('Layer')} Files`);
|
|
172
174
|
for (const row of layerRows) {
|
|
173
175
|
const flag = row.files === 0 ? ' (pattern matches nothing)' : '';
|
|
174
|
-
|
|
176
|
+
const caption = row.description ? ` ${row.description}` : '';
|
|
177
|
+
console.log(` ${pad(row.name)} ${String(row.files).padStart(5)}${flag}${caption}`);
|
|
175
178
|
}
|
|
176
179
|
console.log(` ${pad('(unclassified)')} ${String(unclassified.length).padStart(5)}`);
|
|
177
180
|
console.log('');
|
|
@@ -758,6 +761,7 @@ export function runDoctor(root, config, files, rules, violations, asJson, option
|
|
|
758
761
|
productHonesty,
|
|
759
762
|
governed: cov.governed,
|
|
760
763
|
coverageHonesty,
|
|
764
|
+
layers: cov.layers,
|
|
761
765
|
emptyLayers: cov.emptyLayers,
|
|
762
766
|
layersWithoutRules: cov.layersWithoutRules,
|
|
763
767
|
ungovernedDirs: cov.suggestions.length,
|
package/bin/lib/html-report.mjs
CHANGED
|
@@ -25,6 +25,7 @@ import { capabilityBadgesFor, renderAdvisorySections } from './html-report-advis
|
|
|
25
25
|
import { renderEvolutionSection } from './html-report-evolution.mjs';
|
|
26
26
|
import { arkGitignoreAppendDecision } from './ark-gitignore.mjs';
|
|
27
27
|
import { captureGitSnapshot } from './report-snapshot-context.mjs';
|
|
28
|
+
import { layerDescriptionCaption } from './layer-description.mjs';
|
|
28
29
|
|
|
29
30
|
export { arkGitignoreAppendDecision, gitignoreCoversArkState, gitignoreHasArkNegationException } from './ark-gitignore.mjs';
|
|
30
31
|
|
|
@@ -405,7 +406,7 @@ export function renderBeginnerHtmlReport({ root, config, violations, ok, version
|
|
|
405
406
|
|
|
406
407
|
const placementRows = layers
|
|
407
408
|
.map((layer) => {
|
|
408
|
-
const purpose = layer
|
|
409
|
+
const purpose = layerDescriptionCaption(layer) || 'See ark.config.json';
|
|
409
410
|
const folders = (layer.patterns || []).join(', ') || '—';
|
|
410
411
|
return `<tr><td><strong>${esc(layer.name)}</strong></td><td>${esc(purpose)}</td><td><code>${esc(folders)}</code></td></tr>`;
|
|
411
412
|
})
|
|
@@ -762,9 +763,10 @@ export function renderHtmlReport({
|
|
|
762
763
|
].join(' ');
|
|
763
764
|
const example = exampleByLayer?.get?.(layer.name);
|
|
764
765
|
const files = counts.get(layer.name) || 0;
|
|
766
|
+
const caption = layerDescriptionCaption(layer);
|
|
765
767
|
return `<tr>
|
|
766
768
|
<td class="ln">${esc(layer.name)}<div class="tags">${tags}</div></td>
|
|
767
|
-
<td>${
|
|
769
|
+
<td>${caption ? esc(caption) : '<span class="dim">—</span>'}</td>
|
|
768
770
|
<td class="num">${files}</td>
|
|
769
771
|
<td><code class="pat">${(layer.patterns || []).map(esc).join('<br>') || '—'}</code></td>
|
|
770
772
|
<td>${example ? `<code>${esc(example)}</code>` : '<span class="dim">no files yet</span>'}</td>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* App-context caption from `layers[].description`.
|
|
3
|
+
* Metadata only — callers project it; policyHash strips it elsewhere.
|
|
4
|
+
* Present non-empty string is returned; absence/empty/non-string is undefined.
|
|
5
|
+
*
|
|
6
|
+
* @param {{ description?: unknown } | null | undefined} layerOrPlacement
|
|
7
|
+
* @returns {string | undefined}
|
|
8
|
+
*/
|
|
9
|
+
export function layerDescriptionCaption(layerOrPlacement) {
|
|
10
|
+
const caption =
|
|
11
|
+
layerOrPlacement && typeof layerOrPlacement === 'object'
|
|
12
|
+
? layerOrPlacement.description
|
|
13
|
+
: undefined;
|
|
14
|
+
return typeof caption === 'string' && caption.length > 0 ? caption : undefined;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Project the caption onto place / prepare-write / coverage / doctor JSON.
|
|
19
|
+
* Absence omits the field (never empty string).
|
|
20
|
+
*
|
|
21
|
+
* @param {{ description?: unknown } | null | undefined} layerOrPlacement
|
|
22
|
+
* @returns {{ description: string } | {}}
|
|
23
|
+
*/
|
|
24
|
+
export function placementDescriptionFields(layerOrPlacement) {
|
|
25
|
+
const caption = layerDescriptionCaption(layerOrPlacement);
|
|
26
|
+
return caption ? { description: caption } : {};
|
|
27
|
+
}
|
|
@@ -7,6 +7,12 @@
|
|
|
7
7
|
import crypto from 'node:crypto';
|
|
8
8
|
import { validateWithAutoPatch } from './auto-patch.mjs';
|
|
9
9
|
import { classifyRemediation, enrichViolationWithFixClass } from './remediation.mjs';
|
|
10
|
+
import {
|
|
11
|
+
layerDescriptionCaption,
|
|
12
|
+
placementDescriptionFields,
|
|
13
|
+
} from './layer-description.mjs';
|
|
14
|
+
|
|
15
|
+
export { layerDescriptionCaption, placementDescriptionFields };
|
|
10
16
|
|
|
11
17
|
/**
|
|
12
18
|
* Stable content identity for host commit / cache keys.
|
|
@@ -114,7 +120,7 @@ export function composePrepareWrite(opts) {
|
|
|
114
120
|
...(placement?.suggestedLayers ? { suggestedLayers: placement.suggestedLayers } : {}),
|
|
115
121
|
...(placement?.message ? { placementMessage: placement.message } : {}),
|
|
116
122
|
...(placement?.note ? { placementNote: placement.note } : {}),
|
|
117
|
-
...(placement
|
|
123
|
+
...placementDescriptionFields(placement),
|
|
118
124
|
// Q03: pass through golden pattern from ark_place (advisory; absent is normal).
|
|
119
125
|
...(placement?.goldenPattern ? { goldenPattern: placement.goldenPattern } : {}),
|
|
120
126
|
mode: gate.mode,
|
package/bin/lib/remediation.mjs
CHANGED
|
@@ -107,6 +107,7 @@ const ARKORDER_JUDGMENT_RULE_IDS = new Set([
|
|
|
107
107
|
'ARKORDER_TOO_MANY_PARAMS',
|
|
108
108
|
'ARKORDER_INGEST_WRITES_XI',
|
|
109
109
|
'ARKORDER_XI_FIELD_WRITE',
|
|
110
|
+
'ARKORDER_UNVALVED_RELEASE',
|
|
110
111
|
]);
|
|
111
112
|
function arkRunCallSiteName(violation) {
|
|
112
113
|
return typeof violation.target === 'string' && violation.target.trim().length > 0
|
|
@@ -238,15 +239,17 @@ export function deterministicNextAction(violation) {
|
|
|
238
239
|
case 'ARKORDER_KERNEL_IN_DOMAIN':
|
|
239
240
|
return 'Move the arkgate/order import out of the Domain-role layer into a plane root or adapter, then preflight again. Never mechanical-safe.';
|
|
240
241
|
case 'ARKORDER_GENERIC_UPDATE':
|
|
241
|
-
return 'Use release()
|
|
242
|
+
return 'Use release() for the first freeze of ξ. Later pattern change is proposeRelease then apply(ProposeResult). Never update/patch/set. Never mechanical-safe.';
|
|
242
243
|
case 'ARKORDER_TOO_MANY_PARAMS':
|
|
243
244
|
return 'Cut ξ to the slow keys that actually slave the rest, then preflight again. Never mechanical-safe.';
|
|
244
245
|
case 'ARKORDER_INGEST_WRITES_XI':
|
|
245
|
-
return 'Keep ingest results as absorb/
|
|
246
|
+
return 'Keep ingest results as absorb/escalate_up/hold only. Change ξ with proposeRelease then apply(ProposeResult). Never mechanical-safe.';
|
|
246
247
|
case 'ARKORDER_XI_FIELD_WRITE':
|
|
247
248
|
return typeof violation.target === 'string' && violation.target.length > 0
|
|
248
|
-
? `Do not persist slow key ${violation.target} from a use-case. Absorb the field with ingest() or change the pattern with proposeRelease
|
|
249
|
-
: 'Do not persist a declared slow key from a use-case. Absorb the field with ingest() or change the pattern with proposeRelease
|
|
249
|
+
? `Do not persist slow key ${violation.target} from a use-case. Absorb the field with ingest() or change the pattern with proposeRelease then apply, then preflight again.`
|
|
250
|
+
: 'Do not persist a declared slow key from a use-case. Absorb the field with ingest() or change the pattern with proposeRelease then apply, then preflight again. Never mechanical-safe.';
|
|
251
|
+
case 'ARKORDER_UNVALVED_RELEASE':
|
|
252
|
+
return 'Change ξ with proposeRelease then apply(ProposeResult). release() is only the first freeze. Never mechanical-safe.';
|
|
250
253
|
default:
|
|
251
254
|
if (typeof violation.ruleId === 'string' && violation.ruleId.startsWith('ARKRULE_')) {
|
|
252
255
|
return `Fix the ArkRule ${typeof violation.arkruleId === 'string' ? violation.arkruleId : violation.ruleId}, then preflight again.`;
|
|
@@ -520,6 +523,7 @@ export function enrichViolationWithFixClass(violation) {
|
|
|
520
523
|
case 'ARKORDER_INFORMATION_BUDGET':
|
|
521
524
|
case 'ARKORDER_XI_TTL':
|
|
522
525
|
case 'ARKORDER_STALE_SIGMA':
|
|
526
|
+
case 'ARKORDER_UNVALVED_RELEASE':
|
|
523
527
|
enriched.fixClass = 'arkorder-usage';
|
|
524
528
|
enriched.effort = 'medium';
|
|
525
529
|
enriched.enthusiastHint =
|
|
@@ -539,7 +543,9 @@ export function enrichViolationWithFixClass(violation) {
|
|
|
539
543
|
? 'TTL is σ, never ξ. A slow key that expires is not an order parameter.'
|
|
540
544
|
: violation.ruleId === 'ARKORDER_STALE_SIGMA'
|
|
541
545
|
? 'Refresh σ. ξ does not expire.'
|
|
542
|
-
:
|
|
546
|
+
: violation.ruleId === 'ARKORDER_UNVALVED_RELEASE'
|
|
547
|
+
? 'The pattern is frozen. proposeRelease then apply — do not call release() again with a different ξ.'
|
|
548
|
+
: 'Call createOrderPlane from arkgate/order in a listed plane root so the app actually freezes a pattern.';
|
|
543
549
|
break;
|
|
544
550
|
default:
|
|
545
551
|
enriched.fixClass = 'review-contract';
|
|
@@ -16,6 +16,10 @@ type ArkConfigLayer = {
|
|
|
16
16
|
patterns: string[];
|
|
17
17
|
exclude?: string[];
|
|
18
18
|
intentPrefixes?: string[];
|
|
19
|
+
/**
|
|
20
|
+
* App-context caption for this layer.
|
|
21
|
+
* Metadata — excluded from policy hash. Absence is silent.
|
|
22
|
+
*/
|
|
19
23
|
description?: string;
|
|
20
24
|
forbiddenGlobals?: string[];
|
|
21
25
|
/** ADR 0009 D2 — opt-in effect-capability walls; absence changes no verdict. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as CreateArchitectureProfileOptions, b as ArchitectureProfile, d as ArkCheckConfig, C as CreateArchitectureProfileFromArkConfigOptions, f as CreateElevenLayerArkConfigOptions, i as Policy, j as IntentCreator, I as IntentName } from './types-
|
|
2
|
-
import { A as ArkConfig, c as ArkConfigLoadResult } from './configTypes-
|
|
1
|
+
import { e as CreateArchitectureProfileOptions, b as ArchitectureProfile, d as ArkCheckConfig, C as CreateArchitectureProfileFromArkConfigOptions, f as CreateElevenLayerArkConfigOptions, i as Policy, j as IntentCreator, I as IntentName } from './types-BK47clMl.js';
|
|
2
|
+
import { A as ArkConfig, c as ArkConfigLoadResult } from './configTypes-0eHpocR3.js';
|
|
3
3
|
|
|
4
4
|
/** Versioned public result contract shared by every ArkGate enforcement adapter. */
|
|
5
5
|
/**
|
|
@@ -409,7 +409,7 @@ declare const ARK_ANALYSIS_RESULT_SCHEMA: {
|
|
|
409
409
|
};
|
|
410
410
|
|
|
411
411
|
/** ArkGate library version — single source of truth. */
|
|
412
|
-
declare const version = "4.8.
|
|
412
|
+
declare const version = "4.8.7";
|
|
413
413
|
|
|
414
414
|
/**
|
|
415
415
|
* AI Code Gate (basic).
|