kibi-cli 2.26.3 → 2.28.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/dist/cli-operation-metadata.d.ts +1 -1
- package/dist/cli-operation-metadata.js +1 -1
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +17 -2
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +2 -1
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +24 -0
- package/dist/commands/sync/persistence.d.ts +10 -0
- package/dist/commands/sync/persistence.d.ts.map +1 -1
- package/dist/commands/sync/persistence.js +24 -0
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +5 -1
- package/dist/diagnostics.d.ts +6 -0
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js +25 -9
- package/dist/intent-search.d.ts +2 -0
- package/dist/intent-search.d.ts.map +1 -1
- package/dist/intent-search.js +5 -0
- package/dist/operations/bootstrap/activation.d.ts +6 -0
- package/dist/operations/bootstrap/activation.d.ts.map +1 -1
- package/dist/operations/bootstrap/activation.js +22 -0
- package/dist/operations/bootstrap/claim-restatement.d.ts +2 -0
- package/dist/operations/bootstrap/claim-restatement.d.ts.map +1 -1
- package/dist/operations/bootstrap/conflict-review.d.ts +24 -0
- package/dist/operations/bootstrap/conflict-review.d.ts.map +1 -0
- package/dist/operations/bootstrap/conflict-review.js +92 -0
- package/dist/operations/bootstrap/generate.d.ts.map +1 -1
- package/dist/operations/bootstrap/generate.js +18 -5
- package/dist/operations/bootstrap/guidance-actions.d.ts.map +1 -1
- package/dist/operations/bootstrap/guidance-actions.js +4 -1
- package/dist/operations/bootstrap/intent-claims.d.ts.map +1 -1
- package/dist/operations/bootstrap/intent-claims.js +1 -0
- package/dist/operations/bootstrap/presentation.d.ts.map +1 -1
- package/dist/operations/bootstrap/presentation.js +6 -2
- package/dist/operations/bootstrap/types.d.ts +7 -0
- package/dist/operations/bootstrap/types.d.ts.map +1 -1
- package/dist/operations/migration/entity-type.d.ts +35 -0
- package/dist/operations/migration/entity-type.d.ts.map +1 -0
- package/dist/operations/migration/entity-type.js +89 -0
- package/dist/operations/migration/schema6.d.ts.map +1 -1
- package/dist/operations/migration/schema6.js +32 -0
- package/dist/operations/mutation/symbol-granularity.d.ts +7 -1
- package/dist/operations/mutation/symbol-granularity.d.ts.map +1 -1
- package/dist/operations/mutation/symbol-granularity.js +46 -8
- package/dist/operations/mutation/upsert.d.ts +9 -1
- package/dist/operations/mutation/upsert.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.js +46 -9
- package/dist/operations/mutation/validation.d.ts.map +1 -1
- package/dist/operations/mutation/validation.js +21 -0
- package/dist/operations/planning/compile-intent.d.ts +16 -0
- package/dist/operations/planning/compile-intent.d.ts.map +1 -1
- package/dist/operations/planning/compile-intent.js +118 -5
- package/dist/operations/planning/conflict-review.d.ts +69 -0
- package/dist/operations/planning/conflict-review.d.ts.map +1 -0
- package/dist/operations/planning/conflict-review.js +133 -0
- package/dist/operations/semantic-advisor/ingestion-boundary.d.ts +8 -0
- package/dist/operations/semantic-advisor/ingestion-boundary.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/ingestion-boundary.js +43 -2
- package/dist/public/impact/analyzer.d.ts.map +1 -1
- package/dist/public/impact/analyzer.js +26 -2
- package/dist/public/impact/requirement-statements.d.ts +29 -0
- package/dist/public/impact/requirement-statements.d.ts.map +1 -0
- package/dist/public/impact/requirement-statements.js +127 -0
- package/dist/public/operations/catalog.d.ts +26 -2
- package/dist/public/operations/catalog.d.ts.map +1 -1
- package/dist/public/operations/check-format-shared.d.ts +1 -1
- package/dist/public/operations/check-format-shared.d.ts.map +1 -1
- package/dist/public/operations/check-format-shared.js +19 -4
- package/dist/public/operations/discovery-executors.d.ts.map +1 -1
- package/dist/public/operations/discovery-executors.js +20 -13
- package/dist/public/operations/migration-plan.d.ts.map +1 -1
- package/dist/public/operations/migration-plan.js +14 -4
- package/dist/public/operations/result-envelope.d.ts +2 -0
- package/dist/public/operations/result-envelope.d.ts.map +1 -1
- package/dist/public/operations/result-envelope.js +21 -9
- package/dist/public/operations/specs/check.d.ts +1 -1
- package/dist/public/operations/specs/check.js +1 -1
- package/dist/public/operations/specs/planning.d.ts +25 -1
- package/dist/public/operations/specs/planning.d.ts.map +1 -1
- package/dist/public/operations/specs/planning.js +16 -1
- package/dist/public/skills/kibi-bootstrap/SKILL.md +2 -2
- package/dist/public/skills/kibi-usage/SKILL.md +11 -1
- package/dist/public/symbol-granularity.d.ts +5 -0
- package/dist/public/symbol-granularity.d.ts.map +1 -1
- package/dist/public/symbol-granularity.js +12 -3
- package/dist/traceability/staged-consistency.d.ts +1 -1
- package/dist/traceability/staged-consistency.d.ts.map +1 -1
- package/dist/traceability/staged-consistency.js +2 -2
- package/dist/traceability/staged-diagnostics.d.ts +1 -1
- package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
- package/dist/traceability/staged-entity-context.d.ts +18 -0
- package/dist/traceability/staged-entity-context.d.ts.map +1 -0
- package/dist/traceability/staged-entity-context.js +66 -0
- package/dist/utils/config.d.ts +8 -0
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +10 -0
- package/package.json +2 -2
- package/src/public/impact/analyzer.ts +38 -2
- package/src/public/impact/requirement-statements.ts +171 -0
- package/src/public/operations/check-format-shared.ts +27 -4
- package/src/public/operations/discovery-executors.ts +20 -13
- package/src/public/operations/migration-plan.ts +24 -6
- package/src/public/operations/result-envelope.ts +18 -4
- package/src/public/operations/specs/check.ts +1 -1
- package/src/public/operations/specs/planning.ts +17 -1
- package/src/public/skills/kibi-bootstrap/SKILL.md +2 -2
- package/src/public/skills/kibi-usage/SKILL.md +11 -1
- package/src/public/symbol-granularity.ts +13 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/generate.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/generate.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAkBjF,OAAO,KAAK,EAGV,SAAS,EACT,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAGpB,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,SAAS,gBAAgB,EAAE,EACpC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GACzC,SAAS,gBAAgB,EAAE,CAI7B;AA+BD,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EAC1C,OAAO,EAAE,MAAM,GACd;IACD,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAC1C,QAAQ,CAAC,UAAU,EAAE,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;IAClE,QAAQ,CAAC,iBAAiB,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACxD,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC,CAwJA;AA6ND,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,mBAAmB,CAAC,CAiJ9B"}
|
|
@@ -3,9 +3,11 @@ import path from "node:path";
|
|
|
3
3
|
import { loadCurrentRequirementTexts, loadEntityIds, } from "../../public/operations/discovery-entities.js";
|
|
4
4
|
import { executeStatus } from "../../public/operations/discovery-executors.js";
|
|
5
5
|
import { readWorkspaceSnapshot } from "../../public/operations/workspace-snapshot.js";
|
|
6
|
+
import { loadReviewRequirements } from "../planning/conflict-review.js";
|
|
6
7
|
import { stagedLogicalGroundingError, } from "../semantic-advisor/ingestion-boundary.js";
|
|
7
8
|
import { claimPlanActivation } from "./activation.js";
|
|
8
9
|
import { buildBootstrapCandidates, isProvenanceStubCandidate, } from "./candidates.js";
|
|
10
|
+
import { withConflictReviewSignals } from "./conflict-review.js";
|
|
9
11
|
import { discoverBootstrap } from "./discovery.js";
|
|
10
12
|
import { buildIntentClaimCandidates } from "./intent-claims.js";
|
|
11
13
|
import { normalizeBootstrapContext, presentBootstrap } from "./presentation.js";
|
|
@@ -250,7 +252,7 @@ const NO_EXISTING_KNOWLEDGE = {
|
|
|
250
252
|
* none (the CLI does so for status anyway); an unattached root never starts
|
|
251
253
|
* one.
|
|
252
254
|
*/
|
|
253
|
-
// implements REQ-bootstrap-intent-claim-accounting, REQ-bootstrap-claim-restatement
|
|
255
|
+
// implements REQ-bootstrap-intent-claim-accounting, REQ-bootstrap-claim-restatement, REQ-kibi-contradiction-review-candidates
|
|
254
256
|
async function existingKnowledge(context, attached, withRequirements) {
|
|
255
257
|
try {
|
|
256
258
|
const prolog = context.prolog ?? (attached ? await context.ensureProlog?.() : undefined);
|
|
@@ -259,9 +261,16 @@ async function existingKnowledge(context, attached, withRequirements) {
|
|
|
259
261
|
// Ids only: materializing every entity (receipt histories included)
|
|
260
262
|
// just to build this set exceeds the bounded engine output.
|
|
261
263
|
const ids = new Set((await loadEntityIds(prolog)).filter(Boolean));
|
|
262
|
-
const
|
|
264
|
+
const texts = withRequirements
|
|
263
265
|
? await loadCurrentRequirementTexts(prolog)
|
|
264
266
|
: [];
|
|
267
|
+
const logic = await loadReviewRequirements(prolog, texts.map((requirement) => requirement.id));
|
|
268
|
+
const requirements = texts.map((requirement) => ({
|
|
269
|
+
...requirement,
|
|
270
|
+
...(logic.has(requirement.id)
|
|
271
|
+
? { modeled: logic.get(requirement.id)?.modeled === true }
|
|
272
|
+
: {}),
|
|
273
|
+
}));
|
|
265
274
|
return { ids, requirements };
|
|
266
275
|
}
|
|
267
276
|
catch (error) {
|
|
@@ -343,7 +352,7 @@ async function expectedSnapshots(context, evidencePaths) {
|
|
|
343
352
|
};
|
|
344
353
|
}
|
|
345
354
|
}
|
|
346
|
-
// implements REQ-KIBI-BOOTSTRAP-PLAN, REQ-kibi-operation-interface-parity, REQ-bootstrap-discovered-candidate-budget
|
|
355
|
+
// implements REQ-KIBI-BOOTSTRAP-PLAN, REQ-kibi-operation-interface-parity, REQ-bootstrap-discovered-candidate-budget, REQ-kibi-contradiction-review-candidates
|
|
347
356
|
// implements REQ-KIBI-BOOTSTRAP-PLAN
|
|
348
357
|
export async function executePlanBootstrap(args, context) {
|
|
349
358
|
const declared = normalizeBootstrapContext(args.bootstrapContext);
|
|
@@ -392,8 +401,11 @@ export async function executePlanBootstrap(args, context) {
|
|
|
392
401
|
suppressed: activationSuppressedClaims(declared, discovery.activation),
|
|
393
402
|
diagnostics: [],
|
|
394
403
|
};
|
|
395
|
-
|
|
396
|
-
|
|
404
|
+
// Claims next to prose-only current requirements name them for review,
|
|
405
|
+
// planned or left for authoring: the plan cannot show they are consistent.
|
|
406
|
+
const reviewSignals = await withConflictReviewSignals(claimed.candidates, existing.requirements, context.workspaceRoot, claimed.sourceOnlySignals);
|
|
407
|
+
const filteredSignals = filterSourceOnlySignals([...built.sourceOnlySignals, ...reviewSignals.signals], args.entityTypes);
|
|
408
|
+
const selected = selectBootstrapCandidates([...built.candidates, ...reviewSignals.candidates].filter((candidate) => candidate.confidence >= minConfidence), existingIds, args.entityTypes, maxCandidates);
|
|
397
409
|
// Claims about the same subject share one subject fact.
|
|
398
410
|
const shared = shareSubjectFacts(selected.candidates);
|
|
399
411
|
const ignored = discovery.ignoredSources.map((sourcePath) => ({
|
|
@@ -441,6 +453,7 @@ export async function executePlanBootstrap(args, context) {
|
|
|
441
453
|
]
|
|
442
454
|
: []),
|
|
443
455
|
...claimed.diagnostics,
|
|
456
|
+
...reviewSignals.diagnostics,
|
|
444
457
|
...built.diagnostics,
|
|
445
458
|
...selected.diagnostics,
|
|
446
459
|
...shared.diagnostics,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guidance-actions.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/guidance-actions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"guidance-actions.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/guidance-actions.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EACV,gBAAgB,EAChB,wBAAwB,EACxB,SAAS,EACT,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAkBpB,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,gBAAgB,EAC5B,QAAQ,EAAE,wBAAwB,EAClC,UAAU,EAAE,SAAS,SAAS,EAAE,EAChC,OAAO,EAAE,SAAS,gBAAgB,EAAE,EACpC,MAAM,GAAE,SAAS,WAAW,EAAO,GAClC,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CA+F9C"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import { needsConflictReview } from "./conflict-review.js";
|
|
2
3
|
function relative(root, target) {
|
|
3
4
|
// Intent claims cite tickets and URLs, which are not workspace paths.
|
|
4
5
|
if (!path.isAbsolute(target))
|
|
@@ -77,11 +78,13 @@ export function buildActions(root, activation, declared, candidates, signals, of
|
|
|
77
78
|
kind: "handoff",
|
|
78
79
|
description: "No declared intent claim could be planned. Claims already in the KB need nothing; compile each remaining claim with kb_compile_intent, citing its source and reference (see the Knowledge source diagnostics).",
|
|
79
80
|
});
|
|
81
|
+
// implements REQ-bootstrap-authoring-claim-review
|
|
82
|
+
const toReview = signals.filter(needsConflictReview).length;
|
|
80
83
|
if (signals.length > 0)
|
|
81
84
|
result.push({
|
|
82
85
|
order: order++,
|
|
83
86
|
kind: "handoff",
|
|
84
|
-
description: `Author ${[...new Set(signals.map((signal) => signal.kind.toUpperCase()))].join("/")} entities manually from source-only evidence${seeded ? "; compile declared claims left there with kb_compile_intent" : ""}
|
|
87
|
+
description: `Author ${[...new Set(signals.map((signal) => signal.kind.toUpperCase()))].join("/")} entities manually from source-only evidence${seeded ? "; compile declared claims left there with kb_compile_intent" : ""}.${toReview > 0 ? ` ${toReview} intent claim(s) left for authoring need a conflict review: when you compile each with kb_compile_intent, compare it with the current requirements its conflict-review diagnostic names and report the verdicts through conflictReviews.` : ""}`,
|
|
85
88
|
});
|
|
86
89
|
for (const offer of offers)
|
|
87
90
|
result.push({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intent-claims.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/intent-claims.ts"],"names":[],"mappings":"AASA,OAAO,EACL,KAAK,mBAAmB,EAGzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,KAAK,kBAAkB,EAGxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,wBAAwB,EAGxB,SAAS,EACT,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAQpB,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAC1C,QAAQ,CAAC,iBAAiB,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACxD,QAAQ,CAAC,UAAU,EAAE,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;IAClE,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC,CAAC;AAuPF;;;;;;;;;GASG;AAEH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,wBAAwB,EAClC,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,aAAa,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,kBAAkB,EAChC,oBAAoB,GAAE,SAAS,mBAAmB,EAAO,GACxD,sBAAsB,
|
|
1
|
+
{"version":3,"file":"intent-claims.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/intent-claims.ts"],"names":[],"mappings":"AASA,OAAO,EACL,KAAK,mBAAmB,EAGzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,KAAK,kBAAkB,EAGxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,wBAAwB,EAGxB,SAAS,EACT,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAQpB,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAC1C,QAAQ,CAAC,iBAAiB,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACxD,QAAQ,CAAC,UAAU,EAAE,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;IAClE,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC,CAAC;AAuPF;;;;;;;;;GASG;AAEH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,wBAAwB,EAClC,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,aAAa,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,kBAAkB,EAChC,oBAAoB,GAAE,SAAS,mBAAmB,EAAO,GACxD,sBAAsB,CAgNxB"}
|
|
@@ -363,6 +363,7 @@ export function buildIntentClaimCandidates(declared, existingIds, minConfidence,
|
|
|
363
363
|
sourcePath: claim.reference,
|
|
364
364
|
confidence,
|
|
365
365
|
evidence,
|
|
366
|
+
claimStatement: claim.statement,
|
|
366
367
|
});
|
|
367
368
|
if (nearRestatement)
|
|
368
369
|
diagnostics.push(nearRestatementDiagnostic(source, claim, nearRestatement));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/presentation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"presentation.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/presentation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EACV,gBAAgB,EAGhB,gBAAgB,EAChB,wBAAwB,EAGxB,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AA6GpB,wBAAgB,yBAAyB,CACvC,KAAK,CAAC,EAAE,gBAAgB,GACvB,wBAAwB,CAe1B;AAgBD;;;GAGG;AAEH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,GACjD,SAAS;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,CAYhE;AAwID,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;IACtC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC5C,QAAQ,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;IAC/C,QAAQ,CAAC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IAC7C,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAC1C,QAAQ,CAAC,iBAAiB,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACxD,QAAQ,CAAC,oBAAoB,EAAE,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;IAC5E,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;IAC/C,QAAQ,CAAC,kBAAkB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChD,wEAAwE;IACxE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACjD,GAAG,mBAAmB,CAqOtB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isProvenanceStubCandidate } from "./candidates.js";
|
|
2
|
+
import { needsConflictReview } from "./conflict-review.js";
|
|
2
3
|
import { buildGuidance } from "./guidance.js";
|
|
3
4
|
import { INTENT_CLAIM_KINDS, KNOWLEDGE_SOURCE_AUTHORITIES, KNOWLEDGE_SOURCE_KINDS, bootstrapPlanHash, } from "./types.js";
|
|
4
5
|
function strings(values) {
|
|
@@ -175,7 +176,9 @@ function claimAccounting(declared, candidates, suppressed, signals) {
|
|
|
175
176
|
// A claim below minConfidence or invalid at write time also leaves a
|
|
176
177
|
// follow-up; it is already counted by its row.
|
|
177
178
|
const counted = new Set([...filteredRows, ...otherRows].map((row) => String(row.sourcePath)));
|
|
178
|
-
const
|
|
179
|
+
const sourceSignals = signals.filter((signal) => signal.evidence.some((line) => line.startsWith(`intent_claim:${source.id}:`)));
|
|
180
|
+
const sourceOnly = take(sourceSignals.filter((signal) => !counted.has(signal.sourcePath)).length);
|
|
181
|
+
const toReview = sourceSignals.filter(needsConflictReview).length;
|
|
179
182
|
return [
|
|
180
183
|
{
|
|
181
184
|
source,
|
|
@@ -186,6 +189,7 @@ function claimAccounting(declared, candidates, suppressed, signals) {
|
|
|
186
189
|
byActivation,
|
|
187
190
|
suppressed: suppressedCount,
|
|
188
191
|
sourceOnly,
|
|
192
|
+
toReview,
|
|
189
193
|
unattributed: rest,
|
|
190
194
|
},
|
|
191
195
|
];
|
|
@@ -206,7 +210,7 @@ function accountingLine(row, activation) {
|
|
|
206
210
|
: []),
|
|
207
211
|
...(row.sourceOnly > 0
|
|
208
212
|
? [
|
|
209
|
-
`${row.sourceOnly} need authoring (sourceOnlySignals; compile them with kb_compile_intent)`,
|
|
213
|
+
`${row.sourceOnly} need authoring (sourceOnlySignals; compile them with kb_compile_intent${row.toReview > 0 ? `; ${row.toReview} of them need a conflict review against the current requirements their conflict-review diagnostics name` : ""})`,
|
|
210
214
|
]
|
|
211
215
|
: []),
|
|
212
216
|
...(row.unattributed > 0
|
|
@@ -113,6 +113,11 @@ export type ActivationPolicy = {
|
|
|
113
113
|
readonly allowDeclaredClaims?: boolean;
|
|
114
114
|
readonly reason: string;
|
|
115
115
|
readonly handoffMessage?: string;
|
|
116
|
+
/**
|
|
117
|
+
* The command to run first when it is not the activation state's usual
|
|
118
|
+
* next step (a legacy KB is migrated, not initialized or repaired).
|
|
119
|
+
*/
|
|
120
|
+
readonly nextOperation?: string;
|
|
116
121
|
};
|
|
117
122
|
export type BootstrapEvidence = {
|
|
118
123
|
readonly provider: EvidenceProviderName;
|
|
@@ -208,6 +213,8 @@ export type SourceOnlySignal = {
|
|
|
208
213
|
readonly sourcePath: string;
|
|
209
214
|
readonly confidence: number;
|
|
210
215
|
readonly evidence: readonly string[];
|
|
216
|
+
/** The declared intent claim's statement, when the signal is one. */
|
|
217
|
+
readonly claimStatement?: string;
|
|
211
218
|
};
|
|
212
219
|
export type BootstrapStructuredContent = Readonly<Record<string, unknown>> & {
|
|
213
220
|
/** The exact hash-bound plan returned by this read-only operation. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAExE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,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AS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;IAClE,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;IAC7C,QAAQ,CAAC,oBAAoB,EAAE,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;IAC5E,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAC7B,eAAe,CAAC,0BAA0B,CAAC,GAAG;IAC5C,QAAQ,CAAC,iBAAiB,EAAE,0BAA0B,CAAC;CACxD,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entity files written before Kibi stated `type` in front matter take their
|
|
3
|
+
* type from the folder. Every Kibi write states it, so the first kb_upsert
|
|
4
|
+
* on such a file would add a `type:` line nobody asked for. `kibi migrate`
|
|
5
|
+
* states the folder-implied type instead, at any schema version, so that
|
|
6
|
+
* line lands in the migration commit.
|
|
7
|
+
*/
|
|
8
|
+
export declare const ENTITY_TYPE_BACKFILL_CODE = "entity_type_backfill";
|
|
9
|
+
export declare const ENTITY_TYPE_BACKFILL_ACTION_ID = "entity-type-backfill";
|
|
10
|
+
/** One authored entity file without `type` in its front matter. */
|
|
11
|
+
export type EntityTypeBackfillTarget = Readonly<{
|
|
12
|
+
id: string;
|
|
13
|
+
/** The folder-implied type, as kibi sync reads it. */
|
|
14
|
+
type: string;
|
|
15
|
+
path: string;
|
|
16
|
+
after: string;
|
|
17
|
+
}>;
|
|
18
|
+
export type EntityTypeBackfillSkip = Readonly<{
|
|
19
|
+
path: string;
|
|
20
|
+
reason: string;
|
|
21
|
+
}>;
|
|
22
|
+
export type EntityTypeBackfillPlan = Readonly<{
|
|
23
|
+
targets: readonly EntityTypeBackfillTarget[];
|
|
24
|
+
skipped: readonly EntityTypeBackfillSkip[];
|
|
25
|
+
}>;
|
|
26
|
+
/**
|
|
27
|
+
* Authored entity files whose front matter has no `type`, each with the
|
|
28
|
+
* document that states the folder-implied type as the last front matter key
|
|
29
|
+
* and changes no other byte. Files that do not parse are left to the checks
|
|
30
|
+
* that report them. Read-only.
|
|
31
|
+
*/
|
|
32
|
+
export declare function planEntityTypeBackfill(workspaceRoot: string): EntityTypeBackfillPlan;
|
|
33
|
+
/** State the folder-implied type on every authored entity file without one. */
|
|
34
|
+
export declare function applyEntityTypeBackfill(workspaceRoot: string): EntityTypeBackfillPlan;
|
|
35
|
+
//# sourceMappingURL=entity-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-type.d.ts","sourceRoot":"","sources":["../../../src/operations/migration/entity-type.ts"],"names":[],"mappings":"AA6BA;;;;;;GAMG;AAEH,eAAO,MAAM,yBAAyB,yBAAyB,CAAC;AAEhE,eAAO,MAAM,8BAA8B,yBAAyB,CAAC;AAErE,mEAAmE;AAEnE,MAAM,MAAM,wBAAwB,GAAG,QAAQ,CAAC;IAC9C,EAAE,EAAE,MAAM,CAAC;IACX,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC,CAAC;AAGH,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAGhF,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC;IAC5C,OAAO,EAAE,SAAS,wBAAwB,EAAE,CAAC;IAC7C,OAAO,EAAE,SAAS,sBAAsB,EAAE,CAAC;CAC5C,CAAC,CAAC;AAEH;;;;;GAKG;AAEH,wBAAgB,sBAAsB,CACpC,aAAa,EAAE,MAAM,GACpB,sBAAsB,CAsCxB;AAED,+EAA+E;AAE/E,wBAAgB,uBAAuB,CACrC,aAAa,EAAE,MAAM,GACpB,sBAAsB,CAKxB"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Kibi — repo-local, per-branch, queryable long-term memory for software projects
|
|
3
|
+
Copyright (C) 2026 Piotr Franczyk
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
(at your option) any later version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful,
|
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
GNU Affero General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
import path from "node:path";
|
|
19
|
+
import { load as loadYaml } from "js-yaml";
|
|
20
|
+
import { inferTypeFromPath } from "../../extractors/markdown.js";
|
|
21
|
+
import { listLaneMarkdownFiles, readText, sliceFrontmatter, withTopLevelField, writeFileAtomically, } from "./kb-sources.js";
|
|
22
|
+
/**
|
|
23
|
+
* Entity files written before Kibi stated `type` in front matter take their
|
|
24
|
+
* type from the folder. Every Kibi write states it, so the first kb_upsert
|
|
25
|
+
* on such a file would add a `type:` line nobody asked for. `kibi migrate`
|
|
26
|
+
* states the folder-implied type instead, at any schema version, so that
|
|
27
|
+
* line lands in the migration commit.
|
|
28
|
+
*/
|
|
29
|
+
// implements REQ-cli-migrate-entity-type-backfill
|
|
30
|
+
export const ENTITY_TYPE_BACKFILL_CODE = "entity_type_backfill";
|
|
31
|
+
// implements REQ-cli-migrate-entity-type-backfill
|
|
32
|
+
export const ENTITY_TYPE_BACKFILL_ACTION_ID = "entity-type-backfill";
|
|
33
|
+
/**
|
|
34
|
+
* Authored entity files whose front matter has no `type`, each with the
|
|
35
|
+
* document that states the folder-implied type as the last front matter key
|
|
36
|
+
* and changes no other byte. Files that do not parse are left to the checks
|
|
37
|
+
* that report them. Read-only.
|
|
38
|
+
*/
|
|
39
|
+
// implements REQ-cli-migrate-entity-type-backfill
|
|
40
|
+
export function planEntityTypeBackfill(workspaceRoot) {
|
|
41
|
+
const targets = [];
|
|
42
|
+
const skipped = [];
|
|
43
|
+
for (const file of listLaneMarkdownFiles(workspaceRoot)) {
|
|
44
|
+
const content = readText(file.absolutePath);
|
|
45
|
+
const slice = content === null ? null : sliceFrontmatter(content);
|
|
46
|
+
if (content === null || slice === null)
|
|
47
|
+
continue;
|
|
48
|
+
let data;
|
|
49
|
+
try {
|
|
50
|
+
data = loadYaml(slice.text);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (data === null || typeof data !== "object" || Array.isArray(data))
|
|
56
|
+
continue;
|
|
57
|
+
const record = data;
|
|
58
|
+
if (Object.hasOwn(record, "type"))
|
|
59
|
+
continue;
|
|
60
|
+
const type = inferTypeFromPath(file.absolutePath);
|
|
61
|
+
if (type === null)
|
|
62
|
+
continue;
|
|
63
|
+
const after = withTopLevelField(content, "type", type);
|
|
64
|
+
if (after === null) {
|
|
65
|
+
skipped.push({
|
|
66
|
+
path: file.relativePath,
|
|
67
|
+
reason: "type could not be added without changing other fields",
|
|
68
|
+
});
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
targets.push({
|
|
72
|
+
id: typeof record.id === "string" && record.id.trim() !== ""
|
|
73
|
+
? record.id.trim()
|
|
74
|
+
: path.basename(file.relativePath, ".md"),
|
|
75
|
+
type,
|
|
76
|
+
path: file.relativePath,
|
|
77
|
+
after,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return { targets, skipped };
|
|
81
|
+
}
|
|
82
|
+
/** State the folder-implied type on every authored entity file without one. */
|
|
83
|
+
// implements REQ-cli-migrate-entity-type-backfill
|
|
84
|
+
export function applyEntityTypeBackfill(workspaceRoot) {
|
|
85
|
+
const plan = planEntityTypeBackfill(workspaceRoot);
|
|
86
|
+
for (const target of plan.targets)
|
|
87
|
+
writeFileAtomically(path.join(workspaceRoot, target.path), target.after);
|
|
88
|
+
return plan;
|
|
89
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema6.d.ts","sourceRoot":"","sources":["../../../src/operations/migration/schema6.ts"],"names":[],"mappings":"AAwBA,OAAO,EACL,KAAK,eAAe,EAErB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAEL,kCAAkC,EAClC,wBAAwB,EACxB,mBAAmB,EAEnB,wBAAwB,EAOzB,MAAM,kDAAkD,CAAC;
|
|
1
|
+
{"version":3,"file":"schema6.d.ts","sourceRoot":"","sources":["../../../src/operations/migration/schema6.ts"],"names":[],"mappings":"AAwBA,OAAO,EACL,KAAK,eAAe,EAErB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAEL,kCAAkC,EAClC,wBAAwB,EACxB,mBAAmB,EAEnB,wBAAwB,EAOzB,MAAM,kDAAkD,CAAC;AAwE1D,gEAAgE;AAEhE,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,+EAA+E;AAE/E,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAE7C,4DAA4D;AAE5D,eAAO,MAAM,gCAAgC,IAAI,CAAC;AAElD,yEAAyE;AAEzE,eAAO,MAAM,gCAAgC,gCAAgC,CAAC;AAC9E,gEAAgE;AAEhE,eAAO,MAAM,8BAA8B,8BAA8B,CAAC;AAC1E;;;GAGG;AAEH,eAAO,MAAM,+CAA+C,+CACd,CAAC;AAC/C,iFAAiF;AAEjF,eAAO,MAAM,8BAA8B,8BAA8B,CAAC;AAC1E,+EAA+E;AAE/E,eAAO,MAAM,6BAA6B,6BAA6B,CAAC;AAExE,eAAO,MAAM,kCAAkC,6BAA6B,CAAC;AAC7E,yEAAyE;AAEzE,eAAO,MAAM,2BAA2B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E,MAAM,IAAI,CAAC;CACnB,CAAC,CAAC;AAEH,4DAA4D;AAE5D,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,IAAI,CAAC,CAkJf;AAED;;;GAGG;AAEH,eAAO,MAAM,+BAA+B,EAAE,WAAW,CAAC,MAAM,CAK9D,CAAC;AAGH,eAAO,MAAM,uBAAuB,EAAE,WAAW,CAAC,MAAM,CActD,CAAC"}
|
|
@@ -23,6 +23,7 @@ import { CLOSE_SUPERSEDED_REQUIREMENTS_ACTION_ID, CLOSE_SUPERSEDED_REQUIREMENTS_
|
|
|
23
23
|
import { readAllShards } from "../../relationships/shards.js";
|
|
24
24
|
import { KB_PATHS } from "../../utils/kb-paths.js";
|
|
25
25
|
import { CONTEXT_MISSING_TAG_CODE, SEMANTIC_TEXT_PIN_CODE, applyContextMissingTags, applySemanticTextPins, countByType, planContextMissingTags, planSemanticTextPins, } from "./entity-body-context.js";
|
|
26
|
+
import { ENTITY_TYPE_BACKFILL_ACTION_ID, ENTITY_TYPE_BACKFILL_CODE, applyEntityTypeBackfill, planEntityTypeBackfill, } from "./entity-type.js";
|
|
26
27
|
import { FIRM_SUPERSEDE_ACKNOWLEDGE_CODE, applyFirmSupersedeAcknowledgement, planFirmSupersedeAcknowledgement, } from "./firm-supersede.js";
|
|
27
28
|
import { applyInventoryRederivation, applyInventoryRederivationDroppingGrounding, planInventoryRederivation, } from "./inventory-rederive.js";
|
|
28
29
|
import { listLaneMarkdownFiles } from "./kb-sources.js";
|
|
@@ -435,6 +436,30 @@ export function buildSchema6MigrationFragment(input) {
|
|
|
435
436
|
},
|
|
436
437
|
}));
|
|
437
438
|
}
|
|
439
|
+
// Entity files that take their type from the folder get it stated at any
|
|
440
|
+
// schema version, so the first kb_upsert on one adds no type line.
|
|
441
|
+
const typeBackfill = planEntityTypeBackfill(input.workspaceRoot);
|
|
442
|
+
if (typeBackfill.targets.length > 0) {
|
|
443
|
+
sourceRewriteActionIds.push(ENTITY_TYPE_BACKFILL_ACTION_ID);
|
|
444
|
+
actions.push(migrationAction({
|
|
445
|
+
id: ENTITY_TYPE_BACKFILL_ACTION_ID,
|
|
446
|
+
code: ENTITY_TYPE_BACKFILL_CODE,
|
|
447
|
+
category: "schema",
|
|
448
|
+
safety: "automatic",
|
|
449
|
+
autoApplicable: true,
|
|
450
|
+
invocation: { kind: "cli", command_argv: ["kibi", "migrate", "--yes"] },
|
|
451
|
+
affectedEntityIds: typeBackfill.targets.map((row) => row.id),
|
|
452
|
+
affectedFiles: typeBackfill.targets.map((row) => row.path),
|
|
453
|
+
postconditions: [{ entitiesWithoutType: 0 }],
|
|
454
|
+
evidence: {
|
|
455
|
+
reason: "These entity files take their type from the folder. Every Kibi write states type in front matter, so the first kb_upsert on one would add a type line the change did not ask for. Each gets the folder-implied type as its last front matter key, the type kibi sync already reads.",
|
|
456
|
+
count: typeBackfill.targets.length,
|
|
457
|
+
byType: countByType(typeBackfill.targets),
|
|
458
|
+
skipped: typeBackfill.skipped,
|
|
459
|
+
preserves: "every other front matter key and the body bytes",
|
|
460
|
+
},
|
|
461
|
+
}));
|
|
462
|
+
}
|
|
438
463
|
// Schema 8: pin the checked meaning, then acknowledge missing context. A
|
|
439
464
|
// missing or invalid version upgrades through every step, so it is planned.
|
|
440
465
|
if (input.currentSchemaVersion === null ||
|
|
@@ -750,6 +775,12 @@ export async function applySchema6MigrationAction(action, context) {
|
|
|
750
775
|
applyPolarityValueBackfill(context.workspaceRoot);
|
|
751
776
|
return;
|
|
752
777
|
}
|
|
778
|
+
case ENTITY_TYPE_BACKFILL_CODE: {
|
|
779
|
+
const result = applyEntityTypeBackfill(context.workspaceRoot);
|
|
780
|
+
if (result.skipped.length > 0)
|
|
781
|
+
throw new Error(`Could not state the type of ${result.skipped.map((skip) => `${skip.path} (${skip.reason})`).join(", ")}; add the type line by hand.`);
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
753
784
|
case SEMANTIC_TEXT_PIN_CODE: {
|
|
754
785
|
applySemanticTextPins(context.workspaceRoot);
|
|
755
786
|
return;
|
|
@@ -854,6 +885,7 @@ export const SCHEMA6_APPROVABLE_REVIEW_CODES = new Set([
|
|
|
854
885
|
// implements REQ-kibi-schema6-migration, REQ-cli-schema-migration
|
|
855
886
|
export const SCHEMA6_AUTOMATIC_CODES = new Set([
|
|
856
887
|
POLARITY_VALUE_BACKFILL_CODE,
|
|
888
|
+
ENTITY_TYPE_BACKFILL_CODE,
|
|
857
889
|
SEMANTIC_TEXT_PIN_CODE,
|
|
858
890
|
CONTEXT_MISSING_TAG_CODE,
|
|
859
891
|
SUPERSEDES_REASON_ACKNOWLEDGE_CODE,
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { OperationContext } from "../../public/operations/runtime-types.js";
|
|
2
2
|
import type { RelationshipInput } from "./types.js";
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* The error code of an upsert refused for a coarse symbol link, so the MCP
|
|
5
|
+
* error envelope and the CLI JSON route carry the same code as the staged
|
|
6
|
+
* gate's symbol_granularity_violation.
|
|
7
|
+
*/
|
|
8
|
+
export declare const SYMBOL_GRANULARITY_VIOLATION = "SYMBOL_GRANULARITY_VIOLATION";
|
|
9
|
+
export declare function validateSymbolGranularity(payload: Readonly<Record<string, unknown>>, relationships: readonly RelationshipInput[], context: OperationContext, stored?: () => Promise<Readonly<Record<string, unknown>> | null | undefined>): Promise<void>;
|
|
4
10
|
//# sourceMappingURL=symbol-granularity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbol-granularity.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/symbol-granularity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"symbol-granularity.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/symbol-granularity.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAYjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AA0BpD;;;;GAIG;AAEH,eAAO,MAAM,4BAA4B,iCAAiC,CAAC;AA+B3E,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAC1C,aAAa,EAAE,SAAS,iBAAiB,EAAE,EAC3C,OAAO,EAAE,gBAAgB,EACzB,MAAM,CAAC,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,GAC3E,OAAO,CAAC,IAAI,CAAC,CAiDf"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { collectGranularityCandidates } from "kibi-plugin-builtin";
|
|
3
|
-
import {
|
|
3
|
+
import { InputError } from "../../cli-errors.js";
|
|
4
|
+
import { ALLOWED_GRANULARITY_REASONS_PROSE, coarseLinkBehavioralNames, getBehavioralSymbolNames, getNonBehavioralSymbolNames, inferSymbolRole, isAllowedGranularityReason, isTraceabilityRelationshipType, } from "../../public/symbol-granularity.js";
|
|
4
5
|
function candidate(name, kind) {
|
|
5
6
|
return { name, kind, role: inferSymbolRole(kind) };
|
|
6
7
|
}
|
|
@@ -19,12 +20,45 @@ function summarized(names) {
|
|
|
19
20
|
const hidden = names.length - shown.length;
|
|
20
21
|
return `${shown.join(", ")}${hidden > 0 ? `, and ${hidden} more` : ""}`;
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
/**
|
|
24
|
+
* The error code of an upsert refused for a coarse symbol link, so the MCP
|
|
25
|
+
* error envelope and the CLI JSON route carry the same code as the staged
|
|
26
|
+
* gate's symbol_granularity_violation.
|
|
27
|
+
*/
|
|
28
|
+
// implements REQ-kibi-symbol-link-guidance
|
|
29
|
+
export const SYMBOL_GRANULARITY_VIOLATION = "SYMBOL_GRANULARITY_VIOLATION";
|
|
30
|
+
const STORED_LOCATION_FIELDS = [
|
|
31
|
+
"title",
|
|
32
|
+
"sourceFile",
|
|
33
|
+
"symbol_role",
|
|
34
|
+
"granularity_reason",
|
|
35
|
+
];
|
|
36
|
+
// implements REQ-kibi-symbol-link-guidance
|
|
37
|
+
/**
|
|
38
|
+
* The symbol a granularity check judges when an upsert updates a stored
|
|
39
|
+
* symbol: a payload that only adds links (title and relationships, no
|
|
40
|
+
* sourceFile) still links the stored symbol's file, so the fields the check
|
|
41
|
+
* reads fall back to the stored entity. Fields the payload sets win.
|
|
42
|
+
*/
|
|
43
|
+
function withStoredSymbolLocation(entity, stored) {
|
|
44
|
+
if (entity.type !== "symbol" || stored === null || stored === undefined)
|
|
45
|
+
return entity;
|
|
46
|
+
const merged = { ...entity };
|
|
47
|
+
for (const field of STORED_LOCATION_FIELDS) {
|
|
48
|
+
if (merged[field] === undefined && stored[field] !== undefined)
|
|
49
|
+
merged[field] = stored[field];
|
|
50
|
+
}
|
|
51
|
+
return merged;
|
|
52
|
+
}
|
|
53
|
+
// implements REQ-kibi-operation-interface-parity, REQ-kibi-symbol-link-guidance
|
|
54
|
+
export async function validateSymbolGranularity(payload, relationships, context, stored) {
|
|
55
|
+
if (payload.type !== "symbol")
|
|
25
56
|
return;
|
|
26
57
|
if (!relationships.some((relationship) => isTraceabilityRelationshipType(relationship.type)))
|
|
27
58
|
return;
|
|
59
|
+
const entity = stored === undefined
|
|
60
|
+
? payload
|
|
61
|
+
: withStoredSymbolLocation(payload, await stored());
|
|
28
62
|
if (isAllowedGranularityReason(entity.granularity_reason))
|
|
29
63
|
return;
|
|
30
64
|
if (typeof entity.sourceFile !== "string" || typeof entity.title !== "string")
|
|
@@ -49,14 +83,18 @@ export async function validateSymbolGranularity(entity, relationships, context)
|
|
|
49
83
|
}
|
|
50
84
|
const available = candidates(entity.sourceFile, content);
|
|
51
85
|
const exact = available.find(({ name }) => name === entity.title);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
86
|
+
// A declaration named like the symbol is coarse only through its own
|
|
87
|
+
// behavioral members (a class and its public methods), the same test the
|
|
88
|
+
// staged gate and `kibi check` apply; any other title is judged against
|
|
89
|
+
// every behavioral declaration in the file.
|
|
90
|
+
const behavioral = exact && (exact.kind !== "variable" || entity.symbol_role === "config")
|
|
91
|
+
? coarseLinkBehavioralNames(entity.title, available)
|
|
92
|
+
: getBehavioralSymbolNames(available);
|
|
55
93
|
if (behavioral.length === 0)
|
|
56
94
|
return;
|
|
57
95
|
const nonBehavioral = getNonBehavioralSymbolNames(available);
|
|
58
96
|
const ignored = nonBehavioral.length > 0
|
|
59
97
|
? ` Non-behavioral symbols in the file were ignored for this decision: ${summarized(nonBehavioral)}.`
|
|
60
98
|
: "";
|
|
61
|
-
throw new
|
|
99
|
+
throw new InputError(SYMBOL_GRANULARITY_VIOLATION, `Symbol ${String(entity.id)} links ${entity.sourceFile} coarsely while granular symbols are available (behavioral only): ${summarized(behavioral)}. Move relationships to a behavioral symbol, add a manifest behavioral anchor, or set granularity_reason to ${ALLOWED_GRANULARITY_REASONS_PROSE}.${ignored}`);
|
|
62
100
|
}
|
|
@@ -5,7 +5,15 @@ import { type StoredEntityLookup } from "./stored-entity.js";
|
|
|
5
5
|
import type { RelationshipInput, StagedUpsertState, UpsertInput, UpsertPayload, ValidatedUpsert } from "./types.js";
|
|
6
6
|
import { type UncompiledAuthoredSource } from "./uncompiled-source.js";
|
|
7
7
|
export declare function assertRelationshipShardContained(workspaceRoot: string, shardPath: string): void;
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Check a test write against the stored proof receipt history, which is
|
|
10
|
+
* append-only. An update that omits `proof_receipts` keeps the stored history
|
|
11
|
+
* (an update keeps every property it leaves out): the stored receipts are
|
|
12
|
+
* returned for the write to carry, with the verification scope and
|
|
13
|
+
* perspective they were recorded against. Undefined when there is nothing to
|
|
14
|
+
* carry.
|
|
15
|
+
*/
|
|
16
|
+
export declare function validateAppendOnlyProofReceipts(entity: Readonly<Record<string, unknown>>, context: OperationContext, staged?: StagedUpsertState): Promise<Readonly<Record<string, unknown>> | undefined>;
|
|
9
17
|
export declare function effectiveRelationships(input: UpsertInput, entity: Readonly<Record<string, unknown>>, relationships: readonly RelationshipInput[], context: OperationContext, staged?: StagedUpsertState, lookup?: StoredEntityLookup): Promise<readonly RelationshipInput[]>;
|
|
10
18
|
export type UpsertValidationOptions = Readonly<{
|
|
11
19
|
/** Skip the append-only receipt check (kibi proof prune only). */
|
|
@@ -1 +1 @@
|
|
|
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;AAexE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AA6B3E,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;AACpB,OAAO,EACL,KAAK,wBAAwB,EAI9B,MAAM,wBAAwB,CAAC;AAsEhC,wBAAgB,gCAAgC,CAC9C,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,GAChB,IAAI,CAkBN;
|
|
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;AAexE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AA6B3E,OAAO,EACL,KAAK,kBAAkB,E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