kibi-cli 2.20.0 → 2.21.2
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/dist/cli-operation-metadata.d.ts +1 -1
- package/dist/cli-operation-metadata.js +1 -1
- package/dist/commands/doctor.js +13 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +15 -3
- package/dist/commands/legacy-storage-migration.d.ts.map +1 -1
- package/dist/commands/legacy-storage-migration.js +26 -1
- package/dist/commands/migrate.d.ts +2 -0
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +155 -11
- package/dist/commands/sync/discovery.d.ts.map +1 -1
- package/dist/commands/sync/discovery.js +14 -2
- package/dist/commands/sync/persistence.d.ts.map +1 -1
- package/dist/commands/sync/persistence.js +4 -0
- package/dist/decision-firmness.d.ts +39 -0
- package/dist/decision-firmness.d.ts.map +1 -0
- package/dist/decision-firmness.js +115 -0
- package/dist/extractors/markdown.d.ts +2 -0
- package/dist/extractors/markdown.d.ts.map +1 -1
- package/dist/extractors/markdown.js +16 -1
- package/dist/operations/migration/kb-sources.d.ts +5 -1
- package/dist/operations/migration/kb-sources.d.ts.map +1 -1
- package/dist/operations/migration/kb-sources.js +28 -1
- package/dist/operations/migration/schema6.d.ts +2 -0
- package/dist/operations/migration/schema6.d.ts.map +1 -1
- package/dist/operations/migration/schema6.js +44 -1
- package/dist/operations/migration/supersedes-reason.d.ts +26 -0
- package/dist/operations/migration/supersedes-reason.d.ts.map +1 -0
- package/dist/operations/migration/supersedes-reason.js +69 -0
- package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-applyplan.js +10 -2
- package/dist/operations/modeling/predicate-loader.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-loader.js +11 -0
- package/dist/operations/modeling/predicate-types.d.ts +32 -1
- package/dist/operations/modeling/predicate-types.d.ts.map +1 -1
- package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -1
- package/dist/operations/modeling/suggest-predicates.js +175 -35
- package/dist/operations/mutation/delete.d.ts +5 -1
- package/dist/operations/mutation/delete.d.ts.map +1 -1
- package/dist/operations/mutation/delete.js +223 -17
- package/dist/operations/mutation/serialization.d.ts.map +1 -1
- package/dist/operations/mutation/serialization.js +1 -0
- package/dist/operations/mutation/source-authoring.d.ts +8 -0
- package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
- package/dist/operations/mutation/source-authoring.js +33 -0
- package/dist/operations/mutation/types.d.ts +37 -0
- package/dist/operations/mutation/types.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.js +54 -2
- package/dist/operations/mutation/validation.d.ts.map +1 -1
- package/dist/operations/mutation/validation.js +2 -1
- package/dist/operations/planning/apply-plan.d.ts +6 -1
- package/dist/operations/planning/apply-plan.d.ts.map +1 -1
- package/dist/operations/planning/apply-plan.js +8 -2
- package/dist/operations/semantic-advisor/clauses.d.ts +9 -0
- package/dist/operations/semantic-advisor/clauses.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/clauses.js +24 -0
- package/dist/public/operations/catalog.d.ts +14 -5
- package/dist/public/operations/catalog.d.ts.map +1 -1
- package/dist/public/operations/check-executor.d.ts.map +1 -1
- package/dist/public/operations/check-executor.js +3 -0
- package/dist/public/operations/contracts.d.ts.map +1 -1
- package/dist/public/operations/contracts.js +29 -1
- package/dist/public/operations/decision-firmness.d.ts +34 -0
- package/dist/public/operations/decision-firmness.d.ts.map +1 -0
- package/dist/public/operations/decision-firmness.js +216 -0
- package/dist/public/operations/discovery-executors.d.ts.map +1 -1
- package/dist/public/operations/discovery-executors.js +16 -2
- package/dist/public/operations/migration-plan.d.ts.map +1 -1
- package/dist/public/operations/migration-plan.js +37 -7
- package/dist/public/operations/specs/check-rules.generated.d.ts +1 -1
- package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -1
- package/dist/public/operations/specs/check-rules.generated.js +5 -1
- package/dist/public/operations/specs/check.d.ts +1 -1
- package/dist/public/operations/specs/mutation-schemas.d.ts +7 -2
- package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
- package/dist/public/operations/specs/mutation-schemas.js +13 -17
- package/dist/public/operations/specs/mutation.d.ts +6 -2
- package/dist/public/operations/specs/mutation.d.ts.map +1 -1
- package/dist/public/operations/specs/mutation.js +6 -2
- package/dist/public/operations/specs/upsert.d.ts +7 -2
- package/dist/public/operations/specs/upsert.d.ts.map +1 -1
- package/dist/public/schemas/entity.d.ts.map +1 -1
- package/dist/public/schemas/entity.js +13 -13
- package/dist/public/skills/kibi-traceability/SKILL.md +6 -4
- package/dist/public/skills/kibi-usage/SKILL.md +52 -10
- package/dist/public/skills/kibi-usage/resources/fact-lanes.md +1 -1
- package/dist/public/skills/kibi-usage/resources/source-authoring.md +4 -2
- package/dist/public/skills/kibi-usage/resources/ui-requirements.md +2 -2
- package/dist/public/skills/kibi-usage/resources/workflows.md +1 -1
- package/dist/relationships/shards.d.ts +10 -0
- package/dist/relationships/shards.d.ts.map +1 -1
- package/dist/relationships/shards.js +27 -11
- package/dist/schemas/entity.schema.json +30 -25
- package/dist/search-answer.d.ts +31 -2
- package/dist/search-answer.d.ts.map +1 -1
- package/dist/search-answer.js +115 -17
- package/dist/types/entities.d.ts +4 -0
- package/dist/types/entities.d.ts.map +1 -1
- package/dist/utils/kb-manifest.d.ts +6 -0
- package/dist/utils/kb-manifest.d.ts.map +1 -1
- package/dist/utils/kb-manifest.js +6 -0
- package/dist/utils/rule-registry.generated.d.ts +21 -0
- package/dist/utils/rule-registry.generated.d.ts.map +1 -1
- package/dist/utils/rule-registry.generated.js +25 -0
- package/dist/utils/schema-version.d.ts +1 -1
- package/dist/utils/schema-version.d.ts.map +1 -1
- package/dist/utils/schema-version.js +3 -1
- package/package.json +2 -2
- package/schema/entities.pl +6 -0
- package/src/public/operations/check-executor.ts +6 -0
- package/src/public/operations/contracts.ts +33 -1
- package/src/public/operations/decision-firmness.ts +280 -0
- package/src/public/operations/discovery-executors.ts +17 -2
- package/src/public/operations/migration-plan.ts +41 -9
- package/src/public/operations/specs/check-rules.generated.ts +5 -1
- package/src/public/operations/specs/mutation-schemas.ts +14 -17
- package/src/public/operations/specs/mutation.ts +7 -2
- package/src/public/schemas/entity.ts +14 -13
- package/src/public/skills/kibi-traceability/SKILL.md +6 -4
- package/src/public/skills/kibi-usage/SKILL.md +52 -10
- package/src/public/skills/kibi-usage/resources/fact-lanes.md +1 -1
- package/src/public/skills/kibi-usage/resources/source-authoring.md +4 -2
- package/src/public/skills/kibi-usage/resources/ui-requirements.md +2 -2
- package/src/public/skills/kibi-usage/resources/workflows.md +1 -1
- package/src/schemas/entity.schema.json +30 -25
|
@@ -3,7 +3,7 @@ import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { InputError, OperationError } from "../../cli-errors.js";
|
|
5
5
|
import { parseEntityFromList, parseListOfLists, toPrologAtom, } from "../../prolog/codec.js";
|
|
6
|
-
import { listShards, readAllShards, readShard, removeRelationshipsFromShards, renderShardWithout, } from "../../relationships/shards.js";
|
|
6
|
+
import { listShards, planRelationshipShardRemovals, readAllShards, readShard, removeRelationshipsFromShards, renderShardWithout, } from "../../relationships/shards.js";
|
|
7
7
|
import { resolveBranchAttachment } from "../../utils/branch-resolver.js";
|
|
8
8
|
import { buildEntityDeleteAuditGoal } from "./audit.js";
|
|
9
9
|
import { planRecoveryNotes, settlePendingPlanApplyJournals, withPlanRecoveryNotes, } from "./plan-apply-journal.js";
|
|
@@ -48,9 +48,74 @@ function fileHash(pathname) {
|
|
|
48
48
|
return null;
|
|
49
49
|
return createHash("sha256").update(readFileSync(pathname)).digest("hex");
|
|
50
50
|
}
|
|
51
|
+
/** Effects a dry run or plan-only result leaves to a later call. */
|
|
52
|
+
const PLAN_ONLY_SKIPPED_EFFECTS = ["kb-write", "workspace-write"];
|
|
53
|
+
const DRY_RUN_FIELDS = {
|
|
54
|
+
dryRun: true,
|
|
55
|
+
outcome: "dry_run",
|
|
56
|
+
skippedEffects: PLAN_ONLY_SKIPPED_EFFECTS,
|
|
57
|
+
};
|
|
58
|
+
function sha256(text) {
|
|
59
|
+
return createHash("sha256").update(text).digest("hex");
|
|
60
|
+
}
|
|
61
|
+
// implements REQ-011
|
|
62
|
+
/**
|
|
63
|
+
* The relationship delete a preflight-clean call would perform: the shard and
|
|
64
|
+
* authored-source writes with their hashes and the compiled edges it would
|
|
65
|
+
* retract. Nothing is written and the compiled store is not touched.
|
|
66
|
+
*/
|
|
67
|
+
function relationshipDeleteDryRun(shardRoot, preflight, liveByKey, sourcePatches, workspaceRoot) {
|
|
68
|
+
const planned = planRelationshipShardRemovals(shardRoot, preflight);
|
|
69
|
+
const sourceWrites = [];
|
|
70
|
+
for (const [shardPath, body] of planned.bodies) {
|
|
71
|
+
const before = readFileSync(shardPath, "utf8");
|
|
72
|
+
if (before === body)
|
|
73
|
+
continue;
|
|
74
|
+
sourceWrites.push({
|
|
75
|
+
path: path.relative(workspaceRoot, shardPath).replaceAll("\\", "/"),
|
|
76
|
+
mode: "write",
|
|
77
|
+
beforeHash: sha256(before),
|
|
78
|
+
afterHash: sha256(body),
|
|
79
|
+
created: false,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
for (const [relative, patch] of sourcePatches) {
|
|
83
|
+
sourceWrites.push({
|
|
84
|
+
path: relative,
|
|
85
|
+
mode: "write",
|
|
86
|
+
beforeHash: sha256(patch.before),
|
|
87
|
+
afterHash: sha256(patch.after),
|
|
88
|
+
created: false,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
const compiledEdges = preflight.filter((selector) => liveByKey.get(`${selector.type}\0${selector.from}\0${selector.to}`) ===
|
|
92
|
+
true).length;
|
|
93
|
+
return {
|
|
94
|
+
deleted: 0,
|
|
95
|
+
relationships_deleted: 0,
|
|
96
|
+
skipped: 0,
|
|
97
|
+
errors: [],
|
|
98
|
+
error_codes: [],
|
|
99
|
+
relationship_results: preflight.map((selector, index) => ({
|
|
100
|
+
...selector,
|
|
101
|
+
deleted: false,
|
|
102
|
+
shard_records_removed: planned.removals[index]?.removed ?? false,
|
|
103
|
+
compiled_edge_retracted: liveByKey.get(`${selector.type}\0${selector.from}\0${selector.to}`) ===
|
|
104
|
+
true,
|
|
105
|
+
})),
|
|
106
|
+
wouldDelete: {
|
|
107
|
+
entities: 0,
|
|
108
|
+
relationships: preflight.length,
|
|
109
|
+
compiledEdges,
|
|
110
|
+
},
|
|
111
|
+
sync_required: planned.bodies.size > 0 || sourcePatches.size > 0,
|
|
112
|
+
sourceWrites,
|
|
113
|
+
...DRY_RUN_FIELDS,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
51
116
|
// implements REQ-011
|
|
52
117
|
// covered_by TEST-cli-source-relationship-parity-unit
|
|
53
|
-
async function executeRelationshipDeleteUnlocked(selectors, context, onCommitted = () => undefined) {
|
|
118
|
+
async function executeRelationshipDeleteUnlocked(selectors, context, onCommitted = () => undefined, options = {}) {
|
|
54
119
|
const prolog = requireProlog(context);
|
|
55
120
|
const allowed = new Set(RELATIONSHIP_TYPES);
|
|
56
121
|
const errors = [];
|
|
@@ -164,7 +229,11 @@ async function executeRelationshipDeleteUnlocked(selectors, context, onCommitted
|
|
|
164
229
|
errors,
|
|
165
230
|
error_codes: errorCodes,
|
|
166
231
|
relationship_results: [],
|
|
232
|
+
...(options.dryRun === true ? DRY_RUN_FIELDS : {}),
|
|
167
233
|
};
|
|
234
|
+
if (options.dryRun === true) {
|
|
235
|
+
return relationshipDeleteDryRun(shardRoot, preflight, liveByKey, sourcePatches, context.workspaceRoot);
|
|
236
|
+
}
|
|
168
237
|
// Keep byte-level before-images for rollback. Re-serializing parsed records
|
|
169
238
|
// would silently discard comments, ordering, and CST trivia from unrelated
|
|
170
239
|
// shard records after a later compiled-store failure.
|
|
@@ -314,9 +383,9 @@ async function executeRelationshipDeleteUnlocked(selectors, context, onCommitted
|
|
|
314
383
|
...(sourceWrites.length > 0 ? { sourceWrites } : {}),
|
|
315
384
|
};
|
|
316
385
|
}
|
|
317
|
-
export async function executeRelationshipDelete(selectors, context, onCommitted = () => undefined) {
|
|
386
|
+
export async function executeRelationshipDelete(selectors, context, onCommitted = () => undefined, options = {}) {
|
|
318
387
|
if (!context.fs || context.sourceMutationLockHeld === true)
|
|
319
|
-
return executeRelationshipDeleteUnlocked(selectors, context, onCommitted);
|
|
388
|
+
return executeRelationshipDeleteUnlocked(selectors, context, onCommitted, options);
|
|
320
389
|
const lock = await acquireWorkspaceMutationLock(context.workspaceRoot);
|
|
321
390
|
let operationFailure;
|
|
322
391
|
let committed = false;
|
|
@@ -324,8 +393,8 @@ export async function executeRelationshipDelete(selectors, context, onCommitted
|
|
|
324
393
|
const result = await executeRelationshipDeleteUnlocked(selectors, context, () => {
|
|
325
394
|
committed = true;
|
|
326
395
|
onCommitted();
|
|
327
|
-
});
|
|
328
|
-
committed = true;
|
|
396
|
+
}, options);
|
|
397
|
+
committed = options.dryRun !== true;
|
|
329
398
|
return result;
|
|
330
399
|
}
|
|
331
400
|
catch (error) {
|
|
@@ -337,6 +406,91 @@ export async function executeRelationshipDelete(selectors, context, onCommitted
|
|
|
337
406
|
releaseWorkspaceMutationLock(lock, operationFailure, committed);
|
|
338
407
|
}
|
|
339
408
|
}
|
|
409
|
+
// implements REQ-kibi-operation-interface-parity
|
|
410
|
+
/** The kb_apply_plan call that applies a returned deletion plan unmodified. */
|
|
411
|
+
function applyDeletionPlanNextAction(plan) {
|
|
412
|
+
return {
|
|
413
|
+
operation: "kb_apply_plan",
|
|
414
|
+
input: { plan, approvedPlanHash: plan.planHash },
|
|
415
|
+
reason: `Review deletionPlan, then apply it unmodified to delete ${plan.entityIds.join(", ")} (or call kb_delete again with the same ids and approvedPlanHash).`,
|
|
416
|
+
required: true,
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
// implements REQ-kibi-operation-interface-parity
|
|
420
|
+
/** Requirements evolve append-only: point at the supersession upsert. */
|
|
421
|
+
function supersessionNextAction(requirementIds) {
|
|
422
|
+
return {
|
|
423
|
+
operation: "kb_upsert",
|
|
424
|
+
input: {
|
|
425
|
+
type: "req",
|
|
426
|
+
id: "<REQ-replacement-id>",
|
|
427
|
+
relationships: requirementIds.map((id) => ({
|
|
428
|
+
type: "supersedes",
|
|
429
|
+
from: "<REQ-replacement-id>",
|
|
430
|
+
to: id,
|
|
431
|
+
})),
|
|
432
|
+
},
|
|
433
|
+
reason: `Authored requirements are not deleted. Upsert a replacement requirement linked with supersedes to ${requirementIds.join(", ")}, then upsert each superseded requirement with status closed.`,
|
|
434
|
+
required: true,
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
// implements REQ-kibi-operation-interface-parity
|
|
438
|
+
/**
|
|
439
|
+
* Apply a freshly computed authored-entity deletion plan in the same call
|
|
440
|
+
* when the caller approved its hash. The plan goes through kb_apply_plan's
|
|
441
|
+
* own validation, journal and recovery path; a stale or different approval
|
|
442
|
+
* fails before anything is written.
|
|
443
|
+
*/
|
|
444
|
+
async function applyApprovedDeletionPlan(plan, approvedPlanHash, planErrors, context, onCommitted, reported) {
|
|
445
|
+
if (approvedPlanHash.toLowerCase() !== plan.planHash) {
|
|
446
|
+
throw new InputError("DELETE_PLAN_HASH_MISMATCH", `kb_delete: approvedPlanHash ${approvedPlanHash.slice(0, 12)} does not match the current deletion plan ${plan.planHash.slice(0, 12)} for ${plan.entityIds.join(", ")}. The ids or their sources changed since that plan was returned. Call kb_delete without approvedPlanHash, review the new plan, and approve its planHash. Nothing was written.`);
|
|
447
|
+
}
|
|
448
|
+
if (plan.supersessionRequired) {
|
|
449
|
+
throw new InputError("REQUIREMENT_SUPERSESSION_REQUIRED", "kb_delete: authored requirements evolve through a new requirement linked with supersedes; a deletion plan that requires supersession cannot be approved. Nothing was written.");
|
|
450
|
+
}
|
|
451
|
+
if (planErrors.length > 0) {
|
|
452
|
+
throw new InputError("VALIDATION_FAILED", `kb_delete: approvedPlanHash applies a plan only when every requested id is in it. Remove or fix: ${planErrors.join("; ")} Nothing was written.`);
|
|
453
|
+
}
|
|
454
|
+
// apply-plan imports this module; load it lazily to keep the cycle out of
|
|
455
|
+
// module initialization.
|
|
456
|
+
const { executeApplyPlan } = await import("../planning/apply-plan.js");
|
|
457
|
+
const applied = await executeApplyPlan({ plan, approvedPlanHash: plan.planHash },
|
|
458
|
+
// executeDelete already holds the workspace lock (or runs without fs).
|
|
459
|
+
{ ...context, sourceMutationLockHeld: true }, onCommitted);
|
|
460
|
+
const result = applied.structuredContent;
|
|
461
|
+
const deleted = typeof result.deleted === "number" ? result.deleted : 0;
|
|
462
|
+
const repairs = result.status === "committed_with_repairs";
|
|
463
|
+
const payload = {
|
|
464
|
+
deleted,
|
|
465
|
+
skipped: plan.entityIds.length - deleted,
|
|
466
|
+
errors: [],
|
|
467
|
+
outcome: "plan_applied",
|
|
468
|
+
planHash: plan.planHash,
|
|
469
|
+
sourcePaths: Array.isArray(result.sourcePaths)
|
|
470
|
+
? result.sourcePaths
|
|
471
|
+
: [],
|
|
472
|
+
...(typeof result.recoveryJournalId === "string"
|
|
473
|
+
? { recoveryJournalId: result.recoveryJournalId }
|
|
474
|
+
: {}),
|
|
475
|
+
...(repairs
|
|
476
|
+
? {
|
|
477
|
+
status: "committed_with_repairs",
|
|
478
|
+
nextActions: Array.isArray(result.nextActions)
|
|
479
|
+
? result.nextActions
|
|
480
|
+
: [],
|
|
481
|
+
}
|
|
482
|
+
: {}),
|
|
483
|
+
};
|
|
484
|
+
return {
|
|
485
|
+
content: [
|
|
486
|
+
{
|
|
487
|
+
type: "text",
|
|
488
|
+
text: reported(`Applied deletion plan ${plan.planHash.slice(0, 12)}: deleted ${deleted} entities.${repairs ? " Compiled retraction needs repair; follow nextActions." : ""}`),
|
|
489
|
+
},
|
|
490
|
+
],
|
|
491
|
+
structuredContent: payload,
|
|
492
|
+
};
|
|
493
|
+
}
|
|
340
494
|
export async function executeDelete(input, context) {
|
|
341
495
|
const branchAttachment = context.branchAttachment ?? resolveBranchAttachment(context.workspaceRoot);
|
|
342
496
|
if ("error" in branchAttachment) {
|
|
@@ -362,19 +516,29 @@ export async function executeDelete(input, context) {
|
|
|
362
516
|
}
|
|
363
517
|
const ids = input.ids ?? [];
|
|
364
518
|
const relationships = input.relationships ?? [];
|
|
519
|
+
const dryRun = input.dryRun === true;
|
|
520
|
+
const approvedPlanHash = input.approvedPlanHash;
|
|
365
521
|
if ((ids.length === 0) === (relationships.length === 0))
|
|
366
522
|
throw new Error("Delete requires exactly one non-empty input: ids or relationships");
|
|
523
|
+
if (approvedPlanHash !== undefined) {
|
|
524
|
+
if (dryRun)
|
|
525
|
+
throw new InputError("VALIDATION_FAILED", "kb_delete: dryRun and approvedPlanHash cannot be combined. Omit approvedPlanHash to preview the deletion plan, or omit dryRun to apply it.");
|
|
526
|
+
if (relationships.length > 0)
|
|
527
|
+
throw new InputError("VALIDATION_FAILED", "kb_delete: approvedPlanHash applies only to an authored-entity deletion plan (ids). Relationship deletes apply directly; use dryRun:true to preview them.");
|
|
528
|
+
}
|
|
367
529
|
if (relationships.length > 0) {
|
|
368
530
|
if (relationships.some((value) => !isSelector(value)))
|
|
369
531
|
throw new Error("Each relationship selector requires non-empty type, from, and to strings");
|
|
370
532
|
const payload = await executeRelationshipDelete(relationships, { ...context, sourceMutationLockHeld: true }, () => {
|
|
371
533
|
committed = true;
|
|
372
|
-
});
|
|
534
|
+
}, { dryRun });
|
|
373
535
|
return {
|
|
374
536
|
content: [
|
|
375
537
|
{
|
|
376
538
|
type: "text",
|
|
377
|
-
text: reported(
|
|
539
|
+
text: reported(dryRun
|
|
540
|
+
? `Dry run: would delete ${payload.wouldDelete?.relationships ?? 0} relationships. Skipped ${payload.skipped}. Nothing was written.`
|
|
541
|
+
: `Deleted ${payload.relationships_deleted ?? 0} relationships. Skipped ${payload.skipped}.${payload.sync_required ? " Run kibi sync to reconcile the relationship shard." : ""}`),
|
|
378
542
|
},
|
|
379
543
|
],
|
|
380
544
|
structuredContent: payload,
|
|
@@ -383,6 +547,8 @@ export async function executeDelete(input, context) {
|
|
|
383
547
|
const errors = [];
|
|
384
548
|
const goals = [];
|
|
385
549
|
const authoredIds = [];
|
|
550
|
+
// Resolved ids that a direct delete would retract (non-authored source).
|
|
551
|
+
const directIds = [];
|
|
386
552
|
const authoredRequirementIds = [];
|
|
387
553
|
const sourceHashes = {};
|
|
388
554
|
// Keep the original body for rollback, while applying each deletion to the
|
|
@@ -451,6 +617,8 @@ export async function executeDelete(input, context) {
|
|
|
451
617
|
}
|
|
452
618
|
}
|
|
453
619
|
}
|
|
620
|
+
if (!sourceIsAuthored(source))
|
|
621
|
+
directIds.push(id);
|
|
454
622
|
goals.push(buildEntityDeleteAuditGoal(entity));
|
|
455
623
|
}
|
|
456
624
|
if (authoredIds.length > 0 && context.sourcePlanApplication !== true) {
|
|
@@ -496,23 +664,61 @@ export async function executeDelete(input, context) {
|
|
|
496
664
|
const planHash = createHash("sha256")
|
|
497
665
|
.update(JSON.stringify(planBody))
|
|
498
666
|
.digest("hex");
|
|
667
|
+
const deletionPlan = { ...planBody, planHash };
|
|
668
|
+
// A plan covers only authored ids; any other resolved id in the same
|
|
669
|
+
// call is left for a separate direct delete.
|
|
670
|
+
const planErrors = [
|
|
671
|
+
...errors,
|
|
672
|
+
...directIds.map((id) => `Entity ${id} was not deleted: this call returned an authored-entity deletion plan. Delete ${id} in a separate kb_delete call.`),
|
|
673
|
+
];
|
|
674
|
+
if (approvedPlanHash !== undefined) {
|
|
675
|
+
return await applyApprovedDeletionPlan(deletionPlan, approvedPlanHash, planErrors, { ...context, branchAttachment, prolog }, () => {
|
|
676
|
+
committed = true;
|
|
677
|
+
}, reported);
|
|
678
|
+
}
|
|
499
679
|
const payload = {
|
|
500
680
|
deleted: 0,
|
|
501
|
-
skipped: authoredIds.length,
|
|
502
|
-
errors:
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
681
|
+
skipped: authoredIds.length + planErrors.length,
|
|
682
|
+
errors: planErrors,
|
|
683
|
+
outcome: supersessionRequired
|
|
684
|
+
? "supersession_required"
|
|
685
|
+
: "plan_returned",
|
|
686
|
+
deletionPlan,
|
|
687
|
+
nextActions: supersessionRequired
|
|
688
|
+
? [supersessionNextAction(authoredRequirementIds)]
|
|
689
|
+
: [applyDeletionPlanNextAction(deletionPlan)],
|
|
508
690
|
// Only kb_apply_plan writes; this call returns the plan.
|
|
509
|
-
skippedEffects:
|
|
691
|
+
skippedEffects: PLAN_ONLY_SKIPPED_EFFECTS,
|
|
692
|
+
...(dryRun ? { dryRun: true } : {}),
|
|
693
|
+
};
|
|
694
|
+
return {
|
|
695
|
+
content: [
|
|
696
|
+
{
|
|
697
|
+
type: "text",
|
|
698
|
+
text: reported(supersessionRequired
|
|
699
|
+
? `Authored requirements ${authoredRequirementIds.join(", ")} cannot be deleted: supersede them with kb_upsert (supersedes) and close them instead. Nothing was written.`
|
|
700
|
+
: `Returned deletion plan ${planHash.slice(0, 12)} for ${authoredIds.join(", ")}. Nothing was written; apply it with kb_apply_plan (nextActions[0].input), or call kb_delete again with approvedPlanHash.`),
|
|
701
|
+
},
|
|
702
|
+
],
|
|
703
|
+
structuredContent: payload,
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
if (approvedPlanHash !== undefined &&
|
|
707
|
+
context.sourcePlanApplication !== true)
|
|
708
|
+
throw new InputError("VALIDATION_FAILED", `kb_delete: approvedPlanHash was given but ${ids.join(", ")} produced no authored-entity deletion plan to approve. Omit approvedPlanHash to delete these ids directly.`);
|
|
709
|
+
if (dryRun) {
|
|
710
|
+
const payload = {
|
|
711
|
+
deleted: 0,
|
|
712
|
+
skipped: errors.length,
|
|
713
|
+
errors,
|
|
714
|
+
wouldDelete: { entities: goals.length, ids: directIds },
|
|
715
|
+
...DRY_RUN_FIELDS,
|
|
510
716
|
};
|
|
511
717
|
return {
|
|
512
718
|
content: [
|
|
513
719
|
{
|
|
514
720
|
type: "text",
|
|
515
|
-
text: reported(`
|
|
721
|
+
text: reported(`Dry run: would delete ${goals.length} entities. Skipped ${errors.length}. Nothing was written.${errors.length > 0 ? ` Errors: ${errors.join("; ")}` : ""}`),
|
|
516
722
|
},
|
|
517
723
|
],
|
|
518
724
|
structuredContent: payload,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/serialization.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/serialization.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAyDpD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,MAAM,CAMR;AAGD,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,iBAAiB,GAAG,MAAM,CAOxE;AAGD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAkBtD"}
|
|
@@ -26,6 +26,14 @@ export declare function restoreFileTimes(absolutePath: string, times: FileTimes
|
|
|
26
26
|
* removed file makes every later sync fail on a missing pending source.
|
|
27
27
|
*/
|
|
28
28
|
export declare function retirePendingSourceReceipt(workspaceRoot: string, relativePath: string): void;
|
|
29
|
+
/**
|
|
30
|
+
* Rebind the pending receipt of an untracked source that a migration rewrote
|
|
31
|
+
* in place. A receipt pins the file to exact bytes; a rewrite that leaves the
|
|
32
|
+
* old hash behind makes every later sync refuse the file as "hash drift", so
|
|
33
|
+
* a migration republishes the receipt it finds, and leaves a file without
|
|
34
|
+
* one alone (tracked sources carry no receipt). Returns whether one existed.
|
|
35
|
+
*/
|
|
36
|
+
export declare function republishPendingSourceReceipt(workspaceRoot: string, relativePath: string, afterHash: string): boolean;
|
|
29
37
|
export declare function resolveContainedSourcePath(workspaceRoot: string, relative: string): string;
|
|
30
38
|
export declare function normalizeAuthoredSourcePath(workspaceRoot: string, source: string): string;
|
|
31
39
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-authoring.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/source-authoring.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAOjF,OAAO,KAAK,EAAqB,WAAW,EAAE,MAAM,YAAY,CAAC;AAEjE,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC,CAAC;AAmBH,wBAAgB,yBAAyB,CACvC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,GAChB,IAAI,CAiBN;AAED,KAAK,SAAS,GAAG,QAAQ,CAAC;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,IAAI,CAAA;CAAE,CAAC,CAAC;AAExD,8EAA8E;AAE9E,wBAAgB,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAOpE;AAED;;;;GAIG;AAEH,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,SAAS,GAAG,IAAI,GACtB,IAAI,CAON;AAeD;;;;GAIG;AAEH,wBAAgB,0BAA0B,CACxC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,GACnB,IAAI,CAMN;AAgBD,wBAAgB,0BAA0B,CACxC,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAA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AK,EAAE,WAAW,EAClB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,eAAe,EAAE,MAAM,GAAG,SAAS,EACnC,YAAY,EAAE,MAAM,GACnB,MAAM,CAsBR;AAED;;;;;;;GAOG;AAEH,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,GACf,OAAO,CAaT;AAED,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAC5C,OAAO,CAAC,EAAE,gBAAgB,EAC1B,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC;IACT,OAAO,EAAE,kBAAkB,CAAC;IAC5B,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/B,GAAG,IAAI,CAAC,CA+IR;AAED,uEAAuE;AACvE,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAC3C,MAAM,CAOR"}
|
|
@@ -82,6 +82,39 @@ export function retirePendingSourceReceipt(workspaceRoot, relativePath) {
|
|
|
82
82
|
throw error;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Rebind the pending receipt of an untracked source that a migration rewrote
|
|
87
|
+
* in place. A receipt pins the file to exact bytes; a rewrite that leaves the
|
|
88
|
+
* old hash behind makes every later sync refuse the file as "hash drift", so
|
|
89
|
+
* a migration republishes the receipt it finds, and leaves a file without
|
|
90
|
+
* one alone (tracked sources carry no receipt). Returns whether one existed.
|
|
91
|
+
*/
|
|
92
|
+
// implements REQ-cli-schema-migration, REQ-core-atomic-upsert-persistence
|
|
93
|
+
export function republishPendingSourceReceipt(workspaceRoot, relativePath, afterHash) {
|
|
94
|
+
const receiptPath = pendingReceiptPath(workspaceRoot, relativePath);
|
|
95
|
+
const raw = readPendingSourceReceiptBytes(receiptPath);
|
|
96
|
+
if (raw === null)
|
|
97
|
+
return false;
|
|
98
|
+
let receipt;
|
|
99
|
+
try {
|
|
100
|
+
const parsed = JSON.parse(raw);
|
|
101
|
+
receipt =
|
|
102
|
+
parsed !== null && typeof parsed === "object"
|
|
103
|
+
? parsed
|
|
104
|
+
: {};
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
receipt = {};
|
|
108
|
+
}
|
|
109
|
+
fs.writeFileSync(receiptPath, `${JSON.stringify({
|
|
110
|
+
version: 1,
|
|
111
|
+
...receipt,
|
|
112
|
+
path: relativePath,
|
|
113
|
+
afterHash,
|
|
114
|
+
rebasedAt: new Date().toISOString(),
|
|
115
|
+
}, null, 2)}\n`, { mode: 0o600 });
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
85
118
|
/**
|
|
86
119
|
* Authored YAML round-trips keep long scalars on one line, matching sync and
|
|
87
120
|
* coordinate refresh output, so editing one entry never refolds the others.
|
|
@@ -53,6 +53,12 @@ export type UpsertPayload = {
|
|
|
53
53
|
readonly relationships_created: number;
|
|
54
54
|
readonly warnings: readonly string[];
|
|
55
55
|
readonly semanticAdvisor: SemanticAdvisorReceipt;
|
|
56
|
+
/**
|
|
57
|
+
* For a fact that carries claim_text: the stored claim_key, derived from
|
|
58
|
+
* claim_text when the payload did not supply it, so the writer learns the
|
|
59
|
+
* grounding key without a kb_query.
|
|
60
|
+
*/
|
|
61
|
+
readonly claimKey?: string;
|
|
56
62
|
readonly status?: "committed_with_repairs";
|
|
57
63
|
readonly effectFailures?: readonly {
|
|
58
64
|
readonly kind: string;
|
|
@@ -119,8 +125,17 @@ export type DeleteInput = {
|
|
|
119
125
|
readonly to: string;
|
|
120
126
|
}[];
|
|
121
127
|
readonly _requestId?: string;
|
|
128
|
+
/** Applies the authored-entity deletion plan whose planHash this is. */
|
|
122
129
|
readonly approvedPlanHash?: string;
|
|
130
|
+
/** Preview the delete without writing sources or the compiled store. */
|
|
131
|
+
readonly dryRun?: boolean;
|
|
123
132
|
};
|
|
133
|
+
/**
|
|
134
|
+
* What a kb_delete call did when it was not a direct delete: returned an
|
|
135
|
+
* authored-entity deletion plan, refused a requirement that must be
|
|
136
|
+
* superseded, applied an approved plan, or previewed a dry run.
|
|
137
|
+
*/
|
|
138
|
+
export type DeleteOutcome = "plan_returned" | "supersession_required" | "plan_applied" | "dry_run";
|
|
124
139
|
export type DeletePayload = {
|
|
125
140
|
readonly deleted: number;
|
|
126
141
|
readonly relationships_deleted?: number;
|
|
@@ -131,6 +146,28 @@ export type DeletePayload = {
|
|
|
131
146
|
readonly sync_required?: boolean;
|
|
132
147
|
/** Declared effects this call did not perform, such as a plan-only result. */
|
|
133
148
|
readonly skippedEffects?: readonly string[];
|
|
149
|
+
/** Absent on a direct delete. */
|
|
150
|
+
readonly outcome?: DeleteOutcome;
|
|
151
|
+
readonly dryRun?: true;
|
|
152
|
+
/** Dry run only: what a commit would delete. */
|
|
153
|
+
readonly wouldDelete?: Readonly<{
|
|
154
|
+
readonly entities: number;
|
|
155
|
+
readonly ids?: readonly string[];
|
|
156
|
+
readonly relationships?: number;
|
|
157
|
+
readonly compiledEdges?: number;
|
|
158
|
+
}>;
|
|
159
|
+
/** Applied plan only: the plan hash and the source files it changed. */
|
|
160
|
+
readonly planHash?: string;
|
|
161
|
+
readonly sourcePaths?: readonly string[];
|
|
162
|
+
readonly recoveryJournalId?: string;
|
|
163
|
+
readonly status?: "committed_with_repairs";
|
|
164
|
+
readonly nextActions?: readonly Readonly<{
|
|
165
|
+
readonly operation: string;
|
|
166
|
+
readonly input: unknown;
|
|
167
|
+
readonly reason: string;
|
|
168
|
+
readonly required: boolean;
|
|
169
|
+
readonly detail?: string;
|
|
170
|
+
}>[];
|
|
134
171
|
readonly sourceWrites?: readonly {
|
|
135
172
|
readonly path: string;
|
|
136
173
|
readonly mode?: "write" | "delete";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAGrD,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAGlE,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACvD,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACtD,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAClB,iDAAiD;QACjD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QACvB,yEAAyE;QACzE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,8DAA8D;IAC9D,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACpD,QAAQ,CAAC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAC3C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAGF,wDAAwD;AACx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,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;YAClC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;SACxB,EAAE,CAAC;QACJ,QAAQ,CAAC,oBAAoB,EAAE,OAAO,CAAC;KACxC,CAAC;CACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upsert.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/upsert.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"upsert.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/upsert.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAUxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AA8BnF,OAAO,EACL,KAAK,kBAAkB,EAExB,MAAM,oBAAoB,CAAC;AAQ5B,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,eAAe,EAChB,MAAM,YAAY,CAAC;AA8DpB,wBAAgB,gCAAgC,CAC9C,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,GAChB,IAAI,CAkBN;AAwCD,wBAAsB,+BAA+B,CACnD,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,OAAO,EAAE,gBAAgB,EACzB,MAAM,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,IAAI,CAAC,CAqBf;AAED,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,aAAa,EAAE,SAAS,iBAAiB,EAAE,EAC3C,OAAO,EAAE,gBAAgB,EACzB,MAAM,CAAC,EAAE,iBAAiB,EAC1B,MA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path";
|
|
4
4
|
import { OperationError } from "../../cli-errors.js";
|
|
5
|
+
import { DEFAULT_FIRMNESS, carriesFirmness, firmnessRef, isFirmness, } from "../../decision-firmness.js";
|
|
5
6
|
import { readManifestWithCoordinateOverlay } from "../../extractors/manifest.js";
|
|
6
7
|
import { extractManifestSymbolRecords } from "../../extractors/manifest.js";
|
|
7
8
|
import { loadEntities } from "../../public/operations/discovery-entities.js";
|
|
@@ -47,6 +48,17 @@ function parseChangeKind(value) {
|
|
|
47
48
|
? normalized
|
|
48
49
|
: null;
|
|
49
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* The claim_key a written fact carries, derived from claim_text at
|
|
53
|
+
* validation when the payload did not supply it, echoed so the writer
|
|
54
|
+
* knows the grounding key without a kb_query.
|
|
55
|
+
*/
|
|
56
|
+
// implements REQ-upsert-committed-claim-key
|
|
57
|
+
function storedClaimKey(entity) {
|
|
58
|
+
return entity.type === "fact" && typeof entity.claim_key === "string"
|
|
59
|
+
? { claimKey: entity.claim_key }
|
|
60
|
+
: {};
|
|
61
|
+
}
|
|
50
62
|
function fileHash(pathname) {
|
|
51
63
|
if (!existsSync(pathname))
|
|
52
64
|
return null;
|
|
@@ -220,14 +232,52 @@ export async function validateUpsertForCommit(payload, context, options = {}) {
|
|
|
220
232
|
// The origin the write records is added last: none of the checks above
|
|
221
233
|
// reads it, and a rejected payload never pays for the stored-origin read.
|
|
222
234
|
const recorded = await resolveUpsertOrigin(input, prolog, context.clock(), staged, lookup);
|
|
235
|
+
const decided = await resolveUpsertFirmness(recorded, staged, lookup);
|
|
223
236
|
return {
|
|
224
|
-
validated:
|
|
237
|
+
validated: decided === input
|
|
225
238
|
? validated
|
|
226
|
-
: validateUpsertInput(
|
|
239
|
+
: validateUpsertInput(decided, context.clock()),
|
|
227
240
|
relationships,
|
|
228
241
|
semantic,
|
|
229
242
|
};
|
|
230
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* The firmness a requirement or ADR write records. An update that omits
|
|
246
|
+
* `firmness` keeps the stored value, so the compiled entity matches the
|
|
247
|
+
* authored front matter. A decision left firm must name the human words it
|
|
248
|
+
* rests on, so an agent cannot promote its own choice: it is judged as it
|
|
249
|
+
* will be written, with the origin this write records and the stored
|
|
250
|
+
* `approval_ref` when the write omits one. kb_check enforces the same rule on
|
|
251
|
+
* authored sources.
|
|
252
|
+
*/
|
|
253
|
+
// implements REQ-kb-decision-firmness
|
|
254
|
+
async function resolveUpsertFirmness(input, staged, lookup) {
|
|
255
|
+
if (!carriesFirmness(input.type))
|
|
256
|
+
return input;
|
|
257
|
+
const properties = input.properties;
|
|
258
|
+
if (properties.firmness !== undefined && properties.firmness !== "firm")
|
|
259
|
+
return input;
|
|
260
|
+
const stored = properties.firmness === undefined || properties.approval_ref === undefined
|
|
261
|
+
? (staged?.entities.get(input.id) ?? (await lookup.entity()) ?? undefined)
|
|
262
|
+
: undefined;
|
|
263
|
+
const firmness = properties.firmness ?? stored?.firmness;
|
|
264
|
+
if (!isFirmness(firmness) || firmness === DEFAULT_FIRMNESS)
|
|
265
|
+
return input;
|
|
266
|
+
if (firmness === "firm" &&
|
|
267
|
+
firmnessRef({
|
|
268
|
+
type: input.type,
|
|
269
|
+
origin: properties.origin,
|
|
270
|
+
approval_ref: properties.approval_ref ?? stored?.approval_ref,
|
|
271
|
+
}) === undefined) {
|
|
272
|
+
throw new Error(`Entity validation failed: firmness: firm needs origin.ref${input.type === "req" ? " (or approval_ref)" : ""} pointing at the human words that state the rule; use firmness: default for a delegated or agent choice`);
|
|
273
|
+
}
|
|
274
|
+
return properties.firmness === firmness
|
|
275
|
+
? input
|
|
276
|
+
: {
|
|
277
|
+
...input,
|
|
278
|
+
properties: { ...input.properties, firmness },
|
|
279
|
+
};
|
|
280
|
+
}
|
|
231
281
|
// implements REQ-kibi-operation-interface-parity
|
|
232
282
|
/**
|
|
233
283
|
* A dry run is the former kb_validate_upsert preflight on the kb_upsert
|
|
@@ -461,6 +511,7 @@ export async function executeUpsert(input, context, options = {}) {
|
|
|
461
511
|
relationships_created: validated.relationships.length,
|
|
462
512
|
warnings: [...planRecoveryWarnings, ...semantic.warnings],
|
|
463
513
|
semanticAdvisor: semantic.receipt,
|
|
514
|
+
...storedClaimKey(commitEntity ?? validated.entity),
|
|
464
515
|
deferredCommit,
|
|
465
516
|
...(sourceWrite ? { sourceWrites: [sourceWrite.receipt] } : {}),
|
|
466
517
|
},
|
|
@@ -540,6 +591,7 @@ export async function executeUpsert(input, context, options = {}) {
|
|
|
540
591
|
...shardWarnings,
|
|
541
592
|
],
|
|
542
593
|
semanticAdvisor: semantic.receipt,
|
|
594
|
+
...storedClaimKey(commitEntity ?? validated.entity),
|
|
543
595
|
...(shardWarnings.length > 0
|
|
544
596
|
? {
|
|
545
597
|
status: "committed_with_repairs",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/validation.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,0BAA0B,EAC3B,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/validation.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,0BAA0B,EAC3B,MAAM,oCAAoC,CAAC;AAU5C,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAqI/D,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,WAAW,EAClB,GAAG,EAAE,IAAI,GACR,eAAe,CA6DjB;AAED,OAAO,EAAE,0BAA0B,EAAE,CAAC"}
|
|
@@ -4,7 +4,7 @@ import entitySchema from "../../public/schemas/entity.js";
|
|
|
4
4
|
import relationshipSchema from "../../public/schemas/relationship.js";
|
|
5
5
|
// implements REQ-kibi-operation-interface-parity
|
|
6
6
|
import { SYMBOL_ROLES, isAllowedGranularityReason, } from "../../public/symbol-granularity.js";
|
|
7
|
-
import { semanticClaimKey } from "../semantic-advisor/clauses.js";
|
|
7
|
+
import { deriveFactClaimKey, semanticClaimKey, } from "../semantic-advisor/clauses.js";
|
|
8
8
|
import { factKindShapeHints, validateFactModelingShape, valueFieldHint, } from "./strict-fact.js";
|
|
9
9
|
const ajv = new Ajv({ strict: false });
|
|
10
10
|
const schema = entitySchema;
|
|
@@ -128,6 +128,7 @@ export function validateUpsertInput(input, now) {
|
|
|
128
128
|
if (!validateEntity(entity)) {
|
|
129
129
|
throw new Error(`Entity validation failed: ${formatEntityErrors(entity, validateEntity.errors ?? [])}`);
|
|
130
130
|
}
|
|
131
|
+
deriveFactClaimKey(entity);
|
|
131
132
|
validateSymbolSourceFile(entity);
|
|
132
133
|
validateProofExemptionPairing(entity);
|
|
133
134
|
if (entity.type === "test" && Array.isArray(entity.proof_receipts)) {
|
|
@@ -17,7 +17,12 @@ export declare function orderBootstrapActions(actions: readonly BootstrapAction[
|
|
|
17
17
|
* The apply itself repeats every check under the workspace lock.
|
|
18
18
|
*/
|
|
19
19
|
export declare function preflightApplyPlan(args: ApplyPlanArgs, context: OperationContext): Promise<void>;
|
|
20
|
-
export declare function executeApplyPlan(args: ApplyPlanArgs, context: OperationContext
|
|
20
|
+
export declare function executeApplyPlan(args: ApplyPlanArgs, context: OperationContext,
|
|
21
|
+
/**
|
|
22
|
+
* Called once the plan's commit is authoritative, for a caller that holds
|
|
23
|
+
* the workspace lock and must classify a later failure as committed.
|
|
24
|
+
*/
|
|
25
|
+
onCommitted?: () => void): Promise<{
|
|
21
26
|
content: Array<{
|
|
22
27
|
type: "text";
|
|
23
28
|
text: string;
|