kibi-cli 2.26.3 → 2.27.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/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 +16 -0
- package/dist/operations/bootstrap/conflict-review.d.ts.map +1 -0
- package/dist/operations/bootstrap/conflict-review.js +59 -0
- package/dist/operations/bootstrap/generate.d.ts.map +1 -1
- package/dist/operations/bootstrap/generate.js +17 -4
- package/dist/operations/bootstrap/types.d.ts +5 -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 +1 -1
- package/dist/operations/mutation/symbol-granularity.d.ts.map +1 -1
- package/dist/operations/mutation/symbol-granularity.js +37 -7
- 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 +43 -7
- 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 +7 -2
- 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/traceability/staged-diagnostics.d.ts +1 -1
- package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
- 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 +12 -4
- 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
|
@@ -12,6 +12,7 @@ import { validateUpsertInput } from "../mutation/validation.js";
|
|
|
12
12
|
import { isBlockingWitness, parseWhatIfAnalysis, } from "../mutation/what-if.js";
|
|
13
13
|
import { analyzeSemanticAdvisorInputWithPlugins } from "../semantic-advisor/plugin-orchestration.js";
|
|
14
14
|
import { canonicalize } from "../semantic-advisor/shared.js";
|
|
15
|
+
import { MAX_REVIEW_CANDIDATES, REVIEW_CANDIDATE_MIN_SCORE, loadReviewRequirements, reviewCandidate, reviewNextAction, } from "./conflict-review.js";
|
|
15
16
|
// implements REQ-kibi-change-to-proof-plan-compiler-v2
|
|
16
17
|
export const COMPILE_PLAN_VERSION = "kibi.compile-plan.v1";
|
|
17
18
|
export { isBlockingWitness, parseWhatIfAnalysis } from "../mutation/what-if.js";
|
|
@@ -358,6 +359,7 @@ async function contradictionAnalysis(prolog, requirementId, steps, now) {
|
|
|
358
359
|
introduced: [],
|
|
359
360
|
removed: [],
|
|
360
361
|
unchanged: [],
|
|
362
|
+
reasons: [{ reason: "analysis_unavailable", ids: [] }],
|
|
361
363
|
};
|
|
362
364
|
let goal;
|
|
363
365
|
try {
|
|
@@ -389,6 +391,108 @@ async function contradictionAnalysis(prolog, requirementId, steps, now) {
|
|
|
389
391
|
unchanged: analysis.unchanged,
|
|
390
392
|
};
|
|
391
393
|
}
|
|
394
|
+
// implements REQ-kibi-contradiction-review-candidates
|
|
395
|
+
// No witness is not the same as no conflict: the checker compares only what
|
|
396
|
+
// has a logical model. When a target proposition is unmodeled, or a related
|
|
397
|
+
// current requirement from discovery has no logic of its own, the outcome
|
|
398
|
+
// stays unresolved with the reason, and the related requirements become
|
|
399
|
+
// review candidates the agent compares and judges. The verdicts come back
|
|
400
|
+
// through conflictReviews: a conflict blocks the plan, a no_conflict clears
|
|
401
|
+
// that candidate. A pending review leaves a ready plan ready; the outcome and
|
|
402
|
+
// nextAction say what was not checked.
|
|
403
|
+
async function withConflictReview(prolog, analysis, input) {
|
|
404
|
+
const diagnostics = [];
|
|
405
|
+
const decisions = new Map();
|
|
406
|
+
for (const decision of input.decisions) {
|
|
407
|
+
const id = text(decision.requirementId);
|
|
408
|
+
if (id)
|
|
409
|
+
decisions.set(id, decision);
|
|
410
|
+
}
|
|
411
|
+
const unmodeledClaims = input.propositions
|
|
412
|
+
.filter((proposition) => proposition.status === "ontology_gap" ||
|
|
413
|
+
proposition.status === "ambiguous")
|
|
414
|
+
.map((proposition) => proposition.claimKey);
|
|
415
|
+
// Matches arrive best first, so the first score seen is the highest.
|
|
416
|
+
const scores = new Map();
|
|
417
|
+
for (const match of input.matches) {
|
|
418
|
+
const id = text(match.entity.id);
|
|
419
|
+
if (text(match.entity.type) !== "req" ||
|
|
420
|
+
!id ||
|
|
421
|
+
id === input.requirementId ||
|
|
422
|
+
match.score < REVIEW_CANDIDATE_MIN_SCORE ||
|
|
423
|
+
scores.has(id))
|
|
424
|
+
continue;
|
|
425
|
+
scores.set(id, match.score);
|
|
426
|
+
}
|
|
427
|
+
const requirements = await loadReviewRequirements(prolog, [
|
|
428
|
+
...scores.keys(),
|
|
429
|
+
...[...decisions.keys()].filter((id) => id !== input.requirementId),
|
|
430
|
+
]);
|
|
431
|
+
for (const id of decisions.keys()) {
|
|
432
|
+
if (id === input.requirementId || !requirements.has(id))
|
|
433
|
+
diagnostics.push(`conflictReviews names ${id}, which is not a current requirement other than the target; its verdict was ignored.`);
|
|
434
|
+
}
|
|
435
|
+
const candidates = [];
|
|
436
|
+
let pendingCount = 0;
|
|
437
|
+
for (const [id, score] of scores) {
|
|
438
|
+
const requirement = requirements.get(id);
|
|
439
|
+
if (!requirement)
|
|
440
|
+
continue;
|
|
441
|
+
const decision = decisions.get(id);
|
|
442
|
+
if (!decision) {
|
|
443
|
+
// A modeled target is compared logically with every modeled
|
|
444
|
+
// requirement; only prose-only ones need the agent. An unmodeled
|
|
445
|
+
// target cannot be compared with anything.
|
|
446
|
+
if (unmodeledClaims.length === 0 && requirement.modeled)
|
|
447
|
+
continue;
|
|
448
|
+
if (pendingCount >= MAX_REVIEW_CANDIDATES)
|
|
449
|
+
continue;
|
|
450
|
+
pendingCount += 1;
|
|
451
|
+
}
|
|
452
|
+
candidates.push(reviewCandidate(input.intent, requirement, score, decision));
|
|
453
|
+
}
|
|
454
|
+
// A verdict on a requirement discovery did not rank still counts: the
|
|
455
|
+
// agent may know a conflict the search missed.
|
|
456
|
+
for (const [id, decision] of decisions) {
|
|
457
|
+
const requirement = requirements.get(id);
|
|
458
|
+
if (!requirement || scores.has(id) || id === input.requirementId)
|
|
459
|
+
continue;
|
|
460
|
+
candidates.push(reviewCandidate(input.intent, requirement, 0, decision));
|
|
461
|
+
}
|
|
462
|
+
const pending = candidates.filter((candidate) => candidate.review === "pending");
|
|
463
|
+
const declaredConflicts = candidates.filter((candidate) => candidate.review === "conflict");
|
|
464
|
+
const reasons = [...(analysis.reasons ?? [])];
|
|
465
|
+
if (unmodeledClaims.length > 0)
|
|
466
|
+
reasons.push({ reason: "unmodeled_target", ids: unmodeledClaims });
|
|
467
|
+
const pendingUnmodeled = pending.filter((candidate) => !candidate.modeled);
|
|
468
|
+
if (unmodeledClaims.length === 0 && pendingUnmodeled.length > 0)
|
|
469
|
+
reasons.push({
|
|
470
|
+
reason: "unmodeled_related",
|
|
471
|
+
ids: pendingUnmodeled.map((candidate) => candidate.requirementId),
|
|
472
|
+
});
|
|
473
|
+
const outcome = analysis.outcome === "conflict" || declaredConflicts.length > 0
|
|
474
|
+
? "conflict"
|
|
475
|
+
: analysis.outcome === "unresolved" || reasons.length > 0
|
|
476
|
+
? "unresolved"
|
|
477
|
+
: "no_conflict";
|
|
478
|
+
if (declaredConflicts.length > 0)
|
|
479
|
+
diagnostics.push(`By your review the intent contradicts current requirement ${declaredConflicts.map((candidate) => candidate.requirementId).join(", ")}: ask the human which rule holds, then supersede or change the conflicting requirement, or change the intent, before applying this plan.`);
|
|
480
|
+
if (pending.length > 0)
|
|
481
|
+
diagnostics.push(`Contradiction check incomplete: Kibi could not compare this intent logically with current requirement ${pending.map((candidate) => candidate.requirementId).join(", ")}. Compare them (contradictionAnalysis.reviewCandidates) and send your verdicts in conflictReviews.`);
|
|
482
|
+
const nextAction = outcome === "no_conflict"
|
|
483
|
+
? undefined
|
|
484
|
+
: reviewNextAction(candidates, unmodeledClaims);
|
|
485
|
+
return {
|
|
486
|
+
analysis: {
|
|
487
|
+
...analysis,
|
|
488
|
+
outcome,
|
|
489
|
+
reasons,
|
|
490
|
+
reviewCandidates: candidates,
|
|
491
|
+
...(nextAction !== undefined ? { nextAction } : {}),
|
|
492
|
+
},
|
|
493
|
+
diagnostics,
|
|
494
|
+
};
|
|
495
|
+
}
|
|
392
496
|
function proposalFor(requirementId, match) {
|
|
393
497
|
const candidateId = text(match.entity.id);
|
|
394
498
|
const candidateType = text(match.entity.type);
|
|
@@ -847,15 +951,24 @@ export async function executeCompileIntent(args, context) {
|
|
|
847
951
|
// specified_by links) into the requirement step, which an upsert needs:
|
|
848
952
|
// a step without properties fails entity validation.
|
|
849
953
|
const stepsWithAcceptedProposals = applyAcceptedProposals(mergeSteps([...stepsWithInventory, ...drafts.steps]), proposals);
|
|
850
|
-
const
|
|
851
|
-
if (
|
|
852
|
-
diagnostics.push(
|
|
954
|
+
const checked = await contradictionAnalysis(prolog, requirementId, stepsWithAcceptedProposals, context.clock());
|
|
955
|
+
if (checked.outcome === "conflict")
|
|
956
|
+
diagnostics.push(checked.witnesses.some((witness) => witness.kind === "scenario_feasibility")
|
|
853
957
|
? "The plan leaves a success scenario infeasible or conflicts with a current requirement: set expects: rejection, correct the assumption, record an approved exception, or supersede the conflicting requirement before applying this plan."
|
|
854
958
|
: "Current requirement conflicts must be resolved with an explicit supersedes relationship before applying this plan.");
|
|
855
|
-
if (
|
|
856
|
-
diagnostics.push(
|
|
959
|
+
if (checked.outcome === "unresolved")
|
|
960
|
+
diagnostics.push(checked.witnesses.length > 0
|
|
857
961
|
? "Contradiction analysis is unresolved: the planned rules may overlap with current requirements and the checker can neither prove nor exclude a conflict."
|
|
858
962
|
: "Contradiction analysis could not run against the attached KB snapshot with this plan staged.");
|
|
963
|
+
const reviewed = await withConflictReview(prolog, checked, {
|
|
964
|
+
intent,
|
|
965
|
+
requirementId,
|
|
966
|
+
propositions,
|
|
967
|
+
matches: search.matches,
|
|
968
|
+
decisions: args.conflictReviews ?? [],
|
|
969
|
+
});
|
|
970
|
+
const contradictions = reviewed.analysis;
|
|
971
|
+
diagnostics.push(...reviewed.diagnostics);
|
|
859
972
|
if (args.mode === "create" &&
|
|
860
973
|
existing.length > 0 &&
|
|
861
974
|
diagnostics.some((entry) => entry.includes("already exists with different content")))
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { PrologPort } from "../../public/operations/runtime-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Relevance floor for a related requirement, below the kb_search default
|
|
4
|
+
* (0.18): a missed contradiction costs more than one extra comparison, and a
|
|
5
|
+
* requirement sharing half the intent's terms in other words ("label length
|
|
6
|
+
* is limited" against "label length must be at most 200") scores about 0.13.
|
|
7
|
+
* The candidate cap bounds the noise.
|
|
8
|
+
*/
|
|
9
|
+
export declare const REVIEW_CANDIDATE_MIN_SCORE = 0.1;
|
|
10
|
+
/** At most this many related requirements are put up for review. */
|
|
11
|
+
export declare const MAX_REVIEW_CANDIDATES = 5;
|
|
12
|
+
export type ConflictReviewVerdict = "conflict" | "no_conflict";
|
|
13
|
+
/** The agent's judgement of one review candidate, sent back on recompile. */
|
|
14
|
+
export type ConflictReviewDecision = Readonly<{
|
|
15
|
+
requirementId: string;
|
|
16
|
+
verdict: ConflictReviewVerdict;
|
|
17
|
+
note?: string;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* A current requirement the contradiction checker could not compare with the
|
|
21
|
+
* intent, which the agent must compare itself.
|
|
22
|
+
*/
|
|
23
|
+
export type ConflictReviewCandidate = Readonly<{
|
|
24
|
+
requirementId: string;
|
|
25
|
+
title: string;
|
|
26
|
+
/** The sentence of the requirement that shares the most terms with the intent. */
|
|
27
|
+
sentence: string;
|
|
28
|
+
/** The requirement's checked statement (semantic text, else title), bounded. */
|
|
29
|
+
statement: string;
|
|
30
|
+
/** Discovery score; 0 for a requirement only the agent's review named. */
|
|
31
|
+
score: number;
|
|
32
|
+
/** Whether the requirement has a logical representation of its own. */
|
|
33
|
+
modeled: boolean;
|
|
34
|
+
review: "pending" | ConflictReviewVerdict;
|
|
35
|
+
note?: string;
|
|
36
|
+
}>;
|
|
37
|
+
/** Why the contradiction check could not decide, with the ids involved. */
|
|
38
|
+
export type UncheckedReason = Readonly<{
|
|
39
|
+
reason: "unmodeled_target" | "unmodeled_related" | "analysis_unavailable";
|
|
40
|
+
/** Claim keys for unmodeled_target, requirement ids for unmodeled_related. */
|
|
41
|
+
ids: readonly string[];
|
|
42
|
+
}>;
|
|
43
|
+
/** One current requirement as review reads it. */
|
|
44
|
+
export type ReviewRequirement = Readonly<{
|
|
45
|
+
id: string;
|
|
46
|
+
title: string;
|
|
47
|
+
semanticText: string;
|
|
48
|
+
modeled: boolean;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* The current requirements among `ids`, each with whether it has a logical
|
|
52
|
+
* representation. Ids that are not current requirements (superseded,
|
|
53
|
+
* deprecated or unknown) are left out.
|
|
54
|
+
*/
|
|
55
|
+
export declare function loadReviewRequirements(prolog: Pick<PrologPort, "query">, ids: readonly string[]): Promise<Map<string, ReviewRequirement>>;
|
|
56
|
+
/**
|
|
57
|
+
* The sentence of a requirement most likely to bear on the intent: the one
|
|
58
|
+
* sharing the most intent terms, the first on a tie, the title when the
|
|
59
|
+
* requirement has no prose.
|
|
60
|
+
*/
|
|
61
|
+
export declare function reviewSentence(intent: string, requirement: Pick<ReviewRequirement, "title" | "semanticText">): string;
|
|
62
|
+
export declare function reviewCandidate(intent: string, requirement: ReviewRequirement, score: number, decision: ConflictReviewDecision | undefined): ConflictReviewCandidate;
|
|
63
|
+
/**
|
|
64
|
+
* What the agent does next while the contradiction outcome is not decided:
|
|
65
|
+
* resolve a conflict it found, compare the candidates still pending, or model
|
|
66
|
+
* the claims Kibi could not check.
|
|
67
|
+
*/
|
|
68
|
+
export declare function reviewNextAction(candidates: readonly ConflictReviewCandidate[], unmodeledClaims: readonly string[]): string | undefined;
|
|
69
|
+
//# sourceMappingURL=conflict-review.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conflict-review.d.ts","sourceRoot":"","sources":["../../../src/operations/planning/conflict-review.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAc3E;;;;;;GAMG;AAEH,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAE9C,oEAAoE;AAEpE,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAMvC,MAAM,MAAM,qBAAqB,GAAG,UAAU,GAAG,aAAa,CAAC;AAE/D,6EAA6E;AAE7E,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC;IAC5C,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,qBAAqB,CAAC;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC,CAAC;AAEH;;;GAGG;AAEH,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC;IAC7C,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,kFAAkF;IAClF,QAAQ,EAAE,MAAM,CAAC;IACjB,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,SAAS,GAAG,qBAAqB,CAAC;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC,CAAC;AAEH,2EAA2E;AAE3E,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC;IACrC,MAAM,EAAE,kBAAkB,GAAG,mBAAmB,GAAG,sBAAsB,CAAC;IAC1E,8EAA8E;IAC9E,GAAG,EAAE,SAAS,MAAM,EAAE,CAAC;CACxB,CAAC,CAAC;AAEH,kDAAkD;AAElD,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC,CAAC;AAMH;;;;GAIG;AAEH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,EACjC,GAAG,EAAE,SAAS,MAAM,EAAE,GACrB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CA+BzC;AAaD;;;;GAIG;AAEH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,IAAI,CAAC,iBAAiB,EAAE,OAAO,GAAG,cAAc,CAAC,GAC7D,MAAM,CAgBR;AASD,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,iBAAiB,EAC9B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,sBAAsB,GAAG,SAAS,GAC3C,uBAAuB,CAWzB;AAED;;;;GAIG;AAEH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,SAAS,uBAAuB,EAAE,EAC9C,eAAe,EAAE,SAAS,MAAM,EAAE,GACjC,MAAM,GAAG,SAAS,CAcpB"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { intentTokens } from "../../intent-search.js";
|
|
2
|
+
import { escapeAtomContent, parseListOfLists, parsePrologValue, } from "../../prolog/codec.js";
|
|
3
|
+
import { loadEntityRows } from "../../public/operations/discovery-entities.js";
|
|
4
|
+
/**
|
|
5
|
+
* Relationships that give a requirement a logical representation the
|
|
6
|
+
* contradiction checker can compare. A requirement with none of them is prose
|
|
7
|
+
* only: no witness can ever name it.
|
|
8
|
+
*/
|
|
9
|
+
const LOGICAL_RELATIONSHIPS = [
|
|
10
|
+
"constrains",
|
|
11
|
+
"requires_property",
|
|
12
|
+
"requires_predicate",
|
|
13
|
+
"requires_rule",
|
|
14
|
+
];
|
|
15
|
+
/**
|
|
16
|
+
* Relevance floor for a related requirement, below the kb_search default
|
|
17
|
+
* (0.18): a missed contradiction costs more than one extra comparison, and a
|
|
18
|
+
* requirement sharing half the intent's terms in other words ("label length
|
|
19
|
+
* is limited" against "label length must be at most 200") scores about 0.13.
|
|
20
|
+
* The candidate cap bounds the noise.
|
|
21
|
+
*/
|
|
22
|
+
// implements REQ-kibi-contradiction-review-candidates
|
|
23
|
+
export const REVIEW_CANDIDATE_MIN_SCORE = 0.1;
|
|
24
|
+
/** At most this many related requirements are put up for review. */
|
|
25
|
+
// implements REQ-kibi-contradiction-review-candidates
|
|
26
|
+
export const MAX_REVIEW_CANDIDATES = 5;
|
|
27
|
+
/** The longest requirement statement a review candidate quotes. */
|
|
28
|
+
const MAX_STATEMENT_LENGTH = 600;
|
|
29
|
+
function text(value) {
|
|
30
|
+
return typeof value === "string" ? value.trim() : "";
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The current requirements among `ids`, each with whether it has a logical
|
|
34
|
+
* representation. Ids that are not current requirements (superseded,
|
|
35
|
+
* deprecated or unknown) are left out.
|
|
36
|
+
*/
|
|
37
|
+
// implements REQ-kibi-contradiction-review-candidates
|
|
38
|
+
export async function loadReviewRequirements(prolog, ids) {
|
|
39
|
+
const unique = [...new Set(ids.filter(Boolean))];
|
|
40
|
+
const found = new Map();
|
|
41
|
+
if (unique.length === 0)
|
|
42
|
+
return found;
|
|
43
|
+
const idList = unique.map((id) => `'${escapeAtomContent(id)}'`).join(",");
|
|
44
|
+
const result = await prolog.query(`findall([R,M], (member(R, [${idList}]), kb:current_req(R), (once((member(T, [${LOGICAL_RELATIONSHIPS.join(",")}]), kb_relationship(T, R, _))) -> M = modeled ; M = unmodeled)), Rows)`);
|
|
45
|
+
if (!result.success)
|
|
46
|
+
return found;
|
|
47
|
+
const modeled = new Map(parseListOfLists(result.bindings.Rows ?? "[]").map(([id, flag]) => [
|
|
48
|
+
atom(id),
|
|
49
|
+
atom(flag) === "modeled",
|
|
50
|
+
]));
|
|
51
|
+
const rows = await loadEntityRows(prolog, [...modeled.keys()], ["id", "title", "semantic_text"]);
|
|
52
|
+
for (const row of rows) {
|
|
53
|
+
const id = text(row.id);
|
|
54
|
+
if (!modeled.has(id))
|
|
55
|
+
continue;
|
|
56
|
+
found.set(id, {
|
|
57
|
+
id,
|
|
58
|
+
title: text(row.title),
|
|
59
|
+
semanticText: text(row.semantic_text),
|
|
60
|
+
modeled: modeled.get(id) === true,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return found;
|
|
64
|
+
}
|
|
65
|
+
function atom(value) {
|
|
66
|
+
return String(parsePrologValue(value ?? "")).replace(/^['"]|['"]$/g, "");
|
|
67
|
+
}
|
|
68
|
+
function sentences(value) {
|
|
69
|
+
return value
|
|
70
|
+
.split(/(?<=[.!?])\s+|\n+/)
|
|
71
|
+
.map((sentence) => sentence.trim())
|
|
72
|
+
.filter(Boolean);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The sentence of a requirement most likely to bear on the intent: the one
|
|
76
|
+
* sharing the most intent terms, the first on a tie, the title when the
|
|
77
|
+
* requirement has no prose.
|
|
78
|
+
*/
|
|
79
|
+
// implements REQ-kibi-contradiction-review-candidates
|
|
80
|
+
export function reviewSentence(intent, requirement) {
|
|
81
|
+
const units = sentences(requirement.semanticText);
|
|
82
|
+
if (units.length === 0)
|
|
83
|
+
return requirement.title;
|
|
84
|
+
const wanted = new Set(intentTokens(intent));
|
|
85
|
+
let best = units[0] ?? requirement.title;
|
|
86
|
+
let bestShared = -1;
|
|
87
|
+
for (const unit of units) {
|
|
88
|
+
const shared = intentTokens(unit).filter((token) => wanted.has(token)).length;
|
|
89
|
+
if (shared > bestShared) {
|
|
90
|
+
best = unit;
|
|
91
|
+
bestShared = shared;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return best;
|
|
95
|
+
}
|
|
96
|
+
function bounded(value) {
|
|
97
|
+
return value.length > MAX_STATEMENT_LENGTH
|
|
98
|
+
? `${value.slice(0, MAX_STATEMENT_LENGTH - 1).trimEnd()}…`
|
|
99
|
+
: value;
|
|
100
|
+
}
|
|
101
|
+
// implements REQ-kibi-contradiction-review-candidates
|
|
102
|
+
export function reviewCandidate(intent, requirement, score, decision) {
|
|
103
|
+
return {
|
|
104
|
+
requirementId: requirement.id,
|
|
105
|
+
title: requirement.title,
|
|
106
|
+
sentence: reviewSentence(intent, requirement),
|
|
107
|
+
statement: bounded(requirement.semanticText || requirement.title),
|
|
108
|
+
score: Math.round(score * 1000) / 1000,
|
|
109
|
+
modeled: requirement.modeled,
|
|
110
|
+
review: decision?.verdict ?? "pending",
|
|
111
|
+
...(decision?.note ? { note: decision.note } : {}),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* What the agent does next while the contradiction outcome is not decided:
|
|
116
|
+
* resolve a conflict it found, compare the candidates still pending, or model
|
|
117
|
+
* the claims Kibi could not check.
|
|
118
|
+
*/
|
|
119
|
+
// implements REQ-kibi-contradiction-review-candidates
|
|
120
|
+
export function reviewNextAction(candidates, unmodeledClaims) {
|
|
121
|
+
const ids = (review) => candidates
|
|
122
|
+
.filter((candidate) => candidate.review === review)
|
|
123
|
+
.map((candidate) => candidate.requirementId);
|
|
124
|
+
const conflicts = ids("conflict");
|
|
125
|
+
if (conflicts.length > 0)
|
|
126
|
+
return `You judged that the intent contradicts ${conflicts.join(", ")}. Ask the human which rule holds, then supersede or change the conflicting requirement, or change the intent, and compile again. Record a conflict the human has not decided yet as a review:conflict observation fact.`;
|
|
127
|
+
const pending = ids("pending");
|
|
128
|
+
if (pending.length > 0)
|
|
129
|
+
return `Kibi could not compare this intent with ${pending.join(", ")} logically. Read each reviewCandidates entry (its statement and sentence) and decide whether the intent contradicts it, then call kb_compile_intent again with the same arguments plus conflictReviews: [{requirementId, verdict: "conflict" | "no_conflict", note}] for each.`;
|
|
130
|
+
if (unmodeledClaims.length > 0)
|
|
131
|
+
return `Kibi could not check claim ${unmodeledClaims.join(", ")} for contradictions because it has no logical model: model it with kb_model (mode requirement or predicates) and compile again. Until then no conflict is confirmed, only reviewed.`;
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
@@ -12,6 +12,14 @@ export type SemanticRelationship = Readonly<{
|
|
|
12
12
|
to?: unknown;
|
|
13
13
|
}>;
|
|
14
14
|
export declare function validateSemanticInventoryBoundary(payload: Payload, relationships: readonly SemanticRelationship[], receipt: SemanticAdvisorReceipt): SemanticInventoryBoundaryResult;
|
|
15
|
+
/**
|
|
16
|
+
* The inventory contract the advisor derives for this payload's prose, as
|
|
17
|
+
* the properties to resend: the version, source field and hash, one ledger
|
|
18
|
+
* entry per proposition and the assertive claim keys. An entry keeps the
|
|
19
|
+
* status the payload already gave the same claim key; otherwise it carries
|
|
20
|
+
* the advisor's status (an ambiguity or ontology gap stays explicit).
|
|
21
|
+
*/
|
|
22
|
+
export declare function semanticInventoryContract(payload: Payload, receipt: SemanticAdvisorReceipt): Record<string, unknown>;
|
|
15
23
|
export declare function assertSemanticInventoryBoundary(payload: Payload, relationships: readonly SemanticRelationship[], receipt: SemanticAdvisorReceipt): void;
|
|
16
24
|
/**
|
|
17
25
|
* The write-time claim_key check, run against planned writes only. Returns
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ingestion-boundary.d.ts","sourceRoot":"","sources":["../../../src/operations/semantic-advisor/ingestion-boundary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAG3E,OAAO,EACL,KAAK,OAAO,EAOb,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,sBAAsB,EAAuB,MAAM,YAAY,CAAC;AAgB9E,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC;IAC1C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,EAAE,CAAC,EAAE,OAAO,CAAC;CACd,CAAC,CAAC;AAuEH,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,SAAS,oBAAoB,EAAE,EAC9C,OAAO,EAAE,sBAAsB,GAC9B,+BAA+B,CA0IjC;AAED,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,SAAS,oBAAoB,EAAE,EAC9C,OAAO,EAAE,sBAAsB,GAC9B,IAAI,CAWN;
|
|
1
|
+
{"version":3,"file":"ingestion-boundary.d.ts","sourceRoot":"","sources":["../../../src/operations/semantic-advisor/ingestion-boundary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAG3E,OAAO,EACL,KAAK,OAAO,EAOb,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,sBAAsB,EAAuB,MAAM,YAAY,CAAC;AAgB9E,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC;IAC1C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,EAAE,CAAC,EAAE,OAAO,CAAC;CACd,CAAC,CAAC;AAuEH,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,SAAS,oBAAoB,EAAE,EAC9C,OAAO,EAAE,sBAAsB,GAC9B,+BAA+B,CA0IjC;AAED;;;;;;GAMG;AAEH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,sBAAsB,GAC9B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAuBzB;AAGD,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,SAAS,oBAAoB,EAAE,EAC9C,OAAO,EAAE,sBAAsB,GAC9B,IAAI,CAWN;AAwFD;;;;GAIG;AAEH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,SAAS,oBAAoB,EAAE,EAC9C,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,GAC9D,MAAM,GAAG,IAAI,CAUf;AAGD,wBAAsB,+BAA+B,CACnD,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,SAAS,oBAAoB,EAAE,EAC9C,MAAM,CAAC,EAAE,QAAQ,CAAC;IAChB,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CAClE,CAAC,GACD,OAAO,CAAC,IAAI,CAAC,CAiCf"}
|
|
@@ -157,10 +157,41 @@ export function validateSemanticInventoryBoundary(payload, relationships, receip
|
|
|
157
157
|
}
|
|
158
158
|
return { applicable, errors, sourceHash };
|
|
159
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* The inventory contract the advisor derives for this payload's prose, as
|
|
162
|
+
* the properties to resend: the version, source field and hash, one ledger
|
|
163
|
+
* entry per proposition and the assertive claim keys. An entry keeps the
|
|
164
|
+
* status the payload already gave the same claim key; otherwise it carries
|
|
165
|
+
* the advisor's status (an ambiguity or ontology gap stays explicit).
|
|
166
|
+
*/
|
|
167
|
+
// implements REQ-kb-upsert-ledger-contract-in-error
|
|
168
|
+
export function semanticInventoryContract(payload, receipt) {
|
|
169
|
+
const semanticSource = semanticSourceOf(payload);
|
|
170
|
+
const sent = new Map(inventoryOf(payload).map((entry) => [
|
|
171
|
+
stringValue(entry.claim_key),
|
|
172
|
+
stringValue(entry.status),
|
|
173
|
+
]));
|
|
174
|
+
return {
|
|
175
|
+
semantic_inventory_version: SEMANTIC_INVENTORY_VERSION,
|
|
176
|
+
semantic_source_field: semanticSource.field,
|
|
177
|
+
semantic_source_hash: semanticSourceHash(semanticSource.text),
|
|
178
|
+
semantic_inventory: receipt.propositions.map((proposition) => ({
|
|
179
|
+
claim_key: proposition.claim_key,
|
|
180
|
+
claim_text: proposition.claim_text,
|
|
181
|
+
role: proposition.role,
|
|
182
|
+
status: sent.get(proposition.claim_key) || proposition.status,
|
|
183
|
+
span: { start: proposition.span.start, end: proposition.span.end },
|
|
184
|
+
})),
|
|
185
|
+
logic_claims: receipt.propositions
|
|
186
|
+
.filter(propositionIsAssertive)
|
|
187
|
+
.map(({ claim_key }) => claim_key),
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
// implements REQ-kibi-proposition-complete-ingestion, REQ-kb-upsert-ledger-contract-in-error
|
|
160
191
|
export function assertSemanticInventoryBoundary(payload, relationships, receipt) {
|
|
161
192
|
const result = validateSemanticInventoryBoundary(payload, relationships, receipt);
|
|
162
193
|
if (result.errors.length > 0) {
|
|
163
|
-
throw new Error(`Proposition-complete ingestion failed: ${result.errors.join("; ")}.
|
|
194
|
+
throw new Error(`Proposition-complete ingestion failed: ${result.errors.join("; ")}. The contract kb_model mode analyze returns for this prose, to merge into properties and resend (a claim marked modeled needs one requires_property, requires_predicate or requires_rule link to a fact with its claim_key; otherwise keep the advisor's status): ${JSON.stringify(semanticInventoryContract(payload, receipt))}`);
|
|
164
195
|
}
|
|
165
196
|
}
|
|
166
197
|
function modeledClaimKeysOf(payload) {
|
|
@@ -182,10 +213,13 @@ function groundingTargets(payload, relationships) {
|
|
|
182
213
|
function plannedClaimKey(planned) {
|
|
183
214
|
return planned.type === "fact" ? stringValue(planned.claim_key) : "";
|
|
184
215
|
}
|
|
216
|
+
function missingGroundingFactError(target) {
|
|
217
|
+
return `Proposition-complete ingestion failed: logical grounding target '${target}' does not exist yet. Write the fact first: the kb_compile_intent plan has an earlier fact step for '${target}' that carries its claim_key; run that step before this one, or apply the whole plan with kb_apply_plan.`;
|
|
218
|
+
}
|
|
185
219
|
function groundingClaimKeyError(modeledClaimKeys, grounded) {
|
|
186
220
|
const missing = grounded.find(([, claimKey]) => !claimKey);
|
|
187
221
|
if (missing)
|
|
188
|
-
return `Proposition-complete ingestion failed: logical grounding target '${missing[0]}' must declare a claim_key.`;
|
|
222
|
+
return `Proposition-complete ingestion failed: logical grounding target '${missing[0]}' must declare a claim_key: it is a fact without the claim_key of the claim it grounds. Set the claim_key the kb_compile_intent plan's fact step gives it.`;
|
|
189
223
|
const groundedClaimKeys = grounded.map(([, claimKey]) => claimKey);
|
|
190
224
|
const duplicate = groundedClaimKeys.find((claimKey, index) => groundedClaimKeys.indexOf(claimKey) !== index);
|
|
191
225
|
if (duplicate)
|
|
@@ -256,6 +290,13 @@ export async function assertLogicalGroundingClaimKeys(prolog, payload, relations
|
|
|
256
290
|
claimKey = result.success
|
|
257
291
|
? stringValue(result.bindings.ClaimKey).replace(/^['"]|['"]$/g, "")
|
|
258
292
|
: "";
|
|
293
|
+
// implements REQ-kibi-symbol-link-guidance
|
|
294
|
+
// A target that is not stored yet is a skipped plan step, not a fact
|
|
295
|
+
// missing its key: say which step to run first.
|
|
296
|
+
if (!claimKey &&
|
|
297
|
+
!(await prolog.query(`once(kb_entity('${escapeAtom(target)}', _, _))`))
|
|
298
|
+
.success)
|
|
299
|
+
throw new Error(missingGroundingFactError(target));
|
|
259
300
|
}
|
|
260
301
|
grounded.push([target, claimKey]);
|
|
261
302
|
// The first target without a claim_key is reported; later reads are moot.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../../../src/public/impact/analyzer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../../../src/public/impact/analyzer.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAWpB,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,uBAAuB,CAAC,CA0LlC"}
|
|
@@ -7,11 +7,19 @@ import { extractSymbolsFromStagedFileAsync } from "../../traceability/symbol-ext
|
|
|
7
7
|
import { isTraceabilityRelationshipType } from "../symbol-granularity.js";
|
|
8
8
|
import { createSemanticReviewDiagnostics, createSymbolGranularityDiagnostics, } from "./diagnostics.js";
|
|
9
9
|
import { createImpactManifestLookup, readImpactManifestResults, } from "./manifest.js";
|
|
10
|
+
import { createRequirementStatementDiagnostics, readWorkspaceRequirement, workspaceFileChanged, } from "./requirement-statements.js";
|
|
10
11
|
import { normalizeSourceFile } from "./source-changes.js";
|
|
11
12
|
import { collectSourceChanges, uniqueSorted } from "./source-changes.js";
|
|
12
13
|
import { buildNextActions, collectLinkedEntities, formatExtractedSymbols, } from "./summaries.js";
|
|
13
14
|
import { createSymbolQualityDiagnostics } from "./symbol-quality.js";
|
|
14
15
|
import { createUnownedFileDiagnostics } from "./unowned-files.js";
|
|
16
|
+
/** The workspace-relative document a requirement was read from. */
|
|
17
|
+
function requirementSourcePath(requirement) {
|
|
18
|
+
const source = requirement.source;
|
|
19
|
+
return source && !source.includes("://")
|
|
20
|
+
? source.replace(/^\.\//, "")
|
|
21
|
+
: `.kb/requirements/${requirement.id}.md`;
|
|
22
|
+
}
|
|
15
23
|
export async function analyzeChangedFileImpact(options) {
|
|
16
24
|
const workspaceRoot = path.resolve(options.workspaceRoot);
|
|
17
25
|
const snapshot = options.staged
|
|
@@ -47,8 +55,11 @@ export async function analyzeChangedFileImpact(options) {
|
|
|
47
55
|
(filter.size === 0 || filter.has(file.path)))
|
|
48
56
|
.map((file) => file.path)
|
|
49
57
|
: sourceChanges.map((change) => change.file));
|
|
50
|
-
const
|
|
51
|
-
? readSnapshotKnowledge(snapshot.readGit, snapshot.headTree, snapshot.readBlobs)
|
|
58
|
+
const snapshotKnowledge = snapshot
|
|
59
|
+
? readSnapshotKnowledge(snapshot.readGit, snapshot.headTree, snapshot.readBlobs)
|
|
60
|
+
: undefined;
|
|
61
|
+
const manifestResults = snapshotKnowledge
|
|
62
|
+
? snapshotKnowledge.filter((result) => result.entity.type === "symbol")
|
|
52
63
|
: readImpactManifestResults(workspaceRoot);
|
|
53
64
|
const manifestLookup = createImpactManifestLookup(manifestResults);
|
|
54
65
|
const symbolsByFile = new Map();
|
|
@@ -92,6 +103,19 @@ export async function analyzeChangedFileImpact(options) {
|
|
|
92
103
|
requestedFiles: [...filter],
|
|
93
104
|
linkedSourceFiles,
|
|
94
105
|
}),
|
|
106
|
+
// What the changed code is meant to do, quoted, before the
|
|
107
|
+
// structural findings: "no violations" never compared it.
|
|
108
|
+
...createRequirementStatementDiagnostics({
|
|
109
|
+
workspaceRoot,
|
|
110
|
+
symbolsByFile,
|
|
111
|
+
readRequirement: (id) => snapshotKnowledge
|
|
112
|
+
? snapshotKnowledge.find((result) => result.entity.id === id)
|
|
113
|
+
?.entity
|
|
114
|
+
: readWorkspaceRequirement(workspaceRoot, id),
|
|
115
|
+
requirementChanged: (requirement) => snapshot
|
|
116
|
+
? snapshot.inventory.some((file) => file.path === requirementSourcePath(requirement))
|
|
117
|
+
: workspaceFileChanged(workspaceRoot, requirementSourcePath(requirement)),
|
|
118
|
+
}),
|
|
95
119
|
...createSymbolGranularityDiagnostics({
|
|
96
120
|
manifestResults: activeManifestResults,
|
|
97
121
|
symbolsByFile,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ExtractedEntity } from "../../extractors/markdown.js";
|
|
2
|
+
import type { KibiImpactDiagnostic } from "../../traceability/staged-diagnostics.js";
|
|
3
|
+
import type { ExtractedSymbol } from "../../traceability/symbol-extract.js";
|
|
4
|
+
export type RequirementStatementDiagnosticsOptions = {
|
|
5
|
+
readonly workspaceRoot: string;
|
|
6
|
+
readonly symbolsByFile: ReadonlyMap<string, readonly ExtractedSymbol[]>;
|
|
7
|
+
/** The requirement entity for an id, or undefined when it is unknown. */
|
|
8
|
+
readonly readRequirement: (id: string) => ExtractedEntity | undefined;
|
|
9
|
+
/** Whether the requirement's document changed in this change. */
|
|
10
|
+
readonly requirementChanged: (requirement: ExtractedEntity) => boolean;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* One `requirement_statement_unverified` warning per current requirement that
|
|
14
|
+
* a changed behavioral symbol implements, quoting the requirement's statement
|
|
15
|
+
* and firmness. A requirement whose own document changed in the same change
|
|
16
|
+
* is left to the firmness and supersede checks.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createRequirementStatementDiagnostics(options: RequirementStatementDiagnosticsOptions): KibiImpactDiagnostic[];
|
|
19
|
+
/**
|
|
20
|
+
* Whether Git reports any change (staged, unstaged or untracked) to a
|
|
21
|
+
* workspace file against HEAD. Outside a repository nothing counts as changed.
|
|
22
|
+
*/
|
|
23
|
+
export declare function workspaceFileChanged(workspaceRoot: string, relativePath: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Read a requirement from its canonical document in the working tree
|
|
26
|
+
* (`.kb/requirements/<id>.md`).
|
|
27
|
+
*/
|
|
28
|
+
export declare function readWorkspaceRequirement(workspaceRoot: string, id: string): ExtractedEntity | undefined;
|
|
29
|
+
//# sourceMappingURL=requirement-statements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requirement-statements.d.ts","sourceRoot":"","sources":["../../../src/public/impact/requirement-statements.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,eAAe,EAErB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAgB5E,MAAM,MAAM,sCAAsC,GAAG;IACnD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAC,CAAC;IACxE,yEAAyE;IACzE,QAAQ,CAAC,eAAe,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,eAAe,GAAG,SAAS,CAAC;IACtE,iEAAiE;IACjE,QAAQ,CAAC,kBAAkB,EAAE,CAAC,WAAW,EAAE,eAAe,KAAK,OAAO,CAAC;CACxE,CAAC;AAiBF;;;;;GAKG;AACH,wBAAgB,qCAAqC,CACnD,OAAO,EAAE,sCAAsC,GAC9C,oBAAoB,EAAE,CAsExB;AAGD;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,GACnB,OAAO,CAeT;AAGD;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,aAAa,EAAE,MAAM,EACrB,EAAE,EAAE,MAAM,GACT,eAAe,GAAG,SAAS,CAS7B"}
|